aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CREDITS4
-rw-r--r--Documentation/SubmitChecklist6
-rw-r--r--Documentation/feature-removal-schedule.txt19
-rw-r--r--Documentation/gpio.txt4
-rw-r--r--Documentation/kref.txt2
-rw-r--r--Documentation/mips/pci/pci.README54
-rw-r--r--Documentation/sound/alsa/ALSA-Configuration.txt21
-rw-r--r--Documentation/sound/alsa/Bt87x.txt4
-rw-r--r--Documentation/video4linux/CARDLIST.saa71345
-rw-r--r--Documentation/video4linux/sn9c102.txt18
-rw-r--r--MAINTAINERS7
-rw-r--r--arch/frv/kernel/gdb-stub.c12
-rw-r--r--arch/h8300/kernel/syscalls.S78
-rw-r--r--arch/i386/Kconfig8
-rw-r--r--arch/i386/kernel/process.c1
-rw-r--r--arch/i386/kernel/smp.c2
-rw-r--r--arch/i386/kernel/syscall_table.S3
-rw-r--r--arch/i386/kernel/verify_cpu.S4
-rw-r--r--arch/i386/mm/init.c7
-rw-r--r--arch/i386/mm/pgtable.c26
-rw-r--r--arch/ia64/Kconfig4
-rw-r--r--arch/ia64/hp/common/hwsw_iommu.c2
-rw-r--r--arch/ia64/ia32/audit.c5
-rw-r--r--arch/ia64/kernel/audit.c17
-rw-r--r--arch/ia64/kernel/entry.S2
-rw-r--r--arch/ia64/kernel/err_inject.c2
-rw-r--r--arch/ia64/kernel/irq.c11
-rw-r--r--arch/ia64/kernel/kprobes.c12
-rw-r--r--arch/ia64/kernel/machvec.c2
-rw-r--r--arch/ia64/kernel/mca.c2
-rw-r--r--arch/ia64/mm/contig.c2
-rw-r--r--arch/ia64/mm/discontig.c2
-rw-r--r--arch/ia64/mm/init.c51
-rw-r--r--arch/ia64/sn/kernel/io_common.c2
-rw-r--r--arch/ia64/sn/kernel/xpc_partition.c2
-rw-r--r--arch/ia64/sn/kernel/xpnet.c4
-rw-r--r--arch/m32r/Kconfig4
-rw-r--r--arch/m32r/mm/mmu.S22
-rw-r--r--arch/mips/Kconfig212
-rw-r--r--arch/mips/Makefile42
-rw-r--r--arch/mips/au1000/Kconfig142
-rw-r--r--arch/mips/basler/excite/excite_device.c16
-rw-r--r--arch/mips/cobalt/Makefile2
-rw-r--r--arch/mips/cobalt/rtc.c63
-rw-r--r--arch/mips/cobalt/serial.c85
-rw-r--r--arch/mips/cobalt/setup.c31
-rw-r--r--arch/mips/configs/cobalt_defconfig49
-rw-r--r--arch/mips/configs/db1000_defconfig1
-rw-r--r--arch/mips/configs/db1100_defconfig1
-rw-r--r--arch/mips/configs/db1200_defconfig1
-rw-r--r--arch/mips/configs/db1500_defconfig1
-rw-r--r--arch/mips/configs/db1550_defconfig1
-rw-r--r--arch/mips/configs/jaguar-atx_defconfig897
-rw-r--r--arch/mips/configs/jmr3927_defconfig1
-rw-r--r--arch/mips/configs/pb1100_defconfig1
-rw-r--r--arch/mips/configs/pb1500_defconfig1
-rw-r--r--arch/mips/configs/pb1550_defconfig1
-rw-r--r--arch/mips/configs/rbhma4200_defconfig (renamed from arch/mips/configs/ocelot_g_defconfig)379
-rw-r--r--arch/mips/configs/rbhma4500_defconfig1
-rw-r--r--arch/mips/configs/tb0219_defconfig (renamed from arch/mips/configs/tb0229_defconfig)24
-rw-r--r--arch/mips/kernel/early_printk.c11
-rw-r--r--arch/mips/kernel/irq-msc01.c10
-rw-r--r--arch/mips/kernel/irq.c4
-rw-r--r--arch/mips/kernel/time.c2
-rw-r--r--arch/mips/kernel/traps.c8
-rw-r--r--arch/mips/lib/Makefile2
-rw-r--r--arch/mips/lib/ucmpdi2.c19
-rw-r--r--arch/mips/mips-boards/malta/malta_int.c21
-rw-r--r--arch/mips/mm/highmem.c2
-rw-r--r--arch/mips/mm/init.c3
-rw-r--r--arch/mips/mm/tlbex.c36
-rw-r--r--arch/mips/momentum/Kconfig6
-rw-r--r--arch/mips/momentum/jaguar_atx/Makefile12
-rw-r--r--arch/mips/momentum/jaguar_atx/dbg_io.c125
-rw-r--r--arch/mips/momentum/jaguar_atx/irq.c94
-rw-r--r--arch/mips/momentum/jaguar_atx/ja-console.c101
-rw-r--r--arch/mips/momentum/jaguar_atx/jaguar_atx_fpga.h54
-rw-r--r--arch/mips/momentum/jaguar_atx/platform.c208
-rw-r--r--arch/mips/momentum/jaguar_atx/prom.c210
-rw-r--r--arch/mips/momentum/jaguar_atx/reset.c56
-rw-r--r--arch/mips/momentum/jaguar_atx/setup.c475
-rw-r--r--arch/mips/momentum/ocelot_g/Makefile6
-rw-r--r--arch/mips/momentum/ocelot_g/dbg_io.c121
-rw-r--r--arch/mips/momentum/ocelot_g/gt-irq.c212
-rw-r--r--arch/mips/momentum/ocelot_g/irq.c101
-rw-r--r--arch/mips/momentum/ocelot_g/ocelot_pld.h30
-rw-r--r--arch/mips/momentum/ocelot_g/prom.c84
-rw-r--r--arch/mips/momentum/ocelot_g/reset.c47
-rw-r--r--arch/mips/momentum/ocelot_g/setup.c267
-rw-r--r--arch/mips/pci/Makefile2
-rw-r--r--arch/mips/pci/fixup-cobalt.c25
-rw-r--r--arch/mips/pci/fixup-jaguar.c43
-rw-r--r--arch/mips/pci/fixup-ocelot-g.c37
-rw-r--r--arch/mips/pci/pci-ocelot-g.c97
-rw-r--r--arch/mips/sgi-ip22/Makefile2
-rw-r--r--arch/mips/sgi-ip22/ip22-platform.c177
-rw-r--r--arch/powerpc/Kconfig5
-rw-r--r--arch/powerpc/Makefile2
-rw-r--r--arch/powerpc/boot/Makefile30
-rw-r--r--arch/powerpc/boot/cuboot-83xx.c2
-rw-r--r--arch/powerpc/boot/cuboot-85xx.c2
-rw-r--r--arch/powerpc/boot/dts/prpmc2800.dts315
-rw-r--r--arch/powerpc/boot/mpsc.c170
-rw-r--r--arch/powerpc/boot/mv64x60.c581
-rw-r--r--arch/powerpc/boot/mv64x60.h70
-rw-r--r--arch/powerpc/boot/mv64x60_i2c.c206
-rw-r--r--arch/powerpc/boot/ops.h1
-rw-r--r--arch/powerpc/boot/prpmc2800.c577
-rw-r--r--arch/powerpc/boot/serial.c2
-rw-r--r--arch/powerpc/configs/prpmc2800_defconfig1442
-rw-r--r--arch/powerpc/configs/ps3_defconfig167
-rw-r--r--arch/powerpc/kernel/audit.c17
-rw-r--r--arch/powerpc/kernel/compat_audit.c5
-rw-r--r--arch/powerpc/kernel/irq.c2
-rw-r--r--arch/powerpc/kernel/prom_parse.c2
-rw-r--r--arch/powerpc/kernel/setup-common.c41
-rw-r--r--arch/powerpc/kernel/swsusp.c4
-rw-r--r--arch/powerpc/kernel/time.c19
-rw-r--r--arch/powerpc/mm/hash_native_64.c4
-rw-r--r--arch/powerpc/platforms/cell/pervasive.c6
-rw-r--r--arch/powerpc/platforms/embedded6xx/Kconfig13
-rw-r--r--arch/powerpc/platforms/embedded6xx/Makefile1
-rw-r--r--arch/powerpc/platforms/embedded6xx/prpmc2800.c171
-rw-r--r--arch/powerpc/platforms/pasemi/idle.c1
-rw-r--r--arch/powerpc/platforms/ps3/setup.c2
-rw-r--r--arch/powerpc/platforms/ps3/smp.c6
-rw-r--r--arch/powerpc/platforms/ps3/system-bus.c6
-rw-r--r--arch/powerpc/sysdev/Makefile2
-rw-r--r--arch/powerpc/sysdev/mv64x60.h11
-rw-r--r--arch/powerpc/sysdev/mv64x60_dev.c422
-rw-r--r--arch/powerpc/sysdev/mv64x60_pci.c172
-rw-r--r--arch/powerpc/sysdev/mv64x60_pic.c305
-rw-r--r--arch/ppc/4xx_io/serial_sicc.c10
-rw-r--r--arch/ppc/8xx_io/commproc.c2
-rw-r--r--arch/ppc/8xx_io/fec.c2
-rw-r--r--arch/ppc/boot/lib/vreset.c2
-rw-r--r--arch/ppc/boot/simple/m8xx_tty.c2
-rw-r--r--arch/ppc/boot/simple/misc-embedded.c2
-rw-r--r--arch/ppc/boot/simple/mpc52xx_tty.c2
-rw-r--r--arch/ppc/boot/simple/mv64x60_tty.c2
-rw-r--r--arch/ppc/boot/simple/rw4/stb.h2
-rw-r--r--arch/ppc/kernel/traps.c4
-rw-r--r--arch/ppc/mm/init.c2
-rw-r--r--arch/ppc/platforms/4xx/bubinga.c2
-rw-r--r--arch/ppc/platforms/4xx/ep405.c2
-rw-r--r--arch/ppc/platforms/4xx/ibmnp405h.h2
-rw-r--r--arch/ppc/platforms/4xx/sycamore.c2
-rw-r--r--arch/ppc/platforms/4xx/walnut.c2
-rw-r--r--arch/ppc/platforms/ev64360.c2
-rw-r--r--arch/ppc/platforms/hdpu.c2
-rw-r--r--arch/ppc/platforms/katana.c2
-rw-r--r--arch/ppc/platforms/mbx.h2
-rw-r--r--arch/ppc/platforms/mvme5100.h2
-rw-r--r--arch/ppc/platforms/pplus.h2
-rw-r--r--arch/ppc/platforms/prep_pci.c22
-rw-r--r--arch/ppc/platforms/prep_setup.c6
-rw-r--r--arch/ppc/platforms/prpmc750.h2
-rw-r--r--arch/ppc/platforms/radstone_ppc7d.c2
-rw-r--r--arch/ppc/platforms/sandpoint.c8
-rw-r--r--arch/ppc/syslib/harrier.c2
-rw-r--r--arch/ppc/syslib/hawk_common.c4
-rw-r--r--arch/ppc/syslib/m82xx_pci.c2
-rw-r--r--arch/ppc/syslib/mpc10x_common.c4
-rw-r--r--arch/ppc/syslib/mpc52xx_setup.c2
-rw-r--r--arch/ppc/syslib/mpc8xx_devices.c2
-rw-r--r--arch/ppc/syslib/mv64x60.c10
-rw-r--r--arch/ppc/syslib/ocp.c2
-rw-r--r--arch/ppc/syslib/ppc403_pic.c2
-rw-r--r--arch/ppc/syslib/ppc405_pci.c2
-rw-r--r--arch/ppc/syslib/ppc4xx_dma.c2
-rw-r--r--arch/ppc/syslib/ppc85xx_rio.c4
-rw-r--r--arch/ppc/syslib/xilinx_pic.c2
-rw-r--r--arch/s390/kernel/audit.c17
-rw-r--r--arch/s390/kernel/compat_audit.c5
-rw-r--r--arch/sparc/kernel/auxio.c2
-rw-r--r--arch/sparc/kernel/ioport.c2
-rw-r--r--arch/sparc/kernel/irq.c8
-rw-r--r--arch/sparc/kernel/pcic.c4
-rw-r--r--arch/sparc/kernel/process.c2
-rw-r--r--arch/sparc/kernel/sun4d_irq.c2
-rw-r--r--arch/sparc/kernel/sun4m_irq.c2
-rw-r--r--arch/sparc/kernel/systbls.S5
-rw-r--r--arch/sparc/prom/printf.c2
-rw-r--r--arch/sparc64/Kconfig3
-rw-r--r--arch/sparc64/defconfig124
-rw-r--r--arch/sparc64/kernel/audit.c17
-rw-r--r--arch/sparc64/kernel/compat_audit.c5
-rw-r--r--arch/sparc64/kernel/devices.c2
-rw-r--r--arch/sparc64/kernel/of_device.c4
-rw-r--r--arch/sparc64/kernel/pci.c4
-rw-r--r--arch/sparc64/kernel/pci_fire.c2
-rw-r--r--arch/sparc64/kernel/pci_iommu.c2
-rw-r--r--arch/sparc64/kernel/pci_sun4v.c2
-rw-r--r--arch/sparc64/kernel/process.c2
-rw-r--r--arch/sparc64/kernel/prom.c2
-rw-r--r--arch/sparc64/kernel/systbls.S7
-rw-r--r--arch/sparc64/kernel/time.c230
-rw-r--r--arch/sparc64/mm/init.c2
-rw-r--r--arch/um/Kconfig3
-rw-r--r--arch/um/defconfig2
-rw-r--r--arch/um/include/common-offsets.h2
-rw-r--r--arch/um/include/kern_util.h3
-rw-r--r--arch/um/include/os.h1
-rw-r--r--arch/um/kernel/dyn.lds.S2
-rw-r--r--arch/um/kernel/init_task.c30
-rw-r--r--arch/um/kernel/irq.c115
-rw-r--r--arch/um/kernel/skas/process.c4
-rw-r--r--arch/um/kernel/tt/exec_kern.c2
-rw-r--r--arch/um/kernel/tt/process_kern.c2
-rw-r--r--arch/um/kernel/um_arch.c2
-rw-r--r--arch/um/kernel/uml.lds.S2
-rw-r--r--arch/um/os-Linux/signal.c50
-rw-r--r--arch/um/os-Linux/skas/process.c13
-rw-r--r--arch/um/os-Linux/sys-i386/signal.c8
-rw-r--r--arch/um/os-Linux/sys-x86_64/signal.c6
-rw-r--r--arch/um/os-Linux/util.c23
-rw-r--r--arch/x86_64/ia32/audit.c5
-rw-r--r--arch/x86_64/ia32/ia32entry.S5
-rw-r--r--arch/x86_64/kernel/aperture.c2
-rw-r--r--arch/x86_64/kernel/audit.c17
-rw-r--r--arch/x86_64/kernel/bugs.c2
-rw-r--r--arch/x86_64/kernel/head64.c7
-rw-r--r--arch/x86_64/kernel/pci-gart.c2
-rw-r--r--arch/x86_64/kernel/setup.c4
-rw-r--r--block/ll_rw_blk.c53
-rw-r--r--drivers/ata/Kconfig36
-rw-r--r--drivers/ata/Makefile2
-rw-r--r--drivers/ata/ahci.c5
-rw-r--r--drivers/ata/ata_generic.c12
-rw-r--r--drivers/ata/ata_piix.c8
-rw-r--r--drivers/ata/libata-acpi.c192
-rw-r--r--drivers/ata/libata-core.c72
-rw-r--r--drivers/ata/libata-eh.c246
-rw-r--r--drivers/ata/libata-scsi.c157
-rw-r--r--drivers/ata/libata-sff.c162
-rw-r--r--drivers/ata/libata.h7
-rw-r--r--drivers/ata/pata_ali.c36
-rw-r--r--drivers/ata/pata_amd.c13
-rw-r--r--drivers/ata/pata_artop.c25
-rw-r--r--drivers/ata/pata_atiixp.c10
-rw-r--r--drivers/ata/pata_cmd640.c11
-rw-r--r--drivers/ata/pata_cmd64x.c17
-rw-r--r--drivers/ata/pata_cs5520.c4
-rw-r--r--drivers/ata/pata_cs5530.c14
-rw-r--r--drivers/ata/pata_cs5535.c10
-rw-r--r--drivers/ata/pata_cypress.c10
-rw-r--r--drivers/ata/pata_efar.c10
-rw-r--r--drivers/ata/pata_hpt366.c17
-rw-r--r--drivers/ata/pata_hpt37x.c33
-rw-r--r--drivers/ata/pata_hpt3x2n.c13
-rw-r--r--drivers/ata/pata_hpt3x3.c10
-rw-r--r--drivers/ata/pata_it8213.c12
-rw-r--r--drivers/ata/pata_it821x.c16
-rw-r--r--drivers/ata/pata_ixp4xx_cf.c2
-rw-r--r--drivers/ata/pata_jmicron.c10
-rw-r--r--drivers/ata/pata_marvell.c15
-rw-r--r--drivers/ata/pata_mpc52xx.c4
-rw-r--r--drivers/ata/pata_mpiix.c4
-rw-r--r--drivers/ata/pata_netcell.c10
-rw-r--r--drivers/ata/pata_ns87410.c10
-rw-r--r--drivers/ata/pata_oldpiix.c10
-rw-r--r--drivers/ata/pata_opti.c10
-rw-r--r--drivers/ata/pata_optidma.c16
-rw-r--r--drivers/ata/pata_pcmcia.c1
-rw-r--r--drivers/ata/pata_pdc202xx_old.c12
-rw-r--r--drivers/ata/pata_platform.c4
-rw-r--r--drivers/ata/pata_radisys.c10
-rw-r--r--drivers/ata/pata_rz1000.c18
-rw-r--r--drivers/ata/pata_sc1200.c12
-rw-r--r--drivers/ata/pata_scc.c4
-rw-r--r--drivers/ata/pata_serverworks.c19
-rw-r--r--drivers/ata/pata_sil680.c14
-rw-r--r--drivers/ata/pata_sis.c33
-rw-r--r--drivers/ata/pata_sl82c105.c17
-rw-r--r--drivers/ata/pata_triflex.c10
-rw-r--r--drivers/ata/pata_via.c36
-rw-r--r--drivers/ata/sata_inic162x.c4
-rw-r--r--drivers/ata/sata_nv.c16
-rw-r--r--drivers/ata/sata_sil.c4
-rw-r--r--drivers/ata/sata_sil24.c4
-rw-r--r--drivers/ata/sata_sis.c6
-rw-r--r--drivers/ata/sata_uli.c22
-rw-r--r--drivers/ata/sata_via.c6
-rw-r--r--drivers/ata/sis.h2
-rw-r--r--drivers/atm/Kconfig32
-rw-r--r--drivers/block/loop.c52
-rw-r--r--drivers/bluetooth/hci_ldisc.c10
-rw-r--r--drivers/bluetooth/hci_uart.h5
-rw-r--r--drivers/char/agp/amd64-agp.c2
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c8
-rw-r--r--drivers/char/n_tty.c29
-rw-r--r--drivers/char/rio/riocmd.c2
-rw-r--r--drivers/char/rocket.c3
-rw-r--r--drivers/char/rocket_int.h2
-rw-r--r--drivers/char/snsc_event.c2
-rw-r--r--drivers/char/synclink_gt.c107
-rw-r--r--drivers/char/tpm/tpm_atmel.h3
-rw-r--r--drivers/char/tty_io.c77
-rw-r--r--drivers/char/watchdog/iTCO_wdt.c2
-rw-r--r--drivers/hid/hid-input.c101
-rw-r--r--drivers/hid/usbhid/Kconfig4
-rw-r--r--drivers/hid/usbhid/hid-core.c41
-rw-r--r--drivers/hid/usbhid/hid-lgff.c2
-rw-r--r--drivers/hid/usbhid/hid-plff.c2
-rw-r--r--drivers/hid/usbhid/hid-quirks.c7
-rw-r--r--drivers/hid/usbhid/hid-tmff.c2
-rw-r--r--drivers/hid/usbhid/hid-zpff.c2
-rw-r--r--drivers/hid/usbhid/hiddev.c14
-rw-r--r--drivers/hid/usbhid/usbkbd.c21
-rw-r--r--drivers/hid/usbhid/usbmouse.c9
-rw-r--r--drivers/input/evdev.c2
-rw-r--r--drivers/md/md.c2
-rw-r--r--drivers/media/Kconfig9
-rw-r--r--drivers/media/Makefile2
-rw-r--r--drivers/media/common/saa7146_core.c54
-rw-r--r--drivers/media/common/saa7146_fops.c1
-rw-r--r--drivers/media/dvb/Kconfig24
-rw-r--r--drivers/media/dvb/dvb-core/Kconfig14
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h5
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb.h2
-rw-r--r--drivers/media/dvb/dvb-usb/m920x.c565
-rw-r--r--drivers/media/dvb/dvb-usb/m920x.h13
-rw-r--r--drivers/media/dvb/dvb-usb/vp702x-fe.c14
-rw-r--r--drivers/media/dvb/pluto2/pluto2.c8
-rw-r--r--drivers/media/dvb/ttpci/av7110.c9
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c2
-rw-r--r--drivers/media/dvb/ttpci/budget-core.c37
-rw-r--r--drivers/media/radio/Kconfig11
-rw-r--r--drivers/media/radio/dsbr100.c345
-rw-r--r--drivers/media/radio/radio-cadet.c297
-rw-r--r--drivers/media/radio/radio-maestro.c3
-rw-r--r--drivers/media/radio/radio-zoltrix.c1
-rw-r--r--drivers/media/video/Kconfig45
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c4
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c5
-rw-r--r--drivers/media/video/cx88/cx88-video.c1
-rw-r--r--drivers/media/video/cx88/cx88-vp3054-i2c.c7
-rw-r--r--drivers/media/video/cx88/cx88-vp3054-i2c.h1
-rw-r--r--drivers/media/video/em28xx/Kconfig2
-rw-r--r--drivers/media/video/et61x251/Kconfig2
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-fileops.c2
-rw-r--r--drivers/media/video/pvrusb2/Kconfig2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-encoder.c13
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c10
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-core.c23
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-sysfs.c14
-rw-r--r--drivers/media/video/pwc/Kconfig2
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c123
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c17
-rw-r--r--drivers/media/video/saa7134/saa7134.h3
-rw-r--r--drivers/media/video/sn9c102/Kconfig2
-rw-r--r--drivers/media/video/sn9c102/sn9c102.h2
-rw-r--r--drivers/media/video/sn9c102/sn9c102_core.c91
-rw-r--r--drivers/media/video/sn9c102/sn9c102_devtable.h4
-rw-r--r--drivers/media/video/sn9c102/sn9c102_hv7131d.c6
-rw-r--r--drivers/media/video/sn9c102/sn9c102_hv7131r.c8
-rw-r--r--drivers/media/video/sn9c102/sn9c102_mi0343.c51
-rw-r--r--drivers/media/video/sn9c102/sn9c102_mi0360.c220
-rw-r--r--drivers/media/video/sn9c102/sn9c102_ov7630.c25
-rw-r--r--drivers/media/video/sn9c102/sn9c102_ov7660.c63
-rw-r--r--drivers/media/video/sn9c102/sn9c102_pas106b.c14
-rw-r--r--drivers/media/video/sn9c102/sn9c102_pas202bcb.c48
-rw-r--r--drivers/media/video/sn9c102/sn9c102_sensor.h33
-rw-r--r--drivers/media/video/sn9c102/sn9c102_tas5110c1b.c2
-rw-r--r--drivers/media/video/sn9c102/sn9c102_tas5110d.c2
-rw-r--r--drivers/media/video/sn9c102/sn9c102_tas5130d1b.c2
-rw-r--r--drivers/media/video/usbvideo/Kconfig8
-rw-r--r--drivers/media/video/usbvision/Kconfig2
-rw-r--r--drivers/media/video/v4l1-compat.c62
-rw-r--r--drivers/media/video/video-buf.c4
-rw-r--r--drivers/media/video/videodev.c50
-rw-r--r--drivers/media/video/zc0301/Kconfig2
-rw-r--r--drivers/net/Kconfig18
-rw-r--r--drivers/net/irda/Kconfig14
-rw-r--r--drivers/net/irda/Makefile1
-rw-r--r--drivers/net/irda/kingsun-sir.c657
-rw-r--r--drivers/net/mlx4/eq.c2
-rw-r--r--drivers/net/netxen/netxen_nic_main.c2
-rw-r--r--drivers/net/pcmcia/Kconfig23
-rw-r--r--drivers/net/phy/Kconfig22
-rw-r--r--drivers/net/phy/davicom.c34
-rw-r--r--drivers/net/s2io.c368
-rw-r--r--drivers/net/s2io.h32
-rw-r--r--drivers/net/sgiseeq.c83
-rw-r--r--drivers/net/skge.c9
-rw-r--r--drivers/net/sky2.c53
-rw-r--r--drivers/net/spider_net.c8
-rw-r--r--drivers/net/wan/Kconfig34
-rw-r--r--drivers/net/wireless/libertas/Makefile9
-rw-r--r--drivers/net/wireless/libertas/README516
-rw-r--r--drivers/net/wireless/libertas/assoc.c41
-rw-r--r--drivers/net/wireless/libertas/cmd.c23
-rw-r--r--drivers/net/wireless/libertas/cmdresp.c4
-rw-r--r--drivers/net/wireless/libertas/debugfs.c31
-rw-r--r--drivers/net/wireless/libertas/defs.h52
-rw-r--r--drivers/net/wireless/libertas/dev.h14
-rw-r--r--drivers/net/wireless/libertas/fw.c9
-rw-r--r--drivers/net/wireless/libertas/if_usb.c5
-rw-r--r--drivers/net/wireless/libertas/if_usb.h2
-rw-r--r--drivers/net/wireless/libertas/ioctl.c1529
-rw-r--r--drivers/net/wireless/libertas/join.c194
-rw-r--r--drivers/net/wireless/libertas/join.h7
-rw-r--r--drivers/net/wireless/libertas/main.c7
-rw-r--r--drivers/net/wireless/libertas/rx.c4
-rw-r--r--drivers/net/wireless/libertas/scan.c203
-rw-r--r--drivers/net/wireless/libertas/scan.h22
-rw-r--r--drivers/net/wireless/libertas/tx.c2
-rw-r--r--drivers/net/wireless/libertas/version.h7
-rw-r--r--drivers/net/wireless/libertas/wext.c448
-rw-r--r--drivers/net/wireless/libertas/wext.h85
-rw-r--r--drivers/pci/hotplug/sgi_hotplug.c36
-rw-r--r--drivers/pci/msi.c6
-rw-r--r--drivers/pci/quirks.c1
-rw-r--r--drivers/rtc/Kconfig4
-rw-r--r--drivers/rtc/rtc-rs5c313.c28
-rw-r--r--drivers/sbus/char/envctrl.c1
-rw-r--r--drivers/scsi/sgiwd93.c264
-rw-r--r--drivers/spi/Kconfig7
-rw-r--r--drivers/spi/Makefile1
-rw-r--r--drivers/spi/mpc52xx_psc_spi.c654
-rw-r--r--drivers/video/Kconfig34
-rw-r--r--drivers/video/Makefile1
-rw-r--r--drivers/video/atmel_lcdfb.c752
-rw-r--r--drivers/video/console/Kconfig7
-rw-r--r--drivers/video/nvidia/nv_hw.c4
-rw-r--r--drivers/video/nvidia/nvidia.c1
-rw-r--r--drivers/video/pm2fb.c38
-rw-r--r--drivers/video/pm3fb.c3983
-rw-r--r--drivers/video/riva/rivafb-i2c.c2
-rw-r--r--fs/Makefile4
-rw-r--r--fs/afs/afs.h23
-rw-r--r--fs/afs/afs_fs.h3
-rw-r--r--fs/afs/dir.c18
-rw-r--r--fs/afs/file.c2
-rw-r--r--fs/afs/fsclient.c298
-rw-r--r--fs/afs/inode.c10
-rw-r--r--fs/afs/internal.h6
-rw-r--r--fs/afs/super.c44
-rw-r--r--fs/afs/vnode.c85
-rw-r--r--fs/afs/write.c5
-rw-r--r--fs/aio.c28
-rw-r--r--fs/anon_inodes.c200
-rw-r--r--fs/autofs/autofs_i.h4
-rw-r--r--fs/autofs/inode.c47
-rw-r--r--fs/autofs/root.c83
-rw-r--r--fs/autofs4/inode.c16
-rw-r--r--fs/autofs4/root.c18
-rw-r--r--fs/compat.c49
-rw-r--r--fs/eventfd.c228
-rw-r--r--fs/eventpoll.c1178
-rw-r--r--fs/exec.c15
-rw-r--r--fs/mpage.c174
-rw-r--r--fs/namei.c2
-rw-r--r--fs/ntfs/aops.c36
-rw-r--r--fs/ntfs/file.c59
-rw-r--r--fs/partitions/Kconfig2
-rw-r--r--fs/partitions/efi.c12
-rw-r--r--fs/signalfd.c349
-rw-r--r--fs/timerfd.c227
-rw-r--r--fs/xattr.c2
-rw-r--r--include/asm-alpha/poll.h26
-rw-r--r--include/asm-arm/poll.h28
-rw-r--r--include/asm-arm26/poll.h22
-rw-r--r--include/asm-avr32/poll.h28
-rw-r--r--include/asm-cris/poll.h27
-rw-r--r--include/asm-frv/poll.h18
-rw-r--r--include/asm-generic/Kbuild1
-rw-r--r--include/asm-generic/audit_signal.h3
-rw-r--r--include/asm-generic/poll.h37
-rw-r--r--include/asm-h8300/poll.h18
-rw-r--r--include/asm-h8300/unistd.h66
-rw-r--r--include/asm-i386/alternative.h6
-rw-r--r--include/asm-i386/pgalloc.h2
-rw-r--r--include/asm-i386/pgtable.h5
-rw-r--r--include/asm-i386/poll.h28
-rw-r--r--include/asm-i386/tsc.h6
-rw-r--r--include/asm-i386/unistd.h5
-rw-r--r--include/asm-ia64/irq.h6
-rw-r--r--include/asm-ia64/kprobes.h4
-rw-r--r--include/asm-ia64/pgalloc.h82
-rw-r--r--include/asm-ia64/poll.h33
-rw-r--r--include/asm-ia64/unistd.h4
-rw-r--r--include/asm-m32r/pgtable-2level.h4
-rw-r--r--include/asm-m32r/pgtable.h2
-rw-r--r--include/asm-m32r/poll.h33
-rw-r--r--include/asm-m32r/system.h11
-rw-r--r--include/asm-m68k/atarihw.h2
-rw-r--r--include/asm-m68k/atariints.h2
-rw-r--r--include/asm-m68k/poll.h17
-rw-r--r--include/asm-mips/atomic.h2
-rw-r--r--include/asm-mips/bootinfo.h4
-rw-r--r--include/asm-mips/fpu.h23
-rw-r--r--include/asm-mips/hazards.h32
-rw-r--r--include/asm-mips/highmem.h42
-rw-r--r--include/asm-mips/mach-cobalt/cobalt.h2
-rw-r--r--include/asm-mips/mach-ja/cpu-feature-overrides.h45
-rw-r--r--include/asm-mips/mach-ja/spaces.h20
-rw-r--r--include/asm-mips/mips-boards/malta.h4
-rw-r--r--include/asm-mips/msc01_ic.h5
-rw-r--r--include/asm-mips/page.h4
-rw-r--r--include/asm-mips/poll.h21
-rw-r--r--include/asm-mips/serial.h41
-rw-r--r--include/asm-mips/sgi/seeq.h21
-rw-r--r--include/asm-mips/sgi/wd.h20
-rw-r--r--include/asm-mips/system.h5
-rw-r--r--include/asm-parisc/poll.h28
-rw-r--r--include/asm-powerpc/hw_irq.h11
-rw-r--r--include/asm-powerpc/poll.h25
-rw-r--r--include/asm-s390/poll.h36
-rw-r--r--include/asm-sh/poll.h28
-rw-r--r--include/asm-sh64/poll.h33
-rw-r--r--include/asm-sparc/poll.h14
-rw-r--r--include/asm-sparc/unistd.h5
-rw-r--r--include/asm-sparc64/poll.h14
-rw-r--r--include/asm-sparc64/unistd.h5
-rw-r--r--include/asm-um/thread_info.h2
-rw-r--r--include/asm-v850/poll.h17
-rw-r--r--include/asm-x86_64/alternative.h6
-rw-r--r--include/asm-x86_64/page.h9
-rw-r--r--include/asm-x86_64/poll.h28
-rw-r--r--include/asm-x86_64/unistd.h9
-rw-r--r--include/asm-xtensa/poll.h20
-rw-r--r--include/linux/Kbuild3
-rw-r--r--include/linux/aio.h6
-rw-r--r--include/linux/aio_abi.h18
-rw-r--r--include/linux/anon_inodes.h16
-rw-r--r--include/linux/audit.h21
-rw-r--r--include/linux/compat.h5
-rw-r--r--include/linux/eventfd.h29
-rw-r--r--include/linux/genhd.h6
-rw-r--r--include/linux/hid.h1
-rw-r--r--include/linux/i2c-id.h1
-rw-r--r--include/linux/init_task.h32
-rw-r--r--include/linux/interrupt.h10
-rw-r--r--include/linux/kernel.h15
-rw-r--r--include/linux/libata.h31
-rw-r--r--include/linux/list.h8
-rw-r--r--include/linux/magic.h1
-rw-r--r--include/linux/module.h2
-rw-r--r--include/linux/mpage.h1
-rw-r--r--include/linux/netdevice.h2
-rw-r--r--include/linux/netfilter/x_tables.h8
-rw-r--r--include/linux/netfilter_arp/arp_tables.h41
-rw-r--r--include/linux/netfilter_ipv4/ip_tables.h22
-rw-r--r--include/linux/netfilter_ipv6/ip6_tables.h22
-rw-r--r--include/linux/pci_ids.h1
-rw-r--r--include/linux/pid.h5
-rw-r--r--include/linux/sched.h6
-rw-r--r--include/linux/signal.h1
-rw-r--r--include/linux/signalfd.h97
-rw-r--r--include/linux/synclink.h24
-rw-r--r--include/linux/syscalls.h4
-rw-r--r--include/linux/task_io_accounting_ops.h28
-rw-r--r--include/linux/timerfd.h17
-rw-r--r--include/linux/tty_driver.h9
-rw-r--r--include/linux/tty_ldisc.h7
-rw-r--r--include/linux/writeback.h10
-rw-r--r--include/media/saa7146.h2
-rw-r--r--include/media/saa7146_vv.h2
-rw-r--r--include/net/netfilter/nf_conntrack.h7
-rw-r--r--include/net/netfilter/nf_conntrack_l3proto.h3
-rw-r--r--include/net/netfilter/nf_nat_rule.h11
-rw-r--r--include/net/udp.h9
-rw-r--r--include/net/udplite.h2
-rw-r--r--include/sound/ak4114.h4
-rw-r--r--include/sound/mpu401.h1
-rw-r--r--include/sound/pcm.h7
-rw-r--r--include/sound/version.h4
-rw-r--r--include/video/atmel_lcdc.h196
-rw-r--r--include/video/pm3fb.h110
-rw-r--r--init/Kconfig40
-rw-r--r--init/main.c1
-rw-r--r--ipc/mqueue.c4
-rw-r--r--kernel/audit.h13
-rw-r--r--kernel/auditfilter.c48
-rw-r--r--kernel/auditsc.c311
-rw-r--r--kernel/compat.c8
-rw-r--r--kernel/exit.c22
-rw-r--r--kernel/fork.c24
-rw-r--r--kernel/irq/proc.c7
-rw-r--r--kernel/pid.c11
-rw-r--r--kernel/ptrace.c3
-rw-r--r--kernel/signal.c32
-rw-r--r--kernel/stop_machine.c4
-rw-r--r--kernel/sys.c14
-rw-r--r--kernel/sys_ni.c7
-rw-r--r--lib/Kconfig.debug1
-rw-r--r--lib/Makefile2
-rw-r--r--lib/audit.c11
-rw-r--r--lib/hexdump.c104
-rw-r--r--mm/page-writeback.c59
-rw-r--r--mm/thrash.c5
-rw-r--r--mm/vmstat.c2
-rw-r--r--net/bluetooth/hidp/core.c14
-rw-r--r--net/core/link_watch.c166
-rw-r--r--net/ipv4/netfilter/arptable_filter.c140
-rw-r--r--net/ipv4/netfilter/iptable_filter.c73
-rw-r--r--net/ipv4/netfilter/iptable_mangle.c99
-rw-r--r--net/ipv4/netfilter/iptable_raw.c79
-rw-r--r--net/ipv4/netfilter/nf_nat_rule.c86
-rw-r--r--net/ipv4/netfilter/nf_nat_standalone.c11
-rw-r--r--net/ipv4/udp.c85
-rw-r--r--net/ipv4/udp_impl.h6
-rw-r--r--net/ipv4/udplite.c7
-rw-r--r--net/ipv6/addrconf.c4
-rw-r--r--net/ipv6/exthdrs.c16
-rw-r--r--net/ipv6/ip6_output.c13
-rw-r--r--net/ipv6/netfilter/ip6table_filter.c70
-rw-r--r--net/ipv6/netfilter/ip6table_mangle.c96
-rw-r--r--net/ipv6/netfilter/ip6table_raw.c52
-rw-r--r--net/ipv6/udp.c21
-rw-r--r--net/ipv6/udp_impl.h2
-rw-r--r--net/ipv6/udplite.c2
-rw-r--r--net/mac80211/ieee80211_sta.c2
-rw-r--r--net/netfilter/nf_conntrack_core.c14
-rw-r--r--net/netfilter/nf_conntrack_netlink.c40
-rw-r--r--net/netfilter/xt_conntrack.c54
-rw-r--r--net/sched/sch_generic.c41
-rw-r--r--net/sched/sch_teql.c5
-rw-r--r--net/sctp/socket.c19
-rw-r--r--net/sctp/ulpevent.c11
-rw-r--r--sound/aoa/codecs/snd-aoa-codec-onyx.c4
-rw-r--r--sound/aoa/codecs/snd-aoa-codec-tas.c4
-rw-r--r--sound/aoa/soundbus/core.c2
-rw-r--r--sound/aoa/soundbus/i2sbus/i2sbus-core.c5
-rw-r--r--sound/aoa/soundbus/soundbus.h2
-rw-r--r--sound/core/pcm_native.c30
-rw-r--r--sound/core/rtctimer.c3
-rw-r--r--sound/drivers/mpu401/mpu401.c12
-rw-r--r--sound/drivers/mpu401/mpu401_uart.c18
-rw-r--r--sound/drivers/mts64.c4
-rw-r--r--sound/drivers/portman2x4.c4
-rw-r--r--sound/drivers/vx/vx_hwdep.c14
-rw-r--r--sound/i2c/other/ak4114.c114
-rw-r--r--sound/isa/Kconfig22
-rw-r--r--sound/isa/ad1816a/ad1816a.c8
-rw-r--r--sound/isa/ad1848/ad1848.c167
-rw-r--r--sound/isa/adlib.c122
-rw-r--r--sound/isa/cmi8330.c115
-rw-r--r--sound/isa/cs423x/cs4231.c213
-rw-r--r--sound/isa/cs423x/cs4231_lib.c4
-rw-r--r--sound/isa/cs423x/cs4236.c131
-rw-r--r--sound/isa/es1688/es1688.c251
-rw-r--r--sound/isa/es18xx.c110
-rw-r--r--sound/isa/gus/gusclassic.c292
-rw-r--r--sound/isa/gus/gusextreme.c379
-rw-r--r--sound/isa/gus/gusmax.c71
-rw-r--r--sound/isa/gus/interwave.c101
-rw-r--r--sound/isa/opl3sa2.c127
-rw-r--r--sound/isa/opti9xx/miro.c80
-rw-r--r--sound/isa/opti9xx/opti92x-ad1848.c108
-rw-r--r--sound/isa/sb/sb16.c113
-rw-r--r--sound/isa/sb/sb16_csp.c30
-rw-r--r--sound/isa/sb/sb8.c90
-rw-r--r--sound/isa/sgalaxy.c107
-rw-r--r--sound/isa/sscape.c120
-rw-r--r--sound/isa/wavefront/wavefront.c113
-rw-r--r--sound/isa/wavefront/wavefront_fx.c23
-rw-r--r--sound/pci/Kconfig33
-rw-r--r--sound/pci/ac97/Makefile2
-rw-r--r--sound/pci/ac97/ac97_codec.c43
-rw-r--r--sound/pci/ac97/ac97_local.h55
-rw-r--r--sound/pci/ac97/ac97_patch.c194
-rw-r--r--sound/pci/ac97/ac97_patch.h110
-rw-r--r--sound/pci/ac97/ac97_pcm.c1
-rw-r--r--sound/pci/ali5451/ali5451.c869
-rw-r--r--sound/pci/au88x0/au88x0_sb.h40
-rw-r--r--sound/pci/azt3328.c34
-rw-r--r--sound/pci/azt3328.h4
-rw-r--r--sound/pci/bt87x.c4
-rw-r--r--sound/pci/ca0106/ca0106_main.c4
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c2
-rw-r--r--sound/pci/cs46xx/imgs/cwcemb80.h1607
-rw-r--r--sound/pci/echoaudio/darla20.c2
-rw-r--r--sound/pci/echoaudio/darla24.c2
-rw-r--r--sound/pci/echoaudio/echo3g.c4
-rw-r--r--sound/pci/echoaudio/echoaudio.c4
-rw-r--r--sound/pci/echoaudio/echoaudio_3g.c4
-rw-r--r--sound/pci/echoaudio/gina20.c2
-rw-r--r--sound/pci/echoaudio/gina24.c6
-rw-r--r--sound/pci/echoaudio/indigo.c3
-rw-r--r--sound/pci/echoaudio/indigodj.c3
-rw-r--r--sound/pci/echoaudio/indigoio.c3
-rw-r--r--sound/pci/echoaudio/layla20.c3
-rw-r--r--sound/pci/echoaudio/layla24.c6
-rw-r--r--sound/pci/echoaudio/mia.c3
-rw-r--r--sound/pci/echoaudio/mona.c9
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c24
-rw-r--r--sound/pci/emu10k1/p16v.c4
-rw-r--r--sound/pci/ens1370.c8
-rw-r--r--sound/pci/es1968.c11
-rw-r--r--sound/pci/hda/Makefile9
-rw-r--r--sound/pci/hda/hda_codec.c729
-rw-r--r--sound/pci/hda/hda_codec.h2
-rw-r--r--sound/pci/hda/hda_generic.c2
-rw-r--r--sound/pci/hda/hda_intel.c31
-rw-r--r--sound/pci/hda/hda_local.h12
-rw-r--r--sound/pci/hda/patch_analog.c85
-rw-r--r--sound/pci/hda/patch_atihdmi.c17
-rw-r--r--sound/pci/hda/patch_cmedia.c14
-rw-r--r--sound/pci/hda/patch_conexant.c310
-rw-r--r--sound/pci/hda/patch_realtek.c2269
-rw-r--r--sound/pci/hda/patch_sigmatel.c178
-rw-r--r--sound/pci/hda/patch_via.c14
-rw-r--r--sound/pci/ice1712/amp.c2
-rw-r--r--sound/pci/ice1712/amp.h2
-rw-r--r--sound/pci/ice1712/aureon.c18
-rw-r--r--sound/pci/ice1712/aureon.h2
-rw-r--r--sound/pci/ice1712/delta.c34
-rw-r--r--sound/pci/ice1712/delta.h2
-rw-r--r--sound/pci/ice1712/ews.c24
-rw-r--r--sound/pci/ice1712/ews.h2
-rw-r--r--sound/pci/ice1712/hoontech.c6
-rw-r--r--sound/pci/ice1712/hoontech.h2
-rw-r--r--sound/pci/ice1712/ice1712.c50
-rw-r--r--sound/pci/ice1712/ice1712.h3
-rw-r--r--sound/pci/ice1712/ice1724.c47
-rw-r--r--sound/pci/ice1712/juli.c24
-rw-r--r--sound/pci/ice1712/juli.h2
-rw-r--r--sound/pci/ice1712/phase.c14
-rw-r--r--sound/pci/ice1712/phase.h2
-rw-r--r--sound/pci/ice1712/pontis.c6
-rw-r--r--sound/pci/ice1712/pontis.h2
-rw-r--r--sound/pci/ice1712/prodigy192.c360
-rw-r--r--sound/pci/ice1712/prodigy192.h10
-rw-r--r--sound/pci/ice1712/revo.c26
-rw-r--r--sound/pci/ice1712/revo.h2
-rw-r--r--sound/pci/ice1712/vt1720_mobo.c6
-rw-r--r--sound/pci/ice1712/vt1720_mobo.h2
-rw-r--r--sound/pci/ice1712/wtm.c2
-rw-r--r--sound/pci/intel8x0.c20
-rw-r--r--sound/pci/korg1212/korg1212.c25
-rw-r--r--sound/pci/maestro3.c38
-rw-r--r--sound/pci/mixart/mixart_hwdep.c3
-rw-r--r--sound/pci/pcxhr/pcxhr.c28
-rw-r--r--sound/pci/pcxhr/pcxhr_hwdep.c6
-rw-r--r--sound/pci/riptide/riptide.c1
-rw-r--r--sound/pci/rme32.c7
-rw-r--r--sound/pci/rme9652/hdsp.c99
-rw-r--r--sound/pci/rme9652/hdspm.c185
-rw-r--r--sound/pci/rme9652/rme9652.c8
-rw-r--r--sound/pci/trident/trident_main.c4
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c55
-rw-r--r--sound/pcmcia/vx/vxpocket.c2
-rw-r--r--sound/soc/Kconfig18
-rw-r--r--sound/soc/Makefile2
-rw-r--r--sound/soc/at91/Kconfig10
-rw-r--r--sound/soc/at91/Makefile4
-rw-r--r--sound/soc/at91/at91-ssc.c (renamed from sound/soc/at91/at91-i2s.c)259
-rw-r--r--sound/soc/at91/at91-ssc.h (renamed from sound/soc/at91/at91-i2s.h)14
-rw-r--r--sound/soc/at91/eti_b1_wm8731.c8
-rw-r--r--sound/soc/codecs/Kconfig4
-rw-r--r--sound/soc/codecs/Makefile2
-rw-r--r--sound/soc/codecs/ac97.c1
-rw-r--r--sound/soc/codecs/ac97.h1
-rw-r--r--sound/soc/codecs/wm8750.c2
-rw-r--r--sound/soc/codecs/wm8753.c1811
-rw-r--r--sound/soc/codecs/wm8753.h126
-rw-r--r--sound/soc/codecs/wm9712.c7
-rw-r--r--sound/soc/pxa/Kconfig4
-rw-r--r--sound/soc/s3c24xx/Kconfig10
-rw-r--r--sound/soc/s3c24xx/Makefile6
-rw-r--r--sound/soc/s3c24xx/s3c24xx-i2s.c441
-rw-r--r--sound/soc/s3c24xx/s3c24xx-i2s.h37
-rw-r--r--sound/soc/s3c24xx/s3c24xx-pcm.c468
-rw-r--r--sound/soc/s3c24xx/s3c24xx-pcm.h31
-rw-r--r--sound/soc/soc-dapm.c6
-rw-r--r--sound/sparc/cs4231.c4
-rw-r--r--sound/usb/Kconfig28
-rw-r--r--sound/usb/Makefile2
-rw-r--r--sound/usb/caiaq/Makefile3
-rw-r--r--sound/usb/caiaq/caiaq-audio.c707
-rw-r--r--sound/usb/caiaq/caiaq-audio.h7
-rw-r--r--sound/usb/caiaq/caiaq-device.c436
-rw-r--r--sound/usb/caiaq/caiaq-device.h116
-rw-r--r--sound/usb/caiaq/caiaq-input.c246
-rw-r--r--sound/usb/caiaq/caiaq-input.h8
-rw-r--r--sound/usb/caiaq/caiaq-midi.c177
-rw-r--r--sound/usb/caiaq/caiaq-midi.h8
-rw-r--r--sound/usb/usbaudio.c3
-rw-r--r--sound/usb/usbmidi.c58
-rw-r--r--sound/usb/usbquirks.h23
783 files changed, 27532 insertions, 21432 deletions
diff --git a/CREDITS b/CREDITS
index 6829e91a88d4..273d72b610c3 100644
--- a/CREDITS
+++ b/CREDITS
@@ -2299,8 +2299,8 @@ E: acme@redhat.com
2299W: http://oops.ghostprotocols.net:81/blog/ 2299W: http://oops.ghostprotocols.net:81/blog/
2300P: 1024D/9224DF01 D5DF E3BB E3C8 BCBB F8AD 841A B6AB 4681 9224 DF01 2300P: 1024D/9224DF01 D5DF E3BB E3C8 BCBB F8AD 841A B6AB 4681 9224 DF01
2301D: IPX, LLC, DCCP, cyc2x, wl3501_cs, net/ hacks 2301D: IPX, LLC, DCCP, cyc2x, wl3501_cs, net/ hacks
2302S: R. Brasílio Itiberê, 4270/1010 - Água Verde 2302S: R. Brasílio Itiberê, 4270/1010 - Ãgua Verde
2303S: 80240-060 - Curitiba - Paraná 2303S: 80240-060 - Curitiba - Paraná
2304S: Brazil 2304S: Brazil
2305 2305
2306N: Karsten Merker 2306N: Karsten Merker
diff --git a/Documentation/SubmitChecklist b/Documentation/SubmitChecklist
index 6491b2c45dd4..3af3e65cf43b 100644
--- a/Documentation/SubmitChecklist
+++ b/Documentation/SubmitChecklist
@@ -73,9 +73,9 @@ kernel patches.
73 If the new code is substantial, addition of subsystem-specific fault 73 If the new code is substantial, addition of subsystem-specific fault
74 injection might be appropriate. 74 injection might be appropriate.
75 75
7622: Newly-added code has been compiled with `gcc -W'. This will generate 7622: Newly-added code has been compiled with `gcc -W' (use "make
77 lots of noise, but is good for finding bugs like "warning: comparison 77 EXTRA_CFLAGS=-W"). This will generate lots of noise, but is good for
78 between signed and unsigned". 78 finding bugs like "warning: comparison between signed and unsigned".
79 79
8023: Tested after it has been merged into the -mm patchset to make sure 8023: Tested after it has been merged into the -mm patchset to make sure
81 that it still works with all of the other queued patches and various 81 that it still works with all of the other queued patches and various
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index c6322c760348..498ff31f3aa1 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -328,3 +328,22 @@ Who: Adrian Bunk <bunk@stusta.de>
328 328
329--------------------------- 329---------------------------
330 330
331What: libata.spindown_compat module parameter
332When: Dec 2008
333Why: halt(8) synchronizes caches for and spins down libata disks
334 because libata didn't use to spin down disk on system halt
335 (only synchronized caches).
336 Spin down on system halt is now implemented and can be tested
337 using sysfs node /sys/class/scsi_disk/h:c:i:l/manage_start_stop.
338 Because issuing spin down command to an already spun down disk
339 makes some disks spin up just to spin down again, the old
340 behavior needs to be maintained till userspace tool is updated
341 to check the sysfs node and not to spin down disks with the
342 node set to one.
343 This module parameter is to give userspace tool the time to
344 get updated and should be removed after userspace is
345 reasonably updated.
346Who: Tejun Heo <htejun@gmail.com>
347
348---------------------------
349
diff --git a/Documentation/gpio.txt b/Documentation/gpio.txt
index f8528db967fa..e8be0abb346c 100644
--- a/Documentation/gpio.txt
+++ b/Documentation/gpio.txt
@@ -66,7 +66,9 @@ registers; another might implement it by delegating through abstractions
66used for several very different kinds of GPIO controller. 66used for several very different kinds of GPIO controller.
67 67
68That said, if the convention is supported on their platform, drivers should 68That said, if the convention is supported on their platform, drivers should
69use it when possible: 69use it when possible. Platforms should declare GENERIC_GPIO support in
70Kconfig (boolean true), which multi-platform drivers can depend on when
71using the include file:
70 72
71 #include <asm/gpio.h> 73 #include <asm/gpio.h>
72 74
diff --git a/Documentation/kref.txt b/Documentation/kref.txt
index 42fe28445916..f38b59d00c63 100644
--- a/Documentation/kref.txt
+++ b/Documentation/kref.txt
@@ -67,7 +67,7 @@ void more_data_handling(void *cb_data)
67 . 67 .
68 . do stuff with data here 68 . do stuff with data here
69 . 69 .
70 kref_put(data, data_release); 70 kref_put(&data->refcount, data_release);
71} 71}
72 72
73int my_data_handler(void) 73int my_data_handler(void)
diff --git a/Documentation/mips/pci/pci.README b/Documentation/mips/pci/pci.README
deleted file mode 100644
index 8697ee41372d..000000000000
--- a/Documentation/mips/pci/pci.README
+++ /dev/null
@@ -1,54 +0,0 @@
1
2Pete Popov, ppopov@pacbell.net
307/11/2001
4
5This README briefly explains how to use the pci and pci_auto
6code in arch/mips/kernel. The code was ported from PowerPC and
7modified slightly. It has been tested pretty well on PPC on some
8rather complex systems with multiple bridges and devices behind
9each bridge. However, at the time this README was written, the
10mips port was tested only on boards with a single pci bus and
11no P2P bridges. It's very possible that on boards with P2P
12bridges some modifications have to be made. The code will
13evolve, no doubt, but currently every single mips board
14is doing its own pcibios thing and it has become a big
15mess. This generic pci code is meant to clean up the mips
16pci mess and make it easier to add pci support to new boards.
17
18inside the define for your board in arch/mips/config.in.
19For example, the Galileo EV96100 board looks like this:
20
21if [ "$CONFIG_MIPS_EV96100" = "y" ]; then
22 define_bool CONFIG_PCI y
23 define_bool CONFIG_MIPS_GT96100 y
24 define_bool CONFIG_NEW_PCI y
25 define_bool CONFIG_SWAP_IO_SPACE y
26fi
27
28
29Next, if you want to use the arch/mips/kernel/pci code, which has the
30pcibios_init() function, add
31
32define_bool CONFIG_NEW_PCI y
33
34inside the define for your board. Again, the EV96100 example above
35show NEW_PCI turned on.
36
37
38Now you need to add your files to hook in your pci configuration
39cycles. Usually you'll need only a couple of files named something
40like pci_fixups.c and pci_ops.c. You can copy the templates
41provided and fill in the code.
42
43The file pci_ops.c should contain the pci configuration cycles routines.
44It also has the mips_pci_channels[] array which contains the descriptors
45of each pci controller.
46
47The file pci_fixups.c contains a few routines to do interrupt fixups,
48resources fixups, and, if needed, pci bios fixups.
49
50Usually you'll put your pci_fixups.c file in your board specific directory,
51since the functions in that file are board specific. The functions in
52pci_ops.c, on the other hand, are usually pci controller specific so that
53file could be shared among a few different boards using the same
54pci controller.
diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt
index 73e9a174b642..57b878cc393c 100644
--- a/Documentation/sound/alsa/ALSA-Configuration.txt
+++ b/Documentation/sound/alsa/ALSA-Configuration.txt
@@ -821,6 +821,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
821 6stack-dig 6-jack digital with SPDIF I/O 821 6stack-dig 6-jack digital with SPDIF I/O
822 arima Arima W820Di1 822 arima Arima W820Di1
823 macpro MacPro support 823 macpro MacPro support
824 w2jc ASUS W2JC
824 auto auto-config reading BIOS (default) 825 auto auto-config reading BIOS (default)
825 826
826 ALC883/888 827 ALC883/888
@@ -852,6 +853,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
852 3stack-dig 3-jack with SPDIF OUT 853 3stack-dig 3-jack with SPDIF OUT
853 6stack-dig 6-jack with SPDIF OUT 854 6stack-dig 6-jack with SPDIF OUT
854 3stack-660 3-jack (for ALC660VD) 855 3stack-660 3-jack (for ALC660VD)
856 lenovo Lenovo 3000 C200
855 auto auto-config reading BIOS (default) 857 auto auto-config reading BIOS (default)
856 858
857 CMI9880 859 CMI9880
@@ -909,6 +911,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
909 macbook Intel Mac Book 911 macbook Intel Mac Book
910 macbook-pro-v1 Intel Mac Book Pro 1st generation 912 macbook-pro-v1 Intel Mac Book Pro 1st generation
911 macbook-pro Intel Mac Book Pro 2nd generation 913 macbook-pro Intel Mac Book Pro 2nd generation
914 imac-intel Intel iMac
912 915
913 STAC9202/9250/9251 916 STAC9202/9250/9251
914 ref Reference board, base config 917 ref Reference board, base config
@@ -924,6 +927,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
924 vaio Setup for VAIO FE550G/SZ110 927 vaio Setup for VAIO FE550G/SZ110
925 vaio-ar Setup for VAIO AR 928 vaio-ar Setup for VAIO AR
926 929
930 The model name "genric" is treated as a special case. When this
931 model is given, the driver uses the generic codec parser without
932 "codec-patch". It's sometimes good for testing and debugging.
933
927 If the default configuration doesn't work and one of the above 934 If the default configuration doesn't work and one of the above
928 matches with your device, report it together with the PCI 935 matches with your device, report it together with the PCI
929 subsystem ID (output of "lspci -nv") to ALSA BTS or alsa-devel 936 subsystem ID (output of "lspci -nv") to ALSA BTS or alsa-devel
@@ -1278,6 +1285,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1278 port - port number or -1 (disable) 1285 port - port number or -1 (disable)
1279 irq - IRQ number or -1 (disable) 1286 irq - IRQ number or -1 (disable)
1280 pnp - PnP detection - 0 = disable, 1 = enable (default) 1287 pnp - PnP detection - 0 = disable, 1 = enable (default)
1288 uart_enter - Issue UART_ENTER command at open - bool, default = on
1281 1289
1282 This module supports multiple devices and PnP. 1290 This module supports multiple devices and PnP.
1283 1291
@@ -1692,6 +1700,17 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1692 1700
1693 This module supports multiple devices, autoprobe and hotplugging. 1701 This module supports multiple devices, autoprobe and hotplugging.
1694 1702
1703 Module snd-usb-caiaq
1704 --------------------
1705
1706 Module for caiaq UB audio interfaces,
1707 * Native Instruments RigKontrol2
1708 * Native Instruments Kore Controller
1709 * Native Instruments Audio Kontrol 1
1710 * Native Instruments Audio 8 DJ
1711
1712 This module supports multiple devices, autoprobe and hotplugging.
1713
1695 Module snd-usb-usx2y 1714 Module snd-usb-usx2y
1696 -------------------- 1715 --------------------
1697 1716
@@ -2046,4 +2065,4 @@ Links and Addresses
2046 https://bugtrack.alsa-project.org/bugs/ 2065 https://bugtrack.alsa-project.org/bugs/
2047 2066
2048 ALSA Developers ML 2067 ALSA Developers ML
2049 mailto:alsa-devel@lists.sourceforge.net 2068 mailto:alsa-devel@alsa-project.org
diff --git a/Documentation/sound/alsa/Bt87x.txt b/Documentation/sound/alsa/Bt87x.txt
index 11edb2fd2a5a..f158cde8b065 100644
--- a/Documentation/sound/alsa/Bt87x.txt
+++ b/Documentation/sound/alsa/Bt87x.txt
@@ -36,8 +36,8 @@ recorded data is not right, try to specify the digital_rate option with
36other values than the default 32000 (often it's 44100 or 64000). 36other values than the default 32000 (often it's 44100 or 64000).
37 37
38If you have an unknown card, please mail the ID and board name to 38If you have an unknown card, please mail the ID and board name to
39<alsa-devel@lists.sf.net>, regardless of whether audio capture works or 39<alsa-devel@alsa-project.org>, regardless of whether audio capture works
40not, so that future versions of this driver know about your card. 40or not, so that future versions of this driver know about your card.
41 41
42 42
43Audio modes 43Audio modes
diff --git a/Documentation/video4linux/CARDLIST.saa7134 b/Documentation/video4linux/CARDLIST.saa7134
index d7bb2e2e4d9b..712e8c8333cc 100644
--- a/Documentation/video4linux/CARDLIST.saa7134
+++ b/Documentation/video4linux/CARDLIST.saa7134
@@ -52,7 +52,7 @@
52 51 -> ProVideo PV952 [1540:9524] 52 51 -> ProVideo PV952 [1540:9524]
53 52 -> AverMedia AverTV/305 [1461:2108] 53 52 -> AverMedia AverTV/305 [1461:2108]
54 53 -> ASUS TV-FM 7135 [1043:4845] 54 53 -> ASUS TV-FM 7135 [1043:4845]
55 54 -> LifeView FlyTV Platinum FM / Gold [5168:0214,1489:0214,5168:0304] 55 54 -> LifeView FlyTV Platinum FM / Gold [5168:0214,5168:5214,1489:0214,5168:0304]
56 55 -> LifeView FlyDVB-T DUO / MSI TV@nywhere Duo [5168:0306,4E42:0306] 56 55 -> LifeView FlyDVB-T DUO / MSI TV@nywhere Duo [5168:0306,4E42:0306]
57 56 -> Avermedia AVerTV 307 [1461:a70a] 57 56 -> Avermedia AVerTV 307 [1461:a70a]
58 57 -> Avermedia AVerTV GO 007 FM [1461:f31f] 58 57 -> Avermedia AVerTV GO 007 FM [1461:f31f]
@@ -111,3 +111,6 @@
111110 -> Avermedia M102 [1461:f31e] 111110 -> Avermedia M102 [1461:f31e]
112111 -> ASUS P7131 4871 [1043:4871] 112111 -> ASUS P7131 4871 [1043:4871]
113112 -> ASUSTeK P7131 Hybrid [1043:4876] 113112 -> ASUSTeK P7131 Hybrid [1043:4876]
114113 -> Elitegroup ECS TVP3XP FM1246 Tuner Card (PAL,FM) [1019:4cb6]
115114 -> KWorld DVB-T 210 [17de:7250]
116115 -> Sabrent PCMCIA TV-PCB05 [0919:2003]
diff --git a/Documentation/video4linux/sn9c102.txt b/Documentation/video4linux/sn9c102.txt
index 5fe0ad7dfc20..279717c96f63 100644
--- a/Documentation/video4linux/sn9c102.txt
+++ b/Documentation/video4linux/sn9c102.txt
@@ -355,6 +355,9 @@ devices assembling the SN9C1xx PC camera controllers:
355 355
356Vendor ID Product ID 356Vendor ID Product ID
357--------- ---------- 357--------- ----------
3580x0458 0x7025
3590x045e 0x00f5
3600x045e 0x00f7
3580x0471 0x0327 3610x0471 0x0327
3590x0471 0x0328 3620x0471 0x0328
3600x0c45 0x6001 3630x0c45 0x6001
@@ -432,7 +435,7 @@ Image sensor / SN9C1xx bridge | SN9C10[12] SN9C103 SN9C105 SN9C120
432HV7131D Hynix Semiconductor | Yes No No No 435HV7131D Hynix Semiconductor | Yes No No No
433HV7131R Hynix Semiconductor | No Yes Yes Yes 436HV7131R Hynix Semiconductor | No Yes Yes Yes
434MI-0343 Micron Technology | Yes No No No 437MI-0343 Micron Technology | Yes No No No
435MI-0360 Micron Technology | No Yes No No 438MI-0360 Micron Technology | No Yes Yes Yes
436OV7630 OmniVision Technologies | Yes Yes No No 439OV7630 OmniVision Technologies | Yes Yes No No
437OV7660 OmniVision Technologies | No No Yes Yes 440OV7660 OmniVision Technologies | No No Yes Yes
438PAS106B PixArt Imaging | Yes No No No 441PAS106B PixArt Imaging | Yes No No No
@@ -478,13 +481,12 @@ scaling factor is restored to 1.
478This driver supports two different video formats: the first one is the "8-bit 481This driver supports two different video formats: the first one is the "8-bit
479Sequential Bayer" format and can be used to obtain uncompressed video data 482Sequential Bayer" format and can be used to obtain uncompressed video data
480from the device through the current I/O method, while the second one provides 483from the device through the current I/O method, while the second one provides
481"raw" compressed video data (without frame headers not related to the 484either "raw" compressed video data (without frame headers not related to the
482compressed data). The compression quality may vary from 0 to 1 and can be 485compressed data) or standard JPEG (with frame headers). The compression quality
483selected or queried thanks to the VIDIOC_S_JPEGCOMP and VIDIOC_G_JPEGCOMP V4L2 486may vary from 0 to 1 and can be selected or queried thanks to the
484ioctl's. For maximum flexibility, both the default active video format and the 487VIDIOC_S_JPEGCOMP and VIDIOC_G_JPEGCOMP V4L2 ioctl's. For maximum flexibility,
485default compression quality depend on how the image sensor being used is 488both the default active video format and the default compression quality
486initialized (as described in the documentation of the API for the image sensors 489depend on how the image sensor being used is initialized.
487supplied by this driver).
488 490
489 491
49011. Video frame formats [1] 49211. Video frame formats [1]
diff --git a/MAINTAINERS b/MAINTAINERS
index bd558ac5bb73..68a56add73e3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -372,7 +372,7 @@ AOA (Apple Onboard Audio) ALSA DRIVER
372P: Johannes Berg 372P: Johannes Berg
373M: johannes@sipsolutions.net 373M: johannes@sipsolutions.net
374L: linuxppc-dev@ozlabs.org 374L: linuxppc-dev@ozlabs.org
375L: alsa-devel@alsa-project.org 375L: alsa-devel@alsa-project.org (subscribers-only)
376S: Maintained 376S: Maintained
377 377
378APM DRIVER 378APM DRIVER
@@ -3239,13 +3239,13 @@ S: Maintained
3239SOUND 3239SOUND
3240P: Jaroslav Kysela 3240P: Jaroslav Kysela
3241M: perex@suse.cz 3241M: perex@suse.cz
3242L: alsa-devel@alsa-project.org 3242L: alsa-devel@alsa-project.org (subscribers-only)
3243S: Maintained 3243S: Maintained
3244 3244
3245SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEMENT 3245SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEMENT
3246P: Liam Girdwood 3246P: Liam Girdwood
3247M: liam.girdwood@wolfsonmicro.com 3247M: liam.girdwood@wolfsonmicro.com
3248L: alsa-devel@alsa-project.org 3248L: alsa-devel@alsa-project.org (subscribers-only)
3249S: Supported 3249S: Supported
3250 3250
3251SPI SUBSYSTEM 3251SPI SUBSYSTEM
@@ -3269,7 +3269,6 @@ W: http://tpmdd.sourceforge.net
3269P: Marcel Selhorst 3269P: Marcel Selhorst
3270M: tpm@selhorst.net 3270M: tpm@selhorst.net
3271W: http://www.prosec.rub.de/tpm/ 3271W: http://www.prosec.rub.de/tpm/
3272L: tpmdd-devel@lists.sourceforge.net
3273S: Maintained 3272S: Maintained
3274 3273
3275Telecom Clock Driver for MCPL0010 3274Telecom Clock Driver for MCPL0010
diff --git a/arch/frv/kernel/gdb-stub.c b/arch/frv/kernel/gdb-stub.c
index 9550f37fb62c..1e7a101cbf4c 100644
--- a/arch/frv/kernel/gdb-stub.c
+++ b/arch/frv/kernel/gdb-stub.c
@@ -1195,7 +1195,7 @@ static void gdbstub_check_breakpoint(void)
1195/* 1195/*
1196 * 1196 *
1197 */ 1197 */
1198static void __attribute__((unused)) gdbstub_show_regs(void) 1198static void __maybe_unused gdbstub_show_regs(void)
1199{ 1199{
1200 unsigned long *reg; 1200 unsigned long *reg;
1201 int loop; 1201 int loop;
@@ -1223,7 +1223,7 @@ static void __attribute__((unused)) gdbstub_show_regs(void)
1223/* 1223/*
1224 * dump debugging regs 1224 * dump debugging regs
1225 */ 1225 */
1226static void __attribute__((unused)) gdbstub_dump_debugregs(void) 1226static void __maybe_unused gdbstub_dump_debugregs(void)
1227{ 1227{
1228 gdbstub_printk("DCR %08lx ", __debug_status.dcr); 1228 gdbstub_printk("DCR %08lx ", __debug_status.dcr);
1229 gdbstub_printk("BRR %08lx\n", __debug_status.brr); 1229 gdbstub_printk("BRR %08lx\n", __debug_status.brr);
@@ -2079,25 +2079,25 @@ void gdbstub_exit(int status)
2079 * GDB wants to call malloc() and free() to allocate memory for calling kernel 2079 * GDB wants to call malloc() and free() to allocate memory for calling kernel
2080 * functions directly from its command line 2080 * functions directly from its command line
2081 */ 2081 */
2082static void *malloc(size_t size) __attribute__((unused)); 2082static void *malloc(size_t size) __maybe_unused;
2083static void *malloc(size_t size) 2083static void *malloc(size_t size)
2084{ 2084{
2085 return kmalloc(size, GFP_ATOMIC); 2085 return kmalloc(size, GFP_ATOMIC);
2086} 2086}
2087 2087
2088static void free(void *p) __attribute__((unused)); 2088static void free(void *p) __maybe_unused;
2089static void free(void *p) 2089static void free(void *p)
2090{ 2090{
2091 kfree(p); 2091 kfree(p);
2092} 2092}
2093 2093
2094static uint32_t ___get_HSR0(void) __attribute__((unused)); 2094static uint32_t ___get_HSR0(void) __maybe_unused;
2095static uint32_t ___get_HSR0(void) 2095static uint32_t ___get_HSR0(void)
2096{ 2096{
2097 return __get_HSR(0); 2097 return __get_HSR(0);
2098} 2098}
2099 2099
2100static uint32_t ___set_HSR0(uint32_t x) __attribute__((unused)); 2100static uint32_t ___set_HSR0(uint32_t x) __maybe_unused;
2101static uint32_t ___set_HSR0(uint32_t x) 2101static uint32_t ___set_HSR0(uint32_t x)
2102{ 2102{
2103 __set_HSR(0, x); 2103 __set_HSR(0, x);
diff --git a/arch/h8300/kernel/syscalls.S b/arch/h8300/kernel/syscalls.S
index dab98fd99e63..54e21c3f2057 100644
--- a/arch/h8300/kernel/syscalls.S
+++ b/arch/h8300/kernel/syscalls.S
@@ -31,7 +31,7 @@ SYMBOL_NAME_LABEL(sys_call_table)
31 .long SYMBOL_NAME(sys_mknod) 31 .long SYMBOL_NAME(sys_mknod)
32 .long SYMBOL_NAME(sys_chmod) /* 15 */ 32 .long SYMBOL_NAME(sys_chmod) /* 15 */
33 .long SYMBOL_NAME(sys_chown16) 33 .long SYMBOL_NAME(sys_chown16)
34 .long SYMBOL_NAME(sys_ni_syscall) /* old break syscall holder */ 34 .long SYMBOL_NAME(sys_ni_syscall) /* old break syscall holder */
35 .long SYMBOL_NAME(sys_stat) 35 .long SYMBOL_NAME(sys_stat)
36 .long SYMBOL_NAME(sys_lseek) 36 .long SYMBOL_NAME(sys_lseek)
37 .long SYMBOL_NAME(sys_getpid) /* 20 */ 37 .long SYMBOL_NAME(sys_getpid) /* 20 */
@@ -45,11 +45,11 @@ SYMBOL_NAME_LABEL(sys_call_table)
45 .long SYMBOL_NAME(sys_fstat) 45 .long SYMBOL_NAME(sys_fstat)
46 .long SYMBOL_NAME(sys_pause) 46 .long SYMBOL_NAME(sys_pause)
47 .long SYMBOL_NAME(sys_utime) /* 30 */ 47 .long SYMBOL_NAME(sys_utime) /* 30 */
48 .long SYMBOL_NAME(sys_ni_syscall) /* old stty syscall holder */ 48 .long SYMBOL_NAME(sys_ni_syscall) /* old stty syscall holder */
49 .long SYMBOL_NAME(sys_ni_syscall) /* old gtty syscall holder */ 49 .long SYMBOL_NAME(sys_ni_syscall) /* old gtty syscall holder */
50 .long SYMBOL_NAME(sys_access) 50 .long SYMBOL_NAME(sys_access)
51 .long SYMBOL_NAME(sys_nice) 51 .long SYMBOL_NAME(sys_nice)
52 .long SYMBOL_NAME(sys_ni_syscall) /* 35 */ /* old ftime syscall holder */ 52 .long SYMBOL_NAME(sys_ni_syscall) /* 35 old ftime syscall holder */
53 .long SYMBOL_NAME(sys_sync) 53 .long SYMBOL_NAME(sys_sync)
54 .long SYMBOL_NAME(sys_kill) 54 .long SYMBOL_NAME(sys_kill)
55 .long SYMBOL_NAME(sys_rename) 55 .long SYMBOL_NAME(sys_rename)
@@ -58,7 +58,7 @@ SYMBOL_NAME_LABEL(sys_call_table)
58 .long SYMBOL_NAME(sys_dup) 58 .long SYMBOL_NAME(sys_dup)
59 .long SYMBOL_NAME(sys_pipe) 59 .long SYMBOL_NAME(sys_pipe)
60 .long SYMBOL_NAME(sys_times) 60 .long SYMBOL_NAME(sys_times)
61 .long SYMBOL_NAME(sys_ni_syscall) /* old prof syscall holder */ 61 .long SYMBOL_NAME(sys_ni_syscall) /* old prof syscall holder */
62 .long SYMBOL_NAME(sys_brk) /* 45 */ 62 .long SYMBOL_NAME(sys_brk) /* 45 */
63 .long SYMBOL_NAME(sys_setgid16) 63 .long SYMBOL_NAME(sys_setgid16)
64 .long SYMBOL_NAME(sys_getgid16) 64 .long SYMBOL_NAME(sys_getgid16)
@@ -66,13 +66,13 @@ SYMBOL_NAME_LABEL(sys_call_table)
66 .long SYMBOL_NAME(sys_geteuid16) 66 .long SYMBOL_NAME(sys_geteuid16)
67 .long SYMBOL_NAME(sys_getegid16) /* 50 */ 67 .long SYMBOL_NAME(sys_getegid16) /* 50 */
68 .long SYMBOL_NAME(sys_acct) 68 .long SYMBOL_NAME(sys_acct)
69 .long SYMBOL_NAME(sys_umount) /* recycled never used phys() */ 69 .long SYMBOL_NAME(sys_umount) /* recycled never used phys() */
70 .long SYMBOL_NAME(sys_ni_syscall) /* old lock syscall holder */ 70 .long SYMBOL_NAME(sys_ni_syscall) /* old lock syscall holder */
71 .long SYMBOL_NAME(sys_ioctl) 71 .long SYMBOL_NAME(sys_ioctl)
72 .long SYMBOL_NAME(sys_fcntl) /* 55 */ 72 .long SYMBOL_NAME(sys_fcntl) /* 55 */
73 .long SYMBOL_NAME(sys_ni_syscall) /* old mpx syscall holder */ 73 .long SYMBOL_NAME(sys_ni_syscall) /* old mpx syscall holder */
74 .long SYMBOL_NAME(sys_setpgid) 74 .long SYMBOL_NAME(sys_setpgid)
75 .long SYMBOL_NAME(sys_ni_syscall) /* old ulimit syscall holder */ 75 .long SYMBOL_NAME(sys_ni_syscall) /* old ulimit syscall holder */
76 .long SYMBOL_NAME(sys_ni_syscall) 76 .long SYMBOL_NAME(sys_ni_syscall)
77 .long SYMBOL_NAME(sys_umask) /* 60 */ 77 .long SYMBOL_NAME(sys_umask) /* 60 */
78 .long SYMBOL_NAME(sys_chroot) 78 .long SYMBOL_NAME(sys_chroot)
@@ -112,7 +112,7 @@ SYMBOL_NAME_LABEL(sys_call_table)
112 .long SYMBOL_NAME(sys_fchown16) /* 95 */ 112 .long SYMBOL_NAME(sys_fchown16) /* 95 */
113 .long SYMBOL_NAME(sys_getpriority) 113 .long SYMBOL_NAME(sys_getpriority)
114 .long SYMBOL_NAME(sys_setpriority) 114 .long SYMBOL_NAME(sys_setpriority)
115 .long SYMBOL_NAME(sys_ni_syscall) /* old profil syscall holder */ 115 .long SYMBOL_NAME(sys_ni_syscall) /* old profil syscall holder */
116 .long SYMBOL_NAME(sys_statfs) 116 .long SYMBOL_NAME(sys_statfs)
117 .long SYMBOL_NAME(sys_fstatfs) /* 100 */ 117 .long SYMBOL_NAME(sys_fstatfs) /* 100 */
118 .long SYMBOL_NAME(sys_ni_syscall) /* ioperm for i386 */ 118 .long SYMBOL_NAME(sys_ni_syscall) /* ioperm for i386 */
@@ -202,8 +202,8 @@ SYMBOL_NAME_LABEL(sys_call_table)
202 .long SYMBOL_NAME(sys_capset) /* 185 */ 202 .long SYMBOL_NAME(sys_capset) /* 185 */
203 .long SYMBOL_NAME(sys_sigaltstack) 203 .long SYMBOL_NAME(sys_sigaltstack)
204 .long SYMBOL_NAME(sys_sendfile) 204 .long SYMBOL_NAME(sys_sendfile)
205 .long SYMBOL_NAME(sys_ni_syscall) /* streams1 */ 205 .long SYMBOL_NAME(sys_ni_syscall) /* streams1 */
206 .long SYMBOL_NAME(sys_ni_syscall) /* streams2 */ 206 .long SYMBOL_NAME(sys_ni_syscall) /* streams2 */
207 .long SYMBOL_NAME(sys_vfork) /* 190 */ 207 .long SYMBOL_NAME(sys_vfork) /* 190 */
208 .long SYMBOL_NAME(sys_getrlimit) 208 .long SYMBOL_NAME(sys_getrlimit)
209 .long SYMBOL_NAME(sys_mmap2) 209 .long SYMBOL_NAME(sys_mmap2)
@@ -236,10 +236,10 @@ SYMBOL_NAME_LABEL(sys_call_table)
236 .long SYMBOL_NAME(sys_ni_syscall) 236 .long SYMBOL_NAME(sys_ni_syscall)
237 .long SYMBOL_NAME(sys_getdents64) /* 220 */ 237 .long SYMBOL_NAME(sys_getdents64) /* 220 */
238 .long SYMBOL_NAME(sys_fcntl64) 238 .long SYMBOL_NAME(sys_fcntl64)
239 .long SYMBOL_NAME(sys_ni_syscall) /* reserved for TUX */ 239 .long SYMBOL_NAME(sys_ni_syscall) /* reserved TUX */
240 .long SYMBOL_NAME(sys_ni_syscall) 240 .long SYMBOL_NAME(sys_ni_syscall) /* reserved Security */
241 .long SYMBOL_NAME(sys_gettid) 241 .long SYMBOL_NAME(sys_gettid)
242 .long SYMBOL_NAME(sys_ni_syscall) /* 225 */ /* sys_readahead */ 242 .long SYMBOL_NAME(sys_readahead) /* 225 */
243 .long SYMBOL_NAME(sys_setxattr) 243 .long SYMBOL_NAME(sys_setxattr)
244 .long SYMBOL_NAME(sys_lsetxattr) 244 .long SYMBOL_NAME(sys_lsetxattr)
245 .long SYMBOL_NAME(sys_fsetxattr) 245 .long SYMBOL_NAME(sys_fsetxattr)
@@ -257,8 +257,8 @@ SYMBOL_NAME_LABEL(sys_call_table)
257 .long SYMBOL_NAME(sys_futex) /* 240 */ 257 .long SYMBOL_NAME(sys_futex) /* 240 */
258 .long SYMBOL_NAME(sys_sched_setaffinity) 258 .long SYMBOL_NAME(sys_sched_setaffinity)
259 .long SYMBOL_NAME(sys_sched_getaffinity) 259 .long SYMBOL_NAME(sys_sched_getaffinity)
260 .long SYMBOL_NAME(sys_ni_syscall) /* sys_set_thread_area */ 260 .long SYMBOL_NAME(sys_ni_syscall)
261 .long SYMBOL_NAME(sys_ni_syscall) /* sys_get_thread_area */ 261 .long SYMBOL_NAME(sys_ni_syscall)
262 .long SYMBOL_NAME(sys_io_setup) /* 245 */ 262 .long SYMBOL_NAME(sys_io_setup) /* 245 */
263 .long SYMBOL_NAME(sys_io_destroy) 263 .long SYMBOL_NAME(sys_io_destroy)
264 .long SYMBOL_NAME(sys_io_getevents) 264 .long SYMBOL_NAME(sys_io_getevents)
@@ -288,8 +288,8 @@ SYMBOL_NAME_LABEL(sys_call_table)
288 .long SYMBOL_NAME(sys_utimes) 288 .long SYMBOL_NAME(sys_utimes)
289 .long SYMBOL_NAME(sys_fadvise64_64) 289 .long SYMBOL_NAME(sys_fadvise64_64)
290 .long SYMBOL_NAME(sys_ni_syscall) /* sys_vserver */ 290 .long SYMBOL_NAME(sys_ni_syscall) /* sys_vserver */
291 .long SYMBOL_NAME(sys_mbind) 291 .long SYMBOL_NAME(sys_ni_syscall)
292 .long SYMBOL_NAME(sys_get_mempolicy) 292 .long SYMBOL_NAME(sys_get_mempolicy) /* 275 */
293 .long SYMBOL_NAME(sys_set_mempolicy) 293 .long SYMBOL_NAME(sys_set_mempolicy)
294 .long SYMBOL_NAME(sys_mq_open) 294 .long SYMBOL_NAME(sys_mq_open)
295 .long SYMBOL_NAME(sys_mq_unlink) 295 .long SYMBOL_NAME(sys_mq_unlink)
@@ -297,16 +297,42 @@ SYMBOL_NAME_LABEL(sys_call_table)
297 .long SYMBOL_NAME(sys_mq_timedreceive) /* 280 */ 297 .long SYMBOL_NAME(sys_mq_timedreceive) /* 280 */
298 .long SYMBOL_NAME(sys_mq_notify) 298 .long SYMBOL_NAME(sys_mq_notify)
299 .long SYMBOL_NAME(sys_mq_getsetattr) 299 .long SYMBOL_NAME(sys_mq_getsetattr)
300 .long SYMBOL_NAME(sys_ni_syscall) /* reserved for kexec */
301 .long SYMBOL_NAME(sys_waitid) 300 .long SYMBOL_NAME(sys_waitid)
302 .long SYMBOL_NAME(sys_ni_syscall) /* 285 */ /* available */ 301 .long SYMBOL_NAME(sys_ni_syscall) /* sys_kexec_load */
303 .long SYMBOL_NAME(sys_add_key) 302 .long SYMBOL_NAME(sys_add_key) /* 285 */
304 .long SYMBOL_NAME(sys_request_key) 303 .long SYMBOL_NAME(sys_request_key)
305 .long SYMBOL_NAME(sys_keyctl) 304 .long SYMBOL_NAME(sys_keyctl)
306 305 .long SYMBOL_NAME(sys_ioprio_set)
307 .rept NR_syscalls-(.-SYMBOL_NAME(sys_call_table))/4 306 .long SYMBOL_NAME(sys_ioprio_get) /* 290 */
308 .long SYMBOL_NAME(sys_ni_syscall) 307 .long SYMBOL_NAME(sys_inotify_init)
309 .endr 308 .long SYMBOL_NAME(sys_inotify_add_watch)
309 .long SYMBOL_NAME(sys_inotify_rm_watch)
310 .long SYMBOL_NAME(sys_migrate_pages)
311 .long SYMBOL_NAME(sys_openat) /* 295 */
312 .long SYMBOL_NAME(sys_mkdirat)
313 .long SYMBOL_NAME(sys_mknodat)
314 .long SYMBOL_NAME(sys_fchownat)
315 .long SYMBOL_NAME(sys_futimesat)
316 .long SYMBOL_NAME(sys_fstatat64) /* 300 */
317 .long SYMBOL_NAME(sys_unlinkat)
318 .long SYMBOL_NAME(sys_renameat)
319 .long SYMBOL_NAME(sys_linkat)
320 .long SYMBOL_NAME(sys_symlinkat)
321 .long SYMBOL_NAME(sys_readlinkat) /* 305 */
322 .long SYMBOL_NAME(sys_fchmodat)
323 .long SYMBOL_NAME(sys_faccessat)
324 .long SYMBOL_NAME(sys_ni_syscall) /* sys_pselect6 */
325 .long SYMBOL_NAME(sys_ni_syscall) /* sys_ppoll */
326 .long SYMBOL_NAME(sys_unshare) /* 310 */
327 .long SYMBOL_NAME(sys_set_robust_list)
328 .long SYMBOL_NAME(sys_get_robust_list)
329 .long SYMBOL_NAME(sys_splice)
330 .long SYMBOL_NAME(sys_sync_file_range)
331 .long SYMBOL_NAME(sys_tee) /* 315 */
332 .long SYMBOL_NAME(sys_vmsplice)
333 .long SYMBOL_NAME(sys_ni_syscall) /* sys_move_pages */
334 .long SYMBOL_NAME(sys_getcpu)
335 .long SYMBOL_NAME(sys_ni_syscall) /* sys_epoll_pwait */
310 336
311 .macro call_sp addr 337 .macro call_sp addr
312 mov.l #SYMBOL_NAME(\addr),er6 338 mov.l #SYMBOL_NAME(\addr),er6
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index 30944ee2e61a..c2d54b802232 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -55,6 +55,10 @@ config ZONE_DMA
55 bool 55 bool
56 default y 56 default y
57 57
58config QUICKLIST
59 bool
60 default y
61
58config SBUS 62config SBUS
59 bool 63 bool
60 64
@@ -79,10 +83,6 @@ config ARCH_MAY_HAVE_PC_FDC
79 bool 83 bool
80 default y 84 default y
81 85
82config ARCH_USES_SLAB_PAGE_STRUCT
83 bool
84 default y
85
86config DMI 86config DMI
87 bool 87 bool
88 default y 88 default y
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
index d76d9bc33b30..06dfa65ad180 100644
--- a/arch/i386/kernel/process.c
+++ b/arch/i386/kernel/process.c
@@ -186,6 +186,7 @@ void cpu_idle(void)
186 if (__get_cpu_var(cpu_idle_state)) 186 if (__get_cpu_var(cpu_idle_state))
187 __get_cpu_var(cpu_idle_state) = 0; 187 __get_cpu_var(cpu_idle_state) = 0;
188 188
189 check_pgt_cache();
189 rmb(); 190 rmb();
190 idle = pm_idle; 191 idle = pm_idle;
191 192
diff --git a/arch/i386/kernel/smp.c b/arch/i386/kernel/smp.c
index 93f202a855fa..706bda72dc60 100644
--- a/arch/i386/kernel/smp.c
+++ b/arch/i386/kernel/smp.c
@@ -421,7 +421,7 @@ void flush_tlb_mm (struct mm_struct * mm)
421 } 421 }
422 if (!cpus_empty(cpu_mask)) 422 if (!cpus_empty(cpu_mask))
423 flush_tlb_others(cpu_mask, mm, TLB_FLUSH_ALL); 423 flush_tlb_others(cpu_mask, mm, TLB_FLUSH_ALL);
424 424 check_pgt_cache();
425 preempt_enable(); 425 preempt_enable();
426} 426}
427 427
diff --git a/arch/i386/kernel/syscall_table.S b/arch/i386/kernel/syscall_table.S
index 0772678ceecf..bf6adce52267 100644
--- a/arch/i386/kernel/syscall_table.S
+++ b/arch/i386/kernel/syscall_table.S
@@ -320,3 +320,6 @@ ENTRY(sys_call_table)
320 .long sys_getcpu 320 .long sys_getcpu
321 .long sys_epoll_pwait 321 .long sys_epoll_pwait
322 .long sys_utimensat /* 320 */ 322 .long sys_utimensat /* 320 */
323 .long sys_signalfd
324 .long sys_timerfd
325 .long sys_eventfd
diff --git a/arch/i386/kernel/verify_cpu.S b/arch/i386/kernel/verify_cpu.S
index e51a8695d54e..b2a9d80b6421 100644
--- a/arch/i386/kernel/verify_cpu.S
+++ b/arch/i386/kernel/verify_cpu.S
@@ -10,7 +10,9 @@ verify_cpu:
10 10
11#if CONFIG_X86_MINIMUM_CPU_MODEL >= 4 11#if CONFIG_X86_MINIMUM_CPU_MODEL >= 4
12 pushfl 12 pushfl
13 orl $(1<<18),(%esp) # try setting AC 13 pop %eax
14 orl $(1<<18),%eax # try setting AC
15 push %eax
14 popfl 16 popfl
15 pushfl 17 pushfl
16 popl %eax 18 popl %eax
diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c
index c50782efa5c3..b22ce8d6b1ba 100644
--- a/arch/i386/mm/init.c
+++ b/arch/i386/mm/init.c
@@ -740,7 +740,6 @@ int remove_memory(u64 start, u64 size)
740EXPORT_SYMBOL_GPL(remove_memory); 740EXPORT_SYMBOL_GPL(remove_memory);
741#endif 741#endif
742 742
743struct kmem_cache *pgd_cache;
744struct kmem_cache *pmd_cache; 743struct kmem_cache *pmd_cache;
745 744
746void __init pgtable_cache_init(void) 745void __init pgtable_cache_init(void)
@@ -764,12 +763,6 @@ void __init pgtable_cache_init(void)
764 pgd_size = PAGE_SIZE; 763 pgd_size = PAGE_SIZE;
765 } 764 }
766 } 765 }
767 pgd_cache = kmem_cache_create("pgd",
768 pgd_size,
769 pgd_size,
770 SLAB_PANIC,
771 pgd_ctor,
772 (!SHARED_KERNEL_PMD) ? pgd_dtor : NULL);
773} 766}
774 767
775/* 768/*
diff --git a/arch/i386/mm/pgtable.c b/arch/i386/mm/pgtable.c
index 9a96c1647428..8d7c0864cc04 100644
--- a/arch/i386/mm/pgtable.c
+++ b/arch/i386/mm/pgtable.c
@@ -13,6 +13,7 @@
13#include <linux/pagemap.h> 13#include <linux/pagemap.h>
14#include <linux/spinlock.h> 14#include <linux/spinlock.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/quicklist.h>
16 17
17#include <asm/system.h> 18#include <asm/system.h>
18#include <asm/pgtable.h> 19#include <asm/pgtable.h>
@@ -205,8 +206,6 @@ void pmd_ctor(void *pmd, struct kmem_cache *cache, unsigned long flags)
205 * against pageattr.c; it is the unique case in which a valid change 206 * against pageattr.c; it is the unique case in which a valid change
206 * of kernel pagetables can't be lazily synchronized by vmalloc faults. 207 * of kernel pagetables can't be lazily synchronized by vmalloc faults.
207 * vmalloc faults work because attached pagetables are never freed. 208 * vmalloc faults work because attached pagetables are never freed.
208 * The locking scheme was chosen on the basis of manfred's
209 * recommendations and having no core impact whatsoever.
210 * -- wli 209 * -- wli
211 */ 210 */
212DEFINE_SPINLOCK(pgd_lock); 211DEFINE_SPINLOCK(pgd_lock);
@@ -232,9 +231,11 @@ static inline void pgd_list_del(pgd_t *pgd)
232 set_page_private(next, (unsigned long)pprev); 231 set_page_private(next, (unsigned long)pprev);
233} 232}
234 233
234
235
235#if (PTRS_PER_PMD == 1) 236#if (PTRS_PER_PMD == 1)
236/* Non-PAE pgd constructor */ 237/* Non-PAE pgd constructor */
237void pgd_ctor(void *pgd, struct kmem_cache *cache, unsigned long unused) 238void pgd_ctor(void *pgd)
238{ 239{
239 unsigned long flags; 240 unsigned long flags;
240 241
@@ -256,7 +257,7 @@ void pgd_ctor(void *pgd, struct kmem_cache *cache, unsigned long unused)
256} 257}
257#else /* PTRS_PER_PMD > 1 */ 258#else /* PTRS_PER_PMD > 1 */
258/* PAE pgd constructor */ 259/* PAE pgd constructor */
259void pgd_ctor(void *pgd, struct kmem_cache *cache, unsigned long unused) 260void pgd_ctor(void *pgd)
260{ 261{
261 /* PAE, kernel PMD may be shared */ 262 /* PAE, kernel PMD may be shared */
262 263
@@ -275,11 +276,12 @@ void pgd_ctor(void *pgd, struct kmem_cache *cache, unsigned long unused)
275} 276}
276#endif /* PTRS_PER_PMD */ 277#endif /* PTRS_PER_PMD */
277 278
278void pgd_dtor(void *pgd, struct kmem_cache *cache, unsigned long unused) 279void pgd_dtor(void *pgd)
279{ 280{
280 unsigned long flags; /* can be called from interrupt context */ 281 unsigned long flags; /* can be called from interrupt context */
281 282
282 BUG_ON(SHARED_KERNEL_PMD); 283 if (SHARED_KERNEL_PMD)
284 return;
283 285
284 paravirt_release_pd(__pa(pgd) >> PAGE_SHIFT); 286 paravirt_release_pd(__pa(pgd) >> PAGE_SHIFT);
285 spin_lock_irqsave(&pgd_lock, flags); 287 spin_lock_irqsave(&pgd_lock, flags);
@@ -321,7 +323,7 @@ static void pmd_cache_free(pmd_t *pmd, int idx)
321pgd_t *pgd_alloc(struct mm_struct *mm) 323pgd_t *pgd_alloc(struct mm_struct *mm)
322{ 324{
323 int i; 325 int i;
324 pgd_t *pgd = kmem_cache_alloc(pgd_cache, GFP_KERNEL); 326 pgd_t *pgd = quicklist_alloc(0, GFP_KERNEL, pgd_ctor);
325 327
326 if (PTRS_PER_PMD == 1 || !pgd) 328 if (PTRS_PER_PMD == 1 || !pgd)
327 return pgd; 329 return pgd;
@@ -344,7 +346,7 @@ out_oom:
344 paravirt_release_pd(__pa(pmd) >> PAGE_SHIFT); 346 paravirt_release_pd(__pa(pmd) >> PAGE_SHIFT);
345 pmd_cache_free(pmd, i); 347 pmd_cache_free(pmd, i);
346 } 348 }
347 kmem_cache_free(pgd_cache, pgd); 349 quicklist_free(0, pgd_dtor, pgd);
348 return NULL; 350 return NULL;
349} 351}
350 352
@@ -361,5 +363,11 @@ void pgd_free(pgd_t *pgd)
361 pmd_cache_free(pmd, i); 363 pmd_cache_free(pmd, i);
362 } 364 }
363 /* in the non-PAE case, free_pgtables() clears user pgd entries */ 365 /* in the non-PAE case, free_pgtables() clears user pgd entries */
364 kmem_cache_free(pgd_cache, pgd); 366 quicklist_free(0, pgd_dtor, pgd);
365} 367}
368
369void check_pgt_cache(void)
370{
371 quicklist_trim(0, pgd_dtor, 25, 16);
372}
373
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 6e41471449c0..de1bff659969 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -31,6 +31,10 @@ config ZONE_DMA
31 def_bool y 31 def_bool y
32 depends on !IA64_SGI_SN2 32 depends on !IA64_SGI_SN2
33 33
34config QUICKLIST
35 bool
36 default y
37
34config MMU 38config MMU
35 bool 39 bool
36 default y 40 default y
diff --git a/arch/ia64/hp/common/hwsw_iommu.c b/arch/ia64/hp/common/hwsw_iommu.c
index 2153bcacbe6c..94e57109fad6 100644
--- a/arch/ia64/hp/common/hwsw_iommu.c
+++ b/arch/ia64/hp/common/hwsw_iommu.c
@@ -63,7 +63,7 @@ use_swiotlb (struct device *dev)
63 return dev && dev->dma_mask && !hwiommu_dma_supported(dev, *dev->dma_mask); 63 return dev && dev->dma_mask && !hwiommu_dma_supported(dev, *dev->dma_mask);
64} 64}
65 65
66void 66void __init
67hwsw_init (void) 67hwsw_init (void)
68{ 68{
69 /* default to a smallish 2MB sw I/O TLB */ 69 /* default to a smallish 2MB sw I/O TLB */
diff --git a/arch/ia64/ia32/audit.c b/arch/ia64/ia32/audit.c
index 92d7d0c8d93f..8850fe40ea34 100644
--- a/arch/ia64/ia32/audit.c
+++ b/arch/ia64/ia32/audit.c
@@ -20,6 +20,11 @@ unsigned ia32_read_class[] = {
20~0U 20~0U
21}; 21};
22 22
23unsigned ia32_signal_class[] = {
24#include <asm-generic/audit_signal.h>
25~0U
26};
27
23int ia32_classify_syscall(unsigned syscall) 28int ia32_classify_syscall(unsigned syscall)
24{ 29{
25 switch(syscall) { 30 switch(syscall) {
diff --git a/arch/ia64/kernel/audit.c b/arch/ia64/kernel/audit.c
index 04682555a28c..f3802ae89b10 100644
--- a/arch/ia64/kernel/audit.c
+++ b/arch/ia64/kernel/audit.c
@@ -23,6 +23,20 @@ static unsigned chattr_class[] = {
23~0U 23~0U
24}; 24};
25 25
26static unsigned signal_class[] = {
27#include <asm-generic/audit_signal.h>
28~0U
29};
30
31int audit_classify_arch(int arch)
32{
33#ifdef CONFIG_IA32_SUPPORT
34 if (arch == AUDIT_ARCH_I386)
35 return 1;
36#endif
37 return 0;
38}
39
26int audit_classify_syscall(int abi, unsigned syscall) 40int audit_classify_syscall(int abi, unsigned syscall)
27{ 41{
28#ifdef CONFIG_IA32_SUPPORT 42#ifdef CONFIG_IA32_SUPPORT
@@ -49,15 +63,18 @@ static int __init audit_classes_init(void)
49 extern __u32 ia32_write_class[]; 63 extern __u32 ia32_write_class[];
50 extern __u32 ia32_read_class[]; 64 extern __u32 ia32_read_class[];
51 extern __u32 ia32_chattr_class[]; 65 extern __u32 ia32_chattr_class[];
66 extern __u32 ia32_signal_class[];
52 audit_register_class(AUDIT_CLASS_WRITE_32, ia32_write_class); 67 audit_register_class(AUDIT_CLASS_WRITE_32, ia32_write_class);
53 audit_register_class(AUDIT_CLASS_READ_32, ia32_read_class); 68 audit_register_class(AUDIT_CLASS_READ_32, ia32_read_class);
54 audit_register_class(AUDIT_CLASS_DIR_WRITE_32, ia32_dir_class); 69 audit_register_class(AUDIT_CLASS_DIR_WRITE_32, ia32_dir_class);
55 audit_register_class(AUDIT_CLASS_CHATTR_32, ia32_chattr_class); 70 audit_register_class(AUDIT_CLASS_CHATTR_32, ia32_chattr_class);
71 audit_register_class(AUDIT_CLASS_SIGNAL_32, ia32_signal_class);
56#endif 72#endif
57 audit_register_class(AUDIT_CLASS_WRITE, write_class); 73 audit_register_class(AUDIT_CLASS_WRITE, write_class);
58 audit_register_class(AUDIT_CLASS_READ, read_class); 74 audit_register_class(AUDIT_CLASS_READ, read_class);
59 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class); 75 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
60 audit_register_class(AUDIT_CLASS_CHATTR, chattr_class); 76 audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
77 audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
61 return 0; 78 return 0;
62} 79}
63 80
diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
index b50bf208678e..144b056282af 100644
--- a/arch/ia64/kernel/entry.S
+++ b/arch/ia64/kernel/entry.S
@@ -1583,5 +1583,7 @@ sys_call_table:
1583 data8 sys_vmsplice 1583 data8 sys_vmsplice
1584 data8 sys_ni_syscall // reserved for move_pages 1584 data8 sys_ni_syscall // reserved for move_pages
1585 data8 sys_getcpu 1585 data8 sys_getcpu
1586 data8 sys_epoll_pwait // 1305
1587 data8 sys_utimensat
1586 1588
1587 .org sys_call_table + 8*NR_syscalls // guard against failures to increase NR_syscalls 1589 .org sys_call_table + 8*NR_syscalls // guard against failures to increase NR_syscalls
diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
index 6a49600cf337..b642648cc2ac 100644
--- a/arch/ia64/kernel/err_inject.c
+++ b/arch/ia64/kernel/err_inject.c
@@ -291,5 +291,5 @@ module_init(err_inject_init);
291module_exit(err_inject_exit); 291module_exit(err_inject_exit);
292 292
293MODULE_AUTHOR("Fenghua Yu <fenghua.yu@intel.com>"); 293MODULE_AUTHOR("Fenghua Yu <fenghua.yu@intel.com>");
294MODULE_DESCRIPTION("MC error injection kenrel sysfs interface"); 294MODULE_DESCRIPTION("MC error injection kernel sysfs interface");
295MODULE_LICENSE("GPL"); 295MODULE_LICENSE("GPL");
diff --git a/arch/ia64/kernel/irq.c b/arch/ia64/kernel/irq.c
index ce49c85c928f..b4c239685d2e 100644
--- a/arch/ia64/kernel/irq.c
+++ b/arch/ia64/kernel/irq.c
@@ -104,6 +104,17 @@ void set_irq_affinity_info (unsigned int irq, int hwid, int redir)
104 irq_redir[irq] = (char) (redir & 0xff); 104 irq_redir[irq] = (char) (redir & 0xff);
105 } 105 }
106} 106}
107
108bool is_affinity_mask_valid(cpumask_t cpumask)
109{
110 if (ia64_platform_is("sn2")) {
111 /* Only allow one CPU to be specified in the smp_affinity mask */
112 if (cpus_weight(cpumask) != 1)
113 return false;
114 }
115 return true;
116}
117
107#endif /* CONFIG_SMP */ 118#endif /* CONFIG_SMP */
108 119
109#ifdef CONFIG_HOTPLUG_CPU 120#ifdef CONFIG_HOTPLUG_CPU
diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c
index 4f5fd0960ba7..72e593e94053 100644
--- a/arch/ia64/kernel/kprobes.c
+++ b/arch/ia64/kernel/kprobes.c
@@ -370,14 +370,18 @@ static int __kprobes valid_kprobe_addr(int template, int slot,
370 370
371static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb) 371static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb)
372{ 372{
373 kcb->prev_kprobe.kp = kprobe_running(); 373 unsigned int i;
374 kcb->prev_kprobe.status = kcb->kprobe_status; 374 i = atomic_add_return(1, &kcb->prev_kprobe_index);
375 kcb->prev_kprobe[i-1].kp = kprobe_running();
376 kcb->prev_kprobe[i-1].status = kcb->kprobe_status;
375} 377}
376 378
377static void __kprobes restore_previous_kprobe(struct kprobe_ctlblk *kcb) 379static void __kprobes restore_previous_kprobe(struct kprobe_ctlblk *kcb)
378{ 380{
379 __get_cpu_var(current_kprobe) = kcb->prev_kprobe.kp; 381 unsigned int i;
380 kcb->kprobe_status = kcb->prev_kprobe.status; 382 i = atomic_sub_return(1, &kcb->prev_kprobe_index);
383 __get_cpu_var(current_kprobe) = kcb->prev_kprobe[i].kp;
384 kcb->kprobe_status = kcb->prev_kprobe[i].status;
381} 385}
382 386
383static void __kprobes set_current_kprobe(struct kprobe *p, 387static void __kprobes set_current_kprobe(struct kprobe *p,
diff --git a/arch/ia64/kernel/machvec.c b/arch/ia64/kernel/machvec.c
index 9620822270a6..13df337508e7 100644
--- a/arch/ia64/kernel/machvec.c
+++ b/arch/ia64/kernel/machvec.c
@@ -35,7 +35,7 @@ lookup_machvec (const char *name)
35 return 0; 35 return 0;
36} 36}
37 37
38void 38void __init
39machvec_init (const char *name) 39machvec_init (const char *name)
40{ 40{
41 struct ia64_machine_vector *mv; 41 struct ia64_machine_vector *mv;
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index f8ae709de0b5..26814de6c29a 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -118,7 +118,9 @@ static ia64_mc_info_t ia64_mc_info;
118#define CPE_HISTORY_LENGTH 5 118#define CPE_HISTORY_LENGTH 5
119#define CMC_HISTORY_LENGTH 5 119#define CMC_HISTORY_LENGTH 5
120 120
121#ifdef CONFIG_ACPI
121static struct timer_list cpe_poll_timer; 122static struct timer_list cpe_poll_timer;
123#endif
122static struct timer_list cmc_poll_timer; 124static struct timer_list cmc_poll_timer;
123/* 125/*
124 * This variable tells whether we are currently in polling mode. 126 * This variable tells whether we are currently in polling mode.
diff --git a/arch/ia64/mm/contig.c b/arch/ia64/mm/contig.c
index 44ce5ed9444c..7ac8592a35b6 100644
--- a/arch/ia64/mm/contig.c
+++ b/arch/ia64/mm/contig.c
@@ -88,7 +88,7 @@ void show_mem(void)
88 printk(KERN_INFO "%d pages shared\n", total_shared); 88 printk(KERN_INFO "%d pages shared\n", total_shared);
89 printk(KERN_INFO "%d pages swap cached\n", total_cached); 89 printk(KERN_INFO "%d pages swap cached\n", total_cached);
90 printk(KERN_INFO "Total of %ld pages in page table cache\n", 90 printk(KERN_INFO "Total of %ld pages in page table cache\n",
91 pgtable_quicklist_total_size()); 91 quicklist_total_size());
92 printk(KERN_INFO "%d free buffer pages\n", nr_free_buffer_pages()); 92 printk(KERN_INFO "%d free buffer pages\n", nr_free_buffer_pages());
93} 93}
94 94
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index 94844442812a..38085ac18338 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -561,7 +561,7 @@ void show_mem(void)
561 printk(KERN_INFO "%d pages shared\n", total_shared); 561 printk(KERN_INFO "%d pages shared\n", total_shared);
562 printk(KERN_INFO "%d pages swap cached\n", total_cached); 562 printk(KERN_INFO "%d pages swap cached\n", total_cached);
563 printk(KERN_INFO "Total of %ld pages in page table cache\n", 563 printk(KERN_INFO "Total of %ld pages in page table cache\n",
564 pgtable_quicklist_total_size()); 564 quicklist_total_size());
565 printk(KERN_INFO "%d free buffer pages\n", nr_free_buffer_pages()); 565 printk(KERN_INFO "%d free buffer pages\n", nr_free_buffer_pages());
566} 566}
567 567
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index cffb1e8325e8..c14abefabafa 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -39,9 +39,6 @@
39 39
40DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); 40DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
41 41
42DEFINE_PER_CPU(unsigned long *, __pgtable_quicklist);
43DEFINE_PER_CPU(long, __pgtable_quicklist_size);
44
45extern void ia64_tlb_init (void); 42extern void ia64_tlb_init (void);
46 43
47unsigned long MAX_DMA_ADDRESS = PAGE_OFFSET + 0x100000000UL; 44unsigned long MAX_DMA_ADDRESS = PAGE_OFFSET + 0x100000000UL;
@@ -56,54 +53,6 @@ EXPORT_SYMBOL(vmem_map);
56struct page *zero_page_memmap_ptr; /* map entry for zero page */ 53struct page *zero_page_memmap_ptr; /* map entry for zero page */
57EXPORT_SYMBOL(zero_page_memmap_ptr); 54EXPORT_SYMBOL(zero_page_memmap_ptr);
58 55
59#define MIN_PGT_PAGES 25UL
60#define MAX_PGT_FREES_PER_PASS 16L
61#define PGT_FRACTION_OF_NODE_MEM 16
62
63static inline long
64max_pgt_pages(void)
65{
66 u64 node_free_pages, max_pgt_pages;
67
68#ifndef CONFIG_NUMA
69 node_free_pages = nr_free_pages();
70#else
71 node_free_pages = node_page_state(numa_node_id(), NR_FREE_PAGES);
72#endif
73 max_pgt_pages = node_free_pages / PGT_FRACTION_OF_NODE_MEM;
74 max_pgt_pages = max(max_pgt_pages, MIN_PGT_PAGES);
75 return max_pgt_pages;
76}
77
78static inline long
79min_pages_to_free(void)
80{
81 long pages_to_free;
82
83 pages_to_free = pgtable_quicklist_size - max_pgt_pages();
84 pages_to_free = min(pages_to_free, MAX_PGT_FREES_PER_PASS);
85 return pages_to_free;
86}
87
88void
89check_pgt_cache(void)
90{
91 long pages_to_free;
92
93 if (unlikely(pgtable_quicklist_size <= MIN_PGT_PAGES))
94 return;
95
96 preempt_disable();
97 while (unlikely((pages_to_free = min_pages_to_free()) > 0)) {
98 while (pages_to_free--) {
99 free_page((unsigned long)pgtable_quicklist_alloc());
100 }
101 preempt_enable();
102 preempt_disable();
103 }
104 preempt_enable();
105}
106
107void 56void
108lazy_mmu_prot_update (pte_t pte) 57lazy_mmu_prot_update (pte_t pte)
109{ 58{
diff --git a/arch/ia64/sn/kernel/io_common.c b/arch/ia64/sn/kernel/io_common.c
index d48bcd83253c..7ed72d3faf73 100644
--- a/arch/ia64/sn/kernel/io_common.c
+++ b/arch/ia64/sn/kernel/io_common.c
@@ -364,7 +364,7 @@ void sn_bus_store_sysdata(struct pci_dev *dev)
364 364
365 element = kzalloc(sizeof(struct sysdata_el), GFP_KERNEL); 365 element = kzalloc(sizeof(struct sysdata_el), GFP_KERNEL);
366 if (!element) { 366 if (!element) {
367 dev_dbg(dev, "%s: out of memory!\n", __FUNCTION__); 367 dev_dbg(&dev->dev, "%s: out of memory!\n", __FUNCTION__);
368 return; 368 return;
369 } 369 }
370 element->sysdata = SN_PCIDEV_INFO(dev); 370 element->sysdata = SN_PCIDEV_INFO(dev);
diff --git a/arch/ia64/sn/kernel/xpc_partition.c b/arch/ia64/sn/kernel/xpc_partition.c
index 57c723f5cba4..7ba403232cb8 100644
--- a/arch/ia64/sn/kernel/xpc_partition.c
+++ b/arch/ia64/sn/kernel/xpc_partition.c
@@ -574,7 +574,7 @@ xpc_update_partition_info(struct xpc_partition *part, u8 remote_rp_version,
574 u64 remote_vars_pa, struct xpc_vars *remote_vars) 574 u64 remote_vars_pa, struct xpc_vars *remote_vars)
575{ 575{
576 part->remote_rp_version = remote_rp_version; 576 part->remote_rp_version = remote_rp_version;
577 dev_dbg(xpc_part, " remote_rp_version = 0x%016lx\n", 577 dev_dbg(xpc_part, " remote_rp_version = 0x%016x\n",
578 part->remote_rp_version); 578 part->remote_rp_version);
579 579
580 part->remote_rp_stamp = *remote_rp_stamp; 580 part->remote_rp_stamp = *remote_rp_stamp;
diff --git a/arch/ia64/sn/kernel/xpnet.c b/arch/ia64/sn/kernel/xpnet.c
index 88fad85ceeff..da7213530972 100644
--- a/arch/ia64/sn/kernel/xpnet.c
+++ b/arch/ia64/sn/kernel/xpnet.c
@@ -343,8 +343,8 @@ xpnet_dev_open(struct net_device *dev)
343 enum xpc_retval ret; 343 enum xpc_retval ret;
344 344
345 345
346 dev_dbg(xpnet, "calling xpc_connect(%d, 0x%p, NULL, %ld, %ld, %d, " 346 dev_dbg(xpnet, "calling xpc_connect(%d, 0x%p, NULL, %ld, %ld, %ld, "
347 "%d)\n", XPC_NET_CHANNEL, xpnet_connection_activity, 347 "%ld)\n", XPC_NET_CHANNEL, xpnet_connection_activity,
348 XPNET_MSG_SIZE, XPNET_MSG_NENTRIES, XPNET_MAX_KTHREADS, 348 XPNET_MSG_SIZE, XPNET_MSG_NENTRIES, XPNET_MAX_KTHREADS,
349 XPNET_MAX_IDLE_KTHREADS); 349 XPNET_MAX_IDLE_KTHREADS);
350 350
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig
index 9740d6b8ae11..c3bb8a755b00 100644
--- a/arch/m32r/Kconfig
+++ b/arch/m32r/Kconfig
@@ -241,6 +241,10 @@ config GENERIC_CALIBRATE_DELAY
241 bool 241 bool
242 default y 242 default y
243 243
244config SCHED_NO_NO_OMIT_FRAME_POINTER
245 bool
246 default y
247
244config PREEMPT 248config PREEMPT
245 bool "Preemptible Kernel" 249 bool "Preemptible Kernel"
246 help 250 help
diff --git a/arch/m32r/mm/mmu.S b/arch/m32r/mm/mmu.S
index 8bb74b10dca7..49a6d16a3d58 100644
--- a/arch/m32r/mm/mmu.S
+++ b/arch/m32r/mm/mmu.S
@@ -163,7 +163,8 @@ ENTRY(tme_handler)
163 163
164 ; pte_data = (unsigned long)pte_val(*pte); 164 ; pte_data = (unsigned long)pte_val(*pte);
165 ld r2, @r3 ; r2: pte data 165 ld r2, @r3 ; r2: pte data
166 or3 r2, r2, #2 ; _PAGE_PRESENT(=2) 166 and3 r3, r2, #2 ; _PAGE_PRESENT(=2) check
167 beqz r3, 3f
167 168
168 .fillinsn 169 .fillinsn
1695: 1705:
@@ -264,11 +265,8 @@ ENTRY(tme_handler)
264; 265;
265 and3 r1, r1, #0xeff 266 and3 r1, r1, #0xeff
266 ldi r4, #611 ; _KERNPG_TABLE(=611) 267 ldi r4, #611 ; _KERNPG_TABLE(=611)
267 beq r1, r4, 4f ; !pmd_bad(*pmd) ? 268 bne r1, r4, 3f ; !pmd_bad(*pmd) ?
268 .fillinsn 269
2693:
270 ldi r1, #0 ; r1: pte_data = 0
271 bra 5f
272 .fillinsn 270 .fillinsn
2734: 2714:
274 ; pte = pte_offset(pmd, address); 272 ; pte = pte_offset(pmd, address);
@@ -282,8 +280,10 @@ ENTRY(tme_handler)
282 add r4, r3 ; r4: pte 280 add r4, r3 ; r4: pte
283 ; pte_data = (unsigned long)pte_val(*pte); 281 ; pte_data = (unsigned long)pte_val(*pte);
284 ld r1, @r4 ; r1: pte_data 282 ld r1, @r4 ; r1: pte_data
285 .fillinsn 283 and3 r3, r1, #2 ; _PAGE_PRESENT(=2) check
284 beqz r3, 3f
286 285
286 .fillinsn
287;; set tlb 287;; set tlb
288; r0: address, r1: pte_data, r2: entry 288; r0: address, r1: pte_data, r2: entry
289; r3,r4: (free) 289; r3,r4: (free)
@@ -295,8 +295,7 @@ ENTRY(tme_handler)
295 and3 r4, r4, #(MMU_CONTEXT_ASID_MASK) 295 and3 r4, r4, #(MMU_CONTEXT_ASID_MASK)
296 or r3, r4 296 or r3, r4
297 st r3, @r2 297 st r3, @r2
298 or3 r4, r1, #2 ; _PAGE_PRESENT(=2) 298 st r1, @(4,r2) ; set_tlb_data(entry, pte_data);
299 st r4, @(4,r2) ; set_tlb_data(entry, pte_data);
300 299
301 ld r4, @sp+ 300 ld r4, @sp+
302 ld r3, @sp+ 301 ld r3, @sp+
@@ -306,6 +305,11 @@ ENTRY(tme_handler)
306 ld sp, @sp+ 305 ld sp, @sp+
307 rte 306 rte
308 307
308 .fillinsn
3093:
310 ldi r1, #2 ; r1: pte_data = 0 | _PAGE_PRESENT(=2)
311 bra 5b
312
309#else 313#else
310#error unknown isa configuration 314#error unknown isa configuration
311#endif 315#endif
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 16ecea3c0813..0f09412e1b7f 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -15,121 +15,8 @@ choice
15 prompt "System type" 15 prompt "System type"
16 default SGI_IP22 16 default SGI_IP22
17 17
18config MIPS_MTX1 18config MACH_ALCHEMY
19 bool "4G Systems MTX-1 board" 19 bool "Alchemy processor based machines"
20 select DMA_NONCOHERENT
21 select HW_HAS_PCI
22 select RESOURCES_64BIT if PCI
23 select SOC_AU1500
24 select SYS_HAS_CPU_MIPS32_R1
25 select SYS_SUPPORTS_LITTLE_ENDIAN
26
27config MIPS_BOSPORUS
28 bool "AMD Alchemy Bosporus board"
29 select SOC_AU1500
30 select DMA_NONCOHERENT
31 select SYS_HAS_CPU_MIPS32_R1
32 select SYS_SUPPORTS_LITTLE_ENDIAN
33
34config MIPS_PB1000
35 bool "AMD Alchemy PB1000 board"
36 select SOC_AU1000
37 select DMA_NONCOHERENT
38 select HW_HAS_PCI
39 select RESOURCES_64BIT if PCI
40 select SWAP_IO_SPACE
41 select SYS_HAS_CPU_MIPS32_R1
42 select SYS_SUPPORTS_LITTLE_ENDIAN
43
44config MIPS_PB1100
45 bool "AMD Alchemy PB1100 board"
46 select SOC_AU1100
47 select DMA_NONCOHERENT
48 select HW_HAS_PCI
49 select RESOURCES_64BIT if PCI
50 select SWAP_IO_SPACE
51 select SYS_HAS_CPU_MIPS32_R1
52 select SYS_SUPPORTS_LITTLE_ENDIAN
53
54config MIPS_PB1500
55 bool "AMD Alchemy PB1500 board"
56 select SOC_AU1500
57 select DMA_NONCOHERENT
58 select HW_HAS_PCI
59 select RESOURCES_64BIT if PCI
60 select SYS_HAS_CPU_MIPS32_R1
61 select SYS_SUPPORTS_LITTLE_ENDIAN
62
63config MIPS_PB1550
64 bool "AMD Alchemy PB1550 board"
65 select SOC_AU1550
66 select DMA_NONCOHERENT
67 select HW_HAS_PCI
68 select MIPS_DISABLE_OBSOLETE_IDE
69 select RESOURCES_64BIT if PCI
70 select SYS_HAS_CPU_MIPS32_R1
71 select SYS_SUPPORTS_LITTLE_ENDIAN
72
73config MIPS_PB1200
74 bool "AMD Alchemy PB1200 board"
75 select SOC_AU1200
76 select DMA_NONCOHERENT
77 select MIPS_DISABLE_OBSOLETE_IDE
78 select RESOURCES_64BIT if PCI
79 select SYS_HAS_CPU_MIPS32_R1
80 select SYS_SUPPORTS_LITTLE_ENDIAN
81
82config MIPS_DB1000
83 bool "AMD Alchemy DB1000 board"
84 select SOC_AU1000
85 select DMA_NONCOHERENT
86 select HW_HAS_PCI
87 select RESOURCES_64BIT if PCI
88 select SYS_HAS_CPU_MIPS32_R1
89 select SYS_SUPPORTS_LITTLE_ENDIAN
90
91config MIPS_DB1100
92 bool "AMD Alchemy DB1100 board"
93 select SOC_AU1100
94 select DMA_NONCOHERENT
95 select SYS_HAS_CPU_MIPS32_R1
96 select SYS_SUPPORTS_LITTLE_ENDIAN
97
98config MIPS_DB1500
99 bool "AMD Alchemy DB1500 board"
100 select SOC_AU1500
101 select DMA_NONCOHERENT
102 select HW_HAS_PCI
103 select MIPS_DISABLE_OBSOLETE_IDE
104 select RESOURCES_64BIT if PCI
105 select SYS_HAS_CPU_MIPS32_R1
106 select SYS_SUPPORTS_BIG_ENDIAN
107 select SYS_SUPPORTS_LITTLE_ENDIAN
108
109config MIPS_DB1550
110 bool "AMD Alchemy DB1550 board"
111 select SOC_AU1550
112 select HW_HAS_PCI
113 select DMA_NONCOHERENT
114 select MIPS_DISABLE_OBSOLETE_IDE
115 select RESOURCES_64BIT if PCI
116 select SYS_HAS_CPU_MIPS32_R1
117 select SYS_SUPPORTS_LITTLE_ENDIAN
118
119config MIPS_DB1200
120 bool "AMD Alchemy DB1200 board"
121 select SOC_AU1200
122 select DMA_COHERENT
123 select MIPS_DISABLE_OBSOLETE_IDE
124 select SYS_HAS_CPU_MIPS32_R1
125 select SYS_SUPPORTS_LITTLE_ENDIAN
126
127config MIPS_MIRAGE
128 bool "AMD Alchemy Mirage board"
129 select DMA_NONCOHERENT
130 select SOC_AU1500
131 select SYS_HAS_CPU_MIPS32_R1
132 select SYS_SUPPORTS_LITTLE_ENDIAN
133 20
134config BASLER_EXCITE 21config BASLER_EXCITE
135 bool "Basler eXcite smart camera" 22 bool "Basler eXcite smart camera"
@@ -369,28 +256,6 @@ config MIPS_SIM
369 This option enables support for MIPS Technologies MIPSsim software 256 This option enables support for MIPS Technologies MIPSsim software
370 emulator. 257 emulator.
371 258
372config MOMENCO_JAGUAR_ATX
373 bool "Momentum Jaguar board"
374 select BOOT_ELF32
375 select DMA_NONCOHERENT
376 select HW_HAS_PCI
377 select IRQ_CPU
378 select IRQ_CPU_RM7K
379 select IRQ_MV64340
380 select LIMITED_DMA
381 select PCI_MARVELL
382 select RM7000_CPU_SCACHE
383 select SWAP_IO_SPACE
384 select SYS_HAS_CPU_RM9000
385 select SYS_HAS_EARLY_PRINTK
386 select SYS_SUPPORTS_32BIT_KERNEL
387 select SYS_SUPPORTS_64BIT_KERNEL
388 select SYS_SUPPORTS_BIG_ENDIAN
389 select SYS_SUPPORTS_KGDB
390 help
391 The Jaguar ATX is a MIPS-based Single Board Computer (SBC) made by
392 Momentum Computer <http://www.momenco.com/>.
393
394config MOMENCO_OCELOT 259config MOMENCO_OCELOT
395 bool "Momentum Ocelot board" 260 bool "Momentum Ocelot board"
396 select DMA_NONCOHERENT 261 select DMA_NONCOHERENT
@@ -446,29 +311,6 @@ config MOMENCO_OCELOT_C
446 The Ocelot is a MIPS-based Single Board Computer (SBC) made by 311 The Ocelot is a MIPS-based Single Board Computer (SBC) made by
447 Momentum Computer <http://www.momenco.com/>. 312 Momentum Computer <http://www.momenco.com/>.
448 313
449config MOMENCO_OCELOT_G
450 bool "Momentum Ocelot-G board"
451 select DMA_NONCOHERENT
452 select HW_HAS_PCI
453 select IRQ_CPU
454 select IRQ_CPU_RM7K
455 select PCI_MARVELL
456 select RM7000_CPU_SCACHE
457 select SWAP_IO_SPACE
458 select SYS_HAS_CPU_RM7000
459 select SYS_SUPPORTS_32BIT_KERNEL
460 select SYS_SUPPORTS_64BIT_KERNEL if BROKEN
461 select SYS_SUPPORTS_BIG_ENDIAN
462 help
463 The Ocelot is a MIPS-based Single Board Computer (SBC) made by
464 Momentum Computer <http://www.momenco.com/>.
465
466config MIPS_XXS1500
467 bool "MyCable XXS1500 board"
468 select DMA_NONCOHERENT
469 select SOC_AU1500
470 select SYS_SUPPORTS_LITTLE_ENDIAN
471
472config PNX8550_JBS 314config PNX8550_JBS
473 bool "Philips PNX8550 based JBS board" 315 bool "Philips PNX8550 based JBS board"
474 select PNX8550 316 select PNX8550
@@ -775,7 +617,6 @@ config TOSHIBA_JMR3927
775 select SYS_SUPPORTS_32BIT_KERNEL 617 select SYS_SUPPORTS_32BIT_KERNEL
776 select SYS_SUPPORTS_LITTLE_ENDIAN 618 select SYS_SUPPORTS_LITTLE_ENDIAN
777 select SYS_SUPPORTS_BIG_ENDIAN 619 select SYS_SUPPORTS_BIG_ENDIAN
778 select TOSHIBA_BOARDS
779 select GENERIC_HARDIRQS_NO__DO_IRQ 620 select GENERIC_HARDIRQS_NO__DO_IRQ
780 621
781config TOSHIBA_RBTX4927 622config TOSHIBA_RBTX4927
@@ -791,7 +632,6 @@ config TOSHIBA_RBTX4927
791 select SYS_SUPPORTS_LITTLE_ENDIAN 632 select SYS_SUPPORTS_LITTLE_ENDIAN
792 select SYS_SUPPORTS_BIG_ENDIAN 633 select SYS_SUPPORTS_BIG_ENDIAN
793 select SYS_SUPPORTS_KGDB 634 select SYS_SUPPORTS_KGDB
794 select TOSHIBA_BOARDS
795 select GENERIC_HARDIRQS_NO__DO_IRQ 635 select GENERIC_HARDIRQS_NO__DO_IRQ
796 help 636 help
797 This Toshiba board is based on the TX4927 processor. Say Y here to 637 This Toshiba board is based on the TX4927 processor. Say Y here to
@@ -811,7 +651,6 @@ config TOSHIBA_RBTX4938
811 select SYS_SUPPORTS_LITTLE_ENDIAN 651 select SYS_SUPPORTS_LITTLE_ENDIAN
812 select SYS_SUPPORTS_BIG_ENDIAN 652 select SYS_SUPPORTS_BIG_ENDIAN
813 select SYS_SUPPORTS_KGDB 653 select SYS_SUPPORTS_KGDB
814 select TOSHIBA_BOARDS
815 select GENERIC_HARDIRQS_NO__DO_IRQ 654 select GENERIC_HARDIRQS_NO__DO_IRQ
816 help 655 help
817 This Toshiba board is based on the TX4938 processor. Say Y here to 656 This Toshiba board is based on the TX4938 processor. Say Y here to
@@ -819,11 +658,11 @@ config TOSHIBA_RBTX4938
819 658
820endchoice 659endchoice
821 660
661source "arch/mips/au1000/Kconfig"
822source "arch/mips/ddb5xxx/Kconfig" 662source "arch/mips/ddb5xxx/Kconfig"
823source "arch/mips/gt64120/ev64120/Kconfig" 663source "arch/mips/gt64120/ev64120/Kconfig"
824source "arch/mips/jazz/Kconfig" 664source "arch/mips/jazz/Kconfig"
825source "arch/mips/lasat/Kconfig" 665source "arch/mips/lasat/Kconfig"
826source "arch/mips/momentum/Kconfig"
827source "arch/mips/pmc-sierra/Kconfig" 666source "arch/mips/pmc-sierra/Kconfig"
828source "arch/mips/sgi-ip27/Kconfig" 667source "arch/mips/sgi-ip27/Kconfig"
829source "arch/mips/sibyte/Kconfig" 668source "arch/mips/sibyte/Kconfig"
@@ -923,11 +762,6 @@ config GENERIC_ISA_DMA
923config I8259 762config I8259
924 bool 763 bool
925 764
926config LIMITED_DMA
927 bool
928 select HIGHMEM
929 select SYS_SUPPORTS_HIGHMEM
930
931config MIPS_BONITO64 765config MIPS_BONITO64
932 bool 766 bool
933 767
@@ -1013,33 +847,6 @@ config MIPS_RM9122
1013config PCI_MARVELL 847config PCI_MARVELL
1014 bool 848 bool
1015 849
1016config SOC_AU1000
1017 bool
1018 select SOC_AU1X00
1019
1020config SOC_AU1100
1021 bool
1022 select SOC_AU1X00
1023
1024config SOC_AU1500
1025 bool
1026 select SOC_AU1X00
1027
1028config SOC_AU1550
1029 bool
1030 select SOC_AU1X00
1031
1032config SOC_AU1200
1033 bool
1034 select SOC_AU1X00
1035
1036config SOC_AU1X00
1037 bool
1038 select SYS_HAS_CPU_MIPS32_R1
1039 select SYS_SUPPORTS_32BIT_KERNEL
1040 select SYS_SUPPORTS_APM_EMULATION
1041 select SYS_SUPPORTS_KGDB
1042
1043config SERIAL_RM9000 850config SERIAL_RM9000
1044 bool 851 bool
1045 852
@@ -1081,9 +888,9 @@ config WDT_RM9000
1081choice 888choice
1082 prompt "Galileo Chip Clock" 889 prompt "Galileo Chip Clock"
1083 #default SYSCLK_83 if MIPS_EV64120 890 #default SYSCLK_83 if MIPS_EV64120
1084 depends on MIPS_EV64120 || MOMENCO_OCELOT || MOMENCO_OCELOT_G 891 depends on MIPS_EV64120 || MOMENCO_OCELOT
1085 default SYSCLK_83 if MIPS_EV64120 892 default SYSCLK_83 if MIPS_EV64120
1086 default SYSCLK_100 if MOMENCO_OCELOT || MOMENCO_OCELOT_G 893 default SYSCLK_100 if MOMENCO_OCELOT
1087 894
1088config SYSCLK_75 895config SYSCLK_75
1089 bool "75" if MIPS_EV64120 896 bool "75" if MIPS_EV64120
@@ -1092,7 +899,7 @@ config SYSCLK_83
1092 bool "83.3" if MIPS_EV64120 899 bool "83.3" if MIPS_EV64120
1093 900
1094config SYSCLK_100 901config SYSCLK_100
1095 bool "100" if MIPS_EV64120 || MOMENCO_OCELOT || MOMENCO_OCELOT_G 902 bool "100" if MIPS_EV64120 || MOMENCO_OCELOT
1096 903
1097endchoice 904endchoice
1098 905
@@ -1131,9 +938,6 @@ config ARC64
1131config BOOT_ELF64 938config BOOT_ELF64
1132 bool 939 bool
1133 940
1134config TOSHIBA_BOARDS
1135 bool
1136
1137menu "CPU selection" 941menu "CPU selection"
1138 942
1139choice 943choice
@@ -1557,6 +1361,7 @@ config MIPS_MT_SMP
1557 bool "Use 1 TC on each available VPE for SMP" 1361 bool "Use 1 TC on each available VPE for SMP"
1558 depends on SYS_SUPPORTS_MULTITHREADING 1362 depends on SYS_SUPPORTS_MULTITHREADING
1559 select CPU_MIPSR2_IRQ_VI 1363 select CPU_MIPSR2_IRQ_VI
1364 select CPU_MIPSR2_IRQ_EI
1560 select CPU_MIPSR2_SRS 1365 select CPU_MIPSR2_SRS
1561 select MIPS_MT 1366 select MIPS_MT
1562 select NR_CPUS_DEFAULT_2 1367 select NR_CPUS_DEFAULT_2
@@ -1572,6 +1377,7 @@ config MIPS_MT_SMTC
1572 #depends on CPU_MIPS64_R2 # once there is hardware ... 1377 #depends on CPU_MIPS64_R2 # once there is hardware ...
1573 depends on SYS_SUPPORTS_MULTITHREADING 1378 depends on SYS_SUPPORTS_MULTITHREADING
1574 select CPU_MIPSR2_IRQ_VI 1379 select CPU_MIPSR2_IRQ_VI
1380 select CPU_MIPSR2_IRQ_EI
1575 select CPU_MIPSR2_SRS 1381 select CPU_MIPSR2_SRS
1576 select MIPS_MT 1382 select MIPS_MT
1577 select NR_CPUS_DEFAULT_8 1383 select NR_CPUS_DEFAULT_8
@@ -1584,6 +1390,8 @@ config MIPS_MT_SMTC
1584config MIPS_VPE_LOADER 1390config MIPS_VPE_LOADER
1585 bool "VPE loader support." 1391 bool "VPE loader support."
1586 depends on SYS_SUPPORTS_MULTITHREADING 1392 depends on SYS_SUPPORTS_MULTITHREADING
1393 select CPU_MIPSR2_IRQ_VI
1394 select CPU_MIPSR2_IRQ_EI
1587 select MIPS_MT 1395 select MIPS_MT
1588 help 1396 help
1589 Includes a loader for loading an elf relocatable object 1397 Includes a loader for loading an elf relocatable object
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 4892db88a86a..f450066b6241 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -343,15 +343,6 @@ cflags-$(CONFIG_MOMENCO_OCELOT) += -Iinclude/asm-mips/mach-ocelot
343load-$(CONFIG_MOMENCO_OCELOT) += 0xffffffff80100000 343load-$(CONFIG_MOMENCO_OCELOT) += 0xffffffff80100000
344 344
345# 345#
346# Momentum Ocelot-G board
347#
348# The Ocelot-G setup.o must be linked early - it does the ioremap() for the
349# mips_io_port_base.
350#
351core-$(CONFIG_MOMENCO_OCELOT_G) += arch/mips/momentum/ocelot_g/
352load-$(CONFIG_MOMENCO_OCELOT_G) += 0xffffffff80100000
353
354#
355# Momentum Ocelot-C and -CS boards 346# Momentum Ocelot-C and -CS boards
356# 347#
357# The Ocelot-C[S] setup.o must be linked early - it does the ioremap() for the 348# The Ocelot-C[S] setup.o must be linked early - it does the ioremap() for the
@@ -388,17 +379,6 @@ cflags-$(CONFIG_BASLER_EXCITE) += -Iinclude/asm-mips/mach-excite
388load-$(CONFIG_BASLER_EXCITE) += 0x80100000 379load-$(CONFIG_BASLER_EXCITE) += 0x80100000
389 380
390# 381#
391# Momentum Jaguar ATX
392#
393core-$(CONFIG_MOMENCO_JAGUAR_ATX) += arch/mips/momentum/jaguar_atx/
394cflags-$(CONFIG_MOMENCO_JAGUAR_ATX) += -Iinclude/asm-mips/mach-ja
395#ifdef CONFIG_JAGUAR_DMALOW
396#load-$(CONFIG_MOMENCO_JAGUAR_ATX) += 0xffffffff88000000
397#else
398load-$(CONFIG_MOMENCO_JAGUAR_ATX) += 0xffffffff80100000
399#endif
400
401#
402# NEC DDB 382# NEC DDB
403# 383#
404core-$(CONFIG_DDB5XXX_COMMON) += arch/mips/ddb5xxx/common/ 384core-$(CONFIG_DDB5XXX_COMMON) += arch/mips/ddb5xxx/common/
@@ -729,3 +709,25 @@ archclean:
729CLEAN_FILES += vmlinux.32 \ 709CLEAN_FILES += vmlinux.32 \
730 vmlinux.64 \ 710 vmlinux.64 \
731 vmlinux.ecoff 711 vmlinux.ecoff
712
713quiet_cmd_syscalls_n32 = CALL-N32 $<
714 cmd_syscalls_n32 = $(CONFIG_SHELL) $< $(CC) $(c_flags) -mabi=n32
715
716quiet_cmd_syscalls_o32 = CALL-O32 $<
717 cmd_syscalls_o32 = $(CONFIG_SHELL) $< $(CC) $(c_flags) -mabi=32
718
719PHONY += missing-syscalls-n32 missing-syscalls-o32
720
721missing-syscalls-n32: scripts/checksyscalls.sh FORCE
722 $(call cmd,syscalls_n32)
723
724missing-syscalls-o32: scripts/checksyscalls.sh FORCE
725 $(call cmd,syscalls_o32)
726
727archprepare:
728ifdef CONFIG_MIPS32_N32
729 $(Q)$(MAKE) $(build)=arch/mips missing-syscalls-n32
730endif
731ifdef CONFIG_MIPS32_O32
732 $(Q)$(MAKE) $(build)=arch/mips missing-syscalls-o32
733endif
diff --git a/arch/mips/au1000/Kconfig b/arch/mips/au1000/Kconfig
new file mode 100644
index 000000000000..abea88098253
--- /dev/null
+++ b/arch/mips/au1000/Kconfig
@@ -0,0 +1,142 @@
1choice
2 prompt "Machine type"
3 depends on MACH_ALCHEMY
4 default MIPS_DB1000
5
6config MIPS_MTX1
7 bool "4G Systems MTX-1 board"
8 select DMA_NONCOHERENT
9 select HW_HAS_PCI
10 select RESOURCES_64BIT if PCI
11 select SOC_AU1500
12 select SYS_SUPPORTS_LITTLE_ENDIAN
13
14config MIPS_BOSPORUS
15 bool "Alchemy Bosporus board"
16 select SOC_AU1500
17 select DMA_NONCOHERENT
18 select SYS_SUPPORTS_LITTLE_ENDIAN
19
20config MIPS_DB1000
21 bool "Alchemy DB1000 board"
22 select SOC_AU1000
23 select DMA_NONCOHERENT
24 select HW_HAS_PCI
25 select RESOURCES_64BIT if PCI
26 select SYS_SUPPORTS_LITTLE_ENDIAN
27
28config MIPS_DB1100
29 bool "Alchemy DB1100 board"
30 select SOC_AU1100
31 select DMA_NONCOHERENT
32 select SYS_SUPPORTS_LITTLE_ENDIAN
33
34config MIPS_DB1200
35 bool "Alchemy DB1200 board"
36 select SOC_AU1200
37 select DMA_COHERENT
38 select MIPS_DISABLE_OBSOLETE_IDE
39 select SYS_SUPPORTS_LITTLE_ENDIAN
40
41config MIPS_DB1500
42 bool "Alchemy DB1500 board"
43 select SOC_AU1500
44 select DMA_NONCOHERENT
45 select HW_HAS_PCI
46 select MIPS_DISABLE_OBSOLETE_IDE
47 select RESOURCES_64BIT if PCI
48 select SYS_SUPPORTS_BIG_ENDIAN
49 select SYS_SUPPORTS_LITTLE_ENDIAN
50
51config MIPS_DB1550
52 bool "Alchemy DB1550 board"
53 select SOC_AU1550
54 select HW_HAS_PCI
55 select DMA_NONCOHERENT
56 select MIPS_DISABLE_OBSOLETE_IDE
57 select RESOURCES_64BIT if PCI
58 select SYS_SUPPORTS_LITTLE_ENDIAN
59
60config MIPS_MIRAGE
61 bool "Alchemy Mirage board"
62 select DMA_NONCOHERENT
63 select SOC_AU1500
64 select SYS_SUPPORTS_LITTLE_ENDIAN
65
66config MIPS_PB1000
67 bool "Alchemy PB1000 board"
68 select SOC_AU1000
69 select DMA_NONCOHERENT
70 select HW_HAS_PCI
71 select RESOURCES_64BIT if PCI
72 select SWAP_IO_SPACE
73 select SYS_SUPPORTS_LITTLE_ENDIAN
74
75config MIPS_PB1100
76 bool "Alchemy PB1100 board"
77 select SOC_AU1100
78 select DMA_NONCOHERENT
79 select HW_HAS_PCI
80 select RESOURCES_64BIT if PCI
81 select SWAP_IO_SPACE
82 select SYS_SUPPORTS_LITTLE_ENDIAN
83
84config MIPS_PB1200
85 bool "Alchemy PB1200 board"
86 select SOC_AU1200
87 select DMA_NONCOHERENT
88 select MIPS_DISABLE_OBSOLETE_IDE
89 select RESOURCES_64BIT if PCI
90 select SYS_SUPPORTS_LITTLE_ENDIAN
91
92config MIPS_PB1500
93 bool "Alchemy PB1500 board"
94 select SOC_AU1500
95 select DMA_NONCOHERENT
96 select HW_HAS_PCI
97 select RESOURCES_64BIT if PCI
98 select SYS_SUPPORTS_LITTLE_ENDIAN
99
100config MIPS_PB1550
101 bool "Alchemy PB1550 board"
102 select SOC_AU1550
103 select DMA_NONCOHERENT
104 select HW_HAS_PCI
105 select MIPS_DISABLE_OBSOLETE_IDE
106 select RESOURCES_64BIT if PCI
107 select SYS_SUPPORTS_LITTLE_ENDIAN
108
109config MIPS_XXS1500
110 bool "MyCable XXS1500 board"
111 select DMA_NONCOHERENT
112 select SOC_AU1500
113 select SYS_SUPPORTS_LITTLE_ENDIAN
114
115endchoice
116
117config SOC_AU1000
118 bool
119 select SOC_AU1X00
120
121config SOC_AU1100
122 bool
123 select SOC_AU1X00
124
125config SOC_AU1500
126 bool
127 select SOC_AU1X00
128
129config SOC_AU1550
130 bool
131 select SOC_AU1X00
132
133config SOC_AU1200
134 bool
135 select SOC_AU1X00
136
137config SOC_AU1X00
138 bool
139 select SYS_HAS_CPU_MIPS32_R1
140 select SYS_SUPPORTS_32BIT_KERNEL
141 select SYS_SUPPORTS_APM_EMULATION
142 select SYS_SUPPORTS_KGDB
diff --git a/arch/mips/basler/excite/excite_device.c b/arch/mips/basler/excite/excite_device.c
index cc1ce77eab4a..e00bc2d7f301 100644
--- a/arch/mips/basler/excite/excite_device.c
+++ b/arch/mips/basler/excite/excite_device.c
@@ -68,7 +68,7 @@ enum {
68 68
69 69
70static struct resource 70static struct resource
71 excite_ctr_resource __attribute__((unused)) = { 71 excite_ctr_resource __maybe_unused = {
72 .name = "GPI counters", 72 .name = "GPI counters",
73 .start = 0, 73 .start = 0,
74 .end = 5, 74 .end = 5,
@@ -77,7 +77,7 @@ static struct resource
77 .sibling = NULL, 77 .sibling = NULL,
78 .child = NULL 78 .child = NULL
79 }, 79 },
80 excite_gpislice_resource __attribute__((unused)) = { 80 excite_gpislice_resource __maybe_unused = {
81 .name = "GPI slices", 81 .name = "GPI slices",
82 .start = 0, 82 .start = 0,
83 .end = 1, 83 .end = 1,
@@ -86,7 +86,7 @@ static struct resource
86 .sibling = NULL, 86 .sibling = NULL,
87 .child = NULL 87 .child = NULL
88 }, 88 },
89 excite_mdio_channel_resource __attribute__((unused)) = { 89 excite_mdio_channel_resource __maybe_unused = {
90 .name = "MDIO channels", 90 .name = "MDIO channels",
91 .start = 0, 91 .start = 0,
92 .end = 1, 92 .end = 1,
@@ -95,7 +95,7 @@ static struct resource
95 .sibling = NULL, 95 .sibling = NULL,
96 .child = NULL 96 .child = NULL
97 }, 97 },
98 excite_fifomem_resource __attribute__((unused)) = { 98 excite_fifomem_resource __maybe_unused = {
99 .name = "FIFO memory", 99 .name = "FIFO memory",
100 .start = 0, 100 .start = 0,
101 .end = 767, 101 .end = 767,
@@ -104,7 +104,7 @@ static struct resource
104 .sibling = NULL, 104 .sibling = NULL,
105 .child = NULL 105 .child = NULL
106 }, 106 },
107 excite_scram_resource __attribute__((unused)) = { 107 excite_scram_resource __maybe_unused = {
108 .name = "Scratch RAM", 108 .name = "Scratch RAM",
109 .start = EXCITE_PHYS_SCRAM, 109 .start = EXCITE_PHYS_SCRAM,
110 .end = EXCITE_PHYS_SCRAM + EXCITE_SIZE_SCRAM - 1, 110 .end = EXCITE_PHYS_SCRAM + EXCITE_SIZE_SCRAM - 1,
@@ -113,7 +113,7 @@ static struct resource
113 .sibling = NULL, 113 .sibling = NULL,
114 .child = NULL 114 .child = NULL
115 }, 115 },
116 excite_fpga_resource __attribute__((unused)) = { 116 excite_fpga_resource __maybe_unused = {
117 .name = "System FPGA", 117 .name = "System FPGA",
118 .start = EXCITE_PHYS_FPGA, 118 .start = EXCITE_PHYS_FPGA,
119 .end = EXCITE_PHYS_FPGA + EXCITE_SIZE_FPGA - 1, 119 .end = EXCITE_PHYS_FPGA + EXCITE_SIZE_FPGA - 1,
@@ -122,7 +122,7 @@ static struct resource
122 .sibling = NULL, 122 .sibling = NULL,
123 .child = NULL 123 .child = NULL
124 }, 124 },
125 excite_nand_resource __attribute__((unused)) = { 125 excite_nand_resource __maybe_unused = {
126 .name = "NAND flash control", 126 .name = "NAND flash control",
127 .start = EXCITE_PHYS_NAND, 127 .start = EXCITE_PHYS_NAND,
128 .end = EXCITE_PHYS_NAND + EXCITE_SIZE_NAND - 1, 128 .end = EXCITE_PHYS_NAND + EXCITE_SIZE_NAND - 1,
@@ -131,7 +131,7 @@ static struct resource
131 .sibling = NULL, 131 .sibling = NULL,
132 .child = NULL 132 .child = NULL
133 }, 133 },
134 excite_titan_resource __attribute__((unused)) = { 134 excite_titan_resource __maybe_unused = {
135 .name = "TITAN registers", 135 .name = "TITAN registers",
136 .start = EXCITE_PHYS_TITAN, 136 .start = EXCITE_PHYS_TITAN,
137 .end = EXCITE_PHYS_TITAN + EXCITE_SIZE_TITAN - 1, 137 .end = EXCITE_PHYS_TITAN + EXCITE_SIZE_TITAN - 1,
diff --git a/arch/mips/cobalt/Makefile b/arch/mips/cobalt/Makefile
index 9565b2104dcd..c292f80a8c74 100644
--- a/arch/mips/cobalt/Makefile
+++ b/arch/mips/cobalt/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the Cobalt micro systems family specific parts of the kernel 2# Makefile for the Cobalt micro systems family specific parts of the kernel
3# 3#
4 4
5obj-y := irq.o reset.o setup.o buttons.o 5obj-y := buttons.o irq.o reset.o rtc.o serial.o setup.o
6 6
7obj-$(CONFIG_PCI) += pci.o 7obj-$(CONFIG_PCI) += pci.o
8obj-$(CONFIG_EARLY_PRINTK) += console.o 8obj-$(CONFIG_EARLY_PRINTK) += console.o
diff --git a/arch/mips/cobalt/rtc.c b/arch/mips/cobalt/rtc.c
new file mode 100644
index 000000000000..284daefc5c55
--- /dev/null
+++ b/arch/mips/cobalt/rtc.c
@@ -0,0 +1,63 @@
1/*
2 * Registration of Cobalt RTC platform device.
3 *
4 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#include <linux/errno.h>
21#include <linux/init.h>
22#include <linux/ioport.h>
23#include <linux/platform_device.h>
24
25static struct resource cobalt_rtc_resource[] __initdata = {
26 {
27 .start = 0x70,
28 .end = 0x77,
29 .flags = IORESOURCE_IO,
30 },
31 {
32 .start = 8,
33 .end = 8,
34 .flags = IORESOURCE_IRQ,
35 },
36};
37
38static __init int cobalt_rtc_add(void)
39{
40 struct platform_device *pdev;
41 int retval;
42
43 pdev = platform_device_alloc("rtc_cmos", -1);
44 if (!pdev)
45 return -ENOMEM;
46
47 retval = platform_device_add_resources(pdev, cobalt_rtc_resource,
48 ARRAY_SIZE(cobalt_rtc_resource));
49 if (retval)
50 goto err_free_device;
51
52 retval = platform_device_add(pdev);
53 if (retval)
54 goto err_free_device;
55
56 return 0;
57
58err_free_device:
59 platform_device_put(pdev);
60
61 return retval;
62}
63device_initcall(cobalt_rtc_add);
diff --git a/arch/mips/cobalt/serial.c b/arch/mips/cobalt/serial.c
new file mode 100644
index 000000000000..c27116599a5f
--- /dev/null
+++ b/arch/mips/cobalt/serial.c
@@ -0,0 +1,85 @@
1/*
2 * Registration of Cobalt UART platform device.
3 *
4 * Copyright (C) 2007 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#include <linux/errno.h>
21#include <linux/init.h>
22#include <linux/ioport.h>
23#include <linux/platform_device.h>
24#include <linux/serial_8250.h>
25
26#include <cobalt.h>
27
28static struct resource cobalt_uart_resource[] __initdata = {
29 {
30 .start = 0x1c800000,
31 .end = 0x1c800007,
32 .flags = IORESOURCE_MEM,
33 },
34 {
35 .start = COBALT_SERIAL_IRQ,
36 .end = COBALT_SERIAL_IRQ,
37 .flags = IORESOURCE_IRQ,
38 },
39};
40
41static struct plat_serial8250_port cobalt_serial8250_port[] = {
42 {
43 .irq = COBALT_SERIAL_IRQ,
44 .uartclk = 18432000,
45 .iotype = UPIO_MEM,
46 .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
47 .mapbase = 0x1c800000,
48 },
49 {},
50};
51
52static __init int cobalt_uart_add(void)
53{
54 struct platform_device *pdev;
55 int retval;
56
57 /*
58 * Cobalt Qube1 and RAQ1 have no UART.
59 */
60 if (cobalt_board_id <= COBALT_BRD_ID_RAQ1)
61 return 0;
62
63 pdev = platform_device_alloc("serial8250", -1);
64 if (!pdev)
65 return -ENOMEM;
66
67 pdev->id = PLAT8250_DEV_PLATFORM;
68 pdev->dev.platform_data = cobalt_serial8250_port;
69
70 retval = platform_device_add_resources(pdev, cobalt_uart_resource, ARRAY_SIZE(cobalt_uart_resource));
71 if (retval)
72 goto err_free_device;
73
74 retval = platform_device_add(pdev);
75 if (retval)
76 goto err_free_device;
77
78 return 0;
79
80err_free_device:
81 platform_device_put(pdev);
82
83 return retval;
84}
85device_initcall(cobalt_uart_add);
diff --git a/arch/mips/cobalt/setup.c b/arch/mips/cobalt/setup.c
index d0dd81790f74..7abe45e78425 100644
--- a/arch/mips/cobalt/setup.c
+++ b/arch/mips/cobalt/setup.c
@@ -10,11 +10,8 @@
10 * 10 *
11 */ 11 */
12#include <linux/interrupt.h> 12#include <linux/interrupt.h>
13#include <linux/pci.h>
14#include <linux/init.h> 13#include <linux/init.h>
15#include <linux/pm.h> 14#include <linux/pm.h>
16#include <linux/serial.h>
17#include <linux/serial_core.h>
18 15
19#include <asm/bootinfo.h> 16#include <asm/bootinfo.h>
20#include <asm/time.h> 17#include <asm/time.h>
@@ -27,9 +24,6 @@
27extern void cobalt_machine_restart(char *command); 24extern void cobalt_machine_restart(char *command);
28extern void cobalt_machine_halt(void); 25extern void cobalt_machine_halt(void);
29extern void cobalt_machine_power_off(void); 26extern void cobalt_machine_power_off(void);
30extern void cobalt_early_console(void);
31
32int cobalt_board_id;
33 27
34const char *get_system_type(void) 28const char *get_system_type(void)
35{ 29{
@@ -95,8 +89,6 @@ static struct resource cobalt_reserved_resources[] = {
95 89
96void __init plat_mem_setup(void) 90void __init plat_mem_setup(void)
97{ 91{
98 static struct uart_port uart;
99 unsigned int devfn = PCI_DEVFN(COBALT_PCICONF_VIA, 0);
100 int i; 92 int i;
101 93
102 _machine_restart = cobalt_machine_restart; 94 _machine_restart = cobalt_machine_restart;
@@ -111,29 +103,6 @@ void __init plat_mem_setup(void)
111 /* These resources have been reserved by VIA SuperI/O chip. */ 103 /* These resources have been reserved by VIA SuperI/O chip. */
112 for (i = 0; i < ARRAY_SIZE(cobalt_reserved_resources); i++) 104 for (i = 0; i < ARRAY_SIZE(cobalt_reserved_resources); i++)
113 request_resource(&ioport_resource, cobalt_reserved_resources + i); 105 request_resource(&ioport_resource, cobalt_reserved_resources + i);
114
115 /* Read the cobalt id register out of the PCI config space */
116 PCI_CFG_SET(devfn, (VIA_COBALT_BRD_ID_REG & ~0x3));
117 cobalt_board_id = GT_READ(GT_PCI0_CFGDATA_OFS);
118 cobalt_board_id >>= ((VIA_COBALT_BRD_ID_REG & 3) * 8);
119 cobalt_board_id = VIA_COBALT_BRD_REG_to_ID(cobalt_board_id);
120
121 printk("Cobalt board ID: %d\n", cobalt_board_id);
122
123 if (cobalt_board_id > COBALT_BRD_ID_RAQ1) {
124#ifdef CONFIG_SERIAL_8250
125 uart.line = 0;
126 uart.type = PORT_UNKNOWN;
127 uart.uartclk = 18432000;
128 uart.irq = COBALT_SERIAL_IRQ;
129 uart.flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF |
130 UPF_SKIP_TEST;
131 uart.iotype = UPIO_MEM;
132 uart.mapbase = 0x1c800000;
133
134 early_serial_setup(&uart);
135#endif
136 }
137} 106}
138 107
139/* 108/*
diff --git a/arch/mips/configs/cobalt_defconfig b/arch/mips/configs/cobalt_defconfig
index ba593b510b76..631b2138ad68 100644
--- a/arch/mips/configs/cobalt_defconfig
+++ b/arch/mips/configs/cobalt_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.20 3# Linux kernel version: 2.6.21-rc7
4# Tue Feb 20 21:47:24 2007 4# Wed Apr 18 14:25:45 2007
5# 5#
6CONFIG_MIPS=y 6CONFIG_MIPS=y
7 7
@@ -62,7 +62,6 @@ CONFIG_MIPS_COBALT=y
62# CONFIG_TOSHIBA_JMR3927 is not set 62# CONFIG_TOSHIBA_JMR3927 is not set
63# CONFIG_TOSHIBA_RBTX4927 is not set 63# CONFIG_TOSHIBA_RBTX4927 is not set
64# CONFIG_TOSHIBA_RBTX4938 is not set 64# CONFIG_TOSHIBA_RBTX4938 is not set
65CONFIG_EARLY_PRINTK=y
66CONFIG_RWSEM_GENERIC_SPINLOCK=y 65CONFIG_RWSEM_GENERIC_SPINLOCK=y
67# CONFIG_ARCH_HAS_ILOG2_U32 is not set 66# CONFIG_ARCH_HAS_ILOG2_U32 is not set
68# CONFIG_ARCH_HAS_ILOG2_U64 is not set 67# CONFIG_ARCH_HAS_ILOG2_U64 is not set
@@ -74,12 +73,14 @@ CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
74CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y 73CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
75CONFIG_DMA_NONCOHERENT=y 74CONFIG_DMA_NONCOHERENT=y
76CONFIG_DMA_NEED_PCI_MAP_STATE=y 75CONFIG_DMA_NEED_PCI_MAP_STATE=y
76CONFIG_EARLY_PRINTK=y
77CONFIG_SYS_HAS_EARLY_PRINTK=y
77CONFIG_I8259=y 78CONFIG_I8259=y
78# CONFIG_CPU_BIG_ENDIAN is not set 79# CONFIG_CPU_BIG_ENDIAN is not set
79CONFIG_CPU_LITTLE_ENDIAN=y 80CONFIG_CPU_LITTLE_ENDIAN=y
80CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y 81CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
81CONFIG_IRQ_CPU=y 82CONFIG_IRQ_CPU=y
82CONFIG_MIPS_GT64111=y 83CONFIG_PCI_GT64XXX_PCI0=y
83CONFIG_MIPS_L1_CACHE_SHIFT=5 84CONFIG_MIPS_L1_CACHE_SHIFT=5
84 85
85# 86#
@@ -179,6 +180,7 @@ CONFIG_SYSVIPC_SYSCTL=y
179# CONFIG_IKCONFIG is not set 180# CONFIG_IKCONFIG is not set
180CONFIG_SYSFS_DEPRECATED=y 181CONFIG_SYSFS_DEPRECATED=y
181CONFIG_RELAY=y 182CONFIG_RELAY=y
183# CONFIG_BLK_DEV_INITRD is not set
182# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 184# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
183CONFIG_SYSCTL=y 185CONFIG_SYSCTL=y
184CONFIG_EMBEDDED=y 186CONFIG_EMBEDDED=y
@@ -477,7 +479,6 @@ CONFIG_BLK_DEV_LOOP=y
477# CONFIG_BLK_DEV_NBD is not set 479# CONFIG_BLK_DEV_NBD is not set
478# CONFIG_BLK_DEV_SX8 is not set 480# CONFIG_BLK_DEV_SX8 is not set
479# CONFIG_BLK_DEV_RAM is not set 481# CONFIG_BLK_DEV_RAM is not set
480# CONFIG_BLK_DEV_INITRD is not set
481CONFIG_CDROM_PKTCDVD=y 482CONFIG_CDROM_PKTCDVD=y
482CONFIG_CDROM_PKTCDVD_BUFFERS=8 483CONFIG_CDROM_PKTCDVD_BUFFERS=8
483# CONFIG_CDROM_PKTCDVD_WCACHE is not set 484# CONFIG_CDROM_PKTCDVD_WCACHE is not set
@@ -518,7 +519,7 @@ CONFIG_BLK_DEV_IDEPCI=y
518# CONFIG_BLK_DEV_OPTI621 is not set 519# CONFIG_BLK_DEV_OPTI621 is not set
519CONFIG_BLK_DEV_IDEDMA_PCI=y 520CONFIG_BLK_DEV_IDEDMA_PCI=y
520# CONFIG_BLK_DEV_IDEDMA_FORCED is not set 521# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
521# CONFIG_IDEDMA_PCI_AUTO is not set 522# CONFIG_IDEDMA_ONLYDISK is not set
522# CONFIG_BLK_DEV_AEC62XX is not set 523# CONFIG_BLK_DEV_AEC62XX is not set
523# CONFIG_BLK_DEV_ALI15X3 is not set 524# CONFIG_BLK_DEV_ALI15X3 is not set
524# CONFIG_BLK_DEV_AMD74XX is not set 525# CONFIG_BLK_DEV_AMD74XX is not set
@@ -546,7 +547,6 @@ CONFIG_BLK_DEV_TC86C001=y
546# CONFIG_IDE_ARM is not set 547# CONFIG_IDE_ARM is not set
547CONFIG_BLK_DEV_IDEDMA=y 548CONFIG_BLK_DEV_IDEDMA=y
548# CONFIG_IDEDMA_IVB is not set 549# CONFIG_IDEDMA_IVB is not set
549# CONFIG_IDEDMA_AUTO is not set
550# CONFIG_BLK_DEV_HD is not set 550# CONFIG_BLK_DEV_HD is not set
551 551
552# 552#
@@ -779,7 +779,8 @@ CONFIG_LEGACY_PTY_COUNT=256
779# 779#
780# CONFIG_WATCHDOG is not set 780# CONFIG_WATCHDOG is not set
781# CONFIG_HW_RANDOM is not set 781# CONFIG_HW_RANDOM is not set
782CONFIG_RTC=y 782# CONFIG_RTC is not set
783# CONFIG_GEN_RTC is not set
783CONFIG_COBALT_LCD=y 784CONFIG_COBALT_LCD=y
784# CONFIG_DTLK is not set 785# CONFIG_DTLK is not set
785# CONFIG_R3964 is not set 786# CONFIG_R3964 is not set
@@ -815,6 +816,11 @@ CONFIG_COBALT_LCD=y
815# CONFIG_HWMON_VID is not set 816# CONFIG_HWMON_VID is not set
816 817
817# 818#
819# Multifunction device drivers
820#
821# CONFIG_MFD_SM501 is not set
822
823#
818# Multimedia devices 824# Multimedia devices
819# 825#
820# CONFIG_VIDEO_DEV is not set 826# CONFIG_VIDEO_DEV is not set
@@ -827,7 +833,7 @@ CONFIG_COBALT_LCD=y
827# 833#
828# Graphics support 834# Graphics support
829# 835#
830# CONFIG_FIRMWARE_EDID is not set 836# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
831# CONFIG_FB is not set 837# CONFIG_FB is not set
832 838
833# 839#
@@ -835,7 +841,6 @@ CONFIG_COBALT_LCD=y
835# 841#
836# CONFIG_VGA_CONSOLE is not set 842# CONFIG_VGA_CONSOLE is not set
837CONFIG_DUMMY_CONSOLE=y 843CONFIG_DUMMY_CONSOLE=y
838# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
839 844
840# 845#
841# Sound 846# Sound
@@ -894,7 +899,29 @@ CONFIG_USB_ARCH_HAS_EHCI=y
894# 899#
895# Real Time Clock 900# Real Time Clock
896# 901#
897# CONFIG_RTC_CLASS is not set 902CONFIG_RTC_LIB=y
903CONFIG_RTC_CLASS=y
904CONFIG_RTC_HCTOSYS=y
905CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
906# CONFIG_RTC_DEBUG is not set
907
908#
909# RTC interfaces
910#
911CONFIG_RTC_INTF_SYSFS=y
912CONFIG_RTC_INTF_PROC=y
913CONFIG_RTC_INTF_DEV=y
914# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
915
916#
917# RTC drivers
918#
919CONFIG_RTC_DRV_CMOS=y
920# CONFIG_RTC_DRV_DS1553 is not set
921# CONFIG_RTC_DRV_DS1742 is not set
922# CONFIG_RTC_DRV_M48T86 is not set
923# CONFIG_RTC_DRV_TEST is not set
924# CONFIG_RTC_DRV_V3020 is not set
898 925
899# 926#
900# DMA Engine support 927# DMA Engine support
diff --git a/arch/mips/configs/db1000_defconfig b/arch/mips/configs/db1000_defconfig
index 0db6a8b37301..10f6af43753d 100644
--- a/arch/mips/configs/db1000_defconfig
+++ b/arch/mips/configs/db1000_defconfig
@@ -9,6 +9,7 @@ CONFIG_MIPS=y
9# Machine selection 9# Machine selection
10# 10#
11CONFIG_ZONE_DMA=y 11CONFIG_ZONE_DMA=y
12CONFIG_MACH_ALCHEMY=y
12# CONFIG_MIPS_MTX1 is not set 13# CONFIG_MIPS_MTX1 is not set
13# CONFIG_MIPS_BOSPORUS is not set 14# CONFIG_MIPS_BOSPORUS is not set
14# CONFIG_MIPS_PB1000 is not set 15# CONFIG_MIPS_PB1000 is not set
diff --git a/arch/mips/configs/db1100_defconfig b/arch/mips/configs/db1100_defconfig
index 162add97c5ef..4b0862927748 100644
--- a/arch/mips/configs/db1100_defconfig
+++ b/arch/mips/configs/db1100_defconfig
@@ -9,6 +9,7 @@ CONFIG_MIPS=y
9# Machine selection 9# Machine selection
10# 10#
11CONFIG_ZONE_DMA=y 11CONFIG_ZONE_DMA=y
12CONFIG_MACH_ALCHEMY=y
12# CONFIG_MIPS_MTX1 is not set 13# CONFIG_MIPS_MTX1 is not set
13# CONFIG_MIPS_BOSPORUS is not set 14# CONFIG_MIPS_BOSPORUS is not set
14# CONFIG_MIPS_PB1000 is not set 15# CONFIG_MIPS_PB1000 is not set
diff --git a/arch/mips/configs/db1200_defconfig b/arch/mips/configs/db1200_defconfig
index 82801ec43e6a..820659e810dc 100644
--- a/arch/mips/configs/db1200_defconfig
+++ b/arch/mips/configs/db1200_defconfig
@@ -9,6 +9,7 @@ CONFIG_MIPS=y
9# Machine selection 9# Machine selection
10# 10#
11CONFIG_ZONE_DMA=y 11CONFIG_ZONE_DMA=y
12CONFIG_MACH_ALCHEMY=y
12# CONFIG_MIPS_MTX1 is not set 13# CONFIG_MIPS_MTX1 is not set
13# CONFIG_MIPS_BOSPORUS is not set 14# CONFIG_MIPS_BOSPORUS is not set
14# CONFIG_MIPS_PB1000 is not set 15# CONFIG_MIPS_PB1000 is not set
diff --git a/arch/mips/configs/db1500_defconfig b/arch/mips/configs/db1500_defconfig
index 545f23094e13..4050b9b91bcb 100644
--- a/arch/mips/configs/db1500_defconfig
+++ b/arch/mips/configs/db1500_defconfig
@@ -9,6 +9,7 @@ CONFIG_MIPS=y
9# Machine selection 9# Machine selection
10# 10#
11CONFIG_ZONE_DMA=y 11CONFIG_ZONE_DMA=y
12CONFIG_MACH_ALCHEMY=y
12# CONFIG_MIPS_MTX1 is not set 13# CONFIG_MIPS_MTX1 is not set
13# CONFIG_MIPS_BOSPORUS is not set 14# CONFIG_MIPS_BOSPORUS is not set
14# CONFIG_MIPS_PB1000 is not set 15# CONFIG_MIPS_PB1000 is not set
diff --git a/arch/mips/configs/db1550_defconfig b/arch/mips/configs/db1550_defconfig
index 5bd3b4328e57..7b3519058ab8 100644
--- a/arch/mips/configs/db1550_defconfig
+++ b/arch/mips/configs/db1550_defconfig
@@ -9,6 +9,7 @@ CONFIG_MIPS=y
9# Machine selection 9# Machine selection
10# 10#
11CONFIG_ZONE_DMA=y 11CONFIG_ZONE_DMA=y
12CONFIG_MACH_ALCHEMY=y
12# CONFIG_MIPS_MTX1 is not set 13# CONFIG_MIPS_MTX1 is not set
13# CONFIG_MIPS_BOSPORUS is not set 14# CONFIG_MIPS_BOSPORUS is not set
14# CONFIG_MIPS_PB1000 is not set 15# CONFIG_MIPS_PB1000 is not set
diff --git a/arch/mips/configs/jaguar-atx_defconfig b/arch/mips/configs/jaguar-atx_defconfig
deleted file mode 100644
index 083104daa2ca..000000000000
--- a/arch/mips/configs/jaguar-atx_defconfig
+++ /dev/null
@@ -1,897 +0,0 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.20
4# Tue Feb 20 21:47:33 2007
5#
6CONFIG_MIPS=y
7
8#
9# Machine selection
10#
11CONFIG_ZONE_DMA=y
12# CONFIG_MIPS_MTX1 is not set
13# CONFIG_MIPS_BOSPORUS is not set
14# CONFIG_MIPS_PB1000 is not set
15# CONFIG_MIPS_PB1100 is not set
16# CONFIG_MIPS_PB1500 is not set
17# CONFIG_MIPS_PB1550 is not set
18# CONFIG_MIPS_PB1200 is not set
19# CONFIG_MIPS_DB1000 is not set
20# CONFIG_MIPS_DB1100 is not set
21# CONFIG_MIPS_DB1500 is not set
22# CONFIG_MIPS_DB1550 is not set
23# CONFIG_MIPS_DB1200 is not set
24# CONFIG_MIPS_MIRAGE is not set
25# CONFIG_BASLER_EXCITE is not set
26# CONFIG_MIPS_COBALT is not set
27# CONFIG_MACH_DECSTATION is not set
28# CONFIG_MIPS_EV64120 is not set
29# CONFIG_MACH_JAZZ is not set
30# CONFIG_LASAT is not set
31# CONFIG_MIPS_ATLAS is not set
32# CONFIG_MIPS_MALTA is not set
33# CONFIG_MIPS_SEAD is not set
34# CONFIG_WR_PPMC is not set
35# CONFIG_MIPS_SIM is not set
36CONFIG_MOMENCO_JAGUAR_ATX=y
37# CONFIG_MOMENCO_OCELOT is not set
38# CONFIG_MOMENCO_OCELOT_3 is not set
39# CONFIG_MOMENCO_OCELOT_C is not set
40# CONFIG_MOMENCO_OCELOT_G is not set
41# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_JBS is not set
43# CONFIG_PNX8550_STB810 is not set
44# CONFIG_DDB5477 is not set
45# CONFIG_MACH_VR41XX is not set
46# CONFIG_PMC_YOSEMITE is not set
47# CONFIG_QEMU is not set
48# CONFIG_MARKEINS is not set
49# CONFIG_SGI_IP22 is not set
50# CONFIG_SGI_IP27 is not set
51# CONFIG_SGI_IP32 is not set
52# CONFIG_SIBYTE_BIGSUR is not set
53# CONFIG_SIBYTE_SWARM is not set
54# CONFIG_SIBYTE_SENTOSA is not set
55# CONFIG_SIBYTE_RHONE is not set
56# CONFIG_SIBYTE_CARMEL is not set
57# CONFIG_SIBYTE_PTSWARM is not set
58# CONFIG_SIBYTE_LITTLESUR is not set
59# CONFIG_SIBYTE_CRHINE is not set
60# CONFIG_SIBYTE_CRHONE is not set
61# CONFIG_SNI_RM is not set
62# CONFIG_TOSHIBA_JMR3927 is not set
63# CONFIG_TOSHIBA_RBTX4927 is not set
64# CONFIG_TOSHIBA_RBTX4938 is not set
65CONFIG_JAGUAR_DMALOW=y
66CONFIG_RWSEM_GENERIC_SPINLOCK=y
67# CONFIG_ARCH_HAS_ILOG2_U32 is not set
68# CONFIG_ARCH_HAS_ILOG2_U64 is not set
69CONFIG_GENERIC_FIND_NEXT_BIT=y
70CONFIG_GENERIC_HWEIGHT=y
71CONFIG_GENERIC_CALIBRATE_DELAY=y
72CONFIG_GENERIC_TIME=y
73CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
74# CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ is not set
75CONFIG_DMA_NONCOHERENT=y
76CONFIG_DMA_NEED_PCI_MAP_STATE=y
77CONFIG_LIMITED_DMA=y
78CONFIG_CPU_BIG_ENDIAN=y
79# CONFIG_CPU_LITTLE_ENDIAN is not set
80CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
81CONFIG_IRQ_CPU=y
82CONFIG_IRQ_CPU_RM7K=y
83CONFIG_IRQ_MV64340=y
84CONFIG_PCI_MARVELL=y
85CONFIG_SWAP_IO_SPACE=y
86CONFIG_BOOT_ELF32=y
87CONFIG_MIPS_L1_CACHE_SHIFT=5
88
89#
90# CPU selection
91#
92# CONFIG_CPU_MIPS32_R1 is not set
93# CONFIG_CPU_MIPS32_R2 is not set
94# CONFIG_CPU_MIPS64_R1 is not set
95# CONFIG_CPU_MIPS64_R2 is not set
96# CONFIG_CPU_R3000 is not set
97# CONFIG_CPU_TX39XX is not set
98# CONFIG_CPU_VR41XX is not set
99# CONFIG_CPU_R4300 is not set
100# CONFIG_CPU_R4X00 is not set
101# CONFIG_CPU_TX49XX is not set
102# CONFIG_CPU_R5000 is not set
103# CONFIG_CPU_R5432 is not set
104# CONFIG_CPU_R6000 is not set
105# CONFIG_CPU_NEVADA is not set
106# CONFIG_CPU_R8000 is not set
107# CONFIG_CPU_R10000 is not set
108# CONFIG_CPU_RM7000 is not set
109CONFIG_CPU_RM9000=y
110# CONFIG_CPU_SB1 is not set
111CONFIG_SYS_HAS_CPU_RM9000=y
112CONFIG_WEAK_ORDERING=y
113CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
114CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
115CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
116CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
117
118#
119# Kernel type
120#
121CONFIG_32BIT=y
122# CONFIG_64BIT is not set
123CONFIG_PAGE_SIZE_4KB=y
124# CONFIG_PAGE_SIZE_8KB is not set
125# CONFIG_PAGE_SIZE_16KB is not set
126# CONFIG_PAGE_SIZE_64KB is not set
127CONFIG_BOARD_SCACHE=y
128CONFIG_RM7000_CPU_SCACHE=y
129CONFIG_CPU_HAS_PREFETCH=y
130CONFIG_MIPS_MT_DISABLED=y
131# CONFIG_MIPS_MT_SMP is not set
132# CONFIG_MIPS_MT_SMTC is not set
133# CONFIG_MIPS_VPE_LOADER is not set
134# CONFIG_64BIT_PHYS_ADDR is not set
135CONFIG_CPU_HAS_LLSC=y
136CONFIG_CPU_HAS_SYNC=y
137CONFIG_GENERIC_HARDIRQS=y
138CONFIG_GENERIC_IRQ_PROBE=y
139CONFIG_HIGHMEM=y
140CONFIG_CPU_SUPPORTS_HIGHMEM=y
141CONFIG_SYS_SUPPORTS_HIGHMEM=y
142CONFIG_ARCH_FLATMEM_ENABLE=y
143CONFIG_FLATMEM=y
144CONFIG_FLAT_NODE_MEM_MAP=y
145# CONFIG_SPARSEMEM_STATIC is not set
146CONFIG_SPLIT_PTLOCK_CPUS=4
147# CONFIG_RESOURCES_64BIT is not set
148CONFIG_ZONE_DMA_FLAG=1
149# CONFIG_HZ_48 is not set
150# CONFIG_HZ_100 is not set
151# CONFIG_HZ_128 is not set
152# CONFIG_HZ_250 is not set
153# CONFIG_HZ_256 is not set
154CONFIG_HZ_1000=y
155# CONFIG_HZ_1024 is not set
156CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
157CONFIG_HZ=1000
158CONFIG_PREEMPT_NONE=y
159# CONFIG_PREEMPT_VOLUNTARY is not set
160# CONFIG_PREEMPT is not set
161CONFIG_LOCKDEP_SUPPORT=y
162CONFIG_STACKTRACE_SUPPORT=y
163CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
164
165#
166# Code maturity level options
167#
168# CONFIG_EXPERIMENTAL is not set
169CONFIG_BROKEN_ON_SMP=y
170CONFIG_INIT_ENV_ARG_LIMIT=32
171
172#
173# General setup
174#
175CONFIG_LOCALVERSION=""
176CONFIG_LOCALVERSION_AUTO=y
177CONFIG_SWAP=y
178CONFIG_SYSVIPC=y
179# CONFIG_IPC_NS is not set
180CONFIG_SYSVIPC_SYSCTL=y
181# CONFIG_BSD_PROCESS_ACCT is not set
182# CONFIG_TASKSTATS is not set
183# CONFIG_UTS_NS is not set
184# CONFIG_AUDIT is not set
185CONFIG_IKCONFIG=y
186CONFIG_IKCONFIG_PROC=y
187CONFIG_SYSFS_DEPRECATED=y
188CONFIG_RELAY=y
189CONFIG_SYSCTL=y
190CONFIG_EMBEDDED=y
191CONFIG_SYSCTL_SYSCALL=y
192CONFIG_KALLSYMS=y
193# CONFIG_KALLSYMS_EXTRA_PASS is not set
194CONFIG_HOTPLUG=y
195CONFIG_PRINTK=y
196CONFIG_BUG=y
197CONFIG_ELF_CORE=y
198CONFIG_BASE_FULL=y
199CONFIG_FUTEX=y
200CONFIG_EPOLL=y
201CONFIG_SHMEM=y
202CONFIG_SLAB=y
203CONFIG_VM_EVENT_COUNTERS=y
204CONFIG_RT_MUTEXES=y
205# CONFIG_TINY_SHMEM is not set
206CONFIG_BASE_SMALL=0
207# CONFIG_SLOB is not set
208
209#
210# Loadable module support
211#
212CONFIG_MODULES=y
213CONFIG_MODULE_UNLOAD=y
214# CONFIG_MODVERSIONS is not set
215CONFIG_MODULE_SRCVERSION_ALL=y
216CONFIG_KMOD=y
217
218#
219# Block layer
220#
221CONFIG_BLOCK=y
222# CONFIG_LBD is not set
223# CONFIG_BLK_DEV_IO_TRACE is not set
224# CONFIG_LSF is not set
225
226#
227# IO Schedulers
228#
229CONFIG_IOSCHED_NOOP=y
230CONFIG_IOSCHED_AS=y
231CONFIG_IOSCHED_DEADLINE=y
232CONFIG_IOSCHED_CFQ=y
233CONFIG_DEFAULT_AS=y
234# CONFIG_DEFAULT_DEADLINE is not set
235# CONFIG_DEFAULT_CFQ is not set
236# CONFIG_DEFAULT_NOOP is not set
237CONFIG_DEFAULT_IOSCHED="anticipatory"
238
239#
240# Bus options (PCI, PCMCIA, EISA, ISA, TC)
241#
242CONFIG_HW_HAS_PCI=y
243CONFIG_PCI=y
244CONFIG_MMU=y
245
246#
247# PCCARD (PCMCIA/CardBus) support
248#
249# CONFIG_PCCARD is not set
250
251#
252# PCI Hotplug Support
253#
254
255#
256# Executable file formats
257#
258CONFIG_BINFMT_ELF=y
259# CONFIG_BINFMT_MISC is not set
260CONFIG_TRAD_SIGNALS=y
261
262#
263# Power management options
264#
265CONFIG_PM=y
266# CONFIG_PM_LEGACY is not set
267# CONFIG_PM_DEBUG is not set
268# CONFIG_PM_SYSFS_DEPRECATED is not set
269
270#
271# Networking
272#
273CONFIG_NET=y
274
275#
276# Networking options
277#
278# CONFIG_NETDEBUG is not set
279# CONFIG_PACKET is not set
280CONFIG_UNIX=y
281CONFIG_XFRM=y
282CONFIG_XFRM_USER=m
283# CONFIG_NET_KEY is not set
284CONFIG_INET=y
285# CONFIG_IP_MULTICAST is not set
286# CONFIG_IP_ADVANCED_ROUTER is not set
287CONFIG_IP_FIB_HASH=y
288CONFIG_IP_PNP=y
289# CONFIG_IP_PNP_DHCP is not set
290CONFIG_IP_PNP_BOOTP=y
291# CONFIG_IP_PNP_RARP is not set
292# CONFIG_NET_IPIP is not set
293# CONFIG_NET_IPGRE is not set
294# CONFIG_SYN_COOKIES is not set
295# CONFIG_INET_AH is not set
296# CONFIG_INET_ESP is not set
297# CONFIG_INET_IPCOMP is not set
298# CONFIG_INET_XFRM_TUNNEL is not set
299CONFIG_INET_TUNNEL=m
300CONFIG_INET_XFRM_MODE_TRANSPORT=m
301CONFIG_INET_XFRM_MODE_TUNNEL=m
302CONFIG_INET_XFRM_MODE_BEET=m
303CONFIG_INET_DIAG=y
304CONFIG_INET_TCP_DIAG=y
305# CONFIG_TCP_CONG_ADVANCED is not set
306CONFIG_TCP_CONG_CUBIC=y
307CONFIG_DEFAULT_TCP_CONG="cubic"
308CONFIG_IPV6=m
309CONFIG_IPV6_PRIVACY=y
310CONFIG_IPV6_ROUTER_PREF=y
311CONFIG_INET6_AH=m
312CONFIG_INET6_ESP=m
313CONFIG_INET6_IPCOMP=m
314CONFIG_INET6_XFRM_TUNNEL=m
315CONFIG_INET6_TUNNEL=m
316CONFIG_INET6_XFRM_MODE_TRANSPORT=m
317CONFIG_INET6_XFRM_MODE_TUNNEL=m
318CONFIG_INET6_XFRM_MODE_BEET=m
319CONFIG_IPV6_SIT=m
320CONFIG_IPV6_TUNNEL=m
321CONFIG_NETWORK_SECMARK=y
322# CONFIG_NETFILTER is not set
323# CONFIG_BRIDGE is not set
324# CONFIG_VLAN_8021Q is not set
325# CONFIG_DECNET is not set
326# CONFIG_LLC2 is not set
327# CONFIG_IPX is not set
328# CONFIG_ATALK is not set
329
330#
331# QoS and/or fair queueing
332#
333# CONFIG_NET_SCHED is not set
334
335#
336# Network testing
337#
338# CONFIG_NET_PKTGEN is not set
339# CONFIG_HAMRADIO is not set
340# CONFIG_IRDA is not set
341# CONFIG_BT is not set
342CONFIG_IEEE80211=m
343# CONFIG_IEEE80211_DEBUG is not set
344CONFIG_IEEE80211_CRYPT_WEP=m
345CONFIG_IEEE80211_CRYPT_CCMP=m
346
347#
348# Device Drivers
349#
350
351#
352# Generic Driver Options
353#
354CONFIG_STANDALONE=y
355CONFIG_PREVENT_FIRMWARE_BUILD=y
356CONFIG_FW_LOADER=m
357# CONFIG_SYS_HYPERVISOR is not set
358
359#
360# Connector - unified userspace <-> kernelspace linker
361#
362CONFIG_CONNECTOR=m
363
364#
365# Memory Technology Devices (MTD)
366#
367# CONFIG_MTD is not set
368
369#
370# Parallel port support
371#
372# CONFIG_PARPORT is not set
373
374#
375# Plug and Play support
376#
377# CONFIG_PNPACPI is not set
378
379#
380# Block devices
381#
382# CONFIG_BLK_CPQ_DA is not set
383# CONFIG_BLK_CPQ_CISS_DA is not set
384# CONFIG_BLK_DEV_DAC960 is not set
385# CONFIG_BLK_DEV_COW_COMMON is not set
386# CONFIG_BLK_DEV_LOOP is not set
387# CONFIG_BLK_DEV_NBD is not set
388# CONFIG_BLK_DEV_SX8 is not set
389# CONFIG_BLK_DEV_RAM is not set
390# CONFIG_BLK_DEV_INITRD is not set
391CONFIG_CDROM_PKTCDVD=m
392CONFIG_CDROM_PKTCDVD_BUFFERS=8
393CONFIG_ATA_OVER_ETH=m
394
395#
396# Misc devices
397#
398CONFIG_SGI_IOC4=m
399
400#
401# ATA/ATAPI/MFM/RLL support
402#
403# CONFIG_IDE is not set
404
405#
406# SCSI device support
407#
408CONFIG_RAID_ATTRS=m
409# CONFIG_SCSI is not set
410# CONFIG_SCSI_NETLINK is not set
411
412#
413# Serial ATA (prod) and Parallel ATA (experimental) drivers
414#
415# CONFIG_ATA is not set
416
417#
418# Multi-device support (RAID and LVM)
419#
420# CONFIG_MD is not set
421
422#
423# Fusion MPT device support
424#
425# CONFIG_FUSION is not set
426
427#
428# IEEE 1394 (FireWire) support
429#
430# CONFIG_IEEE1394 is not set
431
432#
433# I2O device support
434#
435# CONFIG_I2O is not set
436
437#
438# Network device support
439#
440CONFIG_NETDEVICES=y
441# CONFIG_DUMMY is not set
442# CONFIG_BONDING is not set
443# CONFIG_EQUALIZER is not set
444# CONFIG_TUN is not set
445
446#
447# ARCnet devices
448#
449# CONFIG_ARCNET is not set
450
451#
452# PHY device support
453#
454CONFIG_PHYLIB=m
455
456#
457# MII PHY device drivers
458#
459CONFIG_MARVELL_PHY=m
460CONFIG_DAVICOM_PHY=m
461CONFIG_QSEMI_PHY=m
462CONFIG_LXT_PHY=m
463CONFIG_CICADA_PHY=m
464CONFIG_VITESSE_PHY=m
465CONFIG_SMSC_PHY=m
466# CONFIG_BROADCOM_PHY is not set
467# CONFIG_FIXED_PHY is not set
468
469#
470# Ethernet (10 or 100Mbit)
471#
472CONFIG_NET_ETHERNET=y
473CONFIG_MII=y
474# CONFIG_HAPPYMEAL is not set
475# CONFIG_SUNGEM is not set
476# CONFIG_CASSINI is not set
477# CONFIG_NET_VENDOR_3COM is not set
478# CONFIG_DM9000 is not set
479
480#
481# Tulip family network device support
482#
483# CONFIG_NET_TULIP is not set
484# CONFIG_HP100 is not set
485CONFIG_NET_PCI=y
486# CONFIG_PCNET32 is not set
487# CONFIG_AMD8111_ETH is not set
488# CONFIG_ADAPTEC_STARFIRE is not set
489# CONFIG_B44 is not set
490# CONFIG_FORCEDETH is not set
491# CONFIG_DGRS is not set
492CONFIG_EEPRO100=y
493# CONFIG_E100 is not set
494# CONFIG_FEALNX is not set
495# CONFIG_NATSEMI is not set
496# CONFIG_NE2K_PCI is not set
497# CONFIG_8139TOO is not set
498# CONFIG_SIS900 is not set
499# CONFIG_EPIC100 is not set
500# CONFIG_SUNDANCE is not set
501# CONFIG_TLAN is not set
502# CONFIG_VIA_RHINE is not set
503
504#
505# Ethernet (1000 Mbit)
506#
507# CONFIG_ACENIC is not set
508# CONFIG_DL2K is not set
509# CONFIG_E1000 is not set
510# CONFIG_NS83820 is not set
511# CONFIG_HAMACHI is not set
512# CONFIG_R8169 is not set
513# CONFIG_SIS190 is not set
514# CONFIG_SKGE is not set
515# CONFIG_SKY2 is not set
516# CONFIG_SK98LIN is not set
517# CONFIG_VIA_VELOCITY is not set
518# CONFIG_TIGON3 is not set
519# CONFIG_BNX2 is not set
520CONFIG_MV643XX_ETH=y
521CONFIG_QLA3XXX=m
522
523#
524# Ethernet (10000 Mbit)
525#
526# CONFIG_CHELSIO_T1 is not set
527CONFIG_CHELSIO_T3=m
528# CONFIG_IXGB is not set
529# CONFIG_S2IO is not set
530# CONFIG_MYRI10GE is not set
531CONFIG_NETXEN_NIC=m
532
533#
534# Token Ring devices
535#
536# CONFIG_TR is not set
537
538#
539# Wireless LAN (non-hamradio)
540#
541# CONFIG_NET_RADIO is not set
542
543#
544# Wan interfaces
545#
546# CONFIG_WAN is not set
547# CONFIG_FDDI is not set
548# CONFIG_PPP is not set
549# CONFIG_SLIP is not set
550# CONFIG_NETPOLL is not set
551# CONFIG_NET_POLL_CONTROLLER is not set
552
553#
554# ISDN subsystem
555#
556# CONFIG_ISDN is not set
557
558#
559# Telephony Support
560#
561# CONFIG_PHONE is not set
562
563#
564# Input device support
565#
566# CONFIG_INPUT is not set
567
568#
569# Hardware I/O ports
570#
571# CONFIG_SERIO is not set
572# CONFIG_GAMEPORT is not set
573
574#
575# Character devices
576#
577# CONFIG_VT is not set
578# CONFIG_SERIAL_NONSTANDARD is not set
579
580#
581# Serial drivers
582#
583CONFIG_SERIAL_8250=y
584CONFIG_SERIAL_8250_CONSOLE=y
585CONFIG_SERIAL_8250_PCI=y
586CONFIG_SERIAL_8250_NR_UARTS=4
587CONFIG_SERIAL_8250_RUNTIME_UARTS=4
588# CONFIG_SERIAL_8250_EXTENDED is not set
589
590#
591# Non-8250 serial port support
592#
593CONFIG_SERIAL_CORE=y
594CONFIG_SERIAL_CORE_CONSOLE=y
595# CONFIG_SERIAL_JSM is not set
596CONFIG_UNIX98_PTYS=y
597CONFIG_LEGACY_PTYS=y
598CONFIG_LEGACY_PTY_COUNT=256
599
600#
601# IPMI
602#
603# CONFIG_IPMI_HANDLER is not set
604
605#
606# Watchdog Cards
607#
608# CONFIG_WATCHDOG is not set
609# CONFIG_HW_RANDOM is not set
610# CONFIG_RTC is not set
611# CONFIG_GEN_RTC is not set
612# CONFIG_DTLK is not set
613# CONFIG_R3964 is not set
614# CONFIG_APPLICOM is not set
615# CONFIG_DRM is not set
616# CONFIG_RAW_DRIVER is not set
617
618#
619# TPM devices
620#
621
622#
623# I2C support
624#
625# CONFIG_I2C is not set
626
627#
628# SPI support
629#
630# CONFIG_SPI is not set
631# CONFIG_SPI_MASTER is not set
632
633#
634# Dallas's 1-wire bus
635#
636# CONFIG_W1 is not set
637
638#
639# Hardware Monitoring support
640#
641# CONFIG_HWMON is not set
642# CONFIG_HWMON_VID is not set
643
644#
645# Multimedia devices
646#
647# CONFIG_VIDEO_DEV is not set
648
649#
650# Digital Video Broadcasting Devices
651#
652# CONFIG_DVB is not set
653
654#
655# Graphics support
656#
657# CONFIG_FIRMWARE_EDID is not set
658# CONFIG_FB is not set
659# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
660
661#
662# Sound
663#
664# CONFIG_SOUND is not set
665
666#
667# USB support
668#
669CONFIG_USB_ARCH_HAS_HCD=y
670CONFIG_USB_ARCH_HAS_OHCI=y
671CONFIG_USB_ARCH_HAS_EHCI=y
672# CONFIG_USB is not set
673
674#
675# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
676#
677
678#
679# USB Gadget Support
680#
681# CONFIG_USB_GADGET is not set
682
683#
684# MMC/SD Card support
685#
686# CONFIG_MMC is not set
687
688#
689# LED devices
690#
691# CONFIG_NEW_LEDS is not set
692
693#
694# LED drivers
695#
696
697#
698# LED Triggers
699#
700
701#
702# InfiniBand support
703#
704# CONFIG_INFINIBAND is not set
705
706#
707# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
708#
709
710#
711# Real Time Clock
712#
713
714#
715# DMA Engine support
716#
717# CONFIG_DMA_ENGINE is not set
718
719#
720# DMA Clients
721#
722
723#
724# DMA Devices
725#
726
727#
728# Auxiliary Display support
729#
730
731#
732# Virtualization
733#
734
735#
736# File systems
737#
738# CONFIG_EXT2_FS is not set
739# CONFIG_EXT3_FS is not set
740# CONFIG_REISERFS_FS is not set
741# CONFIG_JFS_FS is not set
742CONFIG_FS_POSIX_ACL=y
743# CONFIG_XFS_FS is not set
744# CONFIG_OCFS2_FS is not set
745# CONFIG_MINIX_FS is not set
746# CONFIG_ROMFS_FS is not set
747CONFIG_INOTIFY=y
748CONFIG_INOTIFY_USER=y
749# CONFIG_QUOTA is not set
750CONFIG_DNOTIFY=y
751# CONFIG_AUTOFS_FS is not set
752# CONFIG_AUTOFS4_FS is not set
753CONFIG_FUSE_FS=m
754CONFIG_GENERIC_ACL=y
755
756#
757# CD-ROM/DVD Filesystems
758#
759# CONFIG_ISO9660_FS is not set
760# CONFIG_UDF_FS is not set
761
762#
763# DOS/FAT/NT Filesystems
764#
765# CONFIG_MSDOS_FS is not set
766# CONFIG_VFAT_FS is not set
767# CONFIG_NTFS_FS is not set
768
769#
770# Pseudo filesystems
771#
772CONFIG_PROC_FS=y
773CONFIG_PROC_KCORE=y
774CONFIG_PROC_SYSCTL=y
775CONFIG_SYSFS=y
776CONFIG_TMPFS=y
777CONFIG_TMPFS_POSIX_ACL=y
778# CONFIG_HUGETLB_PAGE is not set
779CONFIG_RAMFS=y
780
781#
782# Miscellaneous filesystems
783#
784# CONFIG_HFSPLUS_FS is not set
785# CONFIG_CRAMFS is not set
786# CONFIG_VXFS_FS is not set
787# CONFIG_HPFS_FS is not set
788# CONFIG_QNX4FS_FS is not set
789# CONFIG_SYSV_FS is not set
790# CONFIG_UFS_FS is not set
791
792#
793# Network File Systems
794#
795CONFIG_NFS_FS=y
796# CONFIG_NFS_V3 is not set
797# CONFIG_NFS_DIRECTIO is not set
798# CONFIG_NFSD is not set
799CONFIG_ROOT_NFS=y
800CONFIG_LOCKD=y
801CONFIG_NFS_COMMON=y
802CONFIG_SUNRPC=y
803# CONFIG_SMB_FS is not set
804# CONFIG_CIFS is not set
805# CONFIG_NCP_FS is not set
806# CONFIG_CODA_FS is not set
807
808#
809# Partition Types
810#
811# CONFIG_PARTITION_ADVANCED is not set
812CONFIG_MSDOS_PARTITION=y
813
814#
815# Native Language Support
816#
817# CONFIG_NLS is not set
818
819#
820# Kernel hacking
821#
822CONFIG_TRACE_IRQFLAGS_SUPPORT=y
823# CONFIG_PRINTK_TIME is not set
824CONFIG_ENABLE_MUST_CHECK=y
825# CONFIG_MAGIC_SYSRQ is not set
826# CONFIG_UNUSED_SYMBOLS is not set
827# CONFIG_DEBUG_FS is not set
828# CONFIG_HEADERS_CHECK is not set
829# CONFIG_DEBUG_KERNEL is not set
830CONFIG_LOG_BUF_SHIFT=14
831CONFIG_CROSSCOMPILE=y
832CONFIG_CMDLINE=""
833CONFIG_SYS_SUPPORTS_KGDB=y
834
835#
836# Security options
837#
838CONFIG_KEYS=y
839CONFIG_KEYS_DEBUG_PROC_KEYS=y
840# CONFIG_SECURITY is not set
841
842#
843# Cryptographic options
844#
845CONFIG_CRYPTO=y
846CONFIG_CRYPTO_ALGAPI=y
847CONFIG_CRYPTO_BLKCIPHER=m
848CONFIG_CRYPTO_HASH=y
849CONFIG_CRYPTO_MANAGER=y
850CONFIG_CRYPTO_HMAC=y
851CONFIG_CRYPTO_NULL=m
852CONFIG_CRYPTO_MD4=m
853CONFIG_CRYPTO_MD5=m
854CONFIG_CRYPTO_SHA1=m
855CONFIG_CRYPTO_SHA256=m
856CONFIG_CRYPTO_SHA512=m
857CONFIG_CRYPTO_WP512=m
858CONFIG_CRYPTO_TGR192=m
859CONFIG_CRYPTO_ECB=m
860CONFIG_CRYPTO_CBC=m
861CONFIG_CRYPTO_PCBC=m
862CONFIG_CRYPTO_DES=m
863CONFIG_CRYPTO_FCRYPT=m
864CONFIG_CRYPTO_BLOWFISH=m
865CONFIG_CRYPTO_TWOFISH=m
866CONFIG_CRYPTO_TWOFISH_COMMON=m
867CONFIG_CRYPTO_SERPENT=m
868CONFIG_CRYPTO_AES=m
869CONFIG_CRYPTO_CAST5=m
870CONFIG_CRYPTO_CAST6=m
871CONFIG_CRYPTO_TEA=m
872CONFIG_CRYPTO_ARC4=m
873CONFIG_CRYPTO_KHAZAD=m
874CONFIG_CRYPTO_ANUBIS=m
875CONFIG_CRYPTO_DEFLATE=m
876CONFIG_CRYPTO_MICHAEL_MIC=m
877CONFIG_CRYPTO_CRC32C=m
878CONFIG_CRYPTO_CAMELLIA=m
879# CONFIG_CRYPTO_TEST is not set
880
881#
882# Hardware crypto devices
883#
884
885#
886# Library routines
887#
888CONFIG_BITREVERSE=m
889# CONFIG_CRC_CCITT is not set
890CONFIG_CRC16=m
891CONFIG_CRC32=m
892CONFIG_LIBCRC32C=m
893CONFIG_ZLIB_INFLATE=m
894CONFIG_ZLIB_DEFLATE=m
895CONFIG_PLIST=y
896CONFIG_HAS_IOMEM=y
897CONFIG_HAS_IOPORT=y
diff --git a/arch/mips/configs/jmr3927_defconfig b/arch/mips/configs/jmr3927_defconfig
index 068e48ec7093..1b364cf69140 100644
--- a/arch/mips/configs/jmr3927_defconfig
+++ b/arch/mips/configs/jmr3927_defconfig
@@ -80,7 +80,6 @@ CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
80CONFIG_MIPS_TX3927=y 80CONFIG_MIPS_TX3927=y
81CONFIG_SWAP_IO_SPACE=y 81CONFIG_SWAP_IO_SPACE=y
82CONFIG_MIPS_L1_CACHE_SHIFT=5 82CONFIG_MIPS_L1_CACHE_SHIFT=5
83CONFIG_TOSHIBA_BOARDS=y
84 83
85# 84#
86# CPU selection 85# CPU selection
diff --git a/arch/mips/configs/pb1100_defconfig b/arch/mips/configs/pb1100_defconfig
index 69678d99ae61..37d696c64541 100644
--- a/arch/mips/configs/pb1100_defconfig
+++ b/arch/mips/configs/pb1100_defconfig
@@ -9,6 +9,7 @@ CONFIG_MIPS=y
9# Machine selection 9# Machine selection
10# 10#
11CONFIG_ZONE_DMA=y 11CONFIG_ZONE_DMA=y
12CONFIG_MACH_ALCHEMY=y
12# CONFIG_MIPS_MTX1 is not set 13# CONFIG_MIPS_MTX1 is not set
13# CONFIG_MIPS_BOSPORUS is not set 14# CONFIG_MIPS_BOSPORUS is not set
14# CONFIG_MIPS_PB1000 is not set 15# CONFIG_MIPS_PB1000 is not set
diff --git a/arch/mips/configs/pb1500_defconfig b/arch/mips/configs/pb1500_defconfig
index 070672799dac..b11f0e8b6059 100644
--- a/arch/mips/configs/pb1500_defconfig
+++ b/arch/mips/configs/pb1500_defconfig
@@ -9,6 +9,7 @@ CONFIG_MIPS=y
9# Machine selection 9# Machine selection
10# 10#
11CONFIG_ZONE_DMA=y 11CONFIG_ZONE_DMA=y
12CONFIG_MACH_ALCHEMY=y
12# CONFIG_MIPS_MTX1 is not set 13# CONFIG_MIPS_MTX1 is not set
13# CONFIG_MIPS_BOSPORUS is not set 14# CONFIG_MIPS_BOSPORUS is not set
14# CONFIG_MIPS_PB1000 is not set 15# CONFIG_MIPS_PB1000 is not set
diff --git a/arch/mips/configs/pb1550_defconfig b/arch/mips/configs/pb1550_defconfig
index 354e49b7a5f1..2927f38f4907 100644
--- a/arch/mips/configs/pb1550_defconfig
+++ b/arch/mips/configs/pb1550_defconfig
@@ -9,6 +9,7 @@ CONFIG_MIPS=y
9# Machine selection 9# Machine selection
10# 10#
11CONFIG_ZONE_DMA=y 11CONFIG_ZONE_DMA=y
12CONFIG_MACH_ALCHEMY=y
12# CONFIG_MIPS_MTX1 is not set 13# CONFIG_MIPS_MTX1 is not set
13# CONFIG_MIPS_BOSPORUS is not set 14# CONFIG_MIPS_BOSPORUS is not set
14# CONFIG_MIPS_PB1000 is not set 15# CONFIG_MIPS_PB1000 is not set
diff --git a/arch/mips/configs/ocelot_g_defconfig b/arch/mips/configs/rbhma4200_defconfig
index 7078e6b3ea11..35d64260917e 100644
--- a/arch/mips/configs/ocelot_g_defconfig
+++ b/arch/mips/configs/rbhma4200_defconfig
@@ -1,14 +1,13 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.20 3# Linux kernel version: 2.6.21
4# Tue Feb 20 21:47:36 2007 4# Wed May 9 23:44:19 2007
5# 5#
6CONFIG_MIPS=y 6CONFIG_MIPS=y
7 7
8# 8#
9# Machine selection 9# Machine selection
10# 10#
11CONFIG_ZONE_DMA=y
12# CONFIG_MIPS_MTX1 is not set 11# CONFIG_MIPS_MTX1 is not set
13# CONFIG_MIPS_BOSPORUS is not set 12# CONFIG_MIPS_BOSPORUS is not set
14# CONFIG_MIPS_PB1000 is not set 13# CONFIG_MIPS_PB1000 is not set
@@ -33,11 +32,9 @@ CONFIG_ZONE_DMA=y
33# CONFIG_MIPS_SEAD is not set 32# CONFIG_MIPS_SEAD is not set
34# CONFIG_WR_PPMC is not set 33# CONFIG_WR_PPMC is not set
35# CONFIG_MIPS_SIM is not set 34# CONFIG_MIPS_SIM is not set
36# CONFIG_MOMENCO_JAGUAR_ATX is not set
37# CONFIG_MOMENCO_OCELOT is not set 35# CONFIG_MOMENCO_OCELOT is not set
38# CONFIG_MOMENCO_OCELOT_3 is not set 36# CONFIG_MOMENCO_OCELOT_3 is not set
39# CONFIG_MOMENCO_OCELOT_C is not set 37# CONFIG_MOMENCO_OCELOT_C is not set
40CONFIG_MOMENCO_OCELOT_G=y
41# CONFIG_MIPS_XXS1500 is not set 38# CONFIG_MIPS_XXS1500 is not set
42# CONFIG_PNX8550_JBS is not set 39# CONFIG_PNX8550_JBS is not set
43# CONFIG_PNX8550_STB810 is not set 40# CONFIG_PNX8550_STB810 is not set
@@ -60,8 +57,9 @@ CONFIG_MOMENCO_OCELOT_G=y
60# CONFIG_SIBYTE_CRHONE is not set 57# CONFIG_SIBYTE_CRHONE is not set
61# CONFIG_SNI_RM is not set 58# CONFIG_SNI_RM is not set
62# CONFIG_TOSHIBA_JMR3927 is not set 59# CONFIG_TOSHIBA_JMR3927 is not set
63# CONFIG_TOSHIBA_RBTX4927 is not set 60CONFIG_TOSHIBA_RBTX4927=y
64# CONFIG_TOSHIBA_RBTX4938 is not set 61# CONFIG_TOSHIBA_RBTX4938 is not set
62# CONFIG_TOSHIBA_FPCIB0 is not set
65CONFIG_RWSEM_GENERIC_SPINLOCK=y 63CONFIG_RWSEM_GENERIC_SPINLOCK=y
66# CONFIG_ARCH_HAS_ILOG2_U32 is not set 64# CONFIG_ARCH_HAS_ILOG2_U32 is not set
67# CONFIG_ARCH_HAS_ILOG2_U64 is not set 65# CONFIG_ARCH_HAS_ILOG2_U64 is not set
@@ -70,19 +68,15 @@ CONFIG_GENERIC_HWEIGHT=y
70CONFIG_GENERIC_CALIBRATE_DELAY=y 68CONFIG_GENERIC_CALIBRATE_DELAY=y
71CONFIG_GENERIC_TIME=y 69CONFIG_GENERIC_TIME=y
72CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y 70CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
73# CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ is not set 71CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
74CONFIG_DMA_NONCOHERENT=y 72CONFIG_DMA_NONCOHERENT=y
75CONFIG_DMA_NEED_PCI_MAP_STATE=y 73CONFIG_DMA_NEED_PCI_MAP_STATE=y
74CONFIG_I8259=y
76CONFIG_CPU_BIG_ENDIAN=y 75CONFIG_CPU_BIG_ENDIAN=y
77# CONFIG_CPU_LITTLE_ENDIAN is not set 76# CONFIG_CPU_LITTLE_ENDIAN is not set
78CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y 77CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
79CONFIG_IRQ_CPU=y 78CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
80CONFIG_IRQ_CPU_RM7K=y
81CONFIG_PCI_MARVELL=y
82CONFIG_SWAP_IO_SPACE=y 79CONFIG_SWAP_IO_SPACE=y
83# CONFIG_SYSCLK_75 is not set
84# CONFIG_SYSCLK_83 is not set
85CONFIG_SYSCLK_100=y
86CONFIG_MIPS_L1_CACHE_SHIFT=5 80CONFIG_MIPS_L1_CACHE_SHIFT=5
87 81
88# 82#
@@ -97,18 +91,19 @@ CONFIG_MIPS_L1_CACHE_SHIFT=5
97# CONFIG_CPU_VR41XX is not set 91# CONFIG_CPU_VR41XX is not set
98# CONFIG_CPU_R4300 is not set 92# CONFIG_CPU_R4300 is not set
99# CONFIG_CPU_R4X00 is not set 93# CONFIG_CPU_R4X00 is not set
100# CONFIG_CPU_TX49XX is not set 94CONFIG_CPU_TX49XX=y
101# CONFIG_CPU_R5000 is not set 95# CONFIG_CPU_R5000 is not set
102# CONFIG_CPU_R5432 is not set 96# CONFIG_CPU_R5432 is not set
103# CONFIG_CPU_R6000 is not set 97# CONFIG_CPU_R6000 is not set
104# CONFIG_CPU_NEVADA is not set 98# CONFIG_CPU_NEVADA is not set
105# CONFIG_CPU_R8000 is not set 99# CONFIG_CPU_R8000 is not set
106# CONFIG_CPU_R10000 is not set 100# CONFIG_CPU_R10000 is not set
107CONFIG_CPU_RM7000=y 101# CONFIG_CPU_RM7000 is not set
108# CONFIG_CPU_RM9000 is not set 102# CONFIG_CPU_RM9000 is not set
109# CONFIG_CPU_SB1 is not set 103# CONFIG_CPU_SB1 is not set
110CONFIG_SYS_HAS_CPU_RM7000=y 104CONFIG_SYS_HAS_CPU_TX49XX=y
111CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y 105CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
106CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
112CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y 107CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
113CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y 108CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
114 109
@@ -121,19 +116,15 @@ CONFIG_PAGE_SIZE_4KB=y
121# CONFIG_PAGE_SIZE_8KB is not set 116# CONFIG_PAGE_SIZE_8KB is not set
122# CONFIG_PAGE_SIZE_16KB is not set 117# CONFIG_PAGE_SIZE_16KB is not set
123# CONFIG_PAGE_SIZE_64KB is not set 118# CONFIG_PAGE_SIZE_64KB is not set
124CONFIG_BOARD_SCACHE=y
125CONFIG_RM7000_CPU_SCACHE=y
126CONFIG_CPU_HAS_PREFETCH=y 119CONFIG_CPU_HAS_PREFETCH=y
127CONFIG_MIPS_MT_DISABLED=y 120CONFIG_MIPS_MT_DISABLED=y
128# CONFIG_MIPS_MT_SMP is not set 121# CONFIG_MIPS_MT_SMP is not set
129# CONFIG_MIPS_MT_SMTC is not set 122# CONFIG_MIPS_MT_SMTC is not set
130# CONFIG_MIPS_VPE_LOADER is not set 123# CONFIG_MIPS_VPE_LOADER is not set
131# CONFIG_64BIT_PHYS_ADDR is not set
132CONFIG_CPU_HAS_LLSC=y 124CONFIG_CPU_HAS_LLSC=y
133CONFIG_CPU_HAS_SYNC=y 125CONFIG_CPU_HAS_SYNC=y
134CONFIG_GENERIC_HARDIRQS=y 126CONFIG_GENERIC_HARDIRQS=y
135CONFIG_GENERIC_IRQ_PROBE=y 127CONFIG_GENERIC_IRQ_PROBE=y
136CONFIG_CPU_SUPPORTS_HIGHMEM=y
137CONFIG_ARCH_FLATMEM_ENABLE=y 128CONFIG_ARCH_FLATMEM_ENABLE=y
138CONFIG_SELECT_MEMORY_MODEL=y 129CONFIG_SELECT_MEMORY_MODEL=y
139CONFIG_FLATMEM_MANUAL=y 130CONFIG_FLATMEM_MANUAL=y
@@ -143,17 +134,17 @@ CONFIG_FLATMEM=y
143CONFIG_FLAT_NODE_MEM_MAP=y 134CONFIG_FLAT_NODE_MEM_MAP=y
144# CONFIG_SPARSEMEM_STATIC is not set 135# CONFIG_SPARSEMEM_STATIC is not set
145CONFIG_SPLIT_PTLOCK_CPUS=4 136CONFIG_SPLIT_PTLOCK_CPUS=4
146CONFIG_RESOURCES_64BIT=y 137# CONFIG_RESOURCES_64BIT is not set
147CONFIG_ZONE_DMA_FLAG=1 138CONFIG_ZONE_DMA_FLAG=0
148# CONFIG_HZ_48 is not set 139# CONFIG_HZ_48 is not set
149# CONFIG_HZ_100 is not set 140# CONFIG_HZ_100 is not set
150# CONFIG_HZ_128 is not set 141# CONFIG_HZ_128 is not set
151# CONFIG_HZ_250 is not set 142CONFIG_HZ_250=y
152# CONFIG_HZ_256 is not set 143# CONFIG_HZ_256 is not set
153CONFIG_HZ_1000=y 144# CONFIG_HZ_1000 is not set
154# CONFIG_HZ_1024 is not set 145# CONFIG_HZ_1024 is not set
155CONFIG_SYS_SUPPORTS_ARBIT_HZ=y 146CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
156CONFIG_HZ=1000 147CONFIG_HZ=250
157CONFIG_PREEMPT_NONE=y 148CONFIG_PREEMPT_NONE=y
158# CONFIG_PREEMPT_VOLUNTARY is not set 149# CONFIG_PREEMPT_VOLUNTARY is not set
159# CONFIG_PREEMPT is not set 150# CONFIG_PREEMPT is not set
@@ -183,34 +174,42 @@ CONFIG_SYSVIPC_SYSCTL=y
183# CONFIG_TASKSTATS is not set 174# CONFIG_TASKSTATS is not set
184# CONFIG_UTS_NS is not set 175# CONFIG_UTS_NS is not set
185# CONFIG_AUDIT is not set 176# CONFIG_AUDIT is not set
186# CONFIG_IKCONFIG is not set 177CONFIG_IKCONFIG=y
178CONFIG_IKCONFIG_PROC=y
179CONFIG_LOG_BUF_SHIFT=14
187CONFIG_SYSFS_DEPRECATED=y 180CONFIG_SYSFS_DEPRECATED=y
188CONFIG_RELAY=y 181# CONFIG_RELAY is not set
189# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 182CONFIG_BLK_DEV_INITRD=y
183CONFIG_INITRAMFS_SOURCE=""
184CONFIG_CC_OPTIMIZE_FOR_SIZE=y
190CONFIG_SYSCTL=y 185CONFIG_SYSCTL=y
191CONFIG_EMBEDDED=y 186CONFIG_EMBEDDED=y
192CONFIG_SYSCTL_SYSCALL=y 187CONFIG_SYSCTL_SYSCALL=y
193CONFIG_KALLSYMS=y 188CONFIG_KALLSYMS=y
194# CONFIG_KALLSYMS_EXTRA_PASS is not set 189# CONFIG_KALLSYMS_EXTRA_PASS is not set
195CONFIG_HOTPLUG=y 190# CONFIG_HOTPLUG is not set
196CONFIG_PRINTK=y 191CONFIG_PRINTK=y
197CONFIG_BUG=y 192CONFIG_BUG=y
198CONFIG_ELF_CORE=y 193CONFIG_ELF_CORE=y
199CONFIG_BASE_FULL=y 194CONFIG_BASE_FULL=y
200CONFIG_FUTEX=y 195# CONFIG_FUTEX is not set
201CONFIG_EPOLL=y 196# CONFIG_EPOLL is not set
202CONFIG_SHMEM=y 197CONFIG_SHMEM=y
203CONFIG_SLAB=y
204CONFIG_VM_EVENT_COUNTERS=y 198CONFIG_VM_EVENT_COUNTERS=y
205CONFIG_RT_MUTEXES=y 199CONFIG_SLAB=y
200# CONFIG_SLUB is not set
201# CONFIG_SLOB is not set
206# CONFIG_TINY_SHMEM is not set 202# CONFIG_TINY_SHMEM is not set
207CONFIG_BASE_SMALL=0 203CONFIG_BASE_SMALL=0
208# CONFIG_SLOB is not set
209 204
210# 205#
211# Loadable module support 206# Loadable module support
212# 207#
213# CONFIG_MODULES is not set 208CONFIG_MODULES=y
209# CONFIG_MODULE_UNLOAD is not set
210# CONFIG_MODVERSIONS is not set
211# CONFIG_MODULE_SRCVERSION_ALL is not set
212CONFIG_KMOD=y
214 213
215# 214#
216# Block layer 215# Block layer
@@ -218,7 +217,7 @@ CONFIG_BASE_SMALL=0
218CONFIG_BLOCK=y 217CONFIG_BLOCK=y
219# CONFIG_LBD is not set 218# CONFIG_LBD is not set
220# CONFIG_BLK_DEV_IO_TRACE is not set 219# CONFIG_BLK_DEV_IO_TRACE is not set
221CONFIG_LSF=y 220# CONFIG_LSF is not set
222 221
223# 222#
224# IO Schedulers 223# IO Schedulers
@@ -238,17 +237,12 @@ CONFIG_DEFAULT_IOSCHED="anticipatory"
238# 237#
239CONFIG_HW_HAS_PCI=y 238CONFIG_HW_HAS_PCI=y
240CONFIG_PCI=y 239CONFIG_PCI=y
240# CONFIG_ARCH_SUPPORTS_MSI is not set
241CONFIG_MMU=y 241CONFIG_MMU=y
242 242
243# 243#
244# PCCARD (PCMCIA/CardBus) support 244# PCCARD (PCMCIA/CardBus) support
245# 245#
246# CONFIG_PCCARD is not set
247
248#
249# PCI Hotplug Support
250#
251# CONFIG_HOTPLUG_PCI is not set
252 246
253# 247#
254# Executable file formats 248# Executable file formats
@@ -260,10 +254,7 @@ CONFIG_TRAD_SIGNALS=y
260# 254#
261# Power management options 255# Power management options
262# 256#
263CONFIG_PM=y 257# CONFIG_PM is not set
264# CONFIG_PM_LEGACY is not set
265# CONFIG_PM_DEBUG is not set
266# CONFIG_PM_SYSFS_DEPRECATED is not set
267 258
268# 259#
269# Networking 260# Networking
@@ -273,25 +264,21 @@ CONFIG_NET=y
273# 264#
274# Networking options 265# Networking options
275# 266#
276# CONFIG_NETDEBUG is not set 267CONFIG_PACKET=y
277# CONFIG_PACKET is not set 268# CONFIG_PACKET_MMAP is not set
278CONFIG_UNIX=y 269CONFIG_UNIX=y
279CONFIG_XFRM=y 270# CONFIG_NET_KEY is not set
280CONFIG_XFRM_USER=y
281# CONFIG_XFRM_SUB_POLICY is not set
282CONFIG_XFRM_MIGRATE=y
283CONFIG_NET_KEY=y
284CONFIG_NET_KEY_MIGRATE=y
285CONFIG_INET=y 271CONFIG_INET=y
286# CONFIG_IP_MULTICAST is not set 272CONFIG_IP_MULTICAST=y
287# CONFIG_IP_ADVANCED_ROUTER is not set 273# CONFIG_IP_ADVANCED_ROUTER is not set
288CONFIG_IP_FIB_HASH=y 274CONFIG_IP_FIB_HASH=y
289CONFIG_IP_PNP=y 275CONFIG_IP_PNP=y
290CONFIG_IP_PNP_DHCP=y 276# CONFIG_IP_PNP_DHCP is not set
291# CONFIG_IP_PNP_BOOTP is not set 277# CONFIG_IP_PNP_BOOTP is not set
292# CONFIG_IP_PNP_RARP is not set 278# CONFIG_IP_PNP_RARP is not set
293# CONFIG_NET_IPIP is not set 279# CONFIG_NET_IPIP is not set
294# CONFIG_NET_IPGRE is not set 280# CONFIG_NET_IPGRE is not set
281# CONFIG_IP_MROUTE is not set
295# CONFIG_ARPD is not set 282# CONFIG_ARPD is not set
296# CONFIG_SYN_COOKIES is not set 283# CONFIG_SYN_COOKIES is not set
297# CONFIG_INET_AH is not set 284# CONFIG_INET_AH is not set
@@ -299,19 +286,19 @@ CONFIG_IP_PNP_DHCP=y
299# CONFIG_INET_IPCOMP is not set 286# CONFIG_INET_IPCOMP is not set
300# CONFIG_INET_XFRM_TUNNEL is not set 287# CONFIG_INET_XFRM_TUNNEL is not set
301# CONFIG_INET_TUNNEL is not set 288# CONFIG_INET_TUNNEL is not set
302CONFIG_INET_XFRM_MODE_TRANSPORT=y 289# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
303CONFIG_INET_XFRM_MODE_TUNNEL=y 290# CONFIG_INET_XFRM_MODE_TUNNEL is not set
304CONFIG_INET_XFRM_MODE_BEET=y 291# CONFIG_INET_XFRM_MODE_BEET is not set
305CONFIG_INET_DIAG=y 292CONFIG_INET_DIAG=y
306CONFIG_INET_TCP_DIAG=y 293CONFIG_INET_TCP_DIAG=y
307# CONFIG_TCP_CONG_ADVANCED is not set 294# CONFIG_TCP_CONG_ADVANCED is not set
308CONFIG_TCP_CONG_CUBIC=y 295CONFIG_TCP_CONG_CUBIC=y
309CONFIG_DEFAULT_TCP_CONG="cubic" 296CONFIG_DEFAULT_TCP_CONG="cubic"
310CONFIG_TCP_MD5SIG=y 297# CONFIG_TCP_MD5SIG is not set
311# CONFIG_IPV6 is not set 298# CONFIG_IPV6 is not set
312# CONFIG_INET6_XFRM_TUNNEL is not set 299# CONFIG_INET6_XFRM_TUNNEL is not set
313# CONFIG_INET6_TUNNEL is not set 300# CONFIG_INET6_TUNNEL is not set
314CONFIG_NETWORK_SECMARK=y 301# CONFIG_NETWORK_SECMARK is not set
315# CONFIG_NETFILTER is not set 302# CONFIG_NETFILTER is not set
316 303
317# 304#
@@ -352,13 +339,16 @@ CONFIG_NETWORK_SECMARK=y
352# CONFIG_HAMRADIO is not set 339# CONFIG_HAMRADIO is not set
353# CONFIG_IRDA is not set 340# CONFIG_IRDA is not set
354# CONFIG_BT is not set 341# CONFIG_BT is not set
355CONFIG_IEEE80211=y 342# CONFIG_AF_RXRPC is not set
356# CONFIG_IEEE80211_DEBUG is not set 343
357CONFIG_IEEE80211_CRYPT_WEP=y 344#
358CONFIG_IEEE80211_CRYPT_CCMP=y 345# Wireless
359CONFIG_IEEE80211_SOFTMAC=y 346#
360# CONFIG_IEEE80211_SOFTMAC_DEBUG is not set 347# CONFIG_CFG80211 is not set
361CONFIG_WIRELESS_EXT=y 348# CONFIG_WIRELESS_EXT is not set
349# CONFIG_MAC80211 is not set
350# CONFIG_IEEE80211 is not set
351# CONFIG_RFKILL is not set
362 352
363# 353#
364# Device Drivers 354# Device Drivers
@@ -369,18 +359,12 @@ CONFIG_WIRELESS_EXT=y
369# 359#
370CONFIG_STANDALONE=y 360CONFIG_STANDALONE=y
371CONFIG_PREVENT_FIRMWARE_BUILD=y 361CONFIG_PREVENT_FIRMWARE_BUILD=y
372CONFIG_FW_LOADER=y
373# CONFIG_SYS_HYPERVISOR is not set 362# CONFIG_SYS_HYPERVISOR is not set
374 363
375# 364#
376# Connector - unified userspace <-> kernelspace linker 365# Connector - unified userspace <-> kernelspace linker
377# 366#
378CONFIG_CONNECTOR=y 367# CONFIG_CONNECTOR is not set
379CONFIG_PROC_EVENTS=y
380
381#
382# Memory Technology Devices (MTD)
383#
384# CONFIG_MTD is not set 368# CONFIG_MTD is not set
385 369
386# 370#
@@ -401,21 +385,24 @@ CONFIG_PROC_EVENTS=y
401# CONFIG_BLK_DEV_DAC960 is not set 385# CONFIG_BLK_DEV_DAC960 is not set
402# CONFIG_BLK_DEV_UMEM is not set 386# CONFIG_BLK_DEV_UMEM is not set
403# CONFIG_BLK_DEV_COW_COMMON is not set 387# CONFIG_BLK_DEV_COW_COMMON is not set
404# CONFIG_BLK_DEV_LOOP is not set 388CONFIG_BLK_DEV_LOOP=y
389# CONFIG_BLK_DEV_CRYPTOLOOP is not set
405# CONFIG_BLK_DEV_NBD is not set 390# CONFIG_BLK_DEV_NBD is not set
406# CONFIG_BLK_DEV_SX8 is not set 391# CONFIG_BLK_DEV_SX8 is not set
407# CONFIG_BLK_DEV_RAM is not set 392CONFIG_BLK_DEV_RAM=y
408# CONFIG_BLK_DEV_INITRD is not set 393CONFIG_BLK_DEV_RAM_COUNT=16
409CONFIG_CDROM_PKTCDVD=y 394CONFIG_BLK_DEV_RAM_SIZE=8192
410CONFIG_CDROM_PKTCDVD_BUFFERS=8 395CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
411# CONFIG_CDROM_PKTCDVD_WCACHE is not set 396# CONFIG_CDROM_PKTCDVD is not set
412CONFIG_ATA_OVER_ETH=y 397# CONFIG_ATA_OVER_ETH is not set
413 398
414# 399#
415# Misc devices 400# Misc devices
416# 401#
417CONFIG_SGI_IOC4=y 402# CONFIG_PHANTOM is not set
403# CONFIG_SGI_IOC4 is not set
418# CONFIG_TIFM_CORE is not set 404# CONFIG_TIFM_CORE is not set
405# CONFIG_BLINK is not set
419 406
420# 407#
421# ATA/ATAPI/MFM/RLL support 408# ATA/ATAPI/MFM/RLL support
@@ -425,7 +412,7 @@ CONFIG_SGI_IOC4=y
425# 412#
426# SCSI device support 413# SCSI device support
427# 414#
428CONFIG_RAID_ATTRS=y 415# CONFIG_RAID_ATTRS is not set
429# CONFIG_SCSI is not set 416# CONFIG_SCSI is not set
430# CONFIG_SCSI_NETLINK is not set 417# CONFIG_SCSI_NETLINK is not set
431 418
@@ -471,27 +458,13 @@ CONFIG_NETDEVICES=y
471# 458#
472# PHY device support 459# PHY device support
473# 460#
474CONFIG_PHYLIB=y 461# CONFIG_PHYLIB is not set
475
476#
477# MII PHY device drivers
478#
479CONFIG_MARVELL_PHY=y
480CONFIG_DAVICOM_PHY=y
481CONFIG_QSEMI_PHY=y
482CONFIG_LXT_PHY=y
483CONFIG_CICADA_PHY=y
484CONFIG_VITESSE_PHY=y
485CONFIG_SMSC_PHY=y
486# CONFIG_BROADCOM_PHY is not set
487# CONFIG_FIXED_PHY is not set
488 462
489# 463#
490# Ethernet (10 or 100Mbit) 464# Ethernet (10 or 100Mbit)
491# 465#
492CONFIG_NET_ETHERNET=y 466CONFIG_NET_ETHERNET=y
493CONFIG_MII=y 467# CONFIG_MII is not set
494CONFIG_GALILEO_64240_ETH=y
495# CONFIG_HAPPYMEAL is not set 468# CONFIG_HAPPYMEAL is not set
496# CONFIG_SUNGEM is not set 469# CONFIG_SUNGEM is not set
497# CONFIG_CASSINI is not set 470# CONFIG_CASSINI is not set
@@ -503,6 +476,7 @@ CONFIG_GALILEO_64240_ETH=y
503# 476#
504# CONFIG_NET_TULIP is not set 477# CONFIG_NET_TULIP is not set
505# CONFIG_HP100 is not set 478# CONFIG_HP100 is not set
479CONFIG_NE2000=y
506# CONFIG_NET_PCI is not set 480# CONFIG_NET_PCI is not set
507 481
508# 482#
@@ -521,18 +495,18 @@ CONFIG_GALILEO_64240_ETH=y
521# CONFIG_SK98LIN is not set 495# CONFIG_SK98LIN is not set
522# CONFIG_TIGON3 is not set 496# CONFIG_TIGON3 is not set
523# CONFIG_BNX2 is not set 497# CONFIG_BNX2 is not set
524CONFIG_QLA3XXX=y 498# CONFIG_QLA3XXX is not set
525# CONFIG_ATL1 is not set 499# CONFIG_ATL1 is not set
526 500
527# 501#
528# Ethernet (10000 Mbit) 502# Ethernet (10000 Mbit)
529# 503#
530# CONFIG_CHELSIO_T1 is not set 504# CONFIG_CHELSIO_T1 is not set
531CONFIG_CHELSIO_T3=y 505# CONFIG_CHELSIO_T3 is not set
532# CONFIG_IXGB is not set 506# CONFIG_IXGB is not set
533# CONFIG_S2IO is not set 507# CONFIG_S2IO is not set
534# CONFIG_MYRI10GE is not set 508# CONFIG_MYRI10GE is not set
535CONFIG_NETXEN_NIC=y 509# CONFIG_NETXEN_NIC is not set
536 510
537# 511#
538# Token Ring devices 512# Token Ring devices
@@ -540,9 +514,10 @@ CONFIG_NETXEN_NIC=y
540# CONFIG_TR is not set 514# CONFIG_TR is not set
541 515
542# 516#
543# Wireless LAN (non-hamradio) 517# Wireless LAN
544# 518#
545# CONFIG_NET_RADIO is not set 519# CONFIG_WLAN_PRE80211 is not set
520# CONFIG_WLAN_80211 is not set
546 521
547# 522#
548# Wan interfaces 523# Wan interfaces
@@ -570,29 +545,7 @@ CONFIG_NETXEN_NIC=y
570# 545#
571# Input device support 546# Input device support
572# 547#
573CONFIG_INPUT=y 548# CONFIG_INPUT is not set
574# CONFIG_INPUT_FF_MEMLESS is not set
575
576#
577# Userland interfaces
578#
579CONFIG_INPUT_MOUSEDEV=y
580CONFIG_INPUT_MOUSEDEV_PSAUX=y
581CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
582CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
583# CONFIG_INPUT_JOYDEV is not set
584# CONFIG_INPUT_TSDEV is not set
585# CONFIG_INPUT_EVDEV is not set
586# CONFIG_INPUT_EVBUG is not set
587
588#
589# Input Device Drivers
590#
591# CONFIG_INPUT_KEYBOARD is not set
592# CONFIG_INPUT_MOUSE is not set
593# CONFIG_INPUT_JOYSTICK is not set
594# CONFIG_INPUT_TOUCHSCREEN is not set
595# CONFIG_INPUT_MISC is not set
596 549
597# 550#
598# Hardware I/O ports 551# Hardware I/O ports
@@ -601,34 +554,31 @@ CONFIG_SERIO=y
601# CONFIG_SERIO_I8042 is not set 554# CONFIG_SERIO_I8042 is not set
602CONFIG_SERIO_SERPORT=y 555CONFIG_SERIO_SERPORT=y
603# CONFIG_SERIO_PCIPS2 is not set 556# CONFIG_SERIO_PCIPS2 is not set
604# CONFIG_SERIO_LIBPS2 is not set 557CONFIG_SERIO_LIBPS2=y
605CONFIG_SERIO_RAW=y 558# CONFIG_SERIO_RAW is not set
606# CONFIG_GAMEPORT is not set 559# CONFIG_GAMEPORT is not set
607 560
608# 561#
609# Character devices 562# Character devices
610# 563#
611CONFIG_VT=y 564# CONFIG_VT is not set
612CONFIG_VT_CONSOLE=y
613CONFIG_HW_CONSOLE=y
614CONFIG_VT_HW_CONSOLE_BINDING=y
615# CONFIG_SERIAL_NONSTANDARD is not set 565# CONFIG_SERIAL_NONSTANDARD is not set
616 566
617# 567#
618# Serial drivers 568# Serial drivers
619# 569#
620CONFIG_SERIAL_8250=y 570# CONFIG_SERIAL_8250 is not set
621CONFIG_SERIAL_8250_CONSOLE=y
622CONFIG_SERIAL_8250_PCI=y
623CONFIG_SERIAL_8250_NR_UARTS=4
624CONFIG_SERIAL_8250_RUNTIME_UARTS=4
625# CONFIG_SERIAL_8250_EXTENDED is not set
626 571
627# 572#
628# Non-8250 serial port support 573# Non-8250 serial port support
629# 574#
630CONFIG_SERIAL_CORE=y 575CONFIG_SERIAL_CORE=y
631CONFIG_SERIAL_CORE_CONSOLE=y 576CONFIG_SERIAL_CORE_CONSOLE=y
577CONFIG_SERIAL_TXX9=y
578CONFIG_HAS_TXX9_SERIAL=y
579CONFIG_SERIAL_TXX9_NR_UARTS=6
580CONFIG_SERIAL_TXX9_CONSOLE=y
581CONFIG_SERIAL_TXX9_STDSERIAL=y
632# CONFIG_SERIAL_JSM is not set 582# CONFIG_SERIAL_JSM is not set
633CONFIG_UNIX98_PTYS=y 583CONFIG_UNIX98_PTYS=y
634CONFIG_LEGACY_PTYS=y 584CONFIG_LEGACY_PTYS=y
@@ -656,10 +606,7 @@ CONFIG_LEGACY_PTY_COUNT=256
656# TPM devices 606# TPM devices
657# 607#
658# CONFIG_TCG_TPM is not set 608# CONFIG_TCG_TPM is not set
659 609CONFIG_DEVPORT=y
660#
661# I2C support
662#
663# CONFIG_I2C is not set 610# CONFIG_I2C is not set
664 611
665# 612#
@@ -672,12 +619,12 @@ CONFIG_LEGACY_PTY_COUNT=256
672# Dallas's 1-wire bus 619# Dallas's 1-wire bus
673# 620#
674# CONFIG_W1 is not set 621# CONFIG_W1 is not set
622# CONFIG_HWMON is not set
675 623
676# 624#
677# Hardware Monitoring support 625# Multifunction device drivers
678# 626#
679# CONFIG_HWMON is not set 627# CONFIG_MFD_SM501 is not set
680# CONFIG_HWMON_VID is not set
681 628
682# 629#
683# Multimedia devices 630# Multimedia devices
@@ -692,15 +639,14 @@ CONFIG_LEGACY_PTY_COUNT=256
692# 639#
693# Graphics support 640# Graphics support
694# 641#
695# CONFIG_FIRMWARE_EDID is not set 642# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
696# CONFIG_FB is not set
697 643
698# 644#
699# Console display driver support 645# Display device support
700# 646#
701# CONFIG_VGA_CONSOLE is not set 647# CONFIG_DISPLAY_SUPPORT is not set
702CONFIG_DUMMY_CONSOLE=y 648# CONFIG_VGASTATE is not set
703# CONFIG_BACKLIGHT_LCD_SUPPORT is not set 649# CONFIG_FB is not set
704 650
705# 651#
706# Sound 652# Sound
@@ -708,11 +654,6 @@ CONFIG_DUMMY_CONSOLE=y
708# CONFIG_SOUND is not set 654# CONFIG_SOUND is not set
709 655
710# 656#
711# HID Devices
712#
713# CONFIG_HID is not set
714
715#
716# USB support 657# USB support
717# 658#
718CONFIG_USB_ARCH_HAS_HCD=y 659CONFIG_USB_ARCH_HAS_HCD=y
@@ -728,10 +669,6 @@ CONFIG_USB_ARCH_HAS_EHCI=y
728# USB Gadget Support 669# USB Gadget Support
729# 670#
730# CONFIG_USB_GADGET is not set 671# CONFIG_USB_GADGET is not set
731
732#
733# MMC/SD Card support
734#
735# CONFIG_MMC is not set 672# CONFIG_MMC is not set
736 673
737# 674#
@@ -759,7 +696,40 @@ CONFIG_USB_ARCH_HAS_EHCI=y
759# 696#
760# Real Time Clock 697# Real Time Clock
761# 698#
762# CONFIG_RTC_CLASS is not set 699CONFIG_RTC_LIB=y
700CONFIG_RTC_CLASS=y
701CONFIG_RTC_HCTOSYS=y
702CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
703# CONFIG_RTC_DEBUG is not set
704
705#
706# RTC interfaces
707#
708CONFIG_RTC_INTF_SYSFS=y
709CONFIG_RTC_INTF_PROC=y
710CONFIG_RTC_INTF_DEV=y
711# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
712# CONFIG_RTC_DRV_TEST is not set
713
714#
715# I2C RTC drivers
716#
717
718#
719# SPI RTC drivers
720#
721
722#
723# Platform RTC drivers
724#
725# CONFIG_RTC_DRV_DS1553 is not set
726CONFIG_RTC_DRV_DS1742=y
727# CONFIG_RTC_DRV_M48T86 is not set
728# CONFIG_RTC_DRV_V3020 is not set
729
730#
731# on-CPU RTC drivers
732#
763 733
764# 734#
765# DMA Engine support 735# DMA Engine support
@@ -785,9 +755,7 @@ CONFIG_USB_ARCH_HAS_EHCI=y
785# 755#
786# File systems 756# File systems
787# 757#
788CONFIG_EXT2_FS=y 758# CONFIG_EXT2_FS is not set
789# CONFIG_EXT2_FS_XATTR is not set
790# CONFIG_EXT2_FS_XIP is not set
791# CONFIG_EXT3_FS is not set 759# CONFIG_EXT3_FS is not set
792# CONFIG_EXT4DEV_FS is not set 760# CONFIG_EXT4DEV_FS is not set
793# CONFIG_REISERFS_FS is not set 761# CONFIG_REISERFS_FS is not set
@@ -801,10 +769,10 @@ CONFIG_FS_POSIX_ACL=y
801CONFIG_INOTIFY=y 769CONFIG_INOTIFY=y
802CONFIG_INOTIFY_USER=y 770CONFIG_INOTIFY_USER=y
803# CONFIG_QUOTA is not set 771# CONFIG_QUOTA is not set
804CONFIG_DNOTIFY=y 772# CONFIG_DNOTIFY is not set
805# CONFIG_AUTOFS_FS is not set 773# CONFIG_AUTOFS_FS is not set
806# CONFIG_AUTOFS4_FS is not set 774# CONFIG_AUTOFS4_FS is not set
807CONFIG_FUSE_FS=y 775# CONFIG_FUSE_FS is not set
808CONFIG_GENERIC_ACL=y 776CONFIG_GENERIC_ACL=y
809 777
810# 778#
@@ -824,21 +792,20 @@ CONFIG_GENERIC_ACL=y
824# Pseudo filesystems 792# Pseudo filesystems
825# 793#
826CONFIG_PROC_FS=y 794CONFIG_PROC_FS=y
827CONFIG_PROC_KCORE=y 795# CONFIG_PROC_KCORE is not set
828CONFIG_PROC_SYSCTL=y 796CONFIG_PROC_SYSCTL=y
829CONFIG_SYSFS=y 797CONFIG_SYSFS=y
830CONFIG_TMPFS=y 798CONFIG_TMPFS=y
831CONFIG_TMPFS_POSIX_ACL=y 799CONFIG_TMPFS_POSIX_ACL=y
832# CONFIG_HUGETLB_PAGE is not set 800# CONFIG_HUGETLB_PAGE is not set
833CONFIG_RAMFS=y 801CONFIG_RAMFS=y
834CONFIG_CONFIGFS_FS=y 802# CONFIG_CONFIGFS_FS is not set
835 803
836# 804#
837# Miscellaneous filesystems 805# Miscellaneous filesystems
838# 806#
839# CONFIG_ADFS_FS is not set 807# CONFIG_ADFS_FS is not set
840# CONFIG_AFFS_FS is not set 808# CONFIG_AFFS_FS is not set
841# CONFIG_ECRYPT_FS is not set
842# CONFIG_HFS_FS is not set 809# CONFIG_HFS_FS is not set
843# CONFIG_HFSPLUS_FS is not set 810# CONFIG_HFSPLUS_FS is not set
844# CONFIG_BEFS_FS is not set 811# CONFIG_BEFS_FS is not set
@@ -855,17 +822,17 @@ CONFIG_CONFIGFS_FS=y
855# Network File Systems 822# Network File Systems
856# 823#
857CONFIG_NFS_FS=y 824CONFIG_NFS_FS=y
858# CONFIG_NFS_V3 is not set 825CONFIG_NFS_V3=y
826# CONFIG_NFS_V3_ACL is not set
859# CONFIG_NFS_V4 is not set 827# CONFIG_NFS_V4 is not set
860# CONFIG_NFS_DIRECTIO is not set 828# CONFIG_NFS_DIRECTIO is not set
861CONFIG_NFSD=y 829# CONFIG_NFSD is not set
862# CONFIG_NFSD_V3 is not set
863# CONFIG_NFSD_TCP is not set
864CONFIG_ROOT_NFS=y 830CONFIG_ROOT_NFS=y
865CONFIG_LOCKD=y 831CONFIG_LOCKD=y
866CONFIG_EXPORTFS=y 832CONFIG_LOCKD_V4=y
867CONFIG_NFS_COMMON=y 833CONFIG_NFS_COMMON=y
868CONFIG_SUNRPC=y 834CONFIG_SUNRPC=y
835# CONFIG_SUNRPC_BIND34 is not set
869# CONFIG_RPCSEC_GSS_KRB5 is not set 836# CONFIG_RPCSEC_GSS_KRB5 is not set
870# CONFIG_RPCSEC_GSS_SPKM3 is not set 837# CONFIG_RPCSEC_GSS_SPKM3 is not set
871# CONFIG_SMB_FS is not set 838# CONFIG_SMB_FS is not set
@@ -889,10 +856,7 @@ CONFIG_MSDOS_PARTITION=y
889# 856#
890# Distributed Lock Manager 857# Distributed Lock Manager
891# 858#
892CONFIG_DLM=y 859# CONFIG_DLM is not set
893CONFIG_DLM_TCP=y
894# CONFIG_DLM_SCTP is not set
895# CONFIG_DLM_DEBUG is not set
896 860
897# 861#
898# Profiling support 862# Profiling support
@@ -910,72 +874,29 @@ CONFIG_ENABLE_MUST_CHECK=y
910# CONFIG_DEBUG_FS is not set 874# CONFIG_DEBUG_FS is not set
911# CONFIG_HEADERS_CHECK is not set 875# CONFIG_HEADERS_CHECK is not set
912# CONFIG_DEBUG_KERNEL is not set 876# CONFIG_DEBUG_KERNEL is not set
913CONFIG_LOG_BUF_SHIFT=14
914CONFIG_CROSSCOMPILE=y 877CONFIG_CROSSCOMPILE=y
915CONFIG_CMDLINE="" 878CONFIG_CMDLINE=""
879CONFIG_SYS_SUPPORTS_KGDB=y
916 880
917# 881#
918# Security options 882# Security options
919# 883#
920CONFIG_KEYS=y 884# CONFIG_KEYS is not set
921CONFIG_KEYS_DEBUG_PROC_KEYS=y
922# CONFIG_SECURITY is not set 885# CONFIG_SECURITY is not set
923 886
924# 887#
925# Cryptographic options 888# Cryptographic options
926# 889#
927CONFIG_CRYPTO=y 890# CONFIG_CRYPTO is not set
928CONFIG_CRYPTO_ALGAPI=y
929CONFIG_CRYPTO_BLKCIPHER=y
930CONFIG_CRYPTO_HASH=y
931CONFIG_CRYPTO_MANAGER=y
932CONFIG_CRYPTO_HMAC=y
933CONFIG_CRYPTO_XCBC=y
934CONFIG_CRYPTO_NULL=y
935CONFIG_CRYPTO_MD4=y
936CONFIG_CRYPTO_MD5=y
937CONFIG_CRYPTO_SHA1=y
938CONFIG_CRYPTO_SHA256=y
939CONFIG_CRYPTO_SHA512=y
940CONFIG_CRYPTO_WP512=y
941CONFIG_CRYPTO_TGR192=y
942CONFIG_CRYPTO_GF128MUL=y
943CONFIG_CRYPTO_ECB=y
944CONFIG_CRYPTO_CBC=y
945CONFIG_CRYPTO_PCBC=y
946CONFIG_CRYPTO_LRW=y
947CONFIG_CRYPTO_DES=y
948CONFIG_CRYPTO_FCRYPT=y
949CONFIG_CRYPTO_BLOWFISH=y
950CONFIG_CRYPTO_TWOFISH=y
951CONFIG_CRYPTO_TWOFISH_COMMON=y
952CONFIG_CRYPTO_SERPENT=y
953CONFIG_CRYPTO_AES=y
954CONFIG_CRYPTO_CAST5=y
955CONFIG_CRYPTO_CAST6=y
956CONFIG_CRYPTO_TEA=y
957CONFIG_CRYPTO_ARC4=y
958CONFIG_CRYPTO_KHAZAD=y
959CONFIG_CRYPTO_ANUBIS=y
960CONFIG_CRYPTO_DEFLATE=y
961CONFIG_CRYPTO_MICHAEL_MIC=y
962CONFIG_CRYPTO_CRC32C=y
963CONFIG_CRYPTO_CAMELLIA=y
964
965#
966# Hardware crypto devices
967#
968 891
969# 892#
970# Library routines 893# Library routines
971# 894#
972CONFIG_BITREVERSE=y 895CONFIG_BITREVERSE=y
973# CONFIG_CRC_CCITT is not set 896# CONFIG_CRC_CCITT is not set
974CONFIG_CRC16=y 897# CONFIG_CRC16 is not set
975CONFIG_CRC32=y 898CONFIG_CRC32=y
976CONFIG_LIBCRC32C=y 899# CONFIG_LIBCRC32C is not set
977CONFIG_ZLIB_INFLATE=y
978CONFIG_ZLIB_DEFLATE=y
979CONFIG_PLIST=y
980CONFIG_HAS_IOMEM=y 900CONFIG_HAS_IOMEM=y
981CONFIG_HAS_IOPORT=y 901CONFIG_HAS_IOPORT=y
902CONFIG_HAS_DMA=y
diff --git a/arch/mips/configs/rbhma4500_defconfig b/arch/mips/configs/rbhma4500_defconfig
index 7d0f2174614e..41011f770a67 100644
--- a/arch/mips/configs/rbhma4500_defconfig
+++ b/arch/mips/configs/rbhma4500_defconfig
@@ -89,7 +89,6 @@ CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
89CONFIG_SWAP_IO_SPACE=y 89CONFIG_SWAP_IO_SPACE=y
90CONFIG_MIPS_L1_CACHE_SHIFT=5 90CONFIG_MIPS_L1_CACHE_SHIFT=5
91CONFIG_HAVE_STD_PC_SERIAL_PORT=y 91CONFIG_HAVE_STD_PC_SERIAL_PORT=y
92CONFIG_TOSHIBA_BOARDS=y
93 92
94# 93#
95# CPU selection 94# CPU selection
diff --git a/arch/mips/configs/tb0229_defconfig b/arch/mips/configs/tb0219_defconfig
index 1756d2bdf6b8..8b1675c07ec4 100644
--- a/arch/mips/configs/tb0229_defconfig
+++ b/arch/mips/configs/tb0219_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.20 3# Linux kernel version: 2.6.21-rc6
4# Tue Feb 20 21:47:41 2007 4# Sun Apr 15 01:06:01 2007
5# 5#
6CONFIG_MIPS=y 6CONFIG_MIPS=y
7 7
@@ -66,10 +66,11 @@ CONFIG_MACH_VR41XX=y
66# CONFIG_IBM_WORKPAD is not set 66# CONFIG_IBM_WORKPAD is not set
67# CONFIG_NEC_CMBVR4133 is not set 67# CONFIG_NEC_CMBVR4133 is not set
68CONFIG_TANBAC_TB022X=y 68CONFIG_TANBAC_TB022X=y
69# CONFIG_TANBAC_TB0226 is not set
70# CONFIG_TANBAC_TB0287 is not set
71# CONFIG_VICTOR_MPC30X is not set 69# CONFIG_VICTOR_MPC30X is not set
72# CONFIG_ZAO_CAPCELLA is not set 70# CONFIG_ZAO_CAPCELLA is not set
71CONFIG_TANBAC_TB0219=y
72# CONFIG_TANBAC_TB0226 is not set
73# CONFIG_TANBAC_TB0287 is not set
73CONFIG_PCI_VR41XX=y 74CONFIG_PCI_VR41XX=y
74CONFIG_RWSEM_GENERIC_SPINLOCK=y 75CONFIG_RWSEM_GENERIC_SPINLOCK=y
75# CONFIG_ARCH_HAS_ILOG2_U32 is not set 76# CONFIG_ARCH_HAS_ILOG2_U32 is not set
@@ -184,6 +185,7 @@ CONFIG_SYSVIPC_SYSCTL=y
184# CONFIG_IKCONFIG is not set 185# CONFIG_IKCONFIG is not set
185CONFIG_SYSFS_DEPRECATED=y 186CONFIG_SYSFS_DEPRECATED=y
186# CONFIG_RELAY is not set 187# CONFIG_RELAY is not set
188# CONFIG_BLK_DEV_INITRD is not set
187# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 189# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
188CONFIG_SYSCTL=y 190CONFIG_SYSCTL=y
189CONFIG_EMBEDDED=y 191CONFIG_EMBEDDED=y
@@ -375,7 +377,7 @@ CONFIG_FIB_RULES=y
375# 377#
376CONFIG_STANDALONE=y 378CONFIG_STANDALONE=y
377CONFIG_PREVENT_FIRMWARE_BUILD=y 379CONFIG_PREVENT_FIRMWARE_BUILD=y
378# CONFIG_FW_LOADER is not set 380CONFIG_FW_LOADER=m
379# CONFIG_SYS_HYPERVISOR is not set 381# CONFIG_SYS_HYPERVISOR is not set
380 382
381# 383#
@@ -415,7 +417,6 @@ CONFIG_BLK_DEV_RAM=y
415CONFIG_BLK_DEV_RAM_COUNT=16 417CONFIG_BLK_DEV_RAM_COUNT=16
416CONFIG_BLK_DEV_RAM_SIZE=4096 418CONFIG_BLK_DEV_RAM_SIZE=4096
417CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 419CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
418# CONFIG_BLK_DEV_INITRD is not set
419# CONFIG_CDROM_PKTCDVD is not set 420# CONFIG_CDROM_PKTCDVD is not set
420# CONFIG_ATA_OVER_ETH is not set 421# CONFIG_ATA_OVER_ETH is not set
421 422
@@ -646,7 +647,7 @@ CONFIG_LEGACY_PTY_COUNT=256
646# CONFIG_DTLK is not set 647# CONFIG_DTLK is not set
647# CONFIG_R3964 is not set 648# CONFIG_R3964 is not set
648# CONFIG_APPLICOM is not set 649# CONFIG_APPLICOM is not set
649CONFIG_TANBAC_TB0219=y 650CONFIG_GPIO_TB0219=y
650# CONFIG_DRM is not set 651# CONFIG_DRM is not set
651CONFIG_GPIO_VR41XX=y 652CONFIG_GPIO_VR41XX=y
652# CONFIG_RAW_DRIVER is not set 653# CONFIG_RAW_DRIVER is not set
@@ -679,6 +680,11 @@ CONFIG_GPIO_VR41XX=y
679# CONFIG_HWMON_VID is not set 680# CONFIG_HWMON_VID is not set
680 681
681# 682#
683# Multifunction device drivers
684#
685# CONFIG_MFD_SM501 is not set
686
687#
682# Multimedia devices 688# Multimedia devices
683# 689#
684# CONFIG_VIDEO_DEV is not set 690# CONFIG_VIDEO_DEV is not set
@@ -692,7 +698,7 @@ CONFIG_GPIO_VR41XX=y
692# 698#
693# Graphics support 699# Graphics support
694# 700#
695# CONFIG_FIRMWARE_EDID is not set 701# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
696# CONFIG_FB is not set 702# CONFIG_FB is not set
697 703
698# 704#
@@ -700,7 +706,6 @@ CONFIG_GPIO_VR41XX=y
700# 706#
701# CONFIG_VGA_CONSOLE is not set 707# CONFIG_VGA_CONSOLE is not set
702CONFIG_DUMMY_CONSOLE=y 708CONFIG_DUMMY_CONSOLE=y
703# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
704 709
705# 710#
706# Sound 711# Sound
@@ -831,6 +836,7 @@ CONFIG_USB_MON=y
831# CONFIG_USB_SISUSBVGA is not set 836# CONFIG_USB_SISUSBVGA is not set
832# CONFIG_USB_LD is not set 837# CONFIG_USB_LD is not set
833# CONFIG_USB_TRANCEVIBRATOR is not set 838# CONFIG_USB_TRANCEVIBRATOR is not set
839# CONFIG_USB_IOWARRIOR is not set
834# CONFIG_USB_TEST is not set 840# CONFIG_USB_TEST is not set
835 841
836# 842#
diff --git a/arch/mips/kernel/early_printk.c b/arch/mips/kernel/early_printk.c
index 4fa54b230c09..9dccfa4752b2 100644
--- a/arch/mips/kernel/early_printk.c
+++ b/arch/mips/kernel/early_printk.c
@@ -12,7 +12,8 @@
12 12
13extern void prom_putchar(char); 13extern void prom_putchar(char);
14 14
15static void early_console_write(struct console *con, const char *s, unsigned n) 15static void __init
16early_console_write(struct console *con, const char *s, unsigned n)
16{ 17{
17 while (n-- && *s) { 18 while (n-- && *s) {
18 if (*s == '\n') 19 if (*s == '\n')
@@ -22,14 +23,20 @@ static void early_console_write(struct console *con, const char *s, unsigned n)
22 } 23 }
23} 24}
24 25
25static struct console early_console = { 26static struct console early_console __initdata = {
26 .name = "early", 27 .name = "early",
27 .write = early_console_write, 28 .write = early_console_write,
28 .flags = CON_PRINTBUFFER | CON_BOOT, 29 .flags = CON_PRINTBUFFER | CON_BOOT,
29 .index = -1 30 .index = -1
30}; 31};
31 32
33static int early_console_initialized __initdata;
34
32void __init setup_early_printk(void) 35void __init setup_early_printk(void)
33{ 36{
37 if (early_console_initialized)
38 return;
39 early_console_initialized = 1;
40
34 register_console(&early_console); 41 register_console(&early_console);
35} 42}
diff --git a/arch/mips/kernel/irq-msc01.c b/arch/mips/kernel/irq-msc01.c
index 2967537221e2..410868b5ea5f 100644
--- a/arch/mips/kernel/irq-msc01.c
+++ b/arch/mips/kernel/irq-msc01.c
@@ -132,11 +132,11 @@ struct irq_chip msc_edgeirq_type = {
132}; 132};
133 133
134 134
135void __init init_msc_irqs(unsigned int base, msc_irqmap_t *imp, int nirq) 135void __init init_msc_irqs(unsigned long icubase, unsigned int irqbase, msc_irqmap_t *imp, int nirq)
136{ 136{
137 extern void (*board_bind_eic_interrupt)(unsigned int irq, unsigned int regset); 137 extern void (*board_bind_eic_interrupt)(unsigned int irq, unsigned int regset);
138 138
139 _icctrl_msc = (unsigned long) ioremap (MIPS_MSC01_IC_REG_BASE, 0x40000); 139 _icctrl_msc = (unsigned long) ioremap (icubase, 0x40000);
140 140
141 /* Reset interrupt controller - initialises all registers to 0 */ 141 /* Reset interrupt controller - initialises all registers to 0 */
142 MSCIC_WRITE(MSC01_IC_RST, MSC01_IC_RST_RST_BIT); 142 MSCIC_WRITE(MSC01_IC_RST, MSC01_IC_RST_RST_BIT);
@@ -148,14 +148,14 @@ void __init init_msc_irqs(unsigned int base, msc_irqmap_t *imp, int nirq)
148 148
149 switch (imp->im_type) { 149 switch (imp->im_type) {
150 case MSC01_IRQ_EDGE: 150 case MSC01_IRQ_EDGE:
151 set_irq_chip(base+n, &msc_edgeirq_type); 151 set_irq_chip(irqbase+n, &msc_edgeirq_type);
152 if (cpu_has_veic) 152 if (cpu_has_veic)
153 MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT); 153 MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT);
154 else 154 else
155 MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT | imp->im_lvl); 155 MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT | imp->im_lvl);
156 break; 156 break;
157 case MSC01_IRQ_LEVEL: 157 case MSC01_IRQ_LEVEL:
158 set_irq_chip(base+n, &msc_levelirq_type); 158 set_irq_chip(irqbase+n, &msc_levelirq_type);
159 if (cpu_has_veic) 159 if (cpu_has_veic)
160 MSCIC_WRITE(MSC01_IC_SUP+n*8, 0); 160 MSCIC_WRITE(MSC01_IC_SUP+n*8, 0);
161 else 161 else
@@ -163,7 +163,7 @@ void __init init_msc_irqs(unsigned int base, msc_irqmap_t *imp, int nirq)
163 } 163 }
164 } 164 }
165 165
166 irq_base = base; 166 irq_base = irqbase;
167 167
168 MSCIC_WRITE(MSC01_IC_GENA, MSC01_IC_GENA_GENA_BIT); /* Enable interrupt generation */ 168 MSCIC_WRITE(MSC01_IC_GENA, MSC01_IC_GENA_GENA_BIT); /* Enable interrupt generation */
169 169
diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
index 2fe4c868a801..aeded6c17de5 100644
--- a/arch/mips/kernel/irq.c
+++ b/arch/mips/kernel/irq.c
@@ -28,7 +28,7 @@
28 28
29static unsigned long irq_map[NR_IRQS / BITS_PER_LONG]; 29static unsigned long irq_map[NR_IRQS / BITS_PER_LONG];
30 30
31int __devinit allocate_irqno(void) 31int allocate_irqno(void)
32{ 32{
33 int irq; 33 int irq;
34 34
@@ -59,7 +59,7 @@ void __init alloc_legacy_irqno(void)
59 BUG_ON(test_and_set_bit(i, irq_map)); 59 BUG_ON(test_and_set_bit(i, irq_map));
60} 60}
61 61
62void __devinit free_irqno(unsigned int irq) 62void free_irqno(unsigned int irq)
63{ 63{
64 smp_mb__before_clear_bit(); 64 smp_mb__before_clear_bit();
65 clear_bit(irq, irq_map); 65 clear_bit(irq, irq_map);
diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
index e5e56bd498db..751b4a18b133 100644
--- a/arch/mips/kernel/time.c
+++ b/arch/mips/kernel/time.c
@@ -306,7 +306,7 @@ static unsigned int __init calibrate_hpt(void)
306 306
307struct clocksource clocksource_mips = { 307struct clocksource clocksource_mips = {
308 .name = "MIPS", 308 .name = "MIPS",
309 .mask = 0xffffffff, 309 .mask = CLOCKSOURCE_MASK(32),
310 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 310 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
311}; 311};
312 312
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index ff45a4b8fbaa..200de027f354 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -927,9 +927,9 @@ asmlinkage void do_reserved(struct pt_regs *regs)
927 (regs->cp0_cause & 0x7f) >> 2); 927 (regs->cp0_cause & 0x7f) >> 2);
928} 928}
929 929
930asmlinkage void do_default_vi(struct pt_regs *regs) 930static asmlinkage void do_default_vi(void)
931{ 931{
932 show_regs(regs); 932 show_regs(get_irq_regs());
933 panic("Caught unexpected vectored interrupt."); 933 panic("Caught unexpected vectored interrupt.");
934} 934}
935 935
@@ -1128,7 +1128,7 @@ void mips_srs_free(int set)
1128 clear_bit(set, &sr->sr_allocated); 1128 clear_bit(set, &sr->sr_allocated);
1129} 1129}
1130 1130
1131static void *set_vi_srs_handler(int n, void *addr, int srs) 1131static void *set_vi_srs_handler(int n, vi_handler_t addr, int srs)
1132{ 1132{
1133 unsigned long handler; 1133 unsigned long handler;
1134 unsigned long old_handler = vi_handlers[n]; 1134 unsigned long old_handler = vi_handlers[n];
@@ -1217,7 +1217,7 @@ static void *set_vi_srs_handler(int n, void *addr, int srs)
1217 return (void *)old_handler; 1217 return (void *)old_handler;
1218} 1218}
1219 1219
1220void *set_vi_handler(int n, void *addr) 1220void *set_vi_handler(int n, vi_handler_t addr)
1221{ 1221{
1222 return set_vi_srs_handler(n, addr, 0); 1222 return set_vi_srs_handler(n, addr, 0);
1223} 1223}
diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile
index d7d3b14dcfb2..5dad13efba7e 100644
--- a/arch/mips/lib/Makefile
+++ b/arch/mips/lib/Makefile
@@ -9,4 +9,4 @@ obj-y += iomap.o
9obj-$(CONFIG_PCI) += iomap-pci.o 9obj-$(CONFIG_PCI) += iomap-pci.o
10 10
11# libgcc-style stuff needed in the kernel 11# libgcc-style stuff needed in the kernel
12lib-y += ashldi3.o ashrdi3.o lshrdi3.o 12lib-y += ashldi3.o ashrdi3.o lshrdi3.o ucmpdi2.o
diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c
new file mode 100644
index 000000000000..e9ff258ef028
--- /dev/null
+++ b/arch/mips/lib/ucmpdi2.c
@@ -0,0 +1,19 @@
1#include <linux/module.h>
2
3#include "libgcc.h"
4
5word_type __ucmpdi2 (unsigned long a, unsigned long b)
6{
7 const DWunion au = {.ll = a};
8 const DWunion bu = {.ll = b};
9
10 if ((unsigned int) au.s.high < (unsigned int) bu.s.high)
11 return 0;
12 else if ((unsigned int) au.s.high > (unsigned int) bu.s.high)
13 return 2;
14 if ((unsigned int) au.s.low < (unsigned int) bu.s.low)
15 return 0;
16 else if ((unsigned int) au.s.low > (unsigned int) bu.s.low)
17 return 2;
18 return 1;
19}
diff --git a/arch/mips/mips-boards/malta/malta_int.c b/arch/mips/mips-boards/malta/malta_int.c
index 83d76025d61d..1cd830e3d933 100644
--- a/arch/mips/mips-boards/malta/malta_int.c
+++ b/arch/mips/mips-boards/malta/malta_int.c
@@ -311,16 +311,21 @@ void __init arch_init_irq(void)
311 if (!cpu_has_veic) 311 if (!cpu_has_veic)
312 mips_cpu_irq_init(); 312 mips_cpu_irq_init();
313 313
314 switch(mips_revision_corid) { 314 switch(mips_revision_sconid) {
315 case MIPS_REVISION_CORID_CORE_MSC: 315 case MIPS_REVISION_SCON_SOCIT:
316 case MIPS_REVISION_CORID_CORE_FPGA2: 316 case MIPS_REVISION_SCON_ROCIT:
317 case MIPS_REVISION_CORID_CORE_FPGA3: 317 if (cpu_has_veic)
318 case MIPS_REVISION_CORID_CORE_24K: 318 init_msc_irqs (MIPS_MSC01_IC_REG_BASE, MSC01E_INT_BASE, msc_eicirqmap, msc_nr_eicirqs);
319 case MIPS_REVISION_CORID_CORE_EMUL_MSC: 319 else
320 init_msc_irqs (MIPS_MSC01_IC_REG_BASE, MSC01C_INT_BASE, msc_irqmap, msc_nr_irqs);
321 break;
322
323 case MIPS_REVISION_SCON_SOCITSC:
324 case MIPS_REVISION_SCON_SOCITSCP:
320 if (cpu_has_veic) 325 if (cpu_has_veic)
321 init_msc_irqs (MSC01E_INT_BASE, msc_eicirqmap, msc_nr_eicirqs); 326 init_msc_irqs (MIPS_SOCITSC_IC_REG_BASE, MSC01E_INT_BASE, msc_eicirqmap, msc_nr_eicirqs);
322 else 327 else
323 init_msc_irqs (MSC01C_INT_BASE, msc_irqmap, msc_nr_irqs); 328 init_msc_irqs (MIPS_SOCITSC_IC_REG_BASE, MSC01C_INT_BASE, msc_irqmap, msc_nr_irqs);
324 } 329 }
325 330
326 if (cpu_has_veic) { 331 if (cpu_has_veic) {
diff --git a/arch/mips/mm/highmem.c b/arch/mips/mm/highmem.c
index 675502ada5a2..10dd2af2343b 100644
--- a/arch/mips/mm/highmem.c
+++ b/arch/mips/mm/highmem.c
@@ -80,7 +80,6 @@ void __kunmap_atomic(void *kvaddr, enum km_type type)
80 pagefault_enable(); 80 pagefault_enable();
81} 81}
82 82
83#ifndef CONFIG_LIMITED_DMA
84/* 83/*
85 * This is the same as kmap_atomic() but can map memory that doesn't 84 * This is the same as kmap_atomic() but can map memory that doesn't
86 * have a struct page associated with it. 85 * have a struct page associated with it.
@@ -99,7 +98,6 @@ void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
99 98
100 return (void*) vaddr; 99 return (void*) vaddr;
101} 100}
102#endif /* CONFIG_LIMITED_DMA */
103 101
104struct page *__kmap_atomic_to_page(void *ptr) 102struct page *__kmap_atomic_to_page(void *ptr)
105{ 103{
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 2d1c2c024822..4c80528deadd 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -424,9 +424,6 @@ void __init mem_init(void)
424 continue; 424 continue;
425 } 425 }
426 ClearPageReserved(page); 426 ClearPageReserved(page);
427#ifdef CONFIG_LIMITED_DMA
428 set_page_address(page, lowmem_page_address(page));
429#endif
430 init_page_count(page); 427 init_page_count(page);
431 __free_page(page); 428 __free_page(page);
432 totalhigh_pages++; 429 totalhigh_pages++;
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 492c518e7ba5..e7149290d1cb 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -35,24 +35,24 @@
35#include <asm/smp.h> 35#include <asm/smp.h>
36#include <asm/war.h> 36#include <asm/war.h>
37 37
38static __init int __attribute__((unused)) r45k_bvahwbug(void) 38static __init int __maybe_unused r45k_bvahwbug(void)
39{ 39{
40 /* XXX: We should probe for the presence of this bug, but we don't. */ 40 /* XXX: We should probe for the presence of this bug, but we don't. */
41 return 0; 41 return 0;
42} 42}
43 43
44static __init int __attribute__((unused)) r4k_250MHZhwbug(void) 44static __init int __maybe_unused r4k_250MHZhwbug(void)
45{ 45{
46 /* XXX: We should probe for the presence of this bug, but we don't. */ 46 /* XXX: We should probe for the presence of this bug, but we don't. */
47 return 0; 47 return 0;
48} 48}
49 49
50static __init int __attribute__((unused)) bcm1250_m3_war(void) 50static __init int __maybe_unused bcm1250_m3_war(void)
51{ 51{
52 return BCM1250_M3_WAR; 52 return BCM1250_M3_WAR;
53} 53}
54 54
55static __init int __attribute__((unused)) r10000_llsc_war(void) 55static __init int __maybe_unused r10000_llsc_war(void)
56{ 56{
57 return R10000_LLSC_WAR; 57 return R10000_LLSC_WAR;
58} 58}
@@ -511,18 +511,18 @@ L_LA(_r3000_write_probe_fail)
511#define i_ehb(buf) i_sll(buf, 0, 0, 3) 511#define i_ehb(buf) i_sll(buf, 0, 0, 3)
512 512
513#ifdef CONFIG_64BIT 513#ifdef CONFIG_64BIT
514static __init int __attribute__((unused)) in_compat_space_p(long addr) 514static __init int __maybe_unused in_compat_space_p(long addr)
515{ 515{
516 /* Is this address in 32bit compat space? */ 516 /* Is this address in 32bit compat space? */
517 return (((addr) & 0xffffffff00000000L) == 0xffffffff00000000L); 517 return (((addr) & 0xffffffff00000000L) == 0xffffffff00000000L);
518} 518}
519 519
520static __init int __attribute__((unused)) rel_highest(long val) 520static __init int __maybe_unused rel_highest(long val)
521{ 521{
522 return ((((val + 0x800080008000L) >> 48) & 0xffff) ^ 0x8000) - 0x8000; 522 return ((((val + 0x800080008000L) >> 48) & 0xffff) ^ 0x8000) - 0x8000;
523} 523}
524 524
525static __init int __attribute__((unused)) rel_higher(long val) 525static __init int __maybe_unused rel_higher(long val)
526{ 526{
527 return ((((val + 0x80008000L) >> 32) & 0xffff) ^ 0x8000) - 0x8000; 527 return ((((val + 0x80008000L) >> 32) & 0xffff) ^ 0x8000) - 0x8000;
528} 528}
@@ -556,8 +556,8 @@ static __init void i_LA_mostly(u32 **buf, unsigned int rs, long addr)
556 i_lui(buf, rs, rel_hi(addr)); 556 i_lui(buf, rs, rel_hi(addr));
557} 557}
558 558
559static __init void __attribute__((unused)) i_LA(u32 **buf, unsigned int rs, 559static __init void __maybe_unused i_LA(u32 **buf, unsigned int rs,
560 long addr) 560 long addr)
561{ 561{
562 i_LA_mostly(buf, rs, addr); 562 i_LA_mostly(buf, rs, addr);
563 if (rel_lo(addr)) 563 if (rel_lo(addr))
@@ -636,8 +636,8 @@ static __init void copy_handler(struct reloc *rel, struct label *lab,
636 move_labels(lab, first, end, off); 636 move_labels(lab, first, end, off);
637} 637}
638 638
639static __init int __attribute__((unused)) insn_has_bdelay(struct reloc *rel, 639static __init int __maybe_unused insn_has_bdelay(struct reloc *rel,
640 u32 *addr) 640 u32 *addr)
641{ 641{
642 for (; rel->lab != label_invalid; rel++) { 642 for (; rel->lab != label_invalid; rel++) {
643 if (rel->addr == addr 643 if (rel->addr == addr
@@ -650,15 +650,15 @@ static __init int __attribute__((unused)) insn_has_bdelay(struct reloc *rel,
650} 650}
651 651
652/* convenience functions for labeled branches */ 652/* convenience functions for labeled branches */
653static void __init __attribute__((unused)) 653static void __init __maybe_unused
654 il_bltz(u32 **p, struct reloc **r, unsigned int reg, enum label_id l) 654 il_bltz(u32 **p, struct reloc **r, unsigned int reg, enum label_id l)
655{ 655{
656 r_mips_pc16(r, *p, l); 656 r_mips_pc16(r, *p, l);
657 i_bltz(p, reg, 0); 657 i_bltz(p, reg, 0);
658} 658}
659 659
660static void __init __attribute__((unused)) il_b(u32 **p, struct reloc **r, 660static void __init __maybe_unused il_b(u32 **p, struct reloc **r,
661 enum label_id l) 661 enum label_id l)
662{ 662{
663 r_mips_pc16(r, *p, l); 663 r_mips_pc16(r, *p, l);
664 i_b(p, 0); 664 i_b(p, 0);
@@ -671,7 +671,7 @@ static void __init il_beqz(u32 **p, struct reloc **r, unsigned int reg,
671 i_beqz(p, reg, 0); 671 i_beqz(p, reg, 0);
672} 672}
673 673
674static void __init __attribute__((unused)) 674static void __init __maybe_unused
675il_beqzl(u32 **p, struct reloc **r, unsigned int reg, enum label_id l) 675il_beqzl(u32 **p, struct reloc **r, unsigned int reg, enum label_id l)
676{ 676{
677 r_mips_pc16(r, *p, l); 677 r_mips_pc16(r, *p, l);
@@ -692,7 +692,7 @@ static void __init il_bgezl(u32 **p, struct reloc **r, unsigned int reg,
692 i_bgezl(p, reg, 0); 692 i_bgezl(p, reg, 0);
693} 693}
694 694
695static void __init __attribute__((unused)) 695static void __init __maybe_unused
696il_bgez(u32 **p, struct reloc **r, unsigned int reg, enum label_id l) 696il_bgez(u32 **p, struct reloc **r, unsigned int reg, enum label_id l)
697{ 697{
698 r_mips_pc16(r, *p, l); 698 r_mips_pc16(r, *p, l);
@@ -810,7 +810,7 @@ static __initdata u32 final_handler[64];
810 * 810 *
811 * As if we MIPS hackers wouldn't know how to nop pipelines happy ... 811 * As if we MIPS hackers wouldn't know how to nop pipelines happy ...
812 */ 812 */
813static __init void __attribute__((unused)) build_tlb_probe_entry(u32 **p) 813static __init void __maybe_unused build_tlb_probe_entry(u32 **p)
814{ 814{
815 switch (current_cpu_data.cputype) { 815 switch (current_cpu_data.cputype) {
816 /* Found by experiment: R4600 v2.0 needs this, too. */ 816 /* Found by experiment: R4600 v2.0 needs this, too. */
@@ -1098,7 +1098,7 @@ build_get_pgd_vmalloc64(u32 **p, struct label **l, struct reloc **r,
1098 * TMP and PTR are scratch. 1098 * TMP and PTR are scratch.
1099 * TMP will be clobbered, PTR will hold the pgd entry. 1099 * TMP will be clobbered, PTR will hold the pgd entry.
1100 */ 1100 */
1101static __init void __attribute__((unused)) 1101static __init void __maybe_unused
1102build_get_pgde32(u32 **p, unsigned int tmp, unsigned int ptr) 1102build_get_pgde32(u32 **p, unsigned int tmp, unsigned int ptr)
1103{ 1103{
1104 long pgdc = (long)pgd_current; 1104 long pgdc = (long)pgd_current;
diff --git a/arch/mips/momentum/Kconfig b/arch/mips/momentum/Kconfig
deleted file mode 100644
index 70a61cf7174d..000000000000
--- a/arch/mips/momentum/Kconfig
+++ /dev/null
@@ -1,6 +0,0 @@
1config JAGUAR_DMALOW
2 bool "Low DMA Mode"
3 depends on MOMENCO_JAGUAR_ATX
4 help
5 Select to Y if jump JP5 is set on your board, N otherwise. Normally
6 the jumper is set, so if you feel unsafe, just say Y.
diff --git a/arch/mips/momentum/jaguar_atx/Makefile b/arch/mips/momentum/jaguar_atx/Makefile
deleted file mode 100644
index 2e8cebd49bc0..000000000000
--- a/arch/mips/momentum/jaguar_atx/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
1#
2# Makefile for Momentum Computer's Jaguar-ATX board.
3#
4# Note! Dependencies are done automagically by 'make dep', which also
5# removes any old dependencies. DON'T put your own dependencies here
6# unless it's something special (ie not a .c file).
7#
8
9obj-y += irq.o platform.o prom.o reset.o setup.o
10
11obj-$(CONFIG_SERIAL_8250_CONSOLE) += ja-console.o
12obj-$(CONFIG_REMOTE_DEBUG) += dbg_io.o
diff --git a/arch/mips/momentum/jaguar_atx/dbg_io.c b/arch/mips/momentum/jaguar_atx/dbg_io.c
deleted file mode 100644
index b85a6521f72d..000000000000
--- a/arch/mips/momentum/jaguar_atx/dbg_io.c
+++ /dev/null
@@ -1,125 +0,0 @@
1
2#if defined(CONFIG_REMOTE_DEBUG)
3
4#include <asm/serial.h> /* For the serial port location and base baud */
5
6/* --- CONFIG --- */
7
8typedef unsigned char uint8;
9typedef unsigned int uint32;
10
11/* --- END OF CONFIG --- */
12
13#define UART16550_BAUD_2400 2400
14#define UART16550_BAUD_4800 4800
15#define UART16550_BAUD_9600 9600
16#define UART16550_BAUD_19200 19200
17#define UART16550_BAUD_38400 38400
18#define UART16550_BAUD_57600 57600
19#define UART16550_BAUD_115200 115200
20
21#define UART16550_PARITY_NONE 0
22#define UART16550_PARITY_ODD 0x08
23#define UART16550_PARITY_EVEN 0x18
24#define UART16550_PARITY_MARK 0x28
25#define UART16550_PARITY_SPACE 0x38
26
27#define UART16550_DATA_5BIT 0x0
28#define UART16550_DATA_6BIT 0x1
29#define UART16550_DATA_7BIT 0x2
30#define UART16550_DATA_8BIT 0x3
31
32#define UART16550_STOP_1BIT 0x0
33#define UART16550_STOP_2BIT 0x4
34
35/* ----------------------------------------------------- */
36
37/* === CONFIG === */
38
39/* [jsun] we use the second serial port for kdb */
40#define BASE OCELOT_SERIAL1_BASE
41#define MAX_BAUD OCELOT_BASE_BAUD
42
43/* === END OF CONFIG === */
44
45#define REG_OFFSET 4
46
47/* register offset */
48#define OFS_RCV_BUFFER 0
49#define OFS_TRANS_HOLD 0
50#define OFS_SEND_BUFFER 0
51#define OFS_INTR_ENABLE (1*REG_OFFSET)
52#define OFS_INTR_ID (2*REG_OFFSET)
53#define OFS_DATA_FORMAT (3*REG_OFFSET)
54#define OFS_LINE_CONTROL (3*REG_OFFSET)
55#define OFS_MODEM_CONTROL (4*REG_OFFSET)
56#define OFS_RS232_OUTPUT (4*REG_OFFSET)
57#define OFS_LINE_STATUS (5*REG_OFFSET)
58#define OFS_MODEM_STATUS (6*REG_OFFSET)
59#define OFS_RS232_INPUT (6*REG_OFFSET)
60#define OFS_SCRATCH_PAD (7*REG_OFFSET)
61
62#define OFS_DIVISOR_LSB (0*REG_OFFSET)
63#define OFS_DIVISOR_MSB (1*REG_OFFSET)
64
65
66/* memory-mapped read/write of the port */
67#define UART16550_READ(y) (*((volatile uint8*)(BASE + y)))
68#define UART16550_WRITE(y, z) ((*((volatile uint8*)(BASE + y))) = z)
69
70void debugInit(uint32 baud, uint8 data, uint8 parity, uint8 stop)
71{
72 /* disable interrupts */
73 UART16550_WRITE(OFS_INTR_ENABLE, 0);
74
75 /* set up baud rate */
76 {
77 uint32 divisor;
78
79 /* set DIAB bit */
80 UART16550_WRITE(OFS_LINE_CONTROL, 0x80);
81
82 /* set divisor */
83 divisor = MAX_BAUD / baud;
84 UART16550_WRITE(OFS_DIVISOR_LSB, divisor & 0xff);
85 UART16550_WRITE(OFS_DIVISOR_MSB, (divisor & 0xff00) >> 8);
86
87 /* clear DIAB bit */
88 UART16550_WRITE(OFS_LINE_CONTROL, 0x0);
89 }
90
91 /* set data format */
92 UART16550_WRITE(OFS_DATA_FORMAT, data | parity | stop);
93}
94
95static int remoteDebugInitialized = 0;
96
97uint8 getDebugChar(void)
98{
99 if (!remoteDebugInitialized) {
100 remoteDebugInitialized = 1;
101 debugInit(UART16550_BAUD_38400,
102 UART16550_DATA_8BIT,
103 UART16550_PARITY_NONE, UART16550_STOP_1BIT);
104 }
105
106 while ((UART16550_READ(OFS_LINE_STATUS) & 0x1) == 0);
107 return UART16550_READ(OFS_RCV_BUFFER);
108}
109
110
111int putDebugChar(uint8 byte)
112{
113 if (!remoteDebugInitialized) {
114 remoteDebugInitialized = 1;
115 debugInit(UART16550_BAUD_38400,
116 UART16550_DATA_8BIT,
117 UART16550_PARITY_NONE, UART16550_STOP_1BIT);
118 }
119
120 while ((UART16550_READ(OFS_LINE_STATUS) & 0x20) == 0);
121 UART16550_WRITE(OFS_SEND_BUFFER, byte);
122 return 1;
123}
124
125#endif
diff --git a/arch/mips/momentum/jaguar_atx/irq.c b/arch/mips/momentum/jaguar_atx/irq.c
deleted file mode 100644
index f2b432585df2..000000000000
--- a/arch/mips/momentum/jaguar_atx/irq.c
+++ /dev/null
@@ -1,94 +0,0 @@
1/*
2 * Copyright (C) 2002 Momentum Computer, Inc.
3 * Author: Matthew Dharm, mdharm@momenco.com
4 *
5 * Based on work by:
6 * Copyright (C) 2000 RidgeRun, Inc.
7 * Author: RidgeRun, Inc.
8 * glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
9 *
10 * Copyright 2001 MontaVista Software Inc.
11 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
12 *
13 * Copyright (C) 2000, 01, 06 Ralf Baechle (ralf@linux-mips.org)
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the
17 * Free Software Foundation; either version 2 of the License, or (at your
18 * option) any later version.
19 *
20 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
21 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
23 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 * You should have received a copy of the GNU General Public License along
32 * with this program; if not, write to the Free Software Foundation, Inc.,
33 * 675 Mass Ave, Cambridge, MA 02139, USA.
34 */
35#include <linux/init.h>
36#include <linux/interrupt.h>
37#include <linux/signal.h>
38#include <linux/types.h>
39#include <asm/irq_cpu.h>
40#include <asm/mipsregs.h>
41#include <asm/time.h>
42
43asmlinkage void plat_irq_dispatch(void)
44{
45 unsigned int pending = read_c0_cause() & read_c0_status();
46
47 if (pending & STATUSF_IP0)
48 do_IRQ(0);
49 else if (pending & STATUSF_IP1)
50 do_IRQ(1);
51 else if (pending & STATUSF_IP2)
52 do_IRQ(2);
53 else if (pending & STATUSF_IP3)
54 do_IRQ(3);
55 else if (pending & STATUSF_IP4)
56 do_IRQ(4);
57 else if (pending & STATUSF_IP5)
58 do_IRQ(5);
59 else if (pending & STATUSF_IP6)
60 do_IRQ(6);
61 else if (pending & STATUSF_IP7)
62 ll_timer_interrupt(7);
63 else {
64 /*
65 * Now look at the extended interrupts
66 */
67 pending = (read_c0_cause() & (read_c0_intcontrol() << 8)) >> 16;
68 if (pending & STATUSF_IP8)
69 ll_mv64340_irq();
70 }
71}
72
73static struct irqaction cascade_mv64340 = {
74 no_action, IRQF_DISABLED, CPU_MASK_NONE, "MV64340-Cascade", NULL, NULL
75};
76
77void __init arch_init_irq(void)
78{
79 /*
80 * Clear all of the interrupts while we change the able around a bit.
81 * int-handler is not on bootstrap
82 */
83 clear_c0_status(ST0_IM);
84
85 mips_cpu_irq_init();
86 rm7k_cpu_irq_init();
87
88 /* set up the cascading interrupts */
89 setup_irq(8, &cascade_mv64340);
90
91 mv64340_irq_init(16);
92
93 set_c0_status(ST0_IM);
94}
diff --git a/arch/mips/momentum/jaguar_atx/ja-console.c b/arch/mips/momentum/jaguar_atx/ja-console.c
deleted file mode 100644
index 2c30b4f56245..000000000000
--- a/arch/mips/momentum/jaguar_atx/ja-console.c
+++ /dev/null
@@ -1,101 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2001, 2002, 2004 Ralf Baechle
7 */
8#include <linux/init.h>
9#include <linux/console.h>
10#include <linux/kdev_t.h>
11#include <linux/major.h>
12#include <linux/termios.h>
13#include <linux/sched.h>
14#include <linux/tty.h>
15
16#include <linux/serial.h>
17#include <linux/serial_core.h>
18#include <asm/serial.h>
19
20/* SUPERIO uart register map */
21struct ja_uartregs {
22 union {
23 volatile u8 pad0[3];
24 volatile u8 rbr; /* read only, DLAB == 0 */
25 volatile u8 pad1[3];
26 volatile u8 thr; /* write only, DLAB == 0 */
27 volatile u8 pad2[3];
28 volatile u8 dll; /* DLAB == 1 */
29 } u1;
30 union {
31 volatile u8 pad0[3];
32 volatile u8 ier; /* DLAB == 0 */
33 volatile u8 pad1[3];
34 volatile u8 dlm; /* DLAB == 1 */
35 } u2;
36 union {
37 volatile u8 pad0[3];
38 volatile u8 iir; /* read only */
39 volatile u8 pad1[3];
40 volatile u8 fcr; /* write only */
41 } u3;
42 volatile u8 pad0[3];
43 volatile u8 iu_lcr;
44 volatile u8 pad1[3];
45 volatile u8 iu_mcr;
46 volatile u8 pad2[3];
47 volatile u8 iu_lsr;
48 volatile u8 pad3[3];
49 volatile u8 iu_msr;
50 volatile u8 pad4[3];
51 volatile u8 iu_scr;
52} ja_uregs_t;
53
54#define iu_rbr u1.rbr
55#define iu_thr u1.thr
56#define iu_dll u1.dll
57#define iu_ier u2.ier
58#define iu_dlm u2.dlm
59#define iu_iir u3.iir
60#define iu_fcr u3.fcr
61
62extern unsigned long uart_base;
63
64static inline struct ja_uartregs *console_uart(void)
65{
66 return (struct ja_uartregs *) (uart_base + 0x23UL);
67}
68
69void prom_putchar(char c)
70{
71 struct ja_uartregs *uart = console_uart();
72
73 while ((uart->iu_lsr & 0x20) == 0);
74 uart->iu_thr = c;
75}
76
77static void inline ja_console_probe(void)
78{
79 struct uart_port up;
80
81 /*
82 * Register to interrupt zero because we share the interrupt with
83 * the serial driver which we don't properly support yet.
84 */
85 memset(&up, 0, sizeof(up));
86 up.membase = (unsigned char *) uart_base + 0x23UL;
87 up.irq = JAGUAR_ATX_SERIAL1_IRQ;
88 up.uartclk = JAGUAR_ATX_UART_CLK;
89 up.regshift = 2;
90 up.iotype = UPIO_MEM;
91 up.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
92 up.line = 0;
93
94 if (early_serial_setup(&up))
95 printk(KERN_ERR "Early serial init of port 0 failed\n");
96}
97
98__init void ja_setup_console(void)
99{
100 ja_console_probe();
101}
diff --git a/arch/mips/momentum/jaguar_atx/jaguar_atx_fpga.h b/arch/mips/momentum/jaguar_atx/jaguar_atx_fpga.h
deleted file mode 100644
index 022f6974b76e..000000000000
--- a/arch/mips/momentum/jaguar_atx/jaguar_atx_fpga.h
+++ /dev/null
@@ -1,54 +0,0 @@
1/*
2 * Jaguar-ATX Board Register Definitions
3 *
4 * (C) 2002 Momentum Computer 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 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
12 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
14 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
15 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
18 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 675 Mass Ave, Cambridge, MA 02139, USA.
25 */
26#ifndef __JAGUAR_ATX_FPGA_H__
27#define __JAGUAR_ATX_FPGA_H__
28
29#define JAGUAR_ATX_REG_BOARDREV 0x0
30#define JAGUAR_ATX_REG_FPGA_REV 0x1
31#define JAGUAR_ATX_REG_FPGA_TYPE 0x2
32#define JAGUAR_ATX_REG_RESET_STATUS 0x3
33#define JAGUAR_ATX_REG_BOARD_STATUS 0x4
34#define JAGUAR_ATX_REG_RESERVED1 0x5
35#define JAGUAR_ATX_REG_SET 0x6
36#define JAGUAR_ATX_REG_CLR 0x7
37#define JAGUAR_ATX_REG_EEPROM_MODE 0x9
38#define JAGUAR_ATX_REG_RESERVED2 0xa
39#define JAGUAR_ATX_REG_RESERVED3 0xb
40#define JAGUAR_ATX_REG_RESERVED4 0xc
41#define JAGUAR_ATX_REG_PHY_INTSTAT 0xd
42#define JAGUAR_ATX_REG_RESERVED5 0xe
43#define JAGUAR_ATX_REG_RESERVED6 0xf
44
45#define JAGUAR_ATX_CS0_ADDR 0xfc000000L
46
47extern unsigned long ja_fpga_base;
48
49#define __FPGA_REG_TO_ADDR(reg) \
50 ((void *) ja_fpga_base + JAGUAR_ATX_REG_##reg)
51#define JAGUAR_FPGA_WRITE(x, reg) writeb(x, __FPGA_REG_TO_ADDR(reg))
52#define JAGUAR_FPGA_READ(reg) readb(__FPGA_REG_TO_ADDR(reg))
53
54#endif
diff --git a/arch/mips/momentum/jaguar_atx/platform.c b/arch/mips/momentum/jaguar_atx/platform.c
deleted file mode 100644
index 561844878a90..000000000000
--- a/arch/mips/momentum/jaguar_atx/platform.c
+++ /dev/null
@@ -1,208 +0,0 @@
1#include <linux/delay.h>
2#include <linux/if_ether.h>
3#include <linux/ioport.h>
4#include <linux/mv643xx.h>
5#include <linux/platform_device.h>
6
7#include "jaguar_atx_fpga.h"
8
9#if defined(CONFIG_MV643XX_ETH) || defined(CONFIG_MV643XX_ETH_MODULE)
10
11static struct resource mv643xx_eth_shared_resources[] = {
12 [0] = {
13 .name = "ethernet shared base",
14 .start = 0xf1000000 + MV643XX_ETH_SHARED_REGS,
15 .end = 0xf1000000 + MV643XX_ETH_SHARED_REGS +
16 MV643XX_ETH_SHARED_REGS_SIZE - 1,
17 .flags = IORESOURCE_MEM,
18 },
19};
20
21static struct platform_device mv643xx_eth_shared_device = {
22 .name = MV643XX_ETH_SHARED_NAME,
23 .id = 0,
24 .num_resources = ARRAY_SIZE(mv643xx_eth_shared_resources),
25 .resource = mv643xx_eth_shared_resources,
26};
27
28#define MV_SRAM_BASE 0xfe000000UL
29#define MV_SRAM_SIZE (256 * 1024)
30
31#define MV_SRAM_RXRING_SIZE (MV_SRAM_SIZE / 4)
32#define MV_SRAM_TXRING_SIZE (MV_SRAM_SIZE / 4)
33
34#define MV_SRAM_BASE_ETH0 MV_SRAM_BASE
35#define MV_SRAM_BASE_ETH1 (MV_SRAM_BASE + (MV_SRAM_SIZE / 2))
36
37#define MV64x60_IRQ_ETH_0 48
38#define MV64x60_IRQ_ETH_1 49
39#define MV64x60_IRQ_ETH_2 50
40
41static struct resource mv64x60_eth0_resources[] = {
42 [0] = {
43 .name = "eth0 irq",
44 .start = MV64x60_IRQ_ETH_0,
45 .end = MV64x60_IRQ_ETH_0,
46 .flags = IORESOURCE_IRQ,
47 },
48};
49
50static struct mv643xx_eth_platform_data eth0_pd = {
51 .port_number = 0,
52
53 .tx_sram_addr = MV_SRAM_BASE_ETH0,
54 .tx_sram_size = MV_SRAM_TXRING_SIZE,
55 .tx_queue_size = MV_SRAM_TXRING_SIZE / 16,
56
57 .rx_sram_addr = MV_SRAM_BASE_ETH0 + MV_SRAM_TXRING_SIZE,
58 .rx_sram_size = MV_SRAM_RXRING_SIZE,
59 .rx_queue_size = MV_SRAM_RXRING_SIZE / 16,
60};
61
62static struct platform_device eth0_device = {
63 .name = MV643XX_ETH_NAME,
64 .id = 0,
65 .num_resources = ARRAY_SIZE(mv64x60_eth0_resources),
66 .resource = mv64x60_eth0_resources,
67 .dev = {
68 .platform_data = &eth0_pd,
69 },
70};
71
72static struct resource mv64x60_eth1_resources[] = {
73 [0] = {
74 .name = "eth1 irq",
75 .start = MV64x60_IRQ_ETH_1,
76 .end = MV64x60_IRQ_ETH_1,
77 .flags = IORESOURCE_IRQ,
78 },
79};
80
81static struct mv643xx_eth_platform_data eth1_pd = {
82 .port_number = 1,
83
84 .tx_sram_addr = MV_SRAM_BASE_ETH1,
85 .tx_sram_size = MV_SRAM_TXRING_SIZE,
86 .tx_queue_size = MV_SRAM_TXRING_SIZE / 16,
87
88 .rx_sram_addr = MV_SRAM_BASE_ETH1 + MV_SRAM_TXRING_SIZE,
89 .rx_sram_size = MV_SRAM_RXRING_SIZE,
90 .rx_queue_size = MV_SRAM_RXRING_SIZE / 16,
91};
92
93static struct platform_device eth1_device = {
94 .name = MV643XX_ETH_NAME,
95 .id = 1,
96 .num_resources = ARRAY_SIZE(mv64x60_eth1_resources),
97 .resource = mv64x60_eth1_resources,
98 .dev = {
99 .platform_data = &eth1_pd,
100 },
101};
102
103static struct resource mv64x60_eth2_resources[] = {
104 [0] = {
105 .name = "eth2 irq",
106 .start = MV64x60_IRQ_ETH_2,
107 .end = MV64x60_IRQ_ETH_2,
108 .flags = IORESOURCE_IRQ,
109 },
110};
111
112static struct mv643xx_eth_platform_data eth2_pd = {
113 .port_number = 2,
114};
115
116static struct platform_device eth2_device = {
117 .name = MV643XX_ETH_NAME,
118 .id = 2,
119 .num_resources = ARRAY_SIZE(mv64x60_eth2_resources),
120 .resource = mv64x60_eth2_resources,
121 .dev = {
122 .platform_data = &eth2_pd,
123 },
124};
125
126static struct platform_device *mv643xx_eth_pd_devs[] __initdata = {
127 &mv643xx_eth_shared_device,
128 &eth0_device,
129 &eth1_device,
130 &eth2_device,
131};
132
133static u8 __init exchange_bit(u8 val, u8 cs)
134{
135 /* place the data */
136 JAGUAR_FPGA_WRITE((val << 2) | cs, EEPROM_MODE);
137 udelay(1);
138
139 /* turn the clock on */
140 JAGUAR_FPGA_WRITE((val << 2) | cs | 0x2, EEPROM_MODE);
141 udelay(1);
142
143 /* turn the clock off and read-strobe */
144 JAGUAR_FPGA_WRITE((val << 2) | cs | 0x10, EEPROM_MODE);
145
146 /* return the data */
147 return (JAGUAR_FPGA_READ(EEPROM_MODE) >> 3) & 0x1;
148}
149
150static void __init get_mac(char dest[6])
151{
152 u8 read_opcode[12] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
153 int i,j;
154
155 for (i = 0; i < 12; i++)
156 exchange_bit(read_opcode[i], 1);
157
158 for (j = 0; j < 6; j++) {
159 dest[j] = 0;
160 for (i = 0; i < 8; i++) {
161 dest[j] <<= 1;
162 dest[j] |= exchange_bit(0, 1);
163 }
164 }
165
166 /* turn off CS */
167 exchange_bit(0,0);
168}
169
170/*
171 * Copy and increment ethernet MAC address by a small value.
172 *
173 * This is useful for systems where the only one MAC address is stored in
174 * non-volatile memory for multiple ports.
175 */
176static inline void eth_mac_add(unsigned char *dst, unsigned char *src,
177 unsigned int add)
178{
179 int i;
180
181 BUG_ON(add >= 256);
182
183 for (i = ETH_ALEN; i >= 0; i--) {
184 dst[i] = src[i] + add;
185 add = dst[i] < src[i]; /* compute carry */
186 }
187
188 WARN_ON(add);
189}
190
191static int __init mv643xx_eth_add_pds(void)
192{
193 unsigned char mac[ETH_ALEN];
194 int ret;
195
196 get_mac(mac);
197 eth_mac_add(eth0_pd.mac_addr, mac, 0);
198 eth_mac_add(eth1_pd.mac_addr, mac, 1);
199 eth_mac_add(eth2_pd.mac_addr, mac, 2);
200 ret = platform_add_devices(mv643xx_eth_pd_devs,
201 ARRAY_SIZE(mv643xx_eth_pd_devs));
202
203 return ret;
204}
205
206device_initcall(mv643xx_eth_add_pds);
207
208#endif /* defined(CONFIG_MV643XX_ETH) || defined(CONFIG_MV643XX_ETH_MODULE) */
diff --git a/arch/mips/momentum/jaguar_atx/prom.c b/arch/mips/momentum/jaguar_atx/prom.c
deleted file mode 100644
index 5dd154ee58f6..000000000000
--- a/arch/mips/momentum/jaguar_atx/prom.c
+++ /dev/null
@@ -1,210 +0,0 @@
1/*
2 * Copyright 2002 Momentum Computer Inc.
3 * Author: Matthew Dharm <mdharm@momenco.com>
4 *
5 * Louis Hamilton, Red Hat, Inc.
6 * hamilton@redhat.com [MIPS64 modifications]
7 *
8 * Based on Ocelot Linux port, which is
9 * Copyright 2001 MontaVista Software Inc.
10 * Author: jsun@mvista.com or jsun@junsun.net
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 *
17 * Added changes for SMP - Manish Lachwani (lachwani@pmc-sierra.com)
18 */
19#include <linux/init.h>
20#include <linux/mm.h>
21#include <linux/sched.h>
22#include <linux/bootmem.h>
23#include <linux/mv643xx.h>
24
25#include <asm/addrspace.h>
26#include <asm/bootinfo.h>
27#include <asm/pmon.h>
28
29#include "jaguar_atx_fpga.h"
30
31extern void ja_setup_console(void);
32
33struct callvectors *debug_vectors;
34
35extern unsigned long cpu_clock;
36
37const char *get_system_type(void)
38{
39 return "Momentum Jaguar-ATX";
40}
41
42#ifdef CONFIG_64BIT
43
44unsigned long signext(unsigned long addr)
45{
46 addr &= 0xffffffff;
47 return (unsigned long)((int)addr);
48}
49
50void *get_arg(unsigned long args, int arc)
51{
52 unsigned long ul;
53 unsigned char *puc, uc;
54
55 args += (arc * 4);
56 ul = (unsigned long)signext(args);
57 puc = (unsigned char *)ul;
58 if (puc == 0)
59 return (void *)0;
60
61#ifdef CONFIG_CPU_LITTLE_ENDIAN
62 uc = *puc++;
63 l = (unsigned long)uc;
64 uc = *puc++;
65 ul |= (((unsigned long)uc) << 8);
66 uc = *puc++;
67 ul |= (((unsigned long)uc) << 16);
68 uc = *puc++;
69 ul |= (((unsigned long)uc) << 24);
70#else
71 uc = *puc++;
72 ul = ((unsigned long)uc) << 24;
73 uc = *puc++;
74 ul |= (((unsigned long)uc) << 16);
75 uc = *puc++;
76 ul |= (((unsigned long)uc) << 8);
77 uc = *puc++;
78 ul |= ((unsigned long)uc);
79#endif
80 ul = signext(ul);
81
82 return (void *)ul;
83}
84
85char *arg64(unsigned long addrin, int arg_index)
86{
87 unsigned long args;
88 char *p;
89
90 args = signext(addrin);
91 p = (char *)get_arg(args, arg_index);
92
93 return p;
94}
95#endif /* CONFIG_64BIT */
96
97/* PMON passes arguments in C main() style */
98void __init prom_init(void)
99{
100 int argc = fw_arg0;
101 char **arg = (char **) fw_arg1;
102 char **env = (char **) fw_arg2;
103 struct callvectors *cv = (struct callvectors *) fw_arg3;
104 int i;
105
106#ifdef CONFIG_SERIAL_8250_CONSOLE
107// ja_setup_console(); /* The very first thing. */
108#endif
109
110#ifdef CONFIG_64BIT
111 char *ptr;
112
113 printk("Mips64 Jaguar-ATX\n");
114 /* save the PROM vectors for debugging use */
115 debug_vectors = (struct callvectors *)signext((unsigned long)cv);
116
117 /* arg[0] is "g", the rest is boot parameters */
118 arcs_cmdline[0] = '\0';
119
120 for (i = 1; i < argc; i++) {
121 ptr = (char *)arg64((unsigned long)arg, i);
122 if ((strlen(arcs_cmdline) + strlen(ptr) + 1) >=
123 sizeof(arcs_cmdline))
124 break;
125 strcat(arcs_cmdline, ptr);
126 strcat(arcs_cmdline, " ");
127 }
128
129 i = 0;
130 while (1) {
131 ptr = (char *)arg64((unsigned long)env, i);
132 if (! ptr)
133 break;
134
135 if (strncmp("gtbase", ptr, strlen("gtbase")) == 0) {
136 marvell_base = simple_strtol(ptr + strlen("gtbase="),
137 NULL, 16);
138
139 if ((marvell_base & 0xffffffff00000000) == 0)
140 marvell_base |= 0xffffffff00000000;
141
142 printk("marvell_base set to 0x%016lx\n", marvell_base);
143 }
144 if (strncmp("cpuclock", ptr, strlen("cpuclock")) == 0) {
145 cpu_clock = simple_strtol(ptr + strlen("cpuclock="),
146 NULL, 10);
147 printk("cpu_clock set to %d\n", cpu_clock);
148 }
149 i++;
150 }
151 printk("arcs_cmdline: %s\n", arcs_cmdline);
152
153#else /* CONFIG_64BIT */
154 /* save the PROM vectors for debugging use */
155 debug_vectors = cv;
156
157 /* arg[0] is "g", the rest is boot parameters */
158 arcs_cmdline[0] = '\0';
159 for (i = 1; i < argc; i++) {
160 if (strlen(arcs_cmdline) + strlen(arg[i] + 1)
161 >= sizeof(arcs_cmdline))
162 break;
163 strcat(arcs_cmdline, arg[i]);
164 strcat(arcs_cmdline, " ");
165 }
166
167 while (*env) {
168 if (strncmp("gtbase", *env, strlen("gtbase")) == 0) {
169 marvell_base = simple_strtol(*env + strlen("gtbase="),
170 NULL, 16);
171 }
172 if (strncmp("cpuclock", *env, strlen("cpuclock")) == 0) {
173 cpu_clock = simple_strtol(*env + strlen("cpuclock="),
174 NULL, 10);
175 }
176 env++;
177 }
178#endif /* CONFIG_64BIT */
179 mips_machgroup = MACH_GROUP_MOMENCO;
180 mips_machtype = MACH_MOMENCO_JAGUAR_ATX;
181}
182
183void __init prom_free_prom_memory(void)
184{
185}
186
187void __init prom_fixup_mem_map(unsigned long start, unsigned long end)
188{
189}
190
191int prom_boot_secondary(int cpu, unsigned long sp, unsigned long gp)
192{
193 /* Clear the semaphore */
194 *(volatile uint32_t *)(0xbb000a68) = 0x80000000;
195
196 return 1;
197}
198
199void prom_init_secondary(void)
200{
201 clear_c0_config(CONF_CM_CMASK);
202 set_c0_config(0x2);
203
204 clear_c0_status(ST0_IM);
205 set_c0_status(0x1ffff);
206}
207
208void prom_smp_finish(void)
209{
210}
diff --git a/arch/mips/momentum/jaguar_atx/reset.c b/arch/mips/momentum/jaguar_atx/reset.c
deleted file mode 100644
index c73b0897dc52..000000000000
--- a/arch/mips/momentum/jaguar_atx/reset.c
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation; either version 2 of the License, or (at your
5 * option) any later version.
6 *
7 * Copyright (C) 1997, 2001 Ralf Baechle
8 * Copyright 2001 MontaVista Software Inc.
9 * Author: jsun@mvista.com or jsun@junsun.net
10 *
11 * Copyright (C) 2002 Momentum Computer Inc.
12 * Author: Matthew Dharm <mdharm@momenco.com>
13 *
14 * Louis Hamilton, Red Hat, Inc.
15 * hamilton@redhat.com [MIPS64 modifications]
16 */
17#include <linux/sched.h>
18#include <linux/mm.h>
19#include <asm/io.h>
20#include <asm/pgtable.h>
21#include <asm/processor.h>
22#include <asm/reboot.h>
23#include <asm/system.h>
24#include <linux/delay.h>
25
26void momenco_jaguar_restart(char *command)
27{
28 /* base address of timekeeper portion of part */
29#ifdef CONFIG_64BIT
30 void *nvram = (void*) 0xfffffffffc807000;
31#else
32 void *nvram = (void*) 0xfc807000;
33#endif
34 /* Ask the NVRAM/RTC/watchdog chip to assert reset in 1/16 second */
35 writeb(0x84, nvram + 0xff7);
36
37 /* wait for the watchdog to go off */
38 mdelay(100+(1000/16));
39
40 /* if the watchdog fails for some reason, let people know */
41 printk(KERN_NOTICE "Watchdog reset failed\n");
42}
43
44void momenco_jaguar_halt(void)
45{
46 printk(KERN_NOTICE "\n** You can safely turn off the power\n");
47 while (1)
48 __asm__(".set\tmips3\n\t"
49 "wait\n\t"
50 ".set\tmips0");
51}
52
53void momenco_jaguar_power_off(void)
54{
55 momenco_jaguar_halt();
56}
diff --git a/arch/mips/momentum/jaguar_atx/setup.c b/arch/mips/momentum/jaguar_atx/setup.c
deleted file mode 100644
index 5a510142b978..000000000000
--- a/arch/mips/momentum/jaguar_atx/setup.c
+++ /dev/null
@@ -1,475 +0,0 @@
1/*
2 * BRIEF MODULE DESCRIPTION
3 * Momentum Computer Jaguar-ATX board dependent boot routines
4 *
5 * Copyright (C) 1996, 1997, 2001, 04, 06 Ralf Baechle (ralf@linux-mips.org)
6 * Copyright (C) 2000 RidgeRun, Inc.
7 * Copyright (C) 2001 Red Hat, Inc.
8 * Copyright (C) 2002 Momentum Computer
9 *
10 * Author: Matthew Dharm, Momentum Computer
11 * mdharm@momenco.com
12 *
13 * Louis Hamilton, Red Hat, Inc.
14 * hamilton@redhat.com [MIPS64 modifications]
15 *
16 * Author: RidgeRun, Inc.
17 * glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
18 *
19 * Copyright 2001 MontaVista Software Inc.
20 * Author: jsun@mvista.com or jsun@junsun.net
21 *
22 * This program is free software; you can redistribute it and/or modify it
23 * under the terms of the GNU General Public License as published by the
24 * Free Software Foundation; either version 2 of the License, or (at your
25 * option) any later version.
26 *
27 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
28 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
29 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
30 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
31 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
32 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
33 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
34 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
36 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 *
38 * You should have received a copy of the GNU General Public License along
39 * with this program; if not, write to the Free Software Foundation, Inc.,
40 * 675 Mass Ave, Cambridge, MA 02139, USA.
41 */
42#include <linux/bcd.h>
43#include <linux/init.h>
44#include <linux/kernel.h>
45#include <linux/types.h>
46#include <linux/mm.h>
47#include <linux/bootmem.h>
48#include <linux/module.h>
49#include <linux/pci.h>
50#include <linux/swap.h>
51#include <linux/ioport.h>
52#include <linux/pm.h>
53#include <linux/sched.h>
54#include <linux/interrupt.h>
55#include <linux/timex.h>
56#include <linux/vmalloc.h>
57#include <linux/mv643xx.h>
58
59#include <asm/time.h>
60#include <asm/bootinfo.h>
61#include <asm/page.h>
62#include <asm/io.h>
63#include <asm/irq.h>
64#include <asm/processor.h>
65#include <asm/reboot.h>
66#include <asm/tlbflush.h>
67
68#include "jaguar_atx_fpga.h"
69
70extern unsigned long mv64340_sram_base;
71unsigned long cpu_clock;
72
73/* These functions are used for rebooting or halting the machine*/
74extern void momenco_jaguar_restart(char *command);
75extern void momenco_jaguar_halt(void);
76extern void momenco_jaguar_power_off(void);
77
78void momenco_time_init(void);
79
80static char reset_reason;
81
82static inline unsigned long ENTRYLO(unsigned long paddr)
83{
84 return ((paddr & PAGE_MASK) |
85 (_PAGE_PRESENT | __READABLE | __WRITEABLE | _PAGE_GLOBAL |
86 _CACHE_UNCACHED)) >> 6;
87}
88
89void __init bus_error_init(void) { /* nothing */ }
90
91/*
92 * Load a few TLB entries for the MV64340 and perhiperals. The MV64340 is going
93 * to be hit on every IRQ anyway - there's absolutely no point in letting it be
94 * a random TLB entry, as it'll just cause needless churning of the TLB. And we
95 * use the other half for the serial port, which is just a PITA otherwise :)
96 *
97 * Device Physical Virtual
98 * MV64340 Internal Regs 0xf4000000 0xf4000000
99 * Ocelot-C[S] PLD (CS0) 0xfc000000 0xfc000000
100 * NVRAM (CS1) 0xfc800000 0xfc800000
101 * UARTs (CS2) 0xfd000000 0xfd000000
102 * Internal SRAM 0xfe000000 0xfe000000
103 * M-Systems DOC (CS3) 0xff000000 0xff000000
104 */
105
106static __init void wire_stupidity_into_tlb(void)
107{
108#ifdef CONFIG_32BIT
109 write_c0_wired(0);
110 local_flush_tlb_all();
111
112 /* marvell and extra space */
113 add_wired_entry(ENTRYLO(0xf4000000), ENTRYLO(0xf4010000),
114 0xf4000000UL, PM_64K);
115 /* fpga, rtc, and uart */
116 add_wired_entry(ENTRYLO(0xfc000000), ENTRYLO(0xfd000000),
117 0xfc000000UL, PM_16M);
118// /* m-sys and internal SRAM */
119// add_wired_entry(ENTRYLO(0xfe000000), ENTRYLO(0xff000000),
120// 0xfe000000UL, PM_16M);
121
122 marvell_base = 0xf4000000;
123 //mv64340_sram_base = 0xfe000000; /* Currently unused */
124#endif
125}
126
127unsigned long marvell_base = 0xf4000000L;
128unsigned long ja_fpga_base = JAGUAR_ATX_CS0_ADDR;
129unsigned long uart_base = 0xfd000000L;
130static unsigned char *rtc_base = (unsigned char*) 0xfc800000L;
131
132EXPORT_SYMBOL(marvell_base);
133
134static __init int per_cpu_mappings(void)
135{
136 marvell_base = (unsigned long) ioremap(0xf4000000, 0x10000);
137 ja_fpga_base = (unsigned long) ioremap(JAGUAR_ATX_CS0_ADDR, 0x1000);
138 uart_base = (unsigned long) ioremap(0xfd000000UL, 0x1000);
139 rtc_base = ioremap(0xfc000000UL, 0x8000);
140 // ioremap(0xfe000000, 32 << 20);
141 write_c0_wired(0);
142 local_flush_tlb_all();
143 ja_setup_console();
144
145 return 0;
146}
147arch_initcall(per_cpu_mappings);
148
149unsigned long m48t37y_get_time(void)
150{
151 unsigned int year, month, day, hour, min, sec;
152 unsigned long flags;
153
154 spin_lock_irqsave(&rtc_lock, flags);
155 /* stop the update */
156 rtc_base[0x7ff8] = 0x40;
157
158 year = BCD2BIN(rtc_base[0x7fff]);
159 year += BCD2BIN(rtc_base[0x7ff1]) * 100;
160
161 month = BCD2BIN(rtc_base[0x7ffe]);
162
163 day = BCD2BIN(rtc_base[0x7ffd]);
164
165 hour = BCD2BIN(rtc_base[0x7ffb]);
166 min = BCD2BIN(rtc_base[0x7ffa]);
167 sec = BCD2BIN(rtc_base[0x7ff9]);
168
169 /* start the update */
170 rtc_base[0x7ff8] = 0x00;
171 spin_unlock_irqrestore(&rtc_lock, flags);
172
173 return mktime(year, month, day, hour, min, sec);
174}
175
176int m48t37y_set_time(unsigned long sec)
177{
178 struct rtc_time tm;
179 unsigned long flags;
180
181 /* convert to a more useful format -- note months count from 0 */
182 to_tm(sec, &tm);
183 tm.tm_mon += 1;
184
185 spin_lock_irqsave(&rtc_lock, flags);
186 /* enable writing */
187 rtc_base[0x7ff8] = 0x80;
188
189 /* year */
190 rtc_base[0x7fff] = BIN2BCD(tm.tm_year % 100);
191 rtc_base[0x7ff1] = BIN2BCD(tm.tm_year / 100);
192
193 /* month */
194 rtc_base[0x7ffe] = BIN2BCD(tm.tm_mon);
195
196 /* day */
197 rtc_base[0x7ffd] = BIN2BCD(tm.tm_mday);
198
199 /* hour/min/sec */
200 rtc_base[0x7ffb] = BIN2BCD(tm.tm_hour);
201 rtc_base[0x7ffa] = BIN2BCD(tm.tm_min);
202 rtc_base[0x7ff9] = BIN2BCD(tm.tm_sec);
203
204 /* day of week -- not really used, but let's keep it up-to-date */
205 rtc_base[0x7ffc] = BIN2BCD(tm.tm_wday + 1);
206
207 /* disable writing */
208 rtc_base[0x7ff8] = 0x00;
209 spin_unlock_irqrestore(&rtc_lock, flags);
210
211 return 0;
212}
213
214void __init plat_timer_setup(struct irqaction *irq)
215{
216 setup_irq(8, irq);
217}
218
219/*
220 * Ugly but the least of all evils. TLB initialization did flush the TLB so
221 * We need to setup mappings again before we can touch the RTC.
222 */
223void momenco_time_init(void)
224{
225 wire_stupidity_into_tlb();
226
227 mips_hpt_frequency = cpu_clock / 2;
228
229 rtc_mips_get_time = m48t37y_get_time;
230 rtc_mips_set_time = m48t37y_set_time;
231}
232
233static struct resource mv_pci_io_mem0_resource = {
234 .name = "MV64340 PCI0 IO MEM",
235 .flags = IORESOURCE_IO
236};
237
238static struct resource mv_pci_mem0_resource = {
239 .name = "MV64340 PCI0 MEM",
240 .flags = IORESOURCE_MEM
241};
242
243static struct mv_pci_controller mv_bus0_controller = {
244 .pcic = {
245 .pci_ops = &mv_pci_ops,
246 .mem_resource = &mv_pci_mem0_resource,
247 .io_resource = &mv_pci_io_mem0_resource,
248 },
249 .config_addr = MV64340_PCI_0_CONFIG_ADDR,
250 .config_vreg = MV64340_PCI_0_CONFIG_DATA_VIRTUAL_REG,
251};
252
253static uint32_t mv_io_base, mv_io_size;
254
255static void ja_pci0_init(void)
256{
257 uint32_t mem0_base, mem0_size;
258 uint32_t io_base, io_size;
259
260 io_base = MV_READ(MV64340_PCI_0_IO_BASE_ADDR) << 16;
261 io_size = (MV_READ(MV64340_PCI_0_IO_SIZE) + 1) << 16;
262 mem0_base = MV_READ(MV64340_PCI_0_MEMORY0_BASE_ADDR) << 16;
263 mem0_size = (MV_READ(MV64340_PCI_0_MEMORY0_SIZE) + 1) << 16;
264
265 mv_pci_io_mem0_resource.start = 0;
266 mv_pci_io_mem0_resource.end = io_size - 1;
267 mv_pci_mem0_resource.start = mem0_base;
268 mv_pci_mem0_resource.end = mem0_base + mem0_size - 1;
269 mv_bus0_controller.pcic.mem_offset = mem0_base;
270 mv_bus0_controller.pcic.io_offset = 0;
271
272 ioport_resource.end = io_size - 1;
273
274 register_pci_controller(&mv_bus0_controller.pcic);
275
276 mv_io_base = io_base;
277 mv_io_size = io_size;
278}
279
280static struct resource mv_pci_io_mem1_resource = {
281 .name = "MV64340 PCI1 IO MEM",
282 .flags = IORESOURCE_IO
283};
284
285static struct resource mv_pci_mem1_resource = {
286 .name = "MV64340 PCI1 MEM",
287 .flags = IORESOURCE_MEM
288};
289
290static struct mv_pci_controller mv_bus1_controller = {
291 .pcic = {
292 .pci_ops = &mv_pci_ops,
293 .mem_resource = &mv_pci_mem1_resource,
294 .io_resource = &mv_pci_io_mem1_resource,
295 },
296 .config_addr = MV64340_PCI_1_CONFIG_ADDR,
297 .config_vreg = MV64340_PCI_1_CONFIG_DATA_VIRTUAL_REG,
298};
299
300static __init void ja_pci1_init(void)
301{
302 uint32_t mem0_base, mem0_size;
303 uint32_t io_base, io_size;
304
305 io_base = MV_READ(MV64340_PCI_1_IO_BASE_ADDR) << 16;
306 io_size = (MV_READ(MV64340_PCI_1_IO_SIZE) + 1) << 16;
307 mem0_base = MV_READ(MV64340_PCI_1_MEMORY0_BASE_ADDR) << 16;
308 mem0_size = (MV_READ(MV64340_PCI_1_MEMORY0_SIZE) + 1) << 16;
309
310 /*
311 * Here we assume the I/O window of second bus to be contiguous with
312 * the first. A gap is no problem but would waste address space for
313 * remapping the port space.
314 */
315 mv_pci_io_mem1_resource.start = mv_io_size;
316 mv_pci_io_mem1_resource.end = mv_io_size + io_size - 1;
317 mv_pci_mem1_resource.start = mem0_base;
318 mv_pci_mem1_resource.end = mem0_base + mem0_size - 1;
319 mv_bus1_controller.pcic.mem_offset = mem0_base;
320 mv_bus1_controller.pcic.io_offset = 0;
321
322 ioport_resource.end = io_base + io_size -mv_io_base - 1;
323
324 register_pci_controller(&mv_bus1_controller.pcic);
325
326 mv_io_size = io_base + io_size - mv_io_base;
327}
328
329static __init int __init ja_pci_init(void)
330{
331 unsigned long io_v_base;
332 uint32_t enable;
333
334 enable = ~MV_READ(MV64340_BASE_ADDR_ENABLE);
335
336 /*
337 * We require at least one enabled I/O or PCI memory window or we
338 * will ignore this PCI bus. We ignore PCI windows 1, 2 and 3.
339 */
340 if (enable & (0x01 << 9) || enable & (0x01 << 10))
341 ja_pci0_init();
342
343 if (enable & (0x01 << 14) || enable & (0x01 << 15))
344 ja_pci1_init();
345
346 if (mv_io_size) {
347 io_v_base = (unsigned long) ioremap(mv_io_base, mv_io_size);
348 if (!io_v_base)
349 panic("Could not ioremap I/O port range");
350
351 set_io_port_base(io_v_base);
352 }
353
354 return 0;
355}
356
357arch_initcall(ja_pci_init);
358
359void __init plat_mem_setup(void)
360{
361 unsigned int tmpword;
362
363 board_time_init = momenco_time_init;
364
365 _machine_restart = momenco_jaguar_restart;
366 _machine_halt = momenco_jaguar_halt;
367 pm_power_off = momenco_jaguar_power_off;
368
369 /*
370 * initrd_start = (unsigned long)jaguar_initrd_start;
371 * initrd_end = (unsigned long)jaguar_initrd_start + (ulong)jaguar_initrd_size;
372 * initrd_below_start_ok = 1;
373 */
374
375 wire_stupidity_into_tlb();
376
377 /*
378 * shut down ethernet ports, just to be sure our memory doesn't get
379 * corrupted by random ethernet traffic.
380 */
381 MV_WRITE(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(0), 0xff << 8);
382 MV_WRITE(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(1), 0xff << 8);
383 MV_WRITE(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(2), 0xff << 8);
384 MV_WRITE(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(0), 0xff << 8);
385 MV_WRITE(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(1), 0xff << 8);
386 MV_WRITE(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(2), 0xff << 8);
387 while (MV_READ(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(0)) & 0xff);
388 while (MV_READ(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(1)) & 0xff);
389 while (MV_READ(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(2)) & 0xff);
390 while (MV_READ(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(0)) & 0xff);
391 while (MV_READ(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(1)) & 0xff);
392 while (MV_READ(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(2)) & 0xff);
393 MV_WRITE(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(0),
394 MV_READ(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(0)) & ~1);
395 MV_WRITE(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(1),
396 MV_READ(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(1)) & ~1);
397 MV_WRITE(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(2),
398 MV_READ(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(2)) & ~1);
399
400 /* Turn off the Bit-Error LED */
401 JAGUAR_FPGA_WRITE(0x80, CLR);
402
403 tmpword = JAGUAR_FPGA_READ(BOARDREV);
404 if (tmpword < 26)
405 printk("Momentum Jaguar-ATX: Board Assembly Rev. %c\n",
406 'A'+tmpword);
407 else
408 printk("Momentum Jaguar-ATX: Board Assembly Revision #0x%x\n",
409 tmpword);
410
411 tmpword = JAGUAR_FPGA_READ(FPGA_REV);
412 printk("FPGA Rev: %d.%d\n", tmpword>>4, tmpword&15);
413 tmpword = JAGUAR_FPGA_READ(RESET_STATUS);
414 printk("Reset reason: 0x%x\n", tmpword);
415 switch (tmpword) {
416 case 0x1:
417 printk(" - Power-up reset\n");
418 break;
419 case 0x2:
420 printk(" - Push-button reset\n");
421 break;
422 case 0x8:
423 printk(" - Watchdog reset\n");
424 break;
425 case 0x10:
426 printk(" - JTAG reset\n");
427 break;
428 default:
429 printk(" - Unknown reset cause\n");
430 }
431 reset_reason = tmpword;
432 JAGUAR_FPGA_WRITE(0xff, RESET_STATUS);
433
434 tmpword = JAGUAR_FPGA_READ(BOARD_STATUS);
435 printk("Board Status register: 0x%02x\n", tmpword);
436 printk(" - User jumper: %s\n", (tmpword & 0x80)?"installed":"absent");
437 printk(" - Boot flash write jumper: %s\n", (tmpword&0x40)?"installed":"absent");
438
439 /* 256MiB of RM9000x2 DDR */
440// add_memory_region(0x0, 0x100<<20, BOOT_MEM_RAM);
441
442 /* 128MiB of MV-64340 DDR */
443// add_memory_region(0x100<<20, 0x80<<20, BOOT_MEM_RAM);
444
445 /* XXX Memory configuration should be picked up from PMON2k */
446#ifdef CONFIG_JAGUAR_DMALOW
447 printk("Jaguar ATX DMA-low mode set\n");
448 add_memory_region(0x00000000, 0x08000000, BOOT_MEM_RAM);
449 add_memory_region(0x08000000, 0x10000000, BOOT_MEM_RAM);
450#else
451 /* 128MiB of MV-64340 DDR RAM */
452 printk("Jaguar ATX DMA-low mode is not set\n");
453 add_memory_region(0x100<<20, 0x80<<20, BOOT_MEM_RAM);
454#endif
455
456#ifdef GEMDEBUG_TRACEBUFFER
457 {
458 unsigned int tbControl;
459 tbControl =
460 0 << 26 | /* post trigger delay 0 */
461 0x2 << 16 | /* sequential trace mode */
462 // 0x0 << 16 | /* non-sequential trace mode */
463 // 0xf << 4 | /* watchpoints disabled */
464 2 << 2 | /* armed */
465 2 ; /* interrupt disabled */
466 printk ("setting tbControl = %08lx\n", tbControl);
467 write_32bit_cp0_set1_register($22, tbControl);
468 __asm__ __volatile__(".set noreorder\n\t" \
469 "nop; nop; nop; nop; nop; nop;\n\t" \
470 "nop; nop; nop; nop; nop; nop;\n\t" \
471 ".set reorder\n\t");
472
473 }
474#endif
475}
diff --git a/arch/mips/momentum/ocelot_g/Makefile b/arch/mips/momentum/ocelot_g/Makefile
deleted file mode 100644
index c0a0030d949d..000000000000
--- a/arch/mips/momentum/ocelot_g/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
1#
2# Makefile for Momentum Computer's Ocelot-G board.
3#
4
5obj-y += irq.o gt-irq.o prom.o reset.o setup.o
6obj-$(CONFIG_KGDB) += dbg_io.o
diff --git a/arch/mips/momentum/ocelot_g/dbg_io.c b/arch/mips/momentum/ocelot_g/dbg_io.c
deleted file mode 100644
index 32d6fb4ee679..000000000000
--- a/arch/mips/momentum/ocelot_g/dbg_io.c
+++ /dev/null
@@ -1,121 +0,0 @@
1
2#include <asm/serial.h> /* For the serial port location and base baud */
3
4/* --- CONFIG --- */
5
6typedef unsigned char uint8;
7typedef unsigned int uint32;
8
9/* --- END OF CONFIG --- */
10
11#define UART16550_BAUD_2400 2400
12#define UART16550_BAUD_4800 4800
13#define UART16550_BAUD_9600 9600
14#define UART16550_BAUD_19200 19200
15#define UART16550_BAUD_38400 38400
16#define UART16550_BAUD_57600 57600
17#define UART16550_BAUD_115200 115200
18
19#define UART16550_PARITY_NONE 0
20#define UART16550_PARITY_ODD 0x08
21#define UART16550_PARITY_EVEN 0x18
22#define UART16550_PARITY_MARK 0x28
23#define UART16550_PARITY_SPACE 0x38
24
25#define UART16550_DATA_5BIT 0x0
26#define UART16550_DATA_6BIT 0x1
27#define UART16550_DATA_7BIT 0x2
28#define UART16550_DATA_8BIT 0x3
29
30#define UART16550_STOP_1BIT 0x0
31#define UART16550_STOP_2BIT 0x4
32
33/* ----------------------------------------------------- */
34
35/* === CONFIG === */
36
37/* [jsun] we use the second serial port for kdb */
38#define BASE OCELOT_SERIAL1_BASE
39#define MAX_BAUD OCELOT_BASE_BAUD
40
41/* === END OF CONFIG === */
42
43#define REG_OFFSET 4
44
45/* register offset */
46#define OFS_RCV_BUFFER 0
47#define OFS_TRANS_HOLD 0
48#define OFS_SEND_BUFFER 0
49#define OFS_INTR_ENABLE (1*REG_OFFSET)
50#define OFS_INTR_ID (2*REG_OFFSET)
51#define OFS_DATA_FORMAT (3*REG_OFFSET)
52#define OFS_LINE_CONTROL (3*REG_OFFSET)
53#define OFS_MODEM_CONTROL (4*REG_OFFSET)
54#define OFS_RS232_OUTPUT (4*REG_OFFSET)
55#define OFS_LINE_STATUS (5*REG_OFFSET)
56#define OFS_MODEM_STATUS (6*REG_OFFSET)
57#define OFS_RS232_INPUT (6*REG_OFFSET)
58#define OFS_SCRATCH_PAD (7*REG_OFFSET)
59
60#define OFS_DIVISOR_LSB (0*REG_OFFSET)
61#define OFS_DIVISOR_MSB (1*REG_OFFSET)
62
63
64/* memory-mapped read/write of the port */
65#define UART16550_READ(y) (*((volatile uint8*)(BASE + y)))
66#define UART16550_WRITE(y, z) ((*((volatile uint8*)(BASE + y))) = z)
67
68void debugInit(uint32 baud, uint8 data, uint8 parity, uint8 stop)
69{
70 /* disable interrupts */
71 UART16550_WRITE(OFS_INTR_ENABLE, 0);
72
73 /* set up baud rate */
74 {
75 uint32 divisor;
76
77 /* set DIAB bit */
78 UART16550_WRITE(OFS_LINE_CONTROL, 0x80);
79
80 /* set divisor */
81 divisor = MAX_BAUD / baud;
82 UART16550_WRITE(OFS_DIVISOR_LSB, divisor & 0xff);
83 UART16550_WRITE(OFS_DIVISOR_MSB, (divisor & 0xff00) >> 8);
84
85 /* clear DIAB bit */
86 UART16550_WRITE(OFS_LINE_CONTROL, 0x0);
87 }
88
89 /* set data format */
90 UART16550_WRITE(OFS_DATA_FORMAT, data | parity | stop);
91}
92
93static int remoteDebugInitialized = 0;
94
95uint8 getDebugChar(void)
96{
97 if (!remoteDebugInitialized) {
98 remoteDebugInitialized = 1;
99 debugInit(UART16550_BAUD_38400,
100 UART16550_DATA_8BIT,
101 UART16550_PARITY_NONE, UART16550_STOP_1BIT);
102 }
103
104 while ((UART16550_READ(OFS_LINE_STATUS) & 0x1) == 0);
105 return UART16550_READ(OFS_RCV_BUFFER);
106}
107
108
109int putDebugChar(uint8 byte)
110{
111 if (!remoteDebugInitialized) {
112 remoteDebugInitialized = 1;
113 debugInit(UART16550_BAUD_38400,
114 UART16550_DATA_8BIT,
115 UART16550_PARITY_NONE, UART16550_STOP_1BIT);
116 }
117
118 while ((UART16550_READ(OFS_LINE_STATUS) & 0x20) == 0);
119 UART16550_WRITE(OFS_SEND_BUFFER, byte);
120 return 1;
121}
diff --git a/arch/mips/momentum/ocelot_g/gt-irq.c b/arch/mips/momentum/ocelot_g/gt-irq.c
deleted file mode 100644
index e5576bd50fa9..000000000000
--- a/arch/mips/momentum/ocelot_g/gt-irq.c
+++ /dev/null
@@ -1,212 +0,0 @@
1/*
2 *
3 * Copyright 2002 Momentum Computer
4 * Author: mdharm@momenco.com
5 *
6 * arch/mips/momentum/ocelot_g/gt_irq.c
7 * Interrupt routines for gt64240. Currently it only handles timer irq.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 */
14#include <linux/module.h>
15#include <linux/interrupt.h>
16#include <linux/kernel.h>
17#include <linux/sched.h>
18#include <linux/kernel_stat.h>
19#include <asm/gt64240.h>
20#include <asm/io.h>
21
22unsigned long bus_clock;
23
24/*
25 * These are interrupt handlers for the GT on-chip interrupts. They
26 * all come in to the MIPS on a single interrupt line, and have to
27 * be handled and ack'ed differently than other MIPS interrupts.
28 */
29
30#if 0
31
32struct tq_struct irq_handlers[MAX_CAUSE_REGS][MAX_CAUSE_REG_WIDTH];
33void hook_irq_handler(int int_cause, int bit_num, void *isr_ptr);
34
35/*
36 * Hooks IRQ handler to the system. When the system is interrupted
37 * the interrupt service routine is called.
38 *
39 * Inputs :
40 * int_cause - The interrupt cause number. In EVB64120 two parameters
41 * are declared, INT_CAUSE_MAIN and INT_CAUSE_HIGH.
42 * bit_num - Indicates which bit number in the cause register
43 * isr_ptr - Pointer to the interrupt service routine
44 */
45void hook_irq_handler(int int_cause, int bit_num, void *isr_ptr)
46{
47 irq_handlers[int_cause][bit_num].routine = isr_ptr;
48}
49
50
51/*
52 * Enables the IRQ on Galileo Chip
53 *
54 * Inputs :
55 * int_cause - The interrupt cause number. In EVB64120 two parameters
56 * are declared, INT_CAUSE_MAIN and INT_CAUSE_HIGH.
57 * bit_num - Indicates which bit number in the cause register
58 *
59 * Outputs :
60 * 1 if successful, 0 if failure
61 */
62int enable_galileo_irq(int int_cause, int bit_num)
63{
64 if (int_cause == INT_CAUSE_MAIN)
65 SET_REG_BITS(CPU_INTERRUPT_MASK_REGISTER, (1 << bit_num));
66 else if (int_cause == INT_CAUSE_HIGH)
67 SET_REG_BITS(CPU_HIGH_INTERRUPT_MASK_REGISTER,
68 (1 << bit_num));
69 else
70 return 0;
71
72 return 1;
73}
74
75/*
76 * Disables the IRQ on Galileo Chip
77 *
78 * Inputs :
79 * int_cause - The interrupt cause number. In EVB64120 two parameters
80 * are declared, INT_CAUSE_MAIN and INT_CAUSE_HIGH.
81 * bit_num - Indicates which bit number in the cause register
82 *
83 * Outputs :
84 * 1 if successful, 0 if failure
85 */
86int disable_galileo_irq(int int_cause, int bit_num)
87{
88 if (int_cause == INT_CAUSE_MAIN)
89 RESET_REG_BITS(CPU_INTERRUPT_MASK_REGISTER,
90 (1 << bit_num));
91 else if (int_cause == INT_CAUSE_HIGH)
92 RESET_REG_BITS(CPU_HIGH_INTERRUPT_MASK_REGISTER,
93 (1 << bit_num));
94 else
95 return 0;
96 return 1;
97}
98#endif /* 0 */
99
100/*
101 * Interrupt handler for interrupts coming from the Galileo chip via P0_INT#.
102 *
103 * We route the timer interrupt to P0_INT# (IRQ 6), and that's all this
104 * routine can handle, for now.
105 *
106 * In the future, we'll route more interrupts to this pin, and that's why
107 * we keep this particular structure in the function.
108 */
109
110static irqreturn_t gt64240_p0int_irq(int irq, void *dev)
111{
112 uint32_t irq_src, irq_src_mask;
113 int handled;
114
115 /* get the low interrupt cause register */
116 irq_src = MV_READ(LOW_INTERRUPT_CAUSE_REGISTER);
117
118 /* get the mask register for this pin */
119 irq_src_mask = MV_READ(PCI_0INTERRUPT_CAUSE_MASK_REGISTER_LOW);
120
121 /* mask off only the interrupts we're interested in */
122 irq_src = irq_src & irq_src_mask;
123
124 handled = IRQ_NONE;
125
126 /* Check for timer interrupt */
127 if (irq_src & 0x00000100) {
128 handled = IRQ_HANDLED;
129 irq_src &= ~0x00000100;
130
131 /* Clear any pending cause bits */
132 MV_WRITE(TIMER_COUNTER_0_3_INTERRUPT_CAUSE, 0x0);
133
134 /* handle the timer call */
135 do_timer(1);
136#ifndef CONFIG_SMP
137 update_process_times(user_mode(get_irq_regs()));
138#endif
139 }
140
141 if (irq_src) {
142 printk(KERN_INFO
143 "UNKNOWN P0_INT# interrupt received, irq_src=0x%x\n",
144 irq_src);
145 }
146
147 return handled;
148}
149
150/*
151 * Initializes timer using galileo's built in timer.
152 */
153
154/*
155 * This will ignore the standard MIPS timer interrupt handler
156 * that is passed in as *irq (=irq0 in ../kernel/time.c).
157 * We will do our own timer interrupt handling.
158 */
159void gt64240_time_init(void)
160{
161 static struct irqaction timer;
162
163 /* Stop the timer -- we'll use timer #0 */
164 MV_WRITE(TIMER_COUNTER_0_3_CONTROL, 0x0);
165
166 /* Load timer value for 100 Hz */
167 MV_WRITE(TIMER_COUNTER0, bus_clock / 100);
168
169 /*
170 * Create the IRQ structure entry for the timer. Since we're too early
171 * in the boot process to use the "request_irq()" call, we'll hard-code
172 * the values to the correct interrupt line.
173 */
174 timer.handler = &gt64240_p0int_irq;
175 timer.flags = IRQF_SHARED | IRQF_DISABLED;
176 timer.name = "timer";
177 timer.dev_id = NULL;
178 timer.next = NULL;
179 timer.mask = CPU_MASK_NONE;
180 irq_desc[6].action = &timer;
181
182 enable_irq(6);
183
184 /* Clear any pending cause bits */
185 MV_WRITE(TIMER_COUNTER_0_3_INTERRUPT_CAUSE, 0x0);
186
187 /* Enable the interrupt for timer 0 */
188 MV_WRITE(TIMER_COUNTER_0_3_INTERRUPT_MASK, 0x1);
189
190 /* Enable the timer interrupt for GT-64240 pin P0_INT# */
191 MV_WRITE (PCI_0INTERRUPT_CAUSE_MASK_REGISTER_LOW, 0x100);
192
193 /* Configure and start the timer */
194 MV_WRITE(TIMER_COUNTER_0_3_CONTROL, 0x3);
195}
196
197void gt64240_irq_init(void)
198{
199#if 0
200 int i, j;
201
202 /* Reset irq handlers pointers to NULL */
203 for (i = 0; i < MAX_CAUSE_REGS; i++) {
204 for (j = 0; j < MAX_CAUSE_REG_WIDTH; j++) {
205 irq_handlers[i][j].next = NULL;
206 irq_handlers[i][j].sync = 0;
207 irq_handlers[i][j].routine = NULL;
208 irq_handlers[i][j].data = NULL;
209 }
210 }
211#endif /* 0 */
212}
diff --git a/arch/mips/momentum/ocelot_g/irq.c b/arch/mips/momentum/ocelot_g/irq.c
deleted file mode 100644
index 273541fe7087..000000000000
--- a/arch/mips/momentum/ocelot_g/irq.c
+++ /dev/null
@@ -1,101 +0,0 @@
1/*
2 * Copyright (C) 2000 RidgeRun, Inc.
3 * Author: RidgeRun, Inc.
4 * glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
5 *
6 * Copyright 2001 MontaVista Software Inc.
7 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
8 * Copyright (C) 2000, 01, 05 Ralf Baechle (ralf@linux-mips.org)
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
18 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
21 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 675 Mass Ave, Cambridge, MA 02139, USA.
29 *
30 */
31#include <linux/errno.h>
32#include <linux/init.h>
33#include <linux/kernel_stat.h>
34#include <linux/module.h>
35#include <linux/signal.h>
36#include <linux/sched.h>
37#include <linux/types.h>
38#include <linux/interrupt.h>
39#include <linux/ioport.h>
40#include <linux/timex.h>
41#include <linux/slab.h>
42#include <linux/random.h>
43#include <linux/bitops.h>
44#include <asm/bootinfo.h>
45#include <asm/io.h>
46#include <asm/irq.h>
47#include <asm/irq_cpu.h>
48#include <asm/mipsregs.h>
49#include <asm/system.h>
50
51asmlinkage void plat_irq_dispatch(void)
52{
53 unsigned int pending = read_c0_cause() & read_c0_status();
54
55 if (pending & STATUSF_IP2)
56 do_IRQ(2);
57 else if (pending & STATUSF_IP3)
58 do_IRQ(3);
59 else if (pending & STATUSF_IP4)
60 do_IRQ(4);
61 else if (pending & STATUSF_IP5)
62 do_IRQ(5);
63 else if (pending & STATUSF_IP6)
64 do_IRQ(6);
65 else if (pending & STATUSF_IP7)
66 do_IRQ(7);
67 else {
68 /*
69 * Now look at the extended interrupts
70 */
71 pending = (read_c0_cause() & (read_c0_intcontrol() << 8)) >> 16;
72
73 if (pending & STATUSF_IP8)
74 do_IRQ(8);
75 else if (pending & STATUSF_IP9)
76 do_IRQ(9);
77 else if (pending & STATUSF_IP10)
78 do_IRQ(10);
79 else if (pending & STATUSF_IP11)
80 do_IRQ(11);
81 else
82 spurious_interrupt();
83 }
84}
85
86extern void gt64240_irq_init(void);
87
88void __init arch_init_irq(void)
89{
90 /*
91 * Clear all of the interrupts while we change the able around a bit.
92 * int-handler is not on bootstrap
93 */
94 clear_c0_status(ST0_IM);
95 local_irq_disable();
96
97 mips_cpu_irq_init();
98 rm7k_cpu_irq_init();
99
100 gt64240_irq_init();
101}
diff --git a/arch/mips/momentum/ocelot_g/ocelot_pld.h b/arch/mips/momentum/ocelot_g/ocelot_pld.h
deleted file mode 100644
index 95e0534026d0..000000000000
--- a/arch/mips/momentum/ocelot_g/ocelot_pld.h
+++ /dev/null
@@ -1,30 +0,0 @@
1/*
2 * Ocelot Board Register Definitions
3 *
4 * (C) 2001 Red Hat, Inc.
5 *
6 * GPL'd
7 */
8#ifndef __MOMENCO_OCELOT_PLD_H__
9#define __MOMENCO_OCELOT_PLD_H__
10
11#define OCELOT_CS0_ADDR (0xfc000000)
12
13#define OCELOT_REG_BOARDREV (0)
14#define OCELOT_REG_PLD1_ID (1)
15#define OCELOT_REG_PLD2_ID (2)
16#define OCELOT_REG_RESET_STATUS (3)
17#define OCELOT_REG_BOARD_STATUS (4)
18#define OCELOT_REG_CPCI_ID (5)
19#define OCELOT_REG_I2C_CTRL (8)
20#define OCELOT_REG_EEPROM_MODE (9)
21#define OCELOT_REG_INTMASK (10)
22#define OCELOT_REG_INTSTATUS (11)
23#define OCELOT_REG_INTSET (12)
24#define OCELOT_REG_INTCLR (13)
25
26#define __PLD_REG_TO_ADDR(reg) ((void *) OCELOT_CS0_ADDR + OCELOT_REG_##reg)
27#define OCELOT_PLD_WRITE(x, reg) writeb(x, __PLD_REG_TO_ADDR(reg))
28#define OCELOT_PLD_READ(reg) readb(__PLD_REG_TO_ADDR(reg))
29
30#endif /* __MOMENCO_OCELOT_PLD_H__ */
diff --git a/arch/mips/momentum/ocelot_g/prom.c b/arch/mips/momentum/ocelot_g/prom.c
deleted file mode 100644
index 836d0830720d..000000000000
--- a/arch/mips/momentum/ocelot_g/prom.c
+++ /dev/null
@@ -1,84 +0,0 @@
1/*
2 * Copyright 2002 Momentum Computer Inc.
3 * Author: Matthew Dharm <mdharm@momenco.com>
4 *
5 * Based on Ocelot Linux port, which is
6 * Copyright 2001 MontaVista Software Inc.
7 * Author: jsun@mvista.com or jsun@junsun.net
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 */
14#include <linux/init.h>
15#include <linux/mm.h>
16#include <linux/sched.h>
17#include <linux/bootmem.h>
18
19#include <asm/addrspace.h>
20#include <asm/bootinfo.h>
21#include <asm/pmon.h>
22#include <asm/gt64240.h>
23
24#include "ocelot_pld.h"
25
26struct callvectors* debug_vectors;
27
28extern unsigned long marvell_base;
29extern unsigned long bus_clock;
30
31#ifdef CONFIG_GALILEO_GT64240_ETH
32extern unsigned char prom_mac_addr_base[6];
33#endif
34
35const char *get_system_type(void)
36{
37 return "Momentum Ocelot";
38}
39
40void __init prom_init(void)
41{
42 int argc = fw_arg0;
43 char **arg = (char **) fw_arg1;
44 char **env = (char **) fw_arg2;
45 struct callvectors *cv = (struct callvectors *) fw_arg3;
46 int i;
47
48 /* save the PROM vectors for debugging use */
49 debug_vectors = cv;
50
51 /* arg[0] is "g", the rest is boot parameters */
52 arcs_cmdline[0] = '\0';
53 for (i = 1; i < argc; i++) {
54 if (strlen(arcs_cmdline) + strlen(arg[i] + 1)
55 >= sizeof(arcs_cmdline))
56 break;
57 strcat(arcs_cmdline, arg[i]);
58 strcat(arcs_cmdline, " ");
59 }
60
61 mips_machgroup = MACH_GROUP_MOMENCO;
62 mips_machtype = MACH_MOMENCO_OCELOT_G;
63
64#ifdef CONFIG_GALILEO_GT64240_ETH
65 /* get the base MAC address for on-board ethernet ports */
66 memcpy(prom_mac_addr_base, (void*)0xfc807cf2, 6);
67#endif
68
69 while (*env) {
70 if (strncmp("gtbase", *env, strlen("gtbase")) == 0) {
71 marvell_base = simple_strtol(*env + strlen("gtbase="),
72 NULL, 16);
73 }
74 if (strncmp("busclock", *env, strlen("busclock")) == 0) {
75 bus_clock = simple_strtol(*env + strlen("busclock="),
76 NULL, 10);
77 }
78 env++;
79 }
80}
81
82void __init prom_free_prom_memory(void)
83{
84}
diff --git a/arch/mips/momentum/ocelot_g/reset.c b/arch/mips/momentum/ocelot_g/reset.c
deleted file mode 100644
index 3fd499adf4cf..000000000000
--- a/arch/mips/momentum/ocelot_g/reset.c
+++ /dev/null
@@ -1,47 +0,0 @@
1/*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation; either version 2 of the License, or (at your
5 * option) any later version.
6 *
7 * Copyright (C) 1997, 2001 Ralf Baechle
8 * Copyright 2001 MontaVista Software Inc.
9 * Author: jsun@mvista.com or jsun@junsun.net
10 */
11#include <linux/sched.h>
12#include <linux/mm.h>
13#include <asm/io.h>
14#include <asm/pgtable.h>
15#include <asm/processor.h>
16#include <asm/reboot.h>
17#include <asm/system.h>
18#include <linux/delay.h>
19
20void momenco_ocelot_restart(char *command)
21{
22 void *nvram = ioremap_nocache(0x2c807000, 0x1000);
23
24 if (!nvram) {
25 printk(KERN_NOTICE "ioremap of reset register failed\n");
26 return;
27 }
28 writeb(0x84, nvram + 0xff7); /* Ask the NVRAM/RTC/watchdog chip to
29 assert reset in 1/16 second */
30 mdelay(10+(1000/16));
31 iounmap(nvram);
32 printk(KERN_NOTICE "Watchdog reset failed\n");
33}
34
35void momenco_ocelot_halt(void)
36{
37 printk(KERN_NOTICE "\n** You can safely turn off the power\n");
38 while (1)
39 __asm__(".set\tmips3\n\t"
40 "wait\n\t"
41 ".set\tmips0");
42}
43
44void momenco_ocelot_power_off(void)
45{
46 momenco_ocelot_halt();
47}
diff --git a/arch/mips/momentum/ocelot_g/setup.c b/arch/mips/momentum/ocelot_g/setup.c
deleted file mode 100644
index 9db638a7982c..000000000000
--- a/arch/mips/momentum/ocelot_g/setup.c
+++ /dev/null
@@ -1,267 +0,0 @@
1/*
2 * BRIEF MODULE DESCRIPTION
3 * Momentum Computer Ocelot-G (CP7000G) - board dependent boot routines
4 *
5 * Copyright (C) 1996, 1997, 2001 Ralf Baechle
6 * Copyright (C) 2000 RidgeRun, Inc.
7 * Copyright (C) 2001 Red Hat, Inc.
8 * Copyright (C) 2002 Momentum Computer
9 *
10 * Author: Matthew Dharm, Momentum Computer
11 * mdharm@momenco.com
12 *
13 * Author: RidgeRun, Inc.
14 * glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
15 *
16 * Copyright 2001 MontaVista Software Inc.
17 * Author: jsun@mvista.com or jsun@junsun.net
18 *
19 * This program is free software; you can redistribute it and/or modify it
20 * under the terms of the GNU General Public License as published by the
21 * Free Software Foundation; either version 2 of the License, or (at your
22 * option) any later version.
23 *
24 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
25 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
27 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 * You should have received a copy of the GNU General Public License along
36 * with this program; if not, write to the Free Software Foundation, Inc.,
37 * 675 Mass Ave, Cambridge, MA 02139, USA.
38 *
39 */
40#include <linux/init.h>
41#include <linux/kernel.h>
42#include <linux/types.h>
43#include <linux/mm.h>
44#include <linux/swap.h>
45#include <linux/ioport.h>
46#include <linux/sched.h>
47#include <linux/interrupt.h>
48#include <linux/pci.h>
49#include <linux/pm.h>
50#include <linux/timex.h>
51#include <linux/vmalloc.h>
52
53#include <asm/time.h>
54#include <asm/bootinfo.h>
55#include <asm/page.h>
56#include <asm/io.h>
57#include <asm/gt64240.h>
58#include <asm/irq.h>
59#include <asm/pci.h>
60#include <asm/pgtable.h>
61#include <asm/processor.h>
62#include <asm/reboot.h>
63#include <linux/bootmem.h>
64
65#include "ocelot_pld.h"
66
67#ifdef CONFIG_GALILEO_GT64240_ETH
68extern unsigned char prom_mac_addr_base[6];
69#endif
70
71unsigned long marvell_base;
72
73/* These functions are used for rebooting or halting the machine*/
74extern void momenco_ocelot_restart(char *command);
75extern void momenco_ocelot_halt(void);
76extern void momenco_ocelot_power_off(void);
77
78extern void gt64240_time_init(void);
79extern void momenco_ocelot_irq_setup(void);
80
81static char reset_reason;
82
83static unsigned long ENTRYLO(unsigned long paddr)
84{
85 return ((paddr & PAGE_MASK) |
86 (_PAGE_PRESENT | __READABLE | __WRITEABLE | _PAGE_GLOBAL |
87 _CACHE_UNCACHED)) >> 6;
88}
89
90/* setup code for a handoff from a version 2 PMON 2000 PROM */
91void PMON_v2_setup(void)
92{
93 /* A wired TLB entry for the GT64240 and the serial port. The
94 GT64240 is going to be hit on every IRQ anyway - there's
95 absolutely no point in letting it be a random TLB entry, as
96 it'll just cause needless churning of the TLB. And we use
97 the other half for the serial port, which is just a PITA
98 otherwise :)
99
100 Device Physical Virtual
101 GT64240 Internal Regs 0xf4000000 0xe0000000
102 UARTs (CS2) 0xfd000000 0xe0001000
103 */
104 add_wired_entry(ENTRYLO(0xf4000000), ENTRYLO(0xf4010000),
105 0xf4000000, PM_64K);
106 add_wired_entry(ENTRYLO(0xfd000000), ENTRYLO(0xfd001000),
107 0xfd000000, PM_4K);
108
109 /* Also a temporary entry to let us talk to the Ocelot PLD and NVRAM
110 in the CS[012] region. We can't use ioremap() yet. The NVRAM
111 is a ST M48T37Y, which includes NVRAM, RTC, and Watchdog functions.
112
113 Ocelot PLD (CS0) 0xfc000000 0xe0020000
114 NVRAM (CS1) 0xfc800000 0xe0030000
115 */
116 add_temporary_entry(ENTRYLO(0xfc000000), ENTRYLO(0xfc010000),
117 0xfc000000, PM_64K);
118 add_temporary_entry(ENTRYLO(0xfc800000), ENTRYLO(0xfc810000),
119 0xfc800000, PM_64K);
120
121 marvell_base = 0xf4000000;
122}
123
124extern int rm7k_tcache_enabled;
125
126/*
127 * This runs in KSEG1. See the verbiage in rm7k.c::probe_scache()
128 */
129#define Page_Invalidate_T 0x16
130static void __init setup_l3cache(unsigned long size)
131{
132 int register i;
133
134 printk("Enabling L3 cache...");
135
136 /* Enable the L3 cache in the GT64120A's CPU Configuration register */
137 MV_WRITE(0, MV_READ(0) | (1<<14));
138
139 /* Enable the L3 cache in the CPU */
140 set_c0_config(1<<12 /* CONF_TE */);
141
142 /* Clear the cache */
143 write_c0_taglo(0);
144 write_c0_taghi(0);
145
146 for (i=0; i < size; i+= 4096) {
147 __asm__ __volatile__ (
148 ".set noreorder\n\t"
149 ".set mips3\n\t"
150 "cache %1, (%0)\n\t"
151 ".set mips0\n\t"
152 ".set reorder"
153 :
154 : "r" (KSEG0ADDR(i)),
155 "i" (Page_Invalidate_T));
156 }
157
158 /* Let the RM7000 MM code know that the tertiary cache is enabled */
159 rm7k_tcache_enabled = 1;
160
161 printk("Done\n");
162}
163
164void __init plat_timer_setup(struct irqaction *irq)
165{
166}
167
168void __init plat_mem_setup(void)
169{
170 void (*l3func)(unsigned long) = (void *) KSEG1ADDR(setup_l3cache);
171 unsigned int tmpword;
172
173 board_time_init = gt64240_time_init;
174
175 _machine_restart = momenco_ocelot_restart;
176 _machine_halt = momenco_ocelot_halt;
177 pm_power_off = momenco_ocelot_power_off;
178
179 /*
180 * initrd_start = (unsigned long)ocelot_initrd_start;
181 * initrd_end = (unsigned long)ocelot_initrd_start + (ulong)ocelot_initrd_size;
182 * initrd_below_start_ok = 1;
183 */
184
185 /* do handoff reconfiguration */
186 PMON_v2_setup();
187
188#ifdef CONFIG_GALILEO_GT64240_ETH
189 /* get the mac addr */
190 memcpy(prom_mac_addr_base, (void*)0xfc807cf2, 6);
191#endif
192
193 /* Turn off the Bit-Error LED */
194 OCELOT_PLD_WRITE(0x80, INTCLR);
195
196 tmpword = OCELOT_PLD_READ(BOARDREV);
197 if (tmpword < 26)
198 printk("Momenco Ocelot-G: Board Assembly Rev. %c\n", 'A'+tmpword);
199 else
200 printk("Momenco Ocelot-G: Board Assembly Revision #0x%x\n", tmpword);
201
202 tmpword = OCELOT_PLD_READ(PLD1_ID);
203 printk("PLD 1 ID: %d.%d\n", tmpword>>4, tmpword&15);
204 tmpword = OCELOT_PLD_READ(PLD2_ID);
205 printk("PLD 2 ID: %d.%d\n", tmpword>>4, tmpword&15);
206 tmpword = OCELOT_PLD_READ(RESET_STATUS);
207 printk("Reset reason: 0x%x\n", tmpword);
208 reset_reason = tmpword;
209 OCELOT_PLD_WRITE(0xff, RESET_STATUS);
210
211 tmpword = OCELOT_PLD_READ(BOARD_STATUS);
212 printk("Board Status register: 0x%02x\n", tmpword);
213 printk(" - User jumper: %s\n", (tmpword & 0x80)?"installed":"absent");
214 printk(" - Boot flash write jumper: %s\n", (tmpword&0x40)?"installed":"absent");
215 printk(" - Tulip PHY %s connected\n", (tmpword&0x10)?"is":"not");
216 printk(" - L3 Cache size: %d MiB\n", (1<<((tmpword&12) >> 2))&~1);
217 printk(" - SDRAM size: %d MiB\n", 1<<(6+(tmpword&3)));
218
219 if (tmpword&12)
220 l3func((1<<(((tmpword&12) >> 2)+20)));
221
222 switch(tmpword &3) {
223 case 3:
224 /* 512MiB -- two banks of 256MiB */
225 add_memory_region( 0x0<<20, 0x100<<20, BOOT_MEM_RAM);
226/*
227 add_memory_region(0x100<<20, 0x100<<20, BOOT_MEM_RAM);
228*/
229 break;
230 case 2:
231 /* 256MiB -- two banks of 128MiB */
232 add_memory_region( 0x0<<20, 0x80<<20, BOOT_MEM_RAM);
233 add_memory_region(0x80<<20, 0x80<<20, BOOT_MEM_RAM);
234 break;
235 case 1:
236 /* 128MiB -- 64MiB per bank */
237 add_memory_region( 0x0<<20, 0x40<<20, BOOT_MEM_RAM);
238 add_memory_region(0x40<<20, 0x40<<20, BOOT_MEM_RAM);
239 break;
240 case 0:
241 /* 64MiB */
242 add_memory_region( 0x0<<20, 0x40<<20, BOOT_MEM_RAM);
243 break;
244 }
245
246 /* FIXME: Fix up the DiskOnChip mapping */
247 MV_WRITE(0x468, 0xfef73);
248}
249
250/* This needs to be one of the first initcalls, because no I/O port access
251 can work before this */
252
253static int io_base_ioremap(void)
254{
255 /* we're mapping PCI accesses from 0xc0000000 to 0xf0000000 */
256 unsigned long io_remap_range;
257
258 io_remap_range = (unsigned long) ioremap(0xc0000000, 0x30000000);
259 if (!io_remap_range)
260 panic("Could not ioremap I/O port range");
261
262 set_io_port_base(io_remap_range - 0xc0000000);
263
264 return 0;
265}
266
267module_init(io_base_ioremap);
diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile
index df487c063b1d..aba3dbf47eda 100644
--- a/arch/mips/pci/Makefile
+++ b/arch/mips/pci/Makefile
@@ -30,11 +30,9 @@ obj-$(CONFIG_SOC_AU1500) += fixup-au1000.o ops-au1000.o
30obj-$(CONFIG_SOC_AU1550) += fixup-au1000.o ops-au1000.o 30obj-$(CONFIG_SOC_AU1550) += fixup-au1000.o ops-au1000.o
31obj-$(CONFIG_SOC_PNX8550) += fixup-pnx8550.o ops-pnx8550.o 31obj-$(CONFIG_SOC_PNX8550) += fixup-pnx8550.o ops-pnx8550.o
32obj-$(CONFIG_MIPS_MALTA) += fixup-malta.o 32obj-$(CONFIG_MIPS_MALTA) += fixup-malta.o
33obj-$(CONFIG_MOMENCO_JAGUAR_ATX)+= fixup-jaguar.o
34obj-$(CONFIG_MOMENCO_OCELOT) += fixup-ocelot.o pci-ocelot.o 33obj-$(CONFIG_MOMENCO_OCELOT) += fixup-ocelot.o pci-ocelot.o
35obj-$(CONFIG_MOMENCO_OCELOT_3) += fixup-ocelot3.o 34obj-$(CONFIG_MOMENCO_OCELOT_3) += fixup-ocelot3.o
36obj-$(CONFIG_MOMENCO_OCELOT_C) += fixup-ocelot-c.o pci-ocelot-c.o 35obj-$(CONFIG_MOMENCO_OCELOT_C) += fixup-ocelot-c.o pci-ocelot-c.o
37obj-$(CONFIG_MOMENCO_OCELOT_G) += fixup-ocelot-g.o pci-ocelot-g.o
38obj-$(CONFIG_PMC_YOSEMITE) += fixup-yosemite.o ops-titan.o ops-titan-ht.o \ 36obj-$(CONFIG_PMC_YOSEMITE) += fixup-yosemite.o ops-titan.o ops-titan-ht.o \
39 pci-yosemite.o 37 pci-yosemite.o
40obj-$(CONFIG_SGI_IP27) += ops-bridge.o pci-ip27.o 38obj-$(CONFIG_SGI_IP27) += ops-bridge.o pci-ip27.o
diff --git a/arch/mips/pci/fixup-cobalt.c b/arch/mips/pci/fixup-cobalt.c
index 7d5f6bbf7a9d..d57ffd7242ca 100644
--- a/arch/mips/pci/fixup-cobalt.c
+++ b/arch/mips/pci/fixup-cobalt.c
@@ -17,9 +17,7 @@
17#include <asm/io.h> 17#include <asm/io.h>
18#include <asm/gt64120.h> 18#include <asm/gt64120.h>
19 19
20#include <asm/mach-cobalt/cobalt.h> 20#include <cobalt.h>
21
22extern int cobalt_board_id;
23 21
24static void qube_raq_galileo_early_fixup(struct pci_dev *dev) 22static void qube_raq_galileo_early_fixup(struct pci_dev *dev)
25{ 23{
@@ -115,6 +113,27 @@ static void qube_raq_galileo_fixup(struct pci_dev *dev)
115DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_GT64111, 113DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_GT64111,
116 qube_raq_galileo_fixup); 114 qube_raq_galileo_fixup);
117 115
116int cobalt_board_id;
117
118static void qube_raq_via_board_id_fixup(struct pci_dev *dev)
119{
120 u8 id;
121 int retval;
122
123 retval = pci_read_config_byte(dev, VIA_COBALT_BRD_ID_REG, &id);
124 if (retval) {
125 panic("Cannot read board ID");
126 return;
127 }
128
129 cobalt_board_id = VIA_COBALT_BRD_REG_to_ID(id);
130
131 printk(KERN_INFO "Cobalt board ID: %d\n", cobalt_board_id);
132}
133
134DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_0,
135 qube_raq_via_board_id_fixup);
136
118static char irq_tab_qube1[] __initdata = { 137static char irq_tab_qube1[] __initdata = {
119 [COBALT_PCICONF_CPU] = 0, 138 [COBALT_PCICONF_CPU] = 0,
120 [COBALT_PCICONF_ETH0] = COBALT_QUBE1_ETH0_IRQ, 139 [COBALT_PCICONF_ETH0] = COBALT_QUBE1_ETH0_IRQ,
diff --git a/arch/mips/pci/fixup-jaguar.c b/arch/mips/pci/fixup-jaguar.c
deleted file mode 100644
index 6c5e1d47179c..000000000000
--- a/arch/mips/pci/fixup-jaguar.c
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Marvell MV64340 interrupt fixup code.
7 *
8 * Marvell wants an NDA for their docs so this was written without
9 * documentation. You've been warned.
10 *
11 * Copyright (C) 2004 Ralf Baechle (ralf@linux-mips.org)
12 */
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/pci.h>
16
17#include <asm/mipsregs.h>
18
19/*
20 * WARNING: Example of how _NOT_ to do it.
21 */
22int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
23{
24 int bus = dev->bus->number;
25
26 if (bus == 0 && slot == 1)
27 return 3; /* PCI-X A */
28 if (bus == 0 && slot == 2)
29 return 4; /* PCI-X B */
30 if (bus == 1 && slot == 1)
31 return 5; /* PCI A */
32 if (bus == 1 && slot == 2)
33 return 6; /* PCI B */
34
35return 0;
36 panic("Whooops in pcibios_map_irq");
37}
38
39/* Do platform specific device initialization at pci_enable_device() time */
40int pcibios_plat_dev_init(struct pci_dev *dev)
41{
42 return 0;
43}
diff --git a/arch/mips/pci/fixup-ocelot-g.c b/arch/mips/pci/fixup-ocelot-g.c
deleted file mode 100644
index d7a652e326c5..000000000000
--- a/arch/mips/pci/fixup-ocelot-g.c
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation; either version 2 of the License, or (at your
5 * option) any later version.
6 *
7 * Copyright (C) 2004 Ralf Baechle (ralf@linux-mips.org)
8 */
9#include <linux/types.h>
10#include <linux/pci.h>
11#include <linux/kernel.h>
12#include <linux/init.h>
13
14int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
15{
16 int bus = dev->bus->number;
17
18 if (bus == 0 && slot == 1) /* Intel 82543 Gigabit MAC */
19 return 2; /* irq_nr is 2 for INT0 */
20
21 if (bus == 0 && slot == 2) /* Intel 82543 Gigabit MAC */
22 return 3; /* irq_nr is 3 for INT1 */
23
24 if (bus == 1 && slot == 3) /* Intel 21555 bridge */
25 return 5; /* irq_nr is 8 for INT6 */
26
27 if (bus == 1 && slot == 4) /* PMC Slot */
28 return 9; /* irq_nr is 9 for INT7 */
29
30 return -1;
31}
32
33/* Do platform specific device initialization at pci_enable_device() time */
34int pcibios_plat_dev_init(struct pci_dev *dev)
35{
36 return 0;
37}
diff --git a/arch/mips/pci/pci-ocelot-g.c b/arch/mips/pci/pci-ocelot-g.c
deleted file mode 100644
index 1e3430154fa0..000000000000
--- a/arch/mips/pci/pci-ocelot-g.c
+++ /dev/null
@@ -1,97 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
7 *
8 * This doesn't really fly - but I don't have a GT64240 system for testing.
9 */
10#include <linux/init.h>
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <linux/pci.h>
14#include <asm/gt64240.h>
15
16/*
17 * We assume these address ranges have been programmed into the GT-64240 by
18 * the firmware. PMON in case of the Ocelot G does that. Note the size of
19 * the I/O range is completly stupid; I/O mappings are limited to at most
20 * 256 bytes by the PCI spec and deprecated; and just to make things worse
21 * apparently many devices don't decode more than 64k of I/O space.
22 */
23
24#define gt_io_size 0x20000000UL
25#define gt_io_base 0xe0000000UL
26
27static struct resource gt_pci_mem0_resource = {
28 .name = "MV64240 PCI0 MEM",
29 .start = 0xc0000000UL,
30 .end = 0xcfffffffUL,
31 .flags = IORESOURCE_MEM
32};
33
34static struct resource gt_pci_io_mem0_resource = {
35 .name = "MV64240 PCI0 IO MEM",
36 .start = 0xe0000000UL,
37 .end = 0xefffffffUL,
38 .flags = IORESOURCE_IO
39};
40
41static struct mv_pci_controller gt_bus0_controller = {
42 .pcic = {
43 .pci_ops = &mv_pci_ops,
44 .mem_resource = &gt_pci_mem0_resource,
45 .mem_offset = 0xc0000000UL,
46 .io_resource = &gt_pci_io_mem0_resource,
47 .io_offset = 0x00000000UL
48 },
49 .config_addr = PCI_0CONFIGURATION_ADDRESS,
50 .config_vreg = PCI_0CONFIGURATION_DATA_VIRTUAL_REGISTER,
51};
52
53static struct resource gt_pci_mem1_resource = {
54 .name = "MV64240 PCI1 MEM",
55 .start = 0xd0000000UL,
56 .end = 0xdfffffffUL,
57 .flags = IORESOURCE_MEM
58};
59
60static struct resource gt_pci_io_mem1_resource = {
61 .name = "MV64240 PCI1 IO MEM",
62 .start = 0xf0000000UL,
63 .end = 0xffffffffUL,
64 .flags = IORESOURCE_IO
65};
66
67static struct mv_pci_controller gt_bus1_controller = {
68 .pcic = {
69 .pci_ops = &mv_pci_ops,
70 .mem_resource = &gt_pci_mem1_resource,
71 .mem_offset = 0xd0000000UL,
72 .io_resource = &gt_pci_io_mem1_resource,
73 .io_offset = 0x10000000UL
74 },
75 .config_addr = PCI_1CONFIGURATION_ADDRESS,
76 .config_vreg = PCI_1CONFIGURATION_DATA_VIRTUAL_REGISTER,
77};
78
79static __init int __init ocelot_g_pci_init(void)
80{
81 unsigned long io_v_base;
82
83 if (gt_io_size) {
84 io_v_base = (unsigned long) ioremap(gt_io_base, gt_io_size);
85 if (!io_v_base)
86 panic("Could not ioremap I/O port range");
87
88 set_io_port_base(io_v_base);
89 }
90
91 register_pci_controller(&gt_bus0_controller.pcic);
92 register_pci_controller(&gt_bus1_controller.pcic);
93
94 return 0;
95}
96
97arch_initcall(ocelot_g_pci_init);
diff --git a/arch/mips/sgi-ip22/Makefile b/arch/mips/sgi-ip22/Makefile
index b6d649241dc1..1fb3e353e212 100644
--- a/arch/mips/sgi-ip22/Makefile
+++ b/arch/mips/sgi-ip22/Makefile
@@ -4,6 +4,6 @@
4# 4#
5 5
6obj-y += ip22-mc.o ip22-hpc.o ip22-int.o ip22-berr.o \ 6obj-y += ip22-mc.o ip22-hpc.o ip22-int.o ip22-berr.o \
7 ip22-time.o ip22-nvram.o ip22-reset.o ip22-setup.o 7 ip22-time.o ip22-nvram.o ip22-platform.o ip22-reset.o ip22-setup.o
8 8
9obj-$(CONFIG_EISA) += ip22-eisa.o 9obj-$(CONFIG_EISA) += ip22-eisa.o
diff --git a/arch/mips/sgi-ip22/ip22-platform.c b/arch/mips/sgi-ip22/ip22-platform.c
new file mode 100644
index 000000000000..78b608d2d4e1
--- /dev/null
+++ b/arch/mips/sgi-ip22/ip22-platform.c
@@ -0,0 +1,177 @@
1#include <linux/init.h>
2#include <linux/if_ether.h>
3#include <linux/kernel.h>
4#include <linux/platform_device.h>
5
6#include <asm/paccess.h>
7#include <asm/sgi/ip22.h>
8#include <asm/sgi/hpc3.h>
9#include <asm/sgi/mc.h>
10#include <asm/sgi/seeq.h>
11#include <asm/sgi/wd.h>
12
13static struct resource sgiwd93_0_resources[] = {
14 {
15 .name = "eth0 irq",
16 .start = SGI_WD93_0_IRQ,
17 .end = SGI_WD93_0_IRQ,
18 .flags = IORESOURCE_IRQ
19 }
20};
21
22static struct sgiwd93_platform_data sgiwd93_0_pd = {
23 .unit = 0,
24 .irq = SGI_WD93_0_IRQ,
25};
26
27static struct platform_device sgiwd93_0_device = {
28 .name = "sgiwd93",
29 .id = 0,
30 .num_resources = ARRAY_SIZE(sgiwd93_0_resources),
31 .resource = sgiwd93_0_resources,
32 .dev = {
33 .platform_data = &sgiwd93_0_pd,
34 },
35};
36
37static struct resource sgiwd93_1_resources[] = {
38 {
39 .name = "eth0 irq",
40 .start = SGI_WD93_1_IRQ,
41 .end = SGI_WD93_1_IRQ,
42 .flags = IORESOURCE_IRQ
43 }
44};
45
46static struct sgiwd93_platform_data sgiwd93_1_pd = {
47 .unit = 1,
48 .irq = SGI_WD93_1_IRQ,
49};
50
51static struct platform_device sgiwd93_1_device = {
52 .name = "sgiwd93",
53 .id = 1,
54 .num_resources = ARRAY_SIZE(sgiwd93_1_resources),
55 .resource = sgiwd93_1_resources,
56 .dev = {
57 .platform_data = &sgiwd93_1_pd,
58 },
59};
60
61/*
62 * Create a platform device for the GPI port that receives the
63 * image data from the embedded camera.
64 */
65static int __init sgiwd93_devinit(void)
66{
67 int res;
68
69 sgiwd93_0_pd.hregs = &hpc3c0->scsi_chan0;
70 sgiwd93_0_pd.wdregs = (unsigned char *) hpc3c0->scsi0_ext;
71
72 res = platform_device_register(&sgiwd93_0_device);
73 if (res)
74 return res;
75
76 if (!ip22_is_fullhouse())
77 return 0;
78
79 sgiwd93_1_pd.hregs = &hpc3c0->scsi_chan1;
80 sgiwd93_1_pd.wdregs = (unsigned char *) hpc3c0->scsi1_ext;
81
82 return platform_device_register(&sgiwd93_1_device);
83}
84
85device_initcall(sgiwd93_devinit);
86
87static struct resource sgiseeq_0_resources[] = {
88 {
89 .name = "eth0 irq",
90 .start = SGI_ENET_IRQ,
91 .end = SGI_ENET_IRQ,
92 .flags = IORESOURCE_IRQ
93 }
94};
95
96static struct sgiseeq_platform_data eth0_pd;
97
98static struct platform_device eth0_device = {
99 .name = "sgiseeq",
100 .id = 0,
101 .num_resources = ARRAY_SIZE(sgiseeq_0_resources),
102 .resource = sgiseeq_0_resources,
103 .dev = {
104 .platform_data = &eth0_pd,
105 },
106};
107
108static struct resource sgiseeq_1_resources[] = {
109 {
110 .name = "eth1 irq",
111 .start = SGI_GIO_0_IRQ,
112 .end = SGI_GIO_0_IRQ,
113 .flags = IORESOURCE_IRQ
114 }
115};
116
117static struct sgiseeq_platform_data eth1_pd;
118
119static struct platform_device eth1_device = {
120 .name = "sgiseeq",
121 .id = 1,
122 .num_resources = ARRAY_SIZE(sgiseeq_1_resources),
123 .resource = sgiseeq_1_resources,
124 .dev = {
125 .platform_data = &eth1_pd,
126 },
127};
128
129/*
130 * Create a platform device for the GPI port that receives the
131 * image data from the embedded camera.
132 */
133static int __init sgiseeq_devinit(void)
134{
135 unsigned int tmp;
136 int res, i;
137
138 eth0_pd.hpc = hpc3c0;
139 eth0_pd.irq = SGI_ENET_IRQ;
140#define EADDR_NVOFS 250
141 for (i = 0; i < 3; i++) {
142 unsigned short tmp = ip22_nvram_read(EADDR_NVOFS / 2 + i);
143
144 eth0_pd.mac[2 * i] = tmp >> 8;
145 eth0_pd.mac[2 * i + 1] = tmp & 0xff;
146 }
147
148 res = platform_device_register(&eth0_device);
149 if (res)
150 return res;
151
152 /* Second HPC is missing? */
153 if (ip22_is_fullhouse() ||
154 !get_dbe(tmp, (unsigned int *)&hpc3c1->pbdma[1]))
155 return 0;
156
157 sgimc->giopar |= SGIMC_GIOPAR_MASTEREXP1 | SGIMC_GIOPAR_EXP164 |
158 SGIMC_GIOPAR_HPC264;
159 hpc3c1->pbus_piocfg[0][0] = 0x3ffff;
160 /* interrupt/config register on Challenge S Mezz board */
161 hpc3c1->pbus_extregs[0][0] = 0x30;
162
163 eth1_pd.hpc = hpc3c1;
164 eth1_pd.irq = SGI_GIO_0_IRQ;
165#define EADDR_NVOFS 250
166 for (i = 0; i < 3; i++) {
167 unsigned short tmp = ip22_eeprom_read(&hpc3c1->eeprom,
168 EADDR_NVOFS / 2 + i);
169
170 eth1_pd.mac[2 * i] = tmp >> 8;
171 eth1_pd.mac[2 * i + 1] = tmp & 0xff;
172 }
173
174 return platform_device_register(&eth1_device);
175}
176
177device_initcall(sgiseeq_devinit);
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index ccc5410af996..56d3c0dcd2b8 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -389,6 +389,9 @@ config NOT_COHERENT_CACHE
389 bool 389 bool
390 depends on 4xx || 8xx || E200 390 depends on 4xx || 8xx || E200
391 default y 391 default y
392
393config CONFIG_CHECK_CACHE_COHERENCY
394 bool
392endmenu 395endmenu
393 396
394source "init/Kconfig" 397source "init/Kconfig"
@@ -451,7 +454,7 @@ config ARCH_ENABLE_MEMORY_HOTPLUG
451 454
452config KEXEC 455config KEXEC
453 bool "kexec system call (EXPERIMENTAL)" 456 bool "kexec system call (EXPERIMENTAL)"
454 depends on PPC_MULTIPLATFORM && EXPERIMENTAL 457 depends on (PPC_PRPMC2800 || PPC_MULTIPLATFORM) && EXPERIMENTAL
455 help 458 help
456 kexec is a system call that implements the ability to shutdown your 459 kexec is a system call that implements the ability to shutdown your
457 current kernel, and to start another kernel. It is like a reboot 460 current kernel, and to start another kernel. It is like a reboot
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 81a531d84ff9..d6014a67694b 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -148,7 +148,7 @@ all: $(KBUILD_IMAGE)
148 148
149CPPFLAGS_vmlinux.lds := -Upowerpc 149CPPFLAGS_vmlinux.lds := -Upowerpc
150 150
151BOOT_TARGETS = zImage zImage.initrd uImage 151BOOT_TARGETS = zImage zImage.initrd zImage.dts zImage.dts_initrd uImage
152 152
153PHONY += $(BOOT_TARGETS) 153PHONY += $(BOOT_TARGETS)
154 154
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 5c384aad1184..d4f9fef7f9e9 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -43,9 +43,9 @@ $(addprefix $(obj)/,$(zlib) gunzip_util.o main.o): \
43src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \ 43src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
44 ns16550.c serial.c simple_alloc.c div64.S util.S \ 44 ns16550.c serial.c simple_alloc.c div64.S util.S \
45 gunzip_util.c elf_util.c $(zlib) devtree.c \ 45 gunzip_util.c elf_util.c $(zlib) devtree.c \
46 44x.c ebony.c 46 44x.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c
47src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \ 47src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \
48 cuboot-ebony.c treeboot-ebony.c 48 cuboot-ebony.c treeboot-ebony.c prpmc2800.c
49src-boot := $(src-wlib) $(src-plat) empty.c 49src-boot := $(src-wlib) $(src-plat) empty.c
50 50
51src-boot := $(addprefix $(obj)/, $(src-boot)) 51src-boot := $(addprefix $(obj)/, $(src-boot))
@@ -132,6 +132,7 @@ image-$(CONFIG_PPC_CHRP) += zImage.chrp
132image-$(CONFIG_PPC_EFIKA) += zImage.chrp 132image-$(CONFIG_PPC_EFIKA) += zImage.chrp
133image-$(CONFIG_PPC_PMAC) += zImage.pmac 133image-$(CONFIG_PPC_PMAC) += zImage.pmac
134image-$(CONFIG_PPC_HOLLY) += zImage.holly-elf 134image-$(CONFIG_PPC_HOLLY) += zImage.holly-elf
135image-$(CONFIG_PPC_PRPMC2800) += zImage.prpmc2800
135image-$(CONFIG_DEFAULT_UIMAGE) += uImage 136image-$(CONFIG_DEFAULT_UIMAGE) += uImage
136 137
137ifneq ($(CONFIG_DEVICE_TREE),"") 138ifneq ($(CONFIG_DEVICE_TREE),"")
@@ -154,9 +155,27 @@ targets += $(image-y) $(initrd-y)
154 155
155$(addprefix $(obj)/, $(initrd-y)): $(obj)/ramdisk.image.gz 156$(addprefix $(obj)/, $(initrd-y)): $(obj)/ramdisk.image.gz
156 157
158dts- := $(patsubst zImage%, zImage.dts%, $(image-n) $(image-))
159dts-y := $(patsubst zImage%, zImage.dts%, $(image-y))
160dts-y := $(filter-out $(image-y), $(dts-y))
161targets += $(image-y) $(dts-y)
162
163dts_initrd- := $(patsubst zImage%, zImage.dts_initrd%, $(image-n) $(image-))
164dts_initrd-y := $(patsubst zImage%, zImage.dts_initrd%, $(image-y))
165dts_initrd-y := $(filter-out $(image-y), $(dts_initrd-y))
166targets += $(image-y) $(dts_initrd-y)
167
168$(addprefix $(obj)/, $(dts_initrd-y)): $(obj)/ramdisk.image.gz
169
157# Don't put the ramdisk on the pattern rule; when its missing make will try 170# Don't put the ramdisk on the pattern rule; when its missing make will try
158# the pattern rule with less dependencies that also matches (even with the 171# the pattern rule with less dependencies that also matches (even with the
159# hard dependency listed). 172# hard dependency listed).
173$(obj)/zImage.dts_initrd.%: vmlinux $(wrapperbits) $(dts) $(obj)/ramdisk.image.gz
174 $(call if_changed,wrap,$*,$(dts),,$(obj)/ramdisk.image.gz)
175
176$(obj)/zImage.dts.%: vmlinux $(wrapperbits) $(dts)
177 $(call if_changed,wrap,$*,$(dts))
178
160$(obj)/zImage.initrd.%: vmlinux $(wrapperbits) 179$(obj)/zImage.initrd.%: vmlinux $(wrapperbits)
161 $(call if_changed,wrap,$*,,,$(obj)/ramdisk.image.gz) 180 $(call if_changed,wrap,$*,,,$(obj)/ramdisk.image.gz)
162 181
@@ -195,13 +214,18 @@ $(obj)/zImage: $(addprefix $(obj)/, $(image-y))
195 @rm -f $@; ln $< $@ 214 @rm -f $@; ln $< $@
196$(obj)/zImage.initrd: $(addprefix $(obj)/, $(initrd-y)) 215$(obj)/zImage.initrd: $(addprefix $(obj)/, $(initrd-y))
197 @rm -f $@; ln $< $@ 216 @rm -f $@; ln $< $@
217$(obj)/zImage.dts: $(addprefix $(obj)/, $(dts-y))
218 @rm -f $@; ln $< $@
219$(obj)/zImage.dts_initrd: $(addprefix $(obj)/, $(dts_initrd-y))
220 @rm -f $@; ln $< $@
221
198 222
199install: $(CONFIGURE) $(addprefix $(obj)/, $(image-y)) 223install: $(CONFIGURE) $(addprefix $(obj)/, $(image-y))
200 sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" $< 224 sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" $<
201 225
202# anything not in $(targets) 226# anything not in $(targets)
203clean-files += $(image-) $(initrd-) zImage zImage.initrd cuImage.* \ 227clean-files += $(image-) $(initrd-) zImage zImage.initrd cuImage.* \
204 treeImage.* 228 treeImage.* zImage.dts zImage.dts_initrd
205 229
206# clean up files cached by wrapper 230# clean up files cached by wrapper
207clean-kernel := vmlinux.strip vmlinux.bin 231clean-kernel := vmlinux.strip vmlinux.bin
diff --git a/arch/powerpc/boot/cuboot-83xx.c b/arch/powerpc/boot/cuboot-83xx.c
index 6cbc20afb4d8..9af554eea54b 100644
--- a/arch/powerpc/boot/cuboot-83xx.c
+++ b/arch/powerpc/boot/cuboot-83xx.c
@@ -57,7 +57,7 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
57 57
58 memcpy(&bd, (bd_t *)r3, sizeof(bd)); 58 memcpy(&bd, (bd_t *)r3, sizeof(bd));
59 loader_info.initrd_addr = r4; 59 loader_info.initrd_addr = r4;
60 loader_info.initrd_size = r4 ? r5 : 0; 60 loader_info.initrd_size = r4 ? r5 - r4 : 0;
61 loader_info.cmdline = (char *)r6; 61 loader_info.cmdline = (char *)r6;
62 loader_info.cmdline_len = r7 - r6; 62 loader_info.cmdline_len = r7 - r6;
63 63
diff --git a/arch/powerpc/boot/cuboot-85xx.c b/arch/powerpc/boot/cuboot-85xx.c
index f88ba00ac122..e2560317f278 100644
--- a/arch/powerpc/boot/cuboot-85xx.c
+++ b/arch/powerpc/boot/cuboot-85xx.c
@@ -58,7 +58,7 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
58 58
59 memcpy(&bd, (bd_t *)r3, sizeof(bd)); 59 memcpy(&bd, (bd_t *)r3, sizeof(bd));
60 loader_info.initrd_addr = r4; 60 loader_info.initrd_addr = r4;
61 loader_info.initrd_size = r4 ? r5 : 0; 61 loader_info.initrd_size = r4 ? r5 - r4 : 0;
62 loader_info.cmdline = (char *)r6; 62 loader_info.cmdline = (char *)r6;
63 loader_info.cmdline_len = r7 - r6; 63 loader_info.cmdline_len = r7 - r6;
64 64
diff --git a/arch/powerpc/boot/dts/prpmc2800.dts b/arch/powerpc/boot/dts/prpmc2800.dts
new file mode 100644
index 000000000000..568965a022b9
--- /dev/null
+++ b/arch/powerpc/boot/dts/prpmc2800.dts
@@ -0,0 +1,315 @@
1/* Device Tree Source for Motorola PrPMC2800
2 *
3 * Author: Mark A. Greer <mgreer@mvista.com>
4 *
5 * 2007 (c) MontaVista, Software, Inc. This file is licensed under
6 * the terms of the GNU General Public License version 2. This program
7 * is licensed "as is" without any warranty of any kind, whether express
8 * or implied.
9 *
10 * Property values that are labeled as "Default" will be updated by bootwrapper
11 * if it can determine the exact PrPMC type.
12 *
13 * To build:
14 * dtc -I dts -O asm -o prpmc2800.S -b 0 prpmc2800.dts
15 * dtc -I dts -O dtb -o prpmc2800.dtb -b 0 prpmc2800.dts
16 */
17
18/ {
19 #address-cells = <1>;
20 #size-cells = <1>;
21 model = "PrPMC280/PrPMC2800"; /* Default */
22 compatible = "motorola,PrPMC2800";
23 coherency-off;
24
25 cpus {
26 #address-cells = <1>;
27 #size-cells = <0>;
28
29 PowerPC,7447 {
30 device_type = "cpu";
31 reg = <0>;
32 clock-frequency = <2bb0b140>; /* Default (733 MHz) */
33 bus-frequency = <7f28155>; /* 133.333333 MHz */
34 timebase-frequency = <1fca055>; /* 33.333333 MHz */
35 i-cache-line-size = <20>;
36 d-cache-line-size = <20>;
37 i-cache-size = <8000>;
38 d-cache-size = <8000>;
39 };
40 };
41
42 memory {
43 device_type = "memory";
44 reg = <00000000 20000000>; /* Default (512MB) */
45 };
46
47 mv64x60@f1000000 { /* Marvell Discovery */
48 #address-cells = <1>;
49 #size-cells = <1>;
50 #interrupt-cells = <1>;
51 model = "mv64360"; /* Default */
52 compatible = "marvell,mv64x60";
53 clock-frequency = <7f28155>; /* 133.333333 MHz */
54 reg = <f1000000 00010000>;
55 virtual-reg = <f1000000>;
56 ranges = <88000000 88000000 01000000 /* PCI 0 I/O Space */
57 80000000 80000000 08000000 /* PCI 0 MEM Space */
58 a0000000 a0000000 04000000 /* User FLASH */
59 00000000 f1000000 00010000 /* Bridge's regs */
60 f2000000 f2000000 00040000>; /* Integrated SRAM */
61
62 flash@a0000000 {
63 device_type = "rom";
64 compatible = "direct-mapped";
65 reg = <a0000000 4000000>; /* Default (64MB) */
66 probe-type = "CFI";
67 bank-width = <4>;
68 partitions = <00000000 00100000 /* RO */
69 00100000 00040001 /* RW */
70 00140000 00400000 /* RO */
71 00540000 039c0000 /* RO */
72 03f00000 00100000>; /* RO */
73 partition-names = "FW Image A", "FW Config Data", "Kernel Image", "Filesystem", "FW Image B";
74 };
75
76 mdio {
77 #address-cells = <1>;
78 #size-cells = <0>;
79 device_type = "mdio";
80 compatible = "marvell,mv64x60-mdio";
81 ethernet-phy@1 {
82 device_type = "ethernet-phy";
83 compatible = "broadcom,bcm5421";
84 interrupts = <4c>; /* GPP 12 */
85 interrupt-parent = <&/mv64x60/pic>;
86 reg = <1>;
87 };
88 ethernet-phy@3 {
89 device_type = "ethernet-phy";
90 compatible = "broadcom,bcm5421";
91 interrupts = <4c>; /* GPP 12 */
92 interrupt-parent = <&/mv64x60/pic>;
93 reg = <3>;
94 };
95 };
96
97 ethernet@2000 {
98 reg = <2000 2000>;
99 eth0 {
100 device_type = "network";
101 compatible = "marvell,mv64x60-eth";
102 block-index = <0>;
103 interrupts = <20>;
104 interrupt-parent = <&/mv64x60/pic>;
105 phy = <&/mv64x60/mdio/ethernet-phy@1>;
106 local-mac-address = [ 00 00 00 00 00 00 ];
107 };
108 eth1 {
109 device_type = "network";
110 compatible = "marvell,mv64x60-eth";
111 block-index = <1>;
112 interrupts = <21>;
113 interrupt-parent = <&/mv64x60/pic>;
114 phy = <&/mv64x60/mdio/ethernet-phy@3>;
115 local-mac-address = [ 00 00 00 00 00 00 ];
116 };
117 };
118
119 sdma@4000 {
120 device_type = "dma";
121 compatible = "marvell,mv64x60-sdma";
122 reg = <4000 c18>;
123 virtual-reg = <f1004000>;
124 interrupt-base = <0>;
125 interrupts = <24>;
126 interrupt-parent = <&/mv64x60/pic>;
127 };
128
129 sdma@6000 {
130 device_type = "dma";
131 compatible = "marvell,mv64x60-sdma";
132 reg = <6000 c18>;
133 virtual-reg = <f1006000>;
134 interrupt-base = <0>;
135 interrupts = <26>;
136 interrupt-parent = <&/mv64x60/pic>;
137 };
138
139 brg@b200 {
140 compatible = "marvell,mv64x60-brg";
141 reg = <b200 8>;
142 clock-src = <8>;
143 clock-frequency = <7ed6b40>;
144 current-speed = <2580>;
145 bcr = <0>;
146 };
147
148 brg@b208 {
149 compatible = "marvell,mv64x60-brg";
150 reg = <b208 8>;
151 clock-src = <8>;
152 clock-frequency = <7ed6b40>;
153 current-speed = <2580>;
154 bcr = <0>;
155 };
156
157 cunit@f200 {
158 reg = <f200 200>;
159 };
160
161 mpscrouting@b400 {
162 reg = <b400 c>;
163 };
164
165 mpscintr@b800 {
166 reg = <b800 100>;
167 virtual-reg = <f100b800>;
168 };
169
170 mpsc@8000 {
171 device_type = "serial";
172 compatible = "marvell,mpsc";
173 reg = <8000 38>;
174 virtual-reg = <f1008000>;
175 sdma = <&/mv64x60/sdma@4000>;
176 brg = <&/mv64x60/brg@b200>;
177 cunit = <&/mv64x60/cunit@f200>;
178 mpscrouting = <&/mv64x60/mpscrouting@b400>;
179 mpscintr = <&/mv64x60/mpscintr@b800>;
180 block-index = <0>;
181 max_idle = <28>;
182 chr_1 = <0>;
183 chr_2 = <0>;
184 chr_10 = <3>;
185 mpcr = <0>;
186 interrupts = <28>;
187 interrupt-parent = <&/mv64x60/pic>;
188 };
189
190 mpsc@9000 {
191 device_type = "serial";
192 compatible = "marvell,mpsc";
193 reg = <9000 38>;
194 virtual-reg = <f1009000>;
195 sdma = <&/mv64x60/sdma@6000>;
196 brg = <&/mv64x60/brg@b208>;
197 cunit = <&/mv64x60/cunit@f200>;
198 mpscrouting = <&/mv64x60/mpscrouting@b400>;
199 mpscintr = <&/mv64x60/mpscintr@b800>;
200 block-index = <1>;
201 max_idle = <28>;
202 chr_1 = <0>;
203 chr_2 = <0>;
204 chr_10 = <3>;
205 mpcr = <0>;
206 interrupts = <2a>;
207 interrupt-parent = <&/mv64x60/pic>;
208 };
209
210 i2c@c000 {
211 device_type = "i2c";
212 compatible = "marvell,mv64x60-i2c";
213 reg = <c000 20>;
214 virtual-reg = <f100c000>;
215 freq_m = <8>;
216 freq_n = <3>;
217 timeout = <3e8>; /* 1000 = 1 second */
218 retries = <1>;
219 interrupts = <25>;
220 interrupt-parent = <&/mv64x60/pic>;
221 };
222
223 pic {
224 #interrupt-cells = <1>;
225 #address-cells = <0>;
226 compatible = "marvell,mv64x60-pic";
227 reg = <0000 88>;
228 interrupt-controller;
229 };
230
231 mpp@f000 {
232 compatible = "marvell,mv64x60-mpp";
233 reg = <f000 10>;
234 };
235
236 gpp@f100 {
237 compatible = "marvell,mv64x60-gpp";
238 reg = <f100 20>;
239 };
240
241 pci@80000000 {
242 #address-cells = <3>;
243 #size-cells = <2>;
244 #interrupt-cells = <1>;
245 device_type = "pci";
246 compatible = "marvell,mv64x60-pci";
247 reg = <0cf8 8>;
248 ranges = <01000000 0 0 88000000 0 01000000
249 02000000 0 80000000 80000000 0 08000000>;
250 bus-range = <0 ff>;
251 clock-frequency = <3EF1480>;
252 interrupt-pci-iack = <0c34>;
253 interrupt-parent = <&/mv64x60/pic>;
254 interrupt-map-mask = <f800 0 0 7>;
255 interrupt-map = <
256 /* IDSEL 0x0a */
257 5000 0 0 1 &/mv64x60/pic 50
258 5000 0 0 2 &/mv64x60/pic 51
259 5000 0 0 3 &/mv64x60/pic 5b
260 5000 0 0 4 &/mv64x60/pic 5d
261
262 /* IDSEL 0x0b */
263 5800 0 0 1 &/mv64x60/pic 5b
264 5800 0 0 2 &/mv64x60/pic 5d
265 5800 0 0 3 &/mv64x60/pic 50
266 5800 0 0 4 &/mv64x60/pic 51
267
268 /* IDSEL 0x0c */
269 6000 0 0 1 &/mv64x60/pic 5b
270 6000 0 0 2 &/mv64x60/pic 5d
271 6000 0 0 3 &/mv64x60/pic 50
272 6000 0 0 4 &/mv64x60/pic 51
273
274 /* IDSEL 0x0d */
275 6800 0 0 1 &/mv64x60/pic 5d
276 6800 0 0 2 &/mv64x60/pic 50
277 6800 0 0 3 &/mv64x60/pic 51
278 6800 0 0 4 &/mv64x60/pic 5b
279 >;
280 };
281
282 cpu-error@0070 {
283 compatible = "marvell,mv64x60-cpu-error";
284 reg = <0070 10 0128 28>;
285 interrupts = <03>;
286 interrupt-parent = <&/mv64x60/pic>;
287 };
288
289 sram-ctrl@0380 {
290 compatible = "marvell,mv64x60-sram-ctrl";
291 reg = <0380 80>;
292 interrupts = <0d>;
293 interrupt-parent = <&/mv64x60/pic>;
294 };
295
296 pci-error@1d40 {
297 compatible = "marvell,mv64x60-pci-error";
298 reg = <1d40 40 0c28 4>;
299 interrupts = <0c>;
300 interrupt-parent = <&/mv64x60/pic>;
301 };
302
303 mem-ctrl@1400 {
304 compatible = "marvell,mv64x60-mem-ctrl";
305 reg = <1400 60>;
306 interrupts = <11>;
307 interrupt-parent = <&/mv64x60/pic>;
308 };
309 };
310
311 chosen {
312 bootargs = "ip=on console=ttyMM0";
313 linux,stdout-path = "/mv64x60@f1000000/mpsc@8000";
314 };
315};
diff --git a/arch/powerpc/boot/mpsc.c b/arch/powerpc/boot/mpsc.c
new file mode 100644
index 000000000000..f1c0e965e5ce
--- /dev/null
+++ b/arch/powerpc/boot/mpsc.c
@@ -0,0 +1,170 @@
1/*
2 * MPSC/UART driver for the Marvell mv64360, mv64460, ...
3 *
4 * Author: Mark A. Greer <mgreer@mvista.com>
5 *
6 * 2007 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11
12#include <stdarg.h>
13#include <stddef.h>
14#include "types.h"
15#include "string.h"
16#include "stdio.h"
17#include "io.h"
18#include "ops.h"
19
20extern void udelay(long delay);
21
22#define MPSC_CHR_1 0x000c
23
24#define MPSC_CHR_2 0x0010
25#define MPSC_CHR_2_TA (1<<7)
26#define MPSC_CHR_2_TCS (1<<9)
27#define MPSC_CHR_2_RA (1<<23)
28#define MPSC_CHR_2_CRD (1<<25)
29#define MPSC_CHR_2_EH (1<<31)
30
31#define MPSC_CHR_4 0x0018
32#define MPSC_CHR_4_Z (1<<29)
33
34#define MPSC_CHR_5 0x001c
35#define MPSC_CHR_5_CTL1_INTR (1<<12)
36#define MPSC_CHR_5_CTL1_VALID (1<<15)
37
38#define MPSC_CHR_10 0x0030
39
40#define MPSC_INTR_CAUSE 0x0000
41#define MPSC_INTR_CAUSE_RCC (1<<6)
42#define MPSC_INTR_MASK 0x0080
43
44#define SDMA_SDCM 0x0008
45#define SDMA_SDCM_AR (1<<15)
46#define SDMA_SDCM_AT (1<<31)
47
48static volatile char *mpsc_base;
49static volatile char *mpscintr_base;
50static u32 chr1, chr2;
51
52static int mpsc_open(void)
53{
54 chr1 = in_le32((u32 *)(mpsc_base + MPSC_CHR_1)) & 0x00ff0000;
55 chr2 = in_le32((u32 *)(mpsc_base + MPSC_CHR_2)) & ~(MPSC_CHR_2_TA
56 | MPSC_CHR_2_TCS | MPSC_CHR_2_RA | MPSC_CHR_2_CRD
57 | MPSC_CHR_2_EH);
58 out_le32((u32 *)(mpsc_base + MPSC_CHR_4), MPSC_CHR_4_Z);
59 out_le32((u32 *)(mpsc_base + MPSC_CHR_5),
60 MPSC_CHR_5_CTL1_INTR | MPSC_CHR_5_CTL1_VALID);
61 out_le32((u32 *)(mpsc_base + MPSC_CHR_2), chr2 | MPSC_CHR_2_EH);
62 return 0;
63}
64
65static void mpsc_putc(unsigned char c)
66{
67 while (in_le32((u32 *)(mpsc_base + MPSC_CHR_2)) & MPSC_CHR_2_TCS);
68
69 out_le32((u32 *)(mpsc_base + MPSC_CHR_1), chr1 | c);
70 out_le32((u32 *)(mpsc_base + MPSC_CHR_2), chr2 | MPSC_CHR_2_TCS);
71}
72
73static unsigned char mpsc_getc(void)
74{
75 u32 cause = 0;
76 unsigned char c;
77
78 while (!(cause & MPSC_INTR_CAUSE_RCC))
79 cause = in_le32((u32 *)(mpscintr_base + MPSC_INTR_CAUSE));
80
81 c = in_8((u8 *)(mpsc_base + MPSC_CHR_10 + 2));
82 out_8((u8 *)(mpsc_base + MPSC_CHR_10 + 2), c);
83 out_le32((u32 *)(mpscintr_base + MPSC_INTR_CAUSE),
84 cause & ~MPSC_INTR_CAUSE_RCC);
85
86 return c;
87}
88
89static u8 mpsc_tstc(void)
90{
91 return (u8)((in_le32((u32 *)(mpscintr_base + MPSC_INTR_CAUSE))
92 & MPSC_INTR_CAUSE_RCC) != 0);
93}
94
95static void mpsc_stop_dma(volatile char *sdma_base)
96{
97 out_le32((u32 *)(mpsc_base + MPSC_CHR_2),MPSC_CHR_2_TA | MPSC_CHR_2_RA);
98 out_le32((u32 *)(sdma_base + SDMA_SDCM), SDMA_SDCM_AR | SDMA_SDCM_AT);
99
100 while ((in_le32((u32 *)(sdma_base + SDMA_SDCM))
101 & (SDMA_SDCM_AR | SDMA_SDCM_AT)) != 0)
102 udelay(100);
103}
104
105static volatile char *mpsc_get_virtreg_of_phandle(void *devp, char *prop)
106{
107 void *v;
108 int n;
109
110 n = getprop(devp, prop, &v, sizeof(v));
111 if (n != sizeof(v))
112 goto err_out;
113
114 devp = find_node_by_linuxphandle((u32)v);
115 if (devp == NULL)
116 goto err_out;
117
118 n = getprop(devp, "virtual-reg", &v, sizeof(v));
119 if (n == sizeof(v))
120 return v;
121
122err_out:
123 return NULL;
124}
125
126int mpsc_console_init(void *devp, struct serial_console_data *scdp)
127{
128 void *v;
129 int n, reg_set;
130 volatile char *sdma_base;
131
132 n = getprop(devp, "virtual-reg", &v, sizeof(v));
133 if (n != sizeof(v))
134 goto err_out;
135 mpsc_base = v;
136
137 sdma_base = mpsc_get_virtreg_of_phandle(devp, "sdma");
138 if (sdma_base == NULL)
139 goto err_out;
140
141 mpscintr_base = mpsc_get_virtreg_of_phandle(devp, "mpscintr");
142 if (mpscintr_base == NULL)
143 goto err_out;
144
145 n = getprop(devp, "block-index", &v, sizeof(v));
146 if (n != sizeof(v))
147 goto err_out;
148 reg_set = (int)v;
149
150 mpscintr_base += (reg_set == 0) ? 0x4 : 0xc;
151
152 /* Make sure the mpsc ctlrs are shutdown */
153 out_le32((u32 *)(mpscintr_base + MPSC_INTR_CAUSE), 0);
154 out_le32((u32 *)(mpscintr_base + MPSC_INTR_CAUSE), 0);
155 out_le32((u32 *)(mpscintr_base + MPSC_INTR_MASK), 0);
156 out_le32((u32 *)(mpscintr_base + MPSC_INTR_MASK), 0);
157
158 mpsc_stop_dma(sdma_base);
159
160 scdp->open = mpsc_open;
161 scdp->putc = mpsc_putc;
162 scdp->getc = mpsc_getc;
163 scdp->tstc = mpsc_tstc;
164 scdp->close = NULL;
165
166 return 0;
167
168err_out:
169 return -1;
170}
diff --git a/arch/powerpc/boot/mv64x60.c b/arch/powerpc/boot/mv64x60.c
new file mode 100644
index 000000000000..b43259455d4b
--- /dev/null
+++ b/arch/powerpc/boot/mv64x60.c
@@ -0,0 +1,581 @@
1/*
2 * Marvell hostbridge routines
3 *
4 * Author: Mark A. Greer <source@mvista.com>
5 *
6 * 2004, 2005, 2007 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11
12#include <stdarg.h>
13#include <stddef.h>
14#include "types.h"
15#include "elf.h"
16#include "page.h"
17#include "string.h"
18#include "stdio.h"
19#include "io.h"
20#include "ops.h"
21#include "mv64x60.h"
22
23#define PCI_DEVFN(slot,func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))
24
25#define MV64x60_CPU2MEM_WINDOWS 4
26#define MV64x60_CPU2MEM_0_BASE 0x0008
27#define MV64x60_CPU2MEM_0_SIZE 0x0010
28#define MV64x60_CPU2MEM_1_BASE 0x0208
29#define MV64x60_CPU2MEM_1_SIZE 0x0210
30#define MV64x60_CPU2MEM_2_BASE 0x0018
31#define MV64x60_CPU2MEM_2_SIZE 0x0020
32#define MV64x60_CPU2MEM_3_BASE 0x0218
33#define MV64x60_CPU2MEM_3_SIZE 0x0220
34
35#define MV64x60_ENET2MEM_BAR_ENABLE 0x2290
36#define MV64x60_ENET2MEM_0_BASE 0x2200
37#define MV64x60_ENET2MEM_0_SIZE 0x2204
38#define MV64x60_ENET2MEM_1_BASE 0x2208
39#define MV64x60_ENET2MEM_1_SIZE 0x220c
40#define MV64x60_ENET2MEM_2_BASE 0x2210
41#define MV64x60_ENET2MEM_2_SIZE 0x2214
42#define MV64x60_ENET2MEM_3_BASE 0x2218
43#define MV64x60_ENET2MEM_3_SIZE 0x221c
44#define MV64x60_ENET2MEM_4_BASE 0x2220
45#define MV64x60_ENET2MEM_4_SIZE 0x2224
46#define MV64x60_ENET2MEM_5_BASE 0x2228
47#define MV64x60_ENET2MEM_5_SIZE 0x222c
48#define MV64x60_ENET2MEM_ACC_PROT_0 0x2294
49#define MV64x60_ENET2MEM_ACC_PROT_1 0x2298
50#define MV64x60_ENET2MEM_ACC_PROT_2 0x229c
51
52#define MV64x60_MPSC2MEM_BAR_ENABLE 0xf250
53#define MV64x60_MPSC2MEM_0_BASE 0xf200
54#define MV64x60_MPSC2MEM_0_SIZE 0xf204
55#define MV64x60_MPSC2MEM_1_BASE 0xf208
56#define MV64x60_MPSC2MEM_1_SIZE 0xf20c
57#define MV64x60_MPSC2MEM_2_BASE 0xf210
58#define MV64x60_MPSC2MEM_2_SIZE 0xf214
59#define MV64x60_MPSC2MEM_3_BASE 0xf218
60#define MV64x60_MPSC2MEM_3_SIZE 0xf21c
61#define MV64x60_MPSC_0_REMAP 0xf240
62#define MV64x60_MPSC_1_REMAP 0xf244
63#define MV64x60_MPSC2MEM_ACC_PROT_0 0xf254
64#define MV64x60_MPSC2MEM_ACC_PROT_1 0xf258
65#define MV64x60_MPSC2REGS_BASE 0xf25c
66
67#define MV64x60_IDMA2MEM_BAR_ENABLE 0x0a80
68#define MV64x60_IDMA2MEM_0_BASE 0x0a00
69#define MV64x60_IDMA2MEM_0_SIZE 0x0a04
70#define MV64x60_IDMA2MEM_1_BASE 0x0a08
71#define MV64x60_IDMA2MEM_1_SIZE 0x0a0c
72#define MV64x60_IDMA2MEM_2_BASE 0x0a10
73#define MV64x60_IDMA2MEM_2_SIZE 0x0a14
74#define MV64x60_IDMA2MEM_3_BASE 0x0a18
75#define MV64x60_IDMA2MEM_3_SIZE 0x0a1c
76#define MV64x60_IDMA2MEM_4_BASE 0x0a20
77#define MV64x60_IDMA2MEM_4_SIZE 0x0a24
78#define MV64x60_IDMA2MEM_5_BASE 0x0a28
79#define MV64x60_IDMA2MEM_5_SIZE 0x0a2c
80#define MV64x60_IDMA2MEM_6_BASE 0x0a30
81#define MV64x60_IDMA2MEM_6_SIZE 0x0a34
82#define MV64x60_IDMA2MEM_7_BASE 0x0a38
83#define MV64x60_IDMA2MEM_7_SIZE 0x0a3c
84#define MV64x60_IDMA2MEM_ACC_PROT_0 0x0a70
85#define MV64x60_IDMA2MEM_ACC_PROT_1 0x0a74
86#define MV64x60_IDMA2MEM_ACC_PROT_2 0x0a78
87#define MV64x60_IDMA2MEM_ACC_PROT_3 0x0a7c
88
89#define MV64x60_PCI_ACC_CNTL_WINDOWS 6
90#define MV64x60_PCI0_PCI_DECODE_CNTL 0x0d3c
91#define MV64x60_PCI1_PCI_DECODE_CNTL 0x0dbc
92
93#define MV64x60_PCI0_BAR_ENABLE 0x0c3c
94#define MV64x60_PCI02MEM_0_SIZE 0x0c08
95#define MV64x60_PCI0_ACC_CNTL_0_BASE_LO 0x1e00
96#define MV64x60_PCI0_ACC_CNTL_0_BASE_HI 0x1e04
97#define MV64x60_PCI0_ACC_CNTL_0_SIZE 0x1e08
98#define MV64x60_PCI0_ACC_CNTL_1_BASE_LO 0x1e10
99#define MV64x60_PCI0_ACC_CNTL_1_BASE_HI 0x1e14
100#define MV64x60_PCI0_ACC_CNTL_1_SIZE 0x1e18
101#define MV64x60_PCI0_ACC_CNTL_2_BASE_LO 0x1e20
102#define MV64x60_PCI0_ACC_CNTL_2_BASE_HI 0x1e24
103#define MV64x60_PCI0_ACC_CNTL_2_SIZE 0x1e28
104#define MV64x60_PCI0_ACC_CNTL_3_BASE_LO 0x1e30
105#define MV64x60_PCI0_ACC_CNTL_3_BASE_HI 0x1e34
106#define MV64x60_PCI0_ACC_CNTL_3_SIZE 0x1e38
107#define MV64x60_PCI0_ACC_CNTL_4_BASE_LO 0x1e40
108#define MV64x60_PCI0_ACC_CNTL_4_BASE_HI 0x1e44
109#define MV64x60_PCI0_ACC_CNTL_4_SIZE 0x1e48
110#define MV64x60_PCI0_ACC_CNTL_5_BASE_LO 0x1e50
111#define MV64x60_PCI0_ACC_CNTL_5_BASE_HI 0x1e54
112#define MV64x60_PCI0_ACC_CNTL_5_SIZE 0x1e58
113
114#define MV64x60_PCI1_BAR_ENABLE 0x0cbc
115#define MV64x60_PCI12MEM_0_SIZE 0x0c88
116#define MV64x60_PCI1_ACC_CNTL_0_BASE_LO 0x1e80
117#define MV64x60_PCI1_ACC_CNTL_0_BASE_HI 0x1e84
118#define MV64x60_PCI1_ACC_CNTL_0_SIZE 0x1e88
119#define MV64x60_PCI1_ACC_CNTL_1_BASE_LO 0x1e90
120#define MV64x60_PCI1_ACC_CNTL_1_BASE_HI 0x1e94
121#define MV64x60_PCI1_ACC_CNTL_1_SIZE 0x1e98
122#define MV64x60_PCI1_ACC_CNTL_2_BASE_LO 0x1ea0
123#define MV64x60_PCI1_ACC_CNTL_2_BASE_HI 0x1ea4
124#define MV64x60_PCI1_ACC_CNTL_2_SIZE 0x1ea8
125#define MV64x60_PCI1_ACC_CNTL_3_BASE_LO 0x1eb0
126#define MV64x60_PCI1_ACC_CNTL_3_BASE_HI 0x1eb4
127#define MV64x60_PCI1_ACC_CNTL_3_SIZE 0x1eb8
128#define MV64x60_PCI1_ACC_CNTL_4_BASE_LO 0x1ec0
129#define MV64x60_PCI1_ACC_CNTL_4_BASE_HI 0x1ec4
130#define MV64x60_PCI1_ACC_CNTL_4_SIZE 0x1ec8
131#define MV64x60_PCI1_ACC_CNTL_5_BASE_LO 0x1ed0
132#define MV64x60_PCI1_ACC_CNTL_5_BASE_HI 0x1ed4
133#define MV64x60_PCI1_ACC_CNTL_5_SIZE 0x1ed8
134
135#define MV64x60_CPU2PCI_SWAP_NONE 0x01000000
136
137#define MV64x60_CPU2PCI0_IO_BASE 0x0048
138#define MV64x60_CPU2PCI0_IO_SIZE 0x0050
139#define MV64x60_CPU2PCI0_IO_REMAP 0x00f0
140#define MV64x60_CPU2PCI0_MEM_0_BASE 0x0058
141#define MV64x60_CPU2PCI0_MEM_0_SIZE 0x0060
142#define MV64x60_CPU2PCI0_MEM_0_REMAP_LO 0x00f8
143#define MV64x60_CPU2PCI0_MEM_0_REMAP_HI 0x0320
144
145#define MV64x60_CPU2PCI1_IO_BASE 0x0090
146#define MV64x60_CPU2PCI1_IO_SIZE 0x0098
147#define MV64x60_CPU2PCI1_IO_REMAP 0x0108
148#define MV64x60_CPU2PCI1_MEM_0_BASE 0x00a0
149#define MV64x60_CPU2PCI1_MEM_0_SIZE 0x00a8
150#define MV64x60_CPU2PCI1_MEM_0_REMAP_LO 0x0110
151#define MV64x60_CPU2PCI1_MEM_0_REMAP_HI 0x0340
152
153struct mv64x60_mem_win {
154 u32 hi;
155 u32 lo;
156 u32 size;
157};
158
159struct mv64x60_pci_win {
160 u32 fcn;
161 u32 hi;
162 u32 lo;
163 u32 size;
164};
165
166/* PCI config access routines */
167struct {
168 u32 addr;
169 u32 data;
170} static mv64x60_pci_cfgio[2] = {
171 { /* hose 0 */
172 .addr = 0xcf8,
173 .data = 0xcfc,
174 },
175 { /* hose 1 */
176 .addr = 0xc78,
177 .data = 0xc7c,
178 }
179};
180
181u32 mv64x60_cfg_read(u8 *bridge_base, u8 hose, u8 bus, u8 devfn, u8 offset)
182{
183 out_le32((u32 *)(bridge_base + mv64x60_pci_cfgio[hose].addr),
184 (1 << 31) | (bus << 16) | (devfn << 8) | offset);
185 return in_le32((u32 *)(bridge_base + mv64x60_pci_cfgio[hose].data));
186}
187
188void mv64x60_cfg_write(u8 *bridge_base, u8 hose, u8 bus, u8 devfn, u8 offset,
189 u32 val)
190{
191 out_le32((u32 *)(bridge_base + mv64x60_pci_cfgio[hose].addr),
192 (1 << 31) | (bus << 16) | (devfn << 8) | offset);
193 out_le32((u32 *)(bridge_base + mv64x60_pci_cfgio[hose].data), val);
194}
195
196/* I/O ctlr -> system memory setup */
197static struct mv64x60_mem_win mv64x60_cpu2mem[MV64x60_CPU2MEM_WINDOWS] = {
198 {
199 .lo = MV64x60_CPU2MEM_0_BASE,
200 .size = MV64x60_CPU2MEM_0_SIZE,
201 },
202 {
203 .lo = MV64x60_CPU2MEM_1_BASE,
204 .size = MV64x60_CPU2MEM_1_SIZE,
205 },
206 {
207 .lo = MV64x60_CPU2MEM_2_BASE,
208 .size = MV64x60_CPU2MEM_2_SIZE,
209 },
210 {
211 .lo = MV64x60_CPU2MEM_3_BASE,
212 .size = MV64x60_CPU2MEM_3_SIZE,
213 },
214};
215
216static struct mv64x60_mem_win mv64x60_enet2mem[MV64x60_CPU2MEM_WINDOWS] = {
217 {
218 .lo = MV64x60_ENET2MEM_0_BASE,
219 .size = MV64x60_ENET2MEM_0_SIZE,
220 },
221 {
222 .lo = MV64x60_ENET2MEM_1_BASE,
223 .size = MV64x60_ENET2MEM_1_SIZE,
224 },
225 {
226 .lo = MV64x60_ENET2MEM_2_BASE,
227 .size = MV64x60_ENET2MEM_2_SIZE,
228 },
229 {
230 .lo = MV64x60_ENET2MEM_3_BASE,
231 .size = MV64x60_ENET2MEM_3_SIZE,
232 },
233};
234
235static struct mv64x60_mem_win mv64x60_mpsc2mem[MV64x60_CPU2MEM_WINDOWS] = {
236 {
237 .lo = MV64x60_MPSC2MEM_0_BASE,
238 .size = MV64x60_MPSC2MEM_0_SIZE,
239 },
240 {
241 .lo = MV64x60_MPSC2MEM_1_BASE,
242 .size = MV64x60_MPSC2MEM_1_SIZE,
243 },
244 {
245 .lo = MV64x60_MPSC2MEM_2_BASE,
246 .size = MV64x60_MPSC2MEM_2_SIZE,
247 },
248 {
249 .lo = MV64x60_MPSC2MEM_3_BASE,
250 .size = MV64x60_MPSC2MEM_3_SIZE,
251 },
252};
253
254static struct mv64x60_mem_win mv64x60_idma2mem[MV64x60_CPU2MEM_WINDOWS] = {
255 {
256 .lo = MV64x60_IDMA2MEM_0_BASE,
257 .size = MV64x60_IDMA2MEM_0_SIZE,
258 },
259 {
260 .lo = MV64x60_IDMA2MEM_1_BASE,
261 .size = MV64x60_IDMA2MEM_1_SIZE,
262 },
263 {
264 .lo = MV64x60_IDMA2MEM_2_BASE,
265 .size = MV64x60_IDMA2MEM_2_SIZE,
266 },
267 {
268 .lo = MV64x60_IDMA2MEM_3_BASE,
269 .size = MV64x60_IDMA2MEM_3_SIZE,
270 },
271};
272
273static u32 mv64x60_dram_selects[MV64x60_CPU2MEM_WINDOWS] = {0xe,0xd,0xb,0x7};
274
275/*
276 * ENET, MPSC, and IDMA ctlrs on the MV64x60 have separate windows that
277 * must be set up so that the respective ctlr can access system memory.
278 * Configure them to be same as cpu->memory windows.
279 */
280void mv64x60_config_ctlr_windows(u8 *bridge_base, u8 *bridge_pbase,
281 u8 is_coherent)
282{
283 u32 i, base, size, enables, prot = 0, snoop_bits = 0;
284
285 /* Disable ctlr->mem windows */
286 out_le32((u32 *)(bridge_base + MV64x60_ENET2MEM_BAR_ENABLE), 0x3f);
287 out_le32((u32 *)(bridge_base + MV64x60_MPSC2MEM_BAR_ENABLE), 0xf);
288 out_le32((u32 *)(bridge_base + MV64x60_ENET2MEM_BAR_ENABLE), 0xff);
289
290 if (is_coherent)
291 snoop_bits = 0x2 << 12; /* Writeback */
292
293 enables = in_le32((u32 *)(bridge_base + MV64x60_CPU_BAR_ENABLE)) & 0xf;
294
295 for (i=0; i<MV64x60_CPU2MEM_WINDOWS; i++) {
296 if (enables & (1 << i)) /* Set means disabled */
297 continue;
298
299 base = in_le32((u32 *)(bridge_base + mv64x60_cpu2mem[i].lo))
300 << 16;
301 base |= snoop_bits | (mv64x60_dram_selects[i] << 8);
302 size = in_le32((u32 *)(bridge_base + mv64x60_cpu2mem[i].size))
303 << 16;
304 prot |= (0x3 << (i << 1)); /* RW access */
305
306 out_le32((u32 *)(bridge_base + mv64x60_enet2mem[i].lo), base);
307 out_le32((u32 *)(bridge_base + mv64x60_enet2mem[i].size), size);
308 out_le32((u32 *)(bridge_base + mv64x60_mpsc2mem[i].lo), base);
309 out_le32((u32 *)(bridge_base + mv64x60_mpsc2mem[i].size), size);
310 out_le32((u32 *)(bridge_base + mv64x60_idma2mem[i].lo), base);
311 out_le32((u32 *)(bridge_base + mv64x60_idma2mem[i].size), size);
312 }
313
314 out_le32((u32 *)(bridge_base + MV64x60_ENET2MEM_ACC_PROT_0), prot);
315 out_le32((u32 *)(bridge_base + MV64x60_ENET2MEM_ACC_PROT_1), prot);
316 out_le32((u32 *)(bridge_base + MV64x60_ENET2MEM_ACC_PROT_2), prot);
317 out_le32((u32 *)(bridge_base + MV64x60_MPSC2MEM_ACC_PROT_0), prot);
318 out_le32((u32 *)(bridge_base + MV64x60_MPSC2MEM_ACC_PROT_1), prot);
319 out_le32((u32 *)(bridge_base + MV64x60_IDMA2MEM_ACC_PROT_0), prot);
320 out_le32((u32 *)(bridge_base + MV64x60_IDMA2MEM_ACC_PROT_1), prot);
321 out_le32((u32 *)(bridge_base + MV64x60_IDMA2MEM_ACC_PROT_2), prot);
322 out_le32((u32 *)(bridge_base + MV64x60_IDMA2MEM_ACC_PROT_3), prot);
323
324 /* Set mpsc->bridge's reg window to the bridge's internal registers. */
325 out_le32((u32 *)(bridge_base + MV64x60_MPSC2REGS_BASE),
326 (u32)bridge_pbase);
327
328 out_le32((u32 *)(bridge_base + MV64x60_ENET2MEM_BAR_ENABLE), enables);
329 out_le32((u32 *)(bridge_base + MV64x60_MPSC2MEM_BAR_ENABLE), enables);
330 out_le32((u32 *)(bridge_base + MV64x60_IDMA2MEM_BAR_ENABLE), enables);
331}
332
333/* PCI MEM -> system memory, et. al. setup */
334static struct mv64x60_pci_win mv64x60_pci2mem[2] = {
335 { /* hose 0 */
336 .fcn = 0,
337 .hi = 0x14,
338 .lo = 0x10,
339 .size = MV64x60_PCI02MEM_0_SIZE,
340 },
341 { /* hose 1 */
342 .fcn = 0,
343 .hi = 0x94,
344 .lo = 0x90,
345 .size = MV64x60_PCI12MEM_0_SIZE,
346 },
347};
348
349static struct
350mv64x60_mem_win mv64x60_pci_acc[2][MV64x60_PCI_ACC_CNTL_WINDOWS] = {
351 { /* hose 0 */
352 {
353 .hi = MV64x60_PCI0_ACC_CNTL_0_BASE_HI,
354 .lo = MV64x60_PCI0_ACC_CNTL_0_BASE_LO,
355 .size = MV64x60_PCI0_ACC_CNTL_0_SIZE,
356 },
357 {
358 .hi = MV64x60_PCI0_ACC_CNTL_1_BASE_HI,
359 .lo = MV64x60_PCI0_ACC_CNTL_1_BASE_LO,
360 .size = MV64x60_PCI0_ACC_CNTL_1_SIZE,
361 },
362 {
363 .hi = MV64x60_PCI0_ACC_CNTL_2_BASE_HI,
364 .lo = MV64x60_PCI0_ACC_CNTL_2_BASE_LO,
365 .size = MV64x60_PCI0_ACC_CNTL_2_SIZE,
366 },
367 {
368 .hi = MV64x60_PCI0_ACC_CNTL_3_BASE_HI,
369 .lo = MV64x60_PCI0_ACC_CNTL_3_BASE_LO,
370 .size = MV64x60_PCI0_ACC_CNTL_3_SIZE,
371 },
372 },
373 { /* hose 1 */
374 {
375 .hi = MV64x60_PCI1_ACC_CNTL_0_BASE_HI,
376 .lo = MV64x60_PCI1_ACC_CNTL_0_BASE_LO,
377 .size = MV64x60_PCI1_ACC_CNTL_0_SIZE,
378 },
379 {
380 .hi = MV64x60_PCI1_ACC_CNTL_1_BASE_HI,
381 .lo = MV64x60_PCI1_ACC_CNTL_1_BASE_LO,
382 .size = MV64x60_PCI1_ACC_CNTL_1_SIZE,
383 },
384 {
385 .hi = MV64x60_PCI1_ACC_CNTL_2_BASE_HI,
386 .lo = MV64x60_PCI1_ACC_CNTL_2_BASE_LO,
387 .size = MV64x60_PCI1_ACC_CNTL_2_SIZE,
388 },
389 {
390 .hi = MV64x60_PCI1_ACC_CNTL_3_BASE_HI,
391 .lo = MV64x60_PCI1_ACC_CNTL_3_BASE_LO,
392 .size = MV64x60_PCI1_ACC_CNTL_3_SIZE,
393 },
394 },
395};
396
397static struct mv64x60_mem_win mv64x60_pci2reg[2] = {
398 {
399 .hi = 0x24,
400 .lo = 0x20,
401 .size = 0,
402 },
403 {
404 .hi = 0xa4,
405 .lo = 0xa0,
406 .size = 0,
407 },
408};
409
410/* Only need to use 1 window (per hose) to get access to all of system memory */
411void mv64x60_config_pci_windows(u8 *bridge_base, u8 *bridge_pbase, u8 hose,
412 u8 bus, u32 mem_size, u32 acc_bits)
413{
414 u32 i, offset, bar_enable, enables;
415
416 /* Disable all windows but PCI MEM -> Bridge's regs window */
417 enables = ~(1 << 9);
418 bar_enable = hose ? MV64x60_PCI1_BAR_ENABLE : MV64x60_PCI0_BAR_ENABLE;
419 out_le32((u32 *)(bridge_base + bar_enable), enables);
420
421 for (i=0; i<MV64x60_PCI_ACC_CNTL_WINDOWS; i++)
422 out_le32((u32 *)(bridge_base + mv64x60_pci_acc[hose][i].lo), 0);
423
424 /* If mem_size is 0, leave windows disabled */
425 if (mem_size == 0)
426 return;
427
428 /* Cause automatic updates of PCI remap regs */
429 offset = hose ?
430 MV64x60_PCI1_PCI_DECODE_CNTL : MV64x60_PCI0_PCI_DECODE_CNTL;
431 i = in_le32((u32 *)(bridge_base + offset));
432 out_le32((u32 *)(bridge_base + offset), i & ~0x1);
433
434 mem_size = (mem_size - 1) & 0xfffff000;
435
436 /* Map PCI MEM addr 0 -> System Mem addr 0 */
437 mv64x60_cfg_write(bridge_base, hose, bus,
438 PCI_DEVFN(0, mv64x60_pci2mem[hose].fcn),
439 mv64x60_pci2mem[hose].hi, 0);
440 mv64x60_cfg_write(bridge_base, hose, bus,
441 PCI_DEVFN(0, mv64x60_pci2mem[hose].fcn),
442 mv64x60_pci2mem[hose].lo, 0);
443 out_le32((u32 *)(bridge_base + mv64x60_pci2mem[hose].size),mem_size);
444
445 acc_bits |= MV64x60_PCI_ACC_CNTL_ENABLE;
446 out_le32((u32 *)(bridge_base + mv64x60_pci_acc[hose][0].hi), 0);
447 out_le32((u32 *)(bridge_base + mv64x60_pci_acc[hose][0].lo), acc_bits);
448 out_le32((u32 *)(bridge_base + mv64x60_pci_acc[hose][0].size),mem_size);
449
450 /* Set PCI MEM->bridge's reg window to where they are in CPU mem map */
451 i = (u32)bridge_base;
452 i &= 0xffff0000;
453 i |= (0x2 << 1);
454 mv64x60_cfg_write(bridge_base, hose, bus, PCI_DEVFN(0,0),
455 mv64x60_pci2reg[hose].hi, 0);
456 mv64x60_cfg_write(bridge_base, hose, bus, PCI_DEVFN(0,0),
457 mv64x60_pci2reg[hose].lo, i);
458
459 enables &= ~0x1; /* Enable PCI MEM -> System Mem window 0 */
460 out_le32((u32 *)(bridge_base + bar_enable), enables);
461}
462
463/* CPU -> PCI I/O & MEM setup */
464struct mv64x60_cpu2pci_win mv64x60_cpu2pci_io[2] = {
465 { /* hose 0 */
466 .lo = MV64x60_CPU2PCI0_IO_BASE,
467 .size = MV64x60_CPU2PCI0_IO_SIZE,
468 .remap_hi = 0,
469 .remap_lo = MV64x60_CPU2PCI0_IO_REMAP,
470 },
471 { /* hose 1 */
472 .lo = MV64x60_CPU2PCI1_IO_BASE,
473 .size = MV64x60_CPU2PCI1_IO_SIZE,
474 .remap_hi = 0,
475 .remap_lo = MV64x60_CPU2PCI1_IO_REMAP,
476 },
477};
478
479struct mv64x60_cpu2pci_win mv64x60_cpu2pci_mem[2] = {
480 { /* hose 0 */
481 .lo = MV64x60_CPU2PCI0_MEM_0_BASE,
482 .size = MV64x60_CPU2PCI0_MEM_0_SIZE,
483 .remap_hi = MV64x60_CPU2PCI0_MEM_0_REMAP_HI,
484 .remap_lo = MV64x60_CPU2PCI0_MEM_0_REMAP_LO,
485 },
486 { /* hose 1 */
487 .lo = MV64x60_CPU2PCI1_MEM_0_BASE,
488 .size = MV64x60_CPU2PCI1_MEM_0_SIZE,
489 .remap_hi = MV64x60_CPU2PCI1_MEM_0_REMAP_HI,
490 .remap_lo = MV64x60_CPU2PCI1_MEM_0_REMAP_LO,
491 },
492};
493
494/* Only need to set up 1 window to pci mem space */
495void mv64x60_config_cpu2pci_window(u8 *bridge_base, u8 hose, u32 pci_base_hi,
496 u32 pci_base_lo, u32 cpu_base, u32 size,
497 struct mv64x60_cpu2pci_win *offset_tbl)
498{
499 cpu_base >>= 16;
500 cpu_base |= MV64x60_CPU2PCI_SWAP_NONE;
501 out_le32((u32 *)(bridge_base + offset_tbl[hose].lo), cpu_base);
502
503 if (offset_tbl[hose].remap_hi != 0)
504 out_le32((u32 *)(bridge_base + offset_tbl[hose].remap_hi),
505 pci_base_hi);
506 out_le32((u32 *)(bridge_base + offset_tbl[hose].remap_lo),
507 pci_base_lo >> 16);
508
509 size = (size - 1) >> 16;
510 out_le32((u32 *)(bridge_base + offset_tbl[hose].size), size);
511}
512
513/* Read mem ctlr to get the amount of mem in system */
514u32 mv64x60_get_mem_size(u8 *bridge_base)
515{
516 u32 enables, i, v;
517 u32 mem = 0;
518
519 enables = in_le32((u32 *)(bridge_base + MV64x60_CPU_BAR_ENABLE)) & 0xf;
520
521 for (i=0; i<MV64x60_CPU2MEM_WINDOWS; i++)
522 if (!(enables & (1<<i))) {
523 v = in_le32((u32*)(bridge_base
524 + mv64x60_cpu2mem[i].size));
525 v = ((v & 0xffff) + 1) << 16;
526 mem += v;
527 }
528
529 return mem;
530}
531
532/* Get physical address of bridge's registers */
533u8 *mv64x60_get_bridge_pbase(void)
534{
535 u32 v[2];
536 void *devp;
537
538 devp = finddevice("/mv64x60");
539 if (devp == NULL)
540 goto err_out;
541 if (getprop(devp, "reg", v, sizeof(v)) != sizeof(v))
542 goto err_out;
543
544 return (u8 *)v[0];
545
546err_out:
547 return 0;
548}
549
550/* Get virtual address of bridge's registers */
551u8 *mv64x60_get_bridge_base(void)
552{
553 u32 v;
554 void *devp;
555
556 devp = finddevice("/mv64x60");
557 if (devp == NULL)
558 goto err_out;
559 if (getprop(devp, "virtual-reg", &v, sizeof(v)) != sizeof(v))
560 goto err_out;
561
562 return (u8 *)v;
563
564err_out:
565 return 0;
566}
567
568u8 mv64x60_is_coherent(void)
569{
570 u32 v;
571 void *devp;
572
573 devp = finddevice("/");
574 if (devp == NULL)
575 return 1; /* Assume coherency on */
576
577 if (getprop(devp, "coherency-off", &v, sizeof(v)) < 0)
578 return 1; /* Coherency on */
579 else
580 return 0;
581}
diff --git a/arch/powerpc/boot/mv64x60.h b/arch/powerpc/boot/mv64x60.h
new file mode 100644
index 000000000000..b827105e6e54
--- /dev/null
+++ b/arch/powerpc/boot/mv64x60.h
@@ -0,0 +1,70 @@
1/*
2 * Author: Mark A. Greer <source@mvista.com>
3 *
4 * 2007 (c) MontaVista Software, Inc. This file is licensed under
5 * the terms of the GNU General Public License version 2. This program
6 * is licensed "as is" without any warranty of any kind, whether express
7 * or implied.
8 */
9
10#ifndef _PPC_BOOT_MV64x60_H_
11#define _PPC_BOOT_MV64x60_H_
12
13#define MV64x60_CPU_BAR_ENABLE 0x0278
14
15#define MV64x60_PCI_ACC_CNTL_ENABLE (1<<0)
16#define MV64x60_PCI_ACC_CNTL_REQ64 (1<<1)
17#define MV64x60_PCI_ACC_CNTL_SNOOP_NONE 0x00000000
18#define MV64x60_PCI_ACC_CNTL_SNOOP_WT 0x00000004
19#define MV64x60_PCI_ACC_CNTL_SNOOP_WB 0x00000008
20#define MV64x60_PCI_ACC_CNTL_SNOOP_MASK 0x0000000c
21#define MV64x60_PCI_ACC_CNTL_ACCPROT (1<<4)
22#define MV64x60_PCI_ACC_CNTL_WRPROT (1<<5)
23#define MV64x60_PCI_ACC_CNTL_SWAP_BYTE 0x00000000
24#define MV64x60_PCI_ACC_CNTL_SWAP_NONE 0x00000040
25#define MV64x60_PCI_ACC_CNTL_SWAP_BYTE_WORD 0x00000080
26#define MV64x60_PCI_ACC_CNTL_SWAP_WORD 0x000000c0
27#define MV64x60_PCI_ACC_CNTL_SWAP_MASK 0x000000c0
28#define MV64x60_PCI_ACC_CNTL_MBURST_32_BYTES 0x00000000
29#define MV64x60_PCI_ACC_CNTL_MBURST_64_BYTES 0x00000100
30#define MV64x60_PCI_ACC_CNTL_MBURST_128_BYTES 0x00000200
31#define MV64x60_PCI_ACC_CNTL_MBURST_MASK 0x00000300
32#define MV64x60_PCI_ACC_CNTL_RDSIZE_32_BYTES 0x00000000
33#define MV64x60_PCI_ACC_CNTL_RDSIZE_64_BYTES 0x00000400
34#define MV64x60_PCI_ACC_CNTL_RDSIZE_128_BYTES 0x00000800
35#define MV64x60_PCI_ACC_CNTL_RDSIZE_256_BYTES 0x00000c00
36#define MV64x60_PCI_ACC_CNTL_RDSIZE_MASK 0x00000c00
37
38struct mv64x60_cpu2pci_win {
39 u32 lo;
40 u32 size;
41 u32 remap_hi;
42 u32 remap_lo;
43};
44
45extern struct mv64x60_cpu2pci_win mv64x60_cpu2pci_io[2];
46extern struct mv64x60_cpu2pci_win mv64x60_cpu2pci_mem[2];
47
48u32 mv64x60_cfg_read(u8 *bridge_base, u8 hose, u8 bus, u8 devfn,
49 u8 offset);
50void mv64x60_cfg_write(u8 *bridge_base, u8 hose, u8 bus, u8 devfn,
51 u8 offset, u32 val);
52
53void mv64x60_config_ctlr_windows(u8 *bridge_base, u8 *bridge_pbase,
54 u8 is_coherent);
55void mv64x60_config_pci_windows(u8 *bridge_base, u8 *bridge_pbase, u8 hose,
56 u8 bus, u32 mem_size, u32 acc_bits);
57void mv64x60_config_cpu2pci_window(u8 *bridge_base, u8 hose, u32 pci_base_hi,
58 u32 pci_base_lo, u32 cpu_base, u32 size,
59 struct mv64x60_cpu2pci_win *offset_tbl);
60u32 mv64x60_get_mem_size(u8 *bridge_base);
61u8 *mv64x60_get_bridge_pbase(void);
62u8 *mv64x60_get_bridge_base(void);
63u8 mv64x60_is_coherent(void);
64
65int mv64x60_i2c_open(void);
66int mv64x60_i2c_read(u32 devaddr, u8 *buf, u32 offset, u32 offset_size,
67 u32 count);
68void mv64x60_i2c_close(void);
69
70#endif /* _PPC_BOOT_MV64x60_H_ */
diff --git a/arch/powerpc/boot/mv64x60_i2c.c b/arch/powerpc/boot/mv64x60_i2c.c
new file mode 100644
index 000000000000..435fe8528680
--- /dev/null
+++ b/arch/powerpc/boot/mv64x60_i2c.c
@@ -0,0 +1,206 @@
1/*
2 * Bootloader version of the i2c driver for the MV64x60.
3 *
4 * Author: Dale Farnsworth <dfarnsworth@mvista.com>
5 * Maintained by: Mark A. Greer <mgreer@mvista.com>
6 *
7 * 2003, 2007 (c) MontaVista, Software, Inc. This file is licensed under
8 * the terms of the GNU General Public License version 2. This program is
9 * licensed "as is" without any warranty of any kind, whether express or
10 * implied.
11 */
12
13#include <stdarg.h>
14#include <stddef.h>
15#include "types.h"
16#include "elf.h"
17#include "page.h"
18#include "string.h"
19#include "stdio.h"
20#include "io.h"
21#include "ops.h"
22#include "mv64x60.h"
23
24extern void udelay(long);
25
26/* Register defines */
27#define MV64x60_I2C_REG_SLAVE_ADDR 0x00
28#define MV64x60_I2C_REG_DATA 0x04
29#define MV64x60_I2C_REG_CONTROL 0x08
30#define MV64x60_I2C_REG_STATUS 0x0c
31#define MV64x60_I2C_REG_BAUD 0x0c
32#define MV64x60_I2C_REG_EXT_SLAVE_ADDR 0x10
33#define MV64x60_I2C_REG_SOFT_RESET 0x1c
34
35#define MV64x60_I2C_CONTROL_ACK 0x04
36#define MV64x60_I2C_CONTROL_IFLG 0x08
37#define MV64x60_I2C_CONTROL_STOP 0x10
38#define MV64x60_I2C_CONTROL_START 0x20
39#define MV64x60_I2C_CONTROL_TWSIEN 0x40
40#define MV64x60_I2C_CONTROL_INTEN 0x80
41
42#define MV64x60_I2C_STATUS_BUS_ERR 0x00
43#define MV64x60_I2C_STATUS_MAST_START 0x08
44#define MV64x60_I2C_STATUS_MAST_REPEAT_START 0x10
45#define MV64x60_I2C_STATUS_MAST_WR_ADDR_ACK 0x18
46#define MV64x60_I2C_STATUS_MAST_WR_ADDR_NO_ACK 0x20
47#define MV64x60_I2C_STATUS_MAST_WR_ACK 0x28
48#define MV64x60_I2C_STATUS_MAST_WR_NO_ACK 0x30
49#define MV64x60_I2C_STATUS_MAST_LOST_ARB 0x38
50#define MV64x60_I2C_STATUS_MAST_RD_ADDR_ACK 0x40
51#define MV64x60_I2C_STATUS_MAST_RD_ADDR_NO_ACK 0x48
52#define MV64x60_I2C_STATUS_MAST_RD_DATA_ACK 0x50
53#define MV64x60_I2C_STATUS_MAST_RD_DATA_NO_ACK 0x58
54#define MV64x60_I2C_STATUS_MAST_WR_ADDR_2_ACK 0xd0
55#define MV64x60_I2C_STATUS_MAST_WR_ADDR_2_NO_ACK 0xd8
56#define MV64x60_I2C_STATUS_MAST_RD_ADDR_2_ACK 0xe0
57#define MV64x60_I2C_STATUS_MAST_RD_ADDR_2_NO_ACK 0xe8
58#define MV64x60_I2C_STATUS_NO_STATUS 0xf8
59
60static u8 *ctlr_base;
61
62static int mv64x60_i2c_wait_for_status(int wanted)
63{
64 int i;
65 int status;
66
67 for (i=0; i<1000; i++) {
68 udelay(10);
69 status = in_le32((u32 *)(ctlr_base + MV64x60_I2C_REG_STATUS))
70 & 0xff;
71 if (status == wanted)
72 return status;
73 }
74 return -status;
75}
76
77static int mv64x60_i2c_control(int control, int status)
78{
79 out_le32((u32 *)(ctlr_base + MV64x60_I2C_REG_CONTROL), control & 0xff);
80 return mv64x60_i2c_wait_for_status(status);
81}
82
83static int mv64x60_i2c_read_byte(int control, int status)
84{
85 out_le32((u32 *)(ctlr_base + MV64x60_I2C_REG_CONTROL), control & 0xff);
86 if (mv64x60_i2c_wait_for_status(status) < 0)
87 return -1;
88 return in_le32((u32 *)(ctlr_base + MV64x60_I2C_REG_DATA)) & 0xff;
89}
90
91static int mv64x60_i2c_write_byte(int data, int control, int status)
92{
93 out_le32((u32 *)(ctlr_base + MV64x60_I2C_REG_DATA), data & 0xff);
94 out_le32((u32 *)(ctlr_base + MV64x60_I2C_REG_CONTROL), control & 0xff);
95 return mv64x60_i2c_wait_for_status(status);
96}
97
98int mv64x60_i2c_read(u32 devaddr, u8 *buf, u32 offset, u32 offset_size,
99 u32 count)
100{
101 int i;
102 int data;
103 int control;
104 int status;
105
106 if (ctlr_base == NULL)
107 return -1;
108
109 /* send reset */
110 out_le32((u32 *)(ctlr_base + MV64x60_I2C_REG_SOFT_RESET), 0);
111 out_le32((u32 *)(ctlr_base + MV64x60_I2C_REG_SLAVE_ADDR), 0);
112 out_le32((u32 *)(ctlr_base + MV64x60_I2C_REG_EXT_SLAVE_ADDR), 0);
113 out_le32((u32 *)(ctlr_base + MV64x60_I2C_REG_BAUD), (4 << 3) | 0x4);
114
115 if (mv64x60_i2c_control(MV64x60_I2C_CONTROL_TWSIEN,
116 MV64x60_I2C_STATUS_NO_STATUS) < 0)
117 return -1;
118
119 /* send start */
120 control = MV64x60_I2C_CONTROL_START | MV64x60_I2C_CONTROL_TWSIEN;
121 status = MV64x60_I2C_STATUS_MAST_START;
122 if (mv64x60_i2c_control(control, status) < 0)
123 return -1;
124
125 /* select device for writing */
126 data = devaddr & ~0x1;
127 control = MV64x60_I2C_CONTROL_TWSIEN;
128 status = MV64x60_I2C_STATUS_MAST_WR_ADDR_ACK;
129 if (mv64x60_i2c_write_byte(data, control, status) < 0)
130 return -1;
131
132 /* send offset of data */
133 control = MV64x60_I2C_CONTROL_TWSIEN;
134 status = MV64x60_I2C_STATUS_MAST_WR_ACK;
135 if (offset_size > 1) {
136 if (mv64x60_i2c_write_byte(offset >> 8, control, status) < 0)
137 return -1;
138 }
139 if (mv64x60_i2c_write_byte(offset, control, status) < 0)
140 return -1;
141
142 /* resend start */
143 control = MV64x60_I2C_CONTROL_START | MV64x60_I2C_CONTROL_TWSIEN;
144 status = MV64x60_I2C_STATUS_MAST_REPEAT_START;
145 if (mv64x60_i2c_control(control, status) < 0)
146 return -1;
147
148 /* select device for reading */
149 data = devaddr | 0x1;
150 control = MV64x60_I2C_CONTROL_TWSIEN;
151 status = MV64x60_I2C_STATUS_MAST_RD_ADDR_ACK;
152 if (mv64x60_i2c_write_byte(data, control, status) < 0)
153 return -1;
154
155 /* read all but last byte of data */
156 control = MV64x60_I2C_CONTROL_ACK | MV64x60_I2C_CONTROL_TWSIEN;
157 status = MV64x60_I2C_STATUS_MAST_RD_DATA_ACK;
158
159 for (i=1; i<count; i++) {
160 data = mv64x60_i2c_read_byte(control, status);
161 if (data < 0) {
162 printf("errors on iteration %d\n", i);
163 return -1;
164 }
165 *buf++ = data;
166 }
167
168 /* read last byte of data */
169 control = MV64x60_I2C_CONTROL_TWSIEN;
170 status = MV64x60_I2C_STATUS_MAST_RD_DATA_NO_ACK;
171 data = mv64x60_i2c_read_byte(control, status);
172 if (data < 0)
173 return -1;
174 *buf++ = data;
175
176 /* send stop */
177 control = MV64x60_I2C_CONTROL_STOP | MV64x60_I2C_CONTROL_TWSIEN;
178 status = MV64x60_I2C_STATUS_NO_STATUS;
179 if (mv64x60_i2c_control(control, status) < 0)
180 return -1;
181
182 return count;
183}
184
185int mv64x60_i2c_open(void)
186{
187 u32 v;
188 void *devp;
189
190 devp = finddevice("/mv64x60/i2c");
191 if (devp == NULL)
192 goto err_out;
193 if (getprop(devp, "virtual-reg", &v, sizeof(v)) != sizeof(v))
194 goto err_out;
195
196 ctlr_base = (u8 *)v;
197 return 0;
198
199err_out:
200 return -1;
201}
202
203void mv64x60_i2c_close(void)
204{
205 ctlr_base = NULL;
206}
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index 73bd47a3a079..959124f3f9af 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -79,6 +79,7 @@ void start(void);
79int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device); 79int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device);
80int serial_console_init(void); 80int serial_console_init(void);
81int ns16550_console_init(void *devp, struct serial_console_data *scdp); 81int ns16550_console_init(void *devp, struct serial_console_data *scdp);
82int mpsc_console_init(void *devp, struct serial_console_data *scdp);
82void *simple_alloc_init(char *base, unsigned long heap_size, 83void *simple_alloc_init(char *base, unsigned long heap_size,
83 unsigned long granularity, unsigned long max_allocs); 84 unsigned long granularity, unsigned long max_allocs);
84extern void flush_cache(void *, unsigned long); 85extern void flush_cache(void *, unsigned long);
diff --git a/arch/powerpc/boot/prpmc2800.c b/arch/powerpc/boot/prpmc2800.c
new file mode 100644
index 000000000000..f428bac10d4a
--- /dev/null
+++ b/arch/powerpc/boot/prpmc2800.c
@@ -0,0 +1,577 @@
1/*
2 * Motorola ECC prpmc280/f101 & prpmc2800/f101e platform code.
3 *
4 * Author: Mark A. Greer <mgreer@mvista.com>
5 *
6 * 2007 (c) MontaVista, Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11
12#include <stdarg.h>
13#include <stddef.h>
14#include "types.h"
15#include "elf.h"
16#include "page.h"
17#include "string.h"
18#include "stdio.h"
19#include "io.h"
20#include "ops.h"
21#include "gunzip_util.h"
22#include "mv64x60.h"
23
24extern char _end[];
25extern char _vmlinux_start[], _vmlinux_end[];
26extern char _dtb_start[], _dtb_end[];
27
28extern void udelay(long delay);
29
30#define KB 1024U
31#define MB (KB*KB)
32#define GB (KB*MB)
33#define MHz (1000U*1000U)
34#define GHz (1000U*MHz)
35
36#define BOARD_MODEL "PrPMC2800"
37#define BOARD_MODEL_MAX 32 /* max strlen(BOARD_MODEL) + 1 */
38
39#define EEPROM2_ADDR 0xa4
40#define EEPROM3_ADDR 0xa8
41
42BSS_STACK(16*KB);
43
44static u8 *bridge_base;
45
46typedef enum {
47 BOARD_MODEL_PRPMC280,
48 BOARD_MODEL_PRPMC2800,
49} prpmc2800_board_model;
50
51typedef enum {
52 BRIDGE_TYPE_MV64360,
53 BRIDGE_TYPE_MV64362,
54} prpmc2800_bridge_type;
55
56struct prpmc2800_board_info {
57 prpmc2800_board_model model;
58 char variant;
59 prpmc2800_bridge_type bridge_type;
60 u8 subsys0;
61 u8 subsys1;
62 u8 vpd4;
63 u8 vpd4_mask;
64 u32 core_speed;
65 u32 mem_size;
66 u32 boot_flash;
67 u32 user_flash;
68};
69
70static struct prpmc2800_board_info prpmc2800_board_info[] = {
71 {
72 .model = BOARD_MODEL_PRPMC280,
73 .variant = 'a',
74 .bridge_type = BRIDGE_TYPE_MV64360,
75 .subsys0 = 0xff,
76 .subsys1 = 0xff,
77 .vpd4 = 0x00,
78 .vpd4_mask = 0x0f,
79 .core_speed = 1*GHz,
80 .mem_size = 512*MB,
81 .boot_flash = 1*MB,
82 .user_flash = 64*MB,
83 },
84 {
85 .model = BOARD_MODEL_PRPMC280,
86 .variant = 'b',
87 .bridge_type = BRIDGE_TYPE_MV64362,
88 .subsys0 = 0xff,
89 .subsys1 = 0xff,
90 .vpd4 = 0x01,
91 .vpd4_mask = 0x0f,
92 .core_speed = 1*GHz,
93 .mem_size = 512*MB,
94 .boot_flash = 0,
95 .user_flash = 0,
96 },
97 {
98 .model = BOARD_MODEL_PRPMC280,
99 .variant = 'c',
100 .bridge_type = BRIDGE_TYPE_MV64360,
101 .subsys0 = 0xff,
102 .subsys1 = 0xff,
103 .vpd4 = 0x02,
104 .vpd4_mask = 0x0f,
105 .core_speed = 733*MHz,
106 .mem_size = 512*MB,
107 .boot_flash = 1*MB,
108 .user_flash = 64*MB,
109 },
110 {
111 .model = BOARD_MODEL_PRPMC280,
112 .variant = 'd',
113 .bridge_type = BRIDGE_TYPE_MV64360,
114 .subsys0 = 0xff,
115 .subsys1 = 0xff,
116 .vpd4 = 0x03,
117 .vpd4_mask = 0x0f,
118 .core_speed = 1*GHz,
119 .mem_size = 1*GB,
120 .boot_flash = 1*MB,
121 .user_flash = 64*MB,
122 },
123 {
124 .model = BOARD_MODEL_PRPMC280,
125 .variant = 'e',
126 .bridge_type = BRIDGE_TYPE_MV64360,
127 .subsys0 = 0xff,
128 .subsys1 = 0xff,
129 .vpd4 = 0x04,
130 .vpd4_mask = 0x0f,
131 .core_speed = 1*GHz,
132 .mem_size = 512*MB,
133 .boot_flash = 1*MB,
134 .user_flash = 64*MB,
135 },
136 {
137 .model = BOARD_MODEL_PRPMC280,
138 .variant = 'f',
139 .bridge_type = BRIDGE_TYPE_MV64362,
140 .subsys0 = 0xff,
141 .subsys1 = 0xff,
142 .vpd4 = 0x05,
143 .vpd4_mask = 0x0f,
144 .core_speed = 733*MHz,
145 .mem_size = 128*MB,
146 .boot_flash = 1*MB,
147 .user_flash = 0,
148 },
149 {
150 .model = BOARD_MODEL_PRPMC280,
151 .variant = 'g',
152 .bridge_type = BRIDGE_TYPE_MV64360,
153 .subsys0 = 0xff,
154 .subsys1 = 0xff,
155 .vpd4 = 0x06,
156 .vpd4_mask = 0x0f,
157 .core_speed = 1*GHz,
158 .mem_size = 256*MB,
159 .boot_flash = 1*MB,
160 .user_flash = 0,
161 },
162 {
163 .model = BOARD_MODEL_PRPMC280,
164 .variant = 'h',
165 .bridge_type = BRIDGE_TYPE_MV64360,
166 .subsys0 = 0xff,
167 .subsys1 = 0xff,
168 .vpd4 = 0x07,
169 .vpd4_mask = 0x0f,
170 .core_speed = 1*GHz,
171 .mem_size = 1*GB,
172 .boot_flash = 1*MB,
173 .user_flash = 64*MB,
174 },
175 {
176 .model = BOARD_MODEL_PRPMC2800,
177 .variant = 'a',
178 .bridge_type = BRIDGE_TYPE_MV64360,
179 .subsys0 = 0xb2,
180 .subsys1 = 0x8c,
181 .vpd4 = 0x00,
182 .vpd4_mask = 0x00,
183 .core_speed = 1*GHz,
184 .mem_size = 512*MB,
185 .boot_flash = 2*MB,
186 .user_flash = 64*MB,
187 },
188 {
189 .model = BOARD_MODEL_PRPMC2800,
190 .variant = 'b',
191 .bridge_type = BRIDGE_TYPE_MV64362,
192 .subsys0 = 0xb2,
193 .subsys1 = 0x8d,
194 .vpd4 = 0x00,
195 .vpd4_mask = 0x00,
196 .core_speed = 1*GHz,
197 .mem_size = 512*MB,
198 .boot_flash = 0,
199 .user_flash = 0,
200 },
201 {
202 .model = BOARD_MODEL_PRPMC2800,
203 .variant = 'c',
204 .bridge_type = BRIDGE_TYPE_MV64360,
205 .subsys0 = 0xb2,
206 .subsys1 = 0x8e,
207 .vpd4 = 0x00,
208 .vpd4_mask = 0x00,
209 .core_speed = 733*MHz,
210 .mem_size = 512*MB,
211 .boot_flash = 2*MB,
212 .user_flash = 64*MB,
213 },
214 {
215 .model = BOARD_MODEL_PRPMC2800,
216 .variant = 'd',
217 .bridge_type = BRIDGE_TYPE_MV64360,
218 .subsys0 = 0xb2,
219 .subsys1 = 0x8f,
220 .vpd4 = 0x00,
221 .vpd4_mask = 0x00,
222 .core_speed = 1*GHz,
223 .mem_size = 1*GB,
224 .boot_flash = 2*MB,
225 .user_flash = 64*MB,
226 },
227 {
228 .model = BOARD_MODEL_PRPMC2800,
229 .variant = 'e',
230 .bridge_type = BRIDGE_TYPE_MV64360,
231 .subsys0 = 0xa2,
232 .subsys1 = 0x8a,
233 .vpd4 = 0x00,
234 .vpd4_mask = 0x00,
235 .core_speed = 1*GHz,
236 .mem_size = 512*MB,
237 .boot_flash = 2*MB,
238 .user_flash = 64*MB,
239 },
240 {
241 .model = BOARD_MODEL_PRPMC2800,
242 .variant = 'f',
243 .bridge_type = BRIDGE_TYPE_MV64362,
244 .subsys0 = 0xa2,
245 .subsys1 = 0x8b,
246 .vpd4 = 0x00,
247 .vpd4_mask = 0x00,
248 .core_speed = 733*MHz,
249 .mem_size = 128*MB,
250 .boot_flash = 2*MB,
251 .user_flash = 0,
252 },
253 {
254 .model = BOARD_MODEL_PRPMC2800,
255 .variant = 'g',
256 .bridge_type = BRIDGE_TYPE_MV64360,
257 .subsys0 = 0xa2,
258 .subsys1 = 0x8c,
259 .vpd4 = 0x00,
260 .vpd4_mask = 0x00,
261 .core_speed = 1*GHz,
262 .mem_size = 2*GB,
263 .boot_flash = 2*MB,
264 .user_flash = 64*MB,
265 },
266 {
267 .model = BOARD_MODEL_PRPMC2800,
268 .variant = 'h',
269 .bridge_type = BRIDGE_TYPE_MV64360,
270 .subsys0 = 0xa2,
271 .subsys1 = 0x8d,
272 .vpd4 = 0x00,
273 .vpd4_mask = 0x00,
274 .core_speed = 733*MHz,
275 .mem_size = 1*GB,
276 .boot_flash = 2*MB,
277 .user_flash = 64*MB,
278 },
279};
280
281static struct prpmc2800_board_info *prpmc2800_get_board_info(u8 *vpd)
282{
283 struct prpmc2800_board_info *bip;
284 int i;
285
286 for (i=0,bip=prpmc2800_board_info; i<ARRAY_SIZE(prpmc2800_board_info);
287 i++,bip++)
288 if ((vpd[0] == bip->subsys0) && (vpd[1] == bip->subsys1)
289 && ((vpd[4] & bip->vpd4_mask) == bip->vpd4))
290 return bip;
291
292 return NULL;
293}
294
295/* Get VPD from i2c eeprom 2, then match it to a board info entry */
296static struct prpmc2800_board_info *prpmc2800_get_bip(void)
297{
298 struct prpmc2800_board_info *bip;
299 u8 vpd[5];
300 int rc;
301
302 if (mv64x60_i2c_open())
303 fatal("Error: Can't open i2c device\n\r");
304
305 /* Get VPD from i2c eeprom-2 */
306 memset(vpd, 0, sizeof(vpd));
307 rc = mv64x60_i2c_read(EEPROM2_ADDR, vpd, 0x1fde, 2, sizeof(vpd));
308 if (rc < 0)
309 fatal("Error: Couldn't read eeprom2\n\r");
310 mv64x60_i2c_close();
311
312 /* Get board type & related info */
313 bip = prpmc2800_get_board_info(vpd);
314 if (bip == NULL) {
315 printf("Error: Unsupported board or corrupted VPD:\n\r");
316 printf(" 0x%x 0x%x 0x%x 0x%x 0x%x\n\r",
317 vpd[0], vpd[1], vpd[2], vpd[3], vpd[4]);
318 printf("Using device tree defaults...\n\r");
319 }
320
321 return bip;
322}
323
324static void prpmc2800_bridge_setup(u32 mem_size)
325{
326 u32 i, v[12], enables, acc_bits;
327 u32 pci_base_hi, pci_base_lo, size, buf[2];
328 unsigned long cpu_base;
329 int rc;
330 void *devp;
331 u8 *bridge_pbase, is_coherent;
332 struct mv64x60_cpu2pci_win *tbl;
333
334 bridge_pbase = mv64x60_get_bridge_pbase();
335 is_coherent = mv64x60_is_coherent();
336
337 if (is_coherent)
338 acc_bits = MV64x60_PCI_ACC_CNTL_SNOOP_WB
339 | MV64x60_PCI_ACC_CNTL_SWAP_NONE
340 | MV64x60_PCI_ACC_CNTL_MBURST_32_BYTES
341 | MV64x60_PCI_ACC_CNTL_RDSIZE_32_BYTES;
342 else
343 acc_bits = MV64x60_PCI_ACC_CNTL_SNOOP_NONE
344 | MV64x60_PCI_ACC_CNTL_SWAP_NONE
345 | MV64x60_PCI_ACC_CNTL_MBURST_128_BYTES
346 | MV64x60_PCI_ACC_CNTL_RDSIZE_256_BYTES;
347
348 mv64x60_config_ctlr_windows(bridge_base, bridge_pbase, is_coherent);
349 mv64x60_config_pci_windows(bridge_base, bridge_pbase, 0, 0, mem_size,
350 acc_bits);
351
352 /* Get the cpu -> pci i/o & mem mappings from the device tree */
353 devp = finddevice("/mv64x60/pci@80000000");
354 if (devp == NULL)
355 fatal("Error: Missing /mv64x60/pci@80000000"
356 " device tree node\n\r");
357
358 rc = getprop(devp, "ranges", v, sizeof(v));
359 if (rc != sizeof(v))
360 fatal("Error: Can't find /mv64x60/pci@80000000/ranges"
361 " property\n\r");
362
363 /* Get the cpu -> pci i/o & mem mappings from the device tree */
364 devp = finddevice("/mv64x60");
365 if (devp == NULL)
366 fatal("Error: Missing /mv64x60 device tree node\n\r");
367
368 enables = in_le32((u32 *)(bridge_base + MV64x60_CPU_BAR_ENABLE));
369 enables |= 0x0007fe00; /* Disable all cpu->pci windows */
370 out_le32((u32 *)(bridge_base + MV64x60_CPU_BAR_ENABLE), enables);
371
372 for (i=0; i<12; i+=6) {
373 switch (v[i] & 0xff000000) {
374 case 0x01000000: /* PCI I/O Space */
375 tbl = mv64x60_cpu2pci_io;
376 break;
377 case 0x02000000: /* PCI MEM Space */
378 tbl = mv64x60_cpu2pci_mem;
379 break;
380 default:
381 continue;
382 }
383
384 pci_base_hi = v[i+1];
385 pci_base_lo = v[i+2];
386 cpu_base = v[i+3];
387 size = v[i+5];
388
389 buf[0] = cpu_base;
390 buf[1] = size;
391
392 if (!dt_xlate_addr(devp, buf, sizeof(buf), &cpu_base))
393 fatal("Error: Can't translate PCI address 0x%x\n\r",
394 (u32)cpu_base);
395
396 mv64x60_config_cpu2pci_window(bridge_base, 0, pci_base_hi,
397 pci_base_lo, cpu_base, size, tbl);
398 }
399
400 enables &= ~0x00000600; /* Enable cpu->pci0 i/o, cpu->pci0 mem0 */
401 out_le32((u32 *)(bridge_base + MV64x60_CPU_BAR_ENABLE), enables);
402}
403
404static void prpmc2800_fixups(void)
405{
406 u32 v[2], l, mem_size;
407 int rc;
408 void *devp;
409 char model[BOARD_MODEL_MAX];
410 struct prpmc2800_board_info *bip;
411
412 bip = prpmc2800_get_bip(); /* Get board info based on VPD */
413
414 mem_size = (bip) ? bip->mem_size : mv64x60_get_mem_size(bridge_base);
415 prpmc2800_bridge_setup(mem_size); /* Do necessary bridge setup */
416
417 /* If the VPD doesn't match what we know about, just use the
418 * defaults already in the device tree.
419 */
420 if (!bip)
421 return;
422
423 /* Know the board type so override device tree defaults */
424 /* Set /model appropriately */
425 devp = finddevice("/");
426 if (devp == NULL)
427 fatal("Error: Missing '/' device tree node\n\r");
428 memset(model, 0, BOARD_MODEL_MAX);
429 strncpy(model, BOARD_MODEL, BOARD_MODEL_MAX - 2);
430 l = strlen(model);
431 if (bip->model == BOARD_MODEL_PRPMC280)
432 l--;
433 model[l++] = bip->variant;
434 model[l++] = '\0';
435 setprop(devp, "model", model, l);
436
437 /* Set /cpus/PowerPC,7447/clock-frequency */
438 devp = finddevice("/cpus/PowerPC,7447");
439 if (devp == NULL)
440 fatal("Error: Missing proper /cpus device tree node\n\r");
441 v[0] = bip->core_speed;
442 setprop(devp, "clock-frequency", &v[0], sizeof(v[0]));
443
444 /* Set /memory/reg size */
445 devp = finddevice("/memory");
446 if (devp == NULL)
447 fatal("Error: Missing /memory device tree node\n\r");
448 v[0] = 0;
449 v[1] = bip->mem_size;
450 setprop(devp, "reg", v, sizeof(v));
451
452 /* Update /mv64x60/model, if this is a mv64362 */
453 if (bip->bridge_type == BRIDGE_TYPE_MV64362) {
454 devp = finddevice("/mv64x60");
455 if (devp == NULL)
456 fatal("Error: Missing /mv64x60 device tree node\n\r");
457 setprop(devp, "model", "mv64362", strlen("mv64362") + 1);
458 }
459
460 /* Set User FLASH size */
461 devp = finddevice("/mv64x60/flash@a0000000");
462 if (devp == NULL)
463 fatal("Error: Missing User FLASH device tree node\n\r");
464 rc = getprop(devp, "reg", v, sizeof(v));
465 if (rc != sizeof(v))
466 fatal("Error: Can't find User FLASH reg property\n\r");
467 v[1] = bip->user_flash;
468 setprop(devp, "reg", v, sizeof(v));
469}
470
471#define MV64x60_MPP_CNTL_0 0xf000
472#define MV64x60_MPP_CNTL_2 0xf008
473#define MV64x60_GPP_IO_CNTL 0xf100
474#define MV64x60_GPP_LEVEL_CNTL 0xf110
475#define MV64x60_GPP_VALUE_SET 0xf118
476
477static void prpmc2800_reset(void)
478{
479 u32 temp;
480
481 udelay(5000000);
482
483 if (bridge_base != 0) {
484 temp = in_le32((u32 *)(bridge_base + MV64x60_MPP_CNTL_0));
485 temp &= 0xFFFF0FFF;
486 out_le32((u32 *)(bridge_base + MV64x60_MPP_CNTL_0), temp);
487
488 temp = in_le32((u32 *)(bridge_base + MV64x60_GPP_LEVEL_CNTL));
489 temp |= 0x00000004;
490 out_le32((u32 *)(bridge_base + MV64x60_GPP_LEVEL_CNTL), temp);
491
492 temp = in_le32((u32 *)(bridge_base + MV64x60_GPP_IO_CNTL));
493 temp |= 0x00000004;
494 out_le32((u32 *)(bridge_base + MV64x60_GPP_IO_CNTL), temp);
495
496 temp = in_le32((u32 *)(bridge_base + MV64x60_MPP_CNTL_2));
497 temp &= 0xFFFF0FFF;
498 out_le32((u32 *)(bridge_base + MV64x60_MPP_CNTL_2), temp);
499
500 temp = in_le32((u32 *)(bridge_base + MV64x60_GPP_LEVEL_CNTL));
501 temp |= 0x00080000;
502 out_le32((u32 *)(bridge_base + MV64x60_GPP_LEVEL_CNTL), temp);
503
504 temp = in_le32((u32 *)(bridge_base + MV64x60_GPP_IO_CNTL));
505 temp |= 0x00080000;
506 out_le32((u32 *)(bridge_base + MV64x60_GPP_IO_CNTL), temp);
507
508 out_le32((u32 *)(bridge_base + MV64x60_GPP_VALUE_SET),
509 0x00080004);
510 }
511
512 for (;;);
513}
514
515#define HEAP_SIZE (16*MB)
516static struct gunzip_state gzstate;
517
518void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
519 unsigned long r6, unsigned long r7)
520{
521 struct elf_info ei;
522 char *heap_start, *dtb;
523 int dt_size = _dtb_end - _dtb_start;
524 void *vmlinuz_addr = _vmlinux_start;
525 unsigned long vmlinuz_size = _vmlinux_end - _vmlinux_start;
526 char elfheader[256];
527
528 if (dt_size <= 0) /* No fdt */
529 exit();
530
531 /*
532 * Start heap after end of the kernel (after decompressed to
533 * address 0) or the end of the zImage, whichever is higher.
534 * That's so things allocated by simple_alloc won't overwrite
535 * any part of the zImage and the kernel won't overwrite the dtb
536 * when decompressed & relocated.
537 */
538 gunzip_start(&gzstate, vmlinuz_addr, vmlinuz_size);
539 gunzip_exactly(&gzstate, elfheader, sizeof(elfheader));
540
541 if (!parse_elf32(elfheader, &ei))
542 exit();
543
544 heap_start = (char *)(ei.memsize + ei.elfoffset); /* end of kernel*/
545 heap_start = max(heap_start, (char *)_end); /* end of zImage */
546
547 if ((unsigned)simple_alloc_init(heap_start, HEAP_SIZE, 2*KB, 16)
548 > (128*MB))
549 exit();
550
551 /* Relocate dtb to safe area past end of zImage & kernel */
552 dtb = malloc(dt_size);
553 if (!dtb)
554 exit();
555 memmove(dtb, _dtb_start, dt_size);
556 if (ft_init(dtb, dt_size, 16))
557 exit();
558
559 bridge_base = mv64x60_get_bridge_base();
560
561 platform_ops.fixups = prpmc2800_fixups;
562 platform_ops.exit = prpmc2800_reset;
563
564 if (serial_console_init() < 0)
565 exit();
566}
567
568/* _zimage_start called very early--need to turn off external interrupts */
569asm (" .globl _zimage_start\n\
570 _zimage_start:\n\
571 mfmsr 10\n\
572 rlwinm 10,10,0,~(1<<15) /* Clear MSR_EE */\n\
573 sync\n\
574 mtmsr 10\n\
575 isync\n\
576 b _zimage_start_lib\n\
577");
diff --git a/arch/powerpc/boot/serial.c b/arch/powerpc/boot/serial.c
index e8de4cf59be7..7fd32330a9a5 100644
--- a/arch/powerpc/boot/serial.c
+++ b/arch/powerpc/boot/serial.c
@@ -125,6 +125,8 @@ int serial_console_init(void)
125 125
126 if (!strcmp(compat, "ns16550")) 126 if (!strcmp(compat, "ns16550"))
127 rc = ns16550_console_init(devp, &serial_cd); 127 rc = ns16550_console_init(devp, &serial_cd);
128 else if (!strcmp(compat, "marvell,mpsc"))
129 rc = mpsc_console_init(devp, &serial_cd);
128 130
129 /* Add other serial console driver calls here */ 131 /* Add other serial console driver calls here */
130 132
diff --git a/arch/powerpc/configs/prpmc2800_defconfig b/arch/powerpc/configs/prpmc2800_defconfig
new file mode 100644
index 000000000000..c70a73082007
--- /dev/null
+++ b/arch/powerpc/configs/prpmc2800_defconfig
@@ -0,0 +1,1442 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.21
4# Wed May 9 09:42:46 2007
5#
6# CONFIG_PPC64 is not set
7CONFIG_PPC32=y
8CONFIG_PPC_MERGE=y
9CONFIG_MMU=y
10CONFIG_GENERIC_HARDIRQS=y
11CONFIG_IRQ_PER_CPU=y
12CONFIG_RWSEM_XCHGADD_ALGORITHM=y
13CONFIG_ARCH_HAS_ILOG2_U32=y
14CONFIG_GENERIC_HWEIGHT=y
15CONFIG_GENERIC_CALIBRATE_DELAY=y
16CONFIG_GENERIC_FIND_NEXT_BIT=y
17CONFIG_PPC=y
18CONFIG_EARLY_PRINTK=y
19CONFIG_GENERIC_NVRAM=y
20CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
21CONFIG_ARCH_MAY_HAVE_PC_FDC=y
22CONFIG_PPC_OF=y
23# CONFIG_PPC_UDBG_16550 is not set
24# CONFIG_GENERIC_TBSYNC is not set
25CONFIG_AUDIT_ARCH=y
26CONFIG_GENERIC_BUG=y
27# CONFIG_DEFAULT_UIMAGE is not set
28
29#
30# Processor support
31#
32CONFIG_CLASSIC32=y
33# CONFIG_PPC_82xx is not set
34# CONFIG_PPC_83xx is not set
35# CONFIG_PPC_85xx is not set
36# CONFIG_PPC_86xx is not set
37# CONFIG_PPC_8xx is not set
38# CONFIG_40x is not set
39# CONFIG_44x is not set
40# CONFIG_E200 is not set
41CONFIG_6xx=y
42CONFIG_PPC_FPU=y
43# CONFIG_PPC_DCR_NATIVE is not set
44# CONFIG_PPC_DCR_MMIO is not set
45CONFIG_ALTIVEC=y
46CONFIG_PPC_STD_MMU=y
47CONFIG_PPC_STD_MMU_32=y
48# CONFIG_PPC_MM_SLICES is not set
49# CONFIG_SMP is not set
50CONFIG_NOT_COHERENT_CACHE=y
51CONFIG_CONFIG_CHECK_CACHE_COHERENCY=y
52CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
53
54#
55# Code maturity level options
56#
57CONFIG_EXPERIMENTAL=y
58CONFIG_BROKEN_ON_SMP=y
59CONFIG_INIT_ENV_ARG_LIMIT=32
60
61#
62# General setup
63#
64CONFIG_LOCALVERSION=""
65CONFIG_LOCALVERSION_AUTO=y
66CONFIG_SWAP=y
67CONFIG_SYSVIPC=y
68# CONFIG_IPC_NS is not set
69CONFIG_SYSVIPC_SYSCTL=y
70CONFIG_POSIX_MQUEUE=y
71# CONFIG_BSD_PROCESS_ACCT is not set
72# CONFIG_TASKSTATS is not set
73# CONFIG_UTS_NS is not set
74# CONFIG_AUDIT is not set
75# CONFIG_IKCONFIG is not set
76CONFIG_LOG_BUF_SHIFT=14
77# CONFIG_SYSFS_DEPRECATED is not set
78# CONFIG_RELAY is not set
79CONFIG_BLK_DEV_INITRD=y
80CONFIG_INITRAMFS_SOURCE=""
81# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
82CONFIG_SYSCTL=y
83# CONFIG_EMBEDDED is not set
84CONFIG_SYSCTL_SYSCALL=y
85CONFIG_KALLSYMS=y
86# CONFIG_KALLSYMS_EXTRA_PASS is not set
87CONFIG_HOTPLUG=y
88CONFIG_PRINTK=y
89CONFIG_BUG=y
90CONFIG_ELF_CORE=y
91CONFIG_BASE_FULL=y
92CONFIG_FUTEX=y
93CONFIG_EPOLL=y
94CONFIG_SHMEM=y
95CONFIG_VM_EVENT_COUNTERS=y
96CONFIG_SLAB=y
97# CONFIG_SLUB is not set
98# CONFIG_SLOB is not set
99CONFIG_RT_MUTEXES=y
100# CONFIG_TINY_SHMEM is not set
101CONFIG_BASE_SMALL=0
102
103#
104# Loadable module support
105#
106# CONFIG_MODULES is not set
107
108#
109# Block layer
110#
111CONFIG_BLOCK=y
112CONFIG_LBD=y
113# CONFIG_BLK_DEV_IO_TRACE is not set
114# CONFIG_LSF is not set
115
116#
117# IO Schedulers
118#
119CONFIG_IOSCHED_NOOP=y
120CONFIG_IOSCHED_AS=y
121# CONFIG_IOSCHED_DEADLINE is not set
122# CONFIG_IOSCHED_CFQ is not set
123CONFIG_DEFAULT_AS=y
124# CONFIG_DEFAULT_DEADLINE is not set
125# CONFIG_DEFAULT_CFQ is not set
126# CONFIG_DEFAULT_NOOP is not set
127CONFIG_DEFAULT_IOSCHED="anticipatory"
128
129#
130# Platform support
131#
132# CONFIG_PPC_MULTIPLATFORM is not set
133CONFIG_EMBEDDED6xx=y
134# CONFIG_APUS is not set
135# CONFIG_PPC_MPC52xx is not set
136# CONFIG_PPC_MPC5200 is not set
137# CONFIG_PPC_CELL is not set
138# CONFIG_PPC_CELL_NATIVE is not set
139# CONFIG_PQ2ADS is not set
140# CONFIG_LINKSTATION is not set
141# CONFIG_MPC7448HPC2 is not set
142# CONFIG_PPC_HOLLY is not set
143CONFIG_PPC_PRPMC2800=y
144CONFIG_MV64X60=y
145# CONFIG_MPIC is not set
146# CONFIG_MPIC_WEIRD is not set
147# CONFIG_PPC_I8259 is not set
148# CONFIG_PPC_RTAS is not set
149# CONFIG_MMIO_NVRAM is not set
150# CONFIG_PPC_MPC106 is not set
151# CONFIG_PPC_970_NAP is not set
152# CONFIG_PPC_INDIRECT_IO is not set
153# CONFIG_GENERIC_IOMAP is not set
154# CONFIG_CPU_FREQ is not set
155# CONFIG_TAU is not set
156# CONFIG_CPM2 is not set
157
158#
159# Kernel options
160#
161CONFIG_HIGHMEM=y
162# CONFIG_HZ_100 is not set
163CONFIG_HZ_250=y
164# CONFIG_HZ_300 is not set
165# CONFIG_HZ_1000 is not set
166CONFIG_HZ=250
167CONFIG_PREEMPT_NONE=y
168# CONFIG_PREEMPT_VOLUNTARY is not set
169# CONFIG_PREEMPT is not set
170CONFIG_BINFMT_ELF=y
171CONFIG_BINFMT_MISC=y
172CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
173# CONFIG_KEXEC is not set
174CONFIG_ARCH_FLATMEM_ENABLE=y
175CONFIG_ARCH_POPULATES_NODE_MAP=y
176CONFIG_SELECT_MEMORY_MODEL=y
177CONFIG_FLATMEM_MANUAL=y
178# CONFIG_DISCONTIGMEM_MANUAL is not set
179# CONFIG_SPARSEMEM_MANUAL is not set
180CONFIG_FLATMEM=y
181CONFIG_FLAT_NODE_MEM_MAP=y
182# CONFIG_SPARSEMEM_STATIC is not set
183CONFIG_SPLIT_PTLOCK_CPUS=4
184# CONFIG_RESOURCES_64BIT is not set
185CONFIG_ZONE_DMA_FLAG=1
186CONFIG_PROC_DEVICETREE=y
187# CONFIG_CMDLINE_BOOL is not set
188# CONFIG_PM is not set
189# CONFIG_SECCOMP is not set
190CONFIG_WANT_DEVICE_TREE=y
191CONFIG_DEVICE_TREE="prpmc2800.dts"
192CONFIG_ISA_DMA_API=y
193
194#
195# Bus options
196#
197CONFIG_ZONE_DMA=y
198CONFIG_GENERIC_ISA_DMA=y
199CONFIG_PPC_INDIRECT_PCI=y
200# CONFIG_PPC_INDIRECT_PCI_BE is not set
201CONFIG_PCI=y
202CONFIG_PCI_DOMAINS=y
203# CONFIG_PCIEPORTBUS is not set
204CONFIG_ARCH_SUPPORTS_MSI=y
205# CONFIG_PCI_MSI is not set
206
207#
208# PCCARD (PCMCIA/CardBus) support
209#
210# CONFIG_PCCARD is not set
211# CONFIG_HOTPLUG_PCI is not set
212
213#
214# Advanced setup
215#
216# CONFIG_ADVANCED_OPTIONS is not set
217
218#
219# Default settings for advanced configuration options are used
220#
221CONFIG_HIGHMEM_START=0xfe000000
222CONFIG_LOWMEM_SIZE=0x30000000
223CONFIG_KERNEL_START=0xc0000000
224CONFIG_TASK_SIZE=0x80000000
225CONFIG_CONSISTENT_START=0xff100000
226CONFIG_CONSISTENT_SIZE=0x00200000
227CONFIG_BOOT_LOAD=0x00800000
228
229#
230# Networking
231#
232CONFIG_NET=y
233
234#
235# Networking options
236#
237CONFIG_PACKET=y
238# CONFIG_PACKET_MMAP is not set
239CONFIG_UNIX=y
240CONFIG_XFRM=y
241CONFIG_XFRM_USER=y
242# CONFIG_XFRM_SUB_POLICY is not set
243# CONFIG_XFRM_MIGRATE is not set
244# CONFIG_NET_KEY is not set
245CONFIG_INET=y
246CONFIG_IP_MULTICAST=y
247# CONFIG_IP_ADVANCED_ROUTER is not set
248CONFIG_IP_FIB_HASH=y
249CONFIG_IP_PNP=y
250CONFIG_IP_PNP_DHCP=y
251CONFIG_IP_PNP_BOOTP=y
252# CONFIG_IP_PNP_RARP is not set
253# CONFIG_NET_IPIP is not set
254# CONFIG_NET_IPGRE is not set
255# CONFIG_IP_MROUTE is not set
256# CONFIG_ARPD is not set
257CONFIG_SYN_COOKIES=y
258# CONFIG_INET_AH is not set
259# CONFIG_INET_ESP is not set
260# CONFIG_INET_IPCOMP is not set
261# CONFIG_INET_XFRM_TUNNEL is not set
262# CONFIG_INET_TUNNEL is not set
263CONFIG_INET_XFRM_MODE_TRANSPORT=y
264CONFIG_INET_XFRM_MODE_TUNNEL=y
265CONFIG_INET_XFRM_MODE_BEET=y
266CONFIG_INET_DIAG=y
267CONFIG_INET_TCP_DIAG=y
268# CONFIG_TCP_CONG_ADVANCED is not set
269CONFIG_TCP_CONG_CUBIC=y
270CONFIG_DEFAULT_TCP_CONG="cubic"
271# CONFIG_TCP_MD5SIG is not set
272# CONFIG_IPV6 is not set
273# CONFIG_INET6_XFRM_TUNNEL is not set
274# CONFIG_INET6_TUNNEL is not set
275# CONFIG_NETWORK_SECMARK is not set
276# CONFIG_NETFILTER is not set
277
278#
279# DCCP Configuration (EXPERIMENTAL)
280#
281# CONFIG_IP_DCCP is not set
282
283#
284# SCTP Configuration (EXPERIMENTAL)
285#
286# CONFIG_IP_SCTP is not set
287
288#
289# TIPC Configuration (EXPERIMENTAL)
290#
291# CONFIG_TIPC is not set
292# CONFIG_ATM is not set
293# CONFIG_BRIDGE is not set
294# CONFIG_VLAN_8021Q is not set
295# CONFIG_DECNET is not set
296# CONFIG_LLC2 is not set
297# CONFIG_IPX is not set
298# CONFIG_ATALK is not set
299# CONFIG_X25 is not set
300# CONFIG_LAPB is not set
301# CONFIG_ECONET is not set
302# CONFIG_WAN_ROUTER is not set
303
304#
305# QoS and/or fair queueing
306#
307# CONFIG_NET_SCHED is not set
308
309#
310# Network testing
311#
312# CONFIG_NET_PKTGEN is not set
313# CONFIG_HAMRADIO is not set
314# CONFIG_IRDA is not set
315# CONFIG_BT is not set
316# CONFIG_AF_RXRPC is not set
317
318#
319# Wireless
320#
321# CONFIG_CFG80211 is not set
322# CONFIG_WIRELESS_EXT is not set
323# CONFIG_MAC80211 is not set
324# CONFIG_IEEE80211 is not set
325# CONFIG_RFKILL is not set
326
327#
328# Device Drivers
329#
330
331#
332# Generic Driver Options
333#
334CONFIG_STANDALONE=y
335CONFIG_PREVENT_FIRMWARE_BUILD=y
336# CONFIG_FW_LOADER is not set
337# CONFIG_SYS_HYPERVISOR is not set
338
339#
340# Connector - unified userspace <-> kernelspace linker
341#
342# CONFIG_CONNECTOR is not set
343CONFIG_MTD=y
344# CONFIG_MTD_DEBUG is not set
345CONFIG_MTD_CONCAT=y
346CONFIG_MTD_PARTITIONS=y
347# CONFIG_MTD_REDBOOT_PARTS is not set
348# CONFIG_MTD_CMDLINE_PARTS is not set
349
350#
351# User Modules And Translation Layers
352#
353CONFIG_MTD_CHAR=y
354CONFIG_MTD_BLKDEVS=y
355CONFIG_MTD_BLOCK=y
356# CONFIG_FTL is not set
357# CONFIG_NFTL is not set
358# CONFIG_INFTL is not set
359# CONFIG_RFD_FTL is not set
360# CONFIG_SSFDC is not set
361
362#
363# RAM/ROM/Flash chip drivers
364#
365CONFIG_MTD_CFI=y
366CONFIG_MTD_JEDECPROBE=y
367CONFIG_MTD_GEN_PROBE=y
368# CONFIG_MTD_CFI_ADV_OPTIONS is not set
369CONFIG_MTD_MAP_BANK_WIDTH_1=y
370CONFIG_MTD_MAP_BANK_WIDTH_2=y
371CONFIG_MTD_MAP_BANK_WIDTH_4=y
372# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
373# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
374# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
375CONFIG_MTD_CFI_I1=y
376CONFIG_MTD_CFI_I2=y
377# CONFIG_MTD_CFI_I4 is not set
378# CONFIG_MTD_CFI_I8 is not set
379CONFIG_MTD_CFI_INTELEXT=y
380# CONFIG_MTD_CFI_AMDSTD is not set
381# CONFIG_MTD_CFI_STAA is not set
382CONFIG_MTD_CFI_UTIL=y
383# CONFIG_MTD_RAM is not set
384# CONFIG_MTD_ROM is not set
385# CONFIG_MTD_ABSENT is not set
386# CONFIG_MTD_OBSOLETE_CHIPS is not set
387
388#
389# Mapping drivers for chip access
390#
391# CONFIG_MTD_COMPLEX_MAPPINGS is not set
392# CONFIG_MTD_PHYSMAP is not set
393CONFIG_MTD_PHYSMAP_OF=y
394# CONFIG_MTD_PLATRAM is not set
395
396#
397# Self-contained MTD device drivers
398#
399# CONFIG_MTD_PMC551 is not set
400# CONFIG_MTD_SLRAM is not set
401# CONFIG_MTD_PHRAM is not set
402# CONFIG_MTD_MTDRAM is not set
403# CONFIG_MTD_BLOCK2MTD is not set
404
405#
406# Disk-On-Chip Device Drivers
407#
408# CONFIG_MTD_DOC2000 is not set
409# CONFIG_MTD_DOC2001 is not set
410# CONFIG_MTD_DOC2001PLUS is not set
411# CONFIG_MTD_NAND is not set
412# CONFIG_MTD_ONENAND is not set
413
414#
415# UBI - Unsorted block images
416#
417# CONFIG_MTD_UBI is not set
418
419#
420# Parallel port support
421#
422# CONFIG_PARPORT is not set
423
424#
425# Plug and Play support
426#
427# CONFIG_PNPACPI is not set
428
429#
430# Block devices
431#
432# CONFIG_BLK_DEV_FD is not set
433# CONFIG_BLK_CPQ_DA is not set
434# CONFIG_BLK_CPQ_CISS_DA is not set
435# CONFIG_BLK_DEV_DAC960 is not set
436# CONFIG_BLK_DEV_UMEM is not set
437# CONFIG_BLK_DEV_COW_COMMON is not set
438CONFIG_BLK_DEV_LOOP=y
439# CONFIG_BLK_DEV_CRYPTOLOOP is not set
440# CONFIG_BLK_DEV_NBD is not set
441# CONFIG_BLK_DEV_SX8 is not set
442# CONFIG_BLK_DEV_UB is not set
443CONFIG_BLK_DEV_RAM=y
444CONFIG_BLK_DEV_RAM_COUNT=16
445CONFIG_BLK_DEV_RAM_SIZE=131072
446CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
447# CONFIG_CDROM_PKTCDVD is not set
448# CONFIG_ATA_OVER_ETH is not set
449
450#
451# Misc devices
452#
453# CONFIG_PHANTOM is not set
454# CONFIG_SGI_IOC4 is not set
455# CONFIG_TIFM_CORE is not set
456# CONFIG_BLINK is not set
457
458#
459# ATA/ATAPI/MFM/RLL support
460#
461CONFIG_IDE=y
462CONFIG_BLK_DEV_IDE=y
463
464#
465# Please see Documentation/ide.txt for help/info on IDE drives
466#
467# CONFIG_BLK_DEV_IDE_SATA is not set
468CONFIG_BLK_DEV_IDEDISK=y
469# CONFIG_IDEDISK_MULTI_MODE is not set
470# CONFIG_BLK_DEV_IDECD is not set
471# CONFIG_BLK_DEV_IDETAPE is not set
472# CONFIG_BLK_DEV_IDEFLOPPY is not set
473# CONFIG_BLK_DEV_IDESCSI is not set
474# CONFIG_IDE_TASK_IOCTL is not set
475
476#
477# IDE chipset support/bugfixes
478#
479CONFIG_IDE_GENERIC=y
480CONFIG_BLK_DEV_IDEPCI=y
481# CONFIG_IDEPCI_SHARE_IRQ is not set
482# CONFIG_BLK_DEV_OFFBOARD is not set
483CONFIG_BLK_DEV_GENERIC=y
484# CONFIG_BLK_DEV_OPTI621 is not set
485CONFIG_BLK_DEV_IDEDMA_PCI=y
486# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
487# CONFIG_IDEDMA_ONLYDISK is not set
488# CONFIG_BLK_DEV_AEC62XX is not set
489# CONFIG_BLK_DEV_ALI15X3 is not set
490# CONFIG_BLK_DEV_AMD74XX is not set
491# CONFIG_BLK_DEV_CMD64X is not set
492# CONFIG_BLK_DEV_TRIFLEX is not set
493# CONFIG_BLK_DEV_CY82C693 is not set
494# CONFIG_BLK_DEV_CS5520 is not set
495# CONFIG_BLK_DEV_CS5530 is not set
496# CONFIG_BLK_DEV_HPT34X is not set
497# CONFIG_BLK_DEV_HPT366 is not set
498# CONFIG_BLK_DEV_JMICRON is not set
499# CONFIG_BLK_DEV_SC1200 is not set
500# CONFIG_BLK_DEV_PIIX is not set
501# CONFIG_BLK_DEV_IT8213 is not set
502# CONFIG_BLK_DEV_IT821X is not set
503# CONFIG_BLK_DEV_NS87415 is not set
504# CONFIG_BLK_DEV_PDC202XX_OLD is not set
505CONFIG_BLK_DEV_PDC202XX_NEW=y
506# CONFIG_BLK_DEV_SVWKS is not set
507# CONFIG_BLK_DEV_SIIMAGE is not set
508# CONFIG_BLK_DEV_SL82C105 is not set
509# CONFIG_BLK_DEV_SLC90E66 is not set
510# CONFIG_BLK_DEV_TRM290 is not set
511# CONFIG_BLK_DEV_VIA82CXXX is not set
512# CONFIG_BLK_DEV_TC86C001 is not set
513# CONFIG_IDE_ARM is not set
514CONFIG_BLK_DEV_IDEDMA=y
515# CONFIG_IDEDMA_IVB is not set
516# CONFIG_BLK_DEV_HD is not set
517
518#
519# SCSI device support
520#
521# CONFIG_RAID_ATTRS is not set
522CONFIG_SCSI=y
523# CONFIG_SCSI_TGT is not set
524# CONFIG_SCSI_NETLINK is not set
525CONFIG_SCSI_PROC_FS=y
526
527#
528# SCSI support type (disk, tape, CD-ROM)
529#
530CONFIG_BLK_DEV_SD=y
531# CONFIG_CHR_DEV_ST is not set
532# CONFIG_CHR_DEV_OSST is not set
533# CONFIG_BLK_DEV_SR is not set
534# CONFIG_CHR_DEV_SG is not set
535# CONFIG_CHR_DEV_SCH is not set
536
537#
538# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
539#
540# CONFIG_SCSI_MULTI_LUN is not set
541# CONFIG_SCSI_CONSTANTS is not set
542# CONFIG_SCSI_LOGGING is not set
543# CONFIG_SCSI_SCAN_ASYNC is not set
544
545#
546# SCSI Transports
547#
548# CONFIG_SCSI_SPI_ATTRS is not set
549# CONFIG_SCSI_FC_ATTRS is not set
550# CONFIG_SCSI_ISCSI_ATTRS is not set
551# CONFIG_SCSI_SAS_ATTRS is not set
552# CONFIG_SCSI_SAS_LIBSAS is not set
553
554#
555# SCSI low-level drivers
556#
557# CONFIG_ISCSI_TCP is not set
558# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
559# CONFIG_SCSI_3W_9XXX is not set
560# CONFIG_SCSI_ACARD is not set
561# CONFIG_SCSI_AACRAID is not set
562# CONFIG_SCSI_AIC7XXX is not set
563# CONFIG_SCSI_AIC7XXX_OLD is not set
564# CONFIG_SCSI_AIC79XX is not set
565# CONFIG_SCSI_AIC94XX is not set
566# CONFIG_SCSI_DPT_I2O is not set
567# CONFIG_SCSI_ARCMSR is not set
568# CONFIG_MEGARAID_NEWGEN is not set
569# CONFIG_MEGARAID_LEGACY is not set
570# CONFIG_MEGARAID_SAS is not set
571# CONFIG_SCSI_HPTIOP is not set
572# CONFIG_SCSI_BUSLOGIC is not set
573# CONFIG_SCSI_DMX3191D is not set
574# CONFIG_SCSI_EATA is not set
575# CONFIG_SCSI_FUTURE_DOMAIN is not set
576# CONFIG_SCSI_GDTH is not set
577# CONFIG_SCSI_IPS is not set
578# CONFIG_SCSI_INITIO is not set
579# CONFIG_SCSI_INIA100 is not set
580# CONFIG_SCSI_STEX is not set
581# CONFIG_SCSI_SYM53C8XX_2 is not set
582# CONFIG_SCSI_IPR is not set
583# CONFIG_SCSI_QLOGIC_1280 is not set
584# CONFIG_SCSI_QLA_FC is not set
585# CONFIG_SCSI_QLA_ISCSI is not set
586# CONFIG_SCSI_LPFC is not set
587# CONFIG_SCSI_DC395x is not set
588# CONFIG_SCSI_DC390T is not set
589# CONFIG_SCSI_NSP32 is not set
590# CONFIG_SCSI_DEBUG is not set
591# CONFIG_SCSI_ESP_CORE is not set
592# CONFIG_SCSI_SRP is not set
593
594#
595# Serial ATA (prod) and Parallel ATA (experimental) drivers
596#
597CONFIG_ATA=y
598# CONFIG_ATA_NONSTANDARD is not set
599# CONFIG_SATA_AHCI is not set
600# CONFIG_SATA_SVW is not set
601# CONFIG_ATA_PIIX is not set
602CONFIG_SATA_MV=y
603# CONFIG_SATA_NV is not set
604# CONFIG_PDC_ADMA is not set
605# CONFIG_SATA_QSTOR is not set
606# CONFIG_SATA_PROMISE is not set
607# CONFIG_SATA_SX4 is not set
608# CONFIG_SATA_SIL is not set
609# CONFIG_SATA_SIL24 is not set
610# CONFIG_SATA_SIS is not set
611# CONFIG_SATA_ULI is not set
612# CONFIG_SATA_VIA is not set
613# CONFIG_SATA_VITESSE is not set
614# CONFIG_SATA_INIC162X is not set
615# CONFIG_PATA_ALI is not set
616# CONFIG_PATA_AMD is not set
617# CONFIG_PATA_ARTOP is not set
618# CONFIG_PATA_ATIIXP is not set
619# CONFIG_PATA_CMD640_PCI is not set
620# CONFIG_PATA_CMD64X is not set
621# CONFIG_PATA_CS5520 is not set
622# CONFIG_PATA_CS5530 is not set
623# CONFIG_PATA_CYPRESS is not set
624# CONFIG_PATA_EFAR is not set
625# CONFIG_ATA_GENERIC is not set
626# CONFIG_PATA_HPT366 is not set
627# CONFIG_PATA_HPT37X is not set
628# CONFIG_PATA_HPT3X2N is not set
629# CONFIG_PATA_HPT3X3 is not set
630# CONFIG_PATA_IT821X is not set
631# CONFIG_PATA_IT8213 is not set
632# CONFIG_PATA_JMICRON is not set
633# CONFIG_PATA_TRIFLEX is not set
634# CONFIG_PATA_MARVELL is not set
635# CONFIG_PATA_MPIIX is not set
636# CONFIG_PATA_OLDPIIX is not set
637# CONFIG_PATA_NETCELL is not set
638# CONFIG_PATA_NS87410 is not set
639# CONFIG_PATA_OPTI is not set
640# CONFIG_PATA_OPTIDMA is not set
641# CONFIG_PATA_PDC_OLD is not set
642# CONFIG_PATA_RADISYS is not set
643# CONFIG_PATA_RZ1000 is not set
644# CONFIG_PATA_SC1200 is not set
645# CONFIG_PATA_SERVERWORKS is not set
646# CONFIG_PATA_PDC2027X is not set
647# CONFIG_PATA_SIL680 is not set
648# CONFIG_PATA_SIS is not set
649# CONFIG_PATA_VIA is not set
650# CONFIG_PATA_WINBOND is not set
651
652#
653# Multi-device support (RAID and LVM)
654#
655# CONFIG_MD is not set
656
657#
658# Fusion MPT device support
659#
660# CONFIG_FUSION is not set
661# CONFIG_FUSION_SPI is not set
662# CONFIG_FUSION_FC is not set
663# CONFIG_FUSION_SAS is not set
664
665#
666# IEEE 1394 (FireWire) support
667#
668# CONFIG_IEEE1394 is not set
669
670#
671# I2O device support
672#
673# CONFIG_I2O is not set
674CONFIG_MACINTOSH_DRIVERS=y
675# CONFIG_MAC_EMUMOUSEBTN is not set
676# CONFIG_WINDFARM is not set
677
678#
679# Network device support
680#
681CONFIG_NETDEVICES=y
682# CONFIG_DUMMY is not set
683# CONFIG_BONDING is not set
684# CONFIG_EQUALIZER is not set
685# CONFIG_TUN is not set
686
687#
688# ARCnet devices
689#
690# CONFIG_ARCNET is not set
691
692#
693# PHY device support
694#
695CONFIG_PHYLIB=y
696
697#
698# MII PHY device drivers
699#
700# CONFIG_MARVELL_PHY is not set
701# CONFIG_DAVICOM_PHY is not set
702# CONFIG_QSEMI_PHY is not set
703# CONFIG_LXT_PHY is not set
704# CONFIG_CICADA_PHY is not set
705# CONFIG_VITESSE_PHY is not set
706# CONFIG_SMSC_PHY is not set
707# CONFIG_BROADCOM_PHY is not set
708# CONFIG_FIXED_PHY is not set
709
710#
711# Ethernet (10 or 100Mbit)
712#
713CONFIG_NET_ETHERNET=y
714CONFIG_MII=y
715# CONFIG_HAPPYMEAL is not set
716# CONFIG_SUNGEM is not set
717# CONFIG_CASSINI is not set
718# CONFIG_NET_VENDOR_3COM is not set
719
720#
721# Tulip family network device support
722#
723# CONFIG_NET_TULIP is not set
724# CONFIG_HP100 is not set
725CONFIG_NET_PCI=y
726# CONFIG_PCNET32 is not set
727# CONFIG_AMD8111_ETH is not set
728# CONFIG_ADAPTEC_STARFIRE is not set
729# CONFIG_B44 is not set
730# CONFIG_FORCEDETH is not set
731# CONFIG_DGRS is not set
732# CONFIG_EEPRO100 is not set
733CONFIG_E100=y
734# CONFIG_FEALNX is not set
735# CONFIG_NATSEMI is not set
736# CONFIG_NE2K_PCI is not set
737# CONFIG_8139CP is not set
738CONFIG_8139TOO=y
739# CONFIG_8139TOO_PIO is not set
740# CONFIG_8139TOO_TUNE_TWISTER is not set
741# CONFIG_8139TOO_8129 is not set
742# CONFIG_8139_OLD_RX_RESET is not set
743# CONFIG_SIS900 is not set
744# CONFIG_EPIC100 is not set
745# CONFIG_SUNDANCE is not set
746# CONFIG_TLAN is not set
747# CONFIG_VIA_RHINE is not set
748# CONFIG_SC92031 is not set
749
750#
751# Ethernet (1000 Mbit)
752#
753# CONFIG_ACENIC is not set
754# CONFIG_DL2K is not set
755CONFIG_E1000=y
756# CONFIG_E1000_NAPI is not set
757# CONFIG_E1000_DISABLE_PACKET_SPLIT is not set
758# CONFIG_NS83820 is not set
759# CONFIG_HAMACHI is not set
760# CONFIG_YELLOWFIN is not set
761# CONFIG_R8169 is not set
762# CONFIG_SIS190 is not set
763# CONFIG_SKGE is not set
764# CONFIG_SKY2 is not set
765# CONFIG_SK98LIN is not set
766# CONFIG_VIA_VELOCITY is not set
767# CONFIG_TIGON3 is not set
768# CONFIG_BNX2 is not set
769CONFIG_MV643XX_ETH=y
770# CONFIG_QLA3XXX is not set
771# CONFIG_ATL1 is not set
772
773#
774# Ethernet (10000 Mbit)
775#
776# CONFIG_CHELSIO_T1 is not set
777# CONFIG_CHELSIO_T3 is not set
778# CONFIG_IXGB is not set
779# CONFIG_S2IO is not set
780# CONFIG_MYRI10GE is not set
781# CONFIG_NETXEN_NIC is not set
782
783#
784# Token Ring devices
785#
786# CONFIG_TR is not set
787
788#
789# Wireless LAN
790#
791# CONFIG_WLAN_PRE80211 is not set
792# CONFIG_WLAN_80211 is not set
793
794#
795# Wan interfaces
796#
797# CONFIG_WAN is not set
798# CONFIG_FDDI is not set
799# CONFIG_HIPPI is not set
800# CONFIG_PPP is not set
801# CONFIG_SLIP is not set
802# CONFIG_NET_FC is not set
803# CONFIG_SHAPER is not set
804# CONFIG_NETCONSOLE is not set
805# CONFIG_NETPOLL is not set
806# CONFIG_NET_POLL_CONTROLLER is not set
807
808#
809# ISDN subsystem
810#
811# CONFIG_ISDN is not set
812
813#
814# Telephony Support
815#
816# CONFIG_PHONE is not set
817
818#
819# Input device support
820#
821CONFIG_INPUT=y
822# CONFIG_INPUT_FF_MEMLESS is not set
823
824#
825# Userland interfaces
826#
827CONFIG_INPUT_MOUSEDEV=y
828CONFIG_INPUT_MOUSEDEV_PSAUX=y
829CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
830CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
831# CONFIG_INPUT_JOYDEV is not set
832# CONFIG_INPUT_TSDEV is not set
833# CONFIG_INPUT_EVDEV is not set
834# CONFIG_INPUT_EVBUG is not set
835
836#
837# Input Device Drivers
838#
839# CONFIG_INPUT_KEYBOARD is not set
840# CONFIG_INPUT_MOUSE is not set
841# CONFIG_INPUT_JOYSTICK is not set
842# CONFIG_INPUT_TABLET is not set
843# CONFIG_INPUT_TOUCHSCREEN is not set
844# CONFIG_INPUT_MISC is not set
845
846#
847# Hardware I/O ports
848#
849# CONFIG_SERIO is not set
850# CONFIG_GAMEPORT is not set
851
852#
853# Character devices
854#
855CONFIG_VT=y
856CONFIG_VT_CONSOLE=y
857CONFIG_HW_CONSOLE=y
858# CONFIG_VT_HW_CONSOLE_BINDING is not set
859# CONFIG_SERIAL_NONSTANDARD is not set
860
861#
862# Serial drivers
863#
864# CONFIG_SERIAL_8250 is not set
865
866#
867# Non-8250 serial port support
868#
869CONFIG_SERIAL_MPSC=y
870CONFIG_SERIAL_MPSC_CONSOLE=y
871# CONFIG_SERIAL_UARTLITE is not set
872CONFIG_SERIAL_CORE=y
873CONFIG_SERIAL_CORE_CONSOLE=y
874# CONFIG_SERIAL_JSM is not set
875CONFIG_UNIX98_PTYS=y
876CONFIG_LEGACY_PTYS=y
877CONFIG_LEGACY_PTY_COUNT=256
878
879#
880# IPMI
881#
882# CONFIG_IPMI_HANDLER is not set
883
884#
885# Watchdog Cards
886#
887# CONFIG_WATCHDOG is not set
888# CONFIG_HW_RANDOM is not set
889# CONFIG_NVRAM is not set
890CONFIG_GEN_RTC=y
891# CONFIG_GEN_RTC_X is not set
892# CONFIG_DTLK is not set
893# CONFIG_R3964 is not set
894# CONFIG_APPLICOM is not set
895# CONFIG_AGP is not set
896# CONFIG_DRM is not set
897# CONFIG_RAW_DRIVER is not set
898
899#
900# TPM devices
901#
902# CONFIG_TCG_TPM is not set
903CONFIG_DEVPORT=y
904CONFIG_I2C=y
905CONFIG_I2C_BOARDINFO=y
906CONFIG_I2C_CHARDEV=y
907
908#
909# I2C Algorithms
910#
911# CONFIG_I2C_ALGOBIT is not set
912# CONFIG_I2C_ALGOPCF is not set
913# CONFIG_I2C_ALGOPCA is not set
914
915#
916# I2C Hardware Bus support
917#
918# CONFIG_I2C_ALI1535 is not set
919# CONFIG_I2C_ALI1563 is not set
920# CONFIG_I2C_ALI15X3 is not set
921# CONFIG_I2C_AMD756 is not set
922# CONFIG_I2C_AMD8111 is not set
923# CONFIG_I2C_I801 is not set
924# CONFIG_I2C_I810 is not set
925# CONFIG_I2C_PIIX4 is not set
926# CONFIG_I2C_MPC is not set
927# CONFIG_I2C_NFORCE2 is not set
928# CONFIG_I2C_OCORES is not set
929# CONFIG_I2C_PARPORT_LIGHT is not set
930# CONFIG_I2C_PROSAVAGE is not set
931# CONFIG_I2C_SAVAGE4 is not set
932# CONFIG_I2C_SIMTEC is not set
933# CONFIG_I2C_SIS5595 is not set
934# CONFIG_I2C_SIS630 is not set
935# CONFIG_I2C_SIS96X is not set
936# CONFIG_I2C_TINY_USB is not set
937# CONFIG_I2C_VIA is not set
938# CONFIG_I2C_VIAPRO is not set
939# CONFIG_I2C_VOODOO3 is not set
940CONFIG_I2C_MV64XXX=y
941
942#
943# Miscellaneous I2C Chip support
944#
945# CONFIG_SENSORS_DS1337 is not set
946# CONFIG_SENSORS_DS1374 is not set
947# CONFIG_SENSORS_EEPROM is not set
948# CONFIG_SENSORS_PCF8574 is not set
949# CONFIG_SENSORS_PCA9539 is not set
950# CONFIG_SENSORS_PCF8591 is not set
951# CONFIG_SENSORS_M41T00 is not set
952# CONFIG_SENSORS_MAX6875 is not set
953# CONFIG_I2C_DEBUG_CORE is not set
954# CONFIG_I2C_DEBUG_ALGO is not set
955# CONFIG_I2C_DEBUG_BUS is not set
956# CONFIG_I2C_DEBUG_CHIP is not set
957
958#
959# SPI support
960#
961# CONFIG_SPI is not set
962# CONFIG_SPI_MASTER is not set
963
964#
965# Dallas's 1-wire bus
966#
967# CONFIG_W1 is not set
968CONFIG_HWMON=y
969# CONFIG_HWMON_VID is not set
970# CONFIG_SENSORS_ABITUGURU is not set
971# CONFIG_SENSORS_AD7418 is not set
972# CONFIG_SENSORS_ADM1021 is not set
973# CONFIG_SENSORS_ADM1025 is not set
974# CONFIG_SENSORS_ADM1026 is not set
975# CONFIG_SENSORS_ADM1029 is not set
976# CONFIG_SENSORS_ADM1031 is not set
977# CONFIG_SENSORS_ADM9240 is not set
978# CONFIG_SENSORS_ASB100 is not set
979# CONFIG_SENSORS_ATXP1 is not set
980# CONFIG_SENSORS_DS1621 is not set
981# CONFIG_SENSORS_F71805F is not set
982# CONFIG_SENSORS_FSCHER is not set
983# CONFIG_SENSORS_FSCPOS is not set
984# CONFIG_SENSORS_GL518SM is not set
985# CONFIG_SENSORS_GL520SM is not set
986# CONFIG_SENSORS_IT87 is not set
987# CONFIG_SENSORS_LM63 is not set
988# CONFIG_SENSORS_LM75 is not set
989# CONFIG_SENSORS_LM77 is not set
990# CONFIG_SENSORS_LM78 is not set
991# CONFIG_SENSORS_LM80 is not set
992# CONFIG_SENSORS_LM83 is not set
993# CONFIG_SENSORS_LM85 is not set
994# CONFIG_SENSORS_LM87 is not set
995# CONFIG_SENSORS_LM90 is not set
996# CONFIG_SENSORS_LM92 is not set
997# CONFIG_SENSORS_MAX1619 is not set
998# CONFIG_SENSORS_MAX6650 is not set
999# CONFIG_SENSORS_PC87360 is not set
1000# CONFIG_SENSORS_PC87427 is not set
1001# CONFIG_SENSORS_SIS5595 is not set
1002# CONFIG_SENSORS_SMSC47M1 is not set
1003# CONFIG_SENSORS_SMSC47M192 is not set
1004# CONFIG_SENSORS_SMSC47B397 is not set
1005# CONFIG_SENSORS_VIA686A is not set
1006# CONFIG_SENSORS_VT1211 is not set
1007# CONFIG_SENSORS_VT8231 is not set
1008# CONFIG_SENSORS_W83781D is not set
1009# CONFIG_SENSORS_W83791D is not set
1010# CONFIG_SENSORS_W83792D is not set
1011# CONFIG_SENSORS_W83793 is not set
1012# CONFIG_SENSORS_W83L785TS is not set
1013# CONFIG_SENSORS_W83627HF is not set
1014# CONFIG_SENSORS_W83627EHF is not set
1015# CONFIG_HWMON_DEBUG_CHIP is not set
1016
1017#
1018# Multifunction device drivers
1019#
1020# CONFIG_MFD_SM501 is not set
1021
1022#
1023# Multimedia devices
1024#
1025# CONFIG_VIDEO_DEV is not set
1026
1027#
1028# Digital Video Broadcasting Devices
1029#
1030# CONFIG_DVB is not set
1031# CONFIG_USB_DABUSB is not set
1032
1033#
1034# Graphics support
1035#
1036# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
1037
1038#
1039# Display device support
1040#
1041# CONFIG_DISPLAY_SUPPORT is not set
1042# CONFIG_VGASTATE is not set
1043# CONFIG_FB is not set
1044# CONFIG_FB_IBM_GXT4500 is not set
1045
1046#
1047# Console display driver support
1048#
1049CONFIG_VGA_CONSOLE=y
1050# CONFIG_VGACON_SOFT_SCROLLBACK is not set
1051CONFIG_DUMMY_CONSOLE=y
1052
1053#
1054# Sound
1055#
1056# CONFIG_SOUND is not set
1057
1058#
1059# HID Devices
1060#
1061CONFIG_HID=y
1062# CONFIG_HID_DEBUG is not set
1063
1064#
1065# USB Input Devices
1066#
1067CONFIG_USB_HID=y
1068# CONFIG_USB_HIDINPUT_POWERBOOK is not set
1069# CONFIG_HID_FF is not set
1070# CONFIG_USB_HIDDEV is not set
1071
1072#
1073# USB support
1074#
1075CONFIG_USB_ARCH_HAS_HCD=y
1076CONFIG_USB_ARCH_HAS_OHCI=y
1077CONFIG_USB_ARCH_HAS_EHCI=y
1078CONFIG_USB=y
1079# CONFIG_USB_DEBUG is not set
1080
1081#
1082# Miscellaneous USB options
1083#
1084CONFIG_USB_DEVICEFS=y
1085# CONFIG_USB_DEVICE_CLASS is not set
1086# CONFIG_USB_DYNAMIC_MINORS is not set
1087# CONFIG_USB_OTG is not set
1088
1089#
1090# USB Host Controller Drivers
1091#
1092CONFIG_USB_EHCI_HCD=y
1093# CONFIG_USB_EHCI_SPLIT_ISO is not set
1094# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
1095# CONFIG_USB_EHCI_TT_NEWSCHED is not set
1096# CONFIG_USB_EHCI_BIG_ENDIAN_MMIO is not set
1097# CONFIG_USB_ISP116X_HCD is not set
1098CONFIG_USB_OHCI_HCD=y
1099# CONFIG_USB_OHCI_HCD_PPC_OF is not set
1100# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
1101# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
1102CONFIG_USB_OHCI_LITTLE_ENDIAN=y
1103# CONFIG_USB_UHCI_HCD is not set
1104# CONFIG_USB_SL811_HCD is not set
1105
1106#
1107# USB Device Class drivers
1108#
1109# CONFIG_USB_ACM is not set
1110# CONFIG_USB_PRINTER is not set
1111
1112#
1113# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
1114#
1115
1116#
1117# may also be needed; see USB_STORAGE Help for more information
1118#
1119# CONFIG_USB_STORAGE is not set
1120# CONFIG_USB_LIBUSUAL is not set
1121
1122#
1123# USB Imaging devices
1124#
1125# CONFIG_USB_MDC800 is not set
1126# CONFIG_USB_MICROTEK is not set
1127
1128#
1129# USB Network Adapters
1130#
1131# CONFIG_USB_CATC is not set
1132# CONFIG_USB_KAWETH is not set
1133# CONFIG_USB_PEGASUS is not set
1134# CONFIG_USB_RTL8150 is not set
1135# CONFIG_USB_USBNET_MII is not set
1136# CONFIG_USB_USBNET is not set
1137CONFIG_USB_MON=y
1138
1139#
1140# USB port drivers
1141#
1142
1143#
1144# USB Serial Converter support
1145#
1146# CONFIG_USB_SERIAL is not set
1147
1148#
1149# USB Miscellaneous drivers
1150#
1151# CONFIG_USB_EMI62 is not set
1152# CONFIG_USB_EMI26 is not set
1153# CONFIG_USB_ADUTUX is not set
1154# CONFIG_USB_AUERSWALD is not set
1155# CONFIG_USB_RIO500 is not set
1156# CONFIG_USB_LEGOTOWER is not set
1157# CONFIG_USB_LCD is not set
1158# CONFIG_USB_BERRY_CHARGE is not set
1159# CONFIG_USB_LED is not set
1160# CONFIG_USB_CYPRESS_CY7C63 is not set
1161# CONFIG_USB_CYTHERM is not set
1162# CONFIG_USB_PHIDGET is not set
1163# CONFIG_USB_IDMOUSE is not set
1164# CONFIG_USB_FTDI_ELAN is not set
1165# CONFIG_USB_APPLEDISPLAY is not set
1166# CONFIG_USB_SISUSBVGA is not set
1167# CONFIG_USB_LD is not set
1168# CONFIG_USB_TRANCEVIBRATOR is not set
1169# CONFIG_USB_IOWARRIOR is not set
1170# CONFIG_USB_TEST is not set
1171
1172#
1173# USB DSL modem support
1174#
1175
1176#
1177# USB Gadget Support
1178#
1179# CONFIG_USB_GADGET is not set
1180# CONFIG_MMC is not set
1181
1182#
1183# LED devices
1184#
1185# CONFIG_NEW_LEDS is not set
1186
1187#
1188# LED drivers
1189#
1190
1191#
1192# LED Triggers
1193#
1194
1195#
1196# InfiniBand support
1197#
1198# CONFIG_INFINIBAND is not set
1199
1200#
1201# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
1202#
1203
1204#
1205# Real Time Clock
1206#
1207CONFIG_RTC_LIB=y
1208CONFIG_RTC_CLASS=y
1209CONFIG_RTC_HCTOSYS=y
1210CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
1211# CONFIG_RTC_DEBUG is not set
1212
1213#
1214# RTC interfaces
1215#
1216CONFIG_RTC_INTF_SYSFS=y
1217CONFIG_RTC_INTF_PROC=y
1218CONFIG_RTC_INTF_DEV=y
1219# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
1220# CONFIG_RTC_DRV_TEST is not set
1221
1222#
1223# I2C RTC drivers
1224#
1225# CONFIG_RTC_DRV_DS1307 is not set
1226# CONFIG_RTC_DRV_DS1672 is not set
1227CONFIG_RTC_DRV_MAX6900=y
1228# CONFIG_RTC_DRV_RS5C372 is not set
1229# CONFIG_RTC_DRV_ISL1208 is not set
1230# CONFIG_RTC_DRV_X1205 is not set
1231# CONFIG_RTC_DRV_PCF8563 is not set
1232# CONFIG_RTC_DRV_PCF8583 is not set
1233
1234#
1235# SPI RTC drivers
1236#
1237
1238#
1239# Platform RTC drivers
1240#
1241# CONFIG_RTC_DRV_DS1553 is not set
1242# CONFIG_RTC_DRV_DS1742 is not set
1243# CONFIG_RTC_DRV_M48T86 is not set
1244# CONFIG_RTC_DRV_V3020 is not set
1245
1246#
1247# on-CPU RTC drivers
1248#
1249
1250#
1251# DMA Engine support
1252#
1253# CONFIG_DMA_ENGINE is not set
1254
1255#
1256# DMA Clients
1257#
1258
1259#
1260# DMA Devices
1261#
1262
1263#
1264# Auxiliary Display support
1265#
1266
1267#
1268# Virtualization
1269#
1270
1271#
1272# File systems
1273#
1274CONFIG_EXT2_FS=y
1275# CONFIG_EXT2_FS_XATTR is not set
1276# CONFIG_EXT2_FS_XIP is not set
1277CONFIG_EXT3_FS=y
1278CONFIG_EXT3_FS_XATTR=y
1279# CONFIG_EXT3_FS_POSIX_ACL is not set
1280# CONFIG_EXT3_FS_SECURITY is not set
1281# CONFIG_EXT4DEV_FS is not set
1282CONFIG_JBD=y
1283# CONFIG_JBD_DEBUG is not set
1284CONFIG_FS_MBCACHE=y
1285# CONFIG_REISERFS_FS is not set
1286# CONFIG_JFS_FS is not set
1287# CONFIG_FS_POSIX_ACL is not set
1288# CONFIG_XFS_FS is not set
1289# CONFIG_GFS2_FS is not set
1290# CONFIG_OCFS2_FS is not set
1291# CONFIG_MINIX_FS is not set
1292# CONFIG_ROMFS_FS is not set
1293CONFIG_INOTIFY=y
1294CONFIG_INOTIFY_USER=y
1295# CONFIG_QUOTA is not set
1296CONFIG_DNOTIFY=y
1297# CONFIG_AUTOFS_FS is not set
1298# CONFIG_AUTOFS4_FS is not set
1299# CONFIG_FUSE_FS is not set
1300
1301#
1302# CD-ROM/DVD Filesystems
1303#
1304# CONFIG_ISO9660_FS is not set
1305# CONFIG_UDF_FS is not set
1306
1307#
1308# DOS/FAT/NT Filesystems
1309#
1310# CONFIG_MSDOS_FS is not set
1311# CONFIG_VFAT_FS is not set
1312# CONFIG_NTFS_FS is not set
1313
1314#
1315# Pseudo filesystems
1316#
1317CONFIG_PROC_FS=y
1318CONFIG_PROC_KCORE=y
1319CONFIG_PROC_SYSCTL=y
1320CONFIG_SYSFS=y
1321CONFIG_TMPFS=y
1322# CONFIG_TMPFS_POSIX_ACL is not set
1323# CONFIG_HUGETLB_PAGE is not set
1324CONFIG_RAMFS=y
1325# CONFIG_CONFIGFS_FS is not set
1326
1327#
1328# Miscellaneous filesystems
1329#
1330# CONFIG_ADFS_FS is not set
1331# CONFIG_AFFS_FS is not set
1332# CONFIG_HFS_FS is not set
1333# CONFIG_HFSPLUS_FS is not set
1334# CONFIG_BEFS_FS is not set
1335# CONFIG_BFS_FS is not set
1336# CONFIG_EFS_FS is not set
1337# CONFIG_JFFS2_FS is not set
1338# CONFIG_CRAMFS is not set
1339# CONFIG_VXFS_FS is not set
1340# CONFIG_HPFS_FS is not set
1341# CONFIG_QNX4FS_FS is not set
1342# CONFIG_SYSV_FS is not set
1343# CONFIG_UFS_FS is not set
1344
1345#
1346# Network File Systems
1347#
1348CONFIG_NFS_FS=y
1349# CONFIG_NFS_V3 is not set
1350# CONFIG_NFS_V4 is not set
1351# CONFIG_NFS_DIRECTIO is not set
1352# CONFIG_NFSD is not set
1353CONFIG_ROOT_NFS=y
1354CONFIG_LOCKD=y
1355CONFIG_NFS_COMMON=y
1356CONFIG_SUNRPC=y
1357# CONFIG_SUNRPC_BIND34 is not set
1358# CONFIG_RPCSEC_GSS_KRB5 is not set
1359# CONFIG_RPCSEC_GSS_SPKM3 is not set
1360# CONFIG_SMB_FS is not set
1361# CONFIG_CIFS is not set
1362# CONFIG_NCP_FS is not set
1363# CONFIG_CODA_FS is not set
1364# CONFIG_AFS_FS is not set
1365# CONFIG_9P_FS is not set
1366
1367#
1368# Partition Types
1369#
1370CONFIG_PARTITION_ADVANCED=y
1371# CONFIG_ACORN_PARTITION is not set
1372# CONFIG_OSF_PARTITION is not set
1373# CONFIG_AMIGA_PARTITION is not set
1374# CONFIG_ATARI_PARTITION is not set
1375# CONFIG_MAC_PARTITION is not set
1376CONFIG_MSDOS_PARTITION=y
1377# CONFIG_BSD_DISKLABEL is not set
1378# CONFIG_MINIX_SUBPARTITION is not set
1379# CONFIG_SOLARIS_X86_PARTITION is not set
1380# CONFIG_UNIXWARE_DISKLABEL is not set
1381# CONFIG_LDM_PARTITION is not set
1382# CONFIG_SGI_PARTITION is not set
1383# CONFIG_ULTRIX_PARTITION is not set
1384# CONFIG_SUN_PARTITION is not set
1385# CONFIG_KARMA_PARTITION is not set
1386# CONFIG_EFI_PARTITION is not set
1387# CONFIG_SYSV68_PARTITION is not set
1388
1389#
1390# Native Language Support
1391#
1392# CONFIG_NLS is not set
1393
1394#
1395# Distributed Lock Manager
1396#
1397# CONFIG_DLM is not set
1398# CONFIG_UCC_SLOW is not set
1399# CONFIG_UCC_FAST is not set
1400
1401#
1402# Library routines
1403#
1404CONFIG_BITREVERSE=y
1405# CONFIG_CRC_CCITT is not set
1406# CONFIG_CRC16 is not set
1407CONFIG_CRC32=y
1408# CONFIG_LIBCRC32C is not set
1409CONFIG_PLIST=y
1410CONFIG_HAS_IOMEM=y
1411CONFIG_HAS_IOPORT=y
1412CONFIG_HAS_DMA=y
1413
1414#
1415# Instrumentation Support
1416#
1417# CONFIG_PROFILING is not set
1418
1419#
1420# Kernel hacking
1421#
1422# CONFIG_PRINTK_TIME is not set
1423CONFIG_ENABLE_MUST_CHECK=y
1424# CONFIG_MAGIC_SYSRQ is not set
1425# CONFIG_UNUSED_SYMBOLS is not set
1426# CONFIG_DEBUG_FS is not set
1427# CONFIG_HEADERS_CHECK is not set
1428# CONFIG_DEBUG_KERNEL is not set
1429CONFIG_DEBUG_BUGVERBOSE=y
1430# CONFIG_BOOTX_TEXT is not set
1431# CONFIG_PPC_EARLY_DEBUG is not set
1432
1433#
1434# Security options
1435#
1436# CONFIG_KEYS is not set
1437# CONFIG_SECURITY is not set
1438
1439#
1440# Cryptographic options
1441#
1442# CONFIG_CRYPTO is not set
diff --git a/arch/powerpc/configs/ps3_defconfig b/arch/powerpc/configs/ps3_defconfig
index fd604968f9a2..477934558f06 100644
--- a/arch/powerpc/configs/ps3_defconfig
+++ b/arch/powerpc/configs/ps3_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.21 3# Linux kernel version: 2.6.21
4# Mon Apr 30 12:03:35 2007 4# Fri May 11 10:16:27 2007
5# 5#
6CONFIG_PPC64=y 6CONFIG_PPC64=y
7CONFIG_64BIT=y 7CONFIG_64BIT=y
@@ -40,6 +40,7 @@ CONFIG_PPC_FPU=y
40# CONFIG_PPC_OF_PLATFORM_PCI is not set 40# CONFIG_PPC_OF_PLATFORM_PCI is not set
41CONFIG_ALTIVEC=y 41CONFIG_ALTIVEC=y
42CONFIG_PPC_STD_MMU=y 42CONFIG_PPC_STD_MMU=y
43# CONFIG_PPC_MM_SLICES is not set
43CONFIG_VIRT_CPU_ACCOUNTING=y 44CONFIG_VIRT_CPU_ACCOUNTING=y
44CONFIG_SMP=y 45CONFIG_SMP=y
45CONFIG_NR_CPUS=2 46CONFIG_NR_CPUS=2
@@ -67,6 +68,7 @@ CONFIG_SYSVIPC_SYSCTL=y
67# CONFIG_UTS_NS is not set 68# CONFIG_UTS_NS is not set
68# CONFIG_AUDIT is not set 69# CONFIG_AUDIT is not set
69# CONFIG_IKCONFIG is not set 70# CONFIG_IKCONFIG is not set
71CONFIG_LOG_BUF_SHIFT=17
70# CONFIG_CPUSETS is not set 72# CONFIG_CPUSETS is not set
71CONFIG_SYSFS_DEPRECATED=y 73CONFIG_SYSFS_DEPRECATED=y
72# CONFIG_RELAY is not set 74# CONFIG_RELAY is not set
@@ -87,12 +89,13 @@ CONFIG_BASE_FULL=y
87CONFIG_FUTEX=y 89CONFIG_FUTEX=y
88CONFIG_EPOLL=y 90CONFIG_EPOLL=y
89CONFIG_SHMEM=y 91CONFIG_SHMEM=y
90CONFIG_SLAB=y
91CONFIG_VM_EVENT_COUNTERS=y 92CONFIG_VM_EVENT_COUNTERS=y
93CONFIG_SLAB=y
94# CONFIG_SLUB is not set
95# CONFIG_SLOB is not set
92CONFIG_RT_MUTEXES=y 96CONFIG_RT_MUTEXES=y
93# CONFIG_TINY_SHMEM is not set 97# CONFIG_TINY_SHMEM is not set
94CONFIG_BASE_SMALL=0 98CONFIG_BASE_SMALL=0
95# CONFIG_SLOB is not set
96 99
97# 100#
98# Loadable module support 101# Loadable module support
@@ -213,6 +216,7 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
213CONFIG_RESOURCES_64BIT=y 216CONFIG_RESOURCES_64BIT=y
214CONFIG_ZONE_DMA_FLAG=1 217CONFIG_ZONE_DMA_FLAG=1
215CONFIG_ARCH_MEMORY_PROBE=y 218CONFIG_ARCH_MEMORY_PROBE=y
219# CONFIG_PPC_HAS_HASH_64K is not set
216# CONFIG_PPC_64K_PAGES is not set 220# CONFIG_PPC_64K_PAGES is not set
217# CONFIG_SCHED_SMT is not set 221# CONFIG_SCHED_SMT is not set
218CONFIG_PROC_DEVICETREE=y 222CONFIG_PROC_DEVICETREE=y
@@ -229,15 +233,12 @@ CONFIG_ZONE_DMA=y
229CONFIG_GENERIC_ISA_DMA=y 233CONFIG_GENERIC_ISA_DMA=y
230# CONFIG_PCI is not set 234# CONFIG_PCI is not set
231# CONFIG_PCI_DOMAINS is not set 235# CONFIG_PCI_DOMAINS is not set
236# CONFIG_ARCH_SUPPORTS_MSI is not set
232 237
233# 238#
234# PCCARD (PCMCIA/CardBus) support 239# PCCARD (PCMCIA/CardBus) support
235# 240#
236# CONFIG_PCCARD is not set 241# CONFIG_PCCARD is not set
237
238#
239# PCI Hotplug Support
240#
241CONFIG_KERNEL_START=0xc000000000000000 242CONFIG_KERNEL_START=0xc000000000000000
242 243
243# 244#
@@ -363,7 +364,9 @@ CONFIG_BT_HCIUSB_SCO=y
363# 364#
364# CONFIG_CFG80211 is not set 365# CONFIG_CFG80211 is not set
365CONFIG_WIRELESS_EXT=y 366CONFIG_WIRELESS_EXT=y
367# CONFIG_MAC80211 is not set
366# CONFIG_IEEE80211 is not set 368# CONFIG_IEEE80211 is not set
369# CONFIG_RFKILL is not set
367 370
368# 371#
369# Device Drivers 372# Device Drivers
@@ -414,6 +417,7 @@ CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
414# 417#
415# Misc devices 418# Misc devices
416# 419#
420# CONFIG_BLINK is not set
417 421
418# 422#
419# ATA/ATAPI/MFM/RLL support 423# ATA/ATAPI/MFM/RLL support
@@ -447,6 +451,7 @@ CONFIG_CHR_DEV_SG=m
447# CONFIG_SCSI_CONSTANTS is not set 451# CONFIG_SCSI_CONSTANTS is not set
448# CONFIG_SCSI_LOGGING is not set 452# CONFIG_SCSI_LOGGING is not set
449# CONFIG_SCSI_SCAN_ASYNC is not set 453# CONFIG_SCSI_SCAN_ASYNC is not set
454CONFIG_SCSI_WAIT_SCAN=m
450 455
451# 456#
452# SCSI Transports 457# SCSI Transports
@@ -473,25 +478,7 @@ CONFIG_CHR_DEV_SG=m
473# Multi-device support (RAID and LVM) 478# Multi-device support (RAID and LVM)
474# 479#
475# CONFIG_MD is not set 480# CONFIG_MD is not set
476 481# CONFIG_MACINTOSH_DRIVERS is not set
477#
478# Fusion MPT device support
479#
480# CONFIG_FUSION is not set
481
482#
483# IEEE 1394 (FireWire) support
484#
485
486#
487# I2O device support
488#
489
490#
491# Macintosh device drivers
492#
493# CONFIG_MAC_EMUMOUSEBTN is not set
494# CONFIG_WINDFARM is not set
495 482
496# 483#
497# Network device support 484# Network device support
@@ -519,6 +506,7 @@ CONFIG_MII=m
519# 506#
520# Ethernet (10000 Mbit) 507# Ethernet (10000 Mbit)
521# 508#
509CONFIG_MLX4_DEBUG=y
522 510
523# 511#
524# Token Ring devices 512# Token Ring devices
@@ -531,6 +519,25 @@ CONFIG_MII=m
531# CONFIG_WLAN_80211 is not set 519# CONFIG_WLAN_80211 is not set
532 520
533# 521#
522# USB Network Adapters
523#
524# CONFIG_USB_CATC is not set
525# CONFIG_USB_KAWETH is not set
526CONFIG_USB_PEGASUS=m
527# CONFIG_USB_RTL8150 is not set
528CONFIG_USB_USBNET_MII=m
529CONFIG_USB_USBNET=m
530# CONFIG_USB_NET_CDCETHER is not set
531# CONFIG_USB_NET_DM9601 is not set
532# CONFIG_USB_NET_GL620A is not set
533# CONFIG_USB_NET_NET1080 is not set
534# CONFIG_USB_NET_PLUSB is not set
535CONFIG_USB_NET_MCS7830=m
536# CONFIG_USB_NET_RNDIS_HOST is not set
537# CONFIG_USB_NET_CDC_SUBSET is not set
538# CONFIG_USB_NET_ZAURUS is not set
539
540#
534# Wan interfaces 541# Wan interfaces
535# 542#
536# CONFIG_WAN is not set 543# CONFIG_WAN is not set
@@ -575,6 +582,7 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
575# CONFIG_INPUT_KEYBOARD is not set 582# CONFIG_INPUT_KEYBOARD is not set
576# CONFIG_INPUT_MOUSE is not set 583# CONFIG_INPUT_MOUSE is not set
577# CONFIG_INPUT_JOYSTICK is not set 584# CONFIG_INPUT_JOYSTICK is not set
585# CONFIG_INPUT_TABLET is not set
578# CONFIG_INPUT_TOUCHSCREEN is not set 586# CONFIG_INPUT_TOUCHSCREEN is not set
579# CONFIG_INPUT_MISC is not set 587# CONFIG_INPUT_MISC is not set
580 588
@@ -609,15 +617,10 @@ CONFIG_LEGACY_PTY_COUNT=16
609# IPMI 617# IPMI
610# 618#
611# CONFIG_IPMI_HANDLER is not set 619# CONFIG_IPMI_HANDLER is not set
612
613#
614# Watchdog Cards
615#
616# CONFIG_WATCHDOG is not set 620# CONFIG_WATCHDOG is not set
617# CONFIG_HW_RANDOM is not set 621# CONFIG_HW_RANDOM is not set
618CONFIG_GEN_RTC=y 622CONFIG_GEN_RTC=y
619# CONFIG_GEN_RTC_X is not set 623# CONFIG_GEN_RTC_X is not set
620# CONFIG_DTLK is not set
621# CONFIG_R3964 is not set 624# CONFIG_R3964 is not set
622# CONFIG_RAW_DRIVER is not set 625# CONFIG_RAW_DRIVER is not set
623# CONFIG_HANGCHECK_TIMER is not set 626# CONFIG_HANGCHECK_TIMER is not set
@@ -626,10 +629,6 @@ CONFIG_GEN_RTC=y
626# TPM devices 629# TPM devices
627# 630#
628# CONFIG_TCG_TPM is not set 631# CONFIG_TCG_TPM is not set
629
630#
631# I2C support
632#
633# CONFIG_I2C is not set 632# CONFIG_I2C is not set
634 633
635# 634#
@@ -642,12 +641,7 @@ CONFIG_GEN_RTC=y
642# Dallas's 1-wire bus 641# Dallas's 1-wire bus
643# 642#
644# CONFIG_W1 is not set 643# CONFIG_W1 is not set
645
646#
647# Hardware Monitoring support
648#
649# CONFIG_HWMON is not set 644# CONFIG_HWMON is not set
650# CONFIG_HWMON_VID is not set
651 645
652# 646#
653# Multifunction device drivers 647# Multifunction device drivers
@@ -669,12 +663,23 @@ CONFIG_GEN_RTC=y
669# Graphics support 663# Graphics support
670# 664#
671# CONFIG_BACKLIGHT_LCD_SUPPORT is not set 665# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
666
667#
668# Display device support
669#
670# CONFIG_DISPLAY_SUPPORT is not set
671# CONFIG_VGASTATE is not set
672CONFIG_FB=y 672CONFIG_FB=y
673# CONFIG_FIRMWARE_EDID is not set 673# CONFIG_FIRMWARE_EDID is not set
674# CONFIG_FB_DDC is not set 674# CONFIG_FB_DDC is not set
675CONFIG_FB_CFB_FILLRECT=y 675CONFIG_FB_CFB_FILLRECT=y
676CONFIG_FB_CFB_COPYAREA=y 676CONFIG_FB_CFB_COPYAREA=y
677CONFIG_FB_CFB_IMAGEBLIT=y 677CONFIG_FB_CFB_IMAGEBLIT=y
678# CONFIG_FB_SYS_FILLRECT is not set
679# CONFIG_FB_SYS_COPYAREA is not set
680# CONFIG_FB_SYS_IMAGEBLIT is not set
681# CONFIG_FB_SYS_FOPS is not set
682CONFIG_FB_DEFERRED_IO=y
678# CONFIG_FB_SVGALIB is not set 683# CONFIG_FB_SVGALIB is not set
679# CONFIG_FB_MACMODES is not set 684# CONFIG_FB_MACMODES is not set
680# CONFIG_FB_BACKLIGHT is not set 685# CONFIG_FB_BACKLIGHT is not set
@@ -702,10 +707,6 @@ CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
702# CONFIG_FONTS is not set 707# CONFIG_FONTS is not set
703CONFIG_FONT_8x8=y 708CONFIG_FONT_8x8=y
704CONFIG_FONT_8x16=y 709CONFIG_FONT_8x16=y
705
706#
707# Logo configuration
708#
709CONFIG_LOGO=y 710CONFIG_LOGO=y
710# CONFIG_LOGO_LINUX_MONO is not set 711# CONFIG_LOGO_LINUX_MONO is not set
711# CONFIG_LOGO_LINUX_VGA16 is not set 712# CONFIG_LOGO_LINUX_VGA16 is not set
@@ -768,6 +769,20 @@ CONFIG_HID=y
768# CONFIG_HID_DEBUG is not set 769# CONFIG_HID_DEBUG is not set
769 770
770# 771#
772# USB Input Devices
773#
774CONFIG_USB_HID=m
775# CONFIG_USB_HIDINPUT_POWERBOOK is not set
776# CONFIG_HID_FF is not set
777# CONFIG_USB_HIDDEV is not set
778
779#
780# USB HID Boot Protocol drivers
781#
782# CONFIG_USB_KBD is not set
783# CONFIG_USB_MOUSE is not set
784
785#
771# USB support 786# USB support
772# 787#
773CONFIG_USB_ARCH_HAS_HCD=y 788CONFIG_USB_ARCH_HAS_HCD=y
@@ -827,56 +842,10 @@ CONFIG_USB_STORAGE=m
827# CONFIG_USB_LIBUSUAL is not set 842# CONFIG_USB_LIBUSUAL is not set
828 843
829# 844#
830# USB Input Devices
831#
832CONFIG_USB_HID=m
833# CONFIG_USB_HIDINPUT_POWERBOOK is not set
834# CONFIG_HID_FF is not set
835# CONFIG_USB_HIDDEV is not set
836
837#
838# USB HID Boot Protocol drivers
839#
840# CONFIG_USB_KBD is not set
841# CONFIG_USB_MOUSE is not set
842# CONFIG_USB_AIPTEK is not set
843# CONFIG_USB_WACOM is not set
844# CONFIG_USB_ACECAD is not set
845# CONFIG_USB_KBTAB is not set
846# CONFIG_USB_POWERMATE is not set
847# CONFIG_USB_TOUCHSCREEN is not set
848# CONFIG_USB_YEALINK is not set
849# CONFIG_USB_XPAD is not set
850# CONFIG_USB_ATI_REMOTE is not set
851# CONFIG_USB_ATI_REMOTE2 is not set
852# CONFIG_USB_KEYSPAN_REMOTE is not set
853# CONFIG_USB_APPLETOUCH is not set
854# CONFIG_USB_GTCO is not set
855
856#
857# USB Imaging devices 845# USB Imaging devices
858# 846#
859# CONFIG_USB_MDC800 is not set 847# CONFIG_USB_MDC800 is not set
860# CONFIG_USB_MICROTEK is not set 848# CONFIG_USB_MICROTEK is not set
861
862#
863# USB Network Adapters
864#
865# CONFIG_USB_CATC is not set
866# CONFIG_USB_KAWETH is not set
867CONFIG_USB_PEGASUS=m
868# CONFIG_USB_RTL8150 is not set
869CONFIG_USB_USBNET_MII=m
870CONFIG_USB_USBNET=m
871# CONFIG_USB_NET_CDCETHER is not set
872# CONFIG_USB_NET_DM9601 is not set
873# CONFIG_USB_NET_GL620A is not set
874# CONFIG_USB_NET_NET1080 is not set
875# CONFIG_USB_NET_PLUSB is not set
876CONFIG_USB_NET_MCS7830=m
877# CONFIG_USB_NET_RNDIS_HOST is not set
878# CONFIG_USB_NET_CDC_SUBSET is not set
879# CONFIG_USB_NET_ZAURUS is not set
880CONFIG_USB_MON=y 849CONFIG_USB_MON=y
881 850
882# 851#
@@ -920,10 +889,6 @@ CONFIG_USB_MON=y
920# USB Gadget Support 889# USB Gadget Support
921# 890#
922# CONFIG_USB_GADGET is not set 891# CONFIG_USB_GADGET is not set
923
924#
925# MMC/SD Card support
926#
927# CONFIG_MMC is not set 892# CONFIG_MMC is not set
928 893
929# 894#
@@ -966,14 +931,6 @@ CONFIG_USB_MON=y
966# 931#
967 932
968# 933#
969# Auxiliary Display support
970#
971
972#
973# Virtualization
974#
975
976#
977# File systems 934# File systems
978# 935#
979CONFIG_EXT2_FS=m 936CONFIG_EXT2_FS=m
@@ -1071,6 +1028,7 @@ CONFIG_LOCKD_V4=y
1071CONFIG_NFS_COMMON=y 1028CONFIG_NFS_COMMON=y
1072CONFIG_SUNRPC=y 1029CONFIG_SUNRPC=y
1073CONFIG_SUNRPC_GSS=y 1030CONFIG_SUNRPC_GSS=y
1031# CONFIG_SUNRPC_BIND34 is not set
1074CONFIG_RPCSEC_GSS_KRB5=y 1032CONFIG_RPCSEC_GSS_KRB5=y
1075# CONFIG_RPCSEC_GSS_SPKM3 is not set 1033# CONFIG_RPCSEC_GSS_SPKM3 is not set
1076# CONFIG_SMB_FS is not set 1034# CONFIG_SMB_FS is not set
@@ -1148,11 +1106,13 @@ CONFIG_NLS_ISO8859_1=y
1148CONFIG_BITREVERSE=y 1106CONFIG_BITREVERSE=y
1149# CONFIG_CRC_CCITT is not set 1107# CONFIG_CRC_CCITT is not set
1150# CONFIG_CRC16 is not set 1108# CONFIG_CRC16 is not set
1109# CONFIG_CRC_ITU_T is not set
1151CONFIG_CRC32=y 1110CONFIG_CRC32=y
1152# CONFIG_LIBCRC32C is not set 1111# CONFIG_LIBCRC32C is not set
1153CONFIG_PLIST=y 1112CONFIG_PLIST=y
1154CONFIG_HAS_IOMEM=y 1113CONFIG_HAS_IOMEM=y
1155CONFIG_HAS_IOPORT=y 1114CONFIG_HAS_IOPORT=y
1115CONFIG_HAS_DMA=y
1156 1116
1157# 1117#
1158# Instrumentation Support 1118# Instrumentation Support
@@ -1171,7 +1131,6 @@ CONFIG_ENABLE_MUST_CHECK=y
1171# CONFIG_HEADERS_CHECK is not set 1131# CONFIG_HEADERS_CHECK is not set
1172CONFIG_DEBUG_KERNEL=y 1132CONFIG_DEBUG_KERNEL=y
1173# CONFIG_DEBUG_SHIRQ is not set 1133# CONFIG_DEBUG_SHIRQ is not set
1174CONFIG_LOG_BUF_SHIFT=17
1175CONFIG_DETECT_SOFTLOCKUP=y 1134CONFIG_DETECT_SOFTLOCKUP=y
1176# CONFIG_SCHEDSTATS is not set 1135# CONFIG_SCHEDSTATS is not set
1177# CONFIG_TIMER_STATS is not set 1136# CONFIG_TIMER_STATS is not set
@@ -1205,6 +1164,7 @@ CONFIG_PPC_EARLY_DEBUG=y
1205# CONFIG_PPC_EARLY_DEBUG_ISERIES is not set 1164# CONFIG_PPC_EARLY_DEBUG_ISERIES is not set
1206# CONFIG_PPC_EARLY_DEBUG_PAS_REALMODE is not set 1165# CONFIG_PPC_EARLY_DEBUG_PAS_REALMODE is not set
1207# CONFIG_PPC_EARLY_DEBUG_BEAT is not set 1166# CONFIG_PPC_EARLY_DEBUG_BEAT is not set
1167# CONFIG_PPC_EARLY_DEBUG_44x is not set
1208 1168
1209# 1169#
1210# Security options 1170# Security options
@@ -1234,6 +1194,7 @@ CONFIG_CRYPTO_ECB=m
1234CONFIG_CRYPTO_CBC=y 1194CONFIG_CRYPTO_CBC=y
1235CONFIG_CRYPTO_PCBC=m 1195CONFIG_CRYPTO_PCBC=m
1236# CONFIG_CRYPTO_LRW is not set 1196# CONFIG_CRYPTO_LRW is not set
1197# CONFIG_CRYPTO_CRYPTD is not set
1237CONFIG_CRYPTO_DES=y 1198CONFIG_CRYPTO_DES=y
1238# CONFIG_CRYPTO_FCRYPT is not set 1199# CONFIG_CRYPTO_FCRYPT is not set
1239# CONFIG_CRYPTO_BLOWFISH is not set 1200# CONFIG_CRYPTO_BLOWFISH is not set
diff --git a/arch/powerpc/kernel/audit.c b/arch/powerpc/kernel/audit.c
index 7fe5e6300e9a..a4dab7cab348 100644
--- a/arch/powerpc/kernel/audit.c
+++ b/arch/powerpc/kernel/audit.c
@@ -23,6 +23,20 @@ static unsigned chattr_class[] = {
23~0U 23~0U
24}; 24};
25 25
26static unsigned signal_class[] = {
27#include <asm-generic/audit_signal.h>
28~0U
29};
30
31int audit_classify_arch(int arch)
32{
33#ifdef CONFIG_PPC64
34 if (arch == AUDIT_ARCH_PPC)
35 return 1;
36#endif
37 return 0;
38}
39
26int audit_classify_syscall(int abi, unsigned syscall) 40int audit_classify_syscall(int abi, unsigned syscall)
27{ 41{
28#ifdef CONFIG_PPC64 42#ifdef CONFIG_PPC64
@@ -51,15 +65,18 @@ static int __init audit_classes_init(void)
51 extern __u32 ppc32_write_class[]; 65 extern __u32 ppc32_write_class[];
52 extern __u32 ppc32_read_class[]; 66 extern __u32 ppc32_read_class[];
53 extern __u32 ppc32_chattr_class[]; 67 extern __u32 ppc32_chattr_class[];
68 extern __u32 ppc32_signal_class[];
54 audit_register_class(AUDIT_CLASS_WRITE_32, ppc32_write_class); 69 audit_register_class(AUDIT_CLASS_WRITE_32, ppc32_write_class);
55 audit_register_class(AUDIT_CLASS_READ_32, ppc32_read_class); 70 audit_register_class(AUDIT_CLASS_READ_32, ppc32_read_class);
56 audit_register_class(AUDIT_CLASS_DIR_WRITE_32, ppc32_dir_class); 71 audit_register_class(AUDIT_CLASS_DIR_WRITE_32, ppc32_dir_class);
57 audit_register_class(AUDIT_CLASS_CHATTR_32, ppc32_chattr_class); 72 audit_register_class(AUDIT_CLASS_CHATTR_32, ppc32_chattr_class);
73 audit_register_class(AUDIT_CLASS_SIGNAL_32, ppc32_signal_class);
58#endif 74#endif
59 audit_register_class(AUDIT_CLASS_WRITE, write_class); 75 audit_register_class(AUDIT_CLASS_WRITE, write_class);
60 audit_register_class(AUDIT_CLASS_READ, read_class); 76 audit_register_class(AUDIT_CLASS_READ, read_class);
61 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class); 77 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
62 audit_register_class(AUDIT_CLASS_CHATTR, chattr_class); 78 audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
79 audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
63 return 0; 80 return 0;
64} 81}
65 82
diff --git a/arch/powerpc/kernel/compat_audit.c b/arch/powerpc/kernel/compat_audit.c
index 640d4bb29321..108ff14e2122 100644
--- a/arch/powerpc/kernel/compat_audit.c
+++ b/arch/powerpc/kernel/compat_audit.c
@@ -21,6 +21,11 @@ unsigned ppc32_read_class[] = {
21~0U 21~0U
22}; 22};
23 23
24unsigned ppc32_signal_class[] = {
25#include <asm-generic/audit_signal.h>
26~0U
27};
28
24int ppc32_classify_syscall(unsigned syscall) 29int ppc32_classify_syscall(unsigned syscall)
25{ 30{
26 switch(syscall) { 31 switch(syscall) {
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 9ed4931af164..068377a2a8dc 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -173,7 +173,7 @@ void local_irq_restore(unsigned long en)
173 lv1_get_version_info(&tmp); 173 lv1_get_version_info(&tmp);
174 } 174 }
175 175
176 hard_irq_enable(); 176 __hard_irq_enable();
177} 177}
178#endif /* CONFIG_PPC64 */ 178#endif /* CONFIG_PPC64 */
179 179
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c
index b5c96af955c6..3786dcc8a7b6 100644
--- a/arch/powerpc/kernel/prom_parse.c
+++ b/arch/powerpc/kernel/prom_parse.c
@@ -24,7 +24,7 @@
24/* Max address size we deal with */ 24/* Max address size we deal with */
25#define OF_MAX_ADDR_CELLS 4 25#define OF_MAX_ADDR_CELLS 4
26#define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \ 26#define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \
27 (ns) > 0) 27 (ns) >= 0)
28 28
29static struct of_bus *of_match_bus(struct device_node *np); 29static struct of_bus *of_match_bus(struct device_node *np);
30static int __of_address_to_resource(struct device_node *dev, 30static int __of_address_to_resource(struct device_node *dev,
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 370803722e47..ed07a198f8d6 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -530,3 +530,44 @@ void __init setup_panic(void)
530{ 530{
531 atomic_notifier_chain_register(&panic_notifier_list, &ppc_panic_block); 531 atomic_notifier_chain_register(&panic_notifier_list, &ppc_panic_block);
532} 532}
533
534#ifdef CONFIG_CHECK_CACHE_COHERENCY
535/*
536 * For platforms that have configurable cache-coherency. This function
537 * checks that the cache coherency setting of the kernel matches the setting
538 * left by the firmware, as indicated in the device tree. Since a mismatch
539 * will eventually result in DMA failures, we print * and error and call
540 * BUG() in that case.
541 */
542
543#ifdef CONFIG_NOT_COHERENT_CACHE
544#define KERNEL_COHERENCY 0
545#else
546#define KERNEL_COHERENCY 1
547#endif
548
549static int __init check_cache_coherency(void)
550{
551 struct device_node *np;
552 const void *prop;
553 int devtree_coherency;
554
555 np = of_find_node_by_path("/");
556 prop = of_get_property(np, "coherency-off", NULL);
557 of_node_put(np);
558
559 devtree_coherency = prop ? 0 : 1;
560
561 if (devtree_coherency != KERNEL_COHERENCY) {
562 printk(KERN_ERR
563 "kernel coherency:%s != device tree_coherency:%s\n",
564 KERNEL_COHERENCY ? "on" : "off",
565 devtree_coherency ? "on" : "off");
566 BUG();
567 }
568
569 return 0;
570}
571
572late_initcall(check_cache_coherency);
573#endif /* CONFIG_CHECK_CACHE_COHERENCY */
diff --git a/arch/powerpc/kernel/swsusp.c b/arch/powerpc/kernel/swsusp.c
index 064a7ba4f02c..77b7b34b5955 100644
--- a/arch/powerpc/kernel/swsusp.c
+++ b/arch/powerpc/kernel/swsusp.c
@@ -36,8 +36,4 @@ void restore_processor_state(void)
36#ifdef CONFIG_PPC32 36#ifdef CONFIG_PPC32
37 set_context(current->active_mm->context.id, current->active_mm->pgd); 37 set_context(current->active_mm->context.id, current->active_mm->pgd);
38#endif 38#endif
39
40#ifdef CONFIG_PPC64
41 hard_irq_enable();
42#endif
43} 39}
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 7cedef8f5f70..2c8564d54e4d 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -711,30 +711,15 @@ void wakeup_decrementer(void)
711void __init smp_space_timers(unsigned int max_cpus) 711void __init smp_space_timers(unsigned int max_cpus)
712{ 712{
713 int i; 713 int i;
714 unsigned long half = tb_ticks_per_jiffy / 2;
715 unsigned long offset = tb_ticks_per_jiffy / max_cpus;
716 u64 previous_tb = per_cpu(last_jiffy, boot_cpuid); 714 u64 previous_tb = per_cpu(last_jiffy, boot_cpuid);
717 715
718 /* make sure tb > per_cpu(last_jiffy, cpu) for all cpus always */ 716 /* make sure tb > per_cpu(last_jiffy, cpu) for all cpus always */
719 previous_tb -= tb_ticks_per_jiffy; 717 previous_tb -= tb_ticks_per_jiffy;
720 /* 718
721 * The stolen time calculation for POWER5 shared-processor LPAR
722 * systems works better if the two threads' timebase interrupts
723 * are staggered by half a jiffy with respect to each other.
724 */
725 for_each_possible_cpu(i) { 719 for_each_possible_cpu(i) {
726 if (i == boot_cpuid) 720 if (i == boot_cpuid)
727 continue; 721 continue;
728 if (i == (boot_cpuid ^ 1)) 722 per_cpu(last_jiffy, i) = previous_tb;
729 per_cpu(last_jiffy, i) =
730 per_cpu(last_jiffy, boot_cpuid) - half;
731 else if (i & 1)
732 per_cpu(last_jiffy, i) =
733 per_cpu(last_jiffy, i ^ 1) + half;
734 else {
735 previous_tb += offset;
736 per_cpu(last_jiffy, i) = previous_tb;
737 }
738 } 723 }
739} 724}
740#endif 725#endif
diff --git a/arch/powerpc/mm/hash_native_64.c b/arch/powerpc/mm/hash_native_64.c
index 7d722eea4ea8..4a20d890e2f4 100644
--- a/arch/powerpc/mm/hash_native_64.c
+++ b/arch/powerpc/mm/hash_native_64.c
@@ -351,7 +351,7 @@ static void hpte_decode(hpte_t *hpte, unsigned long slot,
351 unsigned long hpte_r = hpte->r; 351 unsigned long hpte_r = hpte->r;
352 unsigned long hpte_v = hpte->v; 352 unsigned long hpte_v = hpte->v;
353 unsigned long avpn; 353 unsigned long avpn;
354 int i, size, shift, penc, avpnm_bits; 354 int i, size, shift, penc;
355 355
356 if (!(hpte_v & HPTE_V_LARGE)) 356 if (!(hpte_v & HPTE_V_LARGE))
357 size = MMU_PAGE_4K; 357 size = MMU_PAGE_4K;
@@ -395,7 +395,7 @@ static void hpte_decode(hpte_t *hpte, unsigned long slot,
395 vpi = (vsid ^ (vsid << 25) ^ pteg) & htab_hash_mask; 395 vpi = (vsid ^ (vsid << 25) ^ pteg) & htab_hash_mask;
396 break; 396 break;
397 default: 397 default:
398 avpn = vpi = psize = 0; 398 avpn = vpi = size = 0;
399 } 399 }
400 avpn |= (vpi << mmu_psize_defs[size].shift); 400 avpn |= (vpi << mmu_psize_defs[size].shift);
401 } 401 }
diff --git a/arch/powerpc/platforms/cell/pervasive.c b/arch/powerpc/platforms/cell/pervasive.c
index 8c20f0fb8651..812bf563ed65 100644
--- a/arch/powerpc/platforms/cell/pervasive.c
+++ b/arch/powerpc/platforms/cell/pervasive.c
@@ -43,12 +43,10 @@ static void cbe_power_save(void)
43 unsigned long ctrl, thread_switch_control; 43 unsigned long ctrl, thread_switch_control;
44 44
45 /* 45 /*
46 * We need to hard disable interrupts, but we also need to mark them 46 * We need to hard disable interrupts, the local_irq_enable() done by
47 * hard disabled in the PACA so that the local_irq_enable() done by 47 * our caller upon return will hard re-enable.
48 * our caller upon return propertly hard enables.
49 */ 48 */
50 hard_irq_disable(); 49 hard_irq_disable();
51 get_paca()->hard_enabled = 0;
52 50
53 ctrl = mfspr(SPRN_CTRLF); 51 ctrl = mfspr(SPRN_CTRLF);
54 52
diff --git a/arch/powerpc/platforms/embedded6xx/Kconfig b/arch/powerpc/platforms/embedded6xx/Kconfig
index 8f3c2a73e165..f2d26268ca6f 100644
--- a/arch/powerpc/platforms/embedded6xx/Kconfig
+++ b/arch/powerpc/platforms/embedded6xx/Kconfig
@@ -31,6 +31,14 @@ config PPC_HOLLY
31 help 31 help
32 Select PPC_HOLLY if configuring for an IBM 750GX/CL Eval 32 Select PPC_HOLLY if configuring for an IBM 750GX/CL Eval
33 Board with TSI108/9 bridge (Hickory/Holly) 33 Board with TSI108/9 bridge (Hickory/Holly)
34
35config PPC_PRPMC2800
36 bool "Motorola-PrPMC2800"
37 select MV64X60
38 select NOT_COHERENT_CACHE
39 select WANT_DEVICE_TREE
40 help
41 This option enables support for the Motorola PrPMC2800 board
34endchoice 42endchoice
35 43
36config TSI108_BRIDGE 44config TSI108_BRIDGE
@@ -46,6 +54,11 @@ config MPC10X_BRIDGE
46 select PPC_INDIRECT_PCI 54 select PPC_INDIRECT_PCI
47 default y 55 default y
48 56
57config MV64X60
58 bool
59 select PPC_INDIRECT_PCI
60 select CONFIG_CHECK_CACHE_COHERENCY
61
49config MPC10X_OPENPIC 62config MPC10X_OPENPIC
50 bool 63 bool
51 depends on LINKSTATION 64 depends on LINKSTATION
diff --git a/arch/powerpc/platforms/embedded6xx/Makefile b/arch/powerpc/platforms/embedded6xx/Makefile
index b39fe4f470d5..844947cfc5db 100644
--- a/arch/powerpc/platforms/embedded6xx/Makefile
+++ b/arch/powerpc/platforms/embedded6xx/Makefile
@@ -4,3 +4,4 @@
4obj-$(CONFIG_MPC7448HPC2) += mpc7448_hpc2.o 4obj-$(CONFIG_MPC7448HPC2) += mpc7448_hpc2.o
5obj-$(CONFIG_LINKSTATION) += linkstation.o ls_uart.o 5obj-$(CONFIG_LINKSTATION) += linkstation.o ls_uart.o
6obj-$(CONFIG_PPC_HOLLY) += holly.o 6obj-$(CONFIG_PPC_HOLLY) += holly.o
7obj-$(CONFIG_PPC_PRPMC2800) += prpmc2800.o
diff --git a/arch/powerpc/platforms/embedded6xx/prpmc2800.c b/arch/powerpc/platforms/embedded6xx/prpmc2800.c
new file mode 100644
index 000000000000..53420951dc53
--- /dev/null
+++ b/arch/powerpc/platforms/embedded6xx/prpmc2800.c
@@ -0,0 +1,171 @@
1/*
2 * Board setup routines for the Motorola PrPMC2800
3 *
4 * Author: Dale Farnsworth <dale@farnsworth.org>
5 *
6 * 2007 (c) MontaVista, Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11
12#include <linux/stddef.h>
13#include <linux/kernel.h>
14#include <linux/delay.h>
15#include <linux/interrupt.h>
16#include <linux/seq_file.h>
17
18#include <asm/machdep.h>
19#include <asm/prom.h>
20#include <asm/system.h>
21#include <asm/time.h>
22#include <asm/kexec.h>
23
24#include <mm/mmu_decl.h>
25
26#include <sysdev/mv64x60.h>
27
28#define MV64x60_MPP_CNTL_0 0x0000
29#define MV64x60_MPP_CNTL_2 0x0008
30
31#define MV64x60_GPP_IO_CNTL 0x0000
32#define MV64x60_GPP_LEVEL_CNTL 0x0010
33#define MV64x60_GPP_VALUE_SET 0x0018
34
35#define PLATFORM_NAME_MAX 32
36
37static char prpmc2800_platform_name[PLATFORM_NAME_MAX];
38
39static void __iomem *mv64x60_mpp_reg_base;
40static void __iomem *mv64x60_gpp_reg_base;
41
42static void __init prpmc2800_setup_arch(void)
43{
44 struct device_node *np;
45 phys_addr_t paddr;
46 const unsigned int *reg;
47 const unsigned int *prop;
48
49 /*
50 * ioremap mpp and gpp registers in case they are later
51 * needed by prpmc2800_reset_board().
52 */
53 np = of_find_compatible_node(NULL, NULL, "marvell,mv64x60-mpp");
54 reg = of_get_property(np, "reg", NULL);
55 paddr = of_translate_address(np, reg);
56 of_node_put(np);
57 mv64x60_mpp_reg_base = ioremap(paddr, reg[1]);
58
59 np = of_find_compatible_node(NULL, NULL, "marvell,mv64x60-gpp");
60 reg = of_get_property(np, "reg", NULL);
61 paddr = of_translate_address(np, reg);
62 of_node_put(np);
63 mv64x60_gpp_reg_base = ioremap(paddr, reg[1]);
64
65 np = of_find_node_by_type(NULL, "cpu");
66 prop = of_get_property(np, "clock-frequency", NULL);
67 if (prop)
68 loops_per_jiffy = *prop / HZ;
69 of_node_put(np);
70
71#ifdef CONFIG_PCI
72 mv64x60_pci_init();
73#endif
74
75 printk("Motorola %s\n", prpmc2800_platform_name);
76}
77
78static void prpmc2800_reset_board(void)
79{
80 u32 temp;
81
82 local_irq_disable();
83
84 temp = in_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_0);
85 temp &= 0xFFFF0FFF;
86 out_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_0, temp);
87
88 temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL);
89 temp |= 0x00000004;
90 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL, temp);
91
92 temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL);
93 temp |= 0x00000004;
94 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL, temp);
95
96 temp = in_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_2);
97 temp &= 0xFFFF0FFF;
98 out_le32(mv64x60_mpp_reg_base + MV64x60_MPP_CNTL_2, temp);
99
100 temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL);
101 temp |= 0x00080000;
102 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_LEVEL_CNTL, temp);
103
104 temp = in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL);
105 temp |= 0x00080000;
106 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_IO_CNTL, temp);
107
108 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_VALUE_SET, 0x00080004);
109}
110
111static void prpmc2800_restart(char *cmd)
112{
113 volatile ulong i = 10000000;
114
115 prpmc2800_reset_board();
116
117 while (i-- > 0);
118 panic("restart failed\n");
119}
120
121#ifdef CONFIG_NOT_COHERENT_CACHE
122#define PPRPM2800_COHERENCY_SETTING "off"
123#else
124#define PPRPM2800_COHERENCY_SETTING "on"
125#endif
126
127void prpmc2800_show_cpuinfo(struct seq_file *m)
128{
129 uint memsize = total_memory;
130
131 seq_printf(m, "Vendor\t\t: Motorola\n");
132 seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
133 seq_printf(m, "coherency\t: %s\n", PPRPM2800_COHERENCY_SETTING);
134}
135
136/*
137 * Called very early, device-tree isn't unflattened
138 */
139static int __init prpmc2800_probe(void)
140{
141 unsigned long root = of_get_flat_dt_root();
142 unsigned long len = PLATFORM_NAME_MAX;
143 void *m;
144
145 if (!of_flat_dt_is_compatible(root, "motorola,PrPMC2800"))
146 return 0;
147
148 /* Update ppc_md.name with name from dt */
149 m = of_get_flat_dt_prop(root, "model", &len);
150 if (m)
151 strncpy(prpmc2800_platform_name, m,
152 min((int)len, PLATFORM_NAME_MAX - 1));
153
154 return 1;
155}
156
157define_machine(prpmc2800){
158 .name = prpmc2800_platform_name,
159 .probe = prpmc2800_probe,
160 .setup_arch = prpmc2800_setup_arch,
161 .show_cpuinfo = prpmc2800_show_cpuinfo,
162 .init_IRQ = mv64x60_init_irq,
163 .get_irq = mv64x60_get_irq,
164 .restart = prpmc2800_restart,
165 .calibrate_decr = generic_calibrate_decr,
166#ifdef CONFIG_KEXEC
167 .machine_kexec = default_machine_kexec,
168 .machine_kexec_prepare = default_machine_kexec_prepare,
169 .machine_crash_shutdown = default_machine_crash_shutdown,
170#endif
171};
diff --git a/arch/powerpc/platforms/pasemi/idle.c b/arch/powerpc/platforms/pasemi/idle.c
index 5985ce0c5c48..03cd45d8fefa 100644
--- a/arch/powerpc/platforms/pasemi/idle.c
+++ b/arch/powerpc/platforms/pasemi/idle.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/string.h> 24#include <linux/string.h>
25#include <linux/irq.h>
25 26
26#include <asm/machdep.h> 27#include <asm/machdep.h>
27#include <asm/reg.h> 28#include <asm/reg.h>
diff --git a/arch/powerpc/platforms/ps3/setup.c b/arch/powerpc/platforms/ps3/setup.c
index c9894933084f..935396766621 100644
--- a/arch/powerpc/platforms/ps3/setup.c
+++ b/arch/powerpc/platforms/ps3/setup.c
@@ -99,6 +99,7 @@ static void ps3_panic(char *str)
99 while(1); 99 while(1);
100} 100}
101 101
102#ifdef CONFIG_FB_PS3
102static void prealloc(struct ps3_prealloc *p) 103static void prealloc(struct ps3_prealloc *p)
103{ 104{
104 if (!p->size) 105 if (!p->size)
@@ -115,7 +116,6 @@ static void prealloc(struct ps3_prealloc *p)
115 p->address); 116 p->address);
116} 117}
117 118
118#ifdef CONFIG_FB_PS3
119struct ps3_prealloc ps3fb_videomemory = { 119struct ps3_prealloc ps3fb_videomemory = {
120 .name = "ps3fb videomemory", 120 .name = "ps3fb videomemory",
121 .size = CONFIG_FB_PS3_DEFAULT_SIZE_M*1024*1024, 121 .size = CONFIG_FB_PS3_DEFAULT_SIZE_M*1024*1024,
diff --git a/arch/powerpc/platforms/ps3/smp.c b/arch/powerpc/platforms/ps3/smp.c
index 8729348c0608..53416ec5198b 100644
--- a/arch/powerpc/platforms/ps3/smp.c
+++ b/arch/powerpc/platforms/ps3/smp.c
@@ -118,9 +118,11 @@ static void __init ps3_smp_setup_cpu(int cpu)
118 DBG("%s:%d: (%d, %d) => virq %u\n", 118 DBG("%s:%d: (%d, %d) => virq %u\n",
119 __func__, __LINE__, cpu, i, virqs[i]); 119 __func__, __LINE__, cpu, i, virqs[i]);
120 120
121 result = request_irq(virqs[i], ipi_function_handler,
122 IRQF_DISABLED, names[i], (void*)(long)i);
121 123
122 request_irq(virqs[i], ipi_function_handler, IRQF_DISABLED, 124 if (result)
123 names[i], (void*)(long)i); 125 virqs[i] = NO_IRQ;
124 } 126 }
125 127
126 ps3_register_ipi_debug_brk(cpu, virqs[PPC_MSG_DEBUGGER_BREAK]); 128 ps3_register_ipi_debug_brk(cpu, virqs[PPC_MSG_DEBUGGER_BREAK]);
diff --git a/arch/powerpc/platforms/ps3/system-bus.c b/arch/powerpc/platforms/ps3/system-bus.c
index 3c48cce98a5c..6bda51027cc6 100644
--- a/arch/powerpc/platforms/ps3/system-bus.c
+++ b/arch/powerpc/platforms/ps3/system-bus.c
@@ -274,13 +274,13 @@ static void ps3_unmap_single(struct device *_dev, dma_addr_t dma_addr,
274static int ps3_map_sg(struct device *_dev, struct scatterlist *sg, int nents, 274static int ps3_map_sg(struct device *_dev, struct scatterlist *sg, int nents,
275 enum dma_data_direction direction) 275 enum dma_data_direction direction)
276{ 276{
277 struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
278 int i;
279
280#if defined(CONFIG_PS3_DYNAMIC_DMA) 277#if defined(CONFIG_PS3_DYNAMIC_DMA)
281 BUG_ON("do"); 278 BUG_ON("do");
282 return -EPERM; 279 return -EPERM;
283#else 280#else
281 struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
282 int i;
283
284 for (i = 0; i < nents; i++, sg++) { 284 for (i = 0; i < nents; i++, sg++) {
285 int result = ps3_dma_map(dev->d_region, 285 int result = ps3_dma_map(dev->d_region,
286 page_to_phys(sg->page) + sg->offset, sg->length, 286 page_to_phys(sg->page) + sg->offset, sg->length,
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index 9ce775c38ab7..c3ce0bd12c0b 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -16,6 +16,8 @@ obj-$(CONFIG_FSL_SOC) += fsl_soc.o
16obj-$(CONFIG_FSL_PCIE) += fsl_pcie.o 16obj-$(CONFIG_FSL_PCIE) += fsl_pcie.o
17obj-$(CONFIG_TSI108_BRIDGE) += tsi108_pci.o tsi108_dev.o 17obj-$(CONFIG_TSI108_BRIDGE) += tsi108_pci.o tsi108_dev.o
18obj-$(CONFIG_QUICC_ENGINE) += qe_lib/ 18obj-$(CONFIG_QUICC_ENGINE) += qe_lib/
19mv64x60-$(CONFIG_PCI) += mv64x60_pci.o
20obj-$(CONFIG_MV64X60) += $(mv64x60-y) mv64x60_pic.o mv64x60_dev.o
19 21
20# contains only the suspend handler for time 22# contains only the suspend handler for time
21obj-$(CONFIG_PM) += timer.o 23obj-$(CONFIG_PM) += timer.o
diff --git a/arch/powerpc/sysdev/mv64x60.h b/arch/powerpc/sysdev/mv64x60.h
new file mode 100644
index 000000000000..2ff0b4ef2681
--- /dev/null
+++ b/arch/powerpc/sysdev/mv64x60.h
@@ -0,0 +1,11 @@
1#ifndef __MV64X60_H__
2#define __MV64X60_H__
3
4#include <linux/init.h>
5
6extern void __init mv64x60_init_irq(void);
7extern unsigned int mv64x60_get_irq(void);
8
9extern void __init mv64x60_pci_init(void);
10
11#endif /* __MV64X60_H__ */
diff --git a/arch/powerpc/sysdev/mv64x60_dev.c b/arch/powerpc/sysdev/mv64x60_dev.c
new file mode 100644
index 000000000000..4b0a9c88eeb3
--- /dev/null
+++ b/arch/powerpc/sysdev/mv64x60_dev.c
@@ -0,0 +1,422 @@
1/*
2 * Platform device setup for Marvell mv64360/mv64460 host bridges (Discovery)
3 *
4 * Author: Dale Farnsworth <dale@farnsworth.org>
5 *
6 * 2007 (c) MontaVista, Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11
12#include <linux/stddef.h>
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/mv643xx.h>
16#include <linux/platform_device.h>
17
18#include <asm/prom.h>
19
20/*
21 * These functions provide the necessary setup for the mv64x60 drivers.
22 * These drivers are unusual in that they work on both the MIPS and PowerPC
23 * architectures. Because of that, the drivers do not support the normal
24 * PowerPC of_platform_bus_type. They support platform_bus_type instead.
25 */
26
27/*
28 * Create MPSC platform devices
29 */
30static int __init mv64x60_mpsc_register_shared_pdev(struct device_node *np)
31{
32 struct platform_device *pdev;
33 struct resource r[2];
34 struct mpsc_shared_pdata pdata;
35 const phandle *ph;
36 struct device_node *mpscrouting, *mpscintr;
37 int err;
38
39 ph = of_get_property(np, "mpscrouting", NULL);
40 mpscrouting = of_find_node_by_phandle(*ph);
41 if (!mpscrouting)
42 return -ENODEV;
43
44 err = of_address_to_resource(mpscrouting, 0, &r[0]);
45 of_node_put(mpscrouting);
46 if (err)
47 return err;
48
49 ph = of_get_property(np, "mpscintr", NULL);
50 mpscintr = of_find_node_by_phandle(*ph);
51 if (!mpscintr)
52 return -ENODEV;
53
54 err = of_address_to_resource(mpscintr, 0, &r[1]);
55 of_node_put(mpscintr);
56 if (err)
57 return err;
58
59 memset(&pdata, 0, sizeof(pdata));
60
61 pdev = platform_device_alloc(MPSC_SHARED_NAME, 0);
62 if (!pdev)
63 return -ENOMEM;
64
65 err = platform_device_add_resources(pdev, r, 2);
66 if (err)
67 goto error;
68
69 err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
70 if (err)
71 goto error;
72
73 err = platform_device_add(pdev);
74 if (err)
75 goto error;
76
77 return 0;
78
79error:
80 platform_device_put(pdev);
81 return err;
82}
83
84
85static int __init mv64x60_mpsc_device_setup(struct device_node *np, int id)
86{
87 struct resource r[5];
88 struct mpsc_pdata pdata;
89 struct platform_device *pdev;
90 const unsigned int *prop;
91 const phandle *ph;
92 struct device_node *sdma, *brg;
93 int err;
94 int port_number;
95
96 /* only register the shared platform device the first time through */
97 if (id == 0 && (err = mv64x60_mpsc_register_shared_pdev(np)))
98 return err;
99
100 memset(r, 0, sizeof(r));
101
102 err = of_address_to_resource(np, 0, &r[0]);
103 if (err)
104 return err;
105
106 of_irq_to_resource(np, 0, &r[4]);
107
108 ph = of_get_property(np, "sdma", NULL);
109 sdma = of_find_node_by_phandle(*ph);
110 if (!sdma)
111 return -ENODEV;
112
113 of_irq_to_resource(sdma, 0, &r[3]);
114 err = of_address_to_resource(sdma, 0, &r[1]);
115 of_node_put(sdma);
116 if (err)
117 return err;
118
119 ph = of_get_property(np, "brg", NULL);
120 brg = of_find_node_by_phandle(*ph);
121 if (!brg)
122 return -ENODEV;
123
124 err = of_address_to_resource(brg, 0, &r[2]);
125 of_node_put(brg);
126 if (err)
127 return err;
128
129 prop = of_get_property(np, "block-index", NULL);
130 if (!prop)
131 return -ENODEV;
132 port_number = *(int *)prop;
133
134 memset(&pdata, 0, sizeof(pdata));
135
136 pdata.cache_mgmt = 1; /* All current revs need this set */
137
138 prop = of_get_property(np, "max_idle", NULL);
139 if (prop)
140 pdata.max_idle = *prop;
141
142 prop = of_get_property(brg, "current-speed", NULL);
143 if (prop)
144 pdata.default_baud = *prop;
145
146 /* Default is 8 bits, no parity, no flow control */
147 pdata.default_bits = 8;
148 pdata.default_parity = 'n';
149 pdata.default_flow = 'n';
150
151 prop = of_get_property(np, "chr_1", NULL);
152 if (prop)
153 pdata.chr_1_val = *prop;
154
155 prop = of_get_property(np, "chr_2", NULL);
156 if (prop)
157 pdata.chr_2_val = *prop;
158
159 prop = of_get_property(np, "chr_10", NULL);
160 if (prop)
161 pdata.chr_10_val = *prop;
162
163 prop = of_get_property(np, "mpcr", NULL);
164 if (prop)
165 pdata.mpcr_val = *prop;
166
167 prop = of_get_property(brg, "bcr", NULL);
168 if (prop)
169 pdata.bcr_val = *prop;
170
171 pdata.brg_can_tune = 1; /* All current revs need this set */
172
173 prop = of_get_property(brg, "clock-src", NULL);
174 if (prop)
175 pdata.brg_clk_src = *prop;
176
177 prop = of_get_property(brg, "clock-frequency", NULL);
178 if (prop)
179 pdata.brg_clk_freq = *prop;
180
181 pdev = platform_device_alloc(MPSC_CTLR_NAME, port_number);
182 if (!pdev)
183 return -ENOMEM;
184
185 err = platform_device_add_resources(pdev, r, 5);
186 if (err)
187 goto error;
188
189 err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
190 if (err)
191 goto error;
192
193 err = platform_device_add(pdev);
194 if (err)
195 goto error;
196
197 return 0;
198
199error:
200 platform_device_put(pdev);
201 return err;
202}
203
204/*
205 * Create mv64x60_eth platform devices
206 */
207static int __init eth_register_shared_pdev(struct device_node *np)
208{
209 struct platform_device *pdev;
210 struct resource r[1];
211 int err;
212
213 np = of_get_parent(np);
214 if (!np)
215 return -ENODEV;
216
217 err = of_address_to_resource(np, 0, &r[0]);
218 of_node_put(np);
219 if (err)
220 return err;
221
222 pdev = platform_device_register_simple(MV643XX_ETH_SHARED_NAME, 0,
223 r, 1);
224 if (IS_ERR(pdev))
225 return PTR_ERR(pdev);
226
227 return 0;
228}
229
230static int __init mv64x60_eth_device_setup(struct device_node *np, int id)
231{
232 struct resource r[1];
233 struct mv643xx_eth_platform_data pdata;
234 struct platform_device *pdev;
235 struct device_node *phy;
236 const u8 *mac_addr;
237 const int *prop;
238 const phandle *ph;
239 int err;
240
241 /* only register the shared platform device the first time through */
242 if (id == 0 && (err = eth_register_shared_pdev(np)))
243 return err;;
244
245 memset(r, 0, sizeof(r));
246 of_irq_to_resource(np, 0, &r[0]);
247
248 memset(&pdata, 0, sizeof(pdata));
249
250 prop = of_get_property(np, "block-index", NULL);
251 if (!prop)
252 return -ENODEV;
253 pdata.port_number = *prop;
254
255 mac_addr = of_get_mac_address(np);
256 if (mac_addr)
257 memcpy(pdata.mac_addr, mac_addr, 6);
258
259 prop = of_get_property(np, "speed", NULL);
260 if (prop)
261 pdata.speed = *prop;
262
263 prop = of_get_property(np, "tx_queue_size", NULL);
264 if (prop)
265 pdata.tx_queue_size = *prop;
266
267 prop = of_get_property(np, "rx_queue_size", NULL);
268 if (prop)
269 pdata.rx_queue_size = *prop;
270
271 prop = of_get_property(np, "tx_sram_addr", NULL);
272 if (prop)
273 pdata.tx_sram_addr = *prop;
274
275 prop = of_get_property(np, "tx_sram_size", NULL);
276 if (prop)
277 pdata.tx_sram_size = *prop;
278
279 prop = of_get_property(np, "rx_sram_addr", NULL);
280 if (prop)
281 pdata.rx_sram_addr = *prop;
282
283 prop = of_get_property(np, "rx_sram_size", NULL);
284 if (prop)
285 pdata.rx_sram_size = *prop;
286
287 ph = of_get_property(np, "phy", NULL);
288 if (!ph)
289 return -ENODEV;
290
291 phy = of_find_node_by_phandle(*ph);
292 if (phy == NULL)
293 return -ENODEV;
294
295 prop = of_get_property(phy, "reg", NULL);
296 if (prop) {
297 pdata.force_phy_addr = 1;
298 pdata.phy_addr = *prop;
299 }
300
301 of_node_put(phy);
302
303 pdev = platform_device_alloc(MV643XX_ETH_NAME, pdata.port_number);
304 if (!pdev)
305 return -ENOMEM;
306
307 err = platform_device_add_resources(pdev, r, 1);
308 if (err)
309 goto error;
310
311 err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
312 if (err)
313 goto error;
314
315 err = platform_device_add(pdev);
316 if (err)
317 goto error;
318
319 return 0;
320
321error:
322 platform_device_put(pdev);
323 return err;
324}
325
326/*
327 * Create mv64x60_i2c platform devices
328 */
329static int __init mv64x60_i2c_device_setup(struct device_node *np, int id)
330{
331 struct resource r[2];
332 struct platform_device *pdev;
333 struct mv64xxx_i2c_pdata pdata;
334 const unsigned int *prop;
335 int err;
336
337 memset(r, 0, sizeof(r));
338
339 err = of_address_to_resource(np, 0, &r[0]);
340 if (err)
341 return err;
342
343 of_irq_to_resource(np, 0, &r[1]);
344
345 memset(&pdata, 0, sizeof(pdata));
346
347 prop = of_get_property(np, "freq_m", NULL);
348 if (!prop)
349 return -ENODEV;
350 pdata.freq_m = *prop;
351
352 prop = of_get_property(np, "freq_n", NULL);
353 if (!prop)
354 return -ENODEV;
355 pdata.freq_n = *prop;
356
357 prop = of_get_property(np, "timeout", NULL);
358 if (prop)
359 pdata.timeout = *prop;
360 else
361 pdata.timeout = 1000; /* 1 second */
362
363 prop = of_get_property(np, "retries", NULL);
364 if (prop)
365 pdata.retries = *prop;
366 else
367 pdata.retries = 1;
368
369 pdev = platform_device_alloc(MV64XXX_I2C_CTLR_NAME, id);
370 if (!pdev)
371 return -ENOMEM;
372
373 err = platform_device_add_resources(pdev, r, 2);
374 if (err)
375 goto error;
376
377 err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
378 if (err)
379 goto error;
380
381 err = platform_device_add(pdev);
382 if (err)
383 goto error;
384
385 return 0;
386
387error:
388 platform_device_put(pdev);
389 return err;
390}
391
392static int __init mv64x60_device_setup(void)
393{
394 struct device_node *np = NULL;
395 int id;
396 int err;
397
398 for (id = 0;
399 (np = of_find_compatible_node(np, "serial", "marvell,mpsc")); id++)
400 if ((err = mv64x60_mpsc_device_setup(np, id)))
401 goto error;
402
403 for (id = 0;
404 (np = of_find_compatible_node(np, "network",
405 "marvell,mv64x60-eth"));
406 id++)
407 if ((err = mv64x60_eth_device_setup(np, id)))
408 goto error;
409
410 for (id = 0;
411 (np = of_find_compatible_node(np, "i2c", "marvell,mv64x60-i2c"));
412 id++)
413 if ((err = mv64x60_i2c_device_setup(np, id)))
414 goto error;
415
416 return 0;
417
418error:
419 of_node_put(np);
420 return err;
421}
422arch_initcall(mv64x60_device_setup);
diff --git a/arch/powerpc/sysdev/mv64x60_pci.c b/arch/powerpc/sysdev/mv64x60_pci.c
new file mode 100644
index 000000000000..b5aef4cbc8d2
--- /dev/null
+++ b/arch/powerpc/sysdev/mv64x60_pci.c
@@ -0,0 +1,172 @@
1/*
2 * PCI bus setup for Marvell mv64360/mv64460 host bridges (Discovery)
3 *
4 * Author: Dale Farnsworth <dale@farnsworth.org>
5 *
6 * 2007 (c) MontaVista, Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11
12#include <linux/stddef.h>
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/pci.h>
16
17#include <asm/prom.h>
18#include <asm/pci-bridge.h>
19
20#define PCI_HEADER_TYPE_INVALID 0x7f /* Invalid PCI header type */
21
22#ifdef CONFIG_SYSFS
23/* 32-bit hex or dec stringified number + '\n' */
24#define MV64X60_VAL_LEN_MAX 11
25#define MV64X60_PCICFG_CPCI_HOTSWAP 0x68
26
27static ssize_t mv64x60_hs_reg_read(struct kobject *kobj, char *buf, loff_t off,
28 size_t count)
29{
30 struct pci_dev *phb;
31 u32 v;
32
33 if (off > 0)
34 return 0;
35 if (count < MV64X60_VAL_LEN_MAX)
36 return -EINVAL;
37
38 phb = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0));
39 if (!phb)
40 return -ENODEV;
41 pci_read_config_dword(phb, MV64X60_PCICFG_CPCI_HOTSWAP, &v);
42 pci_dev_put(phb);
43
44 return sprintf(buf, "0x%08x\n", v);
45}
46
47static ssize_t mv64x60_hs_reg_write(struct kobject *kobj, char *buf, loff_t off,
48 size_t count)
49{
50 struct pci_dev *phb;
51 u32 v;
52
53 if (off > 0)
54 return 0;
55 if (count <= 0)
56 return -EINVAL;
57
58 if (sscanf(buf, "%i", &v) != 1)
59 return -EINVAL;
60
61 phb = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0));
62 if (!phb)
63 return -ENODEV;
64 pci_write_config_dword(phb, MV64X60_PCICFG_CPCI_HOTSWAP, v);
65 pci_dev_put(phb);
66
67 return count;
68}
69
70static struct bin_attribute mv64x60_hs_reg_attr = { /* Hotswap register */
71 .attr = {
72 .name = "hs_reg",
73 .mode = S_IRUGO | S_IWUSR,
74 .owner = THIS_MODULE,
75 },
76 .size = MV64X60_VAL_LEN_MAX,
77 .read = mv64x60_hs_reg_read,
78 .write = mv64x60_hs_reg_write,
79};
80
81static int __init mv64x60_sysfs_init(void)
82{
83 struct device_node *np;
84 struct platform_device *pdev;
85 const unsigned int *prop;
86
87 np = of_find_compatible_node(NULL, NULL, "marvell,mv64x60");
88 if (!np)
89 return 0;
90
91 prop = of_get_property(np, "hs_reg_valid", NULL);
92 of_node_put(np);
93
94 pdev = platform_device_register_simple("marvell,mv64x60", 0, NULL, 0);
95 if (IS_ERR(pdev))
96 return PTR_ERR(pdev);
97
98 return sysfs_create_bin_file(&pdev->dev.kobj, &mv64x60_hs_reg_attr);
99}
100
101subsys_initcall(mv64x60_sysfs_init);
102
103#endif /* CONFIG_SYSFS */
104
105static void __init mv64x60_pci_fixup_early(struct pci_dev *dev)
106{
107 /*
108 * Set the host bridge hdr_type to an invalid value so that
109 * pci_setup_device() will ignore the host bridge.
110 */
111 dev->hdr_type = PCI_HEADER_TYPE_INVALID;
112}
113DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_MV64360,
114 mv64x60_pci_fixup_early);
115DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_MV64460,
116 mv64x60_pci_fixup_early);
117
118static int __init mv64x60_add_bridge(struct device_node *dev)
119{
120 int len;
121 struct pci_controller *hose;
122 struct resource rsrc;
123 const int *bus_range;
124 int primary;
125
126 memset(&rsrc, 0, sizeof(rsrc));
127
128 /* Fetch host bridge registers address */
129 if (of_address_to_resource(dev, 0, &rsrc)) {
130 printk(KERN_ERR "No PCI reg property in device tree\n");
131 return -ENODEV;
132 }
133
134 /* Get bus range if any */
135 bus_range = of_get_property(dev, "bus-range", &len);
136 if (bus_range == NULL || len < 2 * sizeof(int))
137 printk(KERN_WARNING "Can't get bus-range for %s, assume"
138 " bus 0\n", dev->full_name);
139
140 hose = pcibios_alloc_controller();
141 if (!hose)
142 return -ENOMEM;
143
144 hose->arch_data = dev;
145 hose->set_cfg_type = 1;
146
147 hose->first_busno = bus_range ? bus_range[0] : 0;
148 hose->last_busno = bus_range ? bus_range[1] : 0xff;
149
150 setup_indirect_pci(hose, rsrc.start, rsrc.start + 4);
151 hose->bus_offset = hose->first_busno;
152
153 printk(KERN_INFO "Found MV64x60 PCI host bridge at 0x%016llx. "
154 "Firmware bus number: %d->%d\n",
155 (unsigned long long)rsrc.start, hose->first_busno,
156 hose->last_busno);
157
158 /* Interpret the "ranges" property */
159 /* This also maps the I/O region and sets isa_io/mem_base */
160 primary = (hose->first_busno == 0);
161 pci_process_bridge_OF_ranges(hose, dev, primary);
162
163 return 0;
164}
165
166void __init mv64x60_pci_init(void)
167{
168 struct device_node *np = NULL;
169
170 while ((np = of_find_compatible_node(np, "pci", "marvell,mv64x60-pci")))
171 mv64x60_add_bridge(np);
172}
diff --git a/arch/powerpc/sysdev/mv64x60_pic.c b/arch/powerpc/sysdev/mv64x60_pic.c
new file mode 100644
index 000000000000..01d316287772
--- /dev/null
+++ b/arch/powerpc/sysdev/mv64x60_pic.c
@@ -0,0 +1,305 @@
1/*
2 * Interrupt handling for Marvell mv64360/mv64460 host bridges (Discovery)
3 *
4 * Author: Dale Farnsworth <dale@farnsworth.org>
5 *
6 * 2007 (c) MontaVista, Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11
12#include <linux/stddef.h>
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/irq.h>
16#include <linux/interrupt.h>
17#include <linux/spinlock.h>
18
19#include <asm/byteorder.h>
20#include <asm/io.h>
21#include <asm/prom.h>
22#include <asm/irq.h>
23
24#include "mv64x60.h"
25
26/* Interrupt Controller Interface Registers */
27#define MV64X60_IC_MAIN_CAUSE_LO 0x0004
28#define MV64X60_IC_MAIN_CAUSE_HI 0x000c
29#define MV64X60_IC_CPU0_INTR_MASK_LO 0x0014
30#define MV64X60_IC_CPU0_INTR_MASK_HI 0x001c
31#define MV64X60_IC_CPU0_SELECT_CAUSE 0x0024
32
33#define MV64X60_HIGH_GPP_GROUPS 0x0f000000
34#define MV64X60_SELECT_CAUSE_HIGH 0x40000000
35
36/* General Purpose Pins Controller Interface Registers */
37#define MV64x60_GPP_INTR_CAUSE 0x0008
38#define MV64x60_GPP_INTR_MASK 0x000c
39
40#define MV64x60_LEVEL1_LOW 0
41#define MV64x60_LEVEL1_HIGH 1
42#define MV64x60_LEVEL1_GPP 2
43
44#define MV64x60_LEVEL1_MASK 0x00000060
45#define MV64x60_LEVEL1_OFFSET 5
46
47#define MV64x60_LEVEL2_MASK 0x0000001f
48
49#define MV64x60_NUM_IRQS 96
50
51static DEFINE_SPINLOCK(mv64x60_lock);
52
53static void __iomem *mv64x60_irq_reg_base;
54static void __iomem *mv64x60_gpp_reg_base;
55
56/*
57 * Interrupt Controller Handling
58 *
59 * The interrupt controller handles three groups of interrupts:
60 * main low: IRQ0-IRQ31
61 * main high: IRQ32-IRQ63
62 * gpp: IRQ64-IRQ95
63 *
64 * This code handles interrupts in two levels. Level 1 selects the
65 * interrupt group, and level 2 selects an IRQ within that group.
66 * Each group has its own irq_chip structure.
67 */
68
69static u32 mv64x60_cached_low_mask;
70static u32 mv64x60_cached_high_mask = MV64X60_HIGH_GPP_GROUPS;
71static u32 mv64x60_cached_gpp_mask;
72
73static struct irq_host *mv64x60_irq_host;
74
75/*
76 * mv64x60_chip_low functions
77 */
78
79static void mv64x60_mask_low(unsigned int virq)
80{
81 int level2 = irq_map[virq].hwirq & MV64x60_LEVEL2_MASK;
82 unsigned long flags;
83
84 spin_lock_irqsave(&mv64x60_lock, flags);
85 mv64x60_cached_low_mask &= ~(1 << level2);
86 out_le32(mv64x60_irq_reg_base + MV64X60_IC_CPU0_INTR_MASK_LO,
87 mv64x60_cached_low_mask);
88 spin_unlock_irqrestore(&mv64x60_lock, flags);
89 (void)in_le32(mv64x60_irq_reg_base + MV64X60_IC_CPU0_INTR_MASK_LO);
90}
91
92static void mv64x60_unmask_low(unsigned int virq)
93{
94 int level2 = irq_map[virq].hwirq & MV64x60_LEVEL2_MASK;
95 unsigned long flags;
96
97 spin_lock_irqsave(&mv64x60_lock, flags);
98 mv64x60_cached_low_mask |= 1 << level2;
99 out_le32(mv64x60_irq_reg_base + MV64X60_IC_CPU0_INTR_MASK_LO,
100 mv64x60_cached_low_mask);
101 spin_unlock_irqrestore(&mv64x60_lock, flags);
102 (void)in_le32(mv64x60_irq_reg_base + MV64X60_IC_CPU0_INTR_MASK_LO);
103}
104
105static struct irq_chip mv64x60_chip_low = {
106 .name = "mv64x60_low",
107 .mask = mv64x60_mask_low,
108 .mask_ack = mv64x60_mask_low,
109 .unmask = mv64x60_unmask_low,
110};
111
112/*
113 * mv64x60_chip_high functions
114 */
115
116static void mv64x60_mask_high(unsigned int virq)
117{
118 int level2 = irq_map[virq].hwirq & MV64x60_LEVEL2_MASK;
119 unsigned long flags;
120
121 spin_lock_irqsave(&mv64x60_lock, flags);
122 mv64x60_cached_high_mask &= ~(1 << level2);
123 out_le32(mv64x60_irq_reg_base + MV64X60_IC_CPU0_INTR_MASK_HI,
124 mv64x60_cached_high_mask);
125 spin_unlock_irqrestore(&mv64x60_lock, flags);
126 (void)in_le32(mv64x60_irq_reg_base + MV64X60_IC_CPU0_INTR_MASK_HI);
127}
128
129static void mv64x60_unmask_high(unsigned int virq)
130{
131 int level2 = irq_map[virq].hwirq & MV64x60_LEVEL2_MASK;
132 unsigned long flags;
133
134 spin_lock_irqsave(&mv64x60_lock, flags);
135 mv64x60_cached_high_mask |= 1 << level2;
136 out_le32(mv64x60_irq_reg_base + MV64X60_IC_CPU0_INTR_MASK_HI,
137 mv64x60_cached_high_mask);
138 spin_unlock_irqrestore(&mv64x60_lock, flags);
139 (void)in_le32(mv64x60_irq_reg_base + MV64X60_IC_CPU0_INTR_MASK_HI);
140}
141
142static struct irq_chip mv64x60_chip_high = {
143 .name = "mv64x60_high",
144 .mask = mv64x60_mask_high,
145 .mask_ack = mv64x60_mask_high,
146 .unmask = mv64x60_unmask_high,
147};
148
149/*
150 * mv64x60_chip_gpp functions
151 */
152
153static void mv64x60_mask_gpp(unsigned int virq)
154{
155 int level2 = irq_map[virq].hwirq & MV64x60_LEVEL2_MASK;
156 unsigned long flags;
157
158 spin_lock_irqsave(&mv64x60_lock, flags);
159 mv64x60_cached_gpp_mask &= ~(1 << level2);
160 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_INTR_MASK,
161 mv64x60_cached_gpp_mask);
162 spin_unlock_irqrestore(&mv64x60_lock, flags);
163 (void)in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_INTR_MASK);
164}
165
166static void mv64x60_mask_ack_gpp(unsigned int virq)
167{
168 int level2 = irq_map[virq].hwirq & MV64x60_LEVEL2_MASK;
169 unsigned long flags;
170
171 spin_lock_irqsave(&mv64x60_lock, flags);
172 mv64x60_cached_gpp_mask &= ~(1 << level2);
173 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_INTR_MASK,
174 mv64x60_cached_gpp_mask);
175 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_INTR_CAUSE,
176 ~(1 << level2));
177 spin_unlock_irqrestore(&mv64x60_lock, flags);
178 (void)in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_INTR_CAUSE);
179}
180
181static void mv64x60_unmask_gpp(unsigned int virq)
182{
183 int level2 = irq_map[virq].hwirq & MV64x60_LEVEL2_MASK;
184 unsigned long flags;
185
186 spin_lock_irqsave(&mv64x60_lock, flags);
187 mv64x60_cached_gpp_mask |= 1 << level2;
188 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_INTR_MASK,
189 mv64x60_cached_gpp_mask);
190 spin_unlock_irqrestore(&mv64x60_lock, flags);
191 (void)in_le32(mv64x60_gpp_reg_base + MV64x60_GPP_INTR_MASK);
192}
193
194static struct irq_chip mv64x60_chip_gpp = {
195 .name = "mv64x60_gpp",
196 .mask = mv64x60_mask_gpp,
197 .mask_ack = mv64x60_mask_ack_gpp,
198 .unmask = mv64x60_unmask_gpp,
199};
200
201/*
202 * mv64x60_host_ops functions
203 */
204
205static int mv64x60_host_match(struct irq_host *h, struct device_node *np)
206{
207 return mv64x60_irq_host->host_data == np;
208}
209
210static struct irq_chip *mv64x60_chips[] = {
211 [MV64x60_LEVEL1_LOW] = &mv64x60_chip_low,
212 [MV64x60_LEVEL1_HIGH] = &mv64x60_chip_high,
213 [MV64x60_LEVEL1_GPP] = &mv64x60_chip_gpp,
214};
215
216static int mv64x60_host_map(struct irq_host *h, unsigned int virq,
217 irq_hw_number_t hwirq)
218{
219 int level1;
220
221 get_irq_desc(virq)->status |= IRQ_LEVEL;
222
223 level1 = (hwirq & MV64x60_LEVEL1_MASK) >> MV64x60_LEVEL1_OFFSET;
224 BUG_ON(level1 > MV64x60_LEVEL1_GPP);
225 set_irq_chip_and_handler(virq, mv64x60_chips[level1], handle_level_irq);
226
227 return 0;
228}
229
230static struct irq_host_ops mv64x60_host_ops = {
231 .match = mv64x60_host_match,
232 .map = mv64x60_host_map,
233};
234
235/*
236 * Global functions
237 */
238
239void __init mv64x60_init_irq(void)
240{
241 struct device_node *np;
242 phys_addr_t paddr;
243 unsigned int size;
244 const unsigned int *reg;
245 unsigned long flags;
246
247 np = of_find_compatible_node(NULL, NULL, "marvell,mv64x60-gpp");
248 reg = of_get_property(np, "reg", &size);
249 paddr = of_translate_address(np, reg);
250 mv64x60_gpp_reg_base = ioremap(paddr, reg[1]);
251 of_node_put(np);
252
253 np = of_find_compatible_node(NULL, NULL, "marvell,mv64x60-pic");
254 reg = of_get_property(np, "reg", &size);
255 paddr = of_translate_address(np, reg);
256 of_node_put(np);
257 mv64x60_irq_reg_base = ioremap(paddr, reg[1]);
258
259 mv64x60_irq_host = irq_alloc_host(IRQ_HOST_MAP_LINEAR, MV64x60_NUM_IRQS,
260 &mv64x60_host_ops, MV64x60_NUM_IRQS);
261
262 mv64x60_irq_host->host_data = np;
263
264 spin_lock_irqsave(&mv64x60_lock, flags);
265 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_INTR_MASK,
266 mv64x60_cached_gpp_mask);
267 out_le32(mv64x60_irq_reg_base + MV64X60_IC_CPU0_INTR_MASK_LO,
268 mv64x60_cached_low_mask);
269 out_le32(mv64x60_irq_reg_base + MV64X60_IC_CPU0_INTR_MASK_HI,
270 mv64x60_cached_high_mask);
271
272 out_le32(mv64x60_gpp_reg_base + MV64x60_GPP_INTR_CAUSE, 0);
273 out_le32(mv64x60_irq_reg_base + MV64X60_IC_MAIN_CAUSE_LO, 0);
274 out_le32(mv64x60_irq_reg_base + MV64X60_IC_MAIN_CAUSE_HI, 0);
275 spin_unlock_irqrestore(&mv64x60_lock, flags);
276}
277
278unsigned int mv64x60_get_irq(void)
279{
280 u32 cause;
281 int level1;
282 irq_hw_number_t hwirq;
283 int virq = NO_IRQ;
284
285 cause = in_le32(mv64x60_irq_reg_base + MV64X60_IC_CPU0_SELECT_CAUSE);
286 if (cause & MV64X60_SELECT_CAUSE_HIGH) {
287 cause &= mv64x60_cached_high_mask;
288 level1 = MV64x60_LEVEL1_HIGH;
289 if (cause & MV64X60_HIGH_GPP_GROUPS) {
290 cause = in_le32(mv64x60_gpp_reg_base +
291 MV64x60_GPP_INTR_CAUSE);
292 cause &= mv64x60_cached_gpp_mask;
293 level1 = MV64x60_LEVEL1_GPP;
294 }
295 } else {
296 cause &= mv64x60_cached_low_mask;
297 level1 = MV64x60_LEVEL1_LOW;
298 }
299 if (cause) {
300 hwirq = (level1 << MV64x60_LEVEL1_OFFSET) | __ilog2(cause);
301 virq = irq_linear_revmap(mv64x60_irq_host, hwirq);
302 }
303
304 return virq;
305}
diff --git a/arch/ppc/4xx_io/serial_sicc.c b/arch/ppc/4xx_io/serial_sicc.c
index e35483961b90..efa0a56e230b 100644
--- a/arch/ppc/4xx_io/serial_sicc.c
+++ b/arch/ppc/4xx_io/serial_sicc.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Based on drivers/char/serial_amba.c, by ARM Ltd. 4 * Based on drivers/char/serial_amba.c, by ARM Ltd.
5 * 5 *
6 * Copyright 2001 IBM Crop. 6 * Copyright 2001 IBM Corp.
7 * Author: IBM China Research Lab 7 * Author: IBM China Research Lab
8 * Yudong Yang <yangyud@cn.ibm.com> 8 * Yudong Yang <yangyud@cn.ibm.com>
9 * Yi Ge <geyi@cn.ibm.com> 9 * Yi Ge <geyi@cn.ibm.com>
@@ -155,16 +155,16 @@
155 155
156/* serial port transmit command register */ 156/* serial port transmit command register */
157 157
158#define _TxCR_ET_MASK 0x80 /* transmiter enable mask */ 158#define _TxCR_ET_MASK 0x80 /* transmitter enable mask */
159#define _TxCR_DME_MASK 0x60 /* dma mode mask */ 159#define _TxCR_DME_MASK 0x60 /* dma mode mask */
160#define _TxCR_TIE_MASK 0x10 /* empty interrupt enable mask */ 160#define _TxCR_TIE_MASK 0x10 /* empty interrupt enable mask */
161#define _TxCR_EIE_MASK 0x08 /* error interrupt enable mask */ 161#define _TxCR_EIE_MASK 0x08 /* error interrupt enable mask */
162#define _TxCR_SPE_MASK 0x04 /* stop/pause mask */ 162#define _TxCR_SPE_MASK 0x04 /* stop/pause mask */
163#define _TxCR_TB_MASK 0x02 /* transmit break mask */ 163#define _TxCR_TB_MASK 0x02 /* transmit break mask */
164 164
165#define _TxCR_ET_ENABLE _TxCR_ET_MASK /* transmiter enabled */ 165#define _TxCR_ET_ENABLE _TxCR_ET_MASK /* transmitter enabled */
166#define _TxCR_DME_DISABLE 0x00 /* transmiter disabled, TBR intr disabled */ 166#define _TxCR_DME_DISABLE 0x00 /* transmitter disabled, TBR intr disabled */
167#define _TxCR_DME_TBR 0x20 /* transmiter disabled, TBR intr enabled */ 167#define _TxCR_DME_TBR 0x20 /* transmitter disabled, TBR intr enabled */
168#define _TxCR_DME_CHAN_2 0x40 /* dma enabled, destination chann 2 */ 168#define _TxCR_DME_CHAN_2 0x40 /* dma enabled, destination chann 2 */
169#define _TxCR_DME_CHAN_3 0x60 /* dma enabled, destination chann 3 */ 169#define _TxCR_DME_CHAN_3 0x60 /* dma enabled, destination chann 3 */
170 170
diff --git a/arch/ppc/8xx_io/commproc.c b/arch/ppc/8xx_io/commproc.c
index e2c6210f234b..7088428e1fe2 100644
--- a/arch/ppc/8xx_io/commproc.c
+++ b/arch/ppc/8xx_io/commproc.c
@@ -144,7 +144,7 @@ m8xx_cpm_reset(void)
144 144
145 /* Set SDMA Bus Request priority 5. 145 /* Set SDMA Bus Request priority 5.
146 * On 860T, this also enables FEC priority 6. I am not sure 146 * On 860T, this also enables FEC priority 6. I am not sure
147 * this is what we realy want for some applications, but the 147 * this is what we really want for some applications, but the
148 * manual recommends it. 148 * manual recommends it.
149 * Bit 25, FAM can also be set to use FEC aggressive mode (860T). 149 * Bit 25, FAM can also be set to use FEC aggressive mode (860T).
150 */ 150 */
diff --git a/arch/ppc/8xx_io/fec.c b/arch/ppc/8xx_io/fec.c
index 57a9a61e54b5..d38335d2d710 100644
--- a/arch/ppc/8xx_io/fec.c
+++ b/arch/ppc/8xx_io/fec.c
@@ -1878,7 +1878,7 @@ fec_restart(struct net_device *dev, int duplex)
1878 bdp--; 1878 bdp--;
1879 bdp->cbd_sc |= BD_SC_WRAP; 1879 bdp->cbd_sc |= BD_SC_WRAP;
1880 1880
1881 /* ...and the same for transmmit. 1881 /* ...and the same for transmit.
1882 */ 1882 */
1883 bdp = fep->tx_bd_base; 1883 bdp = fep->tx_bd_base;
1884 for (i=0; i<TX_RING_SIZE; i++) { 1884 for (i=0; i<TX_RING_SIZE; i++) {
diff --git a/arch/ppc/boot/lib/vreset.c b/arch/ppc/boot/lib/vreset.c
index 463ba001fb9b..98539e9f7f96 100644
--- a/arch/ppc/boot/lib/vreset.c
+++ b/arch/ppc/boot/lib/vreset.c
@@ -518,7 +518,7 @@ setTextRegs(struct VgaRegs *svp)
518 outb(0x3c6, 0xff); /* MASK */ 518 outb(0x3c6, 0xff); /* MASK */
519 519
520 for ( i = 0; i < 0x10; i++) 520 for ( i = 0; i < 0x10; i++)
521 writeAttr(i, AC[i], 0); /* pallete */ 521 writeAttr(i, AC[i], 0); /* palette */
522 writeAttr(0x10, 0x0c, 0); /* text mode */ 522 writeAttr(0x10, 0x0c, 0); /* text mode */
523 writeAttr(0x11, 0x00, 0); /* overscan color (border) */ 523 writeAttr(0x11, 0x00, 0); /* overscan color (border) */
524 writeAttr(0x12, 0x0f, 0); /* plane enable */ 524 writeAttr(0x12, 0x0f, 0); /* plane enable */
diff --git a/arch/ppc/boot/simple/m8xx_tty.c b/arch/ppc/boot/simple/m8xx_tty.c
index cacc40fdbcfa..ea615d8ca541 100644
--- a/arch/ppc/boot/simple/m8xx_tty.c
+++ b/arch/ppc/boot/simple/m8xx_tty.c
@@ -1,7 +1,7 @@
1/* Minimal serial functions needed to send messages out the serial 1/* Minimal serial functions needed to send messages out the serial
2 * port on the MBX console. 2 * port on the MBX console.
3 * 3 *
4 * The MBX uxes SMC1 for the serial port. We reset the port and use 4 * The MBX uses SMC1 for the serial port. We reset the port and use
5 * only the first BD that EPPC-Bug set up as a character FIFO. 5 * only the first BD that EPPC-Bug set up as a character FIFO.
6 * 6 *
7 * Later versions (at least 1.4, maybe earlier) of the MBX EPPC-Bug 7 * Later versions (at least 1.4, maybe earlier) of the MBX EPPC-Bug
diff --git a/arch/ppc/boot/simple/misc-embedded.c b/arch/ppc/boot/simple/misc-embedded.c
index 10219eeca054..8a08ad397ed5 100644
--- a/arch/ppc/boot/simple/misc-embedded.c
+++ b/arch/ppc/boot/simple/misc-embedded.c
@@ -136,7 +136,7 @@ load_kernel(unsigned long load_addr, int num_words, unsigned long cksum, bd_t *b
136 136
137 /* 137 /*
138 * We link ourself to an arbitrary low address. When we run, we 138 * We link ourself to an arbitrary low address. When we run, we
139 * relocate outself to that address. __image_being points to 139 * relocate ourself to that address. __image_being points to
140 * the part of the image where the zImage is. -- Tom 140 * the part of the image where the zImage is. -- Tom
141 */ 141 */
142 zimage_start = (char *)(unsigned long)(&__image_begin); 142 zimage_start = (char *)(unsigned long)(&__image_begin);
diff --git a/arch/ppc/boot/simple/mpc52xx_tty.c b/arch/ppc/boot/simple/mpc52xx_tty.c
index 7b5924cc3c02..6955891fb031 100644
--- a/arch/ppc/boot/simple/mpc52xx_tty.c
+++ b/arch/ppc/boot/simple/mpc52xx_tty.c
@@ -33,7 +33,7 @@ static struct mpc52xx_psc __iomem *psc =
33 * rtc. We read the decrementer change during one rtc tick 33 * rtc. We read the decrementer change during one rtc tick
34 * and multiply by 4 to get the system bus clock frequency. Since a 34 * and multiply by 4 to get the system bus clock frequency. Since a
35 * rtc tick is one seconds, and that's pretty long, we change the rtc 35 * rtc tick is one seconds, and that's pretty long, we change the rtc
36 * dividers temporarly to set them 64x faster ;) 36 * dividers temporarily to set them 64x faster ;)
37 */ 37 */
38static int 38static int
39mpc52xx_ipbfreq(void) 39mpc52xx_ipbfreq(void)
diff --git a/arch/ppc/boot/simple/mv64x60_tty.c b/arch/ppc/boot/simple/mv64x60_tty.c
index 781e040a97d1..8a735787a6e9 100644
--- a/arch/ppc/boot/simple/mv64x60_tty.c
+++ b/arch/ppc/boot/simple/mv64x60_tty.c
@@ -338,7 +338,7 @@ serial_tstc(unsigned long com_port)
338 338
339 rdp = &rd[com_port][cur_rd[com_port]]; 339 rdp = &rd[com_port][cur_rd[com_port]];
340 340
341 /* Go thru rcv desc's until empty looking for one with data (no error)*/ 341 /* Go through rcv descs until empty looking for one with data (no error)*/
342 while (((rdp->cmd_stat & SDMA_DESC_CMDSTAT_O) == 0) && 342 while (((rdp->cmd_stat & SDMA_DESC_CMDSTAT_O) == 0) &&
343 (loop_count++ < RX_NUM_DESC)) { 343 (loop_count++ < RX_NUM_DESC)) {
344 344
diff --git a/arch/ppc/boot/simple/rw4/stb.h b/arch/ppc/boot/simple/rw4/stb.h
index fd98ee0f843e..9afa5ab24d26 100644
--- a/arch/ppc/boot/simple/rw4/stb.h
+++ b/arch/ppc/boot/simple/rw4/stb.h
@@ -88,7 +88,7 @@
88/*----------------------------------------------------------------------------+ 88/*----------------------------------------------------------------------------+
89| STB tasks, task stack sizes, and task priorities. The actual task priority 89| STB tasks, task stack sizes, and task priorities. The actual task priority
90| is 1 more than the specified number since priority 0 is reserved (system 90| is 1 more than the specified number since priority 0 is reserved (system
91| internaly adds 1 to supplied priority number). 91| internally adds 1 to supplied priority number).
92+----------------------------------------------------------------------------*/ 92+----------------------------------------------------------------------------*/
93#define STB_IDLE_TASK_SS (5* 1024) 93#define STB_IDLE_TASK_SS (5* 1024)
94#define STB_IDLE_TASK_PRIO 0 94#define STB_IDLE_TASK_PRIO 0
diff --git a/arch/ppc/kernel/traps.c b/arch/ppc/kernel/traps.c
index 810f7aa72e92..aea100be52c8 100644
--- a/arch/ppc/kernel/traps.c
+++ b/arch/ppc/kernel/traps.c
@@ -577,7 +577,7 @@ void program_check_exception(struct pt_regs *regs)
577 * ESR_DST (!?) or 0. In the process of chasing this with the 577 * ESR_DST (!?) or 0. In the process of chasing this with the
578 * hardware people - not sure if it can happen on any illegal 578 * hardware people - not sure if it can happen on any illegal
579 * instruction or only on FP instructions, whether there is a 579 * instruction or only on FP instructions, whether there is a
580 * pattern to occurences etc. -dgibson 31/Mar/2003 */ 580 * pattern to occurrences etc. -dgibson 31/Mar/2003 */
581 if (!(reason & REASON_TRAP) && do_mathemu(regs) == 0) { 581 if (!(reason & REASON_TRAP) && do_mathemu(regs) == 0) {
582 emulate_single_step(regs); 582 emulate_single_step(regs);
583 return; 583 return;
@@ -860,7 +860,7 @@ void SPEFloatingPointException(struct pt_regs *regs)
860 spefscr = current->thread.spefscr; 860 spefscr = current->thread.spefscr;
861 fpexc_mode = current->thread.fpexc_mode; 861 fpexc_mode = current->thread.fpexc_mode;
862 862
863 /* Hardware does not neccessarily set sticky 863 /* Hardware does not necessarily set sticky
864 * underflow/overflow/invalid flags */ 864 * underflow/overflow/invalid flags */
865 if ((spefscr & SPEFSCR_FOVF) && (fpexc_mode & PR_FP_EXC_OVF)) { 865 if ((spefscr & SPEFSCR_FOVF) && (fpexc_mode & PR_FP_EXC_OVF)) {
866 code = FPE_FLTOVF; 866 code = FPE_FLTOVF;
diff --git a/arch/ppc/mm/init.c b/arch/ppc/mm/init.c
index c374e53ae03a..390dd1995c2a 100644
--- a/arch/ppc/mm/init.c
+++ b/arch/ppc/mm/init.c
@@ -48,7 +48,7 @@
48#include "mmu_decl.h" 48#include "mmu_decl.h"
49 49
50#if defined(CONFIG_KERNEL_START_BOOL) || defined(CONFIG_LOWMEM_SIZE_BOOL) 50#if defined(CONFIG_KERNEL_START_BOOL) || defined(CONFIG_LOWMEM_SIZE_BOOL)
51/* The ammount of lowmem must be within 0xF0000000 - KERNELBASE. */ 51/* The amount of lowmem must be within 0xF0000000 - KERNELBASE. */
52#if (CONFIG_LOWMEM_SIZE > (0xF0000000 - KERNELBASE)) 52#if (CONFIG_LOWMEM_SIZE > (0xF0000000 - KERNELBASE))
53#error "You must adjust CONFIG_LOWMEM_SIZE or CONFIG_START_KERNEL" 53#error "You must adjust CONFIG_LOWMEM_SIZE or CONFIG_START_KERNEL"
54#endif 54#endif
diff --git a/arch/ppc/platforms/4xx/bubinga.c b/arch/ppc/platforms/4xx/bubinga.c
index 75857b38e894..1a7f075b754f 100644
--- a/arch/ppc/platforms/4xx/bubinga.c
+++ b/arch/ppc/platforms/4xx/bubinga.c
@@ -197,7 +197,7 @@ bios_fixup(struct pci_controller *hose, struct pcil0_regs *pcip)
197 hose->first_busno, PCI_SLOT(hose->first_busno), 197 hose->first_busno, PCI_SLOT(hose->first_busno),
198 PCI_FUNC(hose->first_busno), bar, bar_response); 198 PCI_FUNC(hose->first_busno), bar, bar_response);
199 } 199 }
200 /* end work arround */ 200 /* end workaround */
201 201
202#ifdef DEBUG 202#ifdef DEBUG
203 printk("PCI bridge regs after fixup \n"); 203 printk("PCI bridge regs after fixup \n");
diff --git a/arch/ppc/platforms/4xx/ep405.c b/arch/ppc/platforms/4xx/ep405.c
index e5adf9ba1fca..5aa295022804 100644
--- a/arch/ppc/platforms/4xx/ep405.c
+++ b/arch/ppc/platforms/4xx/ep405.c
@@ -130,7 +130,7 @@ bios_fixup(struct pci_controller *hose, struct pcil0_regs *pcip)
130 hose->first_busno, PCI_SLOT(hose->first_busno), 130 hose->first_busno, PCI_SLOT(hose->first_busno),
131 PCI_FUNC(hose->first_busno), bar, bar_response); 131 PCI_FUNC(hose->first_busno), bar, bar_response);
132 } 132 }
133 /* end work arround */ 133 /* end workaround */
134#endif 134#endif
135} 135}
136 136
diff --git a/arch/ppc/platforms/4xx/ibmnp405h.h b/arch/ppc/platforms/4xx/ibmnp405h.h
index 4aa8821b478b..08a6a7791903 100644
--- a/arch/ppc/platforms/4xx/ibmnp405h.h
+++ b/arch/ppc/platforms/4xx/ibmnp405h.h
@@ -80,7 +80,7 @@
80#define DCRN_CPMFR_BASE 0x0B9 80#define DCRN_CPMFR_BASE 0x0B9
81#define DCRN_CPMER_BASE 0x0B8 81#define DCRN_CPMER_BASE 0x0B8
82 82
83/* CPM Clocking & Power Mangement defines */ 83/* CPM Clocking & Power Management defines */
84#define IBM_CPM_PCI 0x40000000 /* PCI */ 84#define IBM_CPM_PCI 0x40000000 /* PCI */
85#define IBM_CPM_EMAC2 0x20000000 /* EMAC 2 MII */ 85#define IBM_CPM_EMAC2 0x20000000 /* EMAC 2 MII */
86#define IBM_CPM_EMAC3 0x04000000 /* EMAC 3 MII */ 86#define IBM_CPM_EMAC3 0x04000000 /* EMAC 3 MII */
diff --git a/arch/ppc/platforms/4xx/sycamore.c b/arch/ppc/platforms/4xx/sycamore.c
index c47493e344c2..8689f3e8ef3a 100644
--- a/arch/ppc/platforms/4xx/sycamore.c
+++ b/arch/ppc/platforms/4xx/sycamore.c
@@ -225,7 +225,7 @@ bios_fixup(struct pci_controller *hose, struct pcil0_regs *pcip)
225 hose->first_busno, PCI_SLOT(hose->first_busno), 225 hose->first_busno, PCI_SLOT(hose->first_busno),
226 PCI_FUNC(hose->first_busno), bar, bar_response); 226 PCI_FUNC(hose->first_busno), bar, bar_response);
227 } 227 }
228 /* end work arround */ 228 /* end workaround */
229 229
230#ifdef DEBUG 230#ifdef DEBUG
231 printk("PCI bridge regs after fixup \n"); 231 printk("PCI bridge regs after fixup \n");
diff --git a/arch/ppc/platforms/4xx/walnut.c b/arch/ppc/platforms/4xx/walnut.c
index f414d2d4c58e..2f9772340854 100644
--- a/arch/ppc/platforms/4xx/walnut.c
+++ b/arch/ppc/platforms/4xx/walnut.c
@@ -200,7 +200,7 @@ bios_fixup(struct pci_controller *hose, struct pcil0_regs *pcip)
200 hose->first_busno, PCI_SLOT(hose->first_busno), 200 hose->first_busno, PCI_SLOT(hose->first_busno),
201 PCI_FUNC(hose->first_busno), bar, bar_response); 201 PCI_FUNC(hose->first_busno), bar, bar_response);
202 } 202 }
203 /* end work arround */ 203 /* end work around */
204 204
205#ifdef DEBUG 205#ifdef DEBUG
206 printk("PCI bridge regs after fixup \n"); 206 printk("PCI bridge regs after fixup \n");
diff --git a/arch/ppc/platforms/ev64360.c b/arch/ppc/platforms/ev64360.c
index f87e06f6bab9..f8baf05f16ce 100644
--- a/arch/ppc/platforms/ev64360.c
+++ b/arch/ppc/platforms/ev64360.c
@@ -473,7 +473,7 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
473 * are non-zero, then we should use the board info from the bd_t 473 * are non-zero, then we should use the board info from the bd_t
474 * structure and the cmdline pointed to by r6 instead of the 474 * structure and the cmdline pointed to by r6 instead of the
475 * information from birecs, if any. Otherwise, use the information 475 * information from birecs, if any. Otherwise, use the information
476 * from birecs as discovered by the preceeding call to 476 * from birecs as discovered by the preceding call to
477 * parse_bootinfo(). This rule should work with both PPCBoot, which 477 * parse_bootinfo(). This rule should work with both PPCBoot, which
478 * uses a bd_t board info structure, and the kernel boot wrapper, 478 * uses a bd_t board info structure, and the kernel boot wrapper,
479 * which uses birecs. 479 * which uses birecs.
diff --git a/arch/ppc/platforms/hdpu.c b/arch/ppc/platforms/hdpu.c
index d809e17aa536..ca5de13712fd 100644
--- a/arch/ppc/platforms/hdpu.c
+++ b/arch/ppc/platforms/hdpu.c
@@ -144,7 +144,7 @@ static void __init hdpu_setup_peripherals(void)
144 144
145 /* Enable pipelining */ 145 /* Enable pipelining */
146 mv64x60_set_bits(&bh, MV64x60_CPU_CONFIG, (1 << 13)); 146 mv64x60_set_bits(&bh, MV64x60_CPU_CONFIG, (1 << 13));
147 /* Enable Snoop Pipelineing */ 147 /* Enable Snoop Pipelining */
148 mv64x60_set_bits(&bh, MV64360_D_UNIT_CONTROL_HIGH, (1 << 24)); 148 mv64x60_set_bits(&bh, MV64360_D_UNIT_CONTROL_HIGH, (1 << 24));
149 149
150 /* 150 /*
diff --git a/arch/ppc/platforms/katana.c b/arch/ppc/platforms/katana.c
index 720f8b3e2fbc..c289e9f1b251 100644
--- a/arch/ppc/platforms/katana.c
+++ b/arch/ppc/platforms/katana.c
@@ -880,7 +880,7 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
880 * are non-zero, then we should use the board info from the bd_t 880 * are non-zero, then we should use the board info from the bd_t
881 * structure and the cmdline pointed to by r6 instead of the 881 * structure and the cmdline pointed to by r6 instead of the
882 * information from birecs, if any. Otherwise, use the information 882 * information from birecs, if any. Otherwise, use the information
883 * from birecs as discovered by the preceeding call to 883 * from birecs as discovered by the preceding call to
884 * parse_bootinfo(). This rule should work with both PPCBoot, which 884 * parse_bootinfo(). This rule should work with both PPCBoot, which
885 * uses a bd_t board info structure, and the kernel boot wrapper, 885 * uses a bd_t board info structure, and the kernel boot wrapper,
886 * which uses birecs. 886 * which uses birecs.
diff --git a/arch/ppc/platforms/mbx.h b/arch/ppc/platforms/mbx.h
index fe81ca4ea0a2..1cf36fa3592d 100644
--- a/arch/ppc/platforms/mbx.h
+++ b/arch/ppc/platforms/mbx.h
@@ -37,7 +37,7 @@ typedef struct bd_info {
37 37
38/* Memory map for the MBX as configured by EPPC-Bug. We could reprogram 38/* Memory map for the MBX as configured by EPPC-Bug. We could reprogram
39 * The SIU and PCI bridge, and try to use larger MMU pages, but the 39 * The SIU and PCI bridge, and try to use larger MMU pages, but the
40 * performance gain is not measureable and it certainly complicates the 40 * performance gain is not measurable and it certainly complicates the
41 * generic MMU model. 41 * generic MMU model.
42 * 42 *
43 * In a effort to minimize memory usage for embedded applications, any 43 * In a effort to minimize memory usage for embedded applications, any
diff --git a/arch/ppc/platforms/mvme5100.h b/arch/ppc/platforms/mvme5100.h
index 9e2a09e636ae..fbb5495165c7 100644
--- a/arch/ppc/platforms/mvme5100.h
+++ b/arch/ppc/platforms/mvme5100.h
@@ -69,7 +69,7 @@
69 69
70#define STD_COM_FLAGS ASYNC_BOOT_AUTOCONF 70#define STD_COM_FLAGS ASYNC_BOOT_AUTOCONF
71 71
72/* All UART IRQ's are wire-OR'd to one MPIC IRQ */ 72/* All UART IRQs are wire-OR'd to one MPIC IRQ */
73#define STD_SERIAL_PORT_DFNS \ 73#define STD_SERIAL_PORT_DFNS \
74 { 0, BASE_BAUD, MVME5100_SERIAL_1, \ 74 { 0, BASE_BAUD, MVME5100_SERIAL_1, \
75 MVME5100_SERIAL_IRQ, \ 75 MVME5100_SERIAL_IRQ, \
diff --git a/arch/ppc/platforms/pplus.h b/arch/ppc/platforms/pplus.h
index a07cbbdd72c6..a4bbaa8d858f 100644
--- a/arch/ppc/platforms/pplus.h
+++ b/arch/ppc/platforms/pplus.h
@@ -18,7 +18,7 @@
18#include <asm/io.h> 18#include <asm/io.h>
19 19
20/* 20/*
21 * Due to limiations imposed by legacy hardware (primaryily IDE controllers), 21 * Due to limitations imposed by legacy hardware (primarily IDE controllers),
22 * the PPLUS boards operate using a PReP address map. 22 * the PPLUS boards operate using a PReP address map.
23 * 23 *
24 * From Processor (physical) -> PCI: 24 * From Processor (physical) -> PCI:
diff --git a/arch/ppc/platforms/prep_pci.c b/arch/ppc/platforms/prep_pci.c
index c627ba41335f..1df3150f016e 100644
--- a/arch/ppc/platforms/prep_pci.c
+++ b/arch/ppc/platforms/prep_pci.c
@@ -589,9 +589,9 @@ static unsigned char prep_pci_intpins[4][4] =
589 { 4, 1, 2, 3}, /* Buses 3, 7, 11 ... */ 589 { 4, 1, 2, 3}, /* Buses 3, 7, 11 ... */
590}; 590};
591 591
592/* We have to turn on LEVEL mode for changed IRQ's */ 592/* We have to turn on LEVEL mode for changed IRQs */
593/* All PCI IRQ's need to be level mode, so this should be something 593/* All PCI IRQs need to be level mode, so this should be something
594 * other than hard-coded as well... IRQ's are individually mappable 594 * other than hard-coded as well... IRQs are individually mappable
595 * to either edge or level. 595 * to either edge or level.
596 */ 596 */
597 597
@@ -923,8 +923,8 @@ prep_sandalfoot_setup_pci(char *irq_edge_mask_lo, char *irq_edge_mask_hi)
923 Motherboard_map_name = "IBM 6015/7020 (Sandalfoot/Sandalbow)"; 923 Motherboard_map_name = "IBM 6015/7020 (Sandalfoot/Sandalbow)";
924 Motherboard_map = ibm6015_pci_IRQ_map; 924 Motherboard_map = ibm6015_pci_IRQ_map;
925 Motherboard_routes = ibm6015_pci_IRQ_routes; 925 Motherboard_routes = ibm6015_pci_IRQ_routes;
926 *irq_edge_mask_lo = 0x00; /* irq's 0-7 all edge-triggered */ 926 *irq_edge_mask_lo = 0x00; /* IRQs 0-7 all edge-triggered */
927 *irq_edge_mask_hi = 0xA0; /* irq's 13, 15 level-triggered */ 927 *irq_edge_mask_hi = 0xA0; /* IRQs 13, 15 level-triggered */
928} 928}
929 929
930void __init 930void __init
@@ -933,8 +933,8 @@ prep_thinkpad_setup_pci(char *irq_edge_mask_lo, char *irq_edge_mask_hi)
933 Motherboard_map_name = "IBM Thinkpad 850/860"; 933 Motherboard_map_name = "IBM Thinkpad 850/860";
934 Motherboard_map = Nobis_pci_IRQ_map; 934 Motherboard_map = Nobis_pci_IRQ_map;
935 Motherboard_routes = Nobis_pci_IRQ_routes; 935 Motherboard_routes = Nobis_pci_IRQ_routes;
936 *irq_edge_mask_lo = 0x00; /* irq's 0-7 all edge-triggered */ 936 *irq_edge_mask_lo = 0x00; /* IRQs 0-7 all edge-triggered */
937 *irq_edge_mask_hi = 0xA0; /* irq's 13, 15 level-triggered */ 937 *irq_edge_mask_hi = 0xA0; /* IRQs 13, 15 level-triggered */
938} 938}
939 939
940void __init 940void __init
@@ -943,8 +943,8 @@ prep_carolina_setup_pci(char *irq_edge_mask_lo, char *irq_edge_mask_hi)
943 Motherboard_map_name = "IBM 7248, PowerSeries 830/850 (Carolina)"; 943 Motherboard_map_name = "IBM 7248, PowerSeries 830/850 (Carolina)";
944 Motherboard_map = ibm8xx_pci_IRQ_map; 944 Motherboard_map = ibm8xx_pci_IRQ_map;
945 Motherboard_routes = ibm8xx_pci_IRQ_routes; 945 Motherboard_routes = ibm8xx_pci_IRQ_routes;
946 *irq_edge_mask_lo = 0x00; /* irq's 0-7 all edge-triggered */ 946 *irq_edge_mask_lo = 0x00; /* IRQs 0-7 all edge-triggered */
947 *irq_edge_mask_hi = 0xA4; /* irq's 10, 13, 15 level-triggered */ 947 *irq_edge_mask_hi = 0xA4; /* IRQs 10, 13, 15 level-triggered */
948} 948}
949 949
950void __init 950void __init
@@ -954,8 +954,8 @@ prep_tiger1_setup_pci(char *irq_edge_mask_lo, char *irq_edge_mask_hi)
954 Motherboard_map = ibm43p_pci_IRQ_map; 954 Motherboard_map = ibm43p_pci_IRQ_map;
955 Motherboard_routes = ibm43p_pci_IRQ_routes; 955 Motherboard_routes = ibm43p_pci_IRQ_routes;
956 Motherboard_non0 = ibm43p_pci_map_non0; 956 Motherboard_non0 = ibm43p_pci_map_non0;
957 *irq_edge_mask_lo = 0x00; /* irq's 0-7 all edge-triggered */ 957 *irq_edge_mask_lo = 0x00; /* IRQs 0-7 all edge-triggered */
958 *irq_edge_mask_hi = 0xA0; /* irq's 13, 15 level-triggered */ 958 *irq_edge_mask_hi = 0xA0; /* IRQs 13, 15 level-triggered */
959} 959}
960 960
961void __init 961void __init
diff --git a/arch/ppc/platforms/prep_setup.c b/arch/ppc/platforms/prep_setup.c
index f166299571d6..6f21110a9747 100644
--- a/arch/ppc/platforms/prep_setup.c
+++ b/arch/ppc/platforms/prep_setup.c
@@ -593,7 +593,7 @@ static void __init prep_init_sound(void)
593 PPC_DEVICE *audiodevice = NULL; 593 PPC_DEVICE *audiodevice = NULL;
594 594
595 /* 595 /*
596 * Get the needed resource informations from residual data. 596 * Get the needed resource information from residual data.
597 * 597 *
598 */ 598 */
599 if (have_residual_data) 599 if (have_residual_data)
@@ -632,9 +632,9 @@ static void __init prep_init_sound(void)
632 } 632 }
633 633
634 /* 634 /*
635 * Find a way to push these informations to the cs4232 driver 635 * Find a way to push this information to the cs4232 driver
636 * Give it out with printk, when not in cmd_line? 636 * Give it out with printk, when not in cmd_line?
637 * Append it to cmd_line and boot_command_line? 637 * Append it to cmd_line and boot_command_line?
638 * Format is cs4232=io,irq,dma,dma2 638 * Format is cs4232=io,irq,dma,dma2
639 */ 639 */
640} 640}
diff --git a/arch/ppc/platforms/prpmc750.h b/arch/ppc/platforms/prpmc750.h
index 4c7adcc9ae33..c4dcff09d7ca 100644
--- a/arch/ppc/platforms/prpmc750.h
+++ b/arch/ppc/platforms/prpmc750.h
@@ -16,7 +16,7 @@
16#define __ASM_PRPMC750_H__ 16#define __ASM_PRPMC750_H__
17 17
18/* 18/*
19 * Due to limiations imposed by legacy hardware (primaryily IDE controllers), 19 * Due to limitations imposed by legacy hardware (primarily IDE controllers),
20 * the PrPMC750 carrier board operates using a PReP address map. 20 * the PrPMC750 carrier board operates using a PReP address map.
21 * 21 *
22 * From Processor (physical) -> PCI: 22 * From Processor (physical) -> PCI:
diff --git a/arch/ppc/platforms/radstone_ppc7d.c b/arch/ppc/platforms/radstone_ppc7d.c
index 13d70ab50bf1..b55860734a72 100644
--- a/arch/ppc/platforms/radstone_ppc7d.c
+++ b/arch/ppc/platforms/radstone_ppc7d.c
@@ -1371,7 +1371,7 @@ void __init platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
1371 * are non-zero, then we should use the board info from the bd_t 1371 * are non-zero, then we should use the board info from the bd_t
1372 * structure and the cmdline pointed to by r6 instead of the 1372 * structure and the cmdline pointed to by r6 instead of the
1373 * information from birecs, if any. Otherwise, use the information 1373 * information from birecs, if any. Otherwise, use the information
1374 * from birecs as discovered by the preceeding call to 1374 * from birecs as discovered by the preceding call to
1375 * parse_bootinfo(). This rule should work with both PPCBoot, which 1375 * parse_bootinfo(). This rule should work with both PPCBoot, which
1376 * uses a bd_t board info structure, and the kernel boot wrapper, 1376 * uses a bd_t board info structure, and the kernel boot wrapper,
1377 * which uses birecs. 1377 * which uses birecs.
diff --git a/arch/ppc/platforms/sandpoint.c b/arch/ppc/platforms/sandpoint.c
index a76002af686f..3352fae1c722 100644
--- a/arch/ppc/platforms/sandpoint.c
+++ b/arch/ppc/platforms/sandpoint.c
@@ -54,7 +54,7 @@
54 * 54 *
55 * 55 *
56 * Motorola has finally released a version of DINK32 that correctly 56 * Motorola has finally released a version of DINK32 that correctly
57 * (seemingly) initalizes the memory controller correctly, regardless 57 * (seemingly) initializes the memory controller correctly, regardless
58 * of the amount of memory in the system. Once a method of determining 58 * of the amount of memory in the system. Once a method of determining
59 * what version of DINK initializes the system for us, if applicable, is 59 * what version of DINK initializes the system for us, if applicable, is
60 * found, we can hopefully stop hardcoding 32MB of RAM. 60 * found, we can hopefully stop hardcoding 32MB of RAM.
@@ -473,7 +473,7 @@ sandpoint_request_io(void)
473arch_initcall(sandpoint_request_io); 473arch_initcall(sandpoint_request_io);
474 474
475/* 475/*
476 * Interrupt setup and service. Interrrupts on the Sandpoint come 476 * Interrupt setup and service. Interrupts on the Sandpoint come
477 * from the four PCI slots plus the 8259 in the Winbond Super I/O (SIO). 477 * from the four PCI slots plus the 8259 in the Winbond Super I/O (SIO).
478 * The 8259 is cascaded from EPIC IRQ0, IRQ1-4 map to PCI slots 1-4, 478 * The 8259 is cascaded from EPIC IRQ0, IRQ1-4 map to PCI slots 1-4,
479 * IDE is on EPIC 7 and 8. 479 * IDE is on EPIC 7 and 8.
@@ -505,7 +505,7 @@ sandpoint_find_end_of_memory(void)
505 if (bp->bi_memsize) 505 if (bp->bi_memsize)
506 return bp->bi_memsize; 506 return bp->bi_memsize;
507 507
508 /* DINK32 13.0 correctly initalizes things, so iff you use 508 /* DINK32 13.0 correctly initializes things, so iff you use
509 * this you _should_ be able to change this instead of a 509 * this you _should_ be able to change this instead of a
510 * hardcoded value. */ 510 * hardcoded value. */
511#if 0 511#if 0
@@ -677,7 +677,7 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
677 * are non-zero, then we should use the board info from the bd_t 677 * are non-zero, then we should use the board info from the bd_t
678 * structure and the cmdline pointed to by r6 instead of the 678 * structure and the cmdline pointed to by r6 instead of the
679 * information from birecs, if any. Otherwise, use the information 679 * information from birecs, if any. Otherwise, use the information
680 * from birecs as discovered by the preceeding call to 680 * from birecs as discovered by the preceding call to
681 * parse_bootinfo(). This rule should work with both PPCBoot, which 681 * parse_bootinfo(). This rule should work with both PPCBoot, which
682 * uses a bd_t board info structure, and the kernel boot wrapper, 682 * uses a bd_t board info structure, and the kernel boot wrapper,
683 * which uses birecs. 683 * which uses birecs.
diff --git a/arch/ppc/syslib/harrier.c b/arch/ppc/syslib/harrier.c
index c1583f488325..45b797b3a336 100644
--- a/arch/ppc/syslib/harrier.c
+++ b/arch/ppc/syslib/harrier.c
@@ -210,7 +210,7 @@ harrier_init(struct pci_controller *hose,
210 * This assumes that PPCBug has initialized the memory controller (SMC) 210 * This assumes that PPCBug has initialized the memory controller (SMC)
211 * on the Harrier correctly (i.e., it does no sanity checking). 211 * on the Harrier correctly (i.e., it does no sanity checking).
212 * It also assumes that the memory base registers are set to configure the 212 * It also assumes that the memory base registers are set to configure the
213 * memory as contigous starting with "RAM A BASE", "RAM B BASE", etc. 213 * memory as contiguous starting with "RAM A BASE", "RAM B BASE", etc.
214 * however, RAM base registers can be skipped (e.g. A, B, C are set, 214 * however, RAM base registers can be skipped (e.g. A, B, C are set,
215 * D is skipped but E is set is okay). 215 * D is skipped but E is set is okay).
216 */ 216 */
diff --git a/arch/ppc/syslib/hawk_common.c b/arch/ppc/syslib/hawk_common.c
index c5bf16b0d6a1..86821d8753ed 100644
--- a/arch/ppc/syslib/hawk_common.c
+++ b/arch/ppc/syslib/hawk_common.c
@@ -165,7 +165,7 @@ hawk_init(struct pci_controller *hose,
165 processor_pci_mem_start + 165 processor_pci_mem_start +
166 hose->mem_space.start) | 0x0); 166 hose->mem_space.start) | 0x0);
167 167
168 /* Map MPIC into vitual memory */ 168 /* Map MPIC into virtual memory */
169 OpenPIC_Addr = ioremap(processor_mpic_base, HAWK_MPIC_SIZE); 169 OpenPIC_Addr = ioremap(processor_mpic_base, HAWK_MPIC_SIZE);
170 170
171 return 0; 171 return 0;
@@ -176,7 +176,7 @@ hawk_init(struct pci_controller *hose,
176 * This assumes that PPCBug has initialized the memory controller (SMC) 176 * This assumes that PPCBug has initialized the memory controller (SMC)
177 * on the Falcon/HAWK correctly (i.e., it does no sanity checking). 177 * on the Falcon/HAWK correctly (i.e., it does no sanity checking).
178 * It also assumes that the memory base registers are set to configure the 178 * It also assumes that the memory base registers are set to configure the
179 * memory as contigous starting with "RAM A BASE", "RAM B BASE", etc. 179 * memory as contiguous starting with "RAM A BASE", "RAM B BASE", etc.
180 * however, RAM base registers can be skipped (e.g. A, B, C are set, 180 * however, RAM base registers can be skipped (e.g. A, B, C are set,
181 * D is skipped but E is set is okay). 181 * D is skipped but E is set is okay).
182 */ 182 */
diff --git a/arch/ppc/syslib/m82xx_pci.c b/arch/ppc/syslib/m82xx_pci.c
index e3b586b1ede9..fe860d52e2e4 100644
--- a/arch/ppc/syslib/m82xx_pci.c
+++ b/arch/ppc/syslib/m82xx_pci.c
@@ -197,7 +197,7 @@ pq2ads_setup_pci(struct pci_controller *hose)
197 CPM high 0b0000 197 CPM high 0b0000
198 CPM middle 0b0001 198 CPM middle 0b0001
199 CPM low 0b0010 199 CPM low 0b0010
200 PCI reguest 0b0011 200 PCI request 0b0011
201 Reserved 0b0100 201 Reserved 0b0100
202 Reserved 0b0101 202 Reserved 0b0101
203 Internal Core 0b0110 203 Internal Core 0b0110
diff --git a/arch/ppc/syslib/mpc10x_common.c b/arch/ppc/syslib/mpc10x_common.c
index 2fc7c4150a18..437a294527a9 100644
--- a/arch/ppc/syslib/mpc10x_common.c
+++ b/arch/ppc/syslib/mpc10x_common.c
@@ -432,7 +432,7 @@ mpc10x_bridge_init(struct pci_controller *hose,
432 phys_eumb_base); 432 phys_eumb_base);
433 } 433 }
434 434
435 /* IRQ's are determined at runtime */ 435 /* IRQs are determined at runtime */
436 ppc_sys_platform_devices[MPC10X_IIC1].resource[1].start = MPC10X_I2C_IRQ; 436 ppc_sys_platform_devices[MPC10X_IIC1].resource[1].start = MPC10X_I2C_IRQ;
437 ppc_sys_platform_devices[MPC10X_IIC1].resource[1].end = MPC10X_I2C_IRQ; 437 ppc_sys_platform_devices[MPC10X_IIC1].resource[1].end = MPC10X_I2C_IRQ;
438 ppc_sys_platform_devices[MPC10X_DMA0].resource[1].start = MPC10X_DMA0_IRQ; 438 ppc_sys_platform_devices[MPC10X_DMA0].resource[1].start = MPC10X_DMA0_IRQ;
@@ -646,7 +646,7 @@ void __init mpc10x_set_openpic(void)
646 openpic_set_sources(EPIC_IRQ_BASE, 3, OpenPIC_Addr + 0x11020); 646 openpic_set_sources(EPIC_IRQ_BASE, 3, OpenPIC_Addr + 0x11020);
647 /* Skip reserved space and map Message Unit Interrupt (I2O) */ 647 /* Skip reserved space and map Message Unit Interrupt (I2O) */
648 openpic_set_sources(EPIC_IRQ_BASE + 3, 1, OpenPIC_Addr + 0x110C0); 648 openpic_set_sources(EPIC_IRQ_BASE + 3, 1, OpenPIC_Addr + 0x110C0);
649 /* Skip reserved space and map Serial Interupts */ 649 /* Skip reserved space and map Serial Interrupts */
650 openpic_set_sources(EPIC_IRQ_BASE + 4, 2, OpenPIC_Addr + 0x11120); 650 openpic_set_sources(EPIC_IRQ_BASE + 4, 2, OpenPIC_Addr + 0x11120);
651 651
652 openpic_init(NUM_8259_INTERRUPTS); 652 openpic_init(NUM_8259_INTERRUPTS);
diff --git a/arch/ppc/syslib/mpc52xx_setup.c b/arch/ppc/syslib/mpc52xx_setup.c
index 80c609019bda..ecfa2c0f8ba3 100644
--- a/arch/ppc/syslib/mpc52xx_setup.c
+++ b/arch/ppc/syslib/mpc52xx_setup.c
@@ -252,7 +252,7 @@ mpc52xx_setup_cpu(void)
252 out_be32(&xlb->snoop_window, MPC52xx_PCI_TARGET_MEM | 0x1d); 252 out_be32(&xlb->snoop_window, MPC52xx_PCI_TARGET_MEM | 0x1d);
253 253
254 /* Disable XLB pipelining */ 254 /* Disable XLB pipelining */
255 /* (cfr errate 292. We could do this only just before ATA PIO 255 /* (cfr errata 292. We could do this only just before ATA PIO
256 transaction and re-enable it after ...) */ 256 transaction and re-enable it after ...) */
257 out_be32(&xlb->config, in_be32(&xlb->config) | MPC52xx_XLB_CFG_PLDIS); 257 out_be32(&xlb->config, in_be32(&xlb->config) | MPC52xx_XLB_CFG_PLDIS);
258 258
diff --git a/arch/ppc/syslib/mpc8xx_devices.c b/arch/ppc/syslib/mpc8xx_devices.c
index 31fb56593d17..c05ac87ece4c 100644
--- a/arch/ppc/syslib/mpc8xx_devices.c
+++ b/arch/ppc/syslib/mpc8xx_devices.c
@@ -21,7 +21,7 @@
21#include <asm/irq.h> 21#include <asm/irq.h>
22#include <asm/ppc_sys.h> 22#include <asm/ppc_sys.h>
23 23
24/* We use offsets for IORESOURCE_MEM to do not set dependences at compile time. 24/* We use offsets for IORESOURCE_MEM to do not set dependencies at compile time.
25 * They will get fixed up by mach_mpc8xx_fixup 25 * They will get fixed up by mach_mpc8xx_fixup
26 */ 26 */
27 27
diff --git a/arch/ppc/syslib/mv64x60.c b/arch/ppc/syslib/mv64x60.c
index a6f8b686ea83..8485a68cd475 100644
--- a/arch/ppc/syslib/mv64x60.c
+++ b/arch/ppc/syslib/mv64x60.c
@@ -490,7 +490,7 @@ static struct platform_device *mv64x60_pd_devs[] __initdata = {
490/* 490/*
491 * mv64x60_init() 491 * mv64x60_init()
492 * 492 *
493 * Initialze the bridge based on setting passed in via 'si'. The bridge 493 * Initialize the bridge based on setting passed in via 'si'. The bridge
494 * handle, 'bh', will be set so that it can be used to make subsequent 494 * handle, 'bh', will be set so that it can be used to make subsequent
495 * calls to routines in this file. 495 * calls to routines in this file.
496 */ 496 */
@@ -1704,7 +1704,7 @@ gt64260_disable_all_windows(struct mv64x60_handle *bh,
1704/* 1704/*
1705 * gt64260a_chip_specific_init() 1705 * gt64260a_chip_specific_init()
1706 * 1706 *
1707 * Implement errata work arounds for the GT64260A. 1707 * Implement errata workarounds for the GT64260A.
1708 */ 1708 */
1709static void __init 1709static void __init
1710gt64260a_chip_specific_init(struct mv64x60_handle *bh, 1710gt64260a_chip_specific_init(struct mv64x60_handle *bh,
@@ -1776,7 +1776,7 @@ gt64260a_chip_specific_init(struct mv64x60_handle *bh,
1776/* 1776/*
1777 * gt64260b_chip_specific_init() 1777 * gt64260b_chip_specific_init()
1778 * 1778 *
1779 * Implement errata work arounds for the GT64260B. 1779 * Implement errata workarounds for the GT64260B.
1780 */ 1780 */
1781static void __init 1781static void __init
1782gt64260b_chip_specific_init(struct mv64x60_handle *bh, 1782gt64260b_chip_specific_init(struct mv64x60_handle *bh,
@@ -2316,7 +2316,7 @@ mv64360_set_mpsc2regs_window(struct mv64x60_handle *bh, u32 base)
2316/* 2316/*
2317 * mv64360_chip_specific_init() 2317 * mv64360_chip_specific_init()
2318 * 2318 *
2319 * Implement errata work arounds for the MV64360. 2319 * Implement errata workarounds for the MV64360.
2320 */ 2320 */
2321static void __init 2321static void __init
2322mv64360_chip_specific_init(struct mv64x60_handle *bh, 2322mv64360_chip_specific_init(struct mv64x60_handle *bh,
@@ -2336,7 +2336,7 @@ mv64360_chip_specific_init(struct mv64x60_handle *bh,
2336/* 2336/*
2337 * mv64460_chip_specific_init() 2337 * mv64460_chip_specific_init()
2338 * 2338 *
2339 * Implement errata work arounds for the MV64460. 2339 * Implement errata workarounds for the MV64460.
2340 */ 2340 */
2341static void __init 2341static void __init
2342mv64460_chip_specific_init(struct mv64x60_handle *bh, 2342mv64460_chip_specific_init(struct mv64x60_handle *bh,
diff --git a/arch/ppc/syslib/ocp.c b/arch/ppc/syslib/ocp.c
index 50c55622ece9..491fe9a57229 100644
--- a/arch/ppc/syslib/ocp.c
+++ b/arch/ppc/syslib/ocp.c
@@ -27,7 +27,7 @@
27 * device model. The devices on the OCP bus are seeded by an 27 * device model. The devices on the OCP bus are seeded by an
28 * an initial OCP device array created by the arch-specific 28 * an initial OCP device array created by the arch-specific
29 * Device entries can be added/removed/modified through OCP 29 * Device entries can be added/removed/modified through OCP
30 * helper functions to accomodate system and board-specific 30 * helper functions to accommodate system and board-specific
31 * parameters commonly found in embedded systems. OCP also 31 * parameters commonly found in embedded systems. OCP also
32 * provides a standard method for devices to describe extended 32 * provides a standard method for devices to describe extended
33 * attributes about themselves to the system. A standard access 33 * attributes about themselves to the system. A standard access
diff --git a/arch/ppc/syslib/ppc403_pic.c b/arch/ppc/syslib/ppc403_pic.c
index 607ebd111d44..c3b7b8bfbcfe 100644
--- a/arch/ppc/syslib/ppc403_pic.c
+++ b/arch/ppc/syslib/ppc403_pic.c
@@ -112,7 +112,7 @@ ppc4xx_pic_init(void)
112 112
113 /* 113 /*
114 * Disable all external interrupts until they are 114 * Disable all external interrupts until they are
115 * explicity requested. 115 * explicitly requested.
116 */ 116 */
117 ppc_cached_irq_mask[0] = 0; 117 ppc_cached_irq_mask[0] = 0;
118 118
diff --git a/arch/ppc/syslib/ppc405_pci.c b/arch/ppc/syslib/ppc405_pci.c
index d6d838b16dac..9e9035693bfa 100644
--- a/arch/ppc/syslib/ppc405_pci.c
+++ b/arch/ppc/syslib/ppc405_pci.c
@@ -137,7 +137,7 @@ ppc4xx_find_bridges(void)
137 hose_a->pci_mem_offset = 0; 137 hose_a->pci_mem_offset = 0;
138 138
139 /* Setup bridge memory/IO ranges & resources 139 /* Setup bridge memory/IO ranges & resources
140 * TODO: Handle firmwares setting up a legacy ISA mem base 140 * TODO: Handle firmware setting up a legacy ISA mem base
141 */ 141 */
142 hose_a->io_space.start = PPC405_PCI_LOWER_IO; 142 hose_a->io_space.start = PPC405_PCI_LOWER_IO;
143 hose_a->io_space.end = PPC405_PCI_UPPER_IO; 143 hose_a->io_space.end = PPC405_PCI_UPPER_IO;
diff --git a/arch/ppc/syslib/ppc4xx_dma.c b/arch/ppc/syslib/ppc4xx_dma.c
index 1eef4ffed4fb..bd301868996b 100644
--- a/arch/ppc/syslib/ppc4xx_dma.c
+++ b/arch/ppc/syslib/ppc4xx_dma.c
@@ -241,7 +241,7 @@ ppc4xx_set_dma_count(unsigned int dmanr, unsigned int count)
241} 241}
242 242
243/* 243/*
244 * Returns the number of bytes left to be transfered. 244 * Returns the number of bytes left to be transferred.
245 * After a DMA transfer, this should return zero. 245 * After a DMA transfer, this should return zero.
246 * Reading this while a DMA transfer is still in progress will return 246 * Reading this while a DMA transfer is still in progress will return
247 * unpredictable results. 247 * unpredictable results.
diff --git a/arch/ppc/syslib/ppc85xx_rio.c b/arch/ppc/syslib/ppc85xx_rio.c
index 2b097800cdd9..af2425e4655f 100644
--- a/arch/ppc/syslib/ppc85xx_rio.c
+++ b/arch/ppc/syslib/ppc85xx_rio.c
@@ -349,7 +349,7 @@ EXPORT_SYMBOL_GPL(rio_hw_add_outb_message);
349 * @dev_instance: Pointer to interrupt-specific data 349 * @dev_instance: Pointer to interrupt-specific data
350 * 350 *
351 * Handles outbound message interrupts. Executes a register outbound 351 * Handles outbound message interrupts. Executes a register outbound
352 * mailbox event handler and acks the interrupt occurence. 352 * mailbox event handler and acks the interrupt occurrence.
353 */ 353 */
354static irqreturn_t 354static irqreturn_t
355mpc85xx_rio_tx_handler(int irq, void *dev_instance) 355mpc85xx_rio_tx_handler(int irq, void *dev_instance)
@@ -516,7 +516,7 @@ void rio_close_outb_mbox(struct rio_mport *mport, int mbox)
516 * @dev_instance: Pointer to interrupt-specific data 516 * @dev_instance: Pointer to interrupt-specific data
517 * 517 *
518 * Handles inbound message interrupts. Executes a registered inbound 518 * Handles inbound message interrupts. Executes a registered inbound
519 * mailbox event handler and acks the interrupt occurence. 519 * mailbox event handler and acks the interrupt occurrence.
520 */ 520 */
521static irqreturn_t 521static irqreturn_t
522mpc85xx_rio_rx_handler(int irq, void *dev_instance) 522mpc85xx_rio_rx_handler(int irq, void *dev_instance)
diff --git a/arch/ppc/syslib/xilinx_pic.c b/arch/ppc/syslib/xilinx_pic.c
index 6fd4cdbada72..3b82333e96d8 100644
--- a/arch/ppc/syslib/xilinx_pic.c
+++ b/arch/ppc/syslib/xilinx_pic.c
@@ -130,7 +130,7 @@ ppc4xx_pic_init(void)
130 130
131 /* 131 /*
132 * Disable all external interrupts until they are 132 * Disable all external interrupts until they are
133 * explicity requested. 133 * explicitly requested.
134 */ 134 */
135 intc_out_be32(intc + IER, 0); 135 intc_out_be32(intc + IER, 0);
136 136
diff --git a/arch/s390/kernel/audit.c b/arch/s390/kernel/audit.c
index 0741d9193390..d1c76fe10f29 100644
--- a/arch/s390/kernel/audit.c
+++ b/arch/s390/kernel/audit.c
@@ -23,6 +23,20 @@ static unsigned chattr_class[] = {
23~0U 23~0U
24}; 24};
25 25
26static unsigned signal_class[] = {
27#include <asm-generic/audit_signal.h>
28~0U
29};
30
31int audit_classify_arch(int arch)
32{
33#ifdef CONFIG_COMPAT
34 if (arch == AUDIT_ARCH_S390)
35 return 1;
36#endif
37 return 0;
38}
39
26int audit_classify_syscall(int abi, unsigned syscall) 40int audit_classify_syscall(int abi, unsigned syscall)
27{ 41{
28#ifdef CONFIG_COMPAT 42#ifdef CONFIG_COMPAT
@@ -51,15 +65,18 @@ static int __init audit_classes_init(void)
51 extern __u32 s390_write_class[]; 65 extern __u32 s390_write_class[];
52 extern __u32 s390_read_class[]; 66 extern __u32 s390_read_class[];
53 extern __u32 s390_chattr_class[]; 67 extern __u32 s390_chattr_class[];
68 extern __u32 s390_signal_class[];
54 audit_register_class(AUDIT_CLASS_WRITE_32, s390_write_class); 69 audit_register_class(AUDIT_CLASS_WRITE_32, s390_write_class);
55 audit_register_class(AUDIT_CLASS_READ_32, s390_read_class); 70 audit_register_class(AUDIT_CLASS_READ_32, s390_read_class);
56 audit_register_class(AUDIT_CLASS_DIR_WRITE_32, s390_dir_class); 71 audit_register_class(AUDIT_CLASS_DIR_WRITE_32, s390_dir_class);
57 audit_register_class(AUDIT_CLASS_CHATTR_32, s390_chattr_class); 72 audit_register_class(AUDIT_CLASS_CHATTR_32, s390_chattr_class);
73 audit_register_class(AUDIT_CLASS_SIGNAL_32, s390_signal_class);
58#endif 74#endif
59 audit_register_class(AUDIT_CLASS_WRITE, write_class); 75 audit_register_class(AUDIT_CLASS_WRITE, write_class);
60 audit_register_class(AUDIT_CLASS_READ, read_class); 76 audit_register_class(AUDIT_CLASS_READ, read_class);
61 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class); 77 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
62 audit_register_class(AUDIT_CLASS_CHATTR, chattr_class); 78 audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
79 audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
63 return 0; 80 return 0;
64} 81}
65 82
diff --git a/arch/s390/kernel/compat_audit.c b/arch/s390/kernel/compat_audit.c
index 16d9436bfa91..0569f5126e49 100644
--- a/arch/s390/kernel/compat_audit.c
+++ b/arch/s390/kernel/compat_audit.c
@@ -21,6 +21,11 @@ unsigned s390_read_class[] = {
21~0U 21~0U
22}; 22};
23 23
24unsigned s390_signal_class[] = {
25#include <asm-generic/audit_signal.h>
26~0U
27};
28
24int s390_classify_syscall(unsigned syscall) 29int s390_classify_syscall(unsigned syscall)
25{ 30{
26 switch(syscall) { 31 switch(syscall) {
diff --git a/arch/sparc/kernel/auxio.c b/arch/sparc/kernel/auxio.c
index 118f3eca373e..baf4ed3fb0f3 100644
--- a/arch/sparc/kernel/auxio.c
+++ b/arch/sparc/kernel/auxio.c
@@ -88,7 +88,7 @@ void set_auxio(unsigned char bits_on, unsigned char bits_off)
88 break; 88 break;
89 case sun4m: 89 case sun4m:
90 if(!auxio_register) 90 if(!auxio_register)
91 break; /* VME chassic sun4m, no auxio. */ 91 break; /* VME chassis sun4m, no auxio. */
92 regval = sbus_readb(auxio_register); 92 regval = sbus_readb(auxio_register);
93 sbus_writeb(((regval | bits_on) & ~bits_off) | AUXIO_ORMEIN4M, 93 sbus_writeb(((regval | bits_on) & ~bits_off) | AUXIO_ORMEIN4M,
94 auxio_register); 94 auxio_register);
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index 987ec6782f99..62182d2d7b0d 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -617,7 +617,7 @@ void *pci_alloc_consistent(struct pci_dev *pdev, size_t len, dma_addr_t *pba)
617 * size must be the same as what as passed into pci_alloc_consistent, 617 * size must be the same as what as passed into pci_alloc_consistent,
618 * and likewise dma_addr must be the same as what *dma_addrp was set to. 618 * and likewise dma_addr must be the same as what *dma_addrp was set to.
619 * 619 *
620 * References to the memory and mappings assosciated with cpu_addr/dma_addr 620 * References to the memory and mappings associated with cpu_addr/dma_addr
621 * past this call are illegal. 621 * past this call are illegal.
622 */ 622 */
623void pci_free_consistent(struct pci_dev *pdev, size_t n, void *p, dma_addr_t ba) 623void pci_free_consistent(struct pci_dev *pdev, size_t n, void *p, dma_addr_t ba)
diff --git a/arch/sparc/kernel/irq.c b/arch/sparc/kernel/irq.c
index bdbefa8a9742..f257a67bcf93 100644
--- a/arch/sparc/kernel/irq.c
+++ b/arch/sparc/kernel/irq.c
@@ -1,6 +1,6 @@
1/* $Id: irq.c,v 1.114 2001/12/11 04:55:51 davem Exp $ 1/* $Id: irq.c,v 1.114 2001/12/11 04:55:51 davem Exp $
2 * arch/sparc/kernel/irq.c: Interrupt request handling routines. On the 2 * arch/sparc/kernel/irq.c: Interrupt request handling routines. On the
3 * Sparc the IRQ's are basically 'cast in stone' 3 * Sparc the IRQs are basically 'cast in stone'
4 * and you are supposed to probe the prom's device 4 * and you are supposed to probe the prom's device
5 * node trees to find out who's got which IRQ. 5 * node trees to find out who's got which IRQ.
6 * 6 *
@@ -330,7 +330,7 @@ void handler_irq(int irq, struct pt_regs * regs)
330 irq_enter(); 330 irq_enter();
331 disable_pil_irq(irq); 331 disable_pil_irq(irq);
332#ifdef CONFIG_SMP 332#ifdef CONFIG_SMP
333 /* Only rotate on lower priority IRQ's (scsi, ethernet, etc.). */ 333 /* Only rotate on lower priority IRQs (scsi, ethernet, etc.). */
334 if((sparc_cpu_model==sun4m) && (irq < 10)) 334 if((sparc_cpu_model==sun4m) && (irq < 10))
335 smp4m_irq_rotate(cpu); 335 smp4m_irq_rotate(cpu);
336#endif 336#endif
@@ -371,7 +371,7 @@ void sparc_floppy_irq(int irq, void *dev_id, struct pt_regs *regs)
371} 371}
372#endif 372#endif
373 373
374/* Fast IRQ's on the Sparc can only have one routine attached to them, 374/* Fast IRQs on the Sparc can only have one routine attached to them,
375 * thus no sharing possible. 375 * thus no sharing possible.
376 */ 376 */
377int request_fast_irq(unsigned int irq, 377int request_fast_irq(unsigned int irq,
@@ -608,7 +608,7 @@ void __init init_IRQ(void)
608 break; 608 break;
609 609
610 default: 610 default:
611 prom_printf("Cannot initialize IRQ's on this Sun machine..."); 611 prom_printf("Cannot initialize IRQs on this Sun machine...");
612 break; 612 break;
613 } 613 }
614 btfixup(); 614 btfixup();
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index 5ca7e8f42bd9..791771196905 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -755,7 +755,7 @@ void __init pci_time_init(void)
755static __inline__ unsigned long do_gettimeoffset(void) 755static __inline__ unsigned long do_gettimeoffset(void)
756{ 756{
757 /* 757 /*
758 * We devide all to 100 758 * We divide all by 100
759 * to have microsecond resolution and to avoid overflow 759 * to have microsecond resolution and to avoid overflow
760 */ 760 */
761 unsigned long count = 761 unsigned long count =
@@ -956,7 +956,7 @@ EXPORT_SYMBOL(pci_device_to_OF_node);
956 * Also, think for a moment about likes of floppy.c that 956 * Also, think for a moment about likes of floppy.c that
957 * include architecture specific parts. They may want to redefine ins/outs. 957 * include architecture specific parts. They may want to redefine ins/outs.
958 * 958 *
959 * We do not use horroble macroses here because we want to 959 * We do not use horrible macros here because we want to
960 * advance pointer by sizeof(size). 960 * advance pointer by sizeof(size).
961 */ 961 */
962void outsb(unsigned long addr, const void *src, unsigned long count) 962void outsb(unsigned long addr, const void *src, unsigned long count)
diff --git a/arch/sparc/kernel/process.c b/arch/sparc/kernel/process.c
index 2940d2c1a778..8c37f8f5adb7 100644
--- a/arch/sparc/kernel/process.c
+++ b/arch/sparc/kernel/process.c
@@ -683,7 +683,7 @@ out:
683 * NOTE! Only a kernel-only process(ie the swapper or direct descendants 683 * NOTE! Only a kernel-only process(ie the swapper or direct descendants
684 * who haven't done an "execve()") should use this: it will work within 684 * who haven't done an "execve()") should use this: it will work within
685 * a system call from a "real" process, but the process memory space will 685 * a system call from a "real" process, but the process memory space will
686 * not be free'd until both the parent and the child have exited. 686 * not be freed until both the parent and the child have exited.
687 */ 687 */
688pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) 688pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
689{ 689{
diff --git a/arch/sparc/kernel/sun4d_irq.c b/arch/sparc/kernel/sun4d_irq.c
index 116d6a241ca2..396797e20c39 100644
--- a/arch/sparc/kernel/sun4d_irq.c
+++ b/arch/sparc/kernel/sun4d_irq.c
@@ -521,7 +521,7 @@ static void __init sun4d_init_timers(irq_handler_t counter_fn)
521 lvl14_save[2] += smp4d_ticker - real_irq_entry; 521 lvl14_save[2] += smp4d_ticker - real_irq_entry;
522 522
523 /* For SMP we use the level 14 ticker, however the bootup code 523 /* For SMP we use the level 14 ticker, however the bootup code
524 * has copied the firmwares level 14 vector into boot cpu's 524 * has copied the firmware's level 14 vector into the boot cpu's
525 * trap table, we must fix this now or we get squashed. 525 * trap table, we must fix this now or we get squashed.
526 */ 526 */
527 local_irq_save(flags); 527 local_irq_save(flags);
diff --git a/arch/sparc/kernel/sun4m_irq.c b/arch/sparc/kernel/sun4m_irq.c
index a654c16f4027..91a803ea88be 100644
--- a/arch/sparc/kernel/sun4m_irq.c
+++ b/arch/sparc/kernel/sun4m_irq.c
@@ -299,7 +299,7 @@ static void __init sun4m_init_timers(irq_handler_t counter_fn)
299 struct tt_entry *trap_table = &sparc_ttable[SP_TRAP_IRQ1 + (14 - 1)]; 299 struct tt_entry *trap_table = &sparc_ttable[SP_TRAP_IRQ1 + (14 - 1)];
300 300
301 /* For SMP we use the level 14 ticker, however the bootup code 301 /* For SMP we use the level 14 ticker, however the bootup code
302 * has copied the firmwares level 14 vector into boot cpu's 302 * has copied the firmware's level 14 vector into the boot cpu's
303 * trap table, we must fix this now or we get squashed. 303 * trap table, we must fix this now or we get squashed.
304 */ 304 */
305 local_irq_save(flags); 305 local_irq_save(flags);
diff --git a/arch/sparc/kernel/systbls.S b/arch/sparc/kernel/systbls.S
index e3f5b8ed4c52..90b52d4dab9a 100644
--- a/arch/sparc/kernel/systbls.S
+++ b/arch/sparc/kernel/systbls.S
@@ -80,7 +80,7 @@ sys_call_table:
80/*295*/ .long sys_fchmodat, sys_faccessat, sys_pselect6, sys_ppoll, sys_unshare 80/*295*/ .long sys_fchmodat, sys_faccessat, sys_pselect6, sys_ppoll, sys_unshare
81/*300*/ .long sys_set_robust_list, sys_get_robust_list, sys_migrate_pages, sys_mbind, sys_get_mempolicy 81/*300*/ .long sys_set_robust_list, sys_get_robust_list, sys_migrate_pages, sys_mbind, sys_get_mempolicy
82/*305*/ .long sys_set_mempolicy, sys_kexec_load, sys_move_pages, sys_getcpu, sys_epoll_pwait 82/*305*/ .long sys_set_mempolicy, sys_kexec_load, sys_move_pages, sys_getcpu, sys_epoll_pwait
83/*310*/ .long sys_utimensat 83/*310*/ .long sys_utimensat, sys_signalfd, sys_timerfd, sys_eventfd
84 84
85#ifdef CONFIG_SUNOS_EMUL 85#ifdef CONFIG_SUNOS_EMUL
86 /* Now the SunOS syscall table. */ 86 /* Now the SunOS syscall table. */
@@ -197,6 +197,7 @@ sunos_sys_table:
197 .long sunos_nosys, sunos_nosys, sunos_nosys 197 .long sunos_nosys, sunos_nosys, sunos_nosys
198 .long sunos_nosys, sunos_nosys, sunos_nosys 198 .long sunos_nosys, sunos_nosys, sunos_nosys
199 .long sunos_nosys 199 .long sunos_nosys
200/*310*/ .long sunos_nosys 200/*310*/ .long sunos_nosys, sunos_nosys, sunos_nosys
201 .long sunos_nosys
201 202
202#endif 203#endif
diff --git a/arch/sparc/prom/printf.c b/arch/sparc/prom/printf.c
index dc8b598bedbb..27fdac99f790 100644
--- a/arch/sparc/prom/printf.c
+++ b/arch/sparc/prom/printf.c
@@ -5,7 +5,7 @@
5 * Copyright (c) 2002 Pete Zaitcev (zaitcev@yahoo.com) 5 * Copyright (c) 2002 Pete Zaitcev (zaitcev@yahoo.com)
6 * 6 *
7 * We used to warn all over the code: DO NOT USE prom_printf(), 7 * We used to warn all over the code: DO NOT USE prom_printf(),
8 * and yet people do. Anton's banking code was outputing banks 8 * and yet people do. Anton's banking code was outputting banks
9 * with prom_printf for most of the 2.4 lifetime. Since an effective 9 * with prom_printf for most of the 2.4 lifetime. Since an effective
10 * stick is not available, we deployed a carrot: an early printk 10 * stick is not available, we deployed a carrot: an early printk
11 * through PROM by means of -p boot option. This ought to fix it. 11 * through PROM by means of -p boot option. This ought to fix it.
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index ad8d6b256a70..831781cab271 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -226,9 +226,6 @@ config ARCH_SPARSEMEM_DEFAULT
226 def_bool y 226 def_bool y
227 select SPARSEMEM_STATIC 227 select SPARSEMEM_STATIC
228 228
229config LARGE_ALLOCS
230 def_bool y
231
232source "mm/Kconfig" 229source "mm/Kconfig"
233 230
234config ISA 231config ISA
diff --git a/arch/sparc64/defconfig b/arch/sparc64/defconfig
index 37c2d3695658..585ef4fb7591 100644
--- a/arch/sparc64/defconfig
+++ b/arch/sparc64/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.21 3# Linux kernel version: 2.6.21
4# Sun May 6 22:46:54 2007 4# Fri May 11 14:31:45 2007
5# 5#
6CONFIG_SPARC=y 6CONFIG_SPARC=y
7CONFIG_SPARC64=y 7CONFIG_SPARC64=y
@@ -9,6 +9,7 @@ CONFIG_GENERIC_TIME=y
9CONFIG_GENERIC_CLOCKEVENTS=y 9CONFIG_GENERIC_CLOCKEVENTS=y
10CONFIG_64BIT=y 10CONFIG_64BIT=y
11CONFIG_MMU=y 11CONFIG_MMU=y
12CONFIG_QUICKLIST=y
12CONFIG_STACKTRACE_SUPPORT=y 13CONFIG_STACKTRACE_SUPPORT=y
13CONFIG_LOCKDEP_SUPPORT=y 14CONFIG_LOCKDEP_SUPPORT=y
14CONFIG_ARCH_MAY_HAVE_PC_FDC=y 15CONFIG_ARCH_MAY_HAVE_PC_FDC=y
@@ -49,6 +50,7 @@ CONFIG_POSIX_MQUEUE=y
49# CONFIG_UTS_NS is not set 50# CONFIG_UTS_NS is not set
50# CONFIG_AUDIT is not set 51# CONFIG_AUDIT is not set
51# CONFIG_IKCONFIG is not set 52# CONFIG_IKCONFIG is not set
53CONFIG_LOG_BUF_SHIFT=18
52CONFIG_SYSFS_DEPRECATED=y 54CONFIG_SYSFS_DEPRECATED=y
53CONFIG_RELAY=y 55CONFIG_RELAY=y
54# CONFIG_BLK_DEV_INITRD is not set 56# CONFIG_BLK_DEV_INITRD is not set
@@ -66,14 +68,20 @@ CONFIG_BUG=y
66CONFIG_ELF_CORE=y 68CONFIG_ELF_CORE=y
67CONFIG_BASE_FULL=y 69CONFIG_BASE_FULL=y
68CONFIG_FUTEX=y 70CONFIG_FUTEX=y
71CONFIG_ANON_INODES=y
69CONFIG_EPOLL=y 72CONFIG_EPOLL=y
73CONFIG_SIGNALFD=y
74CONFIG_TIMERFD=y
75CONFIG_EVENTFD=y
70CONFIG_SHMEM=y 76CONFIG_SHMEM=y
71CONFIG_SLAB=y
72CONFIG_VM_EVENT_COUNTERS=y 77CONFIG_VM_EVENT_COUNTERS=y
78CONFIG_SLUB_DEBUG=y
79# CONFIG_SLAB is not set
80CONFIG_SLUB=y
81# CONFIG_SLOB is not set
73CONFIG_RT_MUTEXES=y 82CONFIG_RT_MUTEXES=y
74# CONFIG_TINY_SHMEM is not set 83# CONFIG_TINY_SHMEM is not set
75CONFIG_BASE_SMALL=0 84CONFIG_BASE_SMALL=0
76# CONFIG_SLOB is not set
77 85
78# 86#
79# Loadable module support 87# Loadable module support
@@ -137,7 +145,6 @@ CONFIG_HUGETLB_PAGE_SIZE_4MB=y
137CONFIG_ARCH_SELECT_MEMORY_MODEL=y 145CONFIG_ARCH_SELECT_MEMORY_MODEL=y
138CONFIG_ARCH_SPARSEMEM_ENABLE=y 146CONFIG_ARCH_SPARSEMEM_ENABLE=y
139CONFIG_ARCH_SPARSEMEM_DEFAULT=y 147CONFIG_ARCH_SPARSEMEM_DEFAULT=y
140CONFIG_LARGE_ALLOCS=y
141CONFIG_SELECT_MEMORY_MODEL=y 148CONFIG_SELECT_MEMORY_MODEL=y
142# CONFIG_FLATMEM_MANUAL is not set 149# CONFIG_FLATMEM_MANUAL is not set
143# CONFIG_DISCONTIGMEM_MANUAL is not set 150# CONFIG_DISCONTIGMEM_MANUAL is not set
@@ -148,6 +155,7 @@ CONFIG_SPARSEMEM_STATIC=y
148CONFIG_SPLIT_PTLOCK_CPUS=4 155CONFIG_SPLIT_PTLOCK_CPUS=4
149CONFIG_RESOURCES_64BIT=y 156CONFIG_RESOURCES_64BIT=y
150CONFIG_ZONE_DMA_FLAG=0 157CONFIG_ZONE_DMA_FLAG=0
158CONFIG_NR_QUICK=1
151CONFIG_SBUS=y 159CONFIG_SBUS=y
152CONFIG_SBUSCHAR=y 160CONFIG_SBUSCHAR=y
153CONFIG_SUN_AUXIO=y 161CONFIG_SUN_AUXIO=y
@@ -305,6 +313,7 @@ CONFIG_NET_TCPPROBE=m
305# CONFIG_WIRELESS_EXT is not set 313# CONFIG_WIRELESS_EXT is not set
306# CONFIG_MAC80211 is not set 314# CONFIG_MAC80211 is not set
307# CONFIG_IEEE80211 is not set 315# CONFIG_IEEE80211 is not set
316# CONFIG_RFKILL is not set
308 317
309# 318#
310# Device Drivers 319# Device Drivers
@@ -359,8 +368,10 @@ CONFIG_ATA_OVER_ETH=m
359# 368#
360# Misc devices 369# Misc devices
361# 370#
371# CONFIG_PHANTOM is not set
362# CONFIG_SGI_IOC4 is not set 372# CONFIG_SGI_IOC4 is not set
363# CONFIG_TIFM_CORE is not set 373# CONFIG_TIFM_CORE is not set
374# CONFIG_BLINK is not set
364 375
365# 376#
366# ATA/ATAPI/MFM/RLL support 377# ATA/ATAPI/MFM/RLL support
@@ -379,6 +390,7 @@ CONFIG_BLK_DEV_IDECD=y
379# CONFIG_BLK_DEV_IDEFLOPPY is not set 390# CONFIG_BLK_DEV_IDEFLOPPY is not set
380# CONFIG_BLK_DEV_IDESCSI is not set 391# CONFIG_BLK_DEV_IDESCSI is not set
381# CONFIG_IDE_TASK_IOCTL is not set 392# CONFIG_IDE_TASK_IOCTL is not set
393CONFIG_IDE_PROC_FS=y
382 394
383# 395#
384# IDE chipset support/bugfixes 396# IDE chipset support/bugfixes
@@ -386,6 +398,7 @@ CONFIG_BLK_DEV_IDECD=y
386CONFIG_IDE_GENERIC=y 398CONFIG_IDE_GENERIC=y
387CONFIG_BLK_DEV_IDEPCI=y 399CONFIG_BLK_DEV_IDEPCI=y
388# CONFIG_IDEPCI_SHARE_IRQ is not set 400# CONFIG_IDEPCI_SHARE_IRQ is not set
401CONFIG_IDEPCI_PCIBUS_ORDER=y
389# CONFIG_BLK_DEV_OFFBOARD is not set 402# CONFIG_BLK_DEV_OFFBOARD is not set
390# CONFIG_BLK_DEV_GENERIC is not set 403# CONFIG_BLK_DEV_GENERIC is not set
391# CONFIG_BLK_DEV_OPTI621 is not set 404# CONFIG_BLK_DEV_OPTI621 is not set
@@ -521,6 +534,7 @@ CONFIG_DM_SNAPSHOT=m
521CONFIG_DM_MIRROR=m 534CONFIG_DM_MIRROR=m
522CONFIG_DM_ZERO=m 535CONFIG_DM_ZERO=m
523# CONFIG_DM_MULTIPATH is not set 536# CONFIG_DM_MULTIPATH is not set
537# CONFIG_DM_DELAY is not set
524 538
525# 539#
526# Fusion MPT device support 540# Fusion MPT device support
@@ -533,6 +547,7 @@ CONFIG_DM_ZERO=m
533# 547#
534# IEEE 1394 (FireWire) support 548# IEEE 1394 (FireWire) support
535# 549#
550# CONFIG_FIREWIRE is not set
536# CONFIG_IEEE1394 is not set 551# CONFIG_IEEE1394 is not set
537 552
538# 553#
@@ -629,6 +644,8 @@ CONFIG_BNX2=m
629# CONFIG_S2IO is not set 644# CONFIG_S2IO is not set
630# CONFIG_MYRI10GE is not set 645# CONFIG_MYRI10GE is not set
631# CONFIG_NETXEN_NIC is not set 646# CONFIG_NETXEN_NIC is not set
647# CONFIG_MLX4_CORE is not set
648CONFIG_MLX4_DEBUG=y
632 649
633# 650#
634# Token Ring devices 651# Token Ring devices
@@ -642,6 +659,16 @@ CONFIG_BNX2=m
642# CONFIG_WLAN_80211 is not set 659# CONFIG_WLAN_80211 is not set
643 660
644# 661#
662# USB Network Adapters
663#
664# CONFIG_USB_CATC is not set
665# CONFIG_USB_KAWETH is not set
666# CONFIG_USB_PEGASUS is not set
667# CONFIG_USB_RTL8150 is not set
668# CONFIG_USB_USBNET_MII is not set
669# CONFIG_USB_USBNET is not set
670
671#
645# Wan interfaces 672# Wan interfaces
646# 673#
647# CONFIG_WAN is not set 674# CONFIG_WAN is not set
@@ -711,11 +738,18 @@ CONFIG_MOUSE_PS2_LIFEBOOK=y
711CONFIG_MOUSE_PS2_TRACKPOINT=y 738CONFIG_MOUSE_PS2_TRACKPOINT=y
712# CONFIG_MOUSE_PS2_TOUCHKIT is not set 739# CONFIG_MOUSE_PS2_TOUCHKIT is not set
713CONFIG_MOUSE_SERIAL=y 740CONFIG_MOUSE_SERIAL=y
741# CONFIG_MOUSE_APPLETOUCH is not set
714# CONFIG_MOUSE_VSXXXAA is not set 742# CONFIG_MOUSE_VSXXXAA is not set
715# CONFIG_INPUT_JOYSTICK is not set 743# CONFIG_INPUT_JOYSTICK is not set
744# CONFIG_INPUT_TABLET is not set
716# CONFIG_INPUT_TOUCHSCREEN is not set 745# CONFIG_INPUT_TOUCHSCREEN is not set
717CONFIG_INPUT_MISC=y 746CONFIG_INPUT_MISC=y
718CONFIG_INPUT_SPARCSPKR=y 747CONFIG_INPUT_SPARCSPKR=y
748# CONFIG_INPUT_ATI_REMOTE is not set
749# CONFIG_INPUT_ATI_REMOTE2 is not set
750# CONFIG_INPUT_KEYSPAN_REMOTE is not set
751# CONFIG_INPUT_POWERMATE is not set
752# CONFIG_INPUT_YEALINK is not set
719# CONFIG_INPUT_UINPUT is not set 753# CONFIG_INPUT_UINPUT is not set
720# CONFIG_INPUT_POLLDEV is not set 754# CONFIG_INPUT_POLLDEV is not set
721 755
@@ -762,14 +796,9 @@ CONFIG_UNIX98_PTYS=y
762# IPMI 796# IPMI
763# 797#
764# CONFIG_IPMI_HANDLER is not set 798# CONFIG_IPMI_HANDLER is not set
765
766#
767# Watchdog Cards
768#
769# CONFIG_WATCHDOG is not set 799# CONFIG_WATCHDOG is not set
770# CONFIG_HW_RANDOM is not set 800# CONFIG_HW_RANDOM is not set
771CONFIG_RTC=y 801CONFIG_RTC=y
772# CONFIG_DTLK is not set
773# CONFIG_R3964 is not set 802# CONFIG_R3964 is not set
774# CONFIG_APPLICOM is not set 803# CONFIG_APPLICOM is not set
775# CONFIG_DRM is not set 804# CONFIG_DRM is not set
@@ -779,6 +808,7 @@ CONFIG_RTC=y
779# TPM devices 808# TPM devices
780# 809#
781# CONFIG_TCG_TPM is not set 810# CONFIG_TCG_TPM is not set
811CONFIG_DEVPORT=y
782CONFIG_I2C=y 812CONFIG_I2C=y
783CONFIG_I2C_BOARDINFO=y 813CONFIG_I2C_BOARDINFO=y
784# CONFIG_I2C_CHARDEV is not set 814# CONFIG_I2C_CHARDEV is not set
@@ -841,13 +871,10 @@ CONFIG_I2C_ALGOBIT=y
841# Dallas's 1-wire bus 871# Dallas's 1-wire bus
842# 872#
843# CONFIG_W1 is not set 873# CONFIG_W1 is not set
844
845#
846# Hardware Monitoring support
847#
848CONFIG_HWMON=y 874CONFIG_HWMON=y
849# CONFIG_HWMON_VID is not set 875# CONFIG_HWMON_VID is not set
850# CONFIG_SENSORS_ABITUGURU is not set 876# CONFIG_SENSORS_ABITUGURU is not set
877# CONFIG_SENSORS_AD7418 is not set
851# CONFIG_SENSORS_ADM1021 is not set 878# CONFIG_SENSORS_ADM1021 is not set
852# CONFIG_SENSORS_ADM1025 is not set 879# CONFIG_SENSORS_ADM1025 is not set
853# CONFIG_SENSORS_ADM1026 is not set 880# CONFIG_SENSORS_ADM1026 is not set
@@ -874,6 +901,7 @@ CONFIG_HWMON=y
874# CONFIG_SENSORS_LM90 is not set 901# CONFIG_SENSORS_LM90 is not set
875# CONFIG_SENSORS_LM92 is not set 902# CONFIG_SENSORS_LM92 is not set
876# CONFIG_SENSORS_MAX1619 is not set 903# CONFIG_SENSORS_MAX1619 is not set
904# CONFIG_SENSORS_MAX6650 is not set
877# CONFIG_SENSORS_PC87360 is not set 905# CONFIG_SENSORS_PC87360 is not set
878# CONFIG_SENSORS_PC87427 is not set 906# CONFIG_SENSORS_PC87427 is not set
879# CONFIG_SENSORS_SIS5595 is not set 907# CONFIG_SENSORS_SIS5595 is not set
@@ -901,23 +929,30 @@ CONFIG_HWMON=y
901# Multimedia devices 929# Multimedia devices
902# 930#
903# CONFIG_VIDEO_DEV is not set 931# CONFIG_VIDEO_DEV is not set
932# CONFIG_DVB_CORE is not set
933# CONFIG_DAB is not set
904 934
905# 935#
906# Digital Video Broadcasting Devices 936# Graphics support
907# 937#
908# CONFIG_DVB is not set 938# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
909# CONFIG_USB_DABUSB is not set
910 939
911# 940#
912# Graphics support 941# Display device support
913# 942#
914# CONFIG_BACKLIGHT_LCD_SUPPORT is not set 943# CONFIG_DISPLAY_SUPPORT is not set
944# CONFIG_VGASTATE is not set
915CONFIG_FB=y 945CONFIG_FB=y
916# CONFIG_FIRMWARE_EDID is not set 946# CONFIG_FIRMWARE_EDID is not set
917CONFIG_FB_DDC=y 947CONFIG_FB_DDC=y
918CONFIG_FB_CFB_FILLRECT=y 948CONFIG_FB_CFB_FILLRECT=y
919CONFIG_FB_CFB_COPYAREA=y 949CONFIG_FB_CFB_COPYAREA=y
920CONFIG_FB_CFB_IMAGEBLIT=y 950CONFIG_FB_CFB_IMAGEBLIT=y
951# CONFIG_FB_SYS_FILLRECT is not set
952# CONFIG_FB_SYS_COPYAREA is not set
953# CONFIG_FB_SYS_IMAGEBLIT is not set
954# CONFIG_FB_SYS_FOPS is not set
955CONFIG_FB_DEFERRED_IO=y
921# CONFIG_FB_SVGALIB is not set 956# CONFIG_FB_SVGALIB is not set
922# CONFIG_FB_MACMODES is not set 957# CONFIG_FB_MACMODES is not set
923# CONFIG_FB_BACKLIGHT is not set 958# CONFIG_FB_BACKLIGHT is not set
@@ -949,7 +984,10 @@ CONFIG_FB_RADEON_I2C=y
949# CONFIG_FB_KYRO is not set 984# CONFIG_FB_KYRO is not set
950# CONFIG_FB_3DFX is not set 985# CONFIG_FB_3DFX is not set
951# CONFIG_FB_VOODOO1 is not set 986# CONFIG_FB_VOODOO1 is not set
987# CONFIG_FB_VT8623 is not set
952# CONFIG_FB_TRIDENT is not set 988# CONFIG_FB_TRIDENT is not set
989# CONFIG_FB_ARK is not set
990# CONFIG_FB_PM3 is not set
953# CONFIG_FB_XVR500 is not set 991# CONFIG_FB_XVR500 is not set
954# CONFIG_FB_XVR2500 is not set 992# CONFIG_FB_XVR2500 is not set
955# CONFIG_FB_PCI is not set 993# CONFIG_FB_PCI is not set
@@ -972,10 +1010,6 @@ CONFIG_FONTS=y
972CONFIG_FONT_SUN8x16=y 1010CONFIG_FONT_SUN8x16=y
973# CONFIG_FONT_SUN12x22 is not set 1011# CONFIG_FONT_SUN12x22 is not set
974# CONFIG_FONT_10x18 is not set 1012# CONFIG_FONT_10x18 is not set
975
976#
977# Logo configuration
978#
979CONFIG_LOGO=y 1013CONFIG_LOGO=y
980# CONFIG_LOGO_LINUX_MONO is not set 1014# CONFIG_LOGO_LINUX_MONO is not set
981# CONFIG_LOGO_LINUX_VGA16 is not set 1015# CONFIG_LOGO_LINUX_VGA16 is not set
@@ -1083,6 +1117,7 @@ CONFIG_SND_ALI5451=m
1083# USB devices 1117# USB devices
1084# 1118#
1085# CONFIG_SND_USB_AUDIO is not set 1119# CONFIG_SND_USB_AUDIO is not set
1120# CONFIG_SND_USB_CAIAQ is not set
1086 1121
1087# 1122#
1088# ALSA Sparc devices 1123# ALSA Sparc devices
@@ -1092,7 +1127,7 @@ CONFIG_SND_SUN_CS4231=m
1092# CONFIG_SND_SUN_DBRI is not set 1127# CONFIG_SND_SUN_DBRI is not set
1093 1128
1094# 1129#
1095# SoC audio support 1130# System on Chip audio support
1096# 1131#
1097# CONFIG_SND_SOC is not set 1132# CONFIG_SND_SOC is not set
1098 1133
@@ -1178,37 +1213,10 @@ CONFIG_USB_STORAGE=m
1178# CONFIG_USB_LIBUSUAL is not set 1213# CONFIG_USB_LIBUSUAL is not set
1179 1214
1180# 1215#
1181# USB Input Devices
1182#
1183# CONFIG_USB_AIPTEK is not set
1184# CONFIG_USB_WACOM is not set
1185# CONFIG_USB_ACECAD is not set
1186# CONFIG_USB_KBTAB is not set
1187# CONFIG_USB_POWERMATE is not set
1188# CONFIG_USB_TOUCHSCREEN is not set
1189# CONFIG_USB_YEALINK is not set
1190# CONFIG_USB_XPAD is not set
1191# CONFIG_USB_ATI_REMOTE is not set
1192# CONFIG_USB_ATI_REMOTE2 is not set
1193# CONFIG_USB_KEYSPAN_REMOTE is not set
1194# CONFIG_USB_APPLETOUCH is not set
1195# CONFIG_USB_GTCO is not set
1196
1197#
1198# USB Imaging devices 1216# USB Imaging devices
1199# 1217#
1200# CONFIG_USB_MDC800 is not set 1218# CONFIG_USB_MDC800 is not set
1201# CONFIG_USB_MICROTEK is not set 1219# CONFIG_USB_MICROTEK is not set
1202
1203#
1204# USB Network Adapters
1205#
1206# CONFIG_USB_CATC is not set
1207# CONFIG_USB_KAWETH is not set
1208# CONFIG_USB_PEGASUS is not set
1209# CONFIG_USB_RTL8150 is not set
1210# CONFIG_USB_USBNET_MII is not set
1211# CONFIG_USB_USBNET is not set
1212# CONFIG_USB_MON is not set 1220# CONFIG_USB_MON is not set
1213 1221
1214# 1222#
@@ -1252,10 +1260,6 @@ CONFIG_USB_STORAGE=m
1252# USB Gadget Support 1260# USB Gadget Support
1253# 1261#
1254# CONFIG_USB_GADGET is not set 1262# CONFIG_USB_GADGET is not set
1255
1256#
1257# MMC/SD Card support
1258#
1259# CONFIG_MMC is not set 1263# CONFIG_MMC is not set
1260 1264
1261# 1265#
@@ -1299,14 +1303,6 @@ CONFIG_USB_STORAGE=m
1299# 1303#
1300 1304
1301# 1305#
1302# Auxiliary Display support
1303#
1304
1305#
1306# Virtualization
1307#
1308
1309#
1310# Misc Linux/SPARC drivers 1306# Misc Linux/SPARC drivers
1311# 1307#
1312CONFIG_SUN_OPENPROMIO=m 1308CONFIG_SUN_OPENPROMIO=m
@@ -1486,11 +1482,9 @@ CONFIG_DEBUG_FS=y
1486# CONFIG_HEADERS_CHECK is not set 1482# CONFIG_HEADERS_CHECK is not set
1487CONFIG_DEBUG_KERNEL=y 1483CONFIG_DEBUG_KERNEL=y
1488# CONFIG_DEBUG_SHIRQ is not set 1484# CONFIG_DEBUG_SHIRQ is not set
1489CONFIG_LOG_BUF_SHIFT=18
1490CONFIG_DETECT_SOFTLOCKUP=y 1485CONFIG_DETECT_SOFTLOCKUP=y
1491CONFIG_SCHEDSTATS=y 1486CONFIG_SCHEDSTATS=y
1492# CONFIG_TIMER_STATS is not set 1487# CONFIG_TIMER_STATS is not set
1493# CONFIG_DEBUG_SLAB is not set
1494# CONFIG_DEBUG_RT_MUTEXES is not set 1488# CONFIG_DEBUG_RT_MUTEXES is not set
1495# CONFIG_RT_MUTEX_TESTER is not set 1489# CONFIG_RT_MUTEX_TESTER is not set
1496# CONFIG_DEBUG_SPINLOCK is not set 1490# CONFIG_DEBUG_SPINLOCK is not set
@@ -1574,6 +1568,7 @@ CONFIG_CRYPTO_TEST=m
1574CONFIG_BITREVERSE=y 1568CONFIG_BITREVERSE=y
1575CONFIG_CRC_CCITT=m 1569CONFIG_CRC_CCITT=m
1576CONFIG_CRC16=m 1570CONFIG_CRC16=m
1571# CONFIG_CRC_ITU_T is not set
1577CONFIG_CRC32=y 1572CONFIG_CRC32=y
1578CONFIG_LIBCRC32C=m 1573CONFIG_LIBCRC32C=m
1579CONFIG_ZLIB_INFLATE=y 1574CONFIG_ZLIB_INFLATE=y
@@ -1581,3 +1576,4 @@ CONFIG_ZLIB_DEFLATE=y
1581CONFIG_PLIST=y 1576CONFIG_PLIST=y
1582CONFIG_HAS_IOMEM=y 1577CONFIG_HAS_IOMEM=y
1583CONFIG_HAS_IOPORT=y 1578CONFIG_HAS_IOPORT=y
1579CONFIG_HAS_DMA=y
diff --git a/arch/sparc64/kernel/audit.c b/arch/sparc64/kernel/audit.c
index aef19cc27072..24d7f4b4178a 100644
--- a/arch/sparc64/kernel/audit.c
+++ b/arch/sparc64/kernel/audit.c
@@ -23,6 +23,20 @@ static unsigned chattr_class[] = {
23~0U 23~0U
24}; 24};
25 25
26static unsigned signal_class[] = {
27#include <asm-generic/audit_signal.h>
28~0U
29};
30
31int audit_classify_arch(int arch)
32{
33#ifdef CONFIG_SPARC32_COMPAT
34 if (arch == AUDIT_ARCH_SPARC)
35 return 1;
36#endif
37 return 0;
38}
39
26int audit_classify_syscall(int abi, unsigned syscall) 40int audit_classify_syscall(int abi, unsigned syscall)
27{ 41{
28#ifdef CONFIG_SPARC32_COMPAT 42#ifdef CONFIG_SPARC32_COMPAT
@@ -51,15 +65,18 @@ static int __init audit_classes_init(void)
51 extern __u32 sparc32_write_class[]; 65 extern __u32 sparc32_write_class[];
52 extern __u32 sparc32_read_class[]; 66 extern __u32 sparc32_read_class[];
53 extern __u32 sparc32_chattr_class[]; 67 extern __u32 sparc32_chattr_class[];
68 extern __u32 sparc32_signal_class[];
54 audit_register_class(AUDIT_CLASS_WRITE_32, sparc32_write_class); 69 audit_register_class(AUDIT_CLASS_WRITE_32, sparc32_write_class);
55 audit_register_class(AUDIT_CLASS_READ_32, sparc32_read_class); 70 audit_register_class(AUDIT_CLASS_READ_32, sparc32_read_class);
56 audit_register_class(AUDIT_CLASS_DIR_WRITE_32, sparc32_dir_class); 71 audit_register_class(AUDIT_CLASS_DIR_WRITE_32, sparc32_dir_class);
57 audit_register_class(AUDIT_CLASS_CHATTR_32, sparc32_chattr_class); 72 audit_register_class(AUDIT_CLASS_CHATTR_32, sparc32_chattr_class);
73 audit_register_class(AUDIT_CLASS_SIGNAL_32, sparc32_signal_class);
58#endif 74#endif
59 audit_register_class(AUDIT_CLASS_WRITE, write_class); 75 audit_register_class(AUDIT_CLASS_WRITE, write_class);
60 audit_register_class(AUDIT_CLASS_READ, read_class); 76 audit_register_class(AUDIT_CLASS_READ, read_class);
61 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class); 77 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
62 audit_register_class(AUDIT_CLASS_CHATTR, chattr_class); 78 audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
79 audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
63 return 0; 80 return 0;
64} 81}
65 82
diff --git a/arch/sparc64/kernel/compat_audit.c b/arch/sparc64/kernel/compat_audit.c
index cca96c91b780..c1979482aa92 100644
--- a/arch/sparc64/kernel/compat_audit.c
+++ b/arch/sparc64/kernel/compat_audit.c
@@ -20,6 +20,11 @@ unsigned sparc32_read_class[] = {
20~0U 20~0U
21}; 21};
22 22
23unsigned sparc32_signal_class[] = {
24#include <asm-generic/audit_signal.h>
25~0U
26};
27
23int sparc32_classify_syscall(unsigned syscall) 28int sparc32_classify_syscall(unsigned syscall)
24{ 29{
25 switch(syscall) { 30 switch(syscall) {
diff --git a/arch/sparc64/kernel/devices.c b/arch/sparc64/kernel/devices.c
index ec10f7edcf86..0e03c8e218cd 100644
--- a/arch/sparc64/kernel/devices.c
+++ b/arch/sparc64/kernel/devices.c
@@ -21,7 +21,7 @@
21#include <asm/timer.h> 21#include <asm/timer.h>
22#include <asm/cpudata.h> 22#include <asm/cpudata.h>
23 23
24/* Used to synchronize acceses to NatSemi SUPER I/O chip configure 24/* Used to synchronize accesses to NatSemi SUPER I/O chip configure
25 * operations in asm/ns87303.h 25 * operations in asm/ns87303.h
26 */ 26 */
27DEFINE_SPINLOCK(ns87303_lock); 27DEFINE_SPINLOCK(ns87303_lock);
diff --git a/arch/sparc64/kernel/of_device.c b/arch/sparc64/kernel/of_device.c
index 9ac9a307999a..7455f5d05519 100644
--- a/arch/sparc64/kernel/of_device.c
+++ b/arch/sparc64/kernel/of_device.c
@@ -596,7 +596,7 @@ static void __init build_device_resources(struct of_device *op,
596 /* Convert to num-entries. */ 596 /* Convert to num-entries. */
597 num_reg /= na + ns; 597 num_reg /= na + ns;
598 598
599 /* Prevent overruning the op->resources[] array. */ 599 /* Prevent overrunning the op->resources[] array. */
600 if (num_reg > PROMREG_MAX) { 600 if (num_reg > PROMREG_MAX) {
601 printk(KERN_WARNING "%s: Too many regs (%d), " 601 printk(KERN_WARNING "%s: Too many regs (%d), "
602 "limiting to %d.\n", 602 "limiting to %d.\n",
@@ -904,7 +904,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
904 op->num_irqs = 0; 904 op->num_irqs = 0;
905 } 905 }
906 906
907 /* Prevent overruning the op->irqs[] array. */ 907 /* Prevent overrunning the op->irqs[] array. */
908 if (op->num_irqs > PROMINTR_MAX) { 908 if (op->num_irqs > PROMINTR_MAX) {
909 printk(KERN_WARNING "%s: Too many irqs (%d), " 909 printk(KERN_WARNING "%s: Too many irqs (%d), "
910 "limiting to %d.\n", 910 "limiting to %d.\n",
diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c
index cf9a75112d0f..d4c077dc5e85 100644
--- a/arch/sparc64/kernel/pci.c
+++ b/arch/sparc64/kernel/pci.c
@@ -495,8 +495,8 @@ static void __devinit apb_calc_first_last(u8 map, u32 *first_p, u32 *last_p)
495 *last_p = last; 495 *last_p = last;
496} 496}
497 497
498static void __init pci_resource_adjust(struct resource *res, 498static void pci_resource_adjust(struct resource *res,
499 struct resource *root) 499 struct resource *root)
500{ 500{
501 res->start += root->start; 501 res->start += root->start;
502 res->end += root->start; 502 res->end += root->start;
diff --git a/arch/sparc64/kernel/pci_fire.c b/arch/sparc64/kernel/pci_fire.c
index 9198c1a0f7a5..7f5d473901c4 100644
--- a/arch/sparc64/kernel/pci_fire.c
+++ b/arch/sparc64/kernel/pci_fire.c
@@ -37,7 +37,7 @@ static void pci_fire_scan_bus(struct pci_pbm_info *pbm)
37#define FIRE_IOMMU_CONTROL 0x40000UL 37#define FIRE_IOMMU_CONTROL 0x40000UL
38#define FIRE_IOMMU_TSBBASE 0x40008UL 38#define FIRE_IOMMU_TSBBASE 0x40008UL
39#define FIRE_IOMMU_FLUSH 0x40100UL 39#define FIRE_IOMMU_FLUSH 0x40100UL
40#define FIRE_IOMMU_FLUSHINV 0x40100UL 40#define FIRE_IOMMU_FLUSHINV 0x40108UL
41 41
42static void pci_fire_pbm_iommu_init(struct pci_pbm_info *pbm) 42static void pci_fire_pbm_iommu_init(struct pci_pbm_info *pbm)
43{ 43{
diff --git a/arch/sparc64/kernel/pci_iommu.c b/arch/sparc64/kernel/pci_iommu.c
index dfd6f9f4790b..70d2364fdfe0 100644
--- a/arch/sparc64/kernel/pci_iommu.c
+++ b/arch/sparc64/kernel/pci_iommu.c
@@ -542,7 +542,7 @@ static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg,
542/* Map a set of buffers described by SGLIST with NELEMS array 542/* Map a set of buffers described by SGLIST with NELEMS array
543 * elements in streaming mode for PCI DMA. 543 * elements in streaming mode for PCI DMA.
544 * When making changes here, inspect the assembly output. I was having 544 * When making changes here, inspect the assembly output. I was having
545 * hard time to kepp this routine out of using stack slots for holding variables. 545 * hard time to keep this routine out of using stack slots for holding variables.
546 */ 546 */
547static int pci_4u_map_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int direction) 547static int pci_4u_map_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int direction)
548{ 548{
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c
index 34df4047587a..044e8ec4c0f5 100644
--- a/arch/sparc64/kernel/pci_sun4v.c
+++ b/arch/sparc64/kernel/pci_sun4v.c
@@ -731,7 +731,7 @@ struct pci_sun4v_msiq_entry {
731 731
732 u64 msi_address; 732 u64 msi_address;
733 733
734 /* The format of this value is message type dependant. 734 /* The format of this value is message type dependent.
735 * For MSI bits 15:0 are the data from the MSI packet. 735 * For MSI bits 15:0 are the data from the MSI packet.
736 * For MSI-X bits 31:0 are the data from the MSI packet. 736 * For MSI-X bits 31:0 are the data from the MSI packet.
737 * For MSG, the message code and message routing code where: 737 * For MSG, the message code and message routing code where:
diff --git a/arch/sparc64/kernel/process.c b/arch/sparc64/kernel/process.c
index 8e3c6e435110..952762bfb4c0 100644
--- a/arch/sparc64/kernel/process.c
+++ b/arch/sparc64/kernel/process.c
@@ -677,7 +677,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
677 * NOTE! Only a kernel-only process(ie the swapper or direct descendants 677 * NOTE! Only a kernel-only process(ie the swapper or direct descendants
678 * who haven't done an "execve()") should use this: it will work within 678 * who haven't done an "execve()") should use this: it will work within
679 * a system call from a "real" process, but the process memory space will 679 * a system call from a "real" process, but the process memory space will
680 * not be free'd until both the parent and the child have exited. 680 * not be freed until both the parent and the child have exited.
681 */ 681 */
682pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) 682pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
683{ 683{
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c
index b7976b14d0ba..02830e4671f5 100644
--- a/arch/sparc64/kernel/prom.c
+++ b/arch/sparc64/kernel/prom.c
@@ -899,7 +899,7 @@ static unsigned int fire_irq_build(struct device_node *dp,
899 /* The interrupt map registers do not have an INO field 899 /* The interrupt map registers do not have an INO field
900 * like other chips do. They return zero in the INO 900 * like other chips do. They return zero in the INO
901 * field, and the interrupt controller number is controlled 901 * field, and the interrupt controller number is controlled
902 * in bits 6 thru 9. So in order for build_irq() to get 902 * in bits 6 to 9. So in order for build_irq() to get
903 * the INO right we pass it in as part of the fixup 903 * the INO right we pass it in as part of the fixup
904 * which will get added to the map register zero value 904 * which will get added to the map register zero value
905 * read by build_irq(). 905 * read by build_irq().
diff --git a/arch/sparc64/kernel/systbls.S b/arch/sparc64/kernel/systbls.S
index 5fe7f9ad4a92..8765e32155a0 100644
--- a/arch/sparc64/kernel/systbls.S
+++ b/arch/sparc64/kernel/systbls.S
@@ -81,7 +81,7 @@ sys_call_table32:
81 .word sys_fchmodat, sys_faccessat, compat_sys_pselect6, compat_sys_ppoll, sys_unshare 81 .word sys_fchmodat, sys_faccessat, compat_sys_pselect6, compat_sys_ppoll, sys_unshare
82/*300*/ .word compat_sys_set_robust_list, compat_sys_get_robust_list, compat_sys_migrate_pages, compat_sys_mbind, compat_sys_get_mempolicy 82/*300*/ .word compat_sys_set_robust_list, compat_sys_get_robust_list, compat_sys_migrate_pages, compat_sys_mbind, compat_sys_get_mempolicy
83 .word compat_sys_set_mempolicy, compat_sys_kexec_load, compat_sys_move_pages, sys_getcpu, compat_sys_epoll_pwait 83 .word compat_sys_set_mempolicy, compat_sys_kexec_load, compat_sys_move_pages, sys_getcpu, compat_sys_epoll_pwait
84/*310*/ .word compat_sys_utimensat 84/*310*/ .word compat_sys_utimensat, compat_sys_signalfd, compat_sys_timerfd, sys_eventfd
85 85
86#endif /* CONFIG_COMPAT */ 86#endif /* CONFIG_COMPAT */
87 87
@@ -153,7 +153,7 @@ sys_call_table:
153 .word sys_fchmodat, sys_faccessat, sys_pselect6, sys_ppoll, sys_unshare 153 .word sys_fchmodat, sys_faccessat, sys_pselect6, sys_ppoll, sys_unshare
154/*300*/ .word sys_set_robust_list, sys_get_robust_list, sys_migrate_pages, sys_mbind, sys_get_mempolicy 154/*300*/ .word sys_set_robust_list, sys_get_robust_list, sys_migrate_pages, sys_mbind, sys_get_mempolicy
155 .word sys_set_mempolicy, sys_kexec_load, sys_move_pages, sys_getcpu, sys_epoll_pwait 155 .word sys_set_mempolicy, sys_kexec_load, sys_move_pages, sys_getcpu, sys_epoll_pwait
156/*310*/ .word sys_utimensat 156/*310*/ .word sys_utimensat, sys_signalfd, sys_timerfd, sys_eventfd
157 157
158#if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \ 158#if defined(CONFIG_SUNOS_EMUL) || defined(CONFIG_SOLARIS_EMUL) || \
159 defined(CONFIG_SOLARIS_EMUL_MODULE) 159 defined(CONFIG_SOLARIS_EMUL_MODULE)
@@ -271,6 +271,7 @@ sunos_sys_table:
271 .word sunos_nosys, sunos_nosys, sunos_nosys 271 .word sunos_nosys, sunos_nosys, sunos_nosys
272 .word sunos_nosys, sunos_nosys, sunos_nosys 272 .word sunos_nosys, sunos_nosys, sunos_nosys
273 .word sunos_nosys 273 .word sunos_nosys
274/*310*/ .long sunos_nosys 274/*310*/ .word sunos_nosys, sunos_nosys, sunos_nosys
275 .word sunos_nosys
275 276
276#endif 277#endif
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c
index 259063f41f95..6b9a06e42542 100644
--- a/arch/sparc64/kernel/time.c
+++ b/arch/sparc64/kernel/time.c
@@ -55,6 +55,7 @@ DEFINE_SPINLOCK(rtc_lock);
55void __iomem *mstk48t02_regs = NULL; 55void __iomem *mstk48t02_regs = NULL;
56#ifdef CONFIG_PCI 56#ifdef CONFIG_PCI
57unsigned long ds1287_regs = 0UL; 57unsigned long ds1287_regs = 0UL;
58static void __iomem *bq4802_regs;
58#endif 59#endif
59 60
60static void __iomem *mstk48t08_regs; 61static void __iomem *mstk48t08_regs;
@@ -565,12 +566,14 @@ static void __init set_system_time(void)
565 void __iomem *mregs = mstk48t02_regs; 566 void __iomem *mregs = mstk48t02_regs;
566#ifdef CONFIG_PCI 567#ifdef CONFIG_PCI
567 unsigned long dregs = ds1287_regs; 568 unsigned long dregs = ds1287_regs;
569 void __iomem *bregs = bq4802_regs;
568#else 570#else
569 unsigned long dregs = 0UL; 571 unsigned long dregs = 0UL;
572 void __iomem *bregs = 0UL;
570#endif 573#endif
571 u8 tmp; 574 u8 tmp;
572 575
573 if (!mregs && !dregs) { 576 if (!mregs && !dregs && !bregs) {
574 prom_printf("Something wrong, clock regs not mapped yet.\n"); 577 prom_printf("Something wrong, clock regs not mapped yet.\n");
575 prom_halt(); 578 prom_halt();
576 } 579 }
@@ -589,6 +592,33 @@ static void __init set_system_time(void)
589 day = MSTK_REG_DOM(mregs); 592 day = MSTK_REG_DOM(mregs);
590 mon = MSTK_REG_MONTH(mregs); 593 mon = MSTK_REG_MONTH(mregs);
591 year = MSTK_CVT_YEAR( MSTK_REG_YEAR(mregs) ); 594 year = MSTK_CVT_YEAR( MSTK_REG_YEAR(mregs) );
595 } else if (bregs) {
596 unsigned char val = readb(bregs + 0x0e);
597 unsigned int century;
598
599 /* BQ4802 RTC chip. */
600
601 writeb(val | 0x08, bregs + 0x0e);
602
603 sec = readb(bregs + 0x00);
604 min = readb(bregs + 0x02);
605 hour = readb(bregs + 0x04);
606 day = readb(bregs + 0x06);
607 mon = readb(bregs + 0x09);
608 year = readb(bregs + 0x0a);
609 century = readb(bregs + 0x0f);
610
611 writeb(val, bregs + 0x0e);
612
613 BCD_TO_BIN(sec);
614 BCD_TO_BIN(min);
615 BCD_TO_BIN(hour);
616 BCD_TO_BIN(day);
617 BCD_TO_BIN(mon);
618 BCD_TO_BIN(year);
619 BCD_TO_BIN(century);
620
621 year += (century * 100);
592 } else { 622 } else {
593 /* Dallas 12887 RTC chip. */ 623 /* Dallas 12887 RTC chip. */
594 624
@@ -712,7 +742,8 @@ static int __init clock_model_matches(const char *model)
712 strcmp(model, "m5819") && 742 strcmp(model, "m5819") &&
713 strcmp(model, "m5819p") && 743 strcmp(model, "m5819p") &&
714 strcmp(model, "m5823") && 744 strcmp(model, "m5823") &&
715 strcmp(model, "ds1287")) 745 strcmp(model, "ds1287") &&
746 strcmp(model, "bq4802"))
716 return 0; 747 return 0;
717 748
718 return 1; 749 return 1;
@@ -722,9 +753,13 @@ static int __devinit clock_probe(struct of_device *op, const struct of_device_id
722{ 753{
723 struct device_node *dp = op->node; 754 struct device_node *dp = op->node;
724 const char *model = of_get_property(dp, "model", NULL); 755 const char *model = of_get_property(dp, "model", NULL);
756 const char *compat = of_get_property(dp, "compatible", NULL);
725 unsigned long size, flags; 757 unsigned long size, flags;
726 void __iomem *regs; 758 void __iomem *regs;
727 759
760 if (!model)
761 model = compat;
762
728 if (!model || !clock_model_matches(model)) 763 if (!model || !clock_model_matches(model))
729 return -ENODEV; 764 return -ENODEV;
730 765
@@ -746,6 +781,8 @@ static int __devinit clock_probe(struct of_device *op, const struct of_device_id
746 !strcmp(model, "m5819p") || 781 !strcmp(model, "m5819p") ||
747 !strcmp(model, "m5823")) { 782 !strcmp(model, "m5823")) {
748 ds1287_regs = (unsigned long) regs; 783 ds1287_regs = (unsigned long) regs;
784 } else if (!strcmp(model, "bq4802")) {
785 bq4802_regs = regs;
749 } else 786 } else
750#endif 787#endif
751 if (model[5] == '0' && model[6] == '2') { 788 if (model[5] == '0' && model[6] == '2') {
@@ -1070,8 +1107,10 @@ static int set_rtc_mmss(unsigned long nowtime)
1070 void __iomem *mregs = mstk48t02_regs; 1107 void __iomem *mregs = mstk48t02_regs;
1071#ifdef CONFIG_PCI 1108#ifdef CONFIG_PCI
1072 unsigned long dregs = ds1287_regs; 1109 unsigned long dregs = ds1287_regs;
1110 void __iomem *bregs = bq4802_regs;
1073#else 1111#else
1074 unsigned long dregs = 0UL; 1112 unsigned long dregs = 0UL;
1113 void __iomem *bregs = 0UL;
1075#endif 1114#endif
1076 unsigned long flags; 1115 unsigned long flags;
1077 u8 tmp; 1116 u8 tmp;
@@ -1080,7 +1119,7 @@ static int set_rtc_mmss(unsigned long nowtime)
1080 * Not having a register set can lead to trouble. 1119 * Not having a register set can lead to trouble.
1081 * Also starfire doesn't have a tod clock. 1120 * Also starfire doesn't have a tod clock.
1082 */ 1121 */
1083 if (!mregs && !dregs) 1122 if (!mregs && !dregs & !bregs)
1084 return -1; 1123 return -1;
1085 1124
1086 if (mregs) { 1125 if (mregs) {
@@ -1129,6 +1168,37 @@ static int set_rtc_mmss(unsigned long nowtime)
1129 1168
1130 return -1; 1169 return -1;
1131 } 1170 }
1171 } else if (bregs) {
1172 int retval = 0;
1173 unsigned char val = readb(bregs + 0x0e);
1174
1175 /* BQ4802 RTC chip. */
1176
1177 writeb(val | 0x08, bregs + 0x0e);
1178
1179 chip_minutes = readb(bregs + 0x02);
1180 BCD_TO_BIN(chip_minutes);
1181 real_seconds = nowtime % 60;
1182 real_minutes = nowtime / 60;
1183 if (((abs(real_minutes - chip_minutes) + 15)/30) & 1)
1184 real_minutes += 30;
1185 real_minutes %= 60;
1186
1187 if (abs(real_minutes - chip_minutes) < 30) {
1188 BIN_TO_BCD(real_seconds);
1189 BIN_TO_BCD(real_minutes);
1190 writeb(real_seconds, bregs + 0x00);
1191 writeb(real_minutes, bregs + 0x02);
1192 } else {
1193 printk(KERN_WARNING
1194 "set_rtc_mmss: can't update from %d to %d\n",
1195 chip_minutes, real_minutes);
1196 retval = -1;
1197 }
1198
1199 writeb(val, bregs + 0x0e);
1200
1201 return retval;
1132 } else { 1202 } else {
1133 int retval = 0; 1203 int retval = 0;
1134 unsigned char save_control, save_freq_select; 1204 unsigned char save_control, save_freq_select;
@@ -1259,38 +1329,152 @@ static void to_tm(int tim, struct rtc_time *tm)
1259/* Both Starfire and SUN4V give us seconds since Jan 1st, 1970, 1329/* Both Starfire and SUN4V give us seconds since Jan 1st, 1970,
1260 * aka Unix time. So we have to convert to/from rtc_time. 1330 * aka Unix time. So we have to convert to/from rtc_time.
1261 */ 1331 */
1262static inline void mini_get_rtc_time(struct rtc_time *time) 1332static void starfire_get_rtc_time(struct rtc_time *time)
1263{ 1333{
1264 unsigned long flags; 1334 u32 seconds = starfire_get_time();
1265 u32 seconds;
1266 1335
1267 spin_lock_irqsave(&rtc_lock, flags); 1336 to_tm(seconds, time);
1268 seconds = 0; 1337 time->tm_year -= 1900;
1269 if (this_is_starfire) 1338 time->tm_mon -= 1;
1270 seconds = starfire_get_time(); 1339}
1271 else if (tlb_type == hypervisor) 1340
1272 seconds = hypervisor_get_time(); 1341static int starfire_set_rtc_time(struct rtc_time *time)
1273 spin_unlock_irqrestore(&rtc_lock, flags); 1342{
1343 u32 seconds = mktime(time->tm_year + 1900, time->tm_mon + 1,
1344 time->tm_mday, time->tm_hour,
1345 time->tm_min, time->tm_sec);
1346
1347 return starfire_set_time(seconds);
1348}
1349
1350static void hypervisor_get_rtc_time(struct rtc_time *time)
1351{
1352 u32 seconds = hypervisor_get_time();
1274 1353
1275 to_tm(seconds, time); 1354 to_tm(seconds, time);
1276 time->tm_year -= 1900; 1355 time->tm_year -= 1900;
1277 time->tm_mon -= 1; 1356 time->tm_mon -= 1;
1278} 1357}
1279 1358
1280static inline int mini_set_rtc_time(struct rtc_time *time) 1359static int hypervisor_set_rtc_time(struct rtc_time *time)
1281{ 1360{
1282 u32 seconds = mktime(time->tm_year + 1900, time->tm_mon + 1, 1361 u32 seconds = mktime(time->tm_year + 1900, time->tm_mon + 1,
1283 time->tm_mday, time->tm_hour, 1362 time->tm_mday, time->tm_hour,
1284 time->tm_min, time->tm_sec); 1363 time->tm_min, time->tm_sec);
1364
1365 return hypervisor_set_time(seconds);
1366}
1367
1368static void bq4802_get_rtc_time(struct rtc_time *time)
1369{
1370 unsigned char val = readb(bq4802_regs + 0x0e);
1371 unsigned int century;
1372
1373 writeb(val | 0x08, bq4802_regs + 0x0e);
1374
1375 time->tm_sec = readb(bq4802_regs + 0x00);
1376 time->tm_min = readb(bq4802_regs + 0x02);
1377 time->tm_hour = readb(bq4802_regs + 0x04);
1378 time->tm_mday = readb(bq4802_regs + 0x06);
1379 time->tm_mon = readb(bq4802_regs + 0x09);
1380 time->tm_year = readb(bq4802_regs + 0x0a);
1381 time->tm_wday = readb(bq4802_regs + 0x08);
1382 century = readb(bq4802_regs + 0x0f);
1383
1384 writeb(val, bq4802_regs + 0x0e);
1385
1386 BCD_TO_BIN(time->tm_sec);
1387 BCD_TO_BIN(time->tm_min);
1388 BCD_TO_BIN(time->tm_hour);
1389 BCD_TO_BIN(time->tm_mday);
1390 BCD_TO_BIN(time->tm_mon);
1391 BCD_TO_BIN(time->tm_year);
1392 BCD_TO_BIN(time->tm_wday);
1393 BCD_TO_BIN(century);
1394
1395 time->tm_year += (century * 100);
1396 time->tm_year -= 1900;
1397
1398 time->tm_mon--;
1399}
1400
1401static int bq4802_set_rtc_time(struct rtc_time *time)
1402{
1403 unsigned char val = readb(bq4802_regs + 0x0e);
1404 unsigned char sec, min, hrs, day, mon, yrs, century;
1405 unsigned int year;
1406
1407 year = time->tm_year + 1900;
1408 century = year / 100;
1409 yrs = year % 100;
1410
1411 mon = time->tm_mon + 1; /* tm_mon starts at zero */
1412 day = time->tm_mday;
1413 hrs = time->tm_hour;
1414 min = time->tm_min;
1415 sec = time->tm_sec;
1416
1417 BIN_TO_BCD(sec);
1418 BIN_TO_BCD(min);
1419 BIN_TO_BCD(hrs);
1420 BIN_TO_BCD(day);
1421 BIN_TO_BCD(mon);
1422 BIN_TO_BCD(yrs);
1423 BIN_TO_BCD(century);
1424
1425 writeb(val | 0x08, bq4802_regs + 0x0e);
1426
1427 writeb(sec, bq4802_regs + 0x00);
1428 writeb(min, bq4802_regs + 0x02);
1429 writeb(hrs, bq4802_regs + 0x04);
1430 writeb(day, bq4802_regs + 0x06);
1431 writeb(mon, bq4802_regs + 0x09);
1432 writeb(yrs, bq4802_regs + 0x0a);
1433 writeb(century, bq4802_regs + 0x0f);
1434
1435 writeb(val, bq4802_regs + 0x0e);
1436
1437 return 0;
1438}
1439
1440struct mini_rtc_ops {
1441 void (*get_rtc_time)(struct rtc_time *);
1442 int (*set_rtc_time)(struct rtc_time *);
1443};
1444
1445static struct mini_rtc_ops starfire_rtc_ops = {
1446 .get_rtc_time = starfire_get_rtc_time,
1447 .set_rtc_time = starfire_set_rtc_time,
1448};
1449
1450static struct mini_rtc_ops hypervisor_rtc_ops = {
1451 .get_rtc_time = hypervisor_get_rtc_time,
1452 .set_rtc_time = hypervisor_set_rtc_time,
1453};
1454
1455static struct mini_rtc_ops bq4802_rtc_ops = {
1456 .get_rtc_time = bq4802_get_rtc_time,
1457 .set_rtc_time = bq4802_set_rtc_time,
1458};
1459
1460static struct mini_rtc_ops *mini_rtc_ops;
1461
1462static inline void mini_get_rtc_time(struct rtc_time *time)
1463{
1464 unsigned long flags;
1465
1466 spin_lock_irqsave(&rtc_lock, flags);
1467 mini_rtc_ops->get_rtc_time(time);
1468 spin_unlock_irqrestore(&rtc_lock, flags);
1469}
1470
1471static inline int mini_set_rtc_time(struct rtc_time *time)
1472{
1285 unsigned long flags; 1473 unsigned long flags;
1286 int err; 1474 int err;
1287 1475
1288 spin_lock_irqsave(&rtc_lock, flags); 1476 spin_lock_irqsave(&rtc_lock, flags);
1289 err = -ENODEV; 1477 err = mini_rtc_ops->set_rtc_time(time);
1290 if (this_is_starfire)
1291 err = starfire_set_time(seconds);
1292 else if (tlb_type == hypervisor)
1293 err = hypervisor_set_time(seconds);
1294 spin_unlock_irqrestore(&rtc_lock, flags); 1478 spin_unlock_irqrestore(&rtc_lock, flags);
1295 1479
1296 return err; 1480 return err;
@@ -1391,7 +1575,13 @@ static int __init rtc_mini_init(void)
1391{ 1575{
1392 int retval; 1576 int retval;
1393 1577
1394 if (tlb_type != hypervisor && !this_is_starfire) 1578 if (tlb_type == hypervisor)
1579 mini_rtc_ops = &hypervisor_rtc_ops;
1580 else if (this_is_starfire)
1581 mini_rtc_ops = &starfire_rtc_ops;
1582 else if (bq4802_regs)
1583 mini_rtc_ops = &bq4802_rtc_ops;
1584 else
1395 return -ENODEV; 1585 return -ENODEV;
1396 1586
1397 printk(KERN_INFO "Mini RTC Driver\n"); 1587 printk(KERN_INFO "Mini RTC Driver\n");
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index d7004eaf1c8e..6e5b01d779d2 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -1008,7 +1008,7 @@ static unsigned long __init bootmem_init(unsigned long *pages_avail,
1008 if (initrd_start) { 1008 if (initrd_start) {
1009 size = initrd_end - initrd_start; 1009 size = initrd_end - initrd_start;
1010 1010
1011 /* Resert the initrd image area. */ 1011 /* Reserve the initrd image area. */
1012#ifdef CONFIG_DEBUG_BOOTMEM 1012#ifdef CONFIG_DEBUG_BOOTMEM
1013 prom_printf("reserve_bootmem(initrd): base[%llx] size[%lx]\n", 1013 prom_printf("reserve_bootmem(initrd): base[%llx] size[%lx]\n",
1014 initrd_start, initrd_end); 1014 initrd_start, initrd_end);
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index b9c0f307a8fa..c504312219b4 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -277,7 +277,8 @@ config HIGHMEM
277 277
278config KERNEL_STACK_ORDER 278config KERNEL_STACK_ORDER
279 int "Kernel stack size order" 279 int "Kernel stack size order"
280 default 2 280 default 1 if 64BIT
281 default 0 if !64BIT
281 help 282 help
282 This option determines the size of UML kernel stacks. They will 283 This option determines the size of UML kernel stacks. They will
283 be 1 << order pages. The default is OK unless you're running Valgrind 284 be 1 << order pages. The default is OK unless you're running Valgrind
diff --git a/arch/um/defconfig b/arch/um/defconfig
index f938fa822146..a54d0efecae1 100644
--- a/arch/um/defconfig
+++ b/arch/um/defconfig
@@ -86,7 +86,7 @@ CONFIG_MCONSOLE=y
86# CONFIG_MAGIC_SYSRQ is not set 86# CONFIG_MAGIC_SYSRQ is not set
87CONFIG_NEST_LEVEL=0 87CONFIG_NEST_LEVEL=0
88# CONFIG_HIGHMEM is not set 88# CONFIG_HIGHMEM is not set
89CONFIG_KERNEL_STACK_ORDER=2 89CONFIG_KERNEL_STACK_ORDER=0
90CONFIG_UML_REAL_TIME_CLOCK=y 90CONFIG_UML_REAL_TIME_CLOCK=y
91 91
92# 92#
diff --git a/arch/um/include/common-offsets.h b/arch/um/include/common-offsets.h
index 5593a8027083..541f4a8ca512 100644
--- a/arch/um/include/common-offsets.h
+++ b/arch/um/include/common-offsets.h
@@ -28,3 +28,5 @@ DEFINE(UM_NR_CPUS, NR_CPUS);
28 28
29/* For crypto assembler code. */ 29/* For crypto assembler code. */
30DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx)); 30DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
31
32DEFINE(UM_THREAD_SIZE, THREAD_SIZE);
diff --git a/arch/um/include/kern_util.h b/arch/um/include/kern_util.h
index 50a49691e0e6..8d7f7c1cb9c6 100644
--- a/arch/um/include/kern_util.h
+++ b/arch/um/include/kern_util.h
@@ -117,4 +117,7 @@ extern void sigio_handler(int sig, union uml_pt_regs *regs);
117 117
118extern void copy_sc(union uml_pt_regs *regs, void *from); 118extern void copy_sc(union uml_pt_regs *regs, void *from);
119 119
120unsigned long to_irq_stack(int sig, unsigned long *mask_out);
121unsigned long from_irq_stack(int nested);
122
120#endif 123#endif
diff --git a/arch/um/include/os.h b/arch/um/include/os.h
index 688d181b5f8a..4d9fb26387d5 100644
--- a/arch/um/include/os.h
+++ b/arch/um/include/os.h
@@ -272,7 +272,6 @@ extern void do_longjmp(void *p, int val);
272 272
273/* util.c */ 273/* util.c */
274extern void stack_protections(unsigned long address); 274extern void stack_protections(unsigned long address);
275extern void task_protections(unsigned long address);
276extern int raw(int fd); 275extern int raw(int fd);
277extern void setup_machinename(char *machine_out); 276extern void setup_machinename(char *machine_out);
278extern void setup_hostinfo(char *buf, int len); 277extern void setup_hostinfo(char *buf, int len);
diff --git a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S
index e36f92b463ce..87a4e4427d8d 100644
--- a/arch/um/kernel/dyn.lds.S
+++ b/arch/um/kernel/dyn.lds.S
@@ -97,6 +97,8 @@ SECTIONS
97 .data : { 97 .data : {
98 . = ALIGN(KERNEL_STACK_SIZE); /* init_task */ 98 . = ALIGN(KERNEL_STACK_SIZE); /* init_task */
99 *(.data.init_task) 99 *(.data.init_task)
100 . = ALIGN(KERNEL_STACK_SIZE);
101 *(.data.init_irqstack)
100 *(.data .data.* .gnu.linkonce.d.*) 102 *(.data .data.* .gnu.linkonce.d.*)
101 SORT(CONSTRUCTORS) 103 SORT(CONSTRUCTORS)
102 } 104 }
diff --git a/arch/um/kernel/init_task.c b/arch/um/kernel/init_task.c
index cda91aa8e703..d4f1d1ab252b 100644
--- a/arch/um/kernel/init_task.c
+++ b/arch/um/kernel/init_task.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,intel.linux}.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
@@ -33,28 +33,20 @@ EXPORT_SYMBOL(init_task);
33/* 33/*
34 * Initial thread structure. 34 * Initial thread structure.
35 * 35 *
36 * We need to make sure that this is 16384-byte aligned due to the 36 * We need to make sure that this is aligned due to the
37 * way process stacks are handled. This is done by having a special 37 * way process stacks are handled. This is done by having a special
38 * "init_task" linker map entry.. 38 * "init_task" linker map entry..
39 */ 39 */
40 40
41union thread_union init_thread_union 41union thread_union init_thread_union
42__attribute__((__section__(".data.init_task"))) = 42 __attribute__((__section__(".data.init_task"))) =
43{ INIT_THREAD_INFO(init_task) }; 43 { INIT_THREAD_INFO(init_task) };
44
45union thread_union cpu0_irqstack
46 __attribute__((__section__(".data.init_irqstack"))) =
47 { INIT_THREAD_INFO(init_task) };
44 48
45void unprotect_stack(unsigned long stack) 49void unprotect_stack(unsigned long stack)
46{ 50{
47 os_protect_memory((void *) stack, (1 << CONFIG_KERNEL_STACK_ORDER) * PAGE_SIZE, 51 os_protect_memory((void *) stack, THREAD_SIZE, 1, 1, 0);
48 1, 1, 0);
49} 52}
50
51/*
52 * Overrides for Emacs so that we follow Linus's tabbing style.
53 * Emacs will notice this stuff at the end of the file and automatically
54 * adjust the settings for this buffer only. This must remain at the end
55 * of the file.
56 * ---------------------------------------------------------------------------
57 * Local variables:
58 * c-file-style: "linux"
59 * End:
60 */
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
index 8f2ed3690315..dba04d88b432 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 * Derived (i.e. mostly copied) from arch/i386/kernel/irq.c: 4 * Derived (i.e. mostly copied) from arch/i386/kernel/irq.c:
@@ -32,6 +32,7 @@
32#include "sigio.h" 32#include "sigio.h"
33#include "um_malloc.h" 33#include "um_malloc.h"
34#include "misc_constants.h" 34#include "misc_constants.h"
35#include "as-layout.h"
35 36
36/* 37/*
37 * Generic, controller-independent functions: 38 * Generic, controller-independent functions:
@@ -53,7 +54,7 @@ int show_interrupts(struct seq_file *p, void *v)
53 if (i < NR_IRQS) { 54 if (i < NR_IRQS) {
54 spin_lock_irqsave(&irq_desc[i].lock, flags); 55 spin_lock_irqsave(&irq_desc[i].lock, flags);
55 action = irq_desc[i].action; 56 action = irq_desc[i].action;
56 if (!action) 57 if (!action)
57 goto skip; 58 goto skip;
58 seq_printf(p, "%3d: ",i); 59 seq_printf(p, "%3d: ",i);
59#ifndef CONFIG_SMP 60#ifndef CONFIG_SMP
@@ -468,3 +469,113 @@ int init_aio_irq(int irq, char *name, irq_handler_t handler)
468 out: 469 out:
469 return err; 470 return err;
470} 471}
472
473/*
474 * IRQ stack entry and exit:
475 *
476 * Unlike i386, UML doesn't receive IRQs on the normal kernel stack
477 * and switch over to the IRQ stack after some preparation. We use
478 * sigaltstack to receive signals on a separate stack from the start.
479 * These two functions make sure the rest of the kernel won't be too
480 * upset by being on a different stack. The IRQ stack has a
481 * thread_info structure at the bottom so that current et al continue
482 * to work.
483 *
484 * to_irq_stack copies the current task's thread_info to the IRQ stack
485 * thread_info and sets the tasks's stack to point to the IRQ stack.
486 *
487 * from_irq_stack copies the thread_info struct back (flags may have
488 * been modified) and resets the task's stack pointer.
489 *
490 * Tricky bits -
491 *
492 * What happens when two signals race each other? UML doesn't block
493 * signals with sigprocmask, SA_DEFER, or sa_mask, so a second signal
494 * could arrive while a previous one is still setting up the
495 * thread_info.
496 *
497 * There are three cases -
498 * The first interrupt on the stack - sets up the thread_info and
499 * handles the interrupt
500 * A nested interrupt interrupting the copying of the thread_info -
501 * can't handle the interrupt, as the stack is in an unknown state
502 * A nested interrupt not interrupting the copying of the
503 * thread_info - doesn't do any setup, just handles the interrupt
504 *
505 * The first job is to figure out whether we interrupted stack setup.
506 * This is done by xchging the signal mask with thread_info->pending.
507 * If the value that comes back is zero, then there is no setup in
508 * progress, and the interrupt can be handled. If the value is
509 * non-zero, then there is stack setup in progress. In order to have
510 * the interrupt handled, we leave our signal in the mask, and it will
511 * be handled by the upper handler after it has set up the stack.
512 *
513 * Next is to figure out whether we are the outer handler or a nested
514 * one. As part of setting up the stack, thread_info->real_thread is
515 * set to non-NULL (and is reset to NULL on exit). This is the
516 * nesting indicator. If it is non-NULL, then the stack is already
517 * set up and the handler can run.
518 */
519
520static unsigned long pending_mask;
521
522unsigned long to_irq_stack(int sig, unsigned long *mask_out)
523{
524 struct thread_info *ti;
525 unsigned long mask, old;
526 int nested;
527
528 mask = xchg(&pending_mask, 1 << sig);
529 if(mask != 0){
530 /* If any interrupts come in at this point, we want to
531 * make sure that their bits aren't lost by our
532 * putting our bit in. So, this loop accumulates bits
533 * until xchg returns the same value that we put in.
534 * When that happens, there were no new interrupts,
535 * and pending_mask contains a bit for each interrupt
536 * that came in.
537 */
538 old = 1 << sig;
539 do {
540 old |= mask;
541 mask = xchg(&pending_mask, old);
542 } while(mask != old);
543 return 1;
544 }
545
546 ti = current_thread_info();
547 nested = (ti->real_thread != NULL);
548 if(!nested){
549 struct task_struct *task;
550 struct thread_info *tti;
551
552 task = cpu_tasks[ti->cpu].task;
553 tti = task_thread_info(task);
554 *ti = *tti;
555 ti->real_thread = tti;
556 task->stack = ti;
557 }
558
559 mask = xchg(&pending_mask, 0);
560 *mask_out |= mask | nested;
561 return 0;
562}
563
564unsigned long from_irq_stack(int nested)
565{
566 struct thread_info *ti, *to;
567 unsigned long mask;
568
569 ti = current_thread_info();
570
571 pending_mask = 1;
572
573 to = ti->real_thread;
574 current->stack = to;
575 ti->real_thread = NULL;
576 *to = *ti;
577
578 mask = xchg(&pending_mask, 0);
579 return mask & ~1;
580}
581
diff --git a/arch/um/kernel/skas/process.c b/arch/um/kernel/skas/process.c
index a96ae1a0610e..2a69a7ce5792 100644
--- a/arch/um/kernel/skas/process.c
+++ b/arch/um/kernel/skas/process.c
@@ -163,8 +163,12 @@ static int start_kernel_proc(void *unused)
163 163
164extern int userspace_pid[]; 164extern int userspace_pid[];
165 165
166extern char cpu0_irqstack[];
167
166int start_uml_skas(void) 168int start_uml_skas(void)
167{ 169{
170 stack_protections((unsigned long) &cpu0_irqstack);
171 set_sigstack(cpu0_irqstack, THREAD_SIZE);
168 if(proc_mm) 172 if(proc_mm)
169 userspace_pid[0] = start_userspace(0); 173 userspace_pid[0] = start_userspace(0);
170 174
diff --git a/arch/um/kernel/tt/exec_kern.c b/arch/um/kernel/tt/exec_kern.c
index 98e21743e604..40126cb51801 100644
--- a/arch/um/kernel/tt/exec_kern.c
+++ b/arch/um/kernel/tt/exec_kern.c
@@ -57,7 +57,7 @@ void flush_thread_tt(void)
57 enable_timer(); 57 enable_timer();
58 free_page(stack); 58 free_page(stack);
59 protect_memory(uml_reserved, high_physmem - uml_reserved, 1, 1, 0, 1); 59 protect_memory(uml_reserved, high_physmem - uml_reserved, 1, 1, 0, 1);
60 task_protections((unsigned long) current_thread); 60 stack_protections((unsigned long) current_thread);
61 force_flush_all(); 61 force_flush_all();
62 unblock_signals(); 62 unblock_signals();
63} 63}
diff --git a/arch/um/kernel/tt/process_kern.c b/arch/um/kernel/tt/process_kern.c
index c631303cb800..74347adf81bf 100644
--- a/arch/um/kernel/tt/process_kern.c
+++ b/arch/um/kernel/tt/process_kern.c
@@ -209,7 +209,7 @@ void finish_fork_handler(int sig)
209 if(current->mm != current->parent->mm) 209 if(current->mm != current->parent->mm)
210 protect_memory(uml_reserved, high_physmem - uml_reserved, 1, 210 protect_memory(uml_reserved, high_physmem - uml_reserved, 1,
211 1, 0, 1); 211 1, 0, 1);
212 task_protections((unsigned long) current_thread); 212 stack_protections((unsigned long) current_thread);
213 213
214 free_page(current->thread.temp_stack); 214 free_page(current->thread.temp_stack);
215 local_irq_disable(); 215 local_irq_disable();
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 1cf954a47fd7..ecc458fe51b9 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -459,7 +459,7 @@ int __init linux_main(int argc, char **argv)
459 459
460 uml_postsetup(); 460 uml_postsetup();
461 461
462 task_protections((unsigned long) &init_thread_info); 462 stack_protections((unsigned long) &init_thread_info);
463 os_flush_stdout(); 463 os_flush_stdout();
464 464
465 return CHOOSE_MODE(start_uml_tt(), start_uml_skas()); 465 return CHOOSE_MODE(start_uml_tt(), start_uml_skas());
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S
index f6301274cf3c..bc59f97e34d0 100644
--- a/arch/um/kernel/uml.lds.S
+++ b/arch/um/kernel/uml.lds.S
@@ -59,6 +59,8 @@ SECTIONS
59 { 59 {
60 . = ALIGN(KERNEL_STACK_SIZE); /* init_task */ 60 . = ALIGN(KERNEL_STACK_SIZE); /* init_task */
61 *(.data.init_task) 61 *(.data.init_task)
62 . = ALIGN(KERNEL_STACK_SIZE);
63 *(.data.init_irqstack)
62 *(.data) 64 *(.data)
63 *(.gnu.linkonce.d*) 65 *(.gnu.linkonce.d*)
64 CONSTRUCTORS 66 CONSTRUCTORS
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
index 48d493415301..18e5c8b67eb8 100644
--- a/arch/um/os-Linux/signal.c
+++ b/arch/um/os-Linux/signal.c
@@ -61,15 +61,19 @@ void sig_handler(int sig, struct sigcontext *sc)
61 61
62static void real_alarm_handler(int sig, struct sigcontext *sc) 62static void real_alarm_handler(int sig, struct sigcontext *sc)
63{ 63{
64 union uml_pt_regs regs;
65
64 if(sig == SIGALRM) 66 if(sig == SIGALRM)
65 switch_timers(0); 67 switch_timers(0);
66 68
67 CHOOSE_MODE_PROC(sig_handler_common_tt, sig_handler_common_skas, 69 if(sc != NULL)
68 sig, sc); 70 copy_sc(&regs, sc);
71 regs.skas.is_user = 0;
72 unblock_signals();
73 timer_handler(sig, &regs);
69 74
70 if(sig == SIGALRM) 75 if(sig == SIGALRM)
71 switch_timers(1); 76 switch_timers(1);
72
73} 77}
74 78
75void alarm_handler(int sig, struct sigcontext *sc) 79void alarm_handler(int sig, struct sigcontext *sc)
@@ -113,6 +117,46 @@ void remove_sigstack(void)
113 117
114void (*handlers[_NSIG])(int sig, struct sigcontext *sc); 118void (*handlers[_NSIG])(int sig, struct sigcontext *sc);
115 119
120void handle_signal(int sig, struct sigcontext *sc)
121{
122 unsigned long pending = 0;
123
124 do {
125 int nested, bail;
126
127 /*
128 * pending comes back with one bit set for each
129 * interrupt that arrived while setting up the stack,
130 * plus a bit for this interrupt, plus the zero bit is
131 * set if this is a nested interrupt.
132 * If bail is true, then we interrupted another
133 * handler setting up the stack. In this case, we
134 * have to return, and the upper handler will deal
135 * with this interrupt.
136 */
137 bail = to_irq_stack(sig, &pending);
138 if(bail)
139 return;
140
141 nested = pending & 1;
142 pending &= ~1;
143
144 while((sig = ffs(pending)) != 0){
145 sig--;
146 pending &= ~(1 << sig);
147 (*handlers[sig])(sig, sc);
148 }
149
150 /* Again, pending comes back with a mask of signals
151 * that arrived while tearing down the stack. If this
152 * is non-zero, we just go back, set up the stack
153 * again, and handle the new interrupts.
154 */
155 if(!nested)
156 pending = from_irq_stack(nested);
157 } while(pending);
158}
159
116extern void hard_handler(int sig); 160extern void hard_handler(int sig);
117 161
118void set_handler(int sig, void (*handler)(int), int flags, ...) 162void set_handler(int sig, void (*handler)(int), int flags, ...)
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index 6a0e466d01e3..f9d2f8545afe 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -288,7 +288,8 @@ int start_userspace(unsigned long stub_stack)
288void userspace(union uml_pt_regs *regs) 288void userspace(union uml_pt_regs *regs)
289{ 289{
290 int err, status, op, pid = userspace_pid[0]; 290 int err, status, op, pid = userspace_pid[0];
291 int local_using_sysemu; /*To prevent races if using_sysemu changes under us.*/ 291 /* To prevent races if using_sysemu changes under us.*/
292 int local_using_sysemu;
292 293
293 while(1){ 294 while(1){
294 restore_registers(pid, regs); 295 restore_registers(pid, regs);
@@ -296,7 +297,8 @@ void userspace(union uml_pt_regs *regs)
296 /* Now we set local_using_sysemu to be used for one loop */ 297 /* Now we set local_using_sysemu to be used for one loop */
297 local_using_sysemu = get_using_sysemu(); 298 local_using_sysemu = get_using_sysemu();
298 299
299 op = SELECT_PTRACE_OPERATION(local_using_sysemu, singlestepping(NULL)); 300 op = SELECT_PTRACE_OPERATION(local_using_sysemu,
301 singlestepping(NULL));
300 302
301 err = ptrace(op, pid, 0, 0); 303 err = ptrace(op, pid, 0, 0);
302 if(err) 304 if(err)
@@ -490,8 +492,8 @@ void map_stub_pages(int fd, unsigned long code,
490void new_thread(void *stack, jmp_buf *buf, void (*handler)(void)) 492void new_thread(void *stack, jmp_buf *buf, void (*handler)(void))
491{ 493{
492 (*buf)[0].JB_IP = (unsigned long) handler; 494 (*buf)[0].JB_IP = (unsigned long) handler;
493 (*buf)[0].JB_SP = (unsigned long) stack + 495 (*buf)[0].JB_SP = (unsigned long) stack + UM_THREAD_SIZE -
494 (PAGE_SIZE << UML_CONFIG_KERNEL_STACK_ORDER) - sizeof(void *); 496 sizeof(void *);
495} 497}
496 498
497#define INIT_JMP_NEW_THREAD 0 499#define INIT_JMP_NEW_THREAD 0
@@ -533,8 +535,7 @@ int start_idle_thread(void *stack, jmp_buf *switch_buf)
533 case INIT_JMP_NEW_THREAD: 535 case INIT_JMP_NEW_THREAD:
534 (*switch_buf)[0].JB_IP = (unsigned long) new_thread_handler; 536 (*switch_buf)[0].JB_IP = (unsigned long) new_thread_handler;
535 (*switch_buf)[0].JB_SP = (unsigned long) stack + 537 (*switch_buf)[0].JB_SP = (unsigned long) stack +
536 (PAGE_SIZE << UML_CONFIG_KERNEL_STACK_ORDER) - 538 UM_THREAD_SIZE - sizeof(void *);
537 sizeof(void *);
538 break; 539 break;
539 case INIT_JMP_CALLBACK: 540 case INIT_JMP_CALLBACK:
540 (*cb_proc)(cb_arg); 541 (*cb_proc)(cb_arg);
diff --git a/arch/um/os-Linux/sys-i386/signal.c b/arch/um/os-Linux/sys-i386/signal.c
index 0d3eae518352..f311609f93da 100644
--- a/arch/um/os-Linux/sys-i386/signal.c
+++ b/arch/um/os-Linux/sys-i386/signal.c
@@ -1,15 +1,13 @@
1/* 1/*
2 * Copyright (C) 2006 Jeff Dike (jdike@addtoit.com) 2 * Copyright (C) 2006 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include <signal.h> 6#include <signal.h>
7 7
8extern void (*handlers[])(int sig, struct sigcontext *sc); 8extern void handle_signal(int sig, struct sigcontext *sc);
9 9
10void hard_handler(int sig) 10void hard_handler(int sig)
11{ 11{
12 struct sigcontext *sc = (struct sigcontext *) (&sig + 1); 12 handle_signal(sig, (struct sigcontext *) (&sig + 1));
13
14 (*handlers[sig])(sig, sc);
15} 13}
diff --git a/arch/um/os-Linux/sys-x86_64/signal.c b/arch/um/os-Linux/sys-x86_64/signal.c
index 3f369e5f976b..82a388822cd3 100644
--- a/arch/um/os-Linux/sys-x86_64/signal.c
+++ b/arch/um/os-Linux/sys-x86_64/signal.c
@@ -1,16 +1,16 @@
1/* 1/*
2 * Copyright (C) 2006 Jeff Dike (jdike@addtoit.com) 2 * Copyright (C) 2006 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include <signal.h> 6#include <signal.h>
7 7
8extern void (*handlers[])(int sig, struct sigcontext *sc); 8extern void handle_signal(int sig, struct sigcontext *sc);
9 9
10void hard_handler(int sig) 10void hard_handler(int sig)
11{ 11{
12 struct ucontext *uc; 12 struct ucontext *uc;
13 asm("movq %%rdx, %0" : "=r" (uc)); 13 asm("movq %%rdx, %0" : "=r" (uc));
14 14
15 (*handlers[sig])(sig, (struct sigcontext *) &uc->uc_mcontext); 15 handle_signal(sig, (struct sigcontext *) &uc->uc_mcontext);
16} 16}
diff --git a/arch/um/os-Linux/util.c b/arch/um/os-Linux/util.c
index c307a89ed259..7cbcf484e13d 100644
--- a/arch/um/os-Linux/util.c
+++ b/arch/um/os-Linux/util.c
@@ -33,25 +33,8 @@
33 33
34void stack_protections(unsigned long address) 34void stack_protections(unsigned long address)
35{ 35{
36 int prot = PROT_READ | PROT_WRITE | PROT_EXEC; 36 if(mprotect((void *) address, UM_THREAD_SIZE,
37 37 PROT_READ | PROT_WRITE | PROT_EXEC) < 0)
38 if(mprotect((void *) address, UM_KERN_PAGE_SIZE, prot) < 0)
39 panic("protecting stack failed, errno = %d", errno);
40}
41
42void task_protections(unsigned long address)
43{
44 unsigned long guard = address + UM_KERN_PAGE_SIZE;
45 unsigned long stack = guard + UM_KERN_PAGE_SIZE;
46 int prot = 0, pages;
47
48#ifdef notdef
49 if(mprotect((void *) stack, UM_KERN_PAGE_SIZE, prot) < 0)
50 panic("protecting guard page failed, errno = %d", errno);
51#endif
52 pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER) - 2;
53 prot = PROT_READ | PROT_WRITE | PROT_EXEC;
54 if(mprotect((void *) stack, pages * UM_KERN_PAGE_SIZE, prot) < 0)
55 panic("protecting stack failed, errno = %d", errno); 38 panic("protecting stack failed, errno = %d", errno);
56} 39}
57 40
@@ -72,7 +55,7 @@ int raw(int fd)
72 55
73 /* XXX tcsetattr could have applied only some changes 56 /* XXX tcsetattr could have applied only some changes
74 * (and cfmakeraw() is a set of changes) */ 57 * (and cfmakeraw() is a set of changes) */
75 return(0); 58 return 0;
76} 59}
77 60
78void setup_machinename(char *machine_out) 61void setup_machinename(char *machine_out)
diff --git a/arch/x86_64/ia32/audit.c b/arch/x86_64/ia32/audit.c
index 92d7d0c8d93f..8850fe40ea34 100644
--- a/arch/x86_64/ia32/audit.c
+++ b/arch/x86_64/ia32/audit.c
@@ -20,6 +20,11 @@ unsigned ia32_read_class[] = {
20~0U 20~0U
21}; 21};
22 22
23unsigned ia32_signal_class[] = {
24#include <asm-generic/audit_signal.h>
25~0U
26};
27
23int ia32_classify_syscall(unsigned syscall) 28int ia32_classify_syscall(unsigned syscall)
24{ 29{
25 switch(syscall) { 30 switch(syscall) {
diff --git a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S
index f21068378272..21868f9bed7c 100644
--- a/arch/x86_64/ia32/ia32entry.S
+++ b/arch/x86_64/ia32/ia32entry.S
@@ -716,4 +716,7 @@ ia32_sys_call_table:
716 .quad sys_getcpu 716 .quad sys_getcpu
717 .quad sys_epoll_pwait 717 .quad sys_epoll_pwait
718 .quad compat_sys_utimensat /* 320 */ 718 .quad compat_sys_utimensat /* 320 */
719ia32_syscall_end: 719 .quad compat_sys_signalfd
720 .quad compat_sys_timerfd
721 .quad sys_eventfd
722ia32_syscall_end:
diff --git a/arch/x86_64/kernel/aperture.c b/arch/x86_64/kernel/aperture.c
index a52af5820592..a3d450d6c15b 100644
--- a/arch/x86_64/kernel/aperture.c
+++ b/arch/x86_64/kernel/aperture.c
@@ -86,7 +86,7 @@ static int __init aperture_valid(u64 aper_base, u32 aper_size)
86 printk("Aperture too small (%d MB)\n", aper_size>>20); 86 printk("Aperture too small (%d MB)\n", aper_size>>20);
87 return 0; 87 return 0;
88 } 88 }
89 if (aper_base + aper_size >= 0xffffffff) { 89 if (aper_base + aper_size > 0x100000000UL) {
90 printk("Aperture beyond 4GB. Ignoring.\n"); 90 printk("Aperture beyond 4GB. Ignoring.\n");
91 return 0; 91 return 0;
92 } 92 }
diff --git a/arch/x86_64/kernel/audit.c b/arch/x86_64/kernel/audit.c
index 21f33387bef3..06d3e5a14d9d 100644
--- a/arch/x86_64/kernel/audit.c
+++ b/arch/x86_64/kernel/audit.c
@@ -23,6 +23,20 @@ static unsigned chattr_class[] = {
23~0U 23~0U
24}; 24};
25 25
26static unsigned signal_class[] = {
27#include <asm-generic/audit_signal.h>
28~0U
29};
30
31int audit_classify_arch(int arch)
32{
33#ifdef CONFIG_IA32_EMULATION
34 if (arch == AUDIT_ARCH_I386)
35 return 1;
36#endif
37 return 0;
38}
39
26int audit_classify_syscall(int abi, unsigned syscall) 40int audit_classify_syscall(int abi, unsigned syscall)
27{ 41{
28#ifdef CONFIG_IA32_EMULATION 42#ifdef CONFIG_IA32_EMULATION
@@ -49,15 +63,18 @@ static int __init audit_classes_init(void)
49 extern __u32 ia32_write_class[]; 63 extern __u32 ia32_write_class[];
50 extern __u32 ia32_read_class[]; 64 extern __u32 ia32_read_class[];
51 extern __u32 ia32_chattr_class[]; 65 extern __u32 ia32_chattr_class[];
66 extern __u32 ia32_signal_class[];
52 audit_register_class(AUDIT_CLASS_WRITE_32, ia32_write_class); 67 audit_register_class(AUDIT_CLASS_WRITE_32, ia32_write_class);
53 audit_register_class(AUDIT_CLASS_READ_32, ia32_read_class); 68 audit_register_class(AUDIT_CLASS_READ_32, ia32_read_class);
54 audit_register_class(AUDIT_CLASS_DIR_WRITE_32, ia32_dir_class); 69 audit_register_class(AUDIT_CLASS_DIR_WRITE_32, ia32_dir_class);
55 audit_register_class(AUDIT_CLASS_CHATTR_32, ia32_chattr_class); 70 audit_register_class(AUDIT_CLASS_CHATTR_32, ia32_chattr_class);
71 audit_register_class(AUDIT_CLASS_SIGNAL_32, ia32_signal_class);
56#endif 72#endif
57 audit_register_class(AUDIT_CLASS_WRITE, write_class); 73 audit_register_class(AUDIT_CLASS_WRITE, write_class);
58 audit_register_class(AUDIT_CLASS_READ, read_class); 74 audit_register_class(AUDIT_CLASS_READ, read_class);
59 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class); 75 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
60 audit_register_class(AUDIT_CLASS_CHATTR, chattr_class); 76 audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
77 audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
61 return 0; 78 return 0;
62} 79}
63 80
diff --git a/arch/x86_64/kernel/bugs.c b/arch/x86_64/kernel/bugs.c
index 12b585b5345d..c3c6b91566ed 100644
--- a/arch/x86_64/kernel/bugs.c
+++ b/arch/x86_64/kernel/bugs.c
@@ -9,10 +9,12 @@
9#include <linux/init.h> 9#include <linux/init.h>
10#include <asm/alternative.h> 10#include <asm/alternative.h>
11#include <asm/processor.h> 11#include <asm/processor.h>
12#include <asm/mtrr.h>
12 13
13void __init check_bugs(void) 14void __init check_bugs(void)
14{ 15{
15 identify_cpu(&boot_cpu_data); 16 identify_cpu(&boot_cpu_data);
17 mtrr_bp_init();
16#if !defined(CONFIG_SMP) 18#if !defined(CONFIG_SMP)
17 printk("CPU: "); 19 printk("CPU: ");
18 print_cpu_info(&boot_cpu_data); 20 print_cpu_info(&boot_cpu_data);
diff --git a/arch/x86_64/kernel/head64.c b/arch/x86_64/kernel/head64.c
index 213d90e04755..6c34bdd22e26 100644
--- a/arch/x86_64/kernel/head64.c
+++ b/arch/x86_64/kernel/head64.c
@@ -62,13 +62,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
62{ 62{
63 int i; 63 int i;
64 64
65 /*
66 * Make sure kernel is aligned to 2MB address. Catching it at compile
67 * time is better. Change your config file and compile the kernel
68 * for a 2MB aligned address (CONFIG_PHYSICAL_START)
69 */
70 BUILD_BUG_ON(CONFIG_PHYSICAL_START & (__KERNEL_ALIGN - 1));
71
72 /* clear bss before set_intr_gate with early_idt_handler */ 65 /* clear bss before set_intr_gate with early_idt_handler */
73 clear_bss(); 66 clear_bss();
74 67
diff --git a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c
index 373ef66ca1dc..ae091cdc1a4d 100644
--- a/arch/x86_64/kernel/pci-gart.c
+++ b/arch/x86_64/kernel/pci-gart.c
@@ -476,7 +476,7 @@ static __init unsigned read_aperture(struct pci_dev *dev, u32 *size)
476 aper_base <<= 25; 476 aper_base <<= 25;
477 477
478 aper_size = (32 * 1024 * 1024) << aper_order; 478 aper_size = (32 * 1024 * 1024) << aper_order;
479 if (aper_base + aper_size >= 0xffffffff || !aper_size) 479 if (aper_base + aper_size > 0x100000000UL || !aper_size)
480 aper_base = 0; 480 aper_base = 0;
481 481
482 *size = aper_size; 482 *size = aper_size;
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index db51577bda32..eb6524f3ac29 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -891,9 +891,7 @@ void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
891#ifdef CONFIG_X86_MCE 891#ifdef CONFIG_X86_MCE
892 mcheck_init(c); 892 mcheck_init(c);
893#endif 893#endif
894 if (c == &boot_cpu_data) 894 if (c != &boot_cpu_data)
895 mtrr_bp_init();
896 else
897 mtrr_ap_init(); 895 mtrr_ap_init();
898#ifdef CONFIG_NUMA 896#ifdef CONFIG_NUMA
899 numa_add_cpu(smp_processor_id()); 897 numa_add_cpu(smp_processor_id());
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 17e188973428..74a567afb830 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -3116,7 +3116,7 @@ static inline int should_fail_request(struct bio *bio)
3116 * bi_sector for remaps as it sees fit. So the values of these fields 3116 * bi_sector for remaps as it sees fit. So the values of these fields
3117 * should NOT be depended on after the call to generic_make_request. 3117 * should NOT be depended on after the call to generic_make_request.
3118 */ 3118 */
3119void generic_make_request(struct bio *bio) 3119static inline void __generic_make_request(struct bio *bio)
3120{ 3120{
3121 request_queue_t *q; 3121 request_queue_t *q;
3122 sector_t maxsector; 3122 sector_t maxsector;
@@ -3215,6 +3215,57 @@ end_io:
3215 } while (ret); 3215 } while (ret);
3216} 3216}
3217 3217
3218/*
3219 * We only want one ->make_request_fn to be active at a time,
3220 * else stack usage with stacked devices could be a problem.
3221 * So use current->bio_{list,tail} to keep a list of requests
3222 * submited by a make_request_fn function.
3223 * current->bio_tail is also used as a flag to say if
3224 * generic_make_request is currently active in this task or not.
3225 * If it is NULL, then no make_request is active. If it is non-NULL,
3226 * then a make_request is active, and new requests should be added
3227 * at the tail
3228 */
3229void generic_make_request(struct bio *bio)
3230{
3231 if (current->bio_tail) {
3232 /* make_request is active */
3233 *(current->bio_tail) = bio;
3234 bio->bi_next = NULL;
3235 current->bio_tail = &bio->bi_next;
3236 return;
3237 }
3238 /* following loop may be a bit non-obvious, and so deserves some
3239 * explanation.
3240 * Before entering the loop, bio->bi_next is NULL (as all callers
3241 * ensure that) so we have a list with a single bio.
3242 * We pretend that we have just taken it off a longer list, so
3243 * we assign bio_list to the next (which is NULL) and bio_tail
3244 * to &bio_list, thus initialising the bio_list of new bios to be
3245 * added. __generic_make_request may indeed add some more bios
3246 * through a recursive call to generic_make_request. If it
3247 * did, we find a non-NULL value in bio_list and re-enter the loop
3248 * from the top. In this case we really did just take the bio
3249 * of the top of the list (no pretending) and so fixup bio_list and
3250 * bio_tail or bi_next, and call into __generic_make_request again.
3251 *
3252 * The loop was structured like this to make only one call to
3253 * __generic_make_request (which is important as it is large and
3254 * inlined) and to keep the structure simple.
3255 */
3256 BUG_ON(bio->bi_next);
3257 do {
3258 current->bio_list = bio->bi_next;
3259 if (bio->bi_next == NULL)
3260 current->bio_tail = &current->bio_list;
3261 else
3262 bio->bi_next = NULL;
3263 __generic_make_request(bio);
3264 bio = current->bio_list;
3265 } while (bio);
3266 current->bio_tail = NULL; /* deactivate */
3267}
3268
3218EXPORT_SYMBOL(generic_make_request); 3269EXPORT_SYMBOL(generic_make_request);
3219 3270
3220/** 3271/**
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index f031b8732330..ad1f59c1b3fc 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -2,11 +2,9 @@
2# SATA/PATA driver configuration 2# SATA/PATA driver configuration
3# 3#
4 4
5menu "Serial ATA (prod) and Parallel ATA (experimental) drivers" 5menuconfig ATA
6 tristate "Serial ATA (prod) and Parallel ATA (experimental) drivers"
6 depends on HAS_IOMEM 7 depends on HAS_IOMEM
7
8config ATA
9 tristate "ATA device support"
10 depends on BLOCK 8 depends on BLOCK
11 depends on !(M32R || M68K) || BROKEN 9 depends on !(M32R || M68K) || BROKEN
12 depends on !SUN4 || BROKEN 10 depends on !SUN4 || BROKEN
@@ -24,6 +22,19 @@ config ATA_NONSTANDARD
24 bool 22 bool
25 default n 23 default n
26 24
25config ATA_ACPI
26 bool
27 depends on ACPI && PCI
28 default y
29 help
30 This option adds support for ATA-related ACPI objects.
31 These ACPI objects add the ability to retrieve taskfiles
32 from the ACPI BIOS and write them to the disk controller.
33 These objects may be related to performance, security,
34 power management, or other areas.
35 You can disable this at kernel boot time by using the
36 option libata.noacpi=1
37
27config SATA_AHCI 38config SATA_AHCI
28 tristate "AHCI SATA support" 39 tristate "AHCI SATA support"
29 depends on PCI 40 depends on PCI
@@ -157,19 +168,6 @@ config SATA_INIC162X
157 help 168 help
158 This option enables support for Initio 162x Serial ATA. 169 This option enables support for Initio 162x Serial ATA.
159 170
160config SATA_ACPI
161 bool
162 depends on ACPI && PCI
163 default y
164 help
165 This option adds support for SATA-related ACPI objects.
166 These ACPI objects add the ability to retrieve taskfiles
167 from the ACPI BIOS and write them to the disk controller.
168 These objects may be related to performance, security,
169 power management, or other areas.
170 You can disable this at kernel boot time by using the
171 option libata.noacpi=1
172
173config PATA_ALI 171config PATA_ALI
174 tristate "ALi PATA support (Experimental)" 172 tristate "ALi PATA support (Experimental)"
175 depends on PCI && EXPERIMENTAL 173 depends on PCI && EXPERIMENTAL
@@ -585,6 +583,4 @@ config PATA_SCC
585 583
586 If unsure, say N. 584 If unsure, say N.
587 585
588endif 586endif # ATA
589endmenu
590
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 6f42a0e2812d..8149c68ac2c7 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -69,4 +69,4 @@ obj-$(CONFIG_ATA_GENERIC) += ata_generic.o
69obj-$(CONFIG_PATA_LEGACY) += pata_legacy.o 69obj-$(CONFIG_PATA_LEGACY) += pata_legacy.o
70 70
71libata-objs := libata-core.o libata-scsi.o libata-sff.o libata-eh.o 71libata-objs := libata-core.o libata-scsi.o libata-sff.o libata-eh.o
72libata-$(CONFIG_SATA_ACPI) += libata-acpi.o 72libata-$(CONFIG_ATA_ACPI) += libata-acpi.o
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index d9617892fc23..1ae443d7ab92 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -250,10 +250,6 @@ static struct scsi_host_template ahci_sht = {
250 .slave_configure = ata_scsi_slave_config, 250 .slave_configure = ata_scsi_slave_config,
251 .slave_destroy = ata_scsi_slave_destroy, 251 .slave_destroy = ata_scsi_slave_destroy,
252 .bios_param = ata_std_bios_param, 252 .bios_param = ata_std_bios_param,
253#ifdef CONFIG_PM
254 .suspend = ata_scsi_device_suspend,
255 .resume = ata_scsi_device_resume,
256#endif
257}; 253};
258 254
259static const struct ata_port_operations ahci_ops = { 255static const struct ata_port_operations ahci_ops = {
@@ -400,6 +396,7 @@ static const struct pci_device_id ahci_pci_tbl[] = {
400 396
401 /* ATI */ 397 /* ATI */
402 { PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */ 398 { PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */
399 { PCI_VDEVICE(ATI, 0x4390), board_ahci_sb600 }, /* ATI SB700 */
403 400
404 /* VIA */ 401 /* VIA */
405 { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */ 402 { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c
index 92a491ddd030..c3d753296bc6 100644
--- a/drivers/ata/ata_generic.c
+++ b/drivers/ata/ata_generic.c
@@ -54,7 +54,7 @@ static int generic_set_mode(struct ata_port *ap, struct ata_device **unused)
54 54
55 for (i = 0; i < ATA_MAX_DEVICES; i++) { 55 for (i = 0; i < ATA_MAX_DEVICES; i++) {
56 struct ata_device *dev = &ap->device[i]; 56 struct ata_device *dev = &ap->device[i];
57 if (ata_dev_ready(dev)) { 57 if (ata_dev_enabled(dev)) {
58 /* We don't really care */ 58 /* We don't really care */
59 dev->pio_mode = XFER_PIO_0; 59 dev->pio_mode = XFER_PIO_0;
60 dev->dma_mode = XFER_MW_DMA_0; 60 dev->dma_mode = XFER_MW_DMA_0;
@@ -90,10 +90,6 @@ static struct scsi_host_template generic_sht = {
90 .slave_configure = ata_scsi_slave_config, 90 .slave_configure = ata_scsi_slave_config,
91 .slave_destroy = ata_scsi_slave_destroy, 91 .slave_destroy = ata_scsi_slave_destroy,
92 .bios_param = ata_std_bios_param, 92 .bios_param = ata_std_bios_param,
93#ifdef CONFIG_PM
94 .resume = ata_scsi_device_resume,
95 .suspend = ata_scsi_device_suspend,
96#endif
97}; 93};
98 94
99static struct ata_port_operations generic_port_ops = { 95static struct ata_port_operations generic_port_ops = {
@@ -145,7 +141,7 @@ static int all_generic_ide; /* Set to claim all devices */
145static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id *id) 141static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id *id)
146{ 142{
147 u16 command; 143 u16 command;
148 static struct ata_port_info info = { 144 static const struct ata_port_info info = {
149 .sht = &generic_sht, 145 .sht = &generic_sht,
150 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 146 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
151 .pio_mask = 0x1f, 147 .pio_mask = 0x1f,
@@ -153,7 +149,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id
153 .udma_mask = 0x3f, 149 .udma_mask = 0x3f,
154 .port_ops = &generic_port_ops 150 .port_ops = &generic_port_ops
155 }; 151 };
156 static struct ata_port_info *port_info[2] = { &info, &info }; 152 const struct ata_port_info *ppi[] = { &info, NULL };
157 153
158 /* Don't use the generic entry unless instructed to do so */ 154 /* Don't use the generic entry unless instructed to do so */
159 if (id->driver_data == 1 && all_generic_ide == 0) 155 if (id->driver_data == 1 && all_generic_ide == 0)
@@ -179,7 +175,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id
179 if (dev->vendor == PCI_VENDOR_ID_AL) 175 if (dev->vendor == PCI_VENDOR_ID_AL)
180 ata_pci_clear_simplex(dev); 176 ata_pci_clear_simplex(dev);
181 177
182 return ata_pci_init_one(dev, port_info, 2); 178 return ata_pci_init_one(dev, ppi);
183} 179}
184 180
185static struct pci_device_id ata_generic[] = { 181static struct pci_device_id ata_generic[] = {
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 4a795fdb6a02..13b6b1df2ac4 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -275,10 +275,6 @@ static struct scsi_host_template piix_sht = {
275 .slave_configure = ata_scsi_slave_config, 275 .slave_configure = ata_scsi_slave_config,
276 .slave_destroy = ata_scsi_slave_destroy, 276 .slave_destroy = ata_scsi_slave_destroy,
277 .bios_param = ata_std_bios_param, 277 .bios_param = ata_std_bios_param,
278#ifdef CONFIG_PM
279 .resume = ata_scsi_device_resume,
280 .suspend = ata_scsi_device_suspend,
281#endif
282}; 278};
283 279
284static const struct ata_port_operations piix_pata_ops = { 280static const struct ata_port_operations piix_pata_ops = {
@@ -1034,7 +1030,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1034 static int printed_version; 1030 static int printed_version;
1035 struct device *dev = &pdev->dev; 1031 struct device *dev = &pdev->dev;
1036 struct ata_port_info port_info[2]; 1032 struct ata_port_info port_info[2];
1037 struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] }; 1033 const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] };
1038 struct piix_host_priv *hpriv; 1034 struct piix_host_priv *hpriv;
1039 unsigned long port_flags; 1035 unsigned long port_flags;
1040 1036
@@ -1093,7 +1089,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1093 port_info[1].mwdma_mask = 0; 1089 port_info[1].mwdma_mask = 0;
1094 port_info[1].udma_mask = 0; 1090 port_info[1].udma_mask = 0;
1095 } 1091 }
1096 return ata_pci_init_one(pdev, ppinfo, 2); 1092 return ata_pci_init_one(pdev, ppi);
1097} 1093}
1098 1094
1099static int __init piix_init(void) 1095static int __init piix_init(void)
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index cb3eab6e379d..ed4138e24b0c 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -270,8 +270,7 @@ out:
270 270
271/** 271/**
272 * do_drive_get_GTF - get the drive bootup default taskfile settings 272 * do_drive_get_GTF - get the drive bootup default taskfile settings
273 * @ap: the ata_port for the drive 273 * @dev: target ATA device
274 * @ix: target ata_device (drive) index
275 * @gtf_length: number of bytes of _GTF data returned at @gtf_address 274 * @gtf_length: number of bytes of _GTF data returned at @gtf_address
276 * @gtf_address: buffer containing _GTF taskfile arrays 275 * @gtf_address: buffer containing _GTF taskfile arrays
277 * 276 *
@@ -286,20 +285,19 @@ out:
286 * The returned @gtf_length and @gtf_address are only valid if the 285 * The returned @gtf_length and @gtf_address are only valid if the
287 * function return value is 0. 286 * function return value is 0.
288 */ 287 */
289static int do_drive_get_GTF(struct ata_port *ap, int ix, 288static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length,
290 unsigned int *gtf_length, unsigned long *gtf_address, 289 unsigned long *gtf_address, unsigned long *obj_loc)
291 unsigned long *obj_loc)
292{ 290{
293 acpi_status status; 291 struct ata_port *ap = dev->ap;
294 acpi_handle dev_handle = NULL; 292 acpi_status status;
295 acpi_handle chan_handle, drive_handle; 293 acpi_handle dev_handle = NULL;
296 acpi_integer pcidevfn = 0; 294 acpi_handle chan_handle, drive_handle;
297 u32 dev_adr; 295 acpi_integer pcidevfn = 0;
298 struct acpi_buffer output; 296 u32 dev_adr;
299 union acpi_object *out_obj; 297 struct acpi_buffer output;
300 struct device *dev = ap->host->dev; 298 union acpi_object *out_obj;
301 struct ata_device *atadev = &ap->device[ix]; 299 struct device *gdev = ap->host->dev;
302 int err = -ENODEV; 300 int err = -ENODEV;
303 301
304 *gtf_length = 0; 302 *gtf_length = 0;
305 *gtf_address = 0UL; 303 *gtf_address = 0UL;
@@ -309,14 +307,14 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
309 return 0; 307 return 0;
310 308
311 if (ata_msg_probe(ap)) 309 if (ata_msg_probe(ap))
312 ata_dev_printk(atadev, KERN_DEBUG, "%s: ENTER: port#: %d\n", 310 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n",
313 __FUNCTION__, ap->port_no); 311 __FUNCTION__, ap->port_no);
314 312
315 if (!ata_dev_enabled(atadev) || (ap->flags & ATA_FLAG_DISABLED)) { 313 if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED)) {
316 if (ata_msg_probe(ap)) 314 if (ata_msg_probe(ap))
317 ata_dev_printk(atadev, KERN_DEBUG, "%s: ERR: " 315 ata_dev_printk(dev, KERN_DEBUG, "%s: ERR: "
318 "ata_dev_present: %d, PORT_DISABLED: %lu\n", 316 "ata_dev_present: %d, PORT_DISABLED: %lu\n",
319 __FUNCTION__, ata_dev_enabled(atadev), 317 __FUNCTION__, ata_dev_enabled(dev),
320 ap->flags & ATA_FLAG_DISABLED); 318 ap->flags & ATA_FLAG_DISABLED);
321 goto out; 319 goto out;
322 } 320 }
@@ -324,19 +322,19 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
324 /* Don't continue if device has no _ADR method. 322 /* Don't continue if device has no _ADR method.
325 * _GTF is intended for known motherboard devices. */ 323 * _GTF is intended for known motherboard devices. */
326 if (!(ap->cbl == ATA_CBL_SATA)) { 324 if (!(ap->cbl == ATA_CBL_SATA)) {
327 err = pata_get_dev_handle(dev, &dev_handle, &pcidevfn); 325 err = pata_get_dev_handle(gdev, &dev_handle, &pcidevfn);
328 if (err < 0) { 326 if (err < 0) {
329 if (ata_msg_probe(ap)) 327 if (ata_msg_probe(ap))
330 ata_dev_printk(atadev, KERN_DEBUG, 328 ata_dev_printk(dev, KERN_DEBUG,
331 "%s: pata_get_dev_handle failed (%d)\n", 329 "%s: pata_get_dev_handle failed (%d)\n",
332 __FUNCTION__, err); 330 __FUNCTION__, err);
333 goto out; 331 goto out;
334 } 332 }
335 } else { 333 } else {
336 err = sata_get_dev_handle(dev, &dev_handle, &pcidevfn); 334 err = sata_get_dev_handle(gdev, &dev_handle, &pcidevfn);
337 if (err < 0) { 335 if (err < 0) {
338 if (ata_msg_probe(ap)) 336 if (ata_msg_probe(ap))
339 ata_dev_printk(atadev, KERN_DEBUG, 337 ata_dev_printk(dev, KERN_DEBUG,
340 "%s: sata_get_dev_handle failed (%d\n", 338 "%s: sata_get_dev_handle failed (%d\n",
341 __FUNCTION__, err); 339 __FUNCTION__, err);
342 goto out; 340 goto out;
@@ -344,7 +342,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
344 } 342 }
345 343
346 /* Get this drive's _ADR info. if not already known. */ 344 /* Get this drive's _ADR info. if not already known. */
347 if (!atadev->obj_handle) { 345 if (!dev->obj_handle) {
348 if (!(ap->cbl == ATA_CBL_SATA)) { 346 if (!(ap->cbl == ATA_CBL_SATA)) {
349 /* get child objects of dev_handle == channel objects, 347 /* get child objects of dev_handle == channel objects,
350 * + _their_ children == drive objects */ 348 * + _their_ children == drive objects */
@@ -352,7 +350,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
352 chan_handle = acpi_get_child(dev_handle, 350 chan_handle = acpi_get_child(dev_handle,
353 ap->port_no); 351 ap->port_no);
354 if (ata_msg_probe(ap)) 352 if (ata_msg_probe(ap))
355 ata_dev_printk(atadev, KERN_DEBUG, 353 ata_dev_printk(dev, KERN_DEBUG,
356 "%s: chan adr=%d: chan_handle=0x%p\n", 354 "%s: chan adr=%d: chan_handle=0x%p\n",
357 __FUNCTION__, ap->port_no, 355 __FUNCTION__, ap->port_no,
358 chan_handle); 356 chan_handle);
@@ -361,26 +359,26 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
361 goto out; 359 goto out;
362 } 360 }
363 /* TBD: could also check ACPI object VALID bits */ 361 /* TBD: could also check ACPI object VALID bits */
364 drive_handle = acpi_get_child(chan_handle, ix); 362 drive_handle = acpi_get_child(chan_handle, dev->devno);
365 if (!drive_handle) { 363 if (!drive_handle) {
366 err = -ENODEV; 364 err = -ENODEV;
367 goto out; 365 goto out;
368 } 366 }
369 dev_adr = ix; 367 dev_adr = dev->devno;
370 atadev->obj_handle = drive_handle; 368 dev->obj_handle = drive_handle;
371 } else { /* for SATA mode */ 369 } else { /* for SATA mode */
372 dev_adr = SATA_ADR_RSVD; 370 dev_adr = SATA_ADR_RSVD;
373 err = get_sata_adr(dev, dev_handle, pcidevfn, 0, 371 err = get_sata_adr(gdev, dev_handle, pcidevfn, 0,
374 ap, atadev, &dev_adr); 372 ap, dev, &dev_adr);
375 } 373 }
376 if (err < 0 || dev_adr == SATA_ADR_RSVD || 374 if (err < 0 || dev_adr == SATA_ADR_RSVD ||
377 !atadev->obj_handle) { 375 !dev->obj_handle) {
378 if (ata_msg_probe(ap)) 376 if (ata_msg_probe(ap))
379 ata_dev_printk(atadev, KERN_DEBUG, 377 ata_dev_printk(dev, KERN_DEBUG,
380 "%s: get_sata/pata_adr failed: " 378 "%s: get_sata/pata_adr failed: "
381 "err=%d, dev_adr=%u, obj_handle=0x%p\n", 379 "err=%d, dev_adr=%u, obj_handle=0x%p\n",
382 __FUNCTION__, err, dev_adr, 380 __FUNCTION__, err, dev_adr,
383 atadev->obj_handle); 381 dev->obj_handle);
384 goto out; 382 goto out;
385 } 383 }
386 } 384 }
@@ -391,11 +389,11 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
391 389
392 /* _GTF has no input parameters */ 390 /* _GTF has no input parameters */
393 err = -EIO; 391 err = -EIO;
394 status = acpi_evaluate_object(atadev->obj_handle, "_GTF", 392 status = acpi_evaluate_object(dev->obj_handle, "_GTF",
395 NULL, &output); 393 NULL, &output);
396 if (ACPI_FAILURE(status)) { 394 if (ACPI_FAILURE(status)) {
397 if (ata_msg_probe(ap)) 395 if (ata_msg_probe(ap))
398 ata_dev_printk(atadev, KERN_DEBUG, 396 ata_dev_printk(dev, KERN_DEBUG,
399 "%s: Run _GTF error: status = 0x%x\n", 397 "%s: Run _GTF error: status = 0x%x\n",
400 __FUNCTION__, status); 398 __FUNCTION__, status);
401 goto out; 399 goto out;
@@ -403,7 +401,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
403 401
404 if (!output.length || !output.pointer) { 402 if (!output.length || !output.pointer) {
405 if (ata_msg_probe(ap)) 403 if (ata_msg_probe(ap))
406 ata_dev_printk(atadev, KERN_DEBUG, "%s: Run _GTF: " 404 ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: "
407 "length or ptr is NULL (0x%llx, 0x%p)\n", 405 "length or ptr is NULL (0x%llx, 0x%p)\n",
408 __FUNCTION__, 406 __FUNCTION__,
409 (unsigned long long)output.length, 407 (unsigned long long)output.length,
@@ -416,7 +414,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
416 if (out_obj->type != ACPI_TYPE_BUFFER) { 414 if (out_obj->type != ACPI_TYPE_BUFFER) {
417 kfree(output.pointer); 415 kfree(output.pointer);
418 if (ata_msg_probe(ap)) 416 if (ata_msg_probe(ap))
419 ata_dev_printk(atadev, KERN_DEBUG, "%s: Run _GTF: " 417 ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: "
420 "error: expected object type of " 418 "error: expected object type of "
421 " ACPI_TYPE_BUFFER, got 0x%x\n", 419 " ACPI_TYPE_BUFFER, got 0x%x\n",
422 __FUNCTION__, out_obj->type); 420 __FUNCTION__, out_obj->type);
@@ -427,7 +425,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
427 if (!out_obj->buffer.length || !out_obj->buffer.pointer || 425 if (!out_obj->buffer.length || !out_obj->buffer.pointer ||
428 out_obj->buffer.length % REGS_PER_GTF) { 426 out_obj->buffer.length % REGS_PER_GTF) {
429 if (ata_msg_drv(ap)) 427 if (ata_msg_drv(ap))
430 ata_dev_printk(atadev, KERN_ERR, 428 ata_dev_printk(dev, KERN_ERR,
431 "%s: unexpected GTF length (%d) or addr (0x%p)\n", 429 "%s: unexpected GTF length (%d) or addr (0x%p)\n",
432 __FUNCTION__, out_obj->buffer.length, 430 __FUNCTION__, out_obj->buffer.length,
433 out_obj->buffer.pointer); 431 out_obj->buffer.pointer);
@@ -439,7 +437,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix,
439 *gtf_address = (unsigned long)out_obj->buffer.pointer; 437 *gtf_address = (unsigned long)out_obj->buffer.pointer;
440 *obj_loc = (unsigned long)out_obj; 438 *obj_loc = (unsigned long)out_obj;
441 if (ata_msg_probe(ap)) 439 if (ata_msg_probe(ap))
442 ata_dev_printk(atadev, KERN_DEBUG, "%s: returning " 440 ata_dev_printk(dev, KERN_DEBUG, "%s: returning "
443 "gtf_length=%d, gtf_address=0x%lx, obj_loc=0x%lx\n", 441 "gtf_length=%d, gtf_address=0x%lx, obj_loc=0x%lx\n",
444 __FUNCTION__, *gtf_length, *gtf_address, *obj_loc); 442 __FUNCTION__, *gtf_length, *gtf_address, *obj_loc);
445 err = 0; 443 err = 0;
@@ -449,7 +447,7 @@ out:
449 447
450/** 448/**
451 * taskfile_load_raw - send taskfile registers to host controller 449 * taskfile_load_raw - send taskfile registers to host controller
452 * @ap: Port to which output is sent 450 * @dev: target ATA device
453 * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7) 451 * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7)
454 * 452 *
455 * Outputs ATA taskfile to standard ATA host controller using MMIO 453 * Outputs ATA taskfile to standard ATA host controller using MMIO
@@ -466,15 +464,15 @@ out:
466 * LOCKING: TBD: 464 * LOCKING: TBD:
467 * Inherited from caller. 465 * Inherited from caller.
468 */ 466 */
469static void taskfile_load_raw(struct ata_port *ap, 467static void taskfile_load_raw(struct ata_device *dev,
470 struct ata_device *atadev, 468 const struct taskfile_array *gtf)
471 const struct taskfile_array *gtf)
472{ 469{
470 struct ata_port *ap = dev->ap;
473 struct ata_taskfile tf; 471 struct ata_taskfile tf;
474 unsigned int err; 472 unsigned int err;
475 473
476 if (ata_msg_probe(ap)) 474 if (ata_msg_probe(ap))
477 ata_dev_printk(atadev, KERN_DEBUG, "%s: (0x1f1-1f7): hex: " 475 ata_dev_printk(dev, KERN_DEBUG, "%s: (0x1f1-1f7): hex: "
478 "%02x %02x %02x %02x %02x %02x %02x\n", 476 "%02x %02x %02x %02x %02x %02x %02x\n",
479 __FUNCTION__, 477 __FUNCTION__,
480 gtf->tfa[0], gtf->tfa[1], gtf->tfa[2], 478 gtf->tfa[0], gtf->tfa[1], gtf->tfa[2],
@@ -485,7 +483,7 @@ static void taskfile_load_raw(struct ata_port *ap,
485 && (gtf->tfa[6] == 0)) 483 && (gtf->tfa[6] == 0))
486 return; 484 return;
487 485
488 ata_tf_init(atadev, &tf); 486 ata_tf_init(dev, &tf);
489 487
490 /* convert gtf to tf */ 488 /* convert gtf to tf */
491 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; /* TBD */ 489 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; /* TBD */
@@ -498,17 +496,16 @@ static void taskfile_load_raw(struct ata_port *ap,
498 tf.device = gtf->tfa[5]; /* 0x1f6 */ 496 tf.device = gtf->tfa[5]; /* 0x1f6 */
499 tf.command = gtf->tfa[6]; /* 0x1f7 */ 497 tf.command = gtf->tfa[6]; /* 0x1f7 */
500 498
501 err = ata_exec_internal(atadev, &tf, NULL, DMA_NONE, NULL, 0); 499 err = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0);
502 if (err && ata_msg_probe(ap)) 500 if (err && ata_msg_probe(ap))
503 ata_dev_printk(atadev, KERN_ERR, 501 ata_dev_printk(dev, KERN_ERR,
504 "%s: ata_exec_internal failed: %u\n", 502 "%s: ata_exec_internal failed: %u\n",
505 __FUNCTION__, err); 503 __FUNCTION__, err);
506} 504}
507 505
508/** 506/**
509 * do_drive_set_taskfiles - write the drive taskfile settings from _GTF 507 * do_drive_set_taskfiles - write the drive taskfile settings from _GTF
510 * @ap: the ata_port for the drive 508 * @dev: target ATA device
511 * @atadev: target ata_device
512 * @gtf_length: total number of bytes of _GTF taskfiles 509 * @gtf_length: total number of bytes of _GTF taskfiles
513 * @gtf_address: location of _GTF taskfile arrays 510 * @gtf_address: location of _GTF taskfile arrays
514 * 511 *
@@ -517,30 +514,31 @@ static void taskfile_load_raw(struct ata_port *ap,
517 * Write {gtf_address, length gtf_length} in groups of 514 * Write {gtf_address, length gtf_length} in groups of
518 * REGS_PER_GTF bytes. 515 * REGS_PER_GTF bytes.
519 */ 516 */
520static int do_drive_set_taskfiles(struct ata_port *ap, 517static int do_drive_set_taskfiles(struct ata_device *dev,
521 struct ata_device *atadev, unsigned int gtf_length, 518 unsigned int gtf_length,
522 unsigned long gtf_address) 519 unsigned long gtf_address)
523{ 520{
524 int err = -ENODEV; 521 struct ata_port *ap = dev->ap;
525 int gtf_count = gtf_length / REGS_PER_GTF; 522 int err = -ENODEV;
526 int ix; 523 int gtf_count = gtf_length / REGS_PER_GTF;
524 int ix;
527 struct taskfile_array *gtf; 525 struct taskfile_array *gtf;
528 526
529 if (ata_msg_probe(ap)) 527 if (ata_msg_probe(ap))
530 ata_dev_printk(atadev, KERN_DEBUG, "%s: ENTER: port#: %d\n", 528 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n",
531 __FUNCTION__, ap->port_no); 529 __FUNCTION__, ap->port_no);
532 530
533 if (libata_noacpi || !(ap->cbl == ATA_CBL_SATA)) 531 if (libata_noacpi || !(ap->cbl == ATA_CBL_SATA))
534 return 0; 532 return 0;
535 533
536 if (!ata_dev_enabled(atadev) || (ap->flags & ATA_FLAG_DISABLED)) 534 if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED))
537 goto out; 535 goto out;
538 if (!gtf_count) /* shouldn't be here */ 536 if (!gtf_count) /* shouldn't be here */
539 goto out; 537 goto out;
540 538
541 if (gtf_length % REGS_PER_GTF) { 539 if (gtf_length % REGS_PER_GTF) {
542 if (ata_msg_drv(ap)) 540 if (ata_msg_drv(ap))
543 ata_dev_printk(atadev, KERN_ERR, 541 ata_dev_printk(dev, KERN_ERR,
544 "%s: unexpected GTF length (%d)\n", 542 "%s: unexpected GTF length (%d)\n",
545 __FUNCTION__, gtf_length); 543 __FUNCTION__, gtf_length);
546 goto out; 544 goto out;
@@ -551,7 +549,7 @@ static int do_drive_set_taskfiles(struct ata_port *ap,
551 (gtf_address + ix * REGS_PER_GTF); 549 (gtf_address + ix * REGS_PER_GTF);
552 550
553 /* send all TaskFile registers (0x1f1-0x1f7) *in*that*order* */ 551 /* send all TaskFile registers (0x1f1-0x1f7) *in*that*order* */
554 taskfile_load_raw(ap, atadev, gtf); 552 taskfile_load_raw(dev, gtf);
555 } 553 }
556 554
557 err = 0; 555 err = 0;
@@ -567,11 +565,11 @@ out:
567 */ 565 */
568int ata_acpi_exec_tfs(struct ata_port *ap) 566int ata_acpi_exec_tfs(struct ata_port *ap)
569{ 567{
570 int ix; 568 int ix;
571 int ret =0; 569 int ret = 0;
572 unsigned int gtf_length; 570 unsigned int gtf_length;
573 unsigned long gtf_address; 571 unsigned long gtf_address;
574 unsigned long obj_loc; 572 unsigned long obj_loc;
575 573
576 if (libata_noacpi) 574 if (libata_noacpi)
577 return 0; 575 return 0;
@@ -584,11 +582,13 @@ int ata_acpi_exec_tfs(struct ata_port *ap)
584 return 0; 582 return 0;
585 583
586 for (ix = 0; ix < ATA_MAX_DEVICES; ix++) { 584 for (ix = 0; ix < ATA_MAX_DEVICES; ix++) {
587 if (!ata_dev_enabled(&ap->device[ix])) 585 struct ata_device *dev = &ap->device[ix];
586
587 if (!ata_dev_enabled(dev))
588 continue; 588 continue;
589 589
590 ret = do_drive_get_GTF(ap, ix, 590 ret = do_drive_get_GTF(dev, &gtf_length, &gtf_address,
591 &gtf_length, &gtf_address, &obj_loc); 591 &obj_loc);
592 if (ret < 0) { 592 if (ret < 0) {
593 if (ata_msg_probe(ap)) 593 if (ata_msg_probe(ap))
594 ata_port_printk(ap, KERN_DEBUG, 594 ata_port_printk(ap, KERN_DEBUG,
@@ -597,8 +597,7 @@ int ata_acpi_exec_tfs(struct ata_port *ap)
597 break; 597 break;
598 } 598 }
599 599
600 ret = do_drive_set_taskfiles(ap, &ap->device[ix], 600 ret = do_drive_set_taskfiles(dev, gtf_length, gtf_address);
601 gtf_length, gtf_address);
602 kfree((void *)obj_loc); 601 kfree((void *)obj_loc);
603 if (ret < 0) { 602 if (ret < 0) {
604 if (ata_msg_probe(ap)) 603 if (ata_msg_probe(ap))
@@ -614,8 +613,7 @@ int ata_acpi_exec_tfs(struct ata_port *ap)
614 613
615/** 614/**
616 * ata_acpi_push_id - send Identify data to drive 615 * ata_acpi_push_id - send Identify data to drive
617 * @ap: the ata_port for the drive 616 * @dev: target ATA device
618 * @ix: drive index
619 * 617 *
620 * _SDD ACPI object: for SATA mode only 618 * _SDD ACPI object: for SATA mode only
621 * Must be after Identify (Packet) Device -- uses its data 619 * Must be after Identify (Packet) Device -- uses its data
@@ -623,57 +621,57 @@ int ata_acpi_exec_tfs(struct ata_port *ap)
623 * method and if it fails for whatever reason, we should still 621 * method and if it fails for whatever reason, we should still
624 * just keep going. 622 * just keep going.
625 */ 623 */
626int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) 624int ata_acpi_push_id(struct ata_device *dev)
627{ 625{
628 acpi_handle handle; 626 struct ata_port *ap = dev->ap;
629 acpi_integer pcidevfn; 627 acpi_handle handle;
630 int err; 628 acpi_integer pcidevfn;
631 struct device *dev = ap->host->dev; 629 int err;
632 struct ata_device *atadev = &ap->device[ix]; 630 struct device *gdev = ap->host->dev;
633 u32 dev_adr; 631 u32 dev_adr;
634 acpi_status status; 632 acpi_status status;
635 struct acpi_object_list input; 633 struct acpi_object_list input;
636 union acpi_object in_params[1]; 634 union acpi_object in_params[1];
637 635
638 if (libata_noacpi) 636 if (libata_noacpi)
639 return 0; 637 return 0;
640 638
641 if (ata_msg_probe(ap)) 639 if (ata_msg_probe(ap))
642 ata_dev_printk(atadev, KERN_DEBUG, "%s: ix = %d, port#: %d\n", 640 ata_dev_printk(dev, KERN_DEBUG, "%s: ix = %d, port#: %d\n",
643 __FUNCTION__, ix, ap->port_no); 641 __FUNCTION__, dev->devno, ap->port_no);
644 642
645 /* Don't continue if not a SATA device. */ 643 /* Don't continue if not a SATA device. */
646 if (!(ap->cbl == ATA_CBL_SATA)) { 644 if (!(ap->cbl == ATA_CBL_SATA)) {
647 if (ata_msg_probe(ap)) 645 if (ata_msg_probe(ap))
648 ata_dev_printk(atadev, KERN_DEBUG, 646 ata_dev_printk(dev, KERN_DEBUG,
649 "%s: Not a SATA device\n", __FUNCTION__); 647 "%s: Not a SATA device\n", __FUNCTION__);
650 goto out; 648 goto out;
651 } 649 }
652 650
653 /* Don't continue if device has no _ADR method. 651 /* Don't continue if device has no _ADR method.
654 * _SDD is intended for known motherboard devices. */ 652 * _SDD is intended for known motherboard devices. */
655 err = sata_get_dev_handle(dev, &handle, &pcidevfn); 653 err = sata_get_dev_handle(gdev, &handle, &pcidevfn);
656 if (err < 0) { 654 if (err < 0) {
657 if (ata_msg_probe(ap)) 655 if (ata_msg_probe(ap))
658 ata_dev_printk(atadev, KERN_DEBUG, 656 ata_dev_printk(dev, KERN_DEBUG,
659 "%s: sata_get_dev_handle failed (%d\n", 657 "%s: sata_get_dev_handle failed (%d\n",
660 __FUNCTION__, err); 658 __FUNCTION__, err);
661 goto out; 659 goto out;
662 } 660 }
663 661
664 /* Get this drive's _ADR info, if not already known */ 662 /* Get this drive's _ADR info, if not already known */
665 if (!atadev->obj_handle) { 663 if (!dev->obj_handle) {
666 dev_adr = SATA_ADR_RSVD; 664 dev_adr = SATA_ADR_RSVD;
667 err = get_sata_adr(dev, handle, pcidevfn, ix, ap, atadev, 665 err = get_sata_adr(gdev, handle, pcidevfn, dev->devno, ap, dev,
668 &dev_adr); 666 &dev_adr);
669 if (err < 0 || dev_adr == SATA_ADR_RSVD || 667 if (err < 0 || dev_adr == SATA_ADR_RSVD ||
670 !atadev->obj_handle) { 668 !dev->obj_handle) {
671 if (ata_msg_probe(ap)) 669 if (ata_msg_probe(ap))
672 ata_dev_printk(atadev, KERN_DEBUG, 670 ata_dev_printk(dev, KERN_DEBUG,
673 "%s: get_sata_adr failed: " 671 "%s: get_sata_adr failed: "
674 "err=%d, dev_adr=%u, obj_handle=0x%p\n", 672 "err=%d, dev_adr=%u, obj_handle=0x%p\n",
675 __FUNCTION__, err, dev_adr, 673 __FUNCTION__, err, dev_adr,
676 atadev->obj_handle); 674 dev->obj_handle);
677 goto out; 675 goto out;
678 } 676 }
679 } 677 }
@@ -683,19 +681,19 @@ int ata_acpi_push_id(struct ata_port *ap, unsigned int ix)
683 input.count = 1; 681 input.count = 1;
684 input.pointer = in_params; 682 input.pointer = in_params;
685 in_params[0].type = ACPI_TYPE_BUFFER; 683 in_params[0].type = ACPI_TYPE_BUFFER;
686 in_params[0].buffer.length = sizeof(atadev->id[0]) * ATA_ID_WORDS; 684 in_params[0].buffer.length = sizeof(dev->id[0]) * ATA_ID_WORDS;
687 in_params[0].buffer.pointer = (u8 *)atadev->id; 685 in_params[0].buffer.pointer = (u8 *)dev->id;
688 /* Output buffer: _SDD has no output */ 686 /* Output buffer: _SDD has no output */
689 687
690 /* It's OK for _SDD to be missing too. */ 688 /* It's OK for _SDD to be missing too. */
691 swap_buf_le16(atadev->id, ATA_ID_WORDS); 689 swap_buf_le16(dev->id, ATA_ID_WORDS);
692 status = acpi_evaluate_object(atadev->obj_handle, "_SDD", &input, NULL); 690 status = acpi_evaluate_object(dev->obj_handle, "_SDD", &input, NULL);
693 swap_buf_le16(atadev->id, ATA_ID_WORDS); 691 swap_buf_le16(dev->id, ATA_ID_WORDS);
694 692
695 err = ACPI_FAILURE(status) ? -EIO : 0; 693 err = ACPI_FAILURE(status) ? -EIO : 0;
696 if (err < 0) { 694 if (err < 0) {
697 if (ata_msg_probe(ap)) 695 if (ata_msg_probe(ap))
698 ata_dev_printk(atadev, KERN_DEBUG, 696 ata_dev_printk(dev, KERN_DEBUG,
699 "%s _SDD error: status = 0x%x\n", 697 "%s _SDD error: status = 0x%x\n",
700 __FUNCTION__, status); 698 __FUNCTION__, status);
701 } 699 }
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 4595d1f8cf60..4166407eb47c 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -101,6 +101,12 @@ int libata_noacpi = 1;
101module_param_named(noacpi, libata_noacpi, int, 0444); 101module_param_named(noacpi, libata_noacpi, int, 0444);
102MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set"); 102MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set");
103 103
104int ata_spindown_compat = 1;
105module_param_named(spindown_compat, ata_spindown_compat, int, 0644);
106MODULE_PARM_DESC(spindown_compat, "Enable backward compatible spindown "
107 "behavior. Will be removed. More info can be found in "
108 "Documentation/feature-removal-schedule.txt\n");
109
104MODULE_AUTHOR("Jeff Garzik"); 110MODULE_AUTHOR("Jeff Garzik");
105MODULE_DESCRIPTION("Library module for ATA devices"); 111MODULE_DESCRIPTION("Library module for ATA devices");
106MODULE_LICENSE("GPL"); 112MODULE_LICENSE("GPL");
@@ -1654,7 +1660,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
1654 struct ata_taskfile tf; 1660 struct ata_taskfile tf;
1655 unsigned int err_mask = 0; 1661 unsigned int err_mask = 0;
1656 const char *reason; 1662 const char *reason;
1657 int tried_spinup = 0; 1663 int may_fallback = 1, tried_spinup = 0;
1658 int rc; 1664 int rc;
1659 1665
1660 if (ata_msg_ctl(ap)) 1666 if (ata_msg_ctl(ap))
@@ -1698,11 +1704,31 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
1698 return -ENOENT; 1704 return -ENOENT;
1699 } 1705 }
1700 1706
1707 /* Device or controller might have reported the wrong
1708 * device class. Give a shot at the other IDENTIFY if
1709 * the current one is aborted by the device.
1710 */
1711 if (may_fallback &&
1712 (err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) {
1713 may_fallback = 0;
1714
1715 if (class == ATA_DEV_ATA)
1716 class = ATA_DEV_ATAPI;
1717 else
1718 class = ATA_DEV_ATA;
1719 goto retry;
1720 }
1721
1701 rc = -EIO; 1722 rc = -EIO;
1702 reason = "I/O error"; 1723 reason = "I/O error";
1703 goto err_out; 1724 goto err_out;
1704 } 1725 }
1705 1726
1727 /* Falling back doesn't make sense if ID data was read
1728 * successfully at least once.
1729 */
1730 may_fallback = 0;
1731
1706 swap_buf_le16(id, ATA_ID_WORDS); 1732 swap_buf_le16(id, ATA_ID_WORDS);
1707 1733
1708 /* sanity check */ 1734 /* sanity check */
@@ -1843,7 +1869,7 @@ int ata_dev_configure(struct ata_device *dev)
1843 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __FUNCTION__); 1869 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __FUNCTION__);
1844 1870
1845 /* set _SDD */ 1871 /* set _SDD */
1846 rc = ata_acpi_push_id(ap, dev->devno); 1872 rc = ata_acpi_push_id(dev);
1847 if (rc) { 1873 if (rc) {
1848 ata_dev_printk(dev, KERN_WARNING, "failed to set _SDD(%d)\n", 1874 ata_dev_printk(dev, KERN_WARNING, "failed to set _SDD(%d)\n",
1849 rc); 1875 rc);
@@ -2860,7 +2886,7 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
2860 dev = &ap->device[i]; 2886 dev = &ap->device[i];
2861 2887
2862 /* don't update suspended devices' xfer mode */ 2888 /* don't update suspended devices' xfer mode */
2863 if (!ata_dev_ready(dev)) 2889 if (!ata_dev_enabled(dev))
2864 continue; 2890 continue;
2865 2891
2866 rc = ata_dev_set_mode(dev); 2892 rc = ata_dev_set_mode(dev);
@@ -5845,37 +5871,11 @@ static int ata_host_request_pm(struct ata_host *host, pm_message_t mesg,
5845 */ 5871 */
5846int ata_host_suspend(struct ata_host *host, pm_message_t mesg) 5872int ata_host_suspend(struct ata_host *host, pm_message_t mesg)
5847{ 5873{
5848 int i, j, rc; 5874 int rc;
5849 5875
5850 rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1); 5876 rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1);
5851 if (rc) 5877 if (rc == 0)
5852 goto fail; 5878 host->dev->power.power_state = mesg;
5853
5854 /* EH is quiescent now. Fail if we have any ready device.
5855 * This happens if hotplug occurs between completion of device
5856 * suspension and here.
5857 */
5858 for (i = 0; i < host->n_ports; i++) {
5859 struct ata_port *ap = host->ports[i];
5860
5861 for (j = 0; j < ATA_MAX_DEVICES; j++) {
5862 struct ata_device *dev = &ap->device[j];
5863
5864 if (ata_dev_ready(dev)) {
5865 ata_port_printk(ap, KERN_WARNING,
5866 "suspend failed, device %d "
5867 "still active\n", dev->devno);
5868 rc = -EBUSY;
5869 goto fail;
5870 }
5871 }
5872 }
5873
5874 host->dev->power.power_state = mesg;
5875 return 0;
5876
5877 fail:
5878 ata_host_resume(host);
5879 return rc; 5879 return rc;
5880} 5880}
5881 5881
@@ -5984,6 +5984,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
5984 if (!ap) 5984 if (!ap)
5985 return NULL; 5985 return NULL;
5986 5986
5987 ap->pflags |= ATA_PFLAG_INITIALIZING;
5987 ap->lock = &host->lock; 5988 ap->lock = &host->lock;
5988 ap->flags = ATA_FLAG_DISABLED; 5989 ap->flags = ATA_FLAG_DISABLED;
5989 ap->print_id = -1; 5990 ap->print_id = -1;
@@ -6352,6 +6353,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
6352 ehi->action |= ATA_EH_SOFTRESET; 6353 ehi->action |= ATA_EH_SOFTRESET;
6353 ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET; 6354 ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET;
6354 6355
6356 ap->pflags &= ~ATA_PFLAG_INITIALIZING;
6355 ap->pflags |= ATA_PFLAG_LOADING; 6357 ap->pflags |= ATA_PFLAG_LOADING;
6356 ata_port_schedule_eh(ap); 6358 ata_port_schedule_eh(ap);
6357 6359
@@ -6876,6 +6878,7 @@ EXPORT_SYMBOL_GPL(ata_timing_merge);
6876#ifdef CONFIG_PCI 6878#ifdef CONFIG_PCI
6877EXPORT_SYMBOL_GPL(pci_test_config_bits); 6879EXPORT_SYMBOL_GPL(pci_test_config_bits);
6878EXPORT_SYMBOL_GPL(ata_pci_init_native_host); 6880EXPORT_SYMBOL_GPL(ata_pci_init_native_host);
6881EXPORT_SYMBOL_GPL(ata_pci_init_bmdma);
6879EXPORT_SYMBOL_GPL(ata_pci_prepare_native_host); 6882EXPORT_SYMBOL_GPL(ata_pci_prepare_native_host);
6880EXPORT_SYMBOL_GPL(ata_pci_init_one); 6883EXPORT_SYMBOL_GPL(ata_pci_init_one);
6881EXPORT_SYMBOL_GPL(ata_pci_remove_one); 6884EXPORT_SYMBOL_GPL(ata_pci_remove_one);
@@ -6889,11 +6892,6 @@ EXPORT_SYMBOL_GPL(ata_pci_default_filter);
6889EXPORT_SYMBOL_GPL(ata_pci_clear_simplex); 6892EXPORT_SYMBOL_GPL(ata_pci_clear_simplex);
6890#endif /* CONFIG_PCI */ 6893#endif /* CONFIG_PCI */
6891 6894
6892#ifdef CONFIG_PM
6893EXPORT_SYMBOL_GPL(ata_scsi_device_suspend);
6894EXPORT_SYMBOL_GPL(ata_scsi_device_resume);
6895#endif /* CONFIG_PM */
6896
6897EXPORT_SYMBOL_GPL(ata_eng_timeout); 6895EXPORT_SYMBOL_GPL(ata_eng_timeout);
6898EXPORT_SYMBOL_GPL(ata_port_schedule_eh); 6896EXPORT_SYMBOL_GPL(ata_port_schedule_eh);
6899EXPORT_SYMBOL_GPL(ata_port_abort); 6897EXPORT_SYMBOL_GPL(ata_port_abort);
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 8256655ce7d9..5309c312f517 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -77,29 +77,12 @@ static void ata_eh_finish(struct ata_port *ap);
77#ifdef CONFIG_PM 77#ifdef CONFIG_PM
78static void ata_eh_handle_port_suspend(struct ata_port *ap); 78static void ata_eh_handle_port_suspend(struct ata_port *ap);
79static void ata_eh_handle_port_resume(struct ata_port *ap); 79static void ata_eh_handle_port_resume(struct ata_port *ap);
80static int ata_eh_suspend(struct ata_port *ap,
81 struct ata_device **r_failed_dev);
82static void ata_eh_prep_resume(struct ata_port *ap);
83static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev);
84#else /* CONFIG_PM */ 80#else /* CONFIG_PM */
85static void ata_eh_handle_port_suspend(struct ata_port *ap) 81static void ata_eh_handle_port_suspend(struct ata_port *ap)
86{ } 82{ }
87 83
88static void ata_eh_handle_port_resume(struct ata_port *ap) 84static void ata_eh_handle_port_resume(struct ata_port *ap)
89{ } 85{ }
90
91static int ata_eh_suspend(struct ata_port *ap, struct ata_device **r_failed_dev)
92{
93 return 0;
94}
95
96static void ata_eh_prep_resume(struct ata_port *ap)
97{ }
98
99static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev)
100{
101 return 0;
102}
103#endif /* CONFIG_PM */ 86#endif /* CONFIG_PM */
104 87
105static void ata_ering_record(struct ata_ering *ering, int is_io, 88static void ata_ering_record(struct ata_ering *ering, int is_io,
@@ -568,6 +551,9 @@ void ata_port_schedule_eh(struct ata_port *ap)
568{ 551{
569 WARN_ON(!ap->ops->error_handler); 552 WARN_ON(!ap->ops->error_handler);
570 553
554 if (ap->pflags & ATA_PFLAG_INITIALIZING)
555 return;
556
571 ap->pflags |= ATA_PFLAG_EH_PENDING; 557 ap->pflags |= ATA_PFLAG_EH_PENDING;
572 scsi_schedule_eh(ap->scsi_host); 558 scsi_schedule_eh(ap->scsi_host);
573 559
@@ -1791,7 +1777,7 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
1791 if (ehc->i.flags & ATA_EHI_DID_RESET) 1777 if (ehc->i.flags & ATA_EHI_DID_RESET)
1792 readid_flags |= ATA_READID_POSTRESET; 1778 readid_flags |= ATA_READID_POSTRESET;
1793 1779
1794 if (action & ATA_EH_REVALIDATE && ata_dev_ready(dev)) { 1780 if ((action & ATA_EH_REVALIDATE) && ata_dev_enabled(dev)) {
1795 if (ata_port_offline(ap)) { 1781 if (ata_port_offline(ap)) {
1796 rc = -EIO; 1782 rc = -EIO;
1797 goto err; 1783 goto err;
@@ -1872,166 +1858,6 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
1872 return rc; 1858 return rc;
1873} 1859}
1874 1860
1875#ifdef CONFIG_PM
1876/**
1877 * ata_eh_suspend - handle suspend EH action
1878 * @ap: target host port
1879 * @r_failed_dev: result parameter to indicate failing device
1880 *
1881 * Handle suspend EH action. Disk devices are spinned down and
1882 * other types of devices are just marked suspended. Once
1883 * suspended, no EH action to the device is allowed until it is
1884 * resumed.
1885 *
1886 * LOCKING:
1887 * Kernel thread context (may sleep).
1888 *
1889 * RETURNS:
1890 * 0 on success, -errno otherwise
1891 */
1892static int ata_eh_suspend(struct ata_port *ap, struct ata_device **r_failed_dev)
1893{
1894 struct ata_device *dev;
1895 int i, rc = 0;
1896
1897 DPRINTK("ENTER\n");
1898
1899 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1900 unsigned long flags;
1901 unsigned int action, err_mask;
1902
1903 dev = &ap->device[i];
1904 action = ata_eh_dev_action(dev);
1905
1906 if (!ata_dev_enabled(dev) || !(action & ATA_EH_SUSPEND))
1907 continue;
1908
1909 WARN_ON(dev->flags & ATA_DFLAG_SUSPENDED);
1910
1911 ata_eh_about_to_do(ap, dev, ATA_EH_SUSPEND);
1912
1913 if (dev->class == ATA_DEV_ATA && !(action & ATA_EH_PM_FREEZE)) {
1914 /* flush cache */
1915 rc = ata_flush_cache(dev);
1916 if (rc)
1917 break;
1918
1919 /* spin down */
1920 err_mask = ata_do_simple_cmd(dev, ATA_CMD_STANDBYNOW1);
1921 if (err_mask) {
1922 ata_dev_printk(dev, KERN_ERR, "failed to "
1923 "spin down (err_mask=0x%x)\n",
1924 err_mask);
1925 rc = -EIO;
1926 break;
1927 }
1928 }
1929
1930 spin_lock_irqsave(ap->lock, flags);
1931 dev->flags |= ATA_DFLAG_SUSPENDED;
1932 spin_unlock_irqrestore(ap->lock, flags);
1933
1934 ata_eh_done(ap, dev, ATA_EH_SUSPEND);
1935 }
1936
1937 if (rc)
1938 *r_failed_dev = dev;
1939
1940 DPRINTK("EXIT\n");
1941 return rc;
1942}
1943
1944/**
1945 * ata_eh_prep_resume - prep for resume EH action
1946 * @ap: target host port
1947 *
1948 * Clear SUSPENDED in preparation for scheduled resume actions.
1949 * This allows other parts of EH to access the devices being
1950 * resumed.
1951 *
1952 * LOCKING:
1953 * Kernel thread context (may sleep).
1954 */
1955static void ata_eh_prep_resume(struct ata_port *ap)
1956{
1957 struct ata_device *dev;
1958 unsigned long flags;
1959 int i;
1960
1961 DPRINTK("ENTER\n");
1962
1963 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1964 unsigned int action;
1965
1966 dev = &ap->device[i];
1967 action = ata_eh_dev_action(dev);
1968
1969 if (!ata_dev_enabled(dev) || !(action & ATA_EH_RESUME))
1970 continue;
1971
1972 spin_lock_irqsave(ap->lock, flags);
1973 dev->flags &= ~ATA_DFLAG_SUSPENDED;
1974 spin_unlock_irqrestore(ap->lock, flags);
1975 }
1976
1977 DPRINTK("EXIT\n");
1978}
1979
1980/**
1981 * ata_eh_resume - handle resume EH action
1982 * @ap: target host port
1983 * @r_failed_dev: result parameter to indicate failing device
1984 *
1985 * Handle resume EH action. Target devices are already reset and
1986 * revalidated. Spinning up is the only operation left.
1987 *
1988 * LOCKING:
1989 * Kernel thread context (may sleep).
1990 *
1991 * RETURNS:
1992 * 0 on success, -errno otherwise
1993 */
1994static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev)
1995{
1996 struct ata_device *dev;
1997 int i, rc = 0;
1998
1999 DPRINTK("ENTER\n");
2000
2001 for (i = 0; i < ATA_MAX_DEVICES; i++) {
2002 unsigned int action, err_mask;
2003
2004 dev = &ap->device[i];
2005 action = ata_eh_dev_action(dev);
2006
2007 if (!ata_dev_enabled(dev) || !(action & ATA_EH_RESUME))
2008 continue;
2009
2010 ata_eh_about_to_do(ap, dev, ATA_EH_RESUME);
2011
2012 if (dev->class == ATA_DEV_ATA && !(action & ATA_EH_PM_FREEZE)) {
2013 err_mask = ata_do_simple_cmd(dev,
2014 ATA_CMD_IDLEIMMEDIATE);
2015 if (err_mask) {
2016 ata_dev_printk(dev, KERN_ERR, "failed to "
2017 "spin up (err_mask=0x%x)\n",
2018 err_mask);
2019 rc = -EIO;
2020 break;
2021 }
2022 }
2023
2024 ata_eh_done(ap, dev, ATA_EH_RESUME);
2025 }
2026
2027 if (rc)
2028 *r_failed_dev = dev;
2029
2030 DPRINTK("EXIT\n");
2031 return 0;
2032}
2033#endif /* CONFIG_PM */
2034
2035static int ata_port_nr_enabled(struct ata_port *ap) 1861static int ata_port_nr_enabled(struct ata_port *ap)
2036{ 1862{
2037 int i, cnt = 0; 1863 int i, cnt = 0;
@@ -2057,17 +1883,6 @@ static int ata_eh_skip_recovery(struct ata_port *ap)
2057 struct ata_eh_context *ehc = &ap->eh_context; 1883 struct ata_eh_context *ehc = &ap->eh_context;
2058 int i; 1884 int i;
2059 1885
2060 /* skip if all possible devices are suspended */
2061 for (i = 0; i < ata_port_max_devices(ap); i++) {
2062 struct ata_device *dev = &ap->device[i];
2063
2064 if (!(dev->flags & ATA_DFLAG_SUSPENDED))
2065 break;
2066 }
2067
2068 if (i == ata_port_max_devices(ap))
2069 return 1;
2070
2071 /* thaw frozen port, resume link and recover failed devices */ 1886 /* thaw frozen port, resume link and recover failed devices */
2072 if ((ap->pflags & ATA_PFLAG_FROZEN) || 1887 if ((ap->pflags & ATA_PFLAG_FROZEN) ||
2073 (ehc->i.flags & ATA_EHI_RESUME_LINK) || ata_port_nr_enabled(ap)) 1888 (ehc->i.flags & ATA_EHI_RESUME_LINK) || ata_port_nr_enabled(ap))
@@ -2147,9 +1962,6 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2147 if (ap->pflags & ATA_PFLAG_UNLOADING) 1962 if (ap->pflags & ATA_PFLAG_UNLOADING)
2148 goto out; 1963 goto out;
2149 1964
2150 /* prep for resume */
2151 ata_eh_prep_resume(ap);
2152
2153 /* skip EH if possible. */ 1965 /* skip EH if possible. */
2154 if (ata_eh_skip_recovery(ap)) 1966 if (ata_eh_skip_recovery(ap))
2155 ehc->i.action = 0; 1967 ehc->i.action = 0;
@@ -2177,11 +1989,6 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2177 if (rc) 1989 if (rc)
2178 goto dev_fail; 1990 goto dev_fail;
2179 1991
2180 /* resume devices */
2181 rc = ata_eh_resume(ap, &dev);
2182 if (rc)
2183 goto dev_fail;
2184
2185 /* configure transfer mode if necessary */ 1992 /* configure transfer mode if necessary */
2186 if (ehc->i.flags & ATA_EHI_SETMODE) { 1993 if (ehc->i.flags & ATA_EHI_SETMODE) {
2187 rc = ata_set_mode(ap, &dev); 1994 rc = ata_set_mode(ap, &dev);
@@ -2190,25 +1997,16 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2190 ehc->i.flags &= ~ATA_EHI_SETMODE; 1997 ehc->i.flags &= ~ATA_EHI_SETMODE;
2191 } 1998 }
2192 1999
2193 /* suspend devices */
2194 rc = ata_eh_suspend(ap, &dev);
2195 if (rc)
2196 goto dev_fail;
2197
2198 goto out; 2000 goto out;
2199 2001
2200 dev_fail: 2002 dev_fail:
2201 ehc->tries[dev->devno]--; 2003 ehc->tries[dev->devno]--;
2202 2004
2203 switch (rc) { 2005 switch (rc) {
2204 case -EINVAL:
2205 /* eeek, something went very wrong, give up */
2206 ehc->tries[dev->devno] = 0;
2207 break;
2208
2209 case -ENODEV: 2006 case -ENODEV:
2210 /* device missing or wrong IDENTIFY data, schedule probing */ 2007 /* device missing or wrong IDENTIFY data, schedule probing */
2211 ehc->i.probe_mask |= (1 << dev->devno); 2008 ehc->i.probe_mask |= (1 << dev->devno);
2009 case -EINVAL:
2212 /* give it just one more chance */ 2010 /* give it just one more chance */
2213 ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1); 2011 ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1);
2214 case -EIO: 2012 case -EIO:
@@ -2390,22 +2188,13 @@ static void ata_eh_handle_port_suspend(struct ata_port *ap)
2390 * 2188 *
2391 * Resume @ap. 2189 * Resume @ap.
2392 * 2190 *
2393 * This function also waits upto one second until all devices
2394 * hanging off this port requests resume EH action. This is to
2395 * prevent invoking EH and thus reset multiple times on resume.
2396 *
2397 * On DPM resume, where some of devices might not be resumed
2398 * together, this may delay port resume upto one second, but such
2399 * DPM resumes are rare and 1 sec delay isn't too bad.
2400 *
2401 * LOCKING: 2191 * LOCKING:
2402 * Kernel thread context (may sleep). 2192 * Kernel thread context (may sleep).
2403 */ 2193 */
2404static void ata_eh_handle_port_resume(struct ata_port *ap) 2194static void ata_eh_handle_port_resume(struct ata_port *ap)
2405{ 2195{
2406 unsigned long timeout;
2407 unsigned long flags; 2196 unsigned long flags;
2408 int i, rc = 0; 2197 int rc = 0;
2409 2198
2410 /* are we resuming? */ 2199 /* are we resuming? */
2411 spin_lock_irqsave(ap->lock, flags); 2200 spin_lock_irqsave(ap->lock, flags);
@@ -2416,31 +2205,12 @@ static void ata_eh_handle_port_resume(struct ata_port *ap)
2416 } 2205 }
2417 spin_unlock_irqrestore(ap->lock, flags); 2206 spin_unlock_irqrestore(ap->lock, flags);
2418 2207
2419 /* spurious? */ 2208 WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED));
2420 if (!(ap->pflags & ATA_PFLAG_SUSPENDED))
2421 goto done;
2422 2209
2423 if (ap->ops->port_resume) 2210 if (ap->ops->port_resume)
2424 rc = ap->ops->port_resume(ap); 2211 rc = ap->ops->port_resume(ap);
2425 2212
2426 /* give devices time to request EH */ 2213 /* report result */
2427 timeout = jiffies + HZ; /* 1s max */
2428 while (1) {
2429 for (i = 0; i < ATA_MAX_DEVICES; i++) {
2430 struct ata_device *dev = &ap->device[i];
2431 unsigned int action = ata_eh_dev_action(dev);
2432
2433 if ((dev->flags & ATA_DFLAG_SUSPENDED) &&
2434 !(action & ATA_EH_RESUME))
2435 break;
2436 }
2437
2438 if (i == ATA_MAX_DEVICES || time_after(jiffies, timeout))
2439 break;
2440 msleep(10);
2441 }
2442
2443 done:
2444 spin_lock_irqsave(ap->lock, flags); 2214 spin_lock_irqsave(ap->lock, flags);
2445 ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); 2215 ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED);
2446 if (ap->pm_result) { 2216 if (ap->pm_result) {
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 9afba2ba489e..dd81fa78cdcf 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -510,133 +510,6 @@ static void ata_dump_status(unsigned id, struct ata_taskfile *tf)
510 } 510 }
511} 511}
512 512
513#ifdef CONFIG_PM
514/**
515 * ata_scsi_device_suspend - suspend ATA device associated with sdev
516 * @sdev: the SCSI device to suspend
517 * @mesg: target power management message
518 *
519 * Request suspend EH action on the ATA device associated with
520 * @sdev and wait for the operation to complete.
521 *
522 * LOCKING:
523 * Kernel thread context (may sleep).
524 *
525 * RETURNS:
526 * 0 on success, -errno otherwise.
527 */
528int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t mesg)
529{
530 struct ata_port *ap = ata_shost_to_port(sdev->host);
531 struct ata_device *dev = ata_scsi_find_dev(ap, sdev);
532 unsigned long flags;
533 unsigned int action;
534 int rc = 0;
535
536 if (!dev)
537 goto out;
538
539 spin_lock_irqsave(ap->lock, flags);
540
541 /* wait for the previous resume to complete */
542 while (dev->flags & ATA_DFLAG_SUSPENDED) {
543 spin_unlock_irqrestore(ap->lock, flags);
544 ata_port_wait_eh(ap);
545 spin_lock_irqsave(ap->lock, flags);
546 }
547
548 /* if @sdev is already detached, nothing to do */
549 if (sdev->sdev_state == SDEV_OFFLINE ||
550 sdev->sdev_state == SDEV_CANCEL || sdev->sdev_state == SDEV_DEL)
551 goto out_unlock;
552
553 /* request suspend */
554 action = ATA_EH_SUSPEND;
555 if (mesg.event != PM_EVENT_SUSPEND)
556 action |= ATA_EH_PM_FREEZE;
557 ap->eh_info.dev_action[dev->devno] |= action;
558 ap->eh_info.flags |= ATA_EHI_QUIET;
559 ata_port_schedule_eh(ap);
560
561 spin_unlock_irqrestore(ap->lock, flags);
562
563 /* wait for EH to do the job */
564 ata_port_wait_eh(ap);
565
566 spin_lock_irqsave(ap->lock, flags);
567
568 /* If @sdev is still attached but the associated ATA device
569 * isn't suspended, the operation failed.
570 */
571 if (sdev->sdev_state != SDEV_OFFLINE &&
572 sdev->sdev_state != SDEV_CANCEL && sdev->sdev_state != SDEV_DEL &&
573 !(dev->flags & ATA_DFLAG_SUSPENDED))
574 rc = -EIO;
575
576 out_unlock:
577 spin_unlock_irqrestore(ap->lock, flags);
578 out:
579 if (rc == 0)
580 sdev->sdev_gendev.power.power_state = mesg;
581 return rc;
582}
583
584/**
585 * ata_scsi_device_resume - resume ATA device associated with sdev
586 * @sdev: the SCSI device to resume
587 *
588 * Request resume EH action on the ATA device associated with
589 * @sdev and return immediately. This enables parallel
590 * wakeup/spinup of devices.
591 *
592 * LOCKING:
593 * Kernel thread context (may sleep).
594 *
595 * RETURNS:
596 * 0.
597 */
598int ata_scsi_device_resume(struct scsi_device *sdev)
599{
600 struct ata_port *ap = ata_shost_to_port(sdev->host);
601 struct ata_device *dev = ata_scsi_find_dev(ap, sdev);
602 struct ata_eh_info *ehi = &ap->eh_info;
603 unsigned long flags;
604 unsigned int action;
605
606 if (!dev)
607 goto out;
608
609 spin_lock_irqsave(ap->lock, flags);
610
611 /* if @sdev is already detached, nothing to do */
612 if (sdev->sdev_state == SDEV_OFFLINE ||
613 sdev->sdev_state == SDEV_CANCEL || sdev->sdev_state == SDEV_DEL)
614 goto out_unlock;
615
616 /* request resume */
617 action = ATA_EH_RESUME;
618 if (sdev->sdev_gendev.power.power_state.event == PM_EVENT_SUSPEND)
619 __ata_ehi_hotplugged(ehi);
620 else
621 action |= ATA_EH_PM_FREEZE | ATA_EH_SOFTRESET;
622 ehi->dev_action[dev->devno] |= action;
623
624 /* We don't want autopsy and verbose EH messages. Disable
625 * those if we're the only device on this link.
626 */
627 if (ata_port_max_devices(ap) == 1)
628 ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET;
629
630 ata_port_schedule_eh(ap);
631
632 out_unlock:
633 spin_unlock_irqrestore(ap->lock, flags);
634 out:
635 sdev->sdev_gendev.power.power_state = PMSG_ON;
636 return 0;
637}
638#endif /* CONFIG_PM */
639
640/** 513/**
641 * ata_to_sense_error - convert ATA error to SCSI error 514 * ata_to_sense_error - convert ATA error to SCSI error
642 * @id: ATA device number 515 * @id: ATA device number
@@ -929,6 +802,8 @@ int ata_scsi_slave_config(struct scsi_device *sdev)
929 802
930 blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD); 803 blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD);
931 804
805 sdev->manage_start_stop = 1;
806
932 if (dev) 807 if (dev)
933 ata_scsi_dev_config(sdev, dev); 808 ata_scsi_dev_config(sdev, dev);
934 809
@@ -1069,9 +944,35 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
1069 } 944 }
1070 945
1071 tf->command = ATA_CMD_VERIFY; /* READ VERIFY */ 946 tf->command = ATA_CMD_VERIFY; /* READ VERIFY */
1072 } else 947 } else {
948 /* XXX: This is for backward compatibility, will be
949 * removed. Read Documentation/feature-removal-schedule.txt
950 * for more info.
951 */
952 if (ata_spindown_compat &&
953 (system_state == SYSTEM_HALT ||
954 system_state == SYSTEM_POWER_OFF)) {
955 static int warned = 0;
956
957 if (!warned) {
958 spin_unlock_irq(qc->ap->lock);
959 ata_dev_printk(qc->dev, KERN_WARNING,
960 "DISK MIGHT NOT BE SPUN DOWN PROPERLY. "
961 "UPDATE SHUTDOWN UTILITY\n");
962 ata_dev_printk(qc->dev, KERN_WARNING,
963 "For more info, visit "
964 "http://linux-ata.org/shutdown.html\n");
965 warned = 1;
966 ssleep(5);
967 spin_lock_irq(qc->ap->lock);
968 }
969 scmd->result = SAM_STAT_GOOD;
970 return 1;
971 }
972
1073 /* Issue ATA STANDBY IMMEDIATE command */ 973 /* Issue ATA STANDBY IMMEDIATE command */
1074 tf->command = ATA_CMD_STANDBYNOW1; 974 tf->command = ATA_CMD_STANDBYNOW1;
975 }
1075 976
1076 /* 977 /*
1077 * Standby and Idle condition timers could be implemented but that 978 * Standby and Idle condition timers could be implemented but that
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index d211db6b35a2..e35d13466c69 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -544,7 +544,7 @@ static int ata_resources_present(struct pci_dev *pdev, int port)
544 * RETURNS: 544 * RETURNS:
545 * 0 on success, -errno otherwise. 545 * 0 on success, -errno otherwise.
546 */ 546 */
547static int ata_pci_init_bmdma(struct ata_host *host) 547int ata_pci_init_bmdma(struct ata_host *host)
548{ 548{
549 struct device *gdev = host->dev; 549 struct device *gdev = host->dev;
550 struct pci_dev *pdev = to_pci_dev(gdev); 550 struct pci_dev *pdev = to_pci_dev(gdev);
@@ -566,7 +566,7 @@ static int ata_pci_init_bmdma(struct ata_host *host)
566 } 566 }
567 host->iomap = pcim_iomap_table(pdev); 567 host->iomap = pcim_iomap_table(pdev);
568 568
569 for (i = 0; i < host->n_ports; i++) { 569 for (i = 0; i < 2; i++) {
570 struct ata_port *ap = host->ports[i]; 570 struct ata_port *ap = host->ports[i];
571 void __iomem *bmdma = host->iomap[4] + 8 * i; 571 void __iomem *bmdma = host->iomap[4] + 8 * i;
572 572
@@ -585,54 +585,52 @@ static int ata_pci_init_bmdma(struct ata_host *host)
585/** 585/**
586 * ata_pci_init_native_host - acquire native ATA resources and init host 586 * ata_pci_init_native_host - acquire native ATA resources and init host
587 * @host: target ATA host 587 * @host: target ATA host
588 * @port_mask: ports to consider
589 * 588 *
590 * Acquire native PCI ATA resources for @host and initialize 589 * Acquire native PCI ATA resources for @host and initialize the
591 * @host accordoingly. 590 * first two ports of @host accordingly. Ports marked dummy are
591 * skipped and allocation failure makes the port dummy.
592 * 592 *
593 * LOCKING: 593 * LOCKING:
594 * Inherited from calling layer (may sleep). 594 * Inherited from calling layer (may sleep).
595 * 595 *
596 * RETURNS: 596 * RETURNS:
597 * 0 on success, -errno otherwise. 597 * 0 if at least one port is initialized, -ENODEV if no port is
598 * available.
598 */ 599 */
599int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask) 600int ata_pci_init_native_host(struct ata_host *host)
600{ 601{
601 struct device *gdev = host->dev; 602 struct device *gdev = host->dev;
602 struct pci_dev *pdev = to_pci_dev(gdev); 603 struct pci_dev *pdev = to_pci_dev(gdev);
604 unsigned int mask = 0;
603 int i, rc; 605 int i, rc;
604 606
605 /* Discard disabled ports. Some controllers show their unused
606 * channels this way. Disabled ports are made dummy.
607 */
608 for (i = 0; i < 2; i++) {
609 if ((port_mask & (1 << i)) && !ata_resources_present(pdev, i)) {
610 host->ports[i]->ops = &ata_dummy_port_ops;
611 port_mask &= ~(1 << i);
612 }
613 }
614
615 if (!port_mask) {
616 dev_printk(KERN_ERR, gdev, "no available port\n");
617 return -ENODEV;
618 }
619
620 /* request, iomap BARs and init port addresses accordingly */ 607 /* request, iomap BARs and init port addresses accordingly */
621 for (i = 0; i < 2; i++) { 608 for (i = 0; i < 2; i++) {
622 struct ata_port *ap = host->ports[i]; 609 struct ata_port *ap = host->ports[i];
623 int base = i * 2; 610 int base = i * 2;
624 void __iomem * const *iomap; 611 void __iomem * const *iomap;
625 612
626 if (!(port_mask & (1 << i))) 613 if (ata_port_is_dummy(ap))
614 continue;
615
616 /* Discard disabled ports. Some controllers show
617 * their unused channels this way. Disabled ports are
618 * made dummy.
619 */
620 if (!ata_resources_present(pdev, i)) {
621 ap->ops = &ata_dummy_port_ops;
627 continue; 622 continue;
623 }
628 624
629 rc = pcim_iomap_regions(pdev, 0x3 << base, DRV_NAME); 625 rc = pcim_iomap_regions(pdev, 0x3 << base, DRV_NAME);
630 if (rc) { 626 if (rc) {
631 dev_printk(KERN_ERR, gdev, "failed to request/iomap " 627 dev_printk(KERN_WARNING, gdev,
632 "BARs for port %d (errno=%d)\n", i, rc); 628 "failed to request/iomap BARs for port %d "
629 "(errno=%d)\n", i, rc);
633 if (rc == -EBUSY) 630 if (rc == -EBUSY)
634 pcim_pin_device(pdev); 631 pcim_pin_device(pdev);
635 return rc; 632 ap->ops = &ata_dummy_port_ops;
633 continue;
636 } 634 }
637 host->iomap = iomap = pcim_iomap_table(pdev); 635 host->iomap = iomap = pcim_iomap_table(pdev);
638 636
@@ -641,6 +639,13 @@ int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask)
641 ap->ioaddr.ctl_addr = (void __iomem *) 639 ap->ioaddr.ctl_addr = (void __iomem *)
642 ((unsigned long)iomap[base + 1] | ATA_PCI_CTL_OFS); 640 ((unsigned long)iomap[base + 1] | ATA_PCI_CTL_OFS);
643 ata_std_ports(&ap->ioaddr); 641 ata_std_ports(&ap->ioaddr);
642
643 mask |= 1 << i;
644 }
645
646 if (!mask) {
647 dev_printk(KERN_ERR, gdev, "no available native port\n");
648 return -ENODEV;
644 } 649 }
645 650
646 return 0; 651 return 0;
@@ -649,8 +654,7 @@ int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask)
649/** 654/**
650 * ata_pci_prepare_native_host - helper to prepare native PCI ATA host 655 * ata_pci_prepare_native_host - helper to prepare native PCI ATA host
651 * @pdev: target PCI device 656 * @pdev: target PCI device
652 * @ppi: array of port_info 657 * @ppi: array of port_info, must be enough for two ports
653 * @n_ports: number of ports to allocate
654 * @r_host: out argument for the initialized ATA host 658 * @r_host: out argument for the initialized ATA host
655 * 659 *
656 * Helper to allocate ATA host for @pdev, acquire all native PCI 660 * Helper to allocate ATA host for @pdev, acquire all native PCI
@@ -664,10 +668,9 @@ int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask)
664 */ 668 */
665int ata_pci_prepare_native_host(struct pci_dev *pdev, 669int ata_pci_prepare_native_host(struct pci_dev *pdev,
666 const struct ata_port_info * const * ppi, 670 const struct ata_port_info * const * ppi,
667 int n_ports, struct ata_host **r_host) 671 struct ata_host **r_host)
668{ 672{
669 struct ata_host *host; 673 struct ata_host *host;
670 unsigned int port_mask;
671 int rc; 674 int rc;
672 675
673 if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL)) 676 if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL))
@@ -681,11 +684,7 @@ int ata_pci_prepare_native_host(struct pci_dev *pdev,
681 goto err_out; 684 goto err_out;
682 } 685 }
683 686
684 port_mask = ATA_PORT_PRIMARY; 687 rc = ata_pci_init_native_host(host);
685 if (n_ports > 1)
686 port_mask |= ATA_PORT_SECONDARY;
687
688 rc = ata_pci_init_native_host(host, port_mask);
689 if (rc) 688 if (rc)
690 goto err_out; 689 goto err_out;
691 690
@@ -777,8 +776,11 @@ static int ata_init_legacy_port(struct ata_port *ap,
777 /* iomap cmd and ctl ports */ 776 /* iomap cmd and ctl ports */
778 legacy_dr->cmd_addr[port_no] = ioport_map(cmd_port, 8); 777 legacy_dr->cmd_addr[port_no] = ioport_map(cmd_port, 8);
779 legacy_dr->ctl_addr[port_no] = ioport_map(ctl_port, 1); 778 legacy_dr->ctl_addr[port_no] = ioport_map(ctl_port, 1);
780 if (!legacy_dr->cmd_addr[port_no] || !legacy_dr->ctl_addr[port_no]) 779 if (!legacy_dr->cmd_addr[port_no] || !legacy_dr->ctl_addr[port_no]) {
780 dev_printk(KERN_WARNING, host->dev,
781 "failed to map cmd/ctl ports\n");
781 return -ENOMEM; 782 return -ENOMEM;
783 }
782 784
783 /* init IO addresses */ 785 /* init IO addresses */
784 ap->ioaddr.cmd_addr = legacy_dr->cmd_addr[port_no]; 786 ap->ioaddr.cmd_addr = legacy_dr->cmd_addr[port_no];
@@ -792,19 +794,20 @@ static int ata_init_legacy_port(struct ata_port *ap,
792/** 794/**
793 * ata_init_legacy_host - acquire legacy ATA resources and init ATA host 795 * ata_init_legacy_host - acquire legacy ATA resources and init ATA host
794 * @host: target ATA host 796 * @host: target ATA host
795 * @legacy_mask: out parameter, mask indicating ports is in legacy mode
796 * @was_busy: out parameter, indicates whether any port was busy 797 * @was_busy: out parameter, indicates whether any port was busy
797 * 798 *
798 * Acquire legacy ATA resources for ports. 799 * Acquire legacy ATA resources for the first two ports of @host
800 * and initialize it accordingly. Ports marked dummy are skipped
801 * and resource acquistion failure makes the port dummy.
799 * 802 *
800 * LOCKING: 803 * LOCKING:
801 * Inherited from calling layer (may sleep). 804 * Inherited from calling layer (may sleep).
802 * 805 *
803 * RETURNS: 806 * RETURNS:
804 * 0 on success, -errno otherwise. 807 * 0 if at least one port is initialized, -ENODEV if no port is
808 * available.
805 */ 809 */
806static int ata_init_legacy_host(struct ata_host *host, 810static int ata_init_legacy_host(struct ata_host *host, int *was_busy)
807 unsigned int *legacy_mask, int *was_busy)
808{ 811{
809 struct device *gdev = host->dev; 812 struct device *gdev = host->dev;
810 struct ata_legacy_devres *legacy_dr; 813 struct ata_legacy_devres *legacy_dr;
@@ -821,22 +824,23 @@ static int ata_init_legacy_host(struct ata_host *host,
821 devres_add(gdev, legacy_dr); 824 devres_add(gdev, legacy_dr);
822 825
823 for (i = 0; i < 2; i++) { 826 for (i = 0; i < 2; i++) {
824 *legacy_mask &= ~(1 << i); 827 if (ata_port_is_dummy(host->ports[i]))
828 continue;
829
825 rc = ata_init_legacy_port(host->ports[i], legacy_dr); 830 rc = ata_init_legacy_port(host->ports[i], legacy_dr);
826 if (rc == 0) 831 if (rc == 0)
827 legacy_dr->mask |= 1 << i; 832 legacy_dr->mask |= 1 << i;
828 else if (rc == -EBUSY) 833 else {
829 (*was_busy)++; 834 if (rc == -EBUSY)
830 } 835 (*was_busy)++;
831
832 if (!legacy_dr->mask)
833 return -EBUSY;
834
835 for (i = 0; i < 2; i++)
836 if (!(legacy_dr->mask & (1 << i)))
837 host->ports[i]->ops = &ata_dummy_port_ops; 836 host->ports[i]->ops = &ata_dummy_port_ops;
837 }
838 }
838 839
839 *legacy_mask |= legacy_dr->mask; 840 if (!legacy_dr->mask) {
841 dev_printk(KERN_ERR, gdev, "no available legacy port\n");
842 return -ENODEV;
843 }
840 844
841 devres_remove_group(gdev, NULL); 845 devres_remove_group(gdev, NULL);
842 return 0; 846 return 0;
@@ -875,7 +879,7 @@ static int ata_request_legacy_irqs(struct ata_host *host,
875 legacy_dr = devres_find(host->dev, ata_legacy_release, NULL, NULL); 879 legacy_dr = devres_find(host->dev, ata_legacy_release, NULL, NULL);
876 BUG_ON(!legacy_dr); 880 BUG_ON(!legacy_dr);
877 881
878 for (i = 0; i < host->n_ports; i++) { 882 for (i = 0; i < 2; i++) {
879 unsigned int irq; 883 unsigned int irq;
880 884
881 /* FIXME: ATA_*_IRQ() should take generic device not pci_dev */ 885 /* FIXME: ATA_*_IRQ() should take generic device not pci_dev */
@@ -923,8 +927,7 @@ static int ata_request_legacy_irqs(struct ata_host *host,
923/** 927/**
924 * ata_pci_init_one - Initialize/register PCI IDE host controller 928 * ata_pci_init_one - Initialize/register PCI IDE host controller
925 * @pdev: Controller to be initialized 929 * @pdev: Controller to be initialized
926 * @port_info: Information from low-level host driver 930 * @ppi: array of port_info, must be enough for two ports
927 * @n_ports: Number of ports attached to host controller
928 * 931 *
929 * This is a helper function which can be called from a driver's 932 * This is a helper function which can be called from a driver's
930 * xxx_init_one() probe function if the hardware uses traditional 933 * xxx_init_one() probe function if the hardware uses traditional
@@ -944,26 +947,34 @@ static int ata_request_legacy_irqs(struct ata_host *host,
944 * RETURNS: 947 * RETURNS:
945 * Zero on success, negative on errno-based value on error. 948 * Zero on success, negative on errno-based value on error.
946 */ 949 */
947 950int ata_pci_init_one(struct pci_dev *pdev,
948int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, 951 const struct ata_port_info * const * ppi)
949 unsigned int n_ports)
950{ 952{
951 struct device *dev = &pdev->dev; 953 struct device *dev = &pdev->dev;
954 const struct ata_port_info *pi = NULL;
952 struct ata_host *host = NULL; 955 struct ata_host *host = NULL;
953 const struct ata_port_info *port[2];
954 u8 mask; 956 u8 mask;
955 unsigned int legacy_mode = 0; 957 int legacy_mode = 0;
956 int rc; 958 int i, rc;
957 959
958 DPRINTK("ENTER\n"); 960 DPRINTK("ENTER\n");
959 961
960 if (!devres_open_group(dev, NULL, GFP_KERNEL)) 962 /* look up the first valid port_info */
961 return -ENOMEM; 963 for (i = 0; i < 2 && ppi[i]; i++) {
964 if (ppi[i]->port_ops != &ata_dummy_port_ops) {
965 pi = ppi[i];
966 break;
967 }
968 }
962 969
963 BUG_ON(n_ports < 1 || n_ports > 2); 970 if (!pi) {
971 dev_printk(KERN_ERR, &pdev->dev,
972 "no valid port_info specified\n");
973 return -EINVAL;
974 }
964 975
965 port[0] = port_info[0]; 976 if (!devres_open_group(dev, NULL, GFP_KERNEL))
966 port[1] = (n_ports > 1) ? port_info[1] : NULL; 977 return -ENOMEM;
967 978
968 /* FIXME: Really for ATA it isn't safe because the device may be 979 /* FIXME: Really for ATA it isn't safe because the device may be
969 multi-purpose and we want to leave it alone if it was already 980 multi-purpose and we want to leave it alone if it was already
@@ -984,7 +995,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
984 pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8); 995 pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8);
985 mask = (1 << 2) | (1 << 0); 996 mask = (1 << 2) | (1 << 0);
986 if ((tmp8 & mask) != mask) 997 if ((tmp8 & mask) != mask)
987 legacy_mode = (1 << 3); 998 legacy_mode = 1;
988#if defined(CONFIG_NO_ATA_LEGACY) 999#if defined(CONFIG_NO_ATA_LEGACY)
989 /* Some platforms with PCI limits cannot address compat 1000 /* Some platforms with PCI limits cannot address compat
990 port space. In that case we punt if their firmware has 1001 port space. In that case we punt if their firmware has
@@ -998,7 +1009,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
998 } 1009 }
999 1010
1000 /* alloc and init host */ 1011 /* alloc and init host */
1001 host = ata_host_alloc_pinfo(dev, port, n_ports); 1012 host = ata_host_alloc_pinfo(dev, ppi, 2);
1002 if (!host) { 1013 if (!host) {
1003 dev_printk(KERN_ERR, &pdev->dev, 1014 dev_printk(KERN_ERR, &pdev->dev,
1004 "failed to allocate ATA host\n"); 1015 "failed to allocate ATA host\n");
@@ -1007,19 +1018,13 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
1007 } 1018 }
1008 1019
1009 if (!legacy_mode) { 1020 if (!legacy_mode) {
1010 unsigned int port_mask; 1021 rc = ata_pci_init_native_host(host);
1011
1012 port_mask = ATA_PORT_PRIMARY;
1013 if (n_ports > 1)
1014 port_mask |= ATA_PORT_SECONDARY;
1015
1016 rc = ata_pci_init_native_host(host, port_mask);
1017 if (rc) 1022 if (rc)
1018 goto err_out; 1023 goto err_out;
1019 } else { 1024 } else {
1020 int was_busy = 0; 1025 int was_busy = 0;
1021 1026
1022 rc = ata_init_legacy_host(host, &legacy_mode, &was_busy); 1027 rc = ata_init_legacy_host(host, &was_busy);
1023 if (was_busy) 1028 if (was_busy)
1024 pcim_pin_device(pdev); 1029 pcim_pin_device(pdev);
1025 if (rc) 1030 if (rc)
@@ -1040,8 +1045,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
1040 goto err_out; 1045 goto err_out;
1041 1046
1042 if (!legacy_mode) 1047 if (!legacy_mode)
1043 rc = devm_request_irq(dev, pdev->irq, 1048 rc = devm_request_irq(dev, pdev->irq, pi->port_ops->irq_handler,
1044 port_info[0]->port_ops->irq_handler,
1045 IRQF_SHARED, DRV_NAME, host); 1049 IRQF_SHARED, DRV_NAME, host);
1046 else { 1050 else {
1047 irq_handler_t handler[2] = { host->ops->irq_handler, 1051 irq_handler_t handler[2] = { host->ops->irq_handler,
@@ -1055,7 +1059,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
1055 goto err_out; 1059 goto err_out;
1056 1060
1057 /* register */ 1061 /* register */
1058 rc = ata_host_register(host, port_info[0]->sht); 1062 rc = ata_host_register(host, pi->sht);
1059 if (rc) 1063 if (rc)
1060 goto err_out; 1064 goto err_out;
1061 1065
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 5f4d40cd3288..8b71b73a199c 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -58,6 +58,7 @@ extern int atapi_enabled;
58extern int atapi_dmadir; 58extern int atapi_dmadir;
59extern int libata_fua; 59extern int libata_fua;
60extern int libata_noacpi; 60extern int libata_noacpi;
61extern int ata_spindown_compat;
61extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev); 62extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev);
62extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, 63extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
63 u64 block, u32 n_block, unsigned int tf_flags, 64 u64 block, u32 n_block, unsigned int tf_flags,
@@ -96,15 +97,15 @@ extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg);
96extern struct ata_port *ata_port_alloc(struct ata_host *host); 97extern struct ata_port *ata_port_alloc(struct ata_host *host);
97 98
98/* libata-acpi.c */ 99/* libata-acpi.c */
99#ifdef CONFIG_SATA_ACPI 100#ifdef CONFIG_ATA_ACPI
100extern int ata_acpi_exec_tfs(struct ata_port *ap); 101extern int ata_acpi_exec_tfs(struct ata_port *ap);
101extern int ata_acpi_push_id(struct ata_port *ap, unsigned int ix); 102extern int ata_acpi_push_id(struct ata_device *dev);
102#else 103#else
103static inline int ata_acpi_exec_tfs(struct ata_port *ap) 104static inline int ata_acpi_exec_tfs(struct ata_port *ap)
104{ 105{
105 return 0; 106 return 0;
106} 107}
107static inline int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) 108static inline int ata_acpi_push_id(struct ata_device *dev)
108{ 109{
109 return 0; 110 return 0;
110} 111}
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index d40edebb510a..3c55a5ff74c7 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -291,10 +291,6 @@ static struct scsi_host_template ali_sht = {
291 .slave_configure = ata_scsi_slave_config, 291 .slave_configure = ata_scsi_slave_config,
292 .slave_destroy = ata_scsi_slave_destroy, 292 .slave_destroy = ata_scsi_slave_destroy,
293 .bios_param = ata_std_bios_param, 293 .bios_param = ata_std_bios_param,
294#ifdef CONFIG_PM
295 .resume = ata_scsi_device_resume,
296 .suspend = ata_scsi_device_suspend,
297#endif
298}; 294};
299 295
300/* 296/*
@@ -522,14 +518,14 @@ static void ali_init_chipset(struct pci_dev *pdev)
522 518
523static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 519static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
524{ 520{
525 static struct ata_port_info info_early = { 521 static const struct ata_port_info info_early = {
526 .sht = &ali_sht, 522 .sht = &ali_sht,
527 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 523 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
528 .pio_mask = 0x1f, 524 .pio_mask = 0x1f,
529 .port_ops = &ali_early_port_ops 525 .port_ops = &ali_early_port_ops
530 }; 526 };
531 /* Revision 0x20 added DMA */ 527 /* Revision 0x20 added DMA */
532 static struct ata_port_info info_20 = { 528 static const struct ata_port_info info_20 = {
533 .sht = &ali_sht, 529 .sht = &ali_sht,
534 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, 530 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48,
535 .pio_mask = 0x1f, 531 .pio_mask = 0x1f,
@@ -537,7 +533,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
537 .port_ops = &ali_20_port_ops 533 .port_ops = &ali_20_port_ops
538 }; 534 };
539 /* Revision 0x20 with support logic added UDMA */ 535 /* Revision 0x20 with support logic added UDMA */
540 static struct ata_port_info info_20_udma = { 536 static const struct ata_port_info info_20_udma = {
541 .sht = &ali_sht, 537 .sht = &ali_sht,
542 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, 538 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48,
543 .pio_mask = 0x1f, 539 .pio_mask = 0x1f,
@@ -546,7 +542,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
546 .port_ops = &ali_20_port_ops 542 .port_ops = &ali_20_port_ops
547 }; 543 };
548 /* Revision 0xC2 adds UDMA66 */ 544 /* Revision 0xC2 adds UDMA66 */
549 static struct ata_port_info info_c2 = { 545 static const struct ata_port_info info_c2 = {
550 .sht = &ali_sht, 546 .sht = &ali_sht,
551 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, 547 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48,
552 .pio_mask = 0x1f, 548 .pio_mask = 0x1f,
@@ -555,7 +551,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
555 .port_ops = &ali_c2_port_ops 551 .port_ops = &ali_c2_port_ops
556 }; 552 };
557 /* Revision 0xC3 is UDMA100 */ 553 /* Revision 0xC3 is UDMA100 */
558 static struct ata_port_info info_c3 = { 554 static const struct ata_port_info info_c3 = {
559 .sht = &ali_sht, 555 .sht = &ali_sht,
560 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, 556 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48,
561 .pio_mask = 0x1f, 557 .pio_mask = 0x1f,
@@ -564,7 +560,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
564 .port_ops = &ali_c2_port_ops 560 .port_ops = &ali_c2_port_ops
565 }; 561 };
566 /* Revision 0xC4 is UDMA133 */ 562 /* Revision 0xC4 is UDMA133 */
567 static struct ata_port_info info_c4 = { 563 static const struct ata_port_info info_c4 = {
568 .sht = &ali_sht, 564 .sht = &ali_sht,
569 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, 565 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48,
570 .pio_mask = 0x1f, 566 .pio_mask = 0x1f,
@@ -573,7 +569,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
573 .port_ops = &ali_c2_port_ops 569 .port_ops = &ali_c2_port_ops
574 }; 570 };
575 /* Revision 0xC5 is UDMA133 with LBA48 DMA */ 571 /* Revision 0xC5 is UDMA133 with LBA48 DMA */
576 static struct ata_port_info info_c5 = { 572 static const struct ata_port_info info_c5 = {
577 .sht = &ali_sht, 573 .sht = &ali_sht,
578 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 574 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
579 .pio_mask = 0x1f, 575 .pio_mask = 0x1f,
@@ -582,7 +578,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
582 .port_ops = &ali_c5_port_ops 578 .port_ops = &ali_c5_port_ops
583 }; 579 };
584 580
585 static struct ata_port_info *port_info[2]; 581 const struct ata_port_info *ppi[] = { NULL, NULL };
586 u8 rev, tmp; 582 u8 rev, tmp;
587 struct pci_dev *isa_bridge; 583 struct pci_dev *isa_bridge;
588 584
@@ -594,17 +590,17 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
594 */ 590 */
595 591
596 if (rev < 0x20) { 592 if (rev < 0x20) {
597 port_info[0] = port_info[1] = &info_early; 593 ppi[0] = &info_early;
598 } else if (rev < 0xC2) { 594 } else if (rev < 0xC2) {
599 port_info[0] = port_info[1] = &info_20; 595 ppi[0] = &info_20;
600 } else if (rev == 0xC2) { 596 } else if (rev == 0xC2) {
601 port_info[0] = port_info[1] = &info_c2; 597 ppi[0] = &info_c2;
602 } else if (rev == 0xC3) { 598 } else if (rev == 0xC3) {
603 port_info[0] = port_info[1] = &info_c3; 599 ppi[0] = &info_c3;
604 } else if (rev == 0xC4) { 600 } else if (rev == 0xC4) {
605 port_info[0] = port_info[1] = &info_c4; 601 ppi[0] = &info_c4;
606 } else 602 } else
607 port_info[0] = port_info[1] = &info_c5; 603 ppi[0] = &info_c5;
608 604
609 ali_init_chipset(pdev); 605 ali_init_chipset(pdev);
610 606
@@ -613,10 +609,10 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
613 /* Are we paired with a UDMA capable chip */ 609 /* Are we paired with a UDMA capable chip */
614 pci_read_config_byte(isa_bridge, 0x5E, &tmp); 610 pci_read_config_byte(isa_bridge, 0x5E, &tmp);
615 if ((tmp & 0x1E) == 0x12) 611 if ((tmp & 0x1E) == 0x12)
616 port_info[0] = port_info[1] = &info_20_udma; 612 ppi[0] = &info_20_udma;
617 pci_dev_put(isa_bridge); 613 pci_dev_put(isa_bridge);
618 } 614 }
619 return ata_pci_init_one(pdev, port_info, 2); 615 return ata_pci_init_one(pdev, ppi);
620} 616}
621 617
622#ifdef CONFIG_PM 618#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
index 67c7e87dec04..b439351f1fd3 100644
--- a/drivers/ata/pata_amd.c
+++ b/drivers/ata/pata_amd.c
@@ -324,10 +324,6 @@ static struct scsi_host_template amd_sht = {
324 .slave_configure = ata_scsi_slave_config, 324 .slave_configure = ata_scsi_slave_config,
325 .slave_destroy = ata_scsi_slave_destroy, 325 .slave_destroy = ata_scsi_slave_destroy,
326 .bios_param = ata_std_bios_param, 326 .bios_param = ata_std_bios_param,
327#ifdef CONFIG_PM
328 .resume = ata_scsi_device_resume,
329 .suspend = ata_scsi_device_suspend,
330#endif
331}; 327};
332 328
333static struct ata_port_operations amd33_port_ops = { 329static struct ata_port_operations amd33_port_ops = {
@@ -542,7 +538,7 @@ static struct ata_port_operations nv133_port_ops = {
542 538
543static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 539static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
544{ 540{
545 static struct ata_port_info info[10] = { 541 static const struct ata_port_info info[10] = {
546 { /* 0: AMD 7401 */ 542 { /* 0: AMD 7401 */
547 .sht = &amd_sht, 543 .sht = &amd_sht,
548 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 544 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
@@ -624,7 +620,7 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
624 .port_ops = &amd100_port_ops 620 .port_ops = &amd100_port_ops
625 } 621 }
626 }; 622 };
627 static struct ata_port_info *port_info[2]; 623 const struct ata_port_info *ppi[] = { NULL, NULL };
628 static int printed_version; 624 static int printed_version;
629 int type = id->driver_data; 625 int type = id->driver_data;
630 u8 rev; 626 u8 rev;
@@ -656,9 +652,8 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
656 ata_pci_clear_simplex(pdev); 652 ata_pci_clear_simplex(pdev);
657 653
658 /* And fire it up */ 654 /* And fire it up */
659 655 ppi[0] = &info[type];
660 port_info[0] = port_info[1] = &info[type]; 656 return ata_pci_init_one(pdev, ppi);
661 return ata_pci_init_one(pdev, port_info, 2);
662} 657}
663 658
664#ifdef CONFIG_PM 659#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c
index ef51940c3adb..9861059dd673 100644
--- a/drivers/ata/pata_artop.c
+++ b/drivers/ata/pata_artop.c
@@ -414,7 +414,7 @@ static const struct ata_port_operations artop6260_ops = {
414static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) 414static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
415{ 415{
416 static int printed_version; 416 static int printed_version;
417 static struct ata_port_info info_6210 = { 417 static const struct ata_port_info info_6210 = {
418 .sht = &artop_sht, 418 .sht = &artop_sht,
419 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 419 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
420 .pio_mask = 0x1f, /* pio0-4 */ 420 .pio_mask = 0x1f, /* pio0-4 */
@@ -422,7 +422,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
422 .udma_mask = ATA_UDMA2, 422 .udma_mask = ATA_UDMA2,
423 .port_ops = &artop6210_ops, 423 .port_ops = &artop6210_ops,
424 }; 424 };
425 static struct ata_port_info info_626x = { 425 static const struct ata_port_info info_626x = {
426 .sht = &artop_sht, 426 .sht = &artop_sht,
427 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 427 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
428 .pio_mask = 0x1f, /* pio0-4 */ 428 .pio_mask = 0x1f, /* pio0-4 */
@@ -430,7 +430,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
430 .udma_mask = ATA_UDMA4, 430 .udma_mask = ATA_UDMA4,
431 .port_ops = &artop6260_ops, 431 .port_ops = &artop6260_ops,
432 }; 432 };
433 static struct ata_port_info info_626x_fast = { 433 static const struct ata_port_info info_626x_fast = {
434 .sht = &artop_sht, 434 .sht = &artop_sht,
435 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 435 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
436 .pio_mask = 0x1f, /* pio0-4 */ 436 .pio_mask = 0x1f, /* pio0-4 */
@@ -438,32 +438,30 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
438 .udma_mask = ATA_UDMA5, 438 .udma_mask = ATA_UDMA5,
439 .port_ops = &artop6260_ops, 439 .port_ops = &artop6260_ops,
440 }; 440 };
441 struct ata_port_info *port_info[2]; 441 const struct ata_port_info *ppi[] = { NULL, NULL };
442 struct ata_port_info *info = NULL;
443 int ports = 2;
444 442
445 if (!printed_version++) 443 if (!printed_version++)
446 dev_printk(KERN_DEBUG, &pdev->dev, 444 dev_printk(KERN_DEBUG, &pdev->dev,
447 "version " DRV_VERSION "\n"); 445 "version " DRV_VERSION "\n");
448 446
449 if (id->driver_data == 0) { /* 6210 variant */ 447 if (id->driver_data == 0) { /* 6210 variant */
450 info = &info_6210; 448 ppi[0] = &info_6210;
449 ppi[1] = &ata_dummy_port_info;
451 /* BIOS may have left us in UDMA, clear it before libata probe */ 450 /* BIOS may have left us in UDMA, clear it before libata probe */
452 pci_write_config_byte(pdev, 0x54, 0); 451 pci_write_config_byte(pdev, 0x54, 0);
453 /* For the moment (also lacks dsc) */ 452 /* For the moment (also lacks dsc) */
454 printk(KERN_WARNING "ARTOP 6210 requires serialize functionality not yet supported by libata.\n"); 453 printk(KERN_WARNING "ARTOP 6210 requires serialize functionality not yet supported by libata.\n");
455 printk(KERN_WARNING "Secondary ATA ports will not be activated.\n"); 454 printk(KERN_WARNING "Secondary ATA ports will not be activated.\n");
456 ports = 1;
457 } 455 }
458 else if (id->driver_data == 1) /* 6260 */ 456 else if (id->driver_data == 1) /* 6260 */
459 info = &info_626x; 457 ppi[0] = &info_626x;
460 else if (id->driver_data == 2) { /* 6260 or 6260 + fast */ 458 else if (id->driver_data == 2) { /* 6260 or 6260 + fast */
461 unsigned long io = pci_resource_start(pdev, 4); 459 unsigned long io = pci_resource_start(pdev, 4);
462 u8 reg; 460 u8 reg;
463 461
464 info = &info_626x; 462 ppi[0] = &info_626x;
465 if (inb(io) & 0x10) 463 if (inb(io) & 0x10)
466 info = &info_626x_fast; 464 ppi[0] = &info_626x_fast;
467 /* Mac systems come up with some registers not set as we 465 /* Mac systems come up with some registers not set as we
468 will need them */ 466 will need them */
469 467
@@ -484,10 +482,9 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
484 482
485 } 483 }
486 484
487 BUG_ON(info == NULL); 485 BUG_ON(ppi[0] == NULL);
488 486
489 port_info[0] = port_info[1] = info; 487 return ata_pci_init_one(pdev, ppi);
490 return ata_pci_init_one(pdev, port_info, ports);
491} 488}
492 489
493static const struct pci_device_id artop_pci_tbl[] = { 490static const struct pci_device_id artop_pci_tbl[] = {
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c
index 21515381b5b3..844914681a2a 100644
--- a/drivers/ata/pata_atiixp.c
+++ b/drivers/ata/pata_atiixp.c
@@ -229,10 +229,6 @@ static struct scsi_host_template atiixp_sht = {
229 .slave_configure = ata_scsi_slave_config, 229 .slave_configure = ata_scsi_slave_config,
230 .slave_destroy = ata_scsi_slave_destroy, 230 .slave_destroy = ata_scsi_slave_destroy,
231 .bios_param = ata_std_bios_param, 231 .bios_param = ata_std_bios_param,
232#ifdef CONFIG_PM
233 .resume = ata_scsi_device_resume,
234 .suspend = ata_scsi_device_suspend,
235#endif
236}; 232};
237 233
238static struct ata_port_operations atiixp_port_ops = { 234static struct ata_port_operations atiixp_port_ops = {
@@ -272,7 +268,7 @@ static struct ata_port_operations atiixp_port_ops = {
272 268
273static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) 269static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id)
274{ 270{
275 static struct ata_port_info info = { 271 static const struct ata_port_info info = {
276 .sht = &atiixp_sht, 272 .sht = &atiixp_sht,
277 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 273 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
278 .pio_mask = 0x1f, 274 .pio_mask = 0x1f,
@@ -280,8 +276,8 @@ static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id)
280 .udma_mask = 0x3F, 276 .udma_mask = 0x3F,
281 .port_ops = &atiixp_port_ops 277 .port_ops = &atiixp_port_ops
282 }; 278 };
283 static struct ata_port_info *port_info[2] = { &info, &info }; 279 const struct ata_port_info *ppi[] = { &info, NULL };
284 return ata_pci_init_one(dev, port_info, 2); 280 return ata_pci_init_one(dev, ppi);
285} 281}
286 282
287static const struct pci_device_id atiixp[] = { 283static const struct pci_device_id atiixp[] = {
diff --git a/drivers/ata/pata_cmd640.c b/drivers/ata/pata_cmd640.c
index 2105985a8013..ed00fa9d53be 100644
--- a/drivers/ata/pata_cmd640.c
+++ b/drivers/ata/pata_cmd640.c
@@ -181,10 +181,6 @@ static struct scsi_host_template cmd640_sht = {
181 .slave_configure = ata_scsi_slave_config, 181 .slave_configure = ata_scsi_slave_config,
182 .slave_destroy = ata_scsi_slave_destroy, 182 .slave_destroy = ata_scsi_slave_destroy,
183 .bios_param = ata_std_bios_param, 183 .bios_param = ata_std_bios_param,
184#ifdef CONFIG_PM
185 .resume = ata_scsi_device_resume,
186 .suspend = ata_scsi_device_suspend,
187#endif
188}; 184};
189 185
190static struct ata_port_operations cmd640_port_ops = { 186static struct ata_port_operations cmd640_port_ops = {
@@ -253,17 +249,16 @@ static void cmd640_hardware_init(struct pci_dev *pdev)
253 249
254static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 250static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
255{ 251{
256 static struct ata_port_info info = { 252 static const struct ata_port_info info = {
257 .sht = &cmd640_sht, 253 .sht = &cmd640_sht,
258 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 254 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
259 .pio_mask = 0x1f, 255 .pio_mask = 0x1f,
260 .port_ops = &cmd640_port_ops 256 .port_ops = &cmd640_port_ops
261 }; 257 };
262 258 const struct ata_port_info *ppi[] = { &info, NULL };
263 static struct ata_port_info *port_info[2] = { &info, &info };
264 259
265 cmd640_hardware_init(pdev); 260 cmd640_hardware_init(pdev);
266 return ata_pci_init_one(pdev, port_info, 2); 261 return ata_pci_init_one(pdev, ppi);
267} 262}
268 263
269static int cmd640_reinit_one(struct pci_dev *pdev) 264static int cmd640_reinit_one(struct pci_dev *pdev)
diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c
index 3989cc577fcd..2a79b335cfcc 100644
--- a/drivers/ata/pata_cmd64x.c
+++ b/drivers/ata/pata_cmd64x.c
@@ -266,10 +266,6 @@ static struct scsi_host_template cmd64x_sht = {
266 .slave_configure = ata_scsi_slave_config, 266 .slave_configure = ata_scsi_slave_config,
267 .slave_destroy = ata_scsi_slave_destroy, 267 .slave_destroy = ata_scsi_slave_destroy,
268 .bios_param = ata_std_bios_param, 268 .bios_param = ata_std_bios_param,
269#ifdef CONFIG_PM
270 .resume = ata_scsi_device_resume,
271 .suspend = ata_scsi_device_suspend,
272#endif
273}; 269};
274 270
275static struct ata_port_operations cmd64x_port_ops = { 271static struct ata_port_operations cmd64x_port_ops = {
@@ -381,7 +377,7 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
381{ 377{
382 u32 class_rev; 378 u32 class_rev;
383 379
384 static struct ata_port_info cmd_info[6] = { 380 static const struct ata_port_info cmd_info[6] = {
385 { /* CMD 643 - no UDMA */ 381 { /* CMD 643 - no UDMA */
386 .sht = &cmd64x_sht, 382 .sht = &cmd64x_sht,
387 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 383 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
@@ -428,11 +424,9 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
428 .port_ops = &cmd648_port_ops 424 .port_ops = &cmd648_port_ops
429 } 425 }
430 }; 426 };
431 static struct ata_port_info *port_info[2], *info; 427 const struct ata_port_info *ppi[] = { &cmd_info[id->driver_data], NULL };
432 u8 mrdmode; 428 u8 mrdmode;
433 429
434 info = &cmd_info[id->driver_data];
435
436 pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev); 430 pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev);
437 class_rev &= 0xFF; 431 class_rev &= 0xFF;
438 432
@@ -442,10 +436,10 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
442 if (pdev->device == PCI_DEVICE_ID_CMD_646) { 436 if (pdev->device == PCI_DEVICE_ID_CMD_646) {
443 /* Does UDMA work ? */ 437 /* Does UDMA work ? */
444 if (class_rev > 4) 438 if (class_rev > 4)
445 info = &cmd_info[2]; 439 ppi[0] = &cmd_info[2];
446 /* Early rev with other problems ? */ 440 /* Early rev with other problems ? */
447 else if (class_rev == 1) 441 else if (class_rev == 1)
448 info = &cmd_info[3]; 442 ppi[0] = &cmd_info[3];
449 } 443 }
450 444
451 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64); 445 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64);
@@ -461,8 +455,7 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
461 pci_write_config_byte(pdev, UDIDETCR0, 0xF0); 455 pci_write_config_byte(pdev, UDIDETCR0, 0xF0);
462#endif 456#endif
463 457
464 port_info[0] = port_info[1] = info; 458 return ata_pci_init_one(pdev, ppi);
465 return ata_pci_init_one(pdev, port_info, 2);
466} 459}
467 460
468#ifdef CONFIG_PM 461#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_cs5520.c b/drivers/ata/pata_cs5520.c
index 79bef0d1fad3..83bcc5b32597 100644
--- a/drivers/ata/pata_cs5520.c
+++ b/drivers/ata/pata_cs5520.c
@@ -155,10 +155,6 @@ static struct scsi_host_template cs5520_sht = {
155 .slave_configure = ata_scsi_slave_config, 155 .slave_configure = ata_scsi_slave_config,
156 .slave_destroy = ata_scsi_slave_destroy, 156 .slave_destroy = ata_scsi_slave_destroy,
157 .bios_param = ata_std_bios_param, 157 .bios_param = ata_std_bios_param,
158#ifdef CONFIG_PM
159 .resume = ata_scsi_device_resume,
160 .suspend = ata_scsi_device_suspend,
161#endif
162}; 158};
163 159
164static struct ata_port_operations cs5520_port_ops = { 160static struct ata_port_operations cs5520_port_ops = {
diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c
index 29642d5ee189..1b67923d7a4e 100644
--- a/drivers/ata/pata_cs5530.c
+++ b/drivers/ata/pata_cs5530.c
@@ -176,10 +176,6 @@ static struct scsi_host_template cs5530_sht = {
176 .slave_configure = ata_scsi_slave_config, 176 .slave_configure = ata_scsi_slave_config,
177 .slave_destroy = ata_scsi_slave_destroy, 177 .slave_destroy = ata_scsi_slave_destroy,
178 .bios_param = ata_std_bios_param, 178 .bios_param = ata_std_bios_param,
179#ifdef CONFIG_PM
180 .resume = ata_scsi_device_resume,
181 .suspend = ata_scsi_device_suspend,
182#endif
183}; 179};
184 180
185static struct ata_port_operations cs5530_port_ops = { 181static struct ata_port_operations cs5530_port_ops = {
@@ -339,7 +335,7 @@ fail_put:
339 335
340static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 336static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
341{ 337{
342 static struct ata_port_info info = { 338 static const struct ata_port_info info = {
343 .sht = &cs5530_sht, 339 .sht = &cs5530_sht,
344 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 340 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
345 .pio_mask = 0x1f, 341 .pio_mask = 0x1f,
@@ -348,23 +344,23 @@ static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
348 .port_ops = &cs5530_port_ops 344 .port_ops = &cs5530_port_ops
349 }; 345 };
350 /* The docking connector doesn't do UDMA, and it seems not MWDMA */ 346 /* The docking connector doesn't do UDMA, and it seems not MWDMA */
351 static struct ata_port_info info_palmax_secondary = { 347 static const struct ata_port_info info_palmax_secondary = {
352 .sht = &cs5530_sht, 348 .sht = &cs5530_sht,
353 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 349 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
354 .pio_mask = 0x1f, 350 .pio_mask = 0x1f,
355 .port_ops = &cs5530_port_ops 351 .port_ops = &cs5530_port_ops
356 }; 352 };
357 static struct ata_port_info *port_info[2] = { &info, &info }; 353 const struct ata_port_info *ppi[] = { &info, NULL };
358 354
359 /* Chip initialisation */ 355 /* Chip initialisation */
360 if (cs5530_init_chip()) 356 if (cs5530_init_chip())
361 return -ENODEV; 357 return -ENODEV;
362 358
363 if (cs5530_is_palmax()) 359 if (cs5530_is_palmax())
364 port_info[1] = &info_palmax_secondary; 360 ppi[1] = &info_palmax_secondary;
365 361
366 /* Now kick off ATA set up */ 362 /* Now kick off ATA set up */
367 return ata_pci_init_one(pdev, port_info, 2); 363 return ata_pci_init_one(pdev, ppi);
368} 364}
369 365
370#ifdef CONFIG_PM 366#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c
index 22006ae71941..f37d4cd812a1 100644
--- a/drivers/ata/pata_cs5535.c
+++ b/drivers/ata/pata_cs5535.c
@@ -173,10 +173,6 @@ static struct scsi_host_template cs5535_sht = {
173 .slave_configure = ata_scsi_slave_config, 173 .slave_configure = ata_scsi_slave_config,
174 .slave_destroy = ata_scsi_slave_destroy, 174 .slave_destroy = ata_scsi_slave_destroy,
175 .bios_param = ata_std_bios_param, 175 .bios_param = ata_std_bios_param,
176#ifdef CONFIG_PM
177 .resume = ata_scsi_device_resume,
178 .suspend = ata_scsi_device_suspend,
179#endif
180}; 176};
181 177
182static struct ata_port_operations cs5535_port_ops = { 178static struct ata_port_operations cs5535_port_ops = {
@@ -227,7 +223,7 @@ static struct ata_port_operations cs5535_port_ops = {
227 223
228static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id) 224static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id)
229{ 225{
230 static struct ata_port_info info = { 226 static const struct ata_port_info info = {
231 .sht = &cs5535_sht, 227 .sht = &cs5535_sht,
232 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 228 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
233 .pio_mask = 0x1f, 229 .pio_mask = 0x1f,
@@ -235,7 +231,7 @@ static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id)
235 .udma_mask = 0x1f, 231 .udma_mask = 0x1f,
236 .port_ops = &cs5535_port_ops 232 .port_ops = &cs5535_port_ops
237 }; 233 };
238 struct ata_port_info *ports[1] = { &info }; 234 const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info };
239 235
240 u32 timings, dummy; 236 u32 timings, dummy;
241 237
@@ -247,7 +243,7 @@ static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id)
247 rdmsr(ATAC_CH0D1_PIO, timings, dummy); 243 rdmsr(ATAC_CH0D1_PIO, timings, dummy);
248 if (CS5535_BAD_PIO(timings)) 244 if (CS5535_BAD_PIO(timings))
249 wrmsr(ATAC_CH0D1_PIO, 0xF7F4F7F4UL, 0); 245 wrmsr(ATAC_CH0D1_PIO, 0xF7F4F7F4UL, 0);
250 return ata_pci_init_one(dev, ports, 1); 246 return ata_pci_init_one(dev, ppi);
251} 247}
252 248
253static const struct pci_device_id cs5535[] = { 249static const struct pci_device_id cs5535[] = {
diff --git a/drivers/ata/pata_cypress.c b/drivers/ata/pata_cypress.c
index 6ec049c3b1dc..27b9f29c01e3 100644
--- a/drivers/ata/pata_cypress.c
+++ b/drivers/ata/pata_cypress.c
@@ -125,10 +125,6 @@ static struct scsi_host_template cy82c693_sht = {
125 .slave_configure = ata_scsi_slave_config, 125 .slave_configure = ata_scsi_slave_config,
126 .slave_destroy = ata_scsi_slave_destroy, 126 .slave_destroy = ata_scsi_slave_destroy,
127 .bios_param = ata_std_bios_param, 127 .bios_param = ata_std_bios_param,
128#ifdef CONFIG_PM
129 .resume = ata_scsi_device_resume,
130 .suspend = ata_scsi_device_suspend,
131#endif
132}; 128};
133 129
134static struct ata_port_operations cy82c693_port_ops = { 130static struct ata_port_operations cy82c693_port_ops = {
@@ -169,14 +165,14 @@ static struct ata_port_operations cy82c693_port_ops = {
169 165
170static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 166static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
171{ 167{
172 static struct ata_port_info info = { 168 static const struct ata_port_info info = {
173 .sht = &cy82c693_sht, 169 .sht = &cy82c693_sht,
174 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 170 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
175 .pio_mask = 0x1f, 171 .pio_mask = 0x1f,
176 .mwdma_mask = 0x07, 172 .mwdma_mask = 0x07,
177 .port_ops = &cy82c693_port_ops 173 .port_ops = &cy82c693_port_ops
178 }; 174 };
179 static struct ata_port_info *port_info[1] = { &info }; 175 const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info };
180 176
181 /* Devfn 1 is the ATA primary. The secondary is magic and on devfn2. 177 /* Devfn 1 is the ATA primary. The secondary is magic and on devfn2.
182 For the moment we don't handle the secondary. FIXME */ 178 For the moment we don't handle the secondary. FIXME */
@@ -184,7 +180,7 @@ static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *i
184 if (PCI_FUNC(pdev->devfn) != 1) 180 if (PCI_FUNC(pdev->devfn) != 1)
185 return -ENODEV; 181 return -ENODEV;
186 182
187 return ata_pci_init_one(pdev, port_info, 1); 183 return ata_pci_init_one(pdev, ppi);
188} 184}
189 185
190static const struct pci_device_id cy82c693[] = { 186static const struct pci_device_id cy82c693[] = {
diff --git a/drivers/ata/pata_efar.c b/drivers/ata/pata_efar.c
index d0f52e034906..079248a9b460 100644
--- a/drivers/ata/pata_efar.c
+++ b/drivers/ata/pata_efar.c
@@ -247,10 +247,6 @@ static struct scsi_host_template efar_sht = {
247 .slave_configure = ata_scsi_slave_config, 247 .slave_configure = ata_scsi_slave_config,
248 .slave_destroy = ata_scsi_slave_destroy, 248 .slave_destroy = ata_scsi_slave_destroy,
249 .bios_param = ata_std_bios_param, 249 .bios_param = ata_std_bios_param,
250#ifdef CONFIG_PM
251 .resume = ata_scsi_device_resume,
252 .suspend = ata_scsi_device_suspend,
253#endif
254}; 250};
255 251
256static const struct ata_port_operations efar_ops = { 252static const struct ata_port_operations efar_ops = {
@@ -305,7 +301,7 @@ static const struct ata_port_operations efar_ops = {
305static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 301static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
306{ 302{
307 static int printed_version; 303 static int printed_version;
308 static struct ata_port_info info = { 304 static const struct ata_port_info info = {
309 .sht = &efar_sht, 305 .sht = &efar_sht,
310 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 306 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
311 .pio_mask = 0x1f, /* pio0-4 */ 307 .pio_mask = 0x1f, /* pio0-4 */
@@ -313,13 +309,13 @@ static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
313 .udma_mask = 0x0f, /* UDMA 66 */ 309 .udma_mask = 0x0f, /* UDMA 66 */
314 .port_ops = &efar_ops, 310 .port_ops = &efar_ops,
315 }; 311 };
316 static struct ata_port_info *port_info[2] = { &info, &info }; 312 const struct ata_port_info *ppi[] = { &info, NULL };
317 313
318 if (!printed_version++) 314 if (!printed_version++)
319 dev_printk(KERN_DEBUG, &pdev->dev, 315 dev_printk(KERN_DEBUG, &pdev->dev,
320 "version " DRV_VERSION "\n"); 316 "version " DRV_VERSION "\n");
321 317
322 return ata_pci_init_one(pdev, port_info, 2); 318 return ata_pci_init_one(pdev, ppi);
323} 319}
324 320
325static const struct pci_device_id efar_pci_tbl[] = { 321static const struct pci_device_id efar_pci_tbl[] = {
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index e64e05e5c7fe..c6c8a8bb06d0 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -331,10 +331,6 @@ static struct scsi_host_template hpt36x_sht = {
331 .slave_configure = ata_scsi_slave_config, 331 .slave_configure = ata_scsi_slave_config,
332 .slave_destroy = ata_scsi_slave_destroy, 332 .slave_destroy = ata_scsi_slave_destroy,
333 .bios_param = ata_std_bios_param, 333 .bios_param = ata_std_bios_param,
334#ifdef CONFIG_PM
335 .resume = ata_scsi_device_resume,
336 .suspend = ata_scsi_device_suspend,
337#endif
338}; 334};
339 335
340/* 336/*
@@ -421,7 +417,7 @@ static void hpt36x_init_chipset(struct pci_dev *dev)
421 417
422static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id) 418static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
423{ 419{
424 static struct ata_port_info info_hpt366 = { 420 static const struct ata_port_info info_hpt366 = {
425 .sht = &hpt36x_sht, 421 .sht = &hpt36x_sht,
426 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 422 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
427 .pio_mask = 0x1f, 423 .pio_mask = 0x1f,
@@ -429,7 +425,8 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
429 .udma_mask = 0x1f, 425 .udma_mask = 0x1f,
430 .port_ops = &hpt366_port_ops 426 .port_ops = &hpt366_port_ops
431 }; 427 };
432 struct ata_port_info *port_info[2] = {&info_hpt366, &info_hpt366}; 428 struct ata_port_info info = info_hpt366;
429 const struct ata_port_info *ppi[] = { &info, NULL };
433 430
434 u32 class_rev; 431 u32 class_rev;
435 u32 reg1; 432 u32 reg1;
@@ -450,17 +447,17 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
450 /* info_hpt366 is safe against re-entry so we can scribble on it */ 447 /* info_hpt366 is safe against re-entry so we can scribble on it */
451 switch((reg1 & 0x700) >> 8) { 448 switch((reg1 & 0x700) >> 8) {
452 case 5: 449 case 5:
453 info_hpt366.private_data = &hpt366_40; 450 info.private_data = &hpt366_40;
454 break; 451 break;
455 case 9: 452 case 9:
456 info_hpt366.private_data = &hpt366_25; 453 info.private_data = &hpt366_25;
457 break; 454 break;
458 default: 455 default:
459 info_hpt366.private_data = &hpt366_33; 456 info.private_data = &hpt366_33;
460 break; 457 break;
461 } 458 }
462 /* Now kick off ATA set up */ 459 /* Now kick off ATA set up */
463 return ata_pci_init_one(dev, port_info, 2); 460 return ata_pci_init_one(dev, ppi);
464} 461}
465 462
466#ifdef CONFIG_PM 463#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 1614e8c822a4..5a0a410654e2 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -887,7 +887,7 @@ static int hpt37x_calibrate_dpll(struct pci_dev *dev)
887static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) 887static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
888{ 888{
889 /* HPT370 - UDMA100 */ 889 /* HPT370 - UDMA100 */
890 static struct ata_port_info info_hpt370 = { 890 static const struct ata_port_info info_hpt370 = {
891 .sht = &hpt37x_sht, 891 .sht = &hpt37x_sht,
892 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 892 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
893 .pio_mask = 0x1f, 893 .pio_mask = 0x1f,
@@ -896,7 +896,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
896 .port_ops = &hpt370_port_ops 896 .port_ops = &hpt370_port_ops
897 }; 897 };
898 /* HPT370A - UDMA100 */ 898 /* HPT370A - UDMA100 */
899 static struct ata_port_info info_hpt370a = { 899 static const struct ata_port_info info_hpt370a = {
900 .sht = &hpt37x_sht, 900 .sht = &hpt37x_sht,
901 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 901 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
902 .pio_mask = 0x1f, 902 .pio_mask = 0x1f,
@@ -905,7 +905,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
905 .port_ops = &hpt370a_port_ops 905 .port_ops = &hpt370a_port_ops
906 }; 906 };
907 /* HPT370 - UDMA100 */ 907 /* HPT370 - UDMA100 */
908 static struct ata_port_info info_hpt370_33 = { 908 static const struct ata_port_info info_hpt370_33 = {
909 .sht = &hpt37x_sht, 909 .sht = &hpt37x_sht,
910 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 910 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
911 .pio_mask = 0x1f, 911 .pio_mask = 0x1f,
@@ -914,7 +914,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
914 .port_ops = &hpt370_port_ops 914 .port_ops = &hpt370_port_ops
915 }; 915 };
916 /* HPT370A - UDMA100 */ 916 /* HPT370A - UDMA100 */
917 static struct ata_port_info info_hpt370a_33 = { 917 static const struct ata_port_info info_hpt370a_33 = {
918 .sht = &hpt37x_sht, 918 .sht = &hpt37x_sht,
919 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 919 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
920 .pio_mask = 0x1f, 920 .pio_mask = 0x1f,
@@ -923,7 +923,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
923 .port_ops = &hpt370a_port_ops 923 .port_ops = &hpt370a_port_ops
924 }; 924 };
925 /* HPT371, 372 and friends - UDMA133 */ 925 /* HPT371, 372 and friends - UDMA133 */
926 static struct ata_port_info info_hpt372 = { 926 static const struct ata_port_info info_hpt372 = {
927 .sht = &hpt37x_sht, 927 .sht = &hpt37x_sht,
928 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 928 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
929 .pio_mask = 0x1f, 929 .pio_mask = 0x1f,
@@ -932,7 +932,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
932 .port_ops = &hpt372_port_ops 932 .port_ops = &hpt372_port_ops
933 }; 933 };
934 /* HPT371, 372 and friends - UDMA100 at 50MHz clock */ 934 /* HPT371, 372 and friends - UDMA100 at 50MHz clock */
935 static struct ata_port_info info_hpt372_50 = { 935 static const struct ata_port_info info_hpt372_50 = {
936 .sht = &hpt37x_sht, 936 .sht = &hpt37x_sht,
937 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 937 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
938 .pio_mask = 0x1f, 938 .pio_mask = 0x1f,
@@ -941,7 +941,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
941 .port_ops = &hpt372_port_ops 941 .port_ops = &hpt372_port_ops
942 }; 942 };
943 /* HPT374 - UDMA133 */ 943 /* HPT374 - UDMA133 */
944 static struct ata_port_info info_hpt374 = { 944 static const struct ata_port_info info_hpt374 = {
945 .sht = &hpt37x_sht, 945 .sht = &hpt37x_sht,
946 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 946 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
947 .pio_mask = 0x1f, 947 .pio_mask = 0x1f,
@@ -951,9 +951,10 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
951 }; 951 };
952 952
953 static const int MHz[4] = { 33, 40, 50, 66 }; 953 static const int MHz[4] = { 33, 40, 50, 66 };
954 954 const struct ata_port_info *port;
955 struct ata_port_info *port_info[2]; 955 void *private_data = NULL;
956 struct ata_port_info *port; 956 struct ata_port_info port_info;
957 const struct ata_port_info *ppi[] = { &port_info, NULL };
957 958
958 u8 irqmask; 959 u8 irqmask;
959 u32 class_rev; 960 u32 class_rev;
@@ -1124,13 +1125,13 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1124 return -ENODEV; 1125 return -ENODEV;
1125 } 1126 }
1126 if (clock_slot == 3) 1127 if (clock_slot == 3)
1127 port->private_data = (void *)hpt37x_timings_66; 1128 private_data = (void *)hpt37x_timings_66;
1128 else 1129 else
1129 port->private_data = (void *)hpt37x_timings_50; 1130 private_data = (void *)hpt37x_timings_50;
1130 1131
1131 printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[clock_slot]); 1132 printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[clock_slot]);
1132 } else { 1133 } else {
1133 port->private_data = (void *)chip_table->clocks[clock_slot]; 1134 private_data = (void *)chip_table->clocks[clock_slot];
1134 /* 1135 /*
1135 * Perform a final fixup. Note that we will have used the 1136 * Perform a final fixup. Note that we will have used the
1136 * DPLL on the HPT372 which means we don't have to worry 1137 * DPLL on the HPT372 which means we don't have to worry
@@ -1144,9 +1145,11 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1144 printk(KERN_INFO "hpt37x: %s: Bus clock %dMHz.\n", chip_table->name, MHz[clock_slot]); 1145 printk(KERN_INFO "hpt37x: %s: Bus clock %dMHz.\n", chip_table->name, MHz[clock_slot]);
1145 } 1146 }
1146 1147
1147 port_info[0] = port_info[1] = port;
1148 /* Now kick off ATA set up */ 1148 /* Now kick off ATA set up */
1149 return ata_pci_init_one(dev, port_info, 2); 1149 port_info = *port;
1150 port_info.private_data = private_data;
1151
1152 return ata_pci_init_one(dev, ppi);
1150} 1153}
1151 1154
1152static const struct pci_device_id hpt37x[] = { 1155static const struct pci_device_id hpt37x[] = {
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c
index ea1037d67860..f25154aed75d 100644
--- a/drivers/ata/pata_hpt3x2n.c
+++ b/drivers/ata/pata_hpt3x2n.c
@@ -488,7 +488,7 @@ static int hpt3x2n_pci_clock(struct pci_dev *pdev)
488static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) 488static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
489{ 489{
490 /* HPT372N and friends - UDMA133 */ 490 /* HPT372N and friends - UDMA133 */
491 static struct ata_port_info info = { 491 static const struct ata_port_info info = {
492 .sht = &hpt3x2n_sht, 492 .sht = &hpt3x2n_sht,
493 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 493 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
494 .pio_mask = 0x1f, 494 .pio_mask = 0x1f,
@@ -496,8 +496,8 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
496 .udma_mask = 0x7f, 496 .udma_mask = 0x7f,
497 .port_ops = &hpt3x2n_port_ops 497 .port_ops = &hpt3x2n_port_ops
498 }; 498 };
499 struct ata_port_info *port_info[2]; 499 struct ata_port_info port = info;
500 struct ata_port_info *port = &info; 500 const struct ata_port_info *ppi[] = { &port, NULL };
501 501
502 u8 irqmask; 502 u8 irqmask;
503 u32 class_rev; 503 u32 class_rev;
@@ -585,9 +585,9 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
585 585
586 /* Set our private data up. We only need a few flags so we use 586 /* Set our private data up. We only need a few flags so we use
587 it directly */ 587 it directly */
588 port->private_data = NULL; 588 port.private_data = NULL;
589 if (pci_mhz > 60) { 589 if (pci_mhz > 60) {
590 port->private_data = (void *)PCI66; 590 port.private_data = (void *)PCI66;
591 /* 591 /*
592 * On HPT371N, if ATA clock is 66 MHz we must set bit 2 in 592 * On HPT371N, if ATA clock is 66 MHz we must set bit 2 in
593 * the MISC. register to stretch the UltraDMA Tss timing. 593 * the MISC. register to stretch the UltraDMA Tss timing.
@@ -598,8 +598,7 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
598 } 598 }
599 599
600 /* Now kick off ATA set up */ 600 /* Now kick off ATA set up */
601 port_info[0] = port_info[1] = port; 601 return ata_pci_init_one(dev, ppi);
602 return ata_pci_init_one(dev, port_info, 2);
603} 602}
604 603
605static const struct pci_device_id hpt3x2n[] = { 604static const struct pci_device_id hpt3x2n[] = {
diff --git a/drivers/ata/pata_hpt3x3.c b/drivers/ata/pata_hpt3x3.c
index ac28ec8c50aa..bbabe7902fbb 100644
--- a/drivers/ata/pata_hpt3x3.c
+++ b/drivers/ata/pata_hpt3x3.c
@@ -100,10 +100,6 @@ static struct scsi_host_template hpt3x3_sht = {
100 .slave_configure = ata_scsi_slave_config, 100 .slave_configure = ata_scsi_slave_config,
101 .slave_destroy = ata_scsi_slave_destroy, 101 .slave_destroy = ata_scsi_slave_destroy,
102 .bios_param = ata_std_bios_param, 102 .bios_param = ata_std_bios_param,
103#ifdef CONFIG_PM
104 .resume = ata_scsi_device_resume,
105 .suspend = ata_scsi_device_suspend,
106#endif
107}; 103};
108 104
109static struct ata_port_operations hpt3x3_port_ops = { 105static struct ata_port_operations hpt3x3_port_ops = {
@@ -175,7 +171,7 @@ static void hpt3x3_init_chipset(struct pci_dev *dev)
175 171
176static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id) 172static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id)
177{ 173{
178 static struct ata_port_info info = { 174 static const struct ata_port_info info = {
179 .sht = &hpt3x3_sht, 175 .sht = &hpt3x3_sht,
180 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 176 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
181 .pio_mask = 0x1f, 177 .pio_mask = 0x1f,
@@ -183,11 +179,11 @@ static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id)
183 .udma_mask = 0x07, 179 .udma_mask = 0x07,
184 .port_ops = &hpt3x3_port_ops 180 .port_ops = &hpt3x3_port_ops
185 }; 181 };
186 static struct ata_port_info *port_info[2] = { &info, &info }; 182 const struct ata_port_info *ppi[] = { &info, NULL };
187 183
188 hpt3x3_init_chipset(dev); 184 hpt3x3_init_chipset(dev);
189 /* Now kick off ATA set up */ 185 /* Now kick off ATA set up */
190 return ata_pci_init_one(dev, port_info, 2); 186 return ata_pci_init_one(dev, ppi);
191} 187}
192 188
193#ifdef CONFIG_PM 189#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_it8213.c b/drivers/ata/pata_it8213.c
index 17bf9f3ed013..a769952646e1 100644
--- a/drivers/ata/pata_it8213.c
+++ b/drivers/ata/pata_it8213.c
@@ -257,10 +257,6 @@ static struct scsi_host_template it8213_sht = {
257 .dma_boundary = ATA_DMA_BOUNDARY, 257 .dma_boundary = ATA_DMA_BOUNDARY,
258 .slave_configure = ata_scsi_slave_config, 258 .slave_configure = ata_scsi_slave_config,
259 .bios_param = ata_std_bios_param, 259 .bios_param = ata_std_bios_param,
260#ifdef CONFIG_PM
261 .resume = ata_scsi_device_resume,
262 .suspend = ata_scsi_device_suspend,
263#endif
264}; 260};
265 261
266static const struct ata_port_operations it8213_ops = { 262static const struct ata_port_operations it8213_ops = {
@@ -315,7 +311,7 @@ static const struct ata_port_operations it8213_ops = {
315static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 311static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
316{ 312{
317 static int printed_version; 313 static int printed_version;
318 static struct ata_port_info info = { 314 static const struct ata_port_info info = {
319 .sht = &it8213_sht, 315 .sht = &it8213_sht,
320 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 316 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
321 .pio_mask = 0x1f, /* pio0-4 */ 317 .pio_mask = 0x1f, /* pio0-4 */
@@ -323,14 +319,14 @@ static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *en
323 .udma_mask = 0x1f, /* UDMA 100 */ 319 .udma_mask = 0x1f, /* UDMA 100 */
324 .port_ops = &it8213_ops, 320 .port_ops = &it8213_ops,
325 }; 321 };
326 static struct ata_port_info *port_info[2] = { &info, &info }; 322 /* Current IT8213 stuff is single port */
323 const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info };
327 324
328 if (!printed_version++) 325 if (!printed_version++)
329 dev_printk(KERN_DEBUG, &pdev->dev, 326 dev_printk(KERN_DEBUG, &pdev->dev,
330 "version " DRV_VERSION "\n"); 327 "version " DRV_VERSION "\n");
331 328
332 /* Current IT8213 stuff is single port */ 329 return ata_pci_init_one(pdev, ppi);
333 return ata_pci_init_one(pdev, port_info, 1);
334} 330}
335 331
336static const struct pci_device_id it8213_pci_tbl[] = { 332static const struct pci_device_id it8213_pci_tbl[] = {
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index f1f8cec8c224..ff9a6fd36657 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -620,10 +620,6 @@ static struct scsi_host_template it821x_sht = {
620 .slave_configure = ata_scsi_slave_config, 620 .slave_configure = ata_scsi_slave_config,
621 .slave_destroy = ata_scsi_slave_destroy, 621 .slave_destroy = ata_scsi_slave_destroy,
622 .bios_param = ata_std_bios_param, 622 .bios_param = ata_std_bios_param,
623#ifdef CONFIG_PM
624 .resume = ata_scsi_device_resume,
625 .suspend = ata_scsi_device_suspend,
626#endif
627}; 623};
628 624
629static struct ata_port_operations it821x_smart_port_ops = { 625static struct ata_port_operations it821x_smart_port_ops = {
@@ -722,14 +718,14 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
722{ 718{
723 u8 conf; 719 u8 conf;
724 720
725 static struct ata_port_info info_smart = { 721 static const struct ata_port_info info_smart = {
726 .sht = &it821x_sht, 722 .sht = &it821x_sht,
727 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 723 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
728 .pio_mask = 0x1f, 724 .pio_mask = 0x1f,
729 .mwdma_mask = 0x07, 725 .mwdma_mask = 0x07,
730 .port_ops = &it821x_smart_port_ops 726 .port_ops = &it821x_smart_port_ops
731 }; 727 };
732 static struct ata_port_info info_passthru = { 728 static const struct ata_port_info info_passthru = {
733 .sht = &it821x_sht, 729 .sht = &it821x_sht,
734 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 730 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
735 .pio_mask = 0x1f, 731 .pio_mask = 0x1f,
@@ -737,8 +733,8 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
737 .udma_mask = 0x7f, 733 .udma_mask = 0x7f,
738 .port_ops = &it821x_passthru_port_ops 734 .port_ops = &it821x_passthru_port_ops
739 }; 735 };
740 static struct ata_port_info *port_info[2];
741 736
737 const struct ata_port_info *ppi[] = { NULL, NULL };
742 static char *mode[2] = { "pass through", "smart" }; 738 static char *mode[2] = { "pass through", "smart" };
743 739
744 /* Force the card into bypass mode if so requested */ 740 /* Force the card into bypass mode if so requested */
@@ -751,11 +747,11 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
751 747
752 printk(KERN_INFO DRV_NAME ": controller in %s mode.\n", mode[conf]); 748 printk(KERN_INFO DRV_NAME ": controller in %s mode.\n", mode[conf]);
753 if (conf == 0) 749 if (conf == 0)
754 port_info[0] = port_info[1] = &info_passthru; 750 ppi[0] = &info_passthru;
755 else 751 else
756 port_info[0] = port_info[1] = &info_smart; 752 ppi[0] = &info_smart;
757 753
758 return ata_pci_init_one(pdev, port_info, 2); 754 return ata_pci_init_one(pdev, ppi);
759} 755}
760 756
761#ifdef CONFIG_PM 757#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
index 420c343e5711..b994351fbcd0 100644
--- a/drivers/ata/pata_ixp4xx_cf.c
+++ b/drivers/ata/pata_ixp4xx_cf.c
@@ -31,7 +31,7 @@ static int ixp4xx_set_mode(struct ata_port *ap, struct ata_device **error)
31 31
32 for (i = 0; i < ATA_MAX_DEVICES; i++) { 32 for (i = 0; i < ATA_MAX_DEVICES; i++) {
33 struct ata_device *dev = &ap->device[i]; 33 struct ata_device *dev = &ap->device[i];
34 if (ata_dev_ready(dev)) { 34 if (ata_dev_enabled(dev)) {
35 ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n"); 35 ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n");
36 dev->pio_mode = XFER_PIO_0; 36 dev->pio_mode = XFER_PIO_0;
37 dev->xfer_mode = XFER_PIO_0; 37 dev->xfer_mode = XFER_PIO_0;
diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c
index 1daf78ac6efb..8d799e87f752 100644
--- a/drivers/ata/pata_jmicron.c
+++ b/drivers/ata/pata_jmicron.c
@@ -138,10 +138,6 @@ static struct scsi_host_template jmicron_sht = {
138 .slave_destroy = ata_scsi_slave_destroy, 138 .slave_destroy = ata_scsi_slave_destroy,
139 /* Use standard CHS mapping rules */ 139 /* Use standard CHS mapping rules */
140 .bios_param = ata_std_bios_param, 140 .bios_param = ata_std_bios_param,
141#ifdef CONFIG_PM
142 .suspend = ata_scsi_device_suspend,
143 .resume = ata_scsi_device_resume,
144#endif
145}; 141};
146 142
147static const struct ata_port_operations jmicron_ops = { 143static const struct ata_port_operations jmicron_ops = {
@@ -195,7 +191,7 @@ static const struct ata_port_operations jmicron_ops = {
195 191
196static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *id) 192static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
197{ 193{
198 static struct ata_port_info info = { 194 static const struct ata_port_info info = {
199 .sht = &jmicron_sht, 195 .sht = &jmicron_sht,
200 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 196 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
201 197
@@ -205,9 +201,9 @@ static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *i
205 201
206 .port_ops = &jmicron_ops, 202 .port_ops = &jmicron_ops,
207 }; 203 };
208 struct ata_port_info *port_info[2] = { &info, &info }; 204 const struct ata_port_info *ppi[] = { &info, NULL };
209 205
210 return ata_pci_init_one(pdev, port_info, 2); 206 return ata_pci_init_one(pdev, ppi);
211} 207}
212 208
213static const struct pci_device_id jmicron_pci_tbl[] = { 209static const struct pci_device_id jmicron_pci_tbl[] = {
diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c
index 837b7fe77dc7..edbfe0dbbf78 100644
--- a/drivers/ata/pata_marvell.c
+++ b/drivers/ata/pata_marvell.c
@@ -107,10 +107,6 @@ static struct scsi_host_template marvell_sht = {
107 .slave_destroy = ata_scsi_slave_destroy, 107 .slave_destroy = ata_scsi_slave_destroy,
108 /* Use standard CHS mapping rules */ 108 /* Use standard CHS mapping rules */
109 .bios_param = ata_std_bios_param, 109 .bios_param = ata_std_bios_param,
110#ifdef CONFIG_PM
111 .resume = ata_scsi_device_resume,
112 .suspend = ata_scsi_device_suspend,
113#endif
114}; 110};
115 111
116static const struct ata_port_operations marvell_ops = { 112static const struct ata_port_operations marvell_ops = {
@@ -165,7 +161,7 @@ static const struct ata_port_operations marvell_ops = {
165 161
166static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *id) 162static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
167{ 163{
168 static struct ata_port_info info = { 164 static const struct ata_port_info info = {
169 .sht = &marvell_sht, 165 .sht = &marvell_sht,
170 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 166 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
171 167
@@ -175,7 +171,7 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i
175 171
176 .port_ops = &marvell_ops, 172 .port_ops = &marvell_ops,
177 }; 173 };
178 static struct ata_port_info info_sata = { 174 static const struct ata_port_info info_sata = {
179 .sht = &marvell_sht, 175 .sht = &marvell_sht,
180 /* Slave possible as its magically mapped not real */ 176 /* Slave possible as its magically mapped not real */
181 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 177 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
@@ -186,13 +182,12 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i
186 182
187 .port_ops = &marvell_ops, 183 .port_ops = &marvell_ops,
188 }; 184 };
189 struct ata_port_info *port_info[2] = { &info, &info_sata }; 185 const struct ata_port_info *ppi[] = { &info, &info_sata };
190 int n_port = 2;
191 186
192 if (pdev->device == 0x6101) 187 if (pdev->device == 0x6101)
193 n_port = 1; 188 ppi[1] = &ata_dummy_port_info;
194 189
195 return ata_pci_init_one(pdev, port_info, n_port); 190 return ata_pci_init_one(pdev, ppi);
196} 191}
197 192
198static const struct pci_device_id marvell_pci_tbl[] = { 193static const struct pci_device_id marvell_pci_tbl[] = {
diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c
index 9587a89f9683..368fac7d168b 100644
--- a/drivers/ata/pata_mpc52xx.c
+++ b/drivers/ata/pata_mpc52xx.c
@@ -280,10 +280,6 @@ static struct scsi_host_template mpc52xx_ata_sht = {
280 .dma_boundary = ATA_DMA_BOUNDARY, 280 .dma_boundary = ATA_DMA_BOUNDARY,
281 .slave_configure = ata_scsi_slave_config, 281 .slave_configure = ata_scsi_slave_config,
282 .bios_param = ata_std_bios_param, 282 .bios_param = ata_std_bios_param,
283#ifdef CONFIG_PM
284 .suspend = ata_scsi_device_suspend,
285 .resume = ata_scsi_device_resume,
286#endif
287}; 283};
288 284
289static struct ata_port_operations mpc52xx_ata_port_ops = { 285static struct ata_port_operations mpc52xx_ata_port_ops = {
diff --git a/drivers/ata/pata_mpiix.c b/drivers/ata/pata_mpiix.c
index 3bfbd495f643..4ea42838297e 100644
--- a/drivers/ata/pata_mpiix.c
+++ b/drivers/ata/pata_mpiix.c
@@ -165,10 +165,6 @@ static struct scsi_host_template mpiix_sht = {
165 .slave_configure = ata_scsi_slave_config, 165 .slave_configure = ata_scsi_slave_config,
166 .slave_destroy = ata_scsi_slave_destroy, 166 .slave_destroy = ata_scsi_slave_destroy,
167 .bios_param = ata_std_bios_param, 167 .bios_param = ata_std_bios_param,
168#ifdef CONFIG_PM
169 .resume = ata_scsi_device_resume,
170 .suspend = ata_scsi_device_suspend,
171#endif
172}; 168};
173 169
174static struct ata_port_operations mpiix_port_ops = { 170static struct ata_port_operations mpiix_port_ops = {
diff --git a/drivers/ata/pata_netcell.c b/drivers/ata/pata_netcell.c
index dbba5b77d79c..81f563458666 100644
--- a/drivers/ata/pata_netcell.c
+++ b/drivers/ata/pata_netcell.c
@@ -37,10 +37,6 @@ static struct scsi_host_template netcell_sht = {
37 .slave_destroy = ata_scsi_slave_destroy, 37 .slave_destroy = ata_scsi_slave_destroy,
38 /* Use standard CHS mapping rules */ 38 /* Use standard CHS mapping rules */
39 .bios_param = ata_std_bios_param, 39 .bios_param = ata_std_bios_param,
40#ifdef CONFIG_PM
41 .resume = ata_scsi_device_resume,
42 .suspend = ata_scsi_device_suspend,
43#endif
44}; 40};
45 41
46static const struct ata_port_operations netcell_ops = { 42static const struct ata_port_operations netcell_ops = {
@@ -96,7 +92,7 @@ static const struct ata_port_operations netcell_ops = {
96static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 92static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
97{ 93{
98 static int printed_version; 94 static int printed_version;
99 static struct ata_port_info info = { 95 static const struct ata_port_info info = {
100 .sht = &netcell_sht, 96 .sht = &netcell_sht,
101 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 97 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
102 /* Actually we don't really care about these as the 98 /* Actually we don't really care about these as the
@@ -106,7 +102,7 @@ static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *e
106 .udma_mask = 0x3f, /* UDMA 133 */ 102 .udma_mask = 0x3f, /* UDMA 133 */
107 .port_ops = &netcell_ops, 103 .port_ops = &netcell_ops,
108 }; 104 };
109 static struct ata_port_info *port_info[2] = { &info, &info }; 105 const struct ata_port_info *port_info[] = { &info, NULL };
110 106
111 if (!printed_version++) 107 if (!printed_version++)
112 dev_printk(KERN_DEBUG, &pdev->dev, 108 dev_printk(KERN_DEBUG, &pdev->dev,
@@ -116,7 +112,7 @@ static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *e
116 ata_pci_clear_simplex(pdev); 112 ata_pci_clear_simplex(pdev);
117 113
118 /* And let the library code do the work */ 114 /* And let the library code do the work */
119 return ata_pci_init_one(pdev, port_info, 2); 115 return ata_pci_init_one(pdev, port_info);
120} 116}
121 117
122static const struct pci_device_id netcell_pci_tbl[] = { 118static const struct pci_device_id netcell_pci_tbl[] = {
diff --git a/drivers/ata/pata_ns87410.c b/drivers/ata/pata_ns87410.c
index ebc58a907d26..ea70ec744879 100644
--- a/drivers/ata/pata_ns87410.c
+++ b/drivers/ata/pata_ns87410.c
@@ -158,10 +158,6 @@ static struct scsi_host_template ns87410_sht = {
158 .slave_configure = ata_scsi_slave_config, 158 .slave_configure = ata_scsi_slave_config,
159 .slave_destroy = ata_scsi_slave_destroy, 159 .slave_destroy = ata_scsi_slave_destroy,
160 .bios_param = ata_std_bios_param, 160 .bios_param = ata_std_bios_param,
161#ifdef CONFIG_PM
162 .resume = ata_scsi_device_resume,
163 .suspend = ata_scsi_device_suspend,
164#endif
165}; 161};
166 162
167static struct ata_port_operations ns87410_port_ops = { 163static struct ata_port_operations ns87410_port_ops = {
@@ -195,14 +191,14 @@ static struct ata_port_operations ns87410_port_ops = {
195 191
196static int ns87410_init_one(struct pci_dev *dev, const struct pci_device_id *id) 192static int ns87410_init_one(struct pci_dev *dev, const struct pci_device_id *id)
197{ 193{
198 static struct ata_port_info info = { 194 static const struct ata_port_info info = {
199 .sht = &ns87410_sht, 195 .sht = &ns87410_sht,
200 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 196 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
201 .pio_mask = 0x0F, 197 .pio_mask = 0x0F,
202 .port_ops = &ns87410_port_ops 198 .port_ops = &ns87410_port_ops
203 }; 199 };
204 static struct ata_port_info *port_info[2] = {&info, &info}; 200 const struct ata_port_info *ppi[] = { &info, NULL };
205 return ata_pci_init_one(dev, port_info, 2); 201 return ata_pci_init_one(dev, ppi);
206} 202}
207 203
208static const struct pci_device_id ns87410[] = { 204static const struct pci_device_id ns87410[] = {
diff --git a/drivers/ata/pata_oldpiix.c b/drivers/ata/pata_oldpiix.c
index 4d75d32e5826..29c23ddd6550 100644
--- a/drivers/ata/pata_oldpiix.c
+++ b/drivers/ata/pata_oldpiix.c
@@ -234,10 +234,6 @@ static struct scsi_host_template oldpiix_sht = {
234 .slave_configure = ata_scsi_slave_config, 234 .slave_configure = ata_scsi_slave_config,
235 .slave_destroy = ata_scsi_slave_destroy, 235 .slave_destroy = ata_scsi_slave_destroy,
236 .bios_param = ata_std_bios_param, 236 .bios_param = ata_std_bios_param,
237#ifdef CONFIG_PM
238 .resume = ata_scsi_device_resume,
239 .suspend = ata_scsi_device_suspend,
240#endif
241}; 237};
242 238
243static const struct ata_port_operations oldpiix_pata_ops = { 239static const struct ata_port_operations oldpiix_pata_ops = {
@@ -293,20 +289,20 @@ static const struct ata_port_operations oldpiix_pata_ops = {
293static int oldpiix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 289static int oldpiix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
294{ 290{
295 static int printed_version; 291 static int printed_version;
296 static struct ata_port_info info = { 292 static const struct ata_port_info info = {
297 .sht = &oldpiix_sht, 293 .sht = &oldpiix_sht,
298 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 294 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
299 .pio_mask = 0x1f, /* pio0-4 */ 295 .pio_mask = 0x1f, /* pio0-4 */
300 .mwdma_mask = 0x07, /* mwdma1-2 */ 296 .mwdma_mask = 0x07, /* mwdma1-2 */
301 .port_ops = &oldpiix_pata_ops, 297 .port_ops = &oldpiix_pata_ops,
302 }; 298 };
303 static struct ata_port_info *port_info[2] = { &info, &info }; 299 const struct ata_port_info *ppi[] = { &info, NULL };
304 300
305 if (!printed_version++) 301 if (!printed_version++)
306 dev_printk(KERN_DEBUG, &pdev->dev, 302 dev_printk(KERN_DEBUG, &pdev->dev,
307 "version " DRV_VERSION "\n"); 303 "version " DRV_VERSION "\n");
308 304
309 return ata_pci_init_one(pdev, port_info, 2); 305 return ata_pci_init_one(pdev, ppi);
310} 306}
311 307
312static const struct pci_device_id oldpiix_pci_tbl[] = { 308static const struct pci_device_id oldpiix_pci_tbl[] = {
diff --git a/drivers/ata/pata_opti.c b/drivers/ata/pata_opti.c
index 0af8a2c77cc9..1c44653e1e06 100644
--- a/drivers/ata/pata_opti.c
+++ b/drivers/ata/pata_opti.c
@@ -179,10 +179,6 @@ static struct scsi_host_template opti_sht = {
179 .slave_configure = ata_scsi_slave_config, 179 .slave_configure = ata_scsi_slave_config,
180 .slave_destroy = ata_scsi_slave_destroy, 180 .slave_destroy = ata_scsi_slave_destroy,
181 .bios_param = ata_std_bios_param, 181 .bios_param = ata_std_bios_param,
182#ifdef CONFIG_PM
183 .resume = ata_scsi_device_resume,
184 .suspend = ata_scsi_device_suspend,
185#endif
186}; 182};
187 183
188static struct ata_port_operations opti_port_ops = { 184static struct ata_port_operations opti_port_ops = {
@@ -220,19 +216,19 @@ static struct ata_port_operations opti_port_ops = {
220 216
221static int opti_init_one(struct pci_dev *dev, const struct pci_device_id *id) 217static int opti_init_one(struct pci_dev *dev, const struct pci_device_id *id)
222{ 218{
223 static struct ata_port_info info = { 219 static const struct ata_port_info info = {
224 .sht = &opti_sht, 220 .sht = &opti_sht,
225 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 221 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
226 .pio_mask = 0x1f, 222 .pio_mask = 0x1f,
227 .port_ops = &opti_port_ops 223 .port_ops = &opti_port_ops
228 }; 224 };
229 static struct ata_port_info *port_info[2] = { &info, &info }; 225 const struct ata_port_info *ppi[] = { &info, NULL };
230 static int printed_version; 226 static int printed_version;
231 227
232 if (!printed_version++) 228 if (!printed_version++)
233 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); 229 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n");
234 230
235 return ata_pci_init_one(dev, port_info, 2); 231 return ata_pci_init_one(dev, ppi);
236} 232}
237 233
238static const struct pci_device_id opti[] = { 234static const struct pci_device_id opti[] = {
diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c
index 2843e480f216..3093b02286ce 100644
--- a/drivers/ata/pata_optidma.c
+++ b/drivers/ata/pata_optidma.c
@@ -363,10 +363,6 @@ static struct scsi_host_template optidma_sht = {
363 .slave_configure = ata_scsi_slave_config, 363 .slave_configure = ata_scsi_slave_config,
364 .slave_destroy = ata_scsi_slave_destroy, 364 .slave_destroy = ata_scsi_slave_destroy,
365 .bios_param = ata_std_bios_param, 365 .bios_param = ata_std_bios_param,
366#ifdef CONFIG_PM
367 .resume = ata_scsi_device_resume,
368 .suspend = ata_scsi_device_suspend,
369#endif
370}; 366};
371 367
372static struct ata_port_operations optidma_port_ops = { 368static struct ata_port_operations optidma_port_ops = {
@@ -486,14 +482,14 @@ done_nomsg: /* Wrong chip revision */
486 482
487static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id) 483static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id)
488{ 484{
489 static struct ata_port_info info_82c700 = { 485 static const struct ata_port_info info_82c700 = {
490 .sht = &optidma_sht, 486 .sht = &optidma_sht,
491 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 487 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
492 .pio_mask = 0x1f, 488 .pio_mask = 0x1f,
493 .mwdma_mask = 0x07, 489 .mwdma_mask = 0x07,
494 .port_ops = &optidma_port_ops 490 .port_ops = &optidma_port_ops
495 }; 491 };
496 static struct ata_port_info info_82c700_udma = { 492 static const struct ata_port_info info_82c700_udma = {
497 .sht = &optidma_sht, 493 .sht = &optidma_sht,
498 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 494 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
499 .pio_mask = 0x1f, 495 .pio_mask = 0x1f,
@@ -501,8 +497,7 @@ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id)
501 .udma_mask = 0x07, 497 .udma_mask = 0x07,
502 .port_ops = &optiplus_port_ops 498 .port_ops = &optiplus_port_ops
503 }; 499 };
504 static struct ata_port_info *port_info[2]; 500 const struct ata_port_info *ppi[] = { &info_82c700, NULL };
505 struct ata_port_info *info = &info_82c700;
506 static int printed_version; 501 static int printed_version;
507 502
508 if (!printed_version++) 503 if (!printed_version++)
@@ -514,10 +509,9 @@ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id)
514 pci_clock = inb(0x1F5) & 1; /* 0 = 33Mhz, 1 = 25Mhz */ 509 pci_clock = inb(0x1F5) & 1; /* 0 = 33Mhz, 1 = 25Mhz */
515 510
516 if (optiplus_with_udma(dev)) 511 if (optiplus_with_udma(dev))
517 info = &info_82c700_udma; 512 ppi[0] = &info_82c700_udma;
518 513
519 port_info[0] = port_info[1] = info; 514 return ata_pci_init_one(dev, ppi);
520 return ata_pci_init_one(dev, port_info, 2);
521} 515}
522 516
523static const struct pci_device_id optidma[] = { 517static const struct pci_device_id optidma[] = {
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c
index 11245e331f77..4d44c7555db1 100644
--- a/drivers/ata/pata_pcmcia.c
+++ b/drivers/ata/pata_pcmcia.c
@@ -397,6 +397,7 @@ static struct pcmcia_device_id pcmcia_devices[] = {
397 PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003), 397 PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003),
398 PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443), 398 PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443),
399 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1), 399 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1),
400 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS2GCF120", 0x709b1bf1, 0x969aa4f2),
400 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8), 401 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8),
401 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), 402 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852),
402 PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918), 403 PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918),
diff --git a/drivers/ata/pata_pdc202xx_old.c b/drivers/ata/pata_pdc202xx_old.c
index ee636beb05e1..edbaf9d653b8 100644
--- a/drivers/ata/pata_pdc202xx_old.c
+++ b/drivers/ata/pata_pdc202xx_old.c
@@ -244,10 +244,6 @@ static struct scsi_host_template pdc202xx_sht = {
244 .slave_configure = ata_scsi_slave_config, 244 .slave_configure = ata_scsi_slave_config,
245 .slave_destroy = ata_scsi_slave_destroy, 245 .slave_destroy = ata_scsi_slave_destroy,
246 .bios_param = ata_std_bios_param, 246 .bios_param = ata_std_bios_param,
247#ifdef CONFIG_PM
248 .resume = ata_scsi_device_resume,
249 .suspend = ata_scsi_device_suspend,
250#endif
251}; 247};
252 248
253static struct ata_port_operations pdc2024x_port_ops = { 249static struct ata_port_operations pdc2024x_port_ops = {
@@ -321,7 +317,7 @@ static struct ata_port_operations pdc2026x_port_ops = {
321 317
322static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) 318static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id)
323{ 319{
324 static struct ata_port_info info[3] = { 320 static const struct ata_port_info info[3] = {
325 { 321 {
326 .sht = &pdc202xx_sht, 322 .sht = &pdc202xx_sht,
327 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 323 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
@@ -348,9 +344,7 @@ static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id
348 } 344 }
349 345
350 }; 346 };
351 static struct ata_port_info *port_info[2]; 347 const struct ata_port_info *ppi[] = { &info[id->driver_data], NULL };
352
353 port_info[0] = port_info[1] = &info[id->driver_data];
354 348
355 if (dev->device == PCI_DEVICE_ID_PROMISE_20265) { 349 if (dev->device == PCI_DEVICE_ID_PROMISE_20265) {
356 struct pci_dev *bridge = dev->bus->self; 350 struct pci_dev *bridge = dev->bus->self;
@@ -362,7 +356,7 @@ static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id
362 return -ENODEV; 356 return -ENODEV;
363 } 357 }
364 } 358 }
365 return ata_pci_init_one(dev, port_info, 2); 359 return ata_pci_init_one(dev, ppi);
366} 360}
367 361
368static const struct pci_device_id pdc202xx[] = { 362static const struct pci_device_id pdc202xx[] = {
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
index a0a650c7f272..1f6384895a4f 100644
--- a/drivers/ata/pata_platform.c
+++ b/drivers/ata/pata_platform.c
@@ -48,6 +48,8 @@ static int pata_platform_set_mode(struct ata_port *ap, struct ata_device **unuse
48 return 0; 48 return 0;
49} 49}
50 50
51static int ata_dummy_ret0(struct ata_port *ap) { return 0; }
52
51static struct scsi_host_template pata_platform_sht = { 53static struct scsi_host_template pata_platform_sht = {
52 .module = THIS_MODULE, 54 .module = THIS_MODULE,
53 .name = DRV_NAME, 55 .name = DRV_NAME,
@@ -91,7 +93,7 @@ static struct ata_port_operations pata_platform_port_ops = {
91 .irq_on = ata_irq_on, 93 .irq_on = ata_irq_on,
92 .irq_ack = ata_irq_ack, 94 .irq_ack = ata_irq_ack,
93 95
94 .port_start = ata_port_start, 96 .port_start = ata_dummy_ret0,
95}; 97};
96 98
97static void pata_platform_setup_port(struct ata_ioports *ioaddr, 99static void pata_platform_setup_port(struct ata_ioports *ioaddr,
diff --git a/drivers/ata/pata_radisys.c b/drivers/ata/pata_radisys.c
index 1c54673e008d..ba96b54f5b87 100644
--- a/drivers/ata/pata_radisys.c
+++ b/drivers/ata/pata_radisys.c
@@ -200,10 +200,6 @@ static struct scsi_host_template radisys_sht = {
200 .slave_configure = ata_scsi_slave_config, 200 .slave_configure = ata_scsi_slave_config,
201 .slave_destroy = ata_scsi_slave_destroy, 201 .slave_destroy = ata_scsi_slave_destroy,
202 .bios_param = ata_std_bios_param, 202 .bios_param = ata_std_bios_param,
203#ifdef CONFIG_PM
204 .resume = ata_scsi_device_resume,
205 .suspend = ata_scsi_device_suspend,
206#endif
207}; 203};
208 204
209static const struct ata_port_operations radisys_pata_ops = { 205static const struct ata_port_operations radisys_pata_ops = {
@@ -259,7 +255,7 @@ static const struct ata_port_operations radisys_pata_ops = {
259static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 255static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
260{ 256{
261 static int printed_version; 257 static int printed_version;
262 static struct ata_port_info info = { 258 static const struct ata_port_info info = {
263 .sht = &radisys_sht, 259 .sht = &radisys_sht,
264 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 260 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
265 .pio_mask = 0x1f, /* pio0-4 */ 261 .pio_mask = 0x1f, /* pio0-4 */
@@ -267,13 +263,13 @@ static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *e
267 .udma_mask = 0x14, /* UDMA33/66 only */ 263 .udma_mask = 0x14, /* UDMA33/66 only */
268 .port_ops = &radisys_pata_ops, 264 .port_ops = &radisys_pata_ops,
269 }; 265 };
270 static struct ata_port_info *port_info[2] = { &info, &info }; 266 const struct ata_port_info *ppi[] = { &info, NULL };
271 267
272 if (!printed_version++) 268 if (!printed_version++)
273 dev_printk(KERN_DEBUG, &pdev->dev, 269 dev_printk(KERN_DEBUG, &pdev->dev,
274 "version " DRV_VERSION "\n"); 270 "version " DRV_VERSION "\n");
275 271
276 return ata_pci_init_one(pdev, port_info, 2); 272 return ata_pci_init_one(pdev, ppi);
277} 273}
278 274
279static const struct pci_device_id radisys_pci_tbl[] = { 275static const struct pci_device_id radisys_pci_tbl[] = {
diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c
index 85c45290eeee..2bfd7ef42af5 100644
--- a/drivers/ata/pata_rz1000.c
+++ b/drivers/ata/pata_rz1000.c
@@ -40,7 +40,7 @@ static int rz1000_set_mode(struct ata_port *ap, struct ata_device **unused)
40 40
41 for (i = 0; i < ATA_MAX_DEVICES; i++) { 41 for (i = 0; i < ATA_MAX_DEVICES; i++) {
42 struct ata_device *dev = &ap->device[i]; 42 struct ata_device *dev = &ap->device[i];
43 if (ata_dev_ready(dev)) { 43 if (ata_dev_enabled(dev)) {
44 /* We don't really care */ 44 /* We don't really care */
45 dev->pio_mode = XFER_PIO_0; 45 dev->pio_mode = XFER_PIO_0;
46 dev->xfer_mode = XFER_PIO_0; 46 dev->xfer_mode = XFER_PIO_0;
@@ -69,10 +69,6 @@ static struct scsi_host_template rz1000_sht = {
69 .slave_configure = ata_scsi_slave_config, 69 .slave_configure = ata_scsi_slave_config,
70 .slave_destroy = ata_scsi_slave_destroy, 70 .slave_destroy = ata_scsi_slave_destroy,
71 .bios_param = ata_std_bios_param, 71 .bios_param = ata_std_bios_param,
72#ifdef CONFIG_PM
73 .resume = ata_scsi_device_resume,
74 .suspend = ata_scsi_device_suspend,
75#endif
76}; 72};
77 73
78static struct ata_port_operations rz1000_port_ops = { 74static struct ata_port_operations rz1000_port_ops = {
@@ -135,22 +131,20 @@ static int rz1000_fifo_disable(struct pci_dev *pdev)
135static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 131static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
136{ 132{
137 static int printed_version; 133 static int printed_version;
138 struct ata_port_info *port_info[2]; 134 static const struct ata_port_info info = {
139 static struct ata_port_info info = {
140 .sht = &rz1000_sht, 135 .sht = &rz1000_sht,
141 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 136 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
142 .pio_mask = 0x1f, 137 .pio_mask = 0x1f,
143 .port_ops = &rz1000_port_ops 138 .port_ops = &rz1000_port_ops
144 }; 139 };
140 const struct ata_port_info *ppi[] = { &info, NULL };
145 141
146 if (!printed_version++) 142 if (!printed_version++)
147 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); 143 printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
148 144
149 if (rz1000_fifo_disable(pdev) == 0) { 145 if (rz1000_fifo_disable(pdev) == 0)
150 port_info[0] = &info; 146 return ata_pci_init_one(pdev, ppi);
151 port_info[1] = &info; 147
152 return ata_pci_init_one(pdev, port_info, 2);
153 }
154 printk(KERN_ERR DRV_NAME ": failed to disable read-ahead on chipset..\n"); 148 printk(KERN_ERR DRV_NAME ": failed to disable read-ahead on chipset..\n");
155 /* Not safe to use so skip */ 149 /* Not safe to use so skip */
156 return -ENODEV; 150 return -ENODEV;
diff --git a/drivers/ata/pata_sc1200.c b/drivers/ata/pata_sc1200.c
index 66e8ff467c8d..225013ecf4b6 100644
--- a/drivers/ata/pata_sc1200.c
+++ b/drivers/ata/pata_sc1200.c
@@ -194,10 +194,6 @@ static struct scsi_host_template sc1200_sht = {
194 .slave_configure = ata_scsi_slave_config, 194 .slave_configure = ata_scsi_slave_config,
195 .slave_destroy = ata_scsi_slave_destroy, 195 .slave_destroy = ata_scsi_slave_destroy,
196 .bios_param = ata_std_bios_param, 196 .bios_param = ata_std_bios_param,
197#ifdef CONFIG_PM
198 .resume = ata_scsi_device_resume,
199 .suspend = ata_scsi_device_suspend,
200#endif
201}; 197};
202 198
203static struct ata_port_operations sc1200_port_ops = { 199static struct ata_port_operations sc1200_port_ops = {
@@ -247,7 +243,7 @@ static struct ata_port_operations sc1200_port_ops = {
247 243
248static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) 244static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id)
249{ 245{
250 static struct ata_port_info info = { 246 static const struct ata_port_info info = {
251 .sht = &sc1200_sht, 247 .sht = &sc1200_sht,
252 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, 248 .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
253 .pio_mask = 0x1f, 249 .pio_mask = 0x1f,
@@ -255,10 +251,10 @@ static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id)
255 .udma_mask = 0x07, 251 .udma_mask = 0x07,
256 .port_ops = &sc1200_port_ops 252 .port_ops = &sc1200_port_ops
257 }; 253 };
258 static struct ata_port_info *port_info[2] = { &info, &info };
259
260 /* Can't enable port 2 yet, see top comments */ 254 /* Can't enable port 2 yet, see top comments */
261 return ata_pci_init_one(dev, port_info, 1); 255 const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info };
256
257 return ata_pci_init_one(dev, ppi);
262} 258}
263 259
264static const struct pci_device_id sc1200[] = { 260static const struct pci_device_id sc1200[] = {
diff --git a/drivers/ata/pata_scc.c b/drivers/ata/pata_scc.c
index 203f463ac39f..cca3aa225efe 100644
--- a/drivers/ata/pata_scc.c
+++ b/drivers/ata/pata_scc.c
@@ -984,10 +984,6 @@ static struct scsi_host_template scc_sht = {
984 .slave_configure = ata_scsi_slave_config, 984 .slave_configure = ata_scsi_slave_config,
985 .slave_destroy = ata_scsi_slave_destroy, 985 .slave_destroy = ata_scsi_slave_destroy,
986 .bios_param = ata_std_bios_param, 986 .bios_param = ata_std_bios_param,
987#ifdef CONFIG_PM
988 .resume = ata_scsi_device_resume,
989 .suspend = ata_scsi_device_suspend,
990#endif
991}; 987};
992 988
993static const struct ata_port_operations scc_pata_ops = { 989static const struct ata_port_operations scc_pata_ops = {
diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c
index b6e020383dd9..dee6e211949d 100644
--- a/drivers/ata/pata_serverworks.c
+++ b/drivers/ata/pata_serverworks.c
@@ -315,10 +315,6 @@ static struct scsi_host_template serverworks_sht = {
315 .slave_configure = ata_scsi_slave_config, 315 .slave_configure = ata_scsi_slave_config,
316 .slave_destroy = ata_scsi_slave_destroy, 316 .slave_destroy = ata_scsi_slave_destroy,
317 .bios_param = ata_std_bios_param, 317 .bios_param = ata_std_bios_param,
318#ifdef CONFIG_PM
319 .resume = ata_scsi_device_resume,
320 .suspend = ata_scsi_device_suspend,
321#endif
322}; 318};
323 319
324static struct ata_port_operations serverworks_osb4_port_ops = { 320static struct ata_port_operations serverworks_osb4_port_ops = {
@@ -479,8 +475,7 @@ static void serverworks_fixup_ht1000(struct pci_dev *pdev)
479 475
480static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 476static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
481{ 477{
482 int ports = 2; 478 static const struct ata_port_info info[4] = {
483 static struct ata_port_info info[4] = {
484 { /* OSB4 */ 479 { /* OSB4 */
485 .sht = &serverworks_sht, 480 .sht = &serverworks_sht,
486 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 481 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
@@ -511,8 +506,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
511 .port_ops = &serverworks_csb_port_ops 506 .port_ops = &serverworks_csb_port_ops
512 } 507 }
513 }; 508 };
514 static struct ata_port_info *port_info[2]; 509 const struct ata_port_info *ppi[] = { &info[id->driver_data], NULL };
515 struct ata_port_info *devinfo = &info[id->driver_data];
516 510
517 /* Force master latency timer to 64 PCI clocks */ 511 /* Force master latency timer to 64 PCI clocks */
518 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40); 512 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40);
@@ -521,7 +515,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
521 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { 515 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) {
522 /* Select non UDMA capable OSB4 if we can't do fixups */ 516 /* Select non UDMA capable OSB4 if we can't do fixups */
523 if ( serverworks_fixup_osb4(pdev) < 0) 517 if ( serverworks_fixup_osb4(pdev) < 0)
524 devinfo = &info[1]; 518 ppi[0] = &info[1];
525 } 519 }
526 /* setup CSB5/CSB6 : South Bridge and IDE option RAID */ 520 /* setup CSB5/CSB6 : South Bridge and IDE option RAID */
527 else if ((pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) || 521 else if ((pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ||
@@ -531,11 +525,11 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
531 /* If the returned btr is the newer revision then 525 /* If the returned btr is the newer revision then
532 select the right info block */ 526 select the right info block */
533 if (serverworks_fixup_csb(pdev) == 3) 527 if (serverworks_fixup_csb(pdev) == 3)
534 devinfo = &info[3]; 528 ppi[0] = &info[3];
535 529
536 /* Is this the 3rd channel CSB6 IDE ? */ 530 /* Is this the 3rd channel CSB6 IDE ? */
537 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2) 531 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)
538 ports = 1; 532 ppi[1] = &ata_dummy_port_info;
539 } 533 }
540 /* setup HT1000E */ 534 /* setup HT1000E */
541 else if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) 535 else if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE)
@@ -544,8 +538,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
544 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) 538 if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE)
545 ata_pci_clear_simplex(pdev); 539 ata_pci_clear_simplex(pdev);
546 540
547 port_info[0] = port_info[1] = devinfo; 541 return ata_pci_init_one(pdev, ppi);
548 return ata_pci_init_one(pdev, port_info, ports);
549} 542}
550 543
551#ifdef CONFIG_PM 544#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c
index a5886f061c0b..440e2cb6ee75 100644
--- a/drivers/ata/pata_sil680.c
+++ b/drivers/ata/pata_sil680.c
@@ -232,10 +232,6 @@ static struct scsi_host_template sil680_sht = {
232 .slave_configure = ata_scsi_slave_config, 232 .slave_configure = ata_scsi_slave_config,
233 .slave_destroy = ata_scsi_slave_destroy, 233 .slave_destroy = ata_scsi_slave_destroy,
234 .bios_param = ata_std_bios_param, 234 .bios_param = ata_std_bios_param,
235#ifdef CONFIG_PM
236 .suspend = ata_scsi_device_suspend,
237 .resume = ata_scsi_device_resume,
238#endif
239}; 235};
240 236
241static struct ata_port_operations sil680_port_ops = { 237static struct ata_port_operations sil680_port_ops = {
@@ -345,7 +341,7 @@ static u8 sil680_init_chip(struct pci_dev *pdev)
345 341
346static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 342static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
347{ 343{
348 static struct ata_port_info info = { 344 static const struct ata_port_info info = {
349 .sht = &sil680_sht, 345 .sht = &sil680_sht,
350 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 346 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
351 .pio_mask = 0x1f, 347 .pio_mask = 0x1f,
@@ -353,7 +349,7 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
353 .udma_mask = 0x7f, 349 .udma_mask = 0x7f,
354 .port_ops = &sil680_port_ops 350 .port_ops = &sil680_port_ops
355 }; 351 };
356 static struct ata_port_info info_slow = { 352 static const struct ata_port_info info_slow = {
357 .sht = &sil680_sht, 353 .sht = &sil680_sht,
358 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 354 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
359 .pio_mask = 0x1f, 355 .pio_mask = 0x1f,
@@ -361,7 +357,7 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
361 .udma_mask = 0x3f, 357 .udma_mask = 0x3f,
362 .port_ops = &sil680_port_ops 358 .port_ops = &sil680_port_ops
363 }; 359 };
364 static struct ata_port_info *port_info[2] = {&info, &info}; 360 const struct ata_port_info *ppi[] = { &info, NULL };
365 static int printed_version; 361 static int printed_version;
366 362
367 if (!printed_version++) 363 if (!printed_version++)
@@ -370,12 +366,12 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
370 switch(sil680_init_chip(pdev)) 366 switch(sil680_init_chip(pdev))
371 { 367 {
372 case 0: 368 case 0:
373 port_info[0] = port_info[1] = &info_slow; 369 ppi[0] = &info_slow;
374 break; 370 break;
375 case 0x30: 371 case 0x30:
376 return -ENODEV; 372 return -ENODEV;
377 } 373 }
378 return ata_pci_init_one(pdev, port_info, 2); 374 return ata_pci_init_one(pdev, ppi);
379} 375}
380 376
381#ifdef CONFIG_PM 377#ifdef CONFIG_PM
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index f5838cc11728..f2231267e011 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -38,8 +38,8 @@
38#define DRV_VERSION "0.5.1" 38#define DRV_VERSION "0.5.1"
39 39
40struct sis_chipset { 40struct sis_chipset {
41 u16 device; /* PCI host ID */ 41 u16 device; /* PCI host ID */
42 struct ata_port_info *info; /* Info block */ 42 const struct ata_port_info *info; /* Info block */
43 /* Probably add family, cable detect type etc here to clean 43 /* Probably add family, cable detect type etc here to clean
44 up code later */ 44 up code later */
45}; 45};
@@ -524,10 +524,6 @@ static struct scsi_host_template sis_sht = {
524 .slave_configure = ata_scsi_slave_config, 524 .slave_configure = ata_scsi_slave_config,
525 .slave_destroy = ata_scsi_slave_destroy, 525 .slave_destroy = ata_scsi_slave_destroy,
526 .bios_param = ata_std_bios_param, 526 .bios_param = ata_std_bios_param,
527#ifdef CONFIG_PM
528 .resume = ata_scsi_device_resume,
529 .suspend = ata_scsi_device_suspend,
530#endif
531}; 527};
532 528
533static const struct ata_port_operations sis_133_ops = { 529static const struct ata_port_operations sis_133_ops = {
@@ -700,7 +696,7 @@ static const struct ata_port_operations sis_old_ops = {
700 .port_start = ata_port_start, 696 .port_start = ata_port_start,
701}; 697};
702 698
703static struct ata_port_info sis_info = { 699static const struct ata_port_info sis_info = {
704 .sht = &sis_sht, 700 .sht = &sis_sht,
705 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 701 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
706 .pio_mask = 0x1f, /* pio0-4 */ 702 .pio_mask = 0x1f, /* pio0-4 */
@@ -708,7 +704,7 @@ static struct ata_port_info sis_info = {
708 .udma_mask = 0, 704 .udma_mask = 0,
709 .port_ops = &sis_old_ops, 705 .port_ops = &sis_old_ops,
710}; 706};
711static struct ata_port_info sis_info33 = { 707static const struct ata_port_info sis_info33 = {
712 .sht = &sis_sht, 708 .sht = &sis_sht,
713 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 709 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
714 .pio_mask = 0x1f, /* pio0-4 */ 710 .pio_mask = 0x1f, /* pio0-4 */
@@ -716,35 +712,35 @@ static struct ata_port_info sis_info33 = {
716 .udma_mask = ATA_UDMA2, /* UDMA 33 */ 712 .udma_mask = ATA_UDMA2, /* UDMA 33 */
717 .port_ops = &sis_old_ops, 713 .port_ops = &sis_old_ops,
718}; 714};
719static struct ata_port_info sis_info66 = { 715static const struct ata_port_info sis_info66 = {
720 .sht = &sis_sht, 716 .sht = &sis_sht,
721 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 717 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
722 .pio_mask = 0x1f, /* pio0-4 */ 718 .pio_mask = 0x1f, /* pio0-4 */
723 .udma_mask = ATA_UDMA4, /* UDMA 66 */ 719 .udma_mask = ATA_UDMA4, /* UDMA 66 */
724 .port_ops = &sis_66_ops, 720 .port_ops = &sis_66_ops,
725}; 721};
726static struct ata_port_info sis_info100 = { 722static const struct ata_port_info sis_info100 = {
727 .sht = &sis_sht, 723 .sht = &sis_sht,
728 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 724 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
729 .pio_mask = 0x1f, /* pio0-4 */ 725 .pio_mask = 0x1f, /* pio0-4 */
730 .udma_mask = ATA_UDMA5, 726 .udma_mask = ATA_UDMA5,
731 .port_ops = &sis_100_ops, 727 .port_ops = &sis_100_ops,
732}; 728};
733static struct ata_port_info sis_info100_early = { 729static const struct ata_port_info sis_info100_early = {
734 .sht = &sis_sht, 730 .sht = &sis_sht,
735 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 731 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
736 .udma_mask = ATA_UDMA5, 732 .udma_mask = ATA_UDMA5,
737 .pio_mask = 0x1f, /* pio0-4 */ 733 .pio_mask = 0x1f, /* pio0-4 */
738 .port_ops = &sis_66_ops, 734 .port_ops = &sis_66_ops,
739}; 735};
740struct ata_port_info sis_info133 = { 736const struct ata_port_info sis_info133 = {
741 .sht = &sis_sht, 737 .sht = &sis_sht,
742 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 738 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
743 .pio_mask = 0x1f, /* pio0-4 */ 739 .pio_mask = 0x1f, /* pio0-4 */
744 .udma_mask = ATA_UDMA6, 740 .udma_mask = ATA_UDMA6,
745 .port_ops = &sis_133_ops, 741 .port_ops = &sis_133_ops,
746}; 742};
747static struct ata_port_info sis_info133_early = { 743static const struct ata_port_info sis_info133_early = {
748 .sht = &sis_sht, 744 .sht = &sis_sht,
749 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 745 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
750 .pio_mask = 0x1f, /* pio0-4 */ 746 .pio_mask = 0x1f, /* pio0-4 */
@@ -827,8 +823,8 @@ static void sis_fixup(struct pci_dev *pdev, struct sis_chipset *sis)
827static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 823static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
828{ 824{
829 static int printed_version; 825 static int printed_version;
830 static struct ata_port_info *port_info[2]; 826 struct ata_port_info port;
831 struct ata_port_info *port; 827 const struct ata_port_info *ppi[] = { &port, NULL };
832 struct pci_dev *host = NULL; 828 struct pci_dev *host = NULL;
833 struct sis_chipset *chipset = NULL; 829 struct sis_chipset *chipset = NULL;
834 struct sis_chipset *sets; 830 struct sis_chipset *sets;
@@ -968,13 +964,12 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
968 if (chipset == NULL) 964 if (chipset == NULL)
969 return -ENODEV; 965 return -ENODEV;
970 966
971 port = chipset->info; 967 port = *chipset->info;
972 port->private_data = chipset; 968 port.private_data = chipset;
973 969
974 sis_fixup(pdev, chipset); 970 sis_fixup(pdev, chipset);
975 971
976 port_info[0] = port_info[1] = port; 972 return ata_pci_init_one(pdev, ppi);
977 return ata_pci_init_one(pdev, port_info, 2);
978} 973}
979 974
980static const struct pci_device_id sis_pci_tbl[] = { 975static const struct pci_device_id sis_pci_tbl[] = {
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c
index 9aeffdbe2829..f48491ad5f3a 100644
--- a/drivers/ata/pata_sl82c105.c
+++ b/drivers/ata/pata_sl82c105.c
@@ -301,20 +301,22 @@ static int sl82c105_bridge_revision(struct pci_dev *pdev)
301 301
302static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id) 302static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id)
303{ 303{
304 static struct ata_port_info info_dma = { 304 static const struct ata_port_info info_dma = {
305 .sht = &sl82c105_sht, 305 .sht = &sl82c105_sht,
306 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 306 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
307 .pio_mask = 0x1f, 307 .pio_mask = 0x1f,
308 .mwdma_mask = 0x07, 308 .mwdma_mask = 0x07,
309 .port_ops = &sl82c105_port_ops 309 .port_ops = &sl82c105_port_ops
310 }; 310 };
311 static struct ata_port_info info_early = { 311 static const struct ata_port_info info_early = {
312 .sht = &sl82c105_sht, 312 .sht = &sl82c105_sht,
313 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 313 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
314 .pio_mask = 0x1f, 314 .pio_mask = 0x1f,
315 .port_ops = &sl82c105_port_ops 315 .port_ops = &sl82c105_port_ops
316 }; 316 };
317 static struct ata_port_info *port_info[2] = { &info_early, &info_early }; 317 /* for now use only the first port */
318 const struct ata_port_info *ppi[] = { &info_early,
319 &ata_dummy_port_info };
318 u32 val; 320 u32 val;
319 int rev; 321 int rev;
320 322
@@ -324,17 +326,14 @@ static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id
324 dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Unable to find bridge, disabling DMA.\n"); 326 dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Unable to find bridge, disabling DMA.\n");
325 else if (rev <= 5) 327 else if (rev <= 5)
326 dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Early bridge revision, no DMA available.\n"); 328 dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Early bridge revision, no DMA available.\n");
327 else { 329 else
328 port_info[0] = &info_dma; 330 ppi[0] = &info_dma;
329 port_info[1] = &info_dma;
330 }
331 331
332 pci_read_config_dword(dev, 0x40, &val); 332 pci_read_config_dword(dev, 0x40, &val);
333 val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16; 333 val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16;
334 pci_write_config_dword(dev, 0x40, val); 334 pci_write_config_dword(dev, 0x40, val);
335 335
336 336 return ata_pci_init_one(dev, ppi);
337 return ata_pci_init_one(dev, port_info, 1); /* For now */
338} 337}
339 338
340static const struct pci_device_id sl82c105[] = { 339static const struct pci_device_id sl82c105[] = {
diff --git a/drivers/ata/pata_triflex.c b/drivers/ata/pata_triflex.c
index 349887bf5b93..b1d3076dfe51 100644
--- a/drivers/ata/pata_triflex.c
+++ b/drivers/ata/pata_triflex.c
@@ -194,10 +194,6 @@ static struct scsi_host_template triflex_sht = {
194 .slave_configure = ata_scsi_slave_config, 194 .slave_configure = ata_scsi_slave_config,
195 .slave_destroy = ata_scsi_slave_destroy, 195 .slave_destroy = ata_scsi_slave_destroy,
196 .bios_param = ata_std_bios_param, 196 .bios_param = ata_std_bios_param,
197#ifdef CONFIG_PM
198 .resume = ata_scsi_device_resume,
199 .suspend = ata_scsi_device_suspend,
200#endif
201}; 197};
202 198
203static struct ata_port_operations triflex_port_ops = { 199static struct ata_port_operations triflex_port_ops = {
@@ -237,20 +233,20 @@ static struct ata_port_operations triflex_port_ops = {
237 233
238static int triflex_init_one(struct pci_dev *dev, const struct pci_device_id *id) 234static int triflex_init_one(struct pci_dev *dev, const struct pci_device_id *id)
239{ 235{
240 static struct ata_port_info info = { 236 static const struct ata_port_info info = {
241 .sht = &triflex_sht, 237 .sht = &triflex_sht,
242 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 238 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
243 .pio_mask = 0x1f, 239 .pio_mask = 0x1f,
244 .mwdma_mask = 0x07, 240 .mwdma_mask = 0x07,
245 .port_ops = &triflex_port_ops 241 .port_ops = &triflex_port_ops
246 }; 242 };
247 static struct ata_port_info *port_info[2] = { &info, &info }; 243 const struct ata_port_info *ppi[] = { &info, NULL };
248 static int printed_version; 244 static int printed_version;
249 245
250 if (!printed_version++) 246 if (!printed_version++)
251 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); 247 dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n");
252 248
253 return ata_pci_init_one(dev, port_info, 2); 249 return ata_pci_init_one(dev, ppi);
254} 250}
255 251
256static const struct pci_device_id triflex[] = { 252static const struct pci_device_id triflex[] = {
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index 362beb2f489c..e4c71f76bd55 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -301,10 +301,6 @@ static struct scsi_host_template via_sht = {
301 .slave_configure = ata_scsi_slave_config, 301 .slave_configure = ata_scsi_slave_config,
302 .slave_destroy = ata_scsi_slave_destroy, 302 .slave_destroy = ata_scsi_slave_destroy,
303 .bios_param = ata_std_bios_param, 303 .bios_param = ata_std_bios_param,
304#ifdef CONFIG_PM
305 .resume = ata_scsi_device_resume,
306 .suspend = ata_scsi_device_suspend,
307#endif
308}; 304};
309 305
310static struct ata_port_operations via_port_ops = { 306static struct ata_port_operations via_port_ops = {
@@ -425,7 +421,7 @@ static void via_config_fifo(struct pci_dev *pdev, unsigned int flags)
425static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 421static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
426{ 422{
427 /* Early VIA without UDMA support */ 423 /* Early VIA without UDMA support */
428 static struct ata_port_info via_mwdma_info = { 424 static const struct ata_port_info via_mwdma_info = {
429 .sht = &via_sht, 425 .sht = &via_sht,
430 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, 426 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
431 .pio_mask = 0x1f, 427 .pio_mask = 0x1f,
@@ -433,7 +429,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
433 .port_ops = &via_port_ops 429 .port_ops = &via_port_ops
434 }; 430 };
435 /* Ditto with IRQ masking required */ 431 /* Ditto with IRQ masking required */
436 static struct ata_port_info via_mwdma_info_borked = { 432 static const struct ata_port_info via_mwdma_info_borked = {
437 .sht = &via_sht, 433 .sht = &via_sht,
438 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, 434 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
439 .pio_mask = 0x1f, 435 .pio_mask = 0x1f,
@@ -441,7 +437,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
441 .port_ops = &via_port_ops_noirq, 437 .port_ops = &via_port_ops_noirq,
442 }; 438 };
443 /* VIA UDMA 33 devices (and borked 66) */ 439 /* VIA UDMA 33 devices (and borked 66) */
444 static struct ata_port_info via_udma33_info = { 440 static const struct ata_port_info via_udma33_info = {
445 .sht = &via_sht, 441 .sht = &via_sht,
446 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, 442 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
447 .pio_mask = 0x1f, 443 .pio_mask = 0x1f,
@@ -450,7 +446,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
450 .port_ops = &via_port_ops 446 .port_ops = &via_port_ops
451 }; 447 };
452 /* VIA UDMA 66 devices */ 448 /* VIA UDMA 66 devices */
453 static struct ata_port_info via_udma66_info = { 449 static const struct ata_port_info via_udma66_info = {
454 .sht = &via_sht, 450 .sht = &via_sht,
455 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, 451 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
456 .pio_mask = 0x1f, 452 .pio_mask = 0x1f,
@@ -459,7 +455,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
459 .port_ops = &via_port_ops 455 .port_ops = &via_port_ops
460 }; 456 };
461 /* VIA UDMA 100 devices */ 457 /* VIA UDMA 100 devices */
462 static struct ata_port_info via_udma100_info = { 458 static const struct ata_port_info via_udma100_info = {
463 .sht = &via_sht, 459 .sht = &via_sht,
464 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, 460 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
465 .pio_mask = 0x1f, 461 .pio_mask = 0x1f,
@@ -468,7 +464,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
468 .port_ops = &via_port_ops 464 .port_ops = &via_port_ops
469 }; 465 };
470 /* UDMA133 with bad AST (All current 133) */ 466 /* UDMA133 with bad AST (All current 133) */
471 static struct ata_port_info via_udma133_info = { 467 static const struct ata_port_info via_udma133_info = {
472 .sht = &via_sht, 468 .sht = &via_sht,
473 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, 469 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
474 .pio_mask = 0x1f, 470 .pio_mask = 0x1f,
@@ -476,7 +472,8 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
476 .udma_mask = 0x7f, /* FIXME: should check north bridge */ 472 .udma_mask = 0x7f, /* FIXME: should check north bridge */
477 .port_ops = &via_port_ops 473 .port_ops = &via_port_ops
478 }; 474 };
479 struct ata_port_info *port_info[2], *type; 475 struct ata_port_info type;
476 const struct ata_port_info *ppi[] = { &type, NULL };
480 struct pci_dev *isa = NULL; 477 struct pci_dev *isa = NULL;
481 const struct via_isa_bridge *config; 478 const struct via_isa_bridge *config;
482 static int printed_version; 479 static int printed_version;
@@ -521,25 +518,25 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
521 switch(config->flags & VIA_UDMA) { 518 switch(config->flags & VIA_UDMA) {
522 case VIA_UDMA_NONE: 519 case VIA_UDMA_NONE:
523 if (config->flags & VIA_NO_UNMASK) 520 if (config->flags & VIA_NO_UNMASK)
524 type = &via_mwdma_info_borked; 521 type = via_mwdma_info_borked;
525 else 522 else
526 type = &via_mwdma_info; 523 type = via_mwdma_info;
527 break; 524 break;
528 case VIA_UDMA_33: 525 case VIA_UDMA_33:
529 type = &via_udma33_info; 526 type = via_udma33_info;
530 break; 527 break;
531 case VIA_UDMA_66: 528 case VIA_UDMA_66:
532 type = &via_udma66_info; 529 type = via_udma66_info;
533 /* The 66 MHz devices require we enable the clock */ 530 /* The 66 MHz devices require we enable the clock */
534 pci_read_config_dword(pdev, 0x50, &timing); 531 pci_read_config_dword(pdev, 0x50, &timing);
535 timing |= 0x80008; 532 timing |= 0x80008;
536 pci_write_config_dword(pdev, 0x50, timing); 533 pci_write_config_dword(pdev, 0x50, timing);
537 break; 534 break;
538 case VIA_UDMA_100: 535 case VIA_UDMA_100:
539 type = &via_udma100_info; 536 type = via_udma100_info;
540 break; 537 break;
541 case VIA_UDMA_133: 538 case VIA_UDMA_133:
542 type = &via_udma133_info; 539 type = via_udma133_info;
543 break; 540 break;
544 default: 541 default:
545 WARN_ON(1); 542 WARN_ON(1);
@@ -554,10 +551,9 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
554 } 551 }
555 552
556 /* We have established the device type, now fire it up */ 553 /* We have established the device type, now fire it up */
557 type->private_data = (void *)config; 554 type.private_data = (void *)config;
558 555
559 port_info[0] = port_info[1] = type; 556 return ata_pci_init_one(pdev, ppi);
560 return ata_pci_init_one(pdev, port_info, 2);
561} 557}
562 558
563#ifdef CONFIG_PM 559#ifdef CONFIG_PM
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index b3b62e985f19..bda5e7747c21 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -135,10 +135,6 @@ static struct scsi_host_template inic_sht = {
135 .slave_configure = inic_slave_config, 135 .slave_configure = inic_slave_config,
136 .slave_destroy = ata_scsi_slave_destroy, 136 .slave_destroy = ata_scsi_slave_destroy,
137 .bios_param = ata_std_bios_param, 137 .bios_param = ata_std_bios_param,
138#ifdef CONFIG_PM
139 .suspend = ata_scsi_device_suspend,
140 .resume = ata_scsi_device_resume,
141#endif
142}; 138};
143 139
144static const int scr_map[] = { 140static const int scr_map[] = {
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index a097595d4dc7..4cea3ef75226 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -325,10 +325,6 @@ static struct scsi_host_template nv_sht = {
325 .slave_configure = ata_scsi_slave_config, 325 .slave_configure = ata_scsi_slave_config,
326 .slave_destroy = ata_scsi_slave_destroy, 326 .slave_destroy = ata_scsi_slave_destroy,
327 .bios_param = ata_std_bios_param, 327 .bios_param = ata_std_bios_param,
328#ifdef CONFIG_PM
329 .suspend = ata_scsi_device_suspend,
330 .resume = ata_scsi_device_resume,
331#endif
332}; 328};
333 329
334static struct scsi_host_template nv_adma_sht = { 330static struct scsi_host_template nv_adma_sht = {
@@ -347,10 +343,6 @@ static struct scsi_host_template nv_adma_sht = {
347 .slave_configure = nv_adma_slave_config, 343 .slave_configure = nv_adma_slave_config,
348 .slave_destroy = ata_scsi_slave_destroy, 344 .slave_destroy = ata_scsi_slave_destroy,
349 .bios_param = ata_std_bios_param, 345 .bios_param = ata_std_bios_param,
350#ifdef CONFIG_PM
351 .suspend = ata_scsi_device_suspend,
352 .resume = ata_scsi_device_resume,
353#endif
354}; 346};
355 347
356static const struct ata_port_operations nv_generic_ops = { 348static const struct ata_port_operations nv_generic_ops = {
@@ -465,7 +457,7 @@ static const struct ata_port_operations nv_adma_ops = {
465 .host_stop = nv_adma_host_stop, 457 .host_stop = nv_adma_host_stop,
466}; 458};
467 459
468static struct ata_port_info nv_port_info[] = { 460static const struct ata_port_info nv_port_info[] = {
469 /* generic */ 461 /* generic */
470 { 462 {
471 .sht = &nv_sht, 463 .sht = &nv_sht,
@@ -1545,7 +1537,7 @@ static void nv_adma_error_handler(struct ata_port *ap)
1545static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 1537static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1546{ 1538{
1547 static int printed_version = 0; 1539 static int printed_version = 0;
1548 const struct ata_port_info *ppi[2]; 1540 const struct ata_port_info *ppi[] = { NULL, NULL };
1549 struct ata_host *host; 1541 struct ata_host *host;
1550 struct nv_host_priv *hpriv; 1542 struct nv_host_priv *hpriv;
1551 int rc; 1543 int rc;
@@ -1573,8 +1565,8 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1573 type = ADMA; 1565 type = ADMA;
1574 } 1566 }
1575 1567
1576 ppi[0] = ppi[1] = &nv_port_info[type]; 1568 ppi[0] = &nv_port_info[type];
1577 rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); 1569 rc = ata_pci_prepare_native_host(pdev, ppi, &host);
1578 if (rc) 1570 if (rc)
1579 return rc; 1571 return rc;
1580 1572
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index 0a1e417f309c..e8483aadd11b 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -182,10 +182,6 @@ static struct scsi_host_template sil_sht = {
182 .slave_configure = ata_scsi_slave_config, 182 .slave_configure = ata_scsi_slave_config,
183 .slave_destroy = ata_scsi_slave_destroy, 183 .slave_destroy = ata_scsi_slave_destroy,
184 .bios_param = ata_std_bios_param, 184 .bios_param = ata_std_bios_param,
185#ifdef CONFIG_PM
186 .suspend = ata_scsi_device_suspend,
187 .resume = ata_scsi_device_resume,
188#endif
189}; 185};
190 186
191static const struct ata_port_operations sil_ops = { 187static const struct ata_port_operations sil_ops = {
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index b97ee9f31aec..a69d78cd8e9b 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -380,10 +380,6 @@ static struct scsi_host_template sil24_sht = {
380 .slave_configure = ata_scsi_slave_config, 380 .slave_configure = ata_scsi_slave_config,
381 .slave_destroy = ata_scsi_slave_destroy, 381 .slave_destroy = ata_scsi_slave_destroy,
382 .bios_param = ata_std_bios_param, 382 .bios_param = ata_std_bios_param,
383#ifdef CONFIG_PM
384 .suspend = ata_scsi_device_suspend,
385 .resume = ata_scsi_device_resume,
386#endif
387}; 383};
388 384
389static const struct ata_port_operations sil24_ops = { 385static const struct ata_port_operations sil24_ops = {
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c
index d8ee062e82fc..ee66c5fa7ac8 100644
--- a/drivers/ata/sata_sis.c
+++ b/drivers/ata/sata_sis.c
@@ -129,7 +129,7 @@ static const struct ata_port_operations sis_ops = {
129 .port_start = ata_port_start, 129 .port_start = ata_port_start,
130}; 130};
131 131
132static struct ata_port_info sis_port_info = { 132static const struct ata_port_info sis_port_info = {
133 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 133 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY,
134 .pio_mask = 0x1f, 134 .pio_mask = 0x1f,
135 .mwdma_mask = 0x7, 135 .mwdma_mask = 0x7,
@@ -255,7 +255,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
255{ 255{
256 static int printed_version; 256 static int printed_version;
257 struct ata_port_info pi = sis_port_info; 257 struct ata_port_info pi = sis_port_info;
258 const struct ata_port_info *ppi[2] = { &pi, &pi }; 258 const struct ata_port_info *ppi[] = { &pi, NULL };
259 struct ata_host *host; 259 struct ata_host *host;
260 u32 genctl, val; 260 u32 genctl, val;
261 u8 pmr; 261 u8 pmr;
@@ -335,7 +335,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
335 break; 335 break;
336 } 336 }
337 337
338 rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); 338 rc = ata_pci_prepare_native_host(pdev, ppi, &host);
339 if (rc) 339 if (rc)
340 return rc; 340 return rc;
341 341
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c
index f74e383de083..006f5e352658 100644
--- a/drivers/ata/sata_uli.c
+++ b/drivers/ata/sata_uli.c
@@ -125,7 +125,7 @@ static const struct ata_port_operations uli_ops = {
125 .port_start = ata_port_start, 125 .port_start = ata_port_start,
126}; 126};
127 127
128static struct ata_port_info uli_port_info = { 128static const struct ata_port_info uli_port_info = {
129 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 129 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
130 ATA_FLAG_IGN_SIMPLEX, 130 ATA_FLAG_IGN_SIMPLEX,
131 .pio_mask = 0x1f, /* pio0-4 */ 131 .pio_mask = 0x1f, /* pio0-4 */
@@ -201,19 +201,33 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
201 n_ports = 2; 201 n_ports = 2;
202 if (board_idx == uli_5287) 202 if (board_idx == uli_5287)
203 n_ports = 4; 203 n_ports = 4;
204 rc = ata_pci_prepare_native_host(pdev, ppi, n_ports, &host); 204
205 if (rc) 205 /* allocate the host */
206 return rc; 206 host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
207 if (!host)
208 return -ENOMEM;
207 209
208 hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); 210 hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
209 if (!hpriv) 211 if (!hpriv)
210 return -ENOMEM; 212 return -ENOMEM;
211 host->private_data = hpriv; 213 host->private_data = hpriv;
212 214
215 /* the first two ports are standard SFF */
216 rc = ata_pci_init_native_host(host);
217 if (rc)
218 return rc;
219
220 rc = ata_pci_init_bmdma(host);
221 if (rc)
222 return rc;
223
213 iomap = host->iomap; 224 iomap = host->iomap;
214 225
215 switch (board_idx) { 226 switch (board_idx) {
216 case uli_5287: 227 case uli_5287:
228 /* If there are four, the last two live right after
229 * the standard SFF ports.
230 */
217 hpriv->scr_cfg_addr[0] = ULI5287_BASE; 231 hpriv->scr_cfg_addr[0] = ULI5287_BASE;
218 hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS; 232 hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS;
219 233
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index 939c9246fdd1..d105d2c189d2 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -116,10 +116,6 @@ static struct scsi_host_template svia_sht = {
116 .slave_configure = ata_scsi_slave_config, 116 .slave_configure = ata_scsi_slave_config,
117 .slave_destroy = ata_scsi_slave_destroy, 117 .slave_destroy = ata_scsi_slave_destroy,
118 .bios_param = ata_std_bios_param, 118 .bios_param = ata_std_bios_param,
119#ifdef CONFIG_PM
120 .suspend = ata_scsi_device_suspend,
121 .resume = ata_scsi_device_resume,
122#endif
123}; 119};
124 120
125static const struct ata_port_operations vt6420_sata_ops = { 121static const struct ata_port_operations vt6420_sata_ops = {
@@ -415,7 +411,7 @@ static int vt6420_prepare_host(struct pci_dev *pdev, struct ata_host **r_host)
415 struct ata_host *host; 411 struct ata_host *host;
416 int rc; 412 int rc;
417 413
418 rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); 414 rc = ata_pci_prepare_native_host(pdev, ppi, &host);
419 if (rc) 415 if (rc)
420 return rc; 416 return rc;
421 *r_host = host; 417 *r_host = host;
diff --git a/drivers/ata/sis.h b/drivers/ata/sis.h
index 231da8fc2200..0f2208d8d5ef 100644
--- a/drivers/ata/sis.h
+++ b/drivers/ata/sis.h
@@ -2,4 +2,4 @@
2struct ata_port_info; 2struct ata_port_info;
3 3
4/* pata_sis.c */ 4/* pata_sis.c */
5extern struct ata_port_info sis_info133; 5extern const struct ata_port_info sis_info133;
diff --git a/drivers/atm/Kconfig b/drivers/atm/Kconfig
index 33687454eb32..f5a47a48c3b4 100644
--- a/drivers/atm/Kconfig
+++ b/drivers/atm/Kconfig
@@ -2,19 +2,22 @@
2# ATM device configuration 2# ATM device configuration
3# 3#
4 4
5menu "ATM drivers" 5menuconfig ATM_DRIVERS
6 bool "ATM drivers"
6 depends on NETDEVICES && ATM 7 depends on NETDEVICES && ATM
8 default y
9
10if ATM_DRIVERS
7 11
8config ATM_DUMMY 12config ATM_DUMMY
9 tristate "Dummy ATM driver" 13 tristate "Dummy ATM driver"
10 depends on ATM
11 help 14 help
12 Dummy ATM driver. Useful for proxy signalling, testing, 15 Dummy ATM driver. Useful for proxy signalling, testing,
13 and development. If unsure, say N. 16 and development. If unsure, say N.
14 17
15config ATM_TCP 18config ATM_TCP
16 tristate "ATM over TCP" 19 tristate "ATM over TCP"
17 depends on INET && ATM 20 depends on INET
18 help 21 help
19 ATM over TCP driver. Useful mainly for development and for 22 ATM over TCP driver. Useful mainly for development and for
20 experiments. If unsure, say N. 23 experiments. If unsure, say N.
@@ -30,7 +33,7 @@ config ATM_LANAI
30 33
31config ATM_ENI 34config ATM_ENI
32 tristate "Efficient Networks ENI155P" 35 tristate "Efficient Networks ENI155P"
33 depends on PCI && ATM 36 depends on PCI
34 ---help--- 37 ---help---
35 Driver for the Efficient Networks ENI155p series and SMC ATM 38 Driver for the Efficient Networks ENI155p series and SMC ATM
36 Power155 155 Mbps ATM adapters. Both, the versions with 512KB and 39 Power155 155 Mbps ATM adapters. Both, the versions with 512KB and
@@ -139,7 +142,7 @@ config ATM_ENI_BURST_RX_2W
139 142
140config ATM_FIRESTREAM 143config ATM_FIRESTREAM
141 tristate "Fujitsu FireStream (FS50/FS155) " 144 tristate "Fujitsu FireStream (FS50/FS155) "
142 depends on PCI && ATM 145 depends on PCI
143 help 146 help
144 Driver for the Fujitsu FireStream 155 (MB86697) and 147 Driver for the Fujitsu FireStream 155 (MB86697) and
145 FireStream 50 (MB86695) ATM PCI chips. 148 FireStream 50 (MB86695) ATM PCI chips.
@@ -149,7 +152,7 @@ config ATM_FIRESTREAM
149 152
150config ATM_ZATM 153config ATM_ZATM
151 tristate "ZeitNet ZN1221/ZN1225" 154 tristate "ZeitNet ZN1221/ZN1225"
152 depends on PCI && ATM 155 depends on PCI
153 help 156 help
154 Driver for the ZeitNet ZN1221 (MMF) and ZN1225 (UTP-5) 155 Mbps ATM 157 Driver for the ZeitNet ZN1221 (MMF) and ZN1225 (UTP-5) 155 Mbps ATM
155 adapters. 158 adapters.
@@ -169,7 +172,7 @@ config ATM_ZATM_DEBUG
169 172
170config ATM_NICSTAR 173config ATM_NICSTAR
171 tristate "IDT 77201 (NICStAR) (ForeRunnerLE)" 174 tristate "IDT 77201 (NICStAR) (ForeRunnerLE)"
172 depends on PCI && ATM && !64BIT 175 depends on PCI && !64BIT
173 help 176 help
174 The NICStAR chipset family is used in a large number of ATM NICs for 177 The NICStAR chipset family is used in a large number of ATM NICs for
175 25 and for 155 Mbps, including IDT cards and the Fore ForeRunnerLE 178 25 and for 155 Mbps, including IDT cards and the Fore ForeRunnerLE
@@ -202,7 +205,7 @@ config ATM_NICSTAR_USE_IDT77105
202 205
203config ATM_IDT77252 206config ATM_IDT77252
204 tristate "IDT 77252 (NICStAR II)" 207 tristate "IDT 77252 (NICStAR II)"
205 depends on PCI && ATM 208 depends on PCI
206 help 209 help
207 Driver for the IDT 77252 ATM PCI chips. 210 Driver for the IDT 77252 ATM PCI chips.
208 211
@@ -237,7 +240,7 @@ config ATM_IDT77252_USE_SUNI
237 240
238config ATM_AMBASSADOR 241config ATM_AMBASSADOR
239 tristate "Madge Ambassador (Collage PCI 155 Server)" 242 tristate "Madge Ambassador (Collage PCI 155 Server)"
240 depends on PCI && ATM 243 depends on PCI
241 select BITREVERSE 244 select BITREVERSE
242 help 245 help
243 This is a driver for ATMizer based ATM card produced by Madge 246 This is a driver for ATMizer based ATM card produced by Madge
@@ -262,7 +265,7 @@ config ATM_AMBASSADOR_DEBUG
262 265
263config ATM_HORIZON 266config ATM_HORIZON
264 tristate "Madge Horizon [Ultra] (Collage PCI 25 and Collage PCI 155 Client)" 267 tristate "Madge Horizon [Ultra] (Collage PCI 25 and Collage PCI 155 Client)"
265 depends on PCI && ATM 268 depends on PCI
266 help 269 help
267 This is a driver for the Horizon chipset ATM adapter cards once 270 This is a driver for the Horizon chipset ATM adapter cards once
268 produced by Madge Networks Ltd. Say Y (or M to compile as a module 271 produced by Madge Networks Ltd. Say Y (or M to compile as a module
@@ -286,7 +289,7 @@ config ATM_HORIZON_DEBUG
286 289
287config ATM_IA 290config ATM_IA
288 tristate "Interphase ATM PCI x575/x525/x531" 291 tristate "Interphase ATM PCI x575/x525/x531"
289 depends on PCI && ATM && !64BIT 292 depends on PCI && !64BIT
290 ---help--- 293 ---help---
291 This is a driver for the Interphase (i)ChipSAR adapter cards 294 This is a driver for the Interphase (i)ChipSAR adapter cards
292 which include a variety of variants in term of the size of the 295 which include a variety of variants in term of the size of the
@@ -319,7 +322,7 @@ config ATM_IA_DEBUG
319 322
320config ATM_FORE200E_MAYBE 323config ATM_FORE200E_MAYBE
321 tristate "FORE Systems 200E-series" 324 tristate "FORE Systems 200E-series"
322 depends on (PCI || SBUS) && ATM 325 depends on PCI || SBUS
323 ---help--- 326 ---help---
324 This is a driver for the FORE Systems 200E-series ATM adapter 327 This is a driver for the FORE Systems 200E-series ATM adapter
325 cards. It simultaneously supports PCA-200E and SBA-200E models 328 cards. It simultaneously supports PCA-200E and SBA-200E models
@@ -436,7 +439,7 @@ config ATM_FORE200E
436 439
437config ATM_HE 440config ATM_HE
438 tristate "ForeRunner HE Series" 441 tristate "ForeRunner HE Series"
439 depends on PCI && ATM 442 depends on PCI
440 help 443 help
441 This is a driver for the Marconi ForeRunner HE-series ATM adapter 444 This is a driver for the Marconi ForeRunner HE-series ATM adapter
442 cards. It simultaneously supports the 155 and 622 versions. 445 cards. It simultaneously supports the 155 and 622 versions.
@@ -448,5 +451,4 @@ config ATM_HE_USE_SUNI
448 Support for the S/UNI-Ultra and S/UNI-622 found in the ForeRunner 451 Support for the S/UNI-Ultra and S/UNI-622 found in the ForeRunner
449 HE cards. This driver provides carrier detection some statistics. 452 HE cards. This driver provides carrier detection some statistics.
450 453
451endmenu 454endif # ATM
452
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 18cdd8c77626..e2fc4b6734cf 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1317,18 +1317,6 @@ static long lo_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a
1317} 1317}
1318#endif 1318#endif
1319 1319
1320static struct loop_device *loop_find_dev(int number)
1321{
1322 struct loop_device *lo;
1323
1324 list_for_each_entry(lo, &loop_devices, lo_list) {
1325 if (lo->lo_number == number)
1326 return lo;
1327 }
1328 return NULL;
1329}
1330
1331static struct loop_device *loop_init_one(int i);
1332static int lo_open(struct inode *inode, struct file *file) 1320static int lo_open(struct inode *inode, struct file *file)
1333{ 1321{
1334 struct loop_device *lo = inode->i_bdev->bd_disk->private_data; 1322 struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
@@ -1337,11 +1325,6 @@ static int lo_open(struct inode *inode, struct file *file)
1337 lo->lo_refcnt++; 1325 lo->lo_refcnt++;
1338 mutex_unlock(&lo->lo_ctl_mutex); 1326 mutex_unlock(&lo->lo_ctl_mutex);
1339 1327
1340 mutex_lock(&loop_devices_mutex);
1341 if (!loop_find_dev(lo->lo_number + 1))
1342 loop_init_one(lo->lo_number + 1);
1343 mutex_unlock(&loop_devices_mutex);
1344
1345 return 0; 1328 return 0;
1346} 1329}
1347 1330
@@ -1448,7 +1431,7 @@ out_free_queue:
1448out_free_dev: 1431out_free_dev:
1449 kfree(lo); 1432 kfree(lo);
1450out: 1433out:
1451 return ERR_PTR(-ENOMEM); 1434 return NULL;
1452} 1435}
1453 1436
1454static void loop_del_one(struct loop_device *lo) 1437static void loop_del_one(struct loop_device *lo)
@@ -1460,36 +1443,30 @@ static void loop_del_one(struct loop_device *lo)
1460 kfree(lo); 1443 kfree(lo);
1461} 1444}
1462 1445
1446static int loop_lock(dev_t dev, void *data)
1447{
1448 mutex_lock(&loop_devices_mutex);
1449 return 0;
1450}
1451
1463static struct kobject *loop_probe(dev_t dev, int *part, void *data) 1452static struct kobject *loop_probe(dev_t dev, int *part, void *data)
1464{ 1453{
1465 unsigned int number = dev & MINORMASK; 1454 struct loop_device *lo = loop_init_one(dev & MINORMASK);
1466 struct loop_device *lo; 1455 struct kobject *kobj;
1467 1456
1468 mutex_lock(&loop_devices_mutex); 1457 kobj = lo ? get_disk(lo->lo_disk) : ERR_PTR(-ENOMEM);
1469 lo = loop_find_dev(number);
1470 if (lo == NULL)
1471 lo = loop_init_one(number);
1472 mutex_unlock(&loop_devices_mutex); 1458 mutex_unlock(&loop_devices_mutex);
1473 1459
1474 *part = 0; 1460 *part = 0;
1475 if (IS_ERR(lo)) 1461 return kobj;
1476 return (void *)lo;
1477 else
1478 return &lo->lo_disk->kobj;
1479} 1462}
1480 1463
1481static int __init loop_init(void) 1464static int __init loop_init(void)
1482{ 1465{
1483 struct loop_device *lo;
1484
1485 if (register_blkdev(LOOP_MAJOR, "loop")) 1466 if (register_blkdev(LOOP_MAJOR, "loop"))
1486 return -EIO; 1467 return -EIO;
1487 blk_register_region(MKDEV(LOOP_MAJOR, 0), 1UL << MINORBITS, 1468 blk_register_region(MKDEV(LOOP_MAJOR, 0), 1UL << MINORBITS,
1488 THIS_MODULE, loop_probe, NULL, NULL); 1469 THIS_MODULE, loop_probe, loop_lock, NULL);
1489
1490 lo = loop_init_one(0);
1491 if (IS_ERR(lo))
1492 goto out;
1493 1470
1494 if (max_loop) { 1471 if (max_loop) {
1495 printk(KERN_INFO "loop: the max_loop option is obsolete " 1472 printk(KERN_INFO "loop: the max_loop option is obsolete "
@@ -1498,11 +1475,6 @@ static int __init loop_init(void)
1498 } 1475 }
1499 printk(KERN_INFO "loop: module loaded\n"); 1476 printk(KERN_INFO "loop: module loaded\n");
1500 return 0; 1477 return 0;
1501
1502out:
1503 unregister_blkdev(LOOP_MAJOR, "loop");
1504 printk(KERN_ERR "loop: ran out of memory\n");
1505 return -ENOMEM;
1506} 1478}
1507 1479
1508static void __exit loop_exit(void) 1480static void __exit loop_exit(void)
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 0f4203b499af..6055b9c0ac0f 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -307,7 +307,9 @@ static void hci_uart_tty_close(struct tty_struct *tty)
307 307
308 if (hu) { 308 if (hu) {
309 struct hci_dev *hdev = hu->hdev; 309 struct hci_dev *hdev = hu->hdev;
310 hci_uart_close(hdev); 310
311 if (hdev)
312 hci_uart_close(hdev);
311 313
312 if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) { 314 if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) {
313 hu->proto->close(hu); 315 hu->proto->close(hu);
@@ -473,12 +475,18 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file,
473 tty->low_latency = 1; 475 tty->low_latency = 1;
474 } else 476 } else
475 return -EBUSY; 477 return -EBUSY;
478 break;
476 479
477 case HCIUARTGETPROTO: 480 case HCIUARTGETPROTO:
478 if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) 481 if (test_bit(HCI_UART_PROTO_SET, &hu->flags))
479 return hu->proto->id; 482 return hu->proto->id;
480 return -EUNATCH; 483 return -EUNATCH;
481 484
485 case HCIUARTGETDEVICE:
486 if (test_bit(HCI_UART_PROTO_SET, &hu->flags))
487 return hu->hdev->id;
488 return -EUNATCH;
489
482 default: 490 default:
483 err = n_tty_ioctl(tty, file, cmd, arg); 491 err = n_tty_ioctl(tty, file, cmd, arg);
484 break; 492 break;
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h
index b250e6789dee..1097ce72393f 100644
--- a/drivers/bluetooth/hci_uart.h
+++ b/drivers/bluetooth/hci_uart.h
@@ -28,8 +28,9 @@
28#endif 28#endif
29 29
30/* Ioctls */ 30/* Ioctls */
31#define HCIUARTSETPROTO _IOW('U', 200, int) 31#define HCIUARTSETPROTO _IOW('U', 200, int)
32#define HCIUARTGETPROTO _IOR('U', 201, int) 32#define HCIUARTGETPROTO _IOR('U', 201, int)
33#define HCIUARTGETDEVICE _IOR('U', 202, int)
33 34
34/* UART protocols */ 35/* UART protocols */
35#define HCI_UART_MAX_PROTO 4 36#define HCI_UART_MAX_PROTO 4
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index c9f0f250d78f..801abdd29066 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -268,7 +268,7 @@ static int __devinit aperture_valid(u64 aper, u32 size)
268 printk(KERN_ERR PFX "Aperture too small (%d MB)\n", size>>20); 268 printk(KERN_ERR PFX "Aperture too small (%d MB)\n", size>>20);
269 return 0; 269 return 0;
270 } 270 }
271 if (aper + size > 0xffffffff) { 271 if ((u64)aper + size > 0x100000000ULL) {
272 printk(KERN_ERR PFX "Aperture out of bounds\n"); 272 printk(KERN_ERR PFX "Aperture out of bounds\n");
273 return 0; 273 return 0;
274 } 274 }
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 6c5d15de3317..78e1b962fe35 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -1915,10 +1915,10 @@ static __devinit int try_init_acpi(struct SPMITable *spmi)
1915 1915
1916 if (spmi->addr.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 1916 if (spmi->addr.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
1917 info->io_setup = mem_setup; 1917 info->io_setup = mem_setup;
1918 info->io.addr_type = IPMI_IO_ADDR_SPACE; 1918 info->io.addr_type = IPMI_MEM_ADDR_SPACE;
1919 } else if (spmi->addr.space_id == ACPI_ADR_SPACE_SYSTEM_IO) { 1919 } else if (spmi->addr.space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
1920 info->io_setup = port_setup; 1920 info->io_setup = port_setup;
1921 info->io.addr_type = IPMI_MEM_ADDR_SPACE; 1921 info->io.addr_type = IPMI_IO_ADDR_SPACE;
1922 } else { 1922 } else {
1923 kfree(info); 1923 kfree(info);
1924 printk("ipmi_si: Unknown ACPI I/O Address type\n"); 1924 printk("ipmi_si: Unknown ACPI I/O Address type\n");
@@ -2974,6 +2974,10 @@ static __devinit int init_ipmi_si(void)
2974#ifdef CONFIG_PCI 2974#ifdef CONFIG_PCI
2975 pci_unregister_driver(&ipmi_pci_driver); 2975 pci_unregister_driver(&ipmi_pci_driver);
2976#endif 2976#endif
2977
2978#ifdef CONFIG_PPC_OF
2979 of_unregister_platform_driver(&ipmi_of_platform_driver);
2980#endif
2977 driver_unregister(&ipmi_driver); 2981 driver_unregister(&ipmi_driver);
2978 printk("ipmi_si: Unable to find any System Interface(s)\n"); 2982 printk("ipmi_si: Unable to find any System Interface(s)\n");
2979 return -ENODEV; 2983 return -ENODEV;
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index 6ac3ca4c723c..b3d4ccc33a47 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -1544,21 +1544,18 @@ static unsigned int normal_poll(struct tty_struct * tty, struct file * file, pol
1544} 1544}
1545 1545
1546struct tty_ldisc tty_ldisc_N_TTY = { 1546struct tty_ldisc tty_ldisc_N_TTY = {
1547 TTY_LDISC_MAGIC, /* magic */ 1547 .magic = TTY_LDISC_MAGIC,
1548 "n_tty", /* name */ 1548 .name = "n_tty",
1549 0, /* num */ 1549 .open = n_tty_open,
1550 0, /* flags */ 1550 .close = n_tty_close,
1551 n_tty_open, /* open */ 1551 .flush_buffer = n_tty_flush_buffer,
1552 n_tty_close, /* close */ 1552 .chars_in_buffer = n_tty_chars_in_buffer,
1553 n_tty_flush_buffer, /* flush_buffer */ 1553 .read = read_chan,
1554 n_tty_chars_in_buffer, /* chars_in_buffer */ 1554 .write = write_chan,
1555 read_chan, /* read */ 1555 .ioctl = n_tty_ioctl,
1556 write_chan, /* write */ 1556 .set_termios = n_tty_set_termios,
1557 n_tty_ioctl, /* ioctl */ 1557 .poll = normal_poll,
1558 n_tty_set_termios, /* set_termios */ 1558 .receive_buf = n_tty_receive_buf,
1559 normal_poll, /* poll */ 1559 .write_wakeup = n_tty_write_wakeup
1560 NULL, /* hangup */
1561 n_tty_receive_buf, /* receive_buf */
1562 n_tty_write_wakeup /* write_wakeup */
1563}; 1560};
1564 1561
diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c
index 245f03195b7c..8cc60b693460 100644
--- a/drivers/char/rio/riocmd.c
+++ b/drivers/char/rio/riocmd.c
@@ -402,7 +402,7 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struc
402 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %Zd, name ``%s''\n", HostP - p->RIOHosts, HostP->Name); 402 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %Zd, name ``%s''\n", HostP - p->RIOHosts, HostP->Name);
403 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Rup number 0x%x\n", rup); 403 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Rup number 0x%x\n", rup);
404 404
405 if (Rup >= (unsigned short) MAX_RUP) { 405 if (Rup < (unsigned short) MAX_RUP) {
406 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n", HostP->Mapping[Rup].Name); 406 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n", HostP->Mapping[Rup].Name);
407 } else 407 } else
408 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", ('A' + Rup - MAX_RUP), HostP->Name); 408 rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", ('A' + Rup - MAX_RUP), HostP->Name);
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index 61a63da420c2..a3fd7e7ba5a9 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -1014,9 +1014,6 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
1014 /* 1014 /*
1015 * Info->count is now 1; so it's safe to sleep now. 1015 * Info->count is now 1; so it's safe to sleep now.
1016 */ 1016 */
1017 info->session = process_session(current);
1018 info->pgrp = process_group(current);
1019
1020 if ((info->flags & ROCKET_INITIALIZED) == 0) { 1017 if ((info->flags & ROCKET_INITIALIZED) == 0) {
1021 cp = &info->channel; 1018 cp = &info->channel;
1022 sSetRxTrigger(cp, TRIG_1); 1019 sSetRxTrigger(cp, TRIG_1);
diff --git a/drivers/char/rocket_int.h b/drivers/char/rocket_int.h
index 89b4d7b10d12..b4c53dfa7951 100644
--- a/drivers/char/rocket_int.h
+++ b/drivers/char/rocket_int.h
@@ -1158,8 +1158,6 @@ struct r_port {
1158 int xmit_head; 1158 int xmit_head;
1159 int xmit_tail; 1159 int xmit_tail;
1160 int xmit_cnt; 1160 int xmit_cnt;
1161 int session;
1162 int pgrp;
1163 int cd_status; 1161 int cd_status;
1164 int ignore_status_mask; 1162 int ignore_status_mask;
1165 int read_status_mask; 1163 int read_status_mask;
diff --git a/drivers/char/snsc_event.c b/drivers/char/snsc_event.c
index 2f56e8c54897..1b75b0b7d542 100644
--- a/drivers/char/snsc_event.c
+++ b/drivers/char/snsc_event.c
@@ -203,8 +203,6 @@ scdrv_dispatch_event(char *event, int len)
203 class = (code & EV_CLASS_MASK); 203 class = (code & EV_CLASS_MASK);
204 204
205 if (class == EV_CLASS_PWRD_NOTIFY || code == ENV_PWRDN_PEND) { 205 if (class == EV_CLASS_PWRD_NOTIFY || code == ENV_PWRDN_PEND) {
206 struct task_struct *p;
207
208 if (snsc_shutting_down) 206 if (snsc_shutting_down)
209 return; 207 return;
210 208
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index 2a7736b5f2f7..02b49bc00028 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -1171,6 +1171,112 @@ static int ioctl(struct tty_struct *tty, struct file *file,
1171} 1171}
1172 1172
1173/* 1173/*
1174 * support for 32 bit ioctl calls on 64 bit systems
1175 */
1176#ifdef CONFIG_COMPAT
1177static long get_params32(struct slgt_info *info, struct MGSL_PARAMS32 __user *user_params)
1178{
1179 struct MGSL_PARAMS32 tmp_params;
1180
1181 DBGINFO(("%s get_params32\n", info->device_name));
1182 tmp_params.mode = (compat_ulong_t)info->params.mode;
1183 tmp_params.loopback = info->params.loopback;
1184 tmp_params.flags = info->params.flags;
1185 tmp_params.encoding = info->params.encoding;
1186 tmp_params.clock_speed = (compat_ulong_t)info->params.clock_speed;
1187 tmp_params.addr_filter = info->params.addr_filter;
1188 tmp_params.crc_type = info->params.crc_type;
1189 tmp_params.preamble_length = info->params.preamble_length;
1190 tmp_params.preamble = info->params.preamble;
1191 tmp_params.data_rate = (compat_ulong_t)info->params.data_rate;
1192 tmp_params.data_bits = info->params.data_bits;
1193 tmp_params.stop_bits = info->params.stop_bits;
1194 tmp_params.parity = info->params.parity;
1195 if (copy_to_user(user_params, &tmp_params, sizeof(struct MGSL_PARAMS32)))
1196 return -EFAULT;
1197 return 0;
1198}
1199
1200static long set_params32(struct slgt_info *info, struct MGSL_PARAMS32 __user *new_params)
1201{
1202 struct MGSL_PARAMS32 tmp_params;
1203
1204 DBGINFO(("%s set_params32\n", info->device_name));
1205 if (copy_from_user(&tmp_params, new_params, sizeof(struct MGSL_PARAMS32)))
1206 return -EFAULT;
1207
1208 spin_lock(&info->lock);
1209 info->params.mode = tmp_params.mode;
1210 info->params.loopback = tmp_params.loopback;
1211 info->params.flags = tmp_params.flags;
1212 info->params.encoding = tmp_params.encoding;
1213 info->params.clock_speed = tmp_params.clock_speed;
1214 info->params.addr_filter = tmp_params.addr_filter;
1215 info->params.crc_type = tmp_params.crc_type;
1216 info->params.preamble_length = tmp_params.preamble_length;
1217 info->params.preamble = tmp_params.preamble;
1218 info->params.data_rate = tmp_params.data_rate;
1219 info->params.data_bits = tmp_params.data_bits;
1220 info->params.stop_bits = tmp_params.stop_bits;
1221 info->params.parity = tmp_params.parity;
1222 spin_unlock(&info->lock);
1223
1224 change_params(info);
1225
1226 return 0;
1227}
1228
1229static long slgt_compat_ioctl(struct tty_struct *tty, struct file *file,
1230 unsigned int cmd, unsigned long arg)
1231{
1232 struct slgt_info *info = tty->driver_data;
1233 int rc = -ENOIOCTLCMD;
1234
1235 if (sanity_check(info, tty->name, "compat_ioctl"))
1236 return -ENODEV;
1237 DBGINFO(("%s compat_ioctl() cmd=%08X\n", info->device_name, cmd));
1238
1239 switch (cmd) {
1240
1241 case MGSL_IOCSPARAMS32:
1242 rc = set_params32(info, compat_ptr(arg));
1243 break;
1244
1245 case MGSL_IOCGPARAMS32:
1246 rc = get_params32(info, compat_ptr(arg));
1247 break;
1248
1249 case MGSL_IOCGPARAMS:
1250 case MGSL_IOCSPARAMS:
1251 case MGSL_IOCGTXIDLE:
1252 case MGSL_IOCGSTATS:
1253 case MGSL_IOCWAITEVENT:
1254 case MGSL_IOCGIF:
1255 case MGSL_IOCSGPIO:
1256 case MGSL_IOCGGPIO:
1257 case MGSL_IOCWAITGPIO:
1258 case TIOCGICOUNT:
1259 rc = ioctl(tty, file, cmd, (unsigned long)(compat_ptr(arg)));
1260 break;
1261
1262 case MGSL_IOCSTXIDLE:
1263 case MGSL_IOCTXENABLE:
1264 case MGSL_IOCRXENABLE:
1265 case MGSL_IOCTXABORT:
1266 case TIOCMIWAIT:
1267 case MGSL_IOCSIF:
1268 rc = ioctl(tty, file, cmd, arg);
1269 break;
1270 }
1271
1272 DBGINFO(("%s compat_ioctl() cmd=%08X rc=%d\n", info->device_name, cmd, rc));
1273 return rc;
1274}
1275#else
1276#define slgt_compat_ioctl NULL
1277#endif /* ifdef CONFIG_COMPAT */
1278
1279/*
1174 * proc fs support 1280 * proc fs support
1175 */ 1281 */
1176static inline int line_info(char *buf, struct slgt_info *info) 1282static inline int line_info(char *buf, struct slgt_info *info)
@@ -3446,6 +3552,7 @@ static const struct tty_operations ops = {
3446 .chars_in_buffer = chars_in_buffer, 3552 .chars_in_buffer = chars_in_buffer,
3447 .flush_buffer = flush_buffer, 3553 .flush_buffer = flush_buffer,
3448 .ioctl = ioctl, 3554 .ioctl = ioctl,
3555 .compat_ioctl = slgt_compat_ioctl,
3449 .throttle = throttle, 3556 .throttle = throttle,
3450 .unthrottle = unthrottle, 3557 .unthrottle = unthrottle,
3451 .send_xchar = send_xchar, 3558 .send_xchar = send_xchar,
diff --git a/drivers/char/tpm/tpm_atmel.h b/drivers/char/tpm/tpm_atmel.h
index c912d8691cbd..9363bcf0a402 100644
--- a/drivers/char/tpm/tpm_atmel.h
+++ b/drivers/char/tpm/tpm_atmel.h
@@ -23,6 +23,9 @@
23 */ 23 */
24 24
25#ifdef CONFIG_PPC64 25#ifdef CONFIG_PPC64
26
27#include <asm/prom.h>
28
26#define atmel_getb(chip, offset) readb(chip->vendor->iobase + offset); 29#define atmel_getb(chip, offset) readb(chip->vendor->iobase + offset);
27#define atmel_putb(val, chip, offset) writeb(val, chip->vendor->iobase + offset) 30#define atmel_putb(val, chip, offset) writeb(val, chip->vendor->iobase + offset)
28#define atmel_request_region request_mem_region 31#define atmel_request_region request_mem_region
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index fc662e4ce58a..75d2a46e106f 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -151,6 +151,12 @@ static int tty_open(struct inode *, struct file *);
151static int tty_release(struct inode *, struct file *); 151static int tty_release(struct inode *, struct file *);
152int tty_ioctl(struct inode * inode, struct file * file, 152int tty_ioctl(struct inode * inode, struct file * file,
153 unsigned int cmd, unsigned long arg); 153 unsigned int cmd, unsigned long arg);
154#ifdef CONFIG_COMPAT
155static long tty_compat_ioctl(struct file * file, unsigned int cmd,
156 unsigned long arg);
157#else
158#define tty_compat_ioctl NULL
159#endif
154static int tty_fasync(int fd, struct file * filp, int on); 160static int tty_fasync(int fd, struct file * filp, int on);
155static void release_tty(struct tty_struct *tty, int idx); 161static void release_tty(struct tty_struct *tty, int idx);
156static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty); 162static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty);
@@ -363,6 +369,29 @@ static void tty_buffer_free(struct tty_struct *tty, struct tty_buffer *b)
363} 369}
364 370
365/** 371/**
372 * tty_buffer_flush - flush full tty buffers
373 * @tty: tty to flush
374 *
375 * flush all the buffers containing receive data
376 *
377 * Locking: none
378 */
379
380static void tty_buffer_flush(struct tty_struct *tty)
381{
382 struct tty_buffer *thead;
383 unsigned long flags;
384
385 spin_lock_irqsave(&tty->buf.lock, flags);
386 while((thead = tty->buf.head) != NULL) {
387 tty->buf.head = thead->next;
388 tty_buffer_free(tty, thead);
389 }
390 tty->buf.tail = NULL;
391 spin_unlock_irqrestore(&tty->buf.lock, flags);
392}
393
394/**
366 * tty_buffer_find - find a free tty buffer 395 * tty_buffer_find - find a free tty buffer
367 * @tty: tty owning the buffer 396 * @tty: tty owning the buffer
368 * @size: characters wanted 397 * @size: characters wanted
@@ -1143,8 +1172,8 @@ static unsigned int hung_up_tty_poll(struct file * filp, poll_table * wait)
1143 return POLLIN | POLLOUT | POLLERR | POLLHUP | POLLRDNORM | POLLWRNORM; 1172 return POLLIN | POLLOUT | POLLERR | POLLHUP | POLLRDNORM | POLLWRNORM;
1144} 1173}
1145 1174
1146static int hung_up_tty_ioctl(struct inode * inode, struct file * file, 1175static long hung_up_tty_ioctl(struct file * file,
1147 unsigned int cmd, unsigned long arg) 1176 unsigned int cmd, unsigned long arg)
1148{ 1177{
1149 return cmd == TIOCSPGRP ? -ENOTTY : -EIO; 1178 return cmd == TIOCSPGRP ? -ENOTTY : -EIO;
1150} 1179}
@@ -1155,6 +1184,7 @@ static const struct file_operations tty_fops = {
1155 .write = tty_write, 1184 .write = tty_write,
1156 .poll = tty_poll, 1185 .poll = tty_poll,
1157 .ioctl = tty_ioctl, 1186 .ioctl = tty_ioctl,
1187 .compat_ioctl = tty_compat_ioctl,
1158 .open = tty_open, 1188 .open = tty_open,
1159 .release = tty_release, 1189 .release = tty_release,
1160 .fasync = tty_fasync, 1190 .fasync = tty_fasync,
@@ -1167,6 +1197,7 @@ static const struct file_operations ptmx_fops = {
1167 .write = tty_write, 1197 .write = tty_write,
1168 .poll = tty_poll, 1198 .poll = tty_poll,
1169 .ioctl = tty_ioctl, 1199 .ioctl = tty_ioctl,
1200 .compat_ioctl = tty_compat_ioctl,
1170 .open = ptmx_open, 1201 .open = ptmx_open,
1171 .release = tty_release, 1202 .release = tty_release,
1172 .fasync = tty_fasync, 1203 .fasync = tty_fasync,
@@ -1179,6 +1210,7 @@ static const struct file_operations console_fops = {
1179 .write = redirected_tty_write, 1210 .write = redirected_tty_write,
1180 .poll = tty_poll, 1211 .poll = tty_poll,
1181 .ioctl = tty_ioctl, 1212 .ioctl = tty_ioctl,
1213 .compat_ioctl = tty_compat_ioctl,
1182 .open = tty_open, 1214 .open = tty_open,
1183 .release = tty_release, 1215 .release = tty_release,
1184 .fasync = tty_fasync, 1216 .fasync = tty_fasync,
@@ -1189,7 +1221,8 @@ static const struct file_operations hung_up_tty_fops = {
1189 .read = hung_up_tty_read, 1221 .read = hung_up_tty_read,
1190 .write = hung_up_tty_write, 1222 .write = hung_up_tty_write,
1191 .poll = hung_up_tty_poll, 1223 .poll = hung_up_tty_poll,
1192 .ioctl = hung_up_tty_ioctl, 1224 .unlocked_ioctl = hung_up_tty_ioctl,
1225 .compat_ioctl = hung_up_tty_ioctl,
1193 .release = tty_release, 1226 .release = tty_release,
1194}; 1227};
1195 1228
@@ -1238,6 +1271,7 @@ void tty_ldisc_flush(struct tty_struct *tty)
1238 ld->flush_buffer(tty); 1271 ld->flush_buffer(tty);
1239 tty_ldisc_deref(ld); 1272 tty_ldisc_deref(ld);
1240 } 1273 }
1274 tty_buffer_flush(tty);
1241} 1275}
1242 1276
1243EXPORT_SYMBOL_GPL(tty_ldisc_flush); 1277EXPORT_SYMBOL_GPL(tty_ldisc_flush);
@@ -3340,6 +3374,15 @@ int tty_ioctl(struct inode * inode, struct file * file,
3340 case TIOCMBIC: 3374 case TIOCMBIC:
3341 case TIOCMBIS: 3375 case TIOCMBIS:
3342 return tty_tiocmset(tty, file, cmd, p); 3376 return tty_tiocmset(tty, file, cmd, p);
3377 case TCFLSH:
3378 switch (arg) {
3379 case TCIFLUSH:
3380 case TCIOFLUSH:
3381 /* flush tty buffer and allow ldisc to process ioctl */
3382 tty_buffer_flush(tty);
3383 break;
3384 }
3385 break;
3343 } 3386 }
3344 if (tty->driver->ioctl) { 3387 if (tty->driver->ioctl) {
3345 retval = (tty->driver->ioctl)(tty, file, cmd, arg); 3388 retval = (tty->driver->ioctl)(tty, file, cmd, arg);
@@ -3357,6 +3400,32 @@ int tty_ioctl(struct inode * inode, struct file * file,
3357 return retval; 3400 return retval;
3358} 3401}
3359 3402
3403#ifdef CONFIG_COMPAT
3404static long tty_compat_ioctl(struct file * file, unsigned int cmd,
3405 unsigned long arg)
3406{
3407 struct inode *inode = file->f_dentry->d_inode;
3408 struct tty_struct *tty = file->private_data;
3409 struct tty_ldisc *ld;
3410 int retval = -ENOIOCTLCMD;
3411
3412 if (tty_paranoia_check(tty, inode, "tty_ioctl"))
3413 return -EINVAL;
3414
3415 if (tty->driver->compat_ioctl) {
3416 retval = (tty->driver->compat_ioctl)(tty, file, cmd, arg);
3417 if (retval != -ENOIOCTLCMD)
3418 return retval;
3419 }
3420
3421 ld = tty_ldisc_ref_wait(tty);
3422 if (ld->compat_ioctl)
3423 retval = ld->compat_ioctl(tty, file, cmd, arg);
3424 tty_ldisc_deref(ld);
3425
3426 return retval;
3427}
3428#endif
3360 3429
3361/* 3430/*
3362 * This implements the "Secure Attention Key" --- the idea is to 3431 * This implements the "Secure Attention Key" --- the idea is to
@@ -3689,6 +3758,7 @@ void tty_set_operations(struct tty_driver *driver,
3689 driver->write_room = op->write_room; 3758 driver->write_room = op->write_room;
3690 driver->chars_in_buffer = op->chars_in_buffer; 3759 driver->chars_in_buffer = op->chars_in_buffer;
3691 driver->ioctl = op->ioctl; 3760 driver->ioctl = op->ioctl;
3761 driver->compat_ioctl = op->compat_ioctl;
3692 driver->set_termios = op->set_termios; 3762 driver->set_termios = op->set_termios;
3693 driver->throttle = op->throttle; 3763 driver->throttle = op->throttle;
3694 driver->unthrottle = op->unthrottle; 3764 driver->unthrottle = op->unthrottle;
@@ -3843,6 +3913,7 @@ void proc_clear_tty(struct task_struct *p)
3843 p->signal->tty = NULL; 3913 p->signal->tty = NULL;
3844 spin_unlock_irq(&p->sighand->siglock); 3914 spin_unlock_irq(&p->sighand->siglock);
3845} 3915}
3916EXPORT_SYMBOL(proc_clear_tty);
3846 3917
3847static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty) 3918static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty)
3848{ 3919{
diff --git a/drivers/char/watchdog/iTCO_wdt.c b/drivers/char/watchdog/iTCO_wdt.c
index 3c9684ccd2f9..eac4f9b9f007 100644
--- a/drivers/char/watchdog/iTCO_wdt.c
+++ b/drivers/char/watchdog/iTCO_wdt.c
@@ -571,7 +571,7 @@ static int iTCO_wdt_init(struct pci_dev *pdev, const struct pci_device_id *ent,
571 * ACPIBASE is bits [15:7] from 0x40-0x43 571 * ACPIBASE is bits [15:7] from 0x40-0x43
572 */ 572 */
573 pci_read_config_dword(pdev, 0x40, &base_address); 573 pci_read_config_dword(pdev, 0x40, &base_address);
574 base_address &= 0x00007f80; 574 base_address &= 0x0000ff80;
575 if (base_address == 0x00000000) { 575 if (base_address == 0x00000000) {
576 /* Something's wrong here, ACPIBASE has to be set */ 576 /* Something's wrong here, ACPIBASE has to be set */
577 printk(KERN_ERR PFX "failed to get TCOBASE address\n"); 577 printk(KERN_ERR PFX "failed to get TCOBASE address\n");
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index a19b65ed3119..7f817897b178 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -240,11 +240,94 @@ static inline void hidinput_pb_setup(struct input_dev *input)
240} 240}
241#endif 241#endif
242 242
243static inline int match_scancode(int code, int scancode)
244{
245 if (scancode == 0)
246 return 1;
247 return ((code & (HID_USAGE_PAGE | HID_USAGE)) == scancode);
248}
249
250static inline int match_keycode(int code, int keycode)
251{
252 if (keycode == 0)
253 return 1;
254 return (code == keycode);
255}
256
257static struct hid_usage *hidinput_find_key(struct hid_device *hid,
258 int scancode, int keycode)
259{
260 int i, j, k;
261 struct hid_report *report;
262 struct hid_usage *usage;
263
264 for (k = HID_INPUT_REPORT; k <= HID_OUTPUT_REPORT; k++) {
265 list_for_each_entry(report, &hid->report_enum[k].report_list, list) {
266 for (i = 0; i < report->maxfield; i++) {
267 for ( j = 0; j < report->field[i]->maxusage; j++) {
268 usage = report->field[i]->usage + j;
269 if (usage->type == EV_KEY &&
270 match_scancode(usage->hid, scancode) &&
271 match_keycode(usage->code, keycode))
272 return usage;
273 }
274 }
275 }
276 }
277 return NULL;
278}
279
280static int hidinput_getkeycode(struct input_dev *dev, int scancode,
281 int *keycode)
282{
283 struct hid_device *hid = dev->private;
284 struct hid_usage *usage;
285
286 usage = hidinput_find_key(hid, scancode, 0);
287 if (usage) {
288 *keycode = usage->code;
289 return 0;
290 }
291 return -EINVAL;
292}
293
294static int hidinput_setkeycode(struct input_dev *dev, int scancode,
295 int keycode)
296{
297 struct hid_device *hid = dev->private;
298 struct hid_usage *usage;
299 int old_keycode;
300
301 if (keycode < 0 || keycode > KEY_MAX)
302 return -EINVAL;
303
304 usage = hidinput_find_key(hid, scancode, 0);
305 if (usage) {
306 old_keycode = usage->code;
307 usage->code = keycode;
308
309 clear_bit(old_keycode, dev->keybit);
310 set_bit(usage->code, dev->keybit);
311#ifdef CONFIG_HID_DEBUG
312 printk (KERN_DEBUG "Assigned keycode %d to HID usage code %x\n", keycode, scancode);
313#endif
314 /* Set the keybit for the old keycode if the old keycode is used
315 * by another key */
316 if (hidinput_find_key (hid, 0, old_keycode))
317 set_bit(old_keycode, dev->keybit);
318
319 return 0;
320 }
321
322 return -EINVAL;
323}
324
325
243static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, 326static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field,
244 struct hid_usage *usage) 327 struct hid_usage *usage)
245{ 328{
246 struct input_dev *input = hidinput->input; 329 struct input_dev *input = hidinput->input;
247 struct hid_device *device = input->private; 330 struct hid_device *device = input_get_drvdata(input);
248 int max = 0, code; 331 int max = 0, code;
249 unsigned long *bit = NULL; 332 unsigned long *bit = NULL;
250 333
@@ -553,6 +636,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
553 case 0x1015: map_key_clear(KEY_RECORD); break; 636 case 0x1015: map_key_clear(KEY_RECORD); break;
554 case 0x1016: map_key_clear(KEY_PLAYER); break; 637 case 0x1016: map_key_clear(KEY_PLAYER); break;
555 case 0x1017: map_key_clear(KEY_EJECTCD); break; 638 case 0x1017: map_key_clear(KEY_EJECTCD); break;
639 case 0x1018: map_key_clear(KEY_MEDIA); break;
556 case 0x1019: map_key_clear(KEY_PROG1); break; 640 case 0x1019: map_key_clear(KEY_PROG1); break;
557 case 0x101a: map_key_clear(KEY_PROG2); break; 641 case 0x101a: map_key_clear(KEY_PROG2); break;
558 case 0x101b: map_key_clear(KEY_PROG3); break; 642 case 0x101b: map_key_clear(KEY_PROG3); break;
@@ -560,9 +644,12 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
560 case 0x1020: map_key_clear(KEY_ZOOMOUT); break; 644 case 0x1020: map_key_clear(KEY_ZOOMOUT); break;
561 case 0x1021: map_key_clear(KEY_ZOOMRESET); break; 645 case 0x1021: map_key_clear(KEY_ZOOMRESET); break;
562 case 0x1023: map_key_clear(KEY_CLOSE); break; 646 case 0x1023: map_key_clear(KEY_CLOSE); break;
647 case 0x1027: map_key_clear(KEY_MENU); break;
563 /* this one is marked as 'Rotate' */ 648 /* this one is marked as 'Rotate' */
564 case 0x1028: map_key_clear(KEY_ANGLE); break; 649 case 0x1028: map_key_clear(KEY_ANGLE); break;
565 case 0x1029: map_key_clear(KEY_SHUFFLE); break; 650 case 0x1029: map_key_clear(KEY_SHUFFLE); break;
651 case 0x102a: map_key_clear(KEY_BACK); break;
652 case 0x102b: map_key_clear(KEY_CYCLEWINDOWS); break;
566 case 0x1041: map_key_clear(KEY_BATTERY); break; 653 case 0x1041: map_key_clear(KEY_BATTERY); break;
567 case 0x1042: map_key_clear(KEY_WORDPROCESSOR); break; 654 case 0x1042: map_key_clear(KEY_WORDPROCESSOR); break;
568 case 0x1043: map_key_clear(KEY_SPREADSHEET); break; 655 case 0x1043: map_key_clear(KEY_SPREADSHEET); break;
@@ -855,13 +942,15 @@ EXPORT_SYMBOL_GPL(hidinput_find_field);
855 942
856static int hidinput_open(struct input_dev *dev) 943static int hidinput_open(struct input_dev *dev)
857{ 944{
858 struct hid_device *hid = dev->private; 945 struct hid_device *hid = input_get_drvdata(dev);
946
859 return hid->hid_open(hid); 947 return hid->hid_open(hid);
860} 948}
861 949
862static void hidinput_close(struct input_dev *dev) 950static void hidinput_close(struct input_dev *dev)
863{ 951{
864 struct hid_device *hid = dev->private; 952 struct hid_device *hid = input_get_drvdata(dev);
953
865 hid->hid_close(hid); 954 hid->hid_close(hid);
866} 955}
867 956
@@ -909,10 +998,12 @@ int hidinput_connect(struct hid_device *hid)
909 return -1; 998 return -1;
910 } 999 }
911 1000
912 input_dev->private = hid; 1001 input_set_drvdata(input_dev, hid);
913 input_dev->event = hid->hidinput_input_event; 1002 input_dev->event = hid->hidinput_input_event;
914 input_dev->open = hidinput_open; 1003 input_dev->open = hidinput_open;
915 input_dev->close = hidinput_close; 1004 input_dev->close = hidinput_close;
1005 input_dev->setkeycode = hidinput_setkeycode;
1006 input_dev->getkeycode = hidinput_getkeycode;
916 1007
917 input_dev->name = hid->name; 1008 input_dev->name = hid->name;
918 input_dev->phys = hid->phys; 1009 input_dev->phys = hid->phys;
@@ -921,7 +1012,7 @@ int hidinput_connect(struct hid_device *hid)
921 input_dev->id.vendor = hid->vendor; 1012 input_dev->id.vendor = hid->vendor;
922 input_dev->id.product = hid->product; 1013 input_dev->id.product = hid->product;
923 input_dev->id.version = hid->version; 1014 input_dev->id.version = hid->version;
924 input_dev->cdev.dev = hid->dev; 1015 input_dev->dev.parent = hid->dev;
925 hidinput->input = input_dev; 1016 hidinput->input = input_dev;
926 list_add_tail(&hidinput->list, &hid->inputs); 1017 list_add_tail(&hidinput->list, &hid->inputs);
927 } 1018 }
diff --git a/drivers/hid/usbhid/Kconfig b/drivers/hid/usbhid/Kconfig
index 7c87bdc538bc..1b4b572f899b 100644
--- a/drivers/hid/usbhid/Kconfig
+++ b/drivers/hid/usbhid/Kconfig
@@ -25,12 +25,12 @@ comment "Input core support is needed for USB HID input layer or HIDBP support"
25 depends on USB_HID && INPUT=n 25 depends on USB_HID && INPUT=n
26 26
27config USB_HIDINPUT_POWERBOOK 27config USB_HIDINPUT_POWERBOOK
28 bool "Enable support for iBook/PowerBook special keys" 28 bool "Enable support for iBook/PowerBook/MacBook/MacBookPro special keys"
29 default n 29 default n
30 depends on USB_HID 30 depends on USB_HID
31 help 31 help
32 Say Y here if you want support for the special keys (Fn, Numlock) on 32 Say Y here if you want support for the special keys (Fn, Numlock) on
33 Apple iBooks and PowerBooks. 33 Apple iBooks, PowerBooks, MacBooks and MacBook Pros.
34 34
35 If unsure, say N. 35 If unsure, say N.
36 36
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 91d610358d57..d91b9dac6dff 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -446,7 +446,7 @@ void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, uns
446 446
447static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 447static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
448{ 448{
449 struct hid_device *hid = dev->private; 449 struct hid_device *hid = input_get_drvdata(dev);
450 struct hid_field *field; 450 struct hid_field *field;
451 int offset; 451 int offset;
452 452
@@ -626,14 +626,10 @@ static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid)
626{ 626{
627 struct usbhid_device *usbhid = hid->driver_data; 627 struct usbhid_device *usbhid = hid->driver_data;
628 628
629 if (usbhid->inbuf) 629 usb_buffer_free(dev, usbhid->bufsize, usbhid->inbuf, usbhid->inbuf_dma);
630 usb_buffer_free(dev, usbhid->bufsize, usbhid->inbuf, usbhid->inbuf_dma); 630 usb_buffer_free(dev, usbhid->bufsize, usbhid->outbuf, usbhid->outbuf_dma);
631 if (usbhid->outbuf) 631 usb_buffer_free(dev, sizeof(*(usbhid->cr)), usbhid->cr, usbhid->cr_dma);
632 usb_buffer_free(dev, usbhid->bufsize, usbhid->outbuf, usbhid->outbuf_dma); 632 usb_buffer_free(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma);
633 if (usbhid->cr)
634 usb_buffer_free(dev, sizeof(*(usbhid->cr)), usbhid->cr, usbhid->cr_dma);
635 if (usbhid->ctrlbuf)
636 usb_buffer_free(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma);
637} 633}
638 634
639/* 635/*
@@ -692,6 +688,30 @@ static void hid_fixup_logitech_descriptor(unsigned char *rdesc, int rsize)
692 } 688 }
693} 689}
694 690
691/*
692 * Some USB barcode readers from cypress have usage min and usage max in
693 * the wrong order
694 */
695static void hid_fixup_cypress_descriptor(unsigned char *rdesc, int rsize)
696{
697 short fixed = 0;
698 int i;
699
700 for (i = 0; i < rsize - 4; i++) {
701 if (rdesc[i] == 0x29 && rdesc [i+2] == 0x19) {
702 unsigned char tmp;
703
704 rdesc[i] = 0x19; rdesc[i+2] = 0x29;
705 tmp = rdesc[i+3];
706 rdesc[i+3] = rdesc[i+1];
707 rdesc[i+1] = tmp;
708 }
709 }
710
711 if (fixed)
712 info("Fixing up Cypress report descriptor");
713}
714
695static struct hid_device *usb_hid_configure(struct usb_interface *intf) 715static struct hid_device *usb_hid_configure(struct usb_interface *intf)
696{ 716{
697 struct usb_host_interface *interface = intf->cur_altsetting; 717 struct usb_host_interface *interface = intf->cur_altsetting;
@@ -758,6 +778,9 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
758 if (quirks & HID_QUIRK_LOGITECH_DESCRIPTOR) 778 if (quirks & HID_QUIRK_LOGITECH_DESCRIPTOR)
759 hid_fixup_logitech_descriptor(rdesc, rsize); 779 hid_fixup_logitech_descriptor(rdesc, rsize);
760 780
781 if (quirks & HID_QUIRK_SWAPPED_MIN_MAX)
782 hid_fixup_cypress_descriptor(rdesc, rsize);
783
761#ifdef CONFIG_HID_DEBUG 784#ifdef CONFIG_HID_DEBUG
762 printk(KERN_DEBUG __FILE__ ": report descriptor (size %u, read %d) = ", rsize, n); 785 printk(KERN_DEBUG __FILE__ ": report descriptor (size %u, read %d) = ", rsize, n);
763 for (n = 0; n < rsize; n++) 786 for (n = 0; n < rsize; n++)
diff --git a/drivers/hid/usbhid/hid-lgff.c b/drivers/hid/usbhid/hid-lgff.c
index 92d2553f17b6..c5cd4107d6af 100644
--- a/drivers/hid/usbhid/hid-lgff.c
+++ b/drivers/hid/usbhid/hid-lgff.c
@@ -60,7 +60,7 @@ static const struct dev_type devices[] = {
60 60
61static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *effect) 61static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *effect)
62{ 62{
63 struct hid_device *hid = dev->private; 63 struct hid_device *hid = input_get_drvdata(dev);
64 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; 64 struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
65 struct hid_report *report = list_entry(report_list->next, struct hid_report, list); 65 struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
66 int x, y; 66 int x, y;
diff --git a/drivers/hid/usbhid/hid-plff.c b/drivers/hid/usbhid/hid-plff.c
index 76d2e6e14db4..d6a8f2b49bd2 100644
--- a/drivers/hid/usbhid/hid-plff.c
+++ b/drivers/hid/usbhid/hid-plff.c
@@ -37,7 +37,7 @@ struct plff_device {
37static int hid_plff_play(struct input_dev *dev, void *data, 37static int hid_plff_play(struct input_dev *dev, void *data,
38 struct ff_effect *effect) 38 struct ff_effect *effect)
39{ 39{
40 struct hid_device *hid = dev->private; 40 struct hid_device *hid = input_get_drvdata(dev);
41 struct plff_device *plff = data; 41 struct plff_device *plff = data;
42 int left, right; 42 int left, right;
43 43
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index 17a87555e32f..f6c4145dc202 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -92,6 +92,8 @@
92#define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001 92#define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001
93#define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500 93#define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500
94#define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417 94#define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417
95#define USB_DEVICE_ID_CYPRESS_BARCODE_1 0xde61
96#define USB_DEVICE_ID_CYPRESS_BARCODE_2 0xde64
95 97
96#define USB_VENDOR_ID_DELL 0x413c 98#define USB_VENDOR_ID_DELL 0x413c
97#define USB_DEVICE_ID_DELL_W7658 0x2005 99#define USB_DEVICE_ID_DELL_W7658 0x2005
@@ -193,6 +195,7 @@
193 195
194#define USB_VENDOR_ID_LOGITECH 0x046d 196#define USB_VENDOR_ID_LOGITECH 0x046d
195#define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101 197#define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101
198#define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294
196#define USB_DEVICE_ID_S510_RECEIVER 0xc50c 199#define USB_DEVICE_ID_S510_RECEIVER 0xc50c
197#define USB_DEVICE_ID_S510_RECEIVER_2 0xc517 200#define USB_DEVICE_ID_S510_RECEIVER_2 0xc517
198#define USB_DEVICE_ID_MX3000_RECEIVER 0xc513 201#define USB_DEVICE_ID_MX3000_RECEIVER 0xc513
@@ -422,6 +425,7 @@ static const struct hid_blacklist {
422 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET }, 425 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET },
423 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, 426 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET },
424 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, 427 { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET },
428 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL, HID_QUIRK_NOGET },
425 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, 429 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET },
426 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, 430 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET },
427 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, 431 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT },
@@ -445,6 +449,9 @@ static const struct hid_blacklist {
445 449
446 { USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658, HID_QUIRK_RESET_LEDS }, 450 { USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658, HID_QUIRK_RESET_LEDS },
447 451
452 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1, HID_QUIRK_SWAPPED_MIN_MAX },
453 { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2, HID_QUIRK_SWAPPED_MIN_MAX },
454
448 { 0, 0 } 455 { 0, 0 }
449}; 456};
450 457
diff --git a/drivers/hid/usbhid/hid-tmff.c b/drivers/hid/usbhid/hid-tmff.c
index ab67331620d0..ab5ba6ef891c 100644
--- a/drivers/hid/usbhid/hid-tmff.c
+++ b/drivers/hid/usbhid/hid-tmff.c
@@ -59,7 +59,7 @@ static inline int hid_tmff_scale(unsigned int in, int minimum, int maximum)
59 59
60static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *effect) 60static int hid_tmff_play(struct input_dev *dev, void *data, struct ff_effect *effect)
61{ 61{
62 struct hid_device *hid = dev->private; 62 struct hid_device *hid = input_get_drvdata(dev);
63 struct tmff_device *tmff = data; 63 struct tmff_device *tmff = data;
64 int left, right; /* Rumbling */ 64 int left, right; /* Rumbling */
65 65
diff --git a/drivers/hid/usbhid/hid-zpff.c b/drivers/hid/usbhid/hid-zpff.c
index 7bd8238ca212..a7fbffcdaf36 100644
--- a/drivers/hid/usbhid/hid-zpff.c
+++ b/drivers/hid/usbhid/hid-zpff.c
@@ -37,7 +37,7 @@ struct zpff_device {
37static int hid_zpff_play(struct input_dev *dev, void *data, 37static int hid_zpff_play(struct input_dev *dev, void *data,
38 struct ff_effect *effect) 38 struct ff_effect *effect)
39{ 39{
40 struct hid_device *hid = dev->private; 40 struct hid_device *hid = input_get_drvdata(dev);
41 struct zpff_device *zpff = data; 41 struct zpff_device *zpff = data;
42 int left, right; 42 int left, right;
43 43
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index a8b3d66cd498..488d61bdbf2c 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -51,6 +51,7 @@ struct hiddev {
51 wait_queue_head_t wait; 51 wait_queue_head_t wait;
52 struct hid_device *hid; 52 struct hid_device *hid;
53 struct list_head list; 53 struct list_head list;
54 spinlock_t list_lock;
54}; 55};
55 56
56struct hiddev_list { 57struct hiddev_list {
@@ -161,7 +162,9 @@ static void hiddev_send_event(struct hid_device *hid,
161{ 162{
162 struct hiddev *hiddev = hid->hiddev; 163 struct hiddev *hiddev = hid->hiddev;
163 struct hiddev_list *list; 164 struct hiddev_list *list;
165 unsigned long flags;
164 166
167 spin_lock_irqsave(&hiddev->list_lock, flags);
165 list_for_each_entry(list, &hiddev->list, node) { 168 list_for_each_entry(list, &hiddev->list, node) {
166 if (uref->field_index != HID_FIELD_INDEX_NONE || 169 if (uref->field_index != HID_FIELD_INDEX_NONE ||
167 (list->flags & HIDDEV_FLAG_REPORT) != 0) { 170 (list->flags & HIDDEV_FLAG_REPORT) != 0) {
@@ -171,6 +174,7 @@ static void hiddev_send_event(struct hid_device *hid,
171 kill_fasync(&list->fasync, SIGIO, POLL_IN); 174 kill_fasync(&list->fasync, SIGIO, POLL_IN);
172 } 175 }
173 } 176 }
177 spin_unlock_irqrestore(&hiddev->list_lock, flags);
174 178
175 wake_up_interruptible(&hiddev->wait); 179 wake_up_interruptible(&hiddev->wait);
176} 180}
@@ -235,9 +239,13 @@ static int hiddev_fasync(int fd, struct file *file, int on)
235static int hiddev_release(struct inode * inode, struct file * file) 239static int hiddev_release(struct inode * inode, struct file * file)
236{ 240{
237 struct hiddev_list *list = file->private_data; 241 struct hiddev_list *list = file->private_data;
242 unsigned long flags;
238 243
239 hiddev_fasync(-1, file, 0); 244 hiddev_fasync(-1, file, 0);
245
246 spin_lock_irqsave(&list->hiddev->list_lock, flags);
240 list_del(&list->node); 247 list_del(&list->node);
248 spin_unlock_irqrestore(&list->hiddev->list_lock, flags);
241 249
242 if (!--list->hiddev->open) { 250 if (!--list->hiddev->open) {
243 if (list->hiddev->exist) 251 if (list->hiddev->exist)
@@ -257,6 +265,7 @@ static int hiddev_release(struct inode * inode, struct file * file)
257static int hiddev_open(struct inode *inode, struct file *file) 265static int hiddev_open(struct inode *inode, struct file *file)
258{ 266{
259 struct hiddev_list *list; 267 struct hiddev_list *list;
268 unsigned long flags;
260 269
261 int i = iminor(inode) - HIDDEV_MINOR_BASE; 270 int i = iminor(inode) - HIDDEV_MINOR_BASE;
262 271
@@ -267,7 +276,11 @@ static int hiddev_open(struct inode *inode, struct file *file)
267 return -ENOMEM; 276 return -ENOMEM;
268 277
269 list->hiddev = hiddev_table[i]; 278 list->hiddev = hiddev_table[i];
279
280 spin_lock_irqsave(&list->hiddev->list_lock, flags);
270 list_add_tail(&list->node, &hiddev_table[i]->list); 281 list_add_tail(&list->node, &hiddev_table[i]->list);
282 spin_unlock_irqrestore(&list->hiddev->list_lock, flags);
283
271 file->private_data = list; 284 file->private_data = list;
272 285
273 if (!list->hiddev->open++) 286 if (!list->hiddev->open++)
@@ -773,6 +786,7 @@ int hiddev_connect(struct hid_device *hid)
773 786
774 init_waitqueue_head(&hiddev->wait); 787 init_waitqueue_head(&hiddev->wait);
775 INIT_LIST_HEAD(&hiddev->list); 788 INIT_LIST_HEAD(&hiddev->list);
789 spin_lock_init(&hiddev->list_lock);
776 hiddev->hid = hid; 790 hiddev->hid = hid;
777 hiddev->exist = 1; 791 hiddev->exist = 1;
778 792
diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c
index 65aa12e8d7b3..130978780713 100644
--- a/drivers/hid/usbhid/usbkbd.c
+++ b/drivers/hid/usbhid/usbkbd.c
@@ -133,12 +133,11 @@ resubmit:
133static int usb_kbd_event(struct input_dev *dev, unsigned int type, 133static int usb_kbd_event(struct input_dev *dev, unsigned int type,
134 unsigned int code, int value) 134 unsigned int code, int value)
135{ 135{
136 struct usb_kbd *kbd = dev->private; 136 struct usb_kbd *kbd = input_get_drvdata(dev);
137 137
138 if (type != EV_LED) 138 if (type != EV_LED)
139 return -1; 139 return -1;
140 140
141
142 kbd->newleds = (!!test_bit(LED_KANA, dev->led) << 3) | (!!test_bit(LED_COMPOSE, dev->led) << 3) | 141 kbd->newleds = (!!test_bit(LED_KANA, dev->led) << 3) | (!!test_bit(LED_COMPOSE, dev->led) << 3) |
143 (!!test_bit(LED_SCROLLL, dev->led) << 2) | (!!test_bit(LED_CAPSL, dev->led) << 1) | 142 (!!test_bit(LED_SCROLLL, dev->led) << 2) | (!!test_bit(LED_CAPSL, dev->led) << 1) |
144 (!!test_bit(LED_NUML, dev->led)); 143 (!!test_bit(LED_NUML, dev->led));
@@ -175,7 +174,7 @@ static void usb_kbd_led(struct urb *urb)
175 174
176static int usb_kbd_open(struct input_dev *dev) 175static int usb_kbd_open(struct input_dev *dev)
177{ 176{
178 struct usb_kbd *kbd = dev->private; 177 struct usb_kbd *kbd = input_get_drvdata(dev);
179 178
180 kbd->irq->dev = kbd->usbdev; 179 kbd->irq->dev = kbd->usbdev;
181 if (usb_submit_urb(kbd->irq, GFP_KERNEL)) 180 if (usb_submit_urb(kbd->irq, GFP_KERNEL))
@@ -186,7 +185,7 @@ static int usb_kbd_open(struct input_dev *dev)
186 185
187static void usb_kbd_close(struct input_dev *dev) 186static void usb_kbd_close(struct input_dev *dev)
188{ 187{
189 struct usb_kbd *kbd = dev->private; 188 struct usb_kbd *kbd = input_get_drvdata(dev);
190 189
191 usb_kill_urb(kbd->irq); 190 usb_kill_urb(kbd->irq);
192} 191}
@@ -211,12 +210,9 @@ static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd)
211{ 210{
212 usb_free_urb(kbd->irq); 211 usb_free_urb(kbd->irq);
213 usb_free_urb(kbd->led); 212 usb_free_urb(kbd->led);
214 if (kbd->new) 213 usb_buffer_free(dev, 8, kbd->new, kbd->new_dma);
215 usb_buffer_free(dev, 8, kbd->new, kbd->new_dma); 214 usb_buffer_free(dev, sizeof(struct usb_ctrlrequest), kbd->cr, kbd->cr_dma);
216 if (kbd->cr) 215 usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma);
217 usb_buffer_free(dev, sizeof(struct usb_ctrlrequest), kbd->cr, kbd->cr_dma);
218 if (kbd->leds)
219 usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma);
220} 216}
221 217
222static int usb_kbd_probe(struct usb_interface *iface, 218static int usb_kbd_probe(struct usb_interface *iface,
@@ -274,8 +270,9 @@ static int usb_kbd_probe(struct usb_interface *iface,
274 input_dev->name = kbd->name; 270 input_dev->name = kbd->name;
275 input_dev->phys = kbd->phys; 271 input_dev->phys = kbd->phys;
276 usb_to_input_id(dev, &input_dev->id); 272 usb_to_input_id(dev, &input_dev->id);
277 input_dev->cdev.dev = &iface->dev; 273 input_dev->dev.parent = &iface->dev;
278 input_dev->private = kbd; 274
275 input_set_drvdata(input_dev, kbd);
279 276
280 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP); 277 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_REP);
281 input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA); 278 input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL) | BIT(LED_COMPOSE) | BIT(LED_KANA);
diff --git a/drivers/hid/usbhid/usbmouse.c b/drivers/hid/usbhid/usbmouse.c
index 573776d865e1..5345c73bcf62 100644
--- a/drivers/hid/usbhid/usbmouse.c
+++ b/drivers/hid/usbhid/usbmouse.c
@@ -96,7 +96,7 @@ resubmit:
96 96
97static int usb_mouse_open(struct input_dev *dev) 97static int usb_mouse_open(struct input_dev *dev)
98{ 98{
99 struct usb_mouse *mouse = dev->private; 99 struct usb_mouse *mouse = input_get_drvdata(dev);
100 100
101 mouse->irq->dev = mouse->usbdev; 101 mouse->irq->dev = mouse->usbdev;
102 if (usb_submit_urb(mouse->irq, GFP_KERNEL)) 102 if (usb_submit_urb(mouse->irq, GFP_KERNEL))
@@ -107,7 +107,7 @@ static int usb_mouse_open(struct input_dev *dev)
107 107
108static void usb_mouse_close(struct input_dev *dev) 108static void usb_mouse_close(struct input_dev *dev)
109{ 109{
110 struct usb_mouse *mouse = dev->private; 110 struct usb_mouse *mouse = input_get_drvdata(dev);
111 111
112 usb_kill_urb(mouse->irq); 112 usb_kill_urb(mouse->irq);
113} 113}
@@ -171,7 +171,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
171 input_dev->name = mouse->name; 171 input_dev->name = mouse->name;
172 input_dev->phys = mouse->phys; 172 input_dev->phys = mouse->phys;
173 usb_to_input_id(dev, &input_dev->id); 173 usb_to_input_id(dev, &input_dev->id);
174 input_dev->cdev.dev = &intf->dev; 174 input_dev->dev.parent = &intf->dev;
175 175
176 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); 176 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
177 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE); 177 input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
@@ -179,7 +179,8 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
179 input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA); 179 input_dev->keybit[LONG(BTN_MOUSE)] |= BIT(BTN_SIDE) | BIT(BTN_EXTRA);
180 input_dev->relbit[0] |= BIT(REL_WHEEL); 180 input_dev->relbit[0] |= BIT(REL_WHEEL);
181 181
182 input_dev->private = mouse; 182 input_set_drvdata(input_dev, mouse);
183
183 input_dev->open = usb_mouse_open; 184 input_dev->open = usb_mouse_open;
184 input_dev->close = usb_mouse_close; 185 input_dev->close = usb_mouse_close;
185 186
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 55a72592704c..b234729706be 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -336,7 +336,7 @@ static int bits_to_user(unsigned long *bits, unsigned int maxbit,
336 336
337 if (compat) { 337 if (compat) {
338 len = NBITS_COMPAT(maxbit) * sizeof(compat_long_t); 338 len = NBITS_COMPAT(maxbit) * sizeof(compat_long_t);
339 if (len < maxlen) 339 if (len > maxlen)
340 len = maxlen; 340 len = maxlen;
341 341
342 for (i = 0; i < len / sizeof(compat_long_t); i++) 342 for (i = 0; i < len / sizeof(compat_long_t); i++)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 65814b0340cb..c10ce91b64e9 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5103,7 +5103,7 @@ static int is_mddev_idle(mddev_t *mddev)
5103 * 5103 *
5104 * Note: the following is an unsigned comparison. 5104 * Note: the following is an unsigned comparison.
5105 */ 5105 */
5106 if ((curr_events - rdev->last_events + 4096) > 8192) { 5106 if ((long)curr_events - (long)rdev->last_events > 4096) {
5107 rdev->last_events = curr_events; 5107 rdev->last_events = curr_events;
5108 idle = 0; 5108 idle = 0;
5109 } 5109 }
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index 3a80e0cc7369..624b21cef5b3 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -87,6 +87,14 @@ config VIDEO_TVEEPROM
87 tristate 87 tristate
88 depends on I2C 88 depends on I2C
89 89
90config DAB
91 boolean "DAB adapters"
92 default y
93 ---help---
94 Allow selecting support for for Digital Audio Broadcasting (DAB)
95 Receiver adapters.
96
97if DAB
90config USB_DABUSB 98config USB_DABUSB
91 tristate "DABUSB driver" 99 tristate "DABUSB driver"
92 depends on USB 100 depends on USB
@@ -100,5 +108,6 @@ config USB_DABUSB
100 108
101 To compile this driver as a module, choose M here: the 109 To compile this driver as a module, choose M here: the
102 module will be called dabusb. 110 module will be called dabusb.
111endif # DAB
103 112
104endmenu 113endmenu
diff --git a/drivers/media/Makefile b/drivers/media/Makefile
index c578a529e7a8..8fa19939c2b6 100644
--- a/drivers/media/Makefile
+++ b/drivers/media/Makefile
@@ -5,4 +5,4 @@
5obj-y := common/ 5obj-y := common/
6obj-$(CONFIG_VIDEO_DEV) += video/ 6obj-$(CONFIG_VIDEO_DEV) += video/
7obj-$(CONFIG_VIDEO_DEV) += radio/ 7obj-$(CONFIG_VIDEO_DEV) += radio/
8obj-$(CONFIG_DVB) += dvb/ 8obj-$(CONFIG_DVB_CORE) += dvb/
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c
index 86cbdbcf9d7d..ef3e54cd9407 100644
--- a/drivers/media/common/saa7146_core.c
+++ b/drivers/media/common/saa7146_core.c
@@ -136,28 +136,45 @@ char *saa7146_vmalloc_build_pgtable(struct pci_dev *pci, long length, struct saa
136 char *mem = vmalloc_32(length); 136 char *mem = vmalloc_32(length);
137 int slen = 0; 137 int slen = 0;
138 138
139 if (NULL == mem) { 139 if (NULL == mem)
140 return NULL; 140 goto err_null;
141 }
142 141
143 if (!(pt->slist = vmalloc_to_sg(mem, pages))) { 142 if (!(pt->slist = vmalloc_to_sg(mem, pages)))
144 vfree(mem); 143 goto err_free_mem;
145 return NULL;
146 }
147 144
148 if (saa7146_pgtable_alloc(pci, pt)) { 145 if (saa7146_pgtable_alloc(pci, pt))
149 kfree(pt->slist); 146 goto err_free_slist;
150 pt->slist = NULL;
151 vfree(mem);
152 return NULL;
153 }
154 147
155 slen = pci_map_sg(pci,pt->slist,pages,PCI_DMA_FROMDEVICE); 148 pt->nents = pages;
156 if (0 != saa7146_pgtable_build_single(pci, pt, pt->slist, slen)) { 149 slen = pci_map_sg(pci,pt->slist,pt->nents,PCI_DMA_FROMDEVICE);
157 return NULL; 150 if (0 == slen)
158 } 151 goto err_free_pgtable;
152
153 if (0 != saa7146_pgtable_build_single(pci, pt, pt->slist, slen))
154 goto err_unmap_sg;
159 155
160 return mem; 156 return mem;
157
158err_unmap_sg:
159 pci_unmap_sg(pci, pt->slist, pt->nents, PCI_DMA_FROMDEVICE);
160err_free_pgtable:
161 saa7146_pgtable_free(pci, pt);
162err_free_slist:
163 kfree(pt->slist);
164 pt->slist = NULL;
165err_free_mem:
166 vfree(mem);
167err_null:
168 return NULL;
169}
170
171void saa7146_vfree_destroy_pgtable(struct pci_dev *pci, char *mem, struct saa7146_pgtable *pt)
172{
173 pci_unmap_sg(pci, pt->slist, pt->nents, PCI_DMA_FROMDEVICE);
174 saa7146_pgtable_free(pci, pt);
175 kfree(pt->slist);
176 pt->slist = NULL;
177 vfree(mem);
161} 178}
162 179
163void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt) 180void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt)
@@ -166,8 +183,6 @@ void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt)
166 return; 183 return;
167 pci_free_consistent(pci, pt->size, pt->cpu, pt->dma); 184 pci_free_consistent(pci, pt->size, pt->cpu, pt->dma);
168 pt->cpu = NULL; 185 pt->cpu = NULL;
169 kfree(pt->slist);
170 pt->slist = NULL;
171} 186}
172 187
173int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt) 188int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt)
@@ -528,6 +543,7 @@ EXPORT_SYMBOL_GPL(saa7146_pgtable_alloc);
528EXPORT_SYMBOL_GPL(saa7146_pgtable_free); 543EXPORT_SYMBOL_GPL(saa7146_pgtable_free);
529EXPORT_SYMBOL_GPL(saa7146_pgtable_build_single); 544EXPORT_SYMBOL_GPL(saa7146_pgtable_build_single);
530EXPORT_SYMBOL_GPL(saa7146_vmalloc_build_pgtable); 545EXPORT_SYMBOL_GPL(saa7146_vmalloc_build_pgtable);
546EXPORT_SYMBOL_GPL(saa7146_vfree_destroy_pgtable);
531EXPORT_SYMBOL_GPL(saa7146_wait_for_debi_done); 547EXPORT_SYMBOL_GPL(saa7146_wait_for_debi_done);
532 548
533EXPORT_SYMBOL_GPL(saa7146_setgpio); 549EXPORT_SYMBOL_GPL(saa7146_setgpio);
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index c18a5da64934..b4770aecc01d 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -307,7 +307,6 @@ static int fops_release(struct inode *inode, struct file *file)
307 return 0; 307 return 0;
308} 308}
309 309
310int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int cmd, void *arg);
311static int fops_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 310static int fops_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
312{ 311{
313/* 312/*
diff --git a/drivers/media/dvb/Kconfig b/drivers/media/dvb/Kconfig
index a97c8f5e9a5d..efd2b7468158 100644
--- a/drivers/media/dvb/Kconfig
+++ b/drivers/media/dvb/Kconfig
@@ -2,24 +2,16 @@
2# Multimedia device configuration 2# Multimedia device configuration
3# 3#
4 4
5menu "Digital Video Broadcasting Devices" 5source "drivers/media/dvb/dvb-core/Kconfig"
6 6
7config DVB 7menuconfig DVB_CAPTURE_DRIVERS
8 bool "DVB For Linux" 8 bool "DVB/ATSC adapters"
9 depends on NET && INET 9 depends on DVB_CORE
10 default y
10 ---help--- 11 ---help---
11 Support Digital Video Broadcasting hardware. Enable this if you 12 Say Y to select Digital TV adapters
12 own a DVB adapter and want to use it or if you compile Linux for
13 a digital SetTopBox.
14
15 API specs and user tools are available from <http://www.linuxtv.org/>.
16 13
17 Please report problems regarding this driver to the LinuxDVB 14if DVB_CAPTURE_DRIVERS
18 mailing list.
19
20 If unsure say N.
21
22source "drivers/media/dvb/dvb-core/Kconfig"
23 15
24comment "Supported SAA7146 based PCI Adapters" 16comment "Supported SAA7146 based PCI Adapters"
25 depends on DVB_CORE && PCI && I2C 17 depends on DVB_CORE && PCI && I2C
@@ -48,4 +40,4 @@ comment "Supported DVB Frontends"
48 depends on DVB_CORE 40 depends on DVB_CORE
49source "drivers/media/dvb/frontends/Kconfig" 41source "drivers/media/dvb/frontends/Kconfig"
50 42
51endmenu 43endif # DVB_CAPTURE_DRIVERS
diff --git a/drivers/media/dvb/dvb-core/Kconfig b/drivers/media/dvb/dvb-core/Kconfig
index 1990eda10c46..e3e6839f8073 100644
--- a/drivers/media/dvb/dvb-core/Kconfig
+++ b/drivers/media/dvb/dvb-core/Kconfig
@@ -1,12 +1,22 @@
1config DVB_CORE 1config DVB_CORE
2 tristate "DVB Core Support" 2 tristate "DVB for Linux"
3 depends on DVB 3 depends on NET && INET
4 select CRC32 4 select CRC32
5 help 5 help
6 Support Digital Video Broadcasting hardware. Enable this if you
7 own a DVB adapter and want to use it or if you compile Linux for
8 a digital SetTopBox.
9
6 DVB core utility functions for device handling, software fallbacks etc. 10 DVB core utility functions for device handling, software fallbacks etc.
7 Say Y when you have a DVB card and want to use it. Say Y if your want 11 Say Y when you have a DVB card and want to use it. Say Y if your want
8 to build your drivers outside the kernel, but need the DVB core. All 12 to build your drivers outside the kernel, but need the DVB core. All
9 in-kernel drivers will select this automatically if needed. 13 in-kernel drivers will select this automatically if needed.
14
15 API specs and user tools are available from <http://www.linuxtv.org/>.
16
17 Please report problems regarding this driver to the LinuxDVB
18 mailing list.
19
10 If unsure say N. 20 If unsure say N.
11 21
12config DVB_CORE_ATTACH 22config DVB_CORE_ATTACH
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
index 97715f7514d6..403081689de1 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
@@ -19,6 +19,7 @@
19#define USB_VID_COMPRO_UNK 0x145f 19#define USB_VID_COMPRO_UNK 0x145f
20#define USB_VID_CYPRESS 0x04b4 20#define USB_VID_CYPRESS 0x04b4
21#define USB_VID_DIBCOM 0x10b8 21#define USB_VID_DIBCOM 0x10b8
22#define USB_VID_DPOSH 0x1498
22#define USB_VID_DVICO 0x0fe9 23#define USB_VID_DVICO 0x0fe9
23#define USB_VID_EMPIA 0xeb1a 24#define USB_VID_EMPIA 0xeb1a
24#define USB_VID_GENPIX 0x09c0 25#define USB_VID_GENPIX 0x09c0
@@ -61,6 +62,8 @@
61#define USB_PID_DIBCOM_STK7700P 0x1e14 62#define USB_PID_DIBCOM_STK7700P 0x1e14
62#define USB_PID_DIBCOM_STK7700P_PC 0x1e78 63#define USB_PID_DIBCOM_STK7700P_PC 0x1e78
63#define USB_PID_DIBCOM_ANCHOR_2135_COLD 0x2131 64#define USB_PID_DIBCOM_ANCHOR_2135_COLD 0x2131
65#define USB_PID_DPOSH_M9206_COLD 0x9206
66#define USB_PID_DPOSH_M9206_WARM 0xa090
64#define USB_PID_UNIWILL_STK7700P 0x6003 67#define USB_PID_UNIWILL_STK7700P 0x6003
65#define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0 68#define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0
66#define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1 69#define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1
@@ -145,6 +148,8 @@
145#define USB_PID_MSI_DIGI_VOX_MINI_II 0x1513 148#define USB_PID_MSI_DIGI_VOX_MINI_II 0x1513
146#define USB_PID_OPERA1_COLD 0x2830 149#define USB_PID_OPERA1_COLD 0x2830
147#define USB_PID_OPERA1_WARM 0x3829 150#define USB_PID_OPERA1_WARM 0x3829
151#define USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD 0x0514
152#define USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM 0x0513
148 153
149 154
150#endif 155#endif
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h
index 0d721731a524..6f824a569e14 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -119,7 +119,7 @@ struct usb_data_stream_properties {
119 * @caps: capabilities of the DVB USB device. 119 * @caps: capabilities of the DVB USB device.
120 * @pid_filter_count: number of PID filter position in the optional hardware 120 * @pid_filter_count: number of PID filter position in the optional hardware
121 * PID-filter. 121 * PID-filter.
122 * @streaming_crtl: called to start and stop the MPEG2-TS streaming of the 122 * @streaming_ctrl: called to start and stop the MPEG2-TS streaming of the
123 * device (not URB submitting/killing). 123 * device (not URB submitting/killing).
124 * @pid_filter_ctrl: called to en/disable the PID filter, if any. 124 * @pid_filter_ctrl: called to en/disable the PID filter, if any.
125 * @pid_filter: called to set/unset a PID for filtering. 125 * @pid_filter: called to set/unset a PID for filtering.
diff --git a/drivers/media/dvb/dvb-usb/m920x.c b/drivers/media/dvb/dvb-usb/m920x.c
index 45d7bc214c18..c546ddeda5d4 100644
--- a/drivers/media/dvb/dvb-usb/m920x.c
+++ b/drivers/media/dvb/dvb-usb/m920x.c
@@ -3,8 +3,8 @@
3 * Copyright (C) 2006 Aapo Tahkola (aet@rasterburn.org) 3 * Copyright (C) 2006 Aapo Tahkola (aet@rasterburn.org)
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free 6 * under the terms of the GNU General Public License as published by the
7 * Software Foundation, version 2. 7 * Free Software Foundation, version 2.
8 * 8 *
9 * see Documentation/dvb/README.dvb-usb for more information 9 * see Documentation/dvb/README.dvb-usb for more information
10 */ 10 */
@@ -22,26 +22,7 @@ static int dvb_usb_m920x_debug;
22module_param_named(debug,dvb_usb_m920x_debug, int, 0644); 22module_param_named(debug,dvb_usb_m920x_debug, int, 0644);
23MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); 23MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
24 24
25static struct dvb_usb_rc_key megasky_rc_keys [] = { 25static inline int m920x_read(struct usb_device *udev, u8 request, u16 value,
26 { 0x0, 0x12, KEY_POWER },
27 { 0x0, 0x1e, KEY_CYCLEWINDOWS }, /* min/max */
28 { 0x0, 0x02, KEY_CHANNELUP },
29 { 0x0, 0x05, KEY_CHANNELDOWN },
30 { 0x0, 0x03, KEY_VOLUMEUP },
31 { 0x0, 0x06, KEY_VOLUMEDOWN },
32 { 0x0, 0x04, KEY_MUTE },
33 { 0x0, 0x07, KEY_OK }, /* TS */
34 { 0x0, 0x08, KEY_STOP },
35 { 0x0, 0x09, KEY_MENU }, /* swap */
36 { 0x0, 0x0a, KEY_REWIND },
37 { 0x0, 0x1b, KEY_PAUSE },
38 { 0x0, 0x1f, KEY_FASTFORWARD },
39 { 0x0, 0x0c, KEY_RECORD },
40 { 0x0, 0x0d, KEY_CAMERA }, /* screenshot */
41 { 0x0, 0x0e, KEY_COFFEE }, /* "MTS" */
42};
43
44static inline int m9206_read(struct usb_device *udev, u8 request, u16 value,\
45 u16 index, void *data, int size) 26 u16 index, void *data, int size)
46{ 27{
47 int ret; 28 int ret;
@@ -55,14 +36,14 @@ static inline int m9206_read(struct usb_device *udev, u8 request, u16 value,\
55 } 36 }
56 37
57 if (ret != size) { 38 if (ret != size) {
58 deb_rc("m920x_read = no data\n"); 39 deb("m920x_read = no data\n");
59 return -EIO; 40 return -EIO;
60 } 41 }
61 42
62 return 0; 43 return 0;
63} 44}
64 45
65static inline int m9206_write(struct usb_device *udev, u8 request, 46static inline int m920x_write(struct usb_device *udev, u8 request,
66 u16 value, u16 index) 47 u16 value, u16 index)
67{ 48{
68 int ret; 49 int ret;
@@ -74,32 +55,40 @@ static inline int m9206_write(struct usb_device *udev, u8 request,
74 return ret; 55 return ret;
75} 56}
76 57
77static int m9206_init(struct dvb_usb_device *d) 58static int m920x_init(struct dvb_usb_device *d, struct m920x_inits *rc_seq)
78{ 59{
79 int ret = 0; 60 int ret = 0;
80 61
81 /* Remote controller init. */ 62 /* Remote controller init. */
82 if (d->props.rc_query) { 63 if (d->props.rc_query) {
83 if ((ret = m9206_write(d->udev, M9206_CORE, 0xa8, M9206_RC_INIT2)) != 0) 64 deb("Initialising remote control\n");
84 return ret; 65 while (rc_seq->address) {
66 if ((ret = m920x_write(d->udev, M9206_CORE,
67 rc_seq->data,
68 rc_seq->address)) != 0) {
69 deb("Initialising remote control failed\n");
70 return ret;
71 }
85 72
86 if ((ret = m9206_write(d->udev, M9206_CORE, 0x51, M9206_RC_INIT1)) != 0) 73 rc_seq++;
87 return ret; 74 }
75
76 deb("Initialising remote control success\n");
88 } 77 }
89 78
90 return ret; 79 return ret;
91} 80}
92 81
93static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 82static int m920x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
94{ 83{
95 struct m9206_state *m = d->priv; 84 struct m920x_state *m = d->priv;
96 int i, ret = 0; 85 int i, ret = 0;
97 u8 rc_state[2]; 86 u8 rc_state[2];
98 87
99 if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0) 88 if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_STATE, rc_state, 1)) != 0)
100 goto unlock; 89 goto unlock;
101 90
102 if ((ret = m9206_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0) 91 if ((ret = m920x_read(d->udev, M9206_CORE, 0x0, M9206_RC_KEY, rc_state + 1, 1)) != 0)
103 goto unlock; 92 goto unlock;
104 93
105 for (i = 0; i < d->props.rc_key_map_size; i++) 94 for (i = 0; i < d->props.rc_key_map_size; i++)
@@ -111,6 +100,14 @@ static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
111 *state = REMOTE_NO_KEY_PRESSED; 100 *state = REMOTE_NO_KEY_PRESSED;
112 goto unlock; 101 goto unlock;
113 102
103 case 0x88: /* framing error or "invalid code" */
104 case 0x99:
105 case 0xc0:
106 case 0xd8:
107 *state = REMOTE_NO_KEY_PRESSED;
108 m->rep_count = 0;
109 goto unlock;
110
114 case 0x93: 111 case 0x93:
115 case 0x92: 112 case 0x92:
116 m->rep_count = 0; 113 m->rep_count = 0;
@@ -118,31 +115,32 @@ static int m9206_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
118 goto unlock; 115 goto unlock;
119 116
120 case 0x91: 117 case 0x91:
121 /* For comfort. */ 118 /* prevent immediate auto-repeat */
122 if (++m->rep_count > 2) 119 if (++m->rep_count > 2)
123 *state = REMOTE_KEY_REPEAT; 120 *state = REMOTE_KEY_REPEAT;
121 else
122 *state = REMOTE_NO_KEY_PRESSED;
124 goto unlock; 123 goto unlock;
125 124
126 default: 125 default:
127 deb_rc("Unexpected rc response %x\n", rc_state[0]); 126 deb("Unexpected rc state %02x\n", rc_state[0]);
128 *state = REMOTE_NO_KEY_PRESSED; 127 *state = REMOTE_NO_KEY_PRESSED;
129 goto unlock; 128 goto unlock;
130 } 129 }
131 } 130 }
132 131
133 if (rc_state[1] != 0) 132 if (rc_state[1] != 0)
134 deb_rc("Unknown rc key %x\n", rc_state[1]); 133 deb("Unknown rc key %02x\n", rc_state[1]);
135 134
136 *state = REMOTE_NO_KEY_PRESSED; 135 *state = REMOTE_NO_KEY_PRESSED;
137 136
138 unlock: 137 unlock:
139 138
140 return ret; 139 return ret;
141} 140}
142 141
143/* I2C */ 142/* I2C */
144static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], 143static int m920x_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
145 int num)
146{ 144{
147 struct dvb_usb_device *d = i2c_get_adapdata(adap); 145 struct dvb_usb_device *d = i2c_get_adapdata(adap);
148 int i, j; 146 int i, j;
@@ -155,33 +153,40 @@ static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
155 return -EAGAIN; 153 return -EAGAIN;
156 154
157 for (i = 0; i < num; i++) { 155 for (i = 0; i < num; i++) {
158 if (msg[i].flags & (I2C_M_NO_RD_ACK|I2C_M_IGNORE_NAK|I2C_M_TEN) || 156 if (msg[i].flags & (I2C_M_NO_RD_ACK | I2C_M_IGNORE_NAK | I2C_M_TEN) || msg[i].len == 0) {
159 msg[i].len == 0) { 157 /* For a 0 byte message, I think sending the address
160 /* For a 0 byte message, I think sending the address to index 0x80|0x40 158 * to index 0x80|0x40 would be the correct thing to
161 * would be the correct thing to do. However, zero byte messages are 159 * do. However, zero byte messages are only used for
162 * only used for probing, and since we don't know how to get the slave's 160 * probing, and since we don't know how to get the
163 * ack, we can't probe. */ 161 * slave's ack, we can't probe. */
164 ret = -ENOTSUPP; 162 ret = -ENOTSUPP;
165 goto unlock; 163 goto unlock;
166 } 164 }
167 /* Send START & address/RW bit */ 165 /* Send START & address/RW bit */
168 if (!(msg[i].flags & I2C_M_NOSTART)) { 166 if (!(msg[i].flags & I2C_M_NOSTART)) {
169 if ((ret = m9206_write(d->udev, M9206_I2C, (msg[i].addr<<1)|(msg[i].flags&I2C_M_RD?0x01:0), 0x80)) != 0) 167 if ((ret = m920x_write(d->udev, M9206_I2C,
168 (msg[i].addr << 1) |
169 (msg[i].flags & I2C_M_RD ? 0x01 : 0), 0x80)) != 0)
170 goto unlock; 170 goto unlock;
171 /* Should check for ack here, if we knew how. */ 171 /* Should check for ack here, if we knew how. */
172 } 172 }
173 if (msg[i].flags & I2C_M_RD) { 173 if (msg[i].flags & I2C_M_RD) {
174 for (j = 0; j < msg[i].len; j++) { 174 for (j = 0; j < msg[i].len; j++) {
175 /* Last byte of transaction? Send STOP, otherwise send ACK. */ 175 /* Last byte of transaction?
176 int stop = (i+1 == num && j+1 == msg[i].len)?0x40:0x01; 176 * Send STOP, otherwise send ACK. */
177 if ((ret = m9206_read(d->udev, M9206_I2C, 0x0, 0x20|stop, &msg[i].buf[j], 1)) != 0) 177 int stop = (i+1 == num && j+1 == msg[i].len) ? 0x40 : 0x01;
178
179 if ((ret = m920x_read(d->udev, M9206_I2C, 0x0,
180 0x20 | stop,
181 &msg[i].buf[j], 1)) != 0)
178 goto unlock; 182 goto unlock;
179 } 183 }
180 } else { 184 } else {
181 for (j = 0; j < msg[i].len; j++) { 185 for (j = 0; j < msg[i].len; j++) {
182 /* Last byte of transaction? Then send STOP. */ 186 /* Last byte of transaction? Then send STOP. */
183 int stop = (i+1 == num && j+1 == msg[i].len)?0x40:0x00; 187 int stop = (i+1 == num && j+1 == msg[i].len) ? 0x40 : 0x00;
184 if ((ret = m9206_write(d->udev, M9206_I2C, msg[i].buf[j], stop)) != 0) 188
189 if ((ret = m920x_write(d->udev, M9206_I2C, msg[i].buf[j], stop)) != 0)
185 goto unlock; 190 goto unlock;
186 /* Should check for ack here too. */ 191 /* Should check for ack here too. */
187 } 192 }
@@ -189,25 +194,25 @@ static int m9206_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
189 } 194 }
190 ret = num; 195 ret = num;
191 196
192unlock: 197 unlock:
193 mutex_unlock(&d->i2c_mutex); 198 mutex_unlock(&d->i2c_mutex);
194 199
195 return ret; 200 return ret;
196} 201}
197 202
198static u32 m9206_i2c_func(struct i2c_adapter *adapter) 203static u32 m920x_i2c_func(struct i2c_adapter *adapter)
199{ 204{
200 return I2C_FUNC_I2C; 205 return I2C_FUNC_I2C;
201} 206}
202 207
203static struct i2c_algorithm m9206_i2c_algo = { 208static struct i2c_algorithm m920x_i2c_algo = {
204 .master_xfer = m9206_i2c_xfer, 209 .master_xfer = m920x_i2c_xfer,
205 .functionality = m9206_i2c_func, 210 .functionality = m920x_i2c_func,
206}; 211};
207 212
208 213/* pid filter */
209static int m9206_set_filter(struct dvb_usb_adapter *adap, int type, int idx, 214static int m920x_set_filter(struct dvb_usb_adapter *adap,
210 int pid) 215 int type, int idx, int pid)
211{ 216{
212 int ret = 0; 217 int ret = 0;
213 218
@@ -216,18 +221,18 @@ static int m9206_set_filter(struct dvb_usb_adapter *adap, int type, int idx,
216 221
217 pid |= 0x8000; 222 pid |= 0x8000;
218 223
219 if ((ret = m9206_write(adap->dev->udev, M9206_FILTER, pid, (type << 8) | (idx * 4) )) != 0) 224 if ((ret = m920x_write(adap->dev->udev, M9206_FILTER, pid, (type << 8) | (idx * 4) )) != 0)
220 return ret; 225 return ret;
221 226
222 if ((ret = m9206_write(adap->dev->udev, M9206_FILTER, 0, (type << 8) | (idx * 4) )) != 0) 227 if ((ret = m920x_write(adap->dev->udev, M9206_FILTER, 0, (type << 8) | (idx * 4) )) != 0)
223 return ret; 228 return ret;
224 229
225 return ret; 230 return ret;
226} 231}
227 232
228static int m9206_update_filters(struct dvb_usb_adapter *adap) 233static int m920x_update_filters(struct dvb_usb_adapter *adap)
229{ 234{
230 struct m9206_state *m = adap->dev->priv; 235 struct m920x_state *m = adap->dev->priv;
231 int enabled = m->filtering_enabled; 236 int enabled = m->filtering_enabled;
232 int i, ret = 0, filter = 0; 237 int i, ret = 0, filter = 0;
233 238
@@ -236,14 +241,14 @@ static int m9206_update_filters(struct dvb_usb_adapter *adap)
236 enabled = 0; 241 enabled = 0;
237 242
238 /* Disable all filters */ 243 /* Disable all filters */
239 if ((ret = m9206_set_filter(adap, 0x81, 1, enabled)) != 0) 244 if ((ret = m920x_set_filter(adap, 0x81, 1, enabled)) != 0)
240 return ret; 245 return ret;
241 246
242 for (i = 0; i < M9206_MAX_FILTERS; i++) 247 for (i = 0; i < M9206_MAX_FILTERS; i++)
243 if ((ret = m9206_set_filter(adap, 0x81, i + 2, 0)) != 0) 248 if ((ret = m920x_set_filter(adap, 0x81, i + 2, 0)) != 0)
244 return ret; 249 return ret;
245 250
246 if ((ret = m9206_set_filter(adap, 0x82, 0, 0x0)) != 0) 251 if ((ret = m920x_set_filter(adap, 0x82, 0, 0x0)) != 0)
247 return ret; 252 return ret;
248 253
249 /* Set */ 254 /* Set */
@@ -252,40 +257,38 @@ static int m9206_update_filters(struct dvb_usb_adapter *adap)
252 if (m->filters[i] == 0) 257 if (m->filters[i] == 0)
253 continue; 258 continue;
254 259
255 if ((ret = m9206_set_filter(adap, 0x81, filter + 2, m->filters[i])) != 0) 260 if ((ret = m920x_set_filter(adap, 0x81, filter + 2, m->filters[i])) != 0)
256 return ret; 261 return ret;
257 262
258 filter++; 263 filter++;
259 } 264 }
260 } 265 }
261 266
262 if ((ret = m9206_set_filter(adap, 0x82, 0, 0x02f5)) != 0) 267 if ((ret = m920x_set_filter(adap, 0x82, 0, 0x02f5)) != 0)
263 return ret; 268 return ret;
264 269
265 return ret; 270 return ret;
266} 271}
267 272
268static int m9206_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff) 273static int m920x_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
269{ 274{
270 struct m9206_state *m = adap->dev->priv; 275 struct m920x_state *m = adap->dev->priv;
271 276
272 m->filtering_enabled = onoff ? 1 : 0; 277 m->filtering_enabled = onoff ? 1 : 0;
273 278
274 return m9206_update_filters(adap); 279 return m920x_update_filters(adap);
275} 280}
276 281
277static int m9206_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, 282static int m920x_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, int onoff)
278 int onoff)
279{ 283{
280 struct m9206_state *m = adap->dev->priv; 284 struct m920x_state *m = adap->dev->priv;
281 285
282 m->filters[index] = onoff ? pid : 0; 286 m->filters[index] = onoff ? pid : 0;
283 287
284 return m9206_update_filters(adap); 288 return m920x_update_filters(adap);
285} 289}
286 290
287static int m9206_firmware_download(struct usb_device *udev, 291static int m920x_firmware_download(struct usb_device *udev, const struct firmware *fw)
288 const struct firmware *fw)
289{ 292{
290 u16 value, index, size; 293 u16 value, index, size;
291 u8 read[4], *buff; 294 u8 read[4], *buff;
@@ -293,13 +296,13 @@ static int m9206_firmware_download(struct usb_device *udev,
293 296
294 buff = kmalloc(65536, GFP_KERNEL); 297 buff = kmalloc(65536, GFP_KERNEL);
295 298
296 if ((ret = m9206_read(udev, M9206_FILTER, 0x0, 0x8000, read, 4)) != 0) 299 if ((ret = m920x_read(udev, M9206_FILTER, 0x0, 0x8000, read, 4)) != 0)
297 goto done; 300 goto done;
298 deb_rc("%x %x %x %x\n", read[0], read[1], read[2], read[3]); 301 deb("%x %x %x %x\n", read[0], read[1], read[2], read[3]);
299 302
300 if ((ret = m9206_read(udev, M9206_FW, 0x0, 0x0, read, 1)) != 0) 303 if ((ret = m920x_read(udev, M9206_FW, 0x0, 0x0, read, 1)) != 0)
301 goto done; 304 goto done;
302 deb_rc("%x\n", read[0]); 305 deb("%x\n", read[0]);
303 306
304 for (pass = 0; pass < 2; pass++) { 307 for (pass = 0; pass < 2; pass++) {
305 for (i = 0; i + (sizeof(u16) * 3) < fw->size;) { 308 for (i = 0; i + (sizeof(u16) * 3) < fw->size;) {
@@ -317,11 +320,11 @@ static int m9206_firmware_download(struct usb_device *udev,
317 memcpy(buff, fw->data + i, size); 320 memcpy(buff, fw->data + i, size);
318 321
319 ret = usb_control_msg(udev, usb_sndctrlpipe(udev,0), 322 ret = usb_control_msg(udev, usb_sndctrlpipe(udev,0),
320 M9206_FW, 323 M9206_FW,
321 USB_TYPE_VENDOR | USB_DIR_OUT, 324 USB_TYPE_VENDOR | USB_DIR_OUT,
322 value, index, buff, size, 20); 325 value, index, buff, size, 20);
323 if (ret != size) { 326 if (ret != size) {
324 deb_rc("error while uploading fw!\n"); 327 deb("error while uploading fw!\n");
325 ret = -EIO; 328 ret = -EIO;
326 goto done; 329 goto done;
327 } 330 }
@@ -330,7 +333,7 @@ static int m9206_firmware_download(struct usb_device *udev,
330 i += size; 333 i += size;
331 } 334 }
332 if (i != fw->size) { 335 if (i != fw->size) {
333 deb_rc("bad firmware file!\n"); 336 deb("bad firmware file!\n");
334 ret = -EINVAL; 337 ret = -EINVAL;
335 goto done; 338 goto done;
336 } 339 }
@@ -338,11 +341,11 @@ static int m9206_firmware_download(struct usb_device *udev,
338 341
339 msleep(36); 342 msleep(36);
340 343
341 /* m9206 will disconnect itself from the bus after this. */ 344 /* m920x will disconnect itself from the bus after this. */
342 (void) m9206_write(udev, M9206_CORE, 0x01, M9206_FW_GO); 345 (void) m920x_write(udev, M9206_CORE, 0x01, M9206_FW_GO);
343 deb_rc("firmware uploaded!\n"); 346 deb("firmware uploaded!\n");
344 347
345 done: 348 done:
346 kfree(buff); 349 kfree(buff);
347 350
348 return ret; 351 return ret;
@@ -362,7 +365,8 @@ static int m920x_identify_state(struct usb_device *udev,
362 return 0; 365 return 0;
363} 366}
364 367
365static int megasky_mt352_demod_init(struct dvb_frontend *fe) 368/* demod configurations */
369static int m920x_mt352_demod_init(struct dvb_frontend *fe)
366{ 370{
367 u8 config[] = { CONFIG, 0x3d }; 371 u8 config[] = { CONFIG, 0x3d };
368 u8 clock[] = { CLOCK_CTL, 0x30 }; 372 u8 clock[] = { CLOCK_CTL, 0x30 };
@@ -382,74 +386,174 @@ static int megasky_mt352_demod_init(struct dvb_frontend *fe)
382 mt352_write(fe, unk1, ARRAY_SIZE(unk1)); 386 mt352_write(fe, unk1, ARRAY_SIZE(unk1));
383 mt352_write(fe, unk2, ARRAY_SIZE(unk2)); 387 mt352_write(fe, unk2, ARRAY_SIZE(unk2));
384 388
385 deb_rc("Demod init!\n"); 389 deb("Demod init!\n");
386 390
387 return 0; 391 return 0;
388} 392}
389 393
390static struct mt352_config megasky_mt352_config = { 394static struct mt352_config m920x_mt352_config = {
391 .demod_address = 0x0f, 395 .demod_address = 0x0f,
392 .no_tuner = 1, 396 .no_tuner = 1,
393 .demod_init = megasky_mt352_demod_init, 397 .demod_init = m920x_mt352_demod_init,
398};
399
400static struct tda1004x_config m920x_tda10046_08_config = {
401 .demod_address = 0x08,
402 .invert = 0,
403 .invert_oclk = 0,
404 .ts_mode = TDA10046_TS_SERIAL,
405 .xtal_freq = TDA10046_XTAL_16M,
406 .if_freq = TDA10046_FREQ_045,
407 .agc_config = TDA10046_AGC_TDA827X,
408 .gpio_config = TDA10046_GPTRI,
409 .request_firmware = NULL,
410};
411
412static struct tda1004x_config m920x_tda10046_0b_config = {
413 .demod_address = 0x0b,
414 .invert = 0,
415 .invert_oclk = 0,
416 .ts_mode = TDA10046_TS_SERIAL,
417 .xtal_freq = TDA10046_XTAL_16M,
418 .if_freq = TDA10046_FREQ_045,
419 .agc_config = TDA10046_AGC_TDA827X,
420 .gpio_config = TDA10046_GPTRI,
421 .request_firmware = NULL, /* uses firmware EEPROM */
422};
423
424/* tuner configurations */
425static struct qt1010_config m920x_qt1010_config = {
426 .i2c_address = 0x62
394}; 427};
395 428
396static int megasky_mt352_frontend_attach(struct dvb_usb_adapter *adap) 429/* Callbacks for DVB USB */
430static int m920x_mt352_frontend_attach(struct dvb_usb_adapter *adap)
397{ 431{
398 deb_rc("megasky_frontend_attach!\n"); 432 deb("%s\n",__FUNCTION__);
399 433
400 if ((adap->fe = dvb_attach(mt352_attach, &megasky_mt352_config, &adap->dev->i2c_adap)) == NULL) 434 if ((adap->fe = dvb_attach(mt352_attach,
435 &m920x_mt352_config,
436 &adap->dev->i2c_adap)) == NULL)
401 return -EIO; 437 return -EIO;
402 438
403 return 0; 439 return 0;
404} 440}
405 441
406static struct qt1010_config megasky_qt1010_config = { 442static int m920x_tda10046_08_frontend_attach(struct dvb_usb_adapter *adap)
407 .i2c_address = 0x62
408};
409
410static int megasky_qt1010_tuner_attach(struct dvb_usb_adapter *adap)
411{ 443{
412 if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap, 444 deb("%s\n",__FUNCTION__);
413 &megasky_qt1010_config) == NULL) 445
414 return -ENODEV; 446 if ((adap->fe = dvb_attach(tda10046_attach,
447 &m920x_tda10046_08_config,
448 &adap->dev->i2c_adap)) == NULL)
449 return -EIO;
415 450
416 return 0; 451 return 0;
417} 452}
418 453
419static struct tda1004x_config digivox_tda10046_config = { 454static int m920x_tda10046_0b_frontend_attach(struct dvb_usb_adapter *adap)
420 .demod_address = 0x08,
421 .invert = 0,
422 .invert_oclk = 0,
423 .ts_mode = TDA10046_TS_SERIAL,
424 .xtal_freq = TDA10046_XTAL_16M,
425 .if_freq = TDA10046_FREQ_045,
426 .agc_config = TDA10046_AGC_TDA827X,
427 .gpio_config = TDA10046_GPTRI,
428 .request_firmware = NULL,
429};
430
431static int digivox_tda10046_frontend_attach(struct dvb_usb_adapter *adap)
432{ 455{
433 deb_rc("digivox_tda10046_frontend_attach!\n"); 456 deb("%s\n",__FUNCTION__);
434 457
435 if ((adap->fe = dvb_attach(tda10046_attach, &digivox_tda10046_config, 458 if ((adap->fe = dvb_attach(tda10046_attach,
459 &m920x_tda10046_0b_config,
436 &adap->dev->i2c_adap)) == NULL) 460 &adap->dev->i2c_adap)) == NULL)
437 return -EIO; 461 return -EIO;
438 462
439 return 0; 463 return 0;
440} 464}
441 465
442static int digivox_tda8275_tuner_attach(struct dvb_usb_adapter *adap) 466static int m920x_qt1010_tuner_attach(struct dvb_usb_adapter *adap)
443{ 467{
444 if (dvb_attach(tda827x_attach, adap->fe, 0x60, &adap->dev->i2c_adap, 468 deb("%s\n",__FUNCTION__);
445 NULL) == NULL) 469
470 if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap, &m920x_qt1010_config) == NULL)
446 return -ENODEV; 471 return -ENODEV;
472
447 return 0; 473 return 0;
448} 474}
449 475
476static int m920x_tda8275_60_tuner_attach(struct dvb_usb_adapter *adap)
477{
478 deb("%s\n",__FUNCTION__);
479
480 if (dvb_attach(tda827x_attach, adap->fe, 0x60, &adap->dev->i2c_adap, NULL) == NULL)
481 return -ENODEV;
482
483 return 0;
484}
485
486static int m920x_tda8275_61_tuner_attach(struct dvb_usb_adapter *adap)
487{
488 deb("%s\n",__FUNCTION__);
489
490 if (dvb_attach(tda827x_attach, adap->fe, 0x61, &adap->dev->i2c_adap, NULL) == NULL)
491 return -ENODEV;
492
493 return 0;
494}
495
496/* device-specific initialization */
497static struct m920x_inits megasky_rc_init [] = {
498 { M9206_RC_INIT2, 0xa8 },
499 { M9206_RC_INIT1, 0x51 },
500 { } /* terminating entry */
501};
502
503static struct m920x_inits tvwalkertwin_rc_init [] = {
504 { M9206_RC_INIT2, 0x00 },
505 { M9206_RC_INIT1, 0xef },
506 { 0xff28, 0x00 },
507 { 0xff23, 0x00 },
508 { 0xff21, 0x30 },
509 { } /* terminating entry */
510};
511
512/* ir keymaps */
513static struct dvb_usb_rc_key megasky_rc_keys [] = {
514 { 0x0, 0x12, KEY_POWER },
515 { 0x0, 0x1e, KEY_CYCLEWINDOWS }, /* min/max */
516 { 0x0, 0x02, KEY_CHANNELUP },
517 { 0x0, 0x05, KEY_CHANNELDOWN },
518 { 0x0, 0x03, KEY_VOLUMEUP },
519 { 0x0, 0x06, KEY_VOLUMEDOWN },
520 { 0x0, 0x04, KEY_MUTE },
521 { 0x0, 0x07, KEY_OK }, /* TS */
522 { 0x0, 0x08, KEY_STOP },
523 { 0x0, 0x09, KEY_MENU }, /* swap */
524 { 0x0, 0x0a, KEY_REWIND },
525 { 0x0, 0x1b, KEY_PAUSE },
526 { 0x0, 0x1f, KEY_FASTFORWARD },
527 { 0x0, 0x0c, KEY_RECORD },
528 { 0x0, 0x0d, KEY_CAMERA }, /* screenshot */
529 { 0x0, 0x0e, KEY_COFFEE }, /* "MTS" */
530};
531
532static struct dvb_usb_rc_key tvwalkertwin_rc_keys [] = {
533 { 0x0, 0x01, KEY_ZOOM }, /* Full Screen */
534 { 0x0, 0x02, KEY_CAMERA }, /* snapshot */
535 { 0x0, 0x03, KEY_MUTE },
536 { 0x0, 0x04, KEY_REWIND },
537 { 0x0, 0x05, KEY_PLAYPAUSE }, /* Play/Pause */
538 { 0x0, 0x06, KEY_FASTFORWARD },
539 { 0x0, 0x07, KEY_RECORD },
540 { 0x0, 0x08, KEY_STOP },
541 { 0x0, 0x09, KEY_TIME }, /* Timeshift */
542 { 0x0, 0x0c, KEY_COFFEE }, /* Recall */
543 { 0x0, 0x0e, KEY_CHANNELUP },
544 { 0x0, 0x12, KEY_POWER },
545 { 0x0, 0x15, KEY_MENU }, /* source */
546 { 0x0, 0x18, KEY_CYCLEWINDOWS }, /* TWIN PIP */
547 { 0x0, 0x1a, KEY_CHANNELDOWN },
548 { 0x0, 0x1b, KEY_VOLUMEDOWN },
549 { 0x0, 0x1e, KEY_VOLUMEUP },
550};
551
450/* DVB USB Driver stuff */ 552/* DVB USB Driver stuff */
451static struct dvb_usb_device_properties megasky_properties; 553static struct dvb_usb_device_properties megasky_properties;
452static struct dvb_usb_device_properties digivox_mini_ii_properties; 554static struct dvb_usb_device_properties digivox_mini_ii_properties;
555static struct dvb_usb_device_properties tvwalkertwin_properties;
556static struct dvb_usb_device_properties dposh_properties;
453 557
454static int m920x_probe(struct usb_interface *intf, 558static int m920x_probe(struct usb_interface *intf,
455 const struct usb_device_id *id) 559 const struct usb_device_id *id)
@@ -457,19 +561,57 @@ static int m920x_probe(struct usb_interface *intf,
457 struct dvb_usb_device *d; 561 struct dvb_usb_device *d;
458 struct usb_host_interface *alt; 562 struct usb_host_interface *alt;
459 int ret; 563 int ret;
564 struct m920x_inits *rc_init_seq = NULL;
565 int bInterfaceNumber = intf->cur_altsetting->desc.bInterfaceNumber;
460 566
461 deb_rc("Probed!\n"); 567 deb("Probing for m920x device at interface %d\n", bInterfaceNumber);
462 568
463 if (((ret = dvb_usb_device_init(intf, &megasky_properties, THIS_MODULE, &d)) == 0) || 569 if (bInterfaceNumber == 0) {
464 ((ret = dvb_usb_device_init(intf, &digivox_mini_ii_properties, THIS_MODULE, &d)) == 0)) 570 /* Single-tuner device, or first interface on
465 goto found; 571 * multi-tuner device
572 */
466 573
467 return ret; 574 if ((ret = dvb_usb_device_init(intf, &megasky_properties,
575 THIS_MODULE, &d)) == 0) {
576 rc_init_seq = megasky_rc_init;
577 goto found;
578 }
579
580 if ((ret = dvb_usb_device_init(intf, &digivox_mini_ii_properties,
581 THIS_MODULE, &d)) == 0) {
582 /* No remote control, so no rc_init_seq */
583 goto found;
584 }
585
586 /* This configures both tuners on the TV Walker Twin */
587 if ((ret = dvb_usb_device_init(intf, &tvwalkertwin_properties,
588 THIS_MODULE, &d)) == 0) {
589 rc_init_seq = tvwalkertwin_rc_init;
590 goto found;
591 }
592
593 if ((ret = dvb_usb_device_init(intf, &dposh_properties,
594 THIS_MODULE, &d)) == 0) {
595 /* Remote controller not supported yet. */
596 goto found;
597 }
598
599 return ret;
600 } else {
601 /* Another interface on a multi-tuner device */
468 602
469found: 603 /* The LifeView TV Walker Twin gets here, but struct
604 * tvwalkertwin_properties already configured both
605 * tuners, so there is nothing for us to do here
606 */
607
608 return -ENODEV;
609 }
610
611 found:
470 alt = usb_altnum_to_altsetting(intf, 1); 612 alt = usb_altnum_to_altsetting(intf, 1);
471 if (alt == NULL) { 613 if (alt == NULL) {
472 deb_rc("No alt found!\n"); 614 deb("No alt found!\n");
473 return -ENODEV; 615 return -ENODEV;
474 } 616 }
475 617
@@ -478,7 +620,7 @@ found:
478 if (ret < 0) 620 if (ret < 0)
479 return ret; 621 return ret;
480 622
481 if ((ret = m9206_init(d)) != 0) 623 if ((ret = m920x_init(d, rc_init_seq)) != 0)
482 return ret; 624 return ret;
483 625
484 return ret; 626 return ret;
@@ -488,6 +630,12 @@ static struct usb_device_id m920x_table [] = {
488 { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) }, 630 { USB_DEVICE(USB_VID_MSI, USB_PID_MSI_MEGASKY580) },
489 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC, 631 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
490 USB_PID_MSI_DIGI_VOX_MINI_II) }, 632 USB_PID_MSI_DIGI_VOX_MINI_II) },
633 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
634 USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD) },
635 { USB_DEVICE(USB_VID_ANUBIS_ELECTRONIC,
636 USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM) },
637 { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_COLD) },
638 { USB_DEVICE(USB_VID_DPOSH, USB_PID_DPOSH_M9206_WARM) },
491 { } /* Terminating entry */ 639 { } /* Terminating entry */
492}; 640};
493MODULE_DEVICE_TABLE (usb, m920x_table); 641MODULE_DEVICE_TABLE (usb, m920x_table);
@@ -497,14 +645,14 @@ static struct dvb_usb_device_properties megasky_properties = {
497 645
498 .usb_ctrl = DEVICE_SPECIFIC, 646 .usb_ctrl = DEVICE_SPECIFIC,
499 .firmware = "dvb-usb-megasky-02.fw", 647 .firmware = "dvb-usb-megasky-02.fw",
500 .download_firmware = m9206_firmware_download, 648 .download_firmware = m920x_firmware_download,
501 649
502 .rc_interval = 100, 650 .rc_interval = 100,
503 .rc_key_map = megasky_rc_keys, 651 .rc_key_map = megasky_rc_keys,
504 .rc_key_map_size = ARRAY_SIZE(megasky_rc_keys), 652 .rc_key_map_size = ARRAY_SIZE(megasky_rc_keys),
505 .rc_query = m9206_rc_query, 653 .rc_query = m920x_rc_query,
506 654
507 .size_of_priv = sizeof(struct m9206_state), 655 .size_of_priv = sizeof(struct m920x_state),
508 656
509 .identify_state = m920x_identify_state, 657 .identify_state = m920x_identify_state,
510 .num_adapters = 1, 658 .num_adapters = 1,
@@ -513,11 +661,11 @@ static struct dvb_usb_device_properties megasky_properties = {
513 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 661 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
514 662
515 .pid_filter_count = 8, 663 .pid_filter_count = 8,
516 .pid_filter = m9206_pid_filter, 664 .pid_filter = m920x_pid_filter,
517 .pid_filter_ctrl = m9206_pid_filter_ctrl, 665 .pid_filter_ctrl = m920x_pid_filter_ctrl,
518 666
519 .frontend_attach = megasky_mt352_frontend_attach, 667 .frontend_attach = m920x_mt352_frontend_attach,
520 .tuner_attach = megasky_qt1010_tuner_attach, 668 .tuner_attach = m920x_qt1010_tuner_attach,
521 669
522 .stream = { 670 .stream = {
523 .type = USB_BULK, 671 .type = USB_BULK,
@@ -530,7 +678,7 @@ static struct dvb_usb_device_properties megasky_properties = {
530 } 678 }
531 }, 679 },
532 }}, 680 }},
533 .i2c_algo = &m9206_i2c_algo, 681 .i2c_algo = &m920x_i2c_algo,
534 682
535 .num_device_descs = 1, 683 .num_device_descs = 1,
536 .devices = { 684 .devices = {
@@ -546,22 +694,22 @@ static struct dvb_usb_device_properties digivox_mini_ii_properties = {
546 694
547 .usb_ctrl = DEVICE_SPECIFIC, 695 .usb_ctrl = DEVICE_SPECIFIC,
548 .firmware = "dvb-usb-digivox-02.fw", 696 .firmware = "dvb-usb-digivox-02.fw",
549 .download_firmware = m9206_firmware_download, 697 .download_firmware = m920x_firmware_download,
550 698
551 .size_of_priv = sizeof(struct m9206_state), 699 .size_of_priv = sizeof(struct m920x_state),
552 700
553 .identify_state = m920x_identify_state, 701 .identify_state = m920x_identify_state,
554 .num_adapters = 1, 702 .num_adapters = 1,
555 .adapter = {{ 703 .adapter = {{
556 .caps = DVB_USB_ADAP_HAS_PID_FILTER | 704 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
557 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF, 705 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
558 706
559 .pid_filter_count = 8, 707 .pid_filter_count = 8,
560 .pid_filter = m9206_pid_filter, 708 .pid_filter = m920x_pid_filter,
561 .pid_filter_ctrl = m9206_pid_filter_ctrl, 709 .pid_filter_ctrl = m920x_pid_filter_ctrl,
562 710
563 .frontend_attach = digivox_tda10046_frontend_attach, 711 .frontend_attach = m920x_tda10046_08_frontend_attach,
564 .tuner_attach = digivox_tda8275_tuner_attach, 712 .tuner_attach = m920x_tda8275_60_tuner_attach,
565 713
566 .stream = { 714 .stream = {
567 .type = USB_BULK, 715 .type = USB_BULK,
@@ -574,7 +722,7 @@ static struct dvb_usb_device_properties digivox_mini_ii_properties = {
574 } 722 }
575 }, 723 },
576 }}, 724 }},
577 .i2c_algo = &m9206_i2c_algo, 725 .i2c_algo = &m920x_i2c_algo,
578 726
579 .num_device_descs = 1, 727 .num_device_descs = 1,
580 .devices = { 728 .devices = {
@@ -585,6 +733,122 @@ static struct dvb_usb_device_properties digivox_mini_ii_properties = {
585 } 733 }
586}; 734};
587 735
736/* LifeView TV Walker Twin support by Nick Andrew <nick@nick-andrew.net>
737 *
738 * LifeView TV Walker Twin has 1 x M9206, 2 x TDA10046, 2 x TDA8275A
739 * TDA10046 #0 is located at i2c address 0x08
740 * TDA10046 #1 is located at i2c address 0x0b (presently disabled - not yet working)
741 * TDA8275A #0 is located at i2c address 0x60
742 * TDA8275A #1 is located at i2c address 0x61 (presently disabled - not yet working)
743 */
744static struct dvb_usb_device_properties tvwalkertwin_properties = {
745 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
746
747 .usb_ctrl = DEVICE_SPECIFIC,
748 .firmware = "dvb-usb-tvwalkert.fw",
749 .download_firmware = m920x_firmware_download,
750
751 .rc_interval = 100,
752 .rc_key_map = tvwalkertwin_rc_keys,
753 .rc_key_map_size = ARRAY_SIZE(tvwalkertwin_rc_keys),
754 .rc_query = m920x_rc_query,
755
756 .size_of_priv = sizeof(struct m920x_state),
757
758 .identify_state = m920x_identify_state,
759 .num_adapters = 1,
760 .adapter = {{
761 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
762 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
763
764 .pid_filter_count = 8,
765 .pid_filter = m920x_pid_filter,
766 .pid_filter_ctrl = m920x_pid_filter_ctrl,
767
768 .frontend_attach = m920x_tda10046_08_frontend_attach,
769 .tuner_attach = m920x_tda8275_60_tuner_attach,
770
771 .stream = {
772 .type = USB_BULK,
773 .count = 8,
774 .endpoint = 0x81,
775 .u = {
776 .bulk = {
777 .buffersize = 512,
778 }
779 }
780 }},{
781 .caps = DVB_USB_ADAP_HAS_PID_FILTER |
782 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
783
784 .pid_filter_count = 8,
785 .pid_filter = m920x_pid_filter,
786 .pid_filter_ctrl = m920x_pid_filter_ctrl,
787
788 .frontend_attach = m920x_tda10046_0b_frontend_attach,
789 .tuner_attach = m920x_tda8275_61_tuner_attach,
790
791 .stream = {
792 .type = USB_BULK,
793 .count = 8,
794 .endpoint = 0x82,
795 .u = {
796 .bulk = {
797 .buffersize = 512,
798 }
799 }
800 },
801 }},
802 .i2c_algo = &m920x_i2c_algo,
803
804 .num_device_descs = 1,
805 .devices = {
806 { .name = "LifeView TV Walker Twin DVB-T USB2.0",
807 .cold_ids = { &m920x_table[2], NULL },
808 .warm_ids = { &m920x_table[3], NULL },
809 },
810 }
811};
812
813static struct dvb_usb_device_properties dposh_properties = {
814 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
815
816 .usb_ctrl = DEVICE_SPECIFIC,
817 .firmware = "dvb-usb-dposh-01.fw",
818 .download_firmware = m920x_firmware_download,
819
820 .size_of_priv = sizeof(struct m920x_state),
821
822 .identify_state = m920x_identify_state,
823 .num_adapters = 1,
824 .adapter = {{
825 /* Hardware pid filters don't work with this device/firmware */
826
827 .frontend_attach = m920x_mt352_frontend_attach,
828 .tuner_attach = m920x_qt1010_tuner_attach,
829
830 .stream = {
831 .type = USB_BULK,
832 .count = 8,
833 .endpoint = 0x81,
834 .u = {
835 .bulk = {
836 .buffersize = 512,
837 }
838 }
839 },
840 }},
841 .i2c_algo = &m920x_i2c_algo,
842
843 .num_device_descs = 1,
844 .devices = {
845 { .name = "Dposh DVB-T USB2.0",
846 .cold_ids = { &m920x_table[4], NULL },
847 .warm_ids = { &m920x_table[5], NULL },
848 },
849 }
850};
851
588static struct usb_driver m920x_driver = { 852static struct usb_driver m920x_driver = {
589 .name = "dvb_usb_m920x", 853 .name = "dvb_usb_m920x",
590 .probe = m920x_probe, 854 .probe = m920x_probe,
@@ -615,6 +879,11 @@ module_init (m920x_module_init);
615module_exit (m920x_module_exit); 879module_exit (m920x_module_exit);
616 880
617MODULE_AUTHOR("Aapo Tahkola <aet@rasterburn.org>"); 881MODULE_AUTHOR("Aapo Tahkola <aet@rasterburn.org>");
618MODULE_DESCRIPTION("Driver MSI Mega Sky 580 DVB-T USB2.0 / Uli m920x"); 882MODULE_DESCRIPTION("DVB Driver for ULI M920x");
619MODULE_VERSION("0.1"); 883MODULE_VERSION("0.1");
620MODULE_LICENSE("GPL"); 884MODULE_LICENSE("GPL");
885
886/*
887 * Local variables:
888 * c-basic-offset: 8
889 */
diff --git a/drivers/media/dvb/dvb-usb/m920x.h b/drivers/media/dvb/dvb-usb/m920x.h
index 7dd3db65c80e..2c8942d04222 100644
--- a/drivers/media/dvb/dvb-usb/m920x.h
+++ b/drivers/media/dvb/dvb-usb/m920x.h
@@ -4,7 +4,7 @@
4#define DVB_USB_LOG_PREFIX "m920x" 4#define DVB_USB_LOG_PREFIX "m920x"
5#include "dvb-usb.h" 5#include "dvb-usb.h"
6 6
7#define deb_rc(args...) dprintk(dvb_usb_m920x_debug,0x01,args) 7#define deb(args...) dprintk(dvb_usb_m920x_debug,0x01,args)
8 8
9#define M9206_CORE 0x22 9#define M9206_CORE 0x22
10#define M9206_RC_STATE 0xff51 10#define M9206_RC_STATE 0xff51
@@ -59,9 +59,18 @@ What any other bits might mean, or how to get the slave's ACK/NACK
59response to a write, is unknown. 59response to a write, is unknown.
60*/ 60*/
61 61
62struct m9206_state { 62struct m920x_state {
63 u16 filters[M9206_MAX_FILTERS]; 63 u16 filters[M9206_MAX_FILTERS];
64 int filtering_enabled; 64 int filtering_enabled;
65 int rep_count; 65 int rep_count;
66}; 66};
67
68/* Initialisation data for the m920x
69 */
70
71struct m920x_inits {
72 u16 address;
73 u8 data;
74};
75
67#endif 76#endif
diff --git a/drivers/media/dvb/dvb-usb/vp702x-fe.c b/drivers/media/dvb/dvb-usb/vp702x-fe.c
index 3ecb2e0ce80f..c3fdc7cd094e 100644
--- a/drivers/media/dvb/dvb-usb/vp702x-fe.c
+++ b/drivers/media/dvb/dvb-usb/vp702x-fe.c
@@ -204,8 +204,8 @@ static int vp702x_fe_get_frontend(struct dvb_frontend* fe,
204static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, 204static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe,
205 struct dvb_diseqc_master_cmd *m) 205 struct dvb_diseqc_master_cmd *m)
206{ 206{
207 //struct vp702x_fe_state *st = fe->demodulator_priv; 207 struct vp702x_fe_state *st = fe->demodulator_priv;
208 u8 cmd[8];//,ibuf[10]; 208 u8 cmd[8],ibuf[10];
209 memset(cmd,0,8); 209 memset(cmd,0,8);
210 210
211 deb_fe("%s\n",__FUNCTION__); 211 deb_fe("%s\n",__FUNCTION__);
@@ -218,12 +218,12 @@ static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe,
218 memcpy(&cmd[3], m->msg, m->msg_len); 218 memcpy(&cmd[3], m->msg, m->msg_len);
219 cmd[7] = vp702x_chksum(cmd,0,7); 219 cmd[7] = vp702x_chksum(cmd,0,7);
220 220
221// vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); 221 vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100);
222 222
223// if (ibuf[2] == 0 && ibuf[3] == 0) 223 if (ibuf[2] == 0 && ibuf[3] == 0)
224// deb_fe("diseqc cmd failed.\n"); 224 deb_fe("diseqc cmd failed.\n");
225// else 225 else
226// deb_fe("diseqc cmd succeeded.\n"); 226 deb_fe("diseqc cmd succeeded.\n");
227 227
228 return 0; 228 return 0;
229} 229}
diff --git a/drivers/media/dvb/pluto2/pluto2.c b/drivers/media/dvb/pluto2/pluto2.c
index 058df5c10034..08a2599ed74a 100644
--- a/drivers/media/dvb/pluto2/pluto2.c
+++ b/drivers/media/dvb/pluto2/pluto2.c
@@ -293,12 +293,20 @@ static void pluto_dma_end(struct pluto *pluto, unsigned int nbpackets)
293 * but no packets have been transfered. 293 * but no packets have been transfered.
294 * [2] Sometimes (actually very often) NBPACKETS stays at zero 294 * [2] Sometimes (actually very often) NBPACKETS stays at zero
295 * although one packet has been transfered. 295 * although one packet has been transfered.
296 * [3] Sometimes (actually rarely), the card gets into an erroneous
297 * mode where it continuously generates interrupts, claiming it
298 * has recieved nbpackets>TS_DMA_PACKETS packets, but no packet
299 * has been transfered. Only a reset seems to solve this
296 */ 300 */
297 if ((nbpackets == 0) || (nbpackets > TS_DMA_PACKETS)) { 301 if ((nbpackets == 0) || (nbpackets > TS_DMA_PACKETS)) {
298 unsigned int i = 0; 302 unsigned int i = 0;
299 while (pluto->dma_buf[i] == 0x47) 303 while (pluto->dma_buf[i] == 0x47)
300 i += 188; 304 i += 188;
301 nbpackets = i / 188; 305 nbpackets = i / 188;
306 if (i == 0) {
307 pluto_reset_ts(pluto, 1);
308 dev_printk(KERN_DEBUG, &pluto->pdev->dev, "resetting TS because of invalid packet counter\n");
309 }
302 } 310 }
303 311
304 dvb_dmx_swfilter_packets(&pluto->demux, pluto->dma_buf, nbpackets); 312 dvb_dmx_swfilter_packets(&pluto->demux, pluto->dma_buf, nbpackets);
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 67becdd4db60..ef1108c0bf11 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -1246,6 +1246,9 @@ static void vpeirq(unsigned long data)
1246 if (!budget->feeding1 || (newdma == olddma)) 1246 if (!budget->feeding1 || (newdma == olddma))
1247 return; 1247 return;
1248 1248
1249 /* Ensure streamed PCI data is synced to CPU */
1250 pci_dma_sync_sg_for_cpu(budget->dev->pci, budget->pt.slist, budget->pt.nents, PCI_DMA_FROMDEVICE);
1251
1249#if 0 1252#if 0
1250 /* track rps1 activity */ 1253 /* track rps1 activity */
1251 printk("vpeirq: %02x Event Counter 1 0x%04x\n", 1254 printk("vpeirq: %02x Event Counter 1 0x%04x\n",
@@ -2679,8 +2682,8 @@ err_iobuf_vfree_6:
2679err_pci_free_5: 2682err_pci_free_5:
2680 pci_free_consistent(pdev, 8192, av7110->debi_virt, av7110->debi_bus); 2683 pci_free_consistent(pdev, 8192, av7110->debi_virt, av7110->debi_bus);
2681err_saa71466_vfree_4: 2684err_saa71466_vfree_4:
2682 if (!av7110->grabbing) 2685 if (av7110->grabbing)
2683 saa7146_pgtable_free(pdev, &av7110->pt); 2686 saa7146_vfree_destroy_pgtable(pdev, av7110->grabbing, &av7110->pt);
2684err_i2c_del_3: 2687err_i2c_del_3:
2685 i2c_del_adapter(&av7110->i2c_adap); 2688 i2c_del_adapter(&av7110->i2c_adap);
2686err_dvb_unregister_adapter_2: 2689err_dvb_unregister_adapter_2:
@@ -2710,7 +2713,7 @@ static int __devexit av7110_detach(struct saa7146_dev* saa)
2710 SAA7146_ISR_CLEAR(saa, MASK_10); 2713 SAA7146_ISR_CLEAR(saa, MASK_10);
2711 msleep(50); 2714 msleep(50);
2712 tasklet_kill(&av7110->vpe_tasklet); 2715 tasklet_kill(&av7110->vpe_tasklet);
2713 saa7146_pgtable_free(saa->pci, &av7110->pt); 2716 saa7146_vfree_destroy_pgtable(saa->pci, av7110->grabbing, &av7110->pt);
2714 } 2717 }
2715 av7110_exit_v4l(av7110); 2718 av7110_exit_v4l(av7110);
2716 2719
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index 4ed4599ce816..9d42f88ebb0e 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -904,7 +904,7 @@ static int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struc
904 band = 1; 904 band = 1;
905 } else if (tuner_frequency < 200000000) { 905 } else if (tuner_frequency < 200000000) {
906 cp = 6; 906 cp = 6;
907 band = 2; 907 band = 1;
908 } else if (tuner_frequency < 290000000) { 908 } else if (tuner_frequency < 290000000) {
909 cp = 3; 909 cp = 3;
910 band = 2; 910 band = 2;
diff --git a/drivers/media/dvb/ttpci/budget-core.c b/drivers/media/dvb/ttpci/budget-core.c
index 6b97dc1e6b65..2557ac9620d0 100644
--- a/drivers/media/dvb/ttpci/budget-core.c
+++ b/drivers/media/dvb/ttpci/budget-core.c
@@ -195,6 +195,9 @@ static void vpeirq(unsigned long data)
195 u32 newdma = saa7146_read(budget->dev, PCI_VDP3); 195 u32 newdma = saa7146_read(budget->dev, PCI_VDP3);
196 u32 count; 196 u32 count;
197 197
198 /* Ensure streamed PCI data is synced to CPU */
199 pci_dma_sync_sg_for_cpu(budget->dev->pci, budget->pt.slist, budget->pt.nents, PCI_DMA_FROMDEVICE);
200
198 /* nearest lower position divisible by 188 */ 201 /* nearest lower position divisible by 188 */
199 newdma -= newdma % 188; 202 newdma -= newdma % 188;
200 203
@@ -504,16 +507,16 @@ int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev,
504 strcpy(budget->i2c_adap.name, budget->card->name); 507 strcpy(budget->i2c_adap.name, budget->card->name);
505 508
506 if (i2c_add_adapter(&budget->i2c_adap) < 0) { 509 if (i2c_add_adapter(&budget->i2c_adap) < 0) {
507 dvb_unregister_adapter(&budget->dvb_adapter); 510 ret = -ENOMEM;
508 return -ENOMEM; 511 goto err_dvb_unregister;
509 } 512 }
510 513
511 ttpci_eeprom_parse_mac(&budget->i2c_adap, budget->dvb_adapter.proposed_mac); 514 ttpci_eeprom_parse_mac(&budget->i2c_adap, budget->dvb_adapter.proposed_mac);
512 515
513 if (NULL == 516 budget->grabbing = saa7146_vmalloc_build_pgtable(dev->pci, budget->buffer_size, &budget->pt);
514 (budget->grabbing = saa7146_vmalloc_build_pgtable(dev->pci, budget->buffer_size, &budget->pt))) { 517 if (NULL == budget->grabbing) {
515 ret = -ENOMEM; 518 ret = -ENOMEM;
516 goto err; 519 goto err_del_i2c;
517 } 520 }
518 521
519 saa7146_write(dev, PCI_BT_V1, 0x001c0000); 522 saa7146_write(dev, PCI_BT_V1, 0x001c0000);
@@ -526,14 +529,16 @@ int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev,
526 if (bi->type != BUDGET_FS_ACTIVY) 529 if (bi->type != BUDGET_FS_ACTIVY)
527 saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI); 530 saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI);
528 531
529 if (budget_register(budget) == 0) { 532 if (budget_register(budget) == 0)
530 return 0; 533 return 0; /* Everything OK */
531 } 534
532err: 535 /* An error occurred, cleanup resources */
533 i2c_del_adapter(&budget->i2c_adap); 536 saa7146_vfree_destroy_pgtable(dev->pci, budget->grabbing, &budget->pt);
534 537
535 vfree(budget->grabbing); 538err_del_i2c:
539 i2c_del_adapter(&budget->i2c_adap);
536 540
541err_dvb_unregister:
537 dvb_unregister_adapter(&budget->dvb_adapter); 542 dvb_unregister_adapter(&budget->dvb_adapter);
538 543
539 return ret; 544 return ret;
@@ -555,15 +560,13 @@ int ttpci_budget_deinit(struct budget *budget)
555 560
556 budget_unregister(budget); 561 budget_unregister(budget);
557 562
558 i2c_del_adapter(&budget->i2c_adap);
559
560 dvb_unregister_adapter(&budget->dvb_adapter);
561
562 tasklet_kill(&budget->vpe_tasklet); 563 tasklet_kill(&budget->vpe_tasklet);
563 564
564 saa7146_pgtable_free(dev->pci, &budget->pt); 565 saa7146_vfree_destroy_pgtable(dev->pci, budget->grabbing, &budget->pt);
565 566
566 vfree(budget->grabbing); 567 i2c_del_adapter(&budget->i2c_adap);
568
569 dvb_unregister_adapter(&budget->dvb_adapter);
567 570
568 return 0; 571 return 0;
569} 572}
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index af66a5d5ecd8..a6ac82a609d4 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -2,8 +2,14 @@
2# Multimedia Video device configuration 2# Multimedia Video device configuration
3# 3#
4 4
5menu "Radio Adapters" 5menuconfig RADIO_ADAPTERS
6 bool "Radio Adapters"
6 depends on VIDEO_DEV 7 depends on VIDEO_DEV
8 default y
9 ---help---
10 Say Y here to enable selecting AM/FM radio adapters.
11
12if RADIO_ADAPTERS
7 13
8config RADIO_CADET 14config RADIO_CADET
9 tristate "ADS Cadet AM/FM Tuner" 15 tristate "ADS Cadet AM/FM Tuner"
@@ -328,4 +334,5 @@ config USB_DSBR
328 334
329 To compile this driver as a module, choose M here: the 335 To compile this driver as a module, choose M here: the
330 module will be called dsbr100. 336 module will be called dsbr100.
331endmenu 337
338endif # RADIO_ADAPTERS
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c
index 449df1bb00d3..3bd07f7e3774 100644
--- a/drivers/media/radio/dsbr100.c
+++ b/drivers/media/radio/dsbr100.c
@@ -33,6 +33,10 @@
33 33
34 History: 34 History:
35 35
36 Version 0.42:
37 Converted dsbr100 to use video_ioctl2
38 by Douglas Landgraf <dougsland@gmail.com>
39
36 Version 0.41-ac1: 40 Version 0.41-ac1:
37 Alan Cox: Some cleanups and fixes 41 Alan Cox: Some cleanups and fixes
38 42
@@ -121,8 +125,6 @@ devices, that would be 76 and 91. */
121static int usb_dsbr100_probe(struct usb_interface *intf, 125static int usb_dsbr100_probe(struct usb_interface *intf,
122 const struct usb_device_id *id); 126 const struct usb_device_id *id);
123static void usb_dsbr100_disconnect(struct usb_interface *intf); 127static void usb_dsbr100_disconnect(struct usb_interface *intf);
124static int usb_dsbr100_ioctl(struct inode *inode, struct file *file,
125 unsigned int cmd, unsigned long arg);
126static int usb_dsbr100_open(struct inode *inode, struct file *file); 128static int usb_dsbr100_open(struct inode *inode, struct file *file);
127static int usb_dsbr100_close(struct inode *inode, struct file *file); 129static int usb_dsbr100_close(struct inode *inode, struct file *file);
128 130
@@ -142,26 +144,6 @@ struct dsbr100_device {
142}; 144};
143 145
144 146
145/* File system interface */
146static const struct file_operations usb_dsbr100_fops = {
147 .owner = THIS_MODULE,
148 .open = usb_dsbr100_open,
149 .release = usb_dsbr100_close,
150 .ioctl = usb_dsbr100_ioctl,
151 .compat_ioctl = v4l_compat_ioctl32,
152 .llseek = no_llseek,
153};
154
155/* V4L interface */
156static struct video_device dsbr100_videodev_template=
157{
158 .owner = THIS_MODULE,
159 .name = "D-Link DSB-R 100",
160 .type = VID_TYPE_TUNER,
161 .fops = &usb_dsbr100_fops,
162 .release = video_device_release,
163};
164
165static struct usb_device_id usb_dsbr100_device_table [] = { 147static struct usb_device_id usb_dsbr100_device_table [] = {
166 { USB_DEVICE(DSB100_VENDOR, DSB100_PRODUCT) }, 148 { USB_DEVICE(DSB100_VENDOR, DSB100_PRODUCT) },
167 { } /* Terminating entry */ 149 { } /* Terminating entry */
@@ -252,37 +234,6 @@ static void dsbr100_getstat(struct dsbr100_device *radio)
252 234
253/* USB subsystem interface begins here */ 235/* USB subsystem interface begins here */
254 236
255/* check if the device is present and register with v4l and
256usb if it is */
257static int usb_dsbr100_probe(struct usb_interface *intf,
258 const struct usb_device_id *id)
259{
260 struct dsbr100_device *radio;
261
262 if (!(radio = kmalloc(sizeof(struct dsbr100_device), GFP_KERNEL)))
263 return -ENOMEM;
264 if (!(radio->videodev = video_device_alloc())) {
265 kfree(radio);
266 return -ENOMEM;
267 }
268 memcpy(radio->videodev, &dsbr100_videodev_template,
269 sizeof(dsbr100_videodev_template));
270 radio->removed = 0;
271 radio->users = 0;
272 radio->usbdev = interface_to_usbdev(intf);
273 radio->curfreq = FREQ_MIN*FREQ_MUL;
274 video_set_drvdata(radio->videodev, radio);
275 if (video_register_device(radio->videodev, VFL_TYPE_RADIO,
276 radio_nr)) {
277 warn("Could not register video device");
278 video_device_release(radio->videodev);
279 kfree(radio);
280 return -EIO;
281 }
282 usb_set_intfdata(intf, radio);
283 return 0;
284}
285
286/* handle unplugging of the device, release data structures 237/* handle unplugging of the device, release data structures
287if nothing keeps us from doing it. If something is still 238if nothing keeps us from doing it. If something is still
288keeping us busy, the release callback of v4l will take care 239keeping us busy, the release callback of v4l will take care
@@ -307,133 +258,147 @@ static void usb_dsbr100_disconnect(struct usb_interface *intf)
307} 258}
308 259
309 260
310/* Video for Linux interface */ 261static int vidioc_querycap(struct file *file, void *priv,
262 struct v4l2_capability *v)
263{
264 strlcpy(v->driver, "dsbr100", sizeof(v->driver));
265 strlcpy(v->card, "D-Link R-100 USB FM Radio", sizeof(v->card));
266 sprintf(v->bus_info, "ISA");
267 v->version = RADIO_VERSION;
268 v->capabilities = V4L2_CAP_TUNER;
269 return 0;
270}
311 271
312static int usb_dsbr100_do_ioctl(struct inode *inode, struct file *file, 272static int vidioc_g_tuner(struct file *file, void *priv,
313 unsigned int cmd, void *arg) 273 struct v4l2_tuner *v)
314{ 274{
315 struct dsbr100_device *radio=video_get_drvdata(video_devdata(file)); 275 struct dsbr100_device *radio = video_get_drvdata(video_devdata(file));
276
277 if (v->index > 0)
278 return -EINVAL;
279
280 dsbr100_getstat(radio);
281 strcpy(v->name, "FM");
282 v->type = V4L2_TUNER_RADIO;
283 v->rangelow = FREQ_MIN*FREQ_MUL;
284 v->rangehigh = FREQ_MAX*FREQ_MUL;
285 v->rxsubchans = V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO;
286 v->capability = V4L2_TUNER_CAP_LOW;
287 if(radio->stereo)
288 v->audmode = V4L2_TUNER_MODE_STEREO;
289 else
290 v->audmode = V4L2_TUNER_MODE_MONO;
291 v->signal = 0xffff; /* We can't get the signal strength */
292 return 0;
293}
316 294
317 if (!radio) 295static int vidioc_s_tuner(struct file *file, void *priv,
318 return -EIO; 296 struct v4l2_tuner *v)
297{
298 if (v->index > 0)
299 return -EINVAL;
319 300
320 switch(cmd) { 301 return 0;
321 case VIDIOC_QUERYCAP: 302}
322 {
323 struct v4l2_capability *v = arg;
324 memset(v,0,sizeof(*v));
325 strlcpy(v->driver, "dsbr100", sizeof (v->driver));
326 strlcpy(v->card, "D-Link R-100 USB FM Radio", sizeof (v->card));
327 sprintf(v->bus_info,"ISA");
328 v->version = RADIO_VERSION;
329 v->capabilities = V4L2_CAP_TUNER;
330 303
331 return 0; 304static int vidioc_s_frequency(struct file *file, void *priv,
332 } 305 struct v4l2_frequency *f)
333 case VIDIOC_G_TUNER: 306{
334 { 307 struct dsbr100_device *radio = video_get_drvdata(video_devdata(file));
335 struct v4l2_tuner *v = arg;
336 308
337 if (v->index > 0) 309 radio->curfreq = f->frequency;
338 return -EINVAL; 310 if (dsbr100_setfreq(radio, radio->curfreq)==-1)
311 warn("Set frequency failed");
312 return 0;
313}
339 314
340 dsbr100_getstat(radio); 315static int vidioc_g_frequency(struct file *file, void *priv,
316 struct v4l2_frequency *f)
317{
318 struct dsbr100_device *radio = video_get_drvdata(video_devdata(file));
341 319
342 memset(v,0,sizeof(*v)); 320 f->type = V4L2_TUNER_RADIO;
343 strcpy(v->name, "FM"); 321 f->frequency = radio->curfreq;
344 v->type = V4L2_TUNER_RADIO; 322 return 0;
323}
345 324
346 v->rangelow = FREQ_MIN*FREQ_MUL; 325static int vidioc_queryctrl(struct file *file, void *priv,
347 v->rangehigh = FREQ_MAX*FREQ_MUL; 326 struct v4l2_queryctrl *qc)
348 v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO; 327{
349 v->capability=V4L2_TUNER_CAP_LOW; 328 int i;
350 if(radio->stereo)
351 v->audmode = V4L2_TUNER_MODE_STEREO;
352 else
353 v->audmode = V4L2_TUNER_MODE_MONO;
354 v->signal = 0xFFFF; /* We can't get the signal strength */
355 329
330 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
331 if (qc->id && qc->id == radio_qctrl[i].id) {
332 memcpy(qc, &(radio_qctrl[i]),
333 sizeof(*qc));
356 return 0; 334 return 0;
357 } 335 }
358 case VIDIOC_S_TUNER: 336 }
359 { 337 return -EINVAL;
360 struct v4l2_tuner *v = arg; 338}
361
362 if (v->index > 0)
363 return -EINVAL;
364 339
365 return 0; 340static int vidioc_g_ctrl(struct file *file, void *priv,
366 } 341 struct v4l2_control *ctrl)
367 case VIDIOC_S_FREQUENCY: 342{
368 { 343 struct dsbr100_device *radio = video_get_drvdata(video_devdata(file));
369 struct v4l2_frequency *f = arg;
370 344
371 radio->curfreq = f->frequency; 345 switch (ctrl->id) {
372 if (dsbr100_setfreq(radio, radio->curfreq)==-1) 346 case V4L2_CID_AUDIO_MUTE:
373 warn("Set frequency failed"); 347 ctrl->value = radio->muted;
374 return 0; 348 return 0;
375 } 349 }
376 case VIDIOC_G_FREQUENCY: 350 return -EINVAL;
377 { 351}
378 struct v4l2_frequency *f = arg;
379 352
380 f->type = V4L2_TUNER_RADIO; 353static int vidioc_s_ctrl(struct file *file, void *priv,
381 f->frequency = radio->curfreq; 354 struct v4l2_control *ctrl)
355{
356 struct dsbr100_device *radio = video_get_drvdata(video_devdata(file));
382 357
383 return 0; 358 switch (ctrl->id) {
384 } 359 case V4L2_CID_AUDIO_MUTE:
385 case VIDIOC_QUERYCTRL: 360 if (ctrl->value) {
386 { 361 if (dsbr100_stop(radio)==-1)
387 struct v4l2_queryctrl *qc = arg; 362 warn("Radio did not respond properly");
388 int i; 363 } else {
389 364 if (dsbr100_start(radio)==-1)
390 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { 365 warn("Radio did not respond properly");
391 if (qc->id && qc->id == radio_qctrl[i].id) {
392 memcpy(qc, &(radio_qctrl[i]),
393 sizeof(*qc));
394 return 0;
395 }
396 }
397 return -EINVAL;
398 }
399 case VIDIOC_G_CTRL:
400 {
401 struct v4l2_control *ctrl= arg;
402
403 switch (ctrl->id) {
404 case V4L2_CID_AUDIO_MUTE:
405 ctrl->value=radio->muted;
406 return 0;
407 }
408 return -EINVAL;
409 }
410 case VIDIOC_S_CTRL:
411 {
412 struct v4l2_control *ctrl= arg;
413
414 switch (ctrl->id) {
415 case V4L2_CID_AUDIO_MUTE:
416 if (ctrl->value) {
417 if (dsbr100_stop(radio)==-1)
418 warn("Radio did not respond properly");
419 } else {
420 if (dsbr100_start(radio)==-1)
421 warn("Radio did not respond properly");
422 }
423 return 0;
424 }
425 return -EINVAL;
426 } 366 }
427 default: 367 return 0;
428 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
429 usb_dsbr100_do_ioctl);
430 } 368 }
369 return -EINVAL;
431} 370}
432 371
433static int usb_dsbr100_ioctl(struct inode *inode, struct file *file, 372static int vidioc_g_audio(struct file *file, void *priv,
434 unsigned int cmd, unsigned long arg) 373 struct v4l2_audio *a)
435{ 374{
436 return video_usercopy(inode, file, cmd, arg, usb_dsbr100_do_ioctl); 375 if (a->index > 1)
376 return -EINVAL;
377
378 strcpy(a->name, "Radio");
379 a->capability = V4L2_AUDCAP_STEREO;
380 return 0;
381}
382
383static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i)
384{
385 *i = 0;
386 return 0;
387}
388
389static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
390{
391 if (i != 0)
392 return -EINVAL;
393 return 0;
394}
395
396static int vidioc_s_audio(struct file *file, void *priv,
397 struct v4l2_audio *a)
398{
399 if (a->index != 0)
400 return -EINVAL;
401 return 0;
437} 402}
438 403
439static int usb_dsbr100_open(struct inode *inode, struct file *file) 404static int usb_dsbr100_open(struct inode *inode, struct file *file)
@@ -465,6 +430,68 @@ static int usb_dsbr100_close(struct inode *inode, struct file *file)
465 return 0; 430 return 0;
466} 431}
467 432
433/* File system interface */
434static const struct file_operations usb_dsbr100_fops = {
435 .owner = THIS_MODULE,
436 .open = usb_dsbr100_open,
437 .release = usb_dsbr100_close,
438 .ioctl = video_ioctl2,
439 .compat_ioctl = v4l_compat_ioctl32,
440 .llseek = no_llseek,
441};
442
443/* V4L2 interface */
444static struct video_device dsbr100_videodev_template =
445{
446 .owner = THIS_MODULE,
447 .name = "D-Link DSB-R 100",
448 .type = VID_TYPE_TUNER,
449 .fops = &usb_dsbr100_fops,
450 .release = video_device_release,
451 .vidioc_querycap = vidioc_querycap,
452 .vidioc_g_tuner = vidioc_g_tuner,
453 .vidioc_s_tuner = vidioc_s_tuner,
454 .vidioc_g_frequency = vidioc_g_frequency,
455 .vidioc_s_frequency = vidioc_s_frequency,
456 .vidioc_queryctrl = vidioc_queryctrl,
457 .vidioc_g_ctrl = vidioc_g_ctrl,
458 .vidioc_s_ctrl = vidioc_s_ctrl,
459 .vidioc_g_audio = vidioc_g_audio,
460 .vidioc_s_audio = vidioc_s_audio,
461 .vidioc_g_input = vidioc_g_input,
462 .vidioc_s_input = vidioc_s_input,
463};
464
465/* check if the device is present and register with v4l and
466usb if it is */
467static int usb_dsbr100_probe(struct usb_interface *intf,
468 const struct usb_device_id *id)
469{
470 struct dsbr100_device *radio;
471
472 if (!(radio = kmalloc(sizeof(struct dsbr100_device), GFP_KERNEL)))
473 return -ENOMEM;
474 if (!(radio->videodev = video_device_alloc())) {
475 kfree(radio);
476 return -ENOMEM;
477 }
478 memcpy(radio->videodev, &dsbr100_videodev_template,
479 sizeof(dsbr100_videodev_template));
480 radio->removed = 0;
481 radio->users = 0;
482 radio->usbdev = interface_to_usbdev(intf);
483 radio->curfreq = FREQ_MIN*FREQ_MUL;
484 video_set_drvdata(radio->videodev, radio);
485 if (video_register_device(radio->videodev, VFL_TYPE_RADIO,radio_nr)) {
486 warn("Could not register video device");
487 video_device_release(radio->videodev);
488 kfree(radio);
489 return -EIO;
490 }
491 usb_set_intfdata(intf, radio);
492 return 0;
493}
494
468static int __init dsbr100_init(void) 495static int __init dsbr100_init(void)
469{ 496{
470 int retval = usb_register(&usb_dsbr100_driver); 497 int retval = usb_register(&usb_dsbr100_driver);
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index 8fbf0d8bd278..8cf2e9df5c8a 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -48,6 +48,25 @@
48 48
49#define CADET_VERSION KERNEL_VERSION(0,3,3) 49#define CADET_VERSION KERNEL_VERSION(0,3,3)
50 50
51static struct v4l2_queryctrl radio_qctrl[] = {
52 {
53 .id = V4L2_CID_AUDIO_MUTE,
54 .name = "Mute",
55 .minimum = 0,
56 .maximum = 1,
57 .default_value = 1,
58 .type = V4L2_CTRL_TYPE_BOOLEAN,
59 },{
60 .id = V4L2_CID_AUDIO_VOLUME,
61 .name = "Volume",
62 .minimum = 0,
63 .maximum = 0xff,
64 .step = 1,
65 .default_value = 0xff,
66 .type = V4L2_CTRL_TYPE_INTEGER,
67 }
68};
69
51static int io=-1; /* default to isapnp activation */ 70static int io=-1; /* default to isapnp activation */
52static int radio_nr = -1; 71static int radio_nr = -1;
53static int users=0; 72static int users=0;
@@ -347,135 +366,165 @@ cadet_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
347} 366}
348 367
349 368
369static int vidioc_querycap(struct file *file, void *priv,
370 struct v4l2_capability *v)
371{
372 v->capabilities =
373 V4L2_CAP_TUNER |
374 V4L2_CAP_READWRITE;
375 v->version = CADET_VERSION;
376 strcpy(v->driver, "ADS Cadet");
377 strcpy(v->card, "ADS Cadet");
378 return 0;
379}
350 380
351static int cadet_do_ioctl(struct inode *inode, struct file *file, 381static int vidioc_g_tuner(struct file *file, void *priv,
352 unsigned int cmd, void *arg) 382 struct v4l2_tuner *v)
353{ 383{
354 switch(cmd) 384 v->type = V4L2_TUNER_RADIO;
355 { 385 switch (v->index) {
356 case VIDIOC_QUERYCAP: 386 case 0:
357 { 387 strcpy(v->name, "FM");
358 struct v4l2_capability *cap = arg; 388 v->capability = V4L2_TUNER_CAP_STEREO;
359 memset(cap,0,sizeof(*cap)); 389 v->rangelow = 1400; /* 87.5 MHz */
360 cap->capabilities = 390 v->rangehigh = 1728; /* 108.0 MHz */
361 V4L2_CAP_TUNER | 391 v->rxsubchans=cadet_getstereo();
362 V4L2_CAP_READWRITE; 392 switch (v->rxsubchans){
363 cap->version = CADET_VERSION; 393 case V4L2_TUNER_SUB_MONO:
364 strcpy(cap->driver, "ADS Cadet"); 394 v->audmode = V4L2_TUNER_MODE_MONO;
365 strcpy(cap->card, "ADS Cadet"); 395 break;
366 return 0; 396 case V4L2_TUNER_SUB_STEREO:
397 v->audmode = V4L2_TUNER_MODE_STEREO;
398 break;
399 default: ;
367 } 400 }
368 case VIDIOC_G_TUNER: 401 break;
369 { 402 case 1:
370 struct v4l2_tuner *t = arg; 403 strcpy(v->name, "AM");
371 memset(t,0,sizeof(*t)); 404 v->capability = V4L2_TUNER_CAP_LOW;
372 t->type = V4L2_TUNER_RADIO; 405 v->rangelow = 8320; /* 520 kHz */
373 switch (t->index) 406 v->rangehigh = 26400; /* 1650 kHz */
374 { 407 v->rxsubchans = V4L2_TUNER_SUB_MONO;
375 case 0: strcpy(t->name, "FM"); 408 v->audmode = V4L2_TUNER_MODE_MONO;
376 t->capability = V4L2_TUNER_CAP_STEREO; 409 break;
377 t->rangelow = 1400; /* 87.5 MHz */ 410 default:
378 t->rangehigh = 1728; /* 108.0 MHz */ 411 return -EINVAL;
379 t->rxsubchans=cadet_getstereo(); 412 }
380 switch (t->rxsubchans){ 413 v->signal = sigstrength; /* We might need to modify scaling of this */
381 case V4L2_TUNER_SUB_MONO: 414 return 0;
382 t->audmode = V4L2_TUNER_MODE_MONO; 415}
383 break;
384 case V4L2_TUNER_SUB_STEREO:
385 t->audmode = V4L2_TUNER_MODE_STEREO;
386 break;
387 default: ;
388 }
389 break;
390 case 1: strcpy(t->name, "AM");
391 t->capability = V4L2_TUNER_CAP_LOW;
392 t->rangelow = 8320; /* 520 kHz */
393 t->rangehigh = 26400; /* 1650 kHz */
394 t->rxsubchans = V4L2_TUNER_SUB_MONO;
395 t->audmode = V4L2_TUNER_MODE_MONO;
396 break;
397 default:
398 return -EINVAL;
399 }
400 416
401 t->signal = sigstrength; /* We might need to modify scaling of this */ 417static int vidioc_s_tuner(struct file *file, void *priv,
402 return 0; 418 struct v4l2_tuner *v)
403 } 419{
404 case VIDIOC_S_TUNER: 420 if((v->index != 0)&&(v->index != 1))
405 { 421 return -EINVAL;
406 struct v4l2_tuner *t = arg; 422 curtuner = v->index;
407 if((t->index != 0)&&(t->index != 1)) 423 return 0;
408 return -EINVAL; 424}
409 425
410 curtuner = t->index; 426static int vidioc_g_frequency(struct file *file, void *priv,
411 return 0; 427 struct v4l2_frequency *f)
412 } 428{
413 case VIDIOC_G_FREQUENCY: 429 f->tuner = curtuner;
414 { 430 f->type = V4L2_TUNER_RADIO;
415 struct v4l2_frequency *f = arg; 431 f->frequency = cadet_getfreq();
416 memset(f,0,sizeof(*f)); 432 return 0;
417 f->tuner = curtuner; 433}
418 f->type = V4L2_TUNER_RADIO; 434
419 f->frequency = cadet_getfreq(); 435
420 return 0; 436static int vidioc_s_frequency(struct file *file, void *priv,
421 } 437 struct v4l2_frequency *f)
422 case VIDIOC_S_FREQUENCY: 438{
423 { 439 if (f->type != V4L2_TUNER_RADIO)
424 struct v4l2_frequency *f = arg; 440 return -EINVAL;
425 if (f->type != V4L2_TUNER_RADIO){ 441 if((curtuner==0)&&((f->frequency<1400)||(f->frequency>1728)))
426 return -EINVAL; 442 return -EINVAL;
427 } 443 if((curtuner==1)&&((f->frequency<8320)||(f->frequency>26400)))
428 if((curtuner==0)&&((f->frequency<1400)||(f->frequency>1728))) { 444 return -EINVAL;
429 return -EINVAL; 445 cadet_setfreq(f->frequency);
430 } 446 return 0;
431 if((curtuner==1)&&((f->frequency<8320)||(f->frequency>26400))) { 447}
432 return -EINVAL; 448
433 } 449static int vidioc_queryctrl(struct file *file, void *priv,
434 cadet_setfreq(f->frequency); 450 struct v4l2_queryctrl *qc)
435 return 0; 451{
436 } 452 int i;
437 case VIDIOC_G_CTRL: 453
438 { 454 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
439 struct v4l2_control *c = arg; 455 if (qc->id && qc->id == radio_qctrl[i].id) {
440 switch (c->id){ 456 memcpy(qc, &(radio_qctrl[i]),
441 case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */ 457 sizeof(*qc));
442 c->value = (cadet_getvol() == 0);
443 break;
444 case V4L2_CID_AUDIO_VOLUME:
445 c->value = cadet_getvol();
446 break;
447 default:
448 return -EINVAL;
449 }
450 return 0;
451 }
452 case VIDIOC_S_CTRL:
453 {
454 struct v4l2_control *c = arg;
455 switch (c->id){
456 case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */
457 if (c->value) cadet_setvol(0);
458 else cadet_setvol(0xffff);
459 break;
460 case V4L2_CID_AUDIO_VOLUME:
461 cadet_setvol(c->value);
462 break;
463 default:
464 return -EINVAL;
465 }
466 return 0; 458 return 0;
467 } 459 }
460 }
461 return -EINVAL;
462}
468 463
469 default: 464static int vidioc_g_ctrl(struct file *file, void *priv,
470 return -ENOIOCTLCMD; 465 struct v4l2_control *ctrl)
466{
467 switch (ctrl->id){
468 case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */
469 ctrl->value = (cadet_getvol() == 0);
470 break;
471 case V4L2_CID_AUDIO_VOLUME:
472 ctrl->value = cadet_getvol();
473 break;
474 default:
475 return -EINVAL;
471 } 476 }
477 return 0;
472} 478}
473 479
474static int 480static int vidioc_s_ctrl(struct file *file, void *priv,
475cadet_ioctl(struct inode *inode, struct file *file, 481 struct v4l2_control *ctrl)
476 unsigned int cmd, unsigned long arg)
477{ 482{
478 return video_usercopy(inode, file, cmd, arg, cadet_do_ioctl); 483 switch (ctrl->id){
484 case V4L2_CID_AUDIO_MUTE: /* TODO: Handle this correctly */
485 if (ctrl->value)
486 cadet_setvol(0);
487 else
488 cadet_setvol(0xffff);
489 break;
490 case V4L2_CID_AUDIO_VOLUME:
491 cadet_setvol(ctrl->value);
492 break;
493 default:
494 return -EINVAL;
495 }
496 return 0;
497}
498
499static int vidioc_g_audio(struct file *file, void *priv,
500 struct v4l2_audio *a)
501{
502 if (a->index > 1)
503 return -EINVAL;
504 strcpy(a->name, "Radio");
505 a->capability = V4L2_AUDCAP_STEREO;
506 return 0;
507}
508
509static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i)
510{
511 *i = 0;
512 return 0;
513}
514
515static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
516{
517 if (i != 0)
518 return -EINVAL;
519 return 0;
520}
521
522static int vidioc_s_audio(struct file *file, void *priv,
523 struct v4l2_audio *a)
524{
525 if (a->index != 0)
526 return -EINVAL;
527 return 0;
479} 528}
480 529
481static int 530static int
@@ -512,7 +561,7 @@ static const struct file_operations cadet_fops = {
512 .open = cadet_open, 561 .open = cadet_open,
513 .release = cadet_release, 562 .release = cadet_release,
514 .read = cadet_read, 563 .read = cadet_read,
515 .ioctl = cadet_ioctl, 564 .ioctl = video_ioctl2,
516 .poll = cadet_poll, 565 .poll = cadet_poll,
517 .compat_ioctl = v4l_compat_ioctl32, 566 .compat_ioctl = v4l_compat_ioctl32,
518 .llseek = no_llseek, 567 .llseek = no_llseek,
@@ -524,6 +573,18 @@ static struct video_device cadet_radio=
524 .name = "Cadet radio", 573 .name = "Cadet radio",
525 .type = VID_TYPE_TUNER, 574 .type = VID_TYPE_TUNER,
526 .fops = &cadet_fops, 575 .fops = &cadet_fops,
576 .vidioc_querycap = vidioc_querycap,
577 .vidioc_g_tuner = vidioc_g_tuner,
578 .vidioc_s_tuner = vidioc_s_tuner,
579 .vidioc_g_frequency = vidioc_g_frequency,
580 .vidioc_s_frequency = vidioc_s_frequency,
581 .vidioc_queryctrl = vidioc_queryctrl,
582 .vidioc_g_ctrl = vidioc_g_ctrl,
583 .vidioc_s_ctrl = vidioc_s_ctrl,
584 .vidioc_g_audio = vidioc_g_audio,
585 .vidioc_s_audio = vidioc_s_audio,
586 .vidioc_g_input = vidioc_g_input,
587 .vidioc_s_input = vidioc_s_input,
527}; 588};
528 589
529static struct pnp_device_id cadet_pnp_devices[] = { 590static struct pnp_device_id cadet_pnp_devices[] = {
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c
index 11f80cacd6ed..8e33a19a22a3 100644
--- a/drivers/media/radio/radio-maestro.c
+++ b/drivers/media/radio/radio-maestro.c
@@ -24,7 +24,6 @@
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <asm/io.h> 25#include <asm/io.h>
26#include <asm/uaccess.h> 26#include <asm/uaccess.h>
27#include <linux/mutex.h>
28#include <linux/pci.h> 27#include <linux/pci.h>
29#include <linux/videodev2.h> 28#include <linux/videodev2.h>
30#include <media/v4l2-common.h> 29#include <media/v4l2-common.h>
@@ -110,7 +109,6 @@ struct radio_device {
110 muted, /* VIDEO_AUDIO_MUTE */ 109 muted, /* VIDEO_AUDIO_MUTE */
111 stereo, /* VIDEO_TUNER_STEREO_ON */ 110 stereo, /* VIDEO_TUNER_STEREO_ON */
112 tuned; /* signal strength (0 or 0xffff) */ 111 tuned; /* signal strength (0 or 0xffff) */
113 struct mutex lock;
114}; 112};
115 113
116static u32 radio_bits_get(struct radio_device *dev) 114static u32 radio_bits_get(struct radio_device *dev)
@@ -394,7 +392,6 @@ static int __devinit maestro_probe(struct pci_dev *pdev,
394 } 392 }
395 393
396 radio_unit->io = pci_resource_start(pdev, 0) + GPIO_DATA; 394 radio_unit->io = pci_resource_start(pdev, 0) + GPIO_DATA;
397 mutex_init(&radio_unit->lock);
398 395
399 maestro_radio_inst = video_device_alloc(); 396 maestro_radio_inst = video_device_alloc();
400 if (maestro_radio_inst == NULL) { 397 if (maestro_radio_inst == NULL) {
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c
index a4715901512d..203f4373eeb8 100644
--- a/drivers/media/radio/radio-zoltrix.c
+++ b/drivers/media/radio/radio-zoltrix.c
@@ -410,7 +410,6 @@ static struct video_device zoltrix_radio =
410 .owner = THIS_MODULE, 410 .owner = THIS_MODULE,
411 .name = "Zoltrix Radio Plus", 411 .name = "Zoltrix Radio Plus",
412 .type = VID_TYPE_TUNER, 412 .type = VID_TYPE_TUNER,
413 .hardware = 0,
414 .fops = &zoltrix_fops, 413 .fops = &zoltrix_fops,
415 .vidioc_querycap = vidioc_querycap, 414 .vidioc_querycap = vidioc_querycap,
416 .vidioc_g_tuner = vidioc_g_tuner, 415 .vidioc_g_tuner = vidioc_g_tuner,
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index bc773781993a..5cb3f54b548b 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -2,14 +2,19 @@
2# Multimedia Video device configuration 2# Multimedia Video device configuration
3# 3#
4 4
5menu "Video Capture Adapters" 5menuconfig VIDEO_CAPTURE_DRIVERS
6 bool "Video capture adapters"
6 depends on VIDEO_DEV 7 depends on VIDEO_DEV
8 default y
9 ---help---
10 Say Y here to enable selecting the video adapters for
11 webcams, analog TV, and hybrid analog/digital TV.
12 Some of those devices also supports FM radio.
7 13
8comment "Video Capture Adapters" 14if VIDEO_CAPTURE_DRIVERS
9 15
10config VIDEO_ADV_DEBUG 16config VIDEO_ADV_DEBUG
11 bool "Enable advanced debug functionality" 17 bool "Enable advanced debug functionality"
12 depends on VIDEO_DEV
13 default n 18 default n
14 ---help--- 19 ---help---
15 Say Y here to enable advanced debugging functionality on some 20 Say Y here to enable advanced debugging functionality on some
@@ -34,7 +39,7 @@ config VIDEO_HELPER_CHIPS_AUTO
34# 39#
35 40
36menu "Encoders/decoders and other helper chips" 41menu "Encoders/decoders and other helper chips"
37 depends on VIDEO_DEV && !VIDEO_HELPER_CHIPS_AUTO 42 depends on !VIDEO_HELPER_CHIPS_AUTO
38 43
39comment "Audio decoders" 44comment "Audio decoders"
40 45
@@ -61,7 +66,7 @@ config VIDEO_TDA7432
61 66
62config VIDEO_TDA9840 67config VIDEO_TDA9840
63 tristate "Philips TDA9840 audio processor" 68 tristate "Philips TDA9840 audio processor"
64 depends on VIDEO_DEV && I2C 69 depends on I2C
65 ---help--- 70 ---help---
66 Support for tda9840 audio decoder chip found on some Zoran boards. 71 Support for tda9840 audio decoder chip found on some Zoran boards.
67 72
@@ -79,7 +84,7 @@ config VIDEO_TDA9875
79 84
80config VIDEO_TEA6415C 85config VIDEO_TEA6415C
81 tristate "Philips TEA6415C audio processor" 86 tristate "Philips TEA6415C audio processor"
82 depends on VIDEO_DEV && I2C 87 depends on I2C
83 ---help--- 88 ---help---
84 Support for tea6415c audio decoder chip found on some bt8xx boards. 89 Support for tea6415c audio decoder chip found on some bt8xx boards.
85 90
@@ -88,7 +93,7 @@ config VIDEO_TEA6415C
88 93
89config VIDEO_TEA6420 94config VIDEO_TEA6420
90 tristate "Philips TEA6420 audio processor" 95 tristate "Philips TEA6420 audio processor"
91 depends on VIDEO_DEV && I2C 96 depends on I2C
92 ---help--- 97 ---help---
93 Support for tea6420 audio decoder chip found on some bt8xx boards. 98 Support for tea6420 audio decoder chip found on some bt8xx boards.
94 99
@@ -469,7 +474,7 @@ config VIDEO_SAA5246A
469 474
470config VIDEO_SAA5249 475config VIDEO_SAA5249
471 tristate "SAA5249 Teletext processor" 476 tristate "SAA5249 Teletext processor"
472 depends on VIDEO_DEV && I2C && VIDEO_V4L2 477 depends on I2C && VIDEO_V4L2
473 help 478 help
474 Support for I2C bus based teletext using the SAA5249 chip. At the 479 Support for I2C bus based teletext using the SAA5249 chip. At the
475 moment this is only useful on some European WinTV cards. 480 moment this is only useful on some European WinTV cards.
@@ -479,7 +484,7 @@ config VIDEO_SAA5249
479 484
480config TUNER_3036 485config TUNER_3036
481 tristate "SAB3036 tuner" 486 tristate "SAB3036 tuner"
482 depends on VIDEO_DEV && I2C && VIDEO_V4L1 487 depends on I2C && VIDEO_V4L1
483 help 488 help
484 Say Y here to include support for Philips SAB3036 compatible tuners. 489 Say Y here to include support for Philips SAB3036 compatible tuners.
485 If in doubt, say N. 490 If in doubt, say N.
@@ -681,8 +686,12 @@ config VIDEO_CAFE_CCIC
681# USB Multimedia device configuration 686# USB Multimedia device configuration
682# 687#
683 688
684menu "V4L USB devices" 689menuconfig V4L_USB_DRIVERS
685 depends on USB && VIDEO_DEV 690 bool "V4L USB devices"
691 depends on USB
692 default y
693
694if V4L_USB_DRIVERS
686 695
687source "drivers/media/video/pvrusb2/Kconfig" 696source "drivers/media/video/pvrusb2/Kconfig"
688 697
@@ -707,7 +716,7 @@ config VIDEO_OVCAMCHIP
707 716
708config USB_W9968CF 717config USB_W9968CF
709 tristate "USB W996[87]CF JPEG Dual Mode Camera support" 718 tristate "USB W996[87]CF JPEG Dual Mode Camera support"
710 depends on USB && VIDEO_V4L1 && I2C 719 depends on VIDEO_V4L1 && I2C
711 select VIDEO_OVCAMCHIP 720 select VIDEO_OVCAMCHIP
712 ---help--- 721 ---help---
713 Say Y here if you want support for cameras based on OV681 or 722 Say Y here if you want support for cameras based on OV681 or
@@ -725,7 +734,7 @@ config USB_W9968CF
725 734
726config USB_OV511 735config USB_OV511
727 tristate "USB OV511 Camera support" 736 tristate "USB OV511 Camera support"
728 depends on USB && VIDEO_V4L1 737 depends on VIDEO_V4L1
729 ---help--- 738 ---help---
730 Say Y here if you want to connect this type of camera to your 739 Say Y here if you want to connect this type of camera to your
731 computer's USB port. See <file:Documentation/video4linux/ov511.txt> 740 computer's USB port. See <file:Documentation/video4linux/ov511.txt>
@@ -736,7 +745,7 @@ config USB_OV511
736 745
737config USB_SE401 746config USB_SE401
738 tristate "USB SE401 Camera support" 747 tristate "USB SE401 Camera support"
739 depends on USB && VIDEO_V4L1 748 depends on VIDEO_V4L1
740 ---help--- 749 ---help---
741 Say Y here if you want to connect this type of camera to your 750 Say Y here if you want to connect this type of camera to your
742 computer's USB port. See <file:Documentation/video4linux/se401.txt> 751 computer's USB port. See <file:Documentation/video4linux/se401.txt>
@@ -749,7 +758,7 @@ source "drivers/media/video/sn9c102/Kconfig"
749 758
750config USB_STV680 759config USB_STV680
751 tristate "USB STV680 (Pencam) Camera support" 760 tristate "USB STV680 (Pencam) Camera support"
752 depends on USB && VIDEO_V4L1 761 depends on VIDEO_V4L1
753 ---help--- 762 ---help---
754 Say Y here if you want to connect this type of camera to your 763 Say Y here if you want to connect this type of camera to your
755 computer's USB port. This includes the Pencam line of cameras. 764 computer's USB port. This includes the Pencam line of cameras.
@@ -765,7 +774,7 @@ source "drivers/media/video/pwc/Kconfig"
765 774
766config USB_ZR364XX 775config USB_ZR364XX
767 tristate "USB ZR364XX Camera support" 776 tristate "USB ZR364XX Camera support"
768 depends on USB && VIDEO_V4L2 777 depends on VIDEO_V4L2
769 ---help--- 778 ---help---
770 Say Y here if you want to connect this type of camera to your 779 Say Y here if you want to connect this type of camera to your
771 computer's USB port. 780 computer's USB port.
@@ -775,6 +784,6 @@ config USB_ZR364XX
775 To compile this driver as a module, choose M here: the 784 To compile this driver as a module, choose M here: the
776 module will be called zr364xx. 785 module will be called zr364xx.
777 786
778endmenu # V4L USB devices 787endif # V4L_USB_DRIVERS
779 788
780endmenu 789endif # VIDEO_CAPTURE_DRIVERS
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index 1757a588970f..67bda9f9a44b 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -555,7 +555,7 @@ static int set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
555{ 555{
556 struct v4l2_pix_format *pix; 556 struct v4l2_pix_format *pix;
557 int HSC, VSC, Vsrc, Hsrc, filter, Vlines; 557 int HSC, VSC, Vsrc, Hsrc, filter, Vlines;
558 int is_pal = !(cx25840_get_v4lstd(client) & V4L2_STD_NTSC); 558 int is_50Hz = !(cx25840_get_v4lstd(client) & V4L2_STD_525_60);
559 559
560 switch (fmt->type) { 560 switch (fmt->type) {
561 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 561 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
@@ -567,7 +567,7 @@ static int set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
567 Hsrc = (cx25840_read(client, 0x472) & 0x3f) << 4; 567 Hsrc = (cx25840_read(client, 0x472) & 0x3f) << 4;
568 Hsrc |= (cx25840_read(client, 0x471) & 0xf0) >> 4; 568 Hsrc |= (cx25840_read(client, 0x471) & 0xf0) >> 4;
569 569
570 Vlines = pix->height + (is_pal ? 4 : 7); 570 Vlines = pix->height + (is_50Hz ? 4 : 7);
571 571
572 if ((pix->width * 16 < Hsrc) || (Hsrc < pix->width) || 572 if ((pix->width * 16 < Hsrc) || (Hsrc < pix->width) ||
573 (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) { 573 (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) {
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index 2ebde2fdbcbe..543b05ebc0e7 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -28,6 +28,7 @@
28#include <linux/device.h> 28#include <linux/device.h>
29#include <linux/dma-mapping.h> 29#include <linux/dma-mapping.h>
30#include <linux/interrupt.h> 30#include <linux/interrupt.h>
31#include <linux/dma-mapping.h>
31#include <asm/delay.h> 32#include <asm/delay.h>
32 33
33#include "cx88.h" 34#include "cx88.h"
@@ -612,7 +613,7 @@ struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board
612} 613}
613 614
614/* Driver asked for hardware access. */ 615/* Driver asked for hardware access. */
615int cx8802_request_acquire(struct cx8802_driver *drv) 616static int cx8802_request_acquire(struct cx8802_driver *drv)
616{ 617{
617 struct cx88_core *core = drv->core; 618 struct cx88_core *core = drv->core;
618 619
@@ -632,7 +633,7 @@ int cx8802_request_acquire(struct cx8802_driver *drv)
632} 633}
633 634
634/* Driver asked to release hardware. */ 635/* Driver asked to release hardware. */
635int cx8802_request_release(struct cx8802_driver *drv) 636static int cx8802_request_release(struct cx8802_driver *drv)
636{ 637{
637 struct cx88_core *core = drv->core; 638 struct cx88_core *core = drv->core;
638 639
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index b94ef8ab28c1..98fa35421bdd 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -36,6 +36,7 @@
36#include <linux/dma-mapping.h> 36#include <linux/dma-mapping.h>
37#include <linux/delay.h> 37#include <linux/delay.h>
38#include <linux/kthread.h> 38#include <linux/kthread.h>
39#include <linux/dma-mapping.h>
39#include <asm/div64.h> 40#include <asm/div64.h>
40 41
41#include "cx88.h" 42#include "cx88.h"
diff --git a/drivers/media/video/cx88/cx88-vp3054-i2c.c b/drivers/media/video/cx88/cx88-vp3054-i2c.c
index 6068c9bf82cd..82bc3a28aa22 100644
--- a/drivers/media/video/cx88/cx88-vp3054-i2c.c
+++ b/drivers/media/video/cx88/cx88-vp3054-i2c.c
@@ -111,10 +111,6 @@ static struct i2c_adapter vp3054_i2c_adap_template = {
111 .id = I2C_HW_B_CX2388x, 111 .id = I2C_HW_B_CX2388x,
112}; 112};
113 113
114static struct i2c_client vp3054_i2c_client_template = {
115 .name = "VP-3054",
116};
117
118int vp3054_i2c_probe(struct cx8802_dev *dev) 114int vp3054_i2c_probe(struct cx8802_dev *dev)
119{ 115{
120 struct cx88_core *core = dev->core; 116 struct cx88_core *core = dev->core;
@@ -133,8 +129,6 @@ int vp3054_i2c_probe(struct cx8802_dev *dev)
133 sizeof(vp3054_i2c->adap)); 129 sizeof(vp3054_i2c->adap));
134 memcpy(&vp3054_i2c->algo, &vp3054_i2c_algo_template, 130 memcpy(&vp3054_i2c->algo, &vp3054_i2c_algo_template,
135 sizeof(vp3054_i2c->algo)); 131 sizeof(vp3054_i2c->algo));
136 memcpy(&vp3054_i2c->client, &vp3054_i2c_client_template,
137 sizeof(vp3054_i2c->client));
138 132
139 vp3054_i2c->adap.class |= I2C_CLASS_TV_DIGITAL; 133 vp3054_i2c->adap.class |= I2C_CLASS_TV_DIGITAL;
140 134
@@ -144,7 +138,6 @@ int vp3054_i2c_probe(struct cx8802_dev *dev)
144 vp3054_i2c->algo.data = dev; 138 vp3054_i2c->algo.data = dev;
145 i2c_set_adapdata(&vp3054_i2c->adap, dev); 139 i2c_set_adapdata(&vp3054_i2c->adap, dev);
146 vp3054_i2c->adap.algo_data = &vp3054_i2c->algo; 140 vp3054_i2c->adap.algo_data = &vp3054_i2c->algo;
147 vp3054_i2c->client.adapter = &vp3054_i2c->adap;
148 141
149 vp3054_bit_setscl(dev,1); 142 vp3054_bit_setscl(dev,1);
150 vp3054_bit_setsda(dev,1); 143 vp3054_bit_setsda(dev,1);
diff --git a/drivers/media/video/cx88/cx88-vp3054-i2c.h b/drivers/media/video/cx88/cx88-vp3054-i2c.h
index b7a0a04d2423..637a7d232238 100644
--- a/drivers/media/video/cx88/cx88-vp3054-i2c.h
+++ b/drivers/media/video/cx88/cx88-vp3054-i2c.h
@@ -26,7 +26,6 @@
26struct vp3054_i2c_state { 26struct vp3054_i2c_state {
27 struct i2c_adapter adap; 27 struct i2c_adapter adap;
28 struct i2c_algo_bit_data algo; 28 struct i2c_algo_bit_data algo;
29 struct i2c_client client;
30 u32 state; 29 u32 state;
31}; 30};
32 31
diff --git a/drivers/media/video/em28xx/Kconfig b/drivers/media/video/em28xx/Kconfig
index 9285a58e47aa..3823b62da4a4 100644
--- a/drivers/media/video/em28xx/Kconfig
+++ b/drivers/media/video/em28xx/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_EM28XX 1config VIDEO_EM28XX
2 tristate "Empia EM2800/2820/2840 USB video capture support" 2 tristate "Empia EM2800/2820/2840 USB video capture support"
3 depends on VIDEO_V4L1 && USB && I2C 3 depends on VIDEO_V4L1 && I2C
4 select VIDEO_BUF 4 select VIDEO_BUF
5 select VIDEO_TUNER 5 select VIDEO_TUNER
6 select VIDEO_TVEEPROM 6 select VIDEO_TVEEPROM
diff --git a/drivers/media/video/et61x251/Kconfig b/drivers/media/video/et61x251/Kconfig
index c6bff705688d..664676f44068 100644
--- a/drivers/media/video/et61x251/Kconfig
+++ b/drivers/media/video/et61x251/Kconfig
@@ -1,6 +1,6 @@
1config USB_ET61X251 1config USB_ET61X251
2 tristate "USB ET61X[12]51 PC Camera Controller support" 2 tristate "USB ET61X[12]51 PC Camera Controller support"
3 depends on USB && VIDEO_V4L1 3 depends on VIDEO_V4L1
4 ---help--- 4 ---help---
5 Say Y here if you want support for cameras based on Etoms ET61X151 5 Say Y here if you want support for cameras based on Etoms ET61X151
6 or ET61X251 PC Camera Controllers. 6 or ET61X251 PC Camera Controllers.
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index 45b9328a538f..e29f949adf57 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -74,7 +74,7 @@ int ivtv_first_minor = 0;
74struct ivtv *ivtv_cards[IVTV_MAX_CARDS]; 74struct ivtv *ivtv_cards[IVTV_MAX_CARDS];
75 75
76/* Protects ivtv_cards_active */ 76/* Protects ivtv_cards_active */
77spinlock_t ivtv_cards_lock = SPIN_LOCK_UNLOCKED; 77DEFINE_SPINLOCK(ivtv_cards_lock);
78 78
79/* add your revision and whatnot here */ 79/* add your revision and whatnot here */
80static struct pci_device_id ivtv_pci_tbl[] __devinitdata = { 80static struct pci_device_id ivtv_pci_tbl[] __devinitdata = {
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c
index 1637097ddec7..8976487a65f3 100644
--- a/drivers/media/video/ivtv/ivtv-fileops.c
+++ b/drivers/media/video/ivtv/ivtv-fileops.c
@@ -804,7 +804,7 @@ int ivtv_v4l2_open(struct inode *inode, struct file *filp)
804 struct ivtv_open_id *item; 804 struct ivtv_open_id *item;
805 struct ivtv *itv = NULL; 805 struct ivtv *itv = NULL;
806 struct ivtv_stream *s = NULL; 806 struct ivtv_stream *s = NULL;
807 int minor = MINOR(inode->i_rdev); 807 int minor = iminor(inode);
808 808
809 /* Find which card this open was on */ 809 /* Find which card this open was on */
810 spin_lock(&ivtv_cards_lock); 810 spin_lock(&ivtv_cards_lock);
diff --git a/drivers/media/video/pvrusb2/Kconfig b/drivers/media/video/pvrusb2/Kconfig
index 5645c9318890..d0c2cd785430 100644
--- a/drivers/media/video/pvrusb2/Kconfig
+++ b/drivers/media/video/pvrusb2/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_PVRUSB2 1config VIDEO_PVRUSB2
2 tristate "Hauppauge WinTV-PVR USB2 support" 2 tristate "Hauppauge WinTV-PVR USB2 support"
3 depends on VIDEO_V4L2 && USB && I2C && EXPERIMENTAL 3 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
4 select FW_LOADER 4 select FW_LOADER
5 select VIDEO_TUNER 5 select VIDEO_TUNER
6 select VIDEO_TVEEPROM 6 select VIDEO_TVEEPROM
diff --git a/drivers/media/video/pvrusb2/pvrusb2-encoder.c b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
index 5669c8ca9ca3..20b614436d2c 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-encoder.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
@@ -391,22 +391,29 @@ static int pvr2_encoder_prep_config(struct pvr2_hdw *hdw)
391int pvr2_encoder_configure(struct pvr2_hdw *hdw) 391int pvr2_encoder_configure(struct pvr2_hdw *hdw)
392{ 392{
393 int ret; 393 int ret;
394 int val;
394 pvr2_trace(PVR2_TRACE_ENCODER,"pvr2_encoder_configure" 395 pvr2_trace(PVR2_TRACE_ENCODER,"pvr2_encoder_configure"
395 " (cx2341x module)"); 396 " (cx2341x module)");
396 hdw->enc_ctl_state.port = CX2341X_PORT_STREAMING; 397 hdw->enc_ctl_state.port = CX2341X_PORT_STREAMING;
397 hdw->enc_ctl_state.width = hdw->res_hor_val; 398 hdw->enc_ctl_state.width = hdw->res_hor_val;
398 hdw->enc_ctl_state.height = hdw->res_ver_val; 399 hdw->enc_ctl_state.height = hdw->res_ver_val;
399 hdw->enc_ctl_state.is_50hz = ((hdw->std_mask_cur & 400 hdw->enc_ctl_state.is_50hz = ((hdw->std_mask_cur & V4L2_STD_525_60) ?
400 (V4L2_STD_NTSC|V4L2_STD_PAL_M)) ?
401 0 : 1); 401 0 : 1);
402 402
403 ret = 0; 403 ret = 0;
404 404
405 ret |= pvr2_encoder_prep_config(hdw); 405 ret |= pvr2_encoder_prep_config(hdw);
406 406
407 /* saa7115: 0xf0 */
408 val = 0xf0;
409 if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) {
410 /* ivtv cx25840: 0x140 */
411 val = 0x140;
412 }
413
407 if (!ret) ret = pvr2_encoder_vcmd( 414 if (!ret) ret = pvr2_encoder_vcmd(
408 hdw,CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, 415 hdw,CX2341X_ENC_SET_NUM_VSYNC_LINES, 2,
409 0xf0, 0xf0); 416 val, val);
410 417
411 /* setup firmware to notify us about some events (don't know why...) */ 418 /* setup firmware to notify us about some events (don't know why...) */
412 if (!ret) ret = pvr2_encoder_vcmd( 419 if (!ret) ret = pvr2_encoder_vcmd(
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index acf651e01f94..1311891e7ee3 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -83,7 +83,7 @@ static struct pvr2_string_table pvr2_client_lists[] = {
83}; 83};
84 84
85static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL}; 85static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL};
86static DECLARE_MUTEX(pvr2_unit_sem); 86static DEFINE_MUTEX(pvr2_unit_mtx);
87 87
88static int ctlchg = 0; 88static int ctlchg = 0;
89static int initusbreset = 1; 89static int initusbreset = 1;
@@ -2076,14 +2076,14 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
2076 hdw->ctl_read_urb = usb_alloc_urb(0,GFP_KERNEL); 2076 hdw->ctl_read_urb = usb_alloc_urb(0,GFP_KERNEL);
2077 if (!hdw->ctl_read_urb) goto fail; 2077 if (!hdw->ctl_read_urb) goto fail;
2078 2078
2079 down(&pvr2_unit_sem); do { 2079 mutex_lock(&pvr2_unit_mtx); do {
2080 for (idx = 0; idx < PVR_NUM; idx++) { 2080 for (idx = 0; idx < PVR_NUM; idx++) {
2081 if (unit_pointers[idx]) continue; 2081 if (unit_pointers[idx]) continue;
2082 hdw->unit_number = idx; 2082 hdw->unit_number = idx;
2083 unit_pointers[idx] = hdw; 2083 unit_pointers[idx] = hdw;
2084 break; 2084 break;
2085 } 2085 }
2086 } while (0); up(&pvr2_unit_sem); 2086 } while (0); mutex_unlock(&pvr2_unit_mtx);
2087 2087
2088 cnt1 = 0; 2088 cnt1 = 0;
2089 cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"pvrusb2"); 2089 cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"pvrusb2");
@@ -2186,13 +2186,13 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw)
2186 } 2186 }
2187 pvr2_i2c_core_done(hdw); 2187 pvr2_i2c_core_done(hdw);
2188 pvr2_hdw_remove_usb_stuff(hdw); 2188 pvr2_hdw_remove_usb_stuff(hdw);
2189 down(&pvr2_unit_sem); do { 2189 mutex_lock(&pvr2_unit_mtx); do {
2190 if ((hdw->unit_number >= 0) && 2190 if ((hdw->unit_number >= 0) &&
2191 (hdw->unit_number < PVR_NUM) && 2191 (hdw->unit_number < PVR_NUM) &&
2192 (unit_pointers[hdw->unit_number] == hdw)) { 2192 (unit_pointers[hdw->unit_number] == hdw)) {
2193 unit_pointers[hdw->unit_number] = NULL; 2193 unit_pointers[hdw->unit_number] = NULL;
2194 } 2194 }
2195 } while (0); up(&pvr2_unit_sem); 2195 } while (0); mutex_unlock(&pvr2_unit_mtx);
2196 kfree(hdw->controls); 2196 kfree(hdw->controls);
2197 kfree(hdw->mpeg_ctrl_info); 2197 kfree(hdw->mpeg_ctrl_info);
2198 kfree(hdw->std_defs); 2198 kfree(hdw->std_defs);
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
index 58fc3c730fe1..6786d3c0c98b 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
@@ -23,6 +23,7 @@
23#include "pvrusb2-hdw-internal.h" 23#include "pvrusb2-hdw-internal.h"
24#include "pvrusb2-debug.h" 24#include "pvrusb2-debug.h"
25#include "pvrusb2-fx2-cmd.h" 25#include "pvrusb2-fx2-cmd.h"
26#include "pvrusb2.h"
26 27
27#define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__) 28#define trace_i2c(...) pvr2_trace(PVR2_TRACE_I2C,__VA_ARGS__)
28 29
@@ -38,6 +39,10 @@ static unsigned int i2c_scan = 0;
38module_param(i2c_scan, int, S_IRUGO|S_IWUSR); 39module_param(i2c_scan, int, S_IRUGO|S_IWUSR);
39MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); 40MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
40 41
42static int ir_mode[PVR_NUM] = { [0 ... PVR_NUM-1] = 1 };
43module_param_array(ir_mode, int, NULL, 0444);
44MODULE_PARM_DESC(ir_mode,"specify: 0=disable IR reception, 1=normal IR");
45
41static unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *cp, 46static unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *cp,
42 unsigned int detail, 47 unsigned int detail,
43 char *buf,unsigned int maxlen); 48 char *buf,unsigned int maxlen);
@@ -273,6 +278,15 @@ static int i2c_hack_wm8775(struct pvr2_hdw *hdw,
273 return pvr2_i2c_basic_op(hdw,i2c_addr,wdata,wlen,rdata,rlen); 278 return pvr2_i2c_basic_op(hdw,i2c_addr,wdata,wlen,rdata,rlen);
274} 279}
275 280
281/* This is an entry point designed to always fail any attempt to perform a
282 transfer. We use this to cause certain I2C addresses to not be
283 probed. */
284static int i2c_black_hole(struct pvr2_hdw *hdw,
285 u8 i2c_addr,u8 *wdata,u16 wlen,u8 *rdata,u16 rlen)
286{
287 return -EIO;
288}
289
276/* This is a special entry point that is entered if an I2C operation is 290/* This is a special entry point that is entered if an I2C operation is
277 attempted to a cx25840 chip on model 24xxx hardware. This chip can 291 attempted to a cx25840 chip on model 24xxx hardware. This chip can
278 sometimes wedge itself. Worse still, when this happens msp3400 can 292 sometimes wedge itself. Worse still, when this happens msp3400 can
@@ -994,10 +1008,17 @@ void pvr2_i2c_core_init(struct pvr2_hdw *hdw)
994 } 1008 }
995 1009
996 /* However, deal with various special cases for 24xxx hardware. */ 1010 /* However, deal with various special cases for 24xxx hardware. */
1011 if (ir_mode[hdw->unit_number] == 0) {
1012 printk(KERN_INFO "%s: IR disabled\n",hdw->name);
1013 hdw->i2c_func[0x18] = i2c_black_hole;
1014 } else if (ir_mode[hdw->unit_number] == 1) {
1015 if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) {
1016 hdw->i2c_func[0x18] = i2c_24xxx_ir;
1017 }
1018 }
997 if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) { 1019 if (hdw->hdw_type == PVR2_HDW_TYPE_24XXX) {
998 hdw->i2c_func[0x1b] = i2c_hack_wm8775; 1020 hdw->i2c_func[0x1b] = i2c_hack_wm8775;
999 hdw->i2c_func[0x44] = i2c_hack_cx25840; 1021 hdw->i2c_func[0x44] = i2c_hack_cx25840;
1000 hdw->i2c_func[0x18] = i2c_24xxx_ir;
1001 } 1022 }
1002 1023
1003 // Configure the adapter and set up everything else related to it. 1024 // Configure the adapter and set up everything else related to it.
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
index a741c556a39a..7ab79baa1c8c 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
@@ -518,40 +518,32 @@ static void pvr2_sysfs_add_control(struct pvr2_sysfs *sfp,int ctl_id)
518 } 518 }
519 sfp->item_last = cip; 519 sfp->item_last = cip;
520 520
521 cip->attr_name.attr.owner = THIS_MODULE;
522 cip->attr_name.attr.name = "name"; 521 cip->attr_name.attr.name = "name";
523 cip->attr_name.attr.mode = S_IRUGO; 522 cip->attr_name.attr.mode = S_IRUGO;
524 cip->attr_name.show = fp->show_name; 523 cip->attr_name.show = fp->show_name;
525 524
526 cip->attr_type.attr.owner = THIS_MODULE;
527 cip->attr_type.attr.name = "type"; 525 cip->attr_type.attr.name = "type";
528 cip->attr_type.attr.mode = S_IRUGO; 526 cip->attr_type.attr.mode = S_IRUGO;
529 cip->attr_type.show = fp->show_type; 527 cip->attr_type.show = fp->show_type;
530 528
531 cip->attr_min.attr.owner = THIS_MODULE;
532 cip->attr_min.attr.name = "min_val"; 529 cip->attr_min.attr.name = "min_val";
533 cip->attr_min.attr.mode = S_IRUGO; 530 cip->attr_min.attr.mode = S_IRUGO;
534 cip->attr_min.show = fp->show_min; 531 cip->attr_min.show = fp->show_min;
535 532
536 cip->attr_max.attr.owner = THIS_MODULE;
537 cip->attr_max.attr.name = "max_val"; 533 cip->attr_max.attr.name = "max_val";
538 cip->attr_max.attr.mode = S_IRUGO; 534 cip->attr_max.attr.mode = S_IRUGO;
539 cip->attr_max.show = fp->show_max; 535 cip->attr_max.show = fp->show_max;
540 536
541 cip->attr_val.attr.owner = THIS_MODULE;
542 cip->attr_val.attr.name = "cur_val"; 537 cip->attr_val.attr.name = "cur_val";
543 cip->attr_val.attr.mode = S_IRUGO; 538 cip->attr_val.attr.mode = S_IRUGO;
544 539
545 cip->attr_custom.attr.owner = THIS_MODULE;
546 cip->attr_custom.attr.name = "custom_val"; 540 cip->attr_custom.attr.name = "custom_val";
547 cip->attr_custom.attr.mode = S_IRUGO; 541 cip->attr_custom.attr.mode = S_IRUGO;
548 542
549 cip->attr_enum.attr.owner = THIS_MODULE;
550 cip->attr_enum.attr.name = "enum_val"; 543 cip->attr_enum.attr.name = "enum_val";
551 cip->attr_enum.attr.mode = S_IRUGO; 544 cip->attr_enum.attr.mode = S_IRUGO;
552 cip->attr_enum.show = fp->show_enum; 545 cip->attr_enum.show = fp->show_enum;
553 546
554 cip->attr_bits.attr.owner = THIS_MODULE;
555 cip->attr_bits.attr.name = "bit_val"; 547 cip->attr_bits.attr.name = "bit_val";
556 cip->attr_bits.attr.mode = S_IRUGO; 548 cip->attr_bits.attr.mode = S_IRUGO;
557 cip->attr_bits.show = fp->show_bits; 549 cip->attr_bits.show = fp->show_bits;
@@ -616,12 +608,10 @@ static void pvr2_sysfs_add_debugifc(struct pvr2_sysfs *sfp)
616 608
617 dip = kzalloc(sizeof(*dip),GFP_KERNEL); 609 dip = kzalloc(sizeof(*dip),GFP_KERNEL);
618 if (!dip) return; 610 if (!dip) return;
619 dip->attr_debugcmd.attr.owner = THIS_MODULE;
620 dip->attr_debugcmd.attr.name = "debugcmd"; 611 dip->attr_debugcmd.attr.name = "debugcmd";
621 dip->attr_debugcmd.attr.mode = S_IRUGO|S_IWUSR|S_IWGRP; 612 dip->attr_debugcmd.attr.mode = S_IRUGO|S_IWUSR|S_IWGRP;
622 dip->attr_debugcmd.show = debugcmd_show; 613 dip->attr_debugcmd.show = debugcmd_show;
623 dip->attr_debugcmd.store = debugcmd_store; 614 dip->attr_debugcmd.store = debugcmd_store;
624 dip->attr_debuginfo.attr.owner = THIS_MODULE;
625 dip->attr_debuginfo.attr.name = "debuginfo"; 615 dip->attr_debuginfo.attr.name = "debuginfo";
626 dip->attr_debuginfo.attr.mode = S_IRUGO; 616 dip->attr_debuginfo.attr.mode = S_IRUGO;
627 dip->attr_debuginfo.show = debuginfo_show; 617 dip->attr_debuginfo.show = debuginfo_show;
@@ -811,7 +801,6 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
811 return; 801 return;
812 } 802 }
813 803
814 sfp->attr_v4l_minor_number.attr.owner = THIS_MODULE;
815 sfp->attr_v4l_minor_number.attr.name = "v4l_minor_number"; 804 sfp->attr_v4l_minor_number.attr.name = "v4l_minor_number";
816 sfp->attr_v4l_minor_number.attr.mode = S_IRUGO; 805 sfp->attr_v4l_minor_number.attr.mode = S_IRUGO;
817 sfp->attr_v4l_minor_number.show = v4l_minor_number_show; 806 sfp->attr_v4l_minor_number.show = v4l_minor_number_show;
@@ -825,7 +814,6 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
825 sfp->v4l_minor_number_created_ok = !0; 814 sfp->v4l_minor_number_created_ok = !0;
826 } 815 }
827 816
828 sfp->attr_v4l_radio_minor_number.attr.owner = THIS_MODULE;
829 sfp->attr_v4l_radio_minor_number.attr.name = "v4l_radio_minor_number"; 817 sfp->attr_v4l_radio_minor_number.attr.name = "v4l_radio_minor_number";
830 sfp->attr_v4l_radio_minor_number.attr.mode = S_IRUGO; 818 sfp->attr_v4l_radio_minor_number.attr.mode = S_IRUGO;
831 sfp->attr_v4l_radio_minor_number.show = v4l_radio_minor_number_show; 819 sfp->attr_v4l_radio_minor_number.show = v4l_radio_minor_number_show;
@@ -839,7 +827,6 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
839 sfp->v4l_radio_minor_number_created_ok = !0; 827 sfp->v4l_radio_minor_number_created_ok = !0;
840 } 828 }
841 829
842 sfp->attr_unit_number.attr.owner = THIS_MODULE;
843 sfp->attr_unit_number.attr.name = "unit_number"; 830 sfp->attr_unit_number.attr.name = "unit_number";
844 sfp->attr_unit_number.attr.mode = S_IRUGO; 831 sfp->attr_unit_number.attr.mode = S_IRUGO;
845 sfp->attr_unit_number.show = unit_number_show; 832 sfp->attr_unit_number.show = unit_number_show;
@@ -852,7 +839,6 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
852 sfp->unit_number_created_ok = !0; 839 sfp->unit_number_created_ok = !0;
853 } 840 }
854 841
855 sfp->attr_bus_info.attr.owner = THIS_MODULE;
856 sfp->attr_bus_info.attr.name = "bus_info_str"; 842 sfp->attr_bus_info.attr.name = "bus_info_str";
857 sfp->attr_bus_info.attr.mode = S_IRUGO; 843 sfp->attr_bus_info.attr.mode = S_IRUGO;
858 sfp->attr_bus_info.show = bus_info_show; 844 sfp->attr_bus_info.show = bus_info_show;
diff --git a/drivers/media/video/pwc/Kconfig b/drivers/media/video/pwc/Kconfig
index 8fdf7101d3bf..7298cf2e1650 100644
--- a/drivers/media/video/pwc/Kconfig
+++ b/drivers/media/video/pwc/Kconfig
@@ -1,6 +1,6 @@
1config USB_PWC 1config USB_PWC
2 tristate "USB Philips Cameras" 2 tristate "USB Philips Cameras"
3 depends on USB && VIDEO_V4L1 3 depends on VIDEO_V4L1
4 ---help--- 4 ---help---
5 Say Y or M here if you want to use one of these Philips & OEM 5 Say Y or M here if you want to use one of these Philips & OEM
6 webcams: 6 webcams:
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index 4ea479baee74..50f15adfa7c8 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -1170,6 +1170,42 @@ struct saa7134_board saa7134_boards[] = {
1170 .amux = LINE2, 1170 .amux = LINE2,
1171 }, 1171 },
1172 }, 1172 },
1173 [SAA7134_BOARD_ECS_TVP3XP_4CB6] = {
1174 /* Barry Scott <barry.scott@onelan.co.uk> */
1175 .name = "Elitegroup ECS TVP3XP FM1246 Tuner Card (PAL,FM)",
1176 .audio_clock = 0x187de7,
1177 .tuner_type = TUNER_PHILIPS_PAL_I,
1178 .radio_type = UNSET,
1179 .tuner_addr = ADDR_UNSET,
1180 .radio_addr = ADDR_UNSET,
1181 .inputs = {{
1182 .name = name_tv,
1183 .vmux = 1,
1184 .amux = TV,
1185 .tv = 1,
1186 },{
1187 .name = name_tv_mono,
1188 .vmux = 1,
1189 .amux = LINE2,
1190 .tv = 1,
1191 },{
1192 .name = name_comp1,
1193 .vmux = 3,
1194 .amux = LINE1,
1195 },{
1196 .name = name_svideo,
1197 .vmux = 8,
1198 .amux = LINE1,
1199 },{
1200 .name = "CVid over SVid",
1201 .vmux = 0,
1202 .amux = LINE1,
1203 }},
1204 .radio = {
1205 .name = name_radio,
1206 .amux = LINE2,
1207 },
1208 },
1173 [SAA7134_BOARD_AVACSSMARTTV] = { 1209 [SAA7134_BOARD_AVACSSMARTTV] = {
1174 /* Roman Pszonczenko <romka@kolos.math.uni.lodz.pl> */ 1210 /* Roman Pszonczenko <romka@kolos.math.uni.lodz.pl> */
1175 .name = "AVACS SmartTV", 1211 .name = "AVACS SmartTV",
@@ -2754,6 +2790,35 @@ struct saa7134_board saa7134_boards[] = {
2754 .amux = LINE1, 2790 .amux = LINE1,
2755 }, 2791 },
2756 }, 2792 },
2793 [SAA7134_BOARD_KWORLD_DVBT_210] = {
2794 .name = "KWorld DVB-T 210",
2795 .audio_clock = 0x00187de7,
2796 .tuner_type = TUNER_PHILIPS_TDA8290,
2797 .radio_type = UNSET,
2798 .tuner_addr = ADDR_UNSET,
2799 .radio_addr = ADDR_UNSET,
2800 .mpeg = SAA7134_MPEG_DVB,
2801 .gpiomask = 1 << 21,
2802 .inputs = {{
2803 .name = name_tv,
2804 .vmux = 1,
2805 .amux = TV,
2806 .tv = 1,
2807 },{
2808 .name = name_comp1,
2809 .vmux = 3,
2810 .amux = LINE1,
2811 },{
2812 .name = name_svideo,
2813 .vmux = 8,
2814 .amux = LINE1,
2815 }},
2816 .radio = {
2817 .name = name_radio,
2818 .amux = TV,
2819 .gpio = 0x0200000,
2820 },
2821 },
2757 [SAA7134_BOARD_KWORLD_ATSC110] = { 2822 [SAA7134_BOARD_KWORLD_ATSC110] = {
2758 .name = "Kworld ATSC110", 2823 .name = "Kworld ATSC110",
2759 .audio_clock = 0x00187de7, 2824 .audio_clock = 0x00187de7,
@@ -3407,6 +3472,36 @@ struct saa7134_board saa7134_boards[] = {
3407 .gpio = 0x0200000, 3472 .gpio = 0x0200000,
3408 }, 3473 },
3409 }, 3474 },
3475 [SAA7134_BOARD_SABRENT_TV_PCB05] = {
3476 .name = "Sabrent PCMCIA TV-PCB05",
3477 .audio_clock = 0x00187de7,
3478 .tuner_type = TUNER_PHILIPS_TDA8290,
3479 .radio_type = UNSET,
3480 .tuner_addr = ADDR_UNSET,
3481 .radio_addr = ADDR_UNSET,
3482 .inputs = {{
3483 .name = name_tv,
3484 .vmux = 1,
3485 .amux = TV,
3486 .tv = 1,
3487 },{
3488 .name = name_comp1,
3489 .vmux = 3,
3490 .amux = LINE1,
3491 },{
3492 .name = name_comp2,
3493 .vmux = 0,
3494 .amux = LINE1,
3495 },{
3496 .name = name_svideo,
3497 .vmux = 8,
3498 .amux = LINE1,
3499 }},
3500 .mute = {
3501 .name = name_mute,
3502 .amux = TV,
3503 },
3504 },
3410}; 3505};
3411 3506
3412const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); 3507const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
@@ -3515,7 +3610,13 @@ struct pci_device_id saa7134_pci_tbl[] = {
3515 .vendor = PCI_VENDOR_ID_PHILIPS, 3610 .vendor = PCI_VENDOR_ID_PHILIPS,
3516 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 3611 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
3517 .subvendor = 0x5168, /* Animation Technologies (LifeView) */ 3612 .subvendor = 0x5168, /* Animation Technologies (LifeView) */
3518 .subdevice = 0x0214, /* Standard PCI, LR214WF */ 3613 .subdevice = 0x0214, /* Standard PCI, LR214 Rev E and earlier (SAA7135) */
3614 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM,
3615 },{
3616 .vendor = PCI_VENDOR_ID_PHILIPS,
3617 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
3618 .subvendor = 0x5168, /* Animation Technologies (LifeView) */
3619 .subdevice = 0x5214, /* Standard PCI, LR214 Rev F onwards (SAA7131) */
3519 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM, 3620 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM,
3520 },{ 3621 },{
3521 .vendor = PCI_VENDOR_ID_PHILIPS, 3622 .vendor = PCI_VENDOR_ID_PHILIPS,
@@ -3689,6 +3790,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
3689 .driver_data = SAA7134_BOARD_ECS_TVP3XP_4CB5, 3790 .driver_data = SAA7134_BOARD_ECS_TVP3XP_4CB5,
3690 },{ 3791 },{
3691 .vendor = PCI_VENDOR_ID_PHILIPS, 3792 .vendor = PCI_VENDOR_ID_PHILIPS,
3793 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
3794 .subvendor = 0x1019,
3795 .subdevice = 0x4cb6,
3796 .driver_data = SAA7134_BOARD_ECS_TVP3XP_4CB6,
3797 },{
3798 .vendor = PCI_VENDOR_ID_PHILIPS,
3692 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 3799 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
3693 .subvendor = 0x12ab, 3800 .subvendor = 0x12ab,
3694 .subdevice = 0x0800, 3801 .subdevice = 0x0800,
@@ -3915,6 +4022,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
3915 .driver_data = SAA7134_BOARD_TEVION_DVBT_220RF, 4022 .driver_data = SAA7134_BOARD_TEVION_DVBT_220RF,
3916 },{ 4023 },{
3917 .vendor = PCI_VENDOR_ID_PHILIPS, 4024 .vendor = PCI_VENDOR_ID_PHILIPS,
4025 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
4026 .subvendor = 0x17de,
4027 .subdevice = 0x7250,
4028 .driver_data = SAA7134_BOARD_KWORLD_DVBT_210,
4029 },{
4030 .vendor = PCI_VENDOR_ID_PHILIPS,
3918 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, /* SAA7135HL */ 4031 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, /* SAA7135HL */
3919 .subvendor = 0x17de, 4032 .subvendor = 0x17de,
3920 .subdevice = 0x7350, 4033 .subdevice = 0x7350,
@@ -4100,6 +4213,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
4100 .subdevice = 0x4857, 4213 .subdevice = 0x4857,
4101 .driver_data = SAA7134_BOARD_ASUSTeK_P7131_DUAL, 4214 .driver_data = SAA7134_BOARD_ASUSTeK_P7131_DUAL,
4102 },{ 4215 },{
4216 .vendor = PCI_VENDOR_ID_PHILIPS,
4217 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
4218 .subvendor = 0x0919, /* SinoVideo PCI 2309 Proteus (7134) */
4219 .subdevice = 0x2003, /* OEM cardbus */
4220 .driver_data = SAA7134_BOARD_SABRENT_TV_PCB05,
4221 },{
4103 /* --- boards without eeprom + subsystem ID --- */ 4222 /* --- boards without eeprom + subsystem ID --- */
4104 .vendor = PCI_VENDOR_ID_PHILIPS, 4223 .vendor = PCI_VENDOR_ID_PHILIPS,
4105 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 4224 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
@@ -4178,6 +4297,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
4178 case SAA7134_BOARD_CINERGY600_MK3: 4297 case SAA7134_BOARD_CINERGY600_MK3:
4179 case SAA7134_BOARD_ECS_TVP3XP: 4298 case SAA7134_BOARD_ECS_TVP3XP:
4180 case SAA7134_BOARD_ECS_TVP3XP_4CB5: 4299 case SAA7134_BOARD_ECS_TVP3XP_4CB5:
4300 case SAA7134_BOARD_ECS_TVP3XP_4CB6:
4181 case SAA7134_BOARD_MD2819: 4301 case SAA7134_BOARD_MD2819:
4182 case SAA7134_BOARD_KWORLD_VSTREAM_XPERT: 4302 case SAA7134_BOARD_KWORLD_VSTREAM_XPERT:
4183 case SAA7134_BOARD_KWORLD_XPERT: 4303 case SAA7134_BOARD_KWORLD_XPERT:
@@ -4426,6 +4546,7 @@ int saa7134_board_init2(struct saa7134_dev *dev)
4426 } 4546 }
4427 break; 4547 break;
4428 case SAA7134_BOARD_PINNACLE_PCTV_310i: 4548 case SAA7134_BOARD_PINNACLE_PCTV_310i:
4549 case SAA7134_BOARD_KWORLD_DVBT_210:
4429 case SAA7134_BOARD_TEVION_DVBT_220RF: 4550 case SAA7134_BOARD_TEVION_DVBT_220RF:
4430 case SAA7134_BOARD_ASUSTeK_P7131_DUAL: 4551 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
4431 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: 4552 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 65aec881bbde..e0eec80088c7 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -887,6 +887,20 @@ static struct tda1004x_config asus_p7131_hybrid_lna_config = {
887 .antenna_switch= 2, 887 .antenna_switch= 2,
888 .request_firmware = philips_tda1004x_request_firmware 888 .request_firmware = philips_tda1004x_request_firmware
889}; 889};
890static struct tda1004x_config kworld_dvb_t_210_config = {
891 .demod_address = 0x08,
892 .invert = 1,
893 .invert_oclk = 0,
894 .xtal_freq = TDA10046_XTAL_16M,
895 .agc_config = TDA10046_AGC_TDA827X,
896 .gpio_config = TDA10046_GP11_I,
897 .if_freq = TDA10046_FREQ_045,
898 .i2c_gate = 0x4b,
899 .tuner_address = 0x61,
900 .tuner_config = 2,
901 .antenna_switch= 1,
902 .request_firmware = philips_tda1004x_request_firmware
903};
890/* ------------------------------------------------------------------ 904/* ------------------------------------------------------------------
891 * special case: this card uses saa713x GPIO22 for the mode switch 905 * special case: this card uses saa713x GPIO22 for the mode switch
892 */ 906 */
@@ -1039,6 +1053,9 @@ static int dvb_init(struct saa7134_dev *dev)
1039 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set; 1053 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1040 } 1054 }
1041 break; 1055 break;
1056 case SAA7134_BOARD_KWORLD_DVBT_210:
1057 configure_tda827x_fe(dev, &kworld_dvb_t_210_config);
1058 break;
1042 case SAA7134_BOARD_PHILIPS_TIGER: 1059 case SAA7134_BOARD_PHILIPS_TIGER:
1043 configure_tda827x_fe(dev, &philips_tiger_config); 1060 configure_tda827x_fe(dev, &philips_tiger_config);
1044 break; 1061 break;
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index 62224cc958f1..15623b27ad2e 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -235,6 +235,9 @@ struct saa7134_format {
235#define SAA7134_BOARD_AVERMEDIA_M102 110 235#define SAA7134_BOARD_AVERMEDIA_M102 110
236#define SAA7134_BOARD_ASUS_P7131_4871 111 236#define SAA7134_BOARD_ASUS_P7131_4871 111
237#define SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA 112 237#define SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA 112
238#define SAA7134_BOARD_ECS_TVP3XP_4CB6 113
239#define SAA7134_BOARD_KWORLD_DVBT_210 114
240#define SAA7134_BOARD_SABRENT_TV_PCB05 115
238 241
239#define SAA7134_MAXBOARDS 8 242#define SAA7134_MAXBOARDS 8
240#define SAA7134_INPUT_MAX 8 243#define SAA7134_INPUT_MAX 8
diff --git a/drivers/media/video/sn9c102/Kconfig b/drivers/media/video/sn9c102/Kconfig
index 19204f5686e1..f71f272776de 100644
--- a/drivers/media/video/sn9c102/Kconfig
+++ b/drivers/media/video/sn9c102/Kconfig
@@ -1,6 +1,6 @@
1config USB_SN9C102 1config USB_SN9C102
2 tristate "USB SN9C1xx PC Camera Controller support" 2 tristate "USB SN9C1xx PC Camera Controller support"
3 depends on USB && VIDEO_V4L2 3 depends on VIDEO_V4L2
4 ---help--- 4 ---help---
5 Say Y here if you want support for cameras based on SONiX SN9C101, 5 Say Y here if you want support for cameras based on SONiX SN9C101,
6 SN9C102, SN9C103, SN9C105 and SN9C120 PC Camera Controllers. 6 SN9C102, SN9C103, SN9C105 and SN9C120 PC Camera Controllers.
diff --git a/drivers/media/video/sn9c102/sn9c102.h b/drivers/media/video/sn9c102/sn9c102.h
index 680e74634527..11fcb49f5b99 100644
--- a/drivers/media/video/sn9c102/sn9c102.h
+++ b/drivers/media/video/sn9c102/sn9c102.h
@@ -141,7 +141,7 @@ sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id)
141 141
142void 142void
143sn9c102_attach_sensor(struct sn9c102_device* cam, 143sn9c102_attach_sensor(struct sn9c102_device* cam,
144 struct sn9c102_sensor* sensor) 144 const struct sn9c102_sensor* sensor)
145{ 145{
146 memcpy(&cam->sensor, sensor, sizeof(struct sn9c102_sensor)); 146 memcpy(&cam->sensor, sensor, sizeof(struct sn9c102_sensor));
147} 147}
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c
index 89f83354de3b..74a204f8ebc8 100644
--- a/drivers/media/video/sn9c102/sn9c102_core.c
+++ b/drivers/media/video/sn9c102/sn9c102_core.c
@@ -48,8 +48,8 @@
48#define SN9C102_MODULE_AUTHOR "(C) 2004-2007 Luca Risolia" 48#define SN9C102_MODULE_AUTHOR "(C) 2004-2007 Luca Risolia"
49#define SN9C102_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" 49#define SN9C102_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
50#define SN9C102_MODULE_LICENSE "GPL" 50#define SN9C102_MODULE_LICENSE "GPL"
51#define SN9C102_MODULE_VERSION "1:1.39" 51#define SN9C102_MODULE_VERSION "1:1.44"
52#define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 1, 39) 52#define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 1, 44)
53 53
54/*****************************************************************************/ 54/*****************************************************************************/
55 55
@@ -209,38 +209,41 @@ static void sn9c102_queue_unusedframes(struct sn9c102_device* cam)
209} 209}
210 210
211/*****************************************************************************/ 211/*****************************************************************************/
212
212/* 213/*
213 * Write a sequence of count value/register pairs. Returns -1 after the 214 Write a sequence of count value/register pairs. Returns -1 after the first
214 * first failed write, or 0 for no errors. 215 failed write, or 0 for no errors.
215 */ 216*/
216int sn9c102_write_regs(struct sn9c102_device* cam, const u8 valreg[][2], 217int sn9c102_write_regs(struct sn9c102_device* cam, const u8 valreg[][2],
217 int count) 218 int count)
218{ 219{
219 struct usb_device* udev = cam->usbdev; 220 struct usb_device* udev = cam->usbdev;
220 u8* value = cam->control_buffer; /* Needed for DMA'able memory */ 221 u8* buff = cam->control_buffer;
221 int i, res; 222 int i, res;
222 223
223 for (i = 0; i < count; i++) { 224 for (i = 0; i < count; i++) {
224 u8 index = valreg[i][1]; 225 u8 index = valreg[i][1];
225 226
226 /* 227 /*
227 * index is a u8, so it must be <256 and can't be out of range. 228 index is a u8, so it must be <256 and can't be out of range.
228 * If we put in a check anyway, gcc annoys us with a warning 229 If we put in a check anyway, gcc annoys us with a warning
229 * that our check is useless. People get all uppity when they 230 hat our check is useless. People get all uppity when they
230 * see warnings in the kernel compile. 231 see warnings in the kernel compile.
231 */ 232 */
232 233
233 *value = valreg[i][0]; 234 *buff = valreg[i][0];
234 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 235
235 0x08, 0x41, index, 0, 236 res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08,
236 value, 1, SN9C102_CTRL_TIMEOUT); 237 0x41, index, 0, buff, 1,
238 SN9C102_CTRL_TIMEOUT);
239
237 if (res < 0) { 240 if (res < 0) {
238 DBG(3, "Failed to write a register (value 0x%02X, " 241 DBG(3, "Failed to write a register (value 0x%02X, "
239 "index 0x%02X, error %d)", *value, index, res); 242 "index 0x%02X, error %d)", *buff, index, res);
240 return -1; 243 return -1;
241 } 244 }
242 245
243 cam->reg[index] = *value; 246 cam->reg[index] = *buff;
244 } 247 }
245 248
246 return 0; 249 return 0;
@@ -272,8 +275,8 @@ int sn9c102_write_reg(struct sn9c102_device* cam, u8 value, u16 index)
272} 275}
273 276
274 277
275/* NOTE: reading some registers always returns 0 */ 278/* NOTE: with the SN9C10[123] reading some registers always returns 0 */
276static int sn9c102_read_reg(struct sn9c102_device* cam, u16 index) 279int sn9c102_read_reg(struct sn9c102_device* cam, u16 index)
277{ 280{
278 struct usb_device* udev = cam->usbdev; 281 struct usb_device* udev = cam->usbdev;
279 u8* buff = cam->control_buffer; 282 u8* buff = cam->control_buffer;
@@ -299,7 +302,8 @@ int sn9c102_pread_reg(struct sn9c102_device* cam, u16 index)
299 302
300 303
301static int 304static int
302sn9c102_i2c_wait(struct sn9c102_device* cam, struct sn9c102_sensor* sensor) 305sn9c102_i2c_wait(struct sn9c102_device* cam,
306 const struct sn9c102_sensor* sensor)
303{ 307{
304 int i, r; 308 int i, r;
305 309
@@ -320,7 +324,7 @@ sn9c102_i2c_wait(struct sn9c102_device* cam, struct sn9c102_sensor* sensor)
320 324
321static int 325static int
322sn9c102_i2c_detect_read_error(struct sn9c102_device* cam, 326sn9c102_i2c_detect_read_error(struct sn9c102_device* cam,
323 struct sn9c102_sensor* sensor) 327 const struct sn9c102_sensor* sensor)
324{ 328{
325 int r , err = 0; 329 int r , err = 0;
326 330
@@ -342,7 +346,7 @@ sn9c102_i2c_detect_read_error(struct sn9c102_device* cam,
342 346
343static int 347static int
344sn9c102_i2c_detect_write_error(struct sn9c102_device* cam, 348sn9c102_i2c_detect_write_error(struct sn9c102_device* cam,
345 struct sn9c102_sensor* sensor) 349 const struct sn9c102_sensor* sensor)
346{ 350{
347 int r; 351 int r;
348 r = sn9c102_read_reg(cam, 0x08); 352 r = sn9c102_read_reg(cam, 0x08);
@@ -352,12 +356,12 @@ sn9c102_i2c_detect_write_error(struct sn9c102_device* cam,
352 356
353int 357int
354sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, 358sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
355 struct sn9c102_sensor* sensor, u8 data0, u8 data1, 359 const struct sn9c102_sensor* sensor, u8 data0,
356 u8 n, u8 buffer[]) 360 u8 data1, u8 n, u8 buffer[])
357{ 361{
358 struct usb_device* udev = cam->usbdev; 362 struct usb_device* udev = cam->usbdev;
359 u8* data = cam->control_buffer; 363 u8* data = cam->control_buffer;
360 int err = 0, res; 364 int i = 0, err = 0, res;
361 365
362 /* Write cycle */ 366 /* Write cycle */
363 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) | 367 data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) |
@@ -402,7 +406,8 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
402 } 406 }
403 407
404 if (buffer) 408 if (buffer)
405 memcpy(buffer, data, sizeof(buffer)); 409 for (i = 0; i < n && i < 5; i++)
410 buffer[n-i-1] = data[4-i];
406 411
407 return (int)data[4]; 412 return (int)data[4];
408} 413}
@@ -410,7 +415,7 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
410 415
411int 416int
412sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, 417sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
413 struct sn9c102_sensor* sensor, u8 n, u8 data0, 418 const struct sn9c102_sensor* sensor, u8 n, u8 data0,
414 u8 data1, u8 data2, u8 data3, u8 data4, u8 data5) 419 u8 data1, u8 data2, u8 data3, u8 data4, u8 data5)
415{ 420{
416 struct usb_device* udev = cam->usbdev; 421 struct usb_device* udev = cam->usbdev;
@@ -449,7 +454,7 @@ sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
449 454
450int 455int
451sn9c102_i2c_try_read(struct sn9c102_device* cam, 456sn9c102_i2c_try_read(struct sn9c102_device* cam,
452 struct sn9c102_sensor* sensor, u8 address) 457 const struct sn9c102_sensor* sensor, u8 address)
453{ 458{
454 return sn9c102_i2c_try_raw_read(cam, sensor, sensor->i2c_slave_id, 459 return sn9c102_i2c_try_raw_read(cam, sensor, sensor->i2c_slave_id,
455 address, 1, NULL); 460 address, 1, NULL);
@@ -458,7 +463,7 @@ sn9c102_i2c_try_read(struct sn9c102_device* cam,
458 463
459int 464int
460sn9c102_i2c_try_write(struct sn9c102_device* cam, 465sn9c102_i2c_try_write(struct sn9c102_device* cam,
461 struct sn9c102_sensor* sensor, u8 address, u8 value) 466 const struct sn9c102_sensor* sensor, u8 address, u8 value)
462{ 467{
463 return sn9c102_i2c_try_raw_write(cam, sensor, 3, 468 return sn9c102_i2c_try_raw_write(cam, sensor, 3,
464 sensor->i2c_slave_id, address, 469 sensor->i2c_slave_id, address,
@@ -657,16 +662,6 @@ sn9c102_write_jpegheader(struct sn9c102_device* cam, struct sn9c102_frame_t* f)
657} 662}
658 663
659 664
660static void
661sn9c102_write_eoimarker(struct sn9c102_device* cam, struct sn9c102_frame_t* f)
662{
663 static const u8 eoi_marker[2] = {0xff, 0xd9};
664
665 memcpy(f->bufmem + f->buf.bytesused, eoi_marker, sizeof(eoi_marker));
666 f->buf.bytesused += sizeof(eoi_marker);
667}
668
669
670static void sn9c102_urb_complete(struct urb *urb) 665static void sn9c102_urb_complete(struct urb *urb)
671{ 666{
672 struct sn9c102_device* cam = urb->context; 667 struct sn9c102_device* cam = urb->context;
@@ -3181,14 +3176,14 @@ static int sn9c102_ioctl(struct inode* inode, struct file* filp,
3181 3176
3182static const struct file_operations sn9c102_fops = { 3177static const struct file_operations sn9c102_fops = {
3183 .owner = THIS_MODULE, 3178 .owner = THIS_MODULE,
3184 .open = sn9c102_open, 3179 .open = sn9c102_open,
3185 .release = sn9c102_release, 3180 .release = sn9c102_release,
3186 .ioctl = sn9c102_ioctl, 3181 .ioctl = sn9c102_ioctl,
3187 .compat_ioctl = v4l_compat_ioctl32, 3182 .compat_ioctl = v4l_compat_ioctl32,
3188 .read = sn9c102_read, 3183 .read = sn9c102_read,
3189 .poll = sn9c102_poll, 3184 .poll = sn9c102_poll,
3190 .mmap = sn9c102_mmap, 3185 .mmap = sn9c102_mmap,
3191 .llseek = no_llseek, 3186 .llseek = no_llseek,
3192}; 3187};
3193 3188
3194/*****************************************************************************/ 3189/*****************************************************************************/
@@ -3251,7 +3246,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
3251 break; 3246 break;
3252 } 3247 }
3253 3248
3254 for (i = 0; sn9c102_sensor_table[i]; i++) { 3249 for (i = 0; i < ARRAY_SIZE(sn9c102_sensor_table); i++) {
3255 err = sn9c102_sensor_table[i](cam); 3250 err = sn9c102_sensor_table[i](cam);
3256 if (!err) 3251 if (!err)
3257 break; 3252 break;
@@ -3262,7 +3257,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
3262 DBG(3, "Support for %s maintained by %s", 3257 DBG(3, "Support for %s maintained by %s",
3263 cam->sensor.name, cam->sensor.maintainer); 3258 cam->sensor.name, cam->sensor.maintainer);
3264 } else { 3259 } else {
3265 DBG(1, "No supported image sensor detected"); 3260 DBG(1, "No supported image sensor detected for this bridge");
3266 err = -ENODEV; 3261 err = -ENODEV;
3267 goto fail; 3262 goto fail;
3268 } 3263 }
diff --git a/drivers/media/video/sn9c102/sn9c102_devtable.h b/drivers/media/video/sn9c102/sn9c102_devtable.h
index f49bd8c5b86e..916054faf9be 100644
--- a/drivers/media/video/sn9c102/sn9c102_devtable.h
+++ b/drivers/media/video/sn9c102/sn9c102_devtable.h
@@ -86,6 +86,8 @@ static const struct usb_device_id sn9c102_id_table[] = {
86 { SN9C102_USB_DEVICE(0x0c45, 0x60bc, BRIDGE_SN9C103), }, 86 { SN9C102_USB_DEVICE(0x0c45, 0x60bc, BRIDGE_SN9C103), },
87 { SN9C102_USB_DEVICE(0x0c45, 0x60be, BRIDGE_SN9C103), }, 87 { SN9C102_USB_DEVICE(0x0c45, 0x60be, BRIDGE_SN9C103), },
88 /* SN9C105 */ 88 /* SN9C105 */
89 { SN9C102_USB_DEVICE(0x045e, 0x00f5, BRIDGE_SN9C105), },
90 { SN9C102_USB_DEVICE(0x045e, 0x00f7, BRIDGE_SN9C105), },
89 { SN9C102_USB_DEVICE(0x0471, 0x0327, BRIDGE_SN9C105), }, 91 { SN9C102_USB_DEVICE(0x0471, 0x0327, BRIDGE_SN9C105), },
90 { SN9C102_USB_DEVICE(0x0471, 0x0328, BRIDGE_SN9C105), }, 92 { SN9C102_USB_DEVICE(0x0471, 0x0328, BRIDGE_SN9C105), },
91 { SN9C102_USB_DEVICE(0x0c45, 0x60c0, BRIDGE_SN9C105), }, 93 { SN9C102_USB_DEVICE(0x0c45, 0x60c0, BRIDGE_SN9C105), },
@@ -100,6 +102,7 @@ static const struct usb_device_id sn9c102_id_table[] = {
100 { SN9C102_USB_DEVICE(0x0c45, 0x60fc, BRIDGE_SN9C105), }, 102 { SN9C102_USB_DEVICE(0x0c45, 0x60fc, BRIDGE_SN9C105), },
101 { SN9C102_USB_DEVICE(0x0c45, 0x60fe, BRIDGE_SN9C105), }, 103 { SN9C102_USB_DEVICE(0x0c45, 0x60fe, BRIDGE_SN9C105), },
102 /* SN9C120 */ 104 /* SN9C120 */
105 { SN9C102_USB_DEVICE(0x0458, 0x7025, BRIDGE_SN9C120), },
103 { SN9C102_USB_DEVICE(0x0c45, 0x6102, BRIDGE_SN9C120), }, 106 { SN9C102_USB_DEVICE(0x0c45, 0x6102, BRIDGE_SN9C120), },
104 { SN9C102_USB_DEVICE(0x0c45, 0x6108, BRIDGE_SN9C120), }, 107 { SN9C102_USB_DEVICE(0x0c45, 0x6108, BRIDGE_SN9C120), },
105 { SN9C102_USB_DEVICE(0x0c45, 0x610f, BRIDGE_SN9C120), }, 108 { SN9C102_USB_DEVICE(0x0c45, 0x610f, BRIDGE_SN9C120), },
@@ -148,7 +151,6 @@ static int (*sn9c102_sensor_table[])(struct sn9c102_device*) = {
148 &sn9c102_probe_tas5110c1b, /* detection based on USB pid/vid */ 151 &sn9c102_probe_tas5110c1b, /* detection based on USB pid/vid */
149 &sn9c102_probe_tas5110d, /* detection based on USB pid/vid */ 152 &sn9c102_probe_tas5110d, /* detection based on USB pid/vid */
150 &sn9c102_probe_tas5130d1b, /* detection based on USB pid/vid */ 153 &sn9c102_probe_tas5130d1b, /* detection based on USB pid/vid */
151 NULL,
152}; 154};
153 155
154#endif /* _SN9C102_DEVTABLE_H_ */ 156#endif /* _SN9C102_DEVTABLE_H_ */
diff --git a/drivers/media/video/sn9c102/sn9c102_hv7131d.c b/drivers/media/video/sn9c102/sn9c102_hv7131d.c
index 28a861aed044..eaf9ad0dc8a6 100644
--- a/drivers/media/video/sn9c102/sn9c102_hv7131d.c
+++ b/drivers/media/video/sn9c102/sn9c102_hv7131d.c
@@ -144,7 +144,7 @@ static int hv7131d_set_pix_format(struct sn9c102_device* cam,
144} 144}
145 145
146 146
147static struct sn9c102_sensor hv7131d = { 147static const struct sn9c102_sensor hv7131d = {
148 .name = "HV7131D", 148 .name = "HV7131D",
149 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 149 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
150 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, 150 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102,
@@ -248,12 +248,10 @@ int sn9c102_probe_hv7131d(struct sn9c102_device* cam)
248 248
249 err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, 249 err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01},
250 {0x28, 0x17}); 250 {0x28, 0x17});
251 if (err)
252 return -EIO;
253 251
254 r0 = sn9c102_i2c_try_read(cam, &hv7131d, 0x00); 252 r0 = sn9c102_i2c_try_read(cam, &hv7131d, 0x00);
255 r1 = sn9c102_i2c_try_read(cam, &hv7131d, 0x01); 253 r1 = sn9c102_i2c_try_read(cam, &hv7131d, 0x01);
256 if (r0 < 0 || r1 < 0) 254 if (err || r0 < 0 || r1 < 0)
257 return -EIO; 255 return -EIO;
258 256
259 if (r0 != 0x00 || r1 != 0x04) 257 if (r0 != 0x00 || r1 != 0x04)
diff --git a/drivers/media/video/sn9c102/sn9c102_hv7131r.c b/drivers/media/video/sn9c102/sn9c102_hv7131r.c
index 5a495baa5f95..0fc401223cfc 100644
--- a/drivers/media/video/sn9c102/sn9c102_hv7131r.c
+++ b/drivers/media/video/sn9c102/sn9c102_hv7131r.c
@@ -44,7 +44,6 @@ static int hv7131r_init(struct sn9c102_device* cam)
44 {0xb0, 0x2b}, {0xc0, 0x2c}, 44 {0xb0, 0x2b}, {0xc0, 0x2c},
45 {0xd0, 0x2d}, {0xe0, 0x2e}, 45 {0xd0, 0x2d}, {0xe0, 0x2e},
46 {0xf0, 0x2f}, {0xff, 0x30}); 46 {0xf0, 0x2f}, {0xff, 0x30});
47
48 break; 47 break;
49 case BRIDGE_SN9C105: 48 case BRIDGE_SN9C105:
50 case BRIDGE_SN9C120: 49 case BRIDGE_SN9C120:
@@ -254,7 +253,7 @@ static int hv7131r_set_pix_format(struct sn9c102_device* cam,
254} 253}
255 254
256 255
257static struct sn9c102_sensor hv7131r = { 256static const struct sn9c102_sensor hv7131r = {
258 .name = "HV7131R", 257 .name = "HV7131R",
259 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 258 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
260 .supported_bridge = BRIDGE_SN9C103 | BRIDGE_SN9C105 | BRIDGE_SN9C120, 259 .supported_bridge = BRIDGE_SN9C103 | BRIDGE_SN9C105 | BRIDGE_SN9C120,
@@ -350,11 +349,8 @@ int sn9c102_probe_hv7131r(struct sn9c102_device* cam)
350 {0x34, 0x01}, {0x20, 0x17}, 349 {0x34, 0x01}, {0x20, 0x17},
351 {0x34, 0x01}, {0x46, 0x01}); 350 {0x34, 0x01}, {0x46, 0x01});
352 351
353 if (err)
354 return -EIO;
355
356 devid = sn9c102_i2c_try_read(cam, &hv7131r, 0x00); 352 devid = sn9c102_i2c_try_read(cam, &hv7131r, 0x00);
357 if (devid < 0) 353 if (err || devid < 0)
358 return -EIO; 354 return -EIO;
359 355
360 if (devid != 0x02) 356 if (devid != 0x02)
diff --git a/drivers/media/video/sn9c102/sn9c102_mi0343.c b/drivers/media/video/sn9c102/sn9c102_mi0343.c
index 9200845d011b..00b134ca0a3d 100644
--- a/drivers/media/video/sn9c102/sn9c102_mi0343.c
+++ b/drivers/media/video/sn9c102/sn9c102_mi0343.c
@@ -55,45 +55,45 @@ static int mi0343_get_ctrl(struct sn9c102_device* cam,
55 struct v4l2_control* ctrl) 55 struct v4l2_control* ctrl)
56{ 56{
57 struct sn9c102_sensor* s = sn9c102_get_sensor(cam); 57 struct sn9c102_sensor* s = sn9c102_get_sensor(cam);
58 u8 data[5+1]; 58 u8 data[2];
59 59
60 switch (ctrl->id) { 60 switch (ctrl->id) {
61 case V4L2_CID_EXPOSURE: 61 case V4L2_CID_EXPOSURE:
62 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 62 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 2,
63 2+1, data) < 0) 63 data) < 0)
64 return -EIO; 64 return -EIO;
65 ctrl->value = data[2]; 65 ctrl->value = data[0];
66 return 0; 66 return 0;
67 case V4L2_CID_GAIN: 67 case V4L2_CID_GAIN:
68 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 68 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 2,
69 2+1, data) < 0) 69 data) < 0)
70 return -EIO; 70 return -EIO;
71 break; 71 break;
72 case V4L2_CID_HFLIP: 72 case V4L2_CID_HFLIP:
73 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 73 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2,
74 2+1, data) < 0) 74 data) < 0)
75 return -EIO; 75 return -EIO;
76 ctrl->value = data[3] & 0x20 ? 1 : 0; 76 ctrl->value = data[1] & 0x20 ? 1 : 0;
77 return 0; 77 return 0;
78 case V4L2_CID_VFLIP: 78 case V4L2_CID_VFLIP:
79 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 79 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2,
80 2+1, data) < 0) 80 data) < 0)
81 return -EIO; 81 return -EIO;
82 ctrl->value = data[3] & 0x80 ? 1 : 0; 82 ctrl->value = data[1] & 0x80 ? 1 : 0;
83 return 0; 83 return 0;
84 case V4L2_CID_RED_BALANCE: 84 case V4L2_CID_RED_BALANCE:
85 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 85 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 2,
86 2+1, data) < 0) 86 data) < 0)
87 return -EIO; 87 return -EIO;
88 break; 88 break;
89 case V4L2_CID_BLUE_BALANCE: 89 case V4L2_CID_BLUE_BALANCE:
90 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 90 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 2,
91 2+1, data) < 0) 91 data) < 0)
92 return -EIO; 92 return -EIO;
93 break; 93 break;
94 case SN9C102_V4L2_CID_GREEN_BALANCE: 94 case SN9C102_V4L2_CID_GREEN_BALANCE:
95 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 95 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 2,
96 2+1, data) < 0) 96 data) < 0)
97 return -EIO; 97 return -EIO;
98 break; 98 break;
99 default: 99 default:
@@ -105,7 +105,7 @@ static int mi0343_get_ctrl(struct sn9c102_device* cam,
105 case V4L2_CID_RED_BALANCE: 105 case V4L2_CID_RED_BALANCE:
106 case V4L2_CID_BLUE_BALANCE: 106 case V4L2_CID_BLUE_BALANCE:
107 case SN9C102_V4L2_CID_GREEN_BALANCE: 107 case SN9C102_V4L2_CID_GREEN_BALANCE:
108 ctrl->value = data[3] | (data[2] << 8); 108 ctrl->value = data[1] | (data[0] << 8);
109 if (ctrl->value >= 0x10 && ctrl->value <= 0x3f) 109 if (ctrl->value >= 0x10 && ctrl->value <= 0x3f)
110 ctrl->value -= 0x10; 110 ctrl->value -= 0x10;
111 else if (ctrl->value >= 0x60 && ctrl->value <= 0x7f) 111 else if (ctrl->value >= 0x60 && ctrl->value <= 0x7f)
@@ -223,7 +223,7 @@ static int mi0343_set_pix_format(struct sn9c102_device* cam,
223} 223}
224 224
225 225
226static struct sn9c102_sensor mi0343 = { 226static const struct sn9c102_sensor mi0343 = {
227 .name = "MI-0343", 227 .name = "MI-0343",
228 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 228 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
229 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, 229 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102,
@@ -332,20 +332,17 @@ static struct sn9c102_sensor mi0343 = {
332 332
333int sn9c102_probe_mi0343(struct sn9c102_device* cam) 333int sn9c102_probe_mi0343(struct sn9c102_device* cam)
334{ 334{
335 u8 data[5+1]; 335 u8 data[2];
336 int err = 0;
337
338 err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01},
339 {0x28, 0x17});
340 336
341 if (err) 337 if (sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01},
338 {0x28, 0x17}))
342 return -EIO; 339 return -EIO;
343 340
344 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00, 341 if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00,
345 2, data) < 0) 342 2, data) < 0)
346 return -EIO; 343 return -EIO;
347 344
348 if (data[4] != 0x32 || data[3] != 0xe3) 345 if (data[1] != 0x42 || data[0] != 0xe3)
349 return -ENODEV; 346 return -ENODEV;
350 347
351 sn9c102_attach_sensor(cam, &mi0343); 348 sn9c102_attach_sensor(cam, &mi0343);
diff --git a/drivers/media/video/sn9c102/sn9c102_mi0360.c b/drivers/media/video/sn9c102/sn9c102_mi0360.c
index 64698acb0b15..f8d81d82e8d5 100644
--- a/drivers/media/video/sn9c102/sn9c102_mi0360.c
+++ b/drivers/media/video/sn9c102/sn9c102_mi0360.c
@@ -27,20 +27,105 @@ static int mi0360_init(struct sn9c102_device* cam)
27 struct sn9c102_sensor* s = sn9c102_get_sensor(cam); 27 struct sn9c102_sensor* s = sn9c102_get_sensor(cam);
28 int err = 0; 28 int err = 0;
29 29
30 err = sn9c102_write_const_regs(cam, {0x00, 0x10}, {0x00, 0x11}, 30 switch (sn9c102_get_bridge(cam)) {
31 {0x0a, 0x14}, {0x40, 0x01}, 31 case BRIDGE_SN9C103:
32 {0x20, 0x17}, {0x07, 0x18}, 32 err = sn9c102_write_const_regs(cam, {0x00, 0x10}, {0x00, 0x11},
33 {0xa0, 0x19}, {0x02, 0x1c}, 33 {0x0a, 0x14}, {0x40, 0x01},
34 {0x03, 0x1d}, {0x0f, 0x1e}, 34 {0x20, 0x17}, {0x07, 0x18},
35 {0x0c, 0x1f}, {0x00, 0x20}, 35 {0xa0, 0x19}, {0x02, 0x1c},
36 {0x10, 0x21}, {0x20, 0x22}, 36 {0x03, 0x1d}, {0x0f, 0x1e},
37 {0x30, 0x23}, {0x40, 0x24}, 37 {0x0c, 0x1f}, {0x00, 0x20},
38 {0x50, 0x25}, {0x60, 0x26}, 38 {0x10, 0x21}, {0x20, 0x22},
39 {0x70, 0x27}, {0x80, 0x28}, 39 {0x30, 0x23}, {0x40, 0x24},
40 {0x90, 0x29}, {0xa0, 0x2a}, 40 {0x50, 0x25}, {0x60, 0x26},
41 {0xb0, 0x2b}, {0xc0, 0x2c}, 41 {0x70, 0x27}, {0x80, 0x28},
42 {0xd0, 0x2d}, {0xe0, 0x2e}, 42 {0x90, 0x29}, {0xa0, 0x2a},
43 {0xf0, 0x2f}, {0xff, 0x30}); 43 {0xb0, 0x2b}, {0xc0, 0x2c},
44 {0xd0, 0x2d}, {0xe0, 0x2e},
45 {0xf0, 0x2f}, {0xff, 0x30});
46 break;
47 case BRIDGE_SN9C105:
48 case BRIDGE_SN9C120:
49 err = sn9c102_write_const_regs(cam, {0x44, 0x01}, {0x40, 0x02},
50 {0x00, 0x03}, {0x1a, 0x04},
51 {0x50, 0x05}, {0x20, 0x06},
52 {0x10, 0x07}, {0x03, 0x10},
53 {0x08, 0x14}, {0xa2, 0x17},
54 {0x47, 0x18}, {0x00, 0x19},
55 {0x1d, 0x1a}, {0x10, 0x1b},
56 {0x02, 0x1c}, {0x03, 0x1d},
57 {0x0f, 0x1e}, {0x0c, 0x1f},
58 {0x00, 0x20}, {0x29, 0x21},
59 {0x40, 0x22}, {0x54, 0x23},
60 {0x66, 0x24}, {0x76, 0x25},
61 {0x85, 0x26}, {0x94, 0x27},
62 {0xa1, 0x28}, {0xae, 0x29},
63 {0xbb, 0x2a}, {0xc7, 0x2b},
64 {0xd3, 0x2c}, {0xde, 0x2d},
65 {0xea, 0x2e}, {0xf4, 0x2f},
66 {0xff, 0x30}, {0x00, 0x3F},
67 {0xC7, 0x40}, {0x01, 0x41},
68 {0x44, 0x42}, {0x00, 0x43},
69 {0x44, 0x44}, {0x00, 0x45},
70 {0x44, 0x46}, {0x00, 0x47},
71 {0xC7, 0x48}, {0x01, 0x49},
72 {0xC7, 0x4A}, {0x01, 0x4B},
73 {0xC7, 0x4C}, {0x01, 0x4D},
74 {0x44, 0x4E}, {0x00, 0x4F},
75 {0x44, 0x50}, {0x00, 0x51},
76 {0x44, 0x52}, {0x00, 0x53},
77 {0xC7, 0x54}, {0x01, 0x55},
78 {0xC7, 0x56}, {0x01, 0x57},
79 {0xC7, 0x58}, {0x01, 0x59},
80 {0x44, 0x5A}, {0x00, 0x5B},
81 {0x44, 0x5C}, {0x00, 0x5D},
82 {0x44, 0x5E}, {0x00, 0x5F},
83 {0xC7, 0x60}, {0x01, 0x61},
84 {0xC7, 0x62}, {0x01, 0x63},
85 {0xC7, 0x64}, {0x01, 0x65},
86 {0x44, 0x66}, {0x00, 0x67},
87 {0x44, 0x68}, {0x00, 0x69},
88 {0x44, 0x6A}, {0x00, 0x6B},
89 {0xC7, 0x6C}, {0x01, 0x6D},
90 {0xC7, 0x6E}, {0x01, 0x6F},
91 {0xC7, 0x70}, {0x01, 0x71},
92 {0x44, 0x72}, {0x00, 0x73},
93 {0x44, 0x74}, {0x00, 0x75},
94 {0x44, 0x76}, {0x00, 0x77},
95 {0xC7, 0x78}, {0x01, 0x79},
96 {0xC7, 0x7A}, {0x01, 0x7B},
97 {0xC7, 0x7C}, {0x01, 0x7D},
98 {0x44, 0x7E}, {0x00, 0x7F},
99 {0x14, 0x84}, {0x00, 0x85},
100 {0x27, 0x86}, {0x00, 0x87},
101 {0x07, 0x88}, {0x00, 0x89},
102 {0xEC, 0x8A}, {0x0f, 0x8B},
103 {0xD8, 0x8C}, {0x0f, 0x8D},
104 {0x3D, 0x8E}, {0x00, 0x8F},
105 {0x3D, 0x90}, {0x00, 0x91},
106 {0xCD, 0x92}, {0x0f, 0x93},
107 {0xf7, 0x94}, {0x0f, 0x95},
108 {0x0C, 0x96}, {0x00, 0x97},
109 {0x00, 0x98}, {0x66, 0x99},
110 {0x05, 0x9A}, {0x00, 0x9B},
111 {0x04, 0x9C}, {0x00, 0x9D},
112 {0x08, 0x9E}, {0x00, 0x9F},
113 {0x2D, 0xC0}, {0x2D, 0xC1},
114 {0x3A, 0xC2}, {0x05, 0xC3},
115 {0x04, 0xC4}, {0x3F, 0xC5},
116 {0x00, 0xC6}, {0x00, 0xC7},
117 {0x50, 0xC8}, {0x3C, 0xC9},
118 {0x28, 0xCA}, {0xD8, 0xCB},
119 {0x14, 0xCC}, {0xEC, 0xCD},
120 {0x32, 0xCE}, {0xDD, 0xCF},
121 {0x32, 0xD0}, {0xDD, 0xD1},
122 {0x6A, 0xD2}, {0x50, 0xD3},
123 {0x00, 0xD4}, {0x00, 0xD5},
124 {0x00, 0xD6});
125 break;
126 default:
127 break;
128 }
44 129
45 err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x0d, 130 err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 0x0d,
46 0x00, 0x01, 0, 0); 131 0x00, 0x01, 0, 0);
@@ -65,50 +150,50 @@ static int mi0360_get_ctrl(struct sn9c102_device* cam,
65 struct v4l2_control* ctrl) 150 struct v4l2_control* ctrl)
66{ 151{
67 struct sn9c102_sensor* s = sn9c102_get_sensor(cam); 152 struct sn9c102_sensor* s = sn9c102_get_sensor(cam);
68 u8 data[5+1]; 153 u8 data[2];
69 154
70 switch (ctrl->id) { 155 switch (ctrl->id) {
71 case V4L2_CID_EXPOSURE: 156 case V4L2_CID_EXPOSURE:
72 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 157 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x09, 2,
73 2+1, data) < 0) 158 data) < 0)
74 return -EIO; 159 return -EIO;
75 ctrl->value = data[2]; 160 ctrl->value = data[0];
76 return 0; 161 return 0;
77 case V4L2_CID_GAIN: 162 case V4L2_CID_GAIN:
78 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 163 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x35, 2,
79 2+1, data) < 0) 164 data) < 0)
80 return -EIO; 165 return -EIO;
81 ctrl->value = data[3]; 166 ctrl->value = data[1];
82 return 0; 167 return 0;
83 case V4L2_CID_RED_BALANCE: 168 case V4L2_CID_RED_BALANCE:
84 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 169 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2c, 2,
85 2+1, data) < 0) 170 data) < 0)
86 return -EIO; 171 return -EIO;
87 ctrl->value = data[3]; 172 ctrl->value = data[1];
88 return 0; 173 return 0;
89 case V4L2_CID_BLUE_BALANCE: 174 case V4L2_CID_BLUE_BALANCE:
90 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 175 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2d, 2,
91 2+1, data) < 0) 176 data) < 0)
92 return -EIO; 177 return -EIO;
93 ctrl->value = data[3]; 178 ctrl->value = data[1];
94 return 0; 179 return 0;
95 case SN9C102_V4L2_CID_GREEN_BALANCE: 180 case SN9C102_V4L2_CID_GREEN_BALANCE:
96 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 181 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x2e, 2,
97 2+1, data) < 0) 182 data) < 0)
98 return -EIO; 183 return -EIO;
99 ctrl->value = data[3]; 184 ctrl->value = data[1];
100 return 0; 185 return 0;
101 case V4L2_CID_HFLIP: 186 case V4L2_CID_HFLIP:
102 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 187 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2,
103 2+1, data) < 0) 188 data) < 0)
104 return -EIO; 189 return -EIO;
105 ctrl->value = data[3] & 0x20 ? 1 : 0; 190 ctrl->value = data[1] & 0x20 ? 1 : 0;
106 return 0; 191 return 0;
107 case V4L2_CID_VFLIP: 192 case V4L2_CID_VFLIP:
108 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 193 if (sn9c102_i2c_try_raw_read(cam, s, s->i2c_slave_id, 0x20, 2,
109 2+1, data) < 0) 194 data) < 0)
110 return -EIO; 195 return -EIO;
111 ctrl->value = data[3] & 0x80 ? 1 : 0; 196 ctrl->value = data[1] & 0x80 ? 1 : 0;
112 return 0; 197 return 0;
113 default: 198 default:
114 return -EINVAL; 199 return -EINVAL;
@@ -178,8 +263,19 @@ static int mi0360_set_crop(struct sn9c102_device* cam,
178{ 263{
179 struct sn9c102_sensor* s = sn9c102_get_sensor(cam); 264 struct sn9c102_sensor* s = sn9c102_get_sensor(cam);
180 int err = 0; 265 int err = 0;
181 u8 h_start = (u8)(rect->left - s->cropcap.bounds.left) + 0, 266 u8 h_start = 0, v_start = (u8)(rect->top - s->cropcap.bounds.top) + 1;
182 v_start = (u8)(rect->top - s->cropcap.bounds.top) + 1; 267
268 switch (sn9c102_get_bridge(cam)) {
269 case BRIDGE_SN9C103:
270 h_start = (u8)(rect->left - s->cropcap.bounds.left) + 0;
271 break;
272 case BRIDGE_SN9C105:
273 case BRIDGE_SN9C120:
274 h_start = (u8)(rect->left - s->cropcap.bounds.left) + 1;
275 break;
276 default:
277 break;
278 }
183 279
184 err += sn9c102_write_reg(cam, h_start, 0x12); 280 err += sn9c102_write_reg(cam, h_start, 0x12);
185 err += sn9c102_write_reg(cam, v_start, 0x13); 281 err += sn9c102_write_reg(cam, v_start, 0x13);
@@ -194,24 +290,30 @@ static int mi0360_set_pix_format(struct sn9c102_device* cam,
194 struct sn9c102_sensor* s = sn9c102_get_sensor(cam); 290 struct sn9c102_sensor* s = sn9c102_get_sensor(cam);
195 int err = 0; 291 int err = 0;
196 292
197 if (pix->pixelformat == V4L2_PIX_FMT_SN9C10X) { 293 if (pix->pixelformat == V4L2_PIX_FMT_SBGGR8) {
198 err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id,
199 0x0a, 0x00, 0x02, 0, 0);
200 err += sn9c102_write_reg(cam, 0x20, 0x19);
201 } else {
202 err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id, 294 err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id,
203 0x0a, 0x00, 0x05, 0, 0); 295 0x0a, 0x00, 0x05, 0, 0);
204 err += sn9c102_write_reg(cam, 0x60, 0x19); 296 err += sn9c102_write_reg(cam, 0x60, 0x19);
297 if (sn9c102_get_bridge(cam) == BRIDGE_SN9C105 ||
298 sn9c102_get_bridge(cam) == BRIDGE_SN9C120)
299 err += sn9c102_write_reg(cam, 0xa6, 0x17);
300 } else {
301 err += sn9c102_i2c_try_raw_write(cam, s, 4, s->i2c_slave_id,
302 0x0a, 0x00, 0x02, 0, 0);
303 err += sn9c102_write_reg(cam, 0x20, 0x19);
304 if (sn9c102_get_bridge(cam) == BRIDGE_SN9C105 ||
305 sn9c102_get_bridge(cam) == BRIDGE_SN9C120)
306 err += sn9c102_write_reg(cam, 0xa2, 0x17);
205 } 307 }
206 308
207 return err; 309 return err;
208} 310}
209 311
210 312
211static struct sn9c102_sensor mi0360 = { 313static const struct sn9c102_sensor mi0360 = {
212 .name = "MI-0360", 314 .name = "MI-0360",
213 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 315 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
214 .supported_bridge = BRIDGE_SN9C103, 316 .supported_bridge = BRIDGE_SN9C103 | BRIDGE_SN9C105 | BRIDGE_SN9C120,
215 .frequency = SN9C102_I2C_100KHZ, 317 .frequency = SN9C102_I2C_100KHZ,
216 .interface = SN9C102_I2C_2WIRES, 318 .interface = SN9C102_I2C_2WIRES,
217 .i2c_slave_id = 0x5d, 319 .i2c_slave_id = 0x5d,
@@ -317,19 +419,31 @@ static struct sn9c102_sensor mi0360 = {
317 419
318int sn9c102_probe_mi0360(struct sn9c102_device* cam) 420int sn9c102_probe_mi0360(struct sn9c102_device* cam)
319{ 421{
320 u8 data[5+1];
321 int err;
322 422
323 err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01}, 423 u8 data[2];
324 {0x28, 0x17}); 424
325 if (err) 425 switch (sn9c102_get_bridge(cam)) {
326 return -EIO; 426 case BRIDGE_SN9C103:
427 if (sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01},
428 {0x28, 0x17}))
429 return -EIO;
430 break;
431 case BRIDGE_SN9C105:
432 case BRIDGE_SN9C120:
433 if (sn9c102_write_const_regs(cam, {0x01, 0xf1}, {0x00, 0xf1},
434 {0x01, 0x01}, {0x00, 0x01},
435 {0x28, 0x17}))
436 return -EIO;
437 break;
438 default:
439 break;
440 }
327 441
328 if (sn9c102_i2c_try_raw_read(cam, &mi0360, mi0360.i2c_slave_id, 0x00, 442 if (sn9c102_i2c_try_raw_read(cam, &mi0360, mi0360.i2c_slave_id, 0x00,
329 2+1, data) < 0) 443 2, data) < 0)
330 return -EIO; 444 return -EIO;
331 445
332 if (data[2] != 0x82 || data[3] != 0x43) 446 if (data[0] != 0x82 || data[1] != 0x43)
333 return -ENODEV; 447 return -ENODEV;
334 448
335 sn9c102_attach_sensor(cam, &mi0360); 449 sn9c102_attach_sensor(cam, &mi0360);
diff --git a/drivers/media/video/sn9c102/sn9c102_ov7630.c b/drivers/media/video/sn9c102/sn9c102_ov7630.c
index 31b6080b0615..e6832347894f 100644
--- a/drivers/media/video/sn9c102/sn9c102_ov7630.c
+++ b/drivers/media/video/sn9c102/sn9c102_ov7630.c
@@ -29,9 +29,8 @@ static int ov7630_init(struct sn9c102_device* cam)
29 switch (sn9c102_get_bridge(cam)) { 29 switch (sn9c102_get_bridge(cam)) {
30 case BRIDGE_SN9C101: 30 case BRIDGE_SN9C101:
31 case BRIDGE_SN9C102: 31 case BRIDGE_SN9C102:
32 err = sn9c102_write_const_regs(cam, {0x00, 0x14}, 32 err = sn9c102_write_const_regs(cam, {0x00, 0x14}, {0x60, 0x17},
33 {0x60, 0x17}, {0x0f, 0x18}, 33 {0x0f, 0x18}, {0x50, 0x19});
34 {0x50, 0x19});
35 34
36 err += sn9c102_i2c_write(cam, 0x12, 0x8d); 35 err += sn9c102_i2c_write(cam, 0x12, 0x8d);
37 err += sn9c102_i2c_write(cam, 0x12, 0x0d); 36 err += sn9c102_i2c_write(cam, 0x12, 0x0d);
@@ -61,7 +60,6 @@ static int ov7630_init(struct sn9c102_device* cam)
61 err += sn9c102_i2c_write(cam, 0x71, 0x00); 60 err += sn9c102_i2c_write(cam, 0x71, 0x00);
62 err += sn9c102_i2c_write(cam, 0x74, 0x21); 61 err += sn9c102_i2c_write(cam, 0x74, 0x21);
63 err += sn9c102_i2c_write(cam, 0x7d, 0xf7); 62 err += sn9c102_i2c_write(cam, 0x7d, 0xf7);
64
65 break; 63 break;
66 case BRIDGE_SN9C103: 64 case BRIDGE_SN9C103:
67 err = sn9c102_write_const_regs(cam, {0x00, 0x02}, {0x00, 0x03}, 65 err = sn9c102_write_const_regs(cam, {0x00, 0x02}, {0x00, 0x03},
@@ -253,7 +251,7 @@ static int ov7630_set_pix_format(struct sn9c102_device* cam,
253} 251}
254 252
255 253
256static struct sn9c102_sensor ov7630 = { 254static const struct sn9c102_sensor ov7630 = {
257 .name = "OV7630", 255 .name = "OV7630",
258 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 256 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
259 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103, 257 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103,
@@ -408,19 +406,16 @@ int sn9c102_probe_ov7630(struct sn9c102_device* cam)
408 switch (sn9c102_get_bridge(cam)) { 406 switch (sn9c102_get_bridge(cam)) {
409 case BRIDGE_SN9C101: 407 case BRIDGE_SN9C101:
410 case BRIDGE_SN9C102: 408 case BRIDGE_SN9C102:
411 err = sn9c102_write_const_regs(cam, {0x01, 0x01}, 409 err = sn9c102_write_const_regs(cam, {0x01, 0x01}, {0x00, 0x01},
412 {0x00, 0x01}, {0x28, 0x17}); 410 {0x28, 0x17});
413
414 break; 411 break;
415 case BRIDGE_SN9C103: /* do _not_ change anything! */ 412 case BRIDGE_SN9C103: /* do _not_ change anything! */
416 err = sn9c102_write_const_regs(cam, {0x09, 0x01}, 413 err = sn9c102_write_const_regs(cam, {0x09, 0x01}, {0x42, 0x01},
417 {0x42, 0x01}, {0x28, 0x17}, 414 {0x28, 0x17}, {0x44, 0x02});
418 {0x44, 0x02});
419 pid = sn9c102_i2c_try_read(cam, &ov7630, 0x0a); 415 pid = sn9c102_i2c_try_read(cam, &ov7630, 0x0a);
420 if (err || pid < 0) { /* try a different initialization */ 416 if (err || pid < 0) /* try a different initialization */
421 err = sn9c102_write_reg(cam, 0x01, 0x01); 417 err += sn9c102_write_const_regs(cam, {0x01, 0x01},
422 err += sn9c102_write_reg(cam, 0x00, 0x01); 418 {0x00, 0x01});
423 }
424 break; 419 break;
425 default: 420 default:
426 break; 421 break;
diff --git a/drivers/media/video/sn9c102/sn9c102_ov7660.c b/drivers/media/video/sn9c102/sn9c102_ov7660.c
index c898e948fe8d..4b6474048a72 100644
--- a/drivers/media/video/sn9c102/sn9c102_ov7660.c
+++ b/drivers/media/video/sn9c102/sn9c102_ov7660.c
@@ -104,8 +104,8 @@ static int ov7660_init(struct sn9c102_device* cam)
104 err += sn9c102_i2c_write(cam, 0x12, 0x80); 104 err += sn9c102_i2c_write(cam, 0x12, 0x80);
105 err += sn9c102_i2c_write(cam, 0x11, 0x09); 105 err += sn9c102_i2c_write(cam, 0x11, 0x09);
106 err += sn9c102_i2c_write(cam, 0x00, 0x0A); 106 err += sn9c102_i2c_write(cam, 0x00, 0x0A);
107 err += sn9c102_i2c_write(cam, 0x01, 0x78); 107 err += sn9c102_i2c_write(cam, 0x01, 0x80);
108 err += sn9c102_i2c_write(cam, 0x02, 0x90); 108 err += sn9c102_i2c_write(cam, 0x02, 0x80);
109 err += sn9c102_i2c_write(cam, 0x03, 0x00); 109 err += sn9c102_i2c_write(cam, 0x03, 0x00);
110 err += sn9c102_i2c_write(cam, 0x04, 0x00); 110 err += sn9c102_i2c_write(cam, 0x04, 0x00);
111 err += sn9c102_i2c_write(cam, 0x05, 0x08); 111 err += sn9c102_i2c_write(cam, 0x05, 0x08);
@@ -122,7 +122,7 @@ static int ov7660_init(struct sn9c102_device* cam)
122 err += sn9c102_i2c_write(cam, 0x10, 0x20); 122 err += sn9c102_i2c_write(cam, 0x10, 0x20);
123 err += sn9c102_i2c_write(cam, 0x11, 0x03); 123 err += sn9c102_i2c_write(cam, 0x11, 0x03);
124 err += sn9c102_i2c_write(cam, 0x12, 0x05); 124 err += sn9c102_i2c_write(cam, 0x12, 0x05);
125 err += sn9c102_i2c_write(cam, 0x13, 0xF8); 125 err += sn9c102_i2c_write(cam, 0x13, 0xC7);
126 err += sn9c102_i2c_write(cam, 0x14, 0x2C); 126 err += sn9c102_i2c_write(cam, 0x14, 0x2C);
127 err += sn9c102_i2c_write(cam, 0x15, 0x00); 127 err += sn9c102_i2c_write(cam, 0x15, 0x00);
128 err += sn9c102_i2c_write(cam, 0x16, 0x02); 128 err += sn9c102_i2c_write(cam, 0x16, 0x02);
@@ -162,7 +162,7 @@ static int ov7660_init(struct sn9c102_device* cam)
162 err += sn9c102_i2c_write(cam, 0x38, 0x02); 162 err += sn9c102_i2c_write(cam, 0x38, 0x02);
163 err += sn9c102_i2c_write(cam, 0x39, 0x43); 163 err += sn9c102_i2c_write(cam, 0x39, 0x43);
164 err += sn9c102_i2c_write(cam, 0x3A, 0x00); 164 err += sn9c102_i2c_write(cam, 0x3A, 0x00);
165 err += sn9c102_i2c_write(cam, 0x3B, 0x02); 165 err += sn9c102_i2c_write(cam, 0x3B, 0x0A);
166 err += sn9c102_i2c_write(cam, 0x3C, 0x6C); 166 err += sn9c102_i2c_write(cam, 0x3C, 0x6C);
167 err += sn9c102_i2c_write(cam, 0x3D, 0x99); 167 err += sn9c102_i2c_write(cam, 0x3D, 0x99);
168 err += sn9c102_i2c_write(cam, 0x3E, 0x0E); 168 err += sn9c102_i2c_write(cam, 0x3E, 0x0E);
@@ -281,25 +281,34 @@ static int ov7660_get_ctrl(struct sn9c102_device* cam,
281 return -EIO; 281 return -EIO;
282 break; 282 break;
283 case V4L2_CID_DO_WHITE_BALANCE: 283 case V4L2_CID_DO_WHITE_BALANCE:
284 ctrl->value = sn9c102_pread_reg(cam, 0x02); 284 if ((ctrl->value = sn9c102_read_reg(cam, 0x02)) < 0)
285 return -EIO;
285 ctrl->value = (ctrl->value & 0x04) ? 1 : 0; 286 ctrl->value = (ctrl->value & 0x04) ? 1 : 0;
286 break; 287 break;
287 case V4L2_CID_RED_BALANCE: 288 case V4L2_CID_RED_BALANCE:
288 ctrl->value = sn9c102_pread_reg(cam, 0x05); 289 if ((ctrl->value = sn9c102_read_reg(cam, 0x05)) < 0)
290 return -EIO;
289 ctrl->value &= 0x7f; 291 ctrl->value &= 0x7f;
290 break; 292 break;
291 case V4L2_CID_BLUE_BALANCE: 293 case V4L2_CID_BLUE_BALANCE:
292 ctrl->value = sn9c102_pread_reg(cam, 0x06); 294 if ((ctrl->value = sn9c102_read_reg(cam, 0x06)) < 0)
295 return -EIO;
293 ctrl->value &= 0x7f; 296 ctrl->value &= 0x7f;
294 break; 297 break;
295 case SN9C102_V4L2_CID_GREEN_BALANCE: 298 case SN9C102_V4L2_CID_GREEN_BALANCE:
296 ctrl->value = sn9c102_pread_reg(cam, 0x07); 299 if ((ctrl->value = sn9c102_read_reg(cam, 0x07)) < 0)
300 return -EIO;
297 ctrl->value &= 0x7f; 301 ctrl->value &= 0x7f;
298 break; 302 break;
303 case SN9C102_V4L2_CID_BAND_FILTER:
304 if ((ctrl->value = sn9c102_i2c_read(cam, 0x3b)) < 0)
305 return -EIO;
306 ctrl->value &= 0x08;
307 break;
299 case V4L2_CID_GAIN: 308 case V4L2_CID_GAIN:
300 if ((ctrl->value = sn9c102_i2c_read(cam, 0x00)) < 0) 309 if ((ctrl->value = sn9c102_i2c_read(cam, 0x00)) < 0)
301 return -EIO; 310 return -EIO;
302 ctrl->value &= 0x7f; 311 ctrl->value &= 0x1f;
303 break; 312 break;
304 case V4L2_CID_AUTOGAIN: 313 case V4L2_CID_AUTOGAIN:
305 if ((ctrl->value = sn9c102_i2c_read(cam, 0x13)) < 0) 314 if ((ctrl->value = sn9c102_i2c_read(cam, 0x13)) < 0)
@@ -335,12 +344,15 @@ static int ov7660_set_ctrl(struct sn9c102_device* cam,
335 case SN9C102_V4L2_CID_GREEN_BALANCE: 344 case SN9C102_V4L2_CID_GREEN_BALANCE:
336 err += sn9c102_write_reg(cam, ctrl->value, 0x07); 345 err += sn9c102_write_reg(cam, ctrl->value, 0x07);
337 break; 346 break;
347 case SN9C102_V4L2_CID_BAND_FILTER:
348 err += sn9c102_i2c_write(cam, ctrl->value << 3, 0x3b);
349 break;
338 case V4L2_CID_GAIN: 350 case V4L2_CID_GAIN:
339 err += sn9c102_i2c_write(cam, 0x00, ctrl->value); 351 err += sn9c102_i2c_write(cam, 0x00, 0x60 + ctrl->value);
340 break; 352 break;
341 case V4L2_CID_AUTOGAIN: 353 case V4L2_CID_AUTOGAIN:
342 err += sn9c102_i2c_write(cam, 0x13, 0xf0 | ctrl->value | 354 err += sn9c102_i2c_write(cam, 0x13, 0xc0 |
343 (ctrl->value << 1)); 355 (ctrl->value * 0x07));
344 break; 356 break;
345 default: 357 default:
346 return -EINVAL; 358 return -EINVAL;
@@ -386,7 +398,7 @@ static int ov7660_set_pix_format(struct sn9c102_device* cam,
386} 398}
387 399
388 400
389static struct sn9c102_sensor ov7660 = { 401static const struct sn9c102_sensor ov7660 = {
390 .name = "OV7660", 402 .name = "OV7660",
391 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 403 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
392 .supported_bridge = BRIDGE_SN9C105 | BRIDGE_SN9C120, 404 .supported_bridge = BRIDGE_SN9C105 | BRIDGE_SN9C120,
@@ -401,9 +413,9 @@ static struct sn9c102_sensor ov7660 = {
401 .type = V4L2_CTRL_TYPE_INTEGER, 413 .type = V4L2_CTRL_TYPE_INTEGER,
402 .name = "global gain", 414 .name = "global gain",
403 .minimum = 0x00, 415 .minimum = 0x00,
404 .maximum = 0x7f, 416 .maximum = 0x1f,
405 .step = 0x01, 417 .step = 0x01,
406 .default_value = 0x0a, 418 .default_value = 0x09,
407 .flags = 0, 419 .flags = 0,
408 }, 420 },
409 { 421 {
@@ -413,7 +425,7 @@ static struct sn9c102_sensor ov7660 = {
413 .minimum = 0x00, 425 .minimum = 0x00,
414 .maximum = 0xff, 426 .maximum = 0xff,
415 .step = 0x01, 427 .step = 0x01,
416 .default_value = 0x50, 428 .default_value = 0x27,
417 .flags = 0, 429 .flags = 0,
418 }, 430 },
419 { 431 {
@@ -433,7 +445,7 @@ static struct sn9c102_sensor ov7660 = {
433 .minimum = 0x00, 445 .minimum = 0x00,
434 .maximum = 0x7f, 446 .maximum = 0x7f,
435 .step = 0x01, 447 .step = 0x01,
436 .default_value = 0x1f, 448 .default_value = 0x14,
437 .flags = 0, 449 .flags = 0,
438 }, 450 },
439 { 451 {
@@ -443,7 +455,7 @@ static struct sn9c102_sensor ov7660 = {
443 .minimum = 0x00, 455 .minimum = 0x00,
444 .maximum = 0x7f, 456 .maximum = 0x7f,
445 .step = 0x01, 457 .step = 0x01,
446 .default_value = 0x1e, 458 .default_value = 0x14,
447 .flags = 0, 459 .flags = 0,
448 }, 460 },
449 { 461 {
@@ -453,7 +465,7 @@ static struct sn9c102_sensor ov7660 = {
453 .minimum = 0x00, 465 .minimum = 0x00,
454 .maximum = 0x01, 466 .maximum = 0x01,
455 .step = 0x01, 467 .step = 0x01,
456 .default_value = 0x00, 468 .default_value = 0x01,
457 .flags = 0, 469 .flags = 0,
458 }, 470 },
459 { 471 {
@@ -463,7 +475,17 @@ static struct sn9c102_sensor ov7660 = {
463 .minimum = 0x00, 475 .minimum = 0x00,
464 .maximum = 0x7f, 476 .maximum = 0x7f,
465 .step = 0x01, 477 .step = 0x01,
466 .default_value = 0x20, 478 .default_value = 0x14,
479 .flags = 0,
480 },
481 {
482 .id = SN9C102_V4L2_CID_BAND_FILTER,
483 .type = V4L2_CTRL_TYPE_BOOLEAN,
484 .name = "band filter",
485 .minimum = 0x00,
486 .maximum = 0x01,
487 .step = 0x01,
488 .default_value = 0x00,
467 .flags = 0, 489 .flags = 0,
468 }, 490 },
469 }, 491 },
@@ -508,6 +530,7 @@ int sn9c102_probe_ov7660(struct sn9c102_device* cam)
508 return -EIO; 530 return -EIO;
509 if (pid != 0x76 || ver != 0x60) 531 if (pid != 0x76 || ver != 0x60)
510 return -ENODEV; 532 return -ENODEV;
533
511 sn9c102_attach_sensor(cam, &ov7660); 534 sn9c102_attach_sensor(cam, &ov7660);
512 535
513 return 0; 536 return 0;
diff --git a/drivers/media/video/sn9c102/sn9c102_pas106b.c b/drivers/media/video/sn9c102/sn9c102_pas106b.c
index 67151964801f..360f2a848bc0 100644
--- a/drivers/media/video/sn9c102/sn9c102_pas106b.c
+++ b/drivers/media/video/sn9c102/sn9c102_pas106b.c
@@ -163,7 +163,7 @@ static int pas106b_set_pix_format(struct sn9c102_device* cam,
163} 163}
164 164
165 165
166static struct sn9c102_sensor pas106b = { 166static const struct sn9c102_sensor pas106b = {
167 .name = "PAS106B", 167 .name = "PAS106B",
168 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 168 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
169 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, 169 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102,
@@ -273,23 +273,21 @@ static struct sn9c102_sensor pas106b = {
273 273
274int sn9c102_probe_pas106b(struct sn9c102_device* cam) 274int sn9c102_probe_pas106b(struct sn9c102_device* cam)
275{ 275{
276 int r0 = 0, r1 = 0, err; 276 int r0 = 0, r1 = 0;
277 unsigned int pid = 0; 277 unsigned int pid = 0;
278 278
279 /* 279 /*
280 Minimal initialization to enable the I2C communication 280 Minimal initialization to enable the I2C communication
281 NOTE: do NOT change the values! 281 NOTE: do NOT change the values!
282 */ 282 */
283 err = sn9c102_write_const_regs(cam, 283 if (sn9c102_write_const_regs(cam,
284 {0x01, 0x01}, /* sensor power down */ 284 {0x01, 0x01}, /* sensor power down */
285 {0x00, 0x01}, /* sensor power on */ 285 {0x00, 0x01}, /* sensor power on */
286 {0x28, 0x17});/* sensor clock 24 MHz */ 286 {0x28, 0x17})) /* sensor clock at 24 MHz */
287 if (err)
288 return -EIO; 287 return -EIO;
289 288
290 r0 = sn9c102_i2c_try_read(cam, &pas106b, 0x00); 289 r0 = sn9c102_i2c_try_read(cam, &pas106b, 0x00);
291 r1 = sn9c102_i2c_try_read(cam, &pas106b, 0x01); 290 r1 = sn9c102_i2c_try_read(cam, &pas106b, 0x01);
292
293 if (r0 < 0 || r1 < 0) 291 if (r0 < 0 || r1 < 0)
294 return -EIO; 292 return -EIO;
295 293
diff --git a/drivers/media/video/sn9c102/sn9c102_pas202bcb.c b/drivers/media/video/sn9c102/sn9c102_pas202bcb.c
index c1b8d6b63b47..ca4a1506ed3d 100644
--- a/drivers/media/video/sn9c102/sn9c102_pas202bcb.c
+++ b/drivers/media/video/sn9c102/sn9c102_pas202bcb.c
@@ -35,29 +35,28 @@ static int pas202bcb_init(struct sn9c102_device* cam)
35 switch (sn9c102_get_bridge(cam)) { 35 switch (sn9c102_get_bridge(cam)) {
36 case BRIDGE_SN9C101: 36 case BRIDGE_SN9C101:
37 case BRIDGE_SN9C102: 37 case BRIDGE_SN9C102:
38 err = sn9c102_write_const_regs(cam, {0x00, 0x10}, 38 err = sn9c102_write_const_regs(cam, {0x00, 0x10}, {0x00, 0x11},
39 {0x00, 0x11}, {0x00, 0x14}, 39 {0x00, 0x14}, {0x20, 0x17},
40 {0x20, 0x17}, {0x30, 0x19}, 40 {0x30, 0x19}, {0x09, 0x18});
41 {0x09, 0x18});
42 break; 41 break;
43 case BRIDGE_SN9C103: 42 case BRIDGE_SN9C103:
44 err = sn9c102_write_const_regs(cam, {0x00, 0x02}, 43 err = sn9c102_write_const_regs(cam, {0x00, 0x02}, {0x00, 0x03},
45 {0x00, 0x03}, {0x1a, 0x04}, 44 {0x1a, 0x04}, {0x20, 0x05},
46 {0x20, 0x05}, {0x20, 0x06}, 45 {0x20, 0x06}, {0x20, 0x07},
47 {0x20, 0x07}, {0x00, 0x10}, 46 {0x00, 0x10}, {0x00, 0x11},
48 {0x00, 0x11}, {0x00, 0x14}, 47 {0x00, 0x14}, {0x20, 0x17},
49 {0x20, 0x17}, {0x30, 0x19}, 48 {0x30, 0x19}, {0x09, 0x18},
50 {0x09, 0x18}, {0x02, 0x1c}, 49 {0x02, 0x1c}, {0x03, 0x1d},
51 {0x03, 0x1d}, {0x0f, 0x1e}, 50 {0x0f, 0x1e}, {0x0c, 0x1f},
52 {0x0c, 0x1f}, {0x00, 0x20}, 51 {0x00, 0x20}, {0x10, 0x21},
53 {0x10, 0x21}, {0x20, 0x22}, 52 {0x20, 0x22}, {0x30, 0x23},
54 {0x30, 0x23}, {0x40, 0x24}, 53 {0x40, 0x24}, {0x50, 0x25},
55 {0x50, 0x25}, {0x60, 0x26}, 54 {0x60, 0x26}, {0x70, 0x27},
56 {0x70, 0x27}, {0x80, 0x28}, 55 {0x80, 0x28}, {0x90, 0x29},
57 {0x90, 0x29}, {0xa0, 0x2a}, 56 {0xa0, 0x2a}, {0xb0, 0x2b},
58 {0xb0, 0x2b}, {0xc0, 0x2c}, 57 {0xc0, 0x2c}, {0xd0, 0x2d},
59 {0xd0, 0x2d}, {0xe0, 0x2e}, 58 {0xe0, 0x2e}, {0xf0, 0x2f},
60 {0xf0, 0x2f}, {0xff, 0x30}); 59 {0xff, 0x30});
61 break; 60 break;
62 default: 61 default:
63 break; 62 break;
@@ -197,7 +196,7 @@ static int pas202bcb_set_crop(struct sn9c102_device* cam,
197} 196}
198 197
199 198
200static struct sn9c102_sensor pas202bcb = { 199static const struct sn9c102_sensor pas202bcb = {
201 .name = "PAS202BCB", 200 .name = "PAS202BCB",
202 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 201 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
203 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103, 202 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102 | BRIDGE_SN9C103,
@@ -313,9 +312,8 @@ int sn9c102_probe_pas202bcb(struct sn9c102_device* cam)
313 {0x28, 0x17});/* clock 24 MHz */ 312 {0x28, 0x17});/* clock 24 MHz */
314 break; 313 break;
315 case BRIDGE_SN9C103: /* do _not_ change anything! */ 314 case BRIDGE_SN9C103: /* do _not_ change anything! */
316 err = sn9c102_write_const_regs(cam, {0x09, 0x01}, 315 err = sn9c102_write_const_regs(cam, {0x09, 0x01}, {0x44, 0x01},
317 {0x44, 0x01}, {0x44, 0x02}, 316 {0x44, 0x02}, {0x29, 0x17});
318 {0x29, 0x17});
319 break; 317 break;
320 default: 318 default:
321 break; 319 break;
diff --git a/drivers/media/video/sn9c102/sn9c102_sensor.h b/drivers/media/video/sn9c102/sn9c102_sensor.h
index 1bbf64c897a2..2d7d786b8430 100644
--- a/drivers/media/video/sn9c102/sn9c102_sensor.h
+++ b/drivers/media/video/sn9c102/sn9c102_sensor.h
@@ -22,7 +22,7 @@
22#define _SN9C102_SENSOR_H_ 22#define _SN9C102_SENSOR_H_
23 23
24#include <linux/usb.h> 24#include <linux/usb.h>
25#include <linux/videodev.h> 25#include <linux/videodev2.h>
26#include <linux/device.h> 26#include <linux/device.h>
27#include <linux/stddef.h> 27#include <linux/stddef.h>
28#include <linux/errno.h> 28#include <linux/errno.h>
@@ -74,7 +74,7 @@ sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id);
74/* Attach a probed sensor to the camera. */ 74/* Attach a probed sensor to the camera. */
75extern void 75extern void
76sn9c102_attach_sensor(struct sn9c102_device* cam, 76sn9c102_attach_sensor(struct sn9c102_device* cam,
77 struct sn9c102_sensor* sensor); 77 const struct sn9c102_sensor* sensor);
78 78
79/* 79/*
80 Read/write routines: they always return -1 on error, 0 or the read value 80 Read/write routines: they always return -1 on error, 0 or the read value
@@ -85,10 +85,11 @@ sn9c102_attach_sensor(struct sn9c102_device* cam,
85*/ 85*/
86 86
87/* The "try" I2C I/O versions are used when probing the sensor */ 87/* The "try" I2C I/O versions are used when probing the sensor */
88extern int sn9c102_i2c_try_write(struct sn9c102_device*,struct sn9c102_sensor*, 88extern int sn9c102_i2c_try_write(struct sn9c102_device*,
89 u8 address, u8 value); 89 const struct sn9c102_sensor*, u8 address,
90extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*, 90 u8 value);
91 u8 address); 91extern int sn9c102_i2c_try_read(struct sn9c102_device*,
92 const struct sn9c102_sensor*, u8 address);
92 93
93/* 94/*
94 These must be used if and only if the sensor doesn't implement the standard 95 These must be used if and only if the sensor doesn't implement the standard
@@ -102,29 +103,31 @@ extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*,
102 byte. 103 byte.
103*/ 104*/
104extern int sn9c102_i2c_try_raw_write(struct sn9c102_device* cam, 105extern int sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
105 struct sn9c102_sensor* sensor, u8 n, 106 const struct sn9c102_sensor* sensor, u8 n,
106 u8 data0, u8 data1, u8 data2, u8 data3, 107 u8 data0, u8 data1, u8 data2, u8 data3,
107 u8 data4, u8 data5); 108 u8 data4, u8 data5);
108extern int sn9c102_i2c_try_raw_read(struct sn9c102_device* cam, 109extern int sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
109 struct sn9c102_sensor* sensor, u8 data0, 110 const struct sn9c102_sensor* sensor,
110 u8 data1, u8 n, u8 buffer[]); 111 u8 data0, u8 data1, u8 n, u8 buffer[]);
111 112
112/* To be used after the sensor struct has been attached to the camera struct */ 113/* To be used after the sensor struct has been attached to the camera struct */
113extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value); 114extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value);
114extern int sn9c102_i2c_read(struct sn9c102_device*, u8 address); 115extern int sn9c102_i2c_read(struct sn9c102_device*, u8 address);
115 116
116/* I/O on registers in the bridge. Could be used by the sensor methods too */ 117/* I/O on registers in the bridge. Could be used by the sensor methods too */
118extern int sn9c102_read_reg(struct sn9c102_device*, u16 index);
117extern int sn9c102_pread_reg(struct sn9c102_device*, u16 index); 119extern int sn9c102_pread_reg(struct sn9c102_device*, u16 index);
118extern int sn9c102_write_reg(struct sn9c102_device*, u8 value, u16 index); 120extern int sn9c102_write_reg(struct sn9c102_device*, u8 value, u16 index);
119extern int sn9c102_write_regs(struct sn9c102_device*, const u8 valreg[][2], 121extern int sn9c102_write_regs(struct sn9c102_device*, const u8 valreg[][2],
120 int count); 122 int count);
121/* 123/*
122 * Write multiple registers with constant values. For example: 124 Write multiple registers with constant values. For example:
123 * sn9c102_write_const_regs(cam, {0x00, 0x14}, {0x60, 0x17}, {0x0f, 0x18}); 125 sn9c102_write_const_regs(cam, {0x00, 0x14}, {0x60, 0x17}, {0x0f, 0x18});
124 */ 126 Register adresses must be < 256.
125#define sn9c102_write_const_regs(device, data...) \ 127*/
126 ({ const static u8 _data[][2] = {data}; \ 128#define sn9c102_write_const_regs(sn9c102_device, data...) \
127 sn9c102_write_regs(device, _data, ARRAY_SIZE(_data)); }) 129 ({ const static u8 _valreg[][2] = {data}; \
130 sn9c102_write_regs(sn9c102_device, _valreg, ARRAY_SIZE(_valreg)); })
128 131
129/*****************************************************************************/ 132/*****************************************************************************/
130 133
diff --git a/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c b/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c
index 0e7ec8662c70..e7d2de2bace1 100644
--- a/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c
+++ b/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c
@@ -88,7 +88,7 @@ static int tas5110c1b_set_pix_format(struct sn9c102_device* cam,
88} 88}
89 89
90 90
91static struct sn9c102_sensor tas5110c1b = { 91static const struct sn9c102_sensor tas5110c1b = {
92 .name = "TAS5110C1B", 92 .name = "TAS5110C1B",
93 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 93 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
94 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, 94 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102,
diff --git a/drivers/media/video/sn9c102/sn9c102_tas5110d.c b/drivers/media/video/sn9c102/sn9c102_tas5110d.c
index 83a39e8b5e71..d32fdbccdc5e 100644
--- a/drivers/media/video/sn9c102/sn9c102_tas5110d.c
+++ b/drivers/media/video/sn9c102/sn9c102_tas5110d.c
@@ -68,7 +68,7 @@ static int tas5110d_set_pix_format(struct sn9c102_device* cam,
68} 68}
69 69
70 70
71static struct sn9c102_sensor tas5110d = { 71static const struct sn9c102_sensor tas5110d = {
72 .name = "TAS5110D", 72 .name = "TAS5110D",
73 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 73 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
74 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, 74 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102,
diff --git a/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c b/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c
index 50406503fc40..56fb1d575a8a 100644
--- a/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c
+++ b/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c
@@ -89,7 +89,7 @@ static int tas5130d1b_set_pix_format(struct sn9c102_device* cam,
89} 89}
90 90
91 91
92static struct sn9c102_sensor tas5130d1b = { 92static const struct sn9c102_sensor tas5130d1b = {
93 .name = "TAS5130D1B", 93 .name = "TAS5130D1B",
94 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>", 94 .maintainer = "Luca Risolia <luca.risolia@studio.unibo.it>",
95 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102, 95 .supported_bridge = BRIDGE_SN9C101 | BRIDGE_SN9C102,
diff --git a/drivers/media/video/usbvideo/Kconfig b/drivers/media/video/usbvideo/Kconfig
index a0fd82b924f2..e4cb99c1f94b 100644
--- a/drivers/media/video/usbvideo/Kconfig
+++ b/drivers/media/video/usbvideo/Kconfig
@@ -3,7 +3,7 @@ config VIDEO_USBVIDEO
3 3
4config USB_VICAM 4config USB_VICAM
5 tristate "USB 3com HomeConnect (aka vicam) support (EXPERIMENTAL)" 5 tristate "USB 3com HomeConnect (aka vicam) support (EXPERIMENTAL)"
6 depends on USB && VIDEO_DEV && VIDEO_V4L1 && EXPERIMENTAL 6 depends on VIDEO_V4L1 && EXPERIMENTAL
7 select VIDEO_USBVIDEO 7 select VIDEO_USBVIDEO
8 ---help--- 8 ---help---
9 Say Y here if you have 3com homeconnect camera (vicam). 9 Say Y here if you have 3com homeconnect camera (vicam).
@@ -13,7 +13,7 @@ config USB_VICAM
13 13
14config USB_IBMCAM 14config USB_IBMCAM
15 tristate "USB IBM (Xirlink) C-it Camera support" 15 tristate "USB IBM (Xirlink) C-it Camera support"
16 depends on USB && VIDEO_DEV && VIDEO_V4L1 16 depends on VIDEO_V4L1
17 select VIDEO_USBVIDEO 17 select VIDEO_USBVIDEO
18 ---help--- 18 ---help---
19 Say Y here if you want to connect a IBM "C-It" camera, also known as 19 Say Y here if you want to connect a IBM "C-It" camera, also known as
@@ -28,7 +28,7 @@ config USB_IBMCAM
28 28
29config USB_KONICAWC 29config USB_KONICAWC
30 tristate "USB Konica Webcam support" 30 tristate "USB Konica Webcam support"
31 depends on USB && VIDEO_DEV && VIDEO_V4L1 31 depends on VIDEO_V4L1
32 select VIDEO_USBVIDEO 32 select VIDEO_USBVIDEO
33 ---help--- 33 ---help---
34 Say Y here if you want support for webcams based on a Konica 34 Say Y here if you want support for webcams based on a Konica
@@ -39,7 +39,7 @@ config USB_KONICAWC
39 39
40config USB_QUICKCAM_MESSENGER 40config USB_QUICKCAM_MESSENGER
41 tristate "USB Logitech Quickcam Messenger" 41 tristate "USB Logitech Quickcam Messenger"
42 depends on USB && VIDEO_DEV && VIDEO_V4L1 42 depends on VIDEO_V4L1
43 select VIDEO_USBVIDEO 43 select VIDEO_USBVIDEO
44 ---help--- 44 ---help---
45 Say Y or M here to enable support for the USB Logitech Quickcam 45 Say Y or M here to enable support for the USB Logitech Quickcam
diff --git a/drivers/media/video/usbvision/Kconfig b/drivers/media/video/usbvision/Kconfig
index c43a5d899091..fc24ef05b3f3 100644
--- a/drivers/media/video/usbvision/Kconfig
+++ b/drivers/media/video/usbvision/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_USBVISION 1config VIDEO_USBVISION
2 tristate "USB video devices based on Nogatech NT1003/1004/1005" 2 tristate "USB video devices based on Nogatech NT1003/1004/1005"
3 depends on I2C && VIDEO_V4L2 && USB 3 depends on I2C && VIDEO_V4L2
4 select VIDEO_TUNER 4 select VIDEO_TUNER
5 select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO 5 select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO
6 ---help--- 6 ---help---
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c
index a861e150865e..ede8543818bf 100644
--- a/drivers/media/video/v4l1-compat.c
+++ b/drivers/media/video/v4l1-compat.c
@@ -127,7 +127,7 @@ set_v4l_control(struct inode *inode,
127 127
128/* ----------------------------------------------------------------- */ 128/* ----------------------------------------------------------------- */
129 129
130static int palette2pixelformat[] = { 130const static unsigned int palette2pixelformat[] = {
131 [VIDEO_PALETTE_GREY] = V4L2_PIX_FMT_GREY, 131 [VIDEO_PALETTE_GREY] = V4L2_PIX_FMT_GREY,
132 [VIDEO_PALETTE_RGB555] = V4L2_PIX_FMT_RGB555, 132 [VIDEO_PALETTE_RGB555] = V4L2_PIX_FMT_RGB555,
133 [VIDEO_PALETTE_RGB565] = V4L2_PIX_FMT_RGB565, 133 [VIDEO_PALETTE_RGB565] = V4L2_PIX_FMT_RGB565,
@@ -145,7 +145,7 @@ static int palette2pixelformat[] = {
145 [VIDEO_PALETTE_YUV422P] = V4L2_PIX_FMT_YUV422P, 145 [VIDEO_PALETTE_YUV422P] = V4L2_PIX_FMT_YUV422P,
146}; 146};
147 147
148static unsigned int 148static unsigned int __attribute_pure__
149palette_to_pixelformat(unsigned int palette) 149palette_to_pixelformat(unsigned int palette)
150{ 150{
151 if (palette < ARRAY_SIZE(palette2pixelformat)) 151 if (palette < ARRAY_SIZE(palette2pixelformat))
@@ -154,8 +154,8 @@ palette_to_pixelformat(unsigned int palette)
154 return 0; 154 return 0;
155} 155}
156 156
157static unsigned int 157static unsigned int __attribute_const__
158pixelformat_to_palette(int pixelformat) 158pixelformat_to_palette(unsigned int pixelformat)
159{ 159{
160 int palette = 0; 160 int palette = 0;
161 switch (pixelformat) 161 switch (pixelformat)
@@ -616,6 +616,8 @@ v4l_compat_translate_ioctl(struct inode *inode,
616 case VIDIOCSPICT: /* set tone controls & partial capture format */ 616 case VIDIOCSPICT: /* set tone controls & partial capture format */
617 { 617 {
618 struct video_picture *pict = arg; 618 struct video_picture *pict = arg;
619 int mem_err = 0, ovl_err = 0;
620
619 memset(&fbuf2, 0, sizeof(fbuf2)); 621 memset(&fbuf2, 0, sizeof(fbuf2));
620 622
621 set_v4l_control(inode, file, 623 set_v4l_control(inode, file,
@@ -628,33 +630,59 @@ v4l_compat_translate_ioctl(struct inode *inode,
628 V4L2_CID_SATURATION, pict->colour, drv); 630 V4L2_CID_SATURATION, pict->colour, drv);
629 set_v4l_control(inode, file, 631 set_v4l_control(inode, file,
630 V4L2_CID_WHITENESS, pict->whiteness, drv); 632 V4L2_CID_WHITENESS, pict->whiteness, drv);
633 /*
634 * V4L1 uses this ioctl to set both memory capture and overlay
635 * pixel format, while V4L2 has two different ioctls for this.
636 * Some cards may not support one or the other, and may support
637 * different pixel formats for memory vs overlay.
638 */
631 639
632 fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL); 640 fmt2 = kzalloc(sizeof(*fmt2),GFP_KERNEL);
633 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 641 fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
634 err = drv(inode, file, VIDIOC_G_FMT, fmt2); 642 err = drv(inode, file, VIDIOC_G_FMT, fmt2);
635 if (err < 0) 643 /* If VIDIOC_G_FMT failed, then the driver likely doesn't
644 support memory capture. Trying to set the memory capture
645 parameters would be pointless. */
646 if (err < 0) {
636 dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %d\n",err); 647 dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %d\n",err);
637 if (fmt2->fmt.pix.pixelformat != 648 mem_err = -1000; /* didn't even try */
638 palette_to_pixelformat(pict->palette)) { 649 } else if (fmt2->fmt.pix.pixelformat !=
650 palette_to_pixelformat(pict->palette)) {
639 fmt2->fmt.pix.pixelformat = palette_to_pixelformat( 651 fmt2->fmt.pix.pixelformat = palette_to_pixelformat(
640 pict->palette); 652 pict->palette);
641 err = drv(inode, file, VIDIOC_S_FMT, fmt2); 653 mem_err = drv(inode, file, VIDIOC_S_FMT, fmt2);
642 if (err < 0) 654 if (mem_err < 0)
643 dprintk("VIDIOCSPICT / VIDIOC_S_FMT: %d\n",err); 655 dprintk("VIDIOCSPICT / VIDIOC_S_FMT: %d\n",
656 mem_err);
644 } 657 }
645 658
646 err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2); 659 err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2);
647 if (err < 0) 660 /* If VIDIOC_G_FBUF failed, then the driver likely doesn't
661 support overlay. Trying to set the overlay parameters
662 would be quite pointless. */
663 if (err < 0) {
648 dprintk("VIDIOCSPICT / VIDIOC_G_FBUF: %d\n",err); 664 dprintk("VIDIOCSPICT / VIDIOC_G_FBUF: %d\n",err);
649 if (fbuf2.fmt.pixelformat != 665 ovl_err = -1000; /* didn't even try */
650 palette_to_pixelformat(pict->palette)) { 666 } else if (fbuf2.fmt.pixelformat !=
667 palette_to_pixelformat(pict->palette)) {
651 fbuf2.fmt.pixelformat = palette_to_pixelformat( 668 fbuf2.fmt.pixelformat = palette_to_pixelformat(
652 pict->palette); 669 pict->palette);
653 err = drv(inode, file, VIDIOC_S_FBUF, &fbuf2); 670 ovl_err = drv(inode, file, VIDIOC_S_FBUF, &fbuf2);
654 if (err < 0) 671 if (ovl_err < 0)
655 dprintk("VIDIOCSPICT / VIDIOC_S_FBUF: %d\n",err); 672 dprintk("VIDIOCSPICT / VIDIOC_S_FBUF: %d\n",
656 err = 0; /* likely fails for non-root */ 673 ovl_err);
657 } 674 }
675 if (ovl_err < 0 && mem_err < 0)
676 /* ioctl failed, couldn't set either parameter */
677 if (mem_err != -1000) {
678 err = mem_err;
679 } else if (ovl_err == -EPERM) {
680 err = 0;
681 } else {
682 err = ovl_err;
683 }
684 else
685 err = 0;
658 break; 686 break;
659 } 687 }
660 case VIDIOCGTUNER: /* get tuner information */ 688 case VIDIOCGTUNER: /* get tuner information */
diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c
index 459786ff459a..a32dfbe0585a 100644
--- a/drivers/media/video/video-buf.c
+++ b/drivers/media/video/video-buf.c
@@ -702,9 +702,7 @@ videobuf_qbuf(struct videobuf_queue *q,
702 dprintk(1,"qbuf: memory type is wrong.\n"); 702 dprintk(1,"qbuf: memory type is wrong.\n");
703 goto done; 703 goto done;
704 } 704 }
705 if (buf->state == STATE_QUEUED || 705 if (buf->state != STATE_NEEDS_INIT && buf->state != STATE_IDLE) {
706 buf->state == STATE_PREPARED ||
707 buf->state == STATE_ACTIVE) {
708 dprintk(1,"qbuf: buffer is already queued or active.\n"); 706 dprintk(1,"qbuf: buffer is already queued or active.\n");
709 goto done; 707 goto done;
710 } 708 }
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 5263b50463e1..b876aca69c73 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -433,13 +433,43 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
433 int ret = -EINVAL; 433 int ret = -EINVAL;
434 434
435 if ( (vfd->debug & V4L2_DEBUG_IOCTL) && 435 if ( (vfd->debug & V4L2_DEBUG_IOCTL) &&
436 !(vfd->debug | V4L2_DEBUG_IOCTL_ARG)) { 436 !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) {
437 v4l_print_ioctl(vfd->name, cmd); 437 v4l_print_ioctl(vfd->name, cmd);
438 } 438 }
439 439
440#ifdef CONFIG_VIDEO_V4L1_COMPAT
441 /***********************************************************
442 Handles calls to the obsoleted V4L1 API
443 Due to the nature of VIDIOCGMBUF, each driver that supports
444 V4L1 should implement its own handler for this ioctl.
445 ***********************************************************/
446
447 /* --- streaming capture ------------------------------------- */
448 if (cmd == VIDIOCGMBUF) {
449 struct video_mbuf *p=arg;
450
451 memset(p,0,sizeof(p));
452
453 if (!vfd->vidiocgmbuf)
454 return ret;
455 ret=vfd->vidiocgmbuf(file, fh, p);
456 if (!ret)
457 dbgarg (cmd, "size=%d, frames=%d, offsets=0x%08lx\n",
458 p->size, p->frames,
459 (unsigned long)p->offsets);
460 return ret;
461 }
462
463 /********************************************************
464 All other V4L1 calls are handled by v4l1_compat module.
465 Those calls will be translated into V4L2 calls, and
466 __video_do_ioctl will be called again, with one or more
467 V4L2 ioctls.
468 ********************************************************/
440 if (_IOC_TYPE(cmd)=='v') 469 if (_IOC_TYPE(cmd)=='v')
441 return v4l_compat_translate_ioctl(inode,file,cmd,arg, 470 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
442 __video_do_ioctl); 471 __video_do_ioctl);
472#endif
443 473
444 switch(cmd) { 474 switch(cmd) {
445 /* --- capabilities ------------------------------------------ */ 475 /* --- capabilities ------------------------------------------ */
@@ -791,24 +821,6 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
791 ret=vfd->vidioc_overlay(file, fh, *i); 821 ret=vfd->vidioc_overlay(file, fh, *i);
792 break; 822 break;
793 } 823 }
794#ifdef CONFIG_VIDEO_V4L1_COMPAT
795 /* --- streaming capture ------------------------------------- */
796 case VIDIOCGMBUF:
797 {
798 struct video_mbuf *p=arg;
799
800 memset(p,0,sizeof(p));
801
802 if (!vfd->vidiocgmbuf)
803 break;
804 ret=vfd->vidiocgmbuf(file, fh, p);
805 if (!ret)
806 dbgarg (cmd, "size=%d, frames=%d, offsets=0x%08lx\n",
807 p->size, p->frames,
808 (unsigned long)p->offsets);
809 break;
810 }
811#endif
812 case VIDIOC_G_FBUF: 824 case VIDIOC_G_FBUF:
813 { 825 {
814 struct v4l2_framebuffer *p=arg; 826 struct v4l2_framebuffer *p=arg;
diff --git a/drivers/media/video/zc0301/Kconfig b/drivers/media/video/zc0301/Kconfig
index a859a6920189..47cd93f9c7de 100644
--- a/drivers/media/video/zc0301/Kconfig
+++ b/drivers/media/video/zc0301/Kconfig
@@ -1,6 +1,6 @@
1config USB_ZC0301 1config USB_ZC0301
2 tristate "USB ZC0301[P] Image Processor and Control Chip support" 2 tristate "USB ZC0301[P] Image Processor and Control Chip support"
3 depends on USB && VIDEO_V4L1 3 depends on VIDEO_V4L1
4 ---help--- 4 ---help---
5 Say Y here if you want support for cameras based on the ZC0301 or 5 Say Y here if you want support for cameras based on the ZC0301 or
6 ZC0301P Image Processors and Control Chips. 6 ZC0301P Image Processors and Control Chips.
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index fa489b10c38c..fb99cd445504 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1898,8 +1898,12 @@ endmenu
1898# Gigabit Ethernet 1898# Gigabit Ethernet
1899# 1899#
1900 1900
1901menu "Ethernet (1000 Mbit)" 1901menuconfig NETDEV_1000
1902 bool "Ethernet (1000 Mbit)"
1902 depends on !UML 1903 depends on !UML
1904 default y
1905
1906if NETDEV_1000
1903 1907
1904config ACENIC 1908config ACENIC
1905 tristate "Alteon AceNIC/3Com 3C985/NetGear GA620 Gigabit support" 1909 tristate "Alteon AceNIC/3Com 3C985/NetGear GA620 Gigabit support"
@@ -2299,7 +2303,7 @@ config UGETH_TX_ON_DEMAND
2299 2303
2300config MV643XX_ETH 2304config MV643XX_ETH
2301 tristate "MV-643XX Ethernet support" 2305 tristate "MV-643XX Ethernet support"
2302 depends on MOMENCO_OCELOT_C || MOMENCO_JAGUAR_ATX || MV64360 || MOMENCO_OCELOT_3 || (PPC_MULTIPLATFORM && PPC32) 2306 depends on MOMENCO_OCELOT_C || MOMENCO_JAGUAR_ATX || MV64360 || MV64X60 || MOMENCO_OCELOT_3 || (PPC_MULTIPLATFORM && PPC32)
2303 select MII 2307 select MII
2304 help 2308 help
2305 This driver supports the gigabit Ethernet on the Marvell MV643XX 2309 This driver supports the gigabit Ethernet on the Marvell MV643XX
@@ -2326,14 +2330,18 @@ config ATL1
2326 To compile this driver as a module, choose M here. The module 2330 To compile this driver as a module, choose M here. The module
2327 will be called atl1. 2331 will be called atl1.
2328 2332
2329endmenu 2333endif # NETDEV_1000
2330 2334
2331# 2335#
2332# 10 Gigabit Ethernet 2336# 10 Gigabit Ethernet
2333# 2337#
2334 2338
2335menu "Ethernet (10000 Mbit)" 2339menuconfig NETDEV_10000
2340 bool "Ethernet (10000 Mbit)"
2336 depends on !UML 2341 depends on !UML
2342 default y
2343
2344if NETDEV_10000
2337 2345
2338config CHELSIO_T1 2346config CHELSIO_T1
2339 tristate "Chelsio 10Gb Ethernet support" 2347 tristate "Chelsio 10Gb Ethernet support"
@@ -2507,7 +2515,7 @@ config MLX4_DEBUG
2507 debug_level module parameter (which can also be set after 2515 debug_level module parameter (which can also be set after
2508 the driver is loaded through sysfs). 2516 the driver is loaded through sysfs).
2509 2517
2510endmenu 2518endif # NETDEV_10000
2511 2519
2512source "drivers/net/tokenring/Kconfig" 2520source "drivers/net/tokenring/Kconfig"
2513 2521
diff --git a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig
index 7c8ccc09b601..829da9a1d113 100644
--- a/drivers/net/irda/Kconfig
+++ b/drivers/net/irda/Kconfig
@@ -141,6 +141,20 @@ config ACT200L_DONGLE
141 To activate support for ACTiSYS IR-200L dongle you will have to 141 To activate support for ACTiSYS IR-200L dongle you will have to
142 start irattach like this: "irattach -d act200l". 142 start irattach like this: "irattach -d act200l".
143 143
144config KINGSUN_DONGLE
145 tristate "KingSun/DonShine DS-620 IrDA-USB dongle"
146 depends on IRDA && USB && EXPERIMENTAL
147 help
148 Say Y or M here if you want to build support for the KingSun/DonShine
149 DS-620 IrDA-USB bridge device driver.
150
151 This USB bridge does not conform to the IrDA-USB device class
152 specification, and therefore needs its own specific driver. This
153 dongle supports SIR speed only (9600 bps).
154
155 To compile it as a module, choose M here: the module will be called
156 kingsun-sir.
157
144comment "Old SIR device drivers" 158comment "Old SIR device drivers"
145 159
146config IRPORT_SIR 160config IRPORT_SIR
diff --git a/drivers/net/irda/Makefile b/drivers/net/irda/Makefile
index 5be09f1b9ee2..233a2f923730 100644
--- a/drivers/net/irda/Makefile
+++ b/drivers/net/irda/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_MCP2120_DONGLE) += mcp2120-sir.o
45obj-$(CONFIG_ACT200L_DONGLE) += act200l-sir.o 45obj-$(CONFIG_ACT200L_DONGLE) += act200l-sir.o
46obj-$(CONFIG_MA600_DONGLE) += ma600-sir.o 46obj-$(CONFIG_MA600_DONGLE) += ma600-sir.o
47obj-$(CONFIG_TOIM3232_DONGLE) += toim3232-sir.o 47obj-$(CONFIG_TOIM3232_DONGLE) += toim3232-sir.o
48obj-$(CONFIG_KINGSUN_DONGLE) += kingsun-sir.o
48 49
49# The SIR helper module 50# The SIR helper module
50sir-dev-objs := sir_dev.o sir_dongle.o 51sir-dev-objs := sir_dev.o sir_dongle.o
diff --git a/drivers/net/irda/kingsun-sir.c b/drivers/net/irda/kingsun-sir.c
new file mode 100644
index 000000000000..217429122e79
--- /dev/null
+++ b/drivers/net/irda/kingsun-sir.c
@@ -0,0 +1,657 @@
1/*****************************************************************************
2*
3* Filename: kingsun-sir.c
4* Version: 0.1.1
5* Description: Irda KingSun/DonShine USB Dongle
6* Status: Experimental
7* Author: Alex Villac�s Lasso <a_villacis@palosanto.com>
8*
9* Based on stir4200 and mcs7780 drivers, with (strange?) differences
10*
11* This program is free software; you can redistribute it and/or modify
12* it under the terms of the GNU General Public License as published by
13* the Free Software Foundation; either version 2 of the License.
14*
15* This program is distributed in the hope that it will be useful,
16* but WITHOUT ANY WARRANTY; without even the implied warranty of
17* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18* GNU General Public License for more details.
19*
20* You should have received a copy of the GNU General Public License
21* along with this program; if not, write to the Free Software
22* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23*
24*****************************************************************************/
25
26/*
27 * This is my current (2007-04-25) understanding of how this dongle is supposed
28 * to work. This is based on reverse-engineering and examination of the packet
29 * data sent and received by the WinXP driver using USBSnoopy. Feel free to
30 * update here as more of this dongle is known:
31 *
32 * General: Unlike the other USB IrDA dongles, this particular dongle exposes,
33 * not two bulk (in and out) endpoints, but two *interrupt* ones. This dongle,
34 * like the bulk based ones (stir4200.c and mcs7780.c), requires polling in
35 * order to receive data.
36 * Transmission: Just like stir4200, this dongle uses a raw stream of data,
37 * which needs to be wrapped and escaped in a similar way as in stir4200.c.
38 * Reception: Poll-based, as in stir4200. Each read returns the contents of a
39 * 8-byte buffer, of which the first byte (LSB) indicates the number of bytes
40 * (1-7) of valid data contained within the remaining 7 bytes. For example, if
41 * the buffer had the following contents:
42 * 06 ff ff ff c0 01 04 aa
43 * This means that (06) there are 6 bytes of valid data. The byte 0xaa at the
44 * end is garbage (left over from a previous reception) and is discarded.
45 * If a read returns an "impossible" value as the length of valid data (such as
46 * 0x36) in the first byte, then the buffer is uninitialized (as is the case of
47 * first plug-in) and its contents should be discarded. There is currently no
48 * evidence that the top 5 bits of the 1st byte of the buffer can have values
49 * other than 0 once reception begins.
50 * Once valid bytes are collected, the assembled stream is a sequence of
51 * wrapped IrDA frames that is unwrapped and unescaped as in stir4200.c.
52 * BIG FAT WARNING: the dongle does *not* reset the RX buffer in any way after
53 * a successful read from the host, which means that in absence of further
54 * reception, repeated reads from the dongle will return the exact same
55 * contents repeatedly. Attempts to be smart and cache a previous read seem
56 * to result in corrupted packets, so this driver depends on the unwrap logic
57 * to sort out any repeated reads.
58 * Speed change: no commands observed so far to change speed, assumed fixed
59 * 9600bps (SIR).
60 */
61
62#include <linux/module.h>
63#include <linux/moduleparam.h>
64#include <linux/kernel.h>
65#include <linux/types.h>
66#include <linux/errno.h>
67#include <linux/init.h>
68#include <linux/slab.h>
69#include <linux/module.h>
70#include <linux/kref.h>
71#include <linux/usb.h>
72#include <linux/device.h>
73#include <linux/crc32.h>
74
75#include <asm/unaligned.h>
76#include <asm/byteorder.h>
77#include <asm/uaccess.h>
78
79#include <net/irda/irda.h>
80#include <net/irda/wrapper.h>
81#include <net/irda/crc.h>
82
83/*
84 * According to lsusb, 0x07c0 is assigned to
85 * "Code Mercenaries Hard- und Software GmbH"
86 */
87#define KING_VENDOR_ID 0x07c0
88#define KING_PRODUCT_ID 0x4200
89
90/* These are the currently known USB ids */
91static struct usb_device_id dongles[] = {
92 /* KingSun Co,Ltd IrDA/USB Bridge */
93 { USB_DEVICE(KING_VENDOR_ID, KING_PRODUCT_ID) },
94 { }
95};
96
97MODULE_DEVICE_TABLE(usb, dongles);
98
99#define KINGSUN_MTT 0x07
100
101#define KINGSUN_FIFO_SIZE 4096
102#define KINGSUN_EP_IN 0
103#define KINGSUN_EP_OUT 1
104
105struct kingsun_cb {
106 struct usb_device *usbdev; /* init: probe_irda */
107 struct net_device *netdev; /* network layer */
108 struct irlap_cb *irlap; /* The link layer we are binded to */
109 struct net_device_stats stats; /* network statistics */
110 struct qos_info qos;
111
112 __u8 *in_buf; /* receive buffer */
113 __u8 *out_buf; /* transmit buffer */
114 __u8 max_rx; /* max. atomic read from dongle
115 (usually 8), also size of in_buf */
116 __u8 max_tx; /* max. atomic write to dongle
117 (usually 8) */
118
119 iobuff_t rx_buff; /* receive unwrap state machine */
120 struct timeval rx_time;
121 spinlock_t lock;
122 int receiving;
123
124 __u8 ep_in;
125 __u8 ep_out;
126
127 struct urb *tx_urb;
128 struct urb *rx_urb;
129};
130
131/* Callback transmission routine */
132static void kingsun_send_irq(struct urb *urb)
133{
134 struct kingsun_cb *kingsun = urb->context;
135 struct net_device *netdev = kingsun->netdev;
136
137 /* in process of stopping, just drop data */
138 if (!netif_running(kingsun->netdev)) {
139 err("kingsun_send_irq: Network not running!");
140 return;
141 }
142
143 /* unlink, shutdown, unplug, other nasties */
144 if (urb->status != 0) {
145 err("kingsun_send_irq: urb asynchronously failed - %d",
146 urb->status);
147 }
148 netif_wake_queue(netdev);
149}
150
151/*
152 * Called from net/core when new frame is available.
153 */
154static int kingsun_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
155{
156 struct kingsun_cb *kingsun;
157 int wraplen;
158 int ret = 0;
159
160 if (skb == NULL || netdev == NULL)
161 return -EINVAL;
162
163 netif_stop_queue(netdev);
164
165 /* the IRDA wrapping routines don't deal with non linear skb */
166 SKB_LINEAR_ASSERT(skb);
167
168 kingsun = netdev_priv(netdev);
169
170 spin_lock(&kingsun->lock);
171
172 /* Append data to the end of whatever data remains to be transmitted */
173 wraplen = async_wrap_skb(skb,
174 kingsun->out_buf,
175 KINGSUN_FIFO_SIZE);
176
177 /* Calculate how much data can be transmitted in this urb */
178 usb_fill_int_urb(kingsun->tx_urb, kingsun->usbdev,
179 usb_sndintpipe(kingsun->usbdev, kingsun->ep_out),
180 kingsun->out_buf, wraplen, kingsun_send_irq,
181 kingsun, 1);
182
183 if ((ret = usb_submit_urb(kingsun->tx_urb, GFP_ATOMIC))) {
184 err("kingsun_hard_xmit: failed tx_urb submit: %d", ret);
185 switch (ret) {
186 case -ENODEV:
187 case -EPIPE:
188 break;
189 default:
190 kingsun->stats.tx_errors++;
191 netif_start_queue(netdev);
192 }
193 } else {
194 kingsun->stats.tx_packets++;
195 kingsun->stats.tx_bytes += skb->len;
196 }
197
198 dev_kfree_skb(skb);
199 spin_unlock(&kingsun->lock);
200
201 return ret;
202}
203
204/* Receive callback function */
205static void kingsun_rcv_irq(struct urb *urb)
206{
207 struct kingsun_cb *kingsun = urb->context;
208 int ret;
209
210 /* in process of stopping, just drop data */
211 if (!netif_running(kingsun->netdev)) {
212 kingsun->receiving = 0;
213 return;
214 }
215
216 /* unlink, shutdown, unplug, other nasties */
217 if (urb->status != 0) {
218 err("kingsun_rcv_irq: urb asynchronously failed - %d",
219 urb->status);
220 kingsun->receiving = 0;
221 return;
222 }
223
224 if (urb->actual_length == kingsun->max_rx) {
225 __u8 *bytes = urb->transfer_buffer;
226 int i;
227
228 /* The very first byte in the buffer indicates the length of
229 valid data in the read. This byte must be in the range
230 1..kingsun->max_rx -1 . Values outside this range indicate
231 an uninitialized Rx buffer when the dongle has just been
232 plugged in. */
233 if (bytes[0] >= 1 && bytes[0] < kingsun->max_rx) {
234 for (i = 1; i <= bytes[0]; i++) {
235 async_unwrap_char(kingsun->netdev,
236 &kingsun->stats,
237 &kingsun->rx_buff, bytes[i]);
238 }
239 kingsun->netdev->last_rx = jiffies;
240 do_gettimeofday(&kingsun->rx_time);
241 kingsun->receiving =
242 (kingsun->rx_buff.state != OUTSIDE_FRAME)
243 ? 1 : 0;
244 }
245 } else if (urb->actual_length > 0) {
246 err("%s(): Unexpected response length, expected %d got %d",
247 __FUNCTION__, kingsun->max_rx, urb->actual_length);
248 }
249 /* This urb has already been filled in kingsun_net_open */
250 ret = usb_submit_urb(urb, GFP_ATOMIC);
251}
252
253/*
254 * Function kingsun_net_open (dev)
255 *
256 * Network device is taken up. Usually this is done by "ifconfig irda0 up"
257 */
258static int kingsun_net_open(struct net_device *netdev)
259{
260 struct kingsun_cb *kingsun = netdev_priv(netdev);
261 int err = -ENOMEM;
262 char hwname[16];
263
264 /* At this point, urbs are NULL, and skb is NULL (see kingsun_probe) */
265 kingsun->receiving = 0;
266
267 /* Initialize for SIR to copy data directly into skb. */
268 kingsun->rx_buff.in_frame = FALSE;
269 kingsun->rx_buff.state = OUTSIDE_FRAME;
270 kingsun->rx_buff.truesize = IRDA_SKB_MAX_MTU;
271 kingsun->rx_buff.skb = dev_alloc_skb(IRDA_SKB_MAX_MTU);
272 if (!kingsun->rx_buff.skb)
273 goto free_mem;
274
275 skb_reserve(kingsun->rx_buff.skb, 1);
276 kingsun->rx_buff.head = kingsun->rx_buff.skb->data;
277 do_gettimeofday(&kingsun->rx_time);
278
279 kingsun->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
280 if (!kingsun->rx_urb)
281 goto free_mem;
282
283 kingsun->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
284 if (!kingsun->tx_urb)
285 goto free_mem;
286
287 /*
288 * Now that everything should be initialized properly,
289 * Open new IrLAP layer instance to take care of us...
290 */
291 sprintf(hwname, "usb#%d", kingsun->usbdev->devnum);
292 kingsun->irlap = irlap_open(netdev, &kingsun->qos, hwname);
293 if (!kingsun->irlap) {
294 err("kingsun-sir: irlap_open failed");
295 goto free_mem;
296 }
297
298 /* Start first reception */
299 usb_fill_int_urb(kingsun->rx_urb, kingsun->usbdev,
300 usb_rcvintpipe(kingsun->usbdev, kingsun->ep_in),
301 kingsun->in_buf, kingsun->max_rx,
302 kingsun_rcv_irq, kingsun, 1);
303 kingsun->rx_urb->status = 0;
304 err = usb_submit_urb(kingsun->rx_urb, GFP_KERNEL);
305 if (err) {
306 err("kingsun-sir: first urb-submit failed: %d", err);
307 goto close_irlap;
308 }
309
310 netif_start_queue(netdev);
311
312 /* Situation at this point:
313 - all work buffers allocated
314 - urbs allocated and ready to fill
315 - max rx packet known (in max_rx)
316 - unwrap state machine initialized, in state outside of any frame
317 - receive request in progress
318 - IrLAP layer started, about to hand over packets to send
319 */
320
321 return 0;
322
323 close_irlap:
324 irlap_close(kingsun->irlap);
325 free_mem:
326 if (kingsun->tx_urb) {
327 usb_free_urb(kingsun->tx_urb);
328 kingsun->tx_urb = NULL;
329 }
330 if (kingsun->rx_urb) {
331 usb_free_urb(kingsun->rx_urb);
332 kingsun->rx_urb = NULL;
333 }
334 if (kingsun->rx_buff.skb) {
335 kfree_skb(kingsun->rx_buff.skb);
336 kingsun->rx_buff.skb = NULL;
337 kingsun->rx_buff.head = NULL;
338 }
339 return err;
340}
341
342/*
343 * Function kingsun_net_close (kingsun)
344 *
345 * Network device is taken down. Usually this is done by
346 * "ifconfig irda0 down"
347 */
348static int kingsun_net_close(struct net_device *netdev)
349{
350 struct kingsun_cb *kingsun = netdev_priv(netdev);
351
352 /* Stop transmit processing */
353 netif_stop_queue(netdev);
354
355 /* Mop up receive && transmit urb's */
356 usb_kill_urb(kingsun->tx_urb);
357 usb_kill_urb(kingsun->rx_urb);
358
359 usb_free_urb(kingsun->tx_urb);
360 usb_free_urb(kingsun->rx_urb);
361
362 kingsun->tx_urb = NULL;
363 kingsun->rx_urb = NULL;
364
365 kfree_skb(kingsun->rx_buff.skb);
366 kingsun->rx_buff.skb = NULL;
367 kingsun->rx_buff.head = NULL;
368 kingsun->rx_buff.in_frame = FALSE;
369 kingsun->rx_buff.state = OUTSIDE_FRAME;
370 kingsun->receiving = 0;
371
372 /* Stop and remove instance of IrLAP */
373 if (kingsun->irlap)
374 irlap_close(kingsun->irlap);
375
376 kingsun->irlap = NULL;
377
378 return 0;
379}
380
381/*
382 * IOCTLs : Extra out-of-band network commands...
383 */
384static int kingsun_net_ioctl(struct net_device *netdev, struct ifreq *rq,
385 int cmd)
386{
387 struct if_irda_req *irq = (struct if_irda_req *) rq;
388 struct kingsun_cb *kingsun = netdev_priv(netdev);
389 int ret = 0;
390
391 switch (cmd) {
392 case SIOCSBANDWIDTH: /* Set bandwidth */
393 if (!capable(CAP_NET_ADMIN))
394 return -EPERM;
395
396 /* Check if the device is still there */
397 if (netif_device_present(kingsun->netdev))
398 /* No observed commands for speed change */
399 ret = -EOPNOTSUPP;
400 break;
401
402 case SIOCSMEDIABUSY: /* Set media busy */
403 if (!capable(CAP_NET_ADMIN))
404 return -EPERM;
405
406 /* Check if the IrDA stack is still there */
407 if (netif_running(kingsun->netdev))
408 irda_device_set_media_busy(kingsun->netdev, TRUE);
409 break;
410
411 case SIOCGRECEIVING:
412 /* Only approximately true */
413 irq->ifr_receiving = kingsun->receiving;
414 break;
415
416 default:
417 ret = -EOPNOTSUPP;
418 }
419
420 return ret;
421}
422
423/*
424 * Get device stats (for /proc/net/dev and ifconfig)
425 */
426static struct net_device_stats *
427kingsun_net_get_stats(struct net_device *netdev)
428{
429 struct kingsun_cb *kingsun = netdev_priv(netdev);
430 return &kingsun->stats;
431}
432
433/*
434 * This routine is called by the USB subsystem for each new device
435 * in the system. We need to check if the device is ours, and in
436 * this case start handling it.
437 */
438static int kingsun_probe(struct usb_interface *intf,
439 const struct usb_device_id *id)
440{
441 struct usb_host_interface *interface;
442 struct usb_endpoint_descriptor *endpoint;
443
444 struct usb_device *dev = interface_to_usbdev(intf);
445 struct kingsun_cb *kingsun = NULL;
446 struct net_device *net = NULL;
447 int ret = -ENOMEM;
448 int pipe, maxp_in, maxp_out;
449 __u8 ep_in;
450 __u8 ep_out;
451
452 /* Check that there really are two interrupt endpoints.
453 Check based on the one in drivers/usb/input/usbmouse.c
454 */
455 interface = intf->cur_altsetting;
456 if (interface->desc.bNumEndpoints != 2) {
457 err("kingsun-sir: expected 2 endpoints, found %d",
458 interface->desc.bNumEndpoints);
459 return -ENODEV;
460 }
461 endpoint = &interface->endpoint[KINGSUN_EP_IN].desc;
462 if (!usb_endpoint_is_int_in(endpoint)) {
463 err("kingsun-sir: endpoint 0 is not interrupt IN");
464 return -ENODEV;
465 }
466
467 ep_in = endpoint->bEndpointAddress;
468 pipe = usb_rcvintpipe(dev, ep_in);
469 maxp_in = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
470 if (maxp_in > 255 || maxp_in <= 1) {
471 err("%s: endpoint 0 has max packet size %d not in range",
472 __FILE__, maxp_in);
473 return -ENODEV;
474 }
475
476 endpoint = &interface->endpoint[KINGSUN_EP_OUT].desc;
477 if (!usb_endpoint_is_int_out(endpoint)) {
478 err("kingsun-sir: endpoint 1 is not interrupt OUT");
479 return -ENODEV;
480 }
481
482 ep_out = endpoint->bEndpointAddress;
483 pipe = usb_sndintpipe(dev, ep_out);
484 maxp_out = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
485
486 /* Allocate network device container. */
487 net = alloc_irdadev(sizeof(*kingsun));
488 if(!net)
489 goto err_out1;
490
491 SET_MODULE_OWNER(net);
492 SET_NETDEV_DEV(net, &intf->dev);
493 kingsun = netdev_priv(net);
494 kingsun->irlap = NULL;
495 kingsun->tx_urb = NULL;
496 kingsun->rx_urb = NULL;
497 kingsun->ep_in = ep_in;
498 kingsun->ep_out = ep_out;
499 kingsun->in_buf = NULL;
500 kingsun->out_buf = NULL;
501 kingsun->max_rx = (__u8)maxp_in;
502 kingsun->max_tx = (__u8)maxp_out;
503 kingsun->netdev = net;
504 kingsun->usbdev = dev;
505 kingsun->rx_buff.in_frame = FALSE;
506 kingsun->rx_buff.state = OUTSIDE_FRAME;
507 kingsun->rx_buff.skb = NULL;
508 kingsun->receiving = 0;
509 spin_lock_init(&kingsun->lock);
510
511 /* Allocate input buffer */
512 kingsun->in_buf = (__u8 *)kmalloc(kingsun->max_rx, GFP_KERNEL);
513 if (!kingsun->in_buf)
514 goto free_mem;
515
516 /* Allocate output buffer */
517 kingsun->out_buf = (__u8 *)kmalloc(KINGSUN_FIFO_SIZE, GFP_KERNEL);
518 if (!kingsun->out_buf)
519 goto free_mem;
520
521 printk(KERN_INFO "KingSun/DonShine IRDA/USB found at address %d, "
522 "Vendor: %x, Product: %x\n",
523 dev->devnum, le16_to_cpu(dev->descriptor.idVendor),
524 le16_to_cpu(dev->descriptor.idProduct));
525
526 /* Initialize QoS for this device */
527 irda_init_max_qos_capabilies(&kingsun->qos);
528
529 /* That's the Rx capability. */
530 kingsun->qos.baud_rate.bits &= IR_9600;
531 kingsun->qos.min_turn_time.bits &= KINGSUN_MTT;
532 irda_qos_bits_to_value(&kingsun->qos);
533
534 /* Override the network functions we need to use */
535 net->hard_start_xmit = kingsun_hard_xmit;
536 net->open = kingsun_net_open;
537 net->stop = kingsun_net_close;
538 net->get_stats = kingsun_net_get_stats;
539 net->do_ioctl = kingsun_net_ioctl;
540
541 ret = register_netdev(net);
542 if (ret != 0)
543 goto free_mem;
544
545 info("IrDA: Registered KingSun/DonShine device %s", net->name);
546
547 usb_set_intfdata(intf, kingsun);
548
549 /* Situation at this point:
550 - all work buffers allocated
551 - urbs not allocated, set to NULL
552 - max rx packet known (in max_rx)
553 - unwrap state machine (partially) initialized, but skb == NULL
554 */
555
556 return 0;
557
558free_mem:
559 if (kingsun->out_buf) kfree(kingsun->out_buf);
560 if (kingsun->in_buf) kfree(kingsun->in_buf);
561 free_netdev(net);
562err_out1:
563 return ret;
564}
565
566/*
567 * The current device is removed, the USB layer tell us to shut it down...
568 */
569static void kingsun_disconnect(struct usb_interface *intf)
570{
571 struct kingsun_cb *kingsun = usb_get_intfdata(intf);
572
573 if (!kingsun)
574 return;
575
576 unregister_netdev(kingsun->netdev);
577
578 /* Mop up receive && transmit urb's */
579 if (kingsun->tx_urb != NULL) {
580 usb_kill_urb(kingsun->tx_urb);
581 usb_free_urb(kingsun->tx_urb);
582 kingsun->tx_urb = NULL;
583 }
584 if (kingsun->rx_urb != NULL) {
585 usb_kill_urb(kingsun->rx_urb);
586 usb_free_urb(kingsun->rx_urb);
587 kingsun->rx_urb = NULL;
588 }
589
590 kfree(kingsun->out_buf);
591 kfree(kingsun->in_buf);
592 free_netdev(kingsun->netdev);
593
594 usb_set_intfdata(intf, NULL);
595}
596
597#ifdef CONFIG_PM
598/* USB suspend, so power off the transmitter/receiver */
599static int kingsun_suspend(struct usb_interface *intf, pm_message_t message)
600{
601 struct kingsun_cb *kingsun = usb_get_intfdata(intf);
602
603 netif_device_detach(kingsun->netdev);
604 if (kingsun->tx_urb != NULL) usb_kill_urb(kingsun->tx_urb);
605 if (kingsun->rx_urb != NULL) usb_kill_urb(kingsun->rx_urb);
606 return 0;
607}
608
609/* Coming out of suspend, so reset hardware */
610static int kingsun_resume(struct usb_interface *intf)
611{
612 struct kingsun_cb *kingsun = usb_get_intfdata(intf);
613
614 if (kingsun->rx_urb != NULL)
615 usb_submit_urb(kingsun->rx_urb, GFP_KERNEL);
616 netif_device_attach(kingsun->netdev);
617
618 return 0;
619}
620#endif
621
622/*
623 * USB device callbacks
624 */
625static struct usb_driver irda_driver = {
626 .name = "kingsun-sir",
627 .probe = kingsun_probe,
628 .disconnect = kingsun_disconnect,
629 .id_table = dongles,
630#ifdef CONFIG_PM
631 .suspend = kingsun_suspend,
632 .resume = kingsun_resume,
633#endif
634};
635
636/*
637 * Module insertion
638 */
639static int __init kingsun_init(void)
640{
641 return usb_register(&irda_driver);
642}
643module_init(kingsun_init);
644
645/*
646 * Module removal
647 */
648static void __exit kingsun_cleanup(void)
649{
650 /* Deregister the driver and remove all pending instances */
651 usb_deregister(&irda_driver);
652}
653module_exit(kingsun_cleanup);
654
655MODULE_AUTHOR("Alex Villac�s Lasso <a_villacis@palosanto.com>");
656MODULE_DESCRIPTION("IrDA-USB Dongle Driver for KingSun/DonShine");
657MODULE_LICENSE("GPL");
diff --git a/drivers/net/mlx4/eq.c b/drivers/net/mlx4/eq.c
index acf1c801a1b8..af016d0ea1c6 100644
--- a/drivers/net/mlx4/eq.c
+++ b/drivers/net/mlx4/eq.c
@@ -623,7 +623,7 @@ int __devinit mlx4_init_eq_table(struct mlx4_dev *dev)
623 priv->eq_table.eq[MLX4_EQ_CATAS].have_irq = 1; 623 priv->eq_table.eq[MLX4_EQ_CATAS].have_irq = 1;
624 } else { 624 } else {
625 err = request_irq(dev->pdev->irq, mlx4_interrupt, 625 err = request_irq(dev->pdev->irq, mlx4_interrupt,
626 SA_SHIRQ, DRV_NAME, dev); 626 IRQF_SHARED, DRV_NAME, dev);
627 if (err) 627 if (err)
628 goto err_out_async; 628 goto err_out_async;
629 629
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 4e32bb678ea9..2c5c6d20e6e9 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -735,7 +735,7 @@ static int netxen_nic_open(struct net_device *netdev)
735 } 735 }
736 adapter->irq = adapter->ahw.pdev->irq; 736 adapter->irq = adapter->ahw.pdev->irq;
737 err = request_irq(adapter->ahw.pdev->irq, netxen_intr, 737 err = request_irq(adapter->ahw.pdev->irq, netxen_intr,
738 SA_SHIRQ | SA_SAMPLE_RANDOM, netdev->name, 738 IRQF_SHARED|IRQF_SAMPLE_RANDOM, netdev->name,
739 adapter); 739 adapter);
740 if (err) { 740 if (err) {
741 printk(KERN_ERR "request_irq failed with: %d\n", err); 741 printk(KERN_ERR "request_irq failed with: %d\n", err);
diff --git a/drivers/net/pcmcia/Kconfig b/drivers/net/pcmcia/Kconfig
index 74f862001247..5d658bc9791c 100644
--- a/drivers/net/pcmcia/Kconfig
+++ b/drivers/net/pcmcia/Kconfig
@@ -2,11 +2,9 @@
2# PCMCIA Network device configuration 2# PCMCIA Network device configuration
3# 3#
4 4
5menu "PCMCIA network device support" 5menuconfig NET_PCMCIA
6 depends on NETDEVICES && PCMCIA!=n
7
8config NET_PCMCIA
9 bool "PCMCIA network device support" 6 bool "PCMCIA network device support"
7 depends on PCMCIA
10 ---help--- 8 ---help---
11 Say Y if you would like to include support for any PCMCIA or CardBus 9 Say Y if you would like to include support for any PCMCIA or CardBus
12 network adapters, then say Y to the driver for your particular card 10 network adapters, then say Y to the driver for your particular card
@@ -21,9 +19,10 @@ config NET_PCMCIA
21 19
22 If unsure, say N. 20 If unsure, say N.
23 21
22if NET_PCMCIA
23
24config PCMCIA_3C589 24config PCMCIA_3C589
25 tristate "3Com 3c589 PCMCIA support" 25 tristate "3Com 3c589 PCMCIA support"
26 depends on NET_PCMCIA && PCMCIA
27 help 26 help
28 Say Y here if you intend to attach a 3Com 3c589 or compatible PCMCIA 27 Say Y here if you intend to attach a 3Com 3c589 or compatible PCMCIA
29 (PC-card) Ethernet card to your computer. 28 (PC-card) Ethernet card to your computer.
@@ -33,7 +32,6 @@ config PCMCIA_3C589
33 32
34config PCMCIA_3C574 33config PCMCIA_3C574
35 tristate "3Com 3c574 PCMCIA support" 34 tristate "3Com 3c574 PCMCIA support"
36 depends on NET_PCMCIA && PCMCIA
37 help 35 help
38 Say Y here if you intend to attach a 3Com 3c574 or compatible PCMCIA 36 Say Y here if you intend to attach a 3Com 3c574 or compatible PCMCIA
39 (PC-card) Fast Ethernet card to your computer. 37 (PC-card) Fast Ethernet card to your computer.
@@ -43,7 +41,6 @@ config PCMCIA_3C574
43 41
44config PCMCIA_FMVJ18X 42config PCMCIA_FMVJ18X
45 tristate "Fujitsu FMV-J18x PCMCIA support" 43 tristate "Fujitsu FMV-J18x PCMCIA support"
46 depends on NET_PCMCIA && PCMCIA
47 select CRC32 44 select CRC32
48 help 45 help
49 Say Y here if you intend to attach a Fujitsu FMV-J18x or compatible 46 Say Y here if you intend to attach a Fujitsu FMV-J18x or compatible
@@ -54,7 +51,6 @@ config PCMCIA_FMVJ18X
54 51
55config PCMCIA_PCNET 52config PCMCIA_PCNET
56 tristate "NE2000 compatible PCMCIA support" 53 tristate "NE2000 compatible PCMCIA support"
57 depends on NET_PCMCIA && PCMCIA
58 select CRC32 54 select CRC32
59 help 55 help
60 Say Y here if you intend to attach an NE2000 compatible PCMCIA 56 Say Y here if you intend to attach an NE2000 compatible PCMCIA
@@ -65,7 +61,6 @@ config PCMCIA_PCNET
65 61
66config PCMCIA_NMCLAN 62config PCMCIA_NMCLAN
67 tristate "New Media PCMCIA support" 63 tristate "New Media PCMCIA support"
68 depends on NET_PCMCIA && PCMCIA
69 help 64 help
70 Say Y here if you intend to attach a New Media Ethernet or LiveWire 65 Say Y here if you intend to attach a New Media Ethernet or LiveWire
71 PCMCIA (PC-card) Ethernet card to your computer. 66 PCMCIA (PC-card) Ethernet card to your computer.
@@ -75,7 +70,6 @@ config PCMCIA_NMCLAN
75 70
76config PCMCIA_SMC91C92 71config PCMCIA_SMC91C92
77 tristate "SMC 91Cxx PCMCIA support" 72 tristate "SMC 91Cxx PCMCIA support"
78 depends on NET_PCMCIA && PCMCIA
79 select CRC32 73 select CRC32
80 select MII 74 select MII
81 help 75 help
@@ -87,7 +81,6 @@ config PCMCIA_SMC91C92
87 81
88config PCMCIA_XIRC2PS 82config PCMCIA_XIRC2PS
89 tristate "Xircom 16-bit PCMCIA support" 83 tristate "Xircom 16-bit PCMCIA support"
90 depends on NET_PCMCIA && PCMCIA
91 help 84 help
92 Say Y here if you intend to attach a Xircom 16-bit PCMCIA (PC-card) 85 Say Y here if you intend to attach a Xircom 16-bit PCMCIA (PC-card)
93 Ethernet or Fast Ethernet card to your computer. 86 Ethernet or Fast Ethernet card to your computer.
@@ -97,7 +90,6 @@ config PCMCIA_XIRC2PS
97 90
98config PCMCIA_AXNET 91config PCMCIA_AXNET
99 tristate "Asix AX88190 PCMCIA support" 92 tristate "Asix AX88190 PCMCIA support"
100 depends on NET_PCMCIA && PCMCIA
101 ---help--- 93 ---help---
102 Say Y here if you intend to attach an Asix AX88190-based PCMCIA 94 Say Y here if you intend to attach an Asix AX88190-based PCMCIA
103 (PC-card) Fast Ethernet card to your computer. These cards are 95 (PC-card) Fast Ethernet card to your computer. These cards are
@@ -109,7 +101,7 @@ config PCMCIA_AXNET
109 101
110config ARCNET_COM20020_CS 102config ARCNET_COM20020_CS
111 tristate "COM20020 ARCnet PCMCIA support" 103 tristate "COM20020 ARCnet PCMCIA support"
112 depends on NET_PCMCIA && ARCNET_COM20020 && PCMCIA 104 depends on ARCNET_COM20020
113 help 105 help
114 Say Y here if you intend to attach this type of ARCnet PCMCIA card 106 Say Y here if you intend to attach this type of ARCnet PCMCIA card
115 to your computer. 107 to your computer.
@@ -119,7 +111,7 @@ config ARCNET_COM20020_CS
119 111
120config PCMCIA_IBMTR 112config PCMCIA_IBMTR
121 tristate "IBM PCMCIA tokenring adapter support" 113 tristate "IBM PCMCIA tokenring adapter support"
122 depends on NET_PCMCIA && IBMTR!=y && TR && PCMCIA && !64BIT 114 depends on IBMTR!=y && TR && !64BIT
123 help 115 help
124 Say Y here if you intend to attach this type of Token Ring PCMCIA 116 Say Y here if you intend to attach this type of Token Ring PCMCIA
125 card to your computer. You then also need to say Y to "Token Ring 117 card to your computer. You then also need to say Y to "Token Ring
@@ -128,5 +120,4 @@ config PCMCIA_IBMTR
128 To compile this driver as a module, choose M here: the module will be 120 To compile this driver as a module, choose M here: the module will be
129 called ibmtr_cs. 121 called ibmtr_cs.
130 122
131endmenu 123endif # NET_PCMCIA
132
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index c0d3101eb6a0..09b6f259eb92 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -2,70 +2,61 @@
2# PHY Layer Configuration 2# PHY Layer Configuration
3# 3#
4 4
5menu "PHY device support" 5menuconfig PHYLIB
6 depends on !S390
7
8config PHYLIB
9 tristate "PHY Device support and infrastructure" 6 tristate "PHY Device support and infrastructure"
7 depends on !S390
10 depends on NET_ETHERNET && (BROKEN || !S390) 8 depends on NET_ETHERNET && (BROKEN || !S390)
11 help 9 help
12 Ethernet controllers are usually attached to PHY 10 Ethernet controllers are usually attached to PHY
13 devices. This option provides infrastructure for 11 devices. This option provides infrastructure for
14 managing PHY devices. 12 managing PHY devices.
15 13
14if PHYLIB
15
16comment "MII PHY device drivers" 16comment "MII PHY device drivers"
17 depends on PHYLIB
18 17
19config MARVELL_PHY 18config MARVELL_PHY
20 tristate "Drivers for Marvell PHYs" 19 tristate "Drivers for Marvell PHYs"
21 depends on PHYLIB
22 ---help--- 20 ---help---
23 Currently has a driver for the 88E1011S 21 Currently has a driver for the 88E1011S
24 22
25config DAVICOM_PHY 23config DAVICOM_PHY
26 tristate "Drivers for Davicom PHYs" 24 tristate "Drivers for Davicom PHYs"
27 depends on PHYLIB
28 ---help--- 25 ---help---
29 Currently supports dm9161e and dm9131 26 Currently supports dm9161e and dm9131
30 27
31config QSEMI_PHY 28config QSEMI_PHY
32 tristate "Drivers for Quality Semiconductor PHYs" 29 tristate "Drivers for Quality Semiconductor PHYs"
33 depends on PHYLIB
34 ---help--- 30 ---help---
35 Currently supports the qs6612 31 Currently supports the qs6612
36 32
37config LXT_PHY 33config LXT_PHY
38 tristate "Drivers for the Intel LXT PHYs" 34 tristate "Drivers for the Intel LXT PHYs"
39 depends on PHYLIB
40 ---help--- 35 ---help---
41 Currently supports the lxt970, lxt971 36 Currently supports the lxt970, lxt971
42 37
43config CICADA_PHY 38config CICADA_PHY
44 tristate "Drivers for the Cicada PHYs" 39 tristate "Drivers for the Cicada PHYs"
45 depends on PHYLIB
46 ---help--- 40 ---help---
47 Currently supports the cis8204 41 Currently supports the cis8204
42
48config VITESSE_PHY 43config VITESSE_PHY
49 tristate "Drivers for the Vitesse PHYs" 44 tristate "Drivers for the Vitesse PHYs"
50 depends on PHYLIB
51 ---help--- 45 ---help---
52 Currently supports the vsc8244 46 Currently supports the vsc8244
53 47
54config SMSC_PHY 48config SMSC_PHY
55 tristate "Drivers for SMSC PHYs" 49 tristate "Drivers for SMSC PHYs"
56 depends on PHYLIB
57 ---help--- 50 ---help---
58 Currently supports the LAN83C185 PHY 51 Currently supports the LAN83C185 PHY
59 52
60config BROADCOM_PHY 53config BROADCOM_PHY
61 tristate "Drivers for Broadcom PHYs" 54 tristate "Drivers for Broadcom PHYs"
62 depends on PHYLIB
63 ---help--- 55 ---help---
64 Currently supports the BCM5411, BCM5421 and BCM5461 PHYs. 56 Currently supports the BCM5411, BCM5421 and BCM5461 PHYs.
65 57
66config FIXED_PHY 58config FIXED_PHY
67 tristate "Drivers for PHY emulation on fixed speed/link" 59 tristate "Drivers for PHY emulation on fixed speed/link"
68 depends on PHYLIB
69 ---help--- 60 ---help---
70 Adds the driver to PHY layer to cover the boards that do not have any PHY bound, 61 Adds the driver to PHY layer to cover the boards that do not have any PHY bound,
71 but with the ability to manipulate the speed/link in software. The relevant MII 62 but with the ability to manipulate the speed/link in software. The relevant MII
@@ -80,5 +71,4 @@ config FIXED_MII_100_FDX
80 bool "Emulation for 100M Fdx fixed PHY behavior" 71 bool "Emulation for 100M Fdx fixed PHY behavior"
81 depends on FIXED_PHY 72 depends on FIXED_PHY
82 73
83endmenu 74endif # PHYLIB
84
diff --git a/drivers/net/phy/davicom.c b/drivers/net/phy/davicom.c
index 519baa38be8d..7ed632db00d7 100644
--- a/drivers/net/phy/davicom.c
+++ b/drivers/net/phy/davicom.c
@@ -139,7 +139,7 @@ static int dm9161_ack_interrupt(struct phy_device *phydev)
139 return (err < 0) ? err : 0; 139 return (err < 0) ? err : 0;
140} 140}
141 141
142static struct phy_driver dm9161_driver = { 142static struct phy_driver dm9161e_driver = {
143 .phy_id = 0x0181b880, 143 .phy_id = 0x0181b880,
144 .name = "Davicom DM9161E", 144 .name = "Davicom DM9161E",
145 .phy_id_mask = 0x0ffffff0, 145 .phy_id_mask = 0x0ffffff0,
@@ -147,7 +147,18 @@ static struct phy_driver dm9161_driver = {
147 .config_init = dm9161_config_init, 147 .config_init = dm9161_config_init,
148 .config_aneg = dm9161_config_aneg, 148 .config_aneg = dm9161_config_aneg,
149 .read_status = genphy_read_status, 149 .read_status = genphy_read_status,
150 .driver = { .owner = THIS_MODULE,}, 150 .driver = { .owner = THIS_MODULE,},
151};
152
153static struct phy_driver dm9161a_driver = {
154 .phy_id = 0x0181b8a0,
155 .name = "Davicom DM9161A",
156 .phy_id_mask = 0x0ffffff0,
157 .features = PHY_BASIC_FEATURES,
158 .config_init = dm9161_config_init,
159 .config_aneg = dm9161_config_aneg,
160 .read_status = genphy_read_status,
161 .driver = { .owner = THIS_MODULE,},
151}; 162};
152 163
153static struct phy_driver dm9131_driver = { 164static struct phy_driver dm9131_driver = {
@@ -160,31 +171,38 @@ static struct phy_driver dm9131_driver = {
160 .read_status = genphy_read_status, 171 .read_status = genphy_read_status,
161 .ack_interrupt = dm9161_ack_interrupt, 172 .ack_interrupt = dm9161_ack_interrupt,
162 .config_intr = dm9161_config_intr, 173 .config_intr = dm9161_config_intr,
163 .driver = { .owner = THIS_MODULE,}, 174 .driver = { .owner = THIS_MODULE,},
164}; 175};
165 176
166static int __init davicom_init(void) 177static int __init davicom_init(void)
167{ 178{
168 int ret; 179 int ret;
169 180
170 ret = phy_driver_register(&dm9161_driver); 181 ret = phy_driver_register(&dm9161e_driver);
171 if (ret) 182 if (ret)
172 goto err1; 183 goto err1;
173 184
174 ret = phy_driver_register(&dm9131_driver); 185 ret = phy_driver_register(&dm9161a_driver);
175 if (ret) 186 if (ret)
176 goto err2; 187 goto err2;
188
189 ret = phy_driver_register(&dm9131_driver);
190 if (ret)
191 goto err3;
177 return 0; 192 return 0;
178 193
179 err2: 194 err3:
180 phy_driver_unregister(&dm9161_driver); 195 phy_driver_unregister(&dm9161a_driver);
196 err2:
197 phy_driver_unregister(&dm9161e_driver);
181 err1: 198 err1:
182 return ret; 199 return ret;
183} 200}
184 201
185static void __exit davicom_exit(void) 202static void __exit davicom_exit(void)
186{ 203{
187 phy_driver_unregister(&dm9161_driver); 204 phy_driver_unregister(&dm9161e_driver);
205 phy_driver_unregister(&dm9161a_driver);
188 phy_driver_unregister(&dm9131_driver); 206 phy_driver_unregister(&dm9131_driver);
189} 207}
190 208
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 290e1c1f30c6..e3e6d410d72c 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -84,7 +84,7 @@
84#include "s2io.h" 84#include "s2io.h"
85#include "s2io-regs.h" 85#include "s2io-regs.h"
86 86
87#define DRV_VERSION "2.0.22.1" 87#define DRV_VERSION "2.0.23.1"
88 88
89/* S2io Driver name & version. */ 89/* S2io Driver name & version. */
90static char s2io_driver_name[] = "Neterion"; 90static char s2io_driver_name[] = "Neterion";
@@ -281,6 +281,28 @@ static char ethtool_driver_stats_keys[][ETH_GSTRING_LEN] = {
281 ("lro_out_of_sequence_pkts"), 281 ("lro_out_of_sequence_pkts"),
282 ("lro_flush_due_to_max_pkts"), 282 ("lro_flush_due_to_max_pkts"),
283 ("lro_avg_aggr_pkts"), 283 ("lro_avg_aggr_pkts"),
284 ("mem_alloc_fail_cnt"),
285 ("watchdog_timer_cnt"),
286 ("mem_allocated"),
287 ("mem_freed"),
288 ("link_up_cnt"),
289 ("link_down_cnt"),
290 ("link_up_time"),
291 ("link_down_time"),
292 ("tx_tcode_buf_abort_cnt"),
293 ("tx_tcode_desc_abort_cnt"),
294 ("tx_tcode_parity_err_cnt"),
295 ("tx_tcode_link_loss_cnt"),
296 ("tx_tcode_list_proc_err_cnt"),
297 ("rx_tcode_parity_err_cnt"),
298 ("rx_tcode_abort_cnt"),
299 ("rx_tcode_parity_abort_cnt"),
300 ("rx_tcode_rda_fail_cnt"),
301 ("rx_tcode_unkn_prot_cnt"),
302 ("rx_tcode_fcs_err_cnt"),
303 ("rx_tcode_buf_size_err_cnt"),
304 ("rx_tcode_rxd_corrupt_cnt"),
305 ("rx_tcode_unkn_err_cnt")
284}; 306};
285 307
286#define S2IO_XENA_STAT_LEN sizeof(ethtool_xena_stats_keys)/ ETH_GSTRING_LEN 308#define S2IO_XENA_STAT_LEN sizeof(ethtool_xena_stats_keys)/ ETH_GSTRING_LEN
@@ -490,6 +512,7 @@ static int init_shared_mem(struct s2io_nic *nic)
490 512
491 struct mac_info *mac_control; 513 struct mac_info *mac_control;
492 struct config_param *config; 514 struct config_param *config;
515 unsigned long long mem_allocated = 0;
493 516
494 mac_control = &nic->mac_control; 517 mac_control = &nic->mac_control;
495 config = &nic->config; 518 config = &nic->config;
@@ -519,6 +542,7 @@ static int init_shared_mem(struct s2io_nic *nic)
519 "Malloc failed for list_info\n"); 542 "Malloc failed for list_info\n");
520 return -ENOMEM; 543 return -ENOMEM;
521 } 544 }
545 mem_allocated += list_holder_size;
522 memset(mac_control->fifos[i].list_info, 0, list_holder_size); 546 memset(mac_control->fifos[i].list_info, 0, list_holder_size);
523 } 547 }
524 for (i = 0; i < config->tx_fifo_num; i++) { 548 for (i = 0; i < config->tx_fifo_num; i++) {
@@ -565,6 +589,7 @@ static int init_shared_mem(struct s2io_nic *nic)
565 DBG_PRINT(INFO_DBG, "failed for TxDL\n"); 589 DBG_PRINT(INFO_DBG, "failed for TxDL\n");
566 return -ENOMEM; 590 return -ENOMEM;
567 } 591 }
592 mem_allocated += PAGE_SIZE;
568 } 593 }
569 while (k < lst_per_page) { 594 while (k < lst_per_page) {
570 int l = (j * lst_per_page) + k; 595 int l = (j * lst_per_page) + k;
@@ -582,6 +607,7 @@ static int init_shared_mem(struct s2io_nic *nic)
582 nic->ufo_in_band_v = kcalloc(size, sizeof(u64), GFP_KERNEL); 607 nic->ufo_in_band_v = kcalloc(size, sizeof(u64), GFP_KERNEL);
583 if (!nic->ufo_in_band_v) 608 if (!nic->ufo_in_band_v)
584 return -ENOMEM; 609 return -ENOMEM;
610 mem_allocated += (size * sizeof(u64));
585 611
586 /* Allocation and initialization of RXDs in Rings */ 612 /* Allocation and initialization of RXDs in Rings */
587 size = 0; 613 size = 0;
@@ -639,6 +665,7 @@ static int init_shared_mem(struct s2io_nic *nic)
639 rx_blocks->block_virt_addr = tmp_v_addr; 665 rx_blocks->block_virt_addr = tmp_v_addr;
640 return -ENOMEM; 666 return -ENOMEM;
641 } 667 }
668 mem_allocated += size;
642 memset(tmp_v_addr, 0, size); 669 memset(tmp_v_addr, 0, size);
643 rx_blocks->block_virt_addr = tmp_v_addr; 670 rx_blocks->block_virt_addr = tmp_v_addr;
644 rx_blocks->block_dma_addr = tmp_p_addr; 671 rx_blocks->block_dma_addr = tmp_p_addr;
@@ -647,6 +674,8 @@ static int init_shared_mem(struct s2io_nic *nic)
647 GFP_KERNEL); 674 GFP_KERNEL);
648 if (!rx_blocks->rxds) 675 if (!rx_blocks->rxds)
649 return -ENOMEM; 676 return -ENOMEM;
677 mem_allocated +=
678 (sizeof(struct rxd_info)* rxd_count[nic->rxd_mode]);
650 for (l=0; l<rxd_count[nic->rxd_mode];l++) { 679 for (l=0; l<rxd_count[nic->rxd_mode];l++) {
651 rx_blocks->rxds[l].virt_addr = 680 rx_blocks->rxds[l].virt_addr =
652 rx_blocks->block_virt_addr + 681 rx_blocks->block_virt_addr +
@@ -689,6 +718,7 @@ static int init_shared_mem(struct s2io_nic *nic)
689 GFP_KERNEL); 718 GFP_KERNEL);
690 if (!mac_control->rings[i].ba) 719 if (!mac_control->rings[i].ba)
691 return -ENOMEM; 720 return -ENOMEM;
721 mem_allocated +=(sizeof(struct buffAdd *) * blk_cnt);
692 for (j = 0; j < blk_cnt; j++) { 722 for (j = 0; j < blk_cnt; j++) {
693 int k = 0; 723 int k = 0;
694 mac_control->rings[i].ba[j] = 724 mac_control->rings[i].ba[j] =
@@ -697,6 +727,8 @@ static int init_shared_mem(struct s2io_nic *nic)
697 GFP_KERNEL); 727 GFP_KERNEL);
698 if (!mac_control->rings[i].ba[j]) 728 if (!mac_control->rings[i].ba[j])
699 return -ENOMEM; 729 return -ENOMEM;
730 mem_allocated += (sizeof(struct buffAdd) * \
731 (rxd_count[nic->rxd_mode] + 1));
700 while (k != rxd_count[nic->rxd_mode]) { 732 while (k != rxd_count[nic->rxd_mode]) {
701 ba = &mac_control->rings[i].ba[j][k]; 733 ba = &mac_control->rings[i].ba[j][k];
702 734
@@ -704,6 +736,8 @@ static int init_shared_mem(struct s2io_nic *nic)
704 (BUF0_LEN + ALIGN_SIZE, GFP_KERNEL); 736 (BUF0_LEN + ALIGN_SIZE, GFP_KERNEL);
705 if (!ba->ba_0_org) 737 if (!ba->ba_0_org)
706 return -ENOMEM; 738 return -ENOMEM;
739 mem_allocated +=
740 (BUF0_LEN + ALIGN_SIZE);
707 tmp = (unsigned long)ba->ba_0_org; 741 tmp = (unsigned long)ba->ba_0_org;
708 tmp += ALIGN_SIZE; 742 tmp += ALIGN_SIZE;
709 tmp &= ~((unsigned long) ALIGN_SIZE); 743 tmp &= ~((unsigned long) ALIGN_SIZE);
@@ -713,6 +747,8 @@ static int init_shared_mem(struct s2io_nic *nic)
713 (BUF1_LEN + ALIGN_SIZE, GFP_KERNEL); 747 (BUF1_LEN + ALIGN_SIZE, GFP_KERNEL);
714 if (!ba->ba_1_org) 748 if (!ba->ba_1_org)
715 return -ENOMEM; 749 return -ENOMEM;
750 mem_allocated
751 += (BUF1_LEN + ALIGN_SIZE);
716 tmp = (unsigned long) ba->ba_1_org; 752 tmp = (unsigned long) ba->ba_1_org;
717 tmp += ALIGN_SIZE; 753 tmp += ALIGN_SIZE;
718 tmp &= ~((unsigned long) ALIGN_SIZE); 754 tmp &= ~((unsigned long) ALIGN_SIZE);
@@ -736,6 +772,7 @@ static int init_shared_mem(struct s2io_nic *nic)
736 */ 772 */
737 return -ENOMEM; 773 return -ENOMEM;
738 } 774 }
775 mem_allocated += size;
739 mac_control->stats_mem_sz = size; 776 mac_control->stats_mem_sz = size;
740 777
741 tmp_v_addr = mac_control->stats_mem; 778 tmp_v_addr = mac_control->stats_mem;
@@ -743,7 +780,7 @@ static int init_shared_mem(struct s2io_nic *nic)
743 memset(tmp_v_addr, 0, size); 780 memset(tmp_v_addr, 0, size);
744 DBG_PRINT(INIT_DBG, "%s:Ring Mem PHY: 0x%llx\n", dev->name, 781 DBG_PRINT(INIT_DBG, "%s:Ring Mem PHY: 0x%llx\n", dev->name,
745 (unsigned long long) tmp_p_addr); 782 (unsigned long long) tmp_p_addr);
746 783 mac_control->stats_info->sw_stat.mem_allocated += mem_allocated;
747 return SUCCESS; 784 return SUCCESS;
748} 785}
749 786
@@ -757,12 +794,14 @@ static int init_shared_mem(struct s2io_nic *nic)
757static void free_shared_mem(struct s2io_nic *nic) 794static void free_shared_mem(struct s2io_nic *nic)
758{ 795{
759 int i, j, blk_cnt, size; 796 int i, j, blk_cnt, size;
797 u32 ufo_size = 0;
760 void *tmp_v_addr; 798 void *tmp_v_addr;
761 dma_addr_t tmp_p_addr; 799 dma_addr_t tmp_p_addr;
762 struct mac_info *mac_control; 800 struct mac_info *mac_control;
763 struct config_param *config; 801 struct config_param *config;
764 int lst_size, lst_per_page; 802 int lst_size, lst_per_page;
765 struct net_device *dev = nic->dev; 803 struct net_device *dev = nic->dev;
804 int page_num = 0;
766 805
767 if (!nic) 806 if (!nic)
768 return; 807 return;
@@ -774,8 +813,9 @@ static void free_shared_mem(struct s2io_nic *nic)
774 lst_per_page = PAGE_SIZE / lst_size; 813 lst_per_page = PAGE_SIZE / lst_size;
775 814
776 for (i = 0; i < config->tx_fifo_num; i++) { 815 for (i = 0; i < config->tx_fifo_num; i++) {
777 int page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len, 816 ufo_size += config->tx_cfg[i].fifo_len;
778 lst_per_page); 817 page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len,
818 lst_per_page);
779 for (j = 0; j < page_num; j++) { 819 for (j = 0; j < page_num; j++) {
780 int mem_blks = (j * lst_per_page); 820 int mem_blks = (j * lst_per_page);
781 if (!mac_control->fifos[i].list_info) 821 if (!mac_control->fifos[i].list_info)
@@ -790,6 +830,8 @@ static void free_shared_mem(struct s2io_nic *nic)
790 mac_control->fifos[i]. 830 mac_control->fifos[i].
791 list_info[mem_blks]. 831 list_info[mem_blks].
792 list_phy_addr); 832 list_phy_addr);
833 nic->mac_control.stats_info->sw_stat.mem_freed
834 += PAGE_SIZE;
793 } 835 }
794 /* If we got a zero DMA address during allocation, 836 /* If we got a zero DMA address during allocation,
795 * free the page now 837 * free the page now
@@ -803,8 +845,12 @@ static void free_shared_mem(struct s2io_nic *nic)
803 dev->name); 845 dev->name);
804 DBG_PRINT(INIT_DBG, "Virtual address %p\n", 846 DBG_PRINT(INIT_DBG, "Virtual address %p\n",
805 mac_control->zerodma_virt_addr); 847 mac_control->zerodma_virt_addr);
848 nic->mac_control.stats_info->sw_stat.mem_freed
849 += PAGE_SIZE;
806 } 850 }
807 kfree(mac_control->fifos[i].list_info); 851 kfree(mac_control->fifos[i].list_info);
852 nic->mac_control.stats_info->sw_stat.mem_freed +=
853 (nic->config.tx_cfg[i].fifo_len *sizeof(struct list_info_hold));
808 } 854 }
809 855
810 size = SIZE_OF_BLOCK; 856 size = SIZE_OF_BLOCK;
@@ -819,7 +865,10 @@ static void free_shared_mem(struct s2io_nic *nic)
819 break; 865 break;
820 pci_free_consistent(nic->pdev, size, 866 pci_free_consistent(nic->pdev, size,
821 tmp_v_addr, tmp_p_addr); 867 tmp_v_addr, tmp_p_addr);
868 nic->mac_control.stats_info->sw_stat.mem_freed += size;
822 kfree(mac_control->rings[i].rx_blocks[j].rxds); 869 kfree(mac_control->rings[i].rx_blocks[j].rxds);
870 nic->mac_control.stats_info->sw_stat.mem_freed +=
871 ( sizeof(struct rxd_info)* rxd_count[nic->rxd_mode]);
823 } 872 }
824 } 873 }
825 874
@@ -836,12 +885,20 @@ static void free_shared_mem(struct s2io_nic *nic)
836 struct buffAdd *ba = 885 struct buffAdd *ba =
837 &mac_control->rings[i].ba[j][k]; 886 &mac_control->rings[i].ba[j][k];
838 kfree(ba->ba_0_org); 887 kfree(ba->ba_0_org);
888 nic->mac_control.stats_info->sw_stat.\
889 mem_freed += (BUF0_LEN + ALIGN_SIZE);
839 kfree(ba->ba_1_org); 890 kfree(ba->ba_1_org);
891 nic->mac_control.stats_info->sw_stat.\
892 mem_freed += (BUF1_LEN + ALIGN_SIZE);
840 k++; 893 k++;
841 } 894 }
842 kfree(mac_control->rings[i].ba[j]); 895 kfree(mac_control->rings[i].ba[j]);
896 nic->mac_control.stats_info->sw_stat.mem_freed += (sizeof(struct buffAdd) *
897 (rxd_count[nic->rxd_mode] + 1));
843 } 898 }
844 kfree(mac_control->rings[i].ba); 899 kfree(mac_control->rings[i].ba);
900 nic->mac_control.stats_info->sw_stat.mem_freed +=
901 (sizeof(struct buffAdd *) * blk_cnt);
845 } 902 }
846 } 903 }
847 904
@@ -850,9 +907,14 @@ static void free_shared_mem(struct s2io_nic *nic)
850 mac_control->stats_mem_sz, 907 mac_control->stats_mem_sz,
851 mac_control->stats_mem, 908 mac_control->stats_mem,
852 mac_control->stats_mem_phy); 909 mac_control->stats_mem_phy);
910 nic->mac_control.stats_info->sw_stat.mem_freed +=
911 mac_control->stats_mem_sz;
853 } 912 }
854 if (nic->ufo_in_band_v) 913 if (nic->ufo_in_band_v) {
855 kfree(nic->ufo_in_band_v); 914 kfree(nic->ufo_in_band_v);
915 nic->mac_control.stats_info->sw_stat.mem_freed
916 += (ufo_size * sizeof(u64));
917 }
856} 918}
857 919
858/** 920/**
@@ -2122,10 +2184,12 @@ static void free_tx_buffers(struct s2io_nic *nic)
2122 2184
2123 for (i = 0; i < config->tx_fifo_num; i++) { 2185 for (i = 0; i < config->tx_fifo_num; i++) {
2124 for (j = 0; j < config->tx_cfg[i].fifo_len - 1; j++) { 2186 for (j = 0; j < config->tx_cfg[i].fifo_len - 1; j++) {
2125 txdp = (struct TxD *) mac_control->fifos[i].list_info[j]. 2187 txdp = (struct TxD *) \
2126 list_virt_addr; 2188 mac_control->fifos[i].list_info[j].list_virt_addr;
2127 skb = s2io_txdl_getskb(&mac_control->fifos[i], txdp, j); 2189 skb = s2io_txdl_getskb(&mac_control->fifos[i], txdp, j);
2128 if (skb) { 2190 if (skb) {
2191 nic->mac_control.stats_info->sw_stat.mem_freed
2192 += skb->truesize;
2129 dev_kfree_skb(skb); 2193 dev_kfree_skb(skb);
2130 cnt++; 2194 cnt++;
2131 } 2195 }
@@ -2186,11 +2250,14 @@ static int fill_rxd_3buf(struct s2io_nic *nic, struct RxD_t *rxdp, struct \
2186 /* skb_shinfo(skb)->frag_list will have L4 data payload */ 2250 /* skb_shinfo(skb)->frag_list will have L4 data payload */
2187 skb_shinfo(skb)->frag_list = dev_alloc_skb(dev->mtu + ALIGN_SIZE); 2251 skb_shinfo(skb)->frag_list = dev_alloc_skb(dev->mtu + ALIGN_SIZE);
2188 if (skb_shinfo(skb)->frag_list == NULL) { 2252 if (skb_shinfo(skb)->frag_list == NULL) {
2253 nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++;
2189 DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n ", dev->name); 2254 DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n ", dev->name);
2190 return -ENOMEM ; 2255 return -ENOMEM ;
2191 } 2256 }
2192 frag_list = skb_shinfo(skb)->frag_list; 2257 frag_list = skb_shinfo(skb)->frag_list;
2193 skb->truesize += frag_list->truesize; 2258 skb->truesize += frag_list->truesize;
2259 nic->mac_control.stats_info->sw_stat.mem_allocated
2260 += frag_list->truesize;
2194 frag_list->next = NULL; 2261 frag_list->next = NULL;
2195 tmp = (void *)ALIGN((long)frag_list->data, ALIGN_SIZE + 1); 2262 tmp = (void *)ALIGN((long)frag_list->data, ALIGN_SIZE + 1);
2196 frag_list->data = tmp; 2263 frag_list->data = tmp;
@@ -2319,8 +2386,12 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2319 wmb(); 2386 wmb();
2320 first_rxdp->Control_1 |= RXD_OWN_XENA; 2387 first_rxdp->Control_1 |= RXD_OWN_XENA;
2321 } 2388 }
2389 nic->mac_control.stats_info->sw_stat. \
2390 mem_alloc_fail_cnt++;
2322 return -ENOMEM ; 2391 return -ENOMEM ;
2323 } 2392 }
2393 nic->mac_control.stats_info->sw_stat.mem_allocated
2394 += skb->truesize;
2324 if (nic->rxd_mode == RXD_MODE_1) { 2395 if (nic->rxd_mode == RXD_MODE_1) {
2325 /* 1 buffer mode - normal operation mode */ 2396 /* 1 buffer mode - normal operation mode */
2326 memset(rxdp, 0, sizeof(struct RxD1)); 2397 memset(rxdp, 0, sizeof(struct RxD1));
@@ -2328,7 +2399,8 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2328 ((struct RxD1*)rxdp)->Buffer0_ptr = pci_map_single 2399 ((struct RxD1*)rxdp)->Buffer0_ptr = pci_map_single
2329 (nic->pdev, skb->data, size - NET_IP_ALIGN, 2400 (nic->pdev, skb->data, size - NET_IP_ALIGN,
2330 PCI_DMA_FROMDEVICE); 2401 PCI_DMA_FROMDEVICE);
2331 rxdp->Control_2 = SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN); 2402 rxdp->Control_2 =
2403 SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN);
2332 2404
2333 } else if (nic->rxd_mode >= RXD_MODE_3A) { 2405 } else if (nic->rxd_mode >= RXD_MODE_3A) {
2334 /* 2406 /*
@@ -2342,7 +2414,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2342 * payload 2414 * payload
2343 */ 2415 */
2344 2416
2345 /* save the buffer pointers to avoid frequent dma mapping */ 2417 /* save buffer pointers to avoid frequent dma mapping */
2346 Buffer0_ptr = ((struct RxD3*)rxdp)->Buffer0_ptr; 2418 Buffer0_ptr = ((struct RxD3*)rxdp)->Buffer0_ptr;
2347 Buffer1_ptr = ((struct RxD3*)rxdp)->Buffer1_ptr; 2419 Buffer1_ptr = ((struct RxD3*)rxdp)->Buffer1_ptr;
2348 memset(rxdp, 0, sizeof(struct RxD3)); 2420 memset(rxdp, 0, sizeof(struct RxD3));
@@ -2364,7 +2436,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2364 PCI_DMA_FROMDEVICE); 2436 PCI_DMA_FROMDEVICE);
2365 else 2437 else
2366 pci_dma_sync_single_for_device(nic->pdev, 2438 pci_dma_sync_single_for_device(nic->pdev,
2367 (dma_addr_t) ((struct RxD3*)rxdp)->Buffer0_ptr, 2439 (dma_addr_t) ((struct RxD3*)rxdp)->Buffer0_ptr,
2368 BUF0_LEN, PCI_DMA_FROMDEVICE); 2440 BUF0_LEN, PCI_DMA_FROMDEVICE);
2369 rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN); 2441 rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN);
2370 if (nic->rxd_mode == RXD_MODE_3B) { 2442 if (nic->rxd_mode == RXD_MODE_3B) {
@@ -2391,6 +2463,8 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2391 } else { 2463 } else {
2392 /* 3 buffer mode */ 2464 /* 3 buffer mode */
2393 if (fill_rxd_3buf(nic, rxdp, skb) == -ENOMEM) { 2465 if (fill_rxd_3buf(nic, rxdp, skb) == -ENOMEM) {
2466 nic->mac_control.stats_info->sw_stat.\
2467 mem_freed += skb->truesize;
2394 dev_kfree_skb_irq(skb); 2468 dev_kfree_skb_irq(skb);
2395 if (first_rxdp) { 2469 if (first_rxdp) {
2396 wmb(); 2470 wmb();
@@ -2491,6 +2565,7 @@ static void free_rxd_blk(struct s2io_nic *sp, int ring_no, int blk)
2491 PCI_DMA_FROMDEVICE); 2565 PCI_DMA_FROMDEVICE);
2492 memset(rxdp, 0, sizeof(struct RxD3)); 2566 memset(rxdp, 0, sizeof(struct RxD3));
2493 } 2567 }
2568 sp->mac_control.stats_info->sw_stat.mem_freed += skb->truesize;
2494 dev_kfree_skb(skb); 2569 dev_kfree_skb(skb);
2495 atomic_dec(&sp->rx_bufs_left[ring_no]); 2570 atomic_dec(&sp->rx_bufs_left[ring_no]);
2496 } 2571 }
@@ -2820,13 +2895,35 @@ static void tx_intr_handler(struct fifo_info *fifo_data)
2820 nic->mac_control.stats_info->sw_stat. 2895 nic->mac_control.stats_info->sw_stat.
2821 parity_err_cnt++; 2896 parity_err_cnt++;
2822 } 2897 }
2823 if ((err >> 48) == 0xA) { 2898
2824 DBG_PRINT(TX_DBG, "TxD returned due \ 2899 /* update t_code statistics */
2825 to loss of link\n"); 2900 err >>= 48;
2826 } 2901 switch(err) {
2827 else { 2902 case 2:
2828 DBG_PRINT(ERR_DBG, "***TxD error %llx\n", err); 2903 nic->mac_control.stats_info->sw_stat.
2829 } 2904 tx_buf_abort_cnt++;
2905 break;
2906
2907 case 3:
2908 nic->mac_control.stats_info->sw_stat.
2909 tx_desc_abort_cnt++;
2910 break;
2911
2912 case 7:
2913 nic->mac_control.stats_info->sw_stat.
2914 tx_parity_err_cnt++;
2915 break;
2916
2917 case 10:
2918 nic->mac_control.stats_info->sw_stat.
2919 tx_link_loss_cnt++;
2920 break;
2921
2922 case 15:
2923 nic->mac_control.stats_info->sw_stat.
2924 tx_list_proc_err_cnt++;
2925 break;
2926 }
2830 } 2927 }
2831 2928
2832 skb = s2io_txdl_getskb(fifo_data, txdlp, get_info.offset); 2929 skb = s2io_txdl_getskb(fifo_data, txdlp, get_info.offset);
@@ -2839,6 +2936,7 @@ static void tx_intr_handler(struct fifo_info *fifo_data)
2839 2936
2840 /* Updating the statistics block */ 2937 /* Updating the statistics block */
2841 nic->stats.tx_bytes += skb->len; 2938 nic->stats.tx_bytes += skb->len;
2939 nic->mac_control.stats_info->sw_stat.mem_freed += skb->truesize;
2842 dev_kfree_skb_irq(skb); 2940 dev_kfree_skb_irq(skb);
2843 2941
2844 get_info.offset++; 2942 get_info.offset++;
@@ -3314,7 +3412,9 @@ static void s2io_reset(struct s2io_nic * sp)
3314 u16 subid, pci_cmd; 3412 u16 subid, pci_cmd;
3315 int i; 3413 int i;
3316 u16 val16; 3414 u16 val16;
3317 unsigned long long reset_cnt = 0; 3415 unsigned long long up_cnt, down_cnt, up_time, down_time, reset_cnt;
3416 unsigned long long mem_alloc_cnt, mem_free_cnt, watchdog_cnt;
3417
3318 DBG_PRINT(INIT_DBG,"%s - Resetting XFrame card %s\n", 3418 DBG_PRINT(INIT_DBG,"%s - Resetting XFrame card %s\n",
3319 __FUNCTION__, sp->dev->name); 3419 __FUNCTION__, sp->dev->name);
3320 3420
@@ -3380,11 +3480,26 @@ new_way:
3380 3480
3381 /* Reset device statistics maintained by OS */ 3481 /* Reset device statistics maintained by OS */
3382 memset(&sp->stats, 0, sizeof (struct net_device_stats)); 3482 memset(&sp->stats, 0, sizeof (struct net_device_stats));
3383 /* save reset count */ 3483
3484 up_cnt = sp->mac_control.stats_info->sw_stat.link_up_cnt;
3485 down_cnt = sp->mac_control.stats_info->sw_stat.link_down_cnt;
3486 up_time = sp->mac_control.stats_info->sw_stat.link_up_time;
3487 down_time = sp->mac_control.stats_info->sw_stat.link_down_time;
3384 reset_cnt = sp->mac_control.stats_info->sw_stat.soft_reset_cnt; 3488 reset_cnt = sp->mac_control.stats_info->sw_stat.soft_reset_cnt;
3489 mem_alloc_cnt = sp->mac_control.stats_info->sw_stat.mem_allocated;
3490 mem_free_cnt = sp->mac_control.stats_info->sw_stat.mem_freed;
3491 watchdog_cnt = sp->mac_control.stats_info->sw_stat.watchdog_timer_cnt;
3492 /* save link up/down time/cnt, reset/memory/watchdog cnt */
3385 memset(sp->mac_control.stats_info, 0, sizeof(struct stat_block)); 3493 memset(sp->mac_control.stats_info, 0, sizeof(struct stat_block));
3386 /* restore reset count */ 3494 /* restore link up/down time/cnt, reset/memory/watchdog cnt */
3495 sp->mac_control.stats_info->sw_stat.link_up_cnt = up_cnt;
3496 sp->mac_control.stats_info->sw_stat.link_down_cnt = down_cnt;
3497 sp->mac_control.stats_info->sw_stat.link_up_time = up_time;
3498 sp->mac_control.stats_info->sw_stat.link_down_time = down_time;
3387 sp->mac_control.stats_info->sw_stat.soft_reset_cnt = reset_cnt; 3499 sp->mac_control.stats_info->sw_stat.soft_reset_cnt = reset_cnt;
3500 sp->mac_control.stats_info->sw_stat.mem_allocated = mem_alloc_cnt;
3501 sp->mac_control.stats_info->sw_stat.mem_freed = mem_free_cnt;
3502 sp->mac_control.stats_info->sw_stat.watchdog_timer_cnt = watchdog_cnt;
3388 3503
3389 /* SXE-002: Configure link and activity LED to turn it off */ 3504 /* SXE-002: Configure link and activity LED to turn it off */
3390 subid = sp->pdev->subsystem_device; 3505 subid = sp->pdev->subsystem_device;
@@ -3672,19 +3787,29 @@ static int s2io_enable_msi_x(struct s2io_nic *nic)
3672 nic->entries = kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct msix_entry), 3787 nic->entries = kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct msix_entry),
3673 GFP_KERNEL); 3788 GFP_KERNEL);
3674 if (nic->entries == NULL) { 3789 if (nic->entries == NULL) {
3675 DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", __FUNCTION__); 3790 DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", \
3791 __FUNCTION__);
3792 nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++;
3676 return -ENOMEM; 3793 return -ENOMEM;
3677 } 3794 }
3678 memset(nic->entries, 0, MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); 3795 nic->mac_control.stats_info->sw_stat.mem_allocated
3796 += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
3797 memset(nic->entries, 0,MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
3679 3798
3680 nic->s2io_entries = 3799 nic->s2io_entries =
3681 kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry), 3800 kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry),
3682 GFP_KERNEL); 3801 GFP_KERNEL);
3683 if (nic->s2io_entries == NULL) { 3802 if (nic->s2io_entries == NULL) {
3684 DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n", __FUNCTION__); 3803 DBG_PRINT(INFO_DBG, "%s: Memory allocation failed\n",
3804 __FUNCTION__);
3805 nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++;
3685 kfree(nic->entries); 3806 kfree(nic->entries);
3807 nic->mac_control.stats_info->sw_stat.mem_freed
3808 += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
3686 return -ENOMEM; 3809 return -ENOMEM;
3687 } 3810 }
3811 nic->mac_control.stats_info->sw_stat.mem_allocated
3812 += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry));
3688 memset(nic->s2io_entries, 0, 3813 memset(nic->s2io_entries, 0,
3689 MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); 3814 MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry));
3690 3815
@@ -3708,7 +3833,8 @@ static int s2io_enable_msi_x(struct s2io_nic *nic)
3708 rx_mat = readq(&bar0->rx_mat); 3833 rx_mat = readq(&bar0->rx_mat);
3709 for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) { 3834 for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) {
3710 rx_mat |= RX_MAT_SET(j, msix_indx); 3835 rx_mat |= RX_MAT_SET(j, msix_indx);
3711 nic->s2io_entries[msix_indx].arg = &nic->mac_control.rings[j]; 3836 nic->s2io_entries[msix_indx].arg
3837 = &nic->mac_control.rings[j];
3712 nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE; 3838 nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE;
3713 nic->s2io_entries[msix_indx].in_use = MSIX_FLG; 3839 nic->s2io_entries[msix_indx].in_use = MSIX_FLG;
3714 } 3840 }
@@ -3717,7 +3843,8 @@ static int s2io_enable_msi_x(struct s2io_nic *nic)
3717 tx_mat = readq(&bar0->tx_mat0_n[7]); 3843 tx_mat = readq(&bar0->tx_mat0_n[7]);
3718 for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) { 3844 for (j=0; j<nic->config.rx_ring_num; j++, msix_indx++) {
3719 tx_mat |= TX_MAT_SET(i, msix_indx); 3845 tx_mat |= TX_MAT_SET(i, msix_indx);
3720 nic->s2io_entries[msix_indx].arg = &nic->mac_control.rings[j]; 3846 nic->s2io_entries[msix_indx].arg
3847 = &nic->mac_control.rings[j];
3721 nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE; 3848 nic->s2io_entries[msix_indx].type = MSIX_RING_TYPE;
3722 nic->s2io_entries[msix_indx].in_use = MSIX_FLG; 3849 nic->s2io_entries[msix_indx].in_use = MSIX_FLG;
3723 } 3850 }
@@ -3734,7 +3861,11 @@ static int s2io_enable_msi_x(struct s2io_nic *nic)
3734 if (ret) { 3861 if (ret) {
3735 DBG_PRINT(ERR_DBG, "%s: Enabling MSIX failed\n", nic->dev->name); 3862 DBG_PRINT(ERR_DBG, "%s: Enabling MSIX failed\n", nic->dev->name);
3736 kfree(nic->entries); 3863 kfree(nic->entries);
3864 nic->mac_control.stats_info->sw_stat.mem_freed
3865 += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
3737 kfree(nic->s2io_entries); 3866 kfree(nic->s2io_entries);
3867 nic->mac_control.stats_info->sw_stat.mem_freed
3868 += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry));
3738 nic->entries = NULL; 3869 nic->entries = NULL;
3739 nic->s2io_entries = NULL; 3870 nic->s2io_entries = NULL;
3740 nic->avail_msix_vectors = 0; 3871 nic->avail_msix_vectors = 0;
@@ -3802,10 +3933,16 @@ static int s2io_open(struct net_device *dev)
3802 3933
3803hw_init_failed: 3934hw_init_failed:
3804 if (sp->intr_type == MSI_X) { 3935 if (sp->intr_type == MSI_X) {
3805 if (sp->entries) 3936 if (sp->entries) {
3806 kfree(sp->entries); 3937 kfree(sp->entries);
3807 if (sp->s2io_entries) 3938 sp->mac_control.stats_info->sw_stat.mem_freed
3939 += (MAX_REQUESTED_MSI_X * sizeof(struct msix_entry));
3940 }
3941 if (sp->s2io_entries) {
3808 kfree(sp->s2io_entries); 3942 kfree(sp->s2io_entries);
3943 sp->mac_control.stats_info->sw_stat.mem_freed
3944 += (MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry));
3945 }
3809 } 3946 }
3810 return err; 3947 return err;
3811} 3948}
@@ -3866,6 +4003,13 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
3866 config = &sp->config; 4003 config = &sp->config;
3867 4004
3868 DBG_PRINT(TX_DBG, "%s: In Neterion Tx routine\n", dev->name); 4005 DBG_PRINT(TX_DBG, "%s: In Neterion Tx routine\n", dev->name);
4006
4007 if (unlikely(skb->len <= 0)) {
4008 DBG_PRINT(TX_DBG, "%s:Buffer has no data..\n", dev->name);
4009 dev_kfree_skb_any(skb);
4010 return 0;
4011}
4012
3869 spin_lock_irqsave(&sp->tx_lock, flags); 4013 spin_lock_irqsave(&sp->tx_lock, flags);
3870 if (atomic_read(&sp->card_state) == CARD_DOWN) { 4014 if (atomic_read(&sp->card_state) == CARD_DOWN) {
3871 DBG_PRINT(TX_DBG, "%s: Card going down for reset\n", 4015 DBG_PRINT(TX_DBG, "%s: Card going down for reset\n",
@@ -3876,7 +4020,6 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
3876 } 4020 }
3877 4021
3878 queue = 0; 4022 queue = 0;
3879
3880 /* Get Fifo number to Transmit based on vlan priority */ 4023 /* Get Fifo number to Transmit based on vlan priority */
3881 if (sp->vlgrp && vlan_tx_tag_present(skb)) { 4024 if (sp->vlgrp && vlan_tx_tag_present(skb)) {
3882 vlan_tag = vlan_tx_tag_get(skb); 4025 vlan_tag = vlan_tx_tag_get(skb);
@@ -3900,14 +4043,6 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
3900 return 0; 4043 return 0;
3901 } 4044 }
3902 4045
3903 /* A buffer with no data will be dropped */
3904 if (!skb->len) {
3905 DBG_PRINT(TX_DBG, "%s:Buffer has no data..\n", dev->name);
3906 dev_kfree_skb(skb);
3907 spin_unlock_irqrestore(&sp->tx_lock, flags);
3908 return 0;
3909 }
3910
3911 offload_type = s2io_offload_type(skb); 4046 offload_type = s2io_offload_type(skb);
3912 if (offload_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) { 4047 if (offload_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) {
3913 txdp->Control_1 |= TXD_TCP_LSO_EN; 4048 txdp->Control_1 |= TXD_TCP_LSO_EN;
@@ -4003,7 +4138,7 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
4003 put_off, get_off); 4138 put_off, get_off);
4004 netif_stop_queue(dev); 4139 netif_stop_queue(dev);
4005 } 4140 }
4006 4141 mac_control->stats_info->sw_stat.mem_allocated += skb->truesize;
4007 dev->trans_start = jiffies; 4142 dev->trans_start = jiffies;
4008 spin_unlock_irqrestore(&sp->tx_lock, flags); 4143 spin_unlock_irqrestore(&sp->tx_lock, flags);
4009 4144
@@ -4775,6 +4910,40 @@ static int s2io_ethtool_idnic(struct net_device *dev, u32 data)
4775 return 0; 4910 return 0;
4776} 4911}
4777 4912
4913static void s2io_ethtool_gringparam(struct net_device *dev,
4914 struct ethtool_ringparam *ering)
4915{
4916 struct s2io_nic *sp = dev->priv;
4917 int i,tx_desc_count=0,rx_desc_count=0;
4918
4919 if (sp->rxd_mode == RXD_MODE_1)
4920 ering->rx_max_pending = MAX_RX_DESC_1;
4921 else if (sp->rxd_mode == RXD_MODE_3B)
4922 ering->rx_max_pending = MAX_RX_DESC_2;
4923 else if (sp->rxd_mode == RXD_MODE_3A)
4924 ering->rx_max_pending = MAX_RX_DESC_3;
4925
4926 ering->tx_max_pending = MAX_TX_DESC;
4927 for (i = 0 ; i < sp->config.tx_fifo_num ; i++) {
4928 tx_desc_count += sp->config.tx_cfg[i].fifo_len;
4929 }
4930 DBG_PRINT(INFO_DBG,"\nmax txds : %d\n",sp->config.max_txds);
4931 ering->tx_pending = tx_desc_count;
4932 rx_desc_count = 0;
4933 for (i = 0 ; i < sp->config.rx_ring_num ; i++) {
4934 rx_desc_count += sp->config.rx_cfg[i].num_rxd;
4935 }
4936 ering->rx_pending = rx_desc_count;
4937
4938 ering->rx_mini_max_pending = 0;
4939 ering->rx_mini_pending = 0;
4940 if(sp->rxd_mode == RXD_MODE_1)
4941 ering->rx_jumbo_max_pending = MAX_RX_DESC_1;
4942 else if (sp->rxd_mode == RXD_MODE_3B)
4943 ering->rx_jumbo_max_pending = MAX_RX_DESC_2;
4944 ering->rx_jumbo_pending = rx_desc_count;
4945}
4946
4778/** 4947/**
4779 * s2io_ethtool_getpause_data -Pause frame frame generation and reception. 4948 * s2io_ethtool_getpause_data -Pause frame frame generation and reception.
4780 * @sp : private member of the device structure, which is a pointer to the 4949 * @sp : private member of the device structure, which is a pointer to the
@@ -4981,8 +5150,11 @@ static void s2io_vpd_read(struct s2io_nic *nic)
4981 strcpy(nic->serial_num, "NOT AVAILABLE"); 5150 strcpy(nic->serial_num, "NOT AVAILABLE");
4982 5151
4983 vpd_data = kmalloc(256, GFP_KERNEL); 5152 vpd_data = kmalloc(256, GFP_KERNEL);
4984 if (!vpd_data) 5153 if (!vpd_data) {
5154 nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++;
4985 return; 5155 return;
5156 }
5157 nic->mac_control.stats_info->sw_stat.mem_allocated += 256;
4986 5158
4987 for (i = 0; i < 256; i +=4 ) { 5159 for (i = 0; i < 256; i +=4 ) {
4988 pci_write_config_byte(nic->pdev, (vpd_addr + 2), i); 5160 pci_write_config_byte(nic->pdev, (vpd_addr + 2), i);
@@ -5022,6 +5194,7 @@ static void s2io_vpd_read(struct s2io_nic *nic)
5022 memcpy(nic->product_name, &vpd_data[3], vpd_data[1]); 5194 memcpy(nic->product_name, &vpd_data[3], vpd_data[1]);
5023 } 5195 }
5024 kfree(vpd_data); 5196 kfree(vpd_data);
5197 nic->mac_control.stats_info->sw_stat.mem_freed += 256;
5025} 5198}
5026 5199
5027/** 5200/**
@@ -5742,6 +5915,30 @@ static void s2io_get_ethtool_stats(struct net_device *dev,
5742 } 5915 }
5743 else 5916 else
5744 tmp_stats[i++] = 0; 5917 tmp_stats[i++] = 0;
5918 tmp_stats[i++] = stat_info->sw_stat.mem_alloc_fail_cnt;
5919 tmp_stats[i++] = stat_info->sw_stat.watchdog_timer_cnt;
5920 tmp_stats[i++] = stat_info->sw_stat.mem_allocated;
5921 tmp_stats[i++] = stat_info->sw_stat.mem_freed;
5922 tmp_stats[i++] = stat_info->sw_stat.link_up_cnt;
5923 tmp_stats[i++] = stat_info->sw_stat.link_down_cnt;
5924 tmp_stats[i++] = stat_info->sw_stat.link_up_time;
5925 tmp_stats[i++] = stat_info->sw_stat.link_down_time;
5926
5927 tmp_stats[i++] = stat_info->sw_stat.tx_buf_abort_cnt;
5928 tmp_stats[i++] = stat_info->sw_stat.tx_desc_abort_cnt;
5929 tmp_stats[i++] = stat_info->sw_stat.tx_parity_err_cnt;
5930 tmp_stats[i++] = stat_info->sw_stat.tx_link_loss_cnt;
5931 tmp_stats[i++] = stat_info->sw_stat.tx_list_proc_err_cnt;
5932
5933 tmp_stats[i++] = stat_info->sw_stat.rx_parity_err_cnt;
5934 tmp_stats[i++] = stat_info->sw_stat.rx_abort_cnt;
5935 tmp_stats[i++] = stat_info->sw_stat.rx_parity_abort_cnt;
5936 tmp_stats[i++] = stat_info->sw_stat.rx_rda_fail_cnt;
5937 tmp_stats[i++] = stat_info->sw_stat.rx_unkn_prot_cnt;
5938 tmp_stats[i++] = stat_info->sw_stat.rx_fcs_err_cnt;
5939 tmp_stats[i++] = stat_info->sw_stat.rx_buf_size_err_cnt;
5940 tmp_stats[i++] = stat_info->sw_stat.rx_rxd_corrupt_cnt;
5941 tmp_stats[i++] = stat_info->sw_stat.rx_unkn_err_cnt;
5745} 5942}
5746 5943
5747static int s2io_ethtool_get_regs_len(struct net_device *dev) 5944static int s2io_ethtool_get_regs_len(struct net_device *dev)
@@ -5854,6 +6051,7 @@ static const struct ethtool_ops netdev_ethtool_ops = {
5854 .get_eeprom_len = s2io_get_eeprom_len, 6051 .get_eeprom_len = s2io_get_eeprom_len,
5855 .get_eeprom = s2io_ethtool_geeprom, 6052 .get_eeprom = s2io_ethtool_geeprom,
5856 .set_eeprom = s2io_ethtool_seeprom, 6053 .set_eeprom = s2io_ethtool_seeprom,
6054 .get_ringparam = s2io_ethtool_gringparam,
5857 .get_pauseparam = s2io_ethtool_getpause_data, 6055 .get_pauseparam = s2io_ethtool_getpause_data,
5858 .set_pauseparam = s2io_ethtool_setpause_data, 6056 .set_pauseparam = s2io_ethtool_setpause_data,
5859 .get_rx_csum = s2io_ethtool_get_rx_csum, 6057 .get_rx_csum = s2io_ethtool_get_rx_csum,
@@ -5962,7 +6160,7 @@ static void s2io_tasklet(unsigned long dev_addr)
5962 if (ret == -ENOMEM) { 6160 if (ret == -ENOMEM) {
5963 DBG_PRINT(INFO_DBG, "%s: Out of ", 6161 DBG_PRINT(INFO_DBG, "%s: Out of ",
5964 dev->name); 6162 dev->name);
5965 DBG_PRINT(ERR_DBG, "memory in tasklet\n"); 6163 DBG_PRINT(INFO_DBG, "memory in tasklet\n");
5966 break; 6164 break;
5967 } else if (ret == -EFILL) { 6165 } else if (ret == -EFILL) {
5968 DBG_PRINT(INFO_DBG, 6166 DBG_PRINT(INFO_DBG,
@@ -6077,9 +6275,14 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6077 *skb = dev_alloc_skb(size); 6275 *skb = dev_alloc_skb(size);
6078 if (!(*skb)) { 6276 if (!(*skb)) {
6079 DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name); 6277 DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name);
6080 DBG_PRINT(INFO_DBG, "memory to allocate SKBs\n"); 6278 DBG_PRINT(INFO_DBG, "memory to allocate ");
6279 DBG_PRINT(INFO_DBG, "1 buf mode SKBs\n");
6280 sp->mac_control.stats_info->sw_stat. \
6281 mem_alloc_fail_cnt++;
6081 return -ENOMEM ; 6282 return -ENOMEM ;
6082 } 6283 }
6284 sp->mac_control.stats_info->sw_stat.mem_allocated
6285 += (*skb)->truesize;
6083 /* storing the mapped addr in a temp variable 6286 /* storing the mapped addr in a temp variable
6084 * such it will be used for next rxd whose 6287 * such it will be used for next rxd whose
6085 * Host Control is NULL 6288 * Host Control is NULL
@@ -6099,10 +6302,15 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6099 } else { 6302 } else {
6100 *skb = dev_alloc_skb(size); 6303 *skb = dev_alloc_skb(size);
6101 if (!(*skb)) { 6304 if (!(*skb)) {
6102 DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n", 6305 DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name);
6103 dev->name); 6306 DBG_PRINT(INFO_DBG, "memory to allocate ");
6307 DBG_PRINT(INFO_DBG, "2 buf mode SKBs\n");
6308 sp->mac_control.stats_info->sw_stat. \
6309 mem_alloc_fail_cnt++;
6104 return -ENOMEM; 6310 return -ENOMEM;
6105 } 6311 }
6312 sp->mac_control.stats_info->sw_stat.mem_allocated
6313 += (*skb)->truesize;
6106 ((struct RxD3*)rxdp)->Buffer2_ptr = *temp2 = 6314 ((struct RxD3*)rxdp)->Buffer2_ptr = *temp2 =
6107 pci_map_single(sp->pdev, (*skb)->data, 6315 pci_map_single(sp->pdev, (*skb)->data,
6108 dev->mtu + 4, 6316 dev->mtu + 4,
@@ -6126,10 +6334,15 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6126 } else { 6334 } else {
6127 *skb = dev_alloc_skb(size); 6335 *skb = dev_alloc_skb(size);
6128 if (!(*skb)) { 6336 if (!(*skb)) {
6129 DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n", 6337 DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name);
6130 dev->name); 6338 DBG_PRINT(INFO_DBG, "memory to allocate ");
6339 DBG_PRINT(INFO_DBG, "3 buf mode SKBs\n");
6340 sp->mac_control.stats_info->sw_stat. \
6341 mem_alloc_fail_cnt++;
6131 return -ENOMEM; 6342 return -ENOMEM;
6132 } 6343 }
6344 sp->mac_control.stats_info->sw_stat.mem_allocated
6345 += (*skb)->truesize;
6133 ((struct RxD3*)rxdp)->Buffer0_ptr = *temp0 = 6346 ((struct RxD3*)rxdp)->Buffer0_ptr = *temp0 =
6134 pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN, 6347 pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN,
6135 PCI_DMA_FROMDEVICE); 6348 PCI_DMA_FROMDEVICE);
@@ -6147,10 +6360,14 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6147 if (skb_shinfo(*skb)->frag_list == NULL) { 6360 if (skb_shinfo(*skb)->frag_list == NULL) {
6148 DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb \ 6361 DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb \
6149 failed\n ", dev->name); 6362 failed\n ", dev->name);
6363 sp->mac_control.stats_info->sw_stat. \
6364 mem_alloc_fail_cnt++;
6150 return -ENOMEM ; 6365 return -ENOMEM ;
6151 } 6366 }
6152 frag_list = skb_shinfo(*skb)->frag_list; 6367 frag_list = skb_shinfo(*skb)->frag_list;
6153 frag_list->next = NULL; 6368 frag_list->next = NULL;
6369 sp->mac_control.stats_info->sw_stat.mem_allocated
6370 += frag_list->truesize;
6154 /* 6371 /*
6155 * Buffer-2 receives L4 data payload 6372 * Buffer-2 receives L4 data payload
6156 */ 6373 */
@@ -6566,6 +6783,7 @@ static void s2io_tx_watchdog(struct net_device *dev)
6566 struct s2io_nic *sp = dev->priv; 6783 struct s2io_nic *sp = dev->priv;
6567 6784
6568 if (netif_carrier_ok(dev)) { 6785 if (netif_carrier_ok(dev)) {
6786 sp->mac_control.stats_info->sw_stat.watchdog_timer_cnt++;
6569 schedule_work(&sp->rst_timer_task); 6787 schedule_work(&sp->rst_timer_task);
6570 sp->mac_control.stats_info->sw_stat.soft_reset_cnt++; 6788 sp->mac_control.stats_info->sw_stat.soft_reset_cnt++;
6571 } 6789 }
@@ -6606,7 +6824,53 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
6606 if (err & 0x1) { 6824 if (err & 0x1) {
6607 sp->mac_control.stats_info->sw_stat.parity_err_cnt++; 6825 sp->mac_control.stats_info->sw_stat.parity_err_cnt++;
6608 } 6826 }
6827 err >>= 48;
6828 switch(err) {
6829 case 1:
6830 sp->mac_control.stats_info->sw_stat.
6831 rx_parity_err_cnt++;
6832 break;
6609 6833
6834 case 2:
6835 sp->mac_control.stats_info->sw_stat.
6836 rx_abort_cnt++;
6837 break;
6838
6839 case 3:
6840 sp->mac_control.stats_info->sw_stat.
6841 rx_parity_abort_cnt++;
6842 break;
6843
6844 case 4:
6845 sp->mac_control.stats_info->sw_stat.
6846 rx_rda_fail_cnt++;
6847 break;
6848
6849 case 5:
6850 sp->mac_control.stats_info->sw_stat.
6851 rx_unkn_prot_cnt++;
6852 break;
6853
6854 case 6:
6855 sp->mac_control.stats_info->sw_stat.
6856 rx_fcs_err_cnt++;
6857 break;
6858
6859 case 7:
6860 sp->mac_control.stats_info->sw_stat.
6861 rx_buf_size_err_cnt++;
6862 break;
6863
6864 case 8:
6865 sp->mac_control.stats_info->sw_stat.
6866 rx_rxd_corrupt_cnt++;
6867 break;
6868
6869 case 15:
6870 sp->mac_control.stats_info->sw_stat.
6871 rx_unkn_err_cnt++;
6872 break;
6873 }
6610 /* 6874 /*
6611 * Drop the packet if bad transfer code. Exception being 6875 * Drop the packet if bad transfer code. Exception being
6612 * 0x5, which could be due to unsupported IPv6 extension header. 6876 * 0x5, which could be due to unsupported IPv6 extension header.
@@ -6614,10 +6878,12 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
6614 * Note that in this case, since checksum will be incorrect, 6878 * Note that in this case, since checksum will be incorrect,
6615 * stack will validate the same. 6879 * stack will validate the same.
6616 */ 6880 */
6617 if (err && ((err >> 48) != 0x5)) { 6881 if (err != 0x5) {
6618 DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%llx\n", 6882 DBG_PRINT(ERR_DBG, "%s: Rx error Value: 0x%llx\n",
6619 dev->name, err); 6883 dev->name, err);
6620 sp->stats.rx_crc_errors++; 6884 sp->stats.rx_crc_errors++;
6885 sp->mac_control.stats_info->sw_stat.mem_freed
6886 += skb->truesize;
6621 dev_kfree_skb(skb); 6887 dev_kfree_skb(skb);
6622 atomic_dec(&sp->rx_bufs_left[ring_no]); 6888 atomic_dec(&sp->rx_bufs_left[ring_no]);
6623 rxdp->Host_Control = 0; 6889 rxdp->Host_Control = 0;
@@ -6627,7 +6893,6 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
6627 6893
6628 /* Updating statistics */ 6894 /* Updating statistics */
6629 rxdp->Host_Control = 0; 6895 rxdp->Host_Control = 0;
6630 sp->stats.rx_packets++;
6631 if (sp->rxd_mode == RXD_MODE_1) { 6896 if (sp->rxd_mode == RXD_MODE_1) {
6632 int len = RXD_GET_BUFFER0_SIZE_1(rxdp->Control_2); 6897 int len = RXD_GET_BUFFER0_SIZE_1(rxdp->Control_2);
6633 6898
@@ -6731,7 +6996,7 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
6731 } else { 6996 } else {
6732 skb->ip_summed = CHECKSUM_NONE; 6997 skb->ip_summed = CHECKSUM_NONE;
6733 } 6998 }
6734 6999 sp->mac_control.stats_info->sw_stat.mem_freed += skb->truesize;
6735 if (!sp->lro) { 7000 if (!sp->lro) {
6736 skb->protocol = eth_type_trans(skb, dev); 7001 skb->protocol = eth_type_trans(skb, dev);
6737 if ((sp->vlgrp && RXD_GET_VLAN_TAG(rxdp->Control_2) && 7002 if ((sp->vlgrp && RXD_GET_VLAN_TAG(rxdp->Control_2) &&
@@ -6780,12 +7045,21 @@ static void s2io_link(struct s2io_nic * sp, int link)
6780 if (link == LINK_DOWN) { 7045 if (link == LINK_DOWN) {
6781 DBG_PRINT(ERR_DBG, "%s: Link down\n", dev->name); 7046 DBG_PRINT(ERR_DBG, "%s: Link down\n", dev->name);
6782 netif_carrier_off(dev); 7047 netif_carrier_off(dev);
7048 if(sp->mac_control.stats_info->sw_stat.link_up_cnt)
7049 sp->mac_control.stats_info->sw_stat.link_up_time =
7050 jiffies - sp->start_time;
7051 sp->mac_control.stats_info->sw_stat.link_down_cnt++;
6783 } else { 7052 } else {
6784 DBG_PRINT(ERR_DBG, "%s: Link Up\n", dev->name); 7053 DBG_PRINT(ERR_DBG, "%s: Link Up\n", dev->name);
7054 if (sp->mac_control.stats_info->sw_stat.link_down_cnt)
7055 sp->mac_control.stats_info->sw_stat.link_down_time =
7056 jiffies - sp->start_time;
7057 sp->mac_control.stats_info->sw_stat.link_up_cnt++;
6785 netif_carrier_on(dev); 7058 netif_carrier_on(dev);
6786 } 7059 }
6787 } 7060 }
6788 sp->last_link_state = link; 7061 sp->last_link_state = link;
7062 sp->start_time = jiffies;
6789} 7063}
6790 7064
6791/** 7065/**
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h
index a656d18b33df..54baa0b8ec7c 100644
--- a/drivers/net/s2io.h
+++ b/drivers/net/s2io.h
@@ -95,6 +95,32 @@ struct swStat {
95 unsigned long long flush_max_pkts; 95 unsigned long long flush_max_pkts;
96 unsigned long long sum_avg_pkts_aggregated; 96 unsigned long long sum_avg_pkts_aggregated;
97 unsigned long long num_aggregations; 97 unsigned long long num_aggregations;
98 /* Other statistics */
99 unsigned long long mem_alloc_fail_cnt;
100 unsigned long long watchdog_timer_cnt;
101 unsigned long long mem_allocated;
102 unsigned long long mem_freed;
103 unsigned long long link_up_cnt;
104 unsigned long long link_down_cnt;
105 unsigned long long link_up_time;
106 unsigned long long link_down_time;
107
108 /* Transfer Code statistics */
109 unsigned long long tx_buf_abort_cnt;
110 unsigned long long tx_desc_abort_cnt;
111 unsigned long long tx_parity_err_cnt;
112 unsigned long long tx_link_loss_cnt;
113 unsigned long long tx_list_proc_err_cnt;
114
115 unsigned long long rx_parity_err_cnt;
116 unsigned long long rx_abort_cnt;
117 unsigned long long rx_parity_abort_cnt;
118 unsigned long long rx_rda_fail_cnt;
119 unsigned long long rx_unkn_prot_cnt;
120 unsigned long long rx_fcs_err_cnt;
121 unsigned long long rx_buf_size_err_cnt;
122 unsigned long long rx_rxd_corrupt_cnt;
123 unsigned long long rx_unkn_err_cnt;
98}; 124};
99 125
100/* Xpak releated alarm and warnings */ 126/* Xpak releated alarm and warnings */
@@ -308,6 +334,11 @@ struct stat_block {
308#define MAX_TX_FIFOS 8 334#define MAX_TX_FIFOS 8
309#define MAX_RX_RINGS 8 335#define MAX_RX_RINGS 8
310 336
337#define MAX_RX_DESC_1 (MAX_RX_RINGS * MAX_RX_BLOCKS_PER_RING * 127 )
338#define MAX_RX_DESC_2 (MAX_RX_RINGS * MAX_RX_BLOCKS_PER_RING * 85 )
339#define MAX_RX_DESC_3 (MAX_RX_RINGS * MAX_RX_BLOCKS_PER_RING * 85 )
340#define MAX_TX_DESC (MAX_AVAILABLE_TXDS)
341
311/* FIFO mappings for all possible number of fifos configured */ 342/* FIFO mappings for all possible number of fifos configured */
312static int fifo_map[][MAX_TX_FIFOS] = { 343static int fifo_map[][MAX_TX_FIFOS] = {
313 {0, 0, 0, 0, 0, 0, 0, 0}, 344 {0, 0, 0, 0, 0, 0, 0, 0},
@@ -819,6 +850,7 @@ struct s2io_nic {
819#define LINK_UP 2 850#define LINK_UP 2
820 851
821 int task_flag; 852 int task_flag;
853 unsigned long long start_time;
822#define CARD_DOWN 1 854#define CARD_DOWN 1
823#define CARD_UP 2 855#define CARD_UP 2
824 atomic_t card_state; 856 atomic_t card_state;
diff --git a/drivers/net/sgiseeq.c b/drivers/net/sgiseeq.c
index 1fc77300b055..2106becf6990 100644
--- a/drivers/net/sgiseeq.c
+++ b/drivers/net/sgiseeq.c
@@ -16,11 +16,13 @@
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/netdevice.h> 18#include <linux/netdevice.h>
19#include <linux/platform_device.h>
19#include <linux/etherdevice.h> 20#include <linux/etherdevice.h>
20#include <linux/skbuff.h> 21#include <linux/skbuff.h>
21 22
22#include <asm/sgi/hpc3.h> 23#include <asm/sgi/hpc3.h>
23#include <asm/sgi/ip22.h> 24#include <asm/sgi/ip22.h>
25#include <asm/sgi/seeq.h>
24 26
25#include "sgiseeq.h" 27#include "sgiseeq.h"
26 28
@@ -92,13 +94,9 @@ struct sgiseeq_private {
92 94
93 struct net_device_stats stats; 95 struct net_device_stats stats;
94 96
95 struct net_device *next_module;
96 spinlock_t tx_lock; 97 spinlock_t tx_lock;
97}; 98};
98 99
99/* A list of all installed seeq devices, for removing the driver module. */
100static struct net_device *root_sgiseeq_dev;
101
102static inline void hpc3_eth_reset(struct hpc3_ethregs *hregs) 100static inline void hpc3_eth_reset(struct hpc3_ethregs *hregs)
103{ 101{
104 hregs->reset = HPC3_ERST_CRESET | HPC3_ERST_CLRIRQ; 102 hregs->reset = HPC3_ERST_CRESET | HPC3_ERST_CLRIRQ;
@@ -624,9 +622,12 @@ static inline void setup_rx_ring(struct sgiseeq_rx_desc *buf, int nbufs)
624 622
625#define ALIGNED(x) ((((unsigned long)(x)) + 0xf) & ~(0xf)) 623#define ALIGNED(x) ((((unsigned long)(x)) + 0xf) & ~(0xf))
626 624
627static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq, int has_eeprom) 625static int __init sgiseeq_probe(struct platform_device *pdev)
628{ 626{
627 struct sgiseeq_platform_data *pd = pdev->dev.platform_data;
628 struct hpc3_regs *hpcregs = pd->hpc;
629 struct sgiseeq_init_block *sr; 629 struct sgiseeq_init_block *sr;
630 unsigned int irq = pd->irq;
630 struct sgiseeq_private *sp; 631 struct sgiseeq_private *sp;
631 struct net_device *dev; 632 struct net_device *dev;
632 int err, i; 633 int err, i;
@@ -637,6 +638,8 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq, int has_eeprom)
637 err = -ENOMEM; 638 err = -ENOMEM;
638 goto err_out; 639 goto err_out;
639 } 640 }
641
642 platform_set_drvdata(pdev, dev);
640 sp = netdev_priv(dev); 643 sp = netdev_priv(dev);
641 644
642 /* Make private data page aligned */ 645 /* Make private data page aligned */
@@ -648,15 +651,7 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq, int has_eeprom)
648 } 651 }
649 sp->srings = sr; 652 sp->srings = sr;
650 653
651#define EADDR_NVOFS 250 654 memcpy(dev->dev_addr, pd->mac, ETH_ALEN);
652 for (i = 0; i < 3; i++) {
653 unsigned short tmp = has_eeprom ?
654 ip22_eeprom_read(&hpcregs->eeprom, EADDR_NVOFS / 2+i) :
655 ip22_nvram_read(EADDR_NVOFS / 2+i);
656
657 dev->dev_addr[2 * i] = tmp >> 8;
658 dev->dev_addr[2 * i + 1] = tmp & 0xff;
659 }
660 655
661#ifdef DEBUG 656#ifdef DEBUG
662 gpriv = sp; 657 gpriv = sp;
@@ -720,9 +715,6 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq, int has_eeprom)
720 for (i = 0; i < 6; i++) 715 for (i = 0; i < 6; i++)
721 printk("%2.2x%c", dev->dev_addr[i], i == 5 ? '\n' : ':'); 716 printk("%2.2x%c", dev->dev_addr[i], i == 5 ? '\n' : ':');
722 717
723 sp->next_module = root_sgiseeq_dev;
724 root_sgiseeq_dev = dev;
725
726 return 0; 718 return 0;
727 719
728err_out_free_page: 720err_out_free_page:
@@ -734,43 +726,42 @@ err_out:
734 return err; 726 return err;
735} 727}
736 728
737static int __init sgiseeq_probe(void) 729static void __exit sgiseeq_remove(struct platform_device *pdev)
738{ 730{
739 unsigned int tmp, ret1, ret2 = 0; 731 struct net_device *dev = platform_get_drvdata(pdev);
740 732 struct sgiseeq_private *sp = netdev_priv(dev);
741 /* On board adapter on 1st HPC is always present */
742 ret1 = sgiseeq_init(hpc3c0, SGI_ENET_IRQ, 0);
743 /* Let's see if second HPC is there */
744 if (!(ip22_is_fullhouse()) &&
745 get_dbe(tmp, (unsigned int *)&hpc3c1->pbdma[1]) == 0) {
746 sgimc->giopar |= SGIMC_GIOPAR_MASTEREXP1 |
747 SGIMC_GIOPAR_EXP164 |
748 SGIMC_GIOPAR_HPC264;
749 hpc3c1->pbus_piocfg[0][0] = 0x3ffff;
750 /* interrupt/config register on Challenge S Mezz board */
751 hpc3c1->pbus_extregs[0][0] = 0x30;
752 ret2 = sgiseeq_init(hpc3c1, SGI_GIO_0_IRQ, 1);
753 }
754 733
755 return (ret1 & ret2) ? ret1 : 0; 734 unregister_netdev(dev);
735 free_page((unsigned long) sp->srings);
736 free_netdev(dev);
737 platform_set_drvdata(pdev, NULL);
756} 738}
757 739
758static void __exit sgiseeq_exit(void) 740static struct platform_driver sgiseeq_driver = {
759{ 741 .probe = sgiseeq_probe,
760 struct net_device *next, *dev; 742 .remove = __devexit_p(sgiseeq_remove),
761 struct sgiseeq_private *sp; 743 .driver = {
744 .name = "sgiseeq"
745 }
746};
762 747
763 for (dev = root_sgiseeq_dev; dev; dev = next) { 748static int __init sgiseeq_module_init(void)
764 sp = (struct sgiseeq_private *) netdev_priv(dev); 749{
765 next = sp->next_module; 750 if (platform_driver_register(&sgiseeq_driver)) {
766 unregister_netdev(dev); 751 printk(KERN_ERR "Driver registration failed\n");
767 free_page((unsigned long) sp->srings); 752 return -ENODEV;
768 free_netdev(dev);
769 } 753 }
754
755 return 0;
756}
757
758static void __exit sgiseeq_module_exit(void)
759{
760 platform_driver_unregister(&sgiseeq_driver);
770} 761}
771 762
772module_init(sgiseeq_probe); 763module_init(sgiseeq_module_init);
773module_exit(sgiseeq_exit); 764module_exit(sgiseeq_module_exit);
774 765
775MODULE_DESCRIPTION("SGI Seeq 8003 driver"); 766MODULE_DESCRIPTION("SGI Seeq 8003 driver");
776MODULE_AUTHOR("Linux/MIPS Mailing List <linux-mips@linux-mips.org>"); 767MODULE_AUTHOR("Linux/MIPS Mailing List <linux-mips@linux-mips.org>");
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index e0489578945d..776692946562 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -3802,6 +3802,9 @@ static int skge_suspend(struct pci_dev *pdev, pm_message_t state)
3802 struct skge_hw *hw = pci_get_drvdata(pdev); 3802 struct skge_hw *hw = pci_get_drvdata(pdev);
3803 int i, err, wol = 0; 3803 int i, err, wol = 0;
3804 3804
3805 if (!hw)
3806 return 0;
3807
3805 err = pci_save_state(pdev); 3808 err = pci_save_state(pdev);
3806 if (err) 3809 if (err)
3807 return err; 3810 return err;
@@ -3830,6 +3833,9 @@ static int skge_resume(struct pci_dev *pdev)
3830 struct skge_hw *hw = pci_get_drvdata(pdev); 3833 struct skge_hw *hw = pci_get_drvdata(pdev);
3831 int i, err; 3834 int i, err;
3832 3835
3836 if (!hw)
3837 return 0;
3838
3833 err = pci_set_power_state(pdev, PCI_D0); 3839 err = pci_set_power_state(pdev, PCI_D0);
3834 if (err) 3840 if (err)
3835 goto out; 3841 goto out;
@@ -3868,6 +3874,9 @@ static void skge_shutdown(struct pci_dev *pdev)
3868 struct skge_hw *hw = pci_get_drvdata(pdev); 3874 struct skge_hw *hw = pci_get_drvdata(pdev);
3869 int i, wol = 0; 3875 int i, wol = 0;
3870 3876
3877 if (!hw)
3878 return;
3879
3871 for (i = 0; i < hw->ports; i++) { 3880 for (i = 0; i < hw->ports; i++) {
3872 struct net_device *dev = hw->dev[i]; 3881 struct net_device *dev = hw->dev[i];
3873 struct skge_port *skge = netdev_priv(dev); 3882 struct skge_port *skge = netdev_priv(dev);
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index a307310f13f5..104e20456e6f 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -40,6 +40,7 @@
40#include <linux/if_vlan.h> 40#include <linux/if_vlan.h>
41#include <linux/prefetch.h> 41#include <linux/prefetch.h>
42#include <linux/mii.h> 42#include <linux/mii.h>
43#include <linux/dmi.h>
43 44
44#include <asm/irq.h> 45#include <asm/irq.h>
45 46
@@ -130,7 +131,7 @@ static const struct pci_device_id sky2_id_table[] = {
130 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, /* 88EC034 */ 131 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, /* 88EC034 */
131 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4369) }, /* 88EC042 */ 132 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4369) }, /* 88EC042 */
132 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436A) }, /* 88E8058 */ 133 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436A) }, /* 88E8058 */
133 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436B) }, /* 88E8071 */ 134// { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436B) }, /* 88E8071 */
134 { 0 } 135 { 0 }
135}; 136};
136 137
@@ -150,6 +151,8 @@ static const char *yukon2_name[] = {
150 "FE", /* 0xb7 */ 151 "FE", /* 0xb7 */
151}; 152};
152 153
154static int dmi_blacklisted;
155
153/* Access to external PHY */ 156/* Access to external PHY */
154static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val) 157static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
155{ 158{
@@ -2531,6 +2534,17 @@ static int __devinit sky2_init(struct sky2_hw *hw)
2531 return -EOPNOTSUPP; 2534 return -EOPNOTSUPP;
2532 } 2535 }
2533 2536
2537
2538 /* Some Gigabyte motherboards have 88e8056 but cause problems
2539 * There is some unresolved hardware related problem that causes
2540 * descriptor errors and receive data corruption.
2541 */
2542 if (hw->chip_id == CHIP_ID_YUKON_EC_U && dmi_blacklisted) {
2543 dev_err(&hw->pdev->dev,
2544 "88E8056 on this motherboard not supported\n");
2545 return -EOPNOTSUPP;
2546 }
2547
2534 hw->pmd_type = sky2_read8(hw, B2_PMD_TYP); 2548 hw->pmd_type = sky2_read8(hw, B2_PMD_TYP);
2535 hw->ports = 1; 2549 hw->ports = 1;
2536 t8 = sky2_read8(hw, B2_Y2_HW_RES); 2550 t8 = sky2_read8(hw, B2_Y2_HW_RES);
@@ -3578,17 +3592,6 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3578 goto err_out; 3592 goto err_out;
3579 } 3593 }
3580 3594
3581 /* Some Gigabyte motherboards have 88e8056 but cause problems
3582 * There is some unresolved hardware related problem that causes
3583 * descriptor errors and receive data corruption.
3584 */
3585 if (pdev->vendor == PCI_VENDOR_ID_MARVELL &&
3586 pdev->device == 0x4364 && pdev->subsystem_vendor == 0x1458) {
3587 dev_err(&pdev->dev,
3588 "88E8056 on Gigabyte motherboards not supported\n");
3589 goto err_out_disable;
3590 }
3591
3592 err = pci_request_regions(pdev, DRV_NAME); 3595 err = pci_request_regions(pdev, DRV_NAME);
3593 if (err) { 3596 if (err) {
3594 dev_err(&pdev->dev, "cannot obtain PCI resources\n"); 3597 dev_err(&pdev->dev, "cannot obtain PCI resources\n");
@@ -3732,6 +3735,7 @@ err_out_free_regions:
3732err_out_disable: 3735err_out_disable:
3733 pci_disable_device(pdev); 3736 pci_disable_device(pdev);
3734err_out: 3737err_out:
3738 pci_set_drvdata(pdev, NULL);
3735 return err; 3739 return err;
3736} 3740}
3737 3741
@@ -3784,6 +3788,9 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
3784 struct sky2_hw *hw = pci_get_drvdata(pdev); 3788 struct sky2_hw *hw = pci_get_drvdata(pdev);
3785 int i, wol = 0; 3789 int i, wol = 0;
3786 3790
3791 if (!hw)
3792 return 0;
3793
3787 del_timer_sync(&hw->idle_timer); 3794 del_timer_sync(&hw->idle_timer);
3788 netif_poll_disable(hw->dev[0]); 3795 netif_poll_disable(hw->dev[0]);
3789 3796
@@ -3815,6 +3822,9 @@ static int sky2_resume(struct pci_dev *pdev)
3815 struct sky2_hw *hw = pci_get_drvdata(pdev); 3822 struct sky2_hw *hw = pci_get_drvdata(pdev);
3816 int i, err; 3823 int i, err;
3817 3824
3825 if (!hw)
3826 return 0;
3827
3818 err = pci_set_power_state(pdev, PCI_D0); 3828 err = pci_set_power_state(pdev, PCI_D0);
3819 if (err) 3829 if (err)
3820 goto out; 3830 goto out;
@@ -3861,6 +3871,9 @@ static void sky2_shutdown(struct pci_dev *pdev)
3861 struct sky2_hw *hw = pci_get_drvdata(pdev); 3871 struct sky2_hw *hw = pci_get_drvdata(pdev);
3862 int i, wol = 0; 3872 int i, wol = 0;
3863 3873
3874 if (!hw)
3875 return;
3876
3864 del_timer_sync(&hw->idle_timer); 3877 del_timer_sync(&hw->idle_timer);
3865 netif_poll_disable(hw->dev[0]); 3878 netif_poll_disable(hw->dev[0]);
3866 3879
@@ -3897,8 +3910,24 @@ static struct pci_driver sky2_driver = {
3897 .shutdown = sky2_shutdown, 3910 .shutdown = sky2_shutdown,
3898}; 3911};
3899 3912
3913static struct dmi_system_id __initdata broken_dmi_table[] = {
3914 {
3915 .ident = "Gigabyte 965P-S3",
3916 .matches = {
3917 DMI_MATCH(DMI_SYS_VENDOR, "Gigabyte Technology Co., Ltd."),
3918 DMI_MATCH(DMI_PRODUCT_NAME, "965P-S3"),
3919
3920 },
3921 },
3922 { }
3923};
3924
3900static int __init sky2_init_module(void) 3925static int __init sky2_init_module(void)
3901{ 3926{
3927 /* Look for sick motherboards */
3928 if (dmi_check_system(broken_dmi_table))
3929 dmi_blacklisted = 1;
3930
3902 return pci_register_driver(&sky2_driver); 3931 return pci_register_driver(&sky2_driver);
3903} 3932}
3904 3933
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index c15e97253ede..108adbf5b5eb 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -175,12 +175,10 @@ spider_net_setup_aneg(struct spider_net_card *card)
175{ 175{
176 struct mii_phy *phy = &card->phy; 176 struct mii_phy *phy = &card->phy;
177 u32 advertise = 0; 177 u32 advertise = 0;
178 u16 bmcr, bmsr, stat1000, estat; 178 u16 bmsr, estat;
179 179
180 bmcr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMCR); 180 bmsr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR);
181 bmsr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR); 181 estat = spider_net_read_phy(card->netdev, phy->mii_id, MII_ESTATUS);
182 stat1000 = spider_net_read_phy(card->netdev, phy->mii_id, MII_STAT1000);
183 estat = spider_net_read_phy(card->netdev, phy->mii_id, MII_ESTATUS);
184 182
185 if (bmsr & BMSR_10HALF) 183 if (bmsr & BMSR_10HALF)
186 advertise |= ADVERTISED_10baseT_Half; 184 advertise |= ADVERTISED_10baseT_Half;
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index 8897f538a7c7..4fc8681bc110 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -2,10 +2,7 @@
2# wan devices configuration 2# wan devices configuration
3# 3#
4 4
5menu "Wan interfaces" 5menuconfig WAN
6 depends on NETDEVICES
7
8config WAN
9 bool "Wan interfaces support" 6 bool "Wan interfaces support"
10 ---help--- 7 ---help---
11 Wide Area Networks (WANs), such as X.25, Frame Relay and leased 8 Wide Area Networks (WANs), such as X.25, Frame Relay and leased
@@ -23,10 +20,12 @@ config WAN
23 20
24 If unsure, say N. 21 If unsure, say N.
25 22
23if WAN
24
26# There is no way to detect a comtrol sv11 - force it modular for now. 25# There is no way to detect a comtrol sv11 - force it modular for now.
27config HOSTESS_SV11 26config HOSTESS_SV11
28 tristate "Comtrol Hostess SV-11 support" 27 tristate "Comtrol Hostess SV-11 support"
29 depends on WAN && ISA && m && ISA_DMA_API && INET 28 depends on ISA && m && ISA_DMA_API && INET
30 help 29 help
31 Driver for Comtrol Hostess SV-11 network card which 30 Driver for Comtrol Hostess SV-11 network card which
32 operates on low speed synchronous serial links at up to 31 operates on low speed synchronous serial links at up to
@@ -38,7 +37,7 @@ config HOSTESS_SV11
38# The COSA/SRP driver has not been tested as non-modular yet. 37# The COSA/SRP driver has not been tested as non-modular yet.
39config COSA 38config COSA
40 tristate "COSA/SRP sync serial boards support" 39 tristate "COSA/SRP sync serial boards support"
41 depends on WAN && ISA && m && ISA_DMA_API 40 depends on ISA && m && ISA_DMA_API
42 ---help--- 41 ---help---
43 Driver for COSA and SRP synchronous serial boards. 42 Driver for COSA and SRP synchronous serial boards.
44 43
@@ -62,7 +61,7 @@ config COSA
62# 61#
63config LANMEDIA 62config LANMEDIA
64 tristate "LanMedia Corp. SSI/V.35, T1/E1, HSSI, T3 boards" 63 tristate "LanMedia Corp. SSI/V.35, T1/E1, HSSI, T3 boards"
65 depends on WAN && PCI 64 depends on PCI
66 ---help--- 65 ---help---
67 Driver for the following Lan Media family of serial boards: 66 Driver for the following Lan Media family of serial boards:
68 67
@@ -89,7 +88,7 @@ config LANMEDIA
89# There is no way to detect a Sealevel board. Force it modular 88# There is no way to detect a Sealevel board. Force it modular
90config SEALEVEL_4021 89config SEALEVEL_4021
91 tristate "Sealevel Systems 4021 support" 90 tristate "Sealevel Systems 4021 support"
92 depends on WAN && ISA && m && ISA_DMA_API && INET 91 depends on ISA && m && ISA_DMA_API && INET
93 help 92 help
94 This is a driver for the Sealevel Systems ACB 56 serial I/O adapter. 93 This is a driver for the Sealevel Systems ACB 56 serial I/O adapter.
95 94
@@ -99,7 +98,6 @@ config SEALEVEL_4021
99# Generic HDLC 98# Generic HDLC
100config HDLC 99config HDLC
101 tristate "Generic HDLC layer" 100 tristate "Generic HDLC layer"
102 depends on WAN
103 help 101 help
104 Say Y to this option if your Linux box contains a WAN (Wide Area 102 Say Y to this option if your Linux box contains a WAN (Wide Area
105 Network) card supported by this driver and you are planning to 103 Network) card supported by this driver and you are planning to
@@ -167,7 +165,7 @@ config HDLC_X25
167 If unsure, say N. 165 If unsure, say N.
168 166
169comment "X.25/LAPB support is disabled" 167comment "X.25/LAPB support is disabled"
170 depends on WAN && HDLC && (LAPB!=m || HDLC!=m) && LAPB!=y 168 depends on HDLC && (LAPB!=m || HDLC!=m) && LAPB!=y
171 169
172config PCI200SYN 170config PCI200SYN
173 tristate "Goramo PCI200SYN support" 171 tristate "Goramo PCI200SYN support"
@@ -230,10 +228,10 @@ config PC300_MLPPP
230 Multilink PPP over the PC300 synchronous communication boards. 228 Multilink PPP over the PC300 synchronous communication boards.
231 229
232comment "Cyclades-PC300 MLPPP support is disabled." 230comment "Cyclades-PC300 MLPPP support is disabled."
233 depends on WAN && HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP) 231 depends on HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP)
234 232
235comment "Refer to the file README.mlppp, provided by PC300 package." 233comment "Refer to the file README.mlppp, provided by PC300 package."
236 depends on WAN && HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP) 234 depends on HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP)
237 235
238config PC300TOO 236config PC300TOO
239 tristate "Cyclades PC300 RSV/X21 alternative support" 237 tristate "Cyclades PC300 RSV/X21 alternative support"
@@ -338,7 +336,6 @@ config DSCC4_PCI_RST
338 336
339config DLCI 337config DLCI
340 tristate "Frame Relay DLCI support" 338 tristate "Frame Relay DLCI support"
341 depends on WAN
342 ---help--- 339 ---help---
343 Support for the Frame Relay protocol. 340 Support for the Frame Relay protocol.
344 341
@@ -385,7 +382,7 @@ config SDLA
385# Wan router core. 382# Wan router core.
386config WAN_ROUTER_DRIVERS 383config WAN_ROUTER_DRIVERS
387 tristate "WAN router drivers" 384 tristate "WAN router drivers"
388 depends on WAN && WAN_ROUTER 385 depends on WAN_ROUTER
389 ---help--- 386 ---help---
390 Connect LAN to WAN via Linux box. 387 Connect LAN to WAN via Linux box.
391 388
@@ -440,7 +437,7 @@ config CYCLOMX_X25
440# X.25 network drivers 437# X.25 network drivers
441config LAPBETHER 438config LAPBETHER
442 tristate "LAPB over Ethernet driver (EXPERIMENTAL)" 439 tristate "LAPB over Ethernet driver (EXPERIMENTAL)"
443 depends on WAN && LAPB && X25 440 depends on LAPB && X25
444 ---help--- 441 ---help---
445 Driver for a pseudo device (typically called /dev/lapb0) which allows 442 Driver for a pseudo device (typically called /dev/lapb0) which allows
446 you to open an LAPB point-to-point connection to some other computer 443 you to open an LAPB point-to-point connection to some other computer
@@ -456,7 +453,7 @@ config LAPBETHER
456 453
457config X25_ASY 454config X25_ASY
458 tristate "X.25 async driver (EXPERIMENTAL)" 455 tristate "X.25 async driver (EXPERIMENTAL)"
459 depends on WAN && LAPB && X25 456 depends on LAPB && X25
460 ---help--- 457 ---help---
461 Send and receive X.25 frames over regular asynchronous serial 458 Send and receive X.25 frames over regular asynchronous serial
462 lines such as telephone lines equipped with ordinary modems. 459 lines such as telephone lines equipped with ordinary modems.
@@ -471,7 +468,7 @@ config X25_ASY
471 468
472config SBNI 469config SBNI
473 tristate "Granch SBNI12 Leased Line adapter support" 470 tristate "Granch SBNI12 Leased Line adapter support"
474 depends on WAN && X86 471 depends on X86
475 ---help--- 472 ---help---
476 Driver for ISA SBNI12-xx cards which are low cost alternatives to 473 Driver for ISA SBNI12-xx cards which are low cost alternatives to
477 leased line modems. 474 leased line modems.
@@ -497,5 +494,4 @@ config SBNI_MULTILINE
497 494
498 If unsure, say N. 495 If unsure, say N.
499 496
500endmenu 497endif # WAN
501
diff --git a/drivers/net/wireless/libertas/Makefile b/drivers/net/wireless/libertas/Makefile
index 19c935071d8e..56a8ea1fbf04 100644
--- a/drivers/net/wireless/libertas/Makefile
+++ b/drivers/net/wireless/libertas/Makefile
@@ -1,5 +1,3 @@
1# EXTRA_CFLAGS += -Wpacked
2
3usb8xxx-objs := main.o fw.o wext.o \ 1usb8xxx-objs := main.o fw.o wext.o \
4 rx.o tx.o cmd.o \ 2 rx.o tx.o cmd.o \
5 cmdresp.o scan.o \ 3 cmdresp.o scan.o \
@@ -7,13 +5,6 @@ usb8xxx-objs := main.o fw.o wext.o \
7 ioctl.o debugfs.o \ 5 ioctl.o debugfs.o \
8 ethtool.o assoc.o 6 ethtool.o assoc.o
9 7
10ifeq ($(CONFIG_LIBERTAS_USB_DEBUG), y)
11EXTRA_CFLAGS += -DDEBUG -DPROC_DEBUG
12endif
13
14
15# This is needed to support the newer boot2 bootloader (v >= 3104)
16EXTRA_CFLAGS += -DSUPPORT_BOOT_COMMAND
17usb8xxx-objs += if_bootcmd.o 8usb8xxx-objs += if_bootcmd.o
18usb8xxx-objs += if_usb.o 9usb8xxx-objs += if_usb.o
19 10
diff --git a/drivers/net/wireless/libertas/README b/drivers/net/wireless/libertas/README
index 688da4c784b1..378577200b56 100644
--- a/drivers/net/wireless/libertas/README
+++ b/drivers/net/wireless/libertas/README
@@ -40,64 +40,11 @@ NAME
40SYNOPSIS 40SYNOPSIS
41 iwpriv <ethX> <command> [sub-command] ... 41 iwpriv <ethX> <command> [sub-command] ...
42 42
43 iwpriv ethX version
44 iwpriv ethX scantype [sub-command]
45 iwpriv ethX getSNR <n>
46 iwpriv ethX getNF <n>
47 iwpriv ethX getRSSI <n>
48 iwpriv ethX setrxant <n>
49 iwpriv ethX getrxant
50 iwpriv ethX settxant <n>
51 iwpriv ethX gettxant
52 iwpriv ethX authalgs <n>
53 iwpriv ethX pre-TBTT <n>
54 iwpriv ethX 8021xauthalgs <n>
55 iwpriv ethX encryptionmode <n>
56 iwpriv ethX setregioncode <n> 43 iwpriv ethX setregioncode <n>
57 iwpriv ethX getregioncode 44 iwpriv ethX getregioncode
58 iwpriv ethX setbcnavg <n>
59 iwpriv ethX getbcnavg
60 iwpriv ethX setdataavg <n>
61 iwpriv ethX setlisteninter <n>
62 iwpriv ethX getlisteninter
63 iwpriv ethX setmultipledtim <n>
64 iwpriv ethX getmultipledtim
65 iwpriv ethX atimwindow <n>
66 iwpriv ethX deauth
67 iwpriv ethX adhocstop
68 iwpriv ethX radioon
69 iwpriv ethX radiooff
70 iwpriv ethX reasso-on
71 iwpriv ethX reasso-off
72 iwpriv ethX scanmode [sub-command]
73 iwpriv ethX setwpaie <n>
74 iwpriv ethX wlanidle-off
75 iwpriv ethX wlanidle-on
76 iwpriv ethX getcis
77 iwpriv ethX getlog
78 iwpriv ethX getadhocstatus
79 iwpriv ethX adhocgrate <n>
80
81Version 4 Command:
82 iwpriv ethX inactvityto <n>
83 iwpriv ethX sleeppd <n>
84 iwpriv ethX enable11d <n>
85 iwpriv ethX tpccfg <n>
86 iwpriv ethX powercfg <n>
87 iwpriv ethX setafc <n>
88 iwpriv ethX getafc
89 45
90Version 5 Command: 46Version 5 Command:
91 iwpriv ethX ledgpio <n> 47 iwpriv ethX ledgpio <n>
92 iwpriv ethX scanprobes <n>
93 iwpriv ethX lolisteninter <n>
94 iwpriv ethX rateadapt <n> <m>
95 iwpriv ethX txcontrol <n>
96 iwpriv ethX psnullinterval <n>
97 iwpriv ethX prescan <n>
98 iwpriv ethX getrxinfo
99 iwpriv ethX gettxrate
100 iwpriv ethX beaconinterval
101 48
102BT Commands: 49BT Commands:
103 The blinding table (BT) contains a list of mac addresses that should be 50 The blinding table (BT) contains a list of mac addresses that should be
@@ -150,114 +97,6 @@ DESCRIPTION
150 The ethX parameter specifies the network device that is to be used to 97 The ethX parameter specifies the network device that is to be used to
151 perform this command on. it could be eth0, eth1 etc. 98 perform this command on. it could be eth0, eth1 etc.
152 99
153version
154 This is used to get the current version of the driver and the firmware.
155
156scantype
157 This command is used to set the scan type to be used by the driver in
158 the scan command. This setting will not be used while performing a scan
159 for a specific SSID, as it is always done with scan type being active.
160
161 where the sub-commands are: -
162 active -- to set the scan type to active
163 passive -- to set the scan type to passive
164 get -- to get the scan type set in the driver
165
166getSNR
167 This command gets the average and non average value of Signal to Noise
168 Ratio of Beacon and Data.
169
170 where value is:-
171 0 -- Beacon non-average.
172 1 -- Beacon average.
173 2 -- Data non-average.
174 3 -- Data average.
175
176 If no value is given, all four values are returned in the order mentioned
177 above.
178
179 Note: This command is available only when STA is connected.
180
181getRSSI
182 This command gets the average and non average value os Receive Signal
183 Strength of Beacon and Data.
184
185 where value is:-
186 0 -- Beacon non-average.
187 1 -- Beacon average.
188 2 -- Data non-average.
189 3 -- Data average.
190
191 Note: This command is available only when STA is connected.
192
193getNF
194 This command gets the average and non average value of Noise Floor of
195 Beacon and Data.
196
197 where value is:-
198 0 -- Beacon non-average.
199 1 -- Beacon average.
200 2 -- Data non-average.
201 3 -- Data average.
202
203 Note: This command is available only when STA is connected.
204
205setrxant
206 This command is used to set the mode for Rx antenna.
207
208 The options that can be sent are:-
209 1 -- Antenna 1.
210 2 -- Antenna 2.
211 0xFFFF -- Diversity.
212
213 Usage:
214 iwpriv ethX setrxant 0x01: select Antenna 1.
215
216getrxant
217 This command is used to get the mode for Rx antenna.
218
219
220settxant
221 This command is used to set the mode for Tx antenna.
222 The options that can be sent are:-
223 1 -- Antenna 1.
224 2 -- Antenna 2.
225 0xFFFF -- Diversity.
226 Usage:
227 iwpriv ethX settxant 0x01: select Antenna 1.
228
229gettxant
230 This command is used to get the mode for Tx antenna.
231
232authalgs
233 This command is used by the WPA supplicant to set the authentication
234 algorithms in the station.
235
2368021xauthalgs
237 This command is used by the WPA supplicant to set the 8021.x authentication algorithm type
238 station.
239
240 where values can be:-
241 1 -- None
242 2 -- LEAP
243 4 -- TLS
244 8 -- TTLs
245 16 -- MD5
246
247
248encryptionmode
249 This command is used by the WPA supplicant to set the encryption algorithm.
250
251 where values can be:-
252 0 -- NONE
253 1 -- WEP40
254 2 -- TKIP
255 3 -- CCMP
256 4 -- WEP104
257
258pre-TBTT
259 This command is used to set pre-TBTT time period where value is in microseconds.
260
261setregioncode 100setregioncode
262 This command is used to set the region code in the station. 101 This command is used to set the region code in the station.
263 where value is 'region code' for various regions like 102 where value is 'region code' for various regions like
@@ -270,114 +109,6 @@ getregioncode
270 This command is used to get the region code information set in the 109 This command is used to get the region code information set in the
271 station. 110 station.
272 111
273setbcnavg
274 Set the weighting factor for calculating RSSI.
275
276getbcnavg
277 Get weighting factor for calculating RSSI.
278
279setdataavg
280 Set the weighting factor for calculating SNR.
281
282setlisteninter
283 This command is used to set the listen interval in the
284 station.
285
286 where the value ranges between 1 - 255
287
288getlisteninter
289 This command is used to get the listen interval value set in the
290 station.
291
292setmultipledtim
293 This command is used to set the multiple dtim value in the
294 station.
295 where the value is 1,2,3,4,5,0xfffe
296 0xfffe means the firmware will use listen interval in association
297 command for waking up
298
299getmultipledtim
300 This command is used to get the multiple dtim value set in the station.
301
302atimwindow
303 This command is used to set the atim value in the
304 station.
305
306 where the value ranges between 0 - 50
307
308deauth
309 This command is used to send the de-authentication to the AP with which
310 the station is associated. This command is valid only when
311 station is in Infrastructure mode.
312
313 Note: This command is available only when STA is connected.
314
315adhocstop
316 This command is used to stop beacon transmission from the station and
317 go into idle state in ad-hoc mode.
318
319 Note: This command is available only when STA is connected.
320
321radioon
322 This command is used to turn on the RF antenna.
323
324radiooff
325 This command is sued to turn off the RF antenna.
326
327scanmode
328 This command is used to set the station to scan for either IBSS
329 networks or BSS networks or both BSS and IBSS networks. This
330 command can be used with sub commands,
331
332 where the value for
333 bss -- Scan All the BSS networks.
334 ibss -- Scan All the IBSS networks.
335 any -- Scan both BSS and IBSS networks.
336
337
338
339setwpaie
340 This command is used by WPA supplicant to send the WPA-IE to the driver.
341
342wlanidle-off
343 This command is used to get into idle state.
344
345 Note: This command is available only when STA is connected.
346
347wlanidle-on
348 This command is used to get off the idle state.
349
350 Note: This command is available only when STA is connected.
351
352
353getlog
354 This command is used to get the 802.11 statistics available in the
355 station.
356
357 Note: This command is available only when STA is connected.
358
359getadhocstatus
360 This command is used to get the ad-hoc Network Status.
361
362 The various status codes are:
363 AdhocStarted
364 AdhocJoined
365 AdhocIdle
366 InfraMode
367 AutoUnknownMode
368
369 Note: This command is available only when STA is connected.
370
371adhocgrate
372 This command is used to enable(1) g_rate, Disable(0) g_rate
373 and request(2) the status which g_rate is disabled/enabled,
374 for Ad-hoc creator.
375
376 where value is:-
377 0 -- Disabled
378 1 -- Enabled
379 2 -- Get
380
381ledgpio 112ledgpio
382 This command is used to set/get LEDs. 113 This command is used to set/get LEDs.
383 114
@@ -400,253 +131,6 @@ ledgpio
400 Note: LED0 is invalid 131 Note: LED0 is invalid
401 Note: Maximum Number of LEDs are 16. 132 Note: Maximum Number of LEDs are 16.
402 133
403inactivityto
404 This command is used by the host to set/get the inactivity timeout value,
405 which specifies when WLAN device is put to sleep.
406
407 Usage:
408 iwpriv ethX inactivityto [<timeout>]
409
410 where the parameter are:
411 timeout: timeout value in milliseconds.
412
413 Example:
414 iwpriv eth1 inactivityto
415 "get the timeout value"
416
417 iwpriv eth1 inactivityto X
418 "set timeout value to X ms"
419
420
421sleeppd
422 This command is used to configure the sleep period of the WLAN device.
423
424 Usage:
425 iwpriv ethX sleeppd [<sleep period>]
426
427 where the parameter are:
428 Period: sleep period in milliseconds. Range 10~60.
429
430 Example:
431 iwpriv eth1 sleeppd 10
432 "set period as 10 ms"
433 iwpriv eth1 sleeppd
434 "get the sleep period configuration"
435
436enable11d
437 This command is used to control 11d
438 where value is:-
439 1 -- Enabled
440 0 -- Disabled
441 2 -- Get
442
443
444
445
446tpccfg
447 Enables or disables automatic transmit power control.
448
449 The first parameter turns this feature on (1) or off (0). When turning
450 on, the user must also supply four more parameters in the following
451 order:
452 -UseSNR (Use SNR (in addition to PER) for TPC algorithm),
453 -P0 (P0 power level for TPC),
454 -P1 (P1 power level for TPC),
455 -P2 (P2 power level for TPC).
456
457 Usage:
458 iwpriv ethX tpccfg: Get current configuration
459 iwpriv ethX tpccfg 0: disable auto TPC
460 iwpriv ethX tpccfg 0x01 0x00 0x05 0x0a 0x0d: enable auto TPC; do not use SNR;
461 P0=0x05; P1=0x0a; P2=0x0d;
462 iwpriv ethX tpccfg 0x01 0x01 0x05 0x0a 0x0d: enable auto TPC; use SNR;
463 P0=0x05; P1=0x0a; P2=0x0d.
464
465powercfg
466 Enables or disables power adaptation.
467
468 The first parameter turns this feature on (1) or off (0). When turning
469 on, the user must also supply three more parameters in the following
470 order:
471 -P0 (P0 power level for Power Adaptation),
472 -P1 (P1 power level for Power Adaptation),
473 -P2 (P2 power level for Power Adaptation).
474
475 Usage:
476 iwpriv ethX powercfg: Get current configuration
477 iwpriv ethX powercfg 0: disable power adaptation
478 iwpriv ethX powercfg 1 0x0d 0x0f 0x12: enable power adaptation;
479 P0=0x0d; P1=0x0f; P2=0x12.
480
481getafc
482 This command returns automatic frequency control parameters. It returns
483 three integers:
484 -P0: automatic is on (1), or off (0),
485 -P1: current timing offset in PPM (part per million), and
486 -P2: current frequency offset in PPM.
487
488setafc
489 Set automatic frequency control options.
490
491 The first parameter turns automatic on (1) or off (0).
492 The user must supply two more parameters in either case, in the following
493 order:
494
495 When auto is on:
496
497 -P0 (automatic adjustment frequency threshold in PPM),
498 -P1 (automatic adjustment period in beacon period),
499
500 When auto is off:
501
502 -P0 (manual adjustment timing offset in PPM), and
503 -P1 (manual adjustment frequency offset in PPM).
504
505 Usage:
506 iwpriv ethX setafc 0 10 10: manual adjustment, both timing and frequcncy
507 offset are 10 PPM.
508
509 iwpriv ethX setafc 1 10 10 enable afc, automatic adjustment,
510 frequency threshold 10 PPM, for every 10 beacon periods.
511
512
513
514scanprobes
515 This command sets number of probe requests per channel.
516
517 Usage:
518 iwpriv ethX scanprobes 3 (set scan probes to 3)
519 iwpriv ethX scanprobes (get scan probes)
520
521lolisteninter
522 This command sets the value of listen interval.
523
524 Usage:
525 iwpriv ethX lolisteninter 234 (set the lolisteninter to 234)
526 iwpriv ethX lolisteninter (get the lolisteninter value)
527
528rateadapt
529 This command sets the data rates bitmap.
530 Where <n>
531 0: Disable auto rate adapt
532 1: Enable auto rate adapt
533
534 <m>
535 data rate bitmap
536 Bit Data rate
537 0 1 Mbps
538 1 2 Mbps
539 2 5.5 Mbps
540 3 11 Mbps
541 4 Reserved
542 5 6 Mbps
543 6 9 Mbps
544 7 12 Mbps
545 8 18 Mbps
546 9 24 Mbps
547 10 36 Mbps
548 11 48 Mbps
549 12 54 Mbps
550 12-15 Reserved
551
552 Usage:
553 iwpriv ethX rateadapt
554 read the currect data rate setting
555 iwpriv ethX rateadapt 1 0x07
556 enable auto data rate adapt and
557 data rates are 1Mbps, 2Mbsp and 5.5Mbps
558
559
560txcontrol
561 This command is used to set the Tx rate, ack policy, and retry limit on a per packet basis.
562
563 Where value <n> is:
564 if bit[4] == 1:
565 bit[3:0] -- 0 1 2 3 4 5 6 7 8 9 10 11 12 13-16
566 Data Rate(Mbps) -- 1 2 5.5 11 Rsv 6 9 12 18 24 36 48 54 Rsv
567
568 bit[12:8]
569 if bit[12] == 1, bit[11:8] specifies the Tx retry limit.
570
571 bit[14:13] specifies per packet ack policy:
572 bit[14:13]
573 1 0 use immediate ack policy for this packet
574 1 1 use no ack policy for this packet
575 0 x use the per-packet ack policy setting
576
577 Usage:
578 iwpriv ethX txcontrol 0x7513
579 Use no-ack policy, 5 retires for Tx, 11Mbps rate
580
581
582
583psnullinterval
584 This command is used to set/request NULL package interval for Power Save
585 under infrastructure mode.
586
587 where value is:-
588 -1 -- Disabled
589 n>0 -- Set interval as n (seconds)
590
591prescan
592 This command is used to enable (1)/disable(0) auto prescan before assoicate to the ap
593
594 where value is:-
595 0 -- Disabled
596 1 -- Enabled
597 2 -- Get
598
599getrxinfo
600 This command gets non average value of Signal to Noise Ratio of Data and rate index.
601
602 The following table shows RateIndex and Rate
603
604 RateIndex Data rate
605 0 1 Mbps
606 1 2 Mbps
607 2 5.5 Mbps
608 3 11 Mbps
609 4 Reserved
610 5 6 Mbps
611 6 9 Mbps
612 7 12 Mbps
613 8 18 Mbps
614 9 24 Mbps
615 10 36 Mbps
616 11 48 Mbps
617 12 54 Mbps
618 13-15 Reserved
619
620gettxrate
621 This command gets current Tx rate index of the first packet associated with Rate Adaptation.
622
623 The following table shows RateIndex and Rate
624
625 RateIndex Data rate
626 0 1 Mbps
627 1 2 Mbps
628 2 5.5 Mbps
629 3 11 Mbps
630 4 Reserved
631 5 6 Mbps
632 6 9 Mbps
633 7 12 Mbps
634 8 18 Mbps
635 9 24 Mbps
636 10 36 Mbps
637 11 48 Mbps
638 12 54 Mbps
639 13-15 Reserved
640
641bcninterval
642 This command is used to sets beacon interval in adhoc mode when an argument is given, and gets current adhoc
643 beacon interval when no argument is given. The valid beacon interval is between 20 - 1000,
644 default beacon interval is 100.
645
646 Usage:
647 iwpriv ethX bcninterval 100 (set adhoc beacon interval to 100)
648 iwpriv ethX bcninterval (get adhoc beacon interval)
649
650fwt_add 134fwt_add
651 This command is used to insert an entry into the FWT table. The list of 135 This command is used to insert an entry into the FWT table. The list of
652 parameters must follow the following structure: 136 parameters must follow the following structure:
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index b55c7f57aca8..c260bd1b3d46 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -23,13 +23,13 @@ static int assoc_helper_essid(wlan_private *priv,
23 ENTER(); 23 ENTER();
24 24
25 lbs_pr_debug(1, "New SSID requested: %s\n", assoc_req->ssid.ssid); 25 lbs_pr_debug(1, "New SSID requested: %s\n", assoc_req->ssid.ssid);
26 if (assoc_req->mode == wlan802_11infrastructure) { 26 if (assoc_req->mode == IW_MODE_INFRA) {
27 if (adapter->prescan) { 27 if (adapter->prescan) {
28 libertas_send_specific_SSID_scan(priv, &assoc_req->ssid, 1); 28 libertas_send_specific_SSID_scan(priv, &assoc_req->ssid, 1);
29 } 29 }
30 30
31 i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, 31 i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid,
32 NULL, wlan802_11infrastructure); 32 NULL, IW_MODE_INFRA);
33 if (i >= 0) { 33 if (i >= 0) {
34 lbs_pr_debug(1, 34 lbs_pr_debug(1,
35 "SSID found in scan list ... associating...\n"); 35 "SSID found in scan list ... associating...\n");
@@ -44,7 +44,7 @@ static int assoc_helper_essid(wlan_private *priv,
44 lbs_pr_debug(1, "SSID '%s' not found; cannot associate\n", 44 lbs_pr_debug(1, "SSID '%s' not found; cannot associate\n",
45 assoc_req->ssid.ssid); 45 assoc_req->ssid.ssid);
46 } 46 }
47 } else if (assoc_req->mode == wlan802_11ibss) { 47 } else if (assoc_req->mode == IW_MODE_ADHOC) {
48 /* Scan for the network, do not save previous results. Stale 48 /* Scan for the network, do not save previous results. Stale
49 * scan data will cause us to join a non-existant adhoc network 49 * scan data will cause us to join a non-existant adhoc network
50 */ 50 */
@@ -52,7 +52,7 @@ static int assoc_helper_essid(wlan_private *priv,
52 52
53 /* Search for the requested SSID in the scan table */ 53 /* Search for the requested SSID in the scan table */
54 i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, NULL, 54 i = libertas_find_SSID_in_list(adapter, &assoc_req->ssid, NULL,
55 wlan802_11ibss); 55 IW_MODE_ADHOC);
56 if (i >= 0) { 56 if (i >= 0) {
57 lbs_pr_debug(1, "SSID found at %d in List, so join\n", ret); 57 lbs_pr_debug(1, "SSID found at %d in List, so join\n", ret);
58 libertas_join_adhoc_network(priv, &adapter->scantable[i]); 58 libertas_join_adhoc_network(priv, &adapter->scantable[i]);
@@ -90,10 +90,10 @@ static int assoc_helper_bssid(wlan_private *priv,
90 goto out; 90 goto out;
91 } 91 }
92 92
93 if (assoc_req->mode == wlan802_11infrastructure) { 93 if (assoc_req->mode == IW_MODE_INFRA) {
94 ret = wlan_associate(priv, &adapter->scantable[i]); 94 ret = wlan_associate(priv, &adapter->scantable[i]);
95 lbs_pr_debug(1, "ASSOC: return from wlan_associate(bssd) was %d\n", ret); 95 lbs_pr_debug(1, "ASSOC: return from wlan_associate(bssd) was %d\n", ret);
96 } else if (assoc_req->mode == wlan802_11ibss) { 96 } else if (assoc_req->mode == IW_MODE_ADHOC) {
97 libertas_join_adhoc_network(priv, &adapter->scantable[i]); 97 libertas_join_adhoc_network(priv, &adapter->scantable[i]);
98 } 98 }
99 memcpy(&assoc_req->ssid, &adapter->scantable[i].ssid, 99 memcpy(&assoc_req->ssid, &adapter->scantable[i].ssid,
@@ -142,23 +142,23 @@ static int assoc_helper_mode(wlan_private *priv,
142 142
143 ENTER(); 143 ENTER();
144 144
145 if (assoc_req->mode == adapter->inframode) { 145 if (assoc_req->mode == adapter->mode) {
146 LEAVE(); 146 LEAVE();
147 return 0; 147 return 0;
148 } 148 }
149 149
150 if (assoc_req->mode == wlan802_11infrastructure) { 150 if (assoc_req->mode == IW_MODE_INFRA) {
151 if (adapter->psstate != PS_STATE_FULL_POWER) 151 if (adapter->psstate != PS_STATE_FULL_POWER)
152 libertas_ps_wakeup(priv, cmd_option_waitforrsp); 152 libertas_ps_wakeup(priv, cmd_option_waitforrsp);
153 adapter->psmode = wlan802_11powermodecam; 153 adapter->psmode = wlan802_11powermodecam;
154 } 154 }
155 155
156 adapter->inframode = assoc_req->mode; 156 adapter->mode = assoc_req->mode;
157 ret = libertas_prepare_and_send_command(priv, 157 ret = libertas_prepare_and_send_command(priv,
158 cmd_802_11_snmp_mib, 158 cmd_802_11_snmp_mib,
159 0, cmd_option_waitforrsp, 159 0, cmd_option_waitforrsp,
160 OID_802_11_INFRASTRUCTURE_MODE, 160 OID_802_11_INFRASTRUCTURE_MODE,
161 (void *) assoc_req->mode); 161 (void *) (size_t) assoc_req->mode);
162 162
163 LEAVE(); 163 LEAVE();
164 return ret; 164 return ret;
@@ -196,7 +196,7 @@ static int assoc_helper_wep_keys(wlan_private *priv,
196 goto out; 196 goto out;
197 197
198 /* enable/disable the MAC's WEP packet filter */ 198 /* enable/disable the MAC's WEP packet filter */
199 if (assoc_req->secinfo.WEPstatus == wlan802_11WEPenabled) 199 if (assoc_req->secinfo.wep_enabled)
200 adapter->currentpacketfilter |= cmd_act_mac_wep_enable; 200 adapter->currentpacketfilter |= cmd_act_mac_wep_enable;
201 else 201 else
202 adapter->currentpacketfilter &= ~cmd_act_mac_wep_enable; 202 adapter->currentpacketfilter &= ~cmd_act_mac_wep_enable;
@@ -300,8 +300,7 @@ static int should_deauth_infrastructure(wlan_adapter *adapter,
300 } 300 }
301 301
302 if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) { 302 if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags)) {
303 if (adapter->secinfo.authmode != 303 if (adapter->secinfo.auth_mode != assoc_req->secinfo.auth_mode) {
304 assoc_req->secinfo.authmode) {
305 lbs_pr_debug(1, "Deauthenticating due to updated security " 304 lbs_pr_debug(1, "Deauthenticating due to updated security "
306 "info in configuration request.\n"); 305 "info in configuration request.\n");
307 return 1; 306 return 1;
@@ -316,7 +315,7 @@ static int should_deauth_infrastructure(wlan_adapter *adapter,
316 315
317 /* FIXME: deal with 'auto' mode somehow */ 316 /* FIXME: deal with 'auto' mode somehow */
318 if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { 317 if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) {
319 if (assoc_req->mode != wlan802_11infrastructure) 318 if (assoc_req->mode != IW_MODE_INFRA)
320 return 1; 319 return 1;
321 } 320 }
322 321
@@ -333,12 +332,12 @@ static int should_stop_adhoc(wlan_adapter *adapter,
333 if (adapter->curbssparams.ssid.ssidlength != assoc_req->ssid.ssidlength) 332 if (adapter->curbssparams.ssid.ssidlength != assoc_req->ssid.ssidlength)
334 return 1; 333 return 1;
335 if (memcmp(adapter->curbssparams.ssid.ssid, assoc_req->ssid.ssid, 334 if (memcmp(adapter->curbssparams.ssid.ssid, assoc_req->ssid.ssid,
336 sizeof(struct WLAN_802_11_SSID))) 335 adapter->curbssparams.ssid.ssidlength))
337 return 1; 336 return 1;
338 337
339 /* FIXME: deal with 'auto' mode somehow */ 338 /* FIXME: deal with 'auto' mode somehow */
340 if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) { 339 if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) {
341 if (assoc_req->mode != wlan802_11ibss) 340 if (assoc_req->mode != IW_MODE_ADHOC)
342 return 1; 341 return 1;
343 } 342 }
344 343
@@ -382,7 +381,7 @@ void wlan_association_worker(struct work_struct *work)
382 } 381 }
383 382
384 if (find_any_ssid) { 383 if (find_any_ssid) {
385 enum WLAN_802_11_NETWORK_INFRASTRUCTURE new_mode; 384 u8 new_mode;
386 385
387 ret = libertas_find_best_network_SSID(priv, &assoc_req->ssid, 386 ret = libertas_find_best_network_SSID(priv, &assoc_req->ssid,
388 assoc_req->mode, &new_mode); 387 assoc_req->mode, &new_mode);
@@ -393,7 +392,7 @@ void wlan_association_worker(struct work_struct *work)
393 } 392 }
394 393
395 /* Ensure we switch to the mode of the AP */ 394 /* Ensure we switch to the mode of the AP */
396 if (assoc_req->mode == wlan802_11autounknown) { 395 if (assoc_req->mode == IW_MODE_AUTO) {
397 set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); 396 set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
398 assoc_req->mode = new_mode; 397 assoc_req->mode = new_mode;
399 } 398 }
@@ -403,7 +402,7 @@ void wlan_association_worker(struct work_struct *work)
403 * Check if the attributes being changing require deauthentication 402 * Check if the attributes being changing require deauthentication
404 * from the currently associated infrastructure access point. 403 * from the currently associated infrastructure access point.
405 */ 404 */
406 if (adapter->inframode == wlan802_11infrastructure) { 405 if (adapter->mode == IW_MODE_INFRA) {
407 if (should_deauth_infrastructure(adapter, assoc_req)) { 406 if (should_deauth_infrastructure(adapter, assoc_req)) {
408 ret = libertas_send_deauthentication(priv); 407 ret = libertas_send_deauthentication(priv);
409 if (ret) { 408 if (ret) {
@@ -412,7 +411,7 @@ void wlan_association_worker(struct work_struct *work)
412 ret); 411 ret);
413 } 412 }
414 } 413 }
415 } else if (adapter->inframode == wlan802_11ibss) { 414 } else if (adapter->mode == IW_MODE_ADHOC) {
416 if (should_stop_adhoc(adapter, assoc_req)) { 415 if (should_stop_adhoc(adapter, assoc_req)) {
417 ret = libertas_stop_adhoc_network(priv); 416 ret = libertas_stop_adhoc_network(priv);
418 if (ret) { 417 if (ret) {
@@ -543,7 +542,7 @@ struct assoc_request * wlan_get_association_request(wlan_adapter *adapter)
543 assoc_req->channel = adapter->curbssparams.channel; 542 assoc_req->channel = adapter->curbssparams.channel;
544 543
545 if (!test_bit(ASSOC_FLAG_MODE, &assoc_req->flags)) 544 if (!test_bit(ASSOC_FLAG_MODE, &assoc_req->flags))
546 assoc_req->mode = adapter->inframode; 545 assoc_req->mode = adapter->mode;
547 546
548 if (!test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) { 547 if (!test_bit(ASSOC_FLAG_BSSID, &assoc_req->flags)) {
549 memcpy(&assoc_req->bssid, adapter->curbssparams.bssid, 548 memcpy(&assoc_req->bssid, adapter->curbssparams.bssid,
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index bfdac58b5c06..de9cb46a70ff 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -381,15 +381,16 @@ static int wlan_cmd_802_11_snmp_mib(wlan_private * priv,
381 switch (cmd_oid) { 381 switch (cmd_oid) {
382 case OID_802_11_INFRASTRUCTURE_MODE: 382 case OID_802_11_INFRASTRUCTURE_MODE:
383 { 383 {
384 enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode = 384 u8 mode = (u8) (size_t) pdata_buf;
385 (enum WLAN_802_11_NETWORK_INFRASTRUCTURE) pdata_buf;
386 pSNMPMIB->querytype = cpu_to_le16(cmd_act_set); 385 pSNMPMIB->querytype = cpu_to_le16(cmd_act_set);
387 pSNMPMIB->oid = cpu_to_le16((u16) desired_bsstype_i); 386 pSNMPMIB->oid = cpu_to_le16((u16) desired_bsstype_i);
388 pSNMPMIB->bufsize = sizeof(u8); 387 pSNMPMIB->bufsize = sizeof(u8);
389 if (mode == wlan802_11infrastructure) 388 if (mode == IW_MODE_ADHOC) {
390 ucTemp = SNMP_MIB_VALUE_INFRA;
391 else
392 ucTemp = SNMP_MIB_VALUE_ADHOC; 389 ucTemp = SNMP_MIB_VALUE_ADHOC;
390 } else {
391 /* Infra and Auto modes */
392 ucTemp = SNMP_MIB_VALUE_INFRA;
393 }
393 394
394 memmove(pSNMPMIB->value, &ucTemp, sizeof(u8)); 395 memmove(pSNMPMIB->value, &ucTemp, sizeof(u8));
395 396
@@ -947,8 +948,8 @@ void libertas_queue_cmd(wlan_adapter * adapter, struct cmd_ctrl_node *cmdnode, u
947 948
948 spin_unlock_irqrestore(&adapter->driver_lock, flags); 949 spin_unlock_irqrestore(&adapter->driver_lock, flags);
949 950
950 lbs_pr_debug(1, "QUEUE_CMD: Inserted node=0x%x, cmd=0x%x in cmdpendingq\n", 951 lbs_pr_debug(1, "QUEUE_CMD: Inserted node=%p, cmd=0x%x in cmdpendingq\n",
951 (u32) cmdnode, 952 cmdnode,
952 ((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command); 953 ((struct cmd_ds_gen*)cmdnode->bufvirtualaddr)->command);
953 954
954done: 955done:
@@ -976,8 +977,8 @@ static int DownloadcommandToStation(wlan_private * priv,
976 ENTER(); 977 ENTER();
977 978
978 if (!adapter || !cmdnode) { 979 if (!adapter || !cmdnode) {
979 lbs_pr_debug(1, "DNLD_CMD: adapter = %#x, cmdnode = %#x\n", 980 lbs_pr_debug(1, "DNLD_CMD: adapter = %p, cmdnode = %p\n",
980 (int)adapter, (int)cmdnode); 981 adapter, cmdnode);
981 if (cmdnode) { 982 if (cmdnode) {
982 spin_lock_irqsave(&adapter->driver_lock, flags); 983 spin_lock_irqsave(&adapter->driver_lock, flags);
983 __libertas_cleanup_and_insert_cmd(priv, cmdnode); 984 __libertas_cleanup_and_insert_cmd(priv, cmdnode);
@@ -1174,8 +1175,8 @@ int libertas_prepare_and_send_command(wlan_private * priv,
1174 1175
1175 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr; 1176 cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr;
1176 1177
1177 lbs_pr_debug(1, "PREP_CMD: Val of cmd ptr =0x%x, command=0x%X\n", 1178 lbs_pr_debug(1, "PREP_CMD: Val of cmd ptr=%p, command=0x%X\n",
1178 (u32) cmdptr, cmd_no); 1179 cmdptr, cmd_no);
1179 1180
1180 if (!cmdptr) { 1181 if (!cmdptr) {
1181 lbs_pr_debug(1, "PREP_CMD: bufvirtualaddr of cmdnode is NULL\n"); 1182 lbs_pr_debug(1, "PREP_CMD: bufvirtualaddr of cmdnode is NULL\n");
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c
index cdb012c7e9cf..c86454034b58 100644
--- a/drivers/net/wireless/libertas/cmdresp.c
+++ b/drivers/net/wireless/libertas/cmdresp.c
@@ -72,8 +72,6 @@ void libertas_mac_event_disconnected(wlan_private * priv)
72 adapter->secinfo.WPAenabled = 0; 72 adapter->secinfo.WPAenabled = 0;
73 adapter->secinfo.WPA2enabled = 0; 73 adapter->secinfo.WPA2enabled = 0;
74 adapter->wpa_ie_len = 0; 74 adapter->wpa_ie_len = 0;
75 adapter->secinfo.auth1xalg = WLAN_1X_AUTH_ALG_NONE;
76 adapter->secinfo.Encryptionmode = CIPHER_NONE;
77 75
78 adapter->connect_status = libertas_disconnected; 76 adapter->connect_status = libertas_disconnected;
79 77
@@ -811,7 +809,7 @@ int libertas_process_rx_command(wlan_private * priv)
811 if (result) { 809 if (result) {
812 lbs_pr_debug(1, "CMD_RESP: PS command failed- %#x \n", 810 lbs_pr_debug(1, "CMD_RESP: PS command failed- %#x \n",
813 resp->result); 811 resp->result);
814 if (adapter->inframode == wlan802_11ibss) { 812 if (adapter->mode == IW_MODE_ADHOC) {
815 /* 813 /*
816 * We should not re-try enter-ps command in 814 * We should not re-try enter-ps command in
817 * ad-hoc mode. It takes place in 815 * ad-hoc mode. It takes place in
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 51dfd202f558..7d7bc5e86a56 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -7,6 +7,7 @@
7#include "dev.h" 7#include "dev.h"
8#include "decl.h" 8#include "decl.h"
9#include "host.h" 9#include "host.h"
10#include "debugfs.h"
10 11
11static struct dentry *libertas_dir = NULL; 12static struct dentry *libertas_dir = NULL;
12static char *szStates[] = { 13static char *szStates[] = {
@@ -276,7 +277,7 @@ static void libertas_parse_ssid(char *buf, size_t count,
276 if (!end) 277 if (!end)
277 end = buf + count - 1; 278 end = buf + count - 1;
278 279
279 size = min(IW_ESSID_MAX_SIZE, end - hold); 280 size = min((size_t)IW_ESSID_MAX_SIZE, (size_t) (end - hold));
280 strncpy(scan_cfg->specificSSID, hold, size); 281 strncpy(scan_cfg->specificSSID, hold, size);
281 282
282 return; 283 return;
@@ -1648,7 +1649,7 @@ struct libertas_debugfs_files {
1648 struct file_operations fops; 1649 struct file_operations fops;
1649}; 1650};
1650 1651
1651struct libertas_debugfs_files debugfs_files[] = { 1652static struct libertas_debugfs_files debugfs_files[] = {
1652 { "info", 0444, FOPS(libertas_dev_info, write_file_dummy), }, 1653 { "info", 0444, FOPS(libertas_dev_info, write_file_dummy), },
1653 { "getscantable", 0444, FOPS(libertas_getscantable, 1654 { "getscantable", 0444, FOPS(libertas_getscantable,
1654 write_file_dummy), }, 1655 write_file_dummy), },
@@ -1658,7 +1659,7 @@ struct libertas_debugfs_files debugfs_files[] = {
1658 { "setuserscan", 0600, FOPS(NULL, libertas_setuserscan), }, 1659 { "setuserscan", 0600, FOPS(NULL, libertas_setuserscan), },
1659}; 1660};
1660 1661
1661struct libertas_debugfs_files debugfs_events_files[] = { 1662static struct libertas_debugfs_files debugfs_events_files[] = {
1662 {"low_rssi", 0644, FOPS(libertas_lowrssi_read, 1663 {"low_rssi", 0644, FOPS(libertas_lowrssi_read,
1663 libertas_lowrssi_write), }, 1664 libertas_lowrssi_write), },
1664 {"low_snr", 0644, FOPS(libertas_lowsnr_read, 1665 {"low_snr", 0644, FOPS(libertas_lowsnr_read,
@@ -1673,7 +1674,7 @@ struct libertas_debugfs_files debugfs_events_files[] = {
1673 libertas_highsnr_write), }, 1674 libertas_highsnr_write), },
1674}; 1675};
1675 1676
1676struct libertas_debugfs_files debugfs_regs_files[] = { 1677static struct libertas_debugfs_files debugfs_regs_files[] = {
1677 {"rdmac", 0644, FOPS(libertas_rdmac_read, libertas_rdmac_write), }, 1678 {"rdmac", 0644, FOPS(libertas_rdmac_read, libertas_rdmac_write), },
1678 {"wrmac", 0600, FOPS(NULL, libertas_wrmac_write), }, 1679 {"wrmac", 0600, FOPS(NULL, libertas_wrmac_write), },
1679 {"rdbbp", 0644, FOPS(libertas_rdbbp_read, libertas_rdbbp_write), }, 1680 {"rdbbp", 0644, FOPS(libertas_rdbbp_read, libertas_rdbbp_write), },
@@ -1778,7 +1779,7 @@ void libertas_debugfs_remove_one(wlan_private *priv)
1778struct debug_data { 1779struct debug_data {
1779 char name[32]; 1780 char name[32];
1780 u32 size; 1781 u32 size;
1781 u32 addr; 1782 size_t addr;
1782}; 1783};
1783 1784
1784/* To debug any member of wlan_adapter, simply add one line here. 1785/* To debug any member of wlan_adapter, simply add one line here.
@@ -1825,6 +1826,8 @@ static ssize_t wlan_debugfs_read(struct file *file, char __user *userbuf,
1825 val = *((u16 *) d[i].addr); 1826 val = *((u16 *) d[i].addr);
1826 else if (d[i].size == 4) 1827 else if (d[i].size == 4)
1827 val = *((u32 *) d[i].addr); 1828 val = *((u32 *) d[i].addr);
1829 else if (d[i].size == 8)
1830 val = *((u64 *) d[i].addr);
1828 1831
1829 pos += sprintf(p + pos, "%s=%d\n", d[i].name, val); 1832 pos += sprintf(p + pos, "%s=%d\n", d[i].name, val);
1830 } 1833 }
@@ -1844,7 +1847,7 @@ static ssize_t wlan_debugfs_read(struct file *file, char __user *userbuf,
1844 * @param data data to write 1847 * @param data data to write
1845 * @return number of data 1848 * @return number of data
1846 */ 1849 */
1847static int wlan_debugfs_write(struct file *f, const char __user *buf, 1850static ssize_t wlan_debugfs_write(struct file *f, const char __user *buf,
1848 size_t cnt, loff_t *ppos) 1851 size_t cnt, loff_t *ppos)
1849{ 1852{
1850 int r, i; 1853 int r, i;
@@ -1886,12 +1889,14 @@ static int wlan_debugfs_write(struct file *f, const char __user *buf,
1886 *((u16 *) d[i].addr) = (u16) r; 1889 *((u16 *) d[i].addr) = (u16) r;
1887 else if (d[i].size == 4) 1890 else if (d[i].size == 4)
1888 *((u32 *) d[i].addr) = (u32) r; 1891 *((u32 *) d[i].addr) = (u32) r;
1892 else if (d[i].size == 8)
1893 *((u64 *) d[i].addr) = (u64) r;
1889 break; 1894 break;
1890 } while (1); 1895 } while (1);
1891 } 1896 }
1892 kfree(pdata); 1897 kfree(pdata);
1893 1898
1894 return cnt; 1899 return (ssize_t)cnt;
1895} 1900}
1896 1901
1897static struct file_operations libertas_debug_fops = { 1902static struct file_operations libertas_debug_fops = {
@@ -1916,20 +1921,10 @@ void libertas_debug_init(wlan_private * priv, struct net_device *dev)
1916 return; 1921 return;
1917 1922
1918 for (i = 0; i < num_of_items; i++) 1923 for (i = 0; i < num_of_items; i++)
1919 items[i].addr += (u32) priv->adapter; 1924 items[i].addr += (size_t) priv->adapter;
1920 1925
1921 priv->debugfs_debug = debugfs_create_file("debug", 0644, 1926 priv->debugfs_debug = debugfs_create_file("debug", 0644,
1922 priv->debugfs_dir, &items[0], 1927 priv->debugfs_dir, &items[0],
1923 &libertas_debug_fops); 1928 &libertas_debug_fops);
1924} 1929}
1925 1930
1926/**
1927 * @brief remove proc file
1928 *
1929 * @param priv pointer wlan_private
1930 * @return N/A
1931 */
1932void libertas_debug_remove(wlan_private * priv)
1933{
1934 debugfs_remove(priv->debugfs_debug);
1935}
diff --git a/drivers/net/wireless/libertas/defs.h b/drivers/net/wireless/libertas/defs.h
index fb1478c1b87d..80dd9ea19c8e 100644
--- a/drivers/net/wireless/libertas/defs.h
+++ b/drivers/net/wireless/libertas/defs.h
@@ -9,6 +9,11 @@
9 9
10extern unsigned int libertas_debug; 10extern unsigned int libertas_debug;
11 11
12#ifdef CONFIG_LIBERTAS_DEBUG
13#define DEBUG
14#define PROC_DEBUG
15#endif
16
12#define DRV_NAME "usb8xxx" 17#define DRV_NAME "usb8xxx"
13 18
14#define lbs_pr_info(format, args...) \ 19#define lbs_pr_info(format, args...) \
@@ -223,31 +228,6 @@ enum SNRNF_DATA {
223 MAX_TYPE_AVG 228 MAX_TYPE_AVG
224}; 229};
225 230
226/** WLAN_802_11_AUTH_ALG*/
227enum WLAN_802_11_AUTH_ALG {
228 AUTH_ALG_OPEN_SYSTEM = 1,
229 AUTH_ALG_SHARED_KEY = 2,
230 AUTH_ALG_NETWORK_EAP = 8,
231};
232
233/** WLAN_802_1X_AUTH_ALG */
234enum WLAN_802_1X_AUTH_ALG {
235 WLAN_1X_AUTH_ALG_NONE = 1,
236 WLAN_1X_AUTH_ALG_LEAP = 2,
237 WLAN_1X_AUTH_ALG_TLS = 4,
238 WLAN_1X_AUTH_ALG_TTLS = 8,
239 WLAN_1X_AUTH_ALG_MD5 = 16,
240};
241
242/** WLAN_802_11_ENCRYPTION_MODE */
243enum WLAN_802_11_ENCRYPTION_MODE {
244 CIPHER_NONE,
245 CIPHER_WEP40,
246 CIPHER_TKIP,
247 CIPHER_CCMP,
248 CIPHER_WEP104,
249};
250
251/** WLAN_802_11_POWER_MODE */ 231/** WLAN_802_11_POWER_MODE */
252enum WLAN_802_11_POWER_MODE { 232enum WLAN_802_11_POWER_MODE {
253 wlan802_11powermodecam, 233 wlan802_11powermodecam,
@@ -292,28 +272,6 @@ enum mv_ms_type {
292 MVMS_EVENT 272 MVMS_EVENT
293}; 273};
294 274
295/** WLAN_802_11_NETWORK_INFRASTRUCTURE */
296enum WLAN_802_11_NETWORK_INFRASTRUCTURE {
297 wlan802_11ibss,
298 wlan802_11infrastructure,
299 wlan802_11autounknown,
300 /*defined as upper bound */
301 wlan802_11infrastructuremax
302};
303
304/** WLAN_802_11_AUTHENTICATION_MODE */
305enum WLAN_802_11_AUTHENTICATION_MODE {
306 wlan802_11authmodeopen = 0x00,
307 wlan802_11authmodeshared = 0x01,
308 wlan802_11authmodenetworkEAP = 0x80,
309};
310
311/** WLAN_802_11_WEP_STATUS */
312enum WLAN_802_11_WEP_STATUS {
313 wlan802_11WEPenabled,
314 wlan802_11WEPdisabled,
315};
316
317/** SNMP_MIB_INDEX_e */ 275/** SNMP_MIB_INDEX_e */
318enum SNMP_MIB_INDEX_e { 276enum SNMP_MIB_INDEX_e {
319 desired_bsstype_i = 0, 277 desired_bsstype_i = 0,
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index b1f876f9693b..e8b9020f9bd6 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -10,6 +10,7 @@
10#include <linux/wireless.h> 10#include <linux/wireless.h>
11#include <linux/ethtool.h> 11#include <linux/ethtool.h>
12#include <linux/debugfs.h> 12#include <linux/debugfs.h>
13#include <net/ieee80211.h>
13 14
14#include "defs.h" 15#include "defs.h"
15#include "scan.h" 16#include "scan.h"
@@ -56,10 +57,8 @@ struct region_channel {
56struct wlan_802_11_security { 57struct wlan_802_11_security {
57 u8 WPAenabled; 58 u8 WPAenabled;
58 u8 WPA2enabled; 59 u8 WPA2enabled;
59 enum WLAN_802_11_WEP_STATUS WEPstatus; 60 u8 wep_enabled;
60 enum WLAN_802_11_AUTHENTICATION_MODE authmode; 61 u8 auth_mode;
61 enum WLAN_802_1X_AUTH_ALG auth1xalg;
62 enum WLAN_802_11_ENCRYPTION_MODE Encryptionmode;
63}; 62};
64 63
65/** Current Basic Service Set State Structure */ 64/** Current Basic Service Set State Structure */
@@ -184,7 +183,7 @@ struct assoc_request {
184 183
185 struct WLAN_802_11_SSID ssid; 184 struct WLAN_802_11_SSID ssid;
186 u8 channel; 185 u8 channel;
187 enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode; 186 u8 mode;
188 u8 bssid[ETH_ALEN]; 187 u8 bssid[ETH_ALEN];
189 188
190 /** WEP keys */ 189 /** WEP keys */
@@ -198,7 +197,6 @@ struct assoc_request {
198 struct wlan_802_11_security secinfo; 197 struct wlan_802_11_security secinfo;
199 198
200 /** WPA Information Elements*/ 199 /** WPA Information Elements*/
201#define MAX_WPA_IE_LEN 64
202 u8 wpa_ie[MAX_WPA_IE_LEN]; 200 u8 wpa_ie[MAX_WPA_IE_LEN];
203 u8 wpa_ie_len; 201 u8 wpa_ie_len;
204}; 202};
@@ -254,7 +252,8 @@ struct _wlan_adapter {
254 /** current ssid/bssid related parameters*/ 252 /** current ssid/bssid related parameters*/
255 struct current_bss_params curbssparams; 253 struct current_bss_params curbssparams;
256 254
257 enum WLAN_802_11_NETWORK_INFRASTRUCTURE inframode; 255 /* IW_MODE_* */
256 u8 mode;
258 257
259 struct bss_descriptor *pattemptedbssdesc; 258 struct bss_descriptor *pattemptedbssdesc;
260 259
@@ -339,7 +338,6 @@ struct _wlan_adapter {
339 struct WLAN_802_11_KEY wpa_unicast_key; 338 struct WLAN_802_11_KEY wpa_unicast_key;
340 339
341 /** WPA Information Elements*/ 340 /** WPA Information Elements*/
342#define MAX_WPA_IE_LEN 64
343 u8 wpa_ie[MAX_WPA_IE_LEN]; 341 u8 wpa_ie[MAX_WPA_IE_LEN];
344 u8 wpa_ie_len; 342 u8 wpa_ie_len;
345 343
diff --git a/drivers/net/wireless/libertas/fw.c b/drivers/net/wireless/libertas/fw.c
index b194a4570791..441123c85e62 100644
--- a/drivers/net/wireless/libertas/fw.c
+++ b/drivers/net/wireless/libertas/fw.c
@@ -194,16 +194,13 @@ static void wlan_init_adapter(wlan_private * priv)
194 adapter->scanmode = cmd_bss_type_any; 194 adapter->scanmode = cmd_bss_type_any;
195 195
196 /* 802.11 specific */ 196 /* 802.11 specific */
197 adapter->secinfo.WEPstatus = wlan802_11WEPdisabled; 197 adapter->secinfo.wep_enabled = 0;
198 for (i = 0; i < sizeof(adapter->wep_keys) / sizeof(adapter->wep_keys[0]); 198 for (i = 0; i < sizeof(adapter->wep_keys) / sizeof(adapter->wep_keys[0]);
199 i++) 199 i++)
200 memset(&adapter->wep_keys[i], 0, sizeof(struct WLAN_802_11_KEY)); 200 memset(&adapter->wep_keys[i], 0, sizeof(struct WLAN_802_11_KEY));
201 adapter->wep_tx_keyidx = 0; 201 adapter->wep_tx_keyidx = 0;
202 adapter->secinfo.WEPstatus = wlan802_11WEPdisabled; 202 adapter->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
203 adapter->secinfo.authmode = wlan802_11authmodeopen; 203 adapter->mode = IW_MODE_INFRA;
204 adapter->secinfo.auth1xalg = WLAN_1X_AUTH_ALG_NONE;
205 adapter->secinfo.Encryptionmode = CIPHER_NONE;
206 adapter->inframode = wlan802_11infrastructure;
207 204
208 adapter->assoc_req = NULL; 205 adapter->assoc_req = NULL;
209 206
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
index 695fb6a66ffe..ae6f72a6cdf3 100644
--- a/drivers/net/wireless/libertas/if_usb.c
+++ b/drivers/net/wireless/libertas/if_usb.c
@@ -388,7 +388,7 @@ static int __if_usb_submit_rx_urb(wlan_private * priv,
388 usb_fill_bulk_urb(cardp->rx_urb, cardp->udev, 388 usb_fill_bulk_urb(cardp->rx_urb, cardp->udev,
389 usb_rcvbulkpipe(cardp->udev, 389 usb_rcvbulkpipe(cardp->udev,
390 cardp->bulk_in_endpointAddr), 390 cardp->bulk_in_endpointAddr),
391 skb->tail + IPFIELD_ALIGN_OFFSET, 391 (void *) (skb->tail + (size_t) IPFIELD_ALIGN_OFFSET),
392 MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, 392 MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn,
393 rinfo); 393 rinfo);
394 394
@@ -626,6 +626,7 @@ static void if_usb_receive(struct urb *urb)
626 cardp->usb_event_cause); 626 cardp->usb_event_cause);
627 if (cardp->usb_event_cause & 0xffff0000) { 627 if (cardp->usb_event_cause & 0xffff0000) {
628 libertas_send_tx_feedback(priv); 628 libertas_send_tx_feedback(priv);
629 spin_unlock(&priv->adapter->driver_lock);
629 break; 630 break;
630 } 631 }
631 cardp->usb_event_cause = le32_to_cpu(cardp->usb_event_cause) << 3; 632 cardp->usb_event_cause = le32_to_cpu(cardp->usb_event_cause) << 3;
@@ -775,7 +776,6 @@ restart:
775 return -1; 776 return -1;
776 } 777 }
777 778
778#ifdef SUPPORT_BOOT_COMMAND
779 cardp->bootcmdresp = 0; 779 cardp->bootcmdresp = 0;
780 do { 780 do {
781 int j = 0; 781 int j = 0;
@@ -796,7 +796,6 @@ restart:
796 } 796 }
797 return -1; 797 return -1;
798 } 798 }
799#endif
800 799
801 i = 0; 800 i = 0;
802 priv->adapter->fw_ready = 0; 801 priv->adapter->fw_ready = 0;
diff --git a/drivers/net/wireless/libertas/if_usb.h b/drivers/net/wireless/libertas/if_usb.h
index 785116720bc6..170dfe6809f5 100644
--- a/drivers/net/wireless/libertas/if_usb.h
+++ b/drivers/net/wireless/libertas/if_usb.h
@@ -12,7 +12,6 @@
12#define USB8388_VID_2 0x05a3 12#define USB8388_VID_2 0x05a3
13#define USB8388_PID_2 0x8388 13#define USB8388_PID_2 0x8388
14 14
15#ifdef SUPPORT_BOOT_COMMAND
16#define BOOT_CMD_FW_BY_USB 0x01 15#define BOOT_CMD_FW_BY_USB 0x01
17#define BOOT_CMD_FW_IN_EEPROM 0x02 16#define BOOT_CMD_FW_IN_EEPROM 0x02
18#define BOOT_CMD_UPDATE_BOOT2 0x03 17#define BOOT_CMD_UPDATE_BOOT2 0x03
@@ -36,7 +35,6 @@ struct bootcmdrespStr
36 u8 u8result; 35 u8 u8result;
37 u8 au8dumy[2]; 36 u8 au8dumy[2];
38}; 37};
39#endif /* SUPPORT_BOOT_COMMAND */
40 38
41/* read callback private data */ 39/* read callback private data */
42struct read_cb_info { 40struct read_cb_info {
diff --git a/drivers/net/wireless/libertas/ioctl.c b/drivers/net/wireless/libertas/ioctl.c
index 82b39642423a..a8f76c358992 100644
--- a/drivers/net/wireless/libertas/ioctl.c
+++ b/drivers/net/wireless/libertas/ioctl.c
@@ -27,95 +27,6 @@
27 27
28#define WAIT_FOR_SCAN_RRESULT_MAX_TIME (10 * HZ) 28#define WAIT_FOR_SCAN_RRESULT_MAX_TIME (10 * HZ)
29 29
30static int setrxantenna(wlan_private * priv, int mode)
31{
32 int ret = 0;
33 wlan_adapter *adapter = priv->adapter;
34
35 if (mode != RF_ANTENNA_1 && mode != RF_ANTENNA_2
36 && mode != RF_ANTENNA_AUTO) {
37 return -EINVAL;
38 }
39
40 adapter->rxantennamode = mode;
41
42 lbs_pr_debug(1, "SET RX Antenna mode to 0x%04x\n", adapter->rxantennamode);
43
44 ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna,
45 cmd_act_set_rx,
46 cmd_option_waitforrsp, 0,
47 &adapter->rxantennamode);
48 return ret;
49}
50
51static int settxantenna(wlan_private * priv, int mode)
52{
53 int ret = 0;
54 wlan_adapter *adapter = priv->adapter;
55
56 if ((mode != RF_ANTENNA_1) && (mode != RF_ANTENNA_2)
57 && (mode != RF_ANTENNA_AUTO)) {
58 return -EINVAL;
59 }
60
61 adapter->txantennamode = mode;
62
63 lbs_pr_debug(1, "SET TX Antenna mode to 0x%04x\n", adapter->txantennamode);
64
65 ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna,
66 cmd_act_set_tx,
67 cmd_option_waitforrsp, 0,
68 &adapter->txantennamode);
69
70 return ret;
71}
72
73static int getrxantenna(wlan_private * priv, char *buf)
74{
75 int ret = 0;
76 wlan_adapter *adapter = priv->adapter;
77
78 // clear it, so we will know if the value
79 // returned below is correct or not.
80 adapter->rxantennamode = 0;
81
82 ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna,
83 cmd_act_get_rx,
84 cmd_option_waitforrsp, 0, NULL);
85
86 if (ret) {
87 LEAVE();
88 return ret;
89 }
90
91 lbs_pr_debug(1, "Get Rx Antenna mode:0x%04x\n", adapter->rxantennamode);
92
93 return sprintf(buf, "0x%04x", adapter->rxantennamode) + 1;
94}
95
96static int gettxantenna(wlan_private * priv, char *buf)
97{
98 int ret = 0;
99 wlan_adapter *adapter = priv->adapter;
100
101 // clear it, so we will know if the value
102 // returned below is correct or not.
103 adapter->txantennamode = 0;
104
105 ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_antenna,
106 cmd_act_get_tx,
107 cmd_option_waitforrsp, 0, NULL);
108
109 if (ret) {
110 LEAVE();
111 return ret;
112 }
113
114 lbs_pr_debug(1, "Get Tx Antenna mode:0x%04x\n", adapter->txantennamode);
115
116 return sprintf(buf, "0x%04x", adapter->txantennamode) + 1;
117}
118
119static int wlan_set_region(wlan_private * priv, u16 region_code) 30static int wlan_set_region(wlan_private * priv, u16 region_code)
120{ 31{
121 int i; 32 int i;
@@ -144,998 +55,6 @@ static int wlan_set_region(wlan_private * priv, u16 region_code)
144 return 0; 55 return 0;
145} 56}
146 57
147/**
148 * @brief Get/Set Firmware wakeup method
149 *
150 * @param priv A pointer to wlan_private structure
151 * @param wrq A pointer to user data
152 * @return 0--success, otherwise fail
153 */
154static int wlan_txcontrol(wlan_private * priv, struct iwreq *wrq)
155{
156 wlan_adapter *adapter = priv->adapter;
157 int data;
158 ENTER();
159
160 if ((int)wrq->u.data.length == 0) {
161 if (copy_to_user
162 (wrq->u.data.pointer, &adapter->pkttxctrl, sizeof(u32))) {
163 lbs_pr_alert("copy_to_user failed!\n");
164 return -EFAULT;
165 }
166 } else {
167 if ((int)wrq->u.data.length > 1) {
168 lbs_pr_alert("ioctl too many args!\n");
169 return -EFAULT;
170 }
171 if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) {
172 lbs_pr_alert("Copy from user failed\n");
173 return -EFAULT;
174 }
175
176 adapter->pkttxctrl = (u32) data;
177 }
178
179 wrq->u.data.length = 1;
180
181 LEAVE();
182 return 0;
183}
184
185/**
186 * @brief Get/Set NULL Package generation interval
187 *
188 * @param priv A pointer to wlan_private structure
189 * @param wrq A pointer to user data
190 * @return 0--success, otherwise fail
191 */
192static int wlan_null_pkt_interval(wlan_private * priv, struct iwreq *wrq)
193{
194 wlan_adapter *adapter = priv->adapter;
195 int data;
196 ENTER();
197
198 if ((int)wrq->u.data.length == 0) {
199 data = adapter->nullpktinterval;
200
201 if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int))) {
202 lbs_pr_alert( "copy_to_user failed!\n");
203 return -EFAULT;
204 }
205 } else {
206 if ((int)wrq->u.data.length > 1) {
207 lbs_pr_alert( "ioctl too many args!\n");
208 return -EFAULT;
209 }
210 if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) {
211 lbs_pr_debug(1, "Copy from user failed\n");
212 return -EFAULT;
213 }
214
215 adapter->nullpktinterval = data;
216 }
217
218 wrq->u.data.length = 1;
219
220 LEAVE();
221 return 0;
222}
223
224static int wlan_get_rxinfo(wlan_private * priv, struct iwreq *wrq)
225{
226 wlan_adapter *adapter = priv->adapter;
227 int data[2];
228 ENTER();
229 data[0] = adapter->SNR[TYPE_RXPD][TYPE_NOAVG];
230 data[1] = adapter->rxpd_rate;
231 if (copy_to_user(wrq->u.data.pointer, data, sizeof(int) * 2)) {
232 lbs_pr_debug(1, "Copy to user failed\n");
233 return -EFAULT;
234 }
235 wrq->u.data.length = 2;
236 LEAVE();
237 return 0;
238}
239
240static int wlan_get_snr(wlan_private * priv, struct iwreq *wrq)
241{
242 int ret = 0;
243 wlan_adapter *adapter = priv->adapter;
244 int data[4];
245
246 ENTER();
247 memset(data, 0, sizeof(data));
248 if (wrq->u.data.length) {
249 if (copy_from_user(data, wrq->u.data.pointer,
250 min_t(size_t, wrq->u.data.length, 4) * sizeof(int)))
251 return -EFAULT;
252 }
253 if ((wrq->u.data.length == 0) || (data[0] == 0) || (data[0] == 1)) {
254 if (adapter->connect_status == libertas_connected) {
255 ret = libertas_prepare_and_send_command(priv,
256 cmd_802_11_rssi,
257 0,
258 cmd_option_waitforrsp,
259 0, NULL);
260
261 if (ret) {
262 LEAVE();
263 return ret;
264 }
265 }
266 }
267
268 if (wrq->u.data.length == 0) {
269 data[0] = adapter->SNR[TYPE_BEACON][TYPE_NOAVG];
270 data[1] = adapter->SNR[TYPE_BEACON][TYPE_AVG];
271 data[2] = adapter->SNR[TYPE_RXPD][TYPE_NOAVG];
272 data[3] = adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE;
273 if (copy_to_user(wrq->u.data.pointer, data, sizeof(int) * 4))
274 return -EFAULT;
275 wrq->u.data.length = 4;
276 } else if (data[0] == 0) {
277 data[0] = adapter->SNR[TYPE_BEACON][TYPE_NOAVG];
278 if (copy_to_user(wrq->u.data.pointer, data, sizeof(int)))
279 return -EFAULT;
280 wrq->u.data.length = 1;
281 } else if (data[0] == 1) {
282 data[0] = adapter->SNR[TYPE_BEACON][TYPE_AVG];
283 if (copy_to_user(wrq->u.data.pointer, data, sizeof(int)))
284 return -EFAULT;
285 wrq->u.data.length = 1;
286 } else if (data[0] == 2) {
287 data[0] = adapter->SNR[TYPE_RXPD][TYPE_NOAVG];
288 if (copy_to_user(wrq->u.data.pointer, data, sizeof(int)))
289 return -EFAULT;
290 wrq->u.data.length = 1;
291 } else if (data[0] == 3) {
292 data[0] = adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE;
293 if (copy_to_user(wrq->u.data.pointer, data, sizeof(int)))
294 return -EFAULT;
295 wrq->u.data.length = 1;
296 } else
297 return -ENOTSUPP;
298
299 LEAVE();
300 return 0;
301}
302
303static int wlan_beacon_interval(wlan_private * priv, struct iwreq *wrq)
304{
305 int data;
306 wlan_adapter *adapter = priv->adapter;
307
308 if (wrq->u.data.length > 0) {
309 if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int)))
310 return -EFAULT;
311
312 lbs_pr_debug(1, "WLAN SET BEACON INTERVAL: %d\n", data);
313 if ((data > MRVDRV_MAX_BEACON_INTERVAL)
314 || (data < MRVDRV_MIN_BEACON_INTERVAL))
315 return -ENOTSUPP;
316 adapter->beaconperiod = data;
317 }
318 data = adapter->beaconperiod;
319 if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int)))
320 return -EFAULT;
321
322 wrq->u.data.length = 1;
323
324 return 0;
325}
326
327static int wlan_get_rssi(wlan_private * priv, struct iwreq *wrq)
328{
329 int ret = 0;
330 wlan_adapter *adapter = priv->adapter;
331 int temp;
332 int data = 0;
333 int *val;
334
335 ENTER();
336 data = SUBCMD_DATA(wrq);
337 if ((data == 0) || (data == 1)) {
338 ret = libertas_prepare_and_send_command(priv,
339 cmd_802_11_rssi,
340 0, cmd_option_waitforrsp,
341 0, NULL);
342 if (ret) {
343 LEAVE();
344 return ret;
345 }
346 }
347
348 switch (data) {
349 case 0:
350
351 temp = CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_NOAVG],
352 adapter->NF[TYPE_BEACON][TYPE_NOAVG]);
353 break;
354 case 1:
355 temp = CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_AVG],
356 adapter->NF[TYPE_BEACON][TYPE_AVG]);
357 break;
358 case 2:
359 temp = CAL_RSSI(adapter->SNR[TYPE_RXPD][TYPE_NOAVG],
360 adapter->NF[TYPE_RXPD][TYPE_NOAVG]);
361 break;
362 case 3:
363 temp = CAL_RSSI(adapter->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE,
364 adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE);
365 break;
366 default:
367 return -ENOTSUPP;
368 }
369 val = (int *)wrq->u.name;
370 *val = temp;
371
372 LEAVE();
373 return 0;
374}
375
376static int wlan_get_nf(wlan_private * priv, struct iwreq *wrq)
377{
378 int ret = 0;
379 wlan_adapter *adapter = priv->adapter;
380 int temp;
381 int data = 0;
382 int *val;
383
384 data = SUBCMD_DATA(wrq);
385 if ((data == 0) || (data == 1)) {
386 ret = libertas_prepare_and_send_command(priv,
387 cmd_802_11_rssi,
388 0, cmd_option_waitforrsp,
389 0, NULL);
390
391 if (ret) {
392 LEAVE();
393 return ret;
394 }
395 }
396
397 switch (data) {
398 case 0:
399 temp = adapter->NF[TYPE_BEACON][TYPE_NOAVG];
400 break;
401 case 1:
402 temp = adapter->NF[TYPE_BEACON][TYPE_AVG];
403 break;
404 case 2:
405 temp = adapter->NF[TYPE_RXPD][TYPE_NOAVG];
406 break;
407 case 3:
408 temp = adapter->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE;
409 break;
410 default:
411 return -ENOTSUPP;
412 }
413
414 temp = CAL_NF(temp);
415
416 lbs_pr_debug(1, "%s: temp = %d\n", __FUNCTION__, temp);
417 val = (int *)wrq->u.name;
418 *val = temp;
419 return 0;
420}
421
422static int wlan_get_txrate_ioctl(wlan_private * priv, struct ifreq *req)
423{
424 wlan_adapter *adapter = priv->adapter;
425 int *pdata;
426 struct iwreq *wrq = (struct iwreq *)req;
427 int ret = 0;
428 adapter->txrate = 0;
429 lbs_pr_debug(1, "wlan_get_txrate_ioctl\n");
430 ret = libertas_prepare_and_send_command(priv, cmd_802_11_tx_rate_query,
431 cmd_act_get, cmd_option_waitforrsp,
432 0, NULL);
433 if (ret)
434 return ret;
435
436 pdata = (int *)wrq->u.name;
437 *pdata = (int)adapter->txrate;
438 return 0;
439}
440
441static int wlan_get_adhoc_status_ioctl(wlan_private * priv, struct iwreq *wrq)
442{
443 char status[64];
444 wlan_adapter *adapter = priv->adapter;
445
446 memset(status, 0, sizeof(status));
447
448 switch (adapter->inframode) {
449 case wlan802_11ibss:
450 if (adapter->connect_status == libertas_connected) {
451 if (adapter->adhoccreate)
452 memcpy(&status, "AdhocStarted", sizeof(status));
453 else
454 memcpy(&status, "AdhocJoined", sizeof(status));
455 } else {
456 memcpy(&status, "AdhocIdle", sizeof(status));
457 }
458 break;
459 case wlan802_11infrastructure:
460 memcpy(&status, "Inframode", sizeof(status));
461 break;
462 default:
463 memcpy(&status, "AutoUnknownmode", sizeof(status));
464 break;
465 }
466
467 lbs_pr_debug(1, "status = %s\n", status);
468 wrq->u.data.length = strlen(status) + 1;
469
470 if (wrq->u.data.pointer) {
471 if (copy_to_user(wrq->u.data.pointer,
472 &status, wrq->u.data.length))
473 return -EFAULT;
474 }
475
476 LEAVE();
477 return 0;
478}
479
480/**
481 * @brief Set/Get WPA IE
482 * @param priv A pointer to wlan_private structure
483 * @param req A pointer to ifreq structure
484 * @return 0 --success, otherwise fail
485 */
486static int wlan_setwpaie_ioctl(wlan_private * priv, struct ifreq *req)
487{
488 struct iwreq *wrq = (struct iwreq *)req;
489 wlan_adapter *adapter = priv->adapter;
490 int ret = 0;
491
492 ENTER();
493
494 if (wrq->u.data.length) {
495 if (wrq->u.data.length > sizeof(adapter->wpa_ie)) {
496 lbs_pr_debug(1, "failed to copy WPA IE, too big \n");
497 return -EFAULT;
498 }
499 if (copy_from_user(adapter->wpa_ie, wrq->u.data.pointer,
500 wrq->u.data.length)) {
501 lbs_pr_debug(1, "failed to copy WPA IE \n");
502 return -EFAULT;
503 }
504 adapter->wpa_ie_len = wrq->u.data.length;
505 lbs_pr_debug(1, "Set wpa_ie_len=%d IE=%#x\n", adapter->wpa_ie_len,
506 adapter->wpa_ie[0]);
507 lbs_dbg_hex("wpa_ie", adapter->wpa_ie, adapter->wpa_ie_len);
508 if (adapter->wpa_ie[0] == WPA_IE)
509 adapter->secinfo.WPAenabled = 1;
510 else if (adapter->wpa_ie[0] == WPA2_IE)
511 adapter->secinfo.WPA2enabled = 1;
512 else {
513 adapter->secinfo.WPAenabled = 0;
514 adapter->secinfo.WPA2enabled = 0;
515 }
516 } else {
517 memset(adapter->wpa_ie, 0, sizeof(adapter->wpa_ie));
518 adapter->wpa_ie_len = wrq->u.data.length;
519 lbs_pr_debug(1, "Reset wpa_ie_len=%d IE=%#x\n",
520 adapter->wpa_ie_len, adapter->wpa_ie[0]);
521 adapter->secinfo.WPAenabled = 0;
522 adapter->secinfo.WPA2enabled = 0;
523 }
524
525 // enable/disable RSN in firmware if WPA is enabled/disabled
526 // depending on variable adapter->secinfo.WPAenabled is set or not
527 ret = libertas_prepare_and_send_command(priv, cmd_802_11_enable_rsn,
528 cmd_act_set, cmd_option_waitforrsp,
529 0, NULL);
530
531 LEAVE();
532 return ret;
533}
534
535/**
536 * @brief Set Auto prescan
537 * @param priv A pointer to wlan_private structure
538 * @param wrq A pointer to iwreq structure
539 * @return 0 --success, otherwise fail
540 */
541static int wlan_subcmd_setprescan_ioctl(wlan_private * priv, struct iwreq *wrq)
542{
543 int data;
544 wlan_adapter *adapter = priv->adapter;
545 int *val;
546
547 data = SUBCMD_DATA(wrq);
548 lbs_pr_debug(1, "WLAN_SUBCMD_SET_PRESCAN %d\n", data);
549 adapter->prescan = data;
550
551 val = (int *)wrq->u.name;
552 *val = data;
553 return 0;
554}
555
556static int wlan_set_multiple_dtim_ioctl(wlan_private * priv, struct ifreq *req)
557{
558 struct iwreq *wrq = (struct iwreq *)req;
559 u32 mdtim;
560 int idata;
561 int ret = -EINVAL;
562
563 ENTER();
564
565 idata = SUBCMD_DATA(wrq);
566 mdtim = (u32) idata;
567 if (((mdtim >= MRVDRV_MIN_MULTIPLE_DTIM)
568 && (mdtim <= MRVDRV_MAX_MULTIPLE_DTIM))
569 || (mdtim == MRVDRV_IGNORE_MULTIPLE_DTIM)) {
570 priv->adapter->multipledtim = mdtim;
571 ret = 0;
572 }
573 if (ret)
574 lbs_pr_debug(1, "Invalid parameter, multipledtim not changed.\n");
575
576 LEAVE();
577 return ret;
578}
579
580/**
581 * @brief Set authentication mode
582 * @param priv A pointer to wlan_private structure
583 * @param req A pointer to ifreq structure
584 * @return 0 --success, otherwise fail
585 */
586static int wlan_setauthalg_ioctl(wlan_private * priv, struct ifreq *req)
587{
588 int alg;
589 struct iwreq *wrq = (struct iwreq *)req;
590 wlan_adapter *adapter = priv->adapter;
591
592 if (wrq->u.data.flags == 0) {
593 //from iwpriv subcmd
594 alg = SUBCMD_DATA(wrq);
595 } else {
596 //from wpa_supplicant subcmd
597 if (copy_from_user(&alg, wrq->u.data.pointer, sizeof(alg))) {
598 lbs_pr_debug(1, "Copy from user failed\n");
599 return -EFAULT;
600 }
601 }
602
603 lbs_pr_debug(1, "auth alg is %#x\n", alg);
604
605 switch (alg) {
606 case AUTH_ALG_SHARED_KEY:
607 adapter->secinfo.authmode = wlan802_11authmodeshared;
608 break;
609 case AUTH_ALG_NETWORK_EAP:
610 adapter->secinfo.authmode =
611 wlan802_11authmodenetworkEAP;
612 break;
613 case AUTH_ALG_OPEN_SYSTEM:
614 default:
615 adapter->secinfo.authmode = wlan802_11authmodeopen;
616 break;
617 }
618 return 0;
619}
620
621/**
622 * @brief Set 802.1x authentication mode
623 * @param priv A pointer to wlan_private structure
624 * @param req A pointer to ifreq structure
625 * @return 0 --success, otherwise fail
626 */
627static int wlan_set8021xauthalg_ioctl(wlan_private * priv, struct ifreq *req)
628{
629 int alg;
630 struct iwreq *wrq = (struct iwreq *)req;
631
632 if (wrq->u.data.flags == 0) {
633 //from iwpriv subcmd
634 alg = SUBCMD_DATA(wrq);
635 } else {
636 //from wpa_supplicant subcmd
637 if (copy_from_user(&alg, wrq->u.data.pointer, sizeof(int))) {
638 lbs_pr_debug(1, "Copy from user failed\n");
639 return -EFAULT;
640 }
641 }
642 lbs_pr_debug(1, "802.1x auth alg is %#x\n", alg);
643 priv->adapter->secinfo.auth1xalg = alg;
644 return 0;
645}
646
647static int wlan_setencryptionmode_ioctl(wlan_private * priv, struct ifreq *req)
648{
649 int mode;
650 struct iwreq *wrq = (struct iwreq *)req;
651
652 ENTER();
653
654 if (wrq->u.data.flags == 0) {
655 //from iwpriv subcmd
656 mode = SUBCMD_DATA(wrq);
657 } else {
658 //from wpa_supplicant subcmd
659 if (copy_from_user(&mode, wrq->u.data.pointer, sizeof(int))) {
660 lbs_pr_debug(1, "Copy from user failed\n");
661 return -EFAULT;
662 }
663 }
664 lbs_pr_debug(1, "encryption mode is %#x\n", mode);
665 priv->adapter->secinfo.Encryptionmode = mode;
666
667 LEAVE();
668 return 0;
669}
670
671static void adjust_mtu(wlan_private * priv)
672{
673 int mtu_increment = 0;
674
675 if (priv->adapter->linkmode == WLAN_LINKMODE_802_11)
676 mtu_increment += sizeof(struct ieee80211_hdr_4addr);
677
678 if (priv->adapter->radiomode == WLAN_RADIOMODE_RADIOTAP)
679 mtu_increment += max(sizeof(struct tx_radiotap_hdr),
680 sizeof(struct rx_radiotap_hdr));
681 priv->wlan_dev.netdev->mtu = ETH_FRAME_LEN
682 - sizeof(struct ethhdr)
683 + mtu_increment;
684}
685
686/**
687 * @brief Set Link-Layer Layer mode
688 * @param priv A pointer to wlan_private structure
689 * @param req A pointer to ifreq structure
690 * @return 0 --success, otherwise fail
691 */
692static int wlan_set_linkmode_ioctl(wlan_private * priv, struct ifreq *req)
693{
694 int mode;
695
696 mode = (int)((struct ifreq *)((u8 *) req + 4))->ifr_data;
697
698 switch (mode) {
699 case WLAN_LINKMODE_802_3:
700 priv->adapter->linkmode = mode;
701 break;
702 case WLAN_LINKMODE_802_11:
703 priv->adapter->linkmode = mode;
704 break;
705 default:
706 lbs_pr_info("usb8388-5: invalid link-layer mode (%#x)\n",
707 mode);
708 return -EINVAL;
709 break;
710 }
711 lbs_pr_debug(1, "usb8388-5: link-layer mode is %#x\n", mode);
712
713 adjust_mtu(priv);
714
715 return 0;
716}
717
718/**
719 * @brief Set Radio header mode
720 * @param priv A pointer to wlan_private structure
721 * @param req A pointer to ifreq structure
722 * @return 0 --success, otherwise fail
723 */
724static int wlan_set_radiomode_ioctl(wlan_private * priv, struct ifreq *req)
725{
726 int mode;
727
728 mode = (int)((struct ifreq *)((u8 *) req + 4))->ifr_data;
729
730 switch (mode) {
731 case WLAN_RADIOMODE_NONE:
732 priv->adapter->radiomode = mode;
733 break;
734 case WLAN_RADIOMODE_RADIOTAP:
735 priv->adapter->radiomode = mode;
736 break;
737 default:
738 lbs_pr_debug(1, "usb8388-5: invalid radio header mode (%#x)\n",
739 mode);
740 return -EINVAL;
741 }
742 lbs_pr_debug(1, "usb8388-5: radio-header mode is %#x\n", mode);
743
744 adjust_mtu(priv);
745 return 0;
746}
747
748/**
749 * @brief Set Debug header mode
750 * @param priv A pointer to wlan_private structure
751 * @param req A pointer to ifreq structure
752 * @return 0 --success, otherwise fail
753 */
754static int wlan_set_debugmode_ioctl(wlan_private * priv, struct ifreq *req)
755{
756 priv->adapter->debugmode = (int)((struct ifreq *)
757 ((u8 *) req + 4))->ifr_data;
758 return 0;
759}
760
761static int wlan_subcmd_getrxantenna_ioctl(wlan_private * priv,
762 struct ifreq *req)
763{
764 int len;
765 char buf[8];
766 struct iwreq *wrq = (struct iwreq *)req;
767
768 lbs_pr_debug(1, "WLAN_SUBCMD_GETRXANTENNA\n");
769 len = getrxantenna(priv, buf);
770
771 wrq->u.data.length = len;
772 if (wrq->u.data.pointer) {
773 if (copy_to_user(wrq->u.data.pointer, &buf, len)) {
774 lbs_pr_debug(1, "CopyToUser failed\n");
775 return -EFAULT;
776 }
777 }
778
779 return 0;
780}
781
782static int wlan_subcmd_gettxantenna_ioctl(wlan_private * priv,
783 struct ifreq *req)
784{
785 int len;
786 char buf[8];
787 struct iwreq *wrq = (struct iwreq *)req;
788
789 lbs_pr_debug(1, "WLAN_SUBCMD_GETTXANTENNA\n");
790 len = gettxantenna(priv, buf);
791
792 wrq->u.data.length = len;
793 if (wrq->u.data.pointer) {
794 if (copy_to_user(wrq->u.data.pointer, &buf, len)) {
795 lbs_pr_debug(1, "CopyToUser failed\n");
796 return -EFAULT;
797 }
798 }
799 return 0;
800}
801
802/**
803 * @brief Get the MAC TSF value from the firmware
804 *
805 * @param priv A pointer to wlan_private structure
806 * @param wrq A pointer to iwreq structure containing buffer
807 * space to store a TSF value retrieved from the firmware
808 *
809 * @return 0 if successful; IOCTL error code otherwise
810 */
811static int wlan_get_tsf_ioctl(wlan_private * priv, struct iwreq *wrq)
812{
813 u64 tsfval;
814 int ret;
815
816 ret = libertas_prepare_and_send_command(priv,
817 cmd_get_tsf,
818 0, cmd_option_waitforrsp, 0, &tsfval);
819
820 lbs_pr_debug(1, "IOCTL: Get TSF = 0x%016llx\n", tsfval);
821
822 if (ret != 0) {
823 lbs_pr_debug(1, "IOCTL: Get TSF; command exec failed\n");
824 ret = -EFAULT;
825 } else {
826 if (copy_to_user(wrq->u.data.pointer,
827 &tsfval,
828 min_t(size_t, wrq->u.data.length,
829 sizeof(tsfval))) != 0) {
830
831 lbs_pr_debug(1, "IOCTL: Get TSF; Copy to user failed\n");
832 ret = -EFAULT;
833 } else {
834 ret = 0;
835 }
836 }
837 return ret;
838}
839
840/**
841 * @brief Get/Set adapt rate
842 * @param priv A pointer to wlan_private structure
843 * @param wrq A pointer to iwreq structure
844 * @return 0 --success, otherwise fail
845 */
846static int wlan_adapt_rateset(wlan_private * priv, struct iwreq *wrq)
847{
848 int ret;
849 wlan_adapter *adapter = priv->adapter;
850 int data[2];
851
852 memset(data, 0, sizeof(data));
853 if (!wrq->u.data.length) {
854 lbs_pr_debug(1, "Get ADAPT RATE SET\n");
855 ret = libertas_prepare_and_send_command(priv,
856 cmd_802_11_rate_adapt_rateset,
857 cmd_act_get,
858 cmd_option_waitforrsp, 0, NULL);
859 data[0] = adapter->enablehwauto;
860 data[1] = adapter->ratebitmap;
861 if (copy_to_user(wrq->u.data.pointer, data, sizeof(int) * 2)) {
862 lbs_pr_debug(1, "Copy to user failed\n");
863 return -EFAULT;
864 }
865#define GET_TWO_INT 2
866 wrq->u.data.length = GET_TWO_INT;
867 } else {
868 lbs_pr_debug(1, "Set ADAPT RATE SET\n");
869 if (wrq->u.data.length > 2)
870 return -EINVAL;
871 if (copy_from_user
872 (data, wrq->u.data.pointer,
873 sizeof(int) * wrq->u.data.length)) {
874 lbs_pr_debug(1, "Copy from user failed\n");
875 return -EFAULT;
876 }
877
878 adapter->enablehwauto = data[0];
879 adapter->ratebitmap = data[1];
880 ret = libertas_prepare_and_send_command(priv,
881 cmd_802_11_rate_adapt_rateset,
882 cmd_act_set,
883 cmd_option_waitforrsp, 0, NULL);
884 }
885 return ret;
886}
887
888/**
889 * @brief Get/Set inactivity timeout
890 * @param priv A pointer to wlan_private structure
891 * @param wrq A pointer to iwreq structure
892 * @return 0 --success, otherwise fail
893 */
894static int wlan_inactivity_timeout(wlan_private * priv, struct iwreq *wrq)
895{
896 int ret;
897 int data = 0;
898 u16 timeout = 0;
899
900 ENTER();
901 if (wrq->u.data.length > 1)
902 return -ENOTSUPP;
903
904 if (wrq->u.data.length == 0) {
905 /* Get */
906 ret = libertas_prepare_and_send_command(priv,
907 cmd_802_11_inactivity_timeout,
908 cmd_act_get,
909 cmd_option_waitforrsp, 0,
910 &timeout);
911 data = timeout;
912 if (copy_to_user(wrq->u.data.pointer, &data, sizeof(int))) {
913 lbs_pr_debug(1, "Copy to user failed\n");
914 return -EFAULT;
915 }
916 } else {
917 /* Set */
918 if (copy_from_user(&data, wrq->u.data.pointer, sizeof(int))) {
919 lbs_pr_debug(1, "Copy from user failed\n");
920 return -EFAULT;
921 }
922
923 timeout = data;
924 ret = libertas_prepare_and_send_command(priv,
925 cmd_802_11_inactivity_timeout,
926 cmd_act_set,
927 cmd_option_waitforrsp, 0,
928 &timeout);
929 }
930
931 wrq->u.data.length = 1;
932
933 LEAVE();
934 return ret;
935}
936
937static int wlan_do_getlog_ioctl(wlan_private * priv, struct iwreq *wrq)
938{
939 int ret;
940 char buf[GETLOG_BUFSIZE - 1];
941 wlan_adapter *adapter = priv->adapter;
942
943 lbs_pr_debug(1, " GET STATS\n");
944
945 ret = libertas_prepare_and_send_command(priv, cmd_802_11_get_log,
946 0, cmd_option_waitforrsp, 0, NULL);
947
948 if (ret) {
949 return ret;
950 }
951
952 if (wrq->u.data.pointer) {
953 sprintf(buf, "\n mcasttxframe %u failed %u retry %u "
954 "multiretry %u framedup %u "
955 "rtssuccess %u rtsfailure %u ackfailure %u\n"
956 "rxfrag %u mcastrxframe %u fcserror %u "
957 "txframe %u wepundecryptable %u ",
958 adapter->logmsg.mcasttxframe,
959 adapter->logmsg.failed,
960 adapter->logmsg.retry,
961 adapter->logmsg.multiretry,
962 adapter->logmsg.framedup,
963 adapter->logmsg.rtssuccess,
964 adapter->logmsg.rtsfailure,
965 adapter->logmsg.ackfailure,
966 adapter->logmsg.rxfrag,
967 adapter->logmsg.mcastrxframe,
968 adapter->logmsg.fcserror,
969 adapter->logmsg.txframe,
970 adapter->logmsg.wepundecryptable);
971 wrq->u.data.length = strlen(buf) + 1;
972 if (copy_to_user(wrq->u.data.pointer, buf, wrq->u.data.length)) {
973 lbs_pr_debug(1, "Copy to user failed\n");
974 return -EFAULT;
975 }
976 }
977
978 return 0;
979}
980
981static int wlan_scan_type_ioctl(wlan_private * priv, struct iwreq *wrq)
982{
983 u8 buf[12];
984 u8 *option[] = { "active", "passive", "get", };
985 int i, max_options = (sizeof(option) / sizeof(option[0]));
986 int ret = 0;
987 wlan_adapter *adapter = priv->adapter;
988
989 if (priv->adapter->enable11d) {
990 lbs_pr_debug(1, "11D: Cannot set scantype when 11D enabled\n");
991 return -EFAULT;
992 }
993
994 memset(buf, 0, sizeof(buf));
995
996 if (copy_from_user(buf, wrq->u.data.pointer, min_t(size_t, sizeof(buf),
997 wrq->u.data.length)))
998 return -EFAULT;
999
1000 lbs_pr_debug(1, "Scan type Option = %s\n", buf);
1001
1002 buf[sizeof(buf) - 1] = '\0';
1003
1004 for (i = 0; i < max_options; i++) {
1005 if (!strcmp(buf, option[i]))
1006 break;
1007 }
1008
1009 switch (i) {
1010 case 0:
1011 adapter->scantype = cmd_scan_type_active;
1012 break;
1013 case 1:
1014 adapter->scantype = cmd_scan_type_passive;
1015 break;
1016 case 2:
1017 wrq->u.data.length = strlen(option[adapter->scantype]) + 1;
1018
1019 if (copy_to_user(wrq->u.data.pointer,
1020 option[adapter->scantype],
1021 wrq->u.data.length)) {
1022 lbs_pr_debug(1, "Copy to user failed\n");
1023 ret = -EFAULT;
1024 }
1025
1026 break;
1027 default:
1028 lbs_pr_debug(1, "Invalid Scan type Ioctl Option\n");
1029 ret = -EINVAL;
1030 break;
1031 }
1032
1033 return ret;
1034}
1035
1036static int wlan_scan_mode_ioctl(wlan_private * priv, struct iwreq *wrq)
1037{
1038 wlan_adapter *adapter = priv->adapter;
1039 u8 buf[12];
1040 u8 *option[] = { "bss", "ibss", "any", "get" };
1041 int i, max_options = (sizeof(option) / sizeof(option[0]));
1042 int ret = 0;
1043
1044 ENTER();
1045
1046 memset(buf, 0, sizeof(buf));
1047
1048 if (copy_from_user(buf, wrq->u.data.pointer, min_t(size_t, sizeof(buf),
1049 wrq->u.data.length))) {
1050 lbs_pr_debug(1, "Copy from user failed\n");
1051 return -EFAULT;
1052 }
1053
1054 lbs_pr_debug(1, "Scan mode Option = %s\n", buf);
1055
1056 buf[sizeof(buf) - 1] = '\0';
1057
1058 for (i = 0; i < max_options; i++) {
1059 if (!strcmp(buf, option[i]))
1060 break;
1061 }
1062
1063 switch (i) {
1064
1065 case 0:
1066 adapter->scanmode = cmd_bss_type_bss;
1067 break;
1068 case 1:
1069 adapter->scanmode = cmd_bss_type_ibss;
1070 break;
1071 case 2:
1072 adapter->scanmode = cmd_bss_type_any;
1073 break;
1074 case 3:
1075
1076 wrq->u.data.length = strlen(option[adapter->scanmode - 1]) + 1;
1077
1078 lbs_pr_debug(1, "Get Scan mode Option = %s\n",
1079 option[adapter->scanmode - 1]);
1080
1081 lbs_pr_debug(1, "Scan mode length %d\n", wrq->u.data.length);
1082
1083 if (copy_to_user(wrq->u.data.pointer,
1084 option[adapter->scanmode - 1],
1085 wrq->u.data.length)) {
1086 lbs_pr_debug(1, "Copy to user failed\n");
1087 ret = -EFAULT;
1088 }
1089 lbs_pr_debug(1, "GET Scan type Option after copy = %s\n",
1090 (char *)wrq->u.data.pointer);
1091
1092 break;
1093
1094 default:
1095 lbs_pr_debug(1, "Invalid Scan mode Ioctl Option\n");
1096 ret = -EINVAL;
1097 break;
1098 }
1099
1100 LEAVE();
1101 return ret;
1102}
1103
1104/**
1105 * @brief Get/Set Adhoc G Rate
1106 *
1107 * @param priv A pointer to wlan_private structure
1108 * @param wrq A pointer to user data
1109 * @return 0--success, otherwise fail
1110 */
1111static int wlan_do_set_grate_ioctl(wlan_private * priv, struct iwreq *wrq)
1112{
1113 wlan_adapter *adapter = priv->adapter;
1114 int data, data1;
1115 int *val;
1116
1117 ENTER();
1118
1119 data1 = SUBCMD_DATA(wrq);
1120 switch (data1) {
1121 case 0:
1122 adapter->adhoc_grate_enabled = 0;
1123 break;
1124 case 1:
1125 adapter->adhoc_grate_enabled = 1;
1126 break;
1127 case 2:
1128 break;
1129 default:
1130 return -EINVAL;
1131 }
1132 data = adapter->adhoc_grate_enabled;
1133 val = (int *)wrq->u.name;
1134 *val = data;
1135 LEAVE();
1136 return 0;
1137}
1138
1139static inline int hex2int(char c) 58static inline int hex2int(char c)
1140{ 59{
1141 if (c >= '0' && c <= '9') 60 if (c >= '0' && c <= '9')
@@ -1761,6 +680,7 @@ static int wlan_fwt_list_neighbor_ioctl(wlan_private * priv, struct ifreq *req)
1761 */ 680 */
1762static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req) 681static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req)
1763{ 682{
683 struct iwreq *wrq = (struct iwreq *)req;
1764 static struct cmd_ds_fwt_access fwt_access; 684 static struct cmd_ds_fwt_access fwt_access;
1765 int ret; 685 int ret;
1766 686
@@ -1776,7 +696,7 @@ static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req)
1776 (void *)&fwt_access); 696 (void *)&fwt_access);
1777 697
1778 if (ret == 0) 698 if (ret == 0)
1779 req->ifr_data = (char *)(le32_to_cpu(fwt_access.references)); 699 wrq->u.param.value = le32_to_cpu(fwt_access.references);
1780 else 700 else
1781 return -EFAULT; 701 return -EFAULT;
1782 702
@@ -1792,6 +712,7 @@ static int wlan_fwt_cleanup_ioctl(wlan_private * priv, struct ifreq *req)
1792 */ 712 */
1793static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req) 713static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req)
1794{ 714{
715 struct iwreq *wrq = (struct iwreq *)req;
1795 static struct cmd_ds_fwt_access fwt_access; 716 static struct cmd_ds_fwt_access fwt_access;
1796 int ret; 717 int ret;
1797 718
@@ -1807,7 +728,7 @@ static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req)
1807 (void *)&fwt_access); 728 (void *)&fwt_access);
1808 729
1809 if (ret == 0) 730 if (ret == 0)
1810 req->ifr_data = (char *)(le32_to_cpu(fwt_access.references)); 731 wrq->u.param.value = le32_to_cpu(fwt_access.references);
1811 else 732 else
1812 return -EFAULT; 733 return -EFAULT;
1813 734
@@ -1823,6 +744,7 @@ static int wlan_fwt_time_ioctl(wlan_private * priv, struct ifreq *req)
1823 */ 744 */
1824static int wlan_mesh_get_ttl_ioctl(wlan_private * priv, struct ifreq *req) 745static int wlan_mesh_get_ttl_ioctl(wlan_private * priv, struct ifreq *req)
1825{ 746{
747 struct iwreq *wrq = (struct iwreq *)req;
1826 struct cmd_ds_mesh_access mesh_access; 748 struct cmd_ds_mesh_access mesh_access;
1827 int ret; 749 int ret;
1828 750
@@ -1835,9 +757,8 @@ static int wlan_mesh_get_ttl_ioctl(wlan_private * priv, struct ifreq *req)
1835 cmd_option_waitforrsp, 0, 757 cmd_option_waitforrsp, 0,
1836 (void *)&mesh_access); 758 (void *)&mesh_access);
1837 759
1838 if (ret == 0) { 760 if (ret == 0)
1839 req->ifr_data = (char *)(le32_to_cpu(mesh_access.data[0])); 761 wrq->u.param.value = le32_to_cpu(mesh_access.data[0]);
1840 }
1841 else 762 else
1842 return -EFAULT; 763 return -EFAULT;
1843 764
@@ -1898,36 +819,8 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
1898 819
1899 lbs_pr_debug(1, "libertas_do_ioctl: ioctl cmd = 0x%x\n", cmd); 820 lbs_pr_debug(1, "libertas_do_ioctl: ioctl cmd = 0x%x\n", cmd);
1900 switch (cmd) { 821 switch (cmd) {
1901 case WLANSCAN_TYPE:
1902 lbs_pr_debug(1, "Scan type Ioctl\n");
1903 ret = wlan_scan_type_ioctl(priv, wrq);
1904 break;
1905
1906 case WLAN_SETNONE_GETNONE: /* set WPA mode on/off ioctl #20 */ 822 case WLAN_SETNONE_GETNONE: /* set WPA mode on/off ioctl #20 */
1907 switch (wrq->u.data.flags) { 823 switch (wrq->u.data.flags) {
1908 case WLANDEAUTH:
1909 lbs_pr_debug(1, "Deauth\n");
1910 libertas_send_deauth(priv);
1911 break;
1912
1913 case WLANADHOCSTOP:
1914 lbs_pr_debug(1, "Adhoc stop\n");
1915 ret = libertas_do_adhocstop_ioctl(priv);
1916 break;
1917
1918 case WLANRADIOON:
1919 wlan_radio_ioctl(priv, 1);
1920 break;
1921
1922 case WLANRADIOOFF:
1923 wlan_radio_ioctl(priv, 0);
1924 break;
1925 case WLANWLANIDLEON:
1926 libertas_idle_on(priv);
1927 break;
1928 case WLANWLANIDLEOFF:
1929 libertas_idle_off(priv);
1930 break;
1931 case WLAN_SUBCMD_BT_RESET: /* bt_reset */ 824 case WLAN_SUBCMD_BT_RESET: /* bt_reset */
1932 wlan_bt_reset_ioctl(priv); 825 wlan_bt_reset_ioctl(priv);
1933 break; 826 break;
@@ -1937,162 +830,19 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
1937 } /* End of switch */ 830 } /* End of switch */
1938 break; 831 break;
1939 832
1940 case WLANSETWPAIE:
1941 ret = wlan_setwpaie_ioctl(priv, req);
1942 break;
1943 case WLAN_SETINT_GETINT:
1944 /* The first 4 bytes of req->ifr_data is sub-ioctl number
1945 * after 4 bytes sits the payload.
1946 */
1947 subcmd = (int)req->ifr_data; //from iwpriv subcmd
1948 switch (subcmd) {
1949 case WLANNF:
1950 ret = wlan_get_nf(priv, wrq);
1951 break;
1952 case WLANRSSI:
1953 ret = wlan_get_rssi(priv, wrq);
1954 break;
1955 case WLANENABLE11D:
1956 ret = libertas_cmd_enable_11d(priv, wrq);
1957 break;
1958 case WLANADHOCGRATE:
1959 ret = wlan_do_set_grate_ioctl(priv, wrq);
1960 break;
1961 case WLAN_SUBCMD_SET_PRESCAN:
1962 ret = wlan_subcmd_setprescan_ioctl(priv, wrq);
1963 break;
1964 }
1965 break;
1966
1967 case WLAN_SETONEINT_GETONEINT:
1968 switch (wrq->u.data.flags) {
1969 case WLAN_BEACON_INTERVAL:
1970 ret = wlan_beacon_interval(priv, wrq);
1971 break;
1972
1973 case WLAN_LISTENINTRVL:
1974 if (!wrq->u.data.length) {
1975 int data;
1976 lbs_pr_debug(1, "Get locallisteninterval value\n");
1977#define GET_ONE_INT 1
1978 data = adapter->locallisteninterval;
1979 if (copy_to_user(wrq->u.data.pointer,
1980 &data, sizeof(int))) {
1981 lbs_pr_debug(1, "Copy to user failed\n");
1982 return -EFAULT;
1983 }
1984
1985 wrq->u.data.length = GET_ONE_INT;
1986 } else {
1987 int data;
1988 if (copy_from_user
1989 (&data, wrq->u.data.pointer, sizeof(int))) {
1990 lbs_pr_debug(1, "Copy from user failed\n");
1991 return -EFAULT;
1992 }
1993
1994 lbs_pr_debug(1, "Set locallisteninterval = %d\n",
1995 data);
1996#define MAX_U16_VAL 65535
1997 if (data > MAX_U16_VAL) {
1998 lbs_pr_debug(1, "Exceeds U16 value\n");
1999 return -EINVAL;
2000 }
2001 adapter->locallisteninterval = data;
2002 }
2003 break;
2004 case WLAN_TXCONTROL:
2005 ret = wlan_txcontrol(priv, wrq); //adds for txcontrol ioctl
2006 break;
2007
2008 case WLAN_NULLPKTINTERVAL:
2009 ret = wlan_null_pkt_interval(priv, wrq);
2010 break;
2011
2012 default:
2013 ret = -EOPNOTSUPP;
2014 break;
2015 }
2016 break;
2017
2018 case WLAN_SETONEINT_GETNONE: 833 case WLAN_SETONEINT_GETNONE:
2019 /* The first 4 bytes of req->ifr_data is sub-ioctl number 834 /* The first 4 bytes of req->ifr_data is sub-ioctl number
2020 * after 4 bytes sits the payload. 835 * after 4 bytes sits the payload.
2021 */ 836 */
2022 subcmd = wrq->u.data.flags; //from wpa_supplicant subcmd 837 subcmd = wrq->u.data.flags;
2023
2024 if (!subcmd) 838 if (!subcmd)
2025 subcmd = (int)req->ifr_data; //from iwpriv subcmd 839 subcmd = (int)wrq->u.param.value;
2026 840
2027 switch (subcmd) { 841 switch (subcmd) {
2028 case WLAN_SUBCMD_SETRXANTENNA: /* SETRXANTENNA */
2029 idata = SUBCMD_DATA(wrq);
2030 ret = setrxantenna(priv, idata);
2031 break;
2032 case WLAN_SUBCMD_SETTXANTENNA: /* SETTXANTENNA */
2033 idata = SUBCMD_DATA(wrq);
2034 ret = settxantenna(priv, idata);
2035 break;
2036 case WLAN_SET_ATIM_WINDOW:
2037 adapter->atimwindow = SUBCMD_DATA(wrq);
2038 adapter->atimwindow = min_t(__u16, adapter->atimwindow, 50);
2039 break;
2040 case WLANSETBCNAVG:
2041 adapter->bcn_avg_factor = SUBCMD_DATA(wrq);
2042 if (adapter->bcn_avg_factor == 0)
2043 adapter->bcn_avg_factor =
2044 DEFAULT_BCN_AVG_FACTOR;
2045 if (adapter->bcn_avg_factor > DEFAULT_BCN_AVG_FACTOR)
2046 adapter->bcn_avg_factor =
2047 DEFAULT_BCN_AVG_FACTOR;
2048 break;
2049 case WLANSETDATAAVG:
2050 adapter->data_avg_factor = SUBCMD_DATA(wrq);
2051 if (adapter->data_avg_factor == 0)
2052 adapter->data_avg_factor =
2053 DEFAULT_DATA_AVG_FACTOR;
2054 if (adapter->data_avg_factor > DEFAULT_DATA_AVG_FACTOR)
2055 adapter->data_avg_factor =
2056 DEFAULT_DATA_AVG_FACTOR;
2057 break;
2058 case WLANSETREGION: 842 case WLANSETREGION:
2059 idata = SUBCMD_DATA(wrq); 843 idata = SUBCMD_DATA(wrq);
2060 ret = wlan_set_region(priv, (u16) idata); 844 ret = wlan_set_region(priv, (u16) idata);
2061 break; 845 break;
2062
2063 case WLAN_SET_LISTEN_INTERVAL:
2064 idata = SUBCMD_DATA(wrq);
2065 adapter->listeninterval = (u16) idata;
2066 break;
2067
2068 case WLAN_SET_MULTIPLE_DTIM:
2069 ret = wlan_set_multiple_dtim_ioctl(priv, req);
2070 break;
2071
2072 case WLANSETAUTHALG:
2073 ret = wlan_setauthalg_ioctl(priv, req);
2074 break;
2075
2076 case WLANSET8021XAUTHALG:
2077 ret = wlan_set8021xauthalg_ioctl(priv, req);
2078 break;
2079
2080 case WLANSETENCRYPTIONMODE:
2081 ret = wlan_setencryptionmode_ioctl(priv, req);
2082 break;
2083
2084 case WLAN_SET_LINKMODE:
2085 ret = wlan_set_linkmode_ioctl(priv, req);
2086 break;
2087
2088 case WLAN_SET_RADIOMODE:
2089 ret = wlan_set_radiomode_ioctl(priv, req);
2090 break;
2091
2092 case WLAN_SET_DEBUGMODE:
2093 ret = wlan_set_debugmode_ioctl(priv, req);
2094 break;
2095
2096 case WLAN_SUBCMD_MESH_SET_TTL: 846 case WLAN_SUBCMD_MESH_SET_TTL:
2097 idata = SUBCMD_DATA(wrq); 847 idata = SUBCMD_DATA(wrq);
2098 ret = wlan_mesh_set_ttl_ioctl(priv, idata); 848 ret = wlan_mesh_set_ttl_ioctl(priv, idata);
@@ -2105,38 +855,8 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
2105 855
2106 break; 856 break;
2107 857
2108 case WLAN_SETNONE_GETTWELVE_CHAR: /* Get Antenna settings */
2109 /*
2110 * We've not used IW_PRIV_TYPE_FIXED so sub-ioctl number is
2111 * in flags of iwreq structure, otherwise it will be in
2112 * mode member of iwreq structure.
2113 */
2114 switch ((int)wrq->u.data.flags) {
2115 case WLAN_SUBCMD_GETRXANTENNA: /* Get Rx Antenna */
2116 ret = wlan_subcmd_getrxantenna_ioctl(priv, req);
2117 break;
2118
2119 case WLAN_SUBCMD_GETTXANTENNA: /* Get Tx Antenna */
2120 ret = wlan_subcmd_gettxantenna_ioctl(priv, req);
2121 break;
2122
2123 case WLAN_GET_TSF:
2124 ret = wlan_get_tsf_ioctl(priv, wrq);
2125 break;
2126 }
2127 break;
2128
2129 case WLAN_SET128CHAR_GET128CHAR: 858 case WLAN_SET128CHAR_GET128CHAR:
2130 switch ((int)wrq->u.data.flags) { 859 switch ((int)wrq->u.data.flags) {
2131
2132 case WLANSCAN_MODE:
2133 lbs_pr_debug(1, "Scan mode Ioctl\n");
2134 ret = wlan_scan_mode_ioctl(priv, wrq);
2135 break;
2136
2137 case WLAN_GET_ADHOC_STATUS:
2138 ret = wlan_get_adhoc_status_ioctl(priv, wrq);
2139 break;
2140 case WLAN_SUBCMD_BT_ADD: 860 case WLAN_SUBCMD_BT_ADD:
2141 ret = wlan_bt_add_ioctl(priv, req); 861 ret = wlan_bt_add_ioctl(priv, req);
2142 break; 862 break;
@@ -2168,41 +888,11 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
2168 break; 888 break;
2169 889
2170 case WLAN_SETNONE_GETONEINT: 890 case WLAN_SETNONE_GETONEINT:
2171 switch ((int)req->ifr_data) { 891 switch (wrq->u.param.value) {
2172 case WLANGETBCNAVG:
2173 pdata = (int *)wrq->u.name;
2174 *pdata = (int)adapter->bcn_avg_factor;
2175 break;
2176
2177 case WLANGETREGION: 892 case WLANGETREGION:
2178 pdata = (int *)wrq->u.name; 893 pdata = (int *)wrq->u.name;
2179 *pdata = (int)adapter->regioncode; 894 *pdata = (int)adapter->regioncode;
2180 break; 895 break;
2181
2182 case WLAN_GET_LISTEN_INTERVAL:
2183 pdata = (int *)wrq->u.name;
2184 *pdata = (int)adapter->listeninterval;
2185 break;
2186
2187 case WLAN_GET_LINKMODE:
2188 req->ifr_data = (char *)((u32) adapter->linkmode);
2189 break;
2190
2191 case WLAN_GET_RADIOMODE:
2192 req->ifr_data = (char *)((u32) adapter->radiomode);
2193 break;
2194
2195 case WLAN_GET_DEBUGMODE:
2196 req->ifr_data = (char *)((u32) adapter->debugmode);
2197 break;
2198
2199 case WLAN_GET_MULTIPLE_DTIM:
2200 pdata = (int *)wrq->u.name;
2201 *pdata = (int)adapter->multipledtim;
2202 break;
2203 case WLAN_GET_TX_RATE:
2204 ret = wlan_get_txrate_ioctl(priv, req);
2205 break;
2206 case WLAN_SUBCMD_FWT_CLEANUP: /* fwt_cleanup */ 896 case WLAN_SUBCMD_FWT_CLEANUP: /* fwt_cleanup */
2207 ret = wlan_fwt_cleanup_ioctl(priv, req); 897 ret = wlan_fwt_cleanup_ioctl(priv, req);
2208 break; 898 break;
@@ -2222,196 +912,8 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
2222 912
2223 break; 913 break;
2224 914
2225 case WLANGETLOG:
2226 ret = wlan_do_getlog_ioctl(priv, wrq);
2227 break;
2228
2229 case WLAN_SET_GET_SIXTEEN_INT: 915 case WLAN_SET_GET_SIXTEEN_INT:
2230 switch ((int)wrq->u.data.flags) { 916 switch ((int)wrq->u.data.flags) {
2231 case WLAN_TPCCFG:
2232 {
2233 int data[5];
2234 struct cmd_ds_802_11_tpc_cfg cfg;
2235 memset(&cfg, 0, sizeof(cfg));
2236 if ((wrq->u.data.length > 1)
2237 && (wrq->u.data.length != 5))
2238 return -1;
2239
2240 if (wrq->u.data.length == 0) {
2241 cfg.action =
2242 cpu_to_le16
2243 (cmd_act_get);
2244 } else {
2245 if (copy_from_user
2246 (data, wrq->u.data.pointer,
2247 sizeof(int) * 5)) {
2248 lbs_pr_debug(1,
2249 "Copy from user failed\n");
2250 return -EFAULT;
2251 }
2252
2253 cfg.action =
2254 cpu_to_le16
2255 (cmd_act_set);
2256 cfg.enable = data[0];
2257 cfg.usesnr = data[1];
2258 cfg.P0 = data[2];
2259 cfg.P1 = data[3];
2260 cfg.P2 = data[4];
2261 }
2262
2263 ret =
2264 libertas_prepare_and_send_command(priv,
2265 cmd_802_11_tpc_cfg,
2266 0,
2267 cmd_option_waitforrsp,
2268 0, (void *)&cfg);
2269
2270 data[0] = cfg.enable;
2271 data[1] = cfg.usesnr;
2272 data[2] = cfg.P0;
2273 data[3] = cfg.P1;
2274 data[4] = cfg.P2;
2275 if (copy_to_user
2276 (wrq->u.data.pointer, data,
2277 sizeof(int) * 5)) {
2278 lbs_pr_debug(1, "Copy to user failed\n");
2279 return -EFAULT;
2280 }
2281
2282 wrq->u.data.length = 5;
2283 }
2284 break;
2285
2286 case WLAN_POWERCFG:
2287 {
2288 int data[4];
2289 struct cmd_ds_802_11_pwr_cfg cfg;
2290 memset(&cfg, 0, sizeof(cfg));
2291 if ((wrq->u.data.length > 1)
2292 && (wrq->u.data.length != 4))
2293 return -1;
2294 if (wrq->u.data.length == 0) {
2295 cfg.action =
2296 cpu_to_le16
2297 (cmd_act_get);
2298 } else {
2299 if (copy_from_user
2300 (data, wrq->u.data.pointer,
2301 sizeof(int) * 4)) {
2302 lbs_pr_debug(1,
2303 "Copy from user failed\n");
2304 return -EFAULT;
2305 }
2306
2307 cfg.action =
2308 cpu_to_le16
2309 (cmd_act_set);
2310 cfg.enable = data[0];
2311 cfg.PA_P0 = data[1];
2312 cfg.PA_P1 = data[2];
2313 cfg.PA_P2 = data[3];
2314 }
2315 ret =
2316 libertas_prepare_and_send_command(priv,
2317 cmd_802_11_pwr_cfg,
2318 0,
2319 cmd_option_waitforrsp,
2320 0, (void *)&cfg);
2321 data[0] = cfg.enable;
2322 data[1] = cfg.PA_P0;
2323 data[2] = cfg.PA_P1;
2324 data[3] = cfg.PA_P2;
2325 if (copy_to_user
2326 (wrq->u.data.pointer, data,
2327 sizeof(int) * 4)) {
2328 lbs_pr_debug(1, "Copy to user failed\n");
2329 return -EFAULT;
2330 }
2331
2332 wrq->u.data.length = 4;
2333 }
2334 break;
2335 case WLAN_AUTO_FREQ_SET:
2336 {
2337 int data[3];
2338 struct cmd_ds_802_11_afc afc;
2339 memset(&afc, 0, sizeof(afc));
2340 if (wrq->u.data.length != 3)
2341 return -1;
2342 if (copy_from_user
2343 (data, wrq->u.data.pointer,
2344 sizeof(int) * 3)) {
2345 lbs_pr_debug(1, "Copy from user failed\n");
2346 return -EFAULT;
2347 }
2348 afc.afc_auto = data[0];
2349
2350 if (afc.afc_auto != 0) {
2351 afc.threshold = data[1];
2352 afc.period = data[2];
2353 } else {
2354 afc.timing_offset = data[1];
2355 afc.carrier_offset = data[2];
2356 }
2357 ret =
2358 libertas_prepare_and_send_command(priv,
2359 cmd_802_11_set_afc,
2360 0,
2361 cmd_option_waitforrsp,
2362 0, (void *)&afc);
2363 }
2364 break;
2365 case WLAN_AUTO_FREQ_GET:
2366 {
2367 int data[3];
2368 struct cmd_ds_802_11_afc afc;
2369 memset(&afc, 0, sizeof(afc));
2370 ret =
2371 libertas_prepare_and_send_command(priv,
2372 cmd_802_11_get_afc,
2373 0,
2374 cmd_option_waitforrsp,
2375 0, (void *)&afc);
2376 data[0] = afc.afc_auto;
2377 data[1] = afc.timing_offset;
2378 data[2] = afc.carrier_offset;
2379 if (copy_to_user
2380 (wrq->u.data.pointer, data,
2381 sizeof(int) * 3)) {
2382 lbs_pr_debug(1, "Copy to user failed\n");
2383 return -EFAULT;
2384 }
2385
2386 wrq->u.data.length = 3;
2387 }
2388 break;
2389 case WLAN_SCANPROBES:
2390 {
2391 int data;
2392 if (wrq->u.data.length > 0) {
2393 if (copy_from_user
2394 (&data, wrq->u.data.pointer,
2395 sizeof(int))) {
2396 lbs_pr_debug(1,
2397 "Copy from user failed\n");
2398 return -EFAULT;
2399 }
2400
2401 adapter->scanprobes = data;
2402 } else {
2403 data = adapter->scanprobes;
2404 if (copy_to_user
2405 (wrq->u.data.pointer, &data,
2406 sizeof(int))) {
2407 lbs_pr_debug(1,
2408 "Copy to user failed\n");
2409 return -EFAULT;
2410 }
2411 }
2412 wrq->u.data.length = 1;
2413 }
2414 break;
2415 case WLAN_LED_GPIO_CTRL: 917 case WLAN_LED_GPIO_CTRL:
2416 { 918 {
2417 int i; 919 int i;
@@ -2475,17 +977,6 @@ int libertas_do_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
2475 wrq->u.data.length = gpio->header.len; 977 wrq->u.data.length = gpio->header.len;
2476 } 978 }
2477 break; 979 break;
2478 case WLAN_ADAPT_RATESET:
2479 ret = wlan_adapt_rateset(priv, wrq);
2480 break;
2481 case WLAN_INACTIVITY_TIMEOUT:
2482 ret = wlan_inactivity_timeout(priv, wrq);
2483 break;
2484 case WLANSNR:
2485 ret = wlan_get_snr(priv, wrq);
2486 break;
2487 case WLAN_GET_RXINFO:
2488 ret = wlan_get_rxinfo(priv, wrq);
2489 } 980 }
2490 break; 981 break;
2491 982
diff --git a/drivers/net/wireless/libertas/join.c b/drivers/net/wireless/libertas/join.c
index 11682cbe752b..d4926b83e145 100644
--- a/drivers/net/wireless/libertas/join.c
+++ b/drivers/net/wireless/libertas/join.c
@@ -15,6 +15,8 @@
15#include "join.h" 15#include "join.h"
16#include "dev.h" 16#include "dev.h"
17 17
18#define AD_HOC_CAP_PRIVACY_ON 1
19
18/** 20/**
19 * @brief This function finds out the common rates between rate1 and rate2. 21 * @brief This function finds out the common rates between rate1 and rate2.
20 * 22 *
@@ -85,7 +87,7 @@ int libertas_send_deauth(wlan_private * priv)
85 wlan_adapter *adapter = priv->adapter; 87 wlan_adapter *adapter = priv->adapter;
86 int ret = 0; 88 int ret = 0;
87 89
88 if (adapter->inframode == wlan802_11infrastructure && 90 if (adapter->mode == IW_MODE_INFRA &&
89 adapter->connect_status == libertas_connected) 91 adapter->connect_status == libertas_connected)
90 ret = libertas_send_deauthentication(priv); 92 ret = libertas_send_deauthentication(priv);
91 else 93 else
@@ -94,20 +96,6 @@ int libertas_send_deauth(wlan_private * priv)
94 return ret; 96 return ret;
95} 97}
96 98
97int libertas_do_adhocstop_ioctl(wlan_private * priv)
98{
99 wlan_adapter *adapter = priv->adapter;
100 int ret = 0;
101
102 if (adapter->inframode == wlan802_11ibss &&
103 adapter->connect_status == libertas_connected)
104 ret = libertas_stop_adhoc_network(priv);
105 else
106 ret = -ENOTSUPP;
107
108 return ret;
109}
110
111/** 99/**
112 * @brief Associate to a specific BSS discovered in a scan 100 * @brief Associate to a specific BSS discovered in a scan
113 * 101 *
@@ -207,8 +195,7 @@ int libertas_join_adhoc_network(wlan_private * priv, struct bss_descriptor * pbs
207 /* check if the requested SSID is already joined */ 195 /* check if the requested SSID is already joined */
208 if (adapter->curbssparams.ssid.ssidlength 196 if (adapter->curbssparams.ssid.ssidlength
209 && !libertas_SSID_cmp(&pbssdesc->ssid, &adapter->curbssparams.ssid) 197 && !libertas_SSID_cmp(&pbssdesc->ssid, &adapter->curbssparams.ssid)
210 && (adapter->curbssparams.bssdescriptor.inframode == 198 && (adapter->mode == IW_MODE_ADHOC)) {
211 wlan802_11ibss)) {
212 199
213 lbs_pr_debug(1, 200 lbs_pr_debug(1,
214 "ADHOC_J_CMD: New ad-hoc SSID is the same as current, " 201 "ADHOC_J_CMD: New ad-hoc SSID is the same as current, "
@@ -261,130 +248,6 @@ int libertas_send_deauthentication(wlan_private * priv)
261} 248}
262 249
263/** 250/**
264 * @brief Set Idle Off
265 *
266 * @param priv A pointer to wlan_private structure
267 * @return 0 --success, otherwise fail
268 */
269int libertas_idle_off(wlan_private * priv)
270{
271 wlan_adapter *adapter = priv->adapter;
272 int ret = 0;
273 const u8 zeromac[] = { 0, 0, 0, 0, 0, 0 };
274 int i;
275
276 ENTER();
277
278 if (adapter->connect_status == libertas_disconnected) {
279 if (adapter->inframode == wlan802_11infrastructure) {
280 if (memcmp(adapter->previousbssid, zeromac,
281 sizeof(zeromac)) != 0) {
282
283 lbs_pr_debug(1, "Previous SSID = %s\n",
284 adapter->previousssid.ssid);
285 lbs_pr_debug(1, "Previous BSSID = "
286 "%02x:%02x:%02x:%02x:%02x:%02x:\n",
287 adapter->previousbssid[0],
288 adapter->previousbssid[1],
289 adapter->previousbssid[2],
290 adapter->previousbssid[3],
291 adapter->previousbssid[4],
292 adapter->previousbssid[5]);
293
294 i = libertas_find_SSID_in_list(adapter,
295 &adapter->previousssid,
296 adapter->previousbssid,
297 adapter->inframode);
298
299 if (i < 0) {
300 libertas_send_specific_BSSID_scan(priv,
301 adapter->
302 previousbssid,
303 1);
304 i = libertas_find_SSID_in_list(adapter,
305 &adapter->
306 previousssid,
307 adapter->
308 previousbssid,
309 adapter->
310 inframode);
311 }
312
313 if (i < 0) {
314 /* If the BSSID could not be found, try just the SSID */
315 i = libertas_find_SSID_in_list(adapter,
316 &adapter->
317 previousssid, NULL,
318 adapter->
319 inframode);
320 }
321
322 if (i < 0) {
323 libertas_send_specific_SSID_scan(priv,
324 &adapter->
325 previousssid,
326 1);
327 i = libertas_find_SSID_in_list(adapter,
328 &adapter->
329 previousssid, NULL,
330 adapter->
331 inframode);
332 }
333
334 if (i >= 0) {
335 ret =
336 wlan_associate(priv,
337 &adapter->
338 scantable[i]);
339 }
340 }
341 } else if (adapter->inframode == wlan802_11ibss) {
342 ret = libertas_prepare_and_send_command(priv,
343 cmd_802_11_ad_hoc_start,
344 0,
345 cmd_option_waitforrsp,
346 0, &adapter->previousssid);
347 }
348 }
349 /* else it is connected */
350
351 lbs_pr_debug(1, "\nwlanidle is off");
352 LEAVE();
353 return ret;
354}
355
356/**
357 * @brief Set Idle On
358 *
359 * @param priv A pointer to wlan_private structure
360 * @return 0 --success, otherwise fail
361 */
362int libertas_idle_on(wlan_private * priv)
363{
364 wlan_adapter *adapter = priv->adapter;
365 int ret = 0;
366
367 if (adapter->connect_status == libertas_connected) {
368 if (adapter->inframode == wlan802_11infrastructure) {
369 lbs_pr_debug(1, "Previous SSID = %s\n",
370 adapter->previousssid.ssid);
371 memmove(&adapter->previousssid,
372 &adapter->curbssparams.ssid,
373 sizeof(struct WLAN_802_11_SSID));
374 libertas_send_deauth(priv);
375
376 } else if (adapter->inframode == wlan802_11ibss) {
377 ret = libertas_stop_adhoc_network(priv);
378 }
379
380 }
381
382 lbs_pr_debug(1, "\nwlanidle is on");
383
384 return ret;
385}
386
387/**
388 * @brief This function prepares command of authenticate. 251 * @brief This function prepares command of authenticate.
389 * 252 *
390 * @param priv A pointer to wlan_private structure 253 * @param priv A pointer to wlan_private structure
@@ -398,22 +261,39 @@ int libertas_cmd_80211_authenticate(wlan_private * priv,
398 void *pdata_buf) 261 void *pdata_buf)
399{ 262{
400 wlan_adapter *adapter = priv->adapter; 263 wlan_adapter *adapter = priv->adapter;
401 struct cmd_ds_802_11_authenticate *pauthenticate = 264 struct cmd_ds_802_11_authenticate *pauthenticate = &cmd->params.auth;
402 &cmd->params.auth; 265 int ret = -1;
403 u8 *bssid = pdata_buf; 266 u8 *bssid = pdata_buf;
404 267
405 cmd->command = cpu_to_le16(cmd_802_11_authenticate); 268 cmd->command = cpu_to_le16(cmd_802_11_authenticate);
406 cmd->size = 269 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_authenticate)
407 cpu_to_le16(sizeof(struct cmd_ds_802_11_authenticate) 270 + S_DS_GEN);
408 + S_DS_GEN); 271
272 /* translate auth mode to 802.11 defined wire value */
273 switch (adapter->secinfo.auth_mode) {
274 case IW_AUTH_ALG_OPEN_SYSTEM:
275 pauthenticate->authtype = 0x00;
276 break;
277 case IW_AUTH_ALG_SHARED_KEY:
278 pauthenticate->authtype = 0x01;
279 break;
280 case IW_AUTH_ALG_LEAP:
281 pauthenticate->authtype = 0x80;
282 break;
283 default:
284 lbs_pr_debug(1, "AUTH_CMD: invalid auth alg 0x%X\n",
285 adapter->secinfo.auth_mode);
286 goto out;
287 }
409 288
410 pauthenticate->authtype = adapter->secinfo.authmode;
411 memcpy(pauthenticate->macaddr, bssid, ETH_ALEN); 289 memcpy(pauthenticate->macaddr, bssid, ETH_ALEN);
412 290
413 lbs_pr_debug(1, "AUTH_CMD: Bssid is : %x:%x:%x:%x:%x:%x\n", 291 lbs_pr_debug(1, "AUTH_CMD: Bssid is : %x:%x:%x:%x:%x:%x\n",
414 bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); 292 bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]);
293 ret = 0;
415 294
416 return 0; 295out:
296 return ret;
417} 297}
418 298
419int libertas_cmd_80211_deauthenticate(wlan_private * priv, 299int libertas_cmd_80211_deauthenticate(wlan_private * priv,
@@ -550,7 +430,7 @@ int libertas_cmd_80211_associate(wlan_private * priv,
550 lbs_pr_debug(1, "ASSOC_CMD: rates->header.len = %d\n", rates->header.len); 430 lbs_pr_debug(1, "ASSOC_CMD: rates->header.len = %d\n", rates->header.len);
551 431
552 /* set IBSS field */ 432 /* set IBSS field */
553 if (pbssdesc->inframode == wlan802_11infrastructure) { 433 if (pbssdesc->mode == IW_MODE_INFRA) {
554#define CAPINFO_ESS_MODE 1 434#define CAPINFO_ESS_MODE 1
555 passo->capinfo.ess = CAPINFO_ESS_MODE; 435 passo->capinfo.ess = CAPINFO_ESS_MODE;
556 } 436 }
@@ -624,7 +504,7 @@ int libertas_cmd_80211_ad_hoc_start(wlan_private * priv,
624 504
625 /* set the BSS type */ 505 /* set the BSS type */
626 adhs->bsstype = cmd_bss_type_ibss; 506 adhs->bsstype = cmd_bss_type_ibss;
627 pbssdesc->inframode = wlan802_11ibss; 507 pbssdesc->mode = IW_MODE_ADHOC;
628 adhs->beaconperiod = adapter->beaconperiod; 508 adhs->beaconperiod = adapter->beaconperiod;
629 509
630 /* set Physical param set */ 510 /* set Physical param set */
@@ -666,15 +546,12 @@ int libertas_cmd_80211_ad_hoc_start(wlan_private * priv,
666 adhs->probedelay = cpu_to_le16(cmd_scan_probe_delay_time); 546 adhs->probedelay = cpu_to_le16(cmd_scan_probe_delay_time);
667 547
668 /* set up privacy in adapter->scantable[i] */ 548 /* set up privacy in adapter->scantable[i] */
669 if (adapter->secinfo.WEPstatus == wlan802_11WEPenabled) { 549 if (adapter->secinfo.wep_enabled) {
670 550 lbs_pr_debug(1, "ADHOC_S_CMD: WEP enabled, setting privacy on\n");
671#define AD_HOC_CAP_PRIVACY_ON 1
672 lbs_pr_debug(1, "ADHOC_S_CMD: WEPstatus set, privacy to WEP\n");
673 pbssdesc->privacy = wlan802_11privfilter8021xWEP; 551 pbssdesc->privacy = wlan802_11privfilter8021xWEP;
674 adhs->cap.privacy = AD_HOC_CAP_PRIVACY_ON; 552 adhs->cap.privacy = AD_HOC_CAP_PRIVACY_ON;
675 } else { 553 } else {
676 lbs_pr_debug(1, "ADHOC_S_CMD: WEPstatus NOT set, Setting " 554 lbs_pr_debug(1, "ADHOC_S_CMD: WEP disabled, setting privacy off\n");
677 "privacy to ACCEPT ALL\n");
678 pbssdesc->privacy = wlan802_11privfilteracceptall; 555 pbssdesc->privacy = wlan802_11privfilteracceptall;
679 } 556 }
680 557
@@ -786,9 +663,6 @@ int libertas_cmd_80211_ad_hoc_join(wlan_private * priv,
786 padhocjoin->bssdescriptor.BSSID[5], 663 padhocjoin->bssdescriptor.BSSID[5],
787 padhocjoin->bssdescriptor.SSID); 664 padhocjoin->bssdescriptor.SSID);
788 665
789 lbs_pr_debug(1, "ADHOC_J_CMD: Data Rate = %x\n",
790 (u32) padhocjoin->bssdescriptor.datarates);
791
792 /* failtimeout */ 666 /* failtimeout */
793 padhocjoin->failtimeout = cpu_to_le16(MRVDRV_ASSOCIATION_TIME_OUT); 667 padhocjoin->failtimeout = cpu_to_le16(MRVDRV_ASSOCIATION_TIME_OUT);
794 668
@@ -832,7 +706,7 @@ int libertas_cmd_80211_ad_hoc_join(wlan_private * priv,
832 padhocjoin->bssdescriptor.ssparamset.ibssparamset.atimwindow = 706 padhocjoin->bssdescriptor.ssparamset.ibssparamset.atimwindow =
833 cpu_to_le16(pbssdesc->atimwindow); 707 cpu_to_le16(pbssdesc->atimwindow);
834 708
835 if (adapter->secinfo.WEPstatus == wlan802_11WEPenabled) { 709 if (adapter->secinfo.wep_enabled) {
836 padhocjoin->bssdescriptor.cap.privacy = AD_HOC_CAP_PRIVACY_ON; 710 padhocjoin->bssdescriptor.cap.privacy = AD_HOC_CAP_PRIVACY_ON;
837 } 711 }
838 712
diff --git a/drivers/net/wireless/libertas/join.h b/drivers/net/wireless/libertas/join.h
index 8efa2455af9a..115f5a8ba346 100644
--- a/drivers/net/wireless/libertas/join.h
+++ b/drivers/net/wireless/libertas/join.h
@@ -1,6 +1,3 @@
1/* -*- mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
2/* vi: set expandtab shiftwidth=4 tabstop=4 textwidth=78: */
3
4/** 1/**
5 * Interface for the wlan infrastructure and adhoc join routines 2 * Interface for the wlan infrastructure and adhoc join routines
6 * 3 *
@@ -40,10 +37,6 @@ extern int libertas_ret_80211_disassociate(wlan_private * priv,
40extern int libertas_ret_80211_associate(wlan_private * priv, 37extern int libertas_ret_80211_associate(wlan_private * priv,
41 struct cmd_ds_command *resp); 38 struct cmd_ds_command *resp);
42 39
43extern int libertas_idle_on(wlan_private * priv);
44extern int libertas_idle_off(wlan_private * priv);
45
46extern int libertas_do_adhocstop_ioctl(wlan_private * priv);
47extern int libertas_reassociation_thread(void *data); 40extern int libertas_reassociation_thread(void *data);
48 41
49struct WLAN_802_11_SSID; 42struct WLAN_802_11_SSID;
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index dcbf102a057e..b9b25ce65919 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -21,6 +21,13 @@
21#include "debugfs.h" 21#include "debugfs.h"
22#include "assoc.h" 22#include "assoc.h"
23 23
24#define DRIVER_RELEASE_VERSION "320.p0"
25const char libertas_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION
26#ifdef DEBUG
27 "-dbg"
28#endif
29 "";
30
24#ifdef ENABLE_PM 31#ifdef ENABLE_PM
25static struct pm_dev *wlan_pm_dev = NULL; 32static struct pm_dev *wlan_pm_dev = NULL;
26#endif 33#endif
diff --git a/drivers/net/wireless/libertas/rx.c b/drivers/net/wireless/libertas/rx.c
index 7e3f78f092dc..d17924f764e5 100644
--- a/drivers/net/wireless/libertas/rx.c
+++ b/drivers/net/wireless/libertas/rx.c
@@ -210,7 +210,7 @@ int libertas_process_rxed_packet(wlan_private * priv, struct sk_buff *skb)
210 goto done; 210 goto done;
211 } 211 }
212 212
213 lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %d = %d\n", 213 lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %zd = %zd\n",
214 skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd)); 214 skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd));
215 215
216 lbs_dbg_hex("RX Data: Dest", p_rx_pkt->eth803_hdr.dest_addr, 216 lbs_dbg_hex("RX Data: Dest", p_rx_pkt->eth803_hdr.dest_addr,
@@ -364,7 +364,7 @@ static int process_rxed_802_11_packet(wlan_private * priv, struct sk_buff *skb)
364 priv->stats.rx_errors++; 364 priv->stats.rx_errors++;
365 } 365 }
366 366
367 lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %d = %d\n", 367 lbs_pr_debug(1, "RX Data: skb->len - sizeof(RxPd) = %d - %zd = %zd\n",
368 skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd)); 368 skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd));
369 369
370 /* create the exported radio header */ 370 /* create the exported radio header */
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index e18706238951..3c0b1a2a1727 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -1,6 +1,3 @@
1/* -*- mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
2/* vi: set expandtab shiftwidth=4 tabstop=4 textwidth=78: */
3
4/** 1/**
5 * Functions implementing wlan scan IOCTL and firmware command APIs 2 * Functions implementing wlan scan IOCTL and firmware command APIs
6 * 3 *
@@ -87,118 +84,95 @@
87 * 84 *
88 * @return Index in scantable, or error code if negative 85 * @return Index in scantable, or error code if negative
89 */ 86 */
90static int is_network_compatible(wlan_adapter * adapter, int index, int mode) 87static int is_network_compatible(wlan_adapter * adapter, int index, u8 mode)
91{ 88{
92 ENTER(); 89 ENTER();
93 90
94 if (adapter->scantable[index].inframode == mode) { 91 if (adapter->scantable[index].mode == mode) {
95 if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled 92 if ( !adapter->secinfo.wep_enabled
96 && !adapter->secinfo.WPAenabled 93 && !adapter->secinfo.WPAenabled
97 && !adapter->secinfo.WPA2enabled 94 && !adapter->secinfo.WPA2enabled
98 && adapter->scantable[index].wpa_supplicant.wpa_ie[0] != 95 && adapter->scantable[index].wpa_ie[0] != WPA_IE
99 WPA_IE 96 && adapter->scantable[index].rsn_ie[0] != WPA2_IE
100 && adapter->scantable[index].wpa2_supplicant.wpa_ie[0] !=
101 WPA2_IE && adapter->secinfo.Encryptionmode == CIPHER_NONE
102 && !adapter->scantable[index].privacy) { 97 && !adapter->scantable[index].privacy) {
103 /* no security */ 98 /* no security */
104 LEAVE(); 99 LEAVE();
105 return index; 100 return index;
106 } else if (adapter->secinfo.WEPstatus == wlan802_11WEPenabled 101 } else if ( adapter->secinfo.wep_enabled
107 && !adapter->secinfo.WPAenabled 102 && !adapter->secinfo.WPAenabled
108 && !adapter->secinfo.WPA2enabled 103 && !adapter->secinfo.WPA2enabled
109 && adapter->scantable[index].privacy) { 104 && adapter->scantable[index].privacy) {
110 /* static WEP enabled */ 105 /* static WEP enabled */
111 LEAVE(); 106 LEAVE();
112 return index; 107 return index;
113 } else if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled 108 } else if ( !adapter->secinfo.wep_enabled
114 && adapter->secinfo.WPAenabled 109 && adapter->secinfo.WPAenabled
115 && !adapter->secinfo.WPA2enabled 110 && !adapter->secinfo.WPA2enabled
116 && (adapter->scantable[index].wpa_supplicant. 111 && (adapter->scantable[index].wpa_ie[0] == WPA_IE)
117 wpa_ie[0]
118 == WPA_IE)
119 /* privacy bit may NOT be set in some APs like LinkSys WRT54G 112 /* privacy bit may NOT be set in some APs like LinkSys WRT54G
120 && adapter->scantable[index].privacy */ 113 && adapter->scantable[index].privacy */
121 ) { 114 ) {
122 /* WPA enabled */ 115 /* WPA enabled */
123 lbs_pr_debug(1, 116 lbs_pr_debug(1,
124 "is_network_compatible() WPA: index=%d wpa_ie=%#x " 117 "is_network_compatible() WPA: index=%d wpa_ie=%#x "
125 "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s Encmode=%#x " 118 "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s "
126 "privacy=%#x\n", index, 119 "privacy=%#x\n", index,
127 adapter->scantable[index].wpa_supplicant. 120 adapter->scantable[index].wpa_ie[0],
128 wpa_ie[0], 121 adapter->scantable[index].rsn_ie[0],
129 adapter->scantable[index].wpa2_supplicant. 122 adapter->secinfo.wep_enabled ? "e" : "d",
130 wpa_ie[0], 123 adapter->secinfo.WPAenabled ? "e" : "d",
131 (adapter->secinfo.WEPstatus == 124 adapter->secinfo.WPA2enabled ? "e" : "d",
132 wlan802_11WEPenabled) ? "e" : "d",
133 (adapter->secinfo.WPAenabled) ? "e" : "d",
134 (adapter->secinfo.WPA2enabled) ? "e" : "d",
135 adapter->secinfo.Encryptionmode,
136 adapter->scantable[index].privacy); 125 adapter->scantable[index].privacy);
137 LEAVE(); 126 LEAVE();
138 return index; 127 return index;
139 } else if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled 128 } else if ( !adapter->secinfo.wep_enabled
140 && !adapter->secinfo.WPAenabled 129 && !adapter->secinfo.WPAenabled
141 && adapter->secinfo.WPA2enabled 130 && adapter->secinfo.WPA2enabled
142 && (adapter->scantable[index].wpa2_supplicant. 131 && (adapter->scantable[index].rsn_ie[0] == WPA2_IE)
143 wpa_ie[0]
144 == WPA2_IE)
145 /* privacy bit may NOT be set in some APs like LinkSys WRT54G 132 /* privacy bit may NOT be set in some APs like LinkSys WRT54G
146 && adapter->scantable[index].privacy */ 133 && adapter->scantable[index].privacy */
147 ) { 134 ) {
148 /* WPA2 enabled */ 135 /* WPA2 enabled */
149 lbs_pr_debug(1, 136 lbs_pr_debug(1,
150 "is_network_compatible() WPA2: index=%d wpa_ie=%#x " 137 "is_network_compatible() WPA2: index=%d wpa_ie=%#x "
151 "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s Encmode=%#x " 138 "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s "
152 "privacy=%#x\n", index, 139 "privacy=%#x\n", index,
153 adapter->scantable[index].wpa_supplicant. 140 adapter->scantable[index].wpa_ie[0],
154 wpa_ie[0], 141 adapter->scantable[index].rsn_ie[0],
155 adapter->scantable[index].wpa2_supplicant. 142 adapter->secinfo.wep_enabled ? "e" : "d",
156 wpa_ie[0], 143 adapter->secinfo.WPAenabled ? "e" : "d",
157 (adapter->secinfo.WEPstatus == 144 adapter->secinfo.WPA2enabled ? "e" : "d",
158 wlan802_11WEPenabled) ? "e" : "d",
159 (adapter->secinfo.WPAenabled) ? "e" : "d",
160 (adapter->secinfo.WPA2enabled) ? "e" : "d",
161 adapter->secinfo.Encryptionmode,
162 adapter->scantable[index].privacy); 145 adapter->scantable[index].privacy);
163 LEAVE(); 146 LEAVE();
164 return index; 147 return index;
165 } else if (adapter->secinfo.WEPstatus == wlan802_11WEPdisabled 148 } else if ( !adapter->secinfo.wep_enabled
166 && !adapter->secinfo.WPAenabled 149 && !adapter->secinfo.WPAenabled
167 && !adapter->secinfo.WPA2enabled 150 && !adapter->secinfo.WPA2enabled
168 && (adapter->scantable[index].wpa_supplicant. 151 && (adapter->scantable[index].wpa_ie[0] != WPA_IE)
169 wpa_ie[0] 152 && (adapter->scantable[index].rsn_ie[0] != WPA2_IE)
170 != WPA_IE)
171 && (adapter->scantable[index].wpa2_supplicant.
172 wpa_ie[0]
173 != WPA2_IE)
174 && adapter->secinfo.Encryptionmode != CIPHER_NONE
175 && adapter->scantable[index].privacy) { 153 && adapter->scantable[index].privacy) {
176 /* dynamic WEP enabled */ 154 /* dynamic WEP enabled */
177 lbs_pr_debug(1, 155 lbs_pr_debug(1,
178 "is_network_compatible() dynamic WEP: index=%d " 156 "is_network_compatible() dynamic WEP: index=%d "
179 "wpa_ie=%#x wpa2_ie=%#x Encmode=%#x privacy=%#x\n", 157 "wpa_ie=%#x wpa2_ie=%#x privacy=%#x\n",
180 index, 158 index,
181 adapter->scantable[index].wpa_supplicant. 159 adapter->scantable[index].wpa_ie[0],
182 wpa_ie[0], 160 adapter->scantable[index].rsn_ie[0],
183 adapter->scantable[index].wpa2_supplicant.
184 wpa_ie[0], adapter->secinfo.Encryptionmode,
185 adapter->scantable[index].privacy); 161 adapter->scantable[index].privacy);
186 LEAVE(); 162 LEAVE();
187 return index; 163 return index;
188 } 164 }
189 165
190 /* security doesn't match */ 166 /* security doesn't match */
191 lbs_pr_debug(1, 167 lbs_pr_debug(1,
192 "is_network_compatible() FAILED: index=%d wpa_ie=%#x " 168 "is_network_compatible() FAILED: index=%d wpa_ie=%#x "
193 "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s Encmode=%#x privacy=%#x\n", 169 "wpa2_ie=%#x WEP=%s WPA=%s WPA2=%s privacy=%#x\n",
194 index, 170 index,
195 adapter->scantable[index].wpa_supplicant.wpa_ie[0], 171 adapter->scantable[index].wpa_ie[0],
196 adapter->scantable[index].wpa2_supplicant.wpa_ie[0], 172 adapter->scantable[index].rsn_ie[0],
197 (adapter->secinfo.WEPstatus == 173 adapter->secinfo.wep_enabled ? "e" : "d",
198 wlan802_11WEPenabled) ? "e" : "d", 174 adapter->secinfo.WPAenabled ? "e" : "d",
199 (adapter->secinfo.WPAenabled) ? "e" : "d", 175 adapter->secinfo.WPA2enabled ? "e" : "d",
200 (adapter->secinfo.WPA2enabled) ? "e" : "d",
201 adapter->secinfo.Encryptionmode,
202 adapter->scantable[index].privacy); 176 adapter->scantable[index].privacy);
203 LEAVE(); 177 LEAVE();
204 return -ECONNREFUSED; 178 return -ECONNREFUSED;
@@ -924,8 +898,6 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry,
924 u8 founddatarateie; 898 u8 founddatarateie;
925 int bytesleftforcurrentbeacon; 899 int bytesleftforcurrentbeacon;
926 900
927 struct WPA_SUPPLICANT *pwpa_supplicant;
928 struct WPA_SUPPLICANT *pwpa2_supplicant;
929 struct IE_WPA *pIe; 901 struct IE_WPA *pIe;
930 const u8 oui01[4] = { 0x00, 0x50, 0xf2, 0x01 }; 902 const u8 oui01[4] = { 0x00, 0x50, 0xf2, 0x01 };
931 903
@@ -962,9 +934,6 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry,
962 934
963 bytesleftforcurrentbeacon = beaconsize; 935 bytesleftforcurrentbeacon = beaconsize;
964 936
965 pwpa_supplicant = &pBSSEntry->wpa_supplicant;
966 pwpa2_supplicant = &pBSSEntry->wpa2_supplicant;
967
968 memcpy(pBSSEntry->macaddress, pcurrentptr, ETH_ALEN); 937 memcpy(pBSSEntry->macaddress, pcurrentptr, ETH_ALEN);
969 lbs_pr_debug(1, "InterpretIE: AP MAC Addr-%x:%x:%x:%x:%x:%x\n", 938 lbs_pr_debug(1, "InterpretIE: AP MAC Addr-%x:%x:%x:%x:%x:%x\n",
970 pBSSEntry->macaddress[0], pBSSEntry->macaddress[1], 939 pBSSEntry->macaddress[0], pBSSEntry->macaddress[1],
@@ -1027,9 +996,9 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry,
1027 } 996 }
1028 997
1029 if (pcap->ibss == 1) { 998 if (pcap->ibss == 1) {
1030 pBSSEntry->inframode = wlan802_11ibss; 999 pBSSEntry->mode = IW_MODE_ADHOC;
1031 } else { 1000 } else {
1032 pBSSEntry->inframode = wlan802_11infrastructure; 1001 pBSSEntry->mode = IW_MODE_INFRA;
1033 } 1002 }
1034 1003
1035 /* process variable IE */ 1004 /* process variable IE */
@@ -1116,7 +1085,7 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry,
1116 sizeof(pcountryinfo->countrycode) 1085 sizeof(pcountryinfo->countrycode)
1117 || pcountryinfo->len > 254) { 1086 || pcountryinfo->len > 254) {
1118 lbs_pr_debug(1, "InterpretIE: 11D- Err " 1087 lbs_pr_debug(1, "InterpretIE: 11D- Err "
1119 "CountryInfo len =%d min=%d max=254\n", 1088 "CountryInfo len =%d min=%zd max=254\n",
1120 pcountryinfo->len, 1089 pcountryinfo->len,
1121 sizeof(pcountryinfo->countrycode)); 1090 sizeof(pcountryinfo->countrycode));
1122 LEAVE(); 1091 LEAVE();
@@ -1160,27 +1129,27 @@ static int InterpretBSSDescriptionWithIE(struct bss_descriptor * pBSSEntry,
1160#define IE_ID_LEN_FIELDS_BYTES 2 1129#define IE_ID_LEN_FIELDS_BYTES 2
1161 pIe = (struct IE_WPA *)pcurrentptr; 1130 pIe = (struct IE_WPA *)pcurrentptr;
1162 1131
1163 if (!memcmp(pIe->oui, oui01, sizeof(oui01))) { 1132 if (memcmp(pIe->oui, oui01, sizeof(oui01)))
1164 pwpa_supplicant->wpa_ie_len 1133 break;
1165 = min_t(size_t, elemlen + IE_ID_LEN_FIELDS_BYTES, 1134
1166 sizeof(pwpa_supplicant->wpa_ie)); 1135 pBSSEntry->wpa_ie_len = min_t(size_t,
1167 memcpy(pwpa_supplicant->wpa_ie, 1136 elemlen + IE_ID_LEN_FIELDS_BYTES,
1168 pcurrentptr, 1137 sizeof(pBSSEntry->wpa_ie));
1169 pwpa_supplicant->wpa_ie_len); 1138 memcpy(pBSSEntry->wpa_ie, pcurrentptr,
1170 lbs_dbg_hex("InterpretIE: Resp WPA_IE", 1139 pBSSEntry->wpa_ie_len);
1171 pwpa_supplicant->wpa_ie, elemlen); 1140 lbs_dbg_hex("InterpretIE: Resp WPA_IE",
1172 } 1141 pBSSEntry->wpa_ie, elemlen);
1173 break; 1142 break;
1174 case WPA2_IE: 1143 case WPA2_IE:
1175 pIe = (struct IE_WPA *)pcurrentptr; 1144 pIe = (struct IE_WPA *)pcurrentptr;
1176 pwpa2_supplicant->wpa_ie_len
1177 = min_t(size_t, elemlen + IE_ID_LEN_FIELDS_BYTES,
1178 sizeof(pwpa2_supplicant->wpa_ie));
1179 memcpy(pwpa2_supplicant->wpa_ie,
1180 pcurrentptr, pwpa2_supplicant->wpa_ie_len);
1181 1145
1146 pBSSEntry->rsn_ie_len = min_t(size_t,
1147 elemlen + IE_ID_LEN_FIELDS_BYTES,
1148 sizeof(pBSSEntry->rsn_ie));
1149 memcpy(pBSSEntry->rsn_ie, pcurrentptr,
1150 pBSSEntry->rsn_ie_len);
1182 lbs_dbg_hex("InterpretIE: Resp WPA2_IE", 1151 lbs_dbg_hex("InterpretIE: Resp WPA2_IE",
1183 pwpa2_supplicant->wpa_ie, elemlen); 1152 pBSSEntry->rsn_ie, elemlen);
1184 break; 1153 break;
1185 case TIM: 1154 case TIM:
1186 break; 1155 break;
@@ -1227,7 +1196,7 @@ int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1, struct WLAN_802_11_SSID *s
1227 * 1196 *
1228 * @return index in BSSID list, or error return code (< 0) 1197 * @return index in BSSID list, or error return code (< 0)
1229 */ 1198 */
1230int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, int mode) 1199int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, u8 mode)
1231{ 1200{
1232 int ret = -ENETUNREACH; 1201 int ret = -ENETUNREACH;
1233 int i; 1202 int i;
@@ -1247,8 +1216,8 @@ int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, int mode)
1247 for (i = 0; ret < 0 && i < adapter->numinscantable; i++) { 1216 for (i = 0; ret < 0 && i < adapter->numinscantable; i++) {
1248 if (!memcmp(adapter->scantable[i].macaddress, bssid, ETH_ALEN)) { 1217 if (!memcmp(adapter->scantable[i].macaddress, bssid, ETH_ALEN)) {
1249 switch (mode) { 1218 switch (mode) {
1250 case wlan802_11infrastructure: 1219 case IW_MODE_INFRA:
1251 case wlan802_11ibss: 1220 case IW_MODE_ADHOC:
1252 ret = is_network_compatible(adapter, i, mode); 1221 ret = is_network_compatible(adapter, i, mode);
1253 break; 1222 break;
1254 default: 1223 default:
@@ -1272,7 +1241,7 @@ int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, int mode)
1272 * @return index in BSSID list 1241 * @return index in BSSID list
1273 */ 1242 */
1274int libertas_find_SSID_in_list(wlan_adapter * adapter, 1243int libertas_find_SSID_in_list(wlan_adapter * adapter,
1275 struct WLAN_802_11_SSID *ssid, u8 * bssid, int mode) 1244 struct WLAN_802_11_SSID *ssid, u8 * bssid, u8 mode)
1276{ 1245{
1277 int net = -ENETUNREACH; 1246 int net = -ENETUNREACH;
1278 u8 bestrssi = 0; 1247 u8 bestrssi = 0;
@@ -1287,8 +1256,8 @@ int libertas_find_SSID_in_list(wlan_adapter * adapter,
1287 !memcmp(adapter->scantable[i]. 1256 !memcmp(adapter->scantable[i].
1288 macaddress, bssid, ETH_ALEN))) { 1257 macaddress, bssid, ETH_ALEN))) {
1289 switch (mode) { 1258 switch (mode) {
1290 case wlan802_11infrastructure: 1259 case IW_MODE_INFRA:
1291 case wlan802_11ibss: 1260 case IW_MODE_ADHOC:
1292 j = is_network_compatible(adapter, i, mode); 1261 j = is_network_compatible(adapter, i, mode);
1293 1262
1294 if (j >= 0) { 1263 if (j >= 0) {
@@ -1311,7 +1280,7 @@ int libertas_find_SSID_in_list(wlan_adapter * adapter,
1311 } 1280 }
1312 } 1281 }
1313 break; 1282 break;
1314 case wlan802_11autounknown: 1283 case IW_MODE_AUTO:
1315 default: 1284 default:
1316 if (SCAN_RSSI(adapter->scantable[i].rssi) 1285 if (SCAN_RSSI(adapter->scantable[i].rssi)
1317 > bestrssi) { 1286 > bestrssi) {
@@ -1338,8 +1307,7 @@ int libertas_find_SSID_in_list(wlan_adapter * adapter,
1338 * 1307 *
1339 * @return index in BSSID list 1308 * @return index in BSSID list
1340 */ 1309 */
1341int libertas_find_best_SSID_in_list(wlan_adapter * adapter, 1310int libertas_find_best_SSID_in_list(wlan_adapter * adapter, u8 mode)
1342 enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode)
1343{ 1311{
1344 int bestnet = -ENETUNREACH; 1312 int bestnet = -ENETUNREACH;
1345 u8 bestrssi = 0; 1313 u8 bestrssi = 0;
@@ -1351,8 +1319,8 @@ int libertas_find_best_SSID_in_list(wlan_adapter * adapter,
1351 1319
1352 for (i = 0; i < adapter->numinscantable; i++) { 1320 for (i = 0; i < adapter->numinscantable; i++) {
1353 switch (mode) { 1321 switch (mode) {
1354 case wlan802_11infrastructure: 1322 case IW_MODE_INFRA:
1355 case wlan802_11ibss: 1323 case IW_MODE_ADHOC:
1356 if (is_network_compatible(adapter, i, mode) >= 0) { 1324 if (is_network_compatible(adapter, i, mode) >= 0) {
1357 if (SCAN_RSSI(adapter->scantable[i].rssi) > 1325 if (SCAN_RSSI(adapter->scantable[i].rssi) >
1358 bestrssi) { 1326 bestrssi) {
@@ -1363,7 +1331,7 @@ int libertas_find_best_SSID_in_list(wlan_adapter * adapter,
1363 } 1331 }
1364 } 1332 }
1365 break; 1333 break;
1366 case wlan802_11autounknown: 1334 case IW_MODE_AUTO:
1367 default: 1335 default:
1368 if (SCAN_RSSI(adapter->scantable[i].rssi) > bestrssi) { 1336 if (SCAN_RSSI(adapter->scantable[i].rssi) > bestrssi) {
1369 bestrssi = 1337 bestrssi =
@@ -1388,8 +1356,7 @@ int libertas_find_best_SSID_in_list(wlan_adapter * adapter,
1388 */ 1356 */
1389int libertas_find_best_network_SSID(wlan_private * priv, 1357int libertas_find_best_network_SSID(wlan_private * priv,
1390 struct WLAN_802_11_SSID *pSSID, 1358 struct WLAN_802_11_SSID *pSSID,
1391 enum WLAN_802_11_NETWORK_INFRASTRUCTURE preferred_mode, 1359 u8 preferred_mode, u8 *out_mode)
1392 enum WLAN_802_11_NETWORK_INFRASTRUCTURE *out_mode)
1393{ 1360{
1394 wlan_adapter *adapter = priv->adapter; 1361 wlan_adapter *adapter = priv->adapter;
1395 int ret = 0; 1362 int ret = 0;
@@ -1414,7 +1381,7 @@ int libertas_find_best_network_SSID(wlan_private * priv,
1414 preqbssid = &adapter->scantable[i]; 1381 preqbssid = &adapter->scantable[i];
1415 memcpy(pSSID, &preqbssid->ssid, 1382 memcpy(pSSID, &preqbssid->ssid,
1416 sizeof(struct WLAN_802_11_SSID)); 1383 sizeof(struct WLAN_802_11_SSID));
1417 *out_mode = preqbssid->inframode; 1384 *out_mode = preqbssid->mode;
1418 1385
1419 if (!pSSID->ssidlength) { 1386 if (!pSSID->ssidlength) {
1420 ret = -1; 1387 ret = -1;
@@ -1584,7 +1551,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info,
1584 for (i = 0; i < adapter->numinscantable; i++) { 1551 for (i = 0; i < adapter->numinscantable; i++) {
1585 if ((current_ev + MAX_SCAN_CELL_SIZE) >= end_buf) { 1552 if ((current_ev + MAX_SCAN_CELL_SIZE) >= end_buf) {
1586 lbs_pr_debug(1, "i=%d break out: current_ev=%p end_buf=%p " 1553 lbs_pr_debug(1, "i=%d break out: current_ev=%p end_buf=%p "
1587 "MAX_SCAN_CELL_SIZE=%d\n", 1554 "MAX_SCAN_CELL_SIZE=%zd\n",
1588 i, current_ev, end_buf, MAX_SCAN_CELL_SIZE); 1555 i, current_ev, end_buf, MAX_SCAN_CELL_SIZE);
1589 break; 1556 break;
1590 } 1557 }
@@ -1632,7 +1599,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info,
1632 1599
1633 //Add mode 1600 //Add mode
1634 iwe.cmd = SIOCGIWMODE; 1601 iwe.cmd = SIOCGIWMODE;
1635 iwe.u.mode = adapter->scantable[i].inframode + 1; 1602 iwe.u.mode = adapter->scantable[i].mode;
1636 iwe.len = IW_EV_UINT_LEN; 1603 iwe.len = IW_EV_UINT_LEN;
1637 current_ev = 1604 current_ev =
1638 iwe_stream_add_event(current_ev, end_buf, &iwe, iwe.len); 1605 iwe_stream_add_event(current_ev, end_buf, &iwe, iwe.len);
@@ -1666,7 +1633,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info,
1666 iwe.u.qual.noise = 1633 iwe.u.qual.noise =
1667 CAL_NF(adapter->NF[TYPE_BEACON][TYPE_NOAVG]); 1634 CAL_NF(adapter->NF[TYPE_BEACON][TYPE_NOAVG]);
1668 } 1635 }
1669 if ((adapter->inframode == wlan802_11ibss) && 1636 if ((adapter->mode == IW_MODE_ADHOC) &&
1670 !libertas_SSID_cmp(&adapter->curbssparams.ssid, 1637 !libertas_SSID_cmp(&adapter->curbssparams.ssid,
1671 &adapter->scantable[i].ssid) 1638 &adapter->scantable[i].ssid)
1672 && adapter->adhoccreate) { 1639 && adapter->adhoccreate) {
@@ -1731,7 +1698,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info,
1731 end_buf, &iwe, iwe.len); 1698 end_buf, &iwe, iwe.len);
1732 1699
1733 } 1700 }
1734 if ((adapter->scantable[i].inframode == wlan802_11ibss) 1701 if ((adapter->scantable[i].mode == IW_MODE_ADHOC)
1735 && !libertas_SSID_cmp(&adapter->curbssparams.ssid, 1702 && !libertas_SSID_cmp(&adapter->curbssparams.ssid,
1736 &adapter->scantable[i].ssid) 1703 &adapter->scantable[i].ssid)
1737 && adapter->adhoccreate) { 1704 && adapter->adhoccreate) {
@@ -1745,30 +1712,24 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info,
1745 /* Add new value to event */ 1712 /* Add new value to event */
1746 current_val = current_ev + IW_EV_LCP_LEN; 1713 current_val = current_ev + IW_EV_LCP_LEN;
1747 1714
1748 if (adapter->scantable[i].wpa2_supplicant.wpa_ie[0] == WPA2_IE) { 1715 if (adapter->scantable[i].rsn_ie[0] == WPA2_IE) {
1749 memset(&iwe, 0, sizeof(iwe)); 1716 memset(&iwe, 0, sizeof(iwe));
1750 memset(buf, 0, sizeof(buf)); 1717 memset(buf, 0, sizeof(buf));
1751 memcpy(buf, adapter->scantable[i]. 1718 memcpy(buf, adapter->scantable[i].rsn_ie,
1752 wpa2_supplicant.wpa_ie, 1719 adapter->scantable[i].rsn_ie_len);
1753 adapter->scantable[i].wpa2_supplicant.
1754 wpa_ie_len);
1755 iwe.cmd = IWEVGENIE; 1720 iwe.cmd = IWEVGENIE;
1756 iwe.u.data.length = adapter->scantable[i]. 1721 iwe.u.data.length = adapter->scantable[i].rsn_ie_len;
1757 wpa2_supplicant.wpa_ie_len;
1758 iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; 1722 iwe.len = IW_EV_POINT_LEN + iwe.u.data.length;
1759 current_ev = iwe_stream_add_point(current_ev, end_buf, 1723 current_ev = iwe_stream_add_point(current_ev, end_buf,
1760 &iwe, buf); 1724 &iwe, buf);
1761 } 1725 }
1762 if (adapter->scantable[i].wpa_supplicant.wpa_ie[0] == WPA_IE) { 1726 if (adapter->scantable[i].wpa_ie[0] == WPA_IE) {
1763 memset(&iwe, 0, sizeof(iwe)); 1727 memset(&iwe, 0, sizeof(iwe));
1764 memset(buf, 0, sizeof(buf)); 1728 memset(buf, 0, sizeof(buf));
1765 memcpy(buf, adapter->scantable[i]. 1729 memcpy(buf, adapter->scantable[i].wpa_ie,
1766 wpa_supplicant.wpa_ie, 1730 adapter->scantable[i].wpa_ie_len);
1767 adapter->scantable[i].wpa_supplicant.
1768 wpa_ie_len);
1769 iwe.cmd = IWEVGENIE; 1731 iwe.cmd = IWEVGENIE;
1770 iwe.u.data.length = adapter->scantable[i]. 1732 iwe.u.data.length = adapter->scantable[i].wpa_ie_len;
1771 wpa_supplicant.wpa_ie_len;
1772 iwe.len = IW_EV_POINT_LEN + iwe.u.data.length; 1733 iwe.len = IW_EV_POINT_LEN + iwe.u.data.length;
1773 current_ev = iwe_stream_add_point(current_ev, end_buf, 1734 current_ev = iwe_stream_add_point(current_ev, end_buf,
1774 &iwe, buf); 1735 &iwe, buf);
diff --git a/drivers/net/wireless/libertas/scan.h b/drivers/net/wireless/libertas/scan.h
index d93aa7fa44fd..405f4f0fe575 100644
--- a/drivers/net/wireless/libertas/scan.h
+++ b/drivers/net/wireless/libertas/scan.h
@@ -1,6 +1,3 @@
1/* -*- mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
2/* vi: set expandtab shiftwidth=4 tabstop=4 textwidth=78: */
3
4/** 1/**
5 * Interface for the wlan network scan routines 2 * Interface for the wlan network scan routines
6 * 3 *
@@ -10,6 +7,7 @@
10#ifndef _WLAN_SCAN_H 7#ifndef _WLAN_SCAN_H
11#define _WLAN_SCAN_H 8#define _WLAN_SCAN_H
12 9
10#include <net/ieee80211.h>
13#include "hostcmd.h" 11#include "hostcmd.h"
14 12
15/** 13/**
@@ -155,7 +153,7 @@ struct bss_descriptor {
155 153
156 u32 atimwindow; 154 u32 atimwindow;
157 155
158 enum WLAN_802_11_NETWORK_INFRASTRUCTURE inframode; 156 u8 mode;
159 u8 libertas_supported_rates[WLAN_SUPPORTED_RATES]; 157 u8 libertas_supported_rates[WLAN_SUPPORTED_RATES];
160 158
161 int extra_ie; 159 int extra_ie;
@@ -170,22 +168,22 @@ struct bss_descriptor {
170 168
171 struct ieeetypes_countryinfofullset countryinfo; 169 struct ieeetypes_countryinfofullset countryinfo;
172 170
173 struct WPA_SUPPLICANT wpa_supplicant; 171 u8 wpa_ie[MAX_WPA_IE_LEN];
174 struct WPA_SUPPLICANT wpa2_supplicant; 172 size_t wpa_ie_len;
175 173 u8 rsn_ie[MAX_WPA_IE_LEN];
174 size_t rsn_ie_len;
176}; 175};
177 176
178extern int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1, 177extern int libertas_SSID_cmp(struct WLAN_802_11_SSID *ssid1,
179 struct WLAN_802_11_SSID *ssid2); 178 struct WLAN_802_11_SSID *ssid2);
180extern int libertas_find_SSID_in_list(wlan_adapter * adapter, struct WLAN_802_11_SSID *ssid, 179extern int libertas_find_SSID_in_list(wlan_adapter * adapter, struct WLAN_802_11_SSID *ssid,
181 u8 * bssid, int mode); 180 u8 * bssid, u8 mode);
182int libertas_find_best_SSID_in_list(wlan_adapter * adapter, enum WLAN_802_11_NETWORK_INFRASTRUCTURE mode); 181int libertas_find_best_SSID_in_list(wlan_adapter * adapter, u8 mode);
183extern int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, int mode); 182extern int libertas_find_BSSID_in_list(wlan_adapter * adapter, u8 * bssid, u8 mode);
184 183
185int libertas_find_best_network_SSID(wlan_private * priv, 184int libertas_find_best_network_SSID(wlan_private * priv,
186 struct WLAN_802_11_SSID *pSSID, 185 struct WLAN_802_11_SSID *pSSID,
187 enum WLAN_802_11_NETWORK_INFRASTRUCTURE preferred_mode, 186 u8 preferred_mode, u8 *out_mode);
188 enum WLAN_802_11_NETWORK_INFRASTRUCTURE *out_mode);
189 187
190extern int libertas_send_specific_SSID_scan(wlan_private * priv, 188extern int libertas_send_specific_SSID_scan(wlan_private * priv,
191 struct WLAN_802_11_SSID *prequestedssid, 189 struct WLAN_802_11_SSID *prequestedssid,
diff --git a/drivers/net/wireless/libertas/tx.c b/drivers/net/wireless/libertas/tx.c
index 82d06223043e..d4b13478c9a7 100644
--- a/drivers/net/wireless/libertas/tx.c
+++ b/drivers/net/wireless/libertas/tx.c
@@ -78,7 +78,7 @@ static int SendSinglePacket(wlan_private * priv, struct sk_buff *skb)
78 min_t(unsigned int, skb->len, 100)); 78 min_t(unsigned int, skb->len, 100));
79 79
80 if (!skb->len || (skb->len > MRVDRV_ETH_TX_PACKET_BUFFER_SIZE)) { 80 if (!skb->len || (skb->len > MRVDRV_ETH_TX_PACKET_BUFFER_SIZE)) {
81 lbs_pr_debug(1, "Tx error: Bad skb length %d : %d\n", 81 lbs_pr_debug(1, "Tx error: Bad skb length %d : %zd\n",
82 skb->len, MRVDRV_ETH_TX_PACKET_BUFFER_SIZE); 82 skb->len, MRVDRV_ETH_TX_PACKET_BUFFER_SIZE);
83 ret = -1; 83 ret = -1;
84 goto done; 84 goto done;
diff --git a/drivers/net/wireless/libertas/version.h b/drivers/net/wireless/libertas/version.h
index e86f65ae79b8..8b137891791f 100644
--- a/drivers/net/wireless/libertas/version.h
+++ b/drivers/net/wireless/libertas/version.h
@@ -1,8 +1 @@
1#define DRIVER_RELEASE_VERSION "320.p0"
2const char libertas_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION
3#ifdef DEBUG
4 "-dbg"
5#endif
6 "";
7
8
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index 4a52336bc0f6..69f52b6e59c8 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -17,7 +17,6 @@
17#include "defs.h" 17#include "defs.h"
18#include "dev.h" 18#include "dev.h"
19#include "join.h" 19#include "join.h"
20#include "version.h"
21#include "wext.h" 20#include "wext.h"
22#include "assoc.h" 21#include "assoc.h"
23 22
@@ -233,7 +232,7 @@ static int changeadhocchannel(wlan_private * priv, int channel)
233 232
234 // find out the BSSID that matches the current SSID 233 // find out the BSSID that matches the current SSID
235 i = libertas_find_SSID_in_list(adapter, &curadhocssid, NULL, 234 i = libertas_find_SSID_in_list(adapter, &curadhocssid, NULL,
236 wlan802_11ibss); 235 IW_MODE_ADHOC);
237 236
238 if (i >= 0) { 237 if (i >= 0) {
239 lbs_pr_debug(1, "SSID found at %d in List," 238 lbs_pr_debug(1, "SSID found at %d in List,"
@@ -316,13 +315,11 @@ static int get_active_data_rates(wlan_adapter * adapter,
316 ENTER(); 315 ENTER();
317 316
318 if (adapter->connect_status != libertas_connected) { 317 if (adapter->connect_status != libertas_connected) {
319 if (adapter->inframode == wlan802_11infrastructure) { 318 if (adapter->mode == IW_MODE_INFRA) {
320 //Infra. mode
321 lbs_pr_debug(1, "Infra\n"); 319 lbs_pr_debug(1, "Infra\n");
322 k = copyrates(rates, k, libertas_supported_rates, 320 k = copyrates(rates, k, libertas_supported_rates,
323 sizeof(libertas_supported_rates)); 321 sizeof(libertas_supported_rates));
324 } else { 322 } else {
325 //ad-hoc mode
326 lbs_pr_debug(1, "Adhoc G\n"); 323 lbs_pr_debug(1, "Adhoc G\n");
327 k = copyrates(rates, k, libertas_adhoc_rates_g, 324 k = copyrates(rates, k, libertas_adhoc_rates_g,
328 sizeof(libertas_adhoc_rates_g)); 325 sizeof(libertas_adhoc_rates_g));
@@ -586,20 +583,7 @@ static int wlan_get_mode(struct net_device *dev,
586 583
587 ENTER(); 584 ENTER();
588 585
589 switch (adapter->inframode) { 586 *uwrq = adapter->mode;
590 case wlan802_11ibss:
591 *uwrq = IW_MODE_ADHOC;
592 break;
593
594 case wlan802_11infrastructure:
595 *uwrq = IW_MODE_INFRA;
596 break;
597
598 default:
599 case wlan802_11autounknown:
600 *uwrq = IW_MODE_AUTO;
601 break;
602 }
603 587
604 LEAVE(); 588 LEAVE();
605 return 0; 589 return 0;
@@ -1002,149 +986,18 @@ static const struct iw_priv_args wlan_private_args[] = {
1002 /* 986 /*
1003 * { cmd, set_args, get_args, name } 987 * { cmd, set_args, get_args, name }
1004 */ 988 */
1005 {
1006 WLANSCAN_TYPE,
1007 IW_PRIV_TYPE_CHAR | 8,
1008 IW_PRIV_TYPE_CHAR | 8,
1009 "scantype"},
1010
1011 {
1012 WLAN_SETINT_GETINT,
1013 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1014 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1015 ""},
1016 {
1017 WLANNF,
1018 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1019 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1020 "getNF"},
1021 {
1022 WLANRSSI,
1023 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1024 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1025 "getRSSI"},
1026 {
1027 WLANENABLE11D,
1028 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1029 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1030 "enable11d"},
1031 {
1032 WLANADHOCGRATE,
1033 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1034 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1035 "adhocgrate"},
1036
1037 {
1038 WLAN_SUBCMD_SET_PRESCAN,
1039 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1040 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1041 "prescan"},
1042 {
1043 WLAN_SETONEINT_GETONEINT,
1044 IW_PRIV_TYPE_INT | 1,
1045 IW_PRIV_TYPE_INT | 1,
1046 ""},
1047 {
1048 WLAN_BEACON_INTERVAL,
1049 IW_PRIV_TYPE_INT | 1,
1050 IW_PRIV_TYPE_INT | 1,
1051 "bcninterval"},
1052 {
1053 WLAN_LISTENINTRVL,
1054 IW_PRIV_TYPE_INT | 1,
1055 IW_PRIV_TYPE_INT | 1,
1056 "lolisteninter"},
1057 {
1058 WLAN_TXCONTROL,
1059 IW_PRIV_TYPE_INT | 1,
1060 IW_PRIV_TYPE_INT | 1,
1061 "txcontrol"},
1062 {
1063 WLAN_NULLPKTINTERVAL,
1064 IW_PRIV_TYPE_INT | 1,
1065 IW_PRIV_TYPE_INT | 1,
1066 "psnullinterval"},
1067 /* Using iwpriv sub-command feature */ 989 /* Using iwpriv sub-command feature */
1068 { 990 {
1069 WLAN_SETONEINT_GETNONE, /* IOCTL: 24 */ 991 WLAN_SETONEINT_GETNONE, /* IOCTL: 24 */
1070 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 992 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1071 IW_PRIV_TYPE_NONE, 993 IW_PRIV_TYPE_NONE,
1072 ""}, 994 ""},
1073
1074 {
1075 WLAN_SUBCMD_SETRXANTENNA,
1076 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1077 IW_PRIV_TYPE_NONE,
1078 "setrxant"},
1079 {
1080 WLAN_SUBCMD_SETTXANTENNA,
1081 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1082 IW_PRIV_TYPE_NONE,
1083 "settxant"},
1084 {
1085 WLANSETAUTHALG,
1086 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1087 IW_PRIV_TYPE_NONE,
1088 "authalgs",
1089 },
1090 {
1091 WLANSET8021XAUTHALG,
1092 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1093 IW_PRIV_TYPE_NONE,
1094 "8021xauthalgs",
1095 },
1096 {
1097 WLANSETENCRYPTIONMODE,
1098 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1099 IW_PRIV_TYPE_NONE,
1100 "encryptionmode",
1101 },
1102 { 995 {
1103 WLANSETREGION, 996 WLANSETREGION,
1104 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 997 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1105 IW_PRIV_TYPE_NONE, 998 IW_PRIV_TYPE_NONE,
1106 "setregioncode"}, 999 "setregioncode"},
1107 { 1000 {
1108 WLAN_SET_LISTEN_INTERVAL,
1109 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1110 IW_PRIV_TYPE_NONE,
1111 "setlisteninter"},
1112 {
1113 WLAN_SET_MULTIPLE_DTIM,
1114 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1115 IW_PRIV_TYPE_NONE,
1116 "setmultipledtim"},
1117 {
1118 WLAN_SET_ATIM_WINDOW,
1119 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1120 IW_PRIV_TYPE_NONE,
1121 "atimwindow"},
1122 {
1123 WLANSETBCNAVG,
1124 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1125 IW_PRIV_TYPE_NONE,
1126 "setbcnavg"},
1127 {
1128 WLANSETDATAAVG,
1129 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1130 IW_PRIV_TYPE_NONE,
1131 "setdataavg"},
1132 {
1133 WLAN_SET_LINKMODE,
1134 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1135 IW_PRIV_TYPE_NONE,
1136 "linkmode"},
1137 {
1138 WLAN_SET_RADIOMODE,
1139 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1140 IW_PRIV_TYPE_NONE,
1141 "radiomode"},
1142 {
1143 WLAN_SET_DEBUGMODE,
1144 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1145 IW_PRIV_TYPE_NONE,
1146 "debugmode"},
1147 {
1148 WLAN_SUBCMD_MESH_SET_TTL, 1001 WLAN_SUBCMD_MESH_SET_TTL,
1149 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 1002 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1150 IW_PRIV_TYPE_NONE, 1003 IW_PRIV_TYPE_NONE,
@@ -1160,41 +1013,6 @@ static const struct iw_priv_args wlan_private_args[] = {
1160 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 1013 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1161 "getregioncode"}, 1014 "getregioncode"},
1162 { 1015 {
1163 WLAN_GET_LISTEN_INTERVAL,
1164 IW_PRIV_TYPE_NONE,
1165 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1166 "getlisteninter"},
1167 {
1168 WLAN_GET_MULTIPLE_DTIM,
1169 IW_PRIV_TYPE_NONE,
1170 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1171 "getmultipledtim"},
1172 {
1173 WLAN_GET_TX_RATE,
1174 IW_PRIV_TYPE_NONE,
1175 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1176 "gettxrate"},
1177 {
1178 WLANGETBCNAVG,
1179 IW_PRIV_TYPE_NONE,
1180 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1181 "getbcnavg"},
1182 {
1183 WLAN_GET_LINKMODE,
1184 IW_PRIV_TYPE_NONE,
1185 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1186 "get_linkmode"},
1187 {
1188 WLAN_GET_RADIOMODE,
1189 IW_PRIV_TYPE_NONE,
1190 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1191 "get_radiomode"},
1192 {
1193 WLAN_GET_DEBUGMODE,
1194 IW_PRIV_TYPE_NONE,
1195 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1196 "get_debugmode"},
1197 {
1198 WLAN_SUBCMD_FWT_CLEANUP, 1016 WLAN_SUBCMD_FWT_CLEANUP,
1199 IW_PRIV_TYPE_NONE, 1017 IW_PRIV_TYPE_NONE,
1200 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 1018 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
@@ -1210,61 +1028,11 @@ static const struct iw_priv_args wlan_private_args[] = {
1210 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 1028 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1211 "mesh_get_ttl"}, 1029 "mesh_get_ttl"},
1212 { 1030 {
1213 WLAN_SETNONE_GETTWELVE_CHAR,
1214 IW_PRIV_TYPE_NONE,
1215 IW_PRIV_TYPE_CHAR | 12,
1216 ""},
1217 {
1218 WLAN_SUBCMD_GETRXANTENNA,
1219 IW_PRIV_TYPE_NONE,
1220 IW_PRIV_TYPE_CHAR | 12,
1221 "getrxant"},
1222 {
1223 WLAN_SUBCMD_GETTXANTENNA,
1224 IW_PRIV_TYPE_NONE,
1225 IW_PRIV_TYPE_CHAR | 12,
1226 "gettxant"},
1227 {
1228 WLAN_GET_TSF,
1229 IW_PRIV_TYPE_NONE,
1230 IW_PRIV_TYPE_CHAR | 12,
1231 "gettsf"},
1232 {
1233 WLAN_SETNONE_GETNONE, 1031 WLAN_SETNONE_GETNONE,
1234 IW_PRIV_TYPE_NONE, 1032 IW_PRIV_TYPE_NONE,
1235 IW_PRIV_TYPE_NONE, 1033 IW_PRIV_TYPE_NONE,
1236 ""}, 1034 ""},
1237 { 1035 {
1238 WLANDEAUTH,
1239 IW_PRIV_TYPE_NONE,
1240 IW_PRIV_TYPE_NONE,
1241 "deauth"},
1242 {
1243 WLANADHOCSTOP,
1244 IW_PRIV_TYPE_NONE,
1245 IW_PRIV_TYPE_NONE,
1246 "adhocstop"},
1247 {
1248 WLANRADIOON,
1249 IW_PRIV_TYPE_NONE,
1250 IW_PRIV_TYPE_NONE,
1251 "radioon"},
1252 {
1253 WLANRADIOOFF,
1254 IW_PRIV_TYPE_NONE,
1255 IW_PRIV_TYPE_NONE,
1256 "radiooff"},
1257 {
1258 WLANWLANIDLEON,
1259 IW_PRIV_TYPE_NONE,
1260 IW_PRIV_TYPE_NONE,
1261 "wlanidle-on"},
1262 {
1263 WLANWLANIDLEOFF,
1264 IW_PRIV_TYPE_NONE,
1265 IW_PRIV_TYPE_NONE,
1266 "wlanidle-off"},
1267 {
1268 WLAN_SUBCMD_FWT_RESET, 1036 WLAN_SUBCMD_FWT_RESET,
1269 IW_PRIV_TYPE_NONE, 1037 IW_PRIV_TYPE_NONE,
1270 IW_PRIV_TYPE_NONE, 1038 IW_PRIV_TYPE_NONE,
@@ -1327,90 +1095,15 @@ static const struct iw_priv_args wlan_private_args[] = {
1327 IW_PRIV_TYPE_CHAR | 128, 1095 IW_PRIV_TYPE_CHAR | 128,
1328 "fwt_list_route"}, 1096 "fwt_list_route"},
1329 { 1097 {
1330 WLANSCAN_MODE,
1331 IW_PRIV_TYPE_CHAR | 128,
1332 IW_PRIV_TYPE_CHAR | 128,
1333 "scanmode"},
1334 {
1335 WLAN_GET_ADHOC_STATUS,
1336 IW_PRIV_TYPE_CHAR | 128,
1337 IW_PRIV_TYPE_CHAR | 128,
1338 "getadhocstatus"},
1339 {
1340 WLAN_SETNONE_GETWORDCHAR,
1341 IW_PRIV_TYPE_NONE,
1342 IW_PRIV_TYPE_CHAR | 128,
1343 ""},
1344 {
1345 WLANSETWPAIE,
1346 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 24,
1347 IW_PRIV_TYPE_NONE,
1348 "setwpaie"},
1349 {
1350 WLANGETLOG,
1351 IW_PRIV_TYPE_NONE,
1352 IW_PRIV_TYPE_CHAR | GETLOG_BUFSIZE,
1353 "getlog"},
1354 {
1355 WLAN_SET_GET_SIXTEEN_INT, 1098 WLAN_SET_GET_SIXTEEN_INT,
1356 IW_PRIV_TYPE_INT | 16, 1099 IW_PRIV_TYPE_INT | 16,
1357 IW_PRIV_TYPE_INT | 16, 1100 IW_PRIV_TYPE_INT | 16,
1358 ""}, 1101 ""},
1359 { 1102 {
1360 WLAN_TPCCFG,
1361 IW_PRIV_TYPE_INT | 16,
1362 IW_PRIV_TYPE_INT | 16,
1363 "tpccfg"},
1364 {
1365 WLAN_POWERCFG,
1366 IW_PRIV_TYPE_INT | 16,
1367 IW_PRIV_TYPE_INT | 16,
1368 "powercfg"},
1369 {
1370 WLAN_AUTO_FREQ_SET,
1371 IW_PRIV_TYPE_INT | 16,
1372 IW_PRIV_TYPE_INT | 16,
1373 "setafc"},
1374 {
1375 WLAN_AUTO_FREQ_GET,
1376 IW_PRIV_TYPE_INT | 16,
1377 IW_PRIV_TYPE_INT | 16,
1378 "getafc"},
1379 {
1380 WLAN_SCANPROBES,
1381 IW_PRIV_TYPE_INT | 16,
1382 IW_PRIV_TYPE_INT | 16,
1383 "scanprobes"},
1384 {
1385 WLAN_LED_GPIO_CTRL, 1103 WLAN_LED_GPIO_CTRL,
1386 IW_PRIV_TYPE_INT | 16, 1104 IW_PRIV_TYPE_INT | 16,
1387 IW_PRIV_TYPE_INT | 16, 1105 IW_PRIV_TYPE_INT | 16,
1388 "ledgpio"}, 1106 "ledgpio"},
1389 {
1390 WLAN_ADAPT_RATESET,
1391 IW_PRIV_TYPE_INT | 16,
1392 IW_PRIV_TYPE_INT | 16,
1393 "rateadapt"},
1394 {
1395 WLAN_INACTIVITY_TIMEOUT,
1396 IW_PRIV_TYPE_INT | 16,
1397 IW_PRIV_TYPE_INT | 16,
1398 "inactivityto"},
1399 {
1400 WLANSNR,
1401 IW_PRIV_TYPE_INT | 16,
1402 IW_PRIV_TYPE_INT | 16,
1403 "getSNR"},
1404 {
1405 WLAN_GET_RATE,
1406 IW_PRIV_TYPE_INT | 16,
1407 IW_PRIV_TYPE_INT | 16,
1408 "getrate"},
1409 {
1410 WLAN_GET_RXINFO,
1411 IW_PRIV_TYPE_INT | 16,
1412 IW_PRIV_TYPE_INT | 16,
1413 "getrxinfo"},
1414}; 1107};
1415 1108
1416static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev) 1109static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev)
@@ -1434,7 +1127,7 @@ static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev)
1434 1127
1435 ENTER(); 1128 ENTER();
1436 1129
1437 priv->wstats.status = adapter->inframode; 1130 priv->wstats.status = adapter->mode;
1438 1131
1439 /* If we're not associated, all quality values are meaningless */ 1132 /* If we're not associated, all quality values are meaningless */
1440 if (adapter->connect_status != libertas_connected) 1133 if (adapter->connect_status != libertas_connected)
@@ -1568,13 +1261,12 @@ static int wlan_set_freq(struct net_device *dev, struct iw_request_info *info,
1568 if (!cfp) { 1261 if (!cfp) {
1569 rc = -EINVAL; 1262 rc = -EINVAL;
1570 } else { 1263 } else {
1571 if (adapter->inframode == wlan802_11ibss) { 1264 if (adapter->mode == IW_MODE_ADHOC) {
1572 rc = changeadhocchannel(priv, channel); 1265 rc = changeadhocchannel(priv, channel);
1573 /* If station is WEP enabled, send the 1266 /* If station is WEP enabled, send the
1574 * command to set WEP in firmware 1267 * command to set WEP in firmware
1575 */ 1268 */
1576 if (adapter->secinfo.WEPstatus == 1269 if (adapter->secinfo.wep_enabled) {
1577 wlan802_11WEPenabled) {
1578 lbs_pr_debug(1, "set_freq: WEP enabled\n"); 1270 lbs_pr_debug(1, "set_freq: WEP enabled\n");
1579 ret = libertas_prepare_and_send_command(priv, 1271 ret = libertas_prepare_and_send_command(priv,
1580 cmd_802_11_set_wep, 1272 cmd_802_11_set_wep,
@@ -1716,49 +1408,31 @@ static int wlan_set_mode(struct net_device *dev,
1716 wlan_private *priv = dev->priv; 1408 wlan_private *priv = dev->priv;
1717 wlan_adapter *adapter = priv->adapter; 1409 wlan_adapter *adapter = priv->adapter;
1718 struct assoc_request * assoc_req; 1410 struct assoc_request * assoc_req;
1719 enum WLAN_802_11_NETWORK_INFRASTRUCTURE new_mode;
1720 1411
1721 ENTER(); 1412 ENTER();
1722 1413
1723 switch (*uwrq) { 1414 if ( (*uwrq != IW_MODE_ADHOC)
1724 case IW_MODE_ADHOC: 1415 && (*uwrq != IW_MODE_INFRA)
1725 lbs_pr_debug(1, "Wanted mode is ad-hoc: current datarate=%#x\n", 1416 && (*uwrq != IW_MODE_AUTO)) {
1726 adapter->datarate); 1417 lbs_pr_debug(1, "Invalid mode: 0x%x\n", *uwrq);
1727 new_mode = wlan802_11ibss; 1418 ret = -EINVAL;
1728 adapter->adhocchannel = DEFAULT_AD_HOC_CHANNEL; 1419 goto out;
1729 break;
1730
1731 case IW_MODE_INFRA:
1732 lbs_pr_debug(1, "Wanted mode is Infrastructure\n");
1733 new_mode = wlan802_11infrastructure;
1734 break;
1735
1736 case IW_MODE_AUTO:
1737 lbs_pr_debug(1, "Wanted mode is Auto\n");
1738 new_mode = wlan802_11autounknown;
1739 break;
1740
1741 default:
1742 lbs_pr_debug(1, "Wanted mode is Unknown: 0x%x\n", *uwrq);
1743 return -EINVAL;
1744 } 1420 }
1745 1421
1746 mutex_lock(&adapter->lock); 1422 mutex_lock(&adapter->lock);
1747 assoc_req = wlan_get_association_request(adapter); 1423 assoc_req = wlan_get_association_request(adapter);
1748 if (!assoc_req) { 1424 if (!assoc_req) {
1749 ret = -ENOMEM; 1425 ret = -ENOMEM;
1426 wlan_cancel_association_work(priv);
1750 } else { 1427 } else {
1751 assoc_req->mode = new_mode; 1428 assoc_req->mode = *uwrq;
1752 }
1753
1754 if (ret == 0) {
1755 set_bit(ASSOC_FLAG_MODE, &assoc_req->flags); 1429 set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
1756 wlan_postpone_association_work(priv); 1430 wlan_postpone_association_work(priv);
1757 } else { 1431 lbs_pr_debug(1, "Switching to mode: 0x%x\n", *uwrq);
1758 wlan_cancel_association_work(priv);
1759 } 1432 }
1760 mutex_unlock(&adapter->lock); 1433 mutex_unlock(&adapter->lock);
1761 1434
1435out:
1762 LEAVE(); 1436 LEAVE();
1763 return ret; 1437 return ret;
1764} 1438}
@@ -1789,13 +1463,13 @@ static int wlan_get_encode(struct net_device *dev,
1789 dwrq->flags = 0; 1463 dwrq->flags = 0;
1790 1464
1791 /* Authentication method */ 1465 /* Authentication method */
1792 switch (adapter->secinfo.authmode) { 1466 switch (adapter->secinfo.auth_mode) {
1793 case wlan802_11authmodeopen: 1467 case IW_AUTH_ALG_OPEN_SYSTEM:
1794 dwrq->flags = IW_ENCODE_OPEN; 1468 dwrq->flags = IW_ENCODE_OPEN;
1795 break; 1469 break;
1796 1470
1797 case wlan802_11authmodeshared: 1471 case IW_AUTH_ALG_SHARED_KEY:
1798 case wlan802_11authmodenetworkEAP: 1472 case IW_AUTH_ALG_LEAP:
1799 dwrq->flags = IW_ENCODE_RESTRICTED; 1473 dwrq->flags = IW_ENCODE_RESTRICTED;
1800 break; 1474 break;
1801 default: 1475 default:
@@ -1803,8 +1477,9 @@ static int wlan_get_encode(struct net_device *dev,
1803 break; 1477 break;
1804 } 1478 }
1805 1479
1806 if ((adapter->secinfo.WEPstatus == wlan802_11WEPenabled) 1480 if ( adapter->secinfo.wep_enabled
1807 || adapter->secinfo.WPAenabled || adapter->secinfo.WPA2enabled) { 1481 || adapter->secinfo.WPAenabled
1482 || adapter->secinfo.WPA2enabled) {
1808 dwrq->flags &= ~IW_ENCODE_DISABLED; 1483 dwrq->flags &= ~IW_ENCODE_DISABLED;
1809 } else { 1484 } else {
1810 dwrq->flags |= IW_ENCODE_DISABLED; 1485 dwrq->flags |= IW_ENCODE_DISABLED;
@@ -1818,8 +1493,7 @@ static int wlan_get_encode(struct net_device *dev,
1818 if (index < 0) 1493 if (index < 0)
1819 index = adapter->wep_tx_keyidx; 1494 index = adapter->wep_tx_keyidx;
1820 1495
1821 if ((adapter->wep_keys[index].len) && 1496 if ((adapter->wep_keys[index].len) && adapter->secinfo.wep_enabled) {
1822 (adapter->secinfo.WEPstatus == wlan802_11WEPenabled)) {
1823 memcpy(extra, adapter->wep_keys[index].key, 1497 memcpy(extra, adapter->wep_keys[index].key,
1824 adapter->wep_keys[index].len); 1498 adapter->wep_keys[index].len);
1825 dwrq->length = adapter->wep_keys[index].len; 1499 dwrq->length = adapter->wep_keys[index].len;
@@ -1903,7 +1577,7 @@ static int wlan_set_wep_key(struct assoc_request *assoc_req,
1903 assoc_req->wep_tx_keyidx = index; 1577 assoc_req->wep_tx_keyidx = index;
1904 } 1578 }
1905 1579
1906 assoc_req->secinfo.WEPstatus = wlan802_11WEPenabled; 1580 assoc_req->secinfo.wep_enabled = 1;
1907 1581
1908 LEAVE(); 1582 LEAVE();
1909 return 0; 1583 return 0;
@@ -1932,10 +1606,10 @@ static void disable_wep(struct assoc_request *assoc_req)
1932 int i; 1606 int i;
1933 1607
1934 /* Set Open System auth mode */ 1608 /* Set Open System auth mode */
1935 assoc_req->secinfo.authmode = wlan802_11authmodeopen; 1609 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
1936 1610
1937 /* Clear WEP keys and mark WEP as disabled */ 1611 /* Clear WEP keys and mark WEP as disabled */
1938 assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; 1612 assoc_req->secinfo.wep_enabled = 0;
1939 for (i = 0; i < 4; i++) 1613 for (i = 0; i < 4; i++)
1940 assoc_req->wep_keys[i].len = 0; 1614 assoc_req->wep_keys[i].len = 0;
1941 1615
@@ -1987,8 +1661,7 @@ static int wlan_set_encode(struct net_device *dev,
1987 /* If WEP isn't enabled, or if there is no key data but a valid 1661 /* If WEP isn't enabled, or if there is no key data but a valid
1988 * index, set the TX key. 1662 * index, set the TX key.
1989 */ 1663 */
1990 if ((assoc_req->secinfo.WEPstatus != wlan802_11WEPenabled) 1664 if (!assoc_req->secinfo.wep_enabled || (dwrq->length == 0 && !is_default))
1991 || (dwrq->length == 0 && !is_default))
1992 set_tx_key = 1; 1665 set_tx_key = 1;
1993 1666
1994 ret = wlan_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key); 1667 ret = wlan_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key);
@@ -2001,9 +1674,9 @@ static int wlan_set_encode(struct net_device *dev,
2001 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags); 1674 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
2002 1675
2003 if (dwrq->flags & IW_ENCODE_RESTRICTED) { 1676 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
2004 assoc_req->secinfo.authmode = wlan802_11authmodeshared; 1677 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
2005 } else if (dwrq->flags & IW_ENCODE_OPEN) { 1678 } else if (dwrq->flags & IW_ENCODE_OPEN) {
2006 assoc_req->secinfo.authmode = wlan802_11authmodeopen; 1679 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
2007 } 1680 }
2008 1681
2009out: 1682out:
@@ -2056,30 +1729,31 @@ static int wlan_get_encodeext(struct net_device *dev,
2056 1729
2057 if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY && 1730 if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY &&
2058 ext->alg != IW_ENCODE_ALG_WEP) { 1731 ext->alg != IW_ENCODE_ALG_WEP) {
2059 if (index != 0 || adapter->inframode != wlan802_11infrastructure) 1732 if (index != 0 || adapter->mode != IW_MODE_INFRA)
2060 goto out; 1733 goto out;
2061 } 1734 }
2062 1735
2063 dwrq->flags = index + 1; 1736 dwrq->flags = index + 1;
2064 memset(ext, 0, sizeof(*ext)); 1737 memset(ext, 0, sizeof(*ext));
2065 1738
2066 if ((adapter->secinfo.WEPstatus == wlan802_11WEPdisabled) 1739 if ( !adapter->secinfo.wep_enabled
2067 && !adapter->secinfo.WPAenabled && !adapter->secinfo.WPA2enabled) { 1740 && !adapter->secinfo.WPAenabled
1741 && !adapter->secinfo.WPA2enabled) {
2068 ext->alg = IW_ENCODE_ALG_NONE; 1742 ext->alg = IW_ENCODE_ALG_NONE;
2069 ext->key_len = 0; 1743 ext->key_len = 0;
2070 dwrq->flags |= IW_ENCODE_DISABLED; 1744 dwrq->flags |= IW_ENCODE_DISABLED;
2071 } else { 1745 } else {
2072 u8 *key = NULL; 1746 u8 *key = NULL;
2073 1747
2074 if ((adapter->secinfo.WEPstatus == wlan802_11WEPenabled) 1748 if ( adapter->secinfo.wep_enabled
2075 && !adapter->secinfo.WPAenabled 1749 && !adapter->secinfo.WPAenabled
2076 && !adapter->secinfo.WPA2enabled) { 1750 && !adapter->secinfo.WPA2enabled) {
2077 ext->alg = IW_ENCODE_ALG_WEP; 1751 ext->alg = IW_ENCODE_ALG_WEP;
2078 ext->key_len = adapter->wep_keys[index].len; 1752 ext->key_len = adapter->wep_keys[index].len;
2079 key = &adapter->wep_keys[index].key[0]; 1753 key = &adapter->wep_keys[index].key[0];
2080 } else if ((adapter->secinfo.WEPstatus == wlan802_11WEPdisabled) && 1754 } else if ( !adapter->secinfo.wep_enabled
2081 (adapter->secinfo.WPAenabled || 1755 && (adapter->secinfo.WPAenabled ||
2082 adapter->secinfo.WPA2enabled)) { 1756 adapter->secinfo.WPA2enabled)) {
2083 /* WPA */ 1757 /* WPA */
2084 ext->alg = IW_ENCODE_ALG_TKIP; 1758 ext->alg = IW_ENCODE_ALG_TKIP;
2085 ext->key_len = 0; 1759 ext->key_len = 0;
@@ -2149,7 +1823,7 @@ static int wlan_set_encodeext(struct net_device *dev,
2149 /* If WEP isn't enabled, or if there is no key data but a valid 1823 /* If WEP isn't enabled, or if there is no key data but a valid
2150 * index, or if the set-TX-key flag was passed, set the TX key. 1824 * index, or if the set-TX-key flag was passed, set the TX key.
2151 */ 1825 */
2152 if ((assoc_req->secinfo.WEPstatus != wlan802_11WEPenabled) 1826 if ( !assoc_req->secinfo.wep_enabled
2153 || (dwrq->length == 0 && !is_default) 1827 || (dwrq->length == 0 && !is_default)
2154 || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)) 1828 || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY))
2155 set_tx_key = 1; 1829 set_tx_key = 1;
@@ -2161,11 +1835,9 @@ static int wlan_set_encodeext(struct net_device *dev,
2161 goto out; 1835 goto out;
2162 1836
2163 if (dwrq->flags & IW_ENCODE_RESTRICTED) { 1837 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
2164 assoc_req->secinfo.authmode = 1838 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
2165 wlan802_11authmodeshared;
2166 } else if (dwrq->flags & IW_ENCODE_OPEN) { 1839 } else if (dwrq->flags & IW_ENCODE_OPEN) {
2167 assoc_req->secinfo.authmode = 1840 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
2168 wlan802_11authmodeopen;
2169 } 1841 }
2170 1842
2171 /* Mark the various WEP bits as modified */ 1843 /* Mark the various WEP bits as modified */
@@ -2350,15 +2022,13 @@ static int wlan_set_auth(struct net_device *dev,
2350 } 2022 }
2351 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) { 2023 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) {
2352 assoc_req->secinfo.WPAenabled = 1; 2024 assoc_req->secinfo.WPAenabled = 1;
2353 assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; 2025 assoc_req->secinfo.wep_enabled = 0;
2354 assoc_req->secinfo.authmode = 2026 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
2355 wlan802_11authmodeopen;
2356 } 2027 }
2357 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) { 2028 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) {
2358 assoc_req->secinfo.WPA2enabled = 1; 2029 assoc_req->secinfo.WPA2enabled = 1;
2359 assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; 2030 assoc_req->secinfo.wep_enabled = 0;
2360 assoc_req->secinfo.authmode = 2031 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
2361 wlan802_11authmodeopen;
2362 } 2032 }
2363 updated = 1; 2033 updated = 1;
2364 break; 2034 break;
@@ -2376,14 +2046,11 @@ static int wlan_set_auth(struct net_device *dev,
2376 2046
2377 case IW_AUTH_80211_AUTH_ALG: 2047 case IW_AUTH_80211_AUTH_ALG:
2378 if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) { 2048 if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) {
2379 assoc_req->secinfo.authmode = 2049 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_SHARED_KEY;
2380 wlan802_11authmodeshared;
2381 } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) { 2050 } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) {
2382 assoc_req->secinfo.authmode = 2051 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
2383 wlan802_11authmodeopen;
2384 } else if (dwrq->value & IW_AUTH_ALG_LEAP) { 2052 } else if (dwrq->value & IW_AUTH_ALG_LEAP) {
2385 assoc_req->secinfo.authmode = 2053 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_LEAP;
2386 wlan802_11authmodenetworkEAP;
2387 } else { 2054 } else {
2388 ret = -EINVAL; 2055 ret = -EINVAL;
2389 } 2056 }
@@ -2396,9 +2063,8 @@ static int wlan_set_auth(struct net_device *dev,
2396 !assoc_req->secinfo.WPA2enabled) { 2063 !assoc_req->secinfo.WPA2enabled) {
2397 assoc_req->secinfo.WPAenabled = 1; 2064 assoc_req->secinfo.WPAenabled = 1;
2398 assoc_req->secinfo.WPA2enabled = 1; 2065 assoc_req->secinfo.WPA2enabled = 1;
2399 assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled; 2066 assoc_req->secinfo.wep_enabled = 0;
2400 assoc_req->secinfo.authmode = 2067 assoc_req->secinfo.auth_mode = IW_AUTH_ALG_OPEN_SYSTEM;
2401 wlan802_11authmodeopen;
2402 } 2068 }
2403 } else { 2069 } else {
2404 assoc_req->secinfo.WPAenabled = 0; 2070 assoc_req->secinfo.WPAenabled = 0;
@@ -2455,19 +2121,7 @@ static int wlan_get_auth(struct net_device *dev,
2455 break; 2121 break;
2456 2122
2457 case IW_AUTH_80211_AUTH_ALG: 2123 case IW_AUTH_80211_AUTH_ALG:
2458 switch (adapter->secinfo.authmode) { 2124 dwrq->value = adapter->secinfo.auth_mode;
2459 case wlan802_11authmodeshared:
2460 dwrq->value = IW_AUTH_ALG_SHARED_KEY;
2461 break;
2462 case wlan802_11authmodeopen:
2463 dwrq->value = IW_AUTH_ALG_OPEN_SYSTEM;
2464 break;
2465 case wlan802_11authmodenetworkEAP:
2466 dwrq->value = IW_AUTH_ALG_LEAP;
2467 break;
2468 default:
2469 break;
2470 }
2471 break; 2125 break;
2472 2126
2473 case IW_AUTH_WPA_ENABLED: 2127 case IW_AUTH_WPA_ENABLED:
diff --git a/drivers/net/wireless/libertas/wext.h b/drivers/net/wireless/libertas/wext.h
index 39f367c38d90..15cfaaf0797f 100644
--- a/drivers/net/wireless/libertas/wext.h
+++ b/drivers/net/wireless/libertas/wext.h
@@ -10,88 +10,22 @@
10/** PRIVATE CMD ID */ 10/** PRIVATE CMD ID */
11#define WLANIOCTL SIOCIWFIRSTPRIV 11#define WLANIOCTL SIOCIWFIRSTPRIV
12 12
13#define WLANSETWPAIE (WLANIOCTL + 0)
14
15#define WLAN_SETINT_GETINT (WLANIOCTL + 7)
16#define WLANNF 1
17#define WLANRSSI 2
18#define WLANENABLE11D 5
19#define WLANADHOCGRATE 6
20#define WLAN_SUBCMD_SET_PRESCAN 11
21
22#define WLAN_SETNONE_GETNONE (WLANIOCTL + 8) 13#define WLAN_SETNONE_GETNONE (WLANIOCTL + 8)
23#define WLANDEAUTH 1
24#define WLANRADIOON 2
25#define WLANRADIOOFF 3
26#define WLANREMOVEADHOCAES 4
27#define WLANADHOCSTOP 5
28#define WLANCIPHERTEST 6
29#define WLANCRYPTOTEST 7
30
31#define WLANWLANIDLEON 10
32#define WLANWLANIDLEOFF 11
33#define WLAN_SUBCMD_BT_RESET 13 14#define WLAN_SUBCMD_BT_RESET 13
34#define WLAN_SUBCMD_FWT_RESET 14 15#define WLAN_SUBCMD_FWT_RESET 14
35 16
36#define WLANGETLOG (WLANIOCTL + 9)
37#define GETLOG_BUFSIZE 300
38
39#define WLANSCAN_TYPE (WLANIOCTL + 11)
40
41#define WLAN_SETNONE_GETONEINT (WLANIOCTL + 15) 17#define WLAN_SETNONE_GETONEINT (WLANIOCTL + 15)
42#define WLANGETREGION 1 18#define WLANGETREGION 1
43#define WLAN_GET_LISTEN_INTERVAL 2
44#define WLAN_GET_MULTIPLE_DTIM 3
45#define WLAN_GET_TX_RATE 4
46#define WLANGETBCNAVG 5
47 19
48#define WLAN_GET_LINKMODE 6
49#define WLAN_GET_RADIOMODE 7
50#define WLAN_GET_DEBUGMODE 8
51#define WLAN_SUBCMD_FWT_CLEANUP 15 20#define WLAN_SUBCMD_FWT_CLEANUP 15
52#define WLAN_SUBCMD_FWT_TIME 16 21#define WLAN_SUBCMD_FWT_TIME 16
53#define WLAN_SUBCMD_MESH_GET_TTL 17 22#define WLAN_SUBCMD_MESH_GET_TTL 17
54 23
55#define WLANREGCFRDWR (WLANIOCTL + 18)
56
57#define WLAN_SETNONE_GETTWELVE_CHAR (WLANIOCTL + 19)
58#define WLAN_SUBCMD_GETRXANTENNA 1
59#define WLAN_SUBCMD_GETTXANTENNA 2
60#define WLAN_GET_TSF 3
61
62#define WLAN_SETNONE_GETWORDCHAR (WLANIOCTL + 21)
63#define WLANGETADHOCAES 1
64
65#define WLAN_SETONEINT_GETONEINT (WLANIOCTL + 23)
66#define WLAN_BEACON_INTERVAL 1
67#define WLAN_LISTENINTRVL 4
68
69#define WLAN_TXCONTROL 6
70#define WLAN_NULLPKTINTERVAL 7
71
72#define WLAN_SETONEINT_GETNONE (WLANIOCTL + 24) 24#define WLAN_SETONEINT_GETNONE (WLANIOCTL + 24)
73#define WLAN_SUBCMD_SETRXANTENNA 1
74#define WLAN_SUBCMD_SETTXANTENNA 2
75#define WLANSETAUTHALG 5
76#define WLANSET8021XAUTHALG 6
77#define WLANSETENCRYPTIONMODE 7
78#define WLANSETREGION 8 25#define WLANSETREGION 8
79#define WLAN_SET_LISTEN_INTERVAL 9
80
81#define WLAN_SET_MULTIPLE_DTIM 10
82#define WLAN_SET_ATIM_WINDOW 11
83#define WLANSETBCNAVG 13
84#define WLANSETDATAAVG 14
85#define WLAN_SET_LINKMODE 15
86#define WLAN_SET_RADIOMODE 16
87#define WLAN_SET_DEBUGMODE 17
88#define WLAN_SUBCMD_MESH_SET_TTL 18 26#define WLAN_SUBCMD_MESH_SET_TTL 18
89 27
90#define WLAN_SET128CHAR_GET128CHAR (WLANIOCTL + 25) 28#define WLAN_SET128CHAR_GET128CHAR (WLANIOCTL + 25)
91#define WLANSCAN_MODE 6
92
93#define WLAN_GET_ADHOC_STATUS 9
94
95#define WLAN_SUBCMD_BT_ADD 18 29#define WLAN_SUBCMD_BT_ADD 18
96#define WLAN_SUBCMD_BT_DEL 19 30#define WLAN_SUBCMD_BT_DEL 19
97#define WLAN_SUBCMD_BT_LIST 20 31#define WLAN_SUBCMD_BT_LIST 20
@@ -103,27 +37,8 @@
103#define WLAN_SUBCMD_FWT_LIST_ROUTE 26 37#define WLAN_SUBCMD_FWT_LIST_ROUTE 26
104 38
105#define WLAN_SET_GET_SIXTEEN_INT (WLANIOCTL + 29) 39#define WLAN_SET_GET_SIXTEEN_INT (WLANIOCTL + 29)
106#define WLAN_TPCCFG 1
107#define WLAN_POWERCFG 2
108
109#define WLAN_AUTO_FREQ_SET 3
110#define WLAN_AUTO_FREQ_GET 4
111#define WLAN_LED_GPIO_CTRL 5 40#define WLAN_LED_GPIO_CTRL 5
112#define WLAN_SCANPROBES 6
113#define WLAN_ADAPT_RATESET 8
114#define WLAN_INACTIVITY_TIMEOUT 9
115#define WLANSNR 10
116#define WLAN_GET_RATE 11
117#define WLAN_GET_RXINFO 12
118
119#define WLANCMD52RDWR (WLANIOCTL + 30)
120#define WLANCMD53RDWR (WLANIOCTL + 31)
121#define CMD53BUFLEN 32
122 41
123#define REG_MAC 0x19
124#define REG_BBP 0x1a
125#define REG_RF 0x1b
126#define REG_EEPROM 0x59
127#define WLAN_LINKMODE_802_3 0 42#define WLAN_LINKMODE_802_3 0
128#define WLAN_LINKMODE_802_11 2 43#define WLAN_LINKMODE_802_11 2
129#define WLAN_RADIOMODE_NONE 0 44#define WLAN_RADIOMODE_NONE 0
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index 78cf0711d1fa..ef07c36bccf7 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -249,19 +249,19 @@ static int sn_slot_enable(struct hotplug_slot *bss_hotplug_slot,
249 249
250 250
251 if (rc == PCI_SLOT_ALREADY_UP) { 251 if (rc == PCI_SLOT_ALREADY_UP) {
252 dev_dbg(slot->pci_bus->self, "is already active\n"); 252 dev_dbg(&slot->pci_bus->self->dev, "is already active\n");
253 return 1; /* return 1 to user */ 253 return 1; /* return 1 to user */
254 } 254 }
255 255
256 if (rc == PCI_L1_ERR) { 256 if (rc == PCI_L1_ERR) {
257 dev_dbg(slot->pci_bus->self, 257 dev_dbg(&slot->pci_bus->self->dev,
258 "L1 failure %d with message: %s", 258 "L1 failure %d with message: %s",
259 resp.resp_sub_errno, resp.resp_l1_msg); 259 resp.resp_sub_errno, resp.resp_l1_msg);
260 return -EPERM; 260 return -EPERM;
261 } 261 }
262 262
263 if (rc) { 263 if (rc) {
264 dev_dbg(slot->pci_bus->self, 264 dev_dbg(&slot->pci_bus->self->dev,
265 "insert failed with error %d sub-error %d\n", 265 "insert failed with error %d sub-error %d\n",
266 rc, resp.resp_sub_errno); 266 rc, resp.resp_sub_errno);
267 return -EIO; 267 return -EIO;
@@ -287,25 +287,25 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot,
287 287
288 if ((action == PCI_REQ_SLOT_ELIGIBLE) && 288 if ((action == PCI_REQ_SLOT_ELIGIBLE) &&
289 (rc == PCI_SLOT_ALREADY_DOWN)) { 289 (rc == PCI_SLOT_ALREADY_DOWN)) {
290 dev_dbg(slot->pci_bus->self, "Slot %s already inactive\n"); 290 dev_dbg(&slot->pci_bus->self->dev, "Slot %s already inactive\n", slot->physical_path);
291 return 1; /* return 1 to user */ 291 return 1; /* return 1 to user */
292 } 292 }
293 293
294 if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_EMPTY_33MHZ)) { 294 if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_EMPTY_33MHZ)) {
295 dev_dbg(slot->pci_bus->self, 295 dev_dbg(&slot->pci_bus->self->dev,
296 "Cannot remove last 33MHz card\n"); 296 "Cannot remove last 33MHz card\n");
297 return -EPERM; 297 return -EPERM;
298 } 298 }
299 299
300 if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_L1_ERR)) { 300 if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_L1_ERR)) {
301 dev_dbg(slot->pci_bus->self, 301 dev_dbg(&slot->pci_bus->self->dev,
302 "L1 failure %d with message \n%s\n", 302 "L1 failure %d with message \n%s\n",
303 resp.resp_sub_errno, resp.resp_l1_msg); 303 resp.resp_sub_errno, resp.resp_l1_msg);
304 return -EPERM; 304 return -EPERM;
305 } 305 }
306 306
307 if ((action == PCI_REQ_SLOT_ELIGIBLE) && rc) { 307 if ((action == PCI_REQ_SLOT_ELIGIBLE) && rc) {
308 dev_dbg(slot->pci_bus->self, 308 dev_dbg(&slot->pci_bus->self->dev,
309 "remove failed with error %d sub-error %d\n", 309 "remove failed with error %d sub-error %d\n",
310 rc, resp.resp_sub_errno); 310 rc, resp.resp_sub_errno);
311 return -EIO; 311 return -EIO;
@@ -317,12 +317,12 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot,
317 if ((action == PCI_REQ_SLOT_DISABLE) && !rc) { 317 if ((action == PCI_REQ_SLOT_DISABLE) && !rc) {
318 pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus); 318 pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus);
319 pcibus_info->pbi_enabled_devices &= ~(1 << device_num); 319 pcibus_info->pbi_enabled_devices &= ~(1 << device_num);
320 dev_dbg(slot->pci_bus->self, "remove successful\n"); 320 dev_dbg(&slot->pci_bus->self->dev, "remove successful\n");
321 return 0; 321 return 0;
322 } 322 }
323 323
324 if ((action == PCI_REQ_SLOT_DISABLE) && rc) { 324 if ((action == PCI_REQ_SLOT_DISABLE) && rc) {
325 dev_dbg(slot->pci_bus->self,"remove failed rc = %d\n", rc); 325 dev_dbg(&slot->pci_bus->self->dev,"remove failed rc = %d\n", rc);
326 } 326 }
327 327
328 return rc; 328 return rc;
@@ -375,7 +375,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
375 num_funcs = pci_scan_slot(slot->pci_bus, 375 num_funcs = pci_scan_slot(slot->pci_bus,
376 PCI_DEVFN(slot->device_num + 1, 0)); 376 PCI_DEVFN(slot->device_num + 1, 0));
377 if (!num_funcs) { 377 if (!num_funcs) {
378 dev_dbg(slot->pci_bus->self, "no device in slot\n"); 378 dev_dbg(&slot->pci_bus->self->dev, "no device in slot\n");
379 mutex_unlock(&sn_hotplug_mutex); 379 mutex_unlock(&sn_hotplug_mutex);
380 return -ENODEV; 380 return -ENODEV;
381 } 381 }
@@ -427,7 +427,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
427 phandle = PCI_CONTROLLER(slot->pci_bus)->acpi_handle; 427 phandle = PCI_CONTROLLER(slot->pci_bus)->acpi_handle;
428 428
429 if (acpi_bus_get_device(phandle, &pdevice)) { 429 if (acpi_bus_get_device(phandle, &pdevice)) {
430 dev_dbg(slot->pci_bus->self, 430 dev_dbg(&slot->pci_bus->self->dev,
431 "no parent device, assuming NULL\n"); 431 "no parent device, assuming NULL\n");
432 pdevice = NULL; 432 pdevice = NULL;
433 } 433 }
@@ -479,10 +479,10 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
479 mutex_unlock(&sn_hotplug_mutex); 479 mutex_unlock(&sn_hotplug_mutex);
480 480
481 if (rc == 0) 481 if (rc == 0)
482 dev_dbg(slot->pci_bus->self, 482 dev_dbg(&slot->pci_bus->self->dev,
483 "insert operation successful\n"); 483 "insert operation successful\n");
484 else 484 else
485 dev_dbg(slot->pci_bus->self, 485 dev_dbg(&slot->pci_bus->self->dev,
486 "insert operation failed rc = %d\n", rc); 486 "insert operation failed rc = %d\n", rc);
487 487
488 return rc; 488 return rc;
@@ -659,16 +659,16 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus)
659 if (rc) 659 if (rc)
660 goto register_err; 660 goto register_err;
661 } 661 }
662 dev_dbg(pci_bus->self, "Registered bus with hotplug\n"); 662 dev_dbg(&pci_bus->self->dev, "Registered bus with hotplug\n");
663 return rc; 663 return rc;
664 664
665register_err: 665register_err:
666 dev_dbg(pci_bus->self, "bus failed to register with err = %d\n", 666 dev_dbg(&pci_bus->self->dev, "bus failed to register with err = %d\n",
667 rc); 667 rc);
668 668
669alloc_err: 669alloc_err:
670 if (rc == -ENOMEM) 670 if (rc == -ENOMEM)
671 dev_dbg(pci_bus->self, "Memory allocation error\n"); 671 dev_dbg(&pci_bus->self->dev, "Memory allocation error\n");
672 672
673 /* destroy THIS element */ 673 /* destroy THIS element */
674 if (bss_hotplug_slot) 674 if (bss_hotplug_slot)
@@ -701,10 +701,10 @@ static int sn_pci_hotplug_init(void)
701 701
702 rc = sn_pci_bus_valid(pci_bus); 702 rc = sn_pci_bus_valid(pci_bus);
703 if (rc != 1) { 703 if (rc != 1) {
704 dev_dbg(pci_bus->self, "not a valid hotplug bus\n"); 704 dev_dbg(&pci_bus->self->dev, "not a valid hotplug bus\n");
705 continue; 705 continue;
706 } 706 }
707 dev_dbg(pci_bus->self, "valid hotplug bus\n"); 707 dev_dbg(&pci_bus->self->dev, "valid hotplug bus\n");
708 708
709 rc = sn_hotplug_slot_register(pci_bus); 709 rc = sn_hotplug_slot_register(pci_bus);
710 if (!rc) { 710 if (!rc) {
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index e6740d1a0824..d9cbd586ae4b 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -549,8 +549,10 @@ static int msi_free_irqs(struct pci_dev* dev)
549{ 549{
550 struct msi_desc *entry, *tmp; 550 struct msi_desc *entry, *tmp;
551 551
552 list_for_each_entry(entry, &dev->msi_list, list) 552 list_for_each_entry(entry, &dev->msi_list, list) {
553 BUG_ON(irq_has_action(entry->irq)); 553 if (entry->irq)
554 BUG_ON(irq_has_action(entry->irq));
555 }
554 556
555 arch_teardown_msi_irqs(dev); 557 arch_teardown_msi_irqs(dev);
556 558
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 147d86f8edbf..6ccc2e95930a 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -875,6 +875,7 @@ static void __devinit quirk_sb600_sata(struct pci_dev *pdev)
875 } 875 }
876} 876}
877DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_sb600_sata); 877DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_sb600_sata);
878DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_sb600_sata);
878 879
879/* 880/*
880 * Serverworks CSB5 IDE does not fully support native mode 881 * Serverworks CSB5 IDE does not fully support native mode
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 1759baad439c..95ce8f49e382 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -246,7 +246,7 @@ comment "Platform RTC drivers"
246config RTC_DRV_CMOS 246config RTC_DRV_CMOS
247 tristate "PC-style 'CMOS'" 247 tristate "PC-style 'CMOS'"
248 depends on RTC_CLASS && (X86 || ALPHA || ARM26 || ARM \ 248 depends on RTC_CLASS && (X86 || ALPHA || ARM26 || ARM \
249 || M32R || ATARI || POWERPC) 249 || M32R || ATARI || POWERPC || MIPS)
250 help 250 help
251 Say "yes" here to get direct support for the real time clock 251 Say "yes" here to get direct support for the real time clock
252 found in every PC or ACPI-based system, and some other boards. 252 found in every PC or ACPI-based system, and some other boards.
@@ -397,7 +397,7 @@ config RTC_DRV_BFIN
397 397
398config RTC_DRV_RS5C313 398config RTC_DRV_RS5C313
399 tristate "Ricoh RS5C313" 399 tristate "Ricoh RS5C313"
400 depends on RTC_CLASS && BROKEN 400 depends on RTC_CLASS && SH_LANDISK
401 help 401 help
402 If you say yes here you get support for the Ricoh RS5C313 RTC chips. 402 If you say yes here you get support for the Ricoh RS5C313 RTC chips.
403 403
diff --git a/drivers/rtc/rtc-rs5c313.c b/drivers/rtc/rtc-rs5c313.c
index 9d6de371495b..66eb133bf5fd 100644
--- a/drivers/rtc/rtc-rs5c313.c
+++ b/drivers/rtc/rtc-rs5c313.c
@@ -126,7 +126,7 @@ static void rs5c313_write_data(unsigned char data)
126static unsigned char rs5c313_read_data(void) 126static unsigned char rs5c313_read_data(void)
127{ 127{
128 int i; 128 int i;
129 unsigned char data; 129 unsigned char data = 0;
130 130
131 for (i = 0; i < 8; i++) { 131 for (i = 0; i < 8; i++) {
132 ndelay(700); 132 ndelay(700);
@@ -194,7 +194,7 @@ static void rs5c313_write_reg(unsigned char addr, unsigned char data)
194 return; 194 return;
195} 195}
196 196
197static inline unsigned char rs5c313_read_cntreg(unsigned char addr) 197static inline unsigned char rs5c313_read_cntreg(void)
198{ 198{
199 return rs5c313_read_reg(RS5C313_ADDR_CNTREG); 199 return rs5c313_read_reg(RS5C313_ADDR_CNTREG);
200} 200}
@@ -212,7 +212,9 @@ static inline void rs5c313_write_intintvreg(unsigned char data)
212static int rs5c313_rtc_read_time(struct device *dev, struct rtc_time *tm) 212static int rs5c313_rtc_read_time(struct device *dev, struct rtc_time *tm)
213{ 213{
214 int data; 214 int data;
215 int cnt;
215 216
217 cnt = 0;
216 while (1) { 218 while (1) {
217 RS5C313_CEENABLE; /* CE:H */ 219 RS5C313_CEENABLE; /* CE:H */
218 220
@@ -225,6 +227,10 @@ static int rs5c313_rtc_read_time(struct device *dev, struct rtc_time *tm)
225 RS5C313_CEDISABLE; 227 RS5C313_CEDISABLE;
226 ndelay(700); /* CE:L */ 228 ndelay(700); /* CE:L */
227 229
230 if (cnt++ > 100) {
231 dev_err(dev, "%s: timeout error\n", __FUNCTION__);
232 return -EIO;
233 }
228 } 234 }
229 235
230 data = rs5c313_read_reg(RS5C313_ADDR_SEC); 236 data = rs5c313_read_reg(RS5C313_ADDR_SEC);
@@ -266,7 +272,9 @@ static int rs5c313_rtc_read_time(struct device *dev, struct rtc_time *tm)
266static int rs5c313_rtc_set_time(struct device *dev, struct rtc_time *tm) 272static int rs5c313_rtc_set_time(struct device *dev, struct rtc_time *tm)
267{ 273{
268 int data; 274 int data;
275 int cnt;
269 276
277 cnt = 0;
270 /* busy check. */ 278 /* busy check. */
271 while (1) { 279 while (1) {
272 RS5C313_CEENABLE; /* CE:H */ 280 RS5C313_CEENABLE; /* CE:H */
@@ -279,6 +287,11 @@ static int rs5c313_rtc_set_time(struct device *dev, struct rtc_time *tm)
279 RS5C313_MISCOP; 287 RS5C313_MISCOP;
280 RS5C313_CEDISABLE; 288 RS5C313_CEDISABLE;
281 ndelay(700); /* CE:L */ 289 ndelay(700); /* CE:L */
290
291 if (cnt++ > 100) {
292 dev_err(dev, "%s: timeout error\n", __FUNCTION__);
293 return -EIO;
294 }
282 } 295 }
283 296
284 data = BIN2BCD(tm->tm_sec); 297 data = BIN2BCD(tm->tm_sec);
@@ -317,6 +330,7 @@ static int rs5c313_rtc_set_time(struct device *dev, struct rtc_time *tm)
317static void rs5c313_check_xstp_bit(void) 330static void rs5c313_check_xstp_bit(void)
318{ 331{
319 struct rtc_time tm; 332 struct rtc_time tm;
333 int cnt;
320 334
321 RS5C313_CEENABLE; /* CE:H */ 335 RS5C313_CEENABLE; /* CE:H */
322 if (rs5c313_read_cntreg() & RS5C313_CNTREG_WTEN_XSTP) { 336 if (rs5c313_read_cntreg() & RS5C313_CNTREG_WTEN_XSTP) {
@@ -326,12 +340,16 @@ static void rs5c313_check_xstp_bit(void)
326 rs5c313_write_cntreg(0x07); 340 rs5c313_write_cntreg(0x07);
327 341
328 /* busy check. */ 342 /* busy check. */
329 while (rs5c313_read_cntreg() & RS5C313_CNTREG_ADJ_BSY) 343 for (cnt = 0; cnt < 100; cnt++) {
344 if (!(rs5c313_read_cntreg() & RS5C313_CNTREG_ADJ_BSY))
345 break;
330 RS5C313_MISCOP; 346 RS5C313_MISCOP;
347 }
331 348
332 memset(&tm, 0, sizeof(struct rtc_time)); 349 memset(&tm, 0, sizeof(struct rtc_time));
333 tm.tm_mday = 1; 350 tm.tm_mday = 1;
334 tm.tm_mon = 1; 351 tm.tm_mon = 1 - 1;
352 tm.tm_year = 2000 - 1900;
335 353
336 rs5c313_rtc_set_time(NULL, &tm); 354 rs5c313_rtc_set_time(NULL, &tm);
337 printk(KERN_ERR "RICHO RS5C313: invalid value, resetting to " 355 printk(KERN_ERR "RICHO RS5C313: invalid value, resetting to "
@@ -356,7 +374,7 @@ static int rs5c313_rtc_probe(struct platform_device *pdev)
356 374
357 platform_set_drvdata(pdev, rtc); 375 platform_set_drvdata(pdev, rtc);
358 376
359 return err; 377 return 0;
360} 378}
361 379
362static int __devexit rs5c313_rtc_remove(struct platform_device *pdev) 380static int __devexit rs5c313_rtc_remove(struct platform_device *pdev)
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c
index f2be2ead8742..8328acab47fd 100644
--- a/drivers/sbus/char/envctrl.c
+++ b/drivers/sbus/char/envctrl.c
@@ -30,6 +30,7 @@
30#include <asm/ebus.h> 30#include <asm/ebus.h>
31#include <asm/uaccess.h> 31#include <asm/uaccess.h>
32#include <asm/envctrl.h> 32#include <asm/envctrl.h>
33#include <asm/io.h>
33 34
34#define ENVCTRL_MINOR 162 35#define ENVCTRL_MINOR 162
35 36
diff --git a/drivers/scsi/sgiwd93.c b/drivers/scsi/sgiwd93.c
index a15752b37990..eef82758d047 100644
--- a/drivers/scsi/sgiwd93.c
+++ b/drivers/scsi/sgiwd93.c
@@ -6,87 +6,49 @@
6 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com) 6 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
7 * Copyright (C) 1999 Andrew R. Baker (andrewb@uab.edu) 7 * Copyright (C) 1999 Andrew R. Baker (andrewb@uab.edu)
8 * Copyright (C) 2001 Florian Lohoff (flo@rfc822.org) 8 * Copyright (C) 2001 Florian Lohoff (flo@rfc822.org)
9 * Copyright (C) 2003 Ralf Baechle (ralf@linux-mips.org) 9 * Copyright (C) 2003, 07 Ralf Baechle (ralf@linux-mips.org)
10 * 10 *
11 * (In all truth, Jed Schimmel wrote all this code.) 11 * (In all truth, Jed Schimmel wrote all this code.)
12 */ 12 */
13#include <linux/init.h> 13
14#include <linux/interrupt.h> 14#undef DEBUG
15#include <linux/types.h> 15
16#include <linux/mm.h>
17#include <linux/blkdev.h>
18#include <linux/delay.h> 16#include <linux/delay.h>
19#include <linux/dma-mapping.h> 17#include <linux/dma-mapping.h>
18#include <linux/gfp.h>
19#include <linux/interrupt.h>
20#include <linux/init.h>
21#include <linux/kernel.h>
22#include <linux/types.h>
23#include <linux/module.h>
24#include <linux/platform_device.h>
20#include <linux/spinlock.h> 25#include <linux/spinlock.h>
21 26
22#include <asm/page.h>
23#include <asm/pgtable.h>
24#include <asm/sgialib.h>
25#include <asm/sgi/sgi.h>
26#include <asm/sgi/mc.h>
27#include <asm/sgi/hpc3.h> 27#include <asm/sgi/hpc3.h>
28#include <asm/sgi/ip22.h> 28#include <asm/sgi/ip22.h>
29#include <asm/irq.h> 29#include <asm/sgi/wd.h>
30#include <asm/io.h>
31 30
32#include "scsi.h" 31#include "scsi.h"
33#include <scsi/scsi_host.h>
34#include "wd33c93.h" 32#include "wd33c93.h"
35 33
36#include <linux/stat.h>
37
38#if 0
39#define DPRINTK(args...) printk(args)
40#else
41#define DPRINTK(args...)
42#endif
43
44#define HDATA(ptr) ((struct ip22_hostdata *)((ptr)->hostdata))
45
46struct ip22_hostdata { 34struct ip22_hostdata {
47 struct WD33C93_hostdata wh; 35 struct WD33C93_hostdata wh;
48 struct hpc_data { 36 struct hpc_data {
49 dma_addr_t dma; 37 dma_addr_t dma;
50 void * cpu; 38 void *cpu;
51 } hd; 39 } hd;
52}; 40};
53 41
42#define host_to_hostdata(host) ((struct ip22_hostdata *)((host)->hostdata))
43
54struct hpc_chunk { 44struct hpc_chunk {
55 struct hpc_dma_desc desc; 45 struct hpc_dma_desc desc;
56 u32 _padding; /* align to quadword boundary */ 46 u32 _padding; /* align to quadword boundary */
57}; 47};
58 48
59struct Scsi_Host *sgiwd93_host;
60struct Scsi_Host *sgiwd93_host1;
61
62/* Wuff wuff, wuff, wd33c93.c, wuff wuff, object oriented, bow wow. */
63static inline void write_wd33c93_count(const wd33c93_regs regs,
64 unsigned long value)
65{
66 *regs.SASR = WD_TRANSFER_COUNT_MSB;
67 mb();
68 *regs.SCMD = ((value >> 16) & 0xff);
69 *regs.SCMD = ((value >> 8) & 0xff);
70 *regs.SCMD = ((value >> 0) & 0xff);
71 mb();
72}
73
74static inline unsigned long read_wd33c93_count(const wd33c93_regs regs)
75{
76 unsigned long value;
77
78 *regs.SASR = WD_TRANSFER_COUNT_MSB;
79 mb();
80 value = ((*regs.SCMD & 0xff) << 16);
81 value |= ((*regs.SCMD & 0xff) << 8);
82 value |= ((*regs.SCMD & 0xff) << 0);
83 mb();
84 return value;
85}
86
87static irqreturn_t sgiwd93_intr(int irq, void *dev_id) 49static irqreturn_t sgiwd93_intr(int irq, void *dev_id)
88{ 50{
89 struct Scsi_Host * host = (struct Scsi_Host *) dev_id; 51 struct Scsi_Host * host = dev_id;
90 unsigned long flags; 52 unsigned long flags;
91 53
92 spin_lock_irqsave(host->host_lock, flags); 54 spin_lock_irqsave(host->host_lock, flags);
@@ -131,12 +93,12 @@ void fill_hpc_entries(struct hpc_chunk *hcp, struct scsi_cmnd *cmd, int datainp)
131 93
132static int dma_setup(struct scsi_cmnd *cmd, int datainp) 94static int dma_setup(struct scsi_cmnd *cmd, int datainp)
133{ 95{
134 struct ip22_hostdata *hdata = HDATA(cmd->device->host); 96 struct ip22_hostdata *hdata = host_to_hostdata(cmd->device->host);
135 struct hpc3_scsiregs *hregs = 97 struct hpc3_scsiregs *hregs =
136 (struct hpc3_scsiregs *) cmd->device->host->base; 98 (struct hpc3_scsiregs *) cmd->device->host->base;
137 struct hpc_chunk *hcp = (struct hpc_chunk *) hdata->hd.cpu; 99 struct hpc_chunk *hcp = (struct hpc_chunk *) hdata->hd.cpu;
138 100
139 DPRINTK("dma_setup: datainp<%d> hcp<%p> ", datainp, hcp); 101 pr_debug("dma_setup: datainp<%d> hcp<%p> ", datainp, hcp);
140 102
141 hdata->wh.dma_dir = datainp; 103 hdata->wh.dma_dir = datainp;
142 104
@@ -151,7 +113,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int datainp)
151 113
152 fill_hpc_entries(hcp, cmd, datainp); 114 fill_hpc_entries(hcp, cmd, datainp);
153 115
154 DPRINTK(" HPCGO\n"); 116 pr_debug(" HPCGO\n");
155 117
156 /* Start up the HPC. */ 118 /* Start up the HPC. */
157 hregs->ndptr = hdata->hd.dma; 119 hregs->ndptr = hdata->hd.dma;
@@ -166,7 +128,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int datainp)
166static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, 128static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
167 int status) 129 int status)
168{ 130{
169 struct ip22_hostdata *hdata = HDATA(instance); 131 struct ip22_hostdata *hdata = host_to_hostdata(instance);
170 struct hpc3_scsiregs *hregs; 132 struct hpc3_scsiregs *hregs;
171 133
172 if (!SCpnt) 134 if (!SCpnt)
@@ -174,7 +136,7 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
174 136
175 hregs = (struct hpc3_scsiregs *) SCpnt->device->host->base; 137 hregs = (struct hpc3_scsiregs *) SCpnt->device->host->base;
176 138
177 DPRINTK("dma_stop: status<%d> ", status); 139 pr_debug("dma_stop: status<%d> ", status);
178 140
179 /* First stop the HPC and flush it's FIFO. */ 141 /* First stop the HPC and flush it's FIFO. */
180 if (hdata->wh.dma_dir) { 142 if (hdata->wh.dma_dir) {
@@ -186,7 +148,7 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
186 dma_unmap_single(NULL, SCpnt->SCp.dma_handle, SCpnt->SCp.this_residual, 148 dma_unmap_single(NULL, SCpnt->SCp.dma_handle, SCpnt->SCp.this_residual,
187 SCpnt->sc_data_direction); 149 SCpnt->sc_data_direction);
188 150
189 DPRINTK("\n"); 151 pr_debug("\n");
190} 152}
191 153
192void sgiwd93_reset(unsigned long base) 154void sgiwd93_reset(unsigned long base)
@@ -216,29 +178,71 @@ static inline void init_hpc_chain(struct hpc_data *hd)
216 hcp->desc.pnext = hd->dma; 178 hcp->desc.pnext = hd->dma;
217} 179}
218 180
219static struct Scsi_Host * __init sgiwd93_setup_scsi( 181static int sgiwd93_bus_reset(struct scsi_cmnd *cmd)
220 struct scsi_host_template *SGIblows, int unit, int irq, 182{
221 struct hpc3_scsiregs *hregs, unsigned char *wdregs) 183 /* FIXME perform bus-specific reset */
184
185 /* FIXME 2: kill this function, and let midlayer fallback
186 to the same result, calling wd33c93_host_reset() */
187
188 spin_lock_irq(cmd->device->host->host_lock);
189 wd33c93_host_reset(cmd);
190 spin_unlock_irq(cmd->device->host->host_lock);
191
192 return SUCCESS;
193}
194
195/*
196 * Kludge alert - the SCSI code calls the abort and reset method with int
197 * arguments not with pointers. So this is going to blow up beautyfully
198 * on 64-bit systems with memory outside the compat address spaces.
199 */
200static struct scsi_host_template sgiwd93_template = {
201 .module = THIS_MODULE,
202 .proc_name = "SGIWD93",
203 .name = "SGI WD93",
204 .queuecommand = wd33c93_queuecommand,
205 .eh_abort_handler = wd33c93_abort,
206 .eh_bus_reset_handler = sgiwd93_bus_reset,
207 .eh_host_reset_handler = wd33c93_host_reset,
208 .can_queue = 16,
209 .this_id = 7,
210 .sg_tablesize = SG_ALL,
211 .cmd_per_lun = 8,
212 .use_clustering = DISABLE_CLUSTERING,
213};
214
215static int __init sgiwd93_probe(struct platform_device *pdev)
222{ 216{
217 struct sgiwd93_platform_data *pd = pdev->dev.platform_data;
218 unsigned char *wdregs = pd->wdregs;
219 struct hpc3_scsiregs *hregs = pd->hregs;
223 struct ip22_hostdata *hdata; 220 struct ip22_hostdata *hdata;
224 struct Scsi_Host *host; 221 struct Scsi_Host *host;
225 wd33c93_regs regs; 222 wd33c93_regs regs;
226 223 unsigned int unit = pd->unit;
227 host = scsi_register(SGIblows, sizeof(struct ip22_hostdata)); 224 unsigned int irq = pd->irq;
228 if (!host) 225 int err;
229 return NULL; 226
227 host = scsi_host_alloc(&sgiwd93_template, sizeof(struct ip22_hostdata));
228 if (!host) {
229 err = -ENOMEM;
230 goto out;
231 }
230 232
231 host->base = (unsigned long) hregs; 233 host->base = (unsigned long) hregs;
232 host->irq = irq; 234 host->irq = irq;
233 235
234 hdata = HDATA(host); 236 hdata = host_to_hostdata(host);
235 hdata->hd.cpu = dma_alloc_coherent(NULL, PAGE_SIZE, &hdata->hd.dma, 237 hdata->hd.cpu = dma_alloc_coherent(&pdev->dev, PAGE_SIZE,
236 GFP_KERNEL); 238 &hdata->hd.dma, GFP_KERNEL);
237 if (!hdata->hd.cpu) { 239 if (!hdata->hd.cpu) {
238 printk(KERN_WARNING "sgiwd93: Could not allocate memory for " 240 printk(KERN_WARNING "sgiwd93: Could not allocate memory for "
239 "host %d buffer.\n", unit); 241 "host %d buffer.\n", unit);
240 goto out_unregister; 242 err = -ENOMEM;
243 goto out_put;
241 } 244 }
245
242 init_hpc_chain(&hdata->hd); 246 init_hpc_chain(&hdata->hd);
243 247
244 regs.SASR = wdregs + 3; 248 regs.SASR = wdregs + 3;
@@ -249,95 +253,67 @@ static struct Scsi_Host * __init sgiwd93_setup_scsi(
249 if (hdata->wh.no_sync == 0xff) 253 if (hdata->wh.no_sync == 0xff)
250 hdata->wh.no_sync = 0; 254 hdata->wh.no_sync = 0;
251 255
252 if (request_irq(irq, sgiwd93_intr, 0, "SGI WD93", (void *) host)) { 256 err = request_irq(irq, sgiwd93_intr, 0, "SGI WD93", host);
257 if (err) {
253 printk(KERN_WARNING "sgiwd93: Could not register irq %d " 258 printk(KERN_WARNING "sgiwd93: Could not register irq %d "
254 "for host %d.\n", irq, unit); 259 "for host %d.\n", irq, unit);
255 goto out_free; 260 goto out_free;
256 } 261 }
257 return host;
258 262
259out_free: 263 platform_set_drvdata(pdev, host);
260 dma_free_coherent(NULL, PAGE_SIZE, hdata->hd.cpu, hdata->hd.dma);
261 wd33c93_release();
262 264
263out_unregister: 265 err = scsi_add_host(host, NULL);
264 scsi_unregister(host); 266 if (err)
267 goto out_irq;
265 268
266 return NULL; 269 scsi_scan_host(host);
267}
268
269static int __init sgiwd93_detect(struct scsi_host_template *SGIblows)
270{
271 int found = 0;
272
273 SGIblows->proc_name = "SGIWD93";
274 sgiwd93_host = sgiwd93_setup_scsi(SGIblows, 0, SGI_WD93_0_IRQ,
275 &hpc3c0->scsi_chan0,
276 (unsigned char *)hpc3c0->scsi0_ext);
277 if (sgiwd93_host)
278 found++;
279
280 /* Set up second controller on the Indigo2 */
281 if (ip22_is_fullhouse()) {
282 sgiwd93_host1 = sgiwd93_setup_scsi(SGIblows, 1, SGI_WD93_1_IRQ,
283 &hpc3c0->scsi_chan1,
284 (unsigned char *)hpc3c0->scsi1_ext);
285 if (sgiwd93_host1)
286 found++;
287 }
288
289 return found;
290}
291 270
292static int sgiwd93_release(struct Scsi_Host *instance) 271 return 0;
293{
294 struct ip22_hostdata *hdata = HDATA(instance);
295 int irq = 0;
296
297 if (sgiwd93_host && sgiwd93_host == instance)
298 irq = SGI_WD93_0_IRQ;
299 else if (sgiwd93_host1 && sgiwd93_host1 == instance)
300 irq = SGI_WD93_1_IRQ;
301 272
302 free_irq(irq, sgiwd93_intr); 273out_irq:
274 free_irq(irq, host);
275out_free:
303 dma_free_coherent(NULL, PAGE_SIZE, hdata->hd.cpu, hdata->hd.dma); 276 dma_free_coherent(NULL, PAGE_SIZE, hdata->hd.cpu, hdata->hd.dma);
304 wd33c93_release(); 277out_put:
278 scsi_host_put(host);
279out:
305 280
306 return 1; 281 return err;
307} 282}
308 283
309static int sgiwd93_bus_reset(struct scsi_cmnd *cmd) 284static void __exit sgiwd93_remove(struct platform_device *pdev)
310{ 285{
311 /* FIXME perform bus-specific reset */ 286 struct Scsi_Host *host = platform_get_drvdata(pdev);
287 struct ip22_hostdata *hdata = (struct ip22_hostdata *) host->hostdata;
288 struct sgiwd93_platform_data *pd = pdev->dev.platform_data;
289
290 scsi_remove_host(host);
291 free_irq(pd->irq, host);
292 dma_free_coherent(&pdev->dev, PAGE_SIZE, hdata->hd.cpu, hdata->hd.dma);
293 scsi_host_put(host);
294}
312 295
313 /* FIXME 2: kill this function, and let midlayer fallback 296static struct platform_driver sgiwd93_driver = {
314 to the same result, calling wd33c93_host_reset() */ 297 .probe = sgiwd93_probe,
298 .remove = __devexit_p(sgiwd93_remove),
299 .driver = {
300 .name = "sgiwd93"
301 }
302};
315 303
316 spin_lock_irq(cmd->device->host->host_lock); 304static int __init sgiwd93_module_init(void)
317 wd33c93_host_reset(cmd); 305{
318 spin_unlock_irq(cmd->device->host->host_lock); 306 return platform_driver_register(&sgiwd93_driver);
307}
319 308
320 return SUCCESS; 309static void __exit sgiwd93_module_exit(void)
310{
311 return platform_driver_unregister(&sgiwd93_driver);
321} 312}
322 313
323/* 314module_init(sgiwd93_module_init);
324 * Kludge alert - the SCSI code calls the abort and reset method with int 315module_exit(sgiwd93_module_exit);
325 * arguments not with pointers. So this is going to blow up beautyfully 316
326 * on 64-bit systems with memory outside the compat address spaces. 317MODULE_DESCRIPTION("SGI WD33C93 driver");
327 */ 318MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>");
328static struct scsi_host_template driver_template = { 319MODULE_LICENSE("GPL");
329 .proc_name = "SGIWD93",
330 .name = "SGI WD93",
331 .detect = sgiwd93_detect,
332 .release = sgiwd93_release,
333 .queuecommand = wd33c93_queuecommand,
334 .eh_abort_handler = wd33c93_abort,
335 .eh_bus_reset_handler = sgiwd93_bus_reset,
336 .eh_host_reset_handler = wd33c93_host_reset,
337 .can_queue = 16,
338 .this_id = 7,
339 .sg_tablesize = SG_ALL,
340 .cmd_per_lun = 8,
341 .use_clustering = DISABLE_CLUSTERING,
342};
343#include "scsi_module.c"
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 7c9d37f651e3..5e3f748f2693 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -107,6 +107,13 @@ config SPI_IMX
107 This enables using the Freescale iMX SPI controller in master 107 This enables using the Freescale iMX SPI controller in master
108 mode. 108 mode.
109 109
110config SPI_MPC52xx_PSC
111 tristate "Freescale MPC52xx PSC SPI controller"
112 depends on SPI_MASTER && PPC_MPC52xx && EXPERIMENTAL
113 help
114 This enables using the Freescale MPC52xx Programmable Serial
115 Controller in master SPI mode.
116
110config SPI_MPC83xx 117config SPI_MPC83xx
111 tristate "Freescale MPC83xx SPI controller" 118 tristate "Freescale MPC83xx SPI controller"
112 depends on SPI_MASTER && PPC_83xx && EXPERIMENTAL 119 depends on SPI_MASTER && PPC_83xx && EXPERIMENTAL
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 624b6363f490..5788d867de84 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_SPI_BUTTERFLY) += spi_butterfly.o
19obj-$(CONFIG_SPI_IMX) += spi_imx.o 19obj-$(CONFIG_SPI_IMX) += spi_imx.o
20obj-$(CONFIG_SPI_PXA2XX) += pxa2xx_spi.o 20obj-$(CONFIG_SPI_PXA2XX) += pxa2xx_spi.o
21obj-$(CONFIG_SPI_OMAP_UWIRE) += omap_uwire.o 21obj-$(CONFIG_SPI_OMAP_UWIRE) += omap_uwire.o
22obj-$(CONFIG_SPI_MPC52xx_PSC) += mpc52xx_psc_spi.o
22obj-$(CONFIG_SPI_MPC83xx) += spi_mpc83xx.o 23obj-$(CONFIG_SPI_MPC83xx) += spi_mpc83xx.o
23obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o 24obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o
24obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx.o 25obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx.o
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c
new file mode 100644
index 000000000000..052359fc41ee
--- /dev/null
+++ b/drivers/spi/mpc52xx_psc_spi.c
@@ -0,0 +1,654 @@
1/*
2 * MPC52xx SPC in SPI mode driver.
3 *
4 * Maintainer: Dragos Carp
5 *
6 * Copyright (C) 2006 TOPTICA Photonics AG.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/errno.h>
17#include <linux/interrupt.h>
18
19#if defined(CONFIG_PPC_MERGE)
20#include <asm/of_platform.h>
21#else
22#include <linux/platform_device.h>
23#endif
24
25#include <linux/workqueue.h>
26#include <linux/completion.h>
27#include <linux/io.h>
28#include <linux/delay.h>
29#include <linux/spi/spi.h>
30#include <linux/fsl_devices.h>
31
32#include <asm/mpc52xx.h>
33#include <asm/mpc52xx_psc.h>
34
35#define MCLK 20000000 /* PSC port MClk in hz */
36
37struct mpc52xx_psc_spi {
38 /* fsl_spi_platform data */
39 void (*activate_cs)(u8, u8);
40 void (*deactivate_cs)(u8, u8);
41 u32 sysclk;
42
43 /* driver internal data */
44 struct mpc52xx_psc __iomem *psc;
45 unsigned int irq;
46 u8 bits_per_word;
47 u8 busy;
48
49 struct workqueue_struct *workqueue;
50 struct work_struct work;
51
52 struct list_head queue;
53 spinlock_t lock;
54
55 struct completion done;
56};
57
58/* controller state */
59struct mpc52xx_psc_spi_cs {
60 int bits_per_word;
61 int speed_hz;
62};
63
64/* set clock freq, clock ramp, bits per work
65 * if t is NULL then reset the values to the default values
66 */
67static int mpc52xx_psc_spi_transfer_setup(struct spi_device *spi,
68 struct spi_transfer *t)
69{
70 struct mpc52xx_psc_spi_cs *cs = spi->controller_state;
71
72 cs->speed_hz = (t && t->speed_hz)
73 ? t->speed_hz : spi->max_speed_hz;
74 cs->bits_per_word = (t && t->bits_per_word)
75 ? t->bits_per_word : spi->bits_per_word;
76 cs->bits_per_word = ((cs->bits_per_word + 7) / 8) * 8;
77 return 0;
78}
79
80static void mpc52xx_psc_spi_activate_cs(struct spi_device *spi)
81{
82 struct mpc52xx_psc_spi_cs *cs = spi->controller_state;
83 struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master);
84 struct mpc52xx_psc __iomem *psc = mps->psc;
85 u32 sicr;
86 u16 ccr;
87
88 sicr = in_be32(&psc->sicr);
89
90 /* Set clock phase and polarity */
91 if (spi->mode & SPI_CPHA)
92 sicr |= 0x00001000;
93 else
94 sicr &= ~0x00001000;
95 if (spi->mode & SPI_CPOL)
96 sicr |= 0x00002000;
97 else
98 sicr &= ~0x00002000;
99
100 if (spi->mode & SPI_LSB_FIRST)
101 sicr |= 0x10000000;
102 else
103 sicr &= ~0x10000000;
104 out_be32(&psc->sicr, sicr);
105
106 /* Set clock frequency and bits per word
107 * Because psc->ccr is defined as 16bit register instead of 32bit
108 * just set the lower byte of BitClkDiv
109 */
110 ccr = in_be16(&psc->ccr);
111 ccr &= 0xFF00;
112 if (cs->speed_hz)
113 ccr |= (MCLK / cs->speed_hz - 1) & 0xFF;
114 else /* by default SPI Clk 1MHz */
115 ccr |= (MCLK / 1000000 - 1) & 0xFF;
116 out_be16(&psc->ccr, ccr);
117 mps->bits_per_word = cs->bits_per_word;
118
119 if (mps->activate_cs)
120 mps->activate_cs(spi->chip_select,
121 (spi->mode & SPI_CS_HIGH) ? 1 : 0);
122}
123
124static void mpc52xx_psc_spi_deactivate_cs(struct spi_device *spi)
125{
126 struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master);
127
128 if (mps->deactivate_cs)
129 mps->deactivate_cs(spi->chip_select,
130 (spi->mode & SPI_CS_HIGH) ? 1 : 0);
131}
132
133#define MPC52xx_PSC_BUFSIZE (MPC52xx_PSC_RFNUM_MASK + 1)
134/* wake up when 80% fifo full */
135#define MPC52xx_PSC_RFALARM (MPC52xx_PSC_BUFSIZE * 20 / 100)
136
137static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi,
138 struct spi_transfer *t)
139{
140 struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master);
141 struct mpc52xx_psc __iomem *psc = mps->psc;
142 unsigned rb = 0; /* number of bytes receieved */
143 unsigned sb = 0; /* number of bytes sent */
144 unsigned char *rx_buf = (unsigned char *)t->rx_buf;
145 unsigned char *tx_buf = (unsigned char *)t->tx_buf;
146 unsigned rfalarm;
147 unsigned send_at_once = MPC52xx_PSC_BUFSIZE;
148 unsigned recv_at_once;
149 unsigned bpw = mps->bits_per_word / 8;
150
151 if (!t->tx_buf && !t->rx_buf && t->len)
152 return -EINVAL;
153
154 /* enable transmiter/receiver */
155 out_8(&psc->command, MPC52xx_PSC_TX_ENABLE | MPC52xx_PSC_RX_ENABLE);
156 while (rb < t->len) {
157 if (t->len - rb > MPC52xx_PSC_BUFSIZE) {
158 rfalarm = MPC52xx_PSC_RFALARM;
159 } else {
160 send_at_once = t->len - sb;
161 rfalarm = MPC52xx_PSC_BUFSIZE - (t->len - rb);
162 }
163
164 dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once);
165 if (tx_buf) {
166 for (; send_at_once; sb++, send_at_once--) {
167 /* set EOF flag */
168 if (mps->bits_per_word
169 && (sb + 1) % bpw == 0)
170 out_8(&psc->ircr2, 0x01);
171 out_8(&psc->mpc52xx_psc_buffer_8, tx_buf[sb]);
172 }
173 } else {
174 for (; send_at_once; sb++, send_at_once--) {
175 /* set EOF flag */
176 if (mps->bits_per_word
177 && ((sb + 1) % bpw) == 0)
178 out_8(&psc->ircr2, 0x01);
179 out_8(&psc->mpc52xx_psc_buffer_8, 0);
180 }
181 }
182
183
184 /* enable interupts and wait for wake up
185 * if just one byte is expected the Rx FIFO genererates no
186 * FFULL interrupt, so activate the RxRDY interrupt
187 */
188 out_8(&psc->command, MPC52xx_PSC_SEL_MODE_REG_1);
189 if (t->len - rb == 1) {
190 out_8(&psc->mode, 0);
191 } else {
192 out_8(&psc->mode, MPC52xx_PSC_MODE_FFULL);
193 out_be16(&psc->rfalarm, rfalarm);
194 }
195 out_be16(&psc->mpc52xx_psc_imr, MPC52xx_PSC_IMR_RXRDY);
196 wait_for_completion(&mps->done);
197 recv_at_once = in_be16(&psc->rfnum);
198 dev_dbg(&spi->dev, "%d bytes received\n", recv_at_once);
199
200 send_at_once = recv_at_once;
201 if (rx_buf) {
202 for (; recv_at_once; rb++, recv_at_once--)
203 rx_buf[rb] = in_8(&psc->mpc52xx_psc_buffer_8);
204 } else {
205 for (; recv_at_once; rb++, recv_at_once--)
206 in_8(&psc->mpc52xx_psc_buffer_8);
207 }
208 }
209 /* disable transmiter/receiver */
210 out_8(&psc->command, MPC52xx_PSC_TX_DISABLE | MPC52xx_PSC_RX_DISABLE);
211
212 return 0;
213}
214
215static void mpc52xx_psc_spi_work(struct work_struct *work)
216{
217 struct mpc52xx_psc_spi *mps =
218 container_of(work, struct mpc52xx_psc_spi, work);
219
220 spin_lock_irq(&mps->lock);
221 mps->busy = 1;
222 while (!list_empty(&mps->queue)) {
223 struct spi_message *m;
224 struct spi_device *spi;
225 struct spi_transfer *t = NULL;
226 unsigned cs_change;
227 int status;
228
229 m = container_of(mps->queue.next, struct spi_message, queue);
230 list_del_init(&m->queue);
231 spin_unlock_irq(&mps->lock);
232
233 spi = m->spi;
234 cs_change = 1;
235 status = 0;
236 list_for_each_entry (t, &m->transfers, transfer_list) {
237 if (t->bits_per_word || t->speed_hz) {
238 status = mpc52xx_psc_spi_transfer_setup(spi, t);
239 if (status < 0)
240 break;
241 }
242
243 if (cs_change)
244 mpc52xx_psc_spi_activate_cs(spi);
245 cs_change = t->cs_change;
246
247 status = mpc52xx_psc_spi_transfer_rxtx(spi, t);
248 if (status)
249 break;
250 m->actual_length += t->len;
251
252 if (t->delay_usecs)
253 udelay(t->delay_usecs);
254
255 if (cs_change)
256 mpc52xx_psc_spi_deactivate_cs(spi);
257 }
258
259 m->status = status;
260 m->complete(m->context);
261
262 if (status || !cs_change)
263 mpc52xx_psc_spi_deactivate_cs(spi);
264
265 mpc52xx_psc_spi_transfer_setup(spi, NULL);
266
267 spin_lock_irq(&mps->lock);
268 }
269 mps->busy = 0;
270 spin_unlock_irq(&mps->lock);
271}
272
273static int mpc52xx_psc_spi_setup(struct spi_device *spi)
274{
275 struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master);
276 struct mpc52xx_psc_spi_cs *cs = spi->controller_state;
277 unsigned long flags;
278
279 if (spi->bits_per_word%8)
280 return -EINVAL;
281
282 if (!cs) {
283 cs = kzalloc(sizeof *cs, GFP_KERNEL);
284 if (!cs)
285 return -ENOMEM;
286 spi->controller_state = cs;
287 }
288
289 cs->bits_per_word = spi->bits_per_word;
290 cs->speed_hz = spi->max_speed_hz;
291
292 spin_lock_irqsave(&mps->lock, flags);
293 if (!mps->busy)
294 mpc52xx_psc_spi_deactivate_cs(spi);
295 spin_unlock_irqrestore(&mps->lock, flags);
296
297 return 0;
298}
299
300static int mpc52xx_psc_spi_transfer(struct spi_device *spi,
301 struct spi_message *m)
302{
303 struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master);
304 unsigned long flags;
305
306 m->actual_length = 0;
307 m->status = -EINPROGRESS;
308
309 spin_lock_irqsave(&mps->lock, flags);
310 list_add_tail(&m->queue, &mps->queue);
311 queue_work(mps->workqueue, &mps->work);
312 spin_unlock_irqrestore(&mps->lock, flags);
313
314 return 0;
315}
316
317static void mpc52xx_psc_spi_cleanup(struct spi_device *spi)
318{
319 kfree(spi->controller_state);
320}
321
322static int mpc52xx_psc_spi_port_config(int psc_id, struct mpc52xx_psc_spi *mps)
323{
324 struct mpc52xx_cdm __iomem *cdm;
325 struct mpc52xx_gpio __iomem *gpio;
326 struct mpc52xx_psc __iomem *psc = mps->psc;
327 u32 ul;
328 u32 mclken_div;
329 int ret = 0;
330
331#if defined(CONFIG_PPC_MERGE)
332 cdm = mpc52xx_find_and_map("mpc52xx-cdm");
333 gpio = mpc52xx_find_and_map("mpc52xx-gpio");
334#else
335 cdm = ioremap(MPC52xx_PA(MPC52xx_CDM_OFFSET), MPC52xx_CDM_SIZE);
336 gpio = ioremap(MPC52xx_PA(MPC52xx_GPIO_OFFSET), MPC52xx_GPIO_SIZE);
337#endif
338 if (!cdm || !gpio) {
339 printk(KERN_ERR "Error mapping CDM/GPIO\n");
340 ret = -EFAULT;
341 goto unmap_regs;
342 }
343
344 /* default sysclk is 512MHz */
345 mclken_div = 0x8000 |
346 (((mps->sysclk ? mps->sysclk : 512000000) / MCLK) & 0x1FF);
347
348 switch (psc_id) {
349 case 1:
350 ul = in_be32(&gpio->port_config);
351 ul &= 0xFFFFFFF8;
352 ul |= 0x00000006;
353 out_be32(&gpio->port_config, ul);
354 out_be16(&cdm->mclken_div_psc1, mclken_div);
355 ul = in_be32(&cdm->clk_enables);
356 ul |= 0x00000020;
357 out_be32(&cdm->clk_enables, ul);
358 break;
359 case 2:
360 ul = in_be32(&gpio->port_config);
361 ul &= 0xFFFFFF8F;
362 ul |= 0x00000060;
363 out_be32(&gpio->port_config, ul);
364 out_be16(&cdm->mclken_div_psc2, mclken_div);
365 ul = in_be32(&cdm->clk_enables);
366 ul |= 0x00000040;
367 out_be32(&cdm->clk_enables, ul);
368 break;
369 case 3:
370 ul = in_be32(&gpio->port_config);
371 ul &= 0xFFFFF0FF;
372 ul |= 0x00000600;
373 out_be32(&gpio->port_config, ul);
374 out_be16(&cdm->mclken_div_psc3, mclken_div);
375 ul = in_be32(&cdm->clk_enables);
376 ul |= 0x00000080;
377 out_be32(&cdm->clk_enables, ul);
378 break;
379 case 6:
380 ul = in_be32(&gpio->port_config);
381 ul &= 0xFF8FFFFF;
382 ul |= 0x00700000;
383 out_be32(&gpio->port_config, ul);
384 out_be16(&cdm->mclken_div_psc6, mclken_div);
385 ul = in_be32(&cdm->clk_enables);
386 ul |= 0x00000010;
387 out_be32(&cdm->clk_enables, ul);
388 break;
389 default:
390 ret = -EINVAL;
391 goto unmap_regs;
392 }
393
394 /* Reset the PSC into a known state */
395 out_8(&psc->command, MPC52xx_PSC_RST_RX);
396 out_8(&psc->command, MPC52xx_PSC_RST_TX);
397 out_8(&psc->command, MPC52xx_PSC_TX_DISABLE | MPC52xx_PSC_RX_DISABLE);
398
399 /* Disable interrupts, interrupts are based on alarm level */
400 out_be16(&psc->mpc52xx_psc_imr, 0);
401 out_8(&psc->command, MPC52xx_PSC_SEL_MODE_REG_1);
402 out_8(&psc->rfcntl, 0);
403 out_8(&psc->mode, MPC52xx_PSC_MODE_FFULL);
404
405 /* Configure 8bit codec mode as a SPI master and use EOF flags */
406 /* SICR_SIM_CODEC8|SICR_GENCLK|SICR_SPI|SICR_MSTR|SICR_USEEOF */
407 out_be32(&psc->sicr, 0x0180C800);
408 out_be16(&psc->ccr, 0x070F); /* by default SPI Clk 1MHz */
409
410 /* Set 2ms DTL delay */
411 out_8(&psc->ctur, 0x00);
412 out_8(&psc->ctlr, 0x84);
413
414 mps->bits_per_word = 8;
415
416unmap_regs:
417 if (cdm)
418 iounmap(cdm);
419 if (gpio)
420 iounmap(gpio);
421
422 return ret;
423}
424
425static irqreturn_t mpc52xx_psc_spi_isr(int irq, void *dev_id)
426{
427 struct mpc52xx_psc_spi *mps = (struct mpc52xx_psc_spi *)dev_id;
428 struct mpc52xx_psc __iomem *psc = mps->psc;
429
430 /* disable interrupt and wake up the work queue */
431 if (in_be16(&psc->mpc52xx_psc_isr) & MPC52xx_PSC_IMR_RXRDY) {
432 out_be16(&psc->mpc52xx_psc_imr, 0);
433 complete(&mps->done);
434 return IRQ_HANDLED;
435 }
436 return IRQ_NONE;
437}
438
439/* bus_num is used only for the case dev->platform_data == NULL */
440static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr,
441 u32 size, unsigned int irq, s16 bus_num)
442{
443 struct fsl_spi_platform_data *pdata = dev->platform_data;
444 struct mpc52xx_psc_spi *mps;
445 struct spi_master *master;
446 int ret;
447
448 if (pdata == NULL)
449 return -ENODEV;
450
451 master = spi_alloc_master(dev, sizeof *mps);
452 if (master == NULL)
453 return -ENOMEM;
454
455 dev_set_drvdata(dev, master);
456 mps = spi_master_get_devdata(master);
457
458 mps->irq = irq;
459 if (pdata == NULL) {
460 dev_warn(dev, "probe called without platform data, no "
461 "(de)activate_cs function will be called\n");
462 mps->activate_cs = NULL;
463 mps->deactivate_cs = NULL;
464 mps->sysclk = 0;
465 master->bus_num = bus_num;
466 master->num_chipselect = 255;
467 } else {
468 mps->activate_cs = pdata->activate_cs;
469 mps->deactivate_cs = pdata->deactivate_cs;
470 mps->sysclk = pdata->sysclk;
471 master->bus_num = pdata->bus_num;
472 master->num_chipselect = pdata->max_chipselect;
473 }
474 master->setup = mpc52xx_psc_spi_setup;
475 master->transfer = mpc52xx_psc_spi_transfer;
476 master->cleanup = mpc52xx_psc_spi_cleanup;
477
478 mps->psc = ioremap(regaddr, size);
479 if (!mps->psc) {
480 dev_err(dev, "could not ioremap I/O port range\n");
481 ret = -EFAULT;
482 goto free_master;
483 }
484
485 ret = request_irq(mps->irq, mpc52xx_psc_spi_isr, 0, "mpc52xx-psc-spi",
486 mps);
487 if (ret)
488 goto free_master;
489
490 ret = mpc52xx_psc_spi_port_config(master->bus_num, mps);
491 if (ret < 0)
492 goto free_irq;
493
494 spin_lock_init(&mps->lock);
495 init_completion(&mps->done);
496 INIT_WORK(&mps->work, mpc52xx_psc_spi_work);
497 INIT_LIST_HEAD(&mps->queue);
498
499 mps->workqueue = create_singlethread_workqueue(
500 master->cdev.dev->bus_id);
501 if (mps->workqueue == NULL) {
502 ret = -EBUSY;
503 goto free_irq;
504 }
505
506 ret = spi_register_master(master);
507 if (ret < 0)
508 goto unreg_master;
509
510 return ret;
511
512unreg_master:
513 destroy_workqueue(mps->workqueue);
514free_irq:
515 free_irq(mps->irq, mps);
516free_master:
517 if (mps->psc)
518 iounmap(mps->psc);
519 spi_master_put(master);
520
521 return ret;
522}
523
524static int __exit mpc52xx_psc_spi_do_remove(struct device *dev)
525{
526 struct spi_master *master = dev_get_drvdata(dev);
527 struct mpc52xx_psc_spi *mps = spi_master_get_devdata(master);
528
529 flush_workqueue(mps->workqueue);
530 destroy_workqueue(mps->workqueue);
531 spi_unregister_master(master);
532 free_irq(mps->irq, mps);
533 if (mps->psc)
534 iounmap(mps->psc);
535
536 return 0;
537}
538
539#if !defined(CONFIG_PPC_MERGE)
540static int __init mpc52xx_psc_spi_probe(struct platform_device *dev)
541{
542 switch(dev->id) {
543 case 1:
544 case 2:
545 case 3:
546 case 6:
547 return mpc52xx_psc_spi_do_probe(&dev->dev,
548 MPC52xx_PA(MPC52xx_PSCx_OFFSET(dev->id)),
549 MPC52xx_PSC_SIZE, platform_get_irq(dev, 0), dev->id);
550 default:
551 return -EINVAL;
552 }
553}
554
555static int __exit mpc52xx_psc_spi_remove(struct platform_device *dev)
556{
557 return mpc52xx_psc_spi_do_remove(&dev->dev);
558}
559
560static struct platform_driver mpc52xx_psc_spi_platform_driver = {
561 .remove = __exit_p(mpc52xx_psc_spi_remove),
562 .driver = {
563 .name = "mpc52xx-psc-spi",
564 .owner = THIS_MODULE,
565 },
566};
567
568static int __init mpc52xx_psc_spi_init(void)
569{
570 return platform_driver_probe(&mpc52xx_psc_spi_platform_driver,
571 mpc52xx_psc_spi_probe);
572}
573module_init(mpc52xx_psc_spi_init);
574
575static void __exit mpc52xx_psc_spi_exit(void)
576{
577 platform_driver_unregister(&mpc52xx_psc_spi_platform_driver);
578}
579module_exit(mpc52xx_psc_spi_exit);
580
581#else /* defined(CONFIG_PPC_MERGE) */
582
583static int __init mpc52xx_psc_spi_of_probe(struct of_device *op,
584 const struct of_device_id *match)
585{
586 const u32 *regaddr_p;
587 u64 regaddr64, size64;
588 s16 id = -1;
589
590 regaddr_p = of_get_address(op->node, 0, &size64, NULL);
591 if (!regaddr_p) {
592 printk(KERN_ERR "Invalid PSC address\n");
593 return -EINVAL;
594 }
595 regaddr64 = of_translate_address(op->node, regaddr_p);
596
597 if (op->dev.platform_data == NULL) {
598 struct device_node *np;
599 int i = 0;
600
601 for_each_node_by_type(np, "spi") {
602 if (of_find_device_by_node(np) == op) {
603 id = i;
604 break;
605 }
606 i++;
607 }
608 }
609
610 return mpc52xx_psc_spi_do_probe(&op->dev, (u32)regaddr64, (u32)size64,
611 irq_of_parse_and_map(op->node, 0), id);
612}
613
614static int __exit mpc52xx_psc_spi_of_remove(struct of_device *op)
615{
616 return mpc52xx_psc_spi_do_remove(&op->dev);
617}
618
619static struct of_device_id mpc52xx_psc_spi_of_match[] = {
620 { .type = "spi", .compatible = "mpc52xx-psc-spi", },
621 {},
622};
623
624MODULE_DEVICE_TABLE(of, mpc52xx_psc_spi_of_match);
625
626static struct of_platform_driver mpc52xx_psc_spi_of_driver = {
627 .owner = THIS_MODULE,
628 .name = "mpc52xx-psc-spi",
629 .match_table = mpc52xx_psc_spi_of_match,
630 .probe = mpc52xx_psc_spi_of_probe,
631 .remove = __exit_p(mpc52xx_psc_spi_of_remove),
632 .driver = {
633 .name = "mpc52xx-psc-spi",
634 .owner = THIS_MODULE,
635 },
636};
637
638static int __init mpc52xx_psc_spi_init(void)
639{
640 return of_register_platform_driver(&mpc52xx_psc_spi_of_driver);
641}
642module_init(mpc52xx_psc_spi_init);
643
644static void __exit mpc52xx_psc_spi_exit(void)
645{
646 of_unregister_platform_driver(&mpc52xx_psc_spi_of_driver);
647}
648module_exit(mpc52xx_psc_spi_exit);
649
650#endif /* defined(CONFIG_PPC_MERGE) */
651
652MODULE_AUTHOR("Dragos Carp");
653MODULE_DESCRIPTION("MPC52xx PSC SPI Driver");
654MODULE_LICENSE("GPL");
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index f54438828cb9..eebcb708cff1 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -748,6 +748,22 @@ config FB_S1D13XXX
748 working with S1D13806). Product specs at 748 working with S1D13806). Product specs at
749 <http://www.erd.epson.com/vdc/html/legacy_13xxx.htm> 749 <http://www.erd.epson.com/vdc/html/legacy_13xxx.htm>
750 750
751config FB_ATMEL
752 tristate "AT91/AT32 LCD Controller support"
753 depends on FB && (ARCH_AT91SAM9261 || ARCH_AT91SAM9263 || AVR32)
754 select FB_CFB_FILLRECT
755 select FB_CFB_COPYAREA
756 select FB_CFB_IMAGEBLIT
757 help
758 This enables support for the AT91/AT32 LCD Controller.
759
760config FB_INTSRAM
761 bool "Frame Buffer in internal SRAM"
762 depends on FB_ATMEL && ARCH_AT91SAM9261
763 help
764 Say Y if you want to map Frame Buffer in internal SRAM. Say N if you want
765 to let frame buffer in external SDRAM.
766
751config FB_NVIDIA 767config FB_NVIDIA
752 tristate "nVidia Framebuffer Support" 768 tristate "nVidia Framebuffer Support"
753 depends on FB && PCI 769 depends on FB && PCI
@@ -780,6 +796,15 @@ config FB_NVIDIA_I2C
780 independently validate video mode parameters, you should say Y 796 independently validate video mode parameters, you should say Y
781 here. 797 here.
782 798
799config FB_NVIDIA_DEBUG
800 bool "Lots of debug output"
801 depends on FB_NVIDIA
802 default n
803 help
804 Say Y here if you want the nVidia driver to output all sorts
805 of debugging information to provide to the maintainer when
806 something goes wrong.
807
783config FB_NVIDIA_BACKLIGHT 808config FB_NVIDIA_BACKLIGHT
784 bool "Support for backlight control" 809 bool "Support for backlight control"
785 depends on FB_NVIDIA 810 depends on FB_NVIDIA
@@ -819,7 +844,7 @@ config FB_RIVA_I2C
819 here. 844 here.
820 845
821config FB_RIVA_DEBUG 846config FB_RIVA_DEBUG
822 bool "Lots of debug output from Riva(nVidia) driver" 847 bool "Lots of debug output"
823 depends on FB_RIVA 848 depends on FB_RIVA
824 default n 849 default n
825 help 850 help
@@ -1431,8 +1456,11 @@ config FB_ARK
1431 and ICS 5342 RAMDAC. 1456 and ICS 5342 RAMDAC.
1432 1457
1433config FB_PM3 1458config FB_PM3
1434 tristate "Permedia3 support" 1459 tristate "Permedia3 support (EXPERIMENTAL)"
1435 depends on FB && PCI && BROKEN 1460 depends on FB && PCI && EXPERIMENTAL
1461 select FB_CFB_FILLRECT
1462 select FB_CFB_COPYAREA
1463 select FB_CFB_IMAGEBLIT
1436 help 1464 help
1437 This is the frame buffer device driver for the 3DLabs Permedia3 1465 This is the frame buffer device driver for the 3DLabs Permedia3
1438 chipset, used in Formac ProFormance III, 3DLabs Oxygen VX1 & 1466 chipset, used in Formac ProFormance III, 3DLabs Oxygen VX1 &
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 0b70567458fb..bd8b05229500 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -87,6 +87,7 @@ obj-$(CONFIG_FB_G364) += g364fb.o
87obj-$(CONFIG_FB_SA1100) += sa1100fb.o 87obj-$(CONFIG_FB_SA1100) += sa1100fb.o
88obj-$(CONFIG_FB_HIT) += hitfb.o 88obj-$(CONFIG_FB_HIT) += hitfb.o
89obj-$(CONFIG_FB_EPSON1355) += epson1355fb.o 89obj-$(CONFIG_FB_EPSON1355) += epson1355fb.o
90obj-$(CONFIG_FB_ATMEL) += atmel_lcdfb.o
90obj-$(CONFIG_FB_PVR2) += pvr2fb.o 91obj-$(CONFIG_FB_PVR2) += pvr2fb.o
91obj-$(CONFIG_FB_VOODOO1) += sstfb.o 92obj-$(CONFIG_FB_VOODOO1) += sstfb.o
92obj-$(CONFIG_FB_ARMCLCD) += amba-clcd.o 93obj-$(CONFIG_FB_ARMCLCD) += amba-clcd.o
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
new file mode 100644
index 000000000000..e1d5bd0c98c4
--- /dev/null
+++ b/drivers/video/atmel_lcdfb.c
@@ -0,0 +1,752 @@
1/*
2 * Driver for AT91/AT32 LCD Controller
3 *
4 * Copyright (C) 2007 Atmel Corporation
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive for
8 * more details.
9 */
10
11#include <linux/kernel.h>
12#include <linux/platform_device.h>
13#include <linux/dma-mapping.h>
14#include <linux/interrupt.h>
15#include <linux/clk.h>
16#include <linux/fb.h>
17#include <linux/init.h>
18#include <linux/delay.h>
19
20#include <asm/arch/board.h>
21#include <asm/arch/cpu.h>
22#include <asm/arch/gpio.h>
23
24#include <video/atmel_lcdc.h>
25
26#define lcdc_readl(sinfo, reg) __raw_readl((sinfo)->mmio+(reg))
27#define lcdc_writel(sinfo, reg, val) __raw_writel((val), (sinfo)->mmio+(reg))
28
29/* configurable parameters */
30#define ATMEL_LCDC_CVAL_DEFAULT 0xc8
31#define ATMEL_LCDC_DMA_BURST_LEN 8
32
33#if defined(CONFIG_ARCH_AT91SAM9263)
34#define ATMEL_LCDC_FIFO_SIZE 2048
35#else
36#define ATMEL_LCDC_FIFO_SIZE 512
37#endif
38
39#if defined(CONFIG_ARCH_AT91)
40#define ATMEL_LCDFB_FBINFO_DEFAULT FBINFO_DEFAULT
41
42static inline void atmel_lcdfb_update_dma2d(struct atmel_lcdfb_info *sinfo,
43 struct fb_var_screeninfo *var)
44{
45
46}
47#elif defined(CONFIG_AVR32)
48#define ATMEL_LCDFB_FBINFO_DEFAULT (FBINFO_DEFAULT \
49 | FBINFO_PARTIAL_PAN_OK \
50 | FBINFO_HWACCEL_XPAN \
51 | FBINFO_HWACCEL_YPAN)
52
53static void atmel_lcdfb_update_dma2d(struct atmel_lcdfb_info *sinfo,
54 struct fb_var_screeninfo *var)
55{
56 u32 dma2dcfg;
57 u32 pixeloff;
58
59 pixeloff = (var->xoffset * var->bits_per_pixel) & 0x1f;
60
61 dma2dcfg = ((var->xres_virtual - var->xres) * var->bits_per_pixel) / 8;
62 dma2dcfg |= pixeloff << ATMEL_LCDC_PIXELOFF_OFFSET;
63 lcdc_writel(sinfo, ATMEL_LCDC_DMA2DCFG, dma2dcfg);
64
65 /* Update configuration */
66 lcdc_writel(sinfo, ATMEL_LCDC_DMACON,
67 lcdc_readl(sinfo, ATMEL_LCDC_DMACON)
68 | ATMEL_LCDC_DMAUPDT);
69}
70#endif
71
72
73static struct fb_fix_screeninfo atmel_lcdfb_fix __initdata = {
74 .type = FB_TYPE_PACKED_PIXELS,
75 .visual = FB_VISUAL_TRUECOLOR,
76 .xpanstep = 0,
77 .ypanstep = 0,
78 .ywrapstep = 0,
79 .accel = FB_ACCEL_NONE,
80};
81
82
83static void atmel_lcdfb_update_dma(struct fb_info *info,
84 struct fb_var_screeninfo *var)
85{
86 struct atmel_lcdfb_info *sinfo = info->par;
87 struct fb_fix_screeninfo *fix = &info->fix;
88 unsigned long dma_addr;
89
90 dma_addr = (fix->smem_start + var->yoffset * fix->line_length
91 + var->xoffset * var->bits_per_pixel / 8);
92
93 dma_addr &= ~3UL;
94
95 /* Set framebuffer DMA base address and pixel offset */
96 lcdc_writel(sinfo, ATMEL_LCDC_DMABADDR1, dma_addr);
97
98 atmel_lcdfb_update_dma2d(sinfo, var);
99}
100
101static inline void atmel_lcdfb_free_video_memory(struct atmel_lcdfb_info *sinfo)
102{
103 struct fb_info *info = sinfo->info;
104
105 dma_free_writecombine(info->device, info->fix.smem_len,
106 info->screen_base, info->fix.smem_start);
107}
108
109/**
110 * atmel_lcdfb_alloc_video_memory - Allocate framebuffer memory
111 * @sinfo: the frame buffer to allocate memory for
112 */
113static int atmel_lcdfb_alloc_video_memory(struct atmel_lcdfb_info *sinfo)
114{
115 struct fb_info *info = sinfo->info;
116 struct fb_var_screeninfo *var = &info->var;
117
118 info->fix.smem_len = (var->xres_virtual * var->yres_virtual
119 * ((var->bits_per_pixel + 7) / 8));
120
121 info->screen_base = dma_alloc_writecombine(info->device, info->fix.smem_len,
122 (dma_addr_t *)&info->fix.smem_start, GFP_KERNEL);
123
124 if (!info->screen_base) {
125 return -ENOMEM;
126 }
127
128 return 0;
129}
130
131/**
132 * atmel_lcdfb_check_var - Validates a var passed in.
133 * @var: frame buffer variable screen structure
134 * @info: frame buffer structure that represents a single frame buffer
135 *
136 * Checks to see if the hardware supports the state requested by
137 * var passed in. This function does not alter the hardware
138 * state!!! This means the data stored in struct fb_info and
139 * struct atmel_lcdfb_info do not change. This includes the var
140 * inside of struct fb_info. Do NOT change these. This function
141 * can be called on its own if we intent to only test a mode and
142 * not actually set it. The stuff in modedb.c is a example of
143 * this. If the var passed in is slightly off by what the
144 * hardware can support then we alter the var PASSED in to what
145 * we can do. If the hardware doesn't support mode change a
146 * -EINVAL will be returned by the upper layers. You don't need
147 * to implement this function then. If you hardware doesn't
148 * support changing the resolution then this function is not
149 * needed. In this case the driver would just provide a var that
150 * represents the static state the screen is in.
151 *
152 * Returns negative errno on error, or zero on success.
153 */
154static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var,
155 struct fb_info *info)
156{
157 struct device *dev = info->device;
158 struct atmel_lcdfb_info *sinfo = info->par;
159 unsigned long clk_value_khz;
160
161 clk_value_khz = clk_get_rate(sinfo->lcdc_clk) / 1000;
162
163 dev_dbg(dev, "%s:\n", __func__);
164 dev_dbg(dev, " resolution: %ux%u\n", var->xres, var->yres);
165 dev_dbg(dev, " pixclk: %lu KHz\n", PICOS2KHZ(var->pixclock));
166 dev_dbg(dev, " bpp: %u\n", var->bits_per_pixel);
167 dev_dbg(dev, " clk: %lu KHz\n", clk_value_khz);
168
169 if ((PICOS2KHZ(var->pixclock) * var->bits_per_pixel / 8) > clk_value_khz) {
170 dev_err(dev, "%lu KHz pixel clock is too fast\n", PICOS2KHZ(var->pixclock));
171 return -EINVAL;
172 }
173
174 /* Force same alignment for each line */
175 var->xres = (var->xres + 3) & ~3UL;
176 var->xres_virtual = (var->xres_virtual + 3) & ~3UL;
177
178 var->red.msb_right = var->green.msb_right = var->blue.msb_right = 0;
179 var->transp.msb_right = 0;
180 var->transp.offset = var->transp.length = 0;
181 var->xoffset = var->yoffset = 0;
182
183 switch (var->bits_per_pixel) {
184 case 2:
185 case 4:
186 case 8:
187 var->red.offset = var->green.offset = var->blue.offset = 0;
188 var->red.length = var->green.length = var->blue.length
189 = var->bits_per_pixel;
190 break;
191 case 15:
192 case 16:
193 var->red.offset = 0;
194 var->green.offset = 5;
195 var->blue.offset = 10;
196 var->red.length = var->green.length = var->blue.length = 5;
197 break;
198 case 24:
199 case 32:
200 var->red.offset = 0;
201 var->green.offset = 8;
202 var->blue.offset = 16;
203 var->red.length = var->green.length = var->blue.length = 8;
204 break;
205 default:
206 dev_err(dev, "color depth %d not supported\n",
207 var->bits_per_pixel);
208 return -EINVAL;
209 }
210
211 return 0;
212}
213
214/**
215 * atmel_lcdfb_set_par - Alters the hardware state.
216 * @info: frame buffer structure that represents a single frame buffer
217 *
218 * Using the fb_var_screeninfo in fb_info we set the resolution
219 * of the this particular framebuffer. This function alters the
220 * par AND the fb_fix_screeninfo stored in fb_info. It doesn't
221 * not alter var in fb_info since we are using that data. This
222 * means we depend on the data in var inside fb_info to be
223 * supported by the hardware. atmel_lcdfb_check_var is always called
224 * before atmel_lcdfb_set_par to ensure this. Again if you can't
225 * change the resolution you don't need this function.
226 *
227 */
228static int atmel_lcdfb_set_par(struct fb_info *info)
229{
230 struct atmel_lcdfb_info *sinfo = info->par;
231 unsigned long value;
232 unsigned long clk_value_khz;
233
234 dev_dbg(info->device, "%s:\n", __func__);
235 dev_dbg(info->device, " * resolution: %ux%u (%ux%u virtual)\n",
236 info->var.xres, info->var.yres,
237 info->var.xres_virtual, info->var.yres_virtual);
238
239 /* Turn off the LCD controller and the DMA controller */
240 lcdc_writel(sinfo, ATMEL_LCDC_PWRCON, sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET);
241
242 lcdc_writel(sinfo, ATMEL_LCDC_DMACON, 0);
243
244 if (info->var.bits_per_pixel <= 8)
245 info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
246 else
247 info->fix.visual = FB_VISUAL_TRUECOLOR;
248
249 info->fix.line_length = info->var.xres_virtual * (info->var.bits_per_pixel / 8);
250
251 /* Re-initialize the DMA engine... */
252 dev_dbg(info->device, " * update DMA engine\n");
253 atmel_lcdfb_update_dma(info, &info->var);
254
255 /* ...set frame size and burst length = 8 words (?) */
256 value = (info->var.yres * info->var.xres * info->var.bits_per_pixel) / 32;
257 value |= ((ATMEL_LCDC_DMA_BURST_LEN - 1) << ATMEL_LCDC_BLENGTH_OFFSET);
258 lcdc_writel(sinfo, ATMEL_LCDC_DMAFRMCFG, value);
259
260 /* Now, the LCDC core... */
261
262 /* Set pixel clock */
263 clk_value_khz = clk_get_rate(sinfo->lcdc_clk) / 1000;
264
265 value = clk_value_khz / PICOS2KHZ(info->var.pixclock);
266
267 if (clk_value_khz % PICOS2KHZ(info->var.pixclock))
268 value++;
269
270 value = (value / 2) - 1;
271
272 if (value <= 0) {
273 dev_notice(info->device, "Bypassing pixel clock divider\n");
274 lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, ATMEL_LCDC_BYPASS);
275 } else
276 lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, value << ATMEL_LCDC_CLKVAL_OFFSET);
277
278 /* Initialize control register 2 */
279 value = sinfo->default_lcdcon2;
280
281 if (!(info->var.sync & FB_SYNC_HOR_HIGH_ACT))
282 value |= ATMEL_LCDC_INVLINE_INVERTED;
283 if (!(info->var.sync & FB_SYNC_VERT_HIGH_ACT))
284 value |= ATMEL_LCDC_INVFRAME_INVERTED;
285
286 switch (info->var.bits_per_pixel) {
287 case 1: value |= ATMEL_LCDC_PIXELSIZE_1; break;
288 case 2: value |= ATMEL_LCDC_PIXELSIZE_2; break;
289 case 4: value |= ATMEL_LCDC_PIXELSIZE_4; break;
290 case 8: value |= ATMEL_LCDC_PIXELSIZE_8; break;
291 case 15: /* fall through */
292 case 16: value |= ATMEL_LCDC_PIXELSIZE_16; break;
293 case 24: value |= ATMEL_LCDC_PIXELSIZE_24; break;
294 case 32: value |= ATMEL_LCDC_PIXELSIZE_32; break;
295 default: BUG(); break;
296 }
297 dev_dbg(info->device, " * LCDCON2 = %08lx\n", value);
298 lcdc_writel(sinfo, ATMEL_LCDC_LCDCON2, value);
299
300 /* Vertical timing */
301 value = (info->var.vsync_len - 1) << ATMEL_LCDC_VPW_OFFSET;
302 value |= info->var.upper_margin << ATMEL_LCDC_VBP_OFFSET;
303 value |= info->var.lower_margin;
304 dev_dbg(info->device, " * LCDTIM1 = %08lx\n", value);
305 lcdc_writel(sinfo, ATMEL_LCDC_TIM1, value);
306
307 /* Horizontal timing */
308 value = (info->var.right_margin - 1) << ATMEL_LCDC_HFP_OFFSET;
309 value |= (info->var.hsync_len - 1) << ATMEL_LCDC_HPW_OFFSET;
310 value |= (info->var.left_margin - 1);
311 dev_dbg(info->device, " * LCDTIM2 = %08lx\n", value);
312 lcdc_writel(sinfo, ATMEL_LCDC_TIM2, value);
313
314 /* Display size */
315 value = (info->var.xres - 1) << ATMEL_LCDC_HOZVAL_OFFSET;
316 value |= info->var.yres - 1;
317 lcdc_writel(sinfo, ATMEL_LCDC_LCDFRMCFG, value);
318
319 /* FIFO Threshold: Use formula from data sheet */
320 value = ATMEL_LCDC_FIFO_SIZE - (2 * ATMEL_LCDC_DMA_BURST_LEN + 3);
321 lcdc_writel(sinfo, ATMEL_LCDC_FIFO, value);
322
323 /* Toggle LCD_MODE every frame */
324 lcdc_writel(sinfo, ATMEL_LCDC_MVAL, 0);
325
326 /* Disable all interrupts */
327 lcdc_writel(sinfo, ATMEL_LCDC_IDR, ~0UL);
328
329 /* Set contrast */
330 value = ATMEL_LCDC_PS_DIV8 | ATMEL_LCDC_POL_POSITIVE | ATMEL_LCDC_ENA_PWMENABLE;
331 lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, value);
332 lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_VAL, ATMEL_LCDC_CVAL_DEFAULT);
333 /* ...wait for DMA engine to become idle... */
334 while (lcdc_readl(sinfo, ATMEL_LCDC_DMACON) & ATMEL_LCDC_DMABUSY)
335 msleep(10);
336
337 dev_dbg(info->device, " * re-enable DMA engine\n");
338 /* ...and enable it with updated configuration */
339 lcdc_writel(sinfo, ATMEL_LCDC_DMACON, sinfo->default_dmacon);
340
341 dev_dbg(info->device, " * re-enable LCDC core\n");
342 lcdc_writel(sinfo, ATMEL_LCDC_PWRCON,
343 (sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET) | ATMEL_LCDC_PWR);
344
345 dev_dbg(info->device, " * DONE\n");
346
347 return 0;
348}
349
350static inline unsigned int chan_to_field(unsigned int chan, const struct fb_bitfield *bf)
351{
352 chan &= 0xffff;
353 chan >>= 16 - bf->length;
354 return chan << bf->offset;
355}
356
357/**
358 * atmel_lcdfb_setcolreg - Optional function. Sets a color register.
359 * @regno: Which register in the CLUT we are programming
360 * @red: The red value which can be up to 16 bits wide
361 * @green: The green value which can be up to 16 bits wide
362 * @blue: The blue value which can be up to 16 bits wide.
363 * @transp: If supported the alpha value which can be up to 16 bits wide.
364 * @info: frame buffer info structure
365 *
366 * Set a single color register. The values supplied have a 16 bit
367 * magnitude which needs to be scaled in this function for the hardware.
368 * Things to take into consideration are how many color registers, if
369 * any, are supported with the current color visual. With truecolor mode
370 * no color palettes are supported. Here a psuedo palette is created
371 * which we store the value in pseudo_palette in struct fb_info. For
372 * pseudocolor mode we have a limited color palette. To deal with this
373 * we can program what color is displayed for a particular pixel value.
374 * DirectColor is similar in that we can program each color field. If
375 * we have a static colormap we don't need to implement this function.
376 *
377 * Returns negative errno on error, or zero on success. In an
378 * ideal world, this would have been the case, but as it turns
379 * out, the other drivers return 1 on failure, so that's what
380 * we're going to do.
381 */
382static int atmel_lcdfb_setcolreg(unsigned int regno, unsigned int red,
383 unsigned int green, unsigned int blue,
384 unsigned int transp, struct fb_info *info)
385{
386 struct atmel_lcdfb_info *sinfo = info->par;
387 unsigned int val;
388 u32 *pal;
389 int ret = 1;
390
391 if (info->var.grayscale)
392 red = green = blue = (19595 * red + 38470 * green
393 + 7471 * blue) >> 16;
394
395 switch (info->fix.visual) {
396 case FB_VISUAL_TRUECOLOR:
397 if (regno < 16) {
398 pal = info->pseudo_palette;
399
400 val = chan_to_field(red, &info->var.red);
401 val |= chan_to_field(green, &info->var.green);
402 val |= chan_to_field(blue, &info->var.blue);
403
404 pal[regno] = val;
405 ret = 0;
406 }
407 break;
408
409 case FB_VISUAL_PSEUDOCOLOR:
410 if (regno < 256) {
411 val = ((red >> 11) & 0x001f);
412 val |= ((green >> 6) & 0x03e0);
413 val |= ((blue >> 1) & 0x7c00);
414
415 /*
416 * TODO: intensity bit. Maybe something like
417 * ~(red[10] ^ green[10] ^ blue[10]) & 1
418 */
419
420 lcdc_writel(sinfo, ATMEL_LCDC_LUT(regno), val);
421 ret = 0;
422 }
423 break;
424 }
425
426 return ret;
427}
428
429static int atmel_lcdfb_pan_display(struct fb_var_screeninfo *var,
430 struct fb_info *info)
431{
432 dev_dbg(info->device, "%s\n", __func__);
433
434 atmel_lcdfb_update_dma(info, var);
435
436 return 0;
437}
438
439static struct fb_ops atmel_lcdfb_ops = {
440 .owner = THIS_MODULE,
441 .fb_check_var = atmel_lcdfb_check_var,
442 .fb_set_par = atmel_lcdfb_set_par,
443 .fb_setcolreg = atmel_lcdfb_setcolreg,
444 .fb_pan_display = atmel_lcdfb_pan_display,
445 .fb_fillrect = cfb_fillrect,
446 .fb_copyarea = cfb_copyarea,
447 .fb_imageblit = cfb_imageblit,
448};
449
450static irqreturn_t atmel_lcdfb_interrupt(int irq, void *dev_id)
451{
452 struct fb_info *info = dev_id;
453 struct atmel_lcdfb_info *sinfo = info->par;
454 u32 status;
455
456 status = lcdc_readl(sinfo, ATMEL_LCDC_ISR);
457 lcdc_writel(sinfo, ATMEL_LCDC_IDR, status);
458 return IRQ_HANDLED;
459}
460
461static int __init atmel_lcdfb_init_fbinfo(struct atmel_lcdfb_info *sinfo)
462{
463 struct fb_info *info = sinfo->info;
464 int ret = 0;
465
466 memset_io(info->screen_base, 0, info->fix.smem_len);
467 info->var.activate |= FB_ACTIVATE_FORCE | FB_ACTIVATE_NOW;
468
469 dev_info(info->device,
470 "%luKiB frame buffer at %08lx (mapped at %p)\n",
471 (unsigned long)info->fix.smem_len / 1024,
472 (unsigned long)info->fix.smem_start,
473 info->screen_base);
474
475 /* Allocate colormap */
476 ret = fb_alloc_cmap(&info->cmap, 256, 0);
477 if (ret < 0)
478 dev_err(info->device, "Alloc color map failed\n");
479
480 return ret;
481}
482
483static void atmel_lcdfb_start_clock(struct atmel_lcdfb_info *sinfo)
484{
485 if (sinfo->bus_clk)
486 clk_enable(sinfo->bus_clk);
487 clk_enable(sinfo->lcdc_clk);
488}
489
490static void atmel_lcdfb_stop_clock(struct atmel_lcdfb_info *sinfo)
491{
492 if (sinfo->bus_clk)
493 clk_disable(sinfo->bus_clk);
494 clk_disable(sinfo->lcdc_clk);
495}
496
497
498static int __init atmel_lcdfb_probe(struct platform_device *pdev)
499{
500 struct device *dev = &pdev->dev;
501 struct fb_info *info;
502 struct atmel_lcdfb_info *sinfo;
503 struct atmel_lcdfb_info *pdata_sinfo;
504 struct resource *regs = NULL;
505 struct resource *map = NULL;
506 int ret;
507
508 dev_dbg(dev, "%s BEGIN\n", __func__);
509
510 ret = -ENOMEM;
511 info = framebuffer_alloc(sizeof(struct atmel_lcdfb_info), dev);
512 if (!info) {
513 dev_err(dev, "cannot allocate memory\n");
514 goto out;
515 }
516
517 sinfo = info->par;
518
519 if (dev->platform_data) {
520 pdata_sinfo = (struct atmel_lcdfb_info *)dev->platform_data;
521 sinfo->default_bpp = pdata_sinfo->default_bpp;
522 sinfo->default_dmacon = pdata_sinfo->default_dmacon;
523 sinfo->default_lcdcon2 = pdata_sinfo->default_lcdcon2;
524 sinfo->default_monspecs = pdata_sinfo->default_monspecs;
525 sinfo->atmel_lcdfb_power_control = pdata_sinfo->atmel_lcdfb_power_control;
526 sinfo->guard_time = pdata_sinfo->guard_time;
527 } else {
528 dev_err(dev, "cannot get default configuration\n");
529 goto free_info;
530 }
531 sinfo->info = info;
532 sinfo->pdev = pdev;
533
534 strcpy(info->fix.id, sinfo->pdev->name);
535 info->flags = ATMEL_LCDFB_FBINFO_DEFAULT;
536 info->pseudo_palette = sinfo->pseudo_palette;
537 info->fbops = &atmel_lcdfb_ops;
538
539 memcpy(&info->monspecs, sinfo->default_monspecs, sizeof(info->monspecs));
540 info->fix = atmel_lcdfb_fix;
541
542 /* Enable LCDC Clocks */
543 if (cpu_is_at91sam9261() || cpu_is_at32ap7000()) {
544 sinfo->bus_clk = clk_get(dev, "hck1");
545 if (IS_ERR(sinfo->bus_clk)) {
546 ret = PTR_ERR(sinfo->bus_clk);
547 goto free_info;
548 }
549 }
550 sinfo->lcdc_clk = clk_get(dev, "lcdc_clk");
551 if (IS_ERR(sinfo->lcdc_clk)) {
552 ret = PTR_ERR(sinfo->lcdc_clk);
553 goto put_bus_clk;
554 }
555 atmel_lcdfb_start_clock(sinfo);
556
557 ret = fb_find_mode(&info->var, info, NULL, info->monspecs.modedb,
558 info->monspecs.modedb_len, info->monspecs.modedb,
559 sinfo->default_bpp);
560 if (!ret) {
561 dev_err(dev, "no suitable video mode found\n");
562 goto stop_clk;
563 }
564
565
566 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
567 if (!regs) {
568 dev_err(dev, "resources unusable\n");
569 ret = -ENXIO;
570 goto stop_clk;
571 }
572
573 sinfo->irq_base = platform_get_irq(pdev, 0);
574 if (sinfo->irq_base < 0) {
575 dev_err(dev, "unable to get irq\n");
576 ret = sinfo->irq_base;
577 goto stop_clk;
578 }
579
580 /* Initialize video memory */
581 map = platform_get_resource(pdev, IORESOURCE_MEM, 1);
582 if (map) {
583 /* use a pre-allocated memory buffer */
584 info->fix.smem_start = map->start;
585 info->fix.smem_len = map->end - map->start + 1;
586 if (!request_mem_region(info->fix.smem_start,
587 info->fix.smem_len, pdev->name)) {
588 ret = -EBUSY;
589 goto stop_clk;
590 }
591
592 info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len);
593 if (!info->screen_base)
594 goto release_intmem;
595 } else {
596 /* alocate memory buffer */
597 ret = atmel_lcdfb_alloc_video_memory(sinfo);
598 if (ret < 0) {
599 dev_err(dev, "cannot allocate framebuffer: %d\n", ret);
600 goto stop_clk;
601 }
602 }
603
604 /* LCDC registers */
605 info->fix.mmio_start = regs->start;
606 info->fix.mmio_len = regs->end - regs->start + 1;
607
608 if (!request_mem_region(info->fix.mmio_start,
609 info->fix.mmio_len, pdev->name)) {
610 ret = -EBUSY;
611 goto free_fb;
612 }
613
614 sinfo->mmio = ioremap(info->fix.mmio_start, info->fix.mmio_len);
615 if (!sinfo->mmio) {
616 dev_err(dev, "cannot map LCDC registers\n");
617 goto release_mem;
618 }
619
620 /* interrupt */
621 ret = request_irq(sinfo->irq_base, atmel_lcdfb_interrupt, 0, pdev->name, info);
622 if (ret) {
623 dev_err(dev, "request_irq failed: %d\n", ret);
624 goto unmap_mmio;
625 }
626
627 ret = atmel_lcdfb_init_fbinfo(sinfo);
628 if (ret < 0) {
629 dev_err(dev, "init fbinfo failed: %d\n", ret);
630 goto unregister_irqs;
631 }
632
633 /*
634 * This makes sure that our colour bitfield
635 * descriptors are correctly initialised.
636 */
637 atmel_lcdfb_check_var(&info->var, info);
638
639 ret = fb_set_var(info, &info->var);
640 if (ret) {
641 dev_warn(dev, "unable to set display parameters\n");
642 goto free_cmap;
643 }
644
645 dev_set_drvdata(dev, info);
646
647 /*
648 * Tell the world that we're ready to go
649 */
650 ret = register_framebuffer(info);
651 if (ret < 0) {
652 dev_err(dev, "failed to register framebuffer device: %d\n", ret);
653 goto free_cmap;
654 }
655
656 /* Power up the LCDC screen */
657 if (sinfo->atmel_lcdfb_power_control)
658 sinfo->atmel_lcdfb_power_control(1);
659
660 dev_info(dev, "fb%d: Atmel LCDC at 0x%08lx (mapped at %p), irq %lu\n",
661 info->node, info->fix.mmio_start, sinfo->mmio, sinfo->irq_base);
662
663 return 0;
664
665
666free_cmap:
667 fb_dealloc_cmap(&info->cmap);
668unregister_irqs:
669 free_irq(sinfo->irq_base, info);
670unmap_mmio:
671 iounmap(sinfo->mmio);
672release_mem:
673 release_mem_region(info->fix.mmio_start, info->fix.mmio_len);
674free_fb:
675 if (map)
676 iounmap(info->screen_base);
677 else
678 atmel_lcdfb_free_video_memory(sinfo);
679
680release_intmem:
681 if (map)
682 release_mem_region(info->fix.smem_start, info->fix.smem_len);
683stop_clk:
684 atmel_lcdfb_stop_clock(sinfo);
685 clk_put(sinfo->lcdc_clk);
686put_bus_clk:
687 if (sinfo->bus_clk)
688 clk_put(sinfo->bus_clk);
689free_info:
690 framebuffer_release(info);
691out:
692 dev_dbg(dev, "%s FAILED\n", __func__);
693 return ret;
694}
695
696static int __exit atmel_lcdfb_remove(struct platform_device *pdev)
697{
698 struct device *dev = &pdev->dev;
699 struct fb_info *info = dev_get_drvdata(dev);
700 struct atmel_lcdfb_info *sinfo = info->par;
701
702 if (!sinfo)
703 return 0;
704
705 if (sinfo->atmel_lcdfb_power_control)
706 sinfo->atmel_lcdfb_power_control(0);
707 unregister_framebuffer(info);
708 atmel_lcdfb_stop_clock(sinfo);
709 clk_put(sinfo->lcdc_clk);
710 if (sinfo->bus_clk)
711 clk_put(sinfo->bus_clk);
712 fb_dealloc_cmap(&info->cmap);
713 free_irq(sinfo->irq_base, info);
714 iounmap(sinfo->mmio);
715 release_mem_region(info->fix.mmio_start, info->fix.mmio_len);
716 if (platform_get_resource(pdev, IORESOURCE_MEM, 1)) {
717 iounmap(info->screen_base);
718 release_mem_region(info->fix.smem_start, info->fix.smem_len);
719 } else {
720 atmel_lcdfb_free_video_memory(sinfo);
721 }
722
723 dev_set_drvdata(dev, NULL);
724 framebuffer_release(info);
725
726 return 0;
727}
728
729static struct platform_driver atmel_lcdfb_driver = {
730 .remove = __exit_p(atmel_lcdfb_remove),
731 .driver = {
732 .name = "atmel_lcdfb",
733 .owner = THIS_MODULE,
734 },
735};
736
737static int __init atmel_lcdfb_init(void)
738{
739 return platform_driver_probe(&atmel_lcdfb_driver, atmel_lcdfb_probe);
740}
741
742static void __exit atmel_lcdfb_exit(void)
743{
744 platform_driver_unregister(&atmel_lcdfb_driver);
745}
746
747module_init(atmel_lcdfb_init);
748module_exit(atmel_lcdfb_exit);
749
750MODULE_DESCRIPTION("AT91/AT32 LCD Controller framebuffer driver");
751MODULE_AUTHOR("Nicolas Ferre <nicolas.ferre@rfo.atmel.com>");
752MODULE_LICENSE("GPL");
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
index aa3935df852a..63b85bf81a65 100644
--- a/drivers/video/console/Kconfig
+++ b/drivers/video/console/Kconfig
@@ -19,13 +19,6 @@ config VGA_CONSOLE
19 19
20 Say Y. 20 Say Y.
21 21
22# if [ "$CONFIG_PCI" = "y" -a "$CONFIG_VGA_CONSOLE" = "y" ]; then
23# bool ' Allow VGA on any bus?' CONFIG_VGA_HOSE
24# if [ "$CONFIG_VGA_HOSE" = "y" ]; then
25# define_bool CONFIG_DUMMY_CONSOLE y
26# fi
27# fi
28
29config VGACON_SOFT_SCROLLBACK 22config VGACON_SOFT_SCROLLBACK
30 bool "Enable Scrollback Buffer in System RAM" 23 bool "Enable Scrollback Buffer in System RAM"
31 depends on VGA_CONSOLE 24 depends on VGA_CONSOLE
diff --git a/drivers/video/nvidia/nv_hw.c b/drivers/video/nvidia/nv_hw.c
index c627955aa124..aff11bbf59a7 100644
--- a/drivers/video/nvidia/nv_hw.c
+++ b/drivers/video/nvidia/nv_hw.c
@@ -149,7 +149,9 @@ static void nvGetClocks(struct nvidia_par *par, unsigned int *MClk,
149 pll = NV_RD32(par->PMC, 0x4024); 149 pll = NV_RD32(par->PMC, 0x4024);
150 M = pll & 0xFF; 150 M = pll & 0xFF;
151 N = (pll >> 8) & 0xFF; 151 N = (pll >> 8) & 0xFF;
152 if (((par->Chipset & 0xfff0) == 0x0290) || ((par->Chipset & 0xfff0) == 0x0390) || ((par->Chipset & 0xfff0) == 0x02E0)) { 152 if (((par->Chipset & 0xfff0) == 0x0290) ||
153 ((par->Chipset & 0xfff0) == 0x0390) ||
154 ((par->Chipset & 0xfff0) == 0x02E0)) {
153 MB = 1; 155 MB = 1;
154 NB = 1; 156 NB = 1;
155 } else { 157 } else {
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
index f85edf084da3..41f63658572f 100644
--- a/drivers/video/nvidia/nvidia.c
+++ b/drivers/video/nvidia/nvidia.c
@@ -37,7 +37,6 @@
37#include "nv_proto.h" 37#include "nv_proto.h"
38#include "nv_dma.h" 38#include "nv_dma.h"
39 39
40#undef CONFIG_FB_NVIDIA_DEBUG
41#ifdef CONFIG_FB_NVIDIA_DEBUG 40#ifdef CONFIG_FB_NVIDIA_DEBUG
42#define NVTRACE printk 41#define NVTRACE printk
43#else 42#else
diff --git a/drivers/video/pm2fb.c b/drivers/video/pm2fb.c
index 1ac5264bb2c1..ab5e66890e4e 100644
--- a/drivers/video/pm2fb.c
+++ b/drivers/video/pm2fb.c
@@ -204,17 +204,6 @@ static inline void WAIT_FIFO(struct pm2fb_par* p, u32 a)
204} 204}
205#endif 205#endif
206 206
207static void wait_pm2(struct pm2fb_par* par) {
208
209 WAIT_FIFO(par, 1);
210 pm2_WR(par, PM2R_SYNC, 0);
211 mb();
212 do {
213 while (pm2_RD(par, PM2R_OUT_FIFO_WORDS) == 0);
214 rmb();
215 } while (pm2_RD(par, PM2R_OUT_FIFO) != PM2TAG(PM2R_SYNC));
216}
217
218/* 207/*
219 * partial products for the supported horizontal resolutions. 208 * partial products for the supported horizontal resolutions.
220 */ 209 */
@@ -1050,13 +1039,30 @@ static int pm2fb_blank(int blank_mode, struct fb_info *info)
1050 return 0; 1039 return 0;
1051} 1040}
1052 1041
1042static int pm2fb_sync(struct fb_info *info)
1043{
1044 struct pm2fb_par *par = info->par;
1045
1046 WAIT_FIFO(par, 1);
1047 pm2_WR(par, PM2R_SYNC, 0);
1048 mb();
1049 do {
1050 while (pm2_RD(par, PM2R_OUT_FIFO_WORDS) == 0)
1051 udelay(10);
1052 rmb();
1053 } while (pm2_RD(par, PM2R_OUT_FIFO) != PM2TAG(PM2R_SYNC));
1054
1055 return 0;
1056}
1057
1053/* 1058/*
1054 * block operation. copy=0: rectangle fill, copy=1: rectangle copy. 1059 * block operation. copy=0: rectangle fill, copy=1: rectangle copy.
1055 */ 1060 */
1056static void pm2fb_block_op(struct pm2fb_par* par, int copy, 1061static void pm2fb_block_op(struct fb_info* info, int copy,
1057 s32 xsrc, s32 ysrc, 1062 s32 xsrc, s32 ysrc,
1058 s32 x, s32 y, s32 w, s32 h, 1063 s32 x, s32 y, s32 w, s32 h,
1059 u32 color) { 1064 u32 color) {
1065 struct pm2fb_par *par = info->par;
1060 1066
1061 if (!w || !h) 1067 if (!w || !h)
1062 return; 1068 return;
@@ -1076,13 +1082,11 @@ static void pm2fb_block_op(struct pm2fb_par* par, int copy,
1076 (x<xsrc ? PM2F_INCREASE_X : 0) | 1082 (x<xsrc ? PM2F_INCREASE_X : 0) |
1077 (y<ysrc ? PM2F_INCREASE_Y : 0) | 1083 (y<ysrc ? PM2F_INCREASE_Y : 0) |
1078 (copy ? 0 : PM2F_RENDER_FASTFILL)); 1084 (copy ? 0 : PM2F_RENDER_FASTFILL));
1079 wait_pm2(par);
1080} 1085}
1081 1086
1082static void pm2fb_fillrect (struct fb_info *info, 1087static void pm2fb_fillrect (struct fb_info *info,
1083 const struct fb_fillrect *region) 1088 const struct fb_fillrect *region)
1084{ 1089{
1085 struct pm2fb_par *par = info->par;
1086 struct fb_fillrect modded; 1090 struct fb_fillrect modded;
1087 int vxres, vyres; 1091 int vxres, vyres;
1088 u32 color = (info->fix.visual == FB_VISUAL_TRUECOLOR) ? 1092 u32 color = (info->fix.visual == FB_VISUAL_TRUECOLOR) ?
@@ -1116,7 +1120,7 @@ static void pm2fb_fillrect (struct fb_info *info,
1116 color |= color << 16; 1120 color |= color << 16;
1117 1121
1118 if(info->var.bits_per_pixel != 24) 1122 if(info->var.bits_per_pixel != 24)
1119 pm2fb_block_op(par, 0, 0, 0, 1123 pm2fb_block_op(info, 0, 0, 0,
1120 modded.dx, modded.dy, 1124 modded.dx, modded.dy,
1121 modded.width, modded.height, color); 1125 modded.width, modded.height, color);
1122 else 1126 else
@@ -1126,7 +1130,6 @@ static void pm2fb_fillrect (struct fb_info *info,
1126static void pm2fb_copyarea(struct fb_info *info, 1130static void pm2fb_copyarea(struct fb_info *info,
1127 const struct fb_copyarea *area) 1131 const struct fb_copyarea *area)
1128{ 1132{
1129 struct pm2fb_par *par = info->par;
1130 struct fb_copyarea modded; 1133 struct fb_copyarea modded;
1131 u32 vxres, vyres; 1134 u32 vxres, vyres;
1132 1135
@@ -1156,7 +1159,7 @@ static void pm2fb_copyarea(struct fb_info *info,
1156 if(modded.dy + modded.height > vyres) 1159 if(modded.dy + modded.height > vyres)
1157 modded.height = vyres - modded.dy; 1160 modded.height = vyres - modded.dy;
1158 1161
1159 pm2fb_block_op(par, 1, modded.sx, modded.sy, 1162 pm2fb_block_op(info, 1, modded.sx, modded.sy,
1160 modded.dx, modded.dy, 1163 modded.dx, modded.dy,
1161 modded.width, modded.height, 0); 1164 modded.width, modded.height, 0);
1162} 1165}
@@ -1177,6 +1180,7 @@ static struct fb_ops pm2fb_ops = {
1177 .fb_fillrect = pm2fb_fillrect, 1180 .fb_fillrect = pm2fb_fillrect,
1178 .fb_copyarea = pm2fb_copyarea, 1181 .fb_copyarea = pm2fb_copyarea,
1179 .fb_imageblit = cfb_imageblit, 1182 .fb_imageblit = cfb_imageblit,
1183 .fb_sync = pm2fb_sync,
1180}; 1184};
1181 1185
1182/* 1186/*
diff --git a/drivers/video/pm3fb.c b/drivers/video/pm3fb.c
index bd787e80177d..c77a1a1fd46b 100644
--- a/drivers/video/pm3fb.c
+++ b/drivers/video/pm3fb.c
@@ -1,55 +1,25 @@
1/* 1/*
2 * linux/drivers/video/pm3fb.c -- 3DLabs Permedia3 frame buffer device 2 * linux/drivers/video/pm3fb.c -- 3DLabs Permedia3 frame buffer device
3 * 3 *
4 * Copyright (C) 2001 Romain Dolbeau <dolbeau@irisa.fr> 4 * Copyright (C) 2001 Romain Dolbeau <romain@dolbeau.org>.
5 *
6 * Ported to 2.6 kernel on 1 May 2007 by Krzysztof Helt <krzysztof.h1@wp.pl>
7 * based on pm2fb.c
8 *
5 * Based on code written by: 9 * Based on code written by:
6 * Sven Luther, <luther@dpt-info.u-strasbg.fr> 10 * Sven Luther, <luther@dpt-info.u-strasbg.fr>
7 * Alan Hourihane, <alanh@fairlite.demon.co.uk> 11 * Alan Hourihane, <alanh@fairlite.demon.co.uk>
8 * Russell King, <rmk@arm.linux.org.uk> 12 * Russell King, <rmk@arm.linux.org.uk>
9 * Based on linux/drivers/video/skeletonfb.c: 13 * Based on linux/drivers/video/skeletonfb.c:
10 * Copyright (C) 1997 Geert Uytterhoeven 14 * Copyright (C) 1997 Geert Uytterhoeven
11 * Based on linux/driver/video/pm2fb.c: 15 * Based on linux/driver/video/pm2fb.c:
12 * Copyright (C) 1998-1999 Ilario Nardinocchi (nardinoc@CS.UniBO.IT) 16 * Copyright (C) 1998-1999 Ilario Nardinocchi (nardinoc@CS.UniBO.IT)
13 * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com) 17 * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com)
14 * 18 *
15 * This file is subject to the terms and conditions of the GNU General Public 19 * This file is subject to the terms and conditions of the GNU General Public
16 * License. See the file COPYING in the main directory of this archive for 20 * License. See the file COPYING in the main directory of this archive for
17 * more details. 21 * more details.
18 * 22 *
19 * $Header: /cvsroot/linux/drivers/video/pm3fb.c,v 1.1 2002/02/25 19:11:06 marcelo Exp $
20 *
21 * CHANGELOG:
22 * Mon Feb 11 10:35:48 MET 2002, v 1.4.11B: Cosmetic update.
23 * Wed Jan 23 14:16:59 MET 2002, v 1.4.11: Preliminary 2.5.x support, patch for 2.5.2.
24 * Wed Nov 28 11:08:29 MET 2001, v 1.4.10: potential bug fix for SDRAM-based board, patch for 2.4.16.
25 * Thu Sep 20 10:24:42 MET DST 2001, v 1.4.9: sync bug fix, preliminary flatpanel support, better timings.
26 * Tue Aug 28 10:13:01 MET DST 2001, v 1.4.8: memory timings check, minor bug fixes.
27 * Wed Jul 18 19:06:14 CEST 2001, v 1.4.7: Mode fix (800x600-100, 1024x768-100 changed), using HW panning + accel bug fix.
28 * Mon Jun 25 10:33:56 MET DST 2001, v 1.4.6: Depth 12 fix, chip reset ioctl, moved memory erase ioctl to DEBUG.
29 * Wed Jun 20 11:13:08 MET DST 2001, v 1.4.5: Fixed missing blinking cursor in 8bpp, code cleaning, memory erase IOCTL.
30 * Mon Jun 18 16:00:27 CEST 2001, v 1.4.4: Depth 12 (RGBA 4444) support, code cleaning.
31 * Fri Jun 15 13:53:01 CEST 2001, v 1.4.3: Removed warnings, depth 15 support, add 'depth' option.
32 * Thu Jun 14 10:13:52 MET DST 2001, v 1.4.2: Fixed depth switching bug, preliminary 15bpp (RGB5551) support.
33 * Thu Apr 12 11:16:45 MET DST 2001, v 1.4.1B: Doc updates.
34 * Fri Apr 6 11:12:53 MET DST 2001, v 1.4.1: Configure.help, minor cleanup
35 * Thu Mar 29 10:56:50 MET DST 2001, v 1.4.0: Module & module options support (note: linux patch changed, 2.2.19 added).
36 * Thu Mar 15 15:30:31 MET 2001, v 1.3.2: Fixed mirroring bug on little-endian.
37 * Wed Mar 14 21:25:54 CET 2001, v 1.3.1: Fixed bug in BlockMove (_bmov).
38 * Tue Mar 13 10:53:19 MET 2001, v 1.3.0: Character drawing hardware support (in all width between 1 and 16), fixes.
39 * Thu Mar 8 10:20:16 MET 2001, v 1.2.2: Better J2000 support, "font:" option.
40 * Tue Mar 6 21:25:04 CET 2001, v 1.2.1: Better acceleration support.
41 * Mon Mar 5 21:54:17 CET 2001, v 1.2.0: Partial acceleration support (clear & bmove)
42 * Mon Mar 5 12:52:15 CET 2001, v 1.1.3: Big pan_display fix.
43 * Sun Mar 4 22:21:50 CET 2001, v 1.1.2: (numerous) bug fixes.
44 * Fri Mar 2 15:54:07 CET 2001, v 1.1.1: Might have Appian J2000 support, resource mangement in 2.4
45 * Wed Feb 28 18:21:35 CET 2001, v 1.1.0: Might have multiple boards support (added, but not yest tested)
46 * Tue Feb 27 17:31:12 CET 2001, v 1.0.6: fixes boot-time mode select, add more default mode
47 * Tue Feb 27 14:01:36 CET 2001, v 1.0.5: fixes (1.0.4 was broken for 2.2), cleaning up
48 * Mon Feb 26 23:17:36 CET 2001, v 1.0.4: preliminary 2.4.x support, dropped (useless on pm3) partial product, more OF fix
49 * Mon Feb 26 20:59:05 CET 2001, v 1.0.3: No more shadow register (and wasted memory), endianess fix, use OF-preset resolution by default
50 * Wed Feb 21 22:09:30 CET 2001, v 1.0.2: Code cleaning for future multiboard support, better OF support, bugs fix
51 * Wed Feb 21 19:58:56 CET 2001, v 1.0.1: OpenFirmware support, fixed memory detection, better debug support, code cleaning
52 * Wed Feb 21 14:47:06 CET 2001, v 1.0.0: First working version
53 */ 23 */
54 24
55#include <linux/module.h> 25#include <linux/module.h>
@@ -58,856 +28,155 @@
58#include <linux/string.h> 28#include <linux/string.h>
59#include <linux/mm.h> 29#include <linux/mm.h>
60#include <linux/slab.h> 30#include <linux/slab.h>
61#include <linux/vmalloc.h>
62#include <linux/delay.h> 31#include <linux/delay.h>
63#include <linux/interrupt.h>
64#include <linux/fb.h> 32#include <linux/fb.h>
65#include <linux/init.h> 33#include <linux/init.h>
66#include <linux/pci.h> 34#include <linux/pci.h>
67#include <linux/ioport.h>
68#include <linux/ctype.h>
69
70#include <video/fbcon.h>
71#include <video/fbcon-mfb.h>
72#include <video/fbcon-cfb2.h>
73#include <video/fbcon-cfb4.h>
74#include <video/fbcon-cfb8.h>
75#include <video/fbcon-cfb16.h>
76#include <video/fbcon-cfb24.h>
77#include <video/fbcon-cfb32.h>
78#include <video/pm3fb.h>
79 35
80#include <asm/io.h> 36#include <video/pm3fb.h>
81#include <asm/uaccess.h>
82 37
83#ifdef CONFIG_FB_OF 38#if !defined(CONFIG_PCI)
84#include <asm/prom.h> 39#error "Only generic PCI cards supported."
85#endif 40#endif
86 41
87/* ************************************* */ 42#undef PM3FB_MASTER_DEBUG
88/* ***** The various "global" data ***** */ 43#ifdef PM3FB_MASTER_DEBUG
89/* ************************************* */ 44#define DPRINTK(a,b...) printk(KERN_DEBUG "pm3fb: %s: " a, __FUNCTION__ , ## b)
90 45#else
91/* those will need a rework for multiple board support */ 46#define DPRINTK(a,b...)
92/* Driver name */
93static const char permedia3_name[16] = "Permedia3";
94
95/* the fb_par struct, mandatory */
96struct pm3fb_par {
97 u32 pixclock; /* pixclock in KHz */
98
99 u32 width; /* width of virtual screen */
100 u32 height; /* height of virtual screen */
101
102 u32 hsstart; /* horiz. sync start */
103 u32 hsend; /* horiz. sync end */
104 u32 hbend; /* horiz. blank end (also gate end) */
105 u32 htotal; /* total width (w/ sync & blank) */
106
107 u32 vsstart; /* vert. sync start */
108 u32 vsend; /* vert. sync end */
109 u32 vbend; /* vert. blank end */
110 u32 vtotal; /* total height (w/ sync & blank) */
111
112 u32 stride; /* screen stride */
113 u32 base; /* screen base (xoffset+yoffset) in 128 bits unit */
114 /* NOTE : unlike other pm3 stuff above, stored *after* shiftbpp. don't ask */
115 u32 depth; /* screen depth (8, 12, 15, 16 or 32) */
116 u32 video; /* video control (hsync,vsync) */
117};
118
119/* memory timings */
120struct pm3fb_timings
121{
122 unsigned long caps;
123 unsigned long timings;
124 unsigned long control;
125 unsigned long refresh;
126 unsigned long powerdown;
127};
128typedef enum pm3fb_timing_result { pm3fb_timing_ok, pm3fb_timing_problem, pm3fb_timing_retry } pm3fb_timing_result;
129#define PM3FB_UNKNOWN_TIMING_VALUE ((unsigned long)-1)
130#define PM3FB_UNKNOWN_TIMINGS { PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE }
131
132/* the fb_info struct, mandatory */
133struct pm3fb_info {
134 struct fb_info_gen gen;
135 unsigned long board_num; /* internal board number */
136 unsigned long use_current;
137 struct pm3fb_par *current_par;
138 struct pci_dev *dev; /* PCI device */
139 unsigned long board_type; /* index in the cardbase */
140 unsigned char *fb_base; /* framebuffer memory base */
141 u32 fb_size; /* framebuffer memory size */
142 unsigned char *p_fb; /* physical address of frame buffer */
143 unsigned char *v_fb; /* virtual address of frame buffer */
144 unsigned char *pIOBase; /* physical address of registers region, must be rg_base or rg_base+PM2_REGS_SIZE depending on the host endianness */
145 unsigned char *vIOBase; /* address of registers after ioremap() */
146 struct {
147 u8 transp;
148 u8 red;
149 u8 green;
150 u8 blue;
151 } palette[256];
152 union {
153#ifdef FBCON_HAS_CFB16
154 u16 cmap12[16]; /* RGBA 4444 */
155 u16 cmap15[16]; /* RGBA 5551 */
156 u16 cmap16[16]; /* RGBA 5650 */
157#endif
158#ifdef FBCON_HAS_CFB32
159 u32 cmap32[16];
160#endif 47#endif
161 } cmap;
162 struct pm3fb_timings memt;
163};
164 48
165/* regular resolution database*/ 49/*
166static struct { 50 * Driver data
167 char name[16]; 51 */
168 struct pm3fb_par user_mode; 52static char *mode_option __devinitdata;
169} mode_base[] __initdata = {
170 {
171 "default-800x600", {
172 49500, 800, 600, 16, 96, 256, 1056, 1, 4, 25, 625,
173 800, 0, 8,
174 PM3VideoControl_ENABLE |
175 PM3VideoControl_HSYNC_ACTIVE_HIGH
176 |
177 PM3VideoControl_VSYNC_ACTIVE_HIGH
178 | PM3VideoControl_PIXELSIZE_8BIT}}, {
179 "1024x768-74", {
180 78752, 1024, 768, 32, 128, 304, 1328, 1, 4, 38,
181 806, 1024, 0, 8,
182 PM3VideoControl_ENABLE |
183 PM3VideoControl_HSYNC_ACTIVE_HIGH
184 |
185 PM3VideoControl_VSYNC_ACTIVE_HIGH
186 | PM3VideoControl_PIXELSIZE_8BIT}}, {
187 "1024x768-74-32", {
188 78752, 1024, 768, 32, 128, 304, 1328, 1, 4, 38,
189 806, 1024, 0, 32,
190 PM3VideoControl_ENABLE |
191 PM3VideoControl_HSYNC_ACTIVE_HIGH
192 |
193 PM3VideoControl_VSYNC_ACTIVE_HIGH
194 | PM3VideoControl_PIXELSIZE_32BIT}},
195/* Generated mode : "1600x1024", for the SGI 1600SW flat panel*/
196 {
197 "SGI1600SW", {
198 108000, 1600, 1024, 16, 56, 104, 1704, 3, 6, 32,
199 1056, 1600, 0, 8,
200 PM3VideoControl_ENABLE|
201 PM3VideoControl_HSYNC_ACTIVE_LOW|PM3VideoControl_VSYNC_ACTIVE_LOW|
202 PM3VideoControl_PIXELSIZE_32BIT}},
203/* ##### auto-generated mode, by fbtimings2pm3 */
204/* Generated mode : "640x480-60" */
205 {
206 "640x480-60", {
207 25174, 640, 480, 16, 112, 160, 800, 10, 12, 45,
208 525, 640, 0, 8,
209 PM3VideoControl_ENABLE |
210 PM3VideoControl_HSYNC_ACTIVE_LOW
211 |
212 PM3VideoControl_VSYNC_ACTIVE_LOW
213 | PM3VideoControl_PIXELSIZE_8BIT}},
214/* Generated mode : "640x480-72" */
215 {
216 "640x480-72", {
217 31199, 640, 480, 24, 64, 192, 832, 9, 12, 40, 520,
218 640, 0, 8,
219 PM3VideoControl_ENABLE |
220 PM3VideoControl_HSYNC_ACTIVE_LOW
221 |
222 PM3VideoControl_VSYNC_ACTIVE_LOW
223 | PM3VideoControl_PIXELSIZE_8BIT}},
224/* Generated mode : "640x480-75" */
225 {
226 "640x480-75", {
227 31499, 640, 480, 16, 80, 200, 840, 1, 4, 20, 500,
228 640, 0, 8,
229 PM3VideoControl_ENABLE |
230 PM3VideoControl_HSYNC_ACTIVE_LOW
231 |
232 PM3VideoControl_VSYNC_ACTIVE_LOW
233 | PM3VideoControl_PIXELSIZE_8BIT}},
234/* Generated mode : "640x480-90" */
235 {
236 "640x480-90", {
237 39909, 640, 480, 32, 72, 192, 832, 25, 39, 53, 533,
238 640, 0, 8,
239 PM3VideoControl_ENABLE |
240 PM3VideoControl_HSYNC_ACTIVE_LOW
241 |
242 PM3VideoControl_VSYNC_ACTIVE_LOW
243 | PM3VideoControl_PIXELSIZE_8BIT}},
244/* Generated mode : "640x480-100" */
245 {
246 "640x480-100", {
247 44899, 640, 480, 32, 160, 208, 848, 22, 34, 51,
248 531, 640, 0, 8,
249 PM3VideoControl_ENABLE |
250 PM3VideoControl_HSYNC_ACTIVE_LOW
251 |
252 PM3VideoControl_VSYNC_ACTIVE_LOW
253 | PM3VideoControl_PIXELSIZE_8BIT}},
254/* Generated mode : "800x600-48-lace" */
255/* INTERLACED NOT SUPPORTED
256 {"800x600-48-lace", {35999, 800, 600, 80, 208, 264, 1064, 11, 23, 102, 702, 800, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}},
257 INTERLACED NOT SUPPORTED */
258/* Generated mode : "800x600-56" */
259 {
260 "800x600-56", {
261 35999, 800, 600, 24, 96, 224, 1024, 1, 3, 25, 625,
262 800, 0, 8,
263 PM3VideoControl_ENABLE |
264 PM3VideoControl_HSYNC_ACTIVE_HIGH
265 |
266 PM3VideoControl_VSYNC_ACTIVE_HIGH
267 | PM3VideoControl_PIXELSIZE_8BIT}},
268/* Generated mode : "800x600-60" */
269 {
270 "800x600-60", {
271 40000, 800, 600, 40, 168, 256, 1056, 1, 5, 28, 628,
272 800, 0, 8,
273 PM3VideoControl_ENABLE |
274 PM3VideoControl_HSYNC_ACTIVE_HIGH
275 |
276 PM3VideoControl_VSYNC_ACTIVE_HIGH
277 | PM3VideoControl_PIXELSIZE_8BIT}},
278/* Generated mode : "800x600-70" */
279 {
280 "800x600-70", {
281 44899, 800, 600, 24, 168, 208, 1008, 9, 21, 36,
282 636, 800, 0, 8,
283 PM3VideoControl_ENABLE |
284 PM3VideoControl_HSYNC_ACTIVE_HIGH
285 |
286 PM3VideoControl_VSYNC_ACTIVE_LOW
287 | PM3VideoControl_PIXELSIZE_8BIT}},
288/* Generated mode : "800x600-72" */
289 {
290 "800x600-72", {
291 50000, 800, 600, 56, 176, 240, 1040, 37, 43, 66,
292 666, 800, 0, 8,
293 PM3VideoControl_ENABLE |
294 PM3VideoControl_HSYNC_ACTIVE_HIGH
295 |
296 PM3VideoControl_VSYNC_ACTIVE_HIGH
297 | PM3VideoControl_PIXELSIZE_8BIT}},
298/* Generated mode : "800x600-75" */
299 {
300 "800x600-75", {
301 49497, 800, 600, 16, 96, 256, 1056, 1, 4, 25, 625,
302 800, 0, 8,
303 PM3VideoControl_ENABLE |
304 PM3VideoControl_HSYNC_ACTIVE_HIGH
305 |
306 PM3VideoControl_VSYNC_ACTIVE_HIGH
307 | PM3VideoControl_PIXELSIZE_8BIT}},
308/* Generated mode : "800x600-90" */
309 {
310 "800x600-90", {
311 56637, 800, 600, 8, 72, 192, 992, 8, 19, 35, 635,
312 800, 0, 8,
313 PM3VideoControl_ENABLE |
314 PM3VideoControl_HSYNC_ACTIVE_HIGH
315 |
316 PM3VideoControl_VSYNC_ACTIVE_HIGH
317 | PM3VideoControl_PIXELSIZE_8BIT}},
318/* Generated mode : "800x600-100", from /etc/fb.modes */
319/* DISABLED, hsstart == 0
320 {
321 "800x600-100", {
322 67499, 800, 600, 0, 64, 280, 1080, 7, 11, 25, 625,
323 800, 0, 8,
324 PM3VideoControl_ENABLE |
325 PM3VideoControl_HSYNC_ACTIVE_HIGH
326 |
327 PM3VideoControl_VSYNC_ACTIVE_HIGH
328 | PM3VideoControl_PIXELSIZE_8BIT}},
329*/
330/* Generated mode : "800x600-100", from ??? */
331 {
332 "800x600-100", {
333 69650, 800, 600, 64, 128, 288, 1088, 4, 10, 40, 640, 800, 0, 8,
334 PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_LOW|
335 PM3VideoControl_VSYNC_ACTIVE_LOW|PM3VideoControl_PIXELSIZE_8BIT}},
336/* Generated mode : "1024x768-43-lace" */
337/* INTERLACED NOT SUPPORTED
338 {"1024x768-43-lace", {44899, 1024, 768, 8, 184, 240, 1264, 1, 9, 49, 817, 1024, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}},
339 INTERLACED NOT SUPPORTED */
340/* Generated mode : "1024x768-60" */
341 {
342 "1024x768-60", {
343 64998, 1024, 768, 24, 160, 320, 1344, 3, 9, 38,
344 806, 1024, 0, 8,
345 PM3VideoControl_ENABLE |
346 PM3VideoControl_HSYNC_ACTIVE_LOW
347 |
348 PM3VideoControl_VSYNC_ACTIVE_LOW
349 | PM3VideoControl_PIXELSIZE_8BIT}},
350/* Generated mode : "1024x768-70" */
351 {
352 "1024x768-70", {
353 74996, 1024, 768, 24, 160, 304, 1328, 3, 9, 38,
354 806, 1024, 0, 8,
355 PM3VideoControl_ENABLE |
356 PM3VideoControl_HSYNC_ACTIVE_LOW
357 |
358 PM3VideoControl_VSYNC_ACTIVE_LOW
359 | PM3VideoControl_PIXELSIZE_8BIT}},
360/* Generated mode : "1024x768-72" */
361 {
362 "1024x768-72", {
363 74996, 10224, 768, 24, 160, 264, 10488, 3, 9, 38,
364 806, 10224, 0, 8,
365 PM3VideoControl_ENABLE |
366 PM3VideoControl_HSYNC_ACTIVE_LOW
367 |
368 PM3VideoControl_VSYNC_ACTIVE_LOW
369 | PM3VideoControl_PIXELSIZE_8BIT}},
370/* Generated mode : "1024x768-75" */
371 {
372 "1024x768-75", {
373 78746, 1024, 768, 16, 112, 288, 1312, 1, 4, 32,
374 800, 1024, 0, 8,
375 PM3VideoControl_ENABLE |
376 PM3VideoControl_HSYNC_ACTIVE_HIGH
377 |
378 PM3VideoControl_VSYNC_ACTIVE_HIGH
379 | PM3VideoControl_PIXELSIZE_8BIT}},
380/* Generated mode : "1024x768-90" */
381 {
382 "1024x768-90", {
383 100000, 1024, 768, 0, 96, 288, 1312, 21, 36, 77,
384 845, 1024, 0, 8,
385 PM3VideoControl_ENABLE |
386 PM3VideoControl_HSYNC_ACTIVE_LOW
387 |
388 PM3VideoControl_VSYNC_ACTIVE_LOW
389 | PM3VideoControl_PIXELSIZE_8BIT}},
390/* Generated mode : "1024x768-100", from /etc/fb.modes */
391/* DISABLED, vsstart == 0
392 {
393 "1024x768-100", {
394 109998, 1024, 768, 0, 88, 368, 1392, 0, 8, 24, 792,
395 1024, 0, 8,
396 PM3VideoControl_ENABLE |
397 PM3VideoControl_HSYNC_ACTIVE_LOW
398 |
399 PM3VideoControl_VSYNC_ACTIVE_LOW
400 | PM3VideoControl_PIXELSIZE_8BIT}},
401*/
402/* Generated mode : "1024x768-100", from ??? */
403 {
404 "1024x768-100", {
405 115500, 1024, 768, 32, 224, 416, 1440, 3, 13, 34, 802, 1024, 0, 8,
406 PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_LOW|
407 PM3VideoControl_VSYNC_ACTIVE_LOW|PM3VideoControl_PIXELSIZE_8BIT}},
408/* Generated mode : "1152x864-43-lace" */
409/* INTERLACED NOT SUPPORTED
410 {"1152x864-43-lace", {64998, 1152, 864, 72, 200, 264, 1416, 78, 87, 191, 1055, 1152, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}},
411 INTERLACED NOT SUPPORTED */
412/* Generated mode : "1152x864-47-lace" */
413/* INTERLACED NOT SUPPORTED
414 {"1152x864-47-lace", {64998, 1152, 864, 88, 216, 296, 1448, 30, 39, 83, 947, 1152, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}},
415 INTERLACED NOT SUPPORTED */
416/* Generated mode : "1152x864-60" */
417 {
418 "1152x864-60", {
419 80000, 1152, 864, 64, 176, 304, 1456, 6, 11, 52,
420 916, 1152, 0, 8,
421 PM3VideoControl_ENABLE |
422 PM3VideoControl_HSYNC_ACTIVE_HIGH
423 |
424 PM3VideoControl_VSYNC_ACTIVE_HIGH
425 | PM3VideoControl_PIXELSIZE_8BIT}},
426/* Generated mode : "1152x864-70" */
427 {
428 "1152x864-70", {
429 100000, 1152, 864, 40, 192, 360, 1512, 13, 24, 81,
430 945, 1152, 0, 8,
431 PM3VideoControl_ENABLE |
432 PM3VideoControl_HSYNC_ACTIVE_HIGH
433 |
434 PM3VideoControl_VSYNC_ACTIVE_HIGH
435 | PM3VideoControl_PIXELSIZE_8BIT}},
436/* Generated mode : "1152x864-75" */
437 {
438 "1152x864-75", {
439 109998, 1152, 864, 24, 168, 312, 1464, 45, 53, 138,
440 1002, 1152, 0, 8,
441 PM3VideoControl_ENABLE |
442 PM3VideoControl_HSYNC_ACTIVE_HIGH
443 |
444 PM3VideoControl_VSYNC_ACTIVE_HIGH
445 | PM3VideoControl_PIXELSIZE_8BIT}},
446/* Generated mode : "1152x864-80" */
447 {
448 "1152x864-80", {
449 109998, 1152, 864, 16, 128, 288, 1440, 30, 37, 94,
450 958, 1152, 0, 8,
451 PM3VideoControl_ENABLE |
452 PM3VideoControl_HSYNC_ACTIVE_HIGH
453 |
454 PM3VideoControl_VSYNC_ACTIVE_HIGH
455 | PM3VideoControl_PIXELSIZE_8BIT}},
456/* Generated mode : "1280x1024-43-lace" */
457/* INTERLACED NOT SUPPORTED
458 {"1280x1024-43-lace", {80000, 1024, 1024, 80, 160, 320, 1344, 50, 60, 125, 1149, 1024, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}},
459 INTERLACED NOT SUPPORTED */
460/* Generated mode : "1280x1024-47-lace" */
461/* INTERLACED NOT SUPPORTED
462 {"1280x1024-47-lace", {80000, 1280, 1024, 80, 160, 320, 1600, 1, 11, 29, 1053, 1280, 0, 8, PM3VideoControl_ENABLE|PM3VideoControl_HSYNC_ACTIVE_HIGH|PM3VideoControl_VSYNC_ACTIVE_HIGH|PM3VideoControl_PIXELSIZE_8BIT}},
463 INTERLACED NOT SUPPORTED */
464/* Generated mode : "1280x1024-60" */
465 {
466 "1280x1024-60", {
467 107991, 1280, 1024, 48, 160, 408, 1688, 1, 4, 42,
468 1066, 1280, 0, 8,
469 PM3VideoControl_ENABLE |
470 PM3VideoControl_HSYNC_ACTIVE_HIGH
471 |
472 PM3VideoControl_VSYNC_ACTIVE_HIGH
473 | PM3VideoControl_PIXELSIZE_8BIT}},
474/* Generated mode : "1280x1024-70" */
475 {
476 "1280x1024-70", {
477 125992, 1280, 1024, 80, 192, 408, 1688, 1, 6, 42,
478 1066, 1280, 0, 8,
479 PM3VideoControl_ENABLE |
480 PM3VideoControl_HSYNC_ACTIVE_HIGH
481 |
482 PM3VideoControl_VSYNC_ACTIVE_HIGH
483 | PM3VideoControl_PIXELSIZE_8BIT}},
484/* Generated mode : "1280x1024-74" */
485 {
486 "1280x1024-74", {
487 134989, 1280, 1024, 32, 176, 432, 1712, 0, 30, 40,
488 1064, 1280, 0, 8,
489 PM3VideoControl_ENABLE |
490 PM3VideoControl_HSYNC_ACTIVE_HIGH
491 |
492 PM3VideoControl_VSYNC_ACTIVE_HIGH
493 | PM3VideoControl_PIXELSIZE_8BIT}},
494/* Generated mode : "1280x1024-75" */
495 {
496 "1280x1024-75", {
497 134989, 1280, 1024, 16, 160, 408, 1688, 1, 4, 42,
498 1066, 1280, 0, 8,
499 PM3VideoControl_ENABLE |
500 PM3VideoControl_HSYNC_ACTIVE_HIGH
501 |
502 PM3VideoControl_VSYNC_ACTIVE_HIGH
503 | PM3VideoControl_PIXELSIZE_8BIT}},
504/* Generated mode : "1600x1200-60" */
505 {
506 "1600x1200-60", {
507 155981, 1600, 1200, 32, 192, 448, 2048, 10, 18, 70,
508 1270, 1600, 0, 8,
509 PM3VideoControl_ENABLE |
510 PM3VideoControl_HSYNC_ACTIVE_LOW
511 |
512 PM3VideoControl_VSYNC_ACTIVE_LOW
513 | PM3VideoControl_PIXELSIZE_8BIT}},
514/* Generated mode : "1600x1200-66" */
515 {
516 "1600x1200-66", {
517 171998, 1600, 1200, 40, 176, 480, 2080, 3, 6, 53,
518 1253, 1600, 0, 8,
519 PM3VideoControl_ENABLE |
520 PM3VideoControl_HSYNC_ACTIVE_LOW
521 |
522 PM3VideoControl_VSYNC_ACTIVE_LOW
523 | PM3VideoControl_PIXELSIZE_8BIT}},
524/* Generated mode : "1600x1200-76" */
525 {
526 "1600x1200-76", {
527 197980, 1600, 1200, 40, 176, 480, 2080, 3, 8, 50,
528 1250, 1600, 0, 8,
529 PM3VideoControl_ENABLE |
530 PM3VideoControl_HSYNC_ACTIVE_LOW
531 |
532 PM3VideoControl_VSYNC_ACTIVE_LOW
533 | PM3VideoControl_PIXELSIZE_8BIT}},
534/* ##### end of auto-generated mode */
535 {
536 "\0",}
537};
538
539/* more mandatory stuff (see skeletonfb.c + framebuffer driver HOWTO */
540static struct pm3fb_info fb_info[PM3_MAX_BOARD];
541static struct pm3fb_par current_par[PM3_MAX_BOARD];
542static int current_par_valid[PM3_MAX_BOARD];
543/* to allow explicit filtering of board */
544short bus[PM3_MAX_BOARD];
545short slot[PM3_MAX_BOARD];
546short func[PM3_MAX_BOARD];
547short disable[PM3_MAX_BOARD];
548short noaccel[PM3_MAX_BOARD];
549char fontn[PM3_MAX_BOARD][PM3_FONTNAME_SIZE];
550short depth[PM3_MAX_BOARD];
551short flatpanel[PM3_MAX_BOARD];
552static struct display disp[PM3_MAX_BOARD];
553static char g_options[PM3_OPTIONS_SIZE] __initdata = "pm3fb,dummy";
554short printtimings = 0;
555short forcesize[PM3_MAX_BOARD];
556
557/* ********************* */
558/* ***** prototype ***** */
559/* ********************* */
560/* card-specific */
561static void pm3fb_j2000_setup(struct pm3fb_info *l_fb_info);
562/* permedia3-specific */
563static pm3fb_timing_result pm3fb_preserve_memory_timings(struct pm3fb_info *l_fb_info);
564static pm3fb_timing_result pm3fb_try_memory_timings(struct pm3fb_info *l_fb_info);
565static void pm3fb_write_memory_timings(struct pm3fb_info *l_fb_info);
566static unsigned long pm3fb_read_dac_reg(struct pm3fb_info *l_fb_info,
567 unsigned long r);
568static unsigned long pm3fb_CalculateClock(struct pm3fb_info *l_fb_info, unsigned long reqclock, /* In kHz units */
569 unsigned long refclock, /* In kHz units */
570 unsigned char *prescale, /* ClkPreScale */
571 unsigned char *feedback, /* ClkFeedBackScale */
572 unsigned char *postscale
573 /* ClkPostScale */ );
574static void pm3fb_clear_memory(struct pm3fb_info *l_fb_info, u32 cc);
575static void pm3fb_clear_colormap(struct pm3fb_info *l_fb_info, unsigned char r, unsigned char g, unsigned char b);
576static void pm3fb_common_init(struct pm3fb_info *l_fb_info);
577static int pm3fb_Shiftbpp(struct pm3fb_info *l_fb_info,
578 unsigned long depth, int v);
579static int pm3fb_Unshiftbpp(struct pm3fb_info *l_fb_info,
580 unsigned long depth, int v);
581static void pm3fb_mapIO(struct pm3fb_info *l_fb_info);
582static void pm3fb_unmapIO(struct pm3fb_info *l_fb_info);
583#if defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2)
584static void pm3fb_show_cur_mode(struct pm3fb_info *l_fb_info);
585#endif
586static void pm3fb_show_cur_timing(struct pm3fb_info *l_fb_info);
587static void pm3fb_write_mode(struct pm3fb_info *l_fb_info);
588static void pm3fb_read_mode(struct pm3fb_info *l_fb_info,
589 struct pm3fb_par *curpar);
590static unsigned long pm3fb_size_memory(struct pm3fb_info *l_fb_info);
591/* accelerated permedia3-specific */
592#ifdef PM3FB_USE_ACCEL
593static void pm3fb_wait_pm3(struct pm3fb_info *l_fb_info);
594static void pm3fb_init_engine(struct pm3fb_info *l_fb_info);
595#ifdef FBCON_HAS_CFB32
596static void pm3fb_cfb32_clear(struct vc_data *conp,
597 struct display *p,
598 int sy, int sx, int height, int width);
599static void pm3fb_cfb32_clear_margins(struct vc_data *conp,
600 struct display *p, int bottom_only);
601#endif /* FBCON_HAS_CFB32 */
602#ifdef FBCON_HAS_CFB16
603static void pm3fb_cfb16_clear(struct vc_data *conp,
604 struct display *p,
605 int sy, int sx, int height, int width);
606static void pm3fb_cfb16_clear_margins(struct vc_data *conp,
607 struct display *p, int bottom_only);
608#endif /* FBCON_HAS_CFB16 */
609#ifdef FBCON_HAS_CFB8
610static void pm3fb_cfb8_clear(struct vc_data *conp,
611 struct display *p,
612 int sy, int sx, int height, int width);
613static void pm3fb_cfb8_clear_margins(struct vc_data *conp,
614 struct display *p, int bottom_only);
615#endif /* FBCON_HAS_CFB8 */
616#if defined(FBCON_HAS_CFB8) || defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32)
617static void pm3fb_cfbX_bmove(struct display *p,
618 int sy, int sx,
619 int dy, int dx, int height, int width);
620static void pm3fb_cfbX_putc(struct vc_data *conp, struct display *p,
621 int c, int yy, int xx);
622static void pm3fb_cfbX_putcs(struct vc_data *conp, struct display *p,
623 const unsigned short *s, int count, int yy,
624 int xx);
625static void pm3fb_cfbX_revc(struct display *p, int xx, int yy);
626#endif /* FBCON_HAS_CFB8 || FBCON_HAS_CFB16 || FBCON_HAS_CFB32 */
627#endif /* PM3FB_USE_ACCEL */
628/* pre-init */
629static void pm3fb_mode_setup(char *mode, unsigned long board_num);
630static void pm3fb_pciid_setup(char *pciid, unsigned long board_num);
631static char *pm3fb_boardnum_setup(char *options, unsigned long *bn);
632static void pm3fb_real_setup(char *options);
633/* fbdev */
634static int pm3fb_encode_fix(struct fb_fix_screeninfo *fix,
635 const void *par, struct fb_info_gen *info);
636static int pm3fb_decode_var(const struct fb_var_screeninfo *var,
637 void *par, struct fb_info_gen *info);
638static void pm3fb_encode_depth(struct fb_var_screeninfo *var, long d);
639static int pm3fb_encode_var(struct fb_var_screeninfo *var,
640 const void *par, struct fb_info_gen *info);
641static void pm3fb_get_par(void *par, struct fb_info_gen *info);
642static void pm3fb_set_par(const void *par, struct fb_info_gen *info);
643static void pm3fb_set_color(struct pm3fb_info *l_fb_info,
644 unsigned char regno, unsigned char r,
645 unsigned char g, unsigned char b);
646static int pm3fb_getcolreg(unsigned regno, unsigned *red, unsigned *green,
647 unsigned *blue, unsigned *transp,
648 struct fb_info *info);
649static int pm3fb_setcolreg(unsigned regno, unsigned red, unsigned green,
650 unsigned blue, unsigned transp,
651 struct fb_info *info);
652static int pm3fb_blank(int blank_mode, struct fb_info_gen *info);
653static void pm3fb_set_disp(const void *par, struct display *disp,
654 struct fb_info_gen *info);
655static void pm3fb_detect(void);
656static int pm3fb_pan_display(const struct fb_var_screeninfo *var,
657 struct fb_info_gen *info);
658static int pm3fb_ioctl(struct fb_info *info, u_int cmd, u_long arg);
659
660
661/* the struct that hold them together */
662struct fbgen_hwswitch pm3fb_switch = {
663 pm3fb_detect, pm3fb_encode_fix, pm3fb_decode_var, pm3fb_encode_var,
664 pm3fb_get_par, pm3fb_set_par, pm3fb_getcolreg,
665 pm3fb_pan_display, pm3fb_blank, pm3fb_set_disp
666};
667 53
668static struct fb_ops pm3fb_ops = { 54/*
669 .owner = THIS_MODULE, 55 * If your driver supports multiple boards, you should make the
670 .fb_get_fix = fbgen_get_fix, 56 * below data types arrays, or allocate them dynamically (using kmalloc()).
671 .fb_get_var = fbgen_get_var, 57 */
672 .fb_set_var = fbgen_set_var,
673 .fb_get_cmap = fbgen_get_cmap,
674 .fb_set_cmap = fbgen_set_cmap,
675 .fb_setcolreg = pm3fb_setcolreg,
676 .fb_pan_display =fbgen_pan_display,
677 .fb_blank = fbgen_blank,
678 .fb_ioctl = pm3fb_ioctl,
679};
680 58
681#ifdef PM3FB_USE_ACCEL 59/*
682#ifdef FBCON_HAS_CFB32 60 * This structure defines the hardware state of the graphics card. Normally
683static struct display_switch pm3fb_cfb32 = { 61 * you place this in a header file in linux/include/video. This file usually
684 fbcon_cfb32_setup, pm3fb_cfbX_bmove, pm3fb_cfb32_clear, 62 * also includes register information. That allows other driver subsystems
685 pm3fb_cfbX_putc, pm3fb_cfbX_putcs, pm3fb_cfbX_revc, 63 * and userland applications the ability to use the same header file to
686 NULL /* cursor() */ , NULL /* set_font() */ , 64 * avoid duplicate work and easy porting of software.
687 pm3fb_cfb32_clear_margins, 65 */
688 FONTWIDTHRANGE(1, 16) /* true only if accelerated... */ 66struct pm3_par {
689}; 67 unsigned char __iomem *v_regs;/* virtual address of p_regs */
690#endif /* FBCON_HAS_CFB32 */ 68 u32 video; /* video flags before blanking */
691#ifdef FBCON_HAS_CFB16 69 u32 base; /* screen base (xoffset+yoffset) in 128 bits unit */
692static struct display_switch pm3fb_cfb16 = { 70 u32 palette[16];
693 fbcon_cfb16_setup, pm3fb_cfbX_bmove, pm3fb_cfb16_clear,
694 pm3fb_cfbX_putc, pm3fb_cfbX_putcs, pm3fb_cfbX_revc,
695 NULL /* cursor() */ , NULL /* set_font() */ ,
696 pm3fb_cfb16_clear_margins,
697 FONTWIDTHRANGE(1, 16) /* true only if accelerated... */
698};
699#endif /* FBCON_HAS_CFB16 */
700#ifdef FBCON_HAS_CFB8
701static struct display_switch pm3fb_cfb8 = {
702 fbcon_cfb8_setup, pm3fb_cfbX_bmove, pm3fb_cfb8_clear,
703 pm3fb_cfbX_putc, pm3fb_cfbX_putcs, pm3fb_cfbX_revc,
704 NULL /* cursor() */ , NULL /* set_font() */ ,
705 pm3fb_cfb8_clear_margins,
706 FONTWIDTHRANGE(1, 16) /* true only if accelerated... */
707};
708#endif /* FBCON_HAS_CFB8 */
709#endif /* PM3FB_USE_ACCEL */
710
711/* ****************************** */
712/* ***** card-specific data ***** */
713/* ****************************** */
714struct pm3fb_card_timings {
715 unsigned long memsize; /* 0 for last value (i.e. default) */
716 struct pm3fb_timings memt;
717}; 71};
718 72
719static struct pm3fb_card_timings t_FormacProFormance3[] = { 73/*
720 { 16, { 0x02e311b8, 0x06100205, 0x08000002, 0x00000079, 0x00000000} }, 74 * Here we define the default structs fb_fix_screeninfo and fb_var_screeninfo
721 { 0, { 0x02e311b8, 0x06100205, 0x08000002, 0x00000079, 0x00000000} } /* from 16 MB PF3 */ 75 * if we don't use modedb. If we do use modedb see pm3fb_init how to use it
76 * to get a fb_var_screeninfo. Otherwise define a default var as well.
77 */
78static struct fb_fix_screeninfo pm3fb_fix __devinitdata = {
79 .id = "Permedia3",
80 .type = FB_TYPE_PACKED_PIXELS,
81 .visual = FB_VISUAL_PSEUDOCOLOR,
82 .xpanstep = 1,
83 .ypanstep = 1,
84 .ywrapstep = 0,
85 .accel = FB_ACCEL_NONE,
722}; 86};
723 87
724static struct pm3fb_card_timings t_AppianJeronimo2000[] = { 88/*
725 { 32, { 0x02e311B8, 0x07424905, 0x0c000003, 0x00000061, 0x00000000} }, 89 * Utility functions
726 { 0, { 0x02e311B8, 0x07424905, 0x0c000003, 0x00000061, 0x00000000} } /* from 32MB J2000 */ 90 */
727};
728 91
729static struct pm3fb_card_timings t_3DLabsOxygenVX1[] = { 92static inline u32 PM3_READ_REG(struct pm3_par *par, s32 off)
730 { 32, { 0x30e311b8, 0x08501204, 0x08000002, 0x0000006b, 0x00000000} }, 93{
731 { 0, { 0x30e311b8, 0x08501204, 0x08000002, 0x0000006b, 0x00000000} } /* from 32MB VX1 */ 94 return fb_readl(par->v_regs + off);
732}; 95}
733 96
734static struct { 97static inline void PM3_WRITE_REG(struct pm3_par *par, s32 off, u32 v)
735 char cardname[32]; /* recognized card name */ 98{
736 u16 subvendor; /* subvendor of the card */ 99 fb_writel(v, par->v_regs + off);
737 u16 subdevice; /* subdevice of the card */ 100}
738 u8 func; /* function of the card to which the extra init apply */
739 void (*specific_setup)(struct pm3fb_info *l_fb_info); /* card/func specific setup, done before _any_ FB access */
740 struct pm3fb_card_timings *c_memt; /* defauls timings for the boards */
741} cardbase[] = {
742 { "Unknown Permedia3 board", 0xFFFF, 0xFFFF, 0xFF, NULL, NULL },
743 { "Appian Jeronimo 2000 head 1", 0x1097, 0x3d32, 1, NULL,
744 t_AppianJeronimo2000
745 },
746 { "Appian Jeronimo 2000 head 2", 0x1097, 0x3d32, 2, pm3fb_j2000_setup,
747 t_AppianJeronimo2000
748 },
749 { "Formac ProFormance 3", PCI_VENDOR_ID_3DLABS, 0x000a, 0, NULL, /* Formac use 3DLabs ID ?!? */
750 t_FormacProFormance3
751 },
752 { "3DLabs Permedia3 Create!", PCI_VENDOR_ID_3DLABS, 0x0127, 0, NULL, NULL },
753 { "3DLabs Oxygen VX1 PCI", PCI_VENDOR_ID_3DLABS, 0x0121, 0, NULL,
754 t_3DLabsOxygenVX1
755 },
756 { "3DLabs Oxygen VX1 AGP", PCI_VENDOR_ID_3DLABS, 0x0125, 0, NULL, NULL },
757 { "3DLabs Oxygen VX1-16 AGP", PCI_VENDOR_ID_3DLABS, 0x0140, 0, NULL, NULL },
758 { "3DLabs Oxygen VX1-1600SW PCI", PCI_VENDOR_ID_3DLABS, 0x0800, 0, NULL, NULL },
759 { "\0", 0x0, 0x0, 0, NULL, NULL }
760};
761 101
762/* ********************************** */ 102static inline void PM3_WAIT(struct pm3_par *par, u32 n)
763/* ***** card-specific function ***** */ 103{
764/* ********************************** */ 104 while (PM3_READ_REG(par, PM3InFIFOSpace) < n);
765static void pm3fb_j2000_setup(struct pm3fb_info *l_fb_info)
766{ /* the appian j2000 require more initialization of the second head */
767 /* l_fb_info must point to the _second_ head of the J2000 */
768
769 DTRACE;
770
771 l_fb_info->memt = t_AppianJeronimo2000[0].memt; /* 32 MB, first and only j2000 ? */
772
773 pm3fb_write_memory_timings(l_fb_info);
774} 105}
775 106
776/* *************************************** */ 107static inline void PM3_SLOW_WRITE_REG(struct pm3_par *par, s32 off, u32 v)
777/* ***** permedia3-specific function ***** */
778/* *************************************** */
779static pm3fb_timing_result pm3fb_preserve_memory_timings(struct pm3fb_info *l_fb_info)
780{ 108{
781 l_fb_info->memt.caps = PM3_READ_REG(PM3LocalMemCaps); 109 if (par->v_regs) {
782 l_fb_info->memt.timings = PM3_READ_REG(PM3LocalMemTimings); 110 mb();
783 l_fb_info->memt.control = PM3_READ_REG(PM3LocalMemControl); 111 PM3_WAIT(par, 1);
784 l_fb_info->memt.refresh = PM3_READ_REG(PM3LocalMemRefresh); 112 wmb();
785 l_fb_info->memt.powerdown = PM3_READ_REG(PM3LocalMemPowerDown); 113 PM3_WRITE_REG(par, off, v);
786
787 if ((l_fb_info->memt.caps == PM3FB_UNKNOWN_TIMING_VALUE) ||
788 (l_fb_info->memt.timings == PM3FB_UNKNOWN_TIMING_VALUE) ||
789 (l_fb_info->memt.control == PM3FB_UNKNOWN_TIMING_VALUE) ||
790 (l_fb_info->memt.refresh == PM3FB_UNKNOWN_TIMING_VALUE) ||
791 (l_fb_info->memt.powerdown == PM3FB_UNKNOWN_TIMING_VALUE))
792 {
793 printk(KERN_ERR "pm3fb: invalid memory timings in permedia3 board #%ld\n", l_fb_info->board_num);
794 return(pm3fb_try_memory_timings(l_fb_info));
795 } 114 }
796 return(pm3fb_timing_ok);
797} 115}
798 116
799static pm3fb_timing_result pm3fb_try_memory_timings(struct pm3fb_info *l_fb_info) 117static inline void PM3_SET_INDEX(struct pm3_par *par, unsigned index)
800{ 118{
801 if (cardbase[l_fb_info->board_type].c_memt) 119 PM3_SLOW_WRITE_REG(par, PM3RD_IndexHigh, (index >> 8) & 0xff);
802 { 120 PM3_SLOW_WRITE_REG(par, PM3RD_IndexLow, index & 0xff);
803 int i = 0, done = 0; 121}
804 while (!done) 122
805 { 123static inline void PM3_WRITE_DAC_REG(struct pm3_par *par, unsigned r, u8 v)
806 if ((cardbase[l_fb_info->board_type].c_memt[i].memsize == l_fb_info->fb_size) 124{
807 || !(cardbase[l_fb_info->board_type].c_memt[i].memsize)) 125 PM3_SET_INDEX(par, r);
808 { /* will use the 0-sized timings by default */ 126 wmb();
809 done = 1; 127 PM3_WRITE_REG(par, PM3RD_IndexedData, v);
810 l_fb_info->memt = cardbase[l_fb_info->board_type].c_memt[i].memt;
811 printk(KERN_WARNING "pm3fb: trying to use predefined memory timings for permedia3 board #%ld (%s, %ld MB)\n",
812 l_fb_info->board_num,
813 cardbase[l_fb_info->board_type].cardname,
814 cardbase[l_fb_info->board_type].c_memt[i].memsize);
815 pm3fb_write_memory_timings(l_fb_info);
816 return(pm3fb_timing_retry);
817 }
818 i++;
819 }
820 } else
821 return(pm3fb_timing_problem);
822 return(pm3fb_timing_ok);
823} 128}
824 129
825static void pm3fb_write_memory_timings(struct pm3fb_info *l_fb_info) 130static inline void pm3fb_set_color(struct pm3_par *par, unsigned char regno,
131 unsigned char r, unsigned char g, unsigned char b)
826{ 132{
827 unsigned char m, n, p; 133 PM3_SLOW_WRITE_REG(par, PM3RD_PaletteWriteAddress, regno);
828 unsigned long clockused; 134 PM3_SLOW_WRITE_REG(par, PM3RD_PaletteData, r);
829 135 PM3_SLOW_WRITE_REG(par, PM3RD_PaletteData, g);
830 PM3_SLOW_WRITE_REG(PM3LocalMemCaps, l_fb_info->memt.caps); 136 PM3_SLOW_WRITE_REG(par, PM3RD_PaletteData, b);
831 PM3_SLOW_WRITE_REG(PM3LocalMemTimings, l_fb_info->memt.timings);
832 PM3_SLOW_WRITE_REG(PM3LocalMemControl, l_fb_info->memt.control);
833 PM3_SLOW_WRITE_REG(PM3LocalMemRefresh, l_fb_info->memt.refresh);
834 PM3_SLOW_WRITE_REG(PM3LocalMemPowerDown, l_fb_info->memt.powerdown);
835
836 clockused =
837 pm3fb_CalculateClock(l_fb_info, 2 * 105000, PM3_REF_CLOCK, &m,
838 &n, &p);
839
840 PM3_WRITE_DAC_REG(PM3RD_KClkPreScale, m);
841 PM3_WRITE_DAC_REG(PM3RD_KClkFeedbackScale, n);
842 PM3_WRITE_DAC_REG(PM3RD_KClkPostScale, p);
843 PM3_WRITE_DAC_REG(PM3RD_KClkControl,
844 PM3RD_KClkControl_STATE_RUN |
845 PM3RD_KClkControl_SOURCE_PLL |
846 PM3RD_KClkControl_ENABLE);
847 PM3_WRITE_DAC_REG(PM3RD_MClkControl,
848 PM3RD_MClkControl_STATE_RUN |
849 PM3RD_MClkControl_SOURCE_KCLK |
850 PM3RD_MClkControl_ENABLE);
851 PM3_WRITE_DAC_REG(PM3RD_SClkControl,
852 PM3RD_SClkControl_STATE_RUN |
853 PM3RD_SClkControl_SOURCE_PCLK |
854 PM3RD_SClkControl_ENABLE);
855} 137}
856 138
857static unsigned long pm3fb_read_dac_reg(struct pm3fb_info *l_fb_info, 139static void pm3fb_clear_colormap(struct pm3_par *par,
858 unsigned long r) 140 unsigned char r, unsigned char g, unsigned char b)
859{ 141{
860 DASSERT((l_fb_info->vIOBase != (unsigned char *) (-1)), 142 int i;
861 "l_fb_info->vIOBase mapped in read dac reg\n"); 143
862 PM3_SET_INDEX(r); 144 for (i = 0; i < 256 ; i++) /* fill color map with white */
863 mb(); 145 pm3fb_set_color(par, i, r, g, b);
864 return (PM3_READ_REG(PM3RD_IndexedData)); 146
865} 147}
866 148
867/* Calculating various clock parameter */ 149/* Calculating various clock parameter */
868static unsigned long pm3fb_CalculateClock(struct pm3fb_info *l_fb_info, unsigned long reqclock, /* In kHz units */ 150static void pm3fb_calculate_clock(unsigned long reqclock,
869 unsigned long refclock, /* In kHz units */ 151 unsigned char *prescale,
870 unsigned char *prescale, /* ClkPreScale */ 152 unsigned char *feedback,
871 unsigned char *feedback, /* ClkFeedBackScale */ 153 unsigned char *postscale)
872 unsigned char *postscale
873 /* ClkPostScale */ )
874{ 154{
875 int f, pre, post; 155 int f, pre, post;
876 unsigned long freq; 156 unsigned long freq;
877 long freqerr = 1000; 157 long freqerr = 1000;
878 unsigned long actualclock = 0; 158 long currerr;
879
880 DTRACE;
881 159
882 for (f = 1; f < 256; f++) { 160 for (f = 1; f < 256; f++) {
883 for (pre = 1; pre < 256; pre++) { 161 for (pre = 1; pre < 256; pre++) {
884 for (post = 0; post < 5; post++) { 162 for (post = 0; post < 5; post++) {
885 freq = 163 freq = ((2*PM3_REF_CLOCK * f) >> post) / pre;
886 ((2 * refclock * f) / 164 currerr = (reqclock > freq)
887 (pre * (1 << post))); 165 ? reqclock - freq
888 if ((reqclock > freq - freqerr) 166 : freq - reqclock;
889 && (reqclock < freq + freqerr)) { 167 if (currerr < freqerr) {
890 freqerr = 168 freqerr = currerr;
891 (reqclock >
892 freq) ? reqclock -
893 freq : freq - reqclock;
894 *feedback = f; 169 *feedback = f;
895 *prescale = pre; 170 *prescale = pre;
896 *postscale = post; 171 *postscale = post;
897 actualclock = freq;
898 } 172 }
899 } 173 }
900 } 174 }
901 } 175 }
902
903 return (actualclock);
904} 176}
905 177
906static int pm3fb_Shiftbpp(struct pm3fb_info *l_fb_info, 178static inline int pm3fb_shift_bpp(unsigned long depth, int v)
907 unsigned long depth, int v)
908{ 179{
909 DTRACE;
910
911 switch (depth) { 180 switch (depth) {
912 case 8: 181 case 8:
913 return (v >> 4); 182 return (v >> 4);
@@ -918,181 +187,59 @@ static int pm3fb_Shiftbpp(struct pm3fb_info *l_fb_info,
918 case 32: 187 case 32:
919 return (v >> 2); 188 return (v >> 2);
920 } 189 }
921 DPRINTK(1, "Unsupported depth %ld\n", depth); 190 DPRINTK("Unsupported depth %ld\n", depth);
922 return (0); 191 return 0;
923}
924
925static int pm3fb_Unshiftbpp(struct pm3fb_info *l_fb_info,
926 unsigned long depth, int v)
927{
928 DTRACE;
929
930 switch (depth) {
931 case 8:
932 return (v << 4);
933 case 12:
934 case 15:
935 case 16:
936 return (v << 3);
937 case 32:
938 return (v << 2);
939 }
940 DPRINTK(1, "Unsupported depth %ld\n", depth);
941 return (0);
942}
943
944static void pm3fb_mapIO(struct pm3fb_info *l_fb_info)
945{
946 DTRACE;
947
948 l_fb_info->vIOBase =
949 ioremap((unsigned long) l_fb_info->pIOBase, PM3_REGS_SIZE);
950 l_fb_info->v_fb =
951 ioremap((unsigned long) l_fb_info->p_fb, l_fb_info->fb_size);
952 DPRINTK(2, "IO mapping : IOBase %lx / %lx, fb %lx / %lx\n",
953 (unsigned long) l_fb_info->pIOBase,
954 (unsigned long) l_fb_info->vIOBase,
955 (unsigned long) l_fb_info->p_fb,
956 (unsigned long) l_fb_info->v_fb);
957}
958
959static void pm3fb_unmapIO(struct pm3fb_info *l_fb_info)
960{
961 DTRACE;
962
963 iounmap(l_fb_info->vIOBase);
964 iounmap(l_fb_info->v_fb);
965 l_fb_info->vIOBase = (unsigned char *) -1;
966 l_fb_info->v_fb = (unsigned char *) -1;
967}
968
969#if defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2)
970static void pm3fb_show_cur_mode(struct pm3fb_info *l_fb_info)
971{
972 DPRINTK(2, "PM3Aperture0: 0x%08x\n", PM3_READ_REG(PM3Aperture0));
973 DPRINTK(2, "PM3Aperture1: 0x%08x\n", PM3_READ_REG(PM3Aperture1));
974 DPRINTK(2, "PM3ByAperture1Mode: 0x%08x\n",
975 PM3_READ_REG(PM3ByAperture1Mode));
976 DPRINTK(2, "PM3ByAperture2Mode: 0x%08x\n",
977 PM3_READ_REG(PM3ByAperture2Mode));
978 DPRINTK(2, "PM3ChipConfig: 0x%08x\n", PM3_READ_REG(PM3ChipConfig));
979 DPRINTK(2, "PM3FIFODis: 0x%08x\n", PM3_READ_REG(PM3FIFODis));
980 DPRINTK(2, "PM3HTotal: 0x%08x\n", PM3_READ_REG(PM3HTotal));
981 DPRINTK(2, "PM3HbEnd: 0x%08x\n", PM3_READ_REG(PM3HbEnd));
982 DPRINTK(2, "PM3HgEnd: 0x%08x\n", PM3_READ_REG(PM3HgEnd));
983 DPRINTK(2, "PM3HsEnd: 0x%08x\n", PM3_READ_REG(PM3HsEnd));
984 DPRINTK(2, "PM3HsStart: 0x%08x\n", PM3_READ_REG(PM3HsStart));
985 DPRINTK(2, "PM3MemBypassWriteMask: 0x%08x\n",
986 PM3_READ_REG(PM3MemBypassWriteMask));
987 DPRINTK(2, "PM3RD_IndexControl: 0x%08x\n",
988 PM3_READ_REG(PM3RD_IndexControl));
989 DPRINTK(2, "PM3ScreenBase: 0x%08x\n", PM3_READ_REG(PM3ScreenBase));
990 DPRINTK(2, "PM3ScreenStride: 0x%08x\n",
991 PM3_READ_REG(PM3ScreenStride));
992 DPRINTK(2, "PM3VClkCtl: 0x%08x\n", PM3_READ_REG(PM3VClkCtl));
993 DPRINTK(2, "PM3VTotal: 0x%08x\n", PM3_READ_REG(PM3VTotal));
994 DPRINTK(2, "PM3VbEnd: 0x%08x\n", PM3_READ_REG(PM3VbEnd));
995 DPRINTK(2, "PM3VideoControl: 0x%08x\n",
996 PM3_READ_REG(PM3VideoControl));
997 DPRINTK(2, "PM3VsEnd: 0x%08x\n", PM3_READ_REG(PM3VsEnd));
998 DPRINTK(2, "PM3VsStart: 0x%08x\n", PM3_READ_REG(PM3VsStart));
999
1000 DPRINTK(2, "PM3RD_ColorFormat: %ld\n",
1001 PM3_READ_DAC_REG(PM3RD_ColorFormat));
1002 DPRINTK(2, "PM3RD_DACControl: %ld\n",
1003 PM3_READ_DAC_REG(PM3RD_DACControl));
1004 DPRINTK(2, "PM3RD_DClk0FeedbackScale: %ld\n",
1005 PM3_READ_DAC_REG(PM3RD_DClk0FeedbackScale));
1006 DPRINTK(2, "PM3RD_DClk0PostScale: %ld\n",
1007 PM3_READ_DAC_REG(PM3RD_DClk0PostScale));
1008 DPRINTK(2, "PM3RD_DClk0PreScale: %ld\n",
1009 PM3_READ_DAC_REG(PM3RD_DClk0PreScale));
1010 DPRINTK(2, "[not set] PM3RD_IndexControl: %ld\n",
1011 PM3_READ_DAC_REG(PM3RD_IndexControl));
1012 DPRINTK(2, "PM3RD_MiscControl: %ld\n",
1013 PM3_READ_DAC_REG(PM3RD_MiscControl));
1014 DPRINTK(2, "PM3RD_PixelSize: %ld\n",
1015 PM3_READ_DAC_REG(PM3RD_PixelSize));
1016 DPRINTK(2, "PM3RD_SyncControl: %ld\n",
1017 PM3_READ_DAC_REG(PM3RD_SyncControl));
1018}
1019
1020#endif /* defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2) */
1021static void pm3fb_show_cur_timing(struct pm3fb_info *l_fb_info)
1022{
1023 u16 subvendor, subdevice;
1024
1025 if ((!pci_read_config_word
1026 (l_fb_info->dev, PCI_SUBSYSTEM_VENDOR_ID, &subvendor))
1027 &&
1028 (!pci_read_config_word
1029 (l_fb_info->dev, PCI_SUBSYSTEM_ID, &subdevice))) {
1030 /* well, nothing... */
1031 } else {
1032 subvendor = subdevice = (u16)-1;
1033 }
1034
1035 printk(KERN_INFO "pm3fb: memory timings for board #%ld (subvendor: 0x%hx, subdevice: 0x%hx)\n", l_fb_info->board_num, subvendor, subdevice);
1036 printk(KERN_INFO " PM3LocalMemCaps: 0x%08x\n",
1037 PM3_READ_REG(PM3LocalMemCaps));
1038 printk(KERN_INFO " PM3LocalMemTimings: 0x%08x\n",
1039 PM3_READ_REG(PM3LocalMemTimings));
1040 printk(KERN_INFO " PM3LocalMemControl: 0x%08x\n",
1041 PM3_READ_REG(PM3LocalMemControl));
1042 printk(KERN_INFO " PM3LocalMemRefresh: 0x%08x\n",
1043 PM3_READ_REG(PM3LocalMemRefresh));
1044 printk(KERN_INFO " PM3LocalMemPowerDown: 0x%08x\n",
1045 PM3_READ_REG(PM3LocalMemPowerDown));
1046} 192}
1047 193
1048/* write the mode to registers */ 194/* write the mode to registers */
1049static void pm3fb_write_mode(struct pm3fb_info *l_fb_info) 195static void pm3fb_write_mode(struct fb_info *info)
1050{ 196{
197 struct pm3_par *par = info->par;
1051 char tempsync = 0x00, tempmisc = 0x00; 198 char tempsync = 0x00, tempmisc = 0x00;
1052 DTRACE; 199 const u32 hsstart = info->var.right_margin;
1053 200 const u32 hsend = hsstart + info->var.hsync_len;
1054 PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask, 0xffffffff); 201 const u32 hbend = hsend + info->var.left_margin;
1055 PM3_SLOW_WRITE_REG(PM3Aperture0, 0x00000000); 202 const u32 xres = (info->var.xres + 31) & ~31;
1056 PM3_SLOW_WRITE_REG(PM3Aperture1, 0x00000000); 203 const u32 htotal = xres + hbend;
1057 PM3_SLOW_WRITE_REG(PM3FIFODis, 0x00000007); 204 const u32 vsstart = info->var.lower_margin;
1058 205 const u32 vsend = vsstart + info->var.vsync_len;
1059 PM3_SLOW_WRITE_REG(PM3HTotal, 206 const u32 vbend = vsend + info->var.upper_margin;
1060 pm3fb_Shiftbpp(l_fb_info, 207 const u32 vtotal = info->var.yres + vbend;
1061 l_fb_info->current_par->depth, 208 const u32 width = (info->var.xres_virtual + 7) & ~7;
1062 l_fb_info->current_par->htotal - 209
1063 1)); 210 PM3_SLOW_WRITE_REG(par, PM3MemBypassWriteMask, 0xffffffff);
1064 PM3_SLOW_WRITE_REG(PM3HsEnd, 211 PM3_SLOW_WRITE_REG(par, PM3Aperture0, 0x00000000);
1065 pm3fb_Shiftbpp(l_fb_info, 212 PM3_SLOW_WRITE_REG(par, PM3Aperture1, 0x00000000);
1066 l_fb_info->current_par->depth, 213 PM3_SLOW_WRITE_REG(par, PM3FIFODis, 0x00000007);
1067 l_fb_info->current_par->hsend)); 214
1068 PM3_SLOW_WRITE_REG(PM3HsStart, 215 PM3_SLOW_WRITE_REG(par, PM3HTotal,
1069 pm3fb_Shiftbpp(l_fb_info, 216 pm3fb_shift_bpp(info->var.bits_per_pixel,
1070 l_fb_info->current_par->depth, 217 htotal - 1));
1071 l_fb_info->current_par-> 218 PM3_SLOW_WRITE_REG(par, PM3HsEnd,
219 pm3fb_shift_bpp(info->var.bits_per_pixel,
220 hsend));
221 PM3_SLOW_WRITE_REG(par, PM3HsStart,
222 pm3fb_shift_bpp(info->var.bits_per_pixel,
1072 hsstart)); 223 hsstart));
1073 PM3_SLOW_WRITE_REG(PM3HbEnd, 224 PM3_SLOW_WRITE_REG(par, PM3HbEnd,
1074 pm3fb_Shiftbpp(l_fb_info, 225 pm3fb_shift_bpp(info->var.bits_per_pixel,
1075 l_fb_info->current_par->depth, 226 hbend));
1076 l_fb_info->current_par->hbend)); 227 PM3_SLOW_WRITE_REG(par, PM3HgEnd,
1077 PM3_SLOW_WRITE_REG(PM3HgEnd, 228 pm3fb_shift_bpp(info->var.bits_per_pixel,
1078 pm3fb_Shiftbpp(l_fb_info, 229 hbend));
1079 l_fb_info->current_par->depth, 230 PM3_SLOW_WRITE_REG(par, PM3ScreenStride,
1080 l_fb_info->current_par->hbend)); 231 pm3fb_shift_bpp(info->var.bits_per_pixel,
1081 PM3_SLOW_WRITE_REG(PM3ScreenStride, 232 width));
1082 pm3fb_Shiftbpp(l_fb_info, 233 PM3_SLOW_WRITE_REG(par, PM3VTotal, vtotal - 1);
1083 l_fb_info->current_par->depth, 234 PM3_SLOW_WRITE_REG(par, PM3VsEnd, vsend - 1);
1084 l_fb_info->current_par->stride)); 235 PM3_SLOW_WRITE_REG(par, PM3VsStart, vsstart - 1);
1085 PM3_SLOW_WRITE_REG(PM3VTotal, l_fb_info->current_par->vtotal - 1); 236 PM3_SLOW_WRITE_REG(par, PM3VbEnd, vbend);
1086 PM3_SLOW_WRITE_REG(PM3VsEnd, l_fb_info->current_par->vsend - 1); 237
1087 PM3_SLOW_WRITE_REG(PM3VsStart, 238 switch (info->var.bits_per_pixel) {
1088 l_fb_info->current_par->vsstart - 1);
1089 PM3_SLOW_WRITE_REG(PM3VbEnd, l_fb_info->current_par->vbend);
1090
1091 switch (l_fb_info->current_par->depth) {
1092 case 8: 239 case 8:
1093 PM3_SLOW_WRITE_REG(PM3ByAperture1Mode, 240 PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode,
1094 PM3ByApertureMode_PIXELSIZE_8BIT); 241 PM3ByApertureMode_PIXELSIZE_8BIT);
1095 PM3_SLOW_WRITE_REG(PM3ByAperture2Mode, 242 PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode,
1096 PM3ByApertureMode_PIXELSIZE_8BIT); 243 PM3ByApertureMode_PIXELSIZE_8BIT);
1097 break; 244 break;
1098 245
@@ -1100,15 +247,15 @@ static void pm3fb_write_mode(struct pm3fb_info *l_fb_info)
1100 case 15: 247 case 15:
1101 case 16: 248 case 16:
1102#ifndef __BIG_ENDIAN 249#ifndef __BIG_ENDIAN
1103 PM3_SLOW_WRITE_REG(PM3ByAperture1Mode, 250 PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode,
1104 PM3ByApertureMode_PIXELSIZE_16BIT); 251 PM3ByApertureMode_PIXELSIZE_16BIT);
1105 PM3_SLOW_WRITE_REG(PM3ByAperture2Mode, 252 PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode,
1106 PM3ByApertureMode_PIXELSIZE_16BIT); 253 PM3ByApertureMode_PIXELSIZE_16BIT);
1107#else 254#else
1108 PM3_SLOW_WRITE_REG(PM3ByAperture1Mode, 255 PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode,
1109 PM3ByApertureMode_PIXELSIZE_16BIT | 256 PM3ByApertureMode_PIXELSIZE_16BIT |
1110 PM3ByApertureMode_BYTESWAP_BADC); 257 PM3ByApertureMode_BYTESWAP_BADC);
1111 PM3_SLOW_WRITE_REG(PM3ByAperture2Mode, 258 PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode,
1112 PM3ByApertureMode_PIXELSIZE_16BIT | 259 PM3ByApertureMode_PIXELSIZE_16BIT |
1113 PM3ByApertureMode_BYTESWAP_BADC); 260 PM3ByApertureMode_BYTESWAP_BADC);
1114#endif /* ! __BIG_ENDIAN */ 261#endif /* ! __BIG_ENDIAN */
@@ -1116,23 +263,23 @@ static void pm3fb_write_mode(struct pm3fb_info *l_fb_info)
1116 263
1117 case 32: 264 case 32:
1118#ifndef __BIG_ENDIAN 265#ifndef __BIG_ENDIAN
1119 PM3_SLOW_WRITE_REG(PM3ByAperture1Mode, 266 PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode,
1120 PM3ByApertureMode_PIXELSIZE_32BIT); 267 PM3ByApertureMode_PIXELSIZE_32BIT);
1121 PM3_SLOW_WRITE_REG(PM3ByAperture2Mode, 268 PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode,
1122 PM3ByApertureMode_PIXELSIZE_32BIT); 269 PM3ByApertureMode_PIXELSIZE_32BIT);
1123#else 270#else
1124 PM3_SLOW_WRITE_REG(PM3ByAperture1Mode, 271 PM3_SLOW_WRITE_REG(par, PM3ByAperture1Mode,
1125 PM3ByApertureMode_PIXELSIZE_32BIT | 272 PM3ByApertureMode_PIXELSIZE_32BIT |
1126 PM3ByApertureMode_BYTESWAP_DCBA); 273 PM3ByApertureMode_BYTESWAP_DCBA);
1127 PM3_SLOW_WRITE_REG(PM3ByAperture2Mode, 274 PM3_SLOW_WRITE_REG(par, PM3ByAperture2Mode,
1128 PM3ByApertureMode_PIXELSIZE_32BIT | 275 PM3ByApertureMode_PIXELSIZE_32BIT |
1129 PM3ByApertureMode_BYTESWAP_DCBA); 276 PM3ByApertureMode_BYTESWAP_DCBA);
1130#endif /* ! __BIG_ENDIAN */ 277#endif /* ! __BIG_ENDIAN */
1131 break; 278 break;
1132 279
1133 default: 280 default:
1134 DPRINTK(1, "Unsupported depth %d\n", 281 DPRINTK("Unsupported depth %d\n",
1135 l_fb_info->current_par->depth); 282 info->var.bits_per_pixel);
1136 break; 283 break;
1137 } 284 }
1138 285
@@ -1143,95 +290,86 @@ static void pm3fb_write_mode(struct pm3fb_info *l_fb_info)
1143 * sync options in PM3RD_SyncControl. --rmk 290 * sync options in PM3RD_SyncControl. --rmk
1144 */ 291 */
1145 { 292 {
1146 unsigned int video = l_fb_info->current_par->video; 293 unsigned int video = par->video;
1147 294
1148 video &= ~(PM3VideoControl_HSYNC_MASK | 295 video &= ~(PM3VideoControl_HSYNC_MASK |
1149 PM3VideoControl_VSYNC_MASK); 296 PM3VideoControl_VSYNC_MASK);
1150 video |= PM3VideoControl_HSYNC_ACTIVE_HIGH | 297 video |= PM3VideoControl_HSYNC_ACTIVE_HIGH |
1151 PM3VideoControl_VSYNC_ACTIVE_HIGH; 298 PM3VideoControl_VSYNC_ACTIVE_HIGH;
1152 PM3_SLOW_WRITE_REG(PM3VideoControl, video); 299 PM3_SLOW_WRITE_REG(par, PM3VideoControl, video);
1153 } 300 }
1154 PM3_SLOW_WRITE_REG(PM3VClkCtl, 301 PM3_SLOW_WRITE_REG(par, PM3VClkCtl,
1155 (PM3_READ_REG(PM3VClkCtl) & 0xFFFFFFFC)); 302 (PM3_READ_REG(par, PM3VClkCtl) & 0xFFFFFFFC));
1156 PM3_SLOW_WRITE_REG(PM3ScreenBase, l_fb_info->current_par->base); 303 PM3_SLOW_WRITE_REG(par, PM3ScreenBase, par->base);
1157 PM3_SLOW_WRITE_REG(PM3ChipConfig, 304 PM3_SLOW_WRITE_REG(par, PM3ChipConfig,
1158 (PM3_READ_REG(PM3ChipConfig) & 0xFFFFFFFD)); 305 (PM3_READ_REG(par, PM3ChipConfig) & 0xFFFFFFFD));
1159 306
1160 { 307 {
1161 unsigned char m; /* ClkPreScale */ 308 unsigned char uninitialized_var(m); /* ClkPreScale */
1162 unsigned char n; /* ClkFeedBackScale */ 309 unsigned char uninitialized_var(n); /* ClkFeedBackScale */
1163 unsigned char p; /* ClkPostScale */ 310 unsigned char uninitialized_var(p); /* ClkPostScale */
1164 (void)pm3fb_CalculateClock(l_fb_info, l_fb_info->current_par->pixclock, PM3_REF_CLOCK, &m, &n, &p); 311 unsigned long pixclock = PICOS2KHZ(info->var.pixclock);
1165 312
1166 DPRINTK(2, 313 (void)pm3fb_calculate_clock(pixclock, &m, &n, &p);
1167 "Pixclock: %d, Pre: %d, Feedback: %d, Post: %d\n", 314
1168 l_fb_info->current_par->pixclock, (int) m, (int) n, 315 DPRINTK("Pixclock: %ld, Pre: %d, Feedback: %d, Post: %d\n",
1169 (int) p); 316 pixclock, (int) m, (int) n, (int) p);
1170 317
1171 PM3_WRITE_DAC_REG(PM3RD_DClk0PreScale, m); 318 PM3_WRITE_DAC_REG(par, PM3RD_DClk0PreScale, m);
1172 PM3_WRITE_DAC_REG(PM3RD_DClk0FeedbackScale, n); 319 PM3_WRITE_DAC_REG(par, PM3RD_DClk0FeedbackScale, n);
1173 PM3_WRITE_DAC_REG(PM3RD_DClk0PostScale, p); 320 PM3_WRITE_DAC_REG(par, PM3RD_DClk0PostScale, p);
1174 } 321 }
1175 /* 322 /*
1176 PM3_WRITE_DAC_REG(PM3RD_IndexControl, 0x00); 323 PM3_WRITE_DAC_REG(par, PM3RD_IndexControl, 0x00);
1177 */ 324 */
1178 /* 325 /*
1179 PM3_SLOW_WRITE_REG(PM3RD_IndexControl, 0x00); 326 PM3_SLOW_WRITE_REG(par, PM3RD_IndexControl, 0x00);
1180 */ 327 */
1181 if ((l_fb_info->current_par->video & PM3VideoControl_HSYNC_MASK) == 328 if ((par->video & PM3VideoControl_HSYNC_MASK) ==
1182 PM3VideoControl_HSYNC_ACTIVE_HIGH) 329 PM3VideoControl_HSYNC_ACTIVE_HIGH)
1183 tempsync |= PM3RD_SyncControl_HSYNC_ACTIVE_HIGH; 330 tempsync |= PM3RD_SyncControl_HSYNC_ACTIVE_HIGH;
1184 if ((l_fb_info->current_par->video & PM3VideoControl_VSYNC_MASK) == 331 if ((par->video & PM3VideoControl_VSYNC_MASK) ==
1185 PM3VideoControl_VSYNC_ACTIVE_HIGH) 332 PM3VideoControl_VSYNC_ACTIVE_HIGH)
1186 tempsync |= PM3RD_SyncControl_VSYNC_ACTIVE_HIGH; 333 tempsync |= PM3RD_SyncControl_VSYNC_ACTIVE_HIGH;
1187
1188 PM3_WRITE_DAC_REG(PM3RD_SyncControl, tempsync);
1189 DPRINTK(2, "PM3RD_SyncControl: %d\n", tempsync);
1190
1191 if (flatpanel[l_fb_info->board_num])
1192 {
1193 PM3_WRITE_DAC_REG(PM3RD_DACControl, PM3RD_DACControl_BLANK_PEDESTAL_ENABLE);
1194 PM3_WAIT(2);
1195 PM3_WRITE_REG(PM3VSConfiguration, 0x06);
1196 PM3_WRITE_REG(0x5a00, 1 << 14); /* black magic... */
1197 tempmisc = PM3RD_MiscControl_VSB_OUTPUT_ENABLE;
1198 }
1199 else
1200 PM3_WRITE_DAC_REG(PM3RD_DACControl, 0x00);
1201 334
1202 switch (l_fb_info->current_par->depth) { 335 PM3_WRITE_DAC_REG(par, PM3RD_SyncControl, tempsync);
336 DPRINTK("PM3RD_SyncControl: %d\n", tempsync);
337
338 PM3_WRITE_DAC_REG(par, PM3RD_DACControl, 0x00);
339
340 switch (info->var.bits_per_pixel) {
1203 case 8: 341 case 8:
1204 PM3_WRITE_DAC_REG(PM3RD_PixelSize, 342 PM3_WRITE_DAC_REG(par, PM3RD_PixelSize,
1205 PM3RD_PixelSize_8_BIT_PIXELS); 343 PM3RD_PixelSize_8_BIT_PIXELS);
1206 PM3_WRITE_DAC_REG(PM3RD_ColorFormat, 344 PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat,
1207 PM3RD_ColorFormat_CI8_COLOR | 345 PM3RD_ColorFormat_CI8_COLOR |
1208 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW); 346 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW);
1209 tempmisc |= PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; 347 tempmisc |= PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
1210 break; 348 break;
1211 case 12: 349 case 12:
1212 PM3_WRITE_DAC_REG(PM3RD_PixelSize, 350 PM3_WRITE_DAC_REG(par, PM3RD_PixelSize,
1213 PM3RD_PixelSize_16_BIT_PIXELS); 351 PM3RD_PixelSize_16_BIT_PIXELS);
1214 PM3_WRITE_DAC_REG(PM3RD_ColorFormat, 352 PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat,
1215 PM3RD_ColorFormat_4444_COLOR | 353 PM3RD_ColorFormat_4444_COLOR |
1216 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW | 354 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW |
1217 PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE); 355 PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE);
1218 tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE | 356 tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
1219 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; 357 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
1220 break; 358 break;
1221 case 15: 359 case 15:
1222 PM3_WRITE_DAC_REG(PM3RD_PixelSize, 360 PM3_WRITE_DAC_REG(par, PM3RD_PixelSize,
1223 PM3RD_PixelSize_16_BIT_PIXELS); 361 PM3RD_PixelSize_16_BIT_PIXELS);
1224 PM3_WRITE_DAC_REG(PM3RD_ColorFormat, 362 PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat,
1225 PM3RD_ColorFormat_5551_FRONT_COLOR | 363 PM3RD_ColorFormat_5551_FRONT_COLOR |
1226 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW | 364 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW |
1227 PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE); 365 PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE);
1228 tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE | 366 tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
1229 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; 367 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
1230 break; 368 break;
1231 case 16: 369 case 16:
1232 PM3_WRITE_DAC_REG(PM3RD_PixelSize, 370 PM3_WRITE_DAC_REG(par, PM3RD_PixelSize,
1233 PM3RD_PixelSize_16_BIT_PIXELS); 371 PM3RD_PixelSize_16_BIT_PIXELS);
1234 PM3_WRITE_DAC_REG(PM3RD_ColorFormat, 372 PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat,
1235 PM3RD_ColorFormat_565_FRONT_COLOR | 373 PM3RD_ColorFormat_565_FRONT_COLOR |
1236 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW | 374 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW |
1237 PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE); 375 PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE);
@@ -1239,1936 +377,280 @@ static void pm3fb_write_mode(struct pm3fb_info *l_fb_info)
1239 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; 377 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
1240 break; 378 break;
1241 case 32: 379 case 32:
1242 PM3_WRITE_DAC_REG(PM3RD_PixelSize, 380 PM3_WRITE_DAC_REG(par, PM3RD_PixelSize,
1243 PM3RD_PixelSize_32_BIT_PIXELS); 381 PM3RD_PixelSize_32_BIT_PIXELS);
1244 PM3_WRITE_DAC_REG(PM3RD_ColorFormat, 382 PM3_WRITE_DAC_REG(par, PM3RD_ColorFormat,
1245 PM3RD_ColorFormat_8888_COLOR | 383 PM3RD_ColorFormat_8888_COLOR |
1246 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW); 384 PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW);
1247 tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE | 385 tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
1248 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE; 386 PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
1249 break; 387 break;
1250 } 388 }
1251 PM3_WRITE_DAC_REG(PM3RD_MiscControl, tempmisc); 389 PM3_WRITE_DAC_REG(par, PM3RD_MiscControl, tempmisc);
1252
1253 PM3_SHOW_CUR_MODE;
1254} 390}
1255 391
1256static void pm3fb_read_mode(struct pm3fb_info *l_fb_info, 392/*
1257 struct pm3fb_par *curpar) 393 * hardware independent functions
1258{ 394 */
1259 unsigned long pixsize1, pixsize2, clockused; 395int pm3fb_init(void);
1260 unsigned long pre, feedback, post; 396int pm3fb_setup(char*);
1261
1262 DTRACE;
1263
1264 clockused = PM3_READ_REG(PM3VClkCtl);
1265 397
1266 switch (clockused) { 398static int pm3fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
1267 case 3: 399{
1268 pre = PM3_READ_DAC_REG(PM3RD_DClk3PreScale); 400 u32 lpitch;
1269 feedback = PM3_READ_DAC_REG(PM3RD_DClk3FeedbackScale);
1270 post = PM3_READ_DAC_REG(PM3RD_DClk3PostScale);
1271 401
1272 DPRINTK(2, 402 var->transp.offset = 0;
1273 "DClk3 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n", 403 var->transp.length = 0;
1274 pre, feedback, post, PM3_SCALE_TO_CLOCK(pre, 404 switch(var->bits_per_pixel) {
1275 feedback, 405 case 8:
1276 post)); 406 var->red.length = var->green.length = var->blue.length = 8;
407 var->red.offset = var->green.offset = var->blue.offset = 0;
1277 break; 408 break;
1278 case 2: 409 case 12:
1279 pre = PM3_READ_DAC_REG(PM3RD_DClk2PreScale); 410 var->red.offset = 8;
1280 feedback = PM3_READ_DAC_REG(PM3RD_DClk2FeedbackScale); 411 var->red.length = 4;
1281 post = PM3_READ_DAC_REG(PM3RD_DClk2PostScale); 412 var->green.offset = 4;
1282 413 var->green.length = 4;
1283 DPRINTK(2, 414 var->blue.offset = 0;
1284 "DClk2 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n", 415 var->blue.length = 4;
1285 pre, feedback, post, PM3_SCALE_TO_CLOCK(pre, 416 var->transp.offset = 12;
1286 feedback, 417 var->transp.length = 4;
1287 post)); 418 case 15:
419 var->red.offset = 10;
420 var->red.length = 5;
421 var->green.offset = 5;
422 var->green.length = 5;
423 var->blue.offset = 0;
424 var->blue.length = 5;
425 var->transp.offset = 15;
426 var->transp.length = 1;
1288 break; 427 break;
1289 case 1: 428 case 16:
1290 pre = PM3_READ_DAC_REG(PM3RD_DClk1PreScale); 429 var->red.offset = 11;
1291 feedback = PM3_READ_DAC_REG(PM3RD_DClk1FeedbackScale); 430 var->red.length = 5;
1292 post = PM3_READ_DAC_REG(PM3RD_DClk1PostScale); 431 var->green.offset = 5;
1293 432 var->green.length = 6;
1294 DPRINTK(2, 433 var->blue.offset = 0;
1295 "DClk1 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n", 434 var->blue.length = 5;
1296 pre, feedback, post, PM3_SCALE_TO_CLOCK(pre,
1297 feedback,
1298 post));
1299 break; 435 break;
1300 case 0: 436 case 32:
1301 pre = PM3_READ_DAC_REG(PM3RD_DClk0PreScale); 437 var->transp.offset = 24;
1302 feedback = PM3_READ_DAC_REG(PM3RD_DClk0FeedbackScale); 438 var->transp.length = 8;
1303 post = PM3_READ_DAC_REG(PM3RD_DClk0PostScale); 439 var->red.offset = 16;
1304 440 var->green.offset = 8;
1305 DPRINTK(2, 441 var->blue.offset = 0;
1306 "DClk0 parameter: Pre: %ld, Feedback: %ld, Post: %ld ; giving pixclock: %ld\n", 442 var->red.length = var->green.length = var->blue.length = 8;
1307 pre, feedback, post, PM3_SCALE_TO_CLOCK(pre,
1308 feedback,
1309 post));
1310 break; 443 break;
1311 default: 444 default:
1312 pre = feedback = post = 0; 445 DPRINTK("depth not supported: %u\n", var->bits_per_pixel);
1313 DPRINTK(1, "Unknowk D clock used : %ld\n", clockused); 446 return -EINVAL;
1314 break;
1315 }
1316
1317 curpar->pixclock = PM3_SCALE_TO_CLOCK(pre, feedback, post);
1318
1319 pixsize1 =
1320 PM3ByApertureMode_PIXELSIZE_MASK &
1321 (PM3_READ_REG(PM3ByAperture1Mode));
1322 pixsize2 =
1323 PM3ByApertureMode_PIXELSIZE_MASK &
1324 (PM3_READ_REG(PM3ByAperture2Mode));
1325
1326 DASSERT((pixsize1 == pixsize2),
1327 "pixsize the same in both aperture\n");
1328
1329 if (pixsize1 & PM3ByApertureMode_PIXELSIZE_32BIT)
1330 curpar->depth = 32;
1331 else if (pixsize1 & PM3ByApertureMode_PIXELSIZE_16BIT)
1332 {
1333 curpar->depth = 16;
1334 }
1335 else
1336 curpar->depth = 8;
1337
1338 /* not sure if I need to add one on the next ; it give better result with */
1339 curpar->htotal =
1340 pm3fb_Unshiftbpp(l_fb_info, curpar->depth,
1341 1 + PM3_READ_REG(PM3HTotal));
1342 curpar->hsend =
1343 pm3fb_Unshiftbpp(l_fb_info, curpar->depth,
1344 PM3_READ_REG(PM3HsEnd));
1345 curpar->hsstart =
1346 pm3fb_Unshiftbpp(l_fb_info, curpar->depth,
1347 PM3_READ_REG(PM3HsStart));
1348 curpar->hbend =
1349 pm3fb_Unshiftbpp(l_fb_info, curpar->depth,
1350 PM3_READ_REG(PM3HbEnd));
1351
1352 curpar->stride =
1353 pm3fb_Unshiftbpp(l_fb_info, curpar->depth,
1354 PM3_READ_REG(PM3ScreenStride));
1355
1356 curpar->vtotal = 1 + PM3_READ_REG(PM3VTotal);
1357 curpar->vsend = 1 + PM3_READ_REG(PM3VsEnd);
1358 curpar->vsstart = 1 + PM3_READ_REG(PM3VsStart);
1359 curpar->vbend = PM3_READ_REG(PM3VbEnd);
1360
1361 curpar->video = PM3_READ_REG(PM3VideoControl);
1362
1363 curpar->base = PM3_READ_REG(PM3ScreenBase);
1364 curpar->width = curpar->htotal - curpar->hbend; /* make virtual == displayed resolution */
1365 curpar->height = curpar->vtotal - curpar->vbend;
1366
1367 DPRINTK(2, "Found : %d * %d, %d Khz, stride is %08x\n",
1368 curpar->width, curpar->height, curpar->pixclock,
1369 curpar->stride);
1370}
1371
1372static unsigned long pm3fb_size_memory(struct pm3fb_info *l_fb_info)
1373{
1374 unsigned long memsize = 0, tempBypass, i, temp1, temp2;
1375 u16 subvendor, subdevice;
1376 pm3fb_timing_result ptr;
1377
1378 DTRACE;
1379
1380 l_fb_info->fb_size = 64 * 1024 * 1024; /* pm3 aperture always 64 MB */
1381 pm3fb_mapIO(l_fb_info); /* temporary map IO */
1382
1383 DASSERT((l_fb_info->vIOBase != NULL),
1384 "IO successfully mapped before mem detect\n");
1385 DASSERT((l_fb_info->v_fb != NULL),
1386 "FB successfully mapped before mem detect\n");
1387
1388 /* card-specific stuff, *before* accessing *any* FB memory */
1389 if ((!pci_read_config_word
1390 (l_fb_info->dev, PCI_SUBSYSTEM_VENDOR_ID, &subvendor))
1391 &&
1392 (!pci_read_config_word
1393 (l_fb_info->dev, PCI_SUBSYSTEM_ID, &subdevice))) {
1394 i = 0; l_fb_info->board_type = 0;
1395 while ((cardbase[i].cardname[0]) && !(l_fb_info->board_type)) {
1396 if ((cardbase[i].subvendor == subvendor) &&
1397 (cardbase[i].subdevice == subdevice) &&
1398 (cardbase[i].func == PCI_FUNC(l_fb_info->dev->devfn))) {
1399 DPRINTK(2, "Card #%ld is an %s\n",
1400 l_fb_info->board_num,
1401 cardbase[i].cardname);
1402 if (cardbase[i].specific_setup)
1403 cardbase[i].specific_setup(l_fb_info);
1404 l_fb_info->board_type = i;
1405 }
1406 i++;
1407 }
1408 if (!l_fb_info->board_type) {
1409 DPRINTK(1, "Card #%ld is an unknown 0x%04x / 0x%04x\n",
1410 l_fb_info->board_num, subvendor, subdevice);
1411 }
1412 } else {
1413 printk(KERN_ERR "pm3fb: Error: pci_read_config_word failed, board #%ld\n",
1414 l_fb_info->board_num);
1415 }
1416
1417 if (printtimings)
1418 pm3fb_show_cur_timing(l_fb_info);
1419
1420 /* card-specific setup is done, we preserve the final
1421 memory timing for future reference */
1422 if ((ptr = pm3fb_preserve_memory_timings(l_fb_info)) == pm3fb_timing_problem) { /* memory timings were wrong ! oops.... */
1423 return(0);
1424 }
1425
1426 tempBypass = PM3_READ_REG(PM3MemBypassWriteMask);
1427
1428 DPRINTK(2, "PM3MemBypassWriteMask was: 0x%08lx\n", tempBypass);
1429
1430 PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask, 0xFFFFFFFF);
1431
1432 /* pm3 split up memory, replicates, and do a lot of nasty stuff IMHO ;-) */
1433 for (i = 0; i < 32; i++) {
1434 fb_writel(i * 0x00345678,
1435 (l_fb_info->v_fb + (i * 1048576)));
1436 mb();
1437 temp1 = fb_readl((l_fb_info->v_fb + (i * 1048576)));
1438
1439 /* Let's check for wrapover, write will fail at 16MB boundary */
1440 if (temp1 == (i * 0x00345678))
1441 memsize = i;
1442 else
1443 break;
1444 }
1445
1446 DPRINTK(2, "First detect pass already got %ld MB\n", memsize + 1);
1447
1448 if (memsize == i) {
1449 for (i = 0; i < 32; i++) {
1450 /* Clear first 32MB ; 0 is 0, no need to byteswap */
1451 writel(0x0000000,
1452 (l_fb_info->v_fb + (i * 1048576)));
1453 mb();
1454 }
1455
1456 for (i = 32; i < 64; i++) {
1457 fb_writel(i * 0x00345678,
1458 (l_fb_info->v_fb + (i * 1048576)));
1459 mb();
1460 temp1 =
1461 fb_readl((l_fb_info->v_fb + (i * 1048576)));
1462 temp2 =
1463 fb_readl((l_fb_info->v_fb +
1464 ((i - 32) * 1048576)));
1465 if ((temp1 == (i * 0x00345678)) && (temp2 == 0)) /* different value, different RAM... */
1466 memsize = i;
1467 else
1468 break;
1469 }
1470 }
1471
1472 DPRINTK(2, "Second detect pass got %ld MB\n", memsize + 1);
1473
1474 PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask, tempBypass);
1475
1476 pm3fb_unmapIO(l_fb_info);
1477 memsize = 1048576 * (memsize + 1);
1478
1479 DPRINTK(2, "Returning 0x%08lx bytes\n", memsize);
1480
1481 if (forcesize[l_fb_info->board_num] && ((forcesize[l_fb_info->board_num] * 1048576) != memsize))
1482 {
1483 printk(KERN_WARNING "pm3fb: mismatch between probed (%ld MB) and specified (%hd MB) memory size, using SPECIFIED !\n", memsize, forcesize[l_fb_info->board_num]);
1484 memsize = 1048576 * forcesize[l_fb_info->board_num];
1485 }
1486
1487 l_fb_info->fb_size = memsize;
1488
1489 if (ptr == pm3fb_timing_retry)
1490 {
1491 printk(KERN_WARNING "pm3fb: retrying memory timings check");
1492 if (pm3fb_try_memory_timings(l_fb_info) == pm3fb_timing_problem)
1493 return(0);
1494 }
1495
1496 return (memsize);
1497}
1498
1499static void pm3fb_clear_memory(struct pm3fb_info *l_fb_info, u32 cc)
1500{
1501 int i;
1502
1503 DTRACE;
1504
1505 for (i = 0; i < (l_fb_info->fb_size / sizeof(u32)) ; i++) /* clear entire FB memory to black */
1506 {
1507 fb_writel(cc, (l_fb_info->v_fb + (i * sizeof(u32))));
1508 } 447 }
1509} 448 var->height = var->width = -1;
1510
1511static void pm3fb_clear_colormap(struct pm3fb_info *l_fb_info, unsigned char r, unsigned char g, unsigned char b)
1512{
1513 int i;
1514
1515 DTRACE;
1516
1517 for (i = 0; i < 256 ; i++) /* fill color map with white */
1518 pm3fb_set_color(l_fb_info, i, r, g, b);
1519
1520}
1521
1522/* common initialisation */
1523static void pm3fb_common_init(struct pm3fb_info *l_fb_info)
1524{
1525 DTRACE;
1526
1527 DPRINTK(2, "Initializing board #%ld @ %lx\n", l_fb_info->board_num,
1528 (unsigned long) l_fb_info);
1529
1530 strcpy(l_fb_info->gen.info.modename, permedia3_name);
1531 disp[l_fb_info->board_num].scrollmode = 0; /* SCROLL_YNOMOVE; *//* 0 means "let fbcon choose" */
1532 l_fb_info->gen.parsize = sizeof(struct pm3fb_par);
1533 l_fb_info->gen.info.changevar = NULL;
1534 l_fb_info->gen.info.fbops = &pm3fb_ops;
1535 l_fb_info->gen.info.disp = &(disp[l_fb_info->board_num]);
1536 if (fontn[l_fb_info->board_num][0])
1537 strcpy(l_fb_info->gen.info.fontname,
1538 fontn[l_fb_info->board_num]);
1539 l_fb_info->gen.info.switch_con = &fbgen_switch;
1540 l_fb_info->gen.info.updatevar = &fbgen_update_var; /* */
1541 l_fb_info->gen.info.flags = FBINFO_FLAG_DEFAULT;
1542
1543 pm3fb_mapIO(l_fb_info);
1544
1545 pm3fb_clear_memory(l_fb_info, 0);
1546 pm3fb_clear_colormap(l_fb_info, 0, 0, 0);
1547
1548 (void) fbgen_get_var(&(disp[l_fb_info->board_num]).var, -1,
1549 &l_fb_info->gen.info);
1550 449
1551 if (depth[l_fb_info->board_num]) /* override mode-defined depth */ 450 if (var->xres != var->xres_virtual) {
1552 { 451 DPRINTK("virtual x resolution != physical x resolution not supported\n");
1553 pm3fb_encode_depth(&(disp[l_fb_info->board_num]).var, depth[l_fb_info->board_num]); 452 return -EINVAL;
1554 (disp[l_fb_info->board_num]).var.bits_per_pixel = depth2bpp(depth[l_fb_info->board_num]);
1555 } 453 }
1556 454
1557 (void) fbgen_do_set_var(&(disp[l_fb_info->board_num]).var, 1, 455 if (var->yres > var->yres_virtual) {
1558 &l_fb_info->gen); 456 DPRINTK("virtual y resolution < physical y resolution not possible\n");
1559 457 return -EINVAL;
1560 fbgen_set_disp(-1, &l_fb_info->gen);
1561
1562 do_install_cmap(0, &l_fb_info->gen.info);
1563
1564 if (register_framebuffer(&l_fb_info->gen.info) < 0) {
1565 DPRINTK(1, "Couldn't register framebuffer\n");
1566 return;
1567 } 458 }
1568 459
1569 PM3_WRITE_DAC_REG(PM3RD_CursorMode, 460 if (var->xoffset) {
1570 PM3RD_CursorMode_CURSOR_DISABLE); 461 DPRINTK("xoffset not supported\n");
1571 462 return -EINVAL;
1572 PM3_SHOW_CUR_MODE;
1573
1574 pm3fb_write_mode(l_fb_info);
1575
1576 printk("fb%d: %s, using %uK of video memory (%s)\n",
1577 l_fb_info->gen.info.node,
1578 permedia3_name, (u32) (l_fb_info->fb_size >> 10),
1579 cardbase[l_fb_info->board_type].cardname);
1580}
1581
1582/* **************************************************** */
1583/* ***** accelerated permedia3-specific functions ***** */
1584/* **************************************************** */
1585#ifdef PM3FB_USE_ACCEL
1586static void pm3fb_wait_pm3(struct pm3fb_info *l_fb_info)
1587{
1588 DTRACE;
1589
1590 PM3_SLOW_WRITE_REG(PM3FilterMode, PM3FilterModeSync);
1591 PM3_SLOW_WRITE_REG(PM3Sync, 0);
1592 mb();
1593 do {
1594 while ((PM3_READ_REG(PM3OutFIFOWords)) == 0);
1595 rmb();
1596 } while ((PM3_READ_REG(PM3OutputFifo)) != PM3Sync_Tag);
1597}
1598
1599static void pm3fb_init_engine(struct pm3fb_info *l_fb_info)
1600{
1601 PM3_SLOW_WRITE_REG(PM3FilterMode, PM3FilterModeSync);
1602 PM3_SLOW_WRITE_REG(PM3StatisticMode, 0x0);
1603 PM3_SLOW_WRITE_REG(PM3DeltaMode, 0x0);
1604 PM3_SLOW_WRITE_REG(PM3RasterizerMode, 0x0);
1605 PM3_SLOW_WRITE_REG(PM3ScissorMode, 0x0);
1606 PM3_SLOW_WRITE_REG(PM3LineStippleMode, 0x0);
1607 PM3_SLOW_WRITE_REG(PM3AreaStippleMode, 0x0);
1608 PM3_SLOW_WRITE_REG(PM3GIDMode, 0x0);
1609 PM3_SLOW_WRITE_REG(PM3DepthMode, 0x0);
1610 PM3_SLOW_WRITE_REG(PM3StencilMode, 0x0);
1611 PM3_SLOW_WRITE_REG(PM3StencilData, 0x0);
1612 PM3_SLOW_WRITE_REG(PM3ColorDDAMode, 0x0);
1613 PM3_SLOW_WRITE_REG(PM3TextureCoordMode, 0x0);
1614 PM3_SLOW_WRITE_REG(PM3TextureIndexMode0, 0x0);
1615 PM3_SLOW_WRITE_REG(PM3TextureIndexMode1, 0x0);
1616 PM3_SLOW_WRITE_REG(PM3TextureReadMode, 0x0);
1617 PM3_SLOW_WRITE_REG(PM3LUTMode, 0x0);
1618 PM3_SLOW_WRITE_REG(PM3TextureFilterMode, 0x0);
1619 PM3_SLOW_WRITE_REG(PM3TextureCompositeMode, 0x0);
1620 PM3_SLOW_WRITE_REG(PM3TextureApplicationMode, 0x0);
1621 PM3_SLOW_WRITE_REG(PM3TextureCompositeColorMode1, 0x0);
1622 PM3_SLOW_WRITE_REG(PM3TextureCompositeAlphaMode1, 0x0);
1623 PM3_SLOW_WRITE_REG(PM3TextureCompositeColorMode0, 0x0);
1624 PM3_SLOW_WRITE_REG(PM3TextureCompositeAlphaMode0, 0x0);
1625 PM3_SLOW_WRITE_REG(PM3FogMode, 0x0);
1626 PM3_SLOW_WRITE_REG(PM3ChromaTestMode, 0x0);
1627 PM3_SLOW_WRITE_REG(PM3AlphaTestMode, 0x0);
1628 PM3_SLOW_WRITE_REG(PM3AntialiasMode, 0x0);
1629 PM3_SLOW_WRITE_REG(PM3YUVMode, 0x0);
1630 PM3_SLOW_WRITE_REG(PM3AlphaBlendColorMode, 0x0);
1631 PM3_SLOW_WRITE_REG(PM3AlphaBlendAlphaMode, 0x0);
1632 PM3_SLOW_WRITE_REG(PM3DitherMode, 0x0);
1633 PM3_SLOW_WRITE_REG(PM3LogicalOpMode, 0x0);
1634 PM3_SLOW_WRITE_REG(PM3RouterMode, 0x0);
1635 PM3_SLOW_WRITE_REG(PM3Window, 0x0);
1636
1637 PM3_SLOW_WRITE_REG(PM3Config2D, 0x0);
1638
1639 PM3_SLOW_WRITE_REG(PM3SpanColorMask, 0xffffffff);
1640
1641 PM3_SLOW_WRITE_REG(PM3XBias, 0x0);
1642 PM3_SLOW_WRITE_REG(PM3YBias, 0x0);
1643 PM3_SLOW_WRITE_REG(PM3DeltaControl, 0x0);
1644
1645 PM3_SLOW_WRITE_REG(PM3BitMaskPattern, 0xffffffff);
1646
1647 PM3_SLOW_WRITE_REG(PM3FBDestReadEnables,
1648 PM3FBDestReadEnables_E(0xff) |
1649 PM3FBDestReadEnables_R(0xff) |
1650 PM3FBDestReadEnables_ReferenceAlpha(0xff));
1651 PM3_SLOW_WRITE_REG(PM3FBDestReadBufferAddr0, 0x0);
1652 PM3_SLOW_WRITE_REG(PM3FBDestReadBufferOffset0, 0x0);
1653 PM3_SLOW_WRITE_REG(PM3FBDestReadBufferWidth0,
1654 PM3FBDestReadBufferWidth_Width(l_fb_info->
1655 current_par->
1656 width));
1657
1658 PM3_SLOW_WRITE_REG(PM3FBDestReadMode,
1659 PM3FBDestReadMode_ReadEnable |
1660 PM3FBDestReadMode_Enable0);
1661 PM3_SLOW_WRITE_REG(PM3FBSourceReadBufferAddr, 0x0);
1662 PM3_SLOW_WRITE_REG(PM3FBSourceReadBufferOffset, 0x0);
1663 PM3_SLOW_WRITE_REG(PM3FBSourceReadBufferWidth,
1664 PM3FBSourceReadBufferWidth_Width(l_fb_info->
1665 current_par->
1666 width));
1667 PM3_SLOW_WRITE_REG(PM3FBSourceReadMode,
1668 PM3FBSourceReadMode_Blocking |
1669 PM3FBSourceReadMode_ReadEnable);
1670
1671 {
1672 unsigned long rm = 1;
1673 switch (l_fb_info->current_par->depth) {
1674 case 8:
1675 PM3_SLOW_WRITE_REG(PM3PixelSize,
1676 PM3PixelSize_GLOBAL_8BIT);
1677 break;
1678 case 12:
1679 case 15:
1680 case 16:
1681 PM3_SLOW_WRITE_REG(PM3PixelSize,
1682 PM3PixelSize_GLOBAL_16BIT);
1683 break;
1684 case 32:
1685 PM3_SLOW_WRITE_REG(PM3PixelSize,
1686 PM3PixelSize_GLOBAL_32BIT);
1687 break;
1688 default:
1689 DPRINTK(1, "Unsupported depth %d\n",
1690 l_fb_info->current_par->depth);
1691 break;
1692 }
1693 PM3_SLOW_WRITE_REG(PM3RasterizerMode, rm);
1694 } 463 }
1695 464
1696 PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask, 0xffffffff); 465 if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
1697 PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0xffffffff); 466 DPRINTK("interlace not supported\n");
1698 PM3_SLOW_WRITE_REG(PM3FBWriteMode, 467 return -EINVAL;
1699 PM3FBWriteMode_WriteEnable |
1700 PM3FBWriteMode_OpaqueSpan |
1701 PM3FBWriteMode_Enable0);
1702 PM3_SLOW_WRITE_REG(PM3FBWriteBufferAddr0, 0x0);
1703 PM3_SLOW_WRITE_REG(PM3FBWriteBufferOffset0, 0x0);
1704 PM3_SLOW_WRITE_REG(PM3FBWriteBufferWidth0,
1705 PM3FBWriteBufferWidth_Width(l_fb_info->
1706 current_par->
1707 width));
1708
1709 PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer, 0x0);
1710 {
1711 unsigned long sofb = (8UL * l_fb_info->fb_size) /
1712 ((depth2bpp(l_fb_info->current_par->depth))
1713 * l_fb_info->current_par->width); /* size in lines of FB */
1714 if (sofb > 4095)
1715 PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer, 4095);
1716 else
1717 PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer, sofb);
1718
1719 switch (l_fb_info->current_par->depth) {
1720 case 8:
1721 PM3_SLOW_WRITE_REG(PM3DitherMode,
1722 (1 << 10) | (2 << 3));
1723 break;
1724 case 12:
1725 case 15:
1726 case 16:
1727 PM3_SLOW_WRITE_REG(PM3DitherMode,
1728 (1 << 10) | (1 << 3));
1729 break;
1730 case 32:
1731 PM3_SLOW_WRITE_REG(PM3DitherMode,
1732 (1 << 10) | (0 << 3));
1733 break;
1734 default:
1735 DPRINTK(1, "Unsupported depth %d\n",
1736 l_fb_info->current_par->depth);
1737 break;
1738 }
1739 } 468 }
1740 469
1741 PM3_SLOW_WRITE_REG(PM3dXDom, 0x0); 470 var->xres = (var->xres + 31) & ~31; /* could sometimes be 8 */
1742 PM3_SLOW_WRITE_REG(PM3dXSub, 0x0); 471 lpitch = var->xres * ((var->bits_per_pixel + 7)>>3);
1743 PM3_SLOW_WRITE_REG(PM3dY, (1 << 16));
1744 PM3_SLOW_WRITE_REG(PM3StartXDom, 0x0);
1745 PM3_SLOW_WRITE_REG(PM3StartXSub, 0x0);
1746 PM3_SLOW_WRITE_REG(PM3StartY, 0x0);
1747 PM3_SLOW_WRITE_REG(PM3Count, 0x0);
1748
1749/* Disable LocalBuffer. better safe than sorry */
1750 PM3_SLOW_WRITE_REG(PM3LBDestReadMode, 0x0);
1751 PM3_SLOW_WRITE_REG(PM3LBDestReadEnables, 0x0);
1752 PM3_SLOW_WRITE_REG(PM3LBSourceReadMode, 0x0);
1753 PM3_SLOW_WRITE_REG(PM3LBWriteMode, 0x0);
1754
1755 pm3fb_wait_pm3(l_fb_info);
1756}
1757 472
1758#ifdef FBCON_HAS_CFB32 473 if (var->xres < 200 || var->xres > 2048) {
1759static void pm3fb_cfb32_clear(struct vc_data *conp, 474 DPRINTK("width not supported: %u\n", var->xres);
1760 struct display *p, 475 return -EINVAL;
1761 int sy, int sx, int height, int width)
1762{
1763 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
1764 u32 c;
1765
1766 DTRACE;
1767
1768 sx = sx * fontwidth(p);
1769 width = width * fontwidth(p);
1770 sy = sy * fontheight(p);
1771 height = height * fontheight(p);
1772 c = ((u32 *) p->dispsw_data)[attr_bgcol_ec(p, conp)];
1773
1774 /* block fills in 32bpp are hard, but in low res (width <= 1600 :-)
1775 we can use 16bpp operations, but not if NoWriteMask is on (SDRAM) */
1776 if ((l_fb_info->current_par->width > 1600) ||
1777 (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)) {
1778 PM3_WAIT(4);
1779
1780 PM3_WRITE_REG(PM3Config2D,
1781 PM3Config2D_UseConstantSource |
1782 PM3Config2D_ForegroundROPEnable |
1783 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
1784 PM3Config2D_FBWriteEnable);
1785
1786 PM3_WRITE_REG(PM3ForegroundColor, c);
1787
1788 PM3_WRITE_REG(PM3RectanglePosition,
1789 (PM3RectanglePosition_XOffset(sx)) |
1790 (PM3RectanglePosition_YOffset(sy)));
1791
1792 PM3_WRITE_REG(PM3Render2D,
1793 PM3Render2D_XPositive |
1794 PM3Render2D_YPositive |
1795 PM3Render2D_Operation_Normal |
1796 PM3Render2D_SpanOperation |
1797 (PM3Render2D_Width(width)) |
1798 (PM3Render2D_Height(height)));
1799 } else {
1800 PM3_WAIT(8);
1801
1802 PM3_WRITE_REG(PM3FBBlockColor, c);
1803
1804 PM3_WRITE_REG(PM3PixelSize, PM3PixelSize_GLOBAL_16BIT);
1805
1806 PM3_WRITE_REG(PM3FBWriteBufferWidth0,
1807 PM3FBWriteBufferWidth_Width(l_fb_info->
1808 current_par->
1809 width << 1));
1810
1811 PM3_WRITE_REG(PM3Config2D,
1812 PM3Config2D_UseConstantSource |
1813 PM3Config2D_ForegroundROPEnable |
1814 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
1815 PM3Config2D_FBWriteEnable);
1816
1817 PM3_WRITE_REG(PM3RectanglePosition,
1818 (PM3RectanglePosition_XOffset(sx << 1)) |
1819 (PM3RectanglePosition_YOffset(sy)));
1820
1821 PM3_WRITE_REG(PM3Render2D,
1822 PM3Render2D_XPositive |
1823 PM3Render2D_YPositive |
1824 PM3Render2D_Operation_Normal |
1825 (PM3Render2D_Width(width << 1)) |
1826 (PM3Render2D_Height(height)));
1827
1828 PM3_WRITE_REG(PM3FBWriteBufferWidth0,
1829 PM3FBWriteBufferWidth_Width(l_fb_info->
1830 current_par->
1831 width));
1832
1833 PM3_WRITE_REG(PM3PixelSize, PM3PixelSize_GLOBAL_32BIT);
1834 } 476 }
1835 477
1836 pm3fb_wait_pm3(l_fb_info); 478 if (var->yres < 200 || var->yres > 4095) {
1837} 479 DPRINTK("height not supported: %u\n", var->yres);
1838 480 return -EINVAL;
1839static void pm3fb_cfb32_clear_margins(struct vc_data *conp,
1840 struct display *p, int bottom_only)
1841{
1842 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
1843 int sx, sy;
1844 u32 c;
1845
1846 DTRACE;
1847
1848 sx = conp->vc_cols * fontwidth(p); /* right margin */
1849 sy = conp->vc_rows * fontheight(p); /* bottom margin */
1850 c = ((u32 *) p->dispsw_data)[attr_bgcol_ec(p, conp)];
1851
1852 if (!bottom_only) { /* right margin top->bottom */
1853 PM3_WAIT(4);
1854
1855 PM3_WRITE_REG(PM3Config2D,
1856 PM3Config2D_UseConstantSource |
1857 PM3Config2D_ForegroundROPEnable |
1858 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
1859 PM3Config2D_FBWriteEnable);
1860
1861 PM3_WRITE_REG(PM3ForegroundColor, c);
1862
1863 PM3_WRITE_REG(PM3RectanglePosition,
1864 (PM3RectanglePosition_XOffset
1865 (p->var.xoffset +
1866 sx)) | (PM3RectanglePosition_YOffset(p->
1867 var.
1868 yoffset)));
1869
1870 PM3_WRITE_REG(PM3Render2D,
1871 PM3Render2D_XPositive |
1872 PM3Render2D_YPositive |
1873 PM3Render2D_Operation_Normal |
1874 PM3Render2D_SpanOperation |
1875 (PM3Render2D_Width(p->var.xres - sx)) |
1876 (PM3Render2D_Height(p->var.yres)));
1877 } 481 }
1878 482
1879 /* bottom margin left -> right */ 483 if (lpitch * var->yres_virtual > info->fix.smem_len) {
1880 PM3_WAIT(4); 484 DPRINTK("no memory for screen (%ux%ux%u)\n",
1881 485 var->xres, var->yres_virtual, var->bits_per_pixel);
1882 PM3_WRITE_REG(PM3Config2D, 486 return -EINVAL;
1883 PM3Config2D_UseConstantSource |
1884 PM3Config2D_ForegroundROPEnable |
1885 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
1886 PM3Config2D_FBWriteEnable);
1887
1888 PM3_WRITE_REG(PM3ForegroundColor, c);
1889
1890 PM3_WRITE_REG(PM3RectanglePosition,
1891 (PM3RectanglePosition_XOffset(p->var.xoffset)) |
1892 (PM3RectanglePosition_YOffset(p->var.yoffset + sy)));
1893
1894 PM3_WRITE_REG(PM3Render2D,
1895 PM3Render2D_XPositive |
1896 PM3Render2D_YPositive |
1897 PM3Render2D_Operation_Normal |
1898 PM3Render2D_SpanOperation |
1899 (PM3Render2D_Width(p->var.xres)) |
1900 (PM3Render2D_Height(p->var.yres - sy)));
1901
1902 pm3fb_wait_pm3(l_fb_info);
1903}
1904#endif /* FBCON_HAS_CFB32 */
1905#ifdef FBCON_HAS_CFB16
1906static void pm3fb_cfb16_clear(struct vc_data *conp,
1907 struct display *p,
1908 int sy, int sx, int height, int width)
1909{
1910 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
1911 u32 c;
1912
1913 DTRACE;
1914
1915 sx = sx * fontwidth(p);
1916 width = width * fontwidth(p);
1917 sy = sy * fontheight(p);
1918 height = height * fontheight(p);
1919 c = ((u16 *) p->dispsw_data)[attr_bgcol_ec(p, conp)];
1920 c = c | (c << 16);
1921
1922 PM3_WAIT(4);
1923
1924 if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
1925 PM3_WRITE_REG(PM3ForegroundColor, c);
1926 else
1927 PM3_WRITE_REG(PM3FBBlockColor, c);
1928
1929 PM3_WRITE_REG(PM3Config2D,
1930 PM3Config2D_UseConstantSource |
1931 PM3Config2D_ForegroundROPEnable |
1932 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
1933 PM3Config2D_FBWriteEnable);
1934
1935 PM3_WRITE_REG(PM3RectanglePosition,
1936 (PM3RectanglePosition_XOffset(sx)) |
1937 (PM3RectanglePosition_YOffset(sy)));
1938
1939 if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
1940 PM3_WRITE_REG(PM3Render2D,
1941 PM3Render2D_XPositive |
1942 PM3Render2D_YPositive |
1943 PM3Render2D_Operation_Normal |
1944 PM3Render2D_SpanOperation |
1945 (PM3Render2D_Width(width)) |
1946 (PM3Render2D_Height(height)));
1947 else
1948 PM3_WRITE_REG(PM3Render2D,
1949 PM3Render2D_XPositive |
1950 PM3Render2D_YPositive |
1951 PM3Render2D_Operation_Normal |
1952 (PM3Render2D_Width(width)) |
1953 (PM3Render2D_Height(height)));
1954
1955 pm3fb_wait_pm3(l_fb_info);
1956}
1957
1958static void pm3fb_cfb16_clear_margins(struct vc_data *conp,
1959 struct display *p, int bottom_only)
1960{
1961 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
1962 int sx, sy;
1963 u32 c;
1964
1965 DTRACE;
1966
1967 sx = conp->vc_cols * fontwidth(p); /* right margin */
1968 sy = conp->vc_rows * fontheight(p); /* bottom margin */
1969 c = ((u16 *) p->dispsw_data)[attr_bgcol_ec(p, conp)];
1970 c = c | (c << 16);
1971
1972 if (!bottom_only) { /* right margin top->bottom */
1973 PM3_WAIT(4);
1974
1975 PM3_WRITE_REG(PM3Config2D,
1976 PM3Config2D_UseConstantSource |
1977 PM3Config2D_ForegroundROPEnable |
1978 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
1979 PM3Config2D_FBWriteEnable);
1980
1981 if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
1982 PM3_WRITE_REG(PM3ForegroundColor, c);
1983 else
1984 PM3_WRITE_REG(PM3FBBlockColor, c);
1985
1986 PM3_WRITE_REG(PM3RectanglePosition,
1987 (PM3RectanglePosition_XOffset
1988 (p->var.xoffset +
1989 sx)) | (PM3RectanglePosition_YOffset(p->
1990 var.
1991 yoffset)));
1992 if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
1993 PM3_WRITE_REG(PM3Render2D,
1994 PM3Render2D_XPositive |
1995 PM3Render2D_YPositive |
1996 PM3Render2D_Operation_Normal |
1997 PM3Render2D_SpanOperation |
1998 (PM3Render2D_Width(p->var.xres - sx)) |
1999 (PM3Render2D_Height(p->var.yres)));
2000 else
2001 PM3_WRITE_REG(PM3Render2D,
2002 PM3Render2D_XPositive |
2003 PM3Render2D_YPositive |
2004 PM3Render2D_Operation_Normal |
2005 (PM3Render2D_Width(p->var.xres - sx)) |
2006 (PM3Render2D_Height(p->var.yres)));
2007 } 487 }
2008
2009 /* bottom margin left -> right */
2010 PM3_WAIT(4);
2011
2012 PM3_WRITE_REG(PM3Config2D,
2013 PM3Config2D_UseConstantSource |
2014 PM3Config2D_ForegroundROPEnable |
2015 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2016 PM3Config2D_FBWriteEnable);
2017
2018 if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
2019 PM3_WRITE_REG(PM3ForegroundColor, c);
2020 else
2021 PM3_WRITE_REG(PM3FBBlockColor, c);
2022
2023
2024 PM3_WRITE_REG(PM3RectanglePosition,
2025 (PM3RectanglePosition_XOffset(p->var.xoffset)) |
2026 (PM3RectanglePosition_YOffset(p->var.yoffset + sy)));
2027
2028 if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
2029 PM3_WRITE_REG(PM3Render2D,
2030 PM3Render2D_XPositive |
2031 PM3Render2D_YPositive |
2032 PM3Render2D_Operation_Normal |
2033 PM3Render2D_SpanOperation |
2034 (PM3Render2D_Width(p->var.xres)) |
2035 (PM3Render2D_Height(p->var.yres - sy)));
2036 else
2037 PM3_WRITE_REG(PM3Render2D,
2038 PM3Render2D_XPositive |
2039 PM3Render2D_YPositive |
2040 PM3Render2D_Operation_Normal |
2041 (PM3Render2D_Width(p->var.xres)) |
2042 (PM3Render2D_Height(p->var.yres - sy)));
2043
2044 pm3fb_wait_pm3(l_fb_info);
2045}
2046#endif /* FBCON_HAS_CFB16 */
2047#ifdef FBCON_HAS_CFB8
2048static void pm3fb_cfb8_clear(struct vc_data *conp,
2049 struct display *p,
2050 int sy, int sx, int height, int width)
2051{
2052 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
2053 u32 c;
2054
2055 DTRACE;
2056
2057 sx = sx * fontwidth(p);
2058 width = width * fontwidth(p);
2059 sy = sy * fontheight(p);
2060 height = height * fontheight(p);
2061
2062 c = attr_bgcol_ec(p, conp);
2063 c |= c << 8;
2064 c |= c << 16;
2065 488
2066 PM3_WAIT(4); 489 if (PICOS2KHZ(var->pixclock) > PM3_MAX_PIXCLOCK) {
2067 490 DPRINTK("pixclock too high (%ldKHz)\n", PICOS2KHZ(var->pixclock));
2068 PM3_WRITE_REG(PM3Config2D, 491 return -EINVAL;
2069 PM3Config2D_UseConstantSource |
2070 PM3Config2D_ForegroundROPEnable |
2071 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2072 PM3Config2D_FBWriteEnable);
2073
2074 PM3_WRITE_REG(PM3ForegroundColor, c);
2075
2076 PM3_WRITE_REG(PM3RectanglePosition,
2077 (PM3RectanglePosition_XOffset(sx)) |
2078 (PM3RectanglePosition_YOffset(sy)));
2079
2080 PM3_WRITE_REG(PM3Render2D,
2081 PM3Render2D_XPositive |
2082 PM3Render2D_YPositive |
2083 PM3Render2D_Operation_Normal |
2084 PM3Render2D_SpanOperation |
2085 (PM3Render2D_Width(width)) |
2086 (PM3Render2D_Height(height)));
2087
2088 pm3fb_wait_pm3(l_fb_info);
2089}
2090
2091static void pm3fb_cfb8_clear_margins(struct vc_data *conp,
2092 struct display *p, int bottom_only)
2093{
2094 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
2095 int sx, sy;
2096 u32 c;
2097
2098 DTRACE;
2099
2100 sx = conp->vc_cols * fontwidth(p); /* right margin */
2101 sy = conp->vc_rows * fontheight(p); /* bottom margin */
2102 c = attr_bgcol_ec(p, conp);
2103 c |= c << 8;
2104 c |= c << 16;
2105
2106 if (!bottom_only) { /* right margin top->bottom */
2107 PM3_WAIT(4);
2108
2109 PM3_WRITE_REG(PM3Config2D,
2110 PM3Config2D_UseConstantSource |
2111 PM3Config2D_ForegroundROPEnable |
2112 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2113 PM3Config2D_FBWriteEnable);
2114
2115 PM3_WRITE_REG(PM3ForegroundColor, c);
2116
2117 PM3_WRITE_REG(PM3RectanglePosition,
2118 (PM3RectanglePosition_XOffset
2119 (p->var.xoffset +
2120 sx)) | (PM3RectanglePosition_YOffset(p->
2121 var.
2122 yoffset)));
2123
2124 PM3_WRITE_REG(PM3Render2D,
2125 PM3Render2D_XPositive |
2126 PM3Render2D_YPositive |
2127 PM3Render2D_Operation_Normal |
2128 PM3Render2D_SpanOperation |
2129 (PM3Render2D_Width(p->var.xres - sx)) |
2130 (PM3Render2D_Height(p->var.yres)));
2131 } 492 }
2132 493
2133 /* bottom margin left -> right */ 494 var->accel_flags = 0; /* Can't mmap if this is on */
2134 PM3_WAIT(4);
2135
2136 PM3_WRITE_REG(PM3Config2D,
2137 PM3Config2D_UseConstantSource |
2138 PM3Config2D_ForegroundROPEnable |
2139 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2140 PM3Config2D_FBWriteEnable);
2141
2142 PM3_WRITE_REG(PM3ForegroundColor, c);
2143 495
2144 PM3_WRITE_REG(PM3RectanglePosition, 496 DPRINTK("Checking graphics mode at %dx%d depth %d\n",
2145 (PM3RectanglePosition_XOffset(p->var.xoffset)) | 497 var->xres, var->yres, var->bits_per_pixel);
2146 (PM3RectanglePosition_YOffset(p->var.yoffset + sy))); 498 return 0;
2147
2148 PM3_WRITE_REG(PM3Render2D,
2149 PM3Render2D_XPositive |
2150 PM3Render2D_YPositive |
2151 PM3Render2D_Operation_Normal |
2152 PM3Render2D_SpanOperation |
2153 (PM3Render2D_Width(p->var.xres)) |
2154 (PM3Render2D_Height(p->var.yres - sy)));
2155
2156 pm3fb_wait_pm3(l_fb_info);
2157}
2158#endif /* FBCON_HAS_CFB8 */
2159#if defined(FBCON_HAS_CFB8) || defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32)
2160static void pm3fb_cfbX_bmove(struct display *p,
2161 int sy, int sx,
2162 int dy, int dx, int height, int width)
2163{
2164 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
2165 int x_align, o_x, o_y;
2166
2167 DTRACE;
2168
2169 sx = sx * fontwidth(p);
2170 dx = dx * fontwidth(p);
2171 width = width * fontwidth(p);
2172 sy = sy * fontheight(p);
2173 dy = dy * fontheight(p);
2174 height = height * fontheight(p);
2175
2176 o_x = sx - dx; /*(sx > dx ) ? (sx - dx) : (dx - sx); */
2177 o_y = sy - dy; /*(sy > dy ) ? (sy - dy) : (dy - sy); */
2178
2179 x_align = (sx & 0x1f);
2180
2181 PM3_WAIT(6);
2182
2183 PM3_WRITE_REG(PM3Config2D,
2184 PM3Config2D_UserScissorEnable |
2185 PM3Config2D_ForegroundROPEnable |
2186 PM3Config2D_Blocking |
2187 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2188 PM3Config2D_FBWriteEnable);
2189
2190 PM3_WRITE_REG(PM3ScissorMinXY,
2191 ((dy & 0x0fff) << 16) | (dx & 0x0fff));
2192 PM3_WRITE_REG(PM3ScissorMaxXY,
2193 (((dy + height) & 0x0fff) << 16) |
2194 ((dx + width) & 0x0fff));
2195
2196 PM3_WRITE_REG(PM3FBSourceReadBufferOffset,
2197 PM3FBSourceReadBufferOffset_XOffset(o_x) |
2198 PM3FBSourceReadBufferOffset_YOffset(o_y));
2199
2200 PM3_WRITE_REG(PM3RectanglePosition,
2201 (PM3RectanglePosition_XOffset(dx - x_align)) |
2202 (PM3RectanglePosition_YOffset(dy)));
2203
2204 PM3_WRITE_REG(PM3Render2D,
2205 ((sx > dx) ? PM3Render2D_XPositive : 0) |
2206 ((sy > dy) ? PM3Render2D_YPositive : 0) |
2207 PM3Render2D_Operation_Normal |
2208 PM3Render2D_SpanOperation |
2209 PM3Render2D_FBSourceReadEnable |
2210 (PM3Render2D_Width(width + x_align)) |
2211 (PM3Render2D_Height(height)));
2212
2213 pm3fb_wait_pm3(l_fb_info);
2214} 499}
2215 500
2216static void pm3fb_cfbX_putc(struct vc_data *conp, struct display *p, 501static int pm3fb_set_par(struct fb_info *info)
2217 int c, int yy, int xx)
2218{ 502{
2219 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info; 503 struct pm3_par *par = info->par;
2220 u8 *cdat, asx = 0, asy = 0, o_x = 0, o_y = 0; 504 const u32 xres = (info->var.xres + 31) & ~31;
2221 u32 fgx, bgx, ldat; 505 const int depth = (info->var.bits_per_pixel + 7) & ~7;
2222 int sx, sy, i;
2223
2224 DTRACE;
2225
2226 if (l_fb_info->current_par->depth == 8)
2227 fgx = attr_fgcol(p, c);
2228 else if (depth2bpp(l_fb_info->current_par->depth) == 16)
2229 fgx = ((u16 *) p->dispsw_data)[attr_fgcol(p, c)];
2230 else
2231 fgx = ((u32 *) p->dispsw_data)[attr_fgcol(p, c)];
2232
2233 PM3_COLOR(fgx);
2234
2235 if (l_fb_info->current_par->depth == 8)
2236 bgx = attr_bgcol(p, c);
2237 else if (depth2bpp(l_fb_info->current_par->depth) == 16)
2238 bgx = ((u16 *) p->dispsw_data)[attr_bgcol(p, c)];
2239 else
2240 bgx = ((u32 *) p->dispsw_data)[attr_bgcol(p, c)];
2241
2242 PM3_COLOR(bgx);
2243
2244 PM3_WAIT(4);
2245
2246 PM3_WRITE_REG(PM3Config2D,
2247 PM3Config2D_UseConstantSource |
2248 PM3Config2D_ForegroundROPEnable |
2249 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2250 PM3Config2D_FBWriteEnable | PM3Config2D_OpaqueSpan);
2251
2252 PM3_WRITE_REG(PM3ForegroundColor, fgx);
2253 PM3_WRITE_REG(PM3FillBackgroundColor, bgx);
2254
2255 /* WARNING : address select X need to specify 8 bits for fontwidth <= 8 */
2256 /* and 16 bits for fontwidth <= 16 */
2257 /* same in _putcs, same for Y and fontheight */
2258 if (fontwidth(p) <= 8)
2259 asx = 2;
2260 else if (fontwidth(p) <= 16)
2261 asx = 3; /* look OK */
2262 if (fontheight(p) <= 8)
2263 asy = 2;
2264 else if (fontheight(p) <= 16)
2265 asy = 3; /* look OK */
2266 else if (fontheight(p) <= 32)
2267 asy = 4; /* look OK */
2268
2269 sx = xx * fontwidth(p);
2270 sy = yy * fontheight(p);
2271
2272 if (fontwidth(p) <= 8)
2273 o_x = (8 - (sx & 0x7)) & 0x7;
2274 else if (fontwidth(p) <= 16)
2275 o_x = (16 - (sx & 0xF)) & 0xF;
2276 if (fontheight(p) <= 8)
2277 o_y = (8 - (sy & 0x7)) & 0x7;
2278 else if (fontheight(p) <= 16)
2279 o_y = (16 - (sy & 0xF)) & 0xF;
2280 else if (fontheight(p) <= 32)
2281 o_y = (32 - (sy & 0x1F)) & 0x1F;
2282
2283 PM3_WRITE_REG(PM3AreaStippleMode, (o_x << 7) | (o_y << 12) | /* x_offset, y_offset in pattern */
2284 (1 << 18) | /* BE */
2285 1 | (asx << 1) | (asy << 4) | /* address select x/y */
2286 (1 << 20)); /* OpaqueSpan */
2287
2288 if (fontwidth(p) <= 8) {
2289 cdat = p->fontdata + (c & p->charmask) * fontheight(p);
2290 } else {
2291 cdat =
2292 p->fontdata +
2293 ((c & p->charmask) * (fontheight(p) << 1));
2294 }
2295
2296 PM3_WAIT(2 + fontheight(p));
2297
2298 for (i = 0; i < fontheight(p); i++) { /* assume fontheight <= 32 */
2299 if (fontwidth(p) <= 8) {
2300 ldat = *cdat++;
2301 } else { /* assume fontwidth <= 16 ATM */
2302
2303 ldat = ((*cdat++) << 8);
2304 ldat |= *cdat++;
2305 }
2306 PM3_WRITE_REG(AreaStipplePattern_indexed(i), ldat);
2307 }
2308 506
2309 PM3_WRITE_REG(PM3RectanglePosition, 507 par->base = pm3fb_shift_bpp(info->var.bits_per_pixel,
2310 (PM3RectanglePosition_XOffset(sx)) | 508 (info->var.yoffset * xres)
2311 (PM3RectanglePosition_YOffset(sy))); 509 + info->var.xoffset);
510 par->video = 0;
2312 511
2313 PM3_WRITE_REG(PM3Render2D, 512 if (info->var.sync & FB_SYNC_HOR_HIGH_ACT)
2314 PM3Render2D_AreaStippleEnable | 513 par->video |= PM3VideoControl_HSYNC_ACTIVE_HIGH;
2315 PM3Render2D_XPositive |
2316 PM3Render2D_YPositive |
2317 PM3Render2D_Operation_Normal |
2318 PM3Render2D_SpanOperation |
2319 (PM3Render2D_Width(fontwidth(p))) |
2320 (PM3Render2D_Height(fontheight(p))));
2321
2322 pm3fb_wait_pm3(l_fb_info);
2323}
2324
2325static void pm3fb_cfbX_putcs(struct vc_data *conp, struct display *p,
2326 const unsigned short *s, int count, int yy,
2327 int xx)
2328{
2329 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
2330 u8 *cdat, asx = 0, asy = 0, o_x = 0, o_y = 0;
2331 u32 fgx, bgx, ldat;
2332 int sx, sy, i, j;
2333 u16 sc;
2334
2335 DTRACE;
2336
2337 sc = scr_readw(s);
2338 if (l_fb_info->current_par->depth == 8)
2339 fgx = attr_fgcol(p, sc);
2340 else if (depth2bpp(l_fb_info->current_par->depth) == 16)
2341 fgx = ((u16 *) p->dispsw_data)[attr_fgcol(p, sc)];
2342 else
2343 fgx = ((u32 *) p->dispsw_data)[attr_fgcol(p, sc)];
2344
2345 PM3_COLOR(fgx);
2346
2347 if (l_fb_info->current_par->depth == 8)
2348 bgx = attr_bgcol(p, sc);
2349 else if (depth2bpp(l_fb_info->current_par->depth) == 16)
2350 bgx = ((u16 *) p->dispsw_data)[attr_bgcol(p, sc)];
2351 else 514 else
2352 bgx = ((u32 *) p->dispsw_data)[attr_bgcol(p, sc)]; 515 par->video |= PM3VideoControl_HSYNC_ACTIVE_LOW;
2353
2354 PM3_COLOR(bgx);
2355
2356 PM3_WAIT(4);
2357
2358 PM3_WRITE_REG(PM3Config2D,
2359 PM3Config2D_UseConstantSource |
2360 PM3Config2D_ForegroundROPEnable |
2361 (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
2362 PM3Config2D_FBWriteEnable |
2363 PM3Config2D_OpaqueSpan);
2364
2365 PM3_WRITE_REG(PM3ForegroundColor, fgx);
2366 PM3_WRITE_REG(PM3FillBackgroundColor, bgx);
2367
2368 /* WARNING : address select X need to specify 8 bits for fontwidth <= 8 */
2369 /* and 16 bits for fontwidth <= 16 */
2370 /* same in _putc, same for Y and fontheight */
2371 if (fontwidth(p) <= 8)
2372 asx = 2;
2373 else if (fontwidth(p) <= 16)
2374 asx = 3; /* look OK */
2375 if (fontheight(p) <= 8)
2376 asy = 2;
2377 else if (fontheight(p) <= 16)
2378 asy = 3; /* look OK */
2379 else if (fontheight(p) <= 32)
2380 asy = 4; /* look OK */
2381
2382 sy = yy * fontheight(p);
2383
2384 if (fontheight(p) <= 8)
2385 o_y = (8 - (sy & 0x7)) & 0x7;
2386 else if (fontheight(p) <= 16)
2387 o_y = (16 - (sy & 0xF)) & 0xF;
2388 else if (fontheight(p) <= 32)
2389 o_y = (32 - (sy & 0x1F)) & 0x1F;
2390
2391 for (j = 0; j < count; j++) {
2392 sc = scr_readw(s + j);
2393 if (fontwidth(p) <= 8)
2394 cdat = p->fontdata +
2395 (sc & p->charmask) * fontheight(p);
2396 else
2397 cdat = p->fontdata +
2398 ((sc & p->charmask) * fontheight(p) << 1);
2399
2400 sx = (xx + j) * fontwidth(p);
2401
2402 if (fontwidth(p) <= 8)
2403 o_x = (8 - (sx & 0x7)) & 0x7;
2404 else if (fontwidth(p) <= 16)
2405 o_x = (16 - (sx & 0xF)) & 0xF;
2406
2407 PM3_WAIT(3 + fontheight(p));
2408
2409 PM3_WRITE_REG(PM3AreaStippleMode, (o_x << 7) | (o_y << 12) | /* x_offset, y_offset in pattern */
2410 (1 << 18) | /* BE */
2411 1 | (asx << 1) | (asy << 4) | /* address select x/y */
2412 (1 << 20)); /* OpaqueSpan */
2413
2414 for (i = 0; i < fontheight(p); i++) { /* assume fontheight <= 32 */
2415 if (fontwidth(p) <= 8) {
2416 ldat = *cdat++;
2417 } else { /* assume fontwidth <= 16 ATM */
2418 ldat = ((*cdat++) << 8);
2419 ldat |= *cdat++;
2420 }
2421 PM3_WRITE_REG(AreaStipplePattern_indexed(i), ldat);
2422 }
2423
2424 PM3_WRITE_REG(PM3RectanglePosition,
2425 (PM3RectanglePosition_XOffset(sx)) |
2426 (PM3RectanglePosition_YOffset(sy)));
2427
2428 PM3_WRITE_REG(PM3Render2D,
2429 PM3Render2D_AreaStippleEnable |
2430 PM3Render2D_XPositive |
2431 PM3Render2D_YPositive |
2432 PM3Render2D_Operation_Normal |
2433 PM3Render2D_SpanOperation |
2434 (PM3Render2D_Width(fontwidth(p))) |
2435 (PM3Render2D_Height(fontheight(p))));
2436 }
2437 pm3fb_wait_pm3(l_fb_info);
2438}
2439
2440static void pm3fb_cfbX_revc(struct display *p, int xx, int yy)
2441{
2442 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
2443
2444 xx = xx * fontwidth(p);
2445 yy = yy * fontheight(p);
2446
2447 if (l_fb_info->current_par->depth == 8)
2448 {
2449 if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
2450 PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask, 0x0F0F0F0F);
2451 else
2452 PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0x0F0F0F0F);
2453 }
2454
2455 PM3_WAIT(3);
2456
2457 PM3_WRITE_REG(PM3Config2D,
2458 PM3Config2D_UseConstantSource |
2459 PM3Config2D_ForegroundROPEnable |
2460 (PM3Config2D_ForegroundROP(0xa)) | /* Oxa is GXinvert */
2461 PM3Config2D_FBDestReadEnable |
2462 PM3Config2D_FBWriteEnable);
2463
2464 PM3_WRITE_REG(PM3RectanglePosition,
2465 (PM3RectanglePosition_XOffset(xx)) |
2466 (PM3RectanglePosition_YOffset(yy)));
2467
2468 PM3_WRITE_REG(PM3Render2D,
2469 PM3Render2D_XPositive |
2470 PM3Render2D_YPositive |
2471 PM3Render2D_Operation_Normal |
2472 PM3Render2D_SpanOperation |
2473 (PM3Render2D_Width(fontwidth(p))) |
2474 (PM3Render2D_Height(fontheight(p))));
2475
2476 pm3fb_wait_pm3(l_fb_info);
2477
2478 if (l_fb_info->current_par->depth == 8)
2479 {
2480 if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
2481 PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask, 0xFFFFFFFF);
2482 else
2483 PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0xFFFFFFFF);
2484 }
2485}
2486
2487#endif /* FBCON_HAS_CFB8 || FBCON_HAS_CFB16 || FBCON_HAS_CFB32 */
2488#endif /* PM3FB_USE_ACCEL */
2489/* *********************************** */
2490/* ***** pre-init board(s) setup ***** */
2491/* *********************************** */
2492
2493static void pm3fb_mode_setup(char *mode, unsigned long board_num)
2494{
2495 struct pm3fb_info *l_fb_info = &(fb_info[board_num]);
2496 struct pm3fb_par *l_fb_par = &(current_par[board_num]);
2497 unsigned long i = 0;
2498
2499 current_par_valid[board_num] = 0;
2500
2501 if (!strncmp(mode, "current", 7)) {
2502 l_fb_info->use_current = 1; /* default w/ OpenFirmware */
2503 } else {
2504 while ((mode_base[i].name[0])
2505 && (!current_par_valid[board_num])) {
2506 if (!
2507 (strncmp
2508 (mode, mode_base[i].name,
2509 strlen(mode_base[i].name)))) {
2510 memcpy(l_fb_par, &(mode_base[i].user_mode),
2511 sizeof(struct pm3fb_par));
2512 current_par_valid[board_num] = 1;
2513 DPRINTK(2, "Mode set to %s\n",
2514 mode_base[i].name);
2515 }
2516 i++;
2517 }
2518 DASSERT(current_par_valid[board_num],
2519 "Valid mode on command line\n");
2520 }
2521}
2522
2523static void pm3fb_pciid_setup(char *pciid, unsigned long board_num)
2524{
2525 short l_bus = -1, l_slot = -1, l_func = -1;
2526 char *next;
2527
2528 if (pciid) {
2529 l_bus = simple_strtoul(pciid, &next, 10);
2530 if (next && (next[0] == ':')) {
2531 pciid = next + 1;
2532 l_slot = simple_strtoul(pciid, &next, 10);
2533 if (next && (next[0] == ':')) {
2534 pciid = next + 1;
2535 l_func =
2536 simple_strtoul(pciid, (char **) NULL,
2537 10);
2538 }
2539 }
2540 } else
2541 return;
2542
2543 if ((l_bus >= 0) && (l_slot >= 0) && (l_func >= 0)) {
2544 bus[board_num] = l_bus;
2545 slot[board_num] = l_slot;
2546 func[board_num] = l_func;
2547 DPRINTK(2, "Board #%ld will be PciId: %hd:%hd:%hd\n",
2548 board_num, l_bus, l_slot, l_func);
2549 } else {
2550 DPRINTK(1, "Invalid PciId: %hd:%hd:%hd for board #%ld\n",
2551 l_bus, l_slot, l_func, board_num);
2552 }
2553}
2554
2555static void pm3fb_font_setup(char *lf, unsigned long board_num)
2556{
2557 unsigned long lfs = strlen(lf);
2558
2559 if (lfs > (PM3_FONTNAME_SIZE - 1)) {
2560 DPRINTK(1, "Fontname %s too long\n", lf);
2561 return;
2562 }
2563 strlcpy(fontn[board_num], lf, lfs + 1);
2564}
2565
2566static void pm3fb_bootdepth_setup(char *bds, unsigned long board_num)
2567{
2568 unsigned long bd = simple_strtoul(bds, (char **) NULL, 10);
2569
2570 if (!(depth_supported(bd))) {
2571 printk(KERN_WARNING "pm3fb: ignoring invalid depth %s for board #%ld\n",
2572 bds, board_num);
2573 return;
2574 }
2575 depth[board_num] = bd;
2576}
2577
2578static void pm3fb_forcesize_setup(char *bds, unsigned long board_num)
2579{
2580 unsigned long bd = simple_strtoul(bds, (char **) NULL, 10);
2581
2582 if (bd > 64) {
2583 printk(KERN_WARNING "pm3fb: ignoring invalid memory size %s for board #%ld\n",
2584 bds, board_num);
2585 return;
2586 }
2587 forcesize[board_num] = bd;
2588}
2589
2590static char *pm3fb_boardnum_setup(char *options, unsigned long *bn)
2591{
2592 char *next;
2593
2594 if (!(isdigit(options[0]))) {
2595 (*bn) = 0;
2596 return (options);
2597 }
2598
2599 (*bn) = simple_strtoul(options, &next, 10);
2600 516
2601 if (next && (next[0] == ':') && ((*bn) >= 0) 517 if (info->var.sync & FB_SYNC_VERT_HIGH_ACT)
2602 && ((*bn) <= PM3_MAX_BOARD)) { 518 par->video |= PM3VideoControl_VSYNC_ACTIVE_HIGH;
2603 DPRINTK(2, "Board_num seen as %ld\n", (*bn));
2604 return (next + 1);
2605 } else {
2606 (*bn) = 0;
2607 DPRINTK(2, "Board_num default to %ld\n", (*bn));
2608 return (options);
2609 }
2610}
2611
2612static void pm3fb_real_setup(char *options)
2613{
2614 char *next;
2615 unsigned long i, bn;
2616 struct pm3fb_info *l_fb_info;
2617
2618 DTRACE;
2619
2620 DPRINTK(2, "Options : %s\n", options);
2621
2622 for (i = 0; i < PM3_MAX_BOARD; i++) {
2623 l_fb_info = &(fb_info[i]);
2624 memset(l_fb_info, 0, sizeof(struct pm3fb_info));
2625 l_fb_info->gen.fbhw = &pm3fb_switch;
2626 l_fb_info->board_num = i;
2627 current_par_valid[i] = 0;
2628 slot[i] = -1;
2629 func[i] = -1;
2630 bus[i] = -1;
2631 disable[i] = 0;
2632 noaccel[i] = 0;
2633 fontn[i][0] = '\0';
2634 depth[i] = 0;
2635 l_fb_info->current_par = &(current_par[i]);
2636 }
2637
2638 /* eat up prefix pm3fb and whatever is used as separator i.e. :,= */
2639 if (!strncmp(options, "pm3fb", 5)) {
2640 options += 5;
2641 while (((*options) == ',') || ((*options) == ':')
2642 || ((*options) == '='))
2643 options++;
2644 }
2645
2646 while (options) {
2647 bn = 0;
2648 if ((next = strchr(options, ','))) {
2649 (*next) = '\0';
2650 next++;
2651 }
2652
2653 if (!strncmp(options, "mode:", 5)) {
2654 options = pm3fb_boardnum_setup(options + 5, &bn);
2655 DPRINTK(2, "Setting mode for board #%ld\n", bn);
2656 pm3fb_mode_setup(options, bn);
2657 } else if (!strncmp(options, "off:", 4)) {
2658 options = pm3fb_boardnum_setup(options + 4, &bn);
2659 DPRINTK(2, "Disabling board #%ld\n", bn);
2660 disable[bn] = 1;
2661 } else if (!strncmp(options, "off", 3)) { /* disable everything */
2662 for (i = 0; i < PM3_MAX_BOARD; i++)
2663 disable[i] = 1;
2664 } else if (!strncmp(options, "disable:", 8)) {
2665 options = pm3fb_boardnum_setup(options + 8, &bn);
2666 DPRINTK(2, "Disabling board #%ld\n", bn);
2667 disable[bn] = 1;
2668 } else if (!strncmp(options, "pciid:", 6)) {
2669 options = pm3fb_boardnum_setup(options + 6, &bn);
2670 DPRINTK(2, "Setting PciID for board #%ld\n", bn);
2671 pm3fb_pciid_setup(options, bn);
2672 } else if (!strncmp(options, "noaccel:", 8)) {
2673 options = pm3fb_boardnum_setup(options + 8, &bn);
2674 noaccel[bn] = 1;
2675 } else if (!strncmp(options, "font:", 5)) {
2676 options = pm3fb_boardnum_setup(options + 5, &bn);
2677 pm3fb_font_setup(options, bn);
2678 } else if (!strncmp(options, "depth:", 6)) {
2679 options = pm3fb_boardnum_setup(options + 6, &bn);
2680 pm3fb_bootdepth_setup(options, bn);
2681 } else if (!strncmp(options, "printtimings", 12)) {
2682 printtimings = 1;
2683 } else if (!strncmp(options, "flatpanel:", 10)) {
2684 options = pm3fb_boardnum_setup(options + 10, &bn);
2685 flatpanel[bn] = 1;
2686 } else if (!strncmp(options, "forcesize:", 10)) {
2687 options = pm3fb_boardnum_setup(options + 10, &bn);
2688 pm3fb_forcesize_setup(options, bn);
2689 }
2690 options = next;
2691 }
2692}
2693
2694/* ********************************************** */
2695/* ***** framebuffer API standard functions ***** */
2696/* ********************************************** */
2697
2698static int pm3fb_encode_fix(struct fb_fix_screeninfo *fix,
2699 const void *par, struct fb_info_gen *info)
2700{
2701 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
2702 struct pm3fb_par *p = (struct pm3fb_par *) par;
2703
2704 DTRACE;
2705
2706 strcpy(fix->id, permedia3_name);
2707 fix->smem_start = (unsigned long)l_fb_info->p_fb;
2708 fix->smem_len = l_fb_info->fb_size;
2709 fix->mmio_start = (unsigned long)l_fb_info->pIOBase;
2710 fix->mmio_len = PM3_REGS_SIZE;
2711#ifdef PM3FB_USE_ACCEL
2712 if (!(noaccel[l_fb_info->board_num]))
2713 fix->accel = FB_ACCEL_3DLABS_PERMEDIA3;
2714 else
2715#endif /* PM3FB_USE_ACCEL */
2716 fix->accel = FB_ACCEL_NONE;
2717 fix->type = FB_TYPE_PACKED_PIXELS;
2718 fix->visual =
2719 (p->depth == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
2720 if (current_par_valid[l_fb_info->board_num])
2721 fix->line_length =
2722 l_fb_info->current_par->width *
2723 depth2ByPP(l_fb_info->current_par->depth);
2724 else 519 else
2725 fix->line_length = 0; 520 par->video |= PM3VideoControl_VSYNC_ACTIVE_LOW;
2726 fix->xpanstep = 64 / depth2bpp(p->depth);
2727 fix->ypanstep = 1;
2728 fix->ywrapstep = 0;
2729 return (0);
2730}
2731
2732static int pm3fb_decode_var(const struct fb_var_screeninfo *var,
2733 void *par, struct fb_info_gen *info)
2734{
2735 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
2736 struct pm3fb_par *p = (struct pm3fb_par *) par;
2737 struct pm3fb_par temp_p;
2738 u32 xres;
2739
2740 DTRACE;
2741
2742 DASSERT((var != NULL), "fb_var_screeninfo* not NULL");
2743 DASSERT((p != NULL), "pm3fb_par* not NULL");
2744 DASSERT((l_fb_info != NULL), "pm3fb_info* not NULL");
2745 521
2746 memset(&temp_p, 0, sizeof(struct pm3fb_par)); 522 if ((info->var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE)
2747 temp_p.width = (var->xres_virtual + 7) & ~7; 523 par->video |= PM3VideoControl_LINE_DOUBLE_ON;
2748 temp_p.height = var->yres_virtual;
2749
2750 if (!(depth_supported(var->bits_per_pixel))) /* round unsupported up to a multiple of 8 */
2751 temp_p.depth = depth2bpp(var->bits_per_pixel);
2752 else 524 else
2753 temp_p.depth = var->bits_per_pixel; 525 par->video |= PM3VideoControl_LINE_DOUBLE_OFF;
2754
2755 temp_p.depth = (temp_p.depth > 32) ? 32 : temp_p.depth; /* max 32 */
2756 temp_p.depth = (temp_p.depth == 24) ? 32 : temp_p.depth; /* 24 unsupported, round-up to 32 */
2757
2758 if ((temp_p.depth == 16) && (var->red.length == 5) && (var->green.length == 5) && (var->blue.length == 5))
2759 temp_p.depth = 15; /* RGBA 5551 is stored as depth 15 */
2760
2761 if ((temp_p.depth == 16) && (var->red.length == 4) && (var->green.length == 4) && (var->blue.length == 4))
2762 temp_p.depth = 12; /* RGBA 4444 is stored as depth 12 */
2763
2764
2765 DPRINTK(2,
2766 "xres: %d, yres: %d, vxres: %d, vyres: %d ; xoffset:%d, yoffset: %d\n",
2767 var->xres, var->yres, var->xres_virtual, var->yres_virtual,
2768 var->xoffset, var->yoffset);
2769
2770 xres = (var->xres + 31) & ~31;
2771 if (temp_p.width < xres + var->xoffset)
2772 temp_p.width = xres + var->xoffset;
2773 if (temp_p.height < var->yres + var->yoffset)
2774 temp_p.height = var->yres + var->yoffset;
2775
2776 if (temp_p.width > 2048) {
2777 DPRINTK(1, "virtual width not supported: %u\n",
2778 temp_p.width);
2779 return (-EINVAL);
2780 }
2781 if (var->yres < 200) {
2782 DPRINTK(1, "height not supported: %u\n", (u32) var->yres);
2783 return (-EINVAL);
2784 }
2785 if (temp_p.height < 200 || temp_p.height > 4095) {
2786 DPRINTK(1, "virtual height not supported: %u\n",
2787 temp_p.height);
2788 return (-EINVAL);
2789 }
2790 if (!(depth_supported(temp_p.depth))) {
2791 DPRINTK(1, "depth not supported: %u\n", temp_p.depth);
2792 return (-EINVAL);
2793 }
2794 if ((temp_p.width * temp_p.height * depth2ByPP(temp_p.depth)) >
2795 l_fb_info->fb_size) {
2796 DPRINTK(1, "no memory for screen (%ux%ux%u)\n",
2797 temp_p.width, temp_p.height, temp_p.depth);
2798 return (-EINVAL);
2799 }
2800
2801 if ((!var->pixclock) ||
2802 (!var->right_margin) ||
2803 (!var->hsync_len) ||
2804 (!var->left_margin) ||
2805 (!var->lower_margin) ||
2806 (!var->vsync_len) || (!var->upper_margin)
2807 ) {
2808 unsigned long i = 0, done = 0;
2809 printk(KERN_WARNING "pm3fb: refusing to use a likely wrong timing\n");
2810
2811 while ((mode_base[i].user_mode.width) && !done) {
2812 if ((mode_base[i].user_mode.width == temp_p.width)
2813 && (mode_base[i].user_mode.height ==
2814 temp_p.height)) {
2815 printk(KERN_NOTICE "pm3fb: using close match %s\n",
2816 mode_base[i].name);
2817 temp_p = mode_base[i].user_mode;
2818 done = 1;
2819 }
2820 i++;
2821 }
2822 if (!done)
2823 return (-EINVAL);
2824 } else {
2825 temp_p.pixclock = PICOS2KHZ(var->pixclock);
2826 if (temp_p.pixclock > PM3_MAX_PIXCLOCK) {
2827 DPRINTK(1, "pixclock too high (%uKHz)\n",
2828 temp_p.pixclock);
2829 return (-EINVAL);
2830 }
2831
2832 temp_p.hsstart = var->right_margin;
2833 temp_p.hsend = var->right_margin + var->hsync_len;
2834 temp_p.hbend =
2835 var->right_margin + var->hsync_len + var->left_margin;
2836 temp_p.htotal = xres + temp_p.hbend;
2837
2838 temp_p.vsstart = var->lower_margin;
2839 temp_p.vsend = var->lower_margin + var->vsync_len;
2840 temp_p.vbend =
2841 var->lower_margin + var->vsync_len + var->upper_margin;
2842 temp_p.vtotal = var->yres + temp_p.vbend;
2843
2844 temp_p.stride = temp_p.width;
2845
2846 DPRINTK(2, "Using %d * %d, %d Khz, stride is %08x\n",
2847 temp_p.width, temp_p.height, temp_p.pixclock,
2848 temp_p.stride);
2849
2850 temp_p.base =
2851 pm3fb_Shiftbpp(l_fb_info, temp_p.depth,
2852 (var->yoffset * xres) + var->xoffset);
2853 526
2854 temp_p.video = 0; 527 if (info->var.activate == FB_ACTIVATE_NOW)
2855 528 par->video |= PM3VideoControl_ENABLE;
2856 if (var->sync & FB_SYNC_HOR_HIGH_ACT) 529 else {
2857 temp_p.video |= PM3VideoControl_HSYNC_ACTIVE_HIGH; 530 par->video |= PM3VideoControl_DISABLE;
2858 else 531 DPRINTK("PM3Video disabled\n");
2859 temp_p.video |= PM3VideoControl_HSYNC_ACTIVE_LOW;
2860
2861 if (var->sync & FB_SYNC_VERT_HIGH_ACT)
2862 temp_p.video |= PM3VideoControl_VSYNC_ACTIVE_HIGH;
2863 else
2864 temp_p.video |= PM3VideoControl_VSYNC_ACTIVE_LOW;
2865
2866 if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
2867 DPRINTK(1, "Interlaced mode not supported\n\n");
2868 return (-EINVAL);
2869 }
2870
2871 if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE)
2872 temp_p.video |= PM3VideoControl_LINE_DOUBLE_ON;
2873 else
2874 temp_p.video |= PM3VideoControl_LINE_DOUBLE_OFF;
2875
2876 if (var->activate == FB_ACTIVATE_NOW)
2877 temp_p.video |= PM3VideoControl_ENABLE;
2878 else {
2879 temp_p.video |= PM3VideoControl_DISABLE;
2880 DPRINTK(2, "PM3Video disabled\n");
2881 }
2882
2883 switch (temp_p.depth) {
2884 case 8:
2885 temp_p.video |= PM3VideoControl_PIXELSIZE_8BIT;
2886 break;
2887 case 12:
2888 case 15:
2889 case 16:
2890 temp_p.video |= PM3VideoControl_PIXELSIZE_16BIT;
2891 break;
2892 case 32:
2893 temp_p.video |= PM3VideoControl_PIXELSIZE_32BIT;
2894 break;
2895 default:
2896 DPRINTK(1, "Unsupported depth\n");
2897 break;
2898 }
2899 } 532 }
2900 (*p) = temp_p; 533 switch (depth) {
2901
2902#ifdef PM3FB_USE_ACCEL
2903 if (var->accel_flags & FB_ACCELF_TEXT)
2904 noaccel[l_fb_info->board_num] = 0;
2905 else
2906 noaccel[l_fb_info->board_num] = 1;
2907#endif /* PM3FB_USE_ACCEL */
2908
2909 return (0);
2910}
2911
2912static void pm3fb_encode_depth(struct fb_var_screeninfo *var, long d)
2913{
2914 switch (d) {
2915 case 8: 534 case 8:
2916 var->red.length = var->green.length = var->blue.length = 8; 535 par->video |= PM3VideoControl_PIXELSIZE_8BIT;
2917 var->red.offset = var->green.offset = var->blue.offset = 0;
2918 var->transp.offset = var->transp.length = 0;
2919 break; 536 break;
2920
2921 case 12: 537 case 12:
2922 var->red.offset = 8;
2923 var->red.length = 4;
2924 var->green.offset = 4;
2925 var->green.length = 4;
2926 var->blue.offset = 0;
2927 var->blue.length = 4;
2928 var->transp.offset = 12;
2929 var->transp.length = 4;
2930 break;
2931
2932 case 15: 538 case 15:
2933 var->red.offset = 10;
2934 var->red.length = 5;
2935 var->green.offset = 5;
2936 var->green.length = 5;
2937 var->blue.offset = 0;
2938 var->blue.length = 5;
2939 var->transp.offset = 15;
2940 var->transp.length = 1;
2941 break;
2942
2943 case 16: 539 case 16:
2944 var->red.offset = 11; 540 par->video |= PM3VideoControl_PIXELSIZE_16BIT;
2945 var->red.length = 5;
2946 var->green.offset = 5;
2947 var->green.length = 6;
2948 var->blue.offset = 0;
2949 var->blue.length = 5;
2950 var->transp.offset = var->transp.length = 0;
2951 break; 541 break;
2952
2953 case 32: 542 case 32:
2954 var->transp.offset = 24; 543 par->video |= PM3VideoControl_PIXELSIZE_32BIT;
2955 var->red.offset = 16;
2956 var->green.offset = 8;
2957 var->blue.offset = 0;
2958 var->red.length = var->green.length =
2959 var->blue.length = var->transp.length = 8;
2960 break; 544 break;
2961
2962 default: 545 default:
2963 DPRINTK(1, "Unsupported depth %ld\n", d); 546 DPRINTK("Unsupported depth\n");
2964 break; 547 break;
2965 } 548 }
2966}
2967
2968static int pm3fb_encode_var(struct fb_var_screeninfo *var,
2969 const void *par, struct fb_info_gen *info)
2970{
2971 struct pm3fb_par *p = (struct pm3fb_par *) par;
2972 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
2973
2974 u32 base;
2975
2976 DTRACE;
2977
2978 DASSERT((var != NULL), "fb_var_screeninfo* not NULL");
2979 DASSERT((p != NULL), "pm3fb_par* not NULL");
2980 DASSERT((info != NULL), "fb_info_gen* not NULL");
2981
2982 memset(var, 0, sizeof(struct fb_var_screeninfo));
2983
2984#ifdef PM3FB_USE_ACCEL
2985 if (!(noaccel[l_fb_info->board_num]))
2986 var->accel_flags |= FB_ACCELF_TEXT;
2987#endif /* PM3FB_USE_ACCEL */
2988
2989 var->xres_virtual = p->width;
2990 var->yres_virtual = p->height;
2991 var->xres = p->htotal - p->hbend;
2992 var->yres = p->vtotal - p->vbend;
2993
2994 DPRINTK(2, "xres = %d, yres : %d\n", var->xres, var->yres);
2995
2996 var->right_margin = p->hsstart;
2997 var->hsync_len = p->hsend - p->hsstart;
2998 var->left_margin = p->hbend - p->hsend;
2999 var->lower_margin = p->vsstart;
3000 var->vsync_len = p->vsend - p->vsstart;
3001 var->upper_margin = p->vbend - p->vsend;
3002 var->bits_per_pixel = depth2bpp(p->depth);
3003
3004 pm3fb_encode_depth(var, p->depth);
3005
3006 base = pm3fb_Unshiftbpp(l_fb_info, p->depth, p->base);
3007
3008 var->xoffset = base % var->xres;
3009 var->yoffset = base / var->xres;
3010
3011 var->height = var->width = -1;
3012
3013 var->pixclock = KHZ2PICOS(p->pixclock);
3014
3015 if ((p->video & PM3VideoControl_HSYNC_MASK) ==
3016 PM3VideoControl_HSYNC_ACTIVE_HIGH)
3017 var->sync |= FB_SYNC_HOR_HIGH_ACT;
3018 if ((p->video & PM3VideoControl_VSYNC_MASK) ==
3019 PM3VideoControl_VSYNC_ACTIVE_HIGH)
3020 var->sync |= FB_SYNC_VERT_HIGH_ACT;
3021 if (p->video & PM3VideoControl_LINE_DOUBLE_ON)
3022 var->vmode = FB_VMODE_DOUBLE;
3023
3024 return (0);
3025}
3026
3027static void pm3fb_get_par(void *par, struct fb_info_gen *info)
3028{
3029 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
3030
3031 DTRACE;
3032
3033 if (!current_par_valid[l_fb_info->board_num]) {
3034 if (l_fb_info->use_current)
3035 pm3fb_read_mode(l_fb_info, l_fb_info->current_par);
3036 else
3037 memcpy(l_fb_info->current_par,
3038 &(mode_base[0].user_mode),
3039 sizeof(struct pm3fb_par));
3040 current_par_valid[l_fb_info->board_num] = 1;
3041 }
3042 *((struct pm3fb_par *) par) = *(l_fb_info->current_par);
3043}
3044
3045static void pm3fb_set_par(const void *par, struct fb_info_gen *info)
3046{
3047 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
3048
3049 DTRACE;
3050 549
3051 *(l_fb_info->current_par) = *((struct pm3fb_par *) par); 550 info->fix.visual =
3052 current_par_valid[l_fb_info->board_num] = 1; 551 (depth == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
552 info->fix.line_length = ((info->var.xres_virtual + 7) & ~7)
553 * depth / 8;
3053 554
3054 pm3fb_write_mode(l_fb_info); 555/* pm3fb_clear_memory(info, 0);*/
3055 556 pm3fb_clear_colormap(par, 0, 0, 0);
3056#ifdef PM3FB_USE_ACCEL 557 PM3_WRITE_DAC_REG(par, PM3RD_CursorMode,
3057 pm3fb_init_engine(l_fb_info); 558 PM3RD_CursorMode_CURSOR_DISABLE);
3058#endif /* PM3FB_USE_ACCEL */ 559 pm3fb_write_mode(info);
3059} 560 return 0;
3060
3061static void pm3fb_set_color(struct pm3fb_info *l_fb_info,
3062 unsigned char regno, unsigned char r,
3063 unsigned char g, unsigned char b)
3064{
3065 DTRACE;
3066
3067 PM3_SLOW_WRITE_REG(PM3RD_PaletteWriteAddress, regno);
3068 PM3_SLOW_WRITE_REG(PM3RD_PaletteData, r);
3069 PM3_SLOW_WRITE_REG(PM3RD_PaletteData, g);
3070 PM3_SLOW_WRITE_REG(PM3RD_PaletteData, b);
3071}
3072
3073static int pm3fb_getcolreg(unsigned regno, unsigned *red, unsigned *green,
3074 unsigned *blue, unsigned *transp,
3075 struct fb_info *info)
3076{
3077 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
3078
3079 DTRACE;
3080
3081 if (regno < 256) {
3082 *red =
3083 l_fb_info->palette[regno].red << 8 | l_fb_info->
3084 palette[regno].red;
3085 *green =
3086 l_fb_info->palette[regno].green << 8 | l_fb_info->
3087 palette[regno].green;
3088 *blue =
3089 l_fb_info->palette[regno].blue << 8 | l_fb_info->
3090 palette[regno].blue;
3091 *transp =
3092 l_fb_info->palette[regno].transp << 8 | l_fb_info->
3093 palette[regno].transp;
3094 }
3095 return (regno > 255);
3096} 561}
3097 562
3098static int pm3fb_setcolreg(unsigned regno, unsigned red, unsigned green, 563static int pm3fb_setcolreg(unsigned regno, unsigned red, unsigned green,
3099 unsigned blue, unsigned transp, 564 unsigned blue, unsigned transp,
3100 struct fb_info *info) 565 struct fb_info *info)
3101{ 566{
3102 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; 567 struct pm3_par *par = info->par;
3103 568
3104 DTRACE; 569 if (regno >= 256) /* no. of hw registers */
570 return -EINVAL;
571
572 /* grayscale works only partially under directcolor */
573 if (info->var.grayscale) {
574 /* grayscale = 0.30*R + 0.59*G + 0.11*B */
575 red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
576 }
577
578 /* Directcolor:
579 * var->{color}.offset contains start of bitfield
580 * var->{color}.length contains length of bitfield
581 * {hardwarespecific} contains width of DAC
582 * pseudo_palette[X] is programmed to (X << red.offset) |
583 * (X << green.offset) |
584 * (X << blue.offset)
585 * RAMDAC[X] is programmed to (red, green, blue)
586 * color depth = SUM(var->{color}.length)
587 *
588 * Pseudocolor:
589 * var->{color}.offset is 0
590 * var->{color}.length contains width of DAC or the number of unique
591 * colors available (color depth)
592 * pseudo_palette is not used
593 * RAMDAC[X] is programmed to (red, green, blue)
594 * color depth = var->{color}.length
595 */
3105 596
3106 if (regno < 16) { 597 /*
3107 switch (l_fb_info->current_par->depth) { 598 * This is the point where the color is converted to something that
3108#ifdef FBCON_HAS_CFB8 599 * is acceptable by the hardware.
600 */
601#define CNVT_TOHW(val,width) ((((val)<<(width))+0x7FFF-(val))>>16)
602 red = CNVT_TOHW(red, info->var.red.length);
603 green = CNVT_TOHW(green, info->var.green.length);
604 blue = CNVT_TOHW(blue, info->var.blue.length);
605 transp = CNVT_TOHW(transp, info->var.transp.length);
606#undef CNVT_TOHW
607
608 if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
609 info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
610 u32 v;
611
612 if (regno >= 16)
613 return -EINVAL;
614
615 v = (red << info->var.red.offset) |
616 (green << info->var.green.offset) |
617 (blue << info->var.blue.offset) |
618 (transp << info->var.transp.offset);
619
620 switch (info->var.bits_per_pixel) {
3109 case 8: 621 case 8:
3110 break; 622 break;
3111#endif
3112#ifdef FBCON_HAS_CFB16
3113 case 12:
3114 l_fb_info->cmap.cmap12[regno] =
3115 (((u32) red & 0xf000) >> 4) |
3116 (((u32) green & 0xf000) >> 8) |
3117 (((u32) blue & 0xf000) >> 12);
3118 break;
3119
3120 case 15:
3121 l_fb_info->cmap.cmap15[regno] =
3122 (((u32) red & 0xf800) >> 1) |
3123 (((u32) green & 0xf800) >> 6) |
3124 (((u32) blue & 0xf800) >> 11);
3125 break;
3126
3127 case 16: 623 case 16:
3128 l_fb_info->cmap.cmap16[regno] = 624 case 24:
3129 ((u32) red & 0xf800) |
3130 (((u32) green & 0xfc00) >> 5) |
3131 (((u32) blue & 0xf800) >> 11);
3132 break;
3133#endif
3134#ifdef FBCON_HAS_CFB32
3135 case 32: 625 case 32:
3136 l_fb_info->cmap.cmap32[regno] = 626 ((u32*)(info->pseudo_palette))[regno] = v;
3137 (((u32) transp & 0xff00) << 16) |
3138 (((u32) red & 0xff00) << 8) |
3139 (((u32) green & 0xff00)) |
3140 (((u32) blue & 0xff00) >> 8);
3141 break;
3142#endif
3143 default:
3144 DPRINTK(1, "bad depth %u\n",
3145 l_fb_info->current_par->depth);
3146 break; 627 break;
3147 } 628 }
629 return 0;
3148 } 630 }
3149 if (regno < 256) { 631 else if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR)
3150 l_fb_info->palette[regno].red = red >> 8; 632 pm3fb_set_color(par, regno, red, green, blue);
3151 l_fb_info->palette[regno].green = green >> 8; 633
3152 l_fb_info->palette[regno].blue = blue >> 8; 634 return 0;
3153 l_fb_info->palette[regno].transp = transp >> 8;
3154 if (l_fb_info->current_par->depth == 8)
3155 pm3fb_set_color(l_fb_info, regno, red >> 8,
3156 green >> 8, blue >> 8);
3157 }
3158 return (regno > 255);
3159} 635}
3160 636
3161static int pm3fb_blank(int blank_mode, struct fb_info_gen *info) 637static int pm3fb_pan_display(struct fb_var_screeninfo *var,
638 struct fb_info *info)
3162{ 639{
3163 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; 640 struct pm3_par *par = info->par;
3164 u32 video; 641 const u32 xres = (var->xres + 31) & ~31;
3165
3166 DTRACE;
3167 642
3168 if (!current_par_valid[l_fb_info->board_num]) 643 par->base = pm3fb_shift_bpp(var->bits_per_pixel,
3169 return (1); 644 (var->yoffset * xres)
645 + var->xoffset);
646 PM3_SLOW_WRITE_REG(par, PM3ScreenBase, par->base);
647 return 0;
648}
3170 649
3171 video = l_fb_info->current_par->video; 650static int pm3fb_blank(int blank_mode, struct fb_info *info)
651{
652 struct pm3_par *par = info->par;
653 u32 video = par->video;
3172 654
3173 /* 655 /*
3174 * Oxygen VX1 - it appears that setting PM3VideoControl and 656 * Oxygen VX1 - it appears that setting PM3VideoControl and
@@ -3181,454 +663,345 @@ static int pm3fb_blank(int blank_mode, struct fb_info_gen *info)
3181 video |= PM3VideoControl_HSYNC_ACTIVE_HIGH | 663 video |= PM3VideoControl_HSYNC_ACTIVE_HIGH |
3182 PM3VideoControl_VSYNC_ACTIVE_HIGH; 664 PM3VideoControl_VSYNC_ACTIVE_HIGH;
3183 665
3184 if (blank_mode > 0) { 666 switch (blank_mode) {
3185 switch (blank_mode - 1) { 667 case FB_BLANK_UNBLANK:
3186 668 video = video | PM3VideoControl_ENABLE;
3187 case VESA_NO_BLANKING: /* FIXME */
3188 video = video & ~(PM3VideoControl_ENABLE);
3189 break;
3190
3191 case VESA_HSYNC_SUSPEND:
3192 video = video & ~(PM3VideoControl_HSYNC_MASK |
3193 PM3VideoControl_BLANK_ACTIVE_LOW);
3194 break;
3195 case VESA_VSYNC_SUSPEND:
3196 video = video & ~(PM3VideoControl_VSYNC_MASK |
3197 PM3VideoControl_BLANK_ACTIVE_LOW);
3198 break;
3199 case VESA_POWERDOWN:
3200 video = video & ~(PM3VideoControl_HSYNC_MASK |
3201 PM3VideoControl_VSYNC_MASK |
3202 PM3VideoControl_BLANK_ACTIVE_LOW);
3203 break;
3204 default:
3205 DPRINTK(1, "Unsupported blanking %d\n",
3206 blank_mode);
3207 return (1);
3208 break;
3209 }
3210 }
3211
3212 PM3_SLOW_WRITE_REG(PM3VideoControl, video);
3213
3214 return (0);
3215}
3216
3217static void pm3fb_set_disp(const void *par, struct display *disp,
3218 struct fb_info_gen *info)
3219{
3220 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
3221 struct pm3fb_par *p = (struct pm3fb_par *) par;
3222 u32 flags;
3223
3224 DTRACE;
3225
3226 local_irq_save(flags);
3227 info->info.screen_base = l_fb_info->v_fb;
3228 switch (p->depth) {
3229#ifdef FBCON_HAS_CFB8
3230 case 8:
3231#ifdef PM3FB_USE_ACCEL
3232 if (!(noaccel[l_fb_info->board_num]))
3233 disp->dispsw = &pm3fb_cfb8;
3234 else
3235#endif /* PM3FB_USE_ACCEL */
3236 disp->dispsw = &fbcon_cfb8;
3237 break; 669 break;
3238#endif 670 case FB_BLANK_NORMAL: /* FIXME */
3239#ifdef FBCON_HAS_CFB16 671 video = video & ~(PM3VideoControl_ENABLE);
3240 case 12:
3241#ifdef PM3FB_USE_ACCEL
3242 if (!(noaccel[l_fb_info->board_num]))
3243 disp->dispsw = &pm3fb_cfb16;
3244 else
3245#endif /* PM3FB_USE_ACCEL */
3246 disp->dispsw = &fbcon_cfb16;
3247 disp->dispsw_data = l_fb_info->cmap.cmap12;
3248 break; 672 break;
3249 case 15: 673 case FB_BLANK_HSYNC_SUSPEND:
3250#ifdef PM3FB_USE_ACCEL 674 video = video & ~(PM3VideoControl_HSYNC_MASK |
3251 if (!(noaccel[l_fb_info->board_num])) 675 PM3VideoControl_BLANK_ACTIVE_LOW);
3252 disp->dispsw = &pm3fb_cfb16;
3253 else
3254#endif /* PM3FB_USE_ACCEL */
3255 disp->dispsw = &fbcon_cfb16;
3256 disp->dispsw_data = l_fb_info->cmap.cmap15;
3257 break; 676 break;
3258 case 16: 677 case FB_BLANK_VSYNC_SUSPEND:
3259#ifdef PM3FB_USE_ACCEL 678 video = video & ~(PM3VideoControl_VSYNC_MASK |
3260 if (!(noaccel[l_fb_info->board_num])) 679 PM3VideoControl_BLANK_ACTIVE_LOW);
3261 disp->dispsw = &pm3fb_cfb16;
3262 else
3263#endif /* PM3FB_USE_ACCEL */
3264 disp->dispsw = &fbcon_cfb16;
3265 disp->dispsw_data = l_fb_info->cmap.cmap16;
3266 break; 680 break;
3267#endif 681 case FB_BLANK_POWERDOWN:
3268#ifdef FBCON_HAS_CFB32 682 video = video & ~(PM3VideoControl_HSYNC_MASK |
3269 case 32: 683 PM3VideoControl_VSYNC_MASK |
3270#ifdef PM3FB_USE_ACCEL 684 PM3VideoControl_BLANK_ACTIVE_LOW);
3271 if (!(noaccel[l_fb_info->board_num]))
3272 disp->dispsw = &pm3fb_cfb32;
3273 else
3274#endif /* PM3FB_USE_ACCEL */
3275 disp->dispsw = &fbcon_cfb32;
3276 disp->dispsw_data = l_fb_info->cmap.cmap32;
3277 break; 685 break;
3278#endif /* FBCON_HAS_CFB32 */
3279 default: 686 default:
3280 disp->dispsw = &fbcon_dummy; 687 DPRINTK("Unsupported blanking %d\n", blank_mode);
3281 DPRINTK(1, "Invalid depth, using fbcon_dummy\n"); 688 return 1;
3282 break;
3283 } 689 }
3284 local_irq_restore(flags); 690
691 PM3_SLOW_WRITE_REG(par,PM3VideoControl, video);
692
693 return 0;
3285} 694}
3286 695
3287/* */ 696 /*
3288static void pm3fb_detect(void) 697 * Frame buffer operations
3289{ 698 */
3290 struct pci_dev *dev_array[PM3_MAX_BOARD];
3291 struct pci_dev *dev = NULL;
3292 struct pm3fb_info *l_fb_info = &(fb_info[0]);
3293 unsigned long i, j, done;
3294 699
3295 DTRACE; 700static struct fb_ops pm3fb_ops = {
701 .owner = THIS_MODULE,
702 .fb_check_var = pm3fb_check_var,
703 .fb_set_par = pm3fb_set_par,
704 .fb_setcolreg = pm3fb_setcolreg,
705 .fb_pan_display = pm3fb_pan_display,
706 .fb_fillrect = cfb_fillrect, /* Needed !!! */
707 .fb_copyarea = cfb_copyarea, /* Needed !!! */
708 .fb_imageblit = cfb_imageblit, /* Needed !!! */
709 .fb_blank = pm3fb_blank,
710};
3296 711
3297 for (i = 0; i < PM3_MAX_BOARD; i++) { 712/* ------------------------------------------------------------------------- */
3298 dev_array[i] = NULL;
3299 fb_info[i].dev = NULL;
3300 }
3301 713
3302 dev = pci_get_device(PCI_VENDOR_ID_3DLABS, 714 /*
3303 PCI_DEVICE_ID_3DLABS_PERMEDIA3, dev); 715 * Initialization
716 */
3304 717
3305 for (i = 0; ((i < PM3_MAX_BOARD) && dev); i++) { 718/* mmio register are already mapped when this function is called */
3306 dev_array[i] = dev; 719/* the pm3fb_fix.smem_start is also set */
3307 dev = pci_get_device(PCI_VENDOR_ID_3DLABS, 720static unsigned long pm3fb_size_memory(struct pm3_par *par)
3308 PCI_DEVICE_ID_3DLABS_PERMEDIA3, dev); 721{
3309 } 722 unsigned long memsize = 0, tempBypass, i, temp1, temp2;
723 unsigned char __iomem *screen_mem;
3310 724
3311 if (dev) { /* more than PM3_MAX_BOARD */ 725 pm3fb_fix.smem_len = 64 * 1024 * 1024; /* request full aperture size */
3312 printk(KERN_WARNING "pm3fb: Warning: more than %d boards found\n", 726 /* Linear frame buffer - request region and map it. */
3313 PM3_MAX_BOARD); 727 if (!request_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len,
728 "pm3fb smem")) {
729 printk(KERN_WARNING "pm3fb: Can't reserve smem.\n");
730 return 0;
3314 } 731 }
3315 732 screen_mem =
3316 if (!dev_array[0]) { /* not a single board, abort */ 733 ioremap_nocache(pm3fb_fix.smem_start, pm3fb_fix.smem_len);
3317 return; 734 if (!screen_mem) {
735 printk(KERN_WARNING "pm3fb: Can't ioremap smem area.\n");
736 release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len);
737 return 0;
3318 } 738 }
3319 739
3320 /* allocate user-defined boards */ 740 /* TODO: card-specific stuff, *before* accessing *any* FB memory */
3321 for (i = 0; i < PM3_MAX_BOARD; i++) { 741 /* For Appian Jeronimo 2000 board second head */
3322 if ((bus[i] >= 0) && (slot[i] >= 0) && (func[i] >= 0)) { 742
3323 for (j = 0; j < PM3_MAX_BOARD; j++) { 743 tempBypass = PM3_READ_REG(par, PM3MemBypassWriteMask);
3324 if ((dev_array[j] != NULL) && 744
3325 (dev_array[j]->bus->number == bus[i]) 745 DPRINTK("PM3MemBypassWriteMask was: 0x%08lx\n", tempBypass);
3326 && (PCI_SLOT(dev_array[j]->devfn) == 746
3327 slot[i]) 747 PM3_SLOW_WRITE_REG(par, PM3MemBypassWriteMask, 0xFFFFFFFF);
3328 && (PCI_FUNC(dev_array[j]->devfn) == 748
3329 func[i])) { 749 /* pm3 split up memory, replicates, and do a lot of nasty stuff IMHO ;-) */
3330 fb_info[i].dev = dev_array[j]; 750 for (i = 0; i < 32; i++) {
3331 dev_array[j] = NULL; 751 fb_writel(i * 0x00345678,
3332 } 752 (screen_mem + (i * 1048576)));
3333 } 753 mb();
3334 } 754 temp1 = fb_readl((screen_mem + (i * 1048576)));
755
756 /* Let's check for wrapover, write will fail at 16MB boundary */
757 if (temp1 == (i * 0x00345678))
758 memsize = i;
759 else
760 break;
3335 } 761 }
3336 /* allocate remaining boards */ 762
3337 for (i = 0; i < PM3_MAX_BOARD; i++) { 763 DPRINTK("First detect pass already got %ld MB\n", memsize + 1);
3338 if (fb_info[i].dev == NULL) { 764
3339 done = 0; 765 if (memsize + 1 == i) {
3340 for (j = 0; ((j < PM3_MAX_BOARD) && (!done)); j++) { 766 for (i = 0; i < 32; i++) {
3341 if (dev_array[j] != NULL) { 767 /* Clear first 32MB ; 0 is 0, no need to byteswap */
3342 fb_info[i].dev = dev_array[j]; 768 writel(0x0000000,
3343 dev_array[j] = NULL; 769 (screen_mem + (i * 1048576)));
3344 done = 1; 770 mb();
3345 }
3346 }
3347 } 771 }
3348 }
3349 772
3350 /* at that point, all PCI Permedia3 are detected and allocated */ 773 for (i = 32; i < 64; i++) {
3351 /* now, initialize... or not */ 774 fb_writel(i * 0x00345678,
3352 for (i = 0; i < PM3_MAX_BOARD; i++) { 775 (screen_mem + (i * 1048576)));
3353 l_fb_info = &(fb_info[i]); 776 mb();
3354 if (l_fb_info->dev && !disable[i]) { /* PCI device was found and not disabled by user */ 777 temp1 =
3355 DPRINTK(2, 778 fb_readl((screen_mem + (i * 1048576)));
3356 "found @%lx Vendor %lx Device %lx ; base @ : %lx - %lx - %lx - %lx - %lx - %lx, irq %ld\n", 779 temp2 =
3357 (unsigned long) l_fb_info->dev, 780 fb_readl((screen_mem + ((i - 32) * 1048576)));
3358 (unsigned long) l_fb_info->dev->vendor, 781 /* different value, different RAM... */
3359 (unsigned long) l_fb_info->dev->device, 782 if ((temp1 == (i * 0x00345678)) && (temp2 == 0))
3360 (unsigned long) 783 memsize = i;
3361 pci_resource_start(l_fb_info->dev, 0), 784 else
3362 (unsigned long) 785 break;
3363 pci_resource_start(l_fb_info->dev, 1),
3364 (unsigned long)
3365 pci_resource_start(l_fb_info->dev, 2),
3366 (unsigned long)
3367 pci_resource_start(l_fb_info->dev, 3),
3368 (unsigned long)
3369 pci_resource_start(l_fb_info->dev, 4),
3370 (unsigned long)
3371 pci_resource_start(l_fb_info->dev, 5),
3372 (unsigned long) l_fb_info->dev->irq);
3373
3374 l_fb_info->pIOBase =
3375 (unsigned char *)
3376 pci_resource_start(l_fb_info->dev, 0);
3377#ifdef __BIG_ENDIAN
3378 l_fb_info->pIOBase += PM3_REGS_SIZE;
3379#endif
3380 l_fb_info->vIOBase = (unsigned char *) -1;
3381 l_fb_info->p_fb =
3382 (unsigned char *)
3383 pci_resource_start(l_fb_info->dev, 1);
3384 l_fb_info->v_fb = (unsigned char *) -1;
3385
3386 if (!request_mem_region
3387 ((unsigned long)l_fb_info->p_fb, 64 * 1024 * 1024, /* request full aperture size */
3388 "pm3fb")) {
3389 printk
3390 (KERN_ERR "pm3fb: Error: couldn't request framebuffer memory, board #%ld\n",
3391 l_fb_info->board_num);
3392 continue;
3393 }
3394 if (!request_mem_region
3395 ((unsigned long)l_fb_info->pIOBase, PM3_REGS_SIZE,
3396 "pm3fb I/O regs")) {
3397 printk
3398 (KERN_ERR "pm3fb: Error: couldn't request IObase memory, board #%ld\n",
3399 l_fb_info->board_num);
3400 continue;
3401 }
3402 if (forcesize[l_fb_info->board_num])
3403 l_fb_info->fb_size = forcesize[l_fb_info->board_num];
3404
3405 l_fb_info->fb_size =
3406 pm3fb_size_memory(l_fb_info);
3407 if (l_fb_info->fb_size) {
3408 (void) pci_enable_device(l_fb_info->dev);
3409 pm3fb_common_init(l_fb_info);
3410 } else
3411 printk(KERN_ERR "pm3fb: memory problem, not enabling board #%ld\n", l_fb_info->board_num);
3412 } 786 }
3413 } 787 }
3414} 788 DPRINTK("Second detect pass got %ld MB\n", memsize + 1);
3415 789
3416static int pm3fb_pan_display(const struct fb_var_screeninfo *var, 790 PM3_SLOW_WRITE_REG(par, PM3MemBypassWriteMask, tempBypass);
3417 struct fb_info_gen *info)
3418{
3419 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info;
3420 791
3421 DTRACE; 792 iounmap(screen_mem);
793 release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len);
794 memsize = 1048576 * (memsize + 1);
3422 795
3423 if (!current_par_valid[l_fb_info->board_num]) 796 DPRINTK("Returning 0x%08lx bytes\n", memsize);
3424 return -EINVAL;
3425 797
3426 l_fb_info->current_par->base = /* in 128 bits chunk - i.e. AFTER Shiftbpp */ 798 return memsize;
3427 pm3fb_Shiftbpp(l_fb_info,
3428 l_fb_info->current_par->depth,
3429 (var->yoffset * l_fb_info->current_par->width) +
3430 var->xoffset);
3431 PM3_SLOW_WRITE_REG(PM3ScreenBase, l_fb_info->current_par->base);
3432 return 0;
3433} 799}
3434 800
3435static int pm3fb_ioctl(struct fb_info *info, u_int cmd, u_long arg) 801static int __devinit pm3fb_probe(struct pci_dev *dev,
802 const struct pci_device_id *ent)
3436{ 803{
3437 struct pm3fb_info *l_fb_info = (struct pm3fb_info *) info; 804 struct fb_info *info;
3438 u32 cm, i; 805 struct pm3_par *par;
3439#ifdef PM3FB_MASTER_DEBUG 806 struct device* device = &dev->dev; /* for pci drivers */
3440 char cc[3]; 807 int err, retval = -ENXIO;
3441#endif /* PM3FB_MASTER_DEBUG */
3442 808
3443 switch(cmd) 809 err = pci_enable_device(dev);
3444 { 810 if (err) {
3445#ifdef PM3FB_MASTER_DEBUG 811 printk(KERN_WARNING "pm3fb: Can't enable PCI dev: %d\n", err);
3446 case PM3FBIO_CLEARMEMORY: 812 return err;
3447 if (copy_from_user(&cm, (void *)arg, sizeof(u32))) 813 }
3448 return(-EFAULT); 814 /*
3449 pm3fb_clear_memory(l_fb_info, cm); 815 * Dynamically allocate info and par
3450 return(0); 816 */
3451 break; 817 info = framebuffer_alloc(sizeof(struct pm3_par), device);
3452 818
3453 case PM3FBIO_CLEARCMAP: 819 if (!info)
3454 if (copy_from_user(cc, (void*)arg, 3 * sizeof(char))) 820 return -ENOMEM;
3455 return(-EFAULT); 821 par = info->par;
3456 pm3fb_clear_colormap(l_fb_info, cc[0], cc[1], cc[2]);
3457 return(0);
3458 break;
3459#endif /* PM3FB_MASTER_DEBUG */
3460
3461 case PM3FBIO_RESETCHIP:
3462 cm = 1;
3463 PM3_SLOW_WRITE_REG(PM3ResetStatus, 1);
3464 for (i = 0 ; (i < 10000) && cm ; i++)
3465 {
3466 PM3_DELAY(10);
3467 cm = PM3_READ_REG(PM3ResetStatus);
3468 }
3469 if (cm)
3470 {
3471 printk(KERN_ERR "pm3fb: chip reset failed with status 0x%x\n", cm);
3472 return(-EIO);
3473 }
3474 /* first thing first, reload memory timings */
3475 pm3fb_write_memory_timings(l_fb_info);
3476#ifdef PM3FB_USE_ACCEL
3477 pm3fb_init_engine(l_fb_info);
3478#endif /* PM3FB_USE_ACCEL */
3479 pm3fb_write_mode(l_fb_info);
3480 return(0);
3481 break;
3482 822
3483 default: 823 /*
3484 DPRINTK(2, "unknown ioctl: %d (%x)\n", cmd, cmd); 824 * Here we set the screen_base to the virtual memory address
3485 return(-EINVAL); 825 * for the framebuffer.
826 */
827 pm3fb_fix.mmio_start = pci_resource_start(dev, 0);
828 pm3fb_fix.mmio_len = PM3_REGS_SIZE;
829
830 /* Registers - request region and map it. */
831 if (!request_mem_region(pm3fb_fix.mmio_start, pm3fb_fix.mmio_len,
832 "pm3fb regbase")) {
833 printk(KERN_WARNING "pm3fb: Can't reserve regbase.\n");
834 goto err_exit_neither;
835 }
836 par->v_regs =
837 ioremap_nocache(pm3fb_fix.mmio_start, pm3fb_fix.mmio_len);
838 if (!par->v_regs) {
839 printk(KERN_WARNING "pm3fb: Can't remap %s register area.\n",
840 pm3fb_fix.id);
841 release_mem_region(pm3fb_fix.mmio_start, pm3fb_fix.mmio_len);
842 goto err_exit_neither;
843 }
844
845#if defined(__BIG_ENDIAN)
846 pm3fb_fix.mmio_start += PM3_REGS_SIZE;
847 DPRINTK("Adjusting register base for big-endian.\n");
848#endif
849 /* Linear frame buffer - request region and map it. */
850 pm3fb_fix.smem_start = pci_resource_start(dev, 1);
851 pm3fb_fix.smem_len = pm3fb_size_memory(par);
852 if (!pm3fb_fix.smem_len)
853 {
854 printk(KERN_WARNING "pm3fb: Can't find memory on board.\n");
855 goto err_exit_mmio;
3486 } 856 }
3487} 857 if (!request_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len,
858 "pm3fb smem")) {
859 printk(KERN_WARNING "pm3fb: Can't reserve smem.\n");
860 goto err_exit_mmio;
861 }
862 info->screen_base =
863 ioremap_nocache(pm3fb_fix.smem_start, pm3fb_fix.smem_len);
864 if (!info->screen_base) {
865 printk(KERN_WARNING "pm3fb: Can't ioremap smem area.\n");
866 release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len);
867 goto err_exit_mmio;
868 }
869 info->screen_size = pm3fb_fix.smem_len;
3488 870
3489/* ****************************************** */ 871 info->fbops = &pm3fb_ops;
3490/* ***** standard FB API init functions ***** */
3491/* ****************************************** */
3492 872
3493int __init pm3fb_setup(char *options) 873 par->video = PM3_READ_REG(par, PM3VideoControl);
3494{
3495 long opsi = strlen(options);
3496 874
3497 DTRACE; 875 info->fix = pm3fb_fix;
876 info->pseudo_palette = par->palette;
877 info->flags = FBINFO_DEFAULT;/* | FBINFO_HWACCEL_YPAN;*/
3498 878
3499 memcpy(g_options, options, 879 /*
3500 ((opsi + 1) > 880 * This should give a reasonable default video mode. The following is
3501 PM3_OPTIONS_SIZE) ? PM3_OPTIONS_SIZE : (opsi + 1)); 881 * done when we can set a video mode.
3502 g_options[PM3_OPTIONS_SIZE - 1] = 0; 882 */
883 if (!mode_option)
884 mode_option = "640x480@60";
885
886 retval = fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 8);
887
888 if (!retval || retval == 4) {
889 retval = -EINVAL;
890 goto err_exit_both;
891 }
892
893 /* This has to been done !!! */
894 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
895 retval = -ENOMEM;
896 goto err_exit_both;
897 }
3503 898
3504 return (0); 899 /*
900 * For drivers that can...
901 */
902 pm3fb_check_var(&info->var, info);
903
904 if (register_framebuffer(info) < 0) {
905 retval = -EINVAL;
906 goto err_exit_all;
907 }
908 printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node,
909 info->fix.id);
910 pci_set_drvdata(dev, info); /* or dev_set_drvdata(device, info) */
911 return 0;
912
913 err_exit_all:
914 fb_dealloc_cmap(&info->cmap);
915 err_exit_both:
916 iounmap(info->screen_base);
917 release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len);
918 err_exit_mmio:
919 iounmap(par->v_regs);
920 release_mem_region(pm3fb_fix.mmio_start, pm3fb_fix.mmio_len);
921 err_exit_neither:
922 framebuffer_release(info);
923 return retval;
3505} 924}
3506 925
3507int __init pm3fb_init(void) 926 /*
927 * Cleanup
928 */
929static void __devexit pm3fb_remove(struct pci_dev *dev)
3508{ 930{
3509 DTRACE; 931 struct fb_info *info = pci_get_drvdata(dev);
3510 932
3511 DPRINTK(2, "This is pm3fb.c, CVS version: $Header: /cvsroot/linux/drivers/video/pm3fb.c,v 1.1 2002/02/25 19:11:06 marcelo Exp $"); 933 if (info) {
934 struct fb_fix_screeninfo *fix = &info->fix;
935 struct pm3_par *par = info->par;
3512 936
3513 pm3fb_real_setup(g_options); 937 unregister_framebuffer(info);
938 fb_dealloc_cmap(&info->cmap);
3514 939
3515 pm3fb_detect(); 940 iounmap(info->screen_base);
941 release_mem_region(fix->smem_start, fix->smem_len);
942 iounmap(par->v_regs);
943 release_mem_region(fix->mmio_start, fix->mmio_len);
3516 944
3517 if (!fb_info[0].dev) { /* not even one board ??? */ 945 pci_set_drvdata(dev, NULL);
3518 DPRINTK(1, "No PCI Permedia3 board detected\n"); 946 framebuffer_release(info);
3519 } 947 }
3520 return (0);
3521} 948}
3522 949
3523/* ************************* */ 950static struct pci_device_id pm3fb_id_table[] = {
3524/* **** Module support ***** */ 951 { PCI_VENDOR_ID_3DLABS, 0x0a,
3525/* ************************* */ 952 PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16,
3526 953 0xff0000, 0 },
3527#ifdef MODULE 954 { 0, }
3528MODULE_AUTHOR("Romain Dolbeau"); 955};
3529MODULE_DESCRIPTION("Permedia3 framebuffer device driver");
3530static char *mode[PM3_MAX_BOARD];
3531module_param_array(mode, charp, NULL, 0);
3532MODULE_PARM_DESC(mode,"video mode");
3533module_param_array(disable, short, NULL, 0);
3534MODULE_PARM_DESC(disable,"disable board");
3535static short off[PM3_MAX_BOARD];
3536module_param_array(off, short, NULL, 0);
3537MODULE_PARM_DESC(off,"disable board");
3538static char *pciid[PM3_MAX_BOARD];
3539module_param_array(pciid, charp, NULL, 0);
3540MODULE_PARM_DESC(pciid,"board PCI Id");
3541module_param_array(noaccel, short, NULL, 0);
3542MODULE_PARM_DESC(noaccel,"disable accel");
3543static char *font[PM3_MAX_BOARD];
3544module_param_array(font, charp, NULL, 0);
3545MODULE_PARM_DESC(font,"choose font");
3546module_param(depth, short, NULL, 0);
3547MODULE_PARM_DESC(depth,"boot-time depth");
3548module_param(printtimings, short, NULL, 0);
3549MODULE_PARM_DESC(printtimings, "print the memory timings of the card(s)");
3550module_param(forcesize, short, NULL, 0);
3551MODULE_PARM_DESC(forcesize, "force specified memory size");
3552/*
3553MODULE_SUPPORTED_DEVICE("Permedia3 PCI boards")
3554MODULE_GENERIC_TABLE(gtype,name)
3555MODULE_DEVICE_TABLE(type,name)
3556*/
3557 956
3558void pm3fb_build_options(void) 957/* For PCI drivers */
3559{ 958static struct pci_driver pm3fb_driver = {
3560 int i; 959 .name = "pm3fb",
3561 char ts[128]; 960 .id_table = pm3fb_id_table,
961 .probe = pm3fb_probe,
962 .remove = __devexit_p(pm3fb_remove),
963};
3562 964
3563 strcpy(g_options, "pm3fb"); 965MODULE_DEVICE_TABLE(pci, pm3fb_id_table);
3564 for (i = 0; i < PM3_MAX_BOARD ; i++)
3565 {
3566 if (mode[i])
3567 {
3568 sprintf(ts, ",mode:%d:%s", i, mode[i]);
3569 strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
3570 }
3571 if (disable[i] || off[i])
3572 {
3573 sprintf(ts, ",disable:%d:", i);
3574 strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
3575 }
3576 if (pciid[i])
3577 {
3578 sprintf(ts, ",pciid:%d:%s", i, pciid[i]);
3579 strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
3580 }
3581 if (noaccel[i])
3582 {
3583 sprintf(ts, ",noaccel:%d:", i);
3584 strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
3585 }
3586 if (font[i])
3587 {
3588 sprintf(ts, ",font:%d:%s", i, font[i]);
3589 strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
3590 }
3591 if (depth[i])
3592 {
3593 sprintf(ts, ",depth:%d:%d", i, depth[i]);
3594 strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
3595 }
3596 }
3597 g_options[PM3_OPTIONS_SIZE - 1] = '\0';
3598 DPRINTK(1, "pm3fb use options: %s\n", g_options);
3599}
3600 966
3601int init_module(void) 967int __init pm3fb_init(void)
3602{ 968{
3603 DTRACE; 969 /*
970 * For kernel boot options (in 'video=pm3fb:<options>' format)
971 */
972#ifndef MODULE
973 char *option = NULL;
3604 974
3605 pm3fb_build_options(); 975 if (fb_get_options("pm3fb", &option))
976 return -ENODEV;
977 pm3fb_setup(option);
978#endif
3606 979
3607 pm3fb_init(); 980 return pci_register_driver(&pm3fb_driver);
981}
3608 982
3609 return 0; 983static void __exit pm3fb_exit(void)
984{
985 pci_unregister_driver(&pm3fb_driver);
3610} 986}
3611 987
3612void cleanup_module(void) 988#ifndef MODULE
989 /*
990 * Setup
991 */
992
993/*
994 * Only necessary if your driver takes special options,
995 * otherwise we fall back on the generic fb_setup().
996 */
997int __init pm3fb_setup(char *options)
3613{ 998{
3614 DTRACE; 999 /* Parse user speficied options (`video=pm3fb:') */
3615 { 1000 return 0;
3616 unsigned long i;
3617 struct pm3fb_info *l_fb_info;
3618 for (i = 0; i < PM3_MAX_BOARD; i++) {
3619 l_fb_info = &(fb_info[i]);
3620 pci_dev_put(l_fb_info->dev);
3621 if (l_fb_info->dev != NULL && !(disable[l_fb_info->board_num])) {
3622 if (l_fb_info->vIOBase != (unsigned char *) -1) {
3623 pm3fb_unmapIO(l_fb_info);
3624 release_mem_region(l_fb_info->p_fb,
3625 l_fb_info->fb_size);
3626 release_mem_region(l_fb_info->pIOBase,
3627 PM3_REGS_SIZE);
3628 }
3629 unregister_framebuffer(&l_fb_info->gen.info);
3630 }
3631 }
3632 }
3633} 1001}
3634#endif /* MODULE */ 1002#endif /* MODULE */
1003
1004module_init(pm3fb_init);
1005module_exit(pm3fb_exit);
1006
1007MODULE_LICENSE("GPL");
diff --git a/drivers/video/riva/rivafb-i2c.c b/drivers/video/riva/rivafb-i2c.c
index 76e6ce353c8e..a0e22ac483a3 100644
--- a/drivers/video/riva/rivafb-i2c.c
+++ b/drivers/video/riva/rivafb-i2c.c
@@ -70,8 +70,6 @@ static int riva_gpio_getscl(void* data)
70 if (VGA_RD08(par->riva.PCIO, 0x3d5) & 0x04) 70 if (VGA_RD08(par->riva.PCIO, 0x3d5) & 0x04)
71 val = 1; 71 val = 1;
72 72
73 val = VGA_RD08(par->riva.PCIO, 0x3d5);
74
75 return val; 73 return val;
76} 74}
77 75
diff --git a/fs/Makefile b/fs/Makefile
index 9edf4112bee0..720c29d57a62 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -22,6 +22,10 @@ endif
22obj-$(CONFIG_INOTIFY) += inotify.o 22obj-$(CONFIG_INOTIFY) += inotify.o
23obj-$(CONFIG_INOTIFY_USER) += inotify_user.o 23obj-$(CONFIG_INOTIFY_USER) += inotify_user.o
24obj-$(CONFIG_EPOLL) += eventpoll.o 24obj-$(CONFIG_EPOLL) += eventpoll.o
25obj-$(CONFIG_ANON_INODES) += anon_inodes.o
26obj-$(CONFIG_SIGNALFD) += signalfd.o
27obj-$(CONFIG_TIMERFD) += timerfd.o
28obj-$(CONFIG_EVENTFD) += eventfd.o
25obj-$(CONFIG_COMPAT) += compat.o compat_ioctl.o 29obj-$(CONFIG_COMPAT) += compat.o compat_ioctl.o
26 30
27nfsd-$(CONFIG_NFSD) := nfsctl.o 31nfsd-$(CONFIG_NFSD) := nfsctl.o
diff --git a/fs/afs/afs.h b/fs/afs/afs.h
index 52d0752265b8..245257948140 100644
--- a/fs/afs/afs.h
+++ b/fs/afs/afs.h
@@ -16,6 +16,9 @@
16 16
17#define AFS_MAXCELLNAME 64 /* maximum length of a cell name */ 17#define AFS_MAXCELLNAME 64 /* maximum length of a cell name */
18#define AFS_MAXVOLNAME 64 /* maximum length of a volume name */ 18#define AFS_MAXVOLNAME 64 /* maximum length of a volume name */
19#define AFSNAMEMAX 256 /* maximum length of a filename plus NUL */
20#define AFSPATHMAX 1024 /* maximum length of a pathname plus NUL */
21#define AFSOPAQUEMAX 1024 /* maximum length of an opaque field */
19 22
20typedef unsigned afs_volid_t; 23typedef unsigned afs_volid_t;
21typedef unsigned afs_vnodeid_t; 24typedef unsigned afs_vnodeid_t;
@@ -143,4 +146,24 @@ struct afs_volsync {
143 time_t creation; /* volume creation time */ 146 time_t creation; /* volume creation time */
144}; 147};
145 148
149/*
150 * AFS volume status record
151 */
152struct afs_volume_status {
153 u32 vid; /* volume ID */
154 u32 parent_id; /* parent volume ID */
155 u8 online; /* true if volume currently online and available */
156 u8 in_service; /* true if volume currently in service */
157 u8 blessed; /* same as in_service */
158 u8 needs_salvage; /* true if consistency checking required */
159 u32 type; /* volume type (afs_voltype_t) */
160 u32 min_quota; /* minimum space set aside (blocks) */
161 u32 max_quota; /* maximum space this volume may occupy (blocks) */
162 u32 blocks_in_use; /* space this volume currently occupies (blocks) */
163 u32 part_blocks_avail; /* space available in volume's partition */
164 u32 part_max_blocks; /* size of volume's partition */
165};
166
167#define AFS_BLOCK_SIZE 1024
168
146#endif /* AFS_H */ 169#endif /* AFS_H */
diff --git a/fs/afs/afs_fs.h b/fs/afs/afs_fs.h
index d963ef4daee8..a18c374ebe08 100644
--- a/fs/afs/afs_fs.h
+++ b/fs/afs/afs_fs.h
@@ -28,7 +28,8 @@ enum AFS_FS_Operations {
28 FSMAKEDIR = 141, /* AFS Create a directory */ 28 FSMAKEDIR = 141, /* AFS Create a directory */
29 FSREMOVEDIR = 142, /* AFS Remove a directory */ 29 FSREMOVEDIR = 142, /* AFS Remove a directory */
30 FSGIVEUPCALLBACKS = 147, /* AFS Discard callback promises */ 30 FSGIVEUPCALLBACKS = 147, /* AFS Discard callback promises */
31 FSGETVOLUMEINFO = 148, /* AFS Get root volume information */ 31 FSGETVOLUMEINFO = 148, /* AFS Get information about a volume */
32 FSGETVOLUMESTATUS = 149, /* AFS Get volume status information */
32 FSGETROOTVOLUME = 151, /* AFS Get root volume name */ 33 FSGETROOTVOLUME = 151, /* AFS Get root volume name */
33 FSLOOKUP = 161, /* AFS lookup file in directory */ 34 FSLOOKUP = 161, /* AFS lookup file in directory */
34 FSFETCHDATA64 = 65537, /* AFS Fetch file data */ 35 FSFETCHDATA64 = 65537, /* AFS Fetch file data */
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 2fb31276196b..719af4fb15dc 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -497,7 +497,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
497 497
498 ASSERTCMP(dentry->d_inode, ==, NULL); 498 ASSERTCMP(dentry->d_inode, ==, NULL);
499 499
500 if (dentry->d_name.len > 255) { 500 if (dentry->d_name.len >= AFSNAMEMAX) {
501 _leave(" = -ENAMETOOLONG"); 501 _leave(" = -ENAMETOOLONG");
502 return ERR_PTR(-ENAMETOOLONG); 502 return ERR_PTR(-ENAMETOOLONG);
503 } 503 }
@@ -736,7 +736,7 @@ static int afs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
736 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode); 736 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode);
737 737
738 ret = -ENAMETOOLONG; 738 ret = -ENAMETOOLONG;
739 if (dentry->d_name.len > 255) 739 if (dentry->d_name.len >= AFSNAMEMAX)
740 goto error; 740 goto error;
741 741
742 key = afs_request_key(dvnode->volume->cell); 742 key = afs_request_key(dvnode->volume->cell);
@@ -801,7 +801,7 @@ static int afs_rmdir(struct inode *dir, struct dentry *dentry)
801 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name); 801 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name);
802 802
803 ret = -ENAMETOOLONG; 803 ret = -ENAMETOOLONG;
804 if (dentry->d_name.len > 255) 804 if (dentry->d_name.len >= AFSNAMEMAX)
805 goto error; 805 goto error;
806 806
807 key = afs_request_key(dvnode->volume->cell); 807 key = afs_request_key(dvnode->volume->cell);
@@ -847,7 +847,7 @@ static int afs_unlink(struct inode *dir, struct dentry *dentry)
847 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name); 847 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name);
848 848
849 ret = -ENAMETOOLONG; 849 ret = -ENAMETOOLONG;
850 if (dentry->d_name.len > 255) 850 if (dentry->d_name.len >= AFSNAMEMAX)
851 goto error; 851 goto error;
852 852
853 key = afs_request_key(dvnode->volume->cell); 853 key = afs_request_key(dvnode->volume->cell);
@@ -921,7 +921,7 @@ static int afs_create(struct inode *dir, struct dentry *dentry, int mode,
921 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode); 921 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode);
922 922
923 ret = -ENAMETOOLONG; 923 ret = -ENAMETOOLONG;
924 if (dentry->d_name.len > 255) 924 if (dentry->d_name.len >= AFSNAMEMAX)
925 goto error; 925 goto error;
926 926
927 key = afs_request_key(dvnode->volume->cell); 927 key = afs_request_key(dvnode->volume->cell);
@@ -990,7 +990,7 @@ static int afs_link(struct dentry *from, struct inode *dir,
990 dentry->d_name.name); 990 dentry->d_name.name);
991 991
992 ret = -ENAMETOOLONG; 992 ret = -ENAMETOOLONG;
993 if (dentry->d_name.len > 255) 993 if (dentry->d_name.len >= AFSNAMEMAX)
994 goto error; 994 goto error;
995 995
996 key = afs_request_key(dvnode->volume->cell); 996 key = afs_request_key(dvnode->volume->cell);
@@ -1038,11 +1038,11 @@ static int afs_symlink(struct inode *dir, struct dentry *dentry,
1038 content); 1038 content);
1039 1039
1040 ret = -ENAMETOOLONG; 1040 ret = -ENAMETOOLONG;
1041 if (dentry->d_name.len > 255) 1041 if (dentry->d_name.len >= AFSNAMEMAX)
1042 goto error; 1042 goto error;
1043 1043
1044 ret = -EINVAL; 1044 ret = -EINVAL;
1045 if (strlen(content) > 1023) 1045 if (strlen(content) >= AFSPATHMAX)
1046 goto error; 1046 goto error;
1047 1047
1048 key = afs_request_key(dvnode->volume->cell); 1048 key = afs_request_key(dvnode->volume->cell);
@@ -1112,7 +1112,7 @@ static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
1112 new_dentry->d_name.name); 1112 new_dentry->d_name.name);
1113 1113
1114 ret = -ENAMETOOLONG; 1114 ret = -ENAMETOOLONG;
1115 if (new_dentry->d_name.len > 255) 1115 if (new_dentry->d_name.len >= AFSNAMEMAX)
1116 goto error; 1116 goto error;
1117 1117
1118 key = afs_request_key(orig_dvnode->volume->cell); 1118 key = afs_request_key(orig_dvnode->volume->cell);
diff --git a/fs/afs/file.c b/fs/afs/file.c
index 3e25795e5a42..9c0e721d9fc2 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -236,7 +236,7 @@ static void afs_invalidatepage(struct page *page, unsigned long offset)
236{ 236{
237 int ret = 1; 237 int ret = 1;
238 238
239 kenter("{%lu},%lu", page->index, offset); 239 _enter("{%lu},%lu", page->index, offset);
240 240
241 BUG_ON(!PageLocked(page)); 241 BUG_ON(!PageLocked(page));
242 242
diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c
index 56cc0efa2a0c..5dff1308b6f0 100644
--- a/fs/afs/fsclient.c
+++ b/fs/afs/fsclient.c
@@ -202,6 +202,29 @@ static void xdr_encode_AFS_StoreStatus(__be32 **_bp, struct iattr *attr)
202} 202}
203 203
204/* 204/*
205 * decode an AFSFetchVolumeStatus block
206 */
207static void xdr_decode_AFSFetchVolumeStatus(const __be32 **_bp,
208 struct afs_volume_status *vs)
209{
210 const __be32 *bp = *_bp;
211
212 vs->vid = ntohl(*bp++);
213 vs->parent_id = ntohl(*bp++);
214 vs->online = ntohl(*bp++);
215 vs->in_service = ntohl(*bp++);
216 vs->blessed = ntohl(*bp++);
217 vs->needs_salvage = ntohl(*bp++);
218 vs->type = ntohl(*bp++);
219 vs->min_quota = ntohl(*bp++);
220 vs->max_quota = ntohl(*bp++);
221 vs->blocks_in_use = ntohl(*bp++);
222 vs->part_blocks_avail = ntohl(*bp++);
223 vs->part_max_blocks = ntohl(*bp++);
224 *_bp = bp;
225}
226
227/*
205 * deliver reply data to an FS.FetchStatus 228 * deliver reply data to an FS.FetchStatus
206 */ 229 */
207static int afs_deliver_fs_fetch_status(struct afs_call *call, 230static int afs_deliver_fs_fetch_status(struct afs_call *call,
@@ -1450,3 +1473,278 @@ int afs_fs_setattr(struct afs_server *server, struct key *key,
1450 1473
1451 return afs_make_call(&server->addr, call, GFP_NOFS, wait_mode); 1474 return afs_make_call(&server->addr, call, GFP_NOFS, wait_mode);
1452} 1475}
1476
1477/*
1478 * deliver reply data to an FS.GetVolumeStatus
1479 */
1480static int afs_deliver_fs_get_volume_status(struct afs_call *call,
1481 struct sk_buff *skb, bool last)
1482{
1483 const __be32 *bp;
1484 char *p;
1485 int ret;
1486
1487 _enter("{%u},{%u},%d", call->unmarshall, skb->len, last);
1488
1489 switch (call->unmarshall) {
1490 case 0:
1491 call->offset = 0;
1492 call->unmarshall++;
1493
1494 /* extract the returned status record */
1495 case 1:
1496 _debug("extract status");
1497 ret = afs_extract_data(call, skb, last, call->buffer,
1498 12 * 4);
1499 switch (ret) {
1500 case 0: break;
1501 case -EAGAIN: return 0;
1502 default: return ret;
1503 }
1504
1505 bp = call->buffer;
1506 xdr_decode_AFSFetchVolumeStatus(&bp, call->reply2);
1507 call->offset = 0;
1508 call->unmarshall++;
1509
1510 /* extract the volume name length */
1511 case 2:
1512 ret = afs_extract_data(call, skb, last, &call->tmp, 4);
1513 switch (ret) {
1514 case 0: break;
1515 case -EAGAIN: return 0;
1516 default: return ret;
1517 }
1518
1519 call->count = ntohl(call->tmp);
1520 _debug("volname length: %u", call->count);
1521 if (call->count >= AFSNAMEMAX)
1522 return -EBADMSG;
1523 call->offset = 0;
1524 call->unmarshall++;
1525
1526 /* extract the volume name */
1527 case 3:
1528 _debug("extract volname");
1529 if (call->count > 0) {
1530 ret = afs_extract_data(call, skb, last, call->reply3,
1531 call->count);
1532 switch (ret) {
1533 case 0: break;
1534 case -EAGAIN: return 0;
1535 default: return ret;
1536 }
1537 }
1538
1539 p = call->reply3;
1540 p[call->count] = 0;
1541 _debug("volname '%s'", p);
1542
1543 call->offset = 0;
1544 call->unmarshall++;
1545
1546 /* extract the volume name padding */
1547 if ((call->count & 3) == 0) {
1548 call->unmarshall++;
1549 goto no_volname_padding;
1550 }
1551 call->count = 4 - (call->count & 3);
1552
1553 case 4:
1554 ret = afs_extract_data(call, skb, last, call->buffer,
1555 call->count);
1556 switch (ret) {
1557 case 0: break;
1558 case -EAGAIN: return 0;
1559 default: return ret;
1560 }
1561
1562 call->offset = 0;
1563 call->unmarshall++;
1564 no_volname_padding:
1565
1566 /* extract the offline message length */
1567 case 5:
1568 ret = afs_extract_data(call, skb, last, &call->tmp, 4);
1569 switch (ret) {
1570 case 0: break;
1571 case -EAGAIN: return 0;
1572 default: return ret;
1573 }
1574
1575 call->count = ntohl(call->tmp);
1576 _debug("offline msg length: %u", call->count);
1577 if (call->count >= AFSNAMEMAX)
1578 return -EBADMSG;
1579 call->offset = 0;
1580 call->unmarshall++;
1581
1582 /* extract the offline message */
1583 case 6:
1584 _debug("extract offline");
1585 if (call->count > 0) {
1586 ret = afs_extract_data(call, skb, last, call->reply3,
1587 call->count);
1588 switch (ret) {
1589 case 0: break;
1590 case -EAGAIN: return 0;
1591 default: return ret;
1592 }
1593 }
1594
1595 p = call->reply3;
1596 p[call->count] = 0;
1597 _debug("offline '%s'", p);
1598
1599 call->offset = 0;
1600 call->unmarshall++;
1601
1602 /* extract the offline message padding */
1603 if ((call->count & 3) == 0) {
1604 call->unmarshall++;
1605 goto no_offline_padding;
1606 }
1607 call->count = 4 - (call->count & 3);
1608
1609 case 7:
1610 ret = afs_extract_data(call, skb, last, call->buffer,
1611 call->count);
1612 switch (ret) {
1613 case 0: break;
1614 case -EAGAIN: return 0;
1615 default: return ret;
1616 }
1617
1618 call->offset = 0;
1619 call->unmarshall++;
1620 no_offline_padding:
1621
1622 /* extract the message of the day length */
1623 case 8:
1624 ret = afs_extract_data(call, skb, last, &call->tmp, 4);
1625 switch (ret) {
1626 case 0: break;
1627 case -EAGAIN: return 0;
1628 default: return ret;
1629 }
1630
1631 call->count = ntohl(call->tmp);
1632 _debug("motd length: %u", call->count);
1633 if (call->count >= AFSNAMEMAX)
1634 return -EBADMSG;
1635 call->offset = 0;
1636 call->unmarshall++;
1637
1638 /* extract the message of the day */
1639 case 9:
1640 _debug("extract motd");
1641 if (call->count > 0) {
1642 ret = afs_extract_data(call, skb, last, call->reply3,
1643 call->count);
1644 switch (ret) {
1645 case 0: break;
1646 case -EAGAIN: return 0;
1647 default: return ret;
1648 }
1649 }
1650
1651 p = call->reply3;
1652 p[call->count] = 0;
1653 _debug("motd '%s'", p);
1654
1655 call->offset = 0;
1656 call->unmarshall++;
1657
1658 /* extract the message of the day padding */
1659 if ((call->count & 3) == 0) {
1660 call->unmarshall++;
1661 goto no_motd_padding;
1662 }
1663 call->count = 4 - (call->count & 3);
1664
1665 case 10:
1666 ret = afs_extract_data(call, skb, last, call->buffer,
1667 call->count);
1668 switch (ret) {
1669 case 0: break;
1670 case -EAGAIN: return 0;
1671 default: return ret;
1672 }
1673
1674 call->offset = 0;
1675 call->unmarshall++;
1676 no_motd_padding:
1677
1678 case 11:
1679 _debug("trailer %d", skb->len);
1680 if (skb->len != 0)
1681 return -EBADMSG;
1682 break;
1683 }
1684
1685 if (!last)
1686 return 0;
1687
1688 _leave(" = 0 [done]");
1689 return 0;
1690}
1691
1692/*
1693 * destroy an FS.GetVolumeStatus call
1694 */
1695static void afs_get_volume_status_call_destructor(struct afs_call *call)
1696{
1697 kfree(call->reply3);
1698 call->reply3 = NULL;
1699 afs_flat_call_destructor(call);
1700}
1701
1702/*
1703 * FS.GetVolumeStatus operation type
1704 */
1705static const struct afs_call_type afs_RXFSGetVolumeStatus = {
1706 .name = "FS.GetVolumeStatus",
1707 .deliver = afs_deliver_fs_get_volume_status,
1708 .abort_to_error = afs_abort_to_error,
1709 .destructor = afs_get_volume_status_call_destructor,
1710};
1711
1712/*
1713 * fetch the status of a volume
1714 */
1715int afs_fs_get_volume_status(struct afs_server *server,
1716 struct key *key,
1717 struct afs_vnode *vnode,
1718 struct afs_volume_status *vs,
1719 const struct afs_wait_mode *wait_mode)
1720{
1721 struct afs_call *call;
1722 __be32 *bp;
1723 void *tmpbuf;
1724
1725 _enter("");
1726
1727 tmpbuf = kmalloc(AFSOPAQUEMAX, GFP_KERNEL);
1728 if (!tmpbuf)
1729 return -ENOMEM;
1730
1731 call = afs_alloc_flat_call(&afs_RXFSGetVolumeStatus, 2 * 4, 12 * 4);
1732 if (!call) {
1733 kfree(tmpbuf);
1734 return -ENOMEM;
1735 }
1736
1737 call->key = key;
1738 call->reply = vnode;
1739 call->reply2 = vs;
1740 call->reply3 = tmpbuf;
1741 call->service_id = FS_SERVICE;
1742 call->port = htons(AFS_FS_PORT);
1743
1744 /* marshall the parameters */
1745 bp = call->request;
1746 bp[0] = htonl(FSGETVOLUMESTATUS);
1747 bp[1] = htonl(vnode->fid.vid);
1748
1749 return afs_make_call(&server->addr, call, GFP_NOFS, wait_mode);
1750}
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 515a5d12d8fb..47f5fed7195d 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -209,11 +209,15 @@ bad_inode:
209 */ 209 */
210void afs_zap_data(struct afs_vnode *vnode) 210void afs_zap_data(struct afs_vnode *vnode)
211{ 211{
212 _enter("zap data {%x:%u}", vnode->fid.vid, vnode->fid.vnode); 212 _enter("{%x:%u}", vnode->fid.vid, vnode->fid.vnode);
213 213
214 /* nuke all the non-dirty pages that aren't locked, mapped or being 214 /* nuke all the non-dirty pages that aren't locked, mapped or being
215 * written back */ 215 * written back in a regular file and completely discard the pages in a
216 invalidate_remote_inode(&vnode->vfs_inode); 216 * directory or symlink */
217 if (S_ISREG(vnode->vfs_inode.i_mode))
218 invalidate_remote_inode(&vnode->vfs_inode);
219 else
220 invalidate_inode_pages2(vnode->vfs_inode.i_mapping);
217} 221}
218 222
219/* 223/*
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index a30d4fa768e3..4953ba5a6f44 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -506,6 +506,10 @@ extern int afs_fs_store_data(struct afs_server *, struct afs_writeback *,
506extern int afs_fs_setattr(struct afs_server *, struct key *, 506extern int afs_fs_setattr(struct afs_server *, struct key *,
507 struct afs_vnode *, struct iattr *, 507 struct afs_vnode *, struct iattr *,
508 const struct afs_wait_mode *); 508 const struct afs_wait_mode *);
509extern int afs_fs_get_volume_status(struct afs_server *, struct key *,
510 struct afs_vnode *,
511 struct afs_volume_status *,
512 const struct afs_wait_mode *);
509 513
510/* 514/*
511 * inode.c 515 * inode.c
@@ -672,6 +676,8 @@ extern int afs_vnode_rename(struct afs_vnode *, struct afs_vnode *,
672extern int afs_vnode_store_data(struct afs_writeback *, pgoff_t, pgoff_t, 676extern int afs_vnode_store_data(struct afs_writeback *, pgoff_t, pgoff_t,
673 unsigned, unsigned); 677 unsigned, unsigned);
674extern int afs_vnode_setattr(struct afs_vnode *, struct key *, struct iattr *); 678extern int afs_vnode_setattr(struct afs_vnode *, struct key *, struct iattr *);
679extern int afs_vnode_get_volume_status(struct afs_vnode *, struct key *,
680 struct afs_volume_status *);
675 681
676/* 682/*
677 * volume.c 683 * volume.c
diff --git a/fs/afs/super.c b/fs/afs/super.c
index d24be334b608..579af632c8e8 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -21,22 +21,20 @@
21#include <linux/fs.h> 21#include <linux/fs.h>
22#include <linux/pagemap.h> 22#include <linux/pagemap.h>
23#include <linux/parser.h> 23#include <linux/parser.h>
24#include <linux/statfs.h>
24#include "internal.h" 25#include "internal.h"
25 26
26#define AFS_FS_MAGIC 0x6B414653 /* 'kAFS' */ 27#define AFS_FS_MAGIC 0x6B414653 /* 'kAFS' */
27 28
28static void afs_i_init_once(void *foo, struct kmem_cache *cachep, 29static void afs_i_init_once(void *foo, struct kmem_cache *cachep,
29 unsigned long flags); 30 unsigned long flags);
30
31static int afs_get_sb(struct file_system_type *fs_type, 31static int afs_get_sb(struct file_system_type *fs_type,
32 int flags, const char *dev_name, 32 int flags, const char *dev_name,
33 void *data, struct vfsmount *mnt); 33 void *data, struct vfsmount *mnt);
34
35static struct inode *afs_alloc_inode(struct super_block *sb); 34static struct inode *afs_alloc_inode(struct super_block *sb);
36
37static void afs_put_super(struct super_block *sb); 35static void afs_put_super(struct super_block *sb);
38
39static void afs_destroy_inode(struct inode *inode); 36static void afs_destroy_inode(struct inode *inode);
37static int afs_statfs(struct dentry *dentry, struct kstatfs *buf);
40 38
41struct file_system_type afs_fs_type = { 39struct file_system_type afs_fs_type = {
42 .owner = THIS_MODULE, 40 .owner = THIS_MODULE,
@@ -47,7 +45,7 @@ struct file_system_type afs_fs_type = {
47}; 45};
48 46
49static const struct super_operations afs_super_ops = { 47static const struct super_operations afs_super_ops = {
50 .statfs = simple_statfs, 48 .statfs = afs_statfs,
51 .alloc_inode = afs_alloc_inode, 49 .alloc_inode = afs_alloc_inode,
52 .drop_inode = generic_delete_inode, 50 .drop_inode = generic_delete_inode,
53 .write_inode = afs_write_inode, 51 .write_inode = afs_write_inode,
@@ -488,6 +486,7 @@ static struct inode *afs_alloc_inode(struct super_block *sb)
488 vnode->flags = 1 << AFS_VNODE_UNSET; 486 vnode->flags = 1 << AFS_VNODE_UNSET;
489 vnode->cb_promised = false; 487 vnode->cb_promised = false;
490 488
489 _leave(" = %p", &vnode->vfs_inode);
491 return &vnode->vfs_inode; 490 return &vnode->vfs_inode;
492} 491}
493 492
@@ -498,7 +497,7 @@ static void afs_destroy_inode(struct inode *inode)
498{ 497{
499 struct afs_vnode *vnode = AFS_FS_I(inode); 498 struct afs_vnode *vnode = AFS_FS_I(inode);
500 499
501 _enter("{%lu}", inode->i_ino); 500 _enter("%p{%x:%u}", inode, vnode->fid.vid, vnode->fid.vnode);
502 501
503 _debug("DESTROY INODE %p", inode); 502 _debug("DESTROY INODE %p", inode);
504 503
@@ -507,3 +506,36 @@ static void afs_destroy_inode(struct inode *inode)
507 kmem_cache_free(afs_inode_cachep, vnode); 506 kmem_cache_free(afs_inode_cachep, vnode);
508 atomic_dec(&afs_count_active_inodes); 507 atomic_dec(&afs_count_active_inodes);
509} 508}
509
510/*
511 * return information about an AFS volume
512 */
513static int afs_statfs(struct dentry *dentry, struct kstatfs *buf)
514{
515 struct afs_volume_status vs;
516 struct afs_vnode *vnode = AFS_FS_I(dentry->d_inode);
517 struct key *key;
518 int ret;
519
520 key = afs_request_key(vnode->volume->cell);
521 if (IS_ERR(key))
522 return PTR_ERR(key);
523
524 ret = afs_vnode_get_volume_status(vnode, key, &vs);
525 key_put(key);
526 if (ret < 0) {
527 _leave(" = %d", ret);
528 return ret;
529 }
530
531 buf->f_type = dentry->d_sb->s_magic;
532 buf->f_bsize = AFS_BLOCK_SIZE;
533 buf->f_namelen = AFSNAMEMAX - 1;
534
535 if (vs.max_quota == 0)
536 buf->f_blocks = vs.part_max_blocks;
537 else
538 buf->f_blocks = vs.max_quota;
539 buf->f_bavail = buf->f_bfree = buf->f_blocks - vs.blocks_in_use;
540 return 0;
541}
diff --git a/fs/afs/vnode.c b/fs/afs/vnode.c
index ec814660209f..c36c98ce2c3c 100644
--- a/fs/afs/vnode.c
+++ b/fs/afs/vnode.c
@@ -175,24 +175,33 @@ static void afs_vnode_deleted_remotely(struct afs_vnode *vnode)
175{ 175{
176 struct afs_server *server; 176 struct afs_server *server;
177 177
178 _enter("{%p}", vnode->server);
179
178 set_bit(AFS_VNODE_DELETED, &vnode->flags); 180 set_bit(AFS_VNODE_DELETED, &vnode->flags);
179 181
180 server = vnode->server; 182 server = vnode->server;
181 if (vnode->cb_promised) { 183 if (server) {
182 spin_lock(&server->cb_lock);
183 if (vnode->cb_promised) { 184 if (vnode->cb_promised) {
184 rb_erase(&vnode->cb_promise, &server->cb_promises); 185 spin_lock(&server->cb_lock);
185 vnode->cb_promised = false; 186 if (vnode->cb_promised) {
187 rb_erase(&vnode->cb_promise,
188 &server->cb_promises);
189 vnode->cb_promised = false;
190 }
191 spin_unlock(&server->cb_lock);
186 } 192 }
187 spin_unlock(&server->cb_lock);
188 }
189 193
190 spin_lock(&vnode->server->fs_lock); 194 spin_lock(&server->fs_lock);
191 rb_erase(&vnode->server_rb, &vnode->server->fs_vnodes); 195 rb_erase(&vnode->server_rb, &server->fs_vnodes);
192 spin_unlock(&vnode->server->fs_lock); 196 spin_unlock(&server->fs_lock);
193 197
194 vnode->server = NULL; 198 vnode->server = NULL;
195 afs_put_server(server); 199 afs_put_server(server);
200 } else {
201 ASSERT(!vnode->cb_promised);
202 }
203
204 _leave("");
196} 205}
197 206
198/* 207/*
@@ -225,7 +234,7 @@ void afs_vnode_finalise_status_update(struct afs_vnode *vnode,
225 */ 234 */
226static void afs_vnode_status_update_failed(struct afs_vnode *vnode, int ret) 235static void afs_vnode_status_update_failed(struct afs_vnode *vnode, int ret)
227{ 236{
228 _enter("%p,%d", vnode, ret); 237 _enter("{%x:%u},%d", vnode->fid.vid, vnode->fid.vnode, ret);
229 238
230 spin_lock(&vnode->lock); 239 spin_lock(&vnode->lock);
231 240
@@ -860,3 +869,55 @@ no_server:
860 spin_unlock(&vnode->lock); 869 spin_unlock(&vnode->lock);
861 return PTR_ERR(server); 870 return PTR_ERR(server);
862} 871}
872
873/*
874 * get the status of a volume
875 */
876int afs_vnode_get_volume_status(struct afs_vnode *vnode, struct key *key,
877 struct afs_volume_status *vs)
878{
879 struct afs_server *server;
880 int ret;
881
882 _enter("%s{%x:%u.%u},%x,",
883 vnode->volume->vlocation->vldb.name,
884 vnode->fid.vid,
885 vnode->fid.vnode,
886 vnode->fid.unique,
887 key_serial(key));
888
889 /* this op will fetch the status */
890 spin_lock(&vnode->lock);
891 vnode->update_cnt++;
892 spin_unlock(&vnode->lock);
893
894 do {
895 /* pick a server to query */
896 server = afs_volume_pick_fileserver(vnode);
897 if (IS_ERR(server))
898 goto no_server;
899
900 _debug("USING SERVER: %08x\n", ntohl(server->addr.s_addr));
901
902 ret = afs_fs_get_volume_status(server, key, vnode, vs, &afs_sync_call);
903
904 } while (!afs_volume_release_fileserver(vnode, server, ret));
905
906 /* adjust the flags */
907 if (ret == 0) {
908 afs_vnode_finalise_status_update(vnode, server);
909 afs_put_server(server);
910 } else {
911 afs_vnode_status_update_failed(vnode, ret);
912 }
913
914 _leave(" = %d", ret);
915 return ret;
916
917no_server:
918 spin_lock(&vnode->lock);
919 vnode->update_cnt--;
920 ASSERTCMP(vnode->update_cnt, >=, 0);
921 spin_unlock(&vnode->lock);
922 return PTR_ERR(server);
923}
diff --git a/fs/afs/write.c b/fs/afs/write.c
index 67ae4dbf66b3..28f37516c126 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -395,8 +395,9 @@ static int afs_write_back_from_locked_page(struct afs_writeback *wb,
395 if (n == 0) 395 if (n == 0)
396 goto no_more; 396 goto no_more;
397 if (pages[0]->index != start) { 397 if (pages[0]->index != start) {
398 for (n--; n >= 0; n--) 398 do {
399 put_page(pages[n]); 399 put_page(pages[--n]);
400 } while (n > 0);
400 goto no_more; 401 goto no_more;
401 } 402 }
402 403
diff --git a/fs/aio.c b/fs/aio.c
index ac1c1587aa02..dbe699e9828c 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -30,6 +30,7 @@
30#include <linux/highmem.h> 30#include <linux/highmem.h>
31#include <linux/workqueue.h> 31#include <linux/workqueue.h>
32#include <linux/security.h> 32#include <linux/security.h>
33#include <linux/eventfd.h>
33 34
34#include <asm/kmap_types.h> 35#include <asm/kmap_types.h>
35#include <asm/uaccess.h> 36#include <asm/uaccess.h>
@@ -417,6 +418,7 @@ static struct kiocb fastcall *__aio_get_req(struct kioctx *ctx)
417 req->private = NULL; 418 req->private = NULL;
418 req->ki_iovec = NULL; 419 req->ki_iovec = NULL;
419 INIT_LIST_HEAD(&req->ki_run_list); 420 INIT_LIST_HEAD(&req->ki_run_list);
421 req->ki_eventfd = ERR_PTR(-EINVAL);
420 422
421 /* Check if the completion queue has enough free space to 423 /* Check if the completion queue has enough free space to
422 * accept an event from this io. 424 * accept an event from this io.
@@ -458,6 +460,8 @@ static inline void really_put_req(struct kioctx *ctx, struct kiocb *req)
458{ 460{
459 assert_spin_locked(&ctx->ctx_lock); 461 assert_spin_locked(&ctx->ctx_lock);
460 462
463 if (!IS_ERR(req->ki_eventfd))
464 fput(req->ki_eventfd);
461 if (req->ki_dtor) 465 if (req->ki_dtor)
462 req->ki_dtor(req); 466 req->ki_dtor(req);
463 if (req->ki_iovec != &req->ki_inline_vec) 467 if (req->ki_iovec != &req->ki_inline_vec)
@@ -942,6 +946,14 @@ int fastcall aio_complete(struct kiocb *iocb, long res, long res2)
942 return 1; 946 return 1;
943 } 947 }
944 948
949 /*
950 * Check if the user asked us to deliver the result through an
951 * eventfd. The eventfd_signal() function is safe to be called
952 * from IRQ context.
953 */
954 if (!IS_ERR(iocb->ki_eventfd))
955 eventfd_signal(iocb->ki_eventfd, 1);
956
945 info = &ctx->ring_info; 957 info = &ctx->ring_info;
946 958
947 /* add a completion event to the ring buffer. 959 /* add a completion event to the ring buffer.
@@ -1526,8 +1538,7 @@ int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
1526 ssize_t ret; 1538 ssize_t ret;
1527 1539
1528 /* enforce forwards compatibility on users */ 1540 /* enforce forwards compatibility on users */
1529 if (unlikely(iocb->aio_reserved1 || iocb->aio_reserved2 || 1541 if (unlikely(iocb->aio_reserved1 || iocb->aio_reserved2)) {
1530 iocb->aio_reserved3)) {
1531 pr_debug("EINVAL: io_submit: reserve field set\n"); 1542 pr_debug("EINVAL: io_submit: reserve field set\n");
1532 return -EINVAL; 1543 return -EINVAL;
1533 } 1544 }
@@ -1551,6 +1562,19 @@ int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
1551 fput(file); 1562 fput(file);
1552 return -EAGAIN; 1563 return -EAGAIN;
1553 } 1564 }
1565 if (iocb->aio_flags & IOCB_FLAG_RESFD) {
1566 /*
1567 * If the IOCB_FLAG_RESFD flag of aio_flags is set, get an
1568 * instance of the file* now. The file descriptor must be
1569 * an eventfd() fd, and will be signaled for each completed
1570 * event using the eventfd_signal() function.
1571 */
1572 req->ki_eventfd = eventfd_fget((int) iocb->aio_resfd);
1573 if (unlikely(IS_ERR(req->ki_eventfd))) {
1574 ret = PTR_ERR(req->ki_eventfd);
1575 goto out_put_req;
1576 }
1577 }
1554 1578
1555 req->ki_filp = file; 1579 req->ki_filp = file;
1556 ret = put_user(req->ki_key, &user_iocb->aio_key); 1580 ret = put_user(req->ki_key, &user_iocb->aio_key);
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
new file mode 100644
index 000000000000..40fe3a3222e4
--- /dev/null
+++ b/fs/anon_inodes.c
@@ -0,0 +1,200 @@
1/*
2 * fs/anon_inodes.c
3 *
4 * Copyright (C) 2007 Davide Libenzi <davidel@xmailserver.org>
5 *
6 * Thanks to Arnd Bergmann for code review and suggestions.
7 * More changes for Thomas Gleixner suggestions.
8 *
9 */
10
11#include <linux/file.h>
12#include <linux/poll.h>
13#include <linux/slab.h>
14#include <linux/init.h>
15#include <linux/fs.h>
16#include <linux/mount.h>
17#include <linux/module.h>
18#include <linux/kernel.h>
19#include <linux/magic.h>
20#include <linux/anon_inodes.h>
21
22#include <asm/uaccess.h>
23
24static struct vfsmount *anon_inode_mnt __read_mostly;
25static struct inode *anon_inode_inode;
26static const struct file_operations anon_inode_fops;
27
28static int anon_inodefs_get_sb(struct file_system_type *fs_type, int flags,
29 const char *dev_name, void *data,
30 struct vfsmount *mnt)
31{
32 return get_sb_pseudo(fs_type, "anon_inode:", NULL, ANON_INODE_FS_MAGIC,
33 mnt);
34}
35
36static int anon_inodefs_delete_dentry(struct dentry *dentry)
37{
38 /*
39 * We faked vfs to believe the dentry was hashed when we created it.
40 * Now we restore the flag so that dput() will work correctly.
41 */
42 dentry->d_flags |= DCACHE_UNHASHED;
43 return 1;
44}
45
46static struct file_system_type anon_inode_fs_type = {
47 .name = "anon_inodefs",
48 .get_sb = anon_inodefs_get_sb,
49 .kill_sb = kill_anon_super,
50};
51static struct dentry_operations anon_inodefs_dentry_operations = {
52 .d_delete = anon_inodefs_delete_dentry,
53};
54
55/**
56 * anon_inode_getfd - creates a new file instance by hooking it up to and
57 * anonymous inode, and a dentry that describe the "class"
58 * of the file
59 *
60 * @pfd: [out] pointer to the file descriptor
61 * @dpinode: [out] pointer to the inode
62 * @pfile: [out] pointer to the file struct
63 * @name: [in] name of the "class" of the new file
64 * @fops [in] file operations for the new file
65 * @priv [in] private data for the new file (will be file's private_data)
66 *
67 * Creates a new file by hooking it on a single inode. This is useful for files
68 * that do not need to have a full-fledged inode in order to operate correctly.
69 * All the files created with anon_inode_getfd() will share a single inode, by
70 * hence saving memory and avoiding code duplication for the file/inode/dentry
71 * setup.
72 */
73int anon_inode_getfd(int *pfd, struct inode **pinode, struct file **pfile,
74 const char *name, const struct file_operations *fops,
75 void *priv)
76{
77 struct qstr this;
78 struct dentry *dentry;
79 struct inode *inode;
80 struct file *file;
81 int error, fd;
82
83 if (IS_ERR(anon_inode_inode))
84 return -ENODEV;
85 file = get_empty_filp();
86 if (!file)
87 return -ENFILE;
88
89 inode = igrab(anon_inode_inode);
90 if (IS_ERR(inode)) {
91 error = PTR_ERR(inode);
92 goto err_put_filp;
93 }
94
95 error = get_unused_fd();
96 if (error < 0)
97 goto err_iput;
98 fd = error;
99
100 /*
101 * Link the inode to a directory entry by creating a unique name
102 * using the inode sequence number.
103 */
104 error = -ENOMEM;
105 this.name = name;
106 this.len = strlen(name);
107 this.hash = 0;
108 dentry = d_alloc(anon_inode_mnt->mnt_sb->s_root, &this);
109 if (!dentry)
110 goto err_put_unused_fd;
111 dentry->d_op = &anon_inodefs_dentry_operations;
112 /* Do not publish this dentry inside the global dentry hash table */
113 dentry->d_flags &= ~DCACHE_UNHASHED;
114 d_instantiate(dentry, inode);
115
116 file->f_path.mnt = mntget(anon_inode_mnt);
117 file->f_path.dentry = dentry;
118 file->f_mapping = inode->i_mapping;
119
120 file->f_pos = 0;
121 file->f_flags = O_RDWR;
122 file->f_op = fops;
123 file->f_mode = FMODE_READ | FMODE_WRITE;
124 file->f_version = 0;
125 file->private_data = priv;
126
127 fd_install(fd, file);
128
129 *pfd = fd;
130 *pinode = inode;
131 *pfile = file;
132 return 0;
133
134err_put_unused_fd:
135 put_unused_fd(fd);
136err_iput:
137 iput(inode);
138err_put_filp:
139 put_filp(file);
140 return error;
141}
142
143/*
144 * A single inode exist for all anon_inode files. Contrary to pipes,
145 * anon_inode inodes has no per-instance data associated, so we can avoid
146 * the allocation of multiple of them.
147 */
148static struct inode *anon_inode_mkinode(void)
149{
150 struct inode *inode = new_inode(anon_inode_mnt->mnt_sb);
151
152 if (!inode)
153 return ERR_PTR(-ENOMEM);
154
155 inode->i_fop = &anon_inode_fops;
156
157 /*
158 * Mark the inode dirty from the very beginning,
159 * that way it will never be moved to the dirty
160 * list because mark_inode_dirty() will think
161 * that it already _is_ on the dirty list.
162 */
163 inode->i_state = I_DIRTY;
164 inode->i_mode = S_IRUSR | S_IWUSR;
165 inode->i_uid = current->fsuid;
166 inode->i_gid = current->fsgid;
167 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
168 return inode;
169}
170
171static int __init anon_inode_init(void)
172{
173 int error;
174
175 error = register_filesystem(&anon_inode_fs_type);
176 if (error)
177 goto err_exit;
178 anon_inode_mnt = kern_mount(&anon_inode_fs_type);
179 if (IS_ERR(anon_inode_mnt)) {
180 error = PTR_ERR(anon_inode_mnt);
181 goto err_unregister_filesystem;
182 }
183 anon_inode_inode = anon_inode_mkinode();
184 if (IS_ERR(anon_inode_inode)) {
185 error = PTR_ERR(anon_inode_inode);
186 goto err_mntput;
187 }
188
189 return 0;
190
191err_mntput:
192 mntput(anon_inode_mnt);
193err_unregister_filesystem:
194 unregister_filesystem(&anon_inode_fs_type);
195err_exit:
196 panic(KERN_ERR "anon_inode_init() failed (%d)\n", error);
197}
198
199fs_initcall(anon_inode_init);
200
diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h
index 4ef544434b51..8b4cca3c4705 100644
--- a/fs/autofs/autofs_i.h
+++ b/fs/autofs/autofs_i.h
@@ -101,7 +101,7 @@ struct autofs_symlink {
101struct autofs_sb_info { 101struct autofs_sb_info {
102 u32 magic; 102 u32 magic;
103 struct file *pipe; 103 struct file *pipe;
104 pid_t oz_pgrp; 104 struct pid *oz_pgrp;
105 int catatonic; 105 int catatonic;
106 struct super_block *sb; 106 struct super_block *sb;
107 unsigned long exp_timeout; 107 unsigned long exp_timeout;
@@ -122,7 +122,7 @@ static inline struct autofs_sb_info *autofs_sbi(struct super_block *sb)
122 filesystem without "magic".) */ 122 filesystem without "magic".) */
123 123
124static inline int autofs_oz_mode(struct autofs_sb_info *sbi) { 124static inline int autofs_oz_mode(struct autofs_sb_info *sbi) {
125 return sbi->catatonic || process_group(current) == sbi->oz_pgrp; 125 return sbi->catatonic || task_pgrp(current) == sbi->oz_pgrp;
126} 126}
127 127
128/* Hash operations */ 128/* Hash operations */
diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index aa0b61ff8270..e7204d71acc9 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -34,12 +34,14 @@ void autofs_kill_sb(struct super_block *sb)
34 if (!sbi) 34 if (!sbi)
35 goto out_kill_sb; 35 goto out_kill_sb;
36 36
37 if ( !sbi->catatonic ) 37 if (!sbi->catatonic)
38 autofs_catatonic_mode(sbi); /* Free wait queues, close pipe */ 38 autofs_catatonic_mode(sbi); /* Free wait queues, close pipe */
39 39
40 put_pid(sbi->oz_pgrp);
41
40 autofs_hash_nuke(sbi); 42 autofs_hash_nuke(sbi);
41 for ( n = 0 ; n < AUTOFS_MAX_SYMLINKS ; n++ ) { 43 for (n = 0; n < AUTOFS_MAX_SYMLINKS; n++) {
42 if ( test_bit(n, sbi->symlink_bitmap) ) 44 if (test_bit(n, sbi->symlink_bitmap))
43 kfree(sbi->symlink[n].data); 45 kfree(sbi->symlink[n].data);
44 } 46 }
45 47
@@ -69,7 +71,8 @@ static match_table_t autofs_tokens = {
69 {Opt_err, NULL} 71 {Opt_err, NULL}
70}; 72};
71 73
72static int parse_options(char *options, int *pipefd, uid_t *uid, gid_t *gid, pid_t *pgrp, int *minproto, int *maxproto) 74static int parse_options(char *options, int *pipefd, uid_t *uid, gid_t *gid,
75 pid_t *pgrp, int *minproto, int *maxproto)
73{ 76{
74 char *p; 77 char *p;
75 substring_t args[MAX_OPT_ARGS]; 78 substring_t args[MAX_OPT_ARGS];
@@ -138,9 +141,10 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
138 int pipefd; 141 int pipefd;
139 struct autofs_sb_info *sbi; 142 struct autofs_sb_info *sbi;
140 int minproto, maxproto; 143 int minproto, maxproto;
144 pid_t pgid;
141 145
142 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 146 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
143 if ( !sbi ) 147 if (!sbi)
144 goto fail_unlock; 148 goto fail_unlock;
145 DPRINTK(("autofs: starting up, sbi = %p\n",sbi)); 149 DPRINTK(("autofs: starting up, sbi = %p\n",sbi));
146 150
@@ -149,7 +153,6 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
149 sbi->pipe = NULL; 153 sbi->pipe = NULL;
150 sbi->catatonic = 1; 154 sbi->catatonic = 1;
151 sbi->exp_timeout = 0; 155 sbi->exp_timeout = 0;
152 sbi->oz_pgrp = process_group(current);
153 autofs_initialize_hash(&sbi->dirhash); 156 autofs_initialize_hash(&sbi->dirhash);
154 sbi->queues = NULL; 157 sbi->queues = NULL;
155 memset(sbi->symlink_bitmap, 0, sizeof(long)*AUTOFS_SYMLINK_BITMAP_LEN); 158 memset(sbi->symlink_bitmap, 0, sizeof(long)*AUTOFS_SYMLINK_BITMAP_LEN);
@@ -169,26 +172,36 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
169 goto fail_iput; 172 goto fail_iput;
170 173
171 /* Can this call block? - WTF cares? s is locked. */ 174 /* Can this call block? - WTF cares? s is locked. */
172 if ( parse_options(data,&pipefd,&root_inode->i_uid,&root_inode->i_gid,&sbi->oz_pgrp,&minproto,&maxproto) ) { 175 if (parse_options(data, &pipefd, &root_inode->i_uid,
176 &root_inode->i_gid, &pgid, &minproto,
177 &maxproto)) {
173 printk("autofs: called with bogus options\n"); 178 printk("autofs: called with bogus options\n");
174 goto fail_dput; 179 goto fail_dput;
175 } 180 }
176 181
177 /* Couldn't this be tested earlier? */ 182 /* Couldn't this be tested earlier? */
178 if ( minproto > AUTOFS_PROTO_VERSION || 183 if (minproto > AUTOFS_PROTO_VERSION ||
179 maxproto < AUTOFS_PROTO_VERSION ) { 184 maxproto < AUTOFS_PROTO_VERSION) {
180 printk("autofs: kernel does not match daemon version\n"); 185 printk("autofs: kernel does not match daemon version\n");
181 goto fail_dput; 186 goto fail_dput;
182 } 187 }
183 188
184 DPRINTK(("autofs: pipe fd = %d, pgrp = %u\n", pipefd, sbi->oz_pgrp)); 189 DPRINTK(("autofs: pipe fd = %d, pgrp = %u\n", pipefd, pgid));
190 sbi->oz_pgrp = find_get_pid(pgid);
191
192 if (!sbi->oz_pgrp) {
193 printk("autofs: could not find process group %d\n", pgid);
194 goto fail_dput;
195 }
196
185 pipe = fget(pipefd); 197 pipe = fget(pipefd);
186 198
187 if ( !pipe ) { 199 if (!pipe) {
188 printk("autofs: could not open pipe file descriptor\n"); 200 printk("autofs: could not open pipe file descriptor\n");
189 goto fail_dput; 201 goto fail_put_pid;
190 } 202 }
191 if ( !pipe->f_op || !pipe->f_op->write ) 203
204 if (!pipe->f_op || !pipe->f_op->write)
192 goto fail_fput; 205 goto fail_fput;
193 sbi->pipe = pipe; 206 sbi->pipe = pipe;
194 sbi->catatonic = 0; 207 sbi->catatonic = 0;
@@ -202,6 +215,8 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
202fail_fput: 215fail_fput:
203 printk("autofs: pipe file descriptor does not contain proper ops\n"); 216 printk("autofs: pipe file descriptor does not contain proper ops\n");
204 fput(pipe); 217 fput(pipe);
218fail_put_pid:
219 put_pid(sbi->oz_pgrp);
205fail_dput: 220fail_dput:
206 dput(root); 221 dput(root);
207 goto fail_free; 222 goto fail_free;
@@ -230,7 +245,7 @@ static void autofs_read_inode(struct inode *inode)
230 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 245 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
231 inode->i_blocks = 0; 246 inode->i_blocks = 0;
232 247
233 if ( ino == AUTOFS_ROOT_INO ) { 248 if (ino == AUTOFS_ROOT_INO) {
234 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR; 249 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
235 inode->i_op = &autofs_root_inode_operations; 250 inode->i_op = &autofs_root_inode_operations;
236 inode->i_fop = &autofs_root_operations; 251 inode->i_fop = &autofs_root_operations;
@@ -241,12 +256,12 @@ static void autofs_read_inode(struct inode *inode)
241 inode->i_uid = inode->i_sb->s_root->d_inode->i_uid; 256 inode->i_uid = inode->i_sb->s_root->d_inode->i_uid;
242 inode->i_gid = inode->i_sb->s_root->d_inode->i_gid; 257 inode->i_gid = inode->i_sb->s_root->d_inode->i_gid;
243 258
244 if ( ino >= AUTOFS_FIRST_SYMLINK && ino < AUTOFS_FIRST_DIR_INO ) { 259 if (ino >= AUTOFS_FIRST_SYMLINK && ino < AUTOFS_FIRST_DIR_INO) {
245 /* Symlink inode - should be in symlink list */ 260 /* Symlink inode - should be in symlink list */
246 struct autofs_symlink *sl; 261 struct autofs_symlink *sl;
247 262
248 n = ino - AUTOFS_FIRST_SYMLINK; 263 n = ino - AUTOFS_FIRST_SYMLINK;
249 if ( n >= AUTOFS_MAX_SYMLINKS || !test_bit(n,sbi->symlink_bitmap)) { 264 if (n >= AUTOFS_MAX_SYMLINKS || !test_bit(n,sbi->symlink_bitmap)) {
250 printk("autofs: Looking for bad symlink inode %u\n", (unsigned int) ino); 265 printk("autofs: Looking for bad symlink inode %u\n", (unsigned int) ino);
251 return; 266 return;
252 } 267 }
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index f2597205939d..c1489533277a 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -67,8 +67,8 @@ static int autofs_root_readdir(struct file *filp, void *dirent, filldir_t filldi
67 filp->f_pos = ++nr; 67 filp->f_pos = ++nr;
68 /* fall through */ 68 /* fall through */
69 default: 69 default:
70 while ( onr = nr, ent = autofs_hash_enum(dirhash,&nr,ent) ) { 70 while (onr = nr, ent = autofs_hash_enum(dirhash,&nr,ent)) {
71 if ( !ent->dentry || d_mountpoint(ent->dentry) ) { 71 if (!ent->dentry || d_mountpoint(ent->dentry)) {
72 if (filldir(dirent,ent->name,ent->len,onr,ent->ino,DT_UNKNOWN) < 0) 72 if (filldir(dirent,ent->name,ent->len,onr,ent->ino,DT_UNKNOWN) < 0)
73 goto out; 73 goto out;
74 filp->f_pos = nr; 74 filp->f_pos = nr;
@@ -88,10 +88,10 @@ static int try_to_fill_dentry(struct dentry *dentry, struct super_block *sb, str
88 struct autofs_dir_ent *ent; 88 struct autofs_dir_ent *ent;
89 int status = 0; 89 int status = 0;
90 90
91 if ( !(ent = autofs_hash_lookup(&sbi->dirhash, &dentry->d_name)) ) { 91 if (!(ent = autofs_hash_lookup(&sbi->dirhash, &dentry->d_name))) {
92 do { 92 do {
93 if ( status && dentry->d_inode ) { 93 if (status && dentry->d_inode) {
94 if ( status != -ENOENT ) 94 if (status != -ENOENT)
95 printk("autofs warning: lookup failure on positive dentry, status = %d, name = %s\n", status, dentry->d_name.name); 95 printk("autofs warning: lookup failure on positive dentry, status = %d, name = %s\n", status, dentry->d_name.name);
96 return 0; /* Try to get the kernel to invalidate this dentry */ 96 return 0; /* Try to get the kernel to invalidate this dentry */
97 } 97 }
@@ -106,7 +106,7 @@ static int try_to_fill_dentry(struct dentry *dentry, struct super_block *sb, str
106 return 1; 106 return 1;
107 } 107 }
108 status = autofs_wait(sbi, &dentry->d_name); 108 status = autofs_wait(sbi, &dentry->d_name);
109 } while (!(ent = autofs_hash_lookup(&sbi->dirhash, &dentry->d_name)) ); 109 } while (!(ent = autofs_hash_lookup(&sbi->dirhash, &dentry->d_name)));
110 } 110 }
111 111
112 /* Abuse this field as a pointer to the directory entry, used to 112 /* Abuse this field as a pointer to the directory entry, used to
@@ -124,13 +124,13 @@ static int try_to_fill_dentry(struct dentry *dentry, struct super_block *sb, str
124 124
125 /* If this is a directory that isn't a mount point, bitch at the 125 /* If this is a directory that isn't a mount point, bitch at the
126 daemon and fix it in user space */ 126 daemon and fix it in user space */
127 if ( S_ISDIR(dentry->d_inode->i_mode) && !d_mountpoint(dentry) ) { 127 if (S_ISDIR(dentry->d_inode->i_mode) && !d_mountpoint(dentry)) {
128 return !autofs_wait(sbi, &dentry->d_name); 128 return !autofs_wait(sbi, &dentry->d_name);
129 } 129 }
130 130
131 /* We don't update the usages for the autofs daemon itself, this 131 /* We don't update the usages for the autofs daemon itself, this
132 is necessary for recursive autofs mounts */ 132 is necessary for recursive autofs mounts */
133 if ( !autofs_oz_mode(sbi) ) { 133 if (!autofs_oz_mode(sbi)) {
134 autofs_update_usage(&sbi->dirhash,ent); 134 autofs_update_usage(&sbi->dirhash,ent);
135 } 135 }
136 136
@@ -157,7 +157,7 @@ static int autofs_revalidate(struct dentry * dentry, struct nameidata *nd)
157 sbi = autofs_sbi(dir->i_sb); 157 sbi = autofs_sbi(dir->i_sb);
158 158
159 /* Pending dentry */ 159 /* Pending dentry */
160 if ( dentry->d_flags & DCACHE_AUTOFS_PENDING ) { 160 if (dentry->d_flags & DCACHE_AUTOFS_PENDING) {
161 if (autofs_oz_mode(sbi)) 161 if (autofs_oz_mode(sbi))
162 res = 1; 162 res = 1;
163 else 163 else
@@ -173,7 +173,7 @@ static int autofs_revalidate(struct dentry * dentry, struct nameidata *nd)
173 } 173 }
174 174
175 /* Check for a non-mountpoint directory */ 175 /* Check for a non-mountpoint directory */
176 if ( S_ISDIR(dentry->d_inode->i_mode) && !d_mountpoint(dentry) ) { 176 if (S_ISDIR(dentry->d_inode->i_mode) && !d_mountpoint(dentry)) {
177 if (autofs_oz_mode(sbi)) 177 if (autofs_oz_mode(sbi))
178 res = 1; 178 res = 1;
179 else 179 else
@@ -183,9 +183,9 @@ static int autofs_revalidate(struct dentry * dentry, struct nameidata *nd)
183 } 183 }
184 184
185 /* Update the usage list */ 185 /* Update the usage list */
186 if ( !autofs_oz_mode(sbi) ) { 186 if (!autofs_oz_mode(sbi)) {
187 ent = (struct autofs_dir_ent *) dentry->d_time; 187 ent = (struct autofs_dir_ent *) dentry->d_time;
188 if ( ent ) 188 if (ent)
189 autofs_update_usage(&sbi->dirhash,ent); 189 autofs_update_usage(&sbi->dirhash,ent);
190 } 190 }
191 unlock_kernel(); 191 unlock_kernel();
@@ -213,8 +213,10 @@ static struct dentry *autofs_root_lookup(struct inode *dir, struct dentry *dentr
213 sbi = autofs_sbi(dir->i_sb); 213 sbi = autofs_sbi(dir->i_sb);
214 214
215 oz_mode = autofs_oz_mode(sbi); 215 oz_mode = autofs_oz_mode(sbi);
216 DPRINTK(("autofs_lookup: pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d\n", 216 DPRINTK(("autofs_lookup: pid = %u, pgrp = %u, catatonic = %d, "
217 current->pid, process_group(current), sbi->catatonic, oz_mode)); 217 "oz_mode = %d\n", pid_nr(task_pid(current)),
218 process_group(current), sbi->catatonic,
219 oz_mode));
218 220
219 /* 221 /*
220 * Mark the dentry incomplete, but add it. This is needed so 222 * Mark the dentry incomplete, but add it. This is needed so
@@ -258,7 +260,7 @@ static struct dentry *autofs_root_lookup(struct inode *dir, struct dentry *dentr
258 * doesn't do the right thing for all system calls, but it should 260 * doesn't do the right thing for all system calls, but it should
259 * be OK for the operations we permit from an autofs. 261 * be OK for the operations we permit from an autofs.
260 */ 262 */
261 if ( dentry->d_inode && d_unhashed(dentry) ) 263 if (dentry->d_inode && d_unhashed(dentry))
262 return ERR_PTR(-ENOENT); 264 return ERR_PTR(-ENOENT);
263 265
264 return NULL; 266 return NULL;
@@ -277,18 +279,18 @@ static int autofs_root_symlink(struct inode *dir, struct dentry *dentry, const c
277 autofs_say(dentry->d_name.name,dentry->d_name.len); 279 autofs_say(dentry->d_name.name,dentry->d_name.len);
278 280
279 lock_kernel(); 281 lock_kernel();
280 if ( !autofs_oz_mode(sbi) ) { 282 if (!autofs_oz_mode(sbi)) {
281 unlock_kernel(); 283 unlock_kernel();
282 return -EACCES; 284 return -EACCES;
283 } 285 }
284 286
285 if ( autofs_hash_lookup(dh, &dentry->d_name) ) { 287 if (autofs_hash_lookup(dh, &dentry->d_name)) {
286 unlock_kernel(); 288 unlock_kernel();
287 return -EEXIST; 289 return -EEXIST;
288 } 290 }
289 291
290 n = find_first_zero_bit(sbi->symlink_bitmap,AUTOFS_MAX_SYMLINKS); 292 n = find_first_zero_bit(sbi->symlink_bitmap,AUTOFS_MAX_SYMLINKS);
291 if ( n >= AUTOFS_MAX_SYMLINKS ) { 293 if (n >= AUTOFS_MAX_SYMLINKS) {
292 unlock_kernel(); 294 unlock_kernel();
293 return -ENOSPC; 295 return -ENOSPC;
294 } 296 }
@@ -297,14 +299,14 @@ static int autofs_root_symlink(struct inode *dir, struct dentry *dentry, const c
297 sl = &sbi->symlink[n]; 299 sl = &sbi->symlink[n];
298 sl->len = strlen(symname); 300 sl->len = strlen(symname);
299 sl->data = kmalloc(slsize = sl->len+1, GFP_KERNEL); 301 sl->data = kmalloc(slsize = sl->len+1, GFP_KERNEL);
300 if ( !sl->data ) { 302 if (!sl->data) {
301 clear_bit(n,sbi->symlink_bitmap); 303 clear_bit(n,sbi->symlink_bitmap);
302 unlock_kernel(); 304 unlock_kernel();
303 return -ENOSPC; 305 return -ENOSPC;
304 } 306 }
305 307
306 ent = kmalloc(sizeof(struct autofs_dir_ent), GFP_KERNEL); 308 ent = kmalloc(sizeof(struct autofs_dir_ent), GFP_KERNEL);
307 if ( !ent ) { 309 if (!ent) {
308 kfree(sl->data); 310 kfree(sl->data);
309 clear_bit(n,sbi->symlink_bitmap); 311 clear_bit(n,sbi->symlink_bitmap);
310 unlock_kernel(); 312 unlock_kernel();
@@ -312,7 +314,7 @@ static int autofs_root_symlink(struct inode *dir, struct dentry *dentry, const c
312 } 314 }
313 315
314 ent->name = kmalloc(dentry->d_name.len+1, GFP_KERNEL); 316 ent->name = kmalloc(dentry->d_name.len+1, GFP_KERNEL);
315 if ( !ent->name ) { 317 if (!ent->name) {
316 kfree(sl->data); 318 kfree(sl->data);
317 kfree(ent); 319 kfree(ent);
318 clear_bit(n,sbi->symlink_bitmap); 320 clear_bit(n,sbi->symlink_bitmap);
@@ -354,23 +356,23 @@ static int autofs_root_unlink(struct inode *dir, struct dentry *dentry)
354 356
355 /* This allows root to remove symlinks */ 357 /* This allows root to remove symlinks */
356 lock_kernel(); 358 lock_kernel();
357 if ( !autofs_oz_mode(sbi) && !capable(CAP_SYS_ADMIN) ) { 359 if (!autofs_oz_mode(sbi) && !capable(CAP_SYS_ADMIN)) {
358 unlock_kernel(); 360 unlock_kernel();
359 return -EACCES; 361 return -EACCES;
360 } 362 }
361 363
362 ent = autofs_hash_lookup(dh, &dentry->d_name); 364 ent = autofs_hash_lookup(dh, &dentry->d_name);
363 if ( !ent ) { 365 if (!ent) {
364 unlock_kernel(); 366 unlock_kernel();
365 return -ENOENT; 367 return -ENOENT;
366 } 368 }
367 369
368 n = ent->ino - AUTOFS_FIRST_SYMLINK; 370 n = ent->ino - AUTOFS_FIRST_SYMLINK;
369 if ( n >= AUTOFS_MAX_SYMLINKS ) { 371 if (n >= AUTOFS_MAX_SYMLINKS) {
370 unlock_kernel(); 372 unlock_kernel();
371 return -EISDIR; /* It's a directory, dummy */ 373 return -EISDIR; /* It's a directory, dummy */
372 } 374 }
373 if ( !test_bit(n,sbi->symlink_bitmap) ) { 375 if (!test_bit(n,sbi->symlink_bitmap)) {
374 unlock_kernel(); 376 unlock_kernel();
375 return -EINVAL; /* Nonexistent symlink? Shouldn't happen */ 377 return -EINVAL; /* Nonexistent symlink? Shouldn't happen */
376 } 378 }
@@ -392,23 +394,23 @@ static int autofs_root_rmdir(struct inode *dir, struct dentry *dentry)
392 struct autofs_dir_ent *ent; 394 struct autofs_dir_ent *ent;
393 395
394 lock_kernel(); 396 lock_kernel();
395 if ( !autofs_oz_mode(sbi) ) { 397 if (!autofs_oz_mode(sbi)) {
396 unlock_kernel(); 398 unlock_kernel();
397 return -EACCES; 399 return -EACCES;
398 } 400 }
399 401
400 ent = autofs_hash_lookup(dh, &dentry->d_name); 402 ent = autofs_hash_lookup(dh, &dentry->d_name);
401 if ( !ent ) { 403 if (!ent) {
402 unlock_kernel(); 404 unlock_kernel();
403 return -ENOENT; 405 return -ENOENT;
404 } 406 }
405 407
406 if ( (unsigned int)ent->ino < AUTOFS_FIRST_DIR_INO ) { 408 if ((unsigned int)ent->ino < AUTOFS_FIRST_DIR_INO) {
407 unlock_kernel(); 409 unlock_kernel();
408 return -ENOTDIR; /* Not a directory */ 410 return -ENOTDIR; /* Not a directory */
409 } 411 }
410 412
411 if ( ent->dentry != dentry ) { 413 if (ent->dentry != dentry) {
412 printk("autofs_rmdir: odentry != dentry for entry %s\n", dentry->d_name.name); 414 printk("autofs_rmdir: odentry != dentry for entry %s\n", dentry->d_name.name);
413 } 415 }
414 416
@@ -429,18 +431,18 @@ static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
429 ino_t ino; 431 ino_t ino;
430 432
431 lock_kernel(); 433 lock_kernel();
432 if ( !autofs_oz_mode(sbi) ) { 434 if (!autofs_oz_mode(sbi)) {
433 unlock_kernel(); 435 unlock_kernel();
434 return -EACCES; 436 return -EACCES;
435 } 437 }
436 438
437 ent = autofs_hash_lookup(dh, &dentry->d_name); 439 ent = autofs_hash_lookup(dh, &dentry->d_name);
438 if ( ent ) { 440 if (ent) {
439 unlock_kernel(); 441 unlock_kernel();
440 return -EEXIST; 442 return -EEXIST;
441 } 443 }
442 444
443 if ( sbi->next_dir_ino < AUTOFS_FIRST_DIR_INO ) { 445 if (sbi->next_dir_ino < AUTOFS_FIRST_DIR_INO) {
444 printk("autofs: Out of inode numbers -- what the heck did you do??\n"); 446 printk("autofs: Out of inode numbers -- what the heck did you do??\n");
445 unlock_kernel(); 447 unlock_kernel();
446 return -ENOSPC; 448 return -ENOSPC;
@@ -448,13 +450,13 @@ static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
448 ino = sbi->next_dir_ino++; 450 ino = sbi->next_dir_ino++;
449 451
450 ent = kmalloc(sizeof(struct autofs_dir_ent), GFP_KERNEL); 452 ent = kmalloc(sizeof(struct autofs_dir_ent), GFP_KERNEL);
451 if ( !ent ) { 453 if (!ent) {
452 unlock_kernel(); 454 unlock_kernel();
453 return -ENOSPC; 455 return -ENOSPC;
454 } 456 }
455 457
456 ent->name = kmalloc(dentry->d_name.len+1, GFP_KERNEL); 458 ent->name = kmalloc(dentry->d_name.len+1, GFP_KERNEL);
457 if ( !ent->name ) { 459 if (!ent->name) {
458 kfree(ent); 460 kfree(ent);
459 unlock_kernel(); 461 unlock_kernel();
460 return -ENOSPC; 462 return -ENOSPC;
@@ -483,7 +485,7 @@ static inline int autofs_get_set_timeout(struct autofs_sb_info *sbi,
483 put_user(sbi->exp_timeout / HZ, p)) 485 put_user(sbi->exp_timeout / HZ, p))
484 return -EFAULT; 486 return -EFAULT;
485 487
486 if ( ntimeout > ULONG_MAX/HZ ) 488 if (ntimeout > ULONG_MAX/HZ)
487 sbi->exp_timeout = 0; 489 sbi->exp_timeout = 0;
488 else 490 else
489 sbi->exp_timeout = ntimeout * HZ; 491 sbi->exp_timeout = ntimeout * HZ;
@@ -511,15 +513,14 @@ static inline int autofs_expire_run(struct super_block *sb,
511 pkt.hdr.proto_version = AUTOFS_PROTO_VERSION; 513 pkt.hdr.proto_version = AUTOFS_PROTO_VERSION;
512 pkt.hdr.type = autofs_ptype_expire; 514 pkt.hdr.type = autofs_ptype_expire;
513 515
514 if ( !sbi->exp_timeout || 516 if (!sbi->exp_timeout || !(ent = autofs_expire(sb,sbi,mnt)))
515 !(ent = autofs_expire(sb,sbi,mnt)) )
516 return -EAGAIN; 517 return -EAGAIN;
517 518
518 pkt.len = ent->len; 519 pkt.len = ent->len;
519 memcpy(pkt.name, ent->name, pkt.len); 520 memcpy(pkt.name, ent->name, pkt.len);
520 pkt.name[pkt.len] = '\0'; 521 pkt.name[pkt.len] = '\0';
521 522
522 if ( copy_to_user(pkt_p, &pkt, sizeof(struct autofs_packet_expire)) ) 523 if (copy_to_user(pkt_p, &pkt, sizeof(struct autofs_packet_expire)))
523 return -EFAULT; 524 return -EFAULT;
524 525
525 return 0; 526 return 0;
@@ -537,11 +538,11 @@ static int autofs_root_ioctl(struct inode *inode, struct file *filp,
537 538
538 DPRINTK(("autofs_ioctl: cmd = 0x%08x, arg = 0x%08lx, sbi = %p, pgrp = %u\n",cmd,arg,sbi,process_group(current))); 539 DPRINTK(("autofs_ioctl: cmd = 0x%08x, arg = 0x%08lx, sbi = %p, pgrp = %u\n",cmd,arg,sbi,process_group(current)));
539 540
540 if ( _IOC_TYPE(cmd) != _IOC_TYPE(AUTOFS_IOC_FIRST) || 541 if (_IOC_TYPE(cmd) != _IOC_TYPE(AUTOFS_IOC_FIRST) ||
541 _IOC_NR(cmd) - _IOC_NR(AUTOFS_IOC_FIRST) >= AUTOFS_IOC_COUNT ) 542 _IOC_NR(cmd) - _IOC_NR(AUTOFS_IOC_FIRST) >= AUTOFS_IOC_COUNT)
542 return -ENOTTY; 543 return -ENOTTY;
543 544
544 if ( !autofs_oz_mode(sbi) && !capable(CAP_SYS_ADMIN) ) 545 if (!autofs_oz_mode(sbi) && !capable(CAP_SYS_ADMIN))
545 return -EPERM; 546 return -EPERM;
546 547
547 switch(cmd) { 548 switch(cmd) {
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index 5769a2f9ad60..692364e8ffc3 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -218,8 +218,7 @@ static match_table_t tokens = {
218}; 218};
219 219
220static int parse_options(char *options, int *pipefd, uid_t *uid, gid_t *gid, 220static int parse_options(char *options, int *pipefd, uid_t *uid, gid_t *gid,
221 pid_t *pgrp, unsigned int *type, 221 pid_t *pgrp, unsigned int *type, int *minproto, int *maxproto)
222 int *minproto, int *maxproto)
223{ 222{
224 char *p; 223 char *p;
225 substring_t args[MAX_OPT_ARGS]; 224 substring_t args[MAX_OPT_ARGS];
@@ -314,7 +313,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
314 struct autofs_info *ino; 313 struct autofs_info *ino;
315 314
316 sbi = kmalloc(sizeof(*sbi), GFP_KERNEL); 315 sbi = kmalloc(sizeof(*sbi), GFP_KERNEL);
317 if ( !sbi ) 316 if (!sbi)
318 goto fail_unlock; 317 goto fail_unlock;
319 DPRINTK("starting up, sbi = %p",sbi); 318 DPRINTK("starting up, sbi = %p",sbi);
320 319
@@ -363,10 +362,9 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
363 root->d_fsdata = ino; 362 root->d_fsdata = ino;
364 363
365 /* Can this call block? */ 364 /* Can this call block? */
366 if (parse_options(data, &pipefd, 365 if (parse_options(data, &pipefd, &root_inode->i_uid, &root_inode->i_gid,
367 &root_inode->i_uid, &root_inode->i_gid, 366 &sbi->oz_pgrp, &sbi->type, &sbi->min_proto,
368 &sbi->oz_pgrp, &sbi->type, 367 &sbi->max_proto)) {
369 &sbi->min_proto, &sbi->max_proto)) {
370 printk("autofs: called with bogus options\n"); 368 printk("autofs: called with bogus options\n");
371 goto fail_dput; 369 goto fail_dput;
372 } 370 }
@@ -396,11 +394,11 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
396 DPRINTK("pipe fd = %d, pgrp = %u", pipefd, sbi->oz_pgrp); 394 DPRINTK("pipe fd = %d, pgrp = %u", pipefd, sbi->oz_pgrp);
397 pipe = fget(pipefd); 395 pipe = fget(pipefd);
398 396
399 if ( !pipe ) { 397 if (!pipe) {
400 printk("autofs: could not open pipe file descriptor\n"); 398 printk("autofs: could not open pipe file descriptor\n");
401 goto fail_dput; 399 goto fail_dput;
402 } 400 }
403 if ( !pipe->f_op || !pipe->f_op->write ) 401 if (!pipe->f_op || !pipe->f_op->write)
404 goto fail_fput; 402 goto fail_fput;
405 sbi->pipe = pipe; 403 sbi->pipe = pipe;
406 sbi->pipefd = pipefd; 404 sbi->pipefd = pipefd;
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index 15170f4e13a7..2d4c8a3e604e 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -759,7 +759,7 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry)
759 struct autofs_info *p_ino; 759 struct autofs_info *p_ino;
760 760
761 /* This allows root to remove symlinks */ 761 /* This allows root to remove symlinks */
762 if ( !autofs4_oz_mode(sbi) && !capable(CAP_SYS_ADMIN) ) 762 if (!autofs4_oz_mode(sbi) && !capable(CAP_SYS_ADMIN))
763 return -EACCES; 763 return -EACCES;
764 764
765 if (atomic_dec_and_test(&ino->count)) { 765 if (atomic_dec_and_test(&ino->count)) {
@@ -833,7 +833,7 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode)
833 struct autofs_info *p_ino; 833 struct autofs_info *p_ino;
834 struct inode *inode; 834 struct inode *inode;
835 835
836 if ( !autofs4_oz_mode(sbi) ) 836 if (!autofs4_oz_mode(sbi))
837 return -EACCES; 837 return -EACCES;
838 838
839 DPRINTK("dentry %p, creating %.*s", 839 DPRINTK("dentry %p, creating %.*s",
@@ -871,11 +871,11 @@ static inline int autofs4_get_set_timeout(struct autofs_sb_info *sbi,
871 int rv; 871 int rv;
872 unsigned long ntimeout; 872 unsigned long ntimeout;
873 873
874 if ( (rv = get_user(ntimeout, p)) || 874 if ((rv = get_user(ntimeout, p)) ||
875 (rv = put_user(sbi->exp_timeout/HZ, p)) ) 875 (rv = put_user(sbi->exp_timeout/HZ, p)))
876 return rv; 876 return rv;
877 877
878 if ( ntimeout > ULONG_MAX/HZ ) 878 if (ntimeout > ULONG_MAX/HZ)
879 sbi->exp_timeout = 0; 879 sbi->exp_timeout = 0;
880 else 880 else
881 sbi->exp_timeout = ntimeout * HZ; 881 sbi->exp_timeout = ntimeout * HZ;
@@ -906,7 +906,7 @@ static inline int autofs4_ask_reghost(struct autofs_sb_info *sbi, int __user *p)
906 DPRINTK("returning %d", sbi->needs_reghost); 906 DPRINTK("returning %d", sbi->needs_reghost);
907 907
908 status = put_user(sbi->needs_reghost, p); 908 status = put_user(sbi->needs_reghost, p);
909 if ( status ) 909 if (status)
910 return status; 910 return status;
911 911
912 sbi->needs_reghost = 0; 912 sbi->needs_reghost = 0;
@@ -975,11 +975,11 @@ static int autofs4_root_ioctl(struct inode *inode, struct file *filp,
975 DPRINTK("cmd = 0x%08x, arg = 0x%08lx, sbi = %p, pgrp = %u", 975 DPRINTK("cmd = 0x%08x, arg = 0x%08lx, sbi = %p, pgrp = %u",
976 cmd,arg,sbi,process_group(current)); 976 cmd,arg,sbi,process_group(current));
977 977
978 if ( _IOC_TYPE(cmd) != _IOC_TYPE(AUTOFS_IOC_FIRST) || 978 if (_IOC_TYPE(cmd) != _IOC_TYPE(AUTOFS_IOC_FIRST) ||
979 _IOC_NR(cmd) - _IOC_NR(AUTOFS_IOC_FIRST) >= AUTOFS_IOC_COUNT ) 979 _IOC_NR(cmd) - _IOC_NR(AUTOFS_IOC_FIRST) >= AUTOFS_IOC_COUNT)
980 return -ENOTTY; 980 return -ENOTTY;
981 981
982 if ( !autofs4_oz_mode(sbi) && !capable(CAP_SYS_ADMIN) ) 982 if (!autofs4_oz_mode(sbi) && !capable(CAP_SYS_ADMIN))
983 return -EPERM; 983 return -EPERM;
984 984
985 switch(cmd) { 985 switch(cmd) {
diff --git a/fs/compat.c b/fs/compat.c
index 9cf75df9b2bb..7b21b0a82596 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -46,6 +46,7 @@
46#include <linux/tsacct_kern.h> 46#include <linux/tsacct_kern.h>
47#include <linux/security.h> 47#include <linux/security.h>
48#include <linux/highmem.h> 48#include <linux/highmem.h>
49#include <linux/signal.h>
49#include <linux/poll.h> 50#include <linux/poll.h>
50#include <linux/mm.h> 51#include <linux/mm.h>
51#include <linux/eventpoll.h> 52#include <linux/eventpoll.h>
@@ -2199,3 +2200,51 @@ asmlinkage long compat_sys_epoll_pwait(int epfd,
2199#endif /* TIF_RESTORE_SIGMASK */ 2200#endif /* TIF_RESTORE_SIGMASK */
2200 2201
2201#endif /* CONFIG_EPOLL */ 2202#endif /* CONFIG_EPOLL */
2203
2204#ifdef CONFIG_SIGNALFD
2205
2206asmlinkage long compat_sys_signalfd(int ufd,
2207 const compat_sigset_t __user *sigmask,
2208 compat_size_t sigsetsize)
2209{
2210 compat_sigset_t ss32;
2211 sigset_t tmp;
2212 sigset_t __user *ksigmask;
2213
2214 if (sigsetsize != sizeof(compat_sigset_t))
2215 return -EINVAL;
2216 if (copy_from_user(&ss32, sigmask, sizeof(ss32)))
2217 return -EFAULT;
2218 sigset_from_compat(&tmp, &ss32);
2219 ksigmask = compat_alloc_user_space(sizeof(sigset_t));
2220 if (copy_to_user(ksigmask, &tmp, sizeof(sigset_t)))
2221 return -EFAULT;
2222
2223 return sys_signalfd(ufd, ksigmask, sizeof(sigset_t));
2224}
2225
2226#endif /* CONFIG_SIGNALFD */
2227
2228#ifdef CONFIG_TIMERFD
2229
2230asmlinkage long compat_sys_timerfd(int ufd, int clockid, int flags,
2231 const struct compat_itimerspec __user *utmr)
2232{
2233 long res;
2234 struct itimerspec t;
2235 struct itimerspec __user *ut;
2236
2237 res = -EFAULT;
2238 if (get_compat_itimerspec(&t, utmr))
2239 goto err_exit;
2240 ut = compat_alloc_user_space(sizeof(*ut));
2241 if (copy_to_user(ut, &t, sizeof(t)) )
2242 goto err_exit;
2243
2244 res = sys_timerfd(ufd, clockid, flags, ut);
2245err_exit:
2246 return res;
2247}
2248
2249#endif /* CONFIG_TIMERFD */
2250
diff --git a/fs/eventfd.c b/fs/eventfd.c
new file mode 100644
index 000000000000..480e2b3c4166
--- /dev/null
+++ b/fs/eventfd.c
@@ -0,0 +1,228 @@
1/*
2 * fs/eventfd.c
3 *
4 * Copyright (C) 2007 Davide Libenzi <davidel@xmailserver.org>
5 *
6 */
7
8#include <linux/file.h>
9#include <linux/poll.h>
10#include <linux/init.h>
11#include <linux/fs.h>
12#include <linux/sched.h>
13#include <linux/kernel.h>
14#include <linux/list.h>
15#include <linux/spinlock.h>
16#include <linux/anon_inodes.h>
17#include <linux/eventfd.h>
18
19struct eventfd_ctx {
20 spinlock_t lock;
21 wait_queue_head_t wqh;
22 /*
23 * Every time that a write(2) is performed on an eventfd, the
24 * value of the __u64 being written is added to "count" and a
25 * wakeup is performed on "wqh". A read(2) will return the "count"
26 * value to userspace, and will reset "count" to zero. The kernel
27 * size eventfd_signal() also, adds to the "count" counter and
28 * issue a wakeup.
29 */
30 __u64 count;
31};
32
33/*
34 * Adds "n" to the eventfd counter "count". Returns "n" in case of
35 * success, or a value lower then "n" in case of coutner overflow.
36 * This function is supposed to be called by the kernel in paths
37 * that do not allow sleeping. In this function we allow the counter
38 * to reach the ULLONG_MAX value, and we signal this as overflow
39 * condition by returining a POLLERR to poll(2).
40 */
41int eventfd_signal(struct file *file, int n)
42{
43 struct eventfd_ctx *ctx = file->private_data;
44 unsigned long flags;
45
46 if (n < 0)
47 return -EINVAL;
48 spin_lock_irqsave(&ctx->lock, flags);
49 if (ULLONG_MAX - ctx->count < n)
50 n = (int) (ULLONG_MAX - ctx->count);
51 ctx->count += n;
52 if (waitqueue_active(&ctx->wqh))
53 wake_up_locked(&ctx->wqh);
54 spin_unlock_irqrestore(&ctx->lock, flags);
55
56 return n;
57}
58
59static int eventfd_release(struct inode *inode, struct file *file)
60{
61 kfree(file->private_data);
62 return 0;
63}
64
65static unsigned int eventfd_poll(struct file *file, poll_table *wait)
66{
67 struct eventfd_ctx *ctx = file->private_data;
68 unsigned int events = 0;
69 unsigned long flags;
70
71 poll_wait(file, &ctx->wqh, wait);
72
73 spin_lock_irqsave(&ctx->lock, flags);
74 if (ctx->count > 0)
75 events |= POLLIN;
76 if (ctx->count == ULLONG_MAX)
77 events |= POLLERR;
78 if (ULLONG_MAX - 1 > ctx->count)
79 events |= POLLOUT;
80 spin_unlock_irqrestore(&ctx->lock, flags);
81
82 return events;
83}
84
85static ssize_t eventfd_read(struct file *file, char __user *buf, size_t count,
86 loff_t *ppos)
87{
88 struct eventfd_ctx *ctx = file->private_data;
89 ssize_t res;
90 __u64 ucnt;
91 DECLARE_WAITQUEUE(wait, current);
92
93 if (count < sizeof(ucnt))
94 return -EINVAL;
95 spin_lock_irq(&ctx->lock);
96 res = -EAGAIN;
97 ucnt = ctx->count;
98 if (ucnt > 0)
99 res = sizeof(ucnt);
100 else if (!(file->f_flags & O_NONBLOCK)) {
101 __add_wait_queue(&ctx->wqh, &wait);
102 for (res = 0;;) {
103 set_current_state(TASK_INTERRUPTIBLE);
104 if (ctx->count > 0) {
105 ucnt = ctx->count;
106 res = sizeof(ucnt);
107 break;
108 }
109 if (signal_pending(current)) {
110 res = -ERESTARTSYS;
111 break;
112 }
113 spin_unlock_irq(&ctx->lock);
114 schedule();
115 spin_lock_irq(&ctx->lock);
116 }
117 __remove_wait_queue(&ctx->wqh, &wait);
118 __set_current_state(TASK_RUNNING);
119 }
120 if (res > 0) {
121 ctx->count = 0;
122 if (waitqueue_active(&ctx->wqh))
123 wake_up_locked(&ctx->wqh);
124 }
125 spin_unlock_irq(&ctx->lock);
126 if (res > 0 && put_user(ucnt, (__u64 __user *) buf))
127 return -EFAULT;
128
129 return res;
130}
131
132static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t count,
133 loff_t *ppos)
134{
135 struct eventfd_ctx *ctx = file->private_data;
136 ssize_t res;
137 __u64 ucnt;
138 DECLARE_WAITQUEUE(wait, current);
139
140 if (count < sizeof(ucnt))
141 return -EINVAL;
142 if (copy_from_user(&ucnt, buf, sizeof(ucnt)))
143 return -EFAULT;
144 if (ucnt == ULLONG_MAX)
145 return -EINVAL;
146 spin_lock_irq(&ctx->lock);
147 res = -EAGAIN;
148 if (ULLONG_MAX - ctx->count > ucnt)
149 res = sizeof(ucnt);
150 else if (!(file->f_flags & O_NONBLOCK)) {
151 __add_wait_queue(&ctx->wqh, &wait);
152 for (res = 0;;) {
153 set_current_state(TASK_INTERRUPTIBLE);
154 if (ULLONG_MAX - ctx->count > ucnt) {
155 res = sizeof(ucnt);
156 break;
157 }
158 if (signal_pending(current)) {
159 res = -ERESTARTSYS;
160 break;
161 }
162 spin_unlock_irq(&ctx->lock);
163 schedule();
164 spin_lock_irq(&ctx->lock);
165 }
166 __remove_wait_queue(&ctx->wqh, &wait);
167 __set_current_state(TASK_RUNNING);
168 }
169 if (res > 0) {
170 ctx->count += ucnt;
171 if (waitqueue_active(&ctx->wqh))
172 wake_up_locked(&ctx->wqh);
173 }
174 spin_unlock_irq(&ctx->lock);
175
176 return res;
177}
178
179static const struct file_operations eventfd_fops = {
180 .release = eventfd_release,
181 .poll = eventfd_poll,
182 .read = eventfd_read,
183 .write = eventfd_write,
184};
185
186struct file *eventfd_fget(int fd)
187{
188 struct file *file;
189
190 file = fget(fd);
191 if (!file)
192 return ERR_PTR(-EBADF);
193 if (file->f_op != &eventfd_fops) {
194 fput(file);
195 return ERR_PTR(-EINVAL);
196 }
197
198 return file;
199}
200
201asmlinkage long sys_eventfd(unsigned int count)
202{
203 int error, fd;
204 struct eventfd_ctx *ctx;
205 struct file *file;
206 struct inode *inode;
207
208 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
209 if (!ctx)
210 return -ENOMEM;
211
212 init_waitqueue_head(&ctx->wqh);
213 spin_lock_init(&ctx->lock);
214 ctx->count = count;
215
216 /*
217 * When we call this, the initialization must be complete, since
218 * anon_inode_getfd() will install the fd.
219 */
220 error = anon_inode_getfd(&fd, &inode, &file, "[eventfd]",
221 &eventfd_fops, ctx);
222 if (!error)
223 return fd;
224
225 kfree(ctx);
226 return error;
227}
228
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index b5c7ca584939..1aad34ea61a4 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -11,7 +11,6 @@
11 * 11 *
12 */ 12 */
13 13
14#include <linux/module.h>
15#include <linux/init.h> 14#include <linux/init.h>
16#include <linux/kernel.h> 15#include <linux/kernel.h>
17#include <linux/sched.h> 16#include <linux/sched.h>
@@ -34,6 +33,7 @@
34#include <linux/mount.h> 33#include <linux/mount.h>
35#include <linux/bitops.h> 34#include <linux/bitops.h>
36#include <linux/mutex.h> 35#include <linux/mutex.h>
36#include <linux/anon_inodes.h>
37#include <asm/uaccess.h> 37#include <asm/uaccess.h>
38#include <asm/system.h> 38#include <asm/system.h>
39#include <asm/io.h> 39#include <asm/io.h>
@@ -41,7 +41,6 @@
41#include <asm/atomic.h> 41#include <asm/atomic.h>
42#include <asm/semaphore.h> 42#include <asm/semaphore.h>
43 43
44
45/* 44/*
46 * LOCKING: 45 * LOCKING:
47 * There are three level of locking required by epoll : 46 * There are three level of locking required by epoll :
@@ -74,9 +73,6 @@
74 * a greater scalability. 73 * a greater scalability.
75 */ 74 */
76 75
77
78#define EVENTPOLLFS_MAGIC 0x03111965 /* My birthday should work for this :) */
79
80#define DEBUG_EPOLL 0 76#define DEBUG_EPOLL 0
81 77
82#if DEBUG_EPOLL > 0 78#if DEBUG_EPOLL > 0
@@ -106,7 +102,6 @@
106 102
107#define EP_MAX_EVENTS (INT_MAX / sizeof(struct epoll_event)) 103#define EP_MAX_EVENTS (INT_MAX / sizeof(struct epoll_event))
108 104
109
110struct epoll_filefd { 105struct epoll_filefd {
111 struct file *file; 106 struct file *file;
112 int fd; 107 int fd;
@@ -224,43 +219,6 @@ struct ep_pqueue {
224 struct epitem *epi; 219 struct epitem *epi;
225}; 220};
226 221
227
228
229static void ep_poll_safewake_init(struct poll_safewake *psw);
230static void ep_poll_safewake(struct poll_safewake *psw, wait_queue_head_t *wq);
231static int ep_getfd(int *efd, struct inode **einode, struct file **efile,
232 struct eventpoll *ep);
233static int ep_alloc(struct eventpoll **pep);
234static void ep_free(struct eventpoll *ep);
235static struct epitem *ep_find(struct eventpoll *ep, struct file *file, int fd);
236static void ep_use_epitem(struct epitem *epi);
237static void ep_release_epitem(struct epitem *epi);
238static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead,
239 poll_table *pt);
240static void ep_rbtree_insert(struct eventpoll *ep, struct epitem *epi);
241static int ep_insert(struct eventpoll *ep, struct epoll_event *event,
242 struct file *tfile, int fd);
243static int ep_modify(struct eventpoll *ep, struct epitem *epi,
244 struct epoll_event *event);
245static void ep_unregister_pollwait(struct eventpoll *ep, struct epitem *epi);
246static int ep_unlink(struct eventpoll *ep, struct epitem *epi);
247static int ep_remove(struct eventpoll *ep, struct epitem *epi);
248static int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *key);
249static int ep_eventpoll_close(struct inode *inode, struct file *file);
250static unsigned int ep_eventpoll_poll(struct file *file, poll_table *wait);
251static int ep_send_events(struct eventpoll *ep, struct list_head *txlist,
252 struct epoll_event __user *events, int maxevents);
253static int ep_events_transfer(struct eventpoll *ep,
254 struct epoll_event __user *events,
255 int maxevents);
256static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
257 int maxevents, long timeout);
258static int eventpollfs_delete_dentry(struct dentry *dentry);
259static struct inode *ep_eventpoll_inode(void);
260static int eventpollfs_get_sb(struct file_system_type *fs_type,
261 int flags, const char *dev_name,
262 void *data, struct vfsmount *mnt);
263
264/* 222/*
265 * This semaphore is used to serialize ep_free() and eventpoll_release_file(). 223 * This semaphore is used to serialize ep_free() and eventpoll_release_file().
266 */ 224 */
@@ -275,37 +233,6 @@ static struct kmem_cache *epi_cache __read_mostly;
275/* Slab cache used to allocate "struct eppoll_entry" */ 233/* Slab cache used to allocate "struct eppoll_entry" */
276static struct kmem_cache *pwq_cache __read_mostly; 234static struct kmem_cache *pwq_cache __read_mostly;
277 235
278/* Virtual fs used to allocate inodes for eventpoll files */
279static struct vfsmount *eventpoll_mnt __read_mostly;
280
281/* File callbacks that implement the eventpoll file behaviour */
282static const struct file_operations eventpoll_fops = {
283 .release = ep_eventpoll_close,
284 .poll = ep_eventpoll_poll
285};
286
287/*
288 * This is used to register the virtual file system from where
289 * eventpoll inodes are allocated.
290 */
291static struct file_system_type eventpoll_fs_type = {
292 .name = "eventpollfs",
293 .get_sb = eventpollfs_get_sb,
294 .kill_sb = kill_anon_super,
295};
296
297/* Very basic directory entry operations for the eventpoll virtual file system */
298static struct dentry_operations eventpollfs_dentry_operations = {
299 .d_delete = eventpollfs_delete_dentry,
300};
301
302
303
304/* Fast test to see if the file is an evenpoll file */
305static inline int is_file_epoll(struct file *f)
306{
307 return f->f_op == &eventpoll_fops;
308}
309 236
310/* Setup the structure that is used as key for the rb-tree */ 237/* Setup the structure that is used as key for the rb-tree */
311static inline void ep_set_ffd(struct epoll_filefd *ffd, 238static inline void ep_set_ffd(struct epoll_filefd *ffd,
@@ -374,7 +301,6 @@ static void ep_poll_safewake_init(struct poll_safewake *psw)
374 spin_lock_init(&psw->lock); 301 spin_lock_init(&psw->lock);
375} 302}
376 303
377
378/* 304/*
379 * Perform a safe wake up of the poll wait list. The problem is that 305 * Perform a safe wake up of the poll wait list. The problem is that
380 * with the new callback'd wake up system, it is possible that the 306 * with the new callback'd wake up system, it is possible that the
@@ -429,399 +355,144 @@ static void ep_poll_safewake(struct poll_safewake *psw, wait_queue_head_t *wq)
429 spin_unlock_irqrestore(&psw->lock, flags); 355 spin_unlock_irqrestore(&psw->lock, flags);
430} 356}
431 357
432
433/* 358/*
434 * This is called from eventpoll_release() to unlink files from the eventpoll 359 * This function unregister poll callbacks from the associated file descriptor.
435 * interface. We need to have this facility to cleanup correctly files that are 360 * Since this must be called without holding "ep->lock" the atomic exchange trick
436 * closed without being removed from the eventpoll interface. 361 * will protect us from multiple unregister.
437 */ 362 */
438void eventpoll_release_file(struct file *file) 363static void ep_unregister_pollwait(struct eventpoll *ep, struct epitem *epi)
439{ 364{
440 struct list_head *lsthead = &file->f_ep_links; 365 int nwait;
441 struct eventpoll *ep; 366 struct list_head *lsthead = &epi->pwqlist;
442 struct epitem *epi; 367 struct eppoll_entry *pwq;
443 368
444 /* 369 /* This is called without locks, so we need the atomic exchange */
445 * We don't want to get "file->f_ep_lock" because it is not 370 nwait = xchg(&epi->nwait, 0);
446 * necessary. It is not necessary because we're in the "struct file"
447 * cleanup path, and this means that noone is using this file anymore.
448 * The only hit might come from ep_free() but by holding the semaphore
449 * will correctly serialize the operation. We do need to acquire
450 * "ep->sem" after "epmutex" because ep_remove() requires it when called
451 * from anywhere but ep_free().
452 */
453 mutex_lock(&epmutex);
454 371
455 while (!list_empty(lsthead)) { 372 if (nwait) {
456 epi = list_first_entry(lsthead, struct epitem, fllink); 373 while (!list_empty(lsthead)) {
374 pwq = list_first_entry(lsthead, struct eppoll_entry, llink);
457 375
458 ep = epi->ep; 376 list_del_init(&pwq->llink);
459 list_del_init(&epi->fllink); 377 remove_wait_queue(pwq->whead, &pwq->wait);
460 down_write(&ep->sem); 378 kmem_cache_free(pwq_cache, pwq);
461 ep_remove(ep, epi); 379 }
462 up_write(&ep->sem);
463 } 380 }
464
465 mutex_unlock(&epmutex);
466} 381}
467 382
468
469/* 383/*
470 * It opens an eventpoll file descriptor by suggesting a storage of "size" 384 * Unlink the "struct epitem" from all places it might have been hooked up.
471 * file descriptors. The size parameter is just an hint about how to size 385 * This function must be called with write IRQ lock on "ep->lock".
472 * data structures. It won't prevent the user to store more than "size"
473 * file descriptors inside the epoll interface. It is the kernel part of
474 * the userspace epoll_create(2).
475 */ 386 */
476asmlinkage long sys_epoll_create(int size) 387static int ep_unlink(struct eventpoll *ep, struct epitem *epi)
477{ 388{
478 int error, fd = -1; 389 int error;
479 struct eventpoll *ep;
480 struct inode *inode;
481 struct file *file;
482
483 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d)\n",
484 current, size));
485
486 /*
487 * Sanity check on the size parameter, and create the internal data
488 * structure ( "struct eventpoll" ).
489 */
490 error = -EINVAL;
491 if (size <= 0 || (error = ep_alloc(&ep)) != 0)
492 goto eexit_1;
493 390
494 /* 391 /*
495 * Creates all the items needed to setup an eventpoll file. That is, 392 * It can happen that this one is called for an item already unlinked.
496 * a file structure, and inode and a free file descriptor. 393 * The check protect us from doing a double unlink ( crash ).
497 */ 394 */
498 error = ep_getfd(&fd, &inode, &file, ep); 395 error = -ENOENT;
499 if (error) 396 if (!ep_rb_linked(&epi->rbn))
500 goto eexit_2; 397 goto error_return;
501
502 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n",
503 current, size, fd));
504
505 return fd;
506
507eexit_2:
508 ep_free(ep);
509 kfree(ep);
510eexit_1:
511 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n",
512 current, size, error));
513 return error;
514}
515
516
517/*
518 * The following function implements the controller interface for
519 * the eventpoll file that enables the insertion/removal/change of
520 * file descriptors inside the interest set. It represents
521 * the kernel part of the user space epoll_ctl(2).
522 */
523asmlinkage long
524sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event __user *event)
525{
526 int error;
527 struct file *file, *tfile;
528 struct eventpoll *ep;
529 struct epitem *epi;
530 struct epoll_event epds;
531
532 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_ctl(%d, %d, %d, %p)\n",
533 current, epfd, op, fd, event));
534
535 error = -EFAULT;
536 if (ep_op_has_event(op) &&
537 copy_from_user(&epds, event, sizeof(struct epoll_event)))
538 goto eexit_1;
539
540 /* Get the "struct file *" for the eventpoll file */
541 error = -EBADF;
542 file = fget(epfd);
543 if (!file)
544 goto eexit_1;
545
546 /* Get the "struct file *" for the target file */
547 tfile = fget(fd);
548 if (!tfile)
549 goto eexit_2;
550
551 /* The target file descriptor must support poll */
552 error = -EPERM;
553 if (!tfile->f_op || !tfile->f_op->poll)
554 goto eexit_3;
555 398
556 /* 399 /*
557 * We have to check that the file structure underneath the file descriptor 400 * Clear the event mask for the unlinked item. This will avoid item
558 * the user passed to us _is_ an eventpoll file. And also we do not permit 401 * notifications to be sent after the unlink operation from inside
559 * adding an epoll file descriptor inside itself. 402 * the kernel->userspace event transfer loop.
560 */ 403 */
561 error = -EINVAL; 404 epi->event.events = 0;
562 if (file == tfile || !is_file_epoll(file))
563 goto eexit_3;
564 405
565 /* 406 /*
566 * At this point it is safe to assume that the "private_data" contains 407 * At this point is safe to do the job, unlink the item from our rb-tree.
567 * our own data structure. 408 * This operation togheter with the above check closes the door to
409 * double unlinks.
568 */ 410 */
569 ep = file->private_data; 411 ep_rb_erase(&epi->rbn, &ep->rbr);
570
571 down_write(&ep->sem);
572
573 /* Try to lookup the file inside our RB tree */
574 epi = ep_find(ep, tfile, fd);
575
576 error = -EINVAL;
577 switch (op) {
578 case EPOLL_CTL_ADD:
579 if (!epi) {
580 epds.events |= POLLERR | POLLHUP;
581
582 error = ep_insert(ep, &epds, tfile, fd);
583 } else
584 error = -EEXIST;
585 break;
586 case EPOLL_CTL_DEL:
587 if (epi)
588 error = ep_remove(ep, epi);
589 else
590 error = -ENOENT;
591 break;
592 case EPOLL_CTL_MOD:
593 if (epi) {
594 epds.events |= POLLERR | POLLHUP;
595 error = ep_modify(ep, epi, &epds);
596 } else
597 error = -ENOENT;
598 break;
599 }
600 412
601 /* 413 /*
602 * The function ep_find() increments the usage count of the structure 414 * If the item we are going to remove is inside the ready file descriptors
603 * so, if this is not NULL, we need to release it. 415 * we want to remove it from this list to avoid stale events.
604 */ 416 */
605 if (epi) 417 if (ep_is_linked(&epi->rdllink))
606 ep_release_epitem(epi); 418 list_del_init(&epi->rdllink);
607 419
608 up_write(&ep->sem); 420 error = 0;
421error_return:
609 422
610eexit_3: 423 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: ep_unlink(%p, %p) = %d\n",
611 fput(tfile); 424 current, ep, epi->ffd.file, error));
612eexit_2:
613 fput(file);
614eexit_1:
615 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_ctl(%d, %d, %d, %p) = %d\n",
616 current, epfd, op, fd, event, error));
617 425
618 return error; 426 return error;
619} 427}
620 428
621
622/* 429/*
623 * Implement the event wait interface for the eventpoll file. It is the kernel 430 * Increment the usage count of the "struct epitem" making it sure
624 * part of the user space epoll_wait(2). 431 * that the user will have a valid pointer to reference.
625 */ 432 */
626asmlinkage long sys_epoll_wait(int epfd, struct epoll_event __user *events, 433static void ep_use_epitem(struct epitem *epi)
627 int maxevents, int timeout)
628{ 434{
629 int error; 435 atomic_inc(&epi->usecnt);
630 struct file *file;
631 struct eventpoll *ep;
632
633 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_wait(%d, %p, %d, %d)\n",
634 current, epfd, events, maxevents, timeout));
635
636 /* The maximum number of event must be greater than zero */
637 if (maxevents <= 0 || maxevents > EP_MAX_EVENTS)
638 return -EINVAL;
639
640 /* Verify that the area passed by the user is writeable */
641 if (!access_ok(VERIFY_WRITE, events, maxevents * sizeof(struct epoll_event))) {
642 error = -EFAULT;
643 goto eexit_1;
644 }
645
646 /* Get the "struct file *" for the eventpoll file */
647 error = -EBADF;
648 file = fget(epfd);
649 if (!file)
650 goto eexit_1;
651
652 /*
653 * We have to check that the file structure underneath the fd
654 * the user passed to us _is_ an eventpoll file.
655 */
656 error = -EINVAL;
657 if (!is_file_epoll(file))
658 goto eexit_2;
659
660 /*
661 * At this point it is safe to assume that the "private_data" contains
662 * our own data structure.
663 */
664 ep = file->private_data;
665
666 /* Time to fish for events ... */
667 error = ep_poll(ep, events, maxevents, timeout);
668
669eexit_2:
670 fput(file);
671eexit_1:
672 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_wait(%d, %p, %d, %d) = %d\n",
673 current, epfd, events, maxevents, timeout, error));
674
675 return error;
676} 436}
677 437
678
679#ifdef TIF_RESTORE_SIGMASK
680
681/* 438/*
682 * Implement the event wait interface for the eventpoll file. It is the kernel 439 * Decrement ( release ) the usage count by signaling that the user
683 * part of the user space epoll_pwait(2). 440 * has finished using the structure. It might lead to freeing the
441 * structure itself if the count goes to zero.
684 */ 442 */
685asmlinkage long sys_epoll_pwait(int epfd, struct epoll_event __user *events, 443static void ep_release_epitem(struct epitem *epi)
686 int maxevents, int timeout, const sigset_t __user *sigmask,
687 size_t sigsetsize)
688{ 444{
689 int error; 445 if (atomic_dec_and_test(&epi->usecnt))
690 sigset_t ksigmask, sigsaved; 446 kmem_cache_free(epi_cache, epi);
691
692 /*
693 * If the caller wants a certain signal mask to be set during the wait,
694 * we apply it here.
695 */
696 if (sigmask) {
697 if (sigsetsize != sizeof(sigset_t))
698 return -EINVAL;
699 if (copy_from_user(&ksigmask, sigmask, sizeof(ksigmask)))
700 return -EFAULT;
701 sigdelsetmask(&ksigmask, sigmask(SIGKILL) | sigmask(SIGSTOP));
702 sigprocmask(SIG_SETMASK, &ksigmask, &sigsaved);
703 }
704
705 error = sys_epoll_wait(epfd, events, maxevents, timeout);
706
707 /*
708 * If we changed the signal mask, we need to restore the original one.
709 * In case we've got a signal while waiting, we do not restore the
710 * signal mask yet, and we allow do_signal() to deliver the signal on
711 * the way back to userspace, before the signal mask is restored.
712 */
713 if (sigmask) {
714 if (error == -EINTR) {
715 memcpy(&current->saved_sigmask, &sigsaved,
716 sizeof(sigsaved));
717 set_thread_flag(TIF_RESTORE_SIGMASK);
718 } else
719 sigprocmask(SIG_SETMASK, &sigsaved, NULL);
720 }
721
722 return error;
723} 447}
724 448
725#endif /* #ifdef TIF_RESTORE_SIGMASK */
726
727
728/* 449/*
729 * Creates the file descriptor to be used by the epoll interface. 450 * Removes a "struct epitem" from the eventpoll RB tree and deallocates
451 * all the associated resources.
730 */ 452 */
731static int ep_getfd(int *efd, struct inode **einode, struct file **efile, 453static int ep_remove(struct eventpoll *ep, struct epitem *epi)
732 struct eventpoll *ep)
733{ 454{
734 struct qstr this; 455 int error;
735 char name[32]; 456 unsigned long flags;
736 struct dentry *dentry; 457 struct file *file = epi->ffd.file;
737 struct inode *inode;
738 struct file *file;
739 int error, fd;
740
741 /* Get an ready to use file */
742 error = -ENFILE;
743 file = get_empty_filp();
744 if (!file)
745 goto eexit_1;
746
747 /* Allocates an inode from the eventpoll file system */
748 inode = ep_eventpoll_inode();
749 if (IS_ERR(inode)) {
750 error = PTR_ERR(inode);
751 goto eexit_2;
752 }
753
754 /* Allocates a free descriptor to plug the file onto */
755 error = get_unused_fd();
756 if (error < 0)
757 goto eexit_3;
758 fd = error;
759 458
760 /* 459 /*
761 * Link the inode to a directory entry by creating a unique name 460 * Removes poll wait queue hooks. We _have_ to do this without holding
762 * using the inode number. 461 * the "ep->lock" otherwise a deadlock might occur. This because of the
462 * sequence of the lock acquisition. Here we do "ep->lock" then the wait
463 * queue head lock when unregistering the wait queue. The wakeup callback
464 * will run by holding the wait queue head lock and will call our callback
465 * that will try to get "ep->lock".
763 */ 466 */
764 error = -ENOMEM; 467 ep_unregister_pollwait(ep, epi);
765 sprintf(name, "[%lu]", inode->i_ino);
766 this.name = name;
767 this.len = strlen(name);
768 this.hash = inode->i_ino;
769 dentry = d_alloc(eventpoll_mnt->mnt_sb->s_root, &this);
770 if (!dentry)
771 goto eexit_4;
772 dentry->d_op = &eventpollfs_dentry_operations;
773 d_add(dentry, inode);
774 file->f_path.mnt = mntget(eventpoll_mnt);
775 file->f_path.dentry = dentry;
776 file->f_mapping = inode->i_mapping;
777
778 file->f_pos = 0;
779 file->f_flags = O_RDONLY;
780 file->f_op = &eventpoll_fops;
781 file->f_mode = FMODE_READ;
782 file->f_version = 0;
783 file->private_data = ep;
784
785 /* Install the new setup file into the allocated fd. */
786 fd_install(fd, file);
787
788 *efd = fd;
789 *einode = inode;
790 *efile = file;
791 return 0;
792 468
793eexit_4: 469 /* Remove the current item from the list of epoll hooks */
794 put_unused_fd(fd); 470 spin_lock(&file->f_ep_lock);
795eexit_3: 471 if (ep_is_linked(&epi->fllink))
796 iput(inode); 472 list_del_init(&epi->fllink);
797eexit_2: 473 spin_unlock(&file->f_ep_lock);
798 put_filp(file);
799eexit_1:
800 return error;
801}
802 474
475 /* We need to acquire the write IRQ lock before calling ep_unlink() */
476 write_lock_irqsave(&ep->lock, flags);
803 477
804static int ep_alloc(struct eventpoll **pep) 478 /* Really unlink the item from the RB tree */
805{ 479 error = ep_unlink(ep, epi);
806 struct eventpoll *ep = kzalloc(sizeof(*ep), GFP_KERNEL);
807 480
808 if (!ep) 481 write_unlock_irqrestore(&ep->lock, flags);
809 return -ENOMEM;
810 482
811 rwlock_init(&ep->lock); 483 if (error)
812 init_rwsem(&ep->sem); 484 goto error_return;
813 init_waitqueue_head(&ep->wq);
814 init_waitqueue_head(&ep->poll_wait);
815 INIT_LIST_HEAD(&ep->rdllist);
816 ep->rbr = RB_ROOT;
817 485
818 *pep = ep; 486 /* At this point it is safe to free the eventpoll item */
487 ep_release_epitem(epi);
819 488
820 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: ep_alloc() ep=%p\n", 489 error = 0;
821 current, ep)); 490error_return:
822 return 0; 491 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: ep_remove(%p, %p) = %d\n",
823} 492 current, ep, file, error));
824 493
494 return error;
495}
825 496
826static void ep_free(struct eventpoll *ep) 497static void ep_free(struct eventpoll *ep)
827{ 498{
@@ -865,6 +536,104 @@ static void ep_free(struct eventpoll *ep)
865 mutex_unlock(&epmutex); 536 mutex_unlock(&epmutex);
866} 537}
867 538
539static int ep_eventpoll_release(struct inode *inode, struct file *file)
540{
541 struct eventpoll *ep = file->private_data;
542
543 if (ep) {
544 ep_free(ep);
545 kfree(ep);
546 }
547
548 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: close() ep=%p\n", current, ep));
549 return 0;
550}
551
552static unsigned int ep_eventpoll_poll(struct file *file, poll_table *wait)
553{
554 unsigned int pollflags = 0;
555 unsigned long flags;
556 struct eventpoll *ep = file->private_data;
557
558 /* Insert inside our poll wait queue */
559 poll_wait(file, &ep->poll_wait, wait);
560
561 /* Check our condition */
562 read_lock_irqsave(&ep->lock, flags);
563 if (!list_empty(&ep->rdllist))
564 pollflags = POLLIN | POLLRDNORM;
565 read_unlock_irqrestore(&ep->lock, flags);
566
567 return pollflags;
568}
569
570/* File callbacks that implement the eventpoll file behaviour */
571static const struct file_operations eventpoll_fops = {
572 .release = ep_eventpoll_release,
573 .poll = ep_eventpoll_poll
574};
575
576/* Fast test to see if the file is an evenpoll file */
577static inline int is_file_epoll(struct file *f)
578{
579 return f->f_op == &eventpoll_fops;
580}
581
582/*
583 * This is called from eventpoll_release() to unlink files from the eventpoll
584 * interface. We need to have this facility to cleanup correctly files that are
585 * closed without being removed from the eventpoll interface.
586 */
587void eventpoll_release_file(struct file *file)
588{
589 struct list_head *lsthead = &file->f_ep_links;
590 struct eventpoll *ep;
591 struct epitem *epi;
592
593 /*
594 * We don't want to get "file->f_ep_lock" because it is not
595 * necessary. It is not necessary because we're in the "struct file"
596 * cleanup path, and this means that noone is using this file anymore.
597 * The only hit might come from ep_free() but by holding the semaphore
598 * will correctly serialize the operation. We do need to acquire
599 * "ep->sem" after "epmutex" because ep_remove() requires it when called
600 * from anywhere but ep_free().
601 */
602 mutex_lock(&epmutex);
603
604 while (!list_empty(lsthead)) {
605 epi = list_first_entry(lsthead, struct epitem, fllink);
606
607 ep = epi->ep;
608 list_del_init(&epi->fllink);
609 down_write(&ep->sem);
610 ep_remove(ep, epi);
611 up_write(&ep->sem);
612 }
613
614 mutex_unlock(&epmutex);
615}
616
617static int ep_alloc(struct eventpoll **pep)
618{
619 struct eventpoll *ep = kzalloc(sizeof(*ep), GFP_KERNEL);
620
621 if (!ep)
622 return -ENOMEM;
623
624 rwlock_init(&ep->lock);
625 init_rwsem(&ep->sem);
626 init_waitqueue_head(&ep->wq);
627 init_waitqueue_head(&ep->poll_wait);
628 INIT_LIST_HEAD(&ep->rdllist);
629 ep->rbr = RB_ROOT;
630
631 *pep = ep;
632
633 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: ep_alloc() ep=%p\n",
634 current, ep));
635 return 0;
636}
868 637
869/* 638/*
870 * Search the file inside the eventpoll tree. It add usage count to 639 * Search the file inside the eventpoll tree. It add usage count to
@@ -902,30 +671,58 @@ static struct epitem *ep_find(struct eventpoll *ep, struct file *file, int fd)
902 return epir; 671 return epir;
903} 672}
904 673
905
906/* 674/*
907 * Increment the usage count of the "struct epitem" making it sure 675 * This is the callback that is passed to the wait queue wakeup
908 * that the user will have a valid pointer to reference. 676 * machanism. It is called by the stored file descriptors when they
677 * have events to report.
909 */ 678 */
910static void ep_use_epitem(struct epitem *epi) 679static int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *key)
911{ 680{
681 int pwake = 0;
682 unsigned long flags;
683 struct epitem *epi = ep_item_from_wait(wait);
684 struct eventpoll *ep = epi->ep;
912 685
913 atomic_inc(&epi->usecnt); 686 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: poll_callback(%p) epi=%p ep=%p\n",
914} 687 current, epi->ffd.file, epi, ep));
915 688
689 write_lock_irqsave(&ep->lock, flags);
916 690
917/* 691 /*
918 * Decrement ( release ) the usage count by signaling that the user 692 * If the event mask does not contain any poll(2) event, we consider the
919 * has finished using the structure. It might lead to freeing the 693 * descriptor to be disabled. This condition is likely the effect of the
920 * structure itself if the count goes to zero. 694 * EPOLLONESHOT bit that disables the descriptor when an event is received,
921 */ 695 * until the next EPOLL_CTL_MOD will be issued.
922static void ep_release_epitem(struct epitem *epi) 696 */
923{ 697 if (!(epi->event.events & ~EP_PRIVATE_BITS))
698 goto is_disabled;
924 699
925 if (atomic_dec_and_test(&epi->usecnt)) 700 /* If this file is already in the ready list we exit soon */
926 kmem_cache_free(epi_cache, epi); 701 if (ep_is_linked(&epi->rdllink))
927} 702 goto is_linked;
928 703
704 list_add_tail(&epi->rdllink, &ep->rdllist);
705
706is_linked:
707 /*
708 * Wake up ( if active ) both the eventpoll wait list and the ->poll()
709 * wait list.
710 */
711 if (waitqueue_active(&ep->wq))
712 __wake_up_locked(&ep->wq, TASK_UNINTERRUPTIBLE |
713 TASK_INTERRUPTIBLE);
714 if (waitqueue_active(&ep->poll_wait))
715 pwake++;
716
717is_disabled:
718 write_unlock_irqrestore(&ep->lock, flags);
719
720 /* We have to call this outside the lock */
721 if (pwake)
722 ep_poll_safewake(&psw, &ep->poll_wait);
723
724 return 1;
725}
929 726
930/* 727/*
931 * This is the callback that is used to add our wait queue to the 728 * This is the callback that is used to add our wait queue to the
@@ -950,7 +747,6 @@ static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead,
950 } 747 }
951} 748}
952 749
953
954static void ep_rbtree_insert(struct eventpoll *ep, struct epitem *epi) 750static void ep_rbtree_insert(struct eventpoll *ep, struct epitem *epi)
955{ 751{
956 int kcmp; 752 int kcmp;
@@ -970,7 +766,6 @@ static void ep_rbtree_insert(struct eventpoll *ep, struct epitem *epi)
970 rb_insert_color(&epi->rbn, &ep->rbr); 766 rb_insert_color(&epi->rbn, &ep->rbr);
971} 767}
972 768
973
974static int ep_insert(struct eventpoll *ep, struct epoll_event *event, 769static int ep_insert(struct eventpoll *ep, struct epoll_event *event,
975 struct file *tfile, int fd) 770 struct file *tfile, int fd)
976{ 771{
@@ -981,7 +776,7 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event,
981 776
982 error = -ENOMEM; 777 error = -ENOMEM;
983 if (!(epi = kmem_cache_alloc(epi_cache, GFP_KERNEL))) 778 if (!(epi = kmem_cache_alloc(epi_cache, GFP_KERNEL)))
984 goto eexit_1; 779 goto error_return;
985 780
986 /* Item initialization follow here ... */ 781 /* Item initialization follow here ... */
987 ep_rb_initnode(&epi->rbn); 782 ep_rb_initnode(&epi->rbn);
@@ -1011,7 +806,7 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event,
1011 * high memory pressure. 806 * high memory pressure.
1012 */ 807 */
1013 if (epi->nwait < 0) 808 if (epi->nwait < 0)
1014 goto eexit_2; 809 goto error_unregister;
1015 810
1016 /* Add the current item to the list of active epoll hook for this file */ 811 /* Add the current item to the list of active epoll hook for this file */
1017 spin_lock(&tfile->f_ep_lock); 812 spin_lock(&tfile->f_ep_lock);
@@ -1046,7 +841,7 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event,
1046 841
1047 return 0; 842 return 0;
1048 843
1049eexit_2: 844error_unregister:
1050 ep_unregister_pollwait(ep, epi); 845 ep_unregister_pollwait(ep, epi);
1051 846
1052 /* 847 /*
@@ -1059,11 +854,10 @@ eexit_2:
1059 write_unlock_irqrestore(&ep->lock, flags); 854 write_unlock_irqrestore(&ep->lock, flags);
1060 855
1061 kmem_cache_free(epi_cache, epi); 856 kmem_cache_free(epi_cache, epi);
1062eexit_1: 857error_return:
1063 return error; 858 return error;
1064} 859}
1065 860
1066
1067/* 861/*
1068 * Modify the interest event mask by dropping an event if the new mask 862 * Modify the interest event mask by dropping an event if the new mask
1069 * has a match in the current file status. 863 * has a match in the current file status.
@@ -1126,216 +920,6 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, struct epoll_even
1126 return 0; 920 return 0;
1127} 921}
1128 922
1129
1130/*
1131 * This function unregister poll callbacks from the associated file descriptor.
1132 * Since this must be called without holding "ep->lock" the atomic exchange trick
1133 * will protect us from multiple unregister.
1134 */
1135static void ep_unregister_pollwait(struct eventpoll *ep, struct epitem *epi)
1136{
1137 int nwait;
1138 struct list_head *lsthead = &epi->pwqlist;
1139 struct eppoll_entry *pwq;
1140
1141 /* This is called without locks, so we need the atomic exchange */
1142 nwait = xchg(&epi->nwait, 0);
1143
1144 if (nwait) {
1145 while (!list_empty(lsthead)) {
1146 pwq = list_first_entry(lsthead, struct eppoll_entry, llink);
1147
1148 list_del_init(&pwq->llink);
1149 remove_wait_queue(pwq->whead, &pwq->wait);
1150 kmem_cache_free(pwq_cache, pwq);
1151 }
1152 }
1153}
1154
1155
1156/*
1157 * Unlink the "struct epitem" from all places it might have been hooked up.
1158 * This function must be called with write IRQ lock on "ep->lock".
1159 */
1160static int ep_unlink(struct eventpoll *ep, struct epitem *epi)
1161{
1162 int error;
1163
1164 /*
1165 * It can happen that this one is called for an item already unlinked.
1166 * The check protect us from doing a double unlink ( crash ).
1167 */
1168 error = -ENOENT;
1169 if (!ep_rb_linked(&epi->rbn))
1170 goto eexit_1;
1171
1172 /*
1173 * Clear the event mask for the unlinked item. This will avoid item
1174 * notifications to be sent after the unlink operation from inside
1175 * the kernel->userspace event transfer loop.
1176 */
1177 epi->event.events = 0;
1178
1179 /*
1180 * At this point is safe to do the job, unlink the item from our rb-tree.
1181 * This operation togheter with the above check closes the door to
1182 * double unlinks.
1183 */
1184 ep_rb_erase(&epi->rbn, &ep->rbr);
1185
1186 /*
1187 * If the item we are going to remove is inside the ready file descriptors
1188 * we want to remove it from this list to avoid stale events.
1189 */
1190 if (ep_is_linked(&epi->rdllink))
1191 list_del_init(&epi->rdllink);
1192
1193 error = 0;
1194eexit_1:
1195
1196 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: ep_unlink(%p, %p) = %d\n",
1197 current, ep, epi->ffd.file, error));
1198
1199 return error;
1200}
1201
1202
1203/*
1204 * Removes a "struct epitem" from the eventpoll RB tree and deallocates
1205 * all the associated resources.
1206 */
1207static int ep_remove(struct eventpoll *ep, struct epitem *epi)
1208{
1209 int error;
1210 unsigned long flags;
1211 struct file *file = epi->ffd.file;
1212
1213 /*
1214 * Removes poll wait queue hooks. We _have_ to do this without holding
1215 * the "ep->lock" otherwise a deadlock might occur. This because of the
1216 * sequence of the lock acquisition. Here we do "ep->lock" then the wait
1217 * queue head lock when unregistering the wait queue. The wakeup callback
1218 * will run by holding the wait queue head lock and will call our callback
1219 * that will try to get "ep->lock".
1220 */
1221 ep_unregister_pollwait(ep, epi);
1222
1223 /* Remove the current item from the list of epoll hooks */
1224 spin_lock(&file->f_ep_lock);
1225 if (ep_is_linked(&epi->fllink))
1226 list_del_init(&epi->fllink);
1227 spin_unlock(&file->f_ep_lock);
1228
1229 /* We need to acquire the write IRQ lock before calling ep_unlink() */
1230 write_lock_irqsave(&ep->lock, flags);
1231
1232 /* Really unlink the item from the RB tree */
1233 error = ep_unlink(ep, epi);
1234
1235 write_unlock_irqrestore(&ep->lock, flags);
1236
1237 if (error)
1238 goto eexit_1;
1239
1240 /* At this point it is safe to free the eventpoll item */
1241 ep_release_epitem(epi);
1242
1243 error = 0;
1244eexit_1:
1245 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: ep_remove(%p, %p) = %d\n",
1246 current, ep, file, error));
1247
1248 return error;
1249}
1250
1251
1252/*
1253 * This is the callback that is passed to the wait queue wakeup
1254 * machanism. It is called by the stored file descriptors when they
1255 * have events to report.
1256 */
1257static int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *key)
1258{
1259 int pwake = 0;
1260 unsigned long flags;
1261 struct epitem *epi = ep_item_from_wait(wait);
1262 struct eventpoll *ep = epi->ep;
1263
1264 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: poll_callback(%p) epi=%p ep=%p\n",
1265 current, epi->ffd.file, epi, ep));
1266
1267 write_lock_irqsave(&ep->lock, flags);
1268
1269 /*
1270 * If the event mask does not contain any poll(2) event, we consider the
1271 * descriptor to be disabled. This condition is likely the effect of the
1272 * EPOLLONESHOT bit that disables the descriptor when an event is received,
1273 * until the next EPOLL_CTL_MOD will be issued.
1274 */
1275 if (!(epi->event.events & ~EP_PRIVATE_BITS))
1276 goto is_disabled;
1277
1278 /* If this file is already in the ready list we exit soon */
1279 if (ep_is_linked(&epi->rdllink))
1280 goto is_linked;
1281
1282 list_add_tail(&epi->rdllink, &ep->rdllist);
1283
1284is_linked:
1285 /*
1286 * Wake up ( if active ) both the eventpoll wait list and the ->poll()
1287 * wait list.
1288 */
1289 if (waitqueue_active(&ep->wq))
1290 __wake_up_locked(&ep->wq, TASK_UNINTERRUPTIBLE |
1291 TASK_INTERRUPTIBLE);
1292 if (waitqueue_active(&ep->poll_wait))
1293 pwake++;
1294
1295is_disabled:
1296 write_unlock_irqrestore(&ep->lock, flags);
1297
1298 /* We have to call this outside the lock */
1299 if (pwake)
1300 ep_poll_safewake(&psw, &ep->poll_wait);
1301
1302 return 1;
1303}
1304
1305
1306static int ep_eventpoll_close(struct inode *inode, struct file *file)
1307{
1308 struct eventpoll *ep = file->private_data;
1309
1310 if (ep) {
1311 ep_free(ep);
1312 kfree(ep);
1313 }
1314
1315 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: close() ep=%p\n", current, ep));
1316 return 0;
1317}
1318
1319
1320static unsigned int ep_eventpoll_poll(struct file *file, poll_table *wait)
1321{
1322 unsigned int pollflags = 0;
1323 unsigned long flags;
1324 struct eventpoll *ep = file->private_data;
1325
1326 /* Insert inside our poll wait queue */
1327 poll_wait(file, &ep->poll_wait, wait);
1328
1329 /* Check our condition */
1330 read_lock_irqsave(&ep->lock, flags);
1331 if (!list_empty(&ep->rdllist))
1332 pollflags = POLLIN | POLLRDNORM;
1333 read_unlock_irqrestore(&ep->lock, flags);
1334
1335 return pollflags;
1336}
1337
1338
1339/* 923/*
1340 * This function is called without holding the "ep->lock" since the call to 924 * This function is called without holding the "ep->lock" since the call to
1341 * __copy_to_user() might sleep, and also f_op->poll() might reenable the IRQ 925 * __copy_to_user() might sleep, and also f_op->poll() might reenable the IRQ
@@ -1447,7 +1031,6 @@ static int ep_send_events(struct eventpoll *ep, struct list_head *txlist,
1447 return eventcnt == 0 ? error: eventcnt; 1031 return eventcnt == 0 ? error: eventcnt;
1448} 1032}
1449 1033
1450
1451/* 1034/*
1452 * Perform the transfer of events to user space. 1035 * Perform the transfer of events to user space.
1453 */ 1036 */
@@ -1483,7 +1066,6 @@ static int ep_events_transfer(struct eventpoll *ep,
1483 return eventcnt; 1066 return eventcnt;
1484} 1067}
1485 1068
1486
1487static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, 1069static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
1488 int maxevents, long timeout) 1070 int maxevents, long timeout)
1489{ 1071{
@@ -1553,52 +1135,262 @@ retry:
1553 return res; 1135 return res;
1554} 1136}
1555 1137
1556static int eventpollfs_delete_dentry(struct dentry *dentry) 1138/*
1139 * It opens an eventpoll file descriptor by suggesting a storage of "size"
1140 * file descriptors. The size parameter is just an hint about how to size
1141 * data structures. It won't prevent the user to store more than "size"
1142 * file descriptors inside the epoll interface. It is the kernel part of
1143 * the userspace epoll_create(2).
1144 */
1145asmlinkage long sys_epoll_create(int size)
1557{ 1146{
1147 int error, fd = -1;
1148 struct eventpoll *ep;
1149 struct inode *inode;
1150 struct file *file;
1558 1151
1559 return 1; 1152 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d)\n",
1153 current, size));
1154
1155 /*
1156 * Sanity check on the size parameter, and create the internal data
1157 * structure ( "struct eventpoll" ).
1158 */
1159 error = -EINVAL;
1160 if (size <= 0 || (error = ep_alloc(&ep)) != 0)
1161 goto error_return;
1162
1163 /*
1164 * Creates all the items needed to setup an eventpoll file. That is,
1165 * a file structure, and inode and a free file descriptor.
1166 */
1167 error = anon_inode_getfd(&fd, &inode, &file, "[eventpoll]",
1168 &eventpoll_fops, ep);
1169 if (error)
1170 goto error_free;
1171
1172 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n",
1173 current, size, fd));
1174
1175 return fd;
1176
1177error_free:
1178 ep_free(ep);
1179 kfree(ep);
1180error_return:
1181 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_create(%d) = %d\n",
1182 current, size, error));
1183 return error;
1560} 1184}
1561 1185
1562static struct inode *ep_eventpoll_inode(void) 1186/*
1187 * The following function implements the controller interface for
1188 * the eventpoll file that enables the insertion/removal/change of
1189 * file descriptors inside the interest set. It represents
1190 * the kernel part of the user space epoll_ctl(2).
1191 */
1192asmlinkage long sys_epoll_ctl(int epfd, int op, int fd,
1193 struct epoll_event __user *event)
1563{ 1194{
1564 int error = -ENOMEM; 1195 int error;
1565 struct inode *inode = new_inode(eventpoll_mnt->mnt_sb); 1196 struct file *file, *tfile;
1197 struct eventpoll *ep;
1198 struct epitem *epi;
1199 struct epoll_event epds;
1200
1201 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_ctl(%d, %d, %d, %p)\n",
1202 current, epfd, op, fd, event));
1203
1204 error = -EFAULT;
1205 if (ep_op_has_event(op) &&
1206 copy_from_user(&epds, event, sizeof(struct epoll_event)))
1207 goto error_return;
1208
1209 /* Get the "struct file *" for the eventpoll file */
1210 error = -EBADF;
1211 file = fget(epfd);
1212 if (!file)
1213 goto error_return;
1214
1215 /* Get the "struct file *" for the target file */
1216 tfile = fget(fd);
1217 if (!tfile)
1218 goto error_fput;
1219
1220 /* The target file descriptor must support poll */
1221 error = -EPERM;
1222 if (!tfile->f_op || !tfile->f_op->poll)
1223 goto error_tgt_fput;
1224
1225 /*
1226 * We have to check that the file structure underneath the file descriptor
1227 * the user passed to us _is_ an eventpoll file. And also we do not permit
1228 * adding an epoll file descriptor inside itself.
1229 */
1230 error = -EINVAL;
1231 if (file == tfile || !is_file_epoll(file))
1232 goto error_tgt_fput;
1566 1233
1567 if (!inode) 1234 /*
1568 goto eexit_1; 1235 * At this point it is safe to assume that the "private_data" contains
1236 * our own data structure.
1237 */
1238 ep = file->private_data;
1239
1240 down_write(&ep->sem);
1569 1241
1570 inode->i_fop = &eventpoll_fops; 1242 /* Try to lookup the file inside our RB tree */
1243 epi = ep_find(ep, tfile, fd);
1244
1245 error = -EINVAL;
1246 switch (op) {
1247 case EPOLL_CTL_ADD:
1248 if (!epi) {
1249 epds.events |= POLLERR | POLLHUP;
1571 1250
1251 error = ep_insert(ep, &epds, tfile, fd);
1252 } else
1253 error = -EEXIST;
1254 break;
1255 case EPOLL_CTL_DEL:
1256 if (epi)
1257 error = ep_remove(ep, epi);
1258 else
1259 error = -ENOENT;
1260 break;
1261 case EPOLL_CTL_MOD:
1262 if (epi) {
1263 epds.events |= POLLERR | POLLHUP;
1264 error = ep_modify(ep, epi, &epds);
1265 } else
1266 error = -ENOENT;
1267 break;
1268 }
1572 /* 1269 /*
1573 * Mark the inode dirty from the very beginning, 1270 * The function ep_find() increments the usage count of the structure
1574 * that way it will never be moved to the dirty 1271 * so, if this is not NULL, we need to release it.
1575 * list because mark_inode_dirty() will think
1576 * that it already _is_ on the dirty list.
1577 */ 1272 */
1578 inode->i_state = I_DIRTY; 1273 if (epi)
1579 inode->i_mode = S_IRUSR | S_IWUSR; 1274 ep_release_epitem(epi);
1580 inode->i_uid = current->fsuid; 1275 up_write(&ep->sem);
1581 inode->i_gid = current->fsgid; 1276
1582 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 1277error_tgt_fput:
1583 return inode; 1278 fput(tfile);
1584 1279error_fput:
1585eexit_1: 1280 fput(file);
1586 return ERR_PTR(error); 1281error_return:
1282 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_ctl(%d, %d, %d, %p) = %d\n",
1283 current, epfd, op, fd, event, error));
1284
1285 return error;
1587} 1286}
1588 1287
1589static int 1288/*
1590eventpollfs_get_sb(struct file_system_type *fs_type, int flags, 1289 * Implement the event wait interface for the eventpoll file. It is the kernel
1591 const char *dev_name, void *data, struct vfsmount *mnt) 1290 * part of the user space epoll_wait(2).
1291 */
1292asmlinkage long sys_epoll_wait(int epfd, struct epoll_event __user *events,
1293 int maxevents, int timeout)
1592{ 1294{
1593 return get_sb_pseudo(fs_type, "eventpoll:", NULL, EVENTPOLLFS_MAGIC, 1295 int error;
1594 mnt); 1296 struct file *file;
1297 struct eventpoll *ep;
1298
1299 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_wait(%d, %p, %d, %d)\n",
1300 current, epfd, events, maxevents, timeout));
1301
1302 /* The maximum number of event must be greater than zero */
1303 if (maxevents <= 0 || maxevents > EP_MAX_EVENTS)
1304 return -EINVAL;
1305
1306 /* Verify that the area passed by the user is writeable */
1307 if (!access_ok(VERIFY_WRITE, events, maxevents * sizeof(struct epoll_event))) {
1308 error = -EFAULT;
1309 goto error_return;
1310 }
1311
1312 /* Get the "struct file *" for the eventpoll file */
1313 error = -EBADF;
1314 file = fget(epfd);
1315 if (!file)
1316 goto error_return;
1317
1318 /*
1319 * We have to check that the file structure underneath the fd
1320 * the user passed to us _is_ an eventpoll file.
1321 */
1322 error = -EINVAL;
1323 if (!is_file_epoll(file))
1324 goto error_fput;
1325
1326 /*
1327 * At this point it is safe to assume that the "private_data" contains
1328 * our own data structure.
1329 */
1330 ep = file->private_data;
1331
1332 /* Time to fish for events ... */
1333 error = ep_poll(ep, events, maxevents, timeout);
1334
1335error_fput:
1336 fput(file);
1337error_return:
1338 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: sys_epoll_wait(%d, %p, %d, %d) = %d\n",
1339 current, epfd, events, maxevents, timeout, error));
1340
1341 return error;
1595} 1342}
1596 1343
1344#ifdef TIF_RESTORE_SIGMASK
1597 1345
1598static int __init eventpoll_init(void) 1346/*
1347 * Implement the event wait interface for the eventpoll file. It is the kernel
1348 * part of the user space epoll_pwait(2).
1349 */
1350asmlinkage long sys_epoll_pwait(int epfd, struct epoll_event __user *events,
1351 int maxevents, int timeout, const sigset_t __user *sigmask,
1352 size_t sigsetsize)
1599{ 1353{
1600 int error; 1354 int error;
1355 sigset_t ksigmask, sigsaved;
1356
1357 /*
1358 * If the caller wants a certain signal mask to be set during the wait,
1359 * we apply it here.
1360 */
1361 if (sigmask) {
1362 if (sigsetsize != sizeof(sigset_t))
1363 return -EINVAL;
1364 if (copy_from_user(&ksigmask, sigmask, sizeof(ksigmask)))
1365 return -EFAULT;
1366 sigdelsetmask(&ksigmask, sigmask(SIGKILL) | sigmask(SIGSTOP));
1367 sigprocmask(SIG_SETMASK, &ksigmask, &sigsaved);
1368 }
1369
1370 error = sys_epoll_wait(epfd, events, maxevents, timeout);
1371
1372 /*
1373 * If we changed the signal mask, we need to restore the original one.
1374 * In case we've got a signal while waiting, we do not restore the
1375 * signal mask yet, and we allow do_signal() to deliver the signal on
1376 * the way back to userspace, before the signal mask is restored.
1377 */
1378 if (sigmask) {
1379 if (error == -EINTR) {
1380 memcpy(&current->saved_sigmask, &sigsaved,
1381 sizeof(sigsaved));
1382 set_thread_flag(TIF_RESTORE_SIGMASK);
1383 } else
1384 sigprocmask(SIG_SETMASK, &sigsaved, NULL);
1385 }
1386
1387 return error;
1388}
1601 1389
1390#endif /* #ifdef TIF_RESTORE_SIGMASK */
1391
1392static int __init eventpoll_init(void)
1393{
1602 mutex_init(&epmutex); 1394 mutex_init(&epmutex);
1603 1395
1604 /* Initialize the structure used to perform safe poll wait head wake ups */ 1396 /* Initialize the structure used to perform safe poll wait head wake ups */
@@ -1614,39 +1406,7 @@ static int __init eventpoll_init(void)
1614 sizeof(struct eppoll_entry), 0, 1406 sizeof(struct eppoll_entry), 0,
1615 EPI_SLAB_DEBUG|SLAB_PANIC, NULL, NULL); 1407 EPI_SLAB_DEBUG|SLAB_PANIC, NULL, NULL);
1616 1408
1617 /*
1618 * Register the virtual file system that will be the source of inodes
1619 * for the eventpoll files
1620 */
1621 error = register_filesystem(&eventpoll_fs_type);
1622 if (error)
1623 goto epanic;
1624
1625 /* Mount the above commented virtual file system */
1626 eventpoll_mnt = kern_mount(&eventpoll_fs_type);
1627 error = PTR_ERR(eventpoll_mnt);
1628 if (IS_ERR(eventpoll_mnt))
1629 goto epanic;
1630
1631 DNPRINTK(3, (KERN_INFO "[%p] eventpoll: successfully initialized.\n",
1632 current));
1633 return 0; 1409 return 0;
1634
1635epanic:
1636 panic("eventpoll_init() failed\n");
1637} 1410}
1411fs_initcall(eventpoll_init);
1638 1412
1639
1640static void __exit eventpoll_exit(void)
1641{
1642 /* Undo all operations done inside eventpoll_init() */
1643 unregister_filesystem(&eventpoll_fs_type);
1644 mntput(eventpoll_mnt);
1645 kmem_cache_destroy(pwq_cache);
1646 kmem_cache_destroy(epi_cache);
1647}
1648
1649module_init(eventpoll_init);
1650module_exit(eventpoll_exit);
1651
1652MODULE_LICENSE("GPL");
diff --git a/fs/exec.c b/fs/exec.c
index 1ba85c7fc6af..70fa36554c14 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -50,6 +50,7 @@
50#include <linux/tsacct_kern.h> 50#include <linux/tsacct_kern.h>
51#include <linux/cn_proc.h> 51#include <linux/cn_proc.h>
52#include <linux/audit.h> 52#include <linux/audit.h>
53#include <linux/signalfd.h>
53 54
54#include <asm/uaccess.h> 55#include <asm/uaccess.h>
55#include <asm/mmu_context.h> 56#include <asm/mmu_context.h>
@@ -582,6 +583,13 @@ static int de_thread(struct task_struct *tsk)
582 int count; 583 int count;
583 584
584 /* 585 /*
586 * Tell all the sighand listeners that this sighand has
587 * been detached. The signalfd_detach() function grabs the
588 * sighand lock, if signal listeners are present on the sighand.
589 */
590 signalfd_detach(tsk);
591
592 /*
585 * If we don't share sighandlers, then we aren't sharing anything 593 * If we don't share sighandlers, then we aren't sharing anything
586 * and we can just re-use it all. 594 * and we can just re-use it all.
587 */ 595 */
@@ -702,7 +710,7 @@ static int de_thread(struct task_struct *tsk)
702 */ 710 */
703 detach_pid(tsk, PIDTYPE_PID); 711 detach_pid(tsk, PIDTYPE_PID);
704 tsk->pid = leader->pid; 712 tsk->pid = leader->pid;
705 attach_pid(tsk, PIDTYPE_PID, tsk->pid); 713 attach_pid(tsk, PIDTYPE_PID, find_pid(tsk->pid));
706 transfer_pid(leader, tsk, PIDTYPE_PGID); 714 transfer_pid(leader, tsk, PIDTYPE_PGID);
707 transfer_pid(leader, tsk, PIDTYPE_SID); 715 transfer_pid(leader, tsk, PIDTYPE_SID);
708 list_replace_rcu(&leader->tasks, &tsk->tasks); 716 list_replace_rcu(&leader->tasks, &tsk->tasks);
@@ -757,8 +765,7 @@ no_thread_group:
757 spin_unlock(&oldsighand->siglock); 765 spin_unlock(&oldsighand->siglock);
758 write_unlock_irq(&tasklist_lock); 766 write_unlock_irq(&tasklist_lock);
759 767
760 if (atomic_dec_and_test(&oldsighand->count)) 768 __cleanup_sighand(oldsighand);
761 kmem_cache_free(sighand_cachep, oldsighand);
762 } 769 }
763 770
764 BUG_ON(!thread_group_leader(tsk)); 771 BUG_ON(!thread_group_leader(tsk));
@@ -1488,6 +1495,8 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
1488 int flag = 0; 1495 int flag = 0;
1489 int ispipe = 0; 1496 int ispipe = 0;
1490 1497
1498 audit_core_dumps(signr);
1499
1491 binfmt = current->binfmt; 1500 binfmt = current->binfmt;
1492 if (!binfmt || !binfmt->core_dump) 1501 if (!binfmt || !binfmt->core_dump)
1493 goto fail; 1502 goto fail;
diff --git a/fs/mpage.c b/fs/mpage.c
index 0fb914fc2ee0..c1698f2291aa 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -454,11 +454,18 @@ EXPORT_SYMBOL(mpage_readpage);
454 * written, so it can intelligently allocate a suitably-sized BIO. For now, 454 * written, so it can intelligently allocate a suitably-sized BIO. For now,
455 * just allocate full-size (16-page) BIOs. 455 * just allocate full-size (16-page) BIOs.
456 */ 456 */
457static struct bio * 457struct mpage_data {
458__mpage_writepage(struct bio *bio, struct page *page, get_block_t get_block, 458 struct bio *bio;
459 sector_t *last_block_in_bio, int *ret, struct writeback_control *wbc, 459 sector_t last_block_in_bio;
460 writepage_t writepage_fn) 460 get_block_t *get_block;
461 unsigned use_writepage;
462};
463
464static int __mpage_writepage(struct page *page, struct writeback_control *wbc,
465 void *data)
461{ 466{
467 struct mpage_data *mpd = data;
468 struct bio *bio = mpd->bio;
462 struct address_space *mapping = page->mapping; 469 struct address_space *mapping = page->mapping;
463 struct inode *inode = page->mapping->host; 470 struct inode *inode = page->mapping->host;
464 const unsigned blkbits = inode->i_blkbits; 471 const unsigned blkbits = inode->i_blkbits;
@@ -476,6 +483,7 @@ __mpage_writepage(struct bio *bio, struct page *page, get_block_t get_block,
476 int length; 483 int length;
477 struct buffer_head map_bh; 484 struct buffer_head map_bh;
478 loff_t i_size = i_size_read(inode); 485 loff_t i_size = i_size_read(inode);
486 int ret = 0;
479 487
480 if (page_has_buffers(page)) { 488 if (page_has_buffers(page)) {
481 struct buffer_head *head = page_buffers(page); 489 struct buffer_head *head = page_buffers(page);
@@ -538,7 +546,7 @@ __mpage_writepage(struct bio *bio, struct page *page, get_block_t get_block,
538 546
539 map_bh.b_state = 0; 547 map_bh.b_state = 0;
540 map_bh.b_size = 1 << blkbits; 548 map_bh.b_size = 1 << blkbits;
541 if (get_block(inode, block_in_file, &map_bh, 1)) 549 if (mpd->get_block(inode, block_in_file, &map_bh, 1))
542 goto confused; 550 goto confused;
543 if (buffer_new(&map_bh)) 551 if (buffer_new(&map_bh))
544 unmap_underlying_metadata(map_bh.b_bdev, 552 unmap_underlying_metadata(map_bh.b_bdev,
@@ -584,7 +592,7 @@ page_is_mapped:
584 /* 592 /*
585 * This page will go to BIO. Do we need to send this BIO off first? 593 * This page will go to BIO. Do we need to send this BIO off first?
586 */ 594 */
587 if (bio && *last_block_in_bio != blocks[0] - 1) 595 if (bio && mpd->last_block_in_bio != blocks[0] - 1)
588 bio = mpage_bio_submit(WRITE, bio); 596 bio = mpage_bio_submit(WRITE, bio);
589 597
590alloc_new: 598alloc_new:
@@ -641,7 +649,7 @@ alloc_new:
641 boundary_block, 1 << blkbits); 649 boundary_block, 1 << blkbits);
642 } 650 }
643 } else { 651 } else {
644 *last_block_in_bio = blocks[blocks_per_page - 1]; 652 mpd->last_block_in_bio = blocks[blocks_per_page - 1];
645 } 653 }
646 goto out; 654 goto out;
647 655
@@ -649,18 +657,19 @@ confused:
649 if (bio) 657 if (bio)
650 bio = mpage_bio_submit(WRITE, bio); 658 bio = mpage_bio_submit(WRITE, bio);
651 659
652 if (writepage_fn) { 660 if (mpd->use_writepage) {
653 *ret = (*writepage_fn)(page, wbc); 661 ret = mapping->a_ops->writepage(page, wbc);
654 } else { 662 } else {
655 *ret = -EAGAIN; 663 ret = -EAGAIN;
656 goto out; 664 goto out;
657 } 665 }
658 /* 666 /*
659 * The caller has a ref on the inode, so *mapping is stable 667 * The caller has a ref on the inode, so *mapping is stable
660 */ 668 */
661 mapping_set_error(mapping, *ret); 669 mapping_set_error(mapping, ret);
662out: 670out:
663 return bio; 671 mpd->bio = bio;
672 return ret;
664} 673}
665 674
666/** 675/**
@@ -683,120 +692,27 @@ out:
683 * the call was made get new I/O started against them. If wbc->sync_mode is 692 * the call was made get new I/O started against them. If wbc->sync_mode is
684 * WB_SYNC_ALL then we were called for data integrity and we must wait for 693 * WB_SYNC_ALL then we were called for data integrity and we must wait for
685 * existing IO to complete. 694 * existing IO to complete.
686 *
687 * If you fix this you should check generic_writepages() also!
688 */ 695 */
689int 696int
690mpage_writepages(struct address_space *mapping, 697mpage_writepages(struct address_space *mapping,
691 struct writeback_control *wbc, get_block_t get_block) 698 struct writeback_control *wbc, get_block_t get_block)
692{ 699{
693 struct backing_dev_info *bdi = mapping->backing_dev_info; 700 int ret;
694 struct bio *bio = NULL; 701
695 sector_t last_block_in_bio = 0; 702 if (!get_block)
696 int ret = 0; 703 ret = generic_writepages(mapping, wbc);
697 int done = 0; 704 else {
698 int (*writepage)(struct page *page, struct writeback_control *wbc); 705 struct mpage_data mpd = {
699 struct pagevec pvec; 706 .bio = NULL,
700 int nr_pages; 707 .last_block_in_bio = 0,
701 pgoff_t index; 708 .get_block = get_block,
702 pgoff_t end; /* Inclusive */ 709 .use_writepage = 1,
703 int scanned = 0; 710 };
704 int range_whole = 0; 711
705 712 ret = write_cache_pages(mapping, wbc, __mpage_writepage, &mpd);
706 if (wbc->nonblocking && bdi_write_congested(bdi)) { 713 if (mpd.bio)
707 wbc->encountered_congestion = 1; 714 mpage_bio_submit(WRITE, mpd.bio);
708 return 0;
709 }
710
711 writepage = NULL;
712 if (get_block == NULL)
713 writepage = mapping->a_ops->writepage;
714
715 pagevec_init(&pvec, 0);
716 if (wbc->range_cyclic) {
717 index = mapping->writeback_index; /* Start from prev offset */
718 end = -1;
719 } else {
720 index = wbc->range_start >> PAGE_CACHE_SHIFT;
721 end = wbc->range_end >> PAGE_CACHE_SHIFT;
722 if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
723 range_whole = 1;
724 scanned = 1;
725 } 715 }
726retry:
727 while (!done && (index <= end) &&
728 (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,
729 PAGECACHE_TAG_DIRTY,
730 min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1))) {
731 unsigned i;
732
733 scanned = 1;
734 for (i = 0; i < nr_pages; i++) {
735 struct page *page = pvec.pages[i];
736
737 /*
738 * At this point we hold neither mapping->tree_lock nor
739 * lock on the page itself: the page may be truncated or
740 * invalidated (changing page->mapping to NULL), or even
741 * swizzled back from swapper_space to tmpfs file
742 * mapping
743 */
744
745 lock_page(page);
746
747 if (unlikely(page->mapping != mapping)) {
748 unlock_page(page);
749 continue;
750 }
751
752 if (!wbc->range_cyclic && page->index > end) {
753 done = 1;
754 unlock_page(page);
755 continue;
756 }
757
758 if (wbc->sync_mode != WB_SYNC_NONE)
759 wait_on_page_writeback(page);
760
761 if (PageWriteback(page) ||
762 !clear_page_dirty_for_io(page)) {
763 unlock_page(page);
764 continue;
765 }
766
767 if (writepage) {
768 ret = (*writepage)(page, wbc);
769 mapping_set_error(mapping, ret);
770 } else {
771 bio = __mpage_writepage(bio, page, get_block,
772 &last_block_in_bio, &ret, wbc,
773 page->mapping->a_ops->writepage);
774 }
775 if (unlikely(ret == AOP_WRITEPAGE_ACTIVATE))
776 unlock_page(page);
777 if (ret || (--(wbc->nr_to_write) <= 0))
778 done = 1;
779 if (wbc->nonblocking && bdi_write_congested(bdi)) {
780 wbc->encountered_congestion = 1;
781 done = 1;
782 }
783 }
784 pagevec_release(&pvec);
785 cond_resched();
786 }
787 if (!scanned && !done) {
788 /*
789 * We hit the last page and there is more work to be done: wrap
790 * back to the start of the file
791 */
792 scanned = 1;
793 index = 0;
794 goto retry;
795 }
796 if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
797 mapping->writeback_index = index;
798 if (bio)
799 mpage_bio_submit(WRITE, bio);
800 return ret; 716 return ret;
801} 717}
802EXPORT_SYMBOL(mpage_writepages); 718EXPORT_SYMBOL(mpage_writepages);
@@ -804,15 +720,15 @@ EXPORT_SYMBOL(mpage_writepages);
804int mpage_writepage(struct page *page, get_block_t get_block, 720int mpage_writepage(struct page *page, get_block_t get_block,
805 struct writeback_control *wbc) 721 struct writeback_control *wbc)
806{ 722{
807 int ret = 0; 723 struct mpage_data mpd = {
808 struct bio *bio; 724 .bio = NULL,
809 sector_t last_block_in_bio = 0; 725 .last_block_in_bio = 0,
810 726 .get_block = get_block,
811 bio = __mpage_writepage(NULL, page, get_block, 727 .use_writepage = 0,
812 &last_block_in_bio, &ret, wbc, NULL); 728 };
813 if (bio) 729 int ret = __mpage_writepage(page, wbc, &mpd);
814 mpage_bio_submit(WRITE, bio); 730 if (mpd.bio)
815 731 mpage_bio_submit(WRITE, mpd.bio);
816 return ret; 732 return ret;
817} 733}
818EXPORT_SYMBOL(mpage_writepage); 734EXPORT_SYMBOL(mpage_writepage);
diff --git a/fs/namei.c b/fs/namei.c
index b3780e3fc88e..5e2d98d10c5d 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1719,7 +1719,7 @@ do_last:
1719 * It already exists. 1719 * It already exists.
1720 */ 1720 */
1721 mutex_unlock(&dir->d_inode->i_mutex); 1721 mutex_unlock(&dir->d_inode->i_mutex);
1722 audit_inode_update(path.dentry->d_inode); 1722 audit_inode(pathname, path.dentry->d_inode);
1723 1723
1724 error = -EEXIST; 1724 error = -EEXIST;
1725 if (flag & O_EXCL) 1725 if (flag & O_EXCL)
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c
index 629e7abdd840..6e5c2534f4bc 100644
--- a/fs/ntfs/aops.c
+++ b/fs/ntfs/aops.c
@@ -86,19 +86,15 @@ static void ntfs_end_buffer_async_read(struct buffer_head *bh, int uptodate)
86 } 86 }
87 /* Check for the current buffer head overflowing. */ 87 /* Check for the current buffer head overflowing. */
88 if (unlikely(file_ofs + bh->b_size > init_size)) { 88 if (unlikely(file_ofs + bh->b_size > init_size)) {
89 u8 *kaddr;
90 int ofs; 89 int ofs;
91 90
92 ofs = 0; 91 ofs = 0;
93 if (file_ofs < init_size) 92 if (file_ofs < init_size)
94 ofs = init_size - file_ofs; 93 ofs = init_size - file_ofs;
95 local_irq_save(flags); 94 local_irq_save(flags);
96 kaddr = kmap_atomic(page, KM_BIO_SRC_IRQ); 95 zero_user_page(page, bh_offset(bh) + ofs,
97 memset(kaddr + bh_offset(bh) + ofs, 0, 96 bh->b_size - ofs, KM_BIO_SRC_IRQ);
98 bh->b_size - ofs);
99 kunmap_atomic(kaddr, KM_BIO_SRC_IRQ);
100 local_irq_restore(flags); 97 local_irq_restore(flags);
101 flush_dcache_page(page);
102 } 98 }
103 } else { 99 } else {
104 clear_buffer_uptodate(bh); 100 clear_buffer_uptodate(bh);
@@ -245,8 +241,7 @@ static int ntfs_read_block(struct page *page)
245 rl = NULL; 241 rl = NULL;
246 nr = i = 0; 242 nr = i = 0;
247 do { 243 do {
248 u8 *kaddr; 244 int err = 0;
249 int err;
250 245
251 if (unlikely(buffer_uptodate(bh))) 246 if (unlikely(buffer_uptodate(bh)))
252 continue; 247 continue;
@@ -254,7 +249,6 @@ static int ntfs_read_block(struct page *page)
254 arr[nr++] = bh; 249 arr[nr++] = bh;
255 continue; 250 continue;
256 } 251 }
257 err = 0;
258 bh->b_bdev = vol->sb->s_bdev; 252 bh->b_bdev = vol->sb->s_bdev;
259 /* Is the block within the allowed limits? */ 253 /* Is the block within the allowed limits? */
260 if (iblock < lblock) { 254 if (iblock < lblock) {
@@ -340,10 +334,7 @@ handle_hole:
340 bh->b_blocknr = -1UL; 334 bh->b_blocknr = -1UL;
341 clear_buffer_mapped(bh); 335 clear_buffer_mapped(bh);
342handle_zblock: 336handle_zblock:
343 kaddr = kmap_atomic(page, KM_USER0); 337 zero_user_page(page, i * blocksize, blocksize, KM_USER0);
344 memset(kaddr + i * blocksize, 0, blocksize);
345 kunmap_atomic(kaddr, KM_USER0);
346 flush_dcache_page(page);
347 if (likely(!err)) 338 if (likely(!err))
348 set_buffer_uptodate(bh); 339 set_buffer_uptodate(bh);
349 } while (i++, iblock++, (bh = bh->b_this_page) != head); 340 } while (i++, iblock++, (bh = bh->b_this_page) != head);
@@ -460,10 +451,7 @@ retry_readpage:
460 * ok to ignore the compressed flag here. 451 * ok to ignore the compressed flag here.
461 */ 452 */
462 if (unlikely(page->index > 0)) { 453 if (unlikely(page->index > 0)) {
463 kaddr = kmap_atomic(page, KM_USER0); 454 zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0);
464 memset(kaddr, 0, PAGE_CACHE_SIZE);
465 flush_dcache_page(page);
466 kunmap_atomic(kaddr, KM_USER0);
467 goto done; 455 goto done;
468 } 456 }
469 if (!NInoAttr(ni)) 457 if (!NInoAttr(ni))
@@ -790,14 +778,10 @@ lock_retry_remap:
790 * uptodate so it can get discarded by the VM. 778 * uptodate so it can get discarded by the VM.
791 */ 779 */
792 if (err == -ENOENT || lcn == LCN_ENOENT) { 780 if (err == -ENOENT || lcn == LCN_ENOENT) {
793 u8 *kaddr;
794
795 bh->b_blocknr = -1; 781 bh->b_blocknr = -1;
796 clear_buffer_dirty(bh); 782 clear_buffer_dirty(bh);
797 kaddr = kmap_atomic(page, KM_USER0); 783 zero_user_page(page, bh_offset(bh), blocksize,
798 memset(kaddr + bh_offset(bh), 0, blocksize); 784 KM_USER0);
799 kunmap_atomic(kaddr, KM_USER0);
800 flush_dcache_page(page);
801 set_buffer_uptodate(bh); 785 set_buffer_uptodate(bh);
802 err = 0; 786 err = 0;
803 continue; 787 continue;
@@ -1422,10 +1406,8 @@ retry_writepage:
1422 if (page->index >= (i_size >> PAGE_CACHE_SHIFT)) { 1406 if (page->index >= (i_size >> PAGE_CACHE_SHIFT)) {
1423 /* The page straddles i_size. */ 1407 /* The page straddles i_size. */
1424 unsigned int ofs = i_size & ~PAGE_CACHE_MASK; 1408 unsigned int ofs = i_size & ~PAGE_CACHE_MASK;
1425 kaddr = kmap_atomic(page, KM_USER0); 1409 zero_user_page(page, ofs, PAGE_CACHE_SIZE - ofs,
1426 memset(kaddr + ofs, 0, PAGE_CACHE_SIZE - ofs); 1410 KM_USER0);
1427 kunmap_atomic(kaddr, KM_USER0);
1428 flush_dcache_page(page);
1429 } 1411 }
1430 /* Handle mst protected attributes. */ 1412 /* Handle mst protected attributes. */
1431 if (NInoMstProtected(ni)) 1413 if (NInoMstProtected(ni))
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 621de369e6f8..39a1669506bd 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -606,11 +606,8 @@ do_next_page:
606 ntfs_submit_bh_for_read(bh); 606 ntfs_submit_bh_for_read(bh);
607 *wait_bh++ = bh; 607 *wait_bh++ = bh;
608 } else { 608 } else {
609 u8 *kaddr = kmap_atomic(page, KM_USER0); 609 zero_user_page(page, bh_offset(bh),
610 memset(kaddr + bh_offset(bh), 0, 610 blocksize, KM_USER0);
611 blocksize);
612 kunmap_atomic(kaddr, KM_USER0);
613 flush_dcache_page(page);
614 set_buffer_uptodate(bh); 611 set_buffer_uptodate(bh);
615 } 612 }
616 } 613 }
@@ -685,12 +682,9 @@ map_buffer_cached:
685 ntfs_submit_bh_for_read(bh); 682 ntfs_submit_bh_for_read(bh);
686 *wait_bh++ = bh; 683 *wait_bh++ = bh;
687 } else { 684 } else {
688 u8 *kaddr = kmap_atomic(page, 685 zero_user_page(page,
689 KM_USER0); 686 bh_offset(bh),
690 memset(kaddr + bh_offset(bh), 687 blocksize, KM_USER0);
691 0, blocksize);
692 kunmap_atomic(kaddr, KM_USER0);
693 flush_dcache_page(page);
694 set_buffer_uptodate(bh); 688 set_buffer_uptodate(bh);
695 } 689 }
696 } 690 }
@@ -708,11 +702,8 @@ map_buffer_cached:
708 */ 702 */
709 if (bh_end <= pos || bh_pos >= end) { 703 if (bh_end <= pos || bh_pos >= end) {
710 if (!buffer_uptodate(bh)) { 704 if (!buffer_uptodate(bh)) {
711 u8 *kaddr = kmap_atomic(page, KM_USER0); 705 zero_user_page(page, bh_offset(bh),
712 memset(kaddr + bh_offset(bh), 0, 706 blocksize, KM_USER0);
713 blocksize);
714 kunmap_atomic(kaddr, KM_USER0);
715 flush_dcache_page(page);
716 set_buffer_uptodate(bh); 707 set_buffer_uptodate(bh);
717 } 708 }
718 mark_buffer_dirty(bh); 709 mark_buffer_dirty(bh);
@@ -751,10 +742,8 @@ map_buffer_cached:
751 if (!buffer_uptodate(bh)) 742 if (!buffer_uptodate(bh))
752 set_buffer_uptodate(bh); 743 set_buffer_uptodate(bh);
753 } else if (!buffer_uptodate(bh)) { 744 } else if (!buffer_uptodate(bh)) {
754 u8 *kaddr = kmap_atomic(page, KM_USER0); 745 zero_user_page(page, bh_offset(bh), blocksize,
755 memset(kaddr + bh_offset(bh), 0, blocksize); 746 KM_USER0);
756 kunmap_atomic(kaddr, KM_USER0);
757 flush_dcache_page(page);
758 set_buffer_uptodate(bh); 747 set_buffer_uptodate(bh);
759 } 748 }
760 continue; 749 continue;
@@ -878,11 +867,8 @@ rl_not_mapped_enoent:
878 if (!buffer_uptodate(bh)) 867 if (!buffer_uptodate(bh))
879 set_buffer_uptodate(bh); 868 set_buffer_uptodate(bh);
880 } else if (!buffer_uptodate(bh)) { 869 } else if (!buffer_uptodate(bh)) {
881 u8 *kaddr = kmap_atomic(page, KM_USER0); 870 zero_user_page(page, bh_offset(bh),
882 memset(kaddr + bh_offset(bh), 0, 871 blocksize, KM_USER0);
883 blocksize);
884 kunmap_atomic(kaddr, KM_USER0);
885 flush_dcache_page(page);
886 set_buffer_uptodate(bh); 872 set_buffer_uptodate(bh);
887 } 873 }
888 continue; 874 continue;
@@ -1137,16 +1123,12 @@ rl_not_mapped_enoent:
1137 * to zero the overflowing region. 1123 * to zero the overflowing region.
1138 */ 1124 */
1139 if (unlikely(bh_pos + blocksize > initialized_size)) { 1125 if (unlikely(bh_pos + blocksize > initialized_size)) {
1140 u8 *kaddr;
1141 int ofs = 0; 1126 int ofs = 0;
1142 1127
1143 if (likely(bh_pos < initialized_size)) 1128 if (likely(bh_pos < initialized_size))
1144 ofs = initialized_size - bh_pos; 1129 ofs = initialized_size - bh_pos;
1145 kaddr = kmap_atomic(page, KM_USER0); 1130 zero_user_page(page, bh_offset(bh) + ofs,
1146 memset(kaddr + bh_offset(bh) + ofs, 0, 1131 blocksize - ofs, KM_USER0);
1147 blocksize - ofs);
1148 kunmap_atomic(kaddr, KM_USER0);
1149 flush_dcache_page(page);
1150 } 1132 }
1151 } else /* if (unlikely(!buffer_uptodate(bh))) */ 1133 } else /* if (unlikely(!buffer_uptodate(bh))) */
1152 err = -EIO; 1134 err = -EIO;
@@ -1286,11 +1268,8 @@ rl_not_mapped_enoent:
1286 if (PageUptodate(page)) 1268 if (PageUptodate(page))
1287 set_buffer_uptodate(bh); 1269 set_buffer_uptodate(bh);
1288 else { 1270 else {
1289 u8 *kaddr = kmap_atomic(page, KM_USER0); 1271 zero_user_page(page, bh_offset(bh),
1290 memset(kaddr + bh_offset(bh), 0, 1272 blocksize, KM_USER0);
1291 blocksize);
1292 kunmap_atomic(kaddr, KM_USER0);
1293 flush_dcache_page(page);
1294 set_buffer_uptodate(bh); 1273 set_buffer_uptodate(bh);
1295 } 1274 }
1296 } 1275 }
@@ -1350,9 +1329,7 @@ err_out:
1350 len = PAGE_CACHE_SIZE; 1329 len = PAGE_CACHE_SIZE;
1351 if (len > bytes) 1330 if (len > bytes)
1352 len = bytes; 1331 len = bytes;
1353 kaddr = kmap_atomic(*pages, KM_USER0); 1332 zero_user_page(*pages, 0, len, KM_USER0);
1354 memset(kaddr, 0, len);
1355 kunmap_atomic(kaddr, KM_USER0);
1356 } 1333 }
1357 goto out; 1334 goto out;
1358} 1335}
@@ -1473,9 +1450,7 @@ err_out:
1473 len = PAGE_CACHE_SIZE; 1450 len = PAGE_CACHE_SIZE;
1474 if (len > bytes) 1451 if (len > bytes)
1475 len = bytes; 1452 len = bytes;
1476 kaddr = kmap_atomic(*pages, KM_USER0); 1453 zero_user_page(*pages, 0, len, KM_USER0);
1477 memset(kaddr, 0, len);
1478 kunmap_atomic(kaddr, KM_USER0);
1479 } 1454 }
1480 goto out; 1455 goto out;
1481} 1456}
diff --git a/fs/partitions/Kconfig b/fs/partitions/Kconfig
index 01207042048b..7638a1c42a7d 100644
--- a/fs/partitions/Kconfig
+++ b/fs/partitions/Kconfig
@@ -239,7 +239,7 @@ config EFI_PARTITION
239 239
240config SYSV68_PARTITION 240config SYSV68_PARTITION
241 bool "SYSV68 partition table support" if PARTITION_ADVANCED 241 bool "SYSV68 partition table support" if PARTITION_ADVANCED
242 default y if M68K 242 default y if VME
243 help 243 help
244 Say Y here if you would like to be able to read the hard disk 244 Say Y here if you would like to be able to read the hard disk
245 partition table format used by Motorola Delta machines (using 245 partition table format used by Motorola Delta machines (using
diff --git a/fs/partitions/efi.c b/fs/partitions/efi.c
index 1bea610078b3..e7b07006bc41 100644
--- a/fs/partitions/efi.c
+++ b/fs/partitions/efi.c
@@ -152,7 +152,7 @@ last_lba(struct block_device *bdev)
152} 152}
153 153
154static inline int 154static inline int
155pmbr_part_valid(struct partition *part, u64 lastlba) 155pmbr_part_valid(struct partition *part)
156{ 156{
157 if (part->sys_ind == EFI_PMBR_OSTYPE_EFI_GPT && 157 if (part->sys_ind == EFI_PMBR_OSTYPE_EFI_GPT &&
158 le32_to_cpu(part->start_sect) == 1UL) 158 le32_to_cpu(part->start_sect) == 1UL)
@@ -163,7 +163,6 @@ pmbr_part_valid(struct partition *part, u64 lastlba)
163/** 163/**
164 * is_pmbr_valid(): test Protective MBR for validity 164 * is_pmbr_valid(): test Protective MBR for validity
165 * @mbr: pointer to a legacy mbr structure 165 * @mbr: pointer to a legacy mbr structure
166 * @lastlba: last_lba for the whole device
167 * 166 *
168 * Description: Returns 1 if PMBR is valid, 0 otherwise. 167 * Description: Returns 1 if PMBR is valid, 0 otherwise.
169 * Validity depends on two things: 168 * Validity depends on two things:
@@ -171,13 +170,13 @@ pmbr_part_valid(struct partition *part, u64 lastlba)
171 * 2) One partition of type 0xEE is found 170 * 2) One partition of type 0xEE is found
172 */ 171 */
173static int 172static int
174is_pmbr_valid(legacy_mbr *mbr, u64 lastlba) 173is_pmbr_valid(legacy_mbr *mbr)
175{ 174{
176 int i; 175 int i;
177 if (!mbr || le16_to_cpu(mbr->signature) != MSDOS_MBR_SIGNATURE) 176 if (!mbr || le16_to_cpu(mbr->signature) != MSDOS_MBR_SIGNATURE)
178 return 0; 177 return 0;
179 for (i = 0; i < 4; i++) 178 for (i = 0; i < 4; i++)
180 if (pmbr_part_valid(&mbr->partition_record[i], lastlba)) 179 if (pmbr_part_valid(&mbr->partition_record[i]))
181 return 1; 180 return 1;
182 return 0; 181 return 0;
183} 182}
@@ -516,7 +515,7 @@ find_valid_gpt(struct block_device *bdev, gpt_header **gpt, gpt_entry **ptes)
516 int good_pgpt = 0, good_agpt = 0, good_pmbr = 0; 515 int good_pgpt = 0, good_agpt = 0, good_pmbr = 0;
517 gpt_header *pgpt = NULL, *agpt = NULL; 516 gpt_header *pgpt = NULL, *agpt = NULL;
518 gpt_entry *pptes = NULL, *aptes = NULL; 517 gpt_entry *pptes = NULL, *aptes = NULL;
519 legacy_mbr *legacymbr = NULL; 518 legacy_mbr *legacymbr;
520 u64 lastlba; 519 u64 lastlba;
521 if (!bdev || !gpt || !ptes) 520 if (!bdev || !gpt || !ptes)
522 return 0; 521 return 0;
@@ -528,9 +527,8 @@ find_valid_gpt(struct block_device *bdev, gpt_header **gpt, gpt_entry **ptes)
528 if (legacymbr) { 527 if (legacymbr) {
529 read_lba(bdev, 0, (u8 *) legacymbr, 528 read_lba(bdev, 0, (u8 *) legacymbr,
530 sizeof (*legacymbr)); 529 sizeof (*legacymbr));
531 good_pmbr = is_pmbr_valid(legacymbr, lastlba); 530 good_pmbr = is_pmbr_valid(legacymbr);
532 kfree(legacymbr); 531 kfree(legacymbr);
533 legacymbr=NULL;
534 } 532 }
535 if (!good_pmbr) 533 if (!good_pmbr)
536 goto fail; 534 goto fail;
diff --git a/fs/signalfd.c b/fs/signalfd.c
new file mode 100644
index 000000000000..7cfeab412b45
--- /dev/null
+++ b/fs/signalfd.c
@@ -0,0 +1,349 @@
1/*
2 * fs/signalfd.c
3 *
4 * Copyright (C) 2003 Linus Torvalds
5 *
6 * Mon Mar 5, 2007: Davide Libenzi <davidel@xmailserver.org>
7 * Changed ->read() to return a siginfo strcture instead of signal number.
8 * Fixed locking in ->poll().
9 * Added sighand-detach notification.
10 * Added fd re-use in sys_signalfd() syscall.
11 * Now using anonymous inode source.
12 * Thanks to Oleg Nesterov for useful code review and suggestions.
13 * More comments and suggestions from Arnd Bergmann.
14 */
15
16#include <linux/file.h>
17#include <linux/poll.h>
18#include <linux/init.h>
19#include <linux/fs.h>
20#include <linux/sched.h>
21#include <linux/kernel.h>
22#include <linux/signal.h>
23#include <linux/list.h>
24#include <linux/anon_inodes.h>
25#include <linux/signalfd.h>
26
27struct signalfd_ctx {
28 struct list_head lnk;
29 wait_queue_head_t wqh;
30 sigset_t sigmask;
31 struct task_struct *tsk;
32};
33
34struct signalfd_lockctx {
35 struct task_struct *tsk;
36 unsigned long flags;
37};
38
39/*
40 * Tries to acquire the sighand lock. We do not increment the sighand
41 * use count, and we do not even pin the task struct, so we need to
42 * do it inside an RCU read lock, and we must be prepared for the
43 * ctx->tsk going to NULL (in signalfd_deliver()), and for the sighand
44 * being detached. We return 0 if the sighand has been detached, or
45 * 1 if we were able to pin the sighand lock.
46 */
47static int signalfd_lock(struct signalfd_ctx *ctx, struct signalfd_lockctx *lk)
48{
49 struct sighand_struct *sighand = NULL;
50
51 rcu_read_lock();
52 lk->tsk = rcu_dereference(ctx->tsk);
53 if (likely(lk->tsk != NULL))
54 sighand = lock_task_sighand(lk->tsk, &lk->flags);
55 rcu_read_unlock();
56
57 if (sighand && !ctx->tsk) {
58 unlock_task_sighand(lk->tsk, &lk->flags);
59 sighand = NULL;
60 }
61
62 return sighand != NULL;
63}
64
65static void signalfd_unlock(struct signalfd_lockctx *lk)
66{
67 unlock_task_sighand(lk->tsk, &lk->flags);
68}
69
70/*
71 * This must be called with the sighand lock held.
72 */
73void signalfd_deliver(struct task_struct *tsk, int sig)
74{
75 struct sighand_struct *sighand = tsk->sighand;
76 struct signalfd_ctx *ctx, *tmp;
77
78 BUG_ON(!sig);
79 list_for_each_entry_safe(ctx, tmp, &sighand->signalfd_list, lnk) {
80 /*
81 * We use a negative signal value as a way to broadcast that the
82 * sighand has been orphaned, so that we can notify all the
83 * listeners about this. Remember the ctx->sigmask is inverted,
84 * so if the user is interested in a signal, that corresponding
85 * bit will be zero.
86 */
87 if (sig < 0) {
88 if (ctx->tsk == tsk) {
89 ctx->tsk = NULL;
90 list_del_init(&ctx->lnk);
91 wake_up(&ctx->wqh);
92 }
93 } else {
94 if (!sigismember(&ctx->sigmask, sig))
95 wake_up(&ctx->wqh);
96 }
97 }
98}
99
100static void signalfd_cleanup(struct signalfd_ctx *ctx)
101{
102 struct signalfd_lockctx lk;
103
104 /*
105 * This is tricky. If the sighand is gone, we do not need to remove
106 * context from the list, the list itself won't be there anymore.
107 */
108 if (signalfd_lock(ctx, &lk)) {
109 list_del(&ctx->lnk);
110 signalfd_unlock(&lk);
111 }
112 kfree(ctx);
113}
114
115static int signalfd_release(struct inode *inode, struct file *file)
116{
117 signalfd_cleanup(file->private_data);
118 return 0;
119}
120
121static unsigned int signalfd_poll(struct file *file, poll_table *wait)
122{
123 struct signalfd_ctx *ctx = file->private_data;
124 unsigned int events = 0;
125 struct signalfd_lockctx lk;
126
127 poll_wait(file, &ctx->wqh, wait);
128
129 /*
130 * Let the caller get a POLLIN in this case, ala socket recv() when
131 * the peer disconnects.
132 */
133 if (signalfd_lock(ctx, &lk)) {
134 if (next_signal(&lk.tsk->pending, &ctx->sigmask) > 0 ||
135 next_signal(&lk.tsk->signal->shared_pending,
136 &ctx->sigmask) > 0)
137 events |= POLLIN;
138 signalfd_unlock(&lk);
139 } else
140 events |= POLLIN;
141
142 return events;
143}
144
145/*
146 * Copied from copy_siginfo_to_user() in kernel/signal.c
147 */
148static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo,
149 siginfo_t const *kinfo)
150{
151 long err;
152
153 BUILD_BUG_ON(sizeof(struct signalfd_siginfo) != 128);
154
155 /*
156 * Unused memebers should be zero ...
157 */
158 err = __clear_user(uinfo, sizeof(*uinfo));
159
160 /*
161 * If you change siginfo_t structure, please be sure
162 * this code is fixed accordingly.
163 */
164 err |= __put_user(kinfo->si_signo, &uinfo->signo);
165 err |= __put_user(kinfo->si_errno, &uinfo->err);
166 err |= __put_user((short)kinfo->si_code, &uinfo->code);
167 switch (kinfo->si_code & __SI_MASK) {
168 case __SI_KILL:
169 err |= __put_user(kinfo->si_pid, &uinfo->pid);
170 err |= __put_user(kinfo->si_uid, &uinfo->uid);
171 break;
172 case __SI_TIMER:
173 err |= __put_user(kinfo->si_tid, &uinfo->tid);
174 err |= __put_user(kinfo->si_overrun, &uinfo->overrun);
175 err |= __put_user((long)kinfo->si_ptr, &uinfo->svptr);
176 break;
177 case __SI_POLL:
178 err |= __put_user(kinfo->si_band, &uinfo->band);
179 err |= __put_user(kinfo->si_fd, &uinfo->fd);
180 break;
181 case __SI_FAULT:
182 err |= __put_user((long)kinfo->si_addr, &uinfo->addr);
183#ifdef __ARCH_SI_TRAPNO
184 err |= __put_user(kinfo->si_trapno, &uinfo->trapno);
185#endif
186 break;
187 case __SI_CHLD:
188 err |= __put_user(kinfo->si_pid, &uinfo->pid);
189 err |= __put_user(kinfo->si_uid, &uinfo->uid);
190 err |= __put_user(kinfo->si_status, &uinfo->status);
191 err |= __put_user(kinfo->si_utime, &uinfo->utime);
192 err |= __put_user(kinfo->si_stime, &uinfo->stime);
193 break;
194 case __SI_RT: /* This is not generated by the kernel as of now. */
195 case __SI_MESGQ: /* But this is */
196 err |= __put_user(kinfo->si_pid, &uinfo->pid);
197 err |= __put_user(kinfo->si_uid, &uinfo->uid);
198 err |= __put_user((long)kinfo->si_ptr, &uinfo->svptr);
199 break;
200 default: /* this is just in case for now ... */
201 err |= __put_user(kinfo->si_pid, &uinfo->pid);
202 err |= __put_user(kinfo->si_uid, &uinfo->uid);
203 break;
204 }
205
206 return err ? -EFAULT: sizeof(*uinfo);
207}
208
209/*
210 * Returns either the size of a "struct signalfd_siginfo", or zero if the
211 * sighand we are attached to, has been orphaned. The "count" parameter
212 * must be at least the size of a "struct signalfd_siginfo".
213 */
214static ssize_t signalfd_read(struct file *file, char __user *buf, size_t count,
215 loff_t *ppos)
216{
217 struct signalfd_ctx *ctx = file->private_data;
218 ssize_t res = 0;
219 int locked, signo;
220 siginfo_t info;
221 struct signalfd_lockctx lk;
222 DECLARE_WAITQUEUE(wait, current);
223
224 if (count < sizeof(struct signalfd_siginfo))
225 return -EINVAL;
226 locked = signalfd_lock(ctx, &lk);
227 if (!locked)
228 return 0;
229 res = -EAGAIN;
230 signo = dequeue_signal(lk.tsk, &ctx->sigmask, &info);
231 if (signo == 0 && !(file->f_flags & O_NONBLOCK)) {
232 add_wait_queue(&ctx->wqh, &wait);
233 for (;;) {
234 set_current_state(TASK_INTERRUPTIBLE);
235 signo = dequeue_signal(lk.tsk, &ctx->sigmask, &info);
236 if (signo != 0)
237 break;
238 if (signal_pending(current)) {
239 res = -ERESTARTSYS;
240 break;
241 }
242 signalfd_unlock(&lk);
243 schedule();
244 locked = signalfd_lock(ctx, &lk);
245 if (unlikely(!locked)) {
246 /*
247 * Let the caller read zero byte, ala socket
248 * recv() when the peer disconnect. This test
249 * must be done before doing a dequeue_signal(),
250 * because if the sighand has been orphaned,
251 * the dequeue_signal() call is going to crash.
252 */
253 res = 0;
254 break;
255 }
256 }
257 remove_wait_queue(&ctx->wqh, &wait);
258 __set_current_state(TASK_RUNNING);
259 }
260 if (likely(locked))
261 signalfd_unlock(&lk);
262 if (likely(signo))
263 res = signalfd_copyinfo((struct signalfd_siginfo __user *) buf,
264 &info);
265
266 return res;
267}
268
269static const struct file_operations signalfd_fops = {
270 .release = signalfd_release,
271 .poll = signalfd_poll,
272 .read = signalfd_read,
273};
274
275/*
276 * Create a file descriptor that is associated with our signal
277 * state. We can pass it around to others if we want to, but
278 * it will always be _our_ signal state.
279 */
280asmlinkage long sys_signalfd(int ufd, sigset_t __user *user_mask, size_t sizemask)
281{
282 int error;
283 sigset_t sigmask;
284 struct signalfd_ctx *ctx;
285 struct sighand_struct *sighand;
286 struct file *file;
287 struct inode *inode;
288 struct signalfd_lockctx lk;
289
290 if (sizemask != sizeof(sigset_t) ||
291 copy_from_user(&sigmask, user_mask, sizeof(sigmask)))
292 return error = -EINVAL;
293 sigdelsetmask(&sigmask, sigmask(SIGKILL) | sigmask(SIGSTOP));
294 signotset(&sigmask);
295
296 if (ufd == -1) {
297 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
298 if (!ctx)
299 return -ENOMEM;
300
301 init_waitqueue_head(&ctx->wqh);
302 ctx->sigmask = sigmask;
303 ctx->tsk = current;
304
305 sighand = current->sighand;
306 /*
307 * Add this fd to the list of signal listeners.
308 */
309 spin_lock_irq(&sighand->siglock);
310 list_add_tail(&ctx->lnk, &sighand->signalfd_list);
311 spin_unlock_irq(&sighand->siglock);
312
313 /*
314 * When we call this, the initialization must be complete, since
315 * anon_inode_getfd() will install the fd.
316 */
317 error = anon_inode_getfd(&ufd, &inode, &file, "[signalfd]",
318 &signalfd_fops, ctx);
319 if (error)
320 goto err_fdalloc;
321 } else {
322 file = fget(ufd);
323 if (!file)
324 return -EBADF;
325 ctx = file->private_data;
326 if (file->f_op != &signalfd_fops) {
327 fput(file);
328 return -EINVAL;
329 }
330 /*
331 * We need to be prepared of the fact that the sighand this fd
332 * is attached to, has been detched. In that case signalfd_lock()
333 * will return 0, and we'll just skip setting the new mask.
334 */
335 if (signalfd_lock(ctx, &lk)) {
336 ctx->sigmask = sigmask;
337 signalfd_unlock(&lk);
338 }
339 wake_up(&ctx->wqh);
340 fput(file);
341 }
342
343 return ufd;
344
345err_fdalloc:
346 signalfd_cleanup(ctx);
347 return error;
348}
349
diff --git a/fs/timerfd.c b/fs/timerfd.c
new file mode 100644
index 000000000000..e329e37f15a8
--- /dev/null
+++ b/fs/timerfd.c
@@ -0,0 +1,227 @@
1/*
2 * fs/timerfd.c
3 *
4 * Copyright (C) 2007 Davide Libenzi <davidel@xmailserver.org>
5 *
6 *
7 * Thanks to Thomas Gleixner for code reviews and useful comments.
8 *
9 */
10
11#include <linux/file.h>
12#include <linux/poll.h>
13#include <linux/init.h>
14#include <linux/fs.h>
15#include <linux/sched.h>
16#include <linux/kernel.h>
17#include <linux/list.h>
18#include <linux/spinlock.h>
19#include <linux/time.h>
20#include <linux/hrtimer.h>
21#include <linux/anon_inodes.h>
22#include <linux/timerfd.h>
23
24struct timerfd_ctx {
25 struct hrtimer tmr;
26 ktime_t tintv;
27 spinlock_t lock;
28 wait_queue_head_t wqh;
29 int expired;
30};
31
32/*
33 * This gets called when the timer event triggers. We set the "expired"
34 * flag, but we do not re-arm the timer (in case it's necessary,
35 * tintv.tv64 != 0) until the timer is read.
36 */
37static enum hrtimer_restart timerfd_tmrproc(struct hrtimer *htmr)
38{
39 struct timerfd_ctx *ctx = container_of(htmr, struct timerfd_ctx, tmr);
40 unsigned long flags;
41
42 spin_lock_irqsave(&ctx->lock, flags);
43 ctx->expired = 1;
44 wake_up_locked(&ctx->wqh);
45 spin_unlock_irqrestore(&ctx->lock, flags);
46
47 return HRTIMER_NORESTART;
48}
49
50static void timerfd_setup(struct timerfd_ctx *ctx, int clockid, int flags,
51 const struct itimerspec *ktmr)
52{
53 enum hrtimer_mode htmode;
54 ktime_t texp;
55
56 htmode = (flags & TFD_TIMER_ABSTIME) ?
57 HRTIMER_MODE_ABS: HRTIMER_MODE_REL;
58
59 texp = timespec_to_ktime(ktmr->it_value);
60 ctx->expired = 0;
61 ctx->tintv = timespec_to_ktime(ktmr->it_interval);
62 hrtimer_init(&ctx->tmr, clockid, htmode);
63 ctx->tmr.expires = texp;
64 ctx->tmr.function = timerfd_tmrproc;
65 if (texp.tv64 != 0)
66 hrtimer_start(&ctx->tmr, texp, htmode);
67}
68
69static int timerfd_release(struct inode *inode, struct file *file)
70{
71 struct timerfd_ctx *ctx = file->private_data;
72
73 hrtimer_cancel(&ctx->tmr);
74 kfree(ctx);
75 return 0;
76}
77
78static unsigned int timerfd_poll(struct file *file, poll_table *wait)
79{
80 struct timerfd_ctx *ctx = file->private_data;
81 unsigned int events = 0;
82 unsigned long flags;
83
84 poll_wait(file, &ctx->wqh, wait);
85
86 spin_lock_irqsave(&ctx->lock, flags);
87 if (ctx->expired)
88 events |= POLLIN;
89 spin_unlock_irqrestore(&ctx->lock, flags);
90
91 return events;
92}
93
94static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count,
95 loff_t *ppos)
96{
97 struct timerfd_ctx *ctx = file->private_data;
98 ssize_t res;
99 u32 ticks = 0;
100 DECLARE_WAITQUEUE(wait, current);
101
102 if (count < sizeof(ticks))
103 return -EINVAL;
104 spin_lock_irq(&ctx->lock);
105 res = -EAGAIN;
106 if (!ctx->expired && !(file->f_flags & O_NONBLOCK)) {
107 __add_wait_queue(&ctx->wqh, &wait);
108 for (res = 0;;) {
109 set_current_state(TASK_INTERRUPTIBLE);
110 if (ctx->expired) {
111 res = 0;
112 break;
113 }
114 if (signal_pending(current)) {
115 res = -ERESTARTSYS;
116 break;
117 }
118 spin_unlock_irq(&ctx->lock);
119 schedule();
120 spin_lock_irq(&ctx->lock);
121 }
122 __remove_wait_queue(&ctx->wqh, &wait);
123 __set_current_state(TASK_RUNNING);
124 }
125 if (ctx->expired) {
126 ctx->expired = 0;
127 if (ctx->tintv.tv64 != 0) {
128 /*
129 * If tintv.tv64 != 0, this is a periodic timer that
130 * needs to be re-armed. We avoid doing it in the timer
131 * callback to avoid DoS attacks specifying a very
132 * short timer period.
133 */
134 ticks = (u32)
135 hrtimer_forward(&ctx->tmr,
136 hrtimer_cb_get_time(&ctx->tmr),
137 ctx->tintv);
138 hrtimer_restart(&ctx->tmr);
139 } else
140 ticks = 1;
141 }
142 spin_unlock_irq(&ctx->lock);
143 if (ticks)
144 res = put_user(ticks, buf) ? -EFAULT: sizeof(ticks);
145 return res;
146}
147
148static const struct file_operations timerfd_fops = {
149 .release = timerfd_release,
150 .poll = timerfd_poll,
151 .read = timerfd_read,
152};
153
154asmlinkage long sys_timerfd(int ufd, int clockid, int flags,
155 const struct itimerspec __user *utmr)
156{
157 int error;
158 struct timerfd_ctx *ctx;
159 struct file *file;
160 struct inode *inode;
161 struct itimerspec ktmr;
162
163 if (copy_from_user(&ktmr, utmr, sizeof(ktmr)))
164 return -EFAULT;
165
166 if (clockid != CLOCK_MONOTONIC &&
167 clockid != CLOCK_REALTIME)
168 return -EINVAL;
169 if (!timespec_valid(&ktmr.it_value) ||
170 !timespec_valid(&ktmr.it_interval))
171 return -EINVAL;
172
173 if (ufd == -1) {
174 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
175 if (!ctx)
176 return -ENOMEM;
177
178 init_waitqueue_head(&ctx->wqh);
179 spin_lock_init(&ctx->lock);
180
181 timerfd_setup(ctx, clockid, flags, &ktmr);
182
183 /*
184 * When we call this, the initialization must be complete, since
185 * anon_inode_getfd() will install the fd.
186 */
187 error = anon_inode_getfd(&ufd, &inode, &file, "[timerfd]",
188 &timerfd_fops, ctx);
189 if (error)
190 goto err_tmrcancel;
191 } else {
192 file = fget(ufd);
193 if (!file)
194 return -EBADF;
195 ctx = file->private_data;
196 if (file->f_op != &timerfd_fops) {
197 fput(file);
198 return -EINVAL;
199 }
200 /*
201 * We need to stop the existing timer before reprogramming
202 * it to the new values.
203 */
204 for (;;) {
205 spin_lock_irq(&ctx->lock);
206 if (hrtimer_try_to_cancel(&ctx->tmr) >= 0)
207 break;
208 spin_unlock_irq(&ctx->lock);
209 cpu_relax();
210 }
211 /*
212 * Re-program the timer to the new value ...
213 */
214 timerfd_setup(ctx, clockid, flags, &ktmr);
215
216 spin_unlock_irq(&ctx->lock);
217 fput(file);
218 }
219
220 return ufd;
221
222err_tmrcancel:
223 hrtimer_cancel(&ctx->tmr);
224 kfree(ctx);
225 return error;
226}
227
diff --git a/fs/xattr.c b/fs/xattr.c
index 9f4568b55b0f..4523aca79659 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -350,6 +350,7 @@ sys_fgetxattr(int fd, char __user *name, void __user *value, size_t size)
350 f = fget(fd); 350 f = fget(fd);
351 if (!f) 351 if (!f)
352 return error; 352 return error;
353 audit_inode(NULL, f->f_path.dentry->d_inode);
353 error = getxattr(f->f_path.dentry, name, value, size); 354 error = getxattr(f->f_path.dentry, name, value, size);
354 fput(f); 355 fput(f);
355 return error; 356 return error;
@@ -422,6 +423,7 @@ sys_flistxattr(int fd, char __user *list, size_t size)
422 f = fget(fd); 423 f = fget(fd);
423 if (!f) 424 if (!f)
424 return error; 425 return error;
426 audit_inode(NULL, f->f_path.dentry->d_inode);
425 error = listxattr(f->f_path.dentry, list, size); 427 error = listxattr(f->f_path.dentry, list, size);
426 fput(f); 428 fput(f);
427 return error; 429 return error;
diff --git a/include/asm-alpha/poll.h b/include/asm-alpha/poll.h
index 76f89356b6a7..c98509d3149e 100644
--- a/include/asm-alpha/poll.h
+++ b/include/asm-alpha/poll.h
@@ -1,25 +1 @@
1#ifndef __ALPHA_POLL_H #include <asm-generic/poll.h>
2#define __ALPHA_POLL_H
3
4#define POLLIN (1 << 0)
5#define POLLPRI (1 << 1)
6#define POLLOUT (1 << 2)
7#define POLLERR (1 << 3)
8#define POLLHUP (1 << 4)
9#define POLLNVAL (1 << 5)
10#define POLLRDNORM (1 << 6)
11#define POLLRDBAND (1 << 7)
12#define POLLWRNORM (1 << 8)
13#define POLLWRBAND (1 << 9)
14#define POLLMSG (1 << 10)
15#define POLLREMOVE (1 << 12)
16#define POLLRDHUP (1 << 13)
17
18
19struct pollfd {
20 int fd;
21 short events;
22 short revents;
23};
24
25#endif
diff --git a/include/asm-arm/poll.h b/include/asm-arm/poll.h
index 5030b2b232a3..c98509d3149e 100644
--- a/include/asm-arm/poll.h
+++ b/include/asm-arm/poll.h
@@ -1,27 +1 @@
1#ifndef __ASMARM_POLL_H #include <asm-generic/poll.h>
2#define __ASMARM_POLL_H
3
4/* These are specified by iBCS2 */
5#define POLLIN 0x0001
6#define POLLPRI 0x0002
7#define POLLOUT 0x0004
8#define POLLERR 0x0008
9#define POLLHUP 0x0010
10#define POLLNVAL 0x0020
11
12/* The rest seem to be more-or-less nonstandard. Check them! */
13#define POLLRDNORM 0x0040
14#define POLLRDBAND 0x0080
15#define POLLWRNORM 0x0100
16#define POLLWRBAND 0x0200
17#define POLLMSG 0x0400
18#define POLLREMOVE 0x1000
19#define POLLRDHUP 0x2000
20
21struct pollfd {
22 int fd;
23 short events;
24 short revents;
25};
26
27#endif
diff --git a/include/asm-arm26/poll.h b/include/asm-arm26/poll.h
index 9ccb7f4190ca..1170e7065f6a 100644
--- a/include/asm-arm26/poll.h
+++ b/include/asm-arm26/poll.h
@@ -1,26 +1,8 @@
1#ifndef __ASMARM_POLL_H 1#ifndef __ASMARM_POLL_H
2#define __ASMARM_POLL_H 2#define __ASMARM_POLL_H
3 3
4/* These are specified by iBCS2 */ 4#include <asm-generic/poll.h>
5#define POLLIN 0x0001
6#define POLLPRI 0x0002
7#define POLLOUT 0x0004
8#define POLLERR 0x0008
9#define POLLHUP 0x0010
10#define POLLNVAL 0x0020
11 5
12/* The rest seem to be more-or-less nonstandard. Check them! */ 6#undef POLLREMOVE
13#define POLLRDNORM 0x0040
14#define POLLRDBAND 0x0080
15#define POLLWRNORM 0x0100
16#define POLLWRBAND 0x0200
17#define POLLMSG 0x0400
18#define POLLRDHUP 0x2000
19
20struct pollfd {
21 int fd;
22 short events;
23 short revents;
24};
25 7
26#endif 8#endif
diff --git a/include/asm-avr32/poll.h b/include/asm-avr32/poll.h
index 736e29755dfc..c98509d3149e 100644
--- a/include/asm-avr32/poll.h
+++ b/include/asm-avr32/poll.h
@@ -1,27 +1 @@
1#ifndef __ASM_AVR32_POLL_H #include <asm-generic/poll.h>
2#define __ASM_AVR32_POLL_H
3
4/* These are specified by iBCS2 */
5#define POLLIN 0x0001
6#define POLLPRI 0x0002
7#define POLLOUT 0x0004
8#define POLLERR 0x0008
9#define POLLHUP 0x0010
10#define POLLNVAL 0x0020
11
12/* The rest seem to be more-or-less nonstandard. Check them! */
13#define POLLRDNORM 0x0040
14#define POLLRDBAND 0x0080
15#define POLLWRNORM 0x0100
16#define POLLWRBAND 0x0200
17#define POLLMSG 0x0400
18#define POLLREMOVE 0x1000
19#define POLLRDHUP 0x2000
20
21struct pollfd {
22 int fd;
23 short events;
24 short revents;
25};
26
27#endif /* __ASM_AVR32_POLL_H */
diff --git a/include/asm-cris/poll.h b/include/asm-cris/poll.h
index 1b25d4cf498c..c98509d3149e 100644
--- a/include/asm-cris/poll.h
+++ b/include/asm-cris/poll.h
@@ -1,26 +1 @@
1#ifndef __ASM_CRIS_POLL_H #include <asm-generic/poll.h>
2#define __ASM_CRIS_POLL_H
3
4/* taken from asm-alpha */
5
6#define POLLIN 1
7#define POLLPRI 2
8#define POLLOUT 4
9#define POLLERR 8
10#define POLLHUP 16
11#define POLLNVAL 32
12#define POLLRDNORM 64
13#define POLLRDBAND 128
14#define POLLWRNORM 256
15#define POLLWRBAND 512
16#define POLLMSG 1024
17#define POLLREMOVE 4096
18#define POLLRDHUP 8192
19
20struct pollfd {
21 int fd;
22 short events;
23 short revents;
24};
25
26#endif
diff --git a/include/asm-frv/poll.h b/include/asm-frv/poll.h
index c8fe8801d075..0d01479ccc56 100644
--- a/include/asm-frv/poll.h
+++ b/include/asm-frv/poll.h
@@ -1,24 +1,12 @@
1#ifndef _ASM_POLL_H 1#ifndef _ASM_POLL_H
2#define _ASM_POLL_H 2#define _ASM_POLL_H
3 3
4#define POLLIN 1
5#define POLLPRI 2
6#define POLLOUT 4
7#define POLLERR 8
8#define POLLHUP 16
9#define POLLNVAL 32
10#define POLLRDNORM 64
11#define POLLWRNORM POLLOUT 4#define POLLWRNORM POLLOUT
12#define POLLRDBAND 128
13#define POLLWRBAND 256 5#define POLLWRBAND 256
14#define POLLMSG 0x0400
15#define POLLRDHUP 0x2000
16 6
17struct pollfd { 7#include <asm-generic/poll.h>
18 int fd; 8
19 short events; 9#undef POLLREMOVE
20 short revents;
21};
22 10
23#endif 11#endif
24 12
diff --git a/include/asm-generic/Kbuild b/include/asm-generic/Kbuild
index fa14f8cd30c5..5bfeef761649 100644
--- a/include/asm-generic/Kbuild
+++ b/include/asm-generic/Kbuild
@@ -4,6 +4,7 @@ header-y += fcntl.h
4header-y += ioctl.h 4header-y += ioctl.h
5header-y += ipc.h 5header-y += ipc.h
6header-y += mman.h 6header-y += mman.h
7header-y += poll.h
7header-y += signal.h 8header-y += signal.h
8header-y += statfs.h 9header-y += statfs.h
9 10
diff --git a/include/asm-generic/audit_signal.h b/include/asm-generic/audit_signal.h
new file mode 100644
index 000000000000..6feab7f18a53
--- /dev/null
+++ b/include/asm-generic/audit_signal.h
@@ -0,0 +1,3 @@
1__NR_kill,
2__NR_tgkill,
3__NR_tkill,
diff --git a/include/asm-generic/poll.h b/include/asm-generic/poll.h
new file mode 100644
index 000000000000..44bce836d350
--- /dev/null
+++ b/include/asm-generic/poll.h
@@ -0,0 +1,37 @@
1#ifndef __ASM_GENERIC_POLL_H
2#define __ASM_GENERIC_POLL_H
3
4/* These are specified by iBCS2 */
5#define POLLIN 0x0001
6#define POLLPRI 0x0002
7#define POLLOUT 0x0004
8#define POLLERR 0x0008
9#define POLLHUP 0x0010
10#define POLLNVAL 0x0020
11
12/* The rest seem to be more-or-less nonstandard. Check them! */
13#define POLLRDNORM 0x0040
14#define POLLRDBAND 0x0080
15#ifndef POLLWRNORM
16#define POLLWRNORM 0x0100
17#endif
18#ifndef POLLWRBAND
19#define POLLWRBAND 0x0200
20#endif
21#ifndef POLLMSG
22#define POLLMSG 0x0400
23#endif
24#ifndef POLLREMOVE
25#define POLLREMOVE 0x1000
26#endif
27#ifndef POLLRDHUP
28#define POLLRDHUP 0x2000
29#endif
30
31struct pollfd {
32 int fd;
33 short events;
34 short revents;
35};
36
37#endif /* __ASM_GENERIC_POLL_H */
diff --git a/include/asm-h8300/poll.h b/include/asm-h8300/poll.h
index fc52103b276a..f61540c22d94 100644
--- a/include/asm-h8300/poll.h
+++ b/include/asm-h8300/poll.h
@@ -1,23 +1,11 @@
1#ifndef __H8300_POLL_H 1#ifndef __H8300_POLL_H
2#define __H8300_POLL_H 2#define __H8300_POLL_H
3 3
4#define POLLIN 1
5#define POLLPRI 2
6#define POLLOUT 4
7#define POLLERR 8
8#define POLLHUP 16
9#define POLLNVAL 32
10#define POLLRDNORM 64
11#define POLLWRNORM POLLOUT 4#define POLLWRNORM POLLOUT
12#define POLLRDBAND 128
13#define POLLWRBAND 256 5#define POLLWRBAND 256
14#define POLLMSG 0x0400
15#define POLLRDHUP 0x2000
16 6
17struct pollfd { 7#include <asm-generic/poll.h>
18 int fd; 8
19 short events; 9#undef POLLREMOVE
20 short revents;
21};
22 10
23#endif 11#endif
diff --git a/include/asm-h8300/unistd.h b/include/asm-h8300/unistd.h
index 7ddd414f8d16..99f3c3561ecb 100644
--- a/include/asm-h8300/unistd.h
+++ b/include/asm-h8300/unistd.h
@@ -21,7 +21,7 @@
21#define __NR_time 13 21#define __NR_time 13
22#define __NR_mknod 14 22#define __NR_mknod 14
23#define __NR_chmod 15 23#define __NR_chmod 15
24#define __NR_chown 16 24#define __NR_lchown 16
25#define __NR_break 17 25#define __NR_break 17
26#define __NR_oldstat 18 26#define __NR_oldstat 18
27#define __NR_lseek 19 27#define __NR_lseek 19
@@ -115,10 +115,10 @@
115#define __NR_lstat 107 115#define __NR_lstat 107
116#define __NR_fstat 108 116#define __NR_fstat 108
117#define __NR_olduname 109 117#define __NR_olduname 109
118#define __NR_iopl /* 110 */ not supported 118#define __NR_iopl 110
119#define __NR_vhangup 111 119#define __NR_vhangup 111
120#define __NR_idle /* 112 */ Obsolete 120#define __NR_idle 112
121#define __NR_vm86 /* 113 */ not supported 121#define __NR_vm86old 113
122#define __NR_wait4 114 122#define __NR_wait4 114
123#define __NR_swapoff 115 123#define __NR_swapoff 115
124#define __NR_sysinfo 116 124#define __NR_sysinfo 116
@@ -128,7 +128,7 @@
128#define __NR_clone 120 128#define __NR_clone 120
129#define __NR_setdomainname 121 129#define __NR_setdomainname 121
130#define __NR_uname 122 130#define __NR_uname 122
131#define __NR_cacheflush 123 131#define __NR_modify_ldt 123
132#define __NR_adjtimex 124 132#define __NR_adjtimex 124
133#define __NR_mprotect 125 133#define __NR_mprotect 125
134#define __NR_sigprocmask 126 134#define __NR_sigprocmask 126
@@ -171,7 +171,7 @@
171#define __NR_mremap 163 171#define __NR_mremap 163
172#define __NR_setresuid 164 172#define __NR_setresuid 164
173#define __NR_getresuid 165 173#define __NR_getresuid 165
174#define __NR_getpagesize 166 174#define __NR_vm86 166
175#define __NR_query_module 167 175#define __NR_query_module 167
176#define __NR_poll 168 176#define __NR_poll 168
177#define __NR_nfsservctl 169 177#define __NR_nfsservctl 169
@@ -187,7 +187,7 @@
187#define __NR_rt_sigsuspend 179 187#define __NR_rt_sigsuspend 179
188#define __NR_pread64 180 188#define __NR_pread64 180
189#define __NR_pwrite64 181 189#define __NR_pwrite64 181
190#define __NR_lchown 182 190#define __NR_chown 182
191#define __NR_getcwd 183 191#define __NR_getcwd 183
192#define __NR_capget 184 192#define __NR_capget 184
193#define __NR_capset 185 193#define __NR_capset 185
@@ -203,7 +203,7 @@
203#define __NR_stat64 195 203#define __NR_stat64 195
204#define __NR_lstat64 196 204#define __NR_lstat64 196
205#define __NR_fstat64 197 205#define __NR_fstat64 197
206#define __NR_chown32 198 206#define __NR_lchown32 198
207#define __NR_getuid32 199 207#define __NR_getuid32 199
208#define __NR_getgid32 200 208#define __NR_getgid32 200
209#define __NR_geteuid32 201 209#define __NR_geteuid32 201
@@ -217,15 +217,18 @@
217#define __NR_getresuid32 209 217#define __NR_getresuid32 209
218#define __NR_setresgid32 210 218#define __NR_setresgid32 210
219#define __NR_getresgid32 211 219#define __NR_getresgid32 211
220#define __NR_lchown32 212 220#define __NR_chown32 212
221#define __NR_setuid32 213 221#define __NR_setuid32 213
222#define __NR_setgid32 214 222#define __NR_setgid32 214
223#define __NR_setfsuid32 215 223#define __NR_setfsuid32 215
224#define __NR_setfsgid32 216 224#define __NR_setfsgid32 216
225#define __NR_pivot_root 217 225#define __NR_pivot_root 217
226#define __NR_mincore 218
227#define __NR_madvise 219
228#define __NR_madvise1 219
226#define __NR_getdents64 220 229#define __NR_getdents64 220
227#define __NR_fcntl64 221 230#define __NR_fcntl64 221
228#define __NR_security 223 231/* 223 is unused */
229#define __NR_gettid 224 232#define __NR_gettid 224
230#define __NR_readahead 225 233#define __NR_readahead 225
231#define __NR_setxattr 226 234#define __NR_setxattr 226
@@ -252,13 +255,13 @@
252#define __NR_io_getevents 247 255#define __NR_io_getevents 247
253#define __NR_io_submit 248 256#define __NR_io_submit 248
254#define __NR_io_cancel 249 257#define __NR_io_cancel 249
255#define __NR_alloc_hugepages 250 258#define __NR_fadvise64 250
256#define __NR_free_hugepages 251 259/* 251 is available for reuse (was briefly sys_set_zone_reclaim) */
257#define __NR_exit_group 252 260#define __NR_exit_group 252
258#define __NR_lookup_dcookie 253 261#define __NR_lookup_dcookie 253
259#define __NR_sys_epoll_create 254 262#define __NR_epoll_create 254
260#define __NR_sys_epoll_ctl 255 263#define __NR_epoll_ctl 255
261#define __NR_sys_epoll_wait 256 264#define __NR_epoll_wait 256
262#define __NR_remap_file_pages 257 265#define __NR_remap_file_pages 257
263#define __NR_set_tid_address 258 266#define __NR_set_tid_address 258
264#define __NR_timer_create 259 267#define __NR_timer_create 259
@@ -291,10 +294,41 @@
291#define __NR_add_key 286 294#define __NR_add_key 286
292#define __NR_request_key 287 295#define __NR_request_key 287
293#define __NR_keyctl 288 296#define __NR_keyctl 288
297#define __NR_ioprio_set 289
298#define __NR_ioprio_get 290
299#define __NR_inotify_init 291
300#define __NR_inotify_add_watch 292
301#define __NR_inotify_rm_watch 293
302#define __NR_migrate_pages 294
303#define __NR_openat 295
304#define __NR_mkdirat 296
305#define __NR_mknodat 297
306#define __NR_fchownat 298
307#define __NR_futimesat 299
308#define __NR_fstatat64 300
309#define __NR_unlinkat 301
310#define __NR_renameat 302
311#define __NR_linkat 303
312#define __NR_symlinkat 304
313#define __NR_readlinkat 305
314#define __NR_fchmodat 306
315#define __NR_faccessat 307
316#define __NR_pselect6 308
317#define __NR_ppoll 309
318#define __NR_unshare 310
319#define __NR_set_robust_list 311
320#define __NR_get_robust_list 312
321#define __NR_splice 313
322#define __NR_sync_file_range 314
323#define __NR_tee 315
324#define __NR_vmsplice 316
325#define __NR_move_pages 317
326#define __NR_getcpu 318
327#define __NR_epoll_pwait 319
294 328
295#ifdef __KERNEL__ 329#ifdef __KERNEL__
296 330
297#define NR_syscalls 289 331#define NR_syscalls 320
298 332
299#define __ARCH_WANT_IPC_PARSE_VERSION 333#define __ARCH_WANT_IPC_PARSE_VERSION
300#define __ARCH_WANT_OLD_READDIR 334#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-i386/alternative.h b/include/asm-i386/alternative.h
index 0f70b379b029..eb7da5402bfa 100644
--- a/include/asm-i386/alternative.h
+++ b/include/asm-i386/alternative.h
@@ -98,6 +98,12 @@ static inline void alternatives_smp_switch(int smp) {}
98 ".previous" : output : [feat] "i" (feature), ##input) 98 ".previous" : output : [feat] "i" (feature), ##input)
99 99
100/* 100/*
101 * use this macro(s) if you need more than one output parameter
102 * in alternative_io
103 */
104#define ASM_OUTPUT2(a, b) a, b
105
106/*
101 * Alternative inline assembly for SMP. 107 * Alternative inline assembly for SMP.
102 * 108 *
103 * The LOCK_PREFIX macro defined here replaces the LOCK and 109 * The LOCK_PREFIX macro defined here replaces the LOCK and
diff --git a/include/asm-i386/pgalloc.h b/include/asm-i386/pgalloc.h
index 47430175b75f..d07b7afc2692 100644
--- a/include/asm-i386/pgalloc.h
+++ b/include/asm-i386/pgalloc.h
@@ -65,6 +65,4 @@ do { \
65#define pud_populate(mm, pmd, pte) BUG() 65#define pud_populate(mm, pmd, pte) BUG()
66#endif 66#endif
67 67
68#define check_pgt_cache() do { } while (0)
69
70#endif /* _I386_PGALLOC_H */ 68#endif /* _I386_PGALLOC_H */
diff --git a/include/asm-i386/pgtable.h b/include/asm-i386/pgtable.h
index edce9d51a676..2394589786ba 100644
--- a/include/asm-i386/pgtable.h
+++ b/include/asm-i386/pgtable.h
@@ -35,17 +35,16 @@ struct vm_area_struct;
35#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) 35#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
36extern unsigned long empty_zero_page[1024]; 36extern unsigned long empty_zero_page[1024];
37extern pgd_t swapper_pg_dir[1024]; 37extern pgd_t swapper_pg_dir[1024];
38extern struct kmem_cache *pgd_cache;
39extern struct kmem_cache *pmd_cache; 38extern struct kmem_cache *pmd_cache;
40extern spinlock_t pgd_lock; 39extern spinlock_t pgd_lock;
41extern struct page *pgd_list; 40extern struct page *pgd_list;
41void check_pgt_cache(void);
42 42
43void pmd_ctor(void *, struct kmem_cache *, unsigned long); 43void pmd_ctor(void *, struct kmem_cache *, unsigned long);
44void pgd_ctor(void *, struct kmem_cache *, unsigned long);
45void pgd_dtor(void *, struct kmem_cache *, unsigned long);
46void pgtable_cache_init(void); 44void pgtable_cache_init(void);
47void paging_init(void); 45void paging_init(void);
48 46
47
49/* 48/*
50 * The Linux x86 paging architecture is 'compile-time dual-mode', it 49 * The Linux x86 paging architecture is 'compile-time dual-mode', it
51 * implements both the traditional 2-level x86 page tables and the 50 * implements both the traditional 2-level x86 page tables and the
diff --git a/include/asm-i386/poll.h b/include/asm-i386/poll.h
index 2cd4929abd40..c98509d3149e 100644
--- a/include/asm-i386/poll.h
+++ b/include/asm-i386/poll.h
@@ -1,27 +1 @@
1#ifndef __i386_POLL_H #include <asm-generic/poll.h>
2#define __i386_POLL_H
3
4/* These are specified by iBCS2 */
5#define POLLIN 0x0001
6#define POLLPRI 0x0002
7#define POLLOUT 0x0004
8#define POLLERR 0x0008
9#define POLLHUP 0x0010
10#define POLLNVAL 0x0020
11
12/* The rest seem to be more-or-less nonstandard. Check them! */
13#define POLLRDNORM 0x0040
14#define POLLRDBAND 0x0080
15#define POLLWRNORM 0x0100
16#define POLLWRBAND 0x0200
17#define POLLMSG 0x0400
18#define POLLREMOVE 0x1000
19#define POLLRDHUP 0x2000
20
21struct pollfd {
22 int fd;
23 short events;
24 short revents;
25};
26
27#endif
diff --git a/include/asm-i386/tsc.h b/include/asm-i386/tsc.h
index 3f3c1fa000b4..62c091ffcccc 100644
--- a/include/asm-i386/tsc.h
+++ b/include/asm-i386/tsc.h
@@ -35,14 +35,16 @@ static inline cycles_t get_cycles(void)
35static __always_inline cycles_t get_cycles_sync(void) 35static __always_inline cycles_t get_cycles_sync(void)
36{ 36{
37 unsigned long long ret; 37 unsigned long long ret;
38 unsigned eax; 38 unsigned eax, edx;
39 39
40 /* 40 /*
41 * Use RDTSCP if possible; it is guaranteed to be synchronous 41 * Use RDTSCP if possible; it is guaranteed to be synchronous
42 * and doesn't cause a VMEXIT on Hypervisors 42 * and doesn't cause a VMEXIT on Hypervisors
43 */ 43 */
44 alternative_io(ASM_NOP3, ".byte 0x0f,0x01,0xf9", X86_FEATURE_RDTSCP, 44 alternative_io(ASM_NOP3, ".byte 0x0f,0x01,0xf9", X86_FEATURE_RDTSCP,
45 "=A" (ret), "0" (0ULL) : "ecx", "memory"); 45 ASM_OUTPUT2("=a" (eax), "=d" (edx)),
46 "a" (0U), "d" (0U) : "ecx", "memory");
47 ret = (((unsigned long long)edx) << 32) | ((unsigned long long)eax);
46 if (ret) 48 if (ret)
47 return ret; 49 return ret;
48 50
diff --git a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h
index bd21e795197c..e84ace1ec8bf 100644
--- a/include/asm-i386/unistd.h
+++ b/include/asm-i386/unistd.h
@@ -326,10 +326,13 @@
326#define __NR_getcpu 318 326#define __NR_getcpu 318
327#define __NR_epoll_pwait 319 327#define __NR_epoll_pwait 319
328#define __NR_utimensat 320 328#define __NR_utimensat 320
329#define __NR_signalfd 321
330#define __NR_timerfd 322
331#define __NR_eventfd 323
329 332
330#ifdef __KERNEL__ 333#ifdef __KERNEL__
331 334
332#define NR_syscalls 321 335#define NR_syscalls 324
333 336
334#define __ARCH_WANT_IPC_PARSE_VERSION 337#define __ARCH_WANT_IPC_PARSE_VERSION
335#define __ARCH_WANT_OLD_READDIR 338#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-ia64/irq.h b/include/asm-ia64/irq.h
index 79479e2c6966..67221615e317 100644
--- a/include/asm-ia64/irq.h
+++ b/include/asm-ia64/irq.h
@@ -11,6 +11,9 @@
11 * 02/29/00 D.Mosberger moved most things into hw_irq.h 11 * 02/29/00 D.Mosberger moved most things into hw_irq.h
12 */ 12 */
13 13
14#include <linux/types.h>
15#include <linux/cpumask.h>
16
14#define NR_IRQS 256 17#define NR_IRQS 256
15#define NR_IRQ_VECTORS NR_IRQS 18#define NR_IRQ_VECTORS NR_IRQS
16 19
@@ -29,5 +32,8 @@ extern void disable_irq (unsigned int);
29extern void disable_irq_nosync (unsigned int); 32extern void disable_irq_nosync (unsigned int);
30extern void enable_irq (unsigned int); 33extern void enable_irq (unsigned int);
31extern void set_irq_affinity_info (unsigned int irq, int dest, int redir); 34extern void set_irq_affinity_info (unsigned int irq, int dest, int redir);
35bool is_affinity_mask_valid(cpumask_t cpumask);
36
37#define is_affinity_mask_valid is_affinity_mask_valid
32 38
33#endif /* _ASM_IA64_IRQ_H */ 39#endif /* _ASM_IA64_IRQ_H */
diff --git a/include/asm-ia64/kprobes.h b/include/asm-ia64/kprobes.h
index 828ae00e47c1..2abc98b336f3 100644
--- a/include/asm-ia64/kprobes.h
+++ b/include/asm-ia64/kprobes.h
@@ -71,13 +71,15 @@ struct prev_kprobe {
71 71
72#define MAX_PARAM_RSE_SIZE (0x60+0x60/0x3f) 72#define MAX_PARAM_RSE_SIZE (0x60+0x60/0x3f)
73/* per-cpu kprobe control block */ 73/* per-cpu kprobe control block */
74#define ARCH_PREV_KPROBE_SZ 2
74struct kprobe_ctlblk { 75struct kprobe_ctlblk {
75 unsigned long kprobe_status; 76 unsigned long kprobe_status;
76 struct pt_regs jprobe_saved_regs; 77 struct pt_regs jprobe_saved_regs;
77 unsigned long jprobes_saved_stacked_regs[MAX_PARAM_RSE_SIZE]; 78 unsigned long jprobes_saved_stacked_regs[MAX_PARAM_RSE_SIZE];
78 unsigned long *bsp; 79 unsigned long *bsp;
79 unsigned long cfm; 80 unsigned long cfm;
80 struct prev_kprobe prev_kprobe; 81 atomic_t prev_kprobe_index;
82 struct prev_kprobe prev_kprobe[ARCH_PREV_KPROBE_SZ];
81}; 83};
82 84
83#define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)pentry 85#define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)pentry
diff --git a/include/asm-ia64/pgalloc.h b/include/asm-ia64/pgalloc.h
index 560c287b1233..67552cad5173 100644
--- a/include/asm-ia64/pgalloc.h
+++ b/include/asm-ia64/pgalloc.h
@@ -18,71 +18,18 @@
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/page-flags.h> 19#include <linux/page-flags.h>
20#include <linux/threads.h> 20#include <linux/threads.h>
21#include <linux/quicklist.h>
21 22
22#include <asm/mmu_context.h> 23#include <asm/mmu_context.h>
23 24
24DECLARE_PER_CPU(unsigned long *, __pgtable_quicklist);
25#define pgtable_quicklist __ia64_per_cpu_var(__pgtable_quicklist)
26DECLARE_PER_CPU(long, __pgtable_quicklist_size);
27#define pgtable_quicklist_size __ia64_per_cpu_var(__pgtable_quicklist_size)
28
29static inline long pgtable_quicklist_total_size(void)
30{
31 long ql_size = 0;
32 int cpuid;
33
34 for_each_online_cpu(cpuid) {
35 ql_size += per_cpu(__pgtable_quicklist_size, cpuid);
36 }
37 return ql_size;
38}
39
40static inline void *pgtable_quicklist_alloc(void)
41{
42 unsigned long *ret = NULL;
43
44 preempt_disable();
45
46 ret = pgtable_quicklist;
47 if (likely(ret != NULL)) {
48 pgtable_quicklist = (unsigned long *)(*ret);
49 ret[0] = 0;
50 --pgtable_quicklist_size;
51 preempt_enable();
52 } else {
53 preempt_enable();
54 ret = (unsigned long *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
55 }
56
57 return ret;
58}
59
60static inline void pgtable_quicklist_free(void *pgtable_entry)
61{
62#ifdef CONFIG_NUMA
63 int nid = page_to_nid(virt_to_page(pgtable_entry));
64
65 if (unlikely(nid != numa_node_id())) {
66 free_page((unsigned long)pgtable_entry);
67 return;
68 }
69#endif
70
71 preempt_disable();
72 *(unsigned long *)pgtable_entry = (unsigned long)pgtable_quicklist;
73 pgtable_quicklist = (unsigned long *)pgtable_entry;
74 ++pgtable_quicklist_size;
75 preempt_enable();
76}
77
78static inline pgd_t *pgd_alloc(struct mm_struct *mm) 25static inline pgd_t *pgd_alloc(struct mm_struct *mm)
79{ 26{
80 return pgtable_quicklist_alloc(); 27 return quicklist_alloc(0, GFP_KERNEL, NULL);
81} 28}
82 29
83static inline void pgd_free(pgd_t * pgd) 30static inline void pgd_free(pgd_t * pgd)
84{ 31{
85 pgtable_quicklist_free(pgd); 32 quicklist_free(0, NULL, pgd);
86} 33}
87 34
88#ifdef CONFIG_PGTABLE_4 35#ifdef CONFIG_PGTABLE_4
@@ -94,12 +41,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
94 41
95static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr) 42static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
96{ 43{
97 return pgtable_quicklist_alloc(); 44 return quicklist_alloc(0, GFP_KERNEL, NULL);
98} 45}
99 46
100static inline void pud_free(pud_t * pud) 47static inline void pud_free(pud_t * pud)
101{ 48{
102 pgtable_quicklist_free(pud); 49 quicklist_free(0, NULL, pud);
103} 50}
104#define __pud_free_tlb(tlb, pud) pud_free(pud) 51#define __pud_free_tlb(tlb, pud) pud_free(pud)
105#endif /* CONFIG_PGTABLE_4 */ 52#endif /* CONFIG_PGTABLE_4 */
@@ -112,12 +59,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
112 59
113static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr) 60static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
114{ 61{
115 return pgtable_quicklist_alloc(); 62 return quicklist_alloc(0, GFP_KERNEL, NULL);
116} 63}
117 64
118static inline void pmd_free(pmd_t * pmd) 65static inline void pmd_free(pmd_t * pmd)
119{ 66{
120 pgtable_quicklist_free(pmd); 67 quicklist_free(0, NULL, pmd);
121} 68}
122 69
123#define __pmd_free_tlb(tlb, pmd) pmd_free(pmd) 70#define __pmd_free_tlb(tlb, pmd) pmd_free(pmd)
@@ -137,28 +84,31 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t * pmd_entry, pte_t * pte)
137static inline struct page *pte_alloc_one(struct mm_struct *mm, 84static inline struct page *pte_alloc_one(struct mm_struct *mm,
138 unsigned long addr) 85 unsigned long addr)
139{ 86{
140 void *pg = pgtable_quicklist_alloc(); 87 void *pg = quicklist_alloc(0, GFP_KERNEL, NULL);
141 return pg ? virt_to_page(pg) : NULL; 88 return pg ? virt_to_page(pg) : NULL;
142} 89}
143 90
144static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 91static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
145 unsigned long addr) 92 unsigned long addr)
146{ 93{
147 return pgtable_quicklist_alloc(); 94 return quicklist_alloc(0, GFP_KERNEL, NULL);
148} 95}
149 96
150static inline void pte_free(struct page *pte) 97static inline void pte_free(struct page *pte)
151{ 98{
152 pgtable_quicklist_free(page_address(pte)); 99 quicklist_free_page(0, NULL, pte);
153} 100}
154 101
155static inline void pte_free_kernel(pte_t * pte) 102static inline void pte_free_kernel(pte_t * pte)
156{ 103{
157 pgtable_quicklist_free(pte); 104 quicklist_free(0, NULL, pte);
158} 105}
159 106
160#define __pte_free_tlb(tlb, pte) pte_free(pte) 107static inline void check_pgt_cache(void)
108{
109 quicklist_trim(0, NULL, 25, 16);
110}
161 111
162extern void check_pgt_cache(void); 112#define __pte_free_tlb(tlb, pte) pte_free(pte)
163 113
164#endif /* _ASM_IA64_PGALLOC_H */ 114#endif /* _ASM_IA64_PGALLOC_H */
diff --git a/include/asm-ia64/poll.h b/include/asm-ia64/poll.h
index bcaf9f140242..c98509d3149e 100644
--- a/include/asm-ia64/poll.h
+++ b/include/asm-ia64/poll.h
@@ -1,32 +1 @@
1#ifndef _ASM_IA64_POLL_H #include <asm-generic/poll.h>
2#define _ASM_IA64_POLL_H
3
4/*
5 * poll(2) bit definitions. Based on <asm-i386/poll.h>.
6 *
7 * Modified 1998, 1999, 2002
8 * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co
9 */
10
11#define POLLIN 0x0001
12#define POLLPRI 0x0002
13#define POLLOUT 0x0004
14#define POLLERR 0x0008
15#define POLLHUP 0x0010
16#define POLLNVAL 0x0020
17
18#define POLLRDNORM 0x0040
19#define POLLRDBAND 0x0080
20#define POLLWRNORM 0x0100
21#define POLLWRBAND 0x0200
22#define POLLMSG 0x0400
23#define POLLREMOVE 0x1000
24#define POLLRDHUP 0x2000
25
26struct pollfd {
27 int fd;
28 short events;
29 short revents;
30};
31
32#endif /* _ASM_IA64_POLL_H */
diff --git a/include/asm-ia64/unistd.h b/include/asm-ia64/unistd.h
index 861c8ec87b09..f049bc40ca7d 100644
--- a/include/asm-ia64/unistd.h
+++ b/include/asm-ia64/unistd.h
@@ -294,11 +294,13 @@
294#define __NR_vmsplice 1302 294#define __NR_vmsplice 1302
295/* 1303 reserved for move_pages */ 295/* 1303 reserved for move_pages */
296#define __NR_getcpu 1304 296#define __NR_getcpu 1304
297#define __NR_epoll_pwait 1305
298#define __NR_utimensat 1306
297 299
298#ifdef __KERNEL__ 300#ifdef __KERNEL__
299 301
300 302
301#define NR_syscalls 281 /* length of syscall table */ 303#define NR_syscalls 283 /* length of syscall table */
302 304
303#define __ARCH_WANT_SYS_RT_SIGACTION 305#define __ARCH_WANT_SYS_RT_SIGACTION
304#define __ARCH_WANT_SYS_RT_SIGSUSPEND 306#define __ARCH_WANT_SYS_RT_SIGSUSPEND
diff --git a/include/asm-m32r/pgtable-2level.h b/include/asm-m32r/pgtable-2level.h
index 750925726a10..bca3475f9595 100644
--- a/include/asm-m32r/pgtable-2level.h
+++ b/include/asm-m32r/pgtable-2level.h
@@ -71,8 +71,8 @@ static inline pmd_t *pmd_offset(pgd_t * dir, unsigned long address)
71#define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) 71#define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
72 72
73#define PTE_FILE_MAX_BITS 29 73#define PTE_FILE_MAX_BITS 29
74#define pte_to_pgoff(pte) (((pte_val(pte) >> 2) & 0xef) | (((pte_val(pte) >> 10)) << 7)) 74#define pte_to_pgoff(pte) (((pte_val(pte) >> 2) & 0x7f) | (((pte_val(pte) >> 10)) << 7))
75#define pgoff_to_pte(off) ((pte_t) { (((off) & 0xef) << 2) | (((off) >> 7) << 10) | _PAGE_FILE }) 75#define pgoff_to_pte(off) ((pte_t) { (((off) & 0x7f) << 2) | (((off) >> 7) << 10) | _PAGE_FILE })
76 76
77#endif /* __KERNEL__ */ 77#endif /* __KERNEL__ */
78#endif /* _ASM_M32R_PGTABLE_2LEVEL_H */ 78#endif /* _ASM_M32R_PGTABLE_2LEVEL_H */
diff --git a/include/asm-m32r/pgtable.h b/include/asm-m32r/pgtable.h
index 8b2a2f17e695..6604303fc47c 100644
--- a/include/asm-m32r/pgtable.h
+++ b/include/asm-m32r/pgtable.h
@@ -366,7 +366,7 @@ static inline void pmd_set(pmd_t * pmdp, pte_t * ptep)
366#define pte_unmap_nested(pte) do { } while (0) 366#define pte_unmap_nested(pte) do { } while (0)
367 367
368/* Encode and de-code a swap entry */ 368/* Encode and de-code a swap entry */
369#define __swp_type(x) (((x).val >> 2) & 0x3f) 369#define __swp_type(x) (((x).val >> 2) & 0x1f)
370#define __swp_offset(x) ((x).val >> 10) 370#define __swp_offset(x) ((x).val >> 10)
371#define __swp_entry(type, offset) \ 371#define __swp_entry(type, offset) \
372 ((swp_entry_t) { ((type) << 2) | ((offset) << 10) }) 372 ((swp_entry_t) { ((type) << 2) | ((offset) << 10) })
diff --git a/include/asm-m32r/poll.h b/include/asm-m32r/poll.h
index 9e0e700e727c..c98509d3149e 100644
--- a/include/asm-m32r/poll.h
+++ b/include/asm-m32r/poll.h
@@ -1,32 +1 @@
1#ifndef _ASM_M32R_POLL_H #include <asm-generic/poll.h>
2#define _ASM_M32R_POLL_H
3
4/*
5 * poll(2) bit definitions. Based on <asm-i386/poll.h>.
6 *
7 * Modified 2004
8 * Hirokazu Takata <takata at linux-m32r.org>
9 */
10
11#define POLLIN 0x0001
12#define POLLPRI 0x0002
13#define POLLOUT 0x0004
14#define POLLERR 0x0008
15#define POLLHUP 0x0010
16#define POLLNVAL 0x0020
17
18#define POLLRDNORM 0x0040
19#define POLLRDBAND 0x0080
20#define POLLWRNORM 0x0100
21#define POLLWRBAND 0x0200
22#define POLLMSG 0x0400
23#define POLLREMOVE 0x1000
24#define POLLRDHUP 0x2000
25
26struct pollfd {
27 int fd;
28 short events;
29 short revents;
30};
31
32#endif /* _ASM_M32R_POLL_H */
diff --git a/include/asm-m32r/system.h b/include/asm-m32r/system.h
index f62f5c9abba6..b291b2f72954 100644
--- a/include/asm-m32r/system.h
+++ b/include/asm-m32r/system.h
@@ -21,12 +21,22 @@
21 * `next' and `prev' should be struct task_struct, but it isn't always defined 21 * `next' and `prev' should be struct task_struct, but it isn't always defined
22 */ 22 */
23 23
24#if defined(CONFIG_FRAME_POINTER) || \
25 !defined(CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER)
26#define M32R_PUSH_FP " push fp\n"
27#define M32R_POP_FP " pop fp\n"
28#else
29#define M32R_PUSH_FP ""
30#define M32R_POP_FP ""
31#endif
32
24#define switch_to(prev, next, last) do { \ 33#define switch_to(prev, next, last) do { \
25 __asm__ __volatile__ ( \ 34 __asm__ __volatile__ ( \
26 " seth lr, #high(1f) \n" \ 35 " seth lr, #high(1f) \n" \
27 " or3 lr, lr, #low(1f) \n" \ 36 " or3 lr, lr, #low(1f) \n" \
28 " st lr, @%4 ; store old LR \n" \ 37 " st lr, @%4 ; store old LR \n" \
29 " ld lr, @%5 ; load new LR \n" \ 38 " ld lr, @%5 ; load new LR \n" \
39 M32R_PUSH_FP \
30 " st sp, @%2 ; store old SP \n" \ 40 " st sp, @%2 ; store old SP \n" \
31 " ld sp, @%3 ; load new SP \n" \ 41 " ld sp, @%3 ; load new SP \n" \
32 " push %1 ; store `prev' on new stack \n" \ 42 " push %1 ; store `prev' on new stack \n" \
@@ -34,6 +44,7 @@
34 " .fillinsn \n" \ 44 " .fillinsn \n" \
35 "1: \n" \ 45 "1: \n" \
36 " pop %0 ; restore `__last' from new stack \n" \ 46 " pop %0 ; restore `__last' from new stack \n" \
47 M32R_POP_FP \
37 : "=r" (last) \ 48 : "=r" (last) \
38 : "0" (prev), \ 49 : "0" (prev), \
39 "r" (&(prev->thread.sp)), "r" (&(next->thread.sp)), \ 50 "r" (&(prev->thread.sp)), "r" (&(next->thread.sp)), \
diff --git a/include/asm-m68k/atarihw.h b/include/asm-m68k/atarihw.h
index 6211363a345f..ecf007df7743 100644
--- a/include/asm-m68k/atarihw.h
+++ b/include/asm-m68k/atarihw.h
@@ -2,7 +2,7 @@
2** linux/atarihw.h -- This header defines some macros and pointers for 2** linux/atarihw.h -- This header defines some macros and pointers for
3** the various Atari custom hardware registers. 3** the various Atari custom hardware registers.
4** 4**
5** Copyright 1994 by Bj”rn Brauel 5** Copyright 1994 by Björn Brauel
6** 6**
7** 5/1/94 Roman Hodek: 7** 5/1/94 Roman Hodek:
8** Added definitions for TT specific chips. 8** Added definitions for TT specific chips.
diff --git a/include/asm-m68k/atariints.h b/include/asm-m68k/atariints.h
index ce6c445805bd..5748e99f4e26 100644
--- a/include/asm-m68k/atariints.h
+++ b/include/asm-m68k/atariints.h
@@ -1,7 +1,7 @@
1/* 1/*
2** atariints.h -- Atari Linux interrupt handling structs and prototypes 2** atariints.h -- Atari Linux interrupt handling structs and prototypes
3** 3**
4** Copyright 1994 by Bj”rn Brauel 4** Copyright 1994 by Björn Brauel
5** 5**
6** 5/2/94 Roman Hodek: 6** 5/2/94 Roman Hodek:
7** TT interrupt definitions added. 7** TT interrupt definitions added.
diff --git a/include/asm-m68k/poll.h b/include/asm-m68k/poll.h
index 0fb8843647f8..f080fcdb61bf 100644
--- a/include/asm-m68k/poll.h
+++ b/include/asm-m68k/poll.h
@@ -1,24 +1,9 @@
1#ifndef __m68k_POLL_H 1#ifndef __m68k_POLL_H
2#define __m68k_POLL_H 2#define __m68k_POLL_H
3 3
4#define POLLIN 1
5#define POLLPRI 2
6#define POLLOUT 4
7#define POLLERR 8
8#define POLLHUP 16
9#define POLLNVAL 32
10#define POLLRDNORM 64
11#define POLLWRNORM POLLOUT 4#define POLLWRNORM POLLOUT
12#define POLLRDBAND 128
13#define POLLWRBAND 256 5#define POLLWRBAND 256
14#define POLLMSG 0x0400
15#define POLLREMOVE 0x1000
16#define POLLRDHUP 0x2000
17 6
18struct pollfd { 7#include <asm-generic/poll.h>
19 int fd;
20 short events;
21 short revents;
22};
23 8
24#endif 9#endif
diff --git a/include/asm-mips/atomic.h b/include/asm-mips/atomic.h
index 62daa746a9c9..1b60624dab7e 100644
--- a/include/asm-mips/atomic.h
+++ b/include/asm-mips/atomic.h
@@ -689,7 +689,7 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
689} 689}
690 690
691#define atomic64_cmpxchg(v, o, n) \ 691#define atomic64_cmpxchg(v, o, n) \
692 (((__typeof__((v)->counter)))cmpxchg(&((v)->counter), (o), (n))) 692 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
693#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new))) 693#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
694 694
695/** 695/**
diff --git a/include/asm-mips/bootinfo.h b/include/asm-mips/bootinfo.h
index dbf834f4dac4..b0c329783ac5 100644
--- a/include/asm-mips/bootinfo.h
+++ b/include/asm-mips/bootinfo.h
@@ -119,9 +119,9 @@
119 */ 119 */
120#define MACH_GROUP_MOMENCO 12 /* Momentum Boards */ 120#define MACH_GROUP_MOMENCO 12 /* Momentum Boards */
121#define MACH_MOMENCO_OCELOT 0 121#define MACH_MOMENCO_OCELOT 0
122#define MACH_MOMENCO_OCELOT_G 1 122#define MACH_MOMENCO_OCELOT_G 1 /* no more supported (may 2007) */
123#define MACH_MOMENCO_OCELOT_C 2 123#define MACH_MOMENCO_OCELOT_C 2
124#define MACH_MOMENCO_JAGUAR_ATX 3 124#define MACH_MOMENCO_JAGUAR_ATX 3 /* no more supported (may 2007) */
125#define MACH_MOMENCO_OCELOT_3 4 125#define MACH_MOMENCO_OCELOT_3 4
126 126
127/* 127/*
diff --git a/include/asm-mips/fpu.h b/include/asm-mips/fpu.h
index b414a7d9db43..483685b1592e 100644
--- a/include/asm-mips/fpu.h
+++ b/include/asm-mips/fpu.h
@@ -16,6 +16,7 @@
16#include <asm/mipsregs.h> 16#include <asm/mipsregs.h>
17#include <asm/cpu.h> 17#include <asm/cpu.h>
18#include <asm/cpu-features.h> 18#include <asm/cpu-features.h>
19#include <asm/hazards.h>
19#include <asm/bitops.h> 20#include <asm/bitops.h>
20#include <asm/processor.h> 21#include <asm/processor.h>
21#include <asm/current.h> 22#include <asm/current.h>
@@ -38,34 +39,16 @@ extern void _init_fpu(void);
38extern void _save_fp(struct task_struct *); 39extern void _save_fp(struct task_struct *);
39extern void _restore_fp(struct task_struct *); 40extern void _restore_fp(struct task_struct *);
40 41
41#if defined(CONFIG_CPU_SB1)
42#define __enable_fpu_hazard() \
43do { \
44 asm(".set push \n\t" \
45 ".set mips64 \n\t" \
46 ".set noreorder \n\t" \
47 "ssnop \n\t" \
48 "bnezl $0, .+4 \n\t" \
49 "ssnop \n\t" \
50 ".set pop"); \
51} while (0)
52#else
53#define __enable_fpu_hazard() \
54do { \
55 asm("nop;nop;nop;nop"); /* max. hazard */ \
56} while (0)
57#endif
58
59#define __enable_fpu() \ 42#define __enable_fpu() \
60do { \ 43do { \
61 set_c0_status(ST0_CU1); \ 44 set_c0_status(ST0_CU1); \
62 __enable_fpu_hazard(); \ 45 enable_fpu_hazard(); \
63} while (0) 46} while (0)
64 47
65#define __disable_fpu() \ 48#define __disable_fpu() \
66do { \ 49do { \
67 clear_c0_status(ST0_CU1); \ 50 clear_c0_status(ST0_CU1); \
68 /* We don't care about the c0 hazard here */ \ 51 disable_fpu_hazard(); \
69} while (0) 52} while (0)
70 53
71#define enable_fpu() \ 54#define enable_fpu() \
diff --git a/include/asm-mips/hazards.h b/include/asm-mips/hazards.h
index e50c77e69cb5..d9119f43f9aa 100644
--- a/include/asm-mips/hazards.h
+++ b/include/asm-mips/hazards.h
@@ -178,4 +178,36 @@ ASMMACRO(back_to_back_c0_hazard,
178 178
179#endif 179#endif
180 180
181
182/* FPU hazards */
183
184#if defined(CONFIG_CPU_SB1)
185ASMMACRO(enable_fpu_hazard,
186 .set push;
187 .set mips64;
188 .set noreorder;
189 _ssnop;
190 bnezl $0,.+4;
191 _ssnop;
192 .set pop
193)
194ASMMACRO(disable_fpu_hazard,
195)
196
197#elif defined(CONFIG_CPU_MIPSR2)
198ASMMACRO(enable_fpu_hazard,
199 _ehb
200)
201ASMMACRO(disable_fpu_hazard,
202 _ehb
203)
204#else
205ASMMACRO(enable_fpu_hazard,
206 nop; nop; nop; nop
207)
208ASMMACRO(disable_fpu_hazard,
209 _ehb
210)
211#endif
212
181#endif /* _ASM_HAZARDS_H */ 213#endif /* _ASM_HAZARDS_H */
diff --git a/include/asm-mips/highmem.h b/include/asm-mips/highmem.h
index f8c8182f7f2e..4d6bd5c31c7b 100644
--- a/include/asm-mips/highmem.h
+++ b/include/asm-mips/highmem.h
@@ -48,46 +48,6 @@ extern pte_t *pkmap_page_table;
48extern void * kmap_high(struct page *page); 48extern void * kmap_high(struct page *page);
49extern void kunmap_high(struct page *page); 49extern void kunmap_high(struct page *page);
50 50
51/*
52 * CONFIG_LIMITED_DMA is for systems with DMA limitations such as Momentum's
53 * Jaguar ATX. This option exploits the highmem code in the kernel so is
54 * always enabled together with CONFIG_HIGHMEM but at this time doesn't
55 * actually add highmem functionality.
56 */
57
58#ifdef CONFIG_LIMITED_DMA
59
60/*
61 * These are the default functions for the no-highmem case from
62 * <linux/highmem.h>
63 */
64static inline void *kmap(struct page *page)
65{
66 might_sleep();
67 return page_address(page);
68}
69
70#define kunmap(page) do { (void) (page); } while (0)
71
72static inline void *kmap_atomic(struct page *page, enum km_type type)
73{
74 pagefault_disable();
75 return page_address(page);
76}
77
78static inline void kunmap_atomic(void *kvaddr, enum km_type type)
79{
80 pagefault_enable();
81}
82
83#define kmap_atomic_pfn(pfn, idx) kmap_atomic(pfn_to_page(pfn), (idx))
84
85#define kmap_atomic_to_page(ptr) virt_to_page(ptr)
86
87#define flush_cache_kmaps() do { } while (0)
88
89#else /* LIMITED_DMA */
90
91extern void *__kmap(struct page *page); 51extern void *__kmap(struct page *page);
92extern void __kunmap(struct page *page); 52extern void __kunmap(struct page *page);
93extern void *__kmap_atomic(struct page *page, enum km_type type); 53extern void *__kmap_atomic(struct page *page, enum km_type type);
@@ -103,8 +63,6 @@ extern struct page *__kmap_atomic_to_page(void *ptr);
103 63
104#define flush_cache_kmaps() flush_cache_all() 64#define flush_cache_kmaps() flush_cache_all()
105 65
106#endif /* LIMITED_DMA */
107
108#endif /* __KERNEL__ */ 66#endif /* __KERNEL__ */
109 67
110#endif /* _ASM_HIGHMEM_H */ 68#endif /* _ASM_HIGHMEM_H */
diff --git a/include/asm-mips/mach-cobalt/cobalt.h b/include/asm-mips/mach-cobalt/cobalt.h
index 24a8d51a55a3..684a501c04cf 100644
--- a/include/asm-mips/mach-cobalt/cobalt.h
+++ b/include/asm-mips/mach-cobalt/cobalt.h
@@ -69,6 +69,8 @@
69#define COBALT_BRD_ID_QUBE2 0x5 69#define COBALT_BRD_ID_QUBE2 0x5
70#define COBALT_BRD_ID_RAQ2 0x6 70#define COBALT_BRD_ID_RAQ2 0x6
71 71
72extern int cobalt_board_id;
73
72#define PCI_CFG_SET(devfn,where) \ 74#define PCI_CFG_SET(devfn,where) \
73 GT_WRITE(GT_PCI0_CFGADDR_OFS, (0x80000000 | (PCI_SLOT (devfn) << 11) | \ 75 GT_WRITE(GT_PCI0_CFGADDR_OFS, (0x80000000 | (PCI_SLOT (devfn) << 11) | \
74 (PCI_FUNC (devfn) << 8) | (where))) 76 (PCI_FUNC (devfn) << 8) | (where)))
diff --git a/include/asm-mips/mach-ja/cpu-feature-overrides.h b/include/asm-mips/mach-ja/cpu-feature-overrides.h
deleted file mode 100644
index 84b6dead0e8a..000000000000
--- a/include/asm-mips/mach-ja/cpu-feature-overrides.h
+++ /dev/null
@@ -1,45 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003, 2004 Ralf Baechle
7 */
8#ifndef __ASM_MACH_JA_CPU_FEATURE_OVERRIDES_H
9#define __ASM_MACH_JA_CPU_FEATURE_OVERRIDES_H
10
11/*
12 * Momentum Jaguar ATX always has the RM9000 processor.
13 */
14#define cpu_has_watch 1
15#define cpu_has_mips16 0
16#define cpu_has_divec 0
17#define cpu_has_vce 0
18#define cpu_has_cache_cdex_p 0
19#define cpu_has_cache_cdex_s 0
20#define cpu_has_prefetch 1
21#define cpu_has_mcheck 0
22#define cpu_has_ejtag 0
23
24#define cpu_has_llsc 1
25#define cpu_has_vtag_icache 0
26#define cpu_has_dc_aliases 0
27#define cpu_has_ic_fills_f_dc 0
28#define cpu_has_dsp 0
29#define cpu_icache_snoops_remote_store 0
30
31#define cpu_has_nofpuex 0
32#define cpu_has_64bits 1
33
34#define cpu_has_inclusive_pcaches 0
35
36#define cpu_dcache_line_size() 32
37#define cpu_icache_line_size() 32
38#define cpu_scache_line_size() 32
39
40#define cpu_has_mips32r1 0
41#define cpu_has_mips32r2 0
42#define cpu_has_mips64r1 0
43#define cpu_has_mips64r2 0
44
45#endif /* __ASM_MACH_JA_CPU_FEATURE_OVERRIDES_H */
diff --git a/include/asm-mips/mach-ja/spaces.h b/include/asm-mips/mach-ja/spaces.h
deleted file mode 100644
index 8466a0e69c79..000000000000
--- a/include/asm-mips/mach-ja/spaces.h
+++ /dev/null
@@ -1,20 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994 - 1999, 2000, 03, 04 Ralf Baechle
7 * Copyright (C) 2000, 2002 Maciej W. Rozycki
8 * Copyright (C) 1990, 1999, 2000 Silicon Graphics, Inc.
9 */
10#ifndef __ASM_MACH_JA_SPACES_H
11#define __ASM_MACH_JA_SPACES_H
12
13/*
14 * Memory above this physical address will be considered highmem.
15 */
16#define HIGHMEM_START 0x08000000UL
17
18#include_next <spaces.h>
19
20#endif /* __ASM_MACH_JA_SPACES_H */
diff --git a/include/asm-mips/mips-boards/malta.h b/include/asm-mips/mips-boards/malta.h
index b0ba3c5a921e..eec91001bb65 100644
--- a/include/asm-mips/mips-boards/malta.h
+++ b/include/asm-mips/mips-boards/malta.h
@@ -25,6 +25,10 @@
25#include <asm/mips-boards/msc01_pci.h> 25#include <asm/mips-boards/msc01_pci.h>
26#include <asm/gt64120.h> 26#include <asm/gt64120.h>
27 27
28/* Mips interrupt controller found in SOCit variations */
29#define MIPS_MSC01_IC_REG_BASE 0x1bc40000
30#define MIPS_SOCITSC_IC_REG_BASE 0x1ffa0000
31
28/* 32/*
29 * Malta I/O ports base address for the Galileo GT64120 and Algorithmics 33 * Malta I/O ports base address for the Galileo GT64120 and Algorithmics
30 * Bonito system controllers. 34 * Bonito system controllers.
diff --git a/include/asm-mips/msc01_ic.h b/include/asm-mips/msc01_ic.h
index aa7ad9a71762..7989b9ffc1d2 100644
--- a/include/asm-mips/msc01_ic.h
+++ b/include/asm-mips/msc01_ic.h
@@ -94,10 +94,7 @@
94/* 94/*
95 * MIPS System controller interrupt register base. 95 * MIPS System controller interrupt register base.
96 * 96 *
97 * FIXME - are these macros specific to Malta and co or to the MSC? If the
98 * latter, they should be moved elsewhere.
99 */ 97 */
100#define MIPS_MSC01_IC_REG_BASE 0x1bc40000
101 98
102/***************************************************************************** 99/*****************************************************************************
103 * Absolute register addresses 100 * Absolute register addresses
@@ -144,7 +141,7 @@ typedef struct msc_irqmap {
144#define MSC01_IRQ_LEVEL 0 141#define MSC01_IRQ_LEVEL 0
145#define MSC01_IRQ_EDGE 1 142#define MSC01_IRQ_EDGE 1
146 143
147extern void __init init_msc_irqs(unsigned int base, msc_irqmap_t *imp, int nirq); 144extern void __init init_msc_irqs(unsigned long icubase, unsigned int base, msc_irqmap_t *imp, int nirq);
148extern void ll_msc_irq(void); 145extern void ll_msc_irq(void);
149 146
150#endif /* __ASM_MIPS_BOARDS_MSC01_IC_H */ 147#endif /* __ASM_MIPS_BOARDS_MSC01_IC_H */
diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h
index d3fbd83ff545..5c3239dad0f2 100644
--- a/include/asm-mips/page.h
+++ b/include/asm-mips/page.h
@@ -190,10 +190,6 @@ typedef struct { unsigned long pgprot; } pgprot_t;
190#define UNCAC_ADDR(addr) ((addr) - PAGE_OFFSET + UNCAC_BASE) 190#define UNCAC_ADDR(addr) ((addr) - PAGE_OFFSET + UNCAC_BASE)
191#define CAC_ADDR(addr) ((addr) - UNCAC_BASE + PAGE_OFFSET) 191#define CAC_ADDR(addr) ((addr) - UNCAC_BASE + PAGE_OFFSET)
192 192
193#ifdef CONFIG_LIMITED_DMA
194#define WANT_PAGE_VIRTUAL
195#endif
196
197#include <asm-generic/memory_model.h> 193#include <asm-generic/memory_model.h>
198#include <asm-generic/page.h> 194#include <asm-generic/page.h>
199 195
diff --git a/include/asm-mips/poll.h b/include/asm-mips/poll.h
index 70881f8c5c50..47b952080431 100644
--- a/include/asm-mips/poll.h
+++ b/include/asm-mips/poll.h
@@ -1,28 +1,9 @@
1#ifndef __ASM_POLL_H 1#ifndef __ASM_POLL_H
2#define __ASM_POLL_H 2#define __ASM_POLL_H
3 3
4#define POLLIN 0x0001
5#define POLLPRI 0x0002
6#define POLLOUT 0x0004
7
8#define POLLERR 0x0008
9#define POLLHUP 0x0010
10#define POLLNVAL 0x0020
11
12#define POLLRDNORM 0x0040
13#define POLLRDBAND 0x0080
14#define POLLWRNORM POLLOUT 4#define POLLWRNORM POLLOUT
15#define POLLWRBAND 0x0100 5#define POLLWRBAND 0x0100
16 6
17/* These seem to be more or less nonstandard ... */ 7#include <asm-generic/poll.h>
18#define POLLMSG 0x0400
19#define POLLREMOVE 0x1000
20#define POLLRDHUP 0x2000
21
22struct pollfd {
23 int fd;
24 short events;
25 short revents;
26};
27 8
28#endif /* __ASM_POLL_H */ 9#endif /* __ASM_POLL_H */
diff --git a/include/asm-mips/serial.h b/include/asm-mips/serial.h
index d7a65135d837..ce51213d84f9 100644
--- a/include/asm-mips/serial.h
+++ b/include/asm-mips/serial.h
@@ -81,25 +81,6 @@
81#define STD_SERIAL_PORT_DEFNS 81#define STD_SERIAL_PORT_DEFNS
82#endif /* CONFIG_HAVE_STD_PC_SERIAL_PORTS */ 82#endif /* CONFIG_HAVE_STD_PC_SERIAL_PORTS */
83 83
84#ifdef CONFIG_MOMENCO_JAGUAR_ATX
85/* Ordinary NS16552 duart with a 20MHz crystal. */
86#define JAGUAR_ATX_UART_CLK 20000000
87#define JAGUAR_ATX_BASE_BAUD (JAGUAR_ATX_UART_CLK / 16)
88
89#define JAGUAR_ATX_SERIAL1_IRQ 6
90#define JAGUAR_ATX_SERIAL1_BASE 0xfd000023L
91
92#define _JAGUAR_ATX_SERIAL_INIT(int, base) \
93 { .baud_base = JAGUAR_ATX_BASE_BAUD, irq: int, \
94 .flags = (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST), \
95 .iomem_base = (u8 *) base, iomem_reg_shift: 2, \
96 io_type: SERIAL_IO_MEM }
97#define MOMENCO_JAGUAR_ATX_SERIAL_PORT_DEFNS \
98 _JAGUAR_ATX_SERIAL_INIT(JAGUAR_ATX_SERIAL1_IRQ, JAGUAR_ATX_SERIAL1_BASE)
99#else
100#define MOMENCO_JAGUAR_ATX_SERIAL_PORT_DEFNS
101#endif
102
103#ifdef CONFIG_MOMENCO_OCELOT_3 84#ifdef CONFIG_MOMENCO_OCELOT_3
104#define OCELOT_3_BASE_BAUD ( 20000000 / 16 ) 85#define OCELOT_3_BASE_BAUD ( 20000000 / 16 )
105#define OCELOT_3_SERIAL_IRQ 6 86#define OCELOT_3_SERIAL_IRQ 6
@@ -134,27 +115,6 @@
134#define MOMENCO_OCELOT_SERIAL_PORT_DEFNS 115#define MOMENCO_OCELOT_SERIAL_PORT_DEFNS
135#endif 116#endif
136 117
137#ifdef CONFIG_MOMENCO_OCELOT_G
138/* Ordinary NS16552 duart with a 20MHz crystal. */
139#define OCELOT_G_BASE_BAUD ( 20000000 / 16 )
140
141#define OCELOT_G_SERIAL1_IRQ 4
142#if 0
143#define OCELOT_G_SERIAL1_BASE 0xe0001020
144#else
145#define OCELOT_G_SERIAL1_BASE 0xfd000020
146#endif
147
148#define _OCELOT_G_SERIAL_INIT(int, base) \
149 { .baud_base = OCELOT_G_BASE_BAUD, .irq = int, .flags = STD_COM_FLAGS,\
150 .iomem_base = (u8 *) base, .iomem_reg_shift = 2, \
151 .io_type = SERIAL_IO_MEM }
152#define MOMENCO_OCELOT_G_SERIAL_PORT_DEFNS \
153 _OCELOT_G_SERIAL_INIT(OCELOT_G_SERIAL1_IRQ, OCELOT_G_SERIAL1_BASE)
154#else
155#define MOMENCO_OCELOT_G_SERIAL_PORT_DEFNS
156#endif
157
158#ifdef CONFIG_MOMENCO_OCELOT_C 118#ifdef CONFIG_MOMENCO_OCELOT_C
159/* Ordinary NS16552 duart with a 20MHz crystal. */ 119/* Ordinary NS16552 duart with a 20MHz crystal. */
160#define OCELOT_C_BASE_BAUD ( 20000000 / 16 ) 120#define OCELOT_C_BASE_BAUD ( 20000000 / 16 )
@@ -210,7 +170,6 @@
210 IP32_SERIAL_PORT_DEFNS \ 170 IP32_SERIAL_PORT_DEFNS \
211 JAZZ_SERIAL_PORT_DEFNS \ 171 JAZZ_SERIAL_PORT_DEFNS \
212 STD_SERIAL_PORT_DEFNS \ 172 STD_SERIAL_PORT_DEFNS \
213 MOMENCO_OCELOT_G_SERIAL_PORT_DEFNS \
214 MOMENCO_OCELOT_C_SERIAL_PORT_DEFNS \ 173 MOMENCO_OCELOT_C_SERIAL_PORT_DEFNS \
215 MOMENCO_OCELOT_SERIAL_PORT_DEFNS \ 174 MOMENCO_OCELOT_SERIAL_PORT_DEFNS \
216 MOMENCO_OCELOT_3_SERIAL_PORT_DEFNS 175 MOMENCO_OCELOT_3_SERIAL_PORT_DEFNS
diff --git a/include/asm-mips/sgi/seeq.h b/include/asm-mips/sgi/seeq.h
new file mode 100644
index 000000000000..af0ffd76899d
--- /dev/null
+++ b/include/asm-mips/sgi/seeq.h
@@ -0,0 +1,21 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2007 by Ralf Baechle
7 */
8#ifndef __ASM_SGI_SEEQ_H
9#define __ASM_SGI_SEEQ_H
10
11#include <linux/if_ether.h>
12
13#include <asm/sgi/hpc3.h>
14
15struct sgiseeq_platform_data {
16 struct hpc3_regs *hpc;
17 unsigned int irq;
18 unsigned char mac[ETH_ALEN];
19};
20
21#endif /* __ASM_SGI_SEEQ_H */
diff --git a/include/asm-mips/sgi/wd.h b/include/asm-mips/sgi/wd.h
new file mode 100644
index 000000000000..0d6c3a4da891
--- /dev/null
+++ b/include/asm-mips/sgi/wd.h
@@ -0,0 +1,20 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2007 by Ralf Baechle
7 */
8#ifndef __ASM_SGI_WD_H
9#define __ASM_SGI_WD_H
10
11#include <asm/sgi/hpc3.h>
12
13struct sgiwd93_platform_data {
14 unsigned int unit;
15 unsigned int irq;
16 struct hpc3_scsiregs *hregs;
17 unsigned char *wdregs;
18};
19
20#endif /* __ASM_SGI_WD_H */
diff --git a/include/asm-mips/system.h b/include/asm-mips/system.h
index 3713d256d369..bb0b289dbc9e 100644
--- a/include/asm-mips/system.h
+++ b/include/asm-mips/system.h
@@ -464,7 +464,10 @@ static inline unsigned long __cmpxchg_local(volatile void * ptr,
464 464
465extern void set_handler (unsigned long offset, void *addr, unsigned long len); 465extern void set_handler (unsigned long offset, void *addr, unsigned long len);
466extern void set_uncached_handler (unsigned long offset, void *addr, unsigned long len); 466extern void set_uncached_handler (unsigned long offset, void *addr, unsigned long len);
467extern void *set_vi_handler (int n, void *addr); 467
468typedef void (*vi_handler_t)(void);
469extern void *set_vi_handler (int n, vi_handler_t addr);
470
468extern void *set_except_vector(int n, void *addr); 471extern void *set_except_vector(int n, void *addr);
469extern unsigned long ebase; 472extern unsigned long ebase;
470extern void per_cpu_trap_init(void); 473extern void per_cpu_trap_init(void);
diff --git a/include/asm-parisc/poll.h b/include/asm-parisc/poll.h
index 20e4d03c74cb..c98509d3149e 100644
--- a/include/asm-parisc/poll.h
+++ b/include/asm-parisc/poll.h
@@ -1,27 +1 @@
1#ifndef __PARISC_POLL_H #include <asm-generic/poll.h>
2#define __PARISC_POLL_H
3
4/* These are specified by iBCS2 */
5#define POLLIN 0x0001
6#define POLLPRI 0x0002
7#define POLLOUT 0x0004
8#define POLLERR 0x0008
9#define POLLHUP 0x0010
10#define POLLNVAL 0x0020
11
12/* The rest seem to be more-or-less nonstandard. Check them! */
13#define POLLRDNORM 0x0040
14#define POLLRDBAND 0x0080
15#define POLLWRNORM 0x0100
16#define POLLWRBAND 0x0200
17#define POLLMSG 0x0400
18#define POLLREMOVE 0x1000
19#define POLLRDHUP 0x2000
20
21struct pollfd {
22 int fd;
23 short events;
24 short revents;
25};
26
27#endif
diff --git a/include/asm-powerpc/hw_irq.h b/include/asm-powerpc/hw_irq.h
index 9e4dd98eb220..a7b60bf639e0 100644
--- a/include/asm-powerpc/hw_irq.h
+++ b/include/asm-powerpc/hw_irq.h
@@ -48,8 +48,15 @@ extern void iseries_handle_interrupts(void);
48 48
49#define irqs_disabled() (local_get_flags() == 0) 49#define irqs_disabled() (local_get_flags() == 0)
50 50
51#define hard_irq_enable() __mtmsrd(mfmsr() | MSR_EE, 1) 51#define __hard_irq_enable() __mtmsrd(mfmsr() | MSR_EE, 1)
52#define hard_irq_disable() __mtmsrd(mfmsr() & ~MSR_EE, 1) 52#define __hard_irq_disable() __mtmsrd(mfmsr() & ~MSR_EE, 1)
53
54#define hard_irq_disable() \
55 do { \
56 __hard_irq_disable(); \
57 get_paca()->soft_enabled = 0; \
58 get_paca()->hard_enabled = 0; \
59 } while(0)
53 60
54#else 61#else
55 62
diff --git a/include/asm-powerpc/poll.h b/include/asm-powerpc/poll.h
index 9c7d12631033..c98509d3149e 100644
--- a/include/asm-powerpc/poll.h
+++ b/include/asm-powerpc/poll.h
@@ -1,24 +1 @@
1#ifndef _ASM_POWERPC_POLL_H #include <asm-generic/poll.h>
2#define _ASM_POWERPC_POLL_H
3
4#define POLLIN 0x0001
5#define POLLPRI 0x0002
6#define POLLOUT 0x0004
7#define POLLERR 0x0008
8#define POLLHUP 0x0010
9#define POLLNVAL 0x0020
10#define POLLRDNORM 0x0040
11#define POLLRDBAND 0x0080
12#define POLLWRNORM 0x0100
13#define POLLWRBAND 0x0200
14#define POLLMSG 0x0400
15#define POLLREMOVE 0x1000
16#define POLLRDHUP 0x2000
17
18struct pollfd {
19 int fd;
20 short events;
21 short revents;
22};
23
24#endif /* _ASM_POWERPC_POLL_H */
diff --git a/include/asm-s390/poll.h b/include/asm-s390/poll.h
index 6f7f65ac7d27..c98509d3149e 100644
--- a/include/asm-s390/poll.h
+++ b/include/asm-s390/poll.h
@@ -1,35 +1 @@
1/* #include <asm-generic/poll.h>
2 * include/asm-s390/poll.h
3 *
4 * S390 version
5 *
6 * Derived from "include/asm-i386/poll.h"
7 */
8
9#ifndef __S390_POLL_H
10#define __S390_POLL_H
11
12/* These are specified by iBCS2 */
13#define POLLIN 0x0001
14#define POLLPRI 0x0002
15#define POLLOUT 0x0004
16#define POLLERR 0x0008
17#define POLLHUP 0x0010
18#define POLLNVAL 0x0020
19
20/* The rest seem to be more-or-less nonstandard. Check them! */
21#define POLLRDNORM 0x0040
22#define POLLRDBAND 0x0080
23#define POLLWRNORM 0x0100
24#define POLLWRBAND 0x0200
25#define POLLMSG 0x0400
26#define POLLREMOVE 0x1000
27#define POLLRDHUP 0x2000
28
29struct pollfd {
30 int fd;
31 short events;
32 short revents;
33};
34
35#endif
diff --git a/include/asm-sh/poll.h b/include/asm-sh/poll.h
index dbca9b32f4a6..c98509d3149e 100644
--- a/include/asm-sh/poll.h
+++ b/include/asm-sh/poll.h
@@ -1,27 +1 @@
1#ifndef __ASM_SH_POLL_H #include <asm-generic/poll.h>
2#define __ASM_SH_POLL_H
3
4/* These are specified by iBCS2 */
5#define POLLIN 0x0001
6#define POLLPRI 0x0002
7#define POLLOUT 0x0004
8#define POLLERR 0x0008
9#define POLLHUP 0x0010
10#define POLLNVAL 0x0020
11
12/* The rest seem to be more-or-less nonstandard. Check them! */
13#define POLLRDNORM 0x0040
14#define POLLRDBAND 0x0080
15#define POLLWRNORM 0x0100
16#define POLLWRBAND 0x0200
17#define POLLMSG 0x0400
18#define POLLREMOVE 0x1000
19#define POLLRDHUP 0x2000
20
21struct pollfd {
22 int fd;
23 short events;
24 short revents;
25};
26
27#endif /* __ASM_SH_POLL_H */
diff --git a/include/asm-sh64/poll.h b/include/asm-sh64/poll.h
index 3a6cbad08d28..ca2950267c53 100644
--- a/include/asm-sh64/poll.h
+++ b/include/asm-sh64/poll.h
@@ -1,37 +1,8 @@
1#ifndef __ASM_SH64_POLL_H 1#ifndef __ASM_SH64_POLL_H
2#define __ASM_SH64_POLL_H 2#define __ASM_SH64_POLL_H
3 3
4/* 4#include <asm-generic/poll.h>
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/poll.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14 5
15/* These are specified by iBCS2 */ 6#undef POLLREMOVE
16#define POLLIN 0x0001
17#define POLLPRI 0x0002
18#define POLLOUT 0x0004
19#define POLLERR 0x0008
20#define POLLHUP 0x0010
21#define POLLNVAL 0x0020
22
23/* The rest seem to be more-or-less nonstandard. Check them! */
24#define POLLRDNORM 0x0040
25#define POLLRDBAND 0x0080
26#define POLLWRNORM 0x0100
27#define POLLWRBAND 0x0200
28#define POLLMSG 0x0400
29#define POLLRDHUP 0x2000
30
31struct pollfd {
32 int fd;
33 short events;
34 short revents;
35};
36 7
37#endif /* __ASM_SH64_POLL_H */ 8#endif /* __ASM_SH64_POLL_H */
diff --git a/include/asm-sparc/poll.h b/include/asm-sparc/poll.h
index 26f13fb35497..091d3ad2e830 100644
--- a/include/asm-sparc/poll.h
+++ b/include/asm-sparc/poll.h
@@ -1,24 +1,12 @@
1#ifndef __SPARC_POLL_H 1#ifndef __SPARC_POLL_H
2#define __SPARC_POLL_H 2#define __SPARC_POLL_H
3 3
4#define POLLIN 1
5#define POLLPRI 2
6#define POLLOUT 4
7#define POLLERR 8
8#define POLLHUP 16
9#define POLLNVAL 32
10#define POLLRDNORM 64
11#define POLLWRNORM POLLOUT 4#define POLLWRNORM POLLOUT
12#define POLLRDBAND 128
13#define POLLWRBAND 256 5#define POLLWRBAND 256
14#define POLLMSG 512 6#define POLLMSG 512
15#define POLLREMOVE 1024 7#define POLLREMOVE 1024
16#define POLLRDHUP 2048 8#define POLLRDHUP 2048
17 9
18struct pollfd { 10#include <asm-generic/poll.h>
19 int fd;
20 short events;
21 short revents;
22};
23 11
24#endif 12#endif
diff --git a/include/asm-sparc/unistd.h b/include/asm-sparc/unistd.h
index da9bdc5e5526..64471bcd96f9 100644
--- a/include/asm-sparc/unistd.h
+++ b/include/asm-sparc/unistd.h
@@ -327,8 +327,11 @@
327#define __NR_getcpu 308 327#define __NR_getcpu 308
328#define __NR_epoll_pwait 309 328#define __NR_epoll_pwait 309
329#define __NR_utimensat 310 329#define __NR_utimensat 310
330#define __NR_signalfd 311
331#define __NR_timerfd 312
332#define __NR_eventfd 313
330 333
331#define NR_SYSCALLS 311 334#define NR_SYSCALLS 314
332 335
333#ifdef __KERNEL__ 336#ifdef __KERNEL__
334#define __ARCH_WANT_IPC_PARSE_VERSION 337#define __ARCH_WANT_IPC_PARSE_VERSION
diff --git a/include/asm-sparc64/poll.h b/include/asm-sparc64/poll.h
index ab6b0d1bb4ad..ebeeb3816c40 100644
--- a/include/asm-sparc64/poll.h
+++ b/include/asm-sparc64/poll.h
@@ -1,24 +1,12 @@
1#ifndef __SPARC64_POLL_H 1#ifndef __SPARC64_POLL_H
2#define __SPARC64_POLL_H 2#define __SPARC64_POLL_H
3 3
4#define POLLIN 1
5#define POLLPRI 2
6#define POLLOUT 4
7#define POLLERR 8
8#define POLLHUP 16
9#define POLLNVAL 32
10#define POLLRDNORM 64
11#define POLLWRNORM POLLOUT 4#define POLLWRNORM POLLOUT
12#define POLLRDBAND 128
13#define POLLWRBAND 256 5#define POLLWRBAND 256
14#define POLLMSG 512 6#define POLLMSG 512
15#define POLLREMOVE 1024 7#define POLLREMOVE 1024
16#define POLLRDHUP 2048 8#define POLLRDHUP 2048
17 9
18struct pollfd { 10#include <asm-generic/poll.h>
19 int fd;
20 short events;
21 short revents;
22};
23 11
24#endif 12#endif
diff --git a/include/asm-sparc64/unistd.h b/include/asm-sparc64/unistd.h
index fcd627594f4c..53e96ed9c024 100644
--- a/include/asm-sparc64/unistd.h
+++ b/include/asm-sparc64/unistd.h
@@ -329,8 +329,11 @@
329#define __NR_getcpu 308 329#define __NR_getcpu 308
330#define __NR_epoll_pwait 309 330#define __NR_epoll_pwait 309
331#define __NR_utimensat 310 331#define __NR_utimensat 310
332#define __NR_signalfd 311
333#define __NR_timerfd 312
334#define __NR_eventfd 313
332 335
333#define NR_SYSCALLS 311 336#define NR_SYSCALLS 314
334 337
335#ifdef __KERNEL__ 338#ifdef __KERNEL__
336/* sysconf options, for SunOS compatibility */ 339/* sysconf options, for SunOS compatibility */
diff --git a/include/asm-um/thread_info.h b/include/asm-um/thread_info.h
index 261e2f4528f6..18a13ba74605 100644
--- a/include/asm-um/thread_info.h
+++ b/include/asm-um/thread_info.h
@@ -22,6 +22,7 @@ struct thread_info {
22 0-0xBFFFFFFF for user 22 0-0xBFFFFFFF for user
23 0-0xFFFFFFFF for kernel */ 23 0-0xFFFFFFFF for kernel */
24 struct restart_block restart_block; 24 struct restart_block restart_block;
25 struct thread_info *real_thread; /* Points to non-IRQ stack */
25}; 26};
26 27
27#define INIT_THREAD_INFO(tsk) \ 28#define INIT_THREAD_INFO(tsk) \
@@ -35,6 +36,7 @@ struct thread_info {
35 .restart_block = { \ 36 .restart_block = { \
36 .fn = do_no_restart_syscall, \ 37 .fn = do_no_restart_syscall, \
37 }, \ 38 }, \
39 .real_thread = NULL, \
38} 40}
39 41
40#define init_thread_info (init_thread_union.thread_info) 42#define init_thread_info (init_thread_union.thread_info)
diff --git a/include/asm-v850/poll.h b/include/asm-v850/poll.h
index c10176c2c28f..803cad0b9b59 100644
--- a/include/asm-v850/poll.h
+++ b/include/asm-v850/poll.h
@@ -1,24 +1,9 @@
1#ifndef __V850_POLL_H__ 1#ifndef __V850_POLL_H__
2#define __V850_POLL_H__ 2#define __V850_POLL_H__
3 3
4#define POLLIN 0x0001
5#define POLLPRI 0x0002
6#define POLLOUT 0x0004
7#define POLLERR 0x0008
8#define POLLHUP 0x0010
9#define POLLNVAL 0x0020
10#define POLLRDNORM 0x0040
11#define POLLWRNORM POLLOUT 4#define POLLWRNORM POLLOUT
12#define POLLRDBAND 0x0080
13#define POLLWRBAND 0x0100 5#define POLLWRBAND 0x0100
14#define POLLMSG 0x0400
15#define POLLREMOVE 0x1000
16#define POLLRDHUP 0x2000
17 6
18struct pollfd { 7#include <asm-generic/poll.h>
19 int fd;
20 short events;
21 short revents;
22};
23 8
24#endif /* __V850_POLL_H__ */ 9#endif /* __V850_POLL_H__ */
diff --git a/include/asm-x86_64/alternative.h b/include/asm-x86_64/alternative.h
index a09fe85c268e..a09427640764 100644
--- a/include/asm-x86_64/alternative.h
+++ b/include/asm-x86_64/alternative.h
@@ -103,6 +103,12 @@ static inline void alternatives_smp_switch(int smp) {}
103 ".previous" : output : [feat] "i" (feature), ##input) 103 ".previous" : output : [feat] "i" (feature), ##input)
104 104
105/* 105/*
106 * use this macro(s) if you need more than one output parameter
107 * in alternative_io
108 */
109#define ASM_OUTPUT2(a, b) a, b
110
111/*
106 * Alternative inline assembly for SMP. 112 * Alternative inline assembly for SMP.
107 * 113 *
108 * The LOCK_PREFIX macro defined here replaces the LOCK and 114 * The LOCK_PREFIX macro defined here replaces the LOCK and
diff --git a/include/asm-x86_64/page.h b/include/asm-x86_64/page.h
index dee632fa457d..e327c830da0c 100644
--- a/include/asm-x86_64/page.h
+++ b/include/asm-x86_64/page.h
@@ -80,6 +80,15 @@ extern unsigned long phys_base;
80#define __PHYSICAL_START CONFIG_PHYSICAL_START 80#define __PHYSICAL_START CONFIG_PHYSICAL_START
81#define __KERNEL_ALIGN 0x200000 81#define __KERNEL_ALIGN 0x200000
82 82
83/*
84 * Make sure kernel is aligned to 2MB address. Catching it at compile
85 * time is better. Change your config file and compile the kernel
86 * for a 2MB aligned address (CONFIG_PHYSICAL_START)
87 */
88#if (CONFIG_PHYSICAL_START % __KERNEL_ALIGN) != 0
89#error "CONFIG_PHYSICAL_START must be a multiple of 2MB"
90#endif
91
83#define __START_KERNEL (__START_KERNEL_map + __PHYSICAL_START) 92#define __START_KERNEL (__START_KERNEL_map + __PHYSICAL_START)
84#define __START_KERNEL_map _AC(0xffffffff80000000, UL) 93#define __START_KERNEL_map _AC(0xffffffff80000000, UL)
85#define __PAGE_OFFSET _AC(0xffff810000000000, UL) 94#define __PAGE_OFFSET _AC(0xffff810000000000, UL)
diff --git a/include/asm-x86_64/poll.h b/include/asm-x86_64/poll.h
index c0475a9d8bb8..c98509d3149e 100644
--- a/include/asm-x86_64/poll.h
+++ b/include/asm-x86_64/poll.h
@@ -1,27 +1 @@
1#ifndef __x86_64_POLL_H #include <asm-generic/poll.h>
2#define __x86_64_POLL_H
3
4/* These are specified by iBCS2 */
5#define POLLIN 0x0001
6#define POLLPRI 0x0002
7#define POLLOUT 0x0004
8#define POLLERR 0x0008
9#define POLLHUP 0x0010
10#define POLLNVAL 0x0020
11
12/* The rest seem to be more-or-less nonstandard. Check them! */
13#define POLLRDNORM 0x0040
14#define POLLRDBAND 0x0080
15#define POLLWRNORM 0x0100
16#define POLLWRBAND 0x0200
17#define POLLMSG 0x0400
18#define POLLREMOVE 0x1000
19#define POLLRDHUP 0x2000
20
21struct pollfd {
22 int fd;
23 short events;
24 short revents;
25};
26
27#endif
diff --git a/include/asm-x86_64/unistd.h b/include/asm-x86_64/unistd.h
index 595703949df3..ae1ed05f2814 100644
--- a/include/asm-x86_64/unistd.h
+++ b/include/asm-x86_64/unistd.h
@@ -621,6 +621,15 @@ __SYSCALL(__NR_vmsplice, sys_vmsplice)
621__SYSCALL(__NR_move_pages, sys_move_pages) 621__SYSCALL(__NR_move_pages, sys_move_pages)
622#define __NR_utimensat 280 622#define __NR_utimensat 280
623__SYSCALL(__NR_utimensat, sys_utimensat) 623__SYSCALL(__NR_utimensat, sys_utimensat)
624#define __IGNORE_getcpu /* implemented as a vsyscall */
625#define __NR_epoll_pwait 281
626__SYSCALL(__NR_epoll_pwait, sys_epoll_pwait)
627#define __NR_signalfd 282
628__SYSCALL(__NR_signalfd, sys_signalfd)
629#define __NR_timerfd 282
630__SYSCALL(__NR_timerfd, sys_timerfd)
631#define __NR_eventfd 283
632__SYSCALL(__NR_eventfd, sys_eventfd)
624 633
625#ifndef __NO_STUBS 634#ifndef __NO_STUBS
626#define __ARCH_WANT_OLD_READDIR 635#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-xtensa/poll.h b/include/asm-xtensa/poll.h
index 6fd94773e866..9d2d5993f068 100644
--- a/include/asm-xtensa/poll.h
+++ b/include/asm-xtensa/poll.h
@@ -11,28 +11,10 @@
11#ifndef _XTENSA_POLL_H 11#ifndef _XTENSA_POLL_H
12#define _XTENSA_POLL_H 12#define _XTENSA_POLL_H
13 13
14
15#define POLLIN 0x0001
16#define POLLPRI 0x0002
17#define POLLOUT 0x0004
18
19#define POLLERR 0x0008
20#define POLLHUP 0x0010
21#define POLLNVAL 0x0020
22
23#define POLLRDNORM 0x0040
24#define POLLRDBAND 0x0080
25#define POLLWRNORM POLLOUT 14#define POLLWRNORM POLLOUT
26#define POLLWRBAND 0x0100 15#define POLLWRBAND 0x0100
27
28#define POLLMSG 0x0400
29#define POLLREMOVE 0x0800 16#define POLLREMOVE 0x0800
30#define POLLRDHUP 0x2000
31 17
32struct pollfd { 18#include <asm-generic/poll.h>
33 int fd;
34 short events;
35 short revents;
36};
37 19
38#endif /* _XTENSA_POLL_H */ 20#endif /* _XTENSA_POLL_H */
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index 94cc04a143f2..bcd01f269f60 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -140,7 +140,6 @@ header-y += snmp.h
140header-y += sockios.h 140header-y += sockios.h
141header-y += som.h 141header-y += som.h
142header-y += sound.h 142header-y += sound.h
143header-y += synclink.h
144header-y += taskstats.h 143header-y += taskstats.h
145header-y += telephony.h 144header-y += telephony.h
146header-y += termios.h 145header-y += termios.h
@@ -191,6 +190,7 @@ unifdef-y += errno.h
191unifdef-y += errqueue.h 190unifdef-y += errqueue.h
192unifdef-y += ethtool.h 191unifdef-y += ethtool.h
193unifdef-y += eventpoll.h 192unifdef-y += eventpoll.h
193unifdef-y += signalfd.h
194unifdef-y += ext2_fs.h 194unifdef-y += ext2_fs.h
195unifdef-y += ext3_fs.h 195unifdef-y += ext3_fs.h
196unifdef-y += fb.h 196unifdef-y += fb.h
@@ -320,6 +320,7 @@ unifdef-y += sonypi.h
320unifdef-y += soundcard.h 320unifdef-y += soundcard.h
321unifdef-y += stat.h 321unifdef-y += stat.h
322unifdef-y += stddef.h 322unifdef-y += stddef.h
323unifdef-y += synclink.h
323unifdef-y += sysctl.h 324unifdef-y += sysctl.h
324unifdef-y += tcp.h 325unifdef-y += tcp.h
325unifdef-y += time.h 326unifdef-y += time.h
diff --git a/include/linux/aio.h b/include/linux/aio.h
index 43dc2ebfaa0e..b903fc02bdb7 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -119,6 +119,12 @@ struct kiocb {
119 119
120 struct list_head ki_list; /* the aio core uses this 120 struct list_head ki_list; /* the aio core uses this
121 * for cancellation */ 121 * for cancellation */
122
123 /*
124 * If the aio_resfd field of the userspace iocb is not zero,
125 * this is the underlying file* to deliver event to.
126 */
127 struct file *ki_eventfd;
122}; 128};
123 129
124#define is_sync_kiocb(iocb) ((iocb)->ki_key == KIOCB_SYNC_KEY) 130#define is_sync_kiocb(iocb) ((iocb)->ki_key == KIOCB_SYNC_KEY)
diff --git a/include/linux/aio_abi.h b/include/linux/aio_abi.h
index e3ca0a485cc6..9e0172931315 100644
--- a/include/linux/aio_abi.h
+++ b/include/linux/aio_abi.h
@@ -45,6 +45,14 @@ enum {
45 IOCB_CMD_PWRITEV = 8, 45 IOCB_CMD_PWRITEV = 8,
46}; 46};
47 47
48/*
49 * Valid flags for the "aio_flags" member of the "struct iocb".
50 *
51 * IOCB_FLAG_RESFD - Set if the "aio_resfd" member of the "struct iocb"
52 * is valid.
53 */
54#define IOCB_FLAG_RESFD (1 << 0)
55
48/* read() from /dev/aio returns these structures. */ 56/* read() from /dev/aio returns these structures. */
49struct io_event { 57struct io_event {
50 __u64 data; /* the data field from the iocb */ 58 __u64 data; /* the data field from the iocb */
@@ -84,7 +92,15 @@ struct iocb {
84 92
85 /* extra parameters */ 93 /* extra parameters */
86 __u64 aio_reserved2; /* TODO: use this for a (struct sigevent *) */ 94 __u64 aio_reserved2; /* TODO: use this for a (struct sigevent *) */
87 __u64 aio_reserved3; 95
96 /* flags for the "struct iocb" */
97 __u32 aio_flags;
98
99 /*
100 * if the IOCB_FLAG_RESFD flag of "aio_flags" is set, this is an
101 * eventfd to signal AIO readiness to
102 */
103 __u32 aio_resfd;
88}; /* 64 bytes */ 104}; /* 64 bytes */
89 105
90#undef IFBIG 106#undef IFBIG
diff --git a/include/linux/anon_inodes.h b/include/linux/anon_inodes.h
new file mode 100644
index 000000000000..b2e1ba325b9a
--- /dev/null
+++ b/include/linux/anon_inodes.h
@@ -0,0 +1,16 @@
1/*
2 * include/linux/anon_inodes.h
3 *
4 * Copyright (C) 2007 Davide Libenzi <davidel@xmailserver.org>
5 *
6 */
7
8#ifndef _LINUX_ANON_INODES_H
9#define _LINUX_ANON_INODES_H
10
11int anon_inode_getfd(int *pfd, struct inode **pinode, struct file **pfile,
12 const char *name, const struct file_operations *fops,
13 void *priv);
14
15#endif /* _LINUX_ANON_INODES_H */
16
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 773e30df11ee..fccc6e50298a 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -91,6 +91,7 @@
91#define AUDIT_MQ_GETSETATTR 1315 /* POSIX MQ get/set attribute record type */ 91#define AUDIT_MQ_GETSETATTR 1315 /* POSIX MQ get/set attribute record type */
92#define AUDIT_KERNEL_OTHER 1316 /* For use by 3rd party modules */ 92#define AUDIT_KERNEL_OTHER 1316 /* For use by 3rd party modules */
93#define AUDIT_FD_PAIR 1317 /* audit record for pipe/socketpair */ 93#define AUDIT_FD_PAIR 1317 /* audit record for pipe/socketpair */
94#define AUDIT_OBJ_PID 1318 /* ptrace target */
94 95
95#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */ 96#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */
96#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */ 97#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */
@@ -111,6 +112,7 @@
111#define AUDIT_FIRST_KERN_ANOM_MSG 1700 112#define AUDIT_FIRST_KERN_ANOM_MSG 1700
112#define AUDIT_LAST_KERN_ANOM_MSG 1799 113#define AUDIT_LAST_KERN_ANOM_MSG 1799
113#define AUDIT_ANOM_PROMISCUOUS 1700 /* Device changed promiscuous mode */ 114#define AUDIT_ANOM_PROMISCUOUS 1700 /* Device changed promiscuous mode */
115#define AUDIT_ANOM_ABEND 1701 /* Process ended abnormally */
114 116
115#define AUDIT_KERNEL 2000 /* Asynchronous audit record. NOT A REQUEST. */ 117#define AUDIT_KERNEL 2000 /* Asynchronous audit record. NOT A REQUEST. */
116 118
@@ -148,6 +150,8 @@
148#define AUDIT_CLASS_READ_32 5 150#define AUDIT_CLASS_READ_32 5
149#define AUDIT_CLASS_WRITE 6 151#define AUDIT_CLASS_WRITE 6
150#define AUDIT_CLASS_WRITE_32 7 152#define AUDIT_CLASS_WRITE_32 7
153#define AUDIT_CLASS_SIGNAL 8
154#define AUDIT_CLASS_SIGNAL_32 9
151 155
152/* This bitmask is used to validate user input. It represents all bits that 156/* This bitmask is used to validate user input. It represents all bits that
153 * are currently used in an audit field constant understood by the kernel. 157 * are currently used in an audit field constant understood by the kernel.
@@ -337,6 +341,7 @@ struct mqstat;
337#define AUDITSC_RESULT(x) ( ((long)(x))<0?AUDITSC_FAILURE:AUDITSC_SUCCESS ) 341#define AUDITSC_RESULT(x) ( ((long)(x))<0?AUDITSC_FAILURE:AUDITSC_SUCCESS )
338extern int __init audit_register_class(int class, unsigned *list); 342extern int __init audit_register_class(int class, unsigned *list);
339extern int audit_classify_syscall(int abi, unsigned syscall); 343extern int audit_classify_syscall(int abi, unsigned syscall);
344extern int audit_classify_arch(int arch);
340#ifdef CONFIG_AUDITSYSCALL 345#ifdef CONFIG_AUDITSYSCALL
341/* These are defined in auditsc.c */ 346/* These are defined in auditsc.c */
342 /* Public API */ 347 /* Public API */
@@ -351,7 +356,8 @@ extern void audit_putname(const char *name);
351extern void __audit_inode(const char *name, const struct inode *inode); 356extern void __audit_inode(const char *name, const struct inode *inode);
352extern void __audit_inode_child(const char *dname, const struct inode *inode, 357extern void __audit_inode_child(const char *dname, const struct inode *inode,
353 const struct inode *parent); 358 const struct inode *parent);
354extern void __audit_inode_update(const struct inode *inode); 359extern void __audit_ptrace(struct task_struct *t);
360
355static inline int audit_dummy_context(void) 361static inline int audit_dummy_context(void)
356{ 362{
357 void *p = current->audit_context; 363 void *p = current->audit_context;
@@ -372,9 +378,12 @@ static inline void audit_inode_child(const char *dname,
372 if (unlikely(!audit_dummy_context())) 378 if (unlikely(!audit_dummy_context()))
373 __audit_inode_child(dname, inode, parent); 379 __audit_inode_child(dname, inode, parent);
374} 380}
375static inline void audit_inode_update(const struct inode *inode) { 381void audit_core_dumps(long signr);
382
383static inline void audit_ptrace(struct task_struct *t)
384{
376 if (unlikely(!audit_dummy_context())) 385 if (unlikely(!audit_dummy_context()))
377 __audit_inode_update(inode); 386 __audit_ptrace(t);
378} 387}
379 388
380 /* Private API (for audit.c only) */ 389 /* Private API (for audit.c only) */
@@ -447,6 +456,7 @@ static inline int audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat)
447 return 0; 456 return 0;
448} 457}
449extern int audit_n_rules; 458extern int audit_n_rules;
459extern int audit_signals;
450#else 460#else
451#define audit_alloc(t) ({ 0; }) 461#define audit_alloc(t) ({ 0; })
452#define audit_free(t) do { ; } while (0) 462#define audit_free(t) do { ; } while (0)
@@ -457,10 +467,9 @@ extern int audit_n_rules;
457#define audit_putname(n) do { ; } while (0) 467#define audit_putname(n) do { ; } while (0)
458#define __audit_inode(n,i) do { ; } while (0) 468#define __audit_inode(n,i) do { ; } while (0)
459#define __audit_inode_child(d,i,p) do { ; } while (0) 469#define __audit_inode_child(d,i,p) do { ; } while (0)
460#define __audit_inode_update(i) do { ; } while (0)
461#define audit_inode(n,i) do { ; } while (0) 470#define audit_inode(n,i) do { ; } while (0)
462#define audit_inode_child(d,i,p) do { ; } while (0) 471#define audit_inode_child(d,i,p) do { ; } while (0)
463#define audit_inode_update(i) do { ; } while (0) 472#define audit_core_dumps(i) do { ; } while (0)
464#define auditsc_get_stamp(c,t,s) do { BUG(); } while (0) 473#define auditsc_get_stamp(c,t,s) do { BUG(); } while (0)
465#define audit_get_loginuid(c) ({ -1; }) 474#define audit_get_loginuid(c) ({ -1; })
466#define audit_log_task_context(b) do { ; } while (0) 475#define audit_log_task_context(b) do { ; } while (0)
@@ -477,7 +486,9 @@ extern int audit_n_rules;
477#define audit_mq_timedreceive(d,l,p,t) ({ 0; }) 486#define audit_mq_timedreceive(d,l,p,t) ({ 0; })
478#define audit_mq_notify(d,n) ({ 0; }) 487#define audit_mq_notify(d,n) ({ 0; })
479#define audit_mq_getsetattr(d,s) ({ 0; }) 488#define audit_mq_getsetattr(d,s) ({ 0; })
489#define audit_ptrace(t) ((void)0)
480#define audit_n_rules 0 490#define audit_n_rules 0
491#define audit_signals 0
481#endif 492#endif
482 493
483#ifdef CONFIG_AUDIT 494#ifdef CONFIG_AUDIT
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 70a157a130bb..636502c02734 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -225,6 +225,11 @@ static inline int compat_timespec_compare(struct compat_timespec *lhs,
225 return lhs->tv_nsec - rhs->tv_nsec; 225 return lhs->tv_nsec - rhs->tv_nsec;
226} 226}
227 227
228extern int get_compat_itimerspec(struct itimerspec *dst,
229 const struct compat_itimerspec __user *src);
230extern int put_compat_itimerspec(struct compat_itimerspec __user *dst,
231 const struct itimerspec *src);
232
228asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp); 233asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
229 234
230extern int compat_printk(const char *fmt, ...); 235extern int compat_printk(const char *fmt, ...);
diff --git a/include/linux/eventfd.h b/include/linux/eventfd.h
new file mode 100644
index 000000000000..0d6ecc60b94d
--- /dev/null
+++ b/include/linux/eventfd.h
@@ -0,0 +1,29 @@
1/*
2 * include/linux/eventfd.h
3 *
4 * Copyright (C) 2007 Davide Libenzi <davidel@xmailserver.org>
5 *
6 */
7
8#ifndef _LINUX_EVENTFD_H
9#define _LINUX_EVENTFD_H
10
11
12#ifdef __KERNEL__
13
14#ifdef CONFIG_EVENTFD
15
16struct file *eventfd_fget(int fd);
17int eventfd_signal(struct file *file, int n);
18
19#else /* CONFIG_EVENTFD */
20
21#define eventfd_fget(fd) ERR_PTR(-ENOSYS)
22#define eventfd_signal(f, n) 0
23
24#endif /* CONFIG_EVENTFD */
25
26#endif /* __KERNEL__ */
27
28#endif /* _LINUX_EVENTFD_H */
29
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index f589559cf070..4c03ee353e78 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -434,6 +434,10 @@ static inline struct block_device *bdget_disk(struct gendisk *disk, int index)
434 434
435#endif 435#endif
436 436
437#endif 437#else /* CONFIG_BLOCK */
438
439static inline void printk_all_partitions(void) { }
440
441#endif /* CONFIG_BLOCK */
438 442
439#endif 443#endif
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 37076b116ed0..827ee748fd4c 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -275,6 +275,7 @@ struct hid_item {
275#define HID_QUIRK_LOGITECH_DESCRIPTOR 0x00100000 275#define HID_QUIRK_LOGITECH_DESCRIPTOR 0x00100000
276#define HID_QUIRK_DUPLICATE_USAGES 0x00200000 276#define HID_QUIRK_DUPLICATE_USAGES 0x00200000
277#define HID_QUIRK_RESET_LEDS 0x00400000 277#define HID_QUIRK_RESET_LEDS 0x00400000
278#define HID_QUIRK_SWAPPED_MIN_MAX 0x00800000
278 279
279/* 280/*
280 * This is the global environment of the parser. This information is 281 * This is the global environment of the parser. This information is
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h
index 0e8da684ce68..aa83d4163096 100644
--- a/include/linux/i2c-id.h
+++ b/include/linux/i2c-id.h
@@ -117,6 +117,7 @@
117#define I2C_DRIVERID_ISL1208 88 /* Intersil ISL1208 RTC */ 117#define I2C_DRIVERID_ISL1208 88 /* Intersil ISL1208 RTC */
118#define I2C_DRIVERID_WM8731 89 /* Wolfson WM8731 audio codec */ 118#define I2C_DRIVERID_WM8731 89 /* Wolfson WM8731 audio codec */
119#define I2C_DRIVERID_WM8750 90 /* Wolfson WM8750 audio codec */ 119#define I2C_DRIVERID_WM8750 90 /* Wolfson WM8750 audio codec */
120#define I2C_DRIVERID_WM8753 91 /* Wolfson WM8753 audio codec */
120 121
121#define I2C_DRIVERID_I2CDEV 900 122#define I2C_DRIVERID_I2CDEV 900
122#define I2C_DRIVERID_ARP 902 /* SMBus ARP Client */ 123#define I2C_DRIVERID_ARP 902 /* SMBus ARP Client */
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index 45170b2fa253..276ccaa2670c 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -65,9 +65,9 @@
65 .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \ 65 .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \
66 .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \ 66 .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \
67 .rlim = INIT_RLIMITS, \ 67 .rlim = INIT_RLIMITS, \
68 .pgrp = 1, \ 68 .pgrp = 0, \
69 .tty_old_pgrp = NULL, \ 69 .tty_old_pgrp = NULL, \
70 { .__session = 1}, \ 70 { .__session = 0}, \
71} 71}
72 72
73extern struct nsproxy init_nsproxy; 73extern struct nsproxy init_nsproxy;
@@ -84,10 +84,33 @@ extern struct nsproxy init_nsproxy;
84 .count = ATOMIC_INIT(1), \ 84 .count = ATOMIC_INIT(1), \
85 .action = { { { .sa_handler = NULL, } }, }, \ 85 .action = { { { .sa_handler = NULL, } }, }, \
86 .siglock = __SPIN_LOCK_UNLOCKED(sighand.siglock), \ 86 .siglock = __SPIN_LOCK_UNLOCKED(sighand.siglock), \
87 .signalfd_list = LIST_HEAD_INIT(sighand.signalfd_list), \
87} 88}
88 89
89extern struct group_info init_groups; 90extern struct group_info init_groups;
90 91
92#define INIT_STRUCT_PID { \
93 .count = ATOMIC_INIT(1), \
94 .nr = 0, \
95 /* Don't put this struct pid in pid_hash */ \
96 .pid_chain = { .next = NULL, .pprev = NULL }, \
97 .tasks = { \
98 { .first = &init_task.pids[PIDTYPE_PID].node }, \
99 { .first = &init_task.pids[PIDTYPE_PGID].node }, \
100 { .first = &init_task.pids[PIDTYPE_SID].node }, \
101 }, \
102 .rcu = RCU_HEAD_INIT, \
103}
104
105#define INIT_PID_LINK(type) \
106{ \
107 .node = { \
108 .next = NULL, \
109 .pprev = &init_struct_pid.tasks[type].first, \
110 }, \
111 .pid = &init_struct_pid, \
112}
113
91/* 114/*
92 * INIT_TASK is used to set up the first task table, touch at 115 * INIT_TASK is used to set up the first task table, touch at
93 * your own risk!. Base=0, limit=0x1fffff (=2MB) 116 * your own risk!. Base=0, limit=0x1fffff (=2MB)
@@ -139,6 +162,11 @@ extern struct group_info init_groups;
139 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ 162 .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
140 .fs_excl = ATOMIC_INIT(0), \ 163 .fs_excl = ATOMIC_INIT(0), \
141 .pi_lock = __SPIN_LOCK_UNLOCKED(tsk.pi_lock), \ 164 .pi_lock = __SPIN_LOCK_UNLOCKED(tsk.pi_lock), \
165 .pids = { \
166 [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \
167 [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \
168 [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID), \
169 }, \
142 INIT_TRACE_IRQFLAGS \ 170 INIT_TRACE_IRQFLAGS \
143 INIT_LOCKDEP \ 171 INIT_LOCKDEP \
144} 172}
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index f7b01b9a35b3..5323f6275854 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -241,6 +241,16 @@ static inline void __deprecated save_and_cli(unsigned long *x)
241#define save_and_cli(x) save_and_cli(&x) 241#define save_and_cli(x) save_and_cli(&x)
242#endif /* CONFIG_SMP */ 242#endif /* CONFIG_SMP */
243 243
244/* Some architectures might implement lazy enabling/disabling of
245 * interrupts. In some cases, such as stop_machine, we might want
246 * to ensure that after a local_irq_disable(), interrupts have
247 * really been disabled in hardware. Such architectures need to
248 * implement the following hook.
249 */
250#ifndef hard_irq_disable
251#define hard_irq_disable() do { } while(0)
252#endif
253
244/* PLEASE, avoid to allocate new softirqs, if you need not _really_ high 254/* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
245 frequency threaded job scheduling. For almost all the purposes 255 frequency threaded job scheduling. For almost all the purposes
246 tasklets are more than enough. F.e. all serial device BHs et 256 tasklets are more than enough. F.e. all serial device BHs et
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 8645181fca0f..45353d757cd0 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -213,6 +213,17 @@ extern enum system_states {
213 213
214extern void dump_stack(void); 214extern void dump_stack(void);
215 215
216enum {
217 DUMP_PREFIX_NONE,
218 DUMP_PREFIX_ADDRESS,
219 DUMP_PREFIX_OFFSET
220};
221extern void hex_dump_to_buffer(const void *buf, size_t len, char *linebuf,
222 size_t linebuflen);
223extern void print_hex_dump(const char *level, int prefix_type,
224 void *buf, size_t len);
225#define hex_asc(x) "0123456789abcdef"[x]
226
216#ifdef DEBUG 227#ifdef DEBUG
217/* If you are writing a driver, please use dev_dbg instead */ 228/* If you are writing a driver, please use dev_dbg instead */
218#define pr_debug(fmt,arg...) \ 229#define pr_debug(fmt,arg...) \
@@ -299,8 +310,8 @@ static inline int __attribute__ ((format (printf, 1, 2))) pr_debug(const char *
299 * 310 *
300 */ 311 */
301#define container_of(ptr, type, member) ({ \ 312#define container_of(ptr, type, member) ({ \
302 const typeof( ((type *)0)->member ) *__mptr = (ptr); \ 313 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
303 (type *)( (char *)__mptr - offsetof(type,member) );}) 314 (type *)( (char *)__mptr - offsetof(type,member) );})
304 315
305/* 316/*
306 * Check at compile time that something is of a particular type. 317 * Check at compile time that something is of a particular type.
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 7906d750aa77..27d936279574 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -140,7 +140,6 @@ enum {
140 140
141 ATA_DFLAG_PIO = (1 << 8), /* device limited to PIO mode */ 141 ATA_DFLAG_PIO = (1 << 8), /* device limited to PIO mode */
142 ATA_DFLAG_NCQ_OFF = (1 << 9), /* device limited to non-NCQ mode */ 142 ATA_DFLAG_NCQ_OFF = (1 << 9), /* device limited to non-NCQ mode */
143 ATA_DFLAG_SUSPENDED = (1 << 10), /* device suspended */
144 ATA_DFLAG_INIT_MASK = (1 << 16) - 1, 143 ATA_DFLAG_INIT_MASK = (1 << 16) - 1,
145 144
146 ATA_DFLAG_DETACH = (1 << 16), 145 ATA_DFLAG_DETACH = (1 << 16),
@@ -191,6 +190,7 @@ enum {
191 ATA_PFLAG_LOADING = (1 << 4), /* boot/loading probe */ 190 ATA_PFLAG_LOADING = (1 << 4), /* boot/loading probe */
192 ATA_PFLAG_UNLOADING = (1 << 5), /* module is unloading */ 191 ATA_PFLAG_UNLOADING = (1 << 5), /* module is unloading */
193 ATA_PFLAG_SCSI_HOTPLUG = (1 << 6), /* SCSI hotplug scheduled */ 192 ATA_PFLAG_SCSI_HOTPLUG = (1 << 6), /* SCSI hotplug scheduled */
193 ATA_PFLAG_INITIALIZING = (1 << 7), /* being initialized, don't touch */
194 194
195 ATA_PFLAG_FLUSH_PORT_TASK = (1 << 16), /* flush port task */ 195 ATA_PFLAG_FLUSH_PORT_TASK = (1 << 16), /* flush port task */
196 ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */ 196 ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */
@@ -254,10 +254,6 @@ enum {
254 ATA_DMA_PAD_SZ = 4, 254 ATA_DMA_PAD_SZ = 4,
255 ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE, 255 ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE,
256 256
257 /* masks for port functions */
258 ATA_PORT_PRIMARY = (1 << 0),
259 ATA_PORT_SECONDARY = (1 << 1),
260
261 /* ering size */ 257 /* ering size */
262 ATA_ERING_SIZE = 32, 258 ATA_ERING_SIZE = 32,
263 259
@@ -268,13 +264,9 @@ enum {
268 ATA_EH_REVALIDATE = (1 << 0), 264 ATA_EH_REVALIDATE = (1 << 0),
269 ATA_EH_SOFTRESET = (1 << 1), 265 ATA_EH_SOFTRESET = (1 << 1),
270 ATA_EH_HARDRESET = (1 << 2), 266 ATA_EH_HARDRESET = (1 << 2),
271 ATA_EH_SUSPEND = (1 << 3),
272 ATA_EH_RESUME = (1 << 4),
273 ATA_EH_PM_FREEZE = (1 << 5),
274 267
275 ATA_EH_RESET_MASK = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, 268 ATA_EH_RESET_MASK = ATA_EH_SOFTRESET | ATA_EH_HARDRESET,
276 ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE | ATA_EH_SUSPEND | 269 ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE,
277 ATA_EH_RESUME | ATA_EH_PM_FREEZE,
278 270
279 /* ata_eh_info->flags */ 271 /* ata_eh_info->flags */
280 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ 272 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */
@@ -466,7 +458,7 @@ struct ata_device {
466 struct ata_ering ering; 458 struct ata_ering ering;
467 int spdn_cnt; 459 int spdn_cnt;
468 unsigned int horkage; /* List of broken features */ 460 unsigned int horkage; /* List of broken features */
469#ifdef CONFIG_SATA_ACPI 461#ifdef CONFIG_ATA_ACPI
470 /* ACPI objects info */ 462 /* ACPI objects info */
471 acpi_handle obj_handle; 463 acpi_handle obj_handle;
472#endif 464#endif
@@ -693,8 +685,8 @@ extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes);
693extern void ata_port_disable(struct ata_port *); 685extern void ata_port_disable(struct ata_port *);
694extern void ata_std_ports(struct ata_ioports *ioaddr); 686extern void ata_std_ports(struct ata_ioports *ioaddr);
695#ifdef CONFIG_PCI 687#ifdef CONFIG_PCI
696extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, 688extern int ata_pci_init_one (struct pci_dev *pdev,
697 unsigned int n_ports); 689 const struct ata_port_info * const * ppi);
698extern void ata_pci_remove_one (struct pci_dev *pdev); 690extern void ata_pci_remove_one (struct pci_dev *pdev);
699#ifdef CONFIG_PM 691#ifdef CONFIG_PM
700extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg); 692extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg);
@@ -736,8 +728,6 @@ extern int sata_scr_write_flush(struct ata_port *ap, int reg, u32 val);
736extern int ata_port_online(struct ata_port *ap); 728extern int ata_port_online(struct ata_port *ap);
737extern int ata_port_offline(struct ata_port *ap); 729extern int ata_port_offline(struct ata_port *ap);
738#ifdef CONFIG_PM 730#ifdef CONFIG_PM
739extern int ata_scsi_device_resume(struct scsi_device *);
740extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t mesg);
741extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg); 731extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg);
742extern void ata_host_resume(struct ata_host *host); 732extern void ata_host_resume(struct ata_host *host);
743#endif 733#endif
@@ -861,11 +851,11 @@ struct pci_bits {
861 unsigned long val; 851 unsigned long val;
862}; 852};
863 853
864extern int ata_pci_init_native_host(struct ata_host *host, 854extern int ata_pci_init_native_host(struct ata_host *host);
865 unsigned int port_mask); 855extern int ata_pci_init_bmdma(struct ata_host *host);
866extern int ata_pci_prepare_native_host(struct pci_dev *pdev, 856extern int ata_pci_prepare_native_host(struct pci_dev *pdev,
867 const struct ata_port_info * const * ppi, 857 const struct ata_port_info * const * ppi,
868 int n_ports, struct ata_host **r_host); 858 struct ata_host **r_host);
869extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); 859extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
870extern unsigned long ata_pci_default_filter(struct ata_device *, unsigned long); 860extern unsigned long ata_pci_default_filter(struct ata_device *, unsigned long);
871#endif /* CONFIG_PCI */ 861#endif /* CONFIG_PCI */
@@ -1008,11 +998,6 @@ static inline unsigned int ata_dev_absent(const struct ata_device *dev)
1008 return ata_class_absent(dev->class); 998 return ata_class_absent(dev->class);
1009} 999}
1010 1000
1011static inline unsigned int ata_dev_ready(const struct ata_device *dev)
1012{
1013 return ata_dev_enabled(dev) && !(dev->flags & ATA_DFLAG_SUSPENDED);
1014}
1015
1016/* 1001/*
1017 * port helpers 1002 * port helpers
1018 */ 1003 */
diff --git a/include/linux/list.h b/include/linux/list.h
index 9202703be2a4..f29fc9c1a964 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -264,8 +264,8 @@ static inline void list_del_init(struct list_head *entry)
264 */ 264 */
265static inline void list_move(struct list_head *list, struct list_head *head) 265static inline void list_move(struct list_head *list, struct list_head *head)
266{ 266{
267 __list_del(list->prev, list->next); 267 __list_del(list->prev, list->next);
268 list_add(list, head); 268 list_add(list, head);
269} 269}
270 270
271/** 271/**
@@ -276,8 +276,8 @@ static inline void list_move(struct list_head *list, struct list_head *head)
276static inline void list_move_tail(struct list_head *list, 276static inline void list_move_tail(struct list_head *list,
277 struct list_head *head) 277 struct list_head *head)
278{ 278{
279 __list_del(list->prev, list->next); 279 __list_del(list->prev, list->next);
280 list_add_tail(list, head); 280 list_add_tail(list, head);
281} 281}
282 282
283/** 283/**
diff --git a/include/linux/magic.h b/include/linux/magic.h
index a9c6567fe70c..9d713c03e3da 100644
--- a/include/linux/magic.h
+++ b/include/linux/magic.h
@@ -14,6 +14,7 @@
14#define ISOFS_SUPER_MAGIC 0x9660 14#define ISOFS_SUPER_MAGIC 0x9660
15#define JFFS2_SUPER_MAGIC 0x72b6 15#define JFFS2_SUPER_MAGIC 0x72b6
16#define KVMFS_SUPER_MAGIC 0x19700426 16#define KVMFS_SUPER_MAGIC 0x19700426
17#define ANON_INODE_FS_MAGIC 0x09041934
17 18
18#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */ 19#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
19#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */ 20#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
diff --git a/include/linux/module.h b/include/linux/module.h
index 792d483c9af7..e6e0f86ef5fc 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -124,7 +124,7 @@ extern struct module __this_module;
124 */ 124 */
125#define MODULE_LICENSE(_license) MODULE_INFO(license, _license) 125#define MODULE_LICENSE(_license) MODULE_INFO(license, _license)
126 126
127/* Author, ideally of form NAME <EMAIL>[, NAME <EMAIL>]*[ and NAME <EMAIL>] */ 127/* Author, ideally of form NAME[, NAME]*[ and NAME] */
128#define MODULE_AUTHOR(_author) MODULE_INFO(author, _author) 128#define MODULE_AUTHOR(_author) MODULE_INFO(author, _author)
129 129
130/* What your module does. */ 130/* What your module does. */
diff --git a/include/linux/mpage.h b/include/linux/mpage.h
index cc5fb75af78a..068a0c9946af 100644
--- a/include/linux/mpage.h
+++ b/include/linux/mpage.h
@@ -12,7 +12,6 @@
12#ifdef CONFIG_BLOCK 12#ifdef CONFIG_BLOCK
13 13
14struct writeback_control; 14struct writeback_control;
15typedef int (writepage_t)(struct page *page, struct writeback_control *wbc);
16 15
17int mpage_readpages(struct address_space *mapping, struct list_head *pages, 16int mpage_readpages(struct address_space *mapping, struct list_head *pages,
18 unsigned nr_pages, get_block_t get_block); 17 unsigned nr_pages, get_block_t get_block);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 30446222b396..f671cd2f133f 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -467,6 +467,8 @@ struct net_device
467 /* device index hash chain */ 467 /* device index hash chain */
468 struct hlist_node index_hlist; 468 struct hlist_node index_hlist;
469 469
470 struct net_device *link_watch_next;
471
470 /* register/unregister state machine */ 472 /* register/unregister state machine */
471 enum { NETREG_UNINITIALIZED=0, 473 enum { NETREG_UNINITIALIZED=0,
472 NETREG_REGISTERED, /* completed register_netdevice */ 474 NETREG_REGISTERED, /* completed register_netdevice */
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index 022edfa97ed9..7e733a6ba4f6 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -54,6 +54,14 @@ struct xt_entry_target
54 unsigned char data[0]; 54 unsigned char data[0];
55}; 55};
56 56
57#define XT_TARGET_INIT(__name, __size) \
58{ \
59 .target.u.user = { \
60 .target_size = XT_ALIGN(__size), \
61 .name = __name, \
62 }, \
63}
64
57struct xt_standard_target 65struct xt_standard_target
58{ 66{
59 struct xt_entry_target target; 67 struct xt_entry_target target;
diff --git a/include/linux/netfilter_arp/arp_tables.h b/include/linux/netfilter_arp/arp_tables.h
index 24c8786d12e9..584cd1b18f12 100644
--- a/include/linux/netfilter_arp/arp_tables.h
+++ b/include/linux/netfilter_arp/arp_tables.h
@@ -238,6 +238,47 @@ static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e
238 */ 238 */
239#ifdef __KERNEL__ 239#ifdef __KERNEL__
240 240
241/* Standard entry. */
242struct arpt_standard
243{
244 struct arpt_entry entry;
245 struct arpt_standard_target target;
246};
247
248struct arpt_error_target
249{
250 struct arpt_entry_target target;
251 char errorname[ARPT_FUNCTION_MAXNAMELEN];
252};
253
254struct arpt_error
255{
256 struct arpt_entry entry;
257 struct arpt_error_target target;
258};
259
260#define ARPT_ENTRY_INIT(__size) \
261{ \
262 .target_offset = sizeof(struct arpt_entry), \
263 .next_offset = (__size), \
264}
265
266#define ARPT_STANDARD_INIT(__verdict) \
267{ \
268 .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_standard)), \
269 .target = XT_TARGET_INIT(ARPT_STANDARD_TARGET, \
270 sizeof(struct arpt_standard_target)), \
271 .target.verdict = -(__verdict) - 1, \
272}
273
274#define ARPT_ERROR_INIT \
275{ \
276 .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_error)), \
277 .target = XT_TARGET_INIT(ARPT_ERROR_TARGET, \
278 sizeof(struct arpt_error_target)), \
279 .target.errorname = "ERROR", \
280}
281
241#define arpt_register_target(tgt) \ 282#define arpt_register_target(tgt) \
242({ (tgt)->family = NF_ARP; \ 283({ (tgt)->family = NF_ARP; \
243 xt_register_target(tgt); }) 284 xt_register_target(tgt); })
diff --git a/include/linux/netfilter_ipv4/ip_tables.h b/include/linux/netfilter_ipv4/ip_tables.h
index 9527296595cd..2f46dd728ee1 100644
--- a/include/linux/netfilter_ipv4/ip_tables.h
+++ b/include/linux/netfilter_ipv4/ip_tables.h
@@ -295,6 +295,28 @@ struct ipt_error
295 struct ipt_error_target target; 295 struct ipt_error_target target;
296}; 296};
297 297
298#define IPT_ENTRY_INIT(__size) \
299{ \
300 .target_offset = sizeof(struct ipt_entry), \
301 .next_offset = (__size), \
302}
303
304#define IPT_STANDARD_INIT(__verdict) \
305{ \
306 .entry = IPT_ENTRY_INIT(sizeof(struct ipt_standard)), \
307 .target = XT_TARGET_INIT(IPT_STANDARD_TARGET, \
308 sizeof(struct xt_standard_target)), \
309 .target.verdict = -(__verdict) - 1, \
310}
311
312#define IPT_ERROR_INIT \
313{ \
314 .entry = IPT_ENTRY_INIT(sizeof(struct ipt_error)), \
315 .target = XT_TARGET_INIT(IPT_ERROR_TARGET, \
316 sizeof(struct ipt_error_target)), \
317 .target.errorname = "ERROR", \
318}
319
298extern unsigned int ipt_do_table(struct sk_buff **pskb, 320extern unsigned int ipt_do_table(struct sk_buff **pskb,
299 unsigned int hook, 321 unsigned int hook,
300 const struct net_device *in, 322 const struct net_device *in,
diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h
index 61aa10412fc8..4686f8342cbd 100644
--- a/include/linux/netfilter_ipv6/ip6_tables.h
+++ b/include/linux/netfilter_ipv6/ip6_tables.h
@@ -123,6 +123,28 @@ struct ip6t_error
123 struct ip6t_error_target target; 123 struct ip6t_error_target target;
124}; 124};
125 125
126#define IP6T_ENTRY_INIT(__size) \
127{ \
128 .target_offset = sizeof(struct ip6t_entry), \
129 .next_offset = (__size), \
130}
131
132#define IP6T_STANDARD_INIT(__verdict) \
133{ \
134 .entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_standard)), \
135 .target = XT_TARGET_INIT(IP6T_STANDARD_TARGET, \
136 sizeof(struct ip6t_standard_target)), \
137 .target.verdict = -(__verdict) - 1, \
138}
139
140#define IP6T_ERROR_INIT \
141{ \
142 .entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_error)), \
143 .target = XT_TARGET_INIT(IP6T_ERROR_TARGET, \
144 sizeof(struct ip6t_error_target)), \
145 .target.errorname = "ERROR", \
146}
147
126/* 148/*
127 * New IP firewall options for [gs]etsockopt at the RAW IP level. 149 * New IP firewall options for [gs]etsockopt at the RAW IP level.
128 * Unlike BSD Linux inherits IP options so you don't have to use 150 * Unlike BSD Linux inherits IP options so you don't have to use
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index ae849f0d4430..ccd85e4d3b8f 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -370,6 +370,7 @@
370#define PCI_DEVICE_ID_ATI_IXP600_SATA 0x4380 370#define PCI_DEVICE_ID_ATI_IXP600_SATA 0x4380
371#define PCI_DEVICE_ID_ATI_IXP600_SMBUS 0x4385 371#define PCI_DEVICE_ID_ATI_IXP600_SMBUS 0x4385
372#define PCI_DEVICE_ID_ATI_IXP600_IDE 0x438c 372#define PCI_DEVICE_ID_ATI_IXP600_IDE 0x438c
373#define PCI_DEVICE_ID_ATI_IXP700_SATA 0x4390
373 374
374#define PCI_VENDOR_ID_VLSI 0x1004 375#define PCI_VENDOR_ID_VLSI 0x1004
375#define PCI_DEVICE_ID_VLSI_82C592 0x0005 376#define PCI_DEVICE_ID_VLSI_82C592 0x0005
diff --git a/include/linux/pid.h b/include/linux/pid.h
index 2ac27f9997dd..1e0e4e3423a6 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -51,6 +51,8 @@ struct pid
51 struct rcu_head rcu; 51 struct rcu_head rcu;
52}; 52};
53 53
54extern struct pid init_struct_pid;
55
54struct pid_link 56struct pid_link
55{ 57{
56 struct hlist_node node; 58 struct hlist_node node;
@@ -76,8 +78,7 @@ extern struct pid *get_task_pid(struct task_struct *task, enum pid_type type);
76 * write-held. 78 * write-held.
77 */ 79 */
78extern int FASTCALL(attach_pid(struct task_struct *task, 80extern int FASTCALL(attach_pid(struct task_struct *task,
79 enum pid_type type, int nr)); 81 enum pid_type type, struct pid *pid));
80
81extern void FASTCALL(detach_pid(struct task_struct *task, enum pid_type)); 82extern void FASTCALL(detach_pid(struct task_struct *task, enum pid_type));
82extern void FASTCALL(transfer_pid(struct task_struct *old, 83extern void FASTCALL(transfer_pid(struct task_struct *old,
83 struct task_struct *new, enum pid_type)); 84 struct task_struct *new, enum pid_type));
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 17b72d88c4cb..a81897e2a244 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -88,6 +88,7 @@ struct sched_param {
88 88
89struct exec_domain; 89struct exec_domain;
90struct futex_pi_state; 90struct futex_pi_state;
91struct bio;
91 92
92/* 93/*
93 * List of flags we want to share for kernel threads, 94 * List of flags we want to share for kernel threads,
@@ -391,6 +392,7 @@ struct sighand_struct {
391 atomic_t count; 392 atomic_t count;
392 struct k_sigaction action[_NSIG]; 393 struct k_sigaction action[_NSIG];
393 spinlock_t siglock; 394 spinlock_t siglock;
395 struct list_head signalfd_list;
394}; 396};
395 397
396struct pacct_struct { 398struct pacct_struct {
@@ -469,6 +471,7 @@ struct signal_struct {
469 cputime_t utime, stime, cutime, cstime; 471 cputime_t utime, stime, cutime, cstime;
470 unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; 472 unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
471 unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt; 473 unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
474 unsigned long inblock, oublock, cinblock, coublock;
472 475
473 /* 476 /*
474 * Cumulative ns of scheduled CPU time for dead threads in the 477 * Cumulative ns of scheduled CPU time for dead threads in the
@@ -1014,6 +1017,9 @@ struct task_struct {
1014/* journalling filesystem info */ 1017/* journalling filesystem info */
1015 void *journal_info; 1018 void *journal_info;
1016 1019
1020/* stacked block device info */
1021 struct bio *bio_list, **bio_tail;
1022
1017/* VM state */ 1023/* VM state */
1018 struct reclaim_state *reclaim_state; 1024 struct reclaim_state *reclaim_state;
1019 1025
diff --git a/include/linux/signal.h b/include/linux/signal.h
index 3fa0fab4a04b..9a5eac508e5e 100644
--- a/include/linux/signal.h
+++ b/include/linux/signal.h
@@ -233,6 +233,7 @@ static inline int valid_signal(unsigned long sig)
233 return sig <= _NSIG ? 1 : 0; 233 return sig <= _NSIG ? 1 : 0;
234} 234}
235 235
236extern int next_signal(struct sigpending *pending, sigset_t *mask);
236extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p); 237extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
237extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *); 238extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
238extern long do_sigpending(void __user *, unsigned long); 239extern long do_sigpending(void __user *, unsigned long);
diff --git a/include/linux/signalfd.h b/include/linux/signalfd.h
new file mode 100644
index 000000000000..510429495690
--- /dev/null
+++ b/include/linux/signalfd.h
@@ -0,0 +1,97 @@
1/*
2 * include/linux/signalfd.h
3 *
4 * Copyright (C) 2007 Davide Libenzi <davidel@xmailserver.org>
5 *
6 */
7
8#ifndef _LINUX_SIGNALFD_H
9#define _LINUX_SIGNALFD_H
10
11
12struct signalfd_siginfo {
13 __u32 signo;
14 __s32 err;
15 __s32 code;
16 __u32 pid;
17 __u32 uid;
18 __s32 fd;
19 __u32 tid;
20 __u32 band;
21 __u32 overrun;
22 __u32 trapno;
23 __s32 status;
24 __s32 svint;
25 __u64 svptr;
26 __u64 utime;
27 __u64 stime;
28 __u64 addr;
29
30 /*
31 * Pad strcture to 128 bytes. Remember to update the
32 * pad size when you add new memebers. We use a fixed
33 * size structure to avoid compatibility problems with
34 * future versions, and we leave extra space for additional
35 * members. We use fixed size members because this strcture
36 * comes out of a read(2) and we really don't want to have
37 * a compat on read(2).
38 */
39 __u8 __pad[48];
40};
41
42
43#ifdef __KERNEL__
44
45#ifdef CONFIG_SIGNALFD
46
47/*
48 * Deliver the signal to listening signalfd. This must be called
49 * with the sighand lock held. Same are the following that end up
50 * calling signalfd_deliver().
51 */
52void signalfd_deliver(struct task_struct *tsk, int sig);
53
54/*
55 * No need to fall inside signalfd_deliver() if no signal listeners
56 * are available.
57 */
58static inline void signalfd_notify(struct task_struct *tsk, int sig)
59{
60 if (unlikely(!list_empty(&tsk->sighand->signalfd_list)))
61 signalfd_deliver(tsk, sig);
62}
63
64/*
65 * The signal -1 is used to notify the signalfd that the sighand
66 * is on its way to be detached.
67 */
68static inline void signalfd_detach_locked(struct task_struct *tsk)
69{
70 if (unlikely(!list_empty(&tsk->sighand->signalfd_list)))
71 signalfd_deliver(tsk, -1);
72}
73
74static inline void signalfd_detach(struct task_struct *tsk)
75{
76 struct sighand_struct *sighand = tsk->sighand;
77
78 if (unlikely(!list_empty(&sighand->signalfd_list))) {
79 spin_lock_irq(&sighand->siglock);
80 signalfd_deliver(tsk, -1);
81 spin_unlock_irq(&sighand->siglock);
82 }
83}
84
85#else /* CONFIG_SIGNALFD */
86
87#define signalfd_deliver(t, s) do { } while (0)
88#define signalfd_notify(t, s) do { } while (0)
89#define signalfd_detach_locked(t) do { } while (0)
90#define signalfd_detach(t) do { } while (0)
91
92#endif /* CONFIG_SIGNALFD */
93
94#endif /* __KERNEL__ */
95
96#endif /* _LINUX_SIGNALFD_H */
97
diff --git a/include/linux/synclink.h b/include/linux/synclink.h
index c8b042667af1..5562fbf72095 100644
--- a/include/linux/synclink.h
+++ b/include/linux/synclink.h
@@ -291,4 +291,28 @@ struct gpio_desc {
291#define MGSL_IOCGGPIO _IOR(MGSL_MAGIC_IOC,17,struct gpio_desc) 291#define MGSL_IOCGGPIO _IOR(MGSL_MAGIC_IOC,17,struct gpio_desc)
292#define MGSL_IOCWAITGPIO _IOWR(MGSL_MAGIC_IOC,18,struct gpio_desc) 292#define MGSL_IOCWAITGPIO _IOWR(MGSL_MAGIC_IOC,18,struct gpio_desc)
293 293
294#ifdef __KERNEL__
295/* provide 32 bit ioctl compatibility on 64 bit systems */
296#ifdef CONFIG_COMPAT
297#include <linux/compat.h>
298struct MGSL_PARAMS32 {
299 compat_ulong_t mode;
300 unsigned char loopback;
301 unsigned short flags;
302 unsigned char encoding;
303 compat_ulong_t clock_speed;
304 unsigned char addr_filter;
305 unsigned short crc_type;
306 unsigned char preamble_length;
307 unsigned char preamble;
308 compat_ulong_t data_rate;
309 unsigned char data_bits;
310 unsigned char stop_bits;
311 unsigned char parity;
312};
313#define MGSL_IOCSPARAMS32 _IOW(MGSL_MAGIC_IOC,0,struct MGSL_PARAMS32)
314#define MGSL_IOCGPARAMS32 _IOR(MGSL_MAGIC_IOC,1,struct MGSL_PARAMS32)
315#endif
316#endif
317
294#endif /* _SYNCLINK_H_ */ 318#endif /* _SYNCLINK_H_ */
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 3139f4412297..b02070eac422 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -604,6 +604,10 @@ asmlinkage long sys_get_robust_list(int pid,
604asmlinkage long sys_set_robust_list(struct robust_list_head __user *head, 604asmlinkage long sys_set_robust_list(struct robust_list_head __user *head,
605 size_t len); 605 size_t len);
606asmlinkage long sys_getcpu(unsigned __user *cpu, unsigned __user *node, struct getcpu_cache __user *cache); 606asmlinkage long sys_getcpu(unsigned __user *cpu, unsigned __user *node, struct getcpu_cache __user *cache);
607asmlinkage long sys_signalfd(int ufd, sigset_t __user *user_mask, size_t sizemask);
608asmlinkage long sys_timerfd(int ufd, int clockid, int flags,
609 const struct itimerspec __user *utmr);
610asmlinkage long sys_eventfd(unsigned int count);
607 611
608int kernel_execve(const char *filename, char *const argv[], char *const envp[]); 612int kernel_execve(const char *filename, char *const argv[], char *const envp[]);
609 613
diff --git a/include/linux/task_io_accounting_ops.h b/include/linux/task_io_accounting_ops.h
index df2a319106b2..1218733ec6b5 100644
--- a/include/linux/task_io_accounting_ops.h
+++ b/include/linux/task_io_accounting_ops.h
@@ -10,11 +10,29 @@ static inline void task_io_account_read(size_t bytes)
10 current->ioac.read_bytes += bytes; 10 current->ioac.read_bytes += bytes;
11} 11}
12 12
13/*
14 * We approximate number of blocks, because we account bytes only.
15 * A 'block' is 512 bytes
16 */
17static inline unsigned long task_io_get_inblock(const struct task_struct *p)
18{
19 return p->ioac.read_bytes >> 9;
20}
21
13static inline void task_io_account_write(size_t bytes) 22static inline void task_io_account_write(size_t bytes)
14{ 23{
15 current->ioac.write_bytes += bytes; 24 current->ioac.write_bytes += bytes;
16} 25}
17 26
27/*
28 * We approximate number of blocks, because we account bytes only.
29 * A 'block' is 512 bytes
30 */
31static inline unsigned long task_io_get_oublock(const struct task_struct *p)
32{
33 return p->ioac.write_bytes >> 9;
34}
35
18static inline void task_io_account_cancelled_write(size_t bytes) 36static inline void task_io_account_cancelled_write(size_t bytes)
19{ 37{
20 current->ioac.cancelled_write_bytes += bytes; 38 current->ioac.cancelled_write_bytes += bytes;
@@ -31,10 +49,20 @@ static inline void task_io_account_read(size_t bytes)
31{ 49{
32} 50}
33 51
52static inline unsigned long task_io_get_inblock(const struct task_struct *p)
53{
54 return 0;
55}
56
34static inline void task_io_account_write(size_t bytes) 57static inline void task_io_account_write(size_t bytes)
35{ 58{
36} 59}
37 60
61static inline unsigned long task_io_get_oublock(const struct task_struct *p)
62{
63 return 0;
64}
65
38static inline void task_io_account_cancelled_write(size_t bytes) 66static inline void task_io_account_cancelled_write(size_t bytes)
39{ 67{
40} 68}
diff --git a/include/linux/timerfd.h b/include/linux/timerfd.h
new file mode 100644
index 000000000000..cf2b10d75731
--- /dev/null
+++ b/include/linux/timerfd.h
@@ -0,0 +1,17 @@
1/*
2 * include/linux/timerfd.h
3 *
4 * Copyright (C) 2007 Davide Libenzi <davidel@xmailserver.org>
5 *
6 */
7
8#ifndef _LINUX_TIMERFD_H
9#define _LINUX_TIMERFD_H
10
11
12#define TFD_TIMER_ABSTIME (1 << 0)
13
14
15
16#endif /* _LINUX_TIMERFD_H */
17
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index 659487e3ebeb..85c95cd39bc3 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -52,6 +52,11 @@
52 * This routine allows the tty driver to implement 52 * This routine allows the tty driver to implement
53 * device-specific ioctl's. If the ioctl number passed in cmd 53 * device-specific ioctl's. If the ioctl number passed in cmd
54 * is not recognized by the driver, it should return ENOIOCTLCMD. 54 * is not recognized by the driver, it should return ENOIOCTLCMD.
55 *
56 * long (*compat_ioctl)(struct tty_struct *tty, struct file * file,
57 * unsigned int cmd, unsigned long arg);
58 *
59 * implement ioctl processing for 32 bit process on 64 bit system
55 * 60 *
56 * void (*set_termios)(struct tty_struct *tty, struct ktermios * old); 61 * void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
57 * 62 *
@@ -132,6 +137,8 @@ struct tty_operations {
132 int (*chars_in_buffer)(struct tty_struct *tty); 137 int (*chars_in_buffer)(struct tty_struct *tty);
133 int (*ioctl)(struct tty_struct *tty, struct file * file, 138 int (*ioctl)(struct tty_struct *tty, struct file * file,
134 unsigned int cmd, unsigned long arg); 139 unsigned int cmd, unsigned long arg);
140 long (*compat_ioctl)(struct tty_struct *tty, struct file * file,
141 unsigned int cmd, unsigned long arg);
135 void (*set_termios)(struct tty_struct *tty, struct ktermios * old); 142 void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
136 void (*throttle)(struct tty_struct * tty); 143 void (*throttle)(struct tty_struct * tty);
137 void (*unthrottle)(struct tty_struct * tty); 144 void (*unthrottle)(struct tty_struct * tty);
@@ -193,6 +200,8 @@ struct tty_driver {
193 int (*chars_in_buffer)(struct tty_struct *tty); 200 int (*chars_in_buffer)(struct tty_struct *tty);
194 int (*ioctl)(struct tty_struct *tty, struct file * file, 201 int (*ioctl)(struct tty_struct *tty, struct file * file,
195 unsigned int cmd, unsigned long arg); 202 unsigned int cmd, unsigned long arg);
203 long (*compat_ioctl)(struct tty_struct *tty, struct file * file,
204 unsigned int cmd, unsigned long arg);
196 void (*set_termios)(struct tty_struct *tty, struct ktermios * old); 205 void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
197 void (*throttle)(struct tty_struct * tty); 206 void (*throttle)(struct tty_struct * tty);
198 void (*unthrottle)(struct tty_struct * tty); 207 void (*unthrottle)(struct tty_struct * tty);
diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
index d75932e27710..6226504d9108 100644
--- a/include/linux/tty_ldisc.h
+++ b/include/linux/tty_ldisc.h
@@ -59,6 +59,11 @@
59 * low-level driver can "grab" an ioctl request before the line 59 * low-level driver can "grab" an ioctl request before the line
60 * discpline has a chance to see it. 60 * discpline has a chance to see it.
61 * 61 *
62 * long (*compat_ioctl)(struct tty_struct * tty, struct file * file,
63 * unsigned int cmd, unsigned long arg);
64 *
65 * Process ioctl calls from 32-bit process on 64-bit system
66 *
62 * void (*set_termios)(struct tty_struct *tty, struct ktermios * old); 67 * void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
63 * 68 *
64 * This function notifies the line discpline that a change has 69 * This function notifies the line discpline that a change has
@@ -118,6 +123,8 @@ struct tty_ldisc {
118 const unsigned char * buf, size_t nr); 123 const unsigned char * buf, size_t nr);
119 int (*ioctl)(struct tty_struct * tty, struct file * file, 124 int (*ioctl)(struct tty_struct * tty, struct file * file,
120 unsigned int cmd, unsigned long arg); 125 unsigned int cmd, unsigned long arg);
126 long (*compat_ioctl)(struct tty_struct * tty, struct file * file,
127 unsigned int cmd, unsigned long arg);
121 void (*set_termios)(struct tty_struct *tty, struct ktermios * old); 128 void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
122 unsigned int (*poll)(struct tty_struct *, struct file *, 129 unsigned int (*poll)(struct tty_struct *, struct file *,
123 struct poll_table_struct *); 130 struct poll_table_struct *);
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index daa6c125f66e..050915b59576 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -111,9 +111,15 @@ balance_dirty_pages_ratelimited(struct address_space *mapping)
111 balance_dirty_pages_ratelimited_nr(mapping, 1); 111 balance_dirty_pages_ratelimited_nr(mapping, 1);
112} 112}
113 113
114typedef int (*writepage_t)(struct page *page, struct writeback_control *wbc,
115 void *data);
116
114int pdflush_operation(void (*fn)(unsigned long), unsigned long arg0); 117int pdflush_operation(void (*fn)(unsigned long), unsigned long arg0);
115extern int generic_writepages(struct address_space *mapping, 118int generic_writepages(struct address_space *mapping,
116 struct writeback_control *wbc); 119 struct writeback_control *wbc);
120int write_cache_pages(struct address_space *mapping,
121 struct writeback_control *wbc, writepage_t writepage,
122 void *data);
117int do_writepages(struct address_space *mapping, struct writeback_control *wbc); 123int do_writepages(struct address_space *mapping, struct writeback_control *wbc);
118int sync_page_range(struct inode *inode, struct address_space *mapping, 124int sync_page_range(struct inode *inode, struct address_space *mapping,
119 loff_t pos, loff_t count); 125 loff_t pos, loff_t count);
diff --git a/include/media/saa7146.h b/include/media/saa7146.h
index 796bcf151a3a..d3f4f5a38214 100644
--- a/include/media/saa7146.h
+++ b/include/media/saa7146.h
@@ -58,6 +58,7 @@ struct saa7146_pgtable {
58 unsigned long offset; 58 unsigned long offset;
59 /* used for custom pagetables (used for example by budget dvb cards) */ 59 /* used for custom pagetables (used for example by budget dvb cards) */
60 struct scatterlist *slist; 60 struct scatterlist *slist;
61 int nents;
61}; 62};
62 63
63struct saa7146_pci_extension_data { 64struct saa7146_pci_extension_data {
@@ -157,6 +158,7 @@ int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt);
157void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt); 158void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt);
158int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt, struct scatterlist *list, int length ); 159int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt, struct scatterlist *list, int length );
159char *saa7146_vmalloc_build_pgtable(struct pci_dev *pci, long length, struct saa7146_pgtable *pt); 160char *saa7146_vmalloc_build_pgtable(struct pci_dev *pci, long length, struct saa7146_pgtable *pt);
161void saa7146_vfree_destroy_pgtable(struct pci_dev *pci, char *mem, struct saa7146_pgtable *pt);
160void saa7146_setgpio(struct saa7146_dev *dev, int port, u32 data); 162void saa7146_setgpio(struct saa7146_dev *dev, int port, u32 data);
161int saa7146_wait_for_debi_done(struct saa7146_dev *dev, int nobusyloop); 163int saa7146_wait_for_debi_done(struct saa7146_dev *dev, int nobusyloop);
162 164
diff --git a/include/media/saa7146_vv.h b/include/media/saa7146_vv.h
index 50e33b0e9349..cce20ed5cf6c 100644
--- a/include/media/saa7146_vv.h
+++ b/include/media/saa7146_vv.h
@@ -216,6 +216,8 @@ void saa7146_set_gpio(struct saa7146_dev *saa, u8 pin, u8 data);
216extern struct saa7146_use_ops saa7146_video_uops; 216extern struct saa7146_use_ops saa7146_video_uops;
217int saa7146_start_preview(struct saa7146_fh *fh); 217int saa7146_start_preview(struct saa7146_fh *fh);
218int saa7146_stop_preview(struct saa7146_fh *fh); 218int saa7146_stop_preview(struct saa7146_fh *fh);
219int saa7146_video_do_ioctl(struct inode *inode, struct file *file,
220 unsigned int cmd, void *arg);
219 221
220/* from saa7146_vbi.c */ 222/* from saa7146_vbi.c */
221extern struct saa7146_use_ops saa7146_vbi_uops; 223extern struct saa7146_use_ops saa7146_vbi_uops;
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index 1c6b8bd09b9a..4732432f8eb0 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -183,13 +183,6 @@ extern void nf_conntrack_hash_insert(struct nf_conn *ct);
183 183
184extern void nf_conntrack_flush(void); 184extern void nf_conntrack_flush(void);
185 185
186extern struct nf_conntrack_helper *
187nf_ct_helper_find_get( const struct nf_conntrack_tuple *tuple);
188extern void nf_ct_helper_put(struct nf_conntrack_helper *helper);
189
190extern struct nf_conntrack_helper *
191__nf_conntrack_helper_find_byname(const char *name);
192
193extern int nf_ct_invert_tuplepr(struct nf_conntrack_tuple *inverse, 186extern int nf_ct_invert_tuplepr(struct nf_conntrack_tuple *inverse,
194 const struct nf_conntrack_tuple *orig); 187 const struct nf_conntrack_tuple *orig);
195 188
diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h
index f32f714e5d92..96a58d8e1d3f 100644
--- a/include/net/netfilter/nf_conntrack_l3proto.h
+++ b/include/net/netfilter/nf_conntrack_l3proto.h
@@ -56,9 +56,6 @@ struct nf_conntrack_l3proto
56 */ 56 */
57 int (*new)(struct nf_conn *conntrack, const struct sk_buff *skb); 57 int (*new)(struct nf_conn *conntrack, const struct sk_buff *skb);
58 58
59 /* Called when a conntrack entry is destroyed */
60 void (*destroy)(struct nf_conn *conntrack);
61
62 /* 59 /*
63 * Called before tracking. 60 * Called before tracking.
64 * *dataoff: offset of protocol header (TCP, UDP,...) in *pskb 61 * *dataoff: offset of protocol header (TCP, UDP,...) in *pskb
diff --git a/include/net/netfilter/nf_nat_rule.h b/include/net/netfilter/nf_nat_rule.h
index e76565459ad9..f9743187d57f 100644
--- a/include/net/netfilter/nf_nat_rule.h
+++ b/include/net/netfilter/nf_nat_rule.h
@@ -10,16 +10,11 @@ extern int nf_nat_rule_find(struct sk_buff **pskb,
10 unsigned int hooknum, 10 unsigned int hooknum,
11 const struct net_device *in, 11 const struct net_device *in,
12 const struct net_device *out, 12 const struct net_device *out,
13 struct nf_conn *ct, 13 struct nf_conn *ct);
14 struct nf_nat_info *info);
15 14
16extern unsigned int 15extern unsigned int
17alloc_null_binding(struct nf_conn *ct, 16alloc_null_binding(struct nf_conn *ct, unsigned int hooknum);
18 struct nf_nat_info *info,
19 unsigned int hooknum);
20 17
21extern unsigned int 18extern unsigned int
22alloc_null_binding_confirmed(struct nf_conn *ct, 19alloc_null_binding_confirmed(struct nf_conn *ct, unsigned int hooknum);
23 struct nf_nat_info *info,
24 unsigned int hooknum);
25#endif /* _NF_NAT_RULE_H */ 20#endif /* _NF_NAT_RULE_H */
diff --git a/include/net/udp.h b/include/net/udp.h
index 98755ebaf163..496f89d45c8b 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -119,9 +119,16 @@ static inline void udp_lib_close(struct sock *sk, long timeout)
119} 119}
120 120
121 121
122struct udp_get_port_ops {
123 int (*saddr_cmp)(const struct sock *sk1, const struct sock *sk2);
124 int (*saddr_any)(const struct sock *sk);
125 unsigned int (*hash_port_and_rcv_saddr)(__u16 port,
126 const struct sock *sk);
127};
128
122/* net/ipv4/udp.c */ 129/* net/ipv4/udp.c */
123extern int udp_get_port(struct sock *sk, unsigned short snum, 130extern int udp_get_port(struct sock *sk, unsigned short snum,
124 int (*saddr_cmp)(const struct sock *, const struct sock *)); 131 const struct udp_get_port_ops *ops);
125extern void udp_err(struct sk_buff *, u32); 132extern void udp_err(struct sk_buff *, u32);
126 133
127extern int udp_sendmsg(struct kiocb *iocb, struct sock *sk, 134extern int udp_sendmsg(struct kiocb *iocb, struct sock *sk,
diff --git a/include/net/udplite.h b/include/net/udplite.h
index 635b0eafca95..50b4b424d1ca 100644
--- a/include/net/udplite.h
+++ b/include/net/udplite.h
@@ -120,5 +120,5 @@ static inline __wsum udplite_csum_outgoing(struct sock *sk, struct sk_buff *skb)
120 120
121extern void udplite4_register(void); 121extern void udplite4_register(void);
122extern int udplite_get_port(struct sock *sk, unsigned short snum, 122extern int udplite_get_port(struct sock *sk, unsigned short snum,
123 int (*scmp)(const struct sock *, const struct sock *)); 123 const struct udp_get_port_ops *ops);
124#endif /* _UDPLITE_H */ 124#endif /* _UDPLITE_H */
diff --git a/include/sound/ak4114.h b/include/sound/ak4114.h
index c149d3b2558b..d647dae912b9 100644
--- a/include/sound/ak4114.h
+++ b/include/sound/ak4114.h
@@ -73,7 +73,7 @@
73 73
74/* AK4114_REQ_FORMAT bits */ 74/* AK4114_REQ_FORMAT bits */
75#define AK4114_MONO (1<<7) /* Double Sampling Frequency Mode: 0 = stereo, 1 = mono */ 75#define AK4114_MONO (1<<7) /* Double Sampling Frequency Mode: 0 = stereo, 1 = mono */
76#define AK4114_DIF2 (1<<5) /* Audio Data Control */ 76#define AK4114_DIF2 (1<<6) /* Audio Data Control */
77#define AK4114_DIF1 (1<<5) /* Audio Data Control */ 77#define AK4114_DIF1 (1<<5) /* Audio Data Control */
78#define AK4114_DIF0 (1<<4) /* Audio Data Control */ 78#define AK4114_DIF0 (1<<4) /* Audio Data Control */
79#define AK4114_DIF_16R (0) /* STDO: 16-bit, right justified */ 79#define AK4114_DIF_16R (0) /* STDO: 16-bit, right justified */
@@ -158,7 +158,7 @@
158#define AK4114_CHECK_NO_STAT (1<<0) /* no statistics */ 158#define AK4114_CHECK_NO_STAT (1<<0) /* no statistics */
159#define AK4114_CHECK_NO_RATE (1<<1) /* no rate check */ 159#define AK4114_CHECK_NO_RATE (1<<1) /* no rate check */
160 160
161#define AK4114_CONTROLS 14 161#define AK4114_CONTROLS 15
162 162
163typedef void (ak4114_write_t)(void *private_data, unsigned char addr, unsigned char data); 163typedef void (ak4114_write_t)(void *private_data, unsigned char addr, unsigned char data);
164typedef unsigned char (ak4114_read_t)(void *private_data, unsigned char addr); 164typedef unsigned char (ak4114_read_t)(void *private_data, unsigned char addr);
diff --git a/include/sound/mpu401.h b/include/sound/mpu401.h
index 8c88267e9bea..d5c1396c4c9e 100644
--- a/include/sound/mpu401.h
+++ b/include/sound/mpu401.h
@@ -50,6 +50,7 @@
50#define MPU401_INFO_INTEGRATED (1 << 2) /* integrated h/w port */ 50#define MPU401_INFO_INTEGRATED (1 << 2) /* integrated h/w port */
51#define MPU401_INFO_MMIO (1 << 3) /* MMIO access */ 51#define MPU401_INFO_MMIO (1 << 3) /* MMIO access */
52#define MPU401_INFO_TX_IRQ (1 << 4) /* independent TX irq */ 52#define MPU401_INFO_TX_IRQ (1 << 4) /* independent TX irq */
53#define MPU401_INFO_UART_ONLY (1 << 5) /* No ENTER_UART cmd needed */
53 54
54#define MPU401_MODE_BIT_INPUT 0 55#define MPU401_MODE_BIT_INPUT 0
55#define MPU401_MODE_BIT_OUTPUT 1 56#define MPU401_MODE_BIT_OUTPUT 1
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index deff5a92efa6..73334e0f823f 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -603,11 +603,8 @@ do { \
603 read_unlock_irqrestore(&snd_pcm_link_rwlock, (flags)); \ 603 read_unlock_irqrestore(&snd_pcm_link_rwlock, (flags)); \
604} while (0) 604} while (0)
605 605
606#define snd_pcm_group_for_each(pos, substream) \ 606#define snd_pcm_group_for_each_entry(s, substream) \
607 list_for_each(pos, &substream->group->substreams) 607 list_for_each_entry(s, &substream->group->substreams, link_list)
608
609#define snd_pcm_group_substream_entry(pos) \
610 list_entry(pos, struct snd_pcm_substream, link_list)
611 608
612static inline int snd_pcm_running(struct snd_pcm_substream *substream) 609static inline int snd_pcm_running(struct snd_pcm_substream *substream)
613{ 610{
diff --git a/include/sound/version.h b/include/sound/version.h
index 42a18cc95f38..e820f0e7bdd3 100644
--- a/include/sound/version.h
+++ b/include/sound/version.h
@@ -1,3 +1,3 @@
1/* include/version.h. Generated by alsa/ksync script. */ 1/* include/version.h. Generated by alsa/ksync script. */
2#define CONFIG_SND_VERSION "1.0.14rc3" 2#define CONFIG_SND_VERSION "1.0.14rc4"
3#define CONFIG_SND_DATE " (Wed Mar 14 07:25:50 2007 UTC)" 3#define CONFIG_SND_DATE " (Wed May 09 09:51:39 2007 UTC)"
diff --git a/include/video/atmel_lcdc.h b/include/video/atmel_lcdc.h
new file mode 100644
index 000000000000..4eea63761a3f
--- /dev/null
+++ b/include/video/atmel_lcdc.h
@@ -0,0 +1,196 @@
1/*
2 * Header file for AT91/AT32 LCD Controller
3 *
4 * Data structure and register user interface
5 *
6 * Copyright (C) 2007 Atmel Corporation
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22#ifndef __ATMEL_LCDC_H__
23#define __ATMEL_LCDC_H__
24
25 /* LCD Controller info data structure */
26struct atmel_lcdfb_info {
27 spinlock_t lock;
28 struct fb_info *info;
29 void __iomem *mmio;
30 unsigned long irq_base;
31
32 unsigned int guard_time;
33 struct platform_device *pdev;
34 struct clk *bus_clk;
35 struct clk *lcdc_clk;
36 unsigned int default_bpp;
37 unsigned int default_lcdcon2;
38 unsigned int default_dmacon;
39 void (*atmel_lcdfb_power_control)(int on);
40 struct fb_monspecs *default_monspecs;
41 u32 pseudo_palette[16];
42};
43
44#define ATMEL_LCDC_DMABADDR1 0x00
45#define ATMEL_LCDC_DMABADDR2 0x04
46#define ATMEL_LCDC_DMAFRMPT1 0x08
47#define ATMEL_LCDC_DMAFRMPT2 0x0c
48#define ATMEL_LCDC_DMAFRMADD1 0x10
49#define ATMEL_LCDC_DMAFRMADD2 0x14
50
51#define ATMEL_LCDC_DMAFRMCFG 0x18
52#define ATMEL_LCDC_FRSIZE (0x7fffff << 0)
53#define ATMEL_LCDC_BLENGTH_OFFSET 24
54#define ATMEL_LCDC_BLENGTH (0x7f << ATMEL_LCDC_BLENGTH_OFFSET)
55
56#define ATMEL_LCDC_DMACON 0x1c
57#define ATMEL_LCDC_DMAEN (0x1 << 0)
58#define ATMEL_LCDC_DMARST (0x1 << 1)
59#define ATMEL_LCDC_DMABUSY (0x1 << 2)
60#define ATMEL_LCDC_DMAUPDT (0x1 << 3)
61#define ATMEL_LCDC_DMA2DEN (0x1 << 4)
62
63#define ATMEL_LCDC_DMA2DCFG 0x20
64#define ATMEL_LCDC_ADDRINC_OFFSET 0
65#define ATMEL_LCDC_ADDRINC (0xffff)
66#define ATMEL_LCDC_PIXELOFF_OFFSET 24
67#define ATMEL_LCDC_PIXELOFF (0x1f << 24)
68
69#define ATMEL_LCDC_LCDCON1 0x0800
70#define ATMEL_LCDC_BYPASS (1 << 0)
71#define ATMEL_LCDC_CLKVAL_OFFSET 12
72#define ATMEL_LCDC_CLKVAL (0x1ff << ATMEL_LCDC_CLKVAL_OFFSET)
73#define ATMEL_LCDC_LINCNT (0x7ff << 21)
74
75#define ATMEL_LCDC_LCDCON2 0x0804
76#define ATMEL_LCDC_DISTYPE (3 << 0)
77#define ATMEL_LCDC_DISTYPE_STNMONO (0 << 0)
78#define ATMEL_LCDC_DISTYPE_STNCOLOR (1 << 0)
79#define ATMEL_LCDC_DISTYPE_TFT (2 << 0)
80#define ATMEL_LCDC_SCANMOD (1 << 2)
81#define ATMEL_LCDC_SCANMOD_SINGLE (0 << 2)
82#define ATMEL_LCDC_SCANMOD_DUAL (1 << 2)
83#define ATMEL_LCDC_IFWIDTH (3 << 3)
84#define ATMEL_LCDC_IFWIDTH_4 (0 << 3)
85#define ATMEL_LCDC_IFWIDTH_8 (1 << 3)
86#define ATMEL_LCDC_IFWIDTH_16 (2 << 3)
87#define ATMEL_LCDC_PIXELSIZE (7 << 5)
88#define ATMEL_LCDC_PIXELSIZE_1 (0 << 5)
89#define ATMEL_LCDC_PIXELSIZE_2 (1 << 5)
90#define ATMEL_LCDC_PIXELSIZE_4 (2 << 5)
91#define ATMEL_LCDC_PIXELSIZE_8 (3 << 5)
92#define ATMEL_LCDC_PIXELSIZE_16 (4 << 5)
93#define ATMEL_LCDC_PIXELSIZE_24 (5 << 5)
94#define ATMEL_LCDC_PIXELSIZE_32 (6 << 5)
95#define ATMEL_LCDC_INVVD (1 << 8)
96#define ATMEL_LCDC_INVVD_NORMAL (0 << 8)
97#define ATMEL_LCDC_INVVD_INVERTED (1 << 8)
98#define ATMEL_LCDC_INVFRAME (1 << 9 )
99#define ATMEL_LCDC_INVFRAME_NORMAL (0 << 9)
100#define ATMEL_LCDC_INVFRAME_INVERTED (1 << 9)
101#define ATMEL_LCDC_INVLINE (1 << 10)
102#define ATMEL_LCDC_INVLINE_NORMAL (0 << 10)
103#define ATMEL_LCDC_INVLINE_INVERTED (1 << 10)
104#define ATMEL_LCDC_INVCLK (1 << 11)
105#define ATMEL_LCDC_INVCLK_NORMAL (0 << 11)
106#define ATMEL_LCDC_INVCLK_INVERTED (1 << 11)
107#define ATMEL_LCDC_INVDVAL (1 << 12)
108#define ATMEL_LCDC_INVDVAL_NORMAL (0 << 12)
109#define ATMEL_LCDC_INVDVAL_INVERTED (1 << 12)
110#define ATMEL_LCDC_CLKMOD (1 << 15)
111#define ATMEL_LCDC_CLKMOD_ACTIVEDISPLAY (0 << 15)
112#define ATMEL_LCDC_CLKMOD_ALWAYSACTIVE (1 << 15)
113#define ATMEL_LCDC_MEMOR (1 << 31)
114#define ATMEL_LCDC_MEMOR_BIG (0 << 31)
115#define ATMEL_LCDC_MEMOR_LITTLE (1 << 31)
116
117#define ATMEL_LCDC_TIM1 0x0808
118#define ATMEL_LCDC_VFP (0xff << 0)
119#define ATMEL_LCDC_VBP_OFFSET 8
120#define ATMEL_LCDC_VBP (0xff << ATMEL_LCDC_VBP_OFFSET)
121#define ATMEL_LCDC_VPW_OFFSET 16
122#define ATMEL_LCDC_VPW (0x3f << ATMEL_LCDC_VPW_OFFSET)
123#define ATMEL_LCDC_VHDLY_OFFSET 24
124#define ATMEL_LCDC_VHDLY (0xf << ATMEL_LCDC_VHDLY_OFFSET)
125
126#define ATMEL_LCDC_TIM2 0x080c
127#define ATMEL_LCDC_HBP (0xff << 0)
128#define ATMEL_LCDC_HPW_OFFSET 8
129#define ATMEL_LCDC_HPW (0x3f << ATMEL_LCDC_HPW_OFFSET)
130#define ATMEL_LCDC_HFP_OFFSET 21
131#define ATMEL_LCDC_HFP (0x7ff << ATMEL_LCDC_HFP_OFFSET)
132
133#define ATMEL_LCDC_LCDFRMCFG 0x0810
134#define ATMEL_LCDC_LINEVAL (0x7ff << 0)
135#define ATMEL_LCDC_HOZVAL_OFFSET 21
136#define ATMEL_LCDC_HOZVAL (0x7ff << ATMEL_LCDC_HOZVAL_OFFSET)
137
138#define ATMEL_LCDC_FIFO 0x0814
139#define ATMEL_LCDC_FIFOTH (0xffff)
140
141#define ATMEL_LCDC_MVAL 0x0818
142
143#define ATMEL_LCDC_DP1_2 0x081c
144#define ATMEL_LCDC_DP4_7 0x0820
145#define ATMEL_LCDC_DP3_5 0x0824
146#define ATMEL_LCDC_DP2_3 0x0828
147#define ATMEL_LCDC_DP5_7 0x082c
148#define ATMEL_LCDC_DP3_4 0x0830
149#define ATMEL_LCDC_DP4_5 0x0834
150#define ATMEL_LCDC_DP6_7 0x0838
151#define ATMEL_LCDC_DP1_2_VAL (0xff)
152#define ATMEL_LCDC_DP4_7_VAL (0xfffffff)
153#define ATMEL_LCDC_DP3_5_VAL (0xfffff)
154#define ATMEL_LCDC_DP2_3_VAL (0xfff)
155#define ATMEL_LCDC_DP5_7_VAL (0xfffffff)
156#define ATMEL_LCDC_DP3_4_VAL (0xffff)
157#define ATMEL_LCDC_DP4_5_VAL (0xfffff)
158#define ATMEL_LCDC_DP6_7_VAL (0xfffffff)
159
160#define ATMEL_LCDC_PWRCON 0x083c
161#define ATMEL_LCDC_PWR (1 << 0)
162#define ATMEL_LCDC_GUARDT_OFFSET 1
163#define ATMEL_LCDC_GUARDT (0x7f << ATMEL_LCDC_GUARDT_OFFSET)
164#define ATMEL_LCDC_BUSY (1 << 31)
165
166#define ATMEL_LCDC_CONTRAST_CTR 0x0840
167#define ATMEL_LCDC_PS (3 << 0)
168#define ATMEL_LCDC_PS_DIV1 (0 << 0)
169#define ATMEL_LCDC_PS_DIV2 (1 << 0)
170#define ATMEL_LCDC_PS_DIV4 (2 << 0)
171#define ATMEL_LCDC_PS_DIV8 (3 << 0)
172#define ATMEL_LCDC_POL (1 << 2)
173#define ATMEL_LCDC_POL_NEGATIVE (0 << 2)
174#define ATMEL_LCDC_POL_POSITIVE (1 << 2)
175#define ATMEL_LCDC_ENA (1 << 3)
176#define ATMEL_LCDC_ENA_PWMDISABLE (0 << 3)
177#define ATMEL_LCDC_ENA_PWMENABLE (1 << 3)
178
179#define ATMEL_LCDC_CONTRAST_VAL 0x0844
180#define ATMEL_LCDC_CVAL (0xff)
181
182#define ATMEL_LCDC_IER 0x0848
183#define ATMEL_LCDC_IDR 0x084c
184#define ATMEL_LCDC_IMR 0x0850
185#define ATMEL_LCDC_ISR 0x0854
186#define ATMEL_LCDC_ICR 0x0858
187#define ATMEL_LCDC_LNI (1 << 0)
188#define ATMEL_LCDC_LSTLNI (1 << 1)
189#define ATMEL_LCDC_EOFI (1 << 2)
190#define ATMEL_LCDC_UFLWI (1 << 4)
191#define ATMEL_LCDC_OWRI (1 << 5)
192#define ATMEL_LCDC_MERI (1 << 6)
193
194#define ATMEL_LCDC_LUT(n) (0x0c00 + ((n)*4))
195
196#endif /* __ATMEL_LCDC_H__ */
diff --git a/include/video/pm3fb.h b/include/video/pm3fb.h
index 94c7d2da90ea..d52e45a1e9b8 100644
--- a/include/video/pm3fb.h
+++ b/include/video/pm3fb.h
@@ -7,9 +7,6 @@
7 * This file is subject to the terms and conditions of the GNU General Public 7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file COPYING in the main directory of this archive for 8 * License. See the file COPYING in the main directory of this archive for
9 * more details. 9 * more details.
10 *
11 * $Header: /cvsroot/linux/drivers/video/pm3fb.h,v 1.1 2002/02/25 19:11:06 marcelo Exp $
12 *
13 */ 10 */
14 11
15#ifndef PM3FB_H 12#ifndef PM3FB_H
@@ -1119,117 +1116,10 @@
1119/* ***** pm3fb useful define and macro ***** */ 1116/* ***** pm3fb useful define and macro ***** */
1120/* ***************************************** */ 1117/* ***************************************** */
1121 1118
1122/* permedia3 -specific definitions */
1123#define PM3_SCALE_TO_CLOCK(pr, fe, po) ((2 * PM3_REF_CLOCK * fe) / (pr * (1 << (po))))
1124
1125/* in case it's not in linux/pci.h */
1126#ifndef PCI_DEVICE_ID_3DLABS_PERMEDIA3
1127#define PCI_DEVICE_ID_3DLABS_PERMEDIA3 0x000a
1128#endif
1129
1130/* max number of simultaneous board */
1131#define PM3_MAX_BOARD 4
1132
1133/* max size of options */ 1119/* max size of options */
1134#define PM3_OPTIONS_SIZE 256 1120#define PM3_OPTIONS_SIZE 256
1135 1121
1136/* max size of font name */ 1122/* max size of font name */
1137#define PM3_FONTNAME_SIZE 40 1123#define PM3_FONTNAME_SIZE 40
1138 1124
1139/* do we want accelerated console */
1140#define PM3FB_USE_ACCEL 1
1141
1142/* for driver debugging ONLY */
1143/* 0 = assert only, 1 = error, 2 = info, 3+ = verbose */
1144/* define PM3FB_MASTER_DEBUG 1 */
1145#if defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 3)
1146#define PM3FB_TRACE
1147#endif /* defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 3) */
1148
1149#ifdef PM3FB_MASTER_DEBUG
1150#define DPRINTK(l,a,b...) do { if ((l) <= PM3FB_MASTER_DEBUG) printk("pm3fb: %s: " a, __FUNCTION__ , ## b); } while (0)
1151#define DASSERT(t,a,b...) do { if (!(t)) printk("pm3fb: _assert failed: %s: " a, __FUNCTION__ , ## b); } while (0)
1152#ifdef PM3FB_TRACE
1153#define DTRACE printk("pm3fb: _enter %s\n", __FUNCTION__)
1154#else /* PM3FB_TRACE */
1155#define DTRACE
1156#endif /* PM3FB_TRACE */
1157#else /* PM3FB_MASTER_DEBUG */
1158#define DPRINTK(l,a,b...)
1159#define DASSERT(t,a,b...)
1160#define DTRACE
1161#endif /* PM3FB_MASTER_DEBUG */
1162
1163#if defined(PM3FB_MASTER_DEBUG) && (PM3FB_MASTER_DEBUG >= 2)
1164#define PM3_SHOW_CUR_MODE pm3fb_show_cur_mode(l_fb_info)
1165#else
1166#define PM3_SHOW_CUR_MODE /* pm3fb_show_cur_mode() */
1167#endif
1168
1169/* ******************************************** */
1170/* ***** A bunch of register-access macro ***** */
1171/* ******************************************** */
1172
1173#define PM3_WRITE_REG(r, v) fb_writel(v, (l_fb_info->vIOBase + r))
1174#define PM3_READ_REG(r) fb_readl((l_fb_info->vIOBase + r))
1175
1176
1177#define depth2bpp(d) ((d + 7L) & ~7L)
1178#define depth2ByPP(d) (depth2bpp(d) / 8)
1179
1180#define depth_supported(d) ((d == 8) || (d == 12) || (d == 15) || (d == 16) || (d==32))
1181
1182
1183#define PM3_WAIT(n) \
1184do{ \
1185 while(PM3_READ_REG(PM3InFIFOSpace)<(n)); \
1186} while(0)
1187
1188#define PM3_DELAY(x) do { \
1189 int delay = x; \
1190 unsigned char tmp; \
1191 while(delay--){tmp = PM3_READ_REG(PM3InFIFOSpace);}; \
1192} while(0)
1193
1194#define PM3_SLOW_WRITE_REG(r,v) \
1195do{ \
1196 DASSERT((l_fb_info->vIOBase != (unsigned char*)(-1)), "l_fb_info->vIOBase mapped in slow write\n"); \
1197 mb(); \
1198 PM3_WAIT(1); \
1199 mb(); \
1200 PM3_WRITE_REG(r,v); \
1201} while(0)
1202
1203#define PM3_SET_INDEX(index) \
1204do{ \
1205 PM3_SLOW_WRITE_REG(PM3RD_IndexHigh,(((index)>>8)&0xff)); \
1206 PM3_SLOW_WRITE_REG(PM3RD_IndexLow,((index)&0xff)); \
1207} while(0)
1208
1209#define PM3_WRITE_DAC_REG(r, v) \
1210do { \
1211 DASSERT((l_fb_info->vIOBase != (unsigned char*)(-1)), "l_fb_info->vIOBase mapped in write dac reg\n"); \
1212 PM3_SET_INDEX(r); \
1213 mb(); \
1214 PM3_WRITE_REG(PM3RD_IndexedData, v); \
1215} while (0)
1216
1217/* next one is really a function, added as a macro to be consistent */
1218#define PM3_READ_DAC_REG(r) pm3fb_read_dac_reg(l_fb_info, r)
1219
1220
1221#define PM3_COLOR(c) \
1222do { \
1223 if (l_fb_info->current_par->depth == 8) \
1224 { \
1225 c = (c & 0xFF); \
1226 c = c | (c << 8); \
1227 } \
1228 if ((l_fb_info->current_par->depth == 8) || (depth2bpp(l_fb_info->current_par->depth) == 16)) \
1229 { \
1230 c = (c & 0xFFFF); \
1231 c = c | (c << 16); \
1232 } \
1233} while (0)
1234
1235#endif /* PM3FB_H */ 1125#endif /* PM3FB_H */
diff --git a/init/Kconfig b/init/Kconfig
index 322b1f8c21b3..4e009fde4b69 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -475,13 +475,53 @@ config FUTEX
475 support for "fast userspace mutexes". The resulting kernel may not 475 support for "fast userspace mutexes". The resulting kernel may not
476 run glibc-based applications correctly. 476 run glibc-based applications correctly.
477 477
478config ANON_INODES
479 bool "Enable anonymous inode source" if EMBEDDED
480 default y
481 help
482 Anonymous inode source for pseudo-files like epoll, signalfd,
483 timerfd and eventfd.
484
485 If unsure, say Y.
486
478config EPOLL 487config EPOLL
479 bool "Enable eventpoll support" if EMBEDDED 488 bool "Enable eventpoll support" if EMBEDDED
480 default y 489 default y
490 depends on ANON_INODES
481 help 491 help
482 Disabling this option will cause the kernel to be built without 492 Disabling this option will cause the kernel to be built without
483 support for epoll family of system calls. 493 support for epoll family of system calls.
484 494
495config SIGNALFD
496 bool "Enable signalfd() system call" if EMBEDDED
497 depends on ANON_INODES
498 default y
499 help
500 Enable the signalfd() system call that allows to receive signals
501 on a file descriptor.
502
503 If unsure, say Y.
504
505config TIMERFD
506 bool "Enable timerfd() system call" if EMBEDDED
507 depends on ANON_INODES
508 default y
509 help
510 Enable the timerfd() system call that allows to receive timer
511 events on a file descriptor.
512
513 If unsure, say Y.
514
515config EVENTFD
516 bool "Enable eventfd() system call" if EMBEDDED
517 depends on ANON_INODES
518 default y
519 help
520 Enable the eventfd() system call that allows to receive both
521 kernel notification (ie. KAIO) or userspace notifications.
522
523 If unsure, say Y.
524
485config SHMEM 525config SHMEM
486 bool "Use full shmem filesystem" if EMBEDDED 526 bool "Use full shmem filesystem" if EMBEDDED
487 default y 527 default y
diff --git a/init/main.c b/init/main.c
index e8d080cab443..1940fa75e82e 100644
--- a/init/main.c
+++ b/init/main.c
@@ -801,6 +801,7 @@ static int __init kernel_init(void * unused)
801 */ 801 */
802 init_pid_ns.child_reaper = current; 802 init_pid_ns.child_reaper = current;
803 803
804 __set_special_pids(1, 1);
804 cad_pid = task_pid(current); 805 cad_pid = task_pid(current);
805 806
806 smp_prepare_cpus(max_cpus); 807 smp_prepare_cpus(max_cpus);
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index d17821d3f483..fab5707cb5f7 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -681,6 +681,7 @@ asmlinkage long sys_mq_open(const char __user *u_name, int oflag, mode_t mode,
681 681
682 if (oflag & O_CREAT) { 682 if (oflag & O_CREAT) {
683 if (dentry->d_inode) { /* entry already exists */ 683 if (dentry->d_inode) { /* entry already exists */
684 audit_inode(name, dentry->d_inode);
684 error = -EEXIST; 685 error = -EEXIST;
685 if (oflag & O_EXCL) 686 if (oflag & O_EXCL)
686 goto out; 687 goto out;
@@ -693,6 +694,7 @@ asmlinkage long sys_mq_open(const char __user *u_name, int oflag, mode_t mode,
693 error = -ENOENT; 694 error = -ENOENT;
694 if (!dentry->d_inode) 695 if (!dentry->d_inode)
695 goto out; 696 goto out;
697 audit_inode(name, dentry->d_inode);
696 filp = do_open(dentry, oflag); 698 filp = do_open(dentry, oflag);
697 } 699 }
698 700
@@ -840,6 +842,7 @@ asmlinkage long sys_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr,
840 if (unlikely(filp->f_op != &mqueue_file_operations)) 842 if (unlikely(filp->f_op != &mqueue_file_operations))
841 goto out_fput; 843 goto out_fput;
842 info = MQUEUE_I(inode); 844 info = MQUEUE_I(inode);
845 audit_inode(NULL, inode);
843 846
844 if (unlikely(!(filp->f_mode & FMODE_WRITE))) 847 if (unlikely(!(filp->f_mode & FMODE_WRITE)))
845 goto out_fput; 848 goto out_fput;
@@ -923,6 +926,7 @@ asmlinkage ssize_t sys_mq_timedreceive(mqd_t mqdes, char __user *u_msg_ptr,
923 if (unlikely(filp->f_op != &mqueue_file_operations)) 926 if (unlikely(filp->f_op != &mqueue_file_operations))
924 goto out_fput; 927 goto out_fput;
925 info = MQUEUE_I(inode); 928 info = MQUEUE_I(inode);
929 audit_inode(NULL, inode);
926 930
927 if (unlikely(!(filp->f_mode & FMODE_READ))) 931 if (unlikely(!(filp->f_mode & FMODE_READ)))
928 goto out_fput; 932 goto out_fput;
diff --git a/kernel/audit.h b/kernel/audit.h
index a3370232a390..815d6f5c04ee 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -83,6 +83,7 @@ struct audit_krule {
83 u32 field_count; 83 u32 field_count;
84 char *filterkey; /* ties events to rules */ 84 char *filterkey; /* ties events to rules */
85 struct audit_field *fields; 85 struct audit_field *fields;
86 struct audit_field *arch_f; /* quick access to arch field */
86 struct audit_field *inode_f; /* quick access to an inode field */ 87 struct audit_field *inode_f; /* quick access to an inode field */
87 struct audit_watch *watch; /* associated watch */ 88 struct audit_watch *watch; /* associated watch */
88 struct list_head rlist; /* entry in audit_watch.rules list */ 89 struct list_head rlist; /* entry in audit_watch.rules list */
@@ -131,17 +132,19 @@ extern void audit_handle_ievent(struct inotify_watch *, u32, u32, u32,
131extern int selinux_audit_rule_update(void); 132extern int selinux_audit_rule_update(void);
132 133
133#ifdef CONFIG_AUDITSYSCALL 134#ifdef CONFIG_AUDITSYSCALL
134extern void __audit_signal_info(int sig, struct task_struct *t); 135extern int __audit_signal_info(int sig, struct task_struct *t);
135static inline void audit_signal_info(int sig, struct task_struct *t) 136static inline int audit_signal_info(int sig, struct task_struct *t)
136{ 137{
137 if (unlikely(audit_pid && t->tgid == audit_pid)) 138 if (unlikely((audit_pid && t->tgid == audit_pid) ||
138 __audit_signal_info(sig, t); 139 (audit_signals && !audit_dummy_context())))
140 return __audit_signal_info(sig, t);
141 return 0;
139} 142}
140extern enum audit_state audit_filter_inodes(struct task_struct *, 143extern enum audit_state audit_filter_inodes(struct task_struct *,
141 struct audit_context *); 144 struct audit_context *);
142extern void audit_set_auditable(struct audit_context *); 145extern void audit_set_auditable(struct audit_context *);
143#else 146#else
144#define audit_signal_info(s,t) 147#define audit_signal_info(s,t) AUDIT_DISABLED
145#define audit_filter_inodes(t,c) AUDIT_DISABLED 148#define audit_filter_inodes(t,c) AUDIT_DISABLED
146#define audit_set_auditable(c) 149#define audit_set_auditable(c)
147#endif 150#endif
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index 3749193aed8c..6c61263ff96d 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -311,6 +311,43 @@ int audit_match_class(int class, unsigned syscall)
311 return classes[class][AUDIT_WORD(syscall)] & AUDIT_BIT(syscall); 311 return classes[class][AUDIT_WORD(syscall)] & AUDIT_BIT(syscall);
312} 312}
313 313
314static inline int audit_match_class_bits(int class, u32 *mask)
315{
316 int i;
317
318 if (classes[class]) {
319 for (i = 0; i < AUDIT_BITMASK_SIZE; i++)
320 if (mask[i] & classes[class][i])
321 return 0;
322 }
323 return 1;
324}
325
326static int audit_match_signal(struct audit_entry *entry)
327{
328 struct audit_field *arch = entry->rule.arch_f;
329
330 if (!arch) {
331 /* When arch is unspecified, we must check both masks on biarch
332 * as syscall number alone is ambiguous. */
333 return (audit_match_class_bits(AUDIT_CLASS_SIGNAL,
334 entry->rule.mask) &&
335 audit_match_class_bits(AUDIT_CLASS_SIGNAL_32,
336 entry->rule.mask));
337 }
338
339 switch(audit_classify_arch(arch->val)) {
340 case 0: /* native */
341 return (audit_match_class_bits(AUDIT_CLASS_SIGNAL,
342 entry->rule.mask));
343 case 1: /* 32bit on biarch */
344 return (audit_match_class_bits(AUDIT_CLASS_SIGNAL_32,
345 entry->rule.mask));
346 default:
347 return 1;
348 }
349}
350
314/* Common user-space to kernel rule translation. */ 351/* Common user-space to kernel rule translation. */
315static inline struct audit_entry *audit_to_entry_common(struct audit_rule *rule) 352static inline struct audit_entry *audit_to_entry_common(struct audit_rule *rule)
316{ 353{
@@ -429,6 +466,7 @@ static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule)
429 err = -EINVAL; 466 err = -EINVAL;
430 goto exit_free; 467 goto exit_free;
431 } 468 }
469 entry->rule.arch_f = f;
432 break; 470 break;
433 case AUDIT_PERM: 471 case AUDIT_PERM:
434 if (f->val & ~15) 472 if (f->val & ~15)
@@ -519,7 +557,6 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
519 case AUDIT_FSGID: 557 case AUDIT_FSGID:
520 case AUDIT_LOGINUID: 558 case AUDIT_LOGINUID:
521 case AUDIT_PERS: 559 case AUDIT_PERS:
522 case AUDIT_ARCH:
523 case AUDIT_MSGTYPE: 560 case AUDIT_MSGTYPE:
524 case AUDIT_PPID: 561 case AUDIT_PPID:
525 case AUDIT_DEVMAJOR: 562 case AUDIT_DEVMAJOR:
@@ -531,6 +568,9 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
531 case AUDIT_ARG2: 568 case AUDIT_ARG2:
532 case AUDIT_ARG3: 569 case AUDIT_ARG3:
533 break; 570 break;
571 case AUDIT_ARCH:
572 entry->rule.arch_f = f;
573 break;
534 case AUDIT_SUBJ_USER: 574 case AUDIT_SUBJ_USER:
535 case AUDIT_SUBJ_ROLE: 575 case AUDIT_SUBJ_ROLE:
536 case AUDIT_SUBJ_TYPE: 576 case AUDIT_SUBJ_TYPE:
@@ -1221,6 +1261,9 @@ static inline int audit_add_rule(struct audit_entry *entry,
1221#ifdef CONFIG_AUDITSYSCALL 1261#ifdef CONFIG_AUDITSYSCALL
1222 if (!dont_count) 1262 if (!dont_count)
1223 audit_n_rules++; 1263 audit_n_rules++;
1264
1265 if (!audit_match_signal(entry))
1266 audit_signals++;
1224#endif 1267#endif
1225 mutex_unlock(&audit_filter_mutex); 1268 mutex_unlock(&audit_filter_mutex);
1226 1269
@@ -1294,6 +1337,9 @@ static inline int audit_del_rule(struct audit_entry *entry,
1294#ifdef CONFIG_AUDITSYSCALL 1337#ifdef CONFIG_AUDITSYSCALL
1295 if (!dont_count) 1338 if (!dont_count)
1296 audit_n_rules--; 1339 audit_n_rules--;
1340
1341 if (!audit_match_signal(entry))
1342 audit_signals--;
1297#endif 1343#endif
1298 mutex_unlock(&audit_filter_mutex); 1344 mutex_unlock(&audit_filter_mutex);
1299 1345
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 628c7ac590a0..e36481ed61b4 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -78,17 +78,15 @@ extern int audit_enabled;
78 * for saving names from getname(). */ 78 * for saving names from getname(). */
79#define AUDIT_NAMES 20 79#define AUDIT_NAMES 20
80 80
81/* AUDIT_NAMES_RESERVED is the number of slots we reserve in the
82 * audit_context from being used for nameless inodes from
83 * path_lookup. */
84#define AUDIT_NAMES_RESERVED 7
85
86/* Indicates that audit should log the full pathname. */ 81/* Indicates that audit should log the full pathname. */
87#define AUDIT_NAME_FULL -1 82#define AUDIT_NAME_FULL -1
88 83
89/* number of audit rules */ 84/* number of audit rules */
90int audit_n_rules; 85int audit_n_rules;
91 86
87/* determines whether we collect data for signals sent */
88int audit_signals;
89
92/* When fs/namei.c:getname() is called, we store the pointer in name and 90/* When fs/namei.c:getname() is called, we store the pointer in name and
93 * we don't let putname() free it (instead we free all of the saved 91 * we don't let putname() free it (instead we free all of the saved
94 * pointers at syscall exit time). 92 * pointers at syscall exit time).
@@ -114,6 +112,9 @@ struct audit_aux_data {
114 112
115#define AUDIT_AUX_IPCPERM 0 113#define AUDIT_AUX_IPCPERM 0
116 114
115/* Number of target pids per aux struct. */
116#define AUDIT_AUX_PIDS 16
117
117struct audit_aux_data_mq_open { 118struct audit_aux_data_mq_open {
118 struct audit_aux_data d; 119 struct audit_aux_data d;
119 int oflag; 120 int oflag;
@@ -181,6 +182,13 @@ struct audit_aux_data_path {
181 struct vfsmount *mnt; 182 struct vfsmount *mnt;
182}; 183};
183 184
185struct audit_aux_data_pids {
186 struct audit_aux_data d;
187 pid_t target_pid[AUDIT_AUX_PIDS];
188 u32 target_sid[AUDIT_AUX_PIDS];
189 int pid_count;
190};
191
184/* The per-task audit context. */ 192/* The per-task audit context. */
185struct audit_context { 193struct audit_context {
186 int dummy; /* must be the first element */ 194 int dummy; /* must be the first element */
@@ -201,6 +209,7 @@ struct audit_context {
201 struct vfsmount * pwdmnt; 209 struct vfsmount * pwdmnt;
202 struct audit_context *previous; /* For nested syscalls */ 210 struct audit_context *previous; /* For nested syscalls */
203 struct audit_aux_data *aux; 211 struct audit_aux_data *aux;
212 struct audit_aux_data *aux_pids;
204 213
205 /* Save things to print about task_struct */ 214 /* Save things to print about task_struct */
206 pid_t pid, ppid; 215 pid_t pid, ppid;
@@ -209,6 +218,9 @@ struct audit_context {
209 unsigned long personality; 218 unsigned long personality;
210 int arch; 219 int arch;
211 220
221 pid_t target_pid;
222 u32 target_sid;
223
212#if AUDIT_DEBUG 224#if AUDIT_DEBUG
213 int put_count; 225 int put_count;
214 int ino_count; 226 int ino_count;
@@ -654,6 +666,10 @@ static inline void audit_free_aux(struct audit_context *context)
654 context->aux = aux->next; 666 context->aux = aux->next;
655 kfree(aux); 667 kfree(aux);
656 } 668 }
669 while ((aux = context->aux_pids)) {
670 context->aux_pids = aux->next;
671 kfree(aux);
672 }
657} 673}
658 674
659static inline void audit_zero_context(struct audit_context *context, 675static inline void audit_zero_context(struct audit_context *context,
@@ -795,6 +811,29 @@ static void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk
795 audit_log_task_context(ab); 811 audit_log_task_context(ab);
796} 812}
797 813
814static int audit_log_pid_context(struct audit_context *context, pid_t pid,
815 u32 sid)
816{
817 struct audit_buffer *ab;
818 char *s = NULL;
819 u32 len;
820 int rc = 0;
821
822 ab = audit_log_start(context, GFP_KERNEL, AUDIT_OBJ_PID);
823 if (!ab)
824 return 1;
825
826 if (selinux_sid_to_string(sid, &s, &len)) {
827 audit_log_format(ab, "opid=%d obj=(none)", pid);
828 rc = 1;
829 } else
830 audit_log_format(ab, "opid=%d obj=%s", pid, s);
831 audit_log_end(ab);
832 kfree(s);
833
834 return rc;
835}
836
798static void audit_log_exit(struct audit_context *context, struct task_struct *tsk) 837static void audit_log_exit(struct audit_context *context, struct task_struct *tsk)
799{ 838{
800 int i, call_panic = 0; 839 int i, call_panic = 0;
@@ -973,6 +1012,21 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
973 audit_log_end(ab); 1012 audit_log_end(ab);
974 } 1013 }
975 1014
1015 for (aux = context->aux_pids; aux; aux = aux->next) {
1016 struct audit_aux_data_pids *axs = (void *)aux;
1017 int i;
1018
1019 for (i = 0; i < axs->pid_count; i++)
1020 if (audit_log_pid_context(context, axs->target_pid[i],
1021 axs->target_sid[i]))
1022 call_panic = 1;
1023 }
1024
1025 if (context->target_pid &&
1026 audit_log_pid_context(context, context->target_pid,
1027 context->target_sid))
1028 call_panic = 1;
1029
976 if (context->pwd && context->pwdmnt) { 1030 if (context->pwd && context->pwdmnt) {
977 ab = audit_log_start(context, GFP_KERNEL, AUDIT_CWD); 1031 ab = audit_log_start(context, GFP_KERNEL, AUDIT_CWD);
978 if (ab) { 1032 if (ab) {
@@ -1193,6 +1247,10 @@ void audit_syscall_exit(int valid, long return_code)
1193 } else { 1247 } else {
1194 audit_free_names(context); 1248 audit_free_names(context);
1195 audit_free_aux(context); 1249 audit_free_aux(context);
1250 context->aux = NULL;
1251 context->aux_pids = NULL;
1252 context->target_pid = 0;
1253 context->target_sid = 0;
1196 kfree(context->filterkey); 1254 kfree(context->filterkey);
1197 context->filterkey = NULL; 1255 context->filterkey = NULL;
1198 tsk->audit_context = context; 1256 tsk->audit_context = context;
@@ -1226,6 +1284,7 @@ void __audit_getname(const char *name)
1226 context->names[context->name_count].name_len = AUDIT_NAME_FULL; 1284 context->names[context->name_count].name_len = AUDIT_NAME_FULL;
1227 context->names[context->name_count].name_put = 1; 1285 context->names[context->name_count].name_put = 1;
1228 context->names[context->name_count].ino = (unsigned long)-1; 1286 context->names[context->name_count].ino = (unsigned long)-1;
1287 context->names[context->name_count].osid = 0;
1229 ++context->name_count; 1288 ++context->name_count;
1230 if (!context->pwd) { 1289 if (!context->pwd) {
1231 read_lock(&current->fs->lock); 1290 read_lock(&current->fs->lock);
@@ -1279,6 +1338,28 @@ void audit_putname(const char *name)
1279#endif 1338#endif
1280} 1339}
1281 1340
1341static int audit_inc_name_count(struct audit_context *context,
1342 const struct inode *inode)
1343{
1344 if (context->name_count >= AUDIT_NAMES) {
1345 if (inode)
1346 printk(KERN_DEBUG "name_count maxed, losing inode data: "
1347 "dev=%02x:%02x, inode=%lu",
1348 MAJOR(inode->i_sb->s_dev),
1349 MINOR(inode->i_sb->s_dev),
1350 inode->i_ino);
1351
1352 else
1353 printk(KERN_DEBUG "name_count maxed, losing inode data");
1354 return 1;
1355 }
1356 context->name_count++;
1357#if AUDIT_DEBUG
1358 context->ino_count++;
1359#endif
1360 return 0;
1361}
1362
1282/* Copy inode data into an audit_names. */ 1363/* Copy inode data into an audit_names. */
1283static void audit_copy_inode(struct audit_names *name, const struct inode *inode) 1364static void audit_copy_inode(struct audit_names *name, const struct inode *inode)
1284{ 1365{
@@ -1316,13 +1397,10 @@ void __audit_inode(const char *name, const struct inode *inode)
1316 else { 1397 else {
1317 /* FIXME: how much do we care about inodes that have no 1398 /* FIXME: how much do we care about inodes that have no
1318 * associated name? */ 1399 * associated name? */
1319 if (context->name_count >= AUDIT_NAMES - AUDIT_NAMES_RESERVED) 1400 if (audit_inc_name_count(context, inode))
1320 return; 1401 return;
1321 idx = context->name_count++; 1402 idx = context->name_count - 1;
1322 context->names[idx].name = NULL; 1403 context->names[idx].name = NULL;
1323#if AUDIT_DEBUG
1324 ++context->ino_count;
1325#endif
1326 } 1404 }
1327 audit_copy_inode(&context->names[idx], inode); 1405 audit_copy_inode(&context->names[idx], inode);
1328} 1406}
@@ -1346,7 +1424,7 @@ void __audit_inode_child(const char *dname, const struct inode *inode,
1346{ 1424{
1347 int idx; 1425 int idx;
1348 struct audit_context *context = current->audit_context; 1426 struct audit_context *context = current->audit_context;
1349 const char *found_name = NULL; 1427 const char *found_parent = NULL, *found_child = NULL;
1350 int dirlen = 0; 1428 int dirlen = 0;
1351 1429
1352 if (!context->in_syscall) 1430 if (!context->in_syscall)
@@ -1354,88 +1432,73 @@ void __audit_inode_child(const char *dname, const struct inode *inode,
1354 1432
1355 /* determine matching parent */ 1433 /* determine matching parent */
1356 if (!dname) 1434 if (!dname)
1357 goto update_context; 1435 goto add_names;
1358 for (idx = 0; idx < context->name_count; idx++)
1359 if (context->names[idx].ino == parent->i_ino) {
1360 const char *name = context->names[idx].name;
1361 1436
1362 if (!name) 1437 /* parent is more likely, look for it first */
1363 continue; 1438 for (idx = 0; idx < context->name_count; idx++) {
1439 struct audit_names *n = &context->names[idx];
1364 1440
1365 if (audit_compare_dname_path(dname, name, &dirlen) == 0) { 1441 if (!n->name)
1366 context->names[idx].name_len = dirlen; 1442 continue;
1367 found_name = name; 1443
1368 break; 1444 if (n->ino == parent->i_ino &&
1369 } 1445 !audit_compare_dname_path(dname, n->name, &dirlen)) {
1446 n->name_len = dirlen; /* update parent data in place */
1447 found_parent = n->name;
1448 goto add_names;
1370 } 1449 }
1450 }
1371 1451
1372update_context: 1452 /* no matching parent, look for matching child */
1373 idx = context->name_count; 1453 for (idx = 0; idx < context->name_count; idx++) {
1374 if (context->name_count == AUDIT_NAMES) { 1454 struct audit_names *n = &context->names[idx];
1375 printk(KERN_DEBUG "name_count maxed and losing %s\n", 1455
1376 found_name ?: "(null)"); 1456 if (!n->name)
1377 return; 1457 continue;
1458
1459 /* strcmp() is the more likely scenario */
1460 if (!strcmp(dname, n->name) ||
1461 !audit_compare_dname_path(dname, n->name, &dirlen)) {
1462 if (inode)
1463 audit_copy_inode(n, inode);
1464 else
1465 n->ino = (unsigned long)-1;
1466 found_child = n->name;
1467 goto add_names;
1468 }
1378 } 1469 }
1379 context->name_count++; 1470
1380#if AUDIT_DEBUG 1471add_names:
1381 context->ino_count++; 1472 if (!found_parent) {
1382#endif 1473 if (audit_inc_name_count(context, parent))
1383 /* Re-use the name belonging to the slot for a matching parent directory.
1384 * All names for this context are relinquished in audit_free_names() */
1385 context->names[idx].name = found_name;
1386 context->names[idx].name_len = AUDIT_NAME_FULL;
1387 context->names[idx].name_put = 0; /* don't call __putname() */
1388
1389 if (!inode)
1390 context->names[idx].ino = (unsigned long)-1;
1391 else
1392 audit_copy_inode(&context->names[idx], inode);
1393
1394 /* A parent was not found in audit_names, so copy the inode data for the
1395 * provided parent. */
1396 if (!found_name) {
1397 idx = context->name_count;
1398 if (context->name_count == AUDIT_NAMES) {
1399 printk(KERN_DEBUG
1400 "name_count maxed and losing parent inode data: dev=%02x:%02x, inode=%lu",
1401 MAJOR(parent->i_sb->s_dev),
1402 MINOR(parent->i_sb->s_dev),
1403 parent->i_ino);
1404 return; 1474 return;
1405 } 1475 idx = context->name_count - 1;
1406 context->name_count++; 1476 context->names[idx].name = NULL;
1407#if AUDIT_DEBUG
1408 context->ino_count++;
1409#endif
1410 audit_copy_inode(&context->names[idx], parent); 1477 audit_copy_inode(&context->names[idx], parent);
1411 } 1478 }
1412}
1413 1479
1414/** 1480 if (!found_child) {
1415 * audit_inode_update - update inode info for last collected name 1481 if (audit_inc_name_count(context, inode))
1416 * @inode: inode being audited 1482 return;
1417 * 1483 idx = context->name_count - 1;
1418 * When open() is called on an existing object with the O_CREAT flag, the inode
1419 * data audit initially collects is incorrect. This additional hook ensures
1420 * audit has the inode data for the actual object to be opened.
1421 */
1422void __audit_inode_update(const struct inode *inode)
1423{
1424 struct audit_context *context = current->audit_context;
1425 int idx;
1426 1484
1427 if (!context->in_syscall || !inode) 1485 /* Re-use the name belonging to the slot for a matching parent
1428 return; 1486 * directory. All names for this context are relinquished in
1487 * audit_free_names() */
1488 if (found_parent) {
1489 context->names[idx].name = found_parent;
1490 context->names[idx].name_len = AUDIT_NAME_FULL;
1491 /* don't call __putname() */
1492 context->names[idx].name_put = 0;
1493 } else {
1494 context->names[idx].name = NULL;
1495 }
1429 1496
1430 if (context->name_count == 0) { 1497 if (inode)
1431 context->name_count++; 1498 audit_copy_inode(&context->names[idx], inode);
1432#if AUDIT_DEBUG 1499 else
1433 context->ino_count++; 1500 context->names[idx].ino = (unsigned long)-1;
1434#endif
1435 } 1501 }
1436 idx = context->name_count - 1;
1437
1438 audit_copy_inode(&context->names[idx], inode);
1439} 1502}
1440 1503
1441/** 1504/**
@@ -1880,6 +1943,14 @@ int audit_sockaddr(int len, void *a)
1880 return 0; 1943 return 0;
1881} 1944}
1882 1945
1946void __audit_ptrace(struct task_struct *t)
1947{
1948 struct audit_context *context = current->audit_context;
1949
1950 context->target_pid = t->pid;
1951 selinux_get_task_sid(t, &context->target_sid);
1952}
1953
1883/** 1954/**
1884 * audit_avc_path - record the granting or denial of permissions 1955 * audit_avc_path - record the granting or denial of permissions
1885 * @dentry: dentry to record 1956 * @dentry: dentry to record
@@ -1918,15 +1989,17 @@ int audit_avc_path(struct dentry *dentry, struct vfsmount *mnt)
1918 * If the audit subsystem is being terminated, record the task (pid) 1989 * If the audit subsystem is being terminated, record the task (pid)
1919 * and uid that is doing that. 1990 * and uid that is doing that.
1920 */ 1991 */
1921void __audit_signal_info(int sig, struct task_struct *t) 1992int __audit_signal_info(int sig, struct task_struct *t)
1922{ 1993{
1994 struct audit_aux_data_pids *axp;
1995 struct task_struct *tsk = current;
1996 struct audit_context *ctx = tsk->audit_context;
1923 extern pid_t audit_sig_pid; 1997 extern pid_t audit_sig_pid;
1924 extern uid_t audit_sig_uid; 1998 extern uid_t audit_sig_uid;
1925 extern u32 audit_sig_sid; 1999 extern u32 audit_sig_sid;
1926 2000
1927 if (sig == SIGTERM || sig == SIGHUP || sig == SIGUSR1) { 2001 if (audit_pid && t->tgid == audit_pid &&
1928 struct task_struct *tsk = current; 2002 (sig == SIGTERM || sig == SIGHUP || sig == SIGUSR1)) {
1929 struct audit_context *ctx = tsk->audit_context;
1930 audit_sig_pid = tsk->pid; 2003 audit_sig_pid = tsk->pid;
1931 if (ctx) 2004 if (ctx)
1932 audit_sig_uid = ctx->loginuid; 2005 audit_sig_uid = ctx->loginuid;
@@ -1934,4 +2007,72 @@ void __audit_signal_info(int sig, struct task_struct *t)
1934 audit_sig_uid = tsk->uid; 2007 audit_sig_uid = tsk->uid;
1935 selinux_get_task_sid(tsk, &audit_sig_sid); 2008 selinux_get_task_sid(tsk, &audit_sig_sid);
1936 } 2009 }
2010
2011 if (!audit_signals) /* audit_context checked in wrapper */
2012 return 0;
2013
2014 /* optimize the common case by putting first signal recipient directly
2015 * in audit_context */
2016 if (!ctx->target_pid) {
2017 ctx->target_pid = t->tgid;
2018 selinux_get_task_sid(t, &ctx->target_sid);
2019 return 0;
2020 }
2021
2022 axp = (void *)ctx->aux_pids;
2023 if (!axp || axp->pid_count == AUDIT_AUX_PIDS) {
2024 axp = kzalloc(sizeof(*axp), GFP_ATOMIC);
2025 if (!axp)
2026 return -ENOMEM;
2027
2028 axp->d.type = AUDIT_OBJ_PID;
2029 axp->d.next = ctx->aux_pids;
2030 ctx->aux_pids = (void *)axp;
2031 }
2032 BUG_ON(axp->pid_count > AUDIT_AUX_PIDS);
2033
2034 axp->target_pid[axp->pid_count] = t->tgid;
2035 selinux_get_task_sid(t, &axp->target_sid[axp->pid_count]);
2036 axp->pid_count++;
2037
2038 return 0;
2039}
2040
2041/**
2042 * audit_core_dumps - record information about processes that end abnormally
2043 * @sig: signal value
2044 *
2045 * If a process ends with a core dump, something fishy is going on and we
2046 * should record the event for investigation.
2047 */
2048void audit_core_dumps(long signr)
2049{
2050 struct audit_buffer *ab;
2051 u32 sid;
2052
2053 if (!audit_enabled)
2054 return;
2055
2056 if (signr == SIGQUIT) /* don't care for those */
2057 return;
2058
2059 ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_ANOM_ABEND);
2060 audit_log_format(ab, "auid=%u uid=%u gid=%u",
2061 audit_get_loginuid(current->audit_context),
2062 current->uid, current->gid);
2063 selinux_get_task_sid(current, &sid);
2064 if (sid) {
2065 char *ctx = NULL;
2066 u32 len;
2067
2068 if (selinux_sid_to_string(sid, &ctx, &len))
2069 audit_log_format(ab, " ssid=%u", sid);
2070 else
2071 audit_log_format(ab, " subj=%s", ctx);
2072 kfree(ctx);
2073 }
2074 audit_log_format(ab, " pid=%d comm=", current->pid);
2075 audit_log_untrustedstring(ab, current->comm);
2076 audit_log_format(ab, " sig=%ld", signr);
2077 audit_log_end(ab);
1937} 2078}
diff --git a/kernel/compat.c b/kernel/compat.c
index cebb4c28c039..3bae3742c2aa 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -475,8 +475,8 @@ asmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid, unsigned int len,
475 return min_length; 475 return min_length;
476} 476}
477 477
478static int get_compat_itimerspec(struct itimerspec *dst, 478int get_compat_itimerspec(struct itimerspec *dst,
479 struct compat_itimerspec __user *src) 479 const struct compat_itimerspec __user *src)
480{ 480{
481 if (get_compat_timespec(&dst->it_interval, &src->it_interval) || 481 if (get_compat_timespec(&dst->it_interval, &src->it_interval) ||
482 get_compat_timespec(&dst->it_value, &src->it_value)) 482 get_compat_timespec(&dst->it_value, &src->it_value))
@@ -484,8 +484,8 @@ static int get_compat_itimerspec(struct itimerspec *dst,
484 return 0; 484 return 0;
485} 485}
486 486
487static int put_compat_itimerspec(struct compat_itimerspec __user *dst, 487int put_compat_itimerspec(struct compat_itimerspec __user *dst,
488 struct itimerspec *src) 488 const struct itimerspec *src)
489{ 489{
490 if (put_compat_timespec(&src->it_interval, &dst->it_interval) || 490 if (put_compat_timespec(&src->it_interval, &dst->it_interval) ||
491 put_compat_timespec(&src->it_value, &dst->it_value)) 491 put_compat_timespec(&src->it_value, &dst->it_value))
diff --git a/kernel/exit.c b/kernel/exit.c
index b0c6f0c3a2df..c6d14b8008dd 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -24,6 +24,7 @@
24#include <linux/pid_namespace.h> 24#include <linux/pid_namespace.h>
25#include <linux/ptrace.h> 25#include <linux/ptrace.h>
26#include <linux/profile.h> 26#include <linux/profile.h>
27#include <linux/signalfd.h>
27#include <linux/mount.h> 28#include <linux/mount.h>
28#include <linux/proc_fs.h> 29#include <linux/proc_fs.h>
29#include <linux/kthread.h> 30#include <linux/kthread.h>
@@ -42,6 +43,7 @@
42#include <linux/audit.h> /* for audit_free() */ 43#include <linux/audit.h> /* for audit_free() */
43#include <linux/resource.h> 44#include <linux/resource.h>
44#include <linux/blkdev.h> 45#include <linux/blkdev.h>
46#include <linux/task_io_accounting_ops.h>
45 47
46#include <asm/uaccess.h> 48#include <asm/uaccess.h>
47#include <asm/unistd.h> 49#include <asm/unistd.h>
@@ -82,6 +84,14 @@ static void __exit_signal(struct task_struct *tsk)
82 sighand = rcu_dereference(tsk->sighand); 84 sighand = rcu_dereference(tsk->sighand);
83 spin_lock(&sighand->siglock); 85 spin_lock(&sighand->siglock);
84 86
87 /*
88 * Notify that this sighand has been detached. This must
89 * be called with the tsk->sighand lock held. Also, this
90 * access tsk->sighand internally, so it must be called
91 * before tsk->sighand is reset.
92 */
93 signalfd_detach_locked(tsk);
94
85 posix_cpu_timers_exit(tsk); 95 posix_cpu_timers_exit(tsk);
86 if (atomic_dec_and_test(&sig->count)) 96 if (atomic_dec_and_test(&sig->count))
87 posix_cpu_timers_exit_group(tsk); 97 posix_cpu_timers_exit_group(tsk);
@@ -113,6 +123,8 @@ static void __exit_signal(struct task_struct *tsk)
113 sig->nvcsw += tsk->nvcsw; 123 sig->nvcsw += tsk->nvcsw;
114 sig->nivcsw += tsk->nivcsw; 124 sig->nivcsw += tsk->nivcsw;
115 sig->sched_time += tsk->sched_time; 125 sig->sched_time += tsk->sched_time;
126 sig->inblock += task_io_get_inblock(tsk);
127 sig->oublock += task_io_get_oublock(tsk);
116 sig = NULL; /* Marker for below. */ 128 sig = NULL; /* Marker for below. */
117 } 129 }
118 130
@@ -299,12 +311,12 @@ void __set_special_pids(pid_t session, pid_t pgrp)
299 if (process_session(curr) != session) { 311 if (process_session(curr) != session) {
300 detach_pid(curr, PIDTYPE_SID); 312 detach_pid(curr, PIDTYPE_SID);
301 set_signal_session(curr->signal, session); 313 set_signal_session(curr->signal, session);
302 attach_pid(curr, PIDTYPE_SID, session); 314 attach_pid(curr, PIDTYPE_SID, find_pid(session));
303 } 315 }
304 if (process_group(curr) != pgrp) { 316 if (process_group(curr) != pgrp) {
305 detach_pid(curr, PIDTYPE_PGID); 317 detach_pid(curr, PIDTYPE_PGID);
306 curr->signal->pgrp = pgrp; 318 curr->signal->pgrp = pgrp;
307 attach_pid(curr, PIDTYPE_PGID, pgrp); 319 attach_pid(curr, PIDTYPE_PGID, find_pid(pgrp));
308 } 320 }
309} 321}
310 322
@@ -1193,6 +1205,12 @@ static int wait_task_zombie(struct task_struct *p, int noreap,
1193 p->nvcsw + sig->nvcsw + sig->cnvcsw; 1205 p->nvcsw + sig->nvcsw + sig->cnvcsw;
1194 psig->cnivcsw += 1206 psig->cnivcsw +=
1195 p->nivcsw + sig->nivcsw + sig->cnivcsw; 1207 p->nivcsw + sig->nivcsw + sig->cnivcsw;
1208 psig->cinblock +=
1209 task_io_get_inblock(p) +
1210 sig->inblock + sig->cinblock;
1211 psig->coublock +=
1212 task_io_get_oublock(p) +
1213 sig->oublock + sig->coublock;
1196 spin_unlock_irq(&p->parent->sighand->siglock); 1214 spin_unlock_irq(&p->parent->sighand->siglock);
1197 } 1215 }
1198 1216
diff --git a/kernel/fork.c b/kernel/fork.c
index 5dd3979747f5..49530e40ea8b 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -875,6 +875,7 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts
875 sig->utime = sig->stime = sig->cutime = sig->cstime = cputime_zero; 875 sig->utime = sig->stime = sig->cutime = sig->cstime = cputime_zero;
876 sig->nvcsw = sig->nivcsw = sig->cnvcsw = sig->cnivcsw = 0; 876 sig->nvcsw = sig->nivcsw = sig->cnvcsw = sig->cnivcsw = 0;
877 sig->min_flt = sig->maj_flt = sig->cmin_flt = sig->cmaj_flt = 0; 877 sig->min_flt = sig->maj_flt = sig->cmin_flt = sig->cmaj_flt = 0;
878 sig->inblock = sig->oublock = sig->cinblock = sig->coublock = 0;
878 sig->sched_time = 0; 879 sig->sched_time = 0;
879 INIT_LIST_HEAD(&sig->cpu_timers[0]); 880 INIT_LIST_HEAD(&sig->cpu_timers[0]);
880 INIT_LIST_HEAD(&sig->cpu_timers[1]); 881 INIT_LIST_HEAD(&sig->cpu_timers[1]);
@@ -955,7 +956,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
955 unsigned long stack_size, 956 unsigned long stack_size,
956 int __user *parent_tidptr, 957 int __user *parent_tidptr,
957 int __user *child_tidptr, 958 int __user *child_tidptr,
958 int pid) 959 struct pid *pid)
959{ 960{
960 int retval; 961 int retval;
961 struct task_struct *p = NULL; 962 struct task_struct *p = NULL;
@@ -1022,7 +1023,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1022 p->did_exec = 0; 1023 p->did_exec = 0;
1023 delayacct_tsk_init(p); /* Must remain after dup_task_struct() */ 1024 delayacct_tsk_init(p); /* Must remain after dup_task_struct() */
1024 copy_flags(clone_flags, p); 1025 copy_flags(clone_flags, p);
1025 p->pid = pid; 1026 p->pid = pid_nr(pid);
1026 retval = -EFAULT; 1027 retval = -EFAULT;
1027 if (clone_flags & CLONE_PARENT_SETTID) 1028 if (clone_flags & CLONE_PARENT_SETTID)
1028 if (put_user(p->pid, parent_tidptr)) 1029 if (put_user(p->pid, parent_tidptr))
@@ -1251,13 +1252,13 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1251 p->signal->tty = current->signal->tty; 1252 p->signal->tty = current->signal->tty;
1252 p->signal->pgrp = process_group(current); 1253 p->signal->pgrp = process_group(current);
1253 set_signal_session(p->signal, process_session(current)); 1254 set_signal_session(p->signal, process_session(current));
1254 attach_pid(p, PIDTYPE_PGID, process_group(p)); 1255 attach_pid(p, PIDTYPE_PGID, task_pgrp(current));
1255 attach_pid(p, PIDTYPE_SID, process_session(p)); 1256 attach_pid(p, PIDTYPE_SID, task_session(current));
1256 1257
1257 list_add_tail_rcu(&p->tasks, &init_task.tasks); 1258 list_add_tail_rcu(&p->tasks, &init_task.tasks);
1258 __get_cpu_var(process_counts)++; 1259 __get_cpu_var(process_counts)++;
1259 } 1260 }
1260 attach_pid(p, PIDTYPE_PID, p->pid); 1261 attach_pid(p, PIDTYPE_PID, pid);
1261 nr_threads++; 1262 nr_threads++;
1262 } 1263 }
1263 1264
@@ -1321,7 +1322,8 @@ struct task_struct * __cpuinit fork_idle(int cpu)
1321 struct task_struct *task; 1322 struct task_struct *task;
1322 struct pt_regs regs; 1323 struct pt_regs regs;
1323 1324
1324 task = copy_process(CLONE_VM, 0, idle_regs(&regs), 0, NULL, NULL, 0); 1325 task = copy_process(CLONE_VM, 0, idle_regs(&regs), 0, NULL, NULL,
1326 &init_struct_pid);
1325 if (!IS_ERR(task)) 1327 if (!IS_ERR(task))
1326 init_idle(task, cpu); 1328 init_idle(task, cpu);
1327 1329
@@ -1371,7 +1373,7 @@ long do_fork(unsigned long clone_flags,
1371 clone_flags |= CLONE_PTRACE; 1373 clone_flags |= CLONE_PTRACE;
1372 } 1374 }
1373 1375
1374 p = copy_process(clone_flags, stack_start, regs, stack_size, parent_tidptr, child_tidptr, nr); 1376 p = copy_process(clone_flags, stack_start, regs, stack_size, parent_tidptr, child_tidptr, pid);
1375 /* 1377 /*
1376 * Do this prior waking up the new thread - the thread pointer 1378 * Do this prior waking up the new thread - the thread pointer
1377 * might get invalid after that point, if the thread exits quickly. 1379 * might get invalid after that point, if the thread exits quickly.
@@ -1420,12 +1422,15 @@ long do_fork(unsigned long clone_flags,
1420#define ARCH_MIN_MMSTRUCT_ALIGN 0 1422#define ARCH_MIN_MMSTRUCT_ALIGN 0
1421#endif 1423#endif
1422 1424
1423static void sighand_ctor(void *data, struct kmem_cache *cachep, unsigned long flags) 1425static void sighand_ctor(void *data, struct kmem_cache *cachep,
1426 unsigned long flags)
1424{ 1427{
1425 struct sighand_struct *sighand = data; 1428 struct sighand_struct *sighand = data;
1426 1429
1427 if (flags & SLAB_CTOR_CONSTRUCTOR) 1430 if (flags & SLAB_CTOR_CONSTRUCTOR) {
1428 spin_lock_init(&sighand->siglock); 1431 spin_lock_init(&sighand->siglock);
1432 INIT_LIST_HEAD(&sighand->signalfd_list);
1433 }
1429} 1434}
1430 1435
1431void __init proc_caches_init(void) 1436void __init proc_caches_init(void)
@@ -1451,7 +1456,6 @@ void __init proc_caches_init(void)
1451 SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL); 1456 SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL, NULL);
1452} 1457}
1453 1458
1454
1455/* 1459/*
1456 * Check constraints on flags passed to the unshare system call and 1460 * Check constraints on flags passed to the unshare system call and
1457 * force unsharing of additional process context as appropriate. 1461 * force unsharing of additional process context as appropriate.
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index ddde0ef9ccdc..b4f1674fca79 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -27,6 +27,10 @@ static int irq_affinity_read_proc(char *page, char **start, off_t off,
27 return len; 27 return len;
28} 28}
29 29
30#ifndef is_affinity_mask_valid
31#define is_affinity_mask_valid(val) 1
32#endif
33
30int no_irq_affinity; 34int no_irq_affinity;
31static int irq_affinity_write_proc(struct file *file, const char __user *buffer, 35static int irq_affinity_write_proc(struct file *file, const char __user *buffer,
32 unsigned long count, void *data) 36 unsigned long count, void *data)
@@ -42,6 +46,9 @@ static int irq_affinity_write_proc(struct file *file, const char __user *buffer,
42 if (err) 46 if (err)
43 return err; 47 return err;
44 48
49 if (!is_affinity_mask_valid(new_value))
50 return -EINVAL;
51
45 /* 52 /*
46 * Do not allow disabling IRQs completely - it's a too easy 53 * Do not allow disabling IRQs completely - it's a too easy
47 * way to make the system unusable accidentally :-) At least 54 * way to make the system unusable accidentally :-) At least
diff --git a/kernel/pid.c b/kernel/pid.c
index d3ad724afa83..eb66bd2953ab 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -27,11 +27,13 @@
27#include <linux/bootmem.h> 27#include <linux/bootmem.h>
28#include <linux/hash.h> 28#include <linux/hash.h>
29#include <linux/pid_namespace.h> 29#include <linux/pid_namespace.h>
30#include <linux/init_task.h>
30 31
31#define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift) 32#define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift)
32static struct hlist_head *pid_hash; 33static struct hlist_head *pid_hash;
33static int pidhash_shift; 34static int pidhash_shift;
34static struct kmem_cache *pid_cachep; 35static struct kmem_cache *pid_cachep;
36struct pid init_struct_pid = INIT_STRUCT_PID;
35 37
36int pid_max = PID_MAX_DEFAULT; 38int pid_max = PID_MAX_DEFAULT;
37 39
@@ -247,13 +249,16 @@ struct pid * fastcall find_pid(int nr)
247} 249}
248EXPORT_SYMBOL_GPL(find_pid); 250EXPORT_SYMBOL_GPL(find_pid);
249 251
250int fastcall attach_pid(struct task_struct *task, enum pid_type type, int nr) 252/*
253 * attach_pid() must be called with the tasklist_lock write-held.
254 */
255int fastcall attach_pid(struct task_struct *task, enum pid_type type,
256 struct pid *pid)
251{ 257{
252 struct pid_link *link; 258 struct pid_link *link;
253 struct pid *pid;
254 259
255 link = &task->pids[type]; 260 link = &task->pids[type];
256 link->pid = pid = find_pid(nr); 261 link->pid = pid;
257 hlist_add_head_rcu(&link->node, &pid->tasks[type]); 262 hlist_add_head_rcu(&link->node, &pid->tasks[type]);
258 263
259 return 0; 264 return 0;
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 4d50e06fd745..ad7949a589dd 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -18,6 +18,7 @@
18#include <linux/ptrace.h> 18#include <linux/ptrace.h>
19#include <linux/security.h> 19#include <linux/security.h>
20#include <linux/signal.h> 20#include <linux/signal.h>
21#include <linux/audit.h>
21 22
22#include <asm/pgtable.h> 23#include <asm/pgtable.h>
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
@@ -161,6 +162,8 @@ int ptrace_attach(struct task_struct *task)
161{ 162{
162 int retval; 163 int retval;
163 164
165 audit_ptrace(task);
166
164 retval = -EPERM; 167 retval = -EPERM;
165 if (task->pid <= 1) 168 if (task->pid <= 1)
166 goto out; 169 goto out;
diff --git a/kernel/signal.c b/kernel/signal.c
index 2ac3a668d9dd..364fc95bf97c 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -21,6 +21,7 @@
21#include <linux/syscalls.h> 21#include <linux/syscalls.h>
22#include <linux/ptrace.h> 22#include <linux/ptrace.h>
23#include <linux/signal.h> 23#include <linux/signal.h>
24#include <linux/signalfd.h>
24#include <linux/capability.h> 25#include <linux/capability.h>
25#include <linux/freezer.h> 26#include <linux/freezer.h>
26#include <linux/pid_namespace.h> 27#include <linux/pid_namespace.h>
@@ -113,8 +114,7 @@ void recalc_sigpending(void)
113 114
114/* Given the mask, find the first available signal that should be serviced. */ 115/* Given the mask, find the first available signal that should be serviced. */
115 116
116static int 117int next_signal(struct sigpending *pending, sigset_t *mask)
117next_signal(struct sigpending *pending, sigset_t *mask)
118{ 118{
119 unsigned long i, *s, *m, x; 119 unsigned long i, *s, *m, x;
120 int sig = 0; 120 int sig = 0;
@@ -497,6 +497,11 @@ static int check_kill_permission(int sig, struct siginfo *info,
497 int error = -EINVAL; 497 int error = -EINVAL;
498 if (!valid_signal(sig)) 498 if (!valid_signal(sig))
499 return error; 499 return error;
500
501 error = audit_signal_info(sig, t); /* Let audit system see the signal */
502 if (error)
503 return error;
504
500 error = -EPERM; 505 error = -EPERM;
501 if ((info == SEND_SIG_NOINFO || (!is_si_special(info) && SI_FROMUSER(info))) 506 if ((info == SEND_SIG_NOINFO || (!is_si_special(info) && SI_FROMUSER(info)))
502 && ((sig != SIGCONT) || 507 && ((sig != SIGCONT) ||
@@ -506,10 +511,7 @@ static int check_kill_permission(int sig, struct siginfo *info,
506 && !capable(CAP_KILL)) 511 && !capable(CAP_KILL))
507 return error; 512 return error;
508 513
509 error = security_task_kill(t, info, sig, 0); 514 return security_task_kill(t, info, sig, 0);
510 if (!error)
511 audit_signal_info(sig, t); /* Let audit system see the signal */
512 return error;
513} 515}
514 516
515/* forward decl */ 517/* forward decl */
@@ -630,6 +632,12 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
630 int ret = 0; 632 int ret = 0;
631 633
632 /* 634 /*
635 * Deliver the signal to listening signalfds. This must be called
636 * with the sighand lock held.
637 */
638 signalfd_notify(t, sig);
639
640 /*
633 * fast-pathed signals for kernel-internal things like SIGSTOP 641 * fast-pathed signals for kernel-internal things like SIGSTOP
634 * or SIGKILL. 642 * or SIGKILL.
635 */ 643 */
@@ -1280,6 +1288,11 @@ int send_sigqueue(int sig, struct sigqueue *q, struct task_struct *p)
1280 ret = 1; 1288 ret = 1;
1281 goto out; 1289 goto out;
1282 } 1290 }
1291 /*
1292 * Deliver the signal to listening signalfds. This must be called
1293 * with the sighand lock held.
1294 */
1295 signalfd_notify(p, sig);
1283 1296
1284 list_add_tail(&q->list, &p->pending.list); 1297 list_add_tail(&q->list, &p->pending.list);
1285 sigaddset(&p->pending.signal, sig); 1298 sigaddset(&p->pending.signal, sig);
@@ -1323,6 +1336,11 @@ send_group_sigqueue(int sig, struct sigqueue *q, struct task_struct *p)
1323 q->info.si_overrun++; 1336 q->info.si_overrun++;
1324 goto out; 1337 goto out;
1325 } 1338 }
1339 /*
1340 * Deliver the signal to listening signalfds. This must be called
1341 * with the sighand lock held.
1342 */
1343 signalfd_notify(p, sig);
1326 1344
1327 /* 1345 /*
1328 * Put this signal on the shared-pending queue. 1346 * Put this signal on the shared-pending queue.
@@ -1983,6 +2001,8 @@ int copy_siginfo_to_user(siginfo_t __user *to, siginfo_t *from)
1983 /* 2001 /*
1984 * If you change siginfo_t structure, please be sure 2002 * If you change siginfo_t structure, please be sure
1985 * this code is fixed accordingly. 2003 * this code is fixed accordingly.
2004 * Please remember to update the signalfd_copyinfo() function
2005 * inside fs/signalfd.c too, in case siginfo_t changes.
1986 * It should never copy any pad contained in the structure 2006 * It should never copy any pad contained in the structure
1987 * to avoid security leaks, but must copy the generic 2007 * to avoid security leaks, but must copy the generic
1988 * 3 ints plus the relevant union member. 2008 * 3 ints plus the relevant union member.
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index daabb74ee0bc..fcee2a8e6da3 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -8,6 +8,8 @@
8#include <linux/sched.h> 8#include <linux/sched.h>
9#include <linux/stop_machine.h> 9#include <linux/stop_machine.h>
10#include <linux/syscalls.h> 10#include <linux/syscalls.h>
11#include <linux/interrupt.h>
12
11#include <asm/atomic.h> 13#include <asm/atomic.h>
12#include <asm/semaphore.h> 14#include <asm/semaphore.h>
13#include <asm/uaccess.h> 15#include <asm/uaccess.h>
@@ -45,6 +47,7 @@ static int stopmachine(void *cpu)
45 if (stopmachine_state == STOPMACHINE_DISABLE_IRQ 47 if (stopmachine_state == STOPMACHINE_DISABLE_IRQ
46 && !irqs_disabled) { 48 && !irqs_disabled) {
47 local_irq_disable(); 49 local_irq_disable();
50 hard_irq_disable();
48 irqs_disabled = 1; 51 irqs_disabled = 1;
49 /* Ack: irqs disabled. */ 52 /* Ack: irqs disabled. */
50 smp_mb(); /* Must read state first. */ 53 smp_mb(); /* Must read state first. */
@@ -124,6 +127,7 @@ static int stop_machine(void)
124 127
125 /* Make them disable irqs. */ 128 /* Make them disable irqs. */
126 local_irq_disable(); 129 local_irq_disable();
130 hard_irq_disable();
127 stopmachine_set_state(STOPMACHINE_DISABLE_IRQ); 131 stopmachine_set_state(STOPMACHINE_DISABLE_IRQ);
128 132
129 return 0; 133 return 0;
diff --git a/kernel/sys.c b/kernel/sys.c
index cdb7e9457ba6..872271ccc384 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -14,6 +14,7 @@
14#include <linux/prctl.h> 14#include <linux/prctl.h>
15#include <linux/highuid.h> 15#include <linux/highuid.h>
16#include <linux/fs.h> 16#include <linux/fs.h>
17#include <linux/resource.h>
17#include <linux/kernel.h> 18#include <linux/kernel.h>
18#include <linux/kexec.h> 19#include <linux/kexec.h>
19#include <linux/workqueue.h> 20#include <linux/workqueue.h>
@@ -29,6 +30,7 @@
29#include <linux/signal.h> 30#include <linux/signal.h>
30#include <linux/cn_proc.h> 31#include <linux/cn_proc.h>
31#include <linux/getcpu.h> 32#include <linux/getcpu.h>
33#include <linux/task_io_accounting_ops.h>
32 34
33#include <linux/compat.h> 35#include <linux/compat.h>
34#include <linux/syscalls.h> 36#include <linux/syscalls.h>
@@ -658,7 +660,7 @@ asmlinkage long sys_setpriority(int which, int who, int niceval)
658 int error = -EINVAL; 660 int error = -EINVAL;
659 struct pid *pgrp; 661 struct pid *pgrp;
660 662
661 if (which > 2 || which < 0) 663 if (which > PRIO_USER || which < PRIO_PROCESS)
662 goto out; 664 goto out;
663 665
664 /* normalize: avoid signed division (rounding problems) */ 666 /* normalize: avoid signed division (rounding problems) */
@@ -722,7 +724,7 @@ asmlinkage long sys_getpriority(int which, int who)
722 long niceval, retval = -ESRCH; 724 long niceval, retval = -ESRCH;
723 struct pid *pgrp; 725 struct pid *pgrp;
724 726
725 if (which > 2 || which < 0) 727 if (which > PRIO_USER || which < PRIO_PROCESS)
726 return -EINVAL; 728 return -EINVAL;
727 729
728 read_lock(&tasklist_lock); 730 read_lock(&tasklist_lock);
@@ -1486,7 +1488,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
1486 if (process_group(p) != pgid) { 1488 if (process_group(p) != pgid) {
1487 detach_pid(p, PIDTYPE_PGID); 1489 detach_pid(p, PIDTYPE_PGID);
1488 p->signal->pgrp = pgid; 1490 p->signal->pgrp = pgid;
1489 attach_pid(p, PIDTYPE_PGID, pgid); 1491 attach_pid(p, PIDTYPE_PGID, find_pid(pgid));
1490 } 1492 }
1491 1493
1492 err = 0; 1494 err = 0;
@@ -2082,6 +2084,8 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
2082 r->ru_nivcsw = p->signal->cnivcsw; 2084 r->ru_nivcsw = p->signal->cnivcsw;
2083 r->ru_minflt = p->signal->cmin_flt; 2085 r->ru_minflt = p->signal->cmin_flt;
2084 r->ru_majflt = p->signal->cmaj_flt; 2086 r->ru_majflt = p->signal->cmaj_flt;
2087 r->ru_inblock = p->signal->cinblock;
2088 r->ru_oublock = p->signal->coublock;
2085 2089
2086 if (who == RUSAGE_CHILDREN) 2090 if (who == RUSAGE_CHILDREN)
2087 break; 2091 break;
@@ -2093,6 +2097,8 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
2093 r->ru_nivcsw += p->signal->nivcsw; 2097 r->ru_nivcsw += p->signal->nivcsw;
2094 r->ru_minflt += p->signal->min_flt; 2098 r->ru_minflt += p->signal->min_flt;
2095 r->ru_majflt += p->signal->maj_flt; 2099 r->ru_majflt += p->signal->maj_flt;
2100 r->ru_inblock += p->signal->inblock;
2101 r->ru_oublock += p->signal->oublock;
2096 t = p; 2102 t = p;
2097 do { 2103 do {
2098 utime = cputime_add(utime, t->utime); 2104 utime = cputime_add(utime, t->utime);
@@ -2101,6 +2107,8 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
2101 r->ru_nivcsw += t->nivcsw; 2107 r->ru_nivcsw += t->nivcsw;
2102 r->ru_minflt += t->min_flt; 2108 r->ru_minflt += t->min_flt;
2103 r->ru_majflt += t->maj_flt; 2109 r->ru_majflt += t->maj_flt;
2110 r->ru_inblock += task_io_get_inblock(t);
2111 r->ru_oublock += task_io_get_oublock(t);
2104 t = next_thread(t); 2112 t = next_thread(t);
2105 } while (t != p); 2113 } while (t != p);
2106 break; 2114 break;
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index d7306d0f3dfc..7e11e2c98bf9 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -141,3 +141,10 @@ cond_syscall(compat_sys_migrate_pages);
141cond_syscall(sys_bdflush); 141cond_syscall(sys_bdflush);
142cond_syscall(sys_ioprio_set); 142cond_syscall(sys_ioprio_set);
143cond_syscall(sys_ioprio_get); 143cond_syscall(sys_ioprio_get);
144
145/* New file descriptors */
146cond_syscall(sys_signalfd);
147cond_syscall(sys_timerfd);
148cond_syscall(compat_sys_signalfd);
149cond_syscall(compat_sys_timerfd);
150cond_syscall(sys_eventfd);
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index ee05b8a061b5..fbc5c622acb0 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -438,6 +438,7 @@ config FAULT_INJECTION_DEBUG_FS
438config FAULT_INJECTION_STACKTRACE_FILTER 438config FAULT_INJECTION_STACKTRACE_FILTER
439 bool "stacktrace filter for fault-injection capabilities" 439 bool "stacktrace filter for fault-injection capabilities"
440 depends on FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT 440 depends on FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT
441 depends on !X86_64
441 select STACKTRACE 442 select STACKTRACE
442 select FRAME_POINTER 443 select FRAME_POINTER
443 help 444 help
diff --git a/lib/Makefile b/lib/Makefile
index 1f65b4613e09..c8c8e20784ce 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -13,7 +13,7 @@ lib-$(CONFIG_SMP) += cpumask.o
13lib-y += kobject.o kref.o kobject_uevent.o klist.o 13lib-y += kobject.o kref.o kobject_uevent.o klist.o
14 14
15obj-y += div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ 15obj-y += div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
16 bust_spinlocks.o 16 bust_spinlocks.o hexdump.o
17 17
18ifeq ($(CONFIG_DEBUG_KOBJECT),y) 18ifeq ($(CONFIG_DEBUG_KOBJECT),y)
19CFLAGS_kobject.o += -DDEBUG 19CFLAGS_kobject.o += -DDEBUG
diff --git a/lib/audit.c b/lib/audit.c
index 3b1289fadf06..8e7dc1c63aa9 100644
--- a/lib/audit.c
+++ b/lib/audit.c
@@ -23,6 +23,16 @@ static unsigned chattr_class[] = {
23~0U 23~0U
24}; 24};
25 25
26static unsigned signal_class[] = {
27#include <asm-generic/audit_signal.h>
28~0U
29};
30
31int audit_classify_arch(int arch)
32{
33 return 0;
34}
35
26int audit_classify_syscall(int abi, unsigned syscall) 36int audit_classify_syscall(int abi, unsigned syscall)
27{ 37{
28 switch(syscall) { 38 switch(syscall) {
@@ -49,6 +59,7 @@ static int __init audit_classes_init(void)
49 audit_register_class(AUDIT_CLASS_READ, read_class); 59 audit_register_class(AUDIT_CLASS_READ, read_class);
50 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class); 60 audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
51 audit_register_class(AUDIT_CLASS_CHATTR, chattr_class); 61 audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
62 audit_register_class(AUDIT_CLASS_SIGNAL, signal_class);
52 return 0; 63 return 0;
53} 64}
54 65
diff --git a/lib/hexdump.c b/lib/hexdump.c
new file mode 100644
index 000000000000..e6da5b7fc29a
--- /dev/null
+++ b/lib/hexdump.c
@@ -0,0 +1,104 @@
1/*
2 * lib/hexdump.c
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation. See README and COPYING for
7 * more details.
8 */
9
10#include <linux/types.h>
11#include <linux/ctype.h>
12#include <linux/kernel.h>
13#include <linux/module.h>
14
15/**
16 * hex_dump_to_buffer - convert a blob of data to "hex ASCII" in memory
17 * @buf: data blob to dump
18 * @len: number of bytes in the @buf
19 * @linebuf: where to put the converted data
20 * @linebuflen: total size of @linebuf, including space for terminating NUL
21 *
22 * hex_dump_to_buffer() works on one "line" of output at a time, i.e.,
23 * 16 bytes of input data converted to hex + ASCII output.
24 *
25 * Given a buffer of u8 data, hex_dump_to_buffer() converts the input data
26 * to a hex + ASCII dump at the supplied memory location.
27 * The converted output is always NUL-terminated.
28 *
29 * E.g.:
30 * hex_dump_to_buffer(frame->data, frame->len, linebuf, sizeof(linebuf));
31 *
32 * example output buffer:
33 * 40414243 44454647 48494a4b 4c4d4e4f @ABCDEFGHIJKLMNO
34 */
35void hex_dump_to_buffer(const void *buf, size_t len, char *linebuf,
36 size_t linebuflen)
37{
38 const u8 *ptr = buf;
39 u8 ch;
40 int j, lx = 0;
41
42 for (j = 0; (j < 16) && (j < len) && (lx + 3) < linebuflen; j++) {
43 if (j && !(j % 4))
44 linebuf[lx++] = ' ';
45 ch = ptr[j];
46 linebuf[lx++] = hex_asc(ch >> 4);
47 linebuf[lx++] = hex_asc(ch & 0x0f);
48 }
49 if ((lx + 2) < linebuflen) {
50 linebuf[lx++] = ' ';
51 linebuf[lx++] = ' ';
52 }
53 for (j = 0; (j < 16) && (j < len) && (lx + 2) < linebuflen; j++)
54 linebuf[lx++] = isprint(ptr[j]) ? ptr[j] : '.';
55 linebuf[lx++] = '\0';
56}
57EXPORT_SYMBOL(hex_dump_to_buffer);
58
59/**
60 * print_hex_dump - print a text hex dump to syslog for a binary blob of data
61 * @level: kernel log level (e.g. KERN_DEBUG)
62 * @prefix_type: controls whether prefix of an offset, address, or none
63 * is printed (%DUMP_PREFIX_OFFSET, %DUMP_PREFIX_ADDRESS, %DUMP_PREFIX_NONE)
64 * @buf: data blob to dump
65 * @len: number of bytes in the @buf
66 *
67 * Given a buffer of u8 data, print_hex_dump() prints a hex + ASCII dump
68 * to the kernel log at the specified kernel log level, with an optional
69 * leading prefix.
70 *
71 * E.g.:
72 * print_hex_dump(KERN_DEBUG, DUMP_PREFIX_ADDRESS, frame->data, frame->len);
73 *
74 * Example output using %DUMP_PREFIX_OFFSET:
75 * 0009ab42: 40414243 44454647 48494a4b 4c4d4e4f @ABCDEFGHIJKLMNO
76 * Example output using %DUMP_PREFIX_ADDRESS:
77 * ffffffff88089af0: 70717273 74757677 78797a7b 7c7d7e7f pqrstuvwxyz{|}~.
78 */
79void print_hex_dump(const char *level, int prefix_type, void *buf, size_t len)
80{
81 u8 *ptr = buf;
82 int i, linelen, remaining = len;
83 unsigned char linebuf[100];
84
85 for (i = 0; i < len; i += 16) {
86 linelen = min(remaining, 16);
87 remaining -= 16;
88 hex_dump_to_buffer(ptr + i, linelen, linebuf, sizeof(linebuf));
89
90 switch (prefix_type) {
91 case DUMP_PREFIX_ADDRESS:
92 printk("%s%*p: %s\n", level,
93 (int)(2 * sizeof(void *)), ptr + i, linebuf);
94 break;
95 case DUMP_PREFIX_OFFSET:
96 printk("%s%.8x: %s\n", level, i, linebuf);
97 break;
98 default:
99 printk("%s%s\n", level, linebuf);
100 break;
101 }
102 }
103}
104EXPORT_SYMBOL(print_hex_dump);
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 63cd88840eb2..eec1481ba44f 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -588,31 +588,27 @@ void __init page_writeback_init(void)
588} 588}
589 589
590/** 590/**
591 * generic_writepages - walk the list of dirty pages of the given address space and writepage() all of them. 591 * write_cache_pages - walk the list of dirty pages of the given address space and write all of them.
592 * @mapping: address space structure to write 592 * @mapping: address space structure to write
593 * @wbc: subtract the number of written pages from *@wbc->nr_to_write 593 * @wbc: subtract the number of written pages from *@wbc->nr_to_write
594 * @writepage: function called for each page
595 * @data: data passed to writepage function
594 * 596 *
595 * This is a library function, which implements the writepages() 597 * If a page is already under I/O, write_cache_pages() skips it, even
596 * address_space_operation.
597 *
598 * If a page is already under I/O, generic_writepages() skips it, even
599 * if it's dirty. This is desirable behaviour for memory-cleaning writeback, 598 * if it's dirty. This is desirable behaviour for memory-cleaning writeback,
600 * but it is INCORRECT for data-integrity system calls such as fsync(). fsync() 599 * but it is INCORRECT for data-integrity system calls such as fsync(). fsync()
601 * and msync() need to guarantee that all the data which was dirty at the time 600 * and msync() need to guarantee that all the data which was dirty at the time
602 * the call was made get new I/O started against them. If wbc->sync_mode is 601 * the call was made get new I/O started against them. If wbc->sync_mode is
603 * WB_SYNC_ALL then we were called for data integrity and we must wait for 602 * WB_SYNC_ALL then we were called for data integrity and we must wait for
604 * existing IO to complete. 603 * existing IO to complete.
605 *
606 * Derived from mpage_writepages() - if you fix this you should check that
607 * also!
608 */ 604 */
609int generic_writepages(struct address_space *mapping, 605int write_cache_pages(struct address_space *mapping,
610 struct writeback_control *wbc) 606 struct writeback_control *wbc, writepage_t writepage,
607 void *data)
611{ 608{
612 struct backing_dev_info *bdi = mapping->backing_dev_info; 609 struct backing_dev_info *bdi = mapping->backing_dev_info;
613 int ret = 0; 610 int ret = 0;
614 int done = 0; 611 int done = 0;
615 int (*writepage)(struct page *page, struct writeback_control *wbc);
616 struct pagevec pvec; 612 struct pagevec pvec;
617 int nr_pages; 613 int nr_pages;
618 pgoff_t index; 614 pgoff_t index;
@@ -625,12 +621,6 @@ int generic_writepages(struct address_space *mapping,
625 return 0; 621 return 0;
626 } 622 }
627 623
628 writepage = mapping->a_ops->writepage;
629
630 /* deal with chardevs and other special file */
631 if (!writepage)
632 return 0;
633
634 pagevec_init(&pvec, 0); 624 pagevec_init(&pvec, 0);
635 if (wbc->range_cyclic) { 625 if (wbc->range_cyclic) {
636 index = mapping->writeback_index; /* Start from prev offset */ 626 index = mapping->writeback_index; /* Start from prev offset */
@@ -682,8 +672,7 @@ retry:
682 continue; 672 continue;
683 } 673 }
684 674
685 ret = (*writepage)(page, wbc); 675 ret = (*writepage)(page, wbc, data);
686 mapping_set_error(mapping, ret);
687 676
688 if (unlikely(ret == AOP_WRITEPAGE_ACTIVATE)) 677 if (unlikely(ret == AOP_WRITEPAGE_ACTIVATE))
689 unlock_page(page); 678 unlock_page(page);
@@ -710,6 +699,38 @@ retry:
710 mapping->writeback_index = index; 699 mapping->writeback_index = index;
711 return ret; 700 return ret;
712} 701}
702EXPORT_SYMBOL(write_cache_pages);
703
704/*
705 * Function used by generic_writepages to call the real writepage
706 * function and set the mapping flags on error
707 */
708static int __writepage(struct page *page, struct writeback_control *wbc,
709 void *data)
710{
711 struct address_space *mapping = data;
712 int ret = mapping->a_ops->writepage(page, wbc);
713 mapping_set_error(mapping, ret);
714 return ret;
715}
716
717/**
718 * generic_writepages - walk the list of dirty pages of the given address space and writepage() all of them.
719 * @mapping: address space structure to write
720 * @wbc: subtract the number of written pages from *@wbc->nr_to_write
721 *
722 * This is a library function, which implements the writepages()
723 * address_space_operation.
724 */
725int generic_writepages(struct address_space *mapping,
726 struct writeback_control *wbc)
727{
728 /* deal with chardevs and other special file */
729 if (!mapping->a_ops->writepage)
730 return 0;
731
732 return write_cache_pages(mapping, wbc, __writepage, mapping);
733}
713 734
714EXPORT_SYMBOL(generic_writepages); 735EXPORT_SYMBOL(generic_writepages);
715 736
diff --git a/mm/thrash.c b/mm/thrash.c
index 9ef9071f99bc..c4c5205a9c35 100644
--- a/mm/thrash.c
+++ b/mm/thrash.c
@@ -48,9 +48,8 @@ void grab_swap_token(void)
48 if (current_interval < current->mm->last_interval) 48 if (current_interval < current->mm->last_interval)
49 current->mm->token_priority++; 49 current->mm->token_priority++;
50 else { 50 else {
51 current->mm->token_priority--; 51 if (likely(current->mm->token_priority > 0))
52 if (unlikely(current->mm->token_priority < 0)) 52 current->mm->token_priority--;
53 current->mm->token_priority = 0;
54 } 53 }
55 /* Check if we deserve the token */ 54 /* Check if we deserve the token */
56 if (current->mm->token_priority > 55 if (current->mm->token_priority >
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 9832d9a41d8c..8faf27e5aa98 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -698,7 +698,7 @@ static void __devinit start_cpu_timer(int cpu)
698{ 698{
699 struct delayed_work *vmstat_work = &per_cpu(vmstat_work, cpu); 699 struct delayed_work *vmstat_work = &per_cpu(vmstat_work, cpu);
700 700
701 INIT_DELAYED_WORK(vmstat_work, vmstat_update); 701 INIT_DELAYED_WORK_DEFERRABLE(vmstat_work, vmstat_update);
702 schedule_delayed_work_on(cpu, vmstat_work, HZ + cpu); 702 schedule_delayed_work_on(cpu, vmstat_work, HZ + cpu);
703} 703}
704 704
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index d342e89b8bdd..ceadfcf457c1 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -174,7 +174,7 @@ static inline int hidp_queue_event(struct hidp_session *session, struct input_de
174 174
175static int hidp_hidinput_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 175static int hidp_hidinput_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
176{ 176{
177 struct hid_device *hid = dev->private; 177 struct hid_device *hid = input_get_drvdata(dev);
178 struct hidp_session *session = hid->driver_data; 178 struct hidp_session *session = hid->driver_data;
179 179
180 return hidp_queue_event(session, dev, type, code, value); 180 return hidp_queue_event(session, dev, type, code, value);
@@ -182,7 +182,7 @@ static int hidp_hidinput_event(struct input_dev *dev, unsigned int type, unsigne
182 182
183static int hidp_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 183static int hidp_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
184{ 184{
185 struct hidp_session *session = dev->private; 185 struct hidp_session *session = input_get_drvdata(dev);
186 186
187 return hidp_queue_event(session, dev, type, code, value); 187 return hidp_queue_event(session, dev, type, code, value);
188} 188}
@@ -630,7 +630,7 @@ static inline void hidp_setup_input(struct hidp_session *session, struct hidp_co
630 struct input_dev *input = session->input; 630 struct input_dev *input = session->input;
631 int i; 631 int i;
632 632
633 input->private = session; 633 input_set_drvdata(input, session);
634 634
635 input->name = "Bluetooth HID Boot Protocol Device"; 635 input->name = "Bluetooth HID Boot Protocol Device";
636 636
@@ -663,7 +663,7 @@ static inline void hidp_setup_input(struct hidp_session *session, struct hidp_co
663 input->relbit[0] |= BIT(REL_WHEEL); 663 input->relbit[0] |= BIT(REL_WHEEL);
664 } 664 }
665 665
666 input->cdev.dev = hidp_get_device(session); 666 input->dev.parent = hidp_get_device(session);
667 667
668 input->event = hidp_input_event; 668 input->event = hidp_input_event;
669 669
@@ -737,10 +737,8 @@ static inline void hidp_setup_hid(struct hidp_session *session, struct hidp_conn
737 list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list) 737 list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list)
738 hidp_send_report(session, report); 738 hidp_send_report(session, report);
739 739
740 if (hidinput_connect(hid) == 0) { 740 if (hidinput_connect(hid) == 0)
741 hid->claimed |= HID_CLAIMED_INPUT; 741 hid->claimed |= HID_CLAIMED_INPUT;
742 hid_ff_init(hid);
743 }
744} 742}
745 743
746int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, struct socket *intr_sock) 744int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, struct socket *intr_sock)
@@ -864,7 +862,7 @@ failed:
864 if (session->hid) 862 if (session->hid)
865 hid_free_device(session->hid); 863 hid_free_device(session->hid);
866 864
867 kfree(session->input); 865 input_free_device(session->input);
868 kfree(session); 866 kfree(session);
869 return err; 867 return err;
870} 868}
diff --git a/net/core/link_watch.c b/net/core/link_watch.c
index e3c26a9ccad6..a5e372b9ec4d 100644
--- a/net/core/link_watch.c
+++ b/net/core/link_watch.c
@@ -19,7 +19,6 @@
19#include <linux/rtnetlink.h> 19#include <linux/rtnetlink.h>
20#include <linux/jiffies.h> 20#include <linux/jiffies.h>
21#include <linux/spinlock.h> 21#include <linux/spinlock.h>
22#include <linux/list.h>
23#include <linux/slab.h> 22#include <linux/slab.h>
24#include <linux/workqueue.h> 23#include <linux/workqueue.h>
25#include <linux/bitops.h> 24#include <linux/bitops.h>
@@ -27,8 +26,7 @@
27 26
28 27
29enum lw_bits { 28enum lw_bits {
30 LW_RUNNING = 0, 29 LW_URGENT = 0,
31 LW_SE_USED
32}; 30};
33 31
34static unsigned long linkwatch_flags; 32static unsigned long linkwatch_flags;
@@ -37,17 +35,9 @@ static unsigned long linkwatch_nextevent;
37static void linkwatch_event(struct work_struct *dummy); 35static void linkwatch_event(struct work_struct *dummy);
38static DECLARE_DELAYED_WORK(linkwatch_work, linkwatch_event); 36static DECLARE_DELAYED_WORK(linkwatch_work, linkwatch_event);
39 37
40static LIST_HEAD(lweventlist); 38static struct net_device *lweventlist;
41static DEFINE_SPINLOCK(lweventlist_lock); 39static DEFINE_SPINLOCK(lweventlist_lock);
42 40
43struct lw_event {
44 struct list_head list;
45 struct net_device *dev;
46};
47
48/* Avoid kmalloc() for most systems */
49static struct lw_event singleevent;
50
51static unsigned char default_operstate(const struct net_device *dev) 41static unsigned char default_operstate(const struct net_device *dev)
52{ 42{
53 if (!netif_carrier_ok(dev)) 43 if (!netif_carrier_ok(dev))
@@ -87,25 +77,102 @@ static void rfc2863_policy(struct net_device *dev)
87} 77}
88 78
89 79
90/* Must be called with the rtnl semaphore held */ 80static int linkwatch_urgent_event(struct net_device *dev)
91void linkwatch_run_queue(void)
92{ 81{
93 struct list_head head, *n, *next; 82 return netif_running(dev) && netif_carrier_ok(dev) &&
83 dev->qdisc != dev->qdisc_sleeping;
84}
85
86
87static void linkwatch_add_event(struct net_device *dev)
88{
89 unsigned long flags;
90
91 spin_lock_irqsave(&lweventlist_lock, flags);
92 dev->link_watch_next = lweventlist;
93 lweventlist = dev;
94 spin_unlock_irqrestore(&lweventlist_lock, flags);
95}
96
97
98static void linkwatch_schedule_work(int urgent)
99{
100 unsigned long delay = linkwatch_nextevent - jiffies;
101
102 if (test_bit(LW_URGENT, &linkwatch_flags))
103 return;
104
105 /* Minimise down-time: drop delay for up event. */
106 if (urgent) {
107 if (test_and_set_bit(LW_URGENT, &linkwatch_flags))
108 return;
109 delay = 0;
110 }
111
112 /* If we wrap around we'll delay it by at most HZ. */
113 if (delay > HZ)
114 delay = 0;
115
116 /*
117 * This is true if we've scheduled it immeditately or if we don't
118 * need an immediate execution and it's already pending.
119 */
120 if (schedule_delayed_work(&linkwatch_work, delay) == !delay)
121 return;
122
123 /* Don't bother if there is nothing urgent. */
124 if (!test_bit(LW_URGENT, &linkwatch_flags))
125 return;
126
127 /* It's already running which is good enough. */
128 if (!cancel_delayed_work(&linkwatch_work))
129 return;
130
131 /* Otherwise we reschedule it again for immediate exection. */
132 schedule_delayed_work(&linkwatch_work, 0);
133}
134
135
136static void __linkwatch_run_queue(int urgent_only)
137{
138 struct net_device *next;
139
140 /*
141 * Limit the number of linkwatch events to one
142 * per second so that a runaway driver does not
143 * cause a storm of messages on the netlink
144 * socket. This limit does not apply to up events
145 * while the device qdisc is down.
146 */
147 if (!urgent_only)
148 linkwatch_nextevent = jiffies + HZ;
149 /* Limit wrap-around effect on delay. */
150 else if (time_after(linkwatch_nextevent, jiffies + HZ))
151 linkwatch_nextevent = jiffies;
152
153 clear_bit(LW_URGENT, &linkwatch_flags);
94 154
95 spin_lock_irq(&lweventlist_lock); 155 spin_lock_irq(&lweventlist_lock);
96 list_replace_init(&lweventlist, &head); 156 next = lweventlist;
157 lweventlist = NULL;
97 spin_unlock_irq(&lweventlist_lock); 158 spin_unlock_irq(&lweventlist_lock);
98 159
99 list_for_each_safe(n, next, &head) { 160 while (next) {
100 struct lw_event *event = list_entry(n, struct lw_event, list); 161 struct net_device *dev = next;
101 struct net_device *dev = event->dev;
102 162
103 if (event == &singleevent) { 163 next = dev->link_watch_next;
104 clear_bit(LW_SE_USED, &linkwatch_flags); 164
105 } else { 165 if (urgent_only && !linkwatch_urgent_event(dev)) {
106 kfree(event); 166 linkwatch_add_event(dev);
167 continue;
107 } 168 }
108 169
170 /*
171 * Make sure the above read is complete since it can be
172 * rewritten as soon as we clear the bit below.
173 */
174 smp_mb__before_clear_bit();
175
109 /* We are about to handle this device, 176 /* We are about to handle this device,
110 * so new events can be accepted 177 * so new events can be accepted
111 */ 178 */
@@ -124,58 +191,39 @@ void linkwatch_run_queue(void)
124 191
125 dev_put(dev); 192 dev_put(dev);
126 } 193 }
194
195 if (lweventlist)
196 linkwatch_schedule_work(0);
127} 197}
128 198
129 199
130static void linkwatch_event(struct work_struct *dummy) 200/* Must be called with the rtnl semaphore held */
201void linkwatch_run_queue(void)
131{ 202{
132 /* Limit the number of linkwatch events to one 203 __linkwatch_run_queue(0);
133 * per second so that a runaway driver does not 204}
134 * cause a storm of messages on the netlink
135 * socket
136 */
137 linkwatch_nextevent = jiffies + HZ;
138 clear_bit(LW_RUNNING, &linkwatch_flags);
139 205
206
207static void linkwatch_event(struct work_struct *dummy)
208{
140 rtnl_lock(); 209 rtnl_lock();
141 linkwatch_run_queue(); 210 __linkwatch_run_queue(time_after(linkwatch_nextevent, jiffies));
142 rtnl_unlock(); 211 rtnl_unlock();
143} 212}
144 213
145 214
146void linkwatch_fire_event(struct net_device *dev) 215void linkwatch_fire_event(struct net_device *dev)
147{ 216{
148 if (!test_and_set_bit(__LINK_STATE_LINKWATCH_PENDING, &dev->state)) { 217 int urgent = linkwatch_urgent_event(dev);
149 unsigned long flags;
150 struct lw_event *event;
151
152 if (test_and_set_bit(LW_SE_USED, &linkwatch_flags)) {
153 event = kmalloc(sizeof(struct lw_event), GFP_ATOMIC);
154
155 if (unlikely(event == NULL)) {
156 clear_bit(__LINK_STATE_LINKWATCH_PENDING, &dev->state);
157 return;
158 }
159 } else {
160 event = &singleevent;
161 }
162 218
219 if (!test_and_set_bit(__LINK_STATE_LINKWATCH_PENDING, &dev->state)) {
163 dev_hold(dev); 220 dev_hold(dev);
164 event->dev = dev;
165
166 spin_lock_irqsave(&lweventlist_lock, flags);
167 list_add_tail(&event->list, &lweventlist);
168 spin_unlock_irqrestore(&lweventlist_lock, flags);
169 221
170 if (!test_and_set_bit(LW_RUNNING, &linkwatch_flags)) { 222 linkwatch_add_event(dev);
171 unsigned long delay = linkwatch_nextevent - jiffies; 223 } else if (!urgent)
224 return;
172 225
173 /* If we wrap around we'll delay it by at most HZ. */ 226 linkwatch_schedule_work(urgent);
174 if (delay > HZ)
175 delay = 0;
176 schedule_delayed_work(&linkwatch_work, delay);
177 }
178 }
179} 227}
180 228
181EXPORT_SYMBOL(linkwatch_fire_event); 229EXPORT_SYMBOL(linkwatch_fire_event);
diff --git a/net/ipv4/netfilter/arptable_filter.c b/net/ipv4/netfilter/arptable_filter.c
index 7edea2a1696c..75c023062533 100644
--- a/net/ipv4/netfilter/arptable_filter.c
+++ b/net/ipv4/netfilter/arptable_filter.c
@@ -15,128 +15,34 @@ MODULE_DESCRIPTION("arptables filter table");
15#define FILTER_VALID_HOOKS ((1 << NF_ARP_IN) | (1 << NF_ARP_OUT) | \ 15#define FILTER_VALID_HOOKS ((1 << NF_ARP_IN) | (1 << NF_ARP_OUT) | \
16 (1 << NF_ARP_FORWARD)) 16 (1 << NF_ARP_FORWARD))
17 17
18/* Standard entry. */
19struct arpt_standard
20{
21 struct arpt_entry entry;
22 struct arpt_standard_target target;
23};
24
25struct arpt_error_target
26{
27 struct arpt_entry_target target;
28 char errorname[ARPT_FUNCTION_MAXNAMELEN];
29};
30
31struct arpt_error
32{
33 struct arpt_entry entry;
34 struct arpt_error_target target;
35};
36
37static struct 18static struct
38{ 19{
39 struct arpt_replace repl; 20 struct arpt_replace repl;
40 struct arpt_standard entries[3]; 21 struct arpt_standard entries[3];
41 struct arpt_error term; 22 struct arpt_error term;
42} initial_table __initdata 23} initial_table __initdata = {
43= { { "filter", FILTER_VALID_HOOKS, 4, 24 .repl = {
44 sizeof(struct arpt_standard) * 3 + sizeof(struct arpt_error), 25 .name = "filter",
45 { [NF_ARP_IN] = 0, 26 .valid_hooks = FILTER_VALID_HOOKS,
46 [NF_ARP_OUT] = sizeof(struct arpt_standard), 27 .num_entries = 4,
47 [NF_ARP_FORWARD] = 2 * sizeof(struct arpt_standard), }, 28 .size = sizeof(struct arpt_standard) * 3 + sizeof(struct arpt_error),
48 { [NF_ARP_IN] = 0, 29 .hook_entry = {
49 [NF_ARP_OUT] = sizeof(struct arpt_standard), 30 [NF_ARP_IN] = 0,
50 [NF_ARP_FORWARD] = 2 * sizeof(struct arpt_standard), }, 31 [NF_ARP_OUT] = sizeof(struct arpt_standard),
51 0, NULL, { } }, 32 [NF_ARP_FORWARD] = 2 * sizeof(struct arpt_standard),
52 { 33 },
53 /* ARP_IN */ 34 .underflow = {
54 { 35 [NF_ARP_IN] = 0,
55 { 36 [NF_ARP_OUT] = sizeof(struct arpt_standard),
56 { 37 [NF_ARP_FORWARD] = 2 * sizeof(struct arpt_standard),
57 { 0 }, { 0 }, { 0 }, { 0 }, 38 },
58 0, 0, 39 },
59 { { 0, }, { 0, } }, 40 .entries = {
60 { { 0, }, { 0, } }, 41 ARPT_STANDARD_INIT(NF_ACCEPT), /* ARP_IN */
61 0, 0, 42 ARPT_STANDARD_INIT(NF_ACCEPT), /* ARP_OUT */
62 0, 0, 43 ARPT_STANDARD_INIT(NF_ACCEPT), /* ARP_FORWARD */
63 0, 0, 44 },
64 "", "", { 0 }, { 0 }, 45 .term = ARPT_ERROR_INIT,
65 0, 0
66 },
67 sizeof(struct arpt_entry),
68 sizeof(struct arpt_standard),
69 0,
70 { 0, 0 }, { } },
71 { { { { ARPT_ALIGN(sizeof(struct arpt_standard_target)), "" } }, { } },
72 -NF_ACCEPT - 1 }
73 },
74 /* ARP_OUT */
75 {
76 {
77 {
78 { 0 }, { 0 }, { 0 }, { 0 },
79 0, 0,
80 { { 0, }, { 0, } },
81 { { 0, }, { 0, } },
82 0, 0,
83 0, 0,
84 0, 0,
85 "", "", { 0 }, { 0 },
86 0, 0
87 },
88 sizeof(struct arpt_entry),
89 sizeof(struct arpt_standard),
90 0,
91 { 0, 0 }, { } },
92 { { { { ARPT_ALIGN(sizeof(struct arpt_standard_target)), "" } }, { } },
93 -NF_ACCEPT - 1 }
94 },
95 /* ARP_FORWARD */
96 {
97 {
98 {
99 { 0 }, { 0 }, { 0 }, { 0 },
100 0, 0,
101 { { 0, }, { 0, } },
102 { { 0, }, { 0, } },
103 0, 0,
104 0, 0,
105 0, 0,
106 "", "", { 0 }, { 0 },
107 0, 0
108 },
109 sizeof(struct arpt_entry),
110 sizeof(struct arpt_standard),
111 0,
112 { 0, 0 }, { } },
113 { { { { ARPT_ALIGN(sizeof(struct arpt_standard_target)), "" } }, { } },
114 -NF_ACCEPT - 1 }
115 }
116 },
117 /* ERROR */
118 {
119 {
120 {
121 { 0 }, { 0 }, { 0 }, { 0 },
122 0, 0,
123 { { 0, }, { 0, } },
124 { { 0, }, { 0, } },
125 0, 0,
126 0, 0,
127 0, 0,
128 "", "", { 0 }, { 0 },
129 0, 0
130 },
131 sizeof(struct arpt_entry),
132 sizeof(struct arpt_error),
133 0,
134 { 0, 0 }, { } },
135 { { { { ARPT_ALIGN(sizeof(struct arpt_error_target)), ARPT_ERROR_TARGET } },
136 { } },
137 "ERROR"
138 }
139 }
140}; 46};
141 47
142static struct arpt_table packet_filter = { 48static struct arpt_table packet_filter = {
diff --git a/net/ipv4/netfilter/iptable_filter.c b/net/ipv4/netfilter/iptable_filter.c
index 42728909eba0..4f51c1d7d2d6 100644
--- a/net/ipv4/netfilter/iptable_filter.c
+++ b/net/ipv4/netfilter/iptable_filter.c
@@ -26,53 +26,29 @@ static struct
26 struct ipt_replace repl; 26 struct ipt_replace repl;
27 struct ipt_standard entries[3]; 27 struct ipt_standard entries[3];
28 struct ipt_error term; 28 struct ipt_error term;
29} initial_table __initdata 29} initial_table __initdata = {
30= { { "filter", FILTER_VALID_HOOKS, 4, 30 .repl = {
31 sizeof(struct ipt_standard) * 3 + sizeof(struct ipt_error), 31 .name = "filter",
32 { [NF_IP_LOCAL_IN] = 0, 32 .valid_hooks = FILTER_VALID_HOOKS,
33 [NF_IP_FORWARD] = sizeof(struct ipt_standard), 33 .num_entries = 4,
34 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2 }, 34 .size = sizeof(struct ipt_standard) * 3 + sizeof(struct ipt_error),
35 { [NF_IP_LOCAL_IN] = 0, 35 .hook_entry = {
36 [NF_IP_FORWARD] = sizeof(struct ipt_standard), 36 [NF_IP_LOCAL_IN] = 0,
37 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2 }, 37 [NF_IP_FORWARD] = sizeof(struct ipt_standard),
38 0, NULL, { } }, 38 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2,
39 { 39 },
40 /* LOCAL_IN */ 40 .underflow = {
41 { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 }, 41 [NF_IP_LOCAL_IN] = 0,
42 0, 42 [NF_IP_FORWARD] = sizeof(struct ipt_standard),
43 sizeof(struct ipt_entry), 43 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2,
44 sizeof(struct ipt_standard), 44 },
45 0, { 0, 0 }, { } }, 45 },
46 { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } }, 46 .entries = {
47 -NF_ACCEPT - 1 } }, 47 IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_IN */
48 /* FORWARD */ 48 IPT_STANDARD_INIT(NF_ACCEPT), /* FORWARD */
49 { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 }, 49 IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */
50 0, 50 },
51 sizeof(struct ipt_entry), 51 .term = IPT_ERROR_INIT, /* ERROR */
52 sizeof(struct ipt_standard),
53 0, { 0, 0 }, { } },
54 { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } },
55 -NF_ACCEPT - 1 } },
56 /* LOCAL_OUT */
57 { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
58 0,
59 sizeof(struct ipt_entry),
60 sizeof(struct ipt_standard),
61 0, { 0, 0 }, { } },
62 { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } },
63 -NF_ACCEPT - 1 } }
64 },
65 /* ERROR */
66 { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
67 0,
68 sizeof(struct ipt_entry),
69 sizeof(struct ipt_error),
70 0, { 0, 0 }, { } },
71 { { { { IPT_ALIGN(sizeof(struct ipt_error_target)), IPT_ERROR_TARGET } },
72 { } },
73 "ERROR"
74 }
75 }
76}; 52};
77 53
78static struct xt_table packet_filter = { 54static struct xt_table packet_filter = {
@@ -105,7 +81,8 @@ ipt_local_out_hook(unsigned int hook,
105 if ((*pskb)->len < sizeof(struct iphdr) 81 if ((*pskb)->len < sizeof(struct iphdr)
106 || ip_hdrlen(*pskb) < sizeof(struct iphdr)) { 82 || ip_hdrlen(*pskb) < sizeof(struct iphdr)) {
107 if (net_ratelimit()) 83 if (net_ratelimit())
108 printk("ipt_hook: happy cracking.\n"); 84 printk("iptable_filter: ignoring short SOCK_RAW "
85 "packet.\n");
109 return NF_ACCEPT; 86 return NF_ACCEPT;
110 } 87 }
111 88
diff --git a/net/ipv4/netfilter/iptable_mangle.c b/net/ipv4/netfilter/iptable_mangle.c
index 9278802f2742..902446f7cbca 100644
--- a/net/ipv4/netfilter/iptable_mangle.c
+++ b/net/ipv4/netfilter/iptable_mangle.c
@@ -33,73 +33,35 @@ static struct
33 struct ipt_replace repl; 33 struct ipt_replace repl;
34 struct ipt_standard entries[5]; 34 struct ipt_standard entries[5];
35 struct ipt_error term; 35 struct ipt_error term;
36} initial_table __initdata 36} initial_table __initdata = {
37= { { "mangle", MANGLE_VALID_HOOKS, 6, 37 .repl = {
38 sizeof(struct ipt_standard) * 5 + sizeof(struct ipt_error), 38 .name = "mangle",
39 { [NF_IP_PRE_ROUTING] = 0, 39 .valid_hooks = MANGLE_VALID_HOOKS,
40 [NF_IP_LOCAL_IN] = sizeof(struct ipt_standard), 40 .num_entries = 6,
41 [NF_IP_FORWARD] = sizeof(struct ipt_standard) * 2, 41 .size = sizeof(struct ipt_standard) * 5 + sizeof(struct ipt_error),
42 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 3, 42 .hook_entry = {
43 [NF_IP_POST_ROUTING] = sizeof(struct ipt_standard) * 4 }, 43 [NF_IP_PRE_ROUTING] = 0,
44 { [NF_IP_PRE_ROUTING] = 0, 44 [NF_IP_LOCAL_IN] = sizeof(struct ipt_standard),
45 [NF_IP_LOCAL_IN] = sizeof(struct ipt_standard), 45 [NF_IP_FORWARD] = sizeof(struct ipt_standard) * 2,
46 [NF_IP_FORWARD] = sizeof(struct ipt_standard) * 2, 46 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 3,
47 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 3, 47 [NF_IP_POST_ROUTING] = sizeof(struct ipt_standard) * 4,
48 [NF_IP_POST_ROUTING] = sizeof(struct ipt_standard) * 4 }, 48 },
49 0, NULL, { } }, 49 .underflow = {
50 { 50 [NF_IP_PRE_ROUTING] = 0,
51 /* PRE_ROUTING */ 51 [NF_IP_LOCAL_IN] = sizeof(struct ipt_standard),
52 { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 }, 52 [NF_IP_FORWARD] = sizeof(struct ipt_standard) * 2,
53 0, 53 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 3,
54 sizeof(struct ipt_entry), 54 [NF_IP_POST_ROUTING] = sizeof(struct ipt_standard) * 4,
55 sizeof(struct ipt_standard), 55 },
56 0, { 0, 0 }, { } }, 56 },
57 { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } }, 57 .entries = {
58 -NF_ACCEPT - 1 } }, 58 IPT_STANDARD_INIT(NF_ACCEPT), /* PRE_ROUTING */
59 /* LOCAL_IN */ 59 IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_IN */
60 { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 }, 60 IPT_STANDARD_INIT(NF_ACCEPT), /* FORWARD */
61 0, 61 IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */
62 sizeof(struct ipt_entry), 62 IPT_STANDARD_INIT(NF_ACCEPT), /* POST_ROUTING */
63 sizeof(struct ipt_standard), 63 },
64 0, { 0, 0 }, { } }, 64 .term = IPT_ERROR_INIT, /* ERROR */
65 { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } },
66 -NF_ACCEPT - 1 } },
67 /* FORWARD */
68 { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
69 0,
70 sizeof(struct ipt_entry),
71 sizeof(struct ipt_standard),
72 0, { 0, 0 }, { } },
73 { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } },
74 -NF_ACCEPT - 1 } },
75 /* LOCAL_OUT */
76 { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
77 0,
78 sizeof(struct ipt_entry),
79 sizeof(struct ipt_standard),
80 0, { 0, 0 }, { } },
81 { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } },
82 -NF_ACCEPT - 1 } },
83 /* POST_ROUTING */
84 { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
85 0,
86 sizeof(struct ipt_entry),
87 sizeof(struct ipt_standard),
88 0, { 0, 0 }, { } },
89 { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } },
90 -NF_ACCEPT - 1 } },
91 },
92 /* ERROR */
93 { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 },
94 0,
95 sizeof(struct ipt_entry),
96 sizeof(struct ipt_error),
97 0, { 0, 0 }, { } },
98 { { { { IPT_ALIGN(sizeof(struct ipt_error_target)), IPT_ERROR_TARGET } },
99 { } },
100 "ERROR"
101 }
102 }
103}; 65};
104 66
105static struct xt_table packet_mangler = { 67static struct xt_table packet_mangler = {
@@ -138,7 +100,8 @@ ipt_local_hook(unsigned int hook,
138 if ((*pskb)->len < sizeof(struct iphdr) 100 if ((*pskb)->len < sizeof(struct iphdr)
139 || ip_hdrlen(*pskb) < sizeof(struct iphdr)) { 101 || ip_hdrlen(*pskb) < sizeof(struct iphdr)) {
140 if (net_ratelimit()) 102 if (net_ratelimit())
141 printk("ipt_hook: happy cracking.\n"); 103 printk("iptable_mangle: ignoring short SOCK_RAW "
104 "packet.\n");
142 return NF_ACCEPT; 105 return NF_ACCEPT;
143 } 106 }
144 107
diff --git a/net/ipv4/netfilter/iptable_raw.c b/net/ipv4/netfilter/iptable_raw.c
index 18c3d4c9ff51..d6e503395684 100644
--- a/net/ipv4/netfilter/iptable_raw.c
+++ b/net/ipv4/netfilter/iptable_raw.c
@@ -5,6 +5,7 @@
5 */ 5 */
6#include <linux/module.h> 6#include <linux/module.h>
7#include <linux/netfilter_ipv4/ip_tables.h> 7#include <linux/netfilter_ipv4/ip_tables.h>
8#include <net/ip.h>
8 9
9#define RAW_VALID_HOOKS ((1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_OUT)) 10#define RAW_VALID_HOOKS ((1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_OUT))
10 11
@@ -21,62 +22,18 @@ static struct
21 .size = sizeof(struct ipt_standard) * 2 + sizeof(struct ipt_error), 22 .size = sizeof(struct ipt_standard) * 2 + sizeof(struct ipt_error),
22 .hook_entry = { 23 .hook_entry = {
23 [NF_IP_PRE_ROUTING] = 0, 24 [NF_IP_PRE_ROUTING] = 0,
24 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) }, 25 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard)
26 },
25 .underflow = { 27 .underflow = {
26 [NF_IP_PRE_ROUTING] = 0, 28 [NF_IP_PRE_ROUTING] = 0,
27 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) }, 29 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard)
30 },
28 }, 31 },
29 .entries = { 32 .entries = {
30 /* PRE_ROUTING */ 33 IPT_STANDARD_INIT(NF_ACCEPT), /* PRE_ROUTING */
31 { 34 IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */
32 .entry = {
33 .target_offset = sizeof(struct ipt_entry),
34 .next_offset = sizeof(struct ipt_standard),
35 },
36 .target = {
37 .target = {
38 .u = {
39 .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)),
40 },
41 },
42 .verdict = -NF_ACCEPT - 1,
43 },
44 },
45
46 /* LOCAL_OUT */
47 {
48 .entry = {
49 .target_offset = sizeof(struct ipt_entry),
50 .next_offset = sizeof(struct ipt_standard),
51 },
52 .target = {
53 .target = {
54 .u = {
55 .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)),
56 },
57 },
58 .verdict = -NF_ACCEPT - 1,
59 },
60 },
61 }, 35 },
62 /* ERROR */ 36 .term = IPT_ERROR_INIT, /* ERROR */
63 .term = {
64 .entry = {
65 .target_offset = sizeof(struct ipt_entry),
66 .next_offset = sizeof(struct ipt_error),
67 },
68 .target = {
69 .target = {
70 .u = {
71 .user = {
72 .target_size = IPT_ALIGN(sizeof(struct ipt_error_target)),
73 .name = IPT_ERROR_TARGET,
74 },
75 },
76 },
77 .errorname = "ERROR",
78 },
79 }
80}; 37};
81 38
82static struct xt_table packet_raw = { 39static struct xt_table packet_raw = {
@@ -98,6 +55,24 @@ ipt_hook(unsigned int hook,
98 return ipt_do_table(pskb, hook, in, out, &packet_raw); 55 return ipt_do_table(pskb, hook, in, out, &packet_raw);
99} 56}
100 57
58static unsigned int
59ipt_local_hook(unsigned int hook,
60 struct sk_buff **pskb,
61 const struct net_device *in,
62 const struct net_device *out,
63 int (*okfn)(struct sk_buff *))
64{
65 /* root is playing with raw sockets. */
66 if ((*pskb)->len < sizeof(struct iphdr) ||
67 ip_hdrlen(*pskb) < sizeof(struct iphdr)) {
68 if (net_ratelimit())
69 printk("iptable_raw: ignoring short SOCK_RAW"
70 "packet.\n");
71 return NF_ACCEPT;
72 }
73 return ipt_do_table(pskb, hook, in, out, &packet_raw);
74}
75
101/* 'raw' is the very first table. */ 76/* 'raw' is the very first table. */
102static struct nf_hook_ops ipt_ops[] = { 77static struct nf_hook_ops ipt_ops[] = {
103 { 78 {
@@ -108,7 +83,7 @@ static struct nf_hook_ops ipt_ops[] = {
108 .owner = THIS_MODULE, 83 .owner = THIS_MODULE,
109 }, 84 },
110 { 85 {
111 .hook = ipt_hook, 86 .hook = ipt_local_hook,
112 .pf = PF_INET, 87 .pf = PF_INET,
113 .hooknum = NF_IP_LOCAL_OUT, 88 .hooknum = NF_IP_LOCAL_OUT,
114 .priority = NF_IP_PRI_RAW, 89 .priority = NF_IP_PRI_RAW,
diff --git a/net/ipv4/netfilter/nf_nat_rule.c b/net/ipv4/netfilter/nf_nat_rule.c
index 2534f718ab92..6740736c5e79 100644
--- a/net/ipv4/netfilter/nf_nat_rule.c
+++ b/net/ipv4/netfilter/nf_nat_rule.c
@@ -46,77 +46,20 @@ static struct
46 .hook_entry = { 46 .hook_entry = {
47 [NF_IP_PRE_ROUTING] = 0, 47 [NF_IP_PRE_ROUTING] = 0,
48 [NF_IP_POST_ROUTING] = sizeof(struct ipt_standard), 48 [NF_IP_POST_ROUTING] = sizeof(struct ipt_standard),
49 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2 }, 49 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2
50 },
50 .underflow = { 51 .underflow = {
51 [NF_IP_PRE_ROUTING] = 0, 52 [NF_IP_PRE_ROUTING] = 0,
52 [NF_IP_POST_ROUTING] = sizeof(struct ipt_standard), 53 [NF_IP_POST_ROUTING] = sizeof(struct ipt_standard),
53 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2 }, 54 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2
55 },
54 }, 56 },
55 .entries = { 57 .entries = {
56 /* PRE_ROUTING */ 58 IPT_STANDARD_INIT(NF_ACCEPT), /* PRE_ROUTING */
57 { 59 IPT_STANDARD_INIT(NF_ACCEPT), /* POST_ROUTING */
58 .entry = { 60 IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */
59 .target_offset = sizeof(struct ipt_entry),
60 .next_offset = sizeof(struct ipt_standard),
61 },
62 .target = {
63 .target = {
64 .u = {
65 .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)),
66 },
67 },
68 .verdict = -NF_ACCEPT - 1,
69 },
70 },
71 /* POST_ROUTING */
72 {
73 .entry = {
74 .target_offset = sizeof(struct ipt_entry),
75 .next_offset = sizeof(struct ipt_standard),
76 },
77 .target = {
78 .target = {
79 .u = {
80 .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)),
81 },
82 },
83 .verdict = -NF_ACCEPT - 1,
84 },
85 },
86 /* LOCAL_OUT */
87 {
88 .entry = {
89 .target_offset = sizeof(struct ipt_entry),
90 .next_offset = sizeof(struct ipt_standard),
91 },
92 .target = {
93 .target = {
94 .u = {
95 .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)),
96 },
97 },
98 .verdict = -NF_ACCEPT - 1,
99 },
100 },
101 }, 61 },
102 /* ERROR */ 62 .term = IPT_ERROR_INIT, /* ERROR */
103 .term = {
104 .entry = {
105 .target_offset = sizeof(struct ipt_entry),
106 .next_offset = sizeof(struct ipt_error),
107 },
108 .target = {
109 .target = {
110 .u = {
111 .user = {
112 .target_size = IPT_ALIGN(sizeof(struct ipt_error_target)),
113 .name = IPT_ERROR_TARGET,
114 },
115 },
116 },
117 .errorname = "ERROR",
118 },
119 }
120}; 63};
121 64
122static struct xt_table nat_table = { 65static struct xt_table nat_table = {
@@ -230,9 +173,7 @@ static int ipt_dnat_checkentry(const char *tablename,
230} 173}
231 174
232inline unsigned int 175inline unsigned int
233alloc_null_binding(struct nf_conn *ct, 176alloc_null_binding(struct nf_conn *ct, unsigned int hooknum)
234 struct nf_nat_info *info,
235 unsigned int hooknum)
236{ 177{
237 /* Force range to this IP; let proto decide mapping for 178 /* Force range to this IP; let proto decide mapping for
238 per-proto parts (hence not IP_NAT_RANGE_PROTO_SPECIFIED). 179 per-proto parts (hence not IP_NAT_RANGE_PROTO_SPECIFIED).
@@ -251,9 +192,7 @@ alloc_null_binding(struct nf_conn *ct,
251} 192}
252 193
253unsigned int 194unsigned int
254alloc_null_binding_confirmed(struct nf_conn *ct, 195alloc_null_binding_confirmed(struct nf_conn *ct, unsigned int hooknum)
255 struct nf_nat_info *info,
256 unsigned int hooknum)
257{ 196{
258 __be32 ip 197 __be32 ip
259 = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC 198 = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC
@@ -275,8 +214,7 @@ int nf_nat_rule_find(struct sk_buff **pskb,
275 unsigned int hooknum, 214 unsigned int hooknum,
276 const struct net_device *in, 215 const struct net_device *in,
277 const struct net_device *out, 216 const struct net_device *out,
278 struct nf_conn *ct, 217 struct nf_conn *ct)
279 struct nf_nat_info *info)
280{ 218{
281 int ret; 219 int ret;
282 220
@@ -285,7 +223,7 @@ int nf_nat_rule_find(struct sk_buff **pskb,
285 if (ret == NF_ACCEPT) { 223 if (ret == NF_ACCEPT) {
286 if (!nf_nat_initialized(ct, HOOK2MANIP(hooknum))) 224 if (!nf_nat_initialized(ct, HOOK2MANIP(hooknum)))
287 /* NUL mapping */ 225 /* NUL mapping */
288 ret = alloc_null_binding(ct, info, hooknum); 226 ret = alloc_null_binding(ct, hooknum);
289 } 227 }
290 return ret; 228 return ret;
291} 229}
diff --git a/net/ipv4/netfilter/nf_nat_standalone.c b/net/ipv4/netfilter/nf_nat_standalone.c
index 64bbed2ba780..55dac36dbc85 100644
--- a/net/ipv4/netfilter/nf_nat_standalone.c
+++ b/net/ipv4/netfilter/nf_nat_standalone.c
@@ -80,7 +80,6 @@ nf_nat_fn(unsigned int hooknum,
80 struct nf_conn *ct; 80 struct nf_conn *ct;
81 enum ip_conntrack_info ctinfo; 81 enum ip_conntrack_info ctinfo;
82 struct nf_conn_nat *nat; 82 struct nf_conn_nat *nat;
83 struct nf_nat_info *info;
84 /* maniptype == SRC for postrouting. */ 83 /* maniptype == SRC for postrouting. */
85 enum nf_nat_manip_type maniptype = HOOK2MANIP(hooknum); 84 enum nf_nat_manip_type maniptype = HOOK2MANIP(hooknum);
86 85
@@ -129,7 +128,6 @@ nf_nat_fn(unsigned int hooknum,
129 } 128 }
130 /* Fall thru... (Only ICMPs can be IP_CT_IS_REPLY) */ 129 /* Fall thru... (Only ICMPs can be IP_CT_IS_REPLY) */
131 case IP_CT_NEW: 130 case IP_CT_NEW:
132 info = &nat->info;
133 131
134 /* Seen it before? This can happen for loopback, retrans, 132 /* Seen it before? This can happen for loopback, retrans,
135 or local packets.. */ 133 or local packets.. */
@@ -138,14 +136,13 @@ nf_nat_fn(unsigned int hooknum,
138 136
139 if (unlikely(nf_ct_is_confirmed(ct))) 137 if (unlikely(nf_ct_is_confirmed(ct)))
140 /* NAT module was loaded late */ 138 /* NAT module was loaded late */
141 ret = alloc_null_binding_confirmed(ct, info, 139 ret = alloc_null_binding_confirmed(ct, hooknum);
142 hooknum);
143 else if (hooknum == NF_IP_LOCAL_IN) 140 else if (hooknum == NF_IP_LOCAL_IN)
144 /* LOCAL_IN hook doesn't have a chain! */ 141 /* LOCAL_IN hook doesn't have a chain! */
145 ret = alloc_null_binding(ct, info, hooknum); 142 ret = alloc_null_binding(ct, hooknum);
146 else 143 else
147 ret = nf_nat_rule_find(pskb, hooknum, in, out, 144 ret = nf_nat_rule_find(pskb, hooknum, in, out,
148 ct, info); 145 ct);
149 146
150 if (ret != NF_ACCEPT) { 147 if (ret != NF_ACCEPT) {
151 return ret; 148 return ret;
@@ -160,10 +157,8 @@ nf_nat_fn(unsigned int hooknum,
160 /* ESTABLISHED */ 157 /* ESTABLISHED */
161 NF_CT_ASSERT(ctinfo == IP_CT_ESTABLISHED || 158 NF_CT_ASSERT(ctinfo == IP_CT_ESTABLISHED ||
162 ctinfo == (IP_CT_ESTABLISHED+IP_CT_IS_REPLY)); 159 ctinfo == (IP_CT_ESTABLISHED+IP_CT_IS_REPLY));
163 info = &nat->info;
164 } 160 }
165 161
166 NF_CT_ASSERT(info);
167 return nf_nat_packet(ct, ctinfo, hooknum, pskb); 162 return nf_nat_packet(ct, ctinfo, hooknum, pskb);
168} 163}
169 164
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 66026df1cc76..4c7e95fa090d 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -118,15 +118,15 @@ static int udp_port_rover;
118 * Note about this hash function : 118 * Note about this hash function :
119 * Typical use is probably daddr = 0, only dport is going to vary hash 119 * Typical use is probably daddr = 0, only dport is going to vary hash
120 */ 120 */
121static inline unsigned int hash_port_and_addr(__u16 port, __be32 addr) 121static inline unsigned int udp_hash_port(__u16 port)
122{ 122{
123 addr ^= addr >> 16; 123 return port;
124 addr ^= addr >> 8;
125 return port ^ addr;
126} 124}
127 125
128static inline int __udp_lib_port_inuse(unsigned int hash, int port, 126static inline int __udp_lib_port_inuse(unsigned int hash, int port,
129 __be32 daddr, struct hlist_head udptable[]) 127 const struct sock *this_sk,
128 struct hlist_head udptable[],
129 const struct udp_get_port_ops *ops)
130{ 130{
131 struct sock *sk; 131 struct sock *sk;
132 struct hlist_node *node; 132 struct hlist_node *node;
@@ -138,7 +138,10 @@ static inline int __udp_lib_port_inuse(unsigned int hash, int port,
138 inet = inet_sk(sk); 138 inet = inet_sk(sk);
139 if (inet->num != port) 139 if (inet->num != port)
140 continue; 140 continue;
141 if (inet->rcv_saddr == daddr) 141 if (this_sk) {
142 if (ops->saddr_cmp(sk, this_sk))
143 return 1;
144 } else if (ops->saddr_any(sk))
142 return 1; 145 return 1;
143 } 146 }
144 return 0; 147 return 0;
@@ -151,12 +154,11 @@ static inline int __udp_lib_port_inuse(unsigned int hash, int port,
151 * @snum: port number to look up 154 * @snum: port number to look up
152 * @udptable: hash list table, must be of UDP_HTABLE_SIZE 155 * @udptable: hash list table, must be of UDP_HTABLE_SIZE
153 * @port_rover: pointer to record of last unallocated port 156 * @port_rover: pointer to record of last unallocated port
154 * @saddr_comp: AF-dependent comparison of bound local IP addresses 157 * @ops: AF-dependent address operations
155 */ 158 */
156int __udp_lib_get_port(struct sock *sk, unsigned short snum, 159int __udp_lib_get_port(struct sock *sk, unsigned short snum,
157 struct hlist_head udptable[], int *port_rover, 160 struct hlist_head udptable[], int *port_rover,
158 int (*saddr_comp)(const struct sock *sk1, 161 const struct udp_get_port_ops *ops)
159 const struct sock *sk2 ) )
160{ 162{
161 struct hlist_node *node; 163 struct hlist_node *node;
162 struct hlist_head *head; 164 struct hlist_head *head;
@@ -176,8 +178,7 @@ int __udp_lib_get_port(struct sock *sk, unsigned short snum,
176 for (i = 0; i < UDP_HTABLE_SIZE; i++, result++) { 178 for (i = 0; i < UDP_HTABLE_SIZE; i++, result++) {
177 int size; 179 int size;
178 180
179 hash = hash_port_and_addr(result, 181 hash = ops->hash_port_and_rcv_saddr(result, sk);
180 inet_sk(sk)->rcv_saddr);
181 head = &udptable[hash & (UDP_HTABLE_SIZE - 1)]; 182 head = &udptable[hash & (UDP_HTABLE_SIZE - 1)];
182 if (hlist_empty(head)) { 183 if (hlist_empty(head)) {
183 if (result > sysctl_local_port_range[1]) 184 if (result > sysctl_local_port_range[1])
@@ -203,17 +204,16 @@ int __udp_lib_get_port(struct sock *sk, unsigned short snum,
203 result = sysctl_local_port_range[0] 204 result = sysctl_local_port_range[0]
204 + ((result - sysctl_local_port_range[0]) & 205 + ((result - sysctl_local_port_range[0]) &
205 (UDP_HTABLE_SIZE - 1)); 206 (UDP_HTABLE_SIZE - 1));
206 hash = hash_port_and_addr(result, 0); 207 hash = udp_hash_port(result);
207 if (__udp_lib_port_inuse(hash, result, 208 if (__udp_lib_port_inuse(hash, result,
208 0, udptable)) 209 NULL, udptable, ops))
209 continue; 210 continue;
210 if (!inet_sk(sk)->rcv_saddr) 211 if (ops->saddr_any(sk))
211 break; 212 break;
212 213
213 hash = hash_port_and_addr(result, 214 hash = ops->hash_port_and_rcv_saddr(result, sk);
214 inet_sk(sk)->rcv_saddr);
215 if (! __udp_lib_port_inuse(hash, result, 215 if (! __udp_lib_port_inuse(hash, result,
216 inet_sk(sk)->rcv_saddr, udptable)) 216 sk, udptable, ops))
217 break; 217 break;
218 } 218 }
219 if (i >= (1 << 16) / UDP_HTABLE_SIZE) 219 if (i >= (1 << 16) / UDP_HTABLE_SIZE)
@@ -221,7 +221,7 @@ int __udp_lib_get_port(struct sock *sk, unsigned short snum,
221gotit: 221gotit:
222 *port_rover = snum = result; 222 *port_rover = snum = result;
223 } else { 223 } else {
224 hash = hash_port_and_addr(snum, 0); 224 hash = udp_hash_port(snum);
225 head = &udptable[hash & (UDP_HTABLE_SIZE - 1)]; 225 head = &udptable[hash & (UDP_HTABLE_SIZE - 1)];
226 226
227 sk_for_each(sk2, node, head) 227 sk_for_each(sk2, node, head)
@@ -231,12 +231,11 @@ gotit:
231 (!sk2->sk_reuse || !sk->sk_reuse) && 231 (!sk2->sk_reuse || !sk->sk_reuse) &&
232 (!sk2->sk_bound_dev_if || !sk->sk_bound_dev_if || 232 (!sk2->sk_bound_dev_if || !sk->sk_bound_dev_if ||
233 sk2->sk_bound_dev_if == sk->sk_bound_dev_if) && 233 sk2->sk_bound_dev_if == sk->sk_bound_dev_if) &&
234 (*saddr_comp)(sk, sk2)) 234 ops->saddr_cmp(sk, sk2))
235 goto fail; 235 goto fail;
236 236
237 if (inet_sk(sk)->rcv_saddr) { 237 if (!ops->saddr_any(sk)) {
238 hash = hash_port_and_addr(snum, 238 hash = ops->hash_port_and_rcv_saddr(snum, sk);
239 inet_sk(sk)->rcv_saddr);
240 head = &udptable[hash & (UDP_HTABLE_SIZE - 1)]; 239 head = &udptable[hash & (UDP_HTABLE_SIZE - 1)];
241 240
242 sk_for_each(sk2, node, head) 241 sk_for_each(sk2, node, head)
@@ -248,7 +247,7 @@ gotit:
248 !sk->sk_bound_dev_if || 247 !sk->sk_bound_dev_if ||
249 sk2->sk_bound_dev_if == 248 sk2->sk_bound_dev_if ==
250 sk->sk_bound_dev_if) && 249 sk->sk_bound_dev_if) &&
251 (*saddr_comp)(sk, sk2)) 250 ops->saddr_cmp(sk, sk2))
252 goto fail; 251 goto fail;
253 } 252 }
254 } 253 }
@@ -266,12 +265,12 @@ fail:
266} 265}
267 266
268int udp_get_port(struct sock *sk, unsigned short snum, 267int udp_get_port(struct sock *sk, unsigned short snum,
269 int (*scmp)(const struct sock *, const struct sock *)) 268 const struct udp_get_port_ops *ops)
270{ 269{
271 return __udp_lib_get_port(sk, snum, udp_hash, &udp_port_rover, scmp); 270 return __udp_lib_get_port(sk, snum, udp_hash, &udp_port_rover, ops);
272} 271}
273 272
274int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2) 273static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
275{ 274{
276 struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2); 275 struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
277 276
@@ -280,9 +279,33 @@ int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
280 inet1->rcv_saddr == inet2->rcv_saddr )); 279 inet1->rcv_saddr == inet2->rcv_saddr ));
281} 280}
282 281
282static int ipv4_rcv_saddr_any(const struct sock *sk)
283{
284 return !inet_sk(sk)->rcv_saddr;
285}
286
287static inline unsigned int ipv4_hash_port_and_addr(__u16 port, __be32 addr)
288{
289 addr ^= addr >> 16;
290 addr ^= addr >> 8;
291 return port ^ addr;
292}
293
294static unsigned int ipv4_hash_port_and_rcv_saddr(__u16 port,
295 const struct sock *sk)
296{
297 return ipv4_hash_port_and_addr(port, inet_sk(sk)->rcv_saddr);
298}
299
300const struct udp_get_port_ops udp_ipv4_ops = {
301 .saddr_cmp = ipv4_rcv_saddr_equal,
302 .saddr_any = ipv4_rcv_saddr_any,
303 .hash_port_and_rcv_saddr = ipv4_hash_port_and_rcv_saddr,
304};
305
283static inline int udp_v4_get_port(struct sock *sk, unsigned short snum) 306static inline int udp_v4_get_port(struct sock *sk, unsigned short snum)
284{ 307{
285 return udp_get_port(sk, snum, ipv4_rcv_saddr_equal); 308 return udp_get_port(sk, snum, &udp_ipv4_ops);
286} 309}
287 310
288/* UDP is nearly always wildcards out the wazoo, it makes no sense to try 311/* UDP is nearly always wildcards out the wazoo, it makes no sense to try
@@ -297,8 +320,8 @@ static struct sock *__udp4_lib_lookup(__be32 saddr, __be16 sport,
297 unsigned int hash, hashwild; 320 unsigned int hash, hashwild;
298 int score, best = -1, hport = ntohs(dport); 321 int score, best = -1, hport = ntohs(dport);
299 322
300 hash = hash_port_and_addr(hport, daddr); 323 hash = ipv4_hash_port_and_addr(hport, daddr);
301 hashwild = hash_port_and_addr(hport, 0); 324 hashwild = udp_hash_port(hport);
302 325
303 read_lock(&udp_hash_lock); 326 read_lock(&udp_hash_lock);
304 327
@@ -1198,8 +1221,8 @@ static int __udp4_lib_mcast_deliver(struct sk_buff *skb,
1198 struct sock *sk, *skw, *sknext; 1221 struct sock *sk, *skw, *sknext;
1199 int dif; 1222 int dif;
1200 int hport = ntohs(uh->dest); 1223 int hport = ntohs(uh->dest);
1201 unsigned int hash = hash_port_and_addr(hport, daddr); 1224 unsigned int hash = ipv4_hash_port_and_addr(hport, daddr);
1202 unsigned int hashwild = hash_port_and_addr(hport, 0); 1225 unsigned int hashwild = udp_hash_port(hport);
1203 1226
1204 dif = skb->dev->ifindex; 1227 dif = skb->dev->ifindex;
1205 1228
diff --git a/net/ipv4/udp_impl.h b/net/ipv4/udp_impl.h
index 820a477cfaa6..06d94195e644 100644
--- a/net/ipv4/udp_impl.h
+++ b/net/ipv4/udp_impl.h
@@ -5,14 +5,14 @@
5#include <net/protocol.h> 5#include <net/protocol.h>
6#include <net/inet_common.h> 6#include <net/inet_common.h>
7 7
8extern const struct udp_get_port_ops udp_ipv4_ops;
9
8extern int __udp4_lib_rcv(struct sk_buff *, struct hlist_head [], int ); 10extern int __udp4_lib_rcv(struct sk_buff *, struct hlist_head [], int );
9extern void __udp4_lib_err(struct sk_buff *, u32, struct hlist_head []); 11extern void __udp4_lib_err(struct sk_buff *, u32, struct hlist_head []);
10 12
11extern int __udp_lib_get_port(struct sock *sk, unsigned short snum, 13extern int __udp_lib_get_port(struct sock *sk, unsigned short snum,
12 struct hlist_head udptable[], int *port_rover, 14 struct hlist_head udptable[], int *port_rover,
13 int (*)(const struct sock*,const struct sock*)); 15 const struct udp_get_port_ops *ops);
14extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
15
16 16
17extern int udp_setsockopt(struct sock *sk, int level, int optname, 17extern int udp_setsockopt(struct sock *sk, int level, int optname,
18 char __user *optval, int optlen); 18 char __user *optval, int optlen);
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c
index f34fd686a8f1..3653b32dce2d 100644
--- a/net/ipv4/udplite.c
+++ b/net/ipv4/udplite.c
@@ -19,14 +19,15 @@ struct hlist_head udplite_hash[UDP_HTABLE_SIZE];
19static int udplite_port_rover; 19static int udplite_port_rover;
20 20
21int udplite_get_port(struct sock *sk, unsigned short p, 21int udplite_get_port(struct sock *sk, unsigned short p,
22 int (*c)(const struct sock *, const struct sock *)) 22 const struct udp_get_port_ops *ops)
23{ 23{
24 return __udp_lib_get_port(sk, p, udplite_hash, &udplite_port_rover, c); 24 return __udp_lib_get_port(sk, p, udplite_hash,
25 &udplite_port_rover, ops);
25} 26}
26 27
27static int udplite_v4_get_port(struct sock *sk, unsigned short snum) 28static int udplite_v4_get_port(struct sock *sk, unsigned short snum)
28{ 29{
29 return udplite_get_port(sk, snum, ipv4_rcv_saddr_equal); 30 return udplite_get_port(sk, snum, &udp_ipv4_ops);
30} 31}
31 32
32static int udplite_rcv(struct sk_buff *skb) 33static int udplite_rcv(struct sk_buff *skb)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index d02685c6bc69..c7ea248fae2e 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -4204,6 +4204,10 @@ int __init addrconf_init(void)
4204 return err; 4204 return err;
4205 4205
4206 ip6_null_entry.rt6i_idev = in6_dev_get(&loopback_dev); 4206 ip6_null_entry.rt6i_idev = in6_dev_get(&loopback_dev);
4207#ifdef CONFIG_IPV6_MULTIPLE_TABLES
4208 ip6_prohibit_entry.rt6i_idev = in6_dev_get(&loopback_dev);
4209 ip6_blk_hole_entry.rt6i_idev = in6_dev_get(&loopback_dev);
4210#endif
4207 4211
4208 register_netdevice_notifier(&ipv6_dev_notf); 4212 register_netdevice_notifier(&ipv6_dev_notf);
4209 4213
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 6d8e4ac7bdad..14be0b9b77a5 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -660,6 +660,14 @@ EXPORT_SYMBOL_GPL(ipv6_invert_rthdr);
660 Hop-by-hop options. 660 Hop-by-hop options.
661 **********************************/ 661 **********************************/
662 662
663/*
664 * Note: we cannot rely on skb->dst before we assign it in ip6_route_input().
665 */
666static inline struct inet6_dev *ipv6_skb_idev(struct sk_buff *skb)
667{
668 return skb->dst ? ip6_dst_idev(skb->dst) : __in6_dev_get(skb->dev);
669}
670
663/* Router Alert as of RFC 2711 */ 671/* Router Alert as of RFC 2711 */
664 672
665static int ipv6_hop_ra(struct sk_buff **skbp, int optoff) 673static int ipv6_hop_ra(struct sk_buff **skbp, int optoff)
@@ -688,25 +696,25 @@ static int ipv6_hop_jumbo(struct sk_buff **skbp, int optoff)
688 if (nh[optoff + 1] != 4 || (optoff & 3) != 2) { 696 if (nh[optoff + 1] != 4 || (optoff & 3) != 2) {
689 LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n", 697 LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n",
690 nh[optoff+1]); 698 nh[optoff+1]);
691 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), 699 IP6_INC_STATS_BH(ipv6_skb_idev(skb),
692 IPSTATS_MIB_INHDRERRORS); 700 IPSTATS_MIB_INHDRERRORS);
693 goto drop; 701 goto drop;
694 } 702 }
695 703
696 pkt_len = ntohl(*(__be32 *)(nh + optoff + 2)); 704 pkt_len = ntohl(*(__be32 *)(nh + optoff + 2));
697 if (pkt_len <= IPV6_MAXPLEN) { 705 if (pkt_len <= IPV6_MAXPLEN) {
698 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), IPSTATS_MIB_INHDRERRORS); 706 IP6_INC_STATS_BH(ipv6_skb_idev(skb), IPSTATS_MIB_INHDRERRORS);
699 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff+2); 707 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff+2);
700 return 0; 708 return 0;
701 } 709 }
702 if (ipv6_hdr(skb)->payload_len) { 710 if (ipv6_hdr(skb)->payload_len) {
703 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), IPSTATS_MIB_INHDRERRORS); 711 IP6_INC_STATS_BH(ipv6_skb_idev(skb), IPSTATS_MIB_INHDRERRORS);
704 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff); 712 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff);
705 return 0; 713 return 0;
706 } 714 }
707 715
708 if (pkt_len > skb->len - sizeof(struct ipv6hdr)) { 716 if (pkt_len > skb->len - sizeof(struct ipv6hdr)) {
709 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), IPSTATS_MIB_INTRUNCATEDPKTS); 717 IP6_INC_STATS_BH(ipv6_skb_idev(skb), IPSTATS_MIB_INTRUNCATEDPKTS);
710 goto drop; 718 goto drop;
711 } 719 }
712 720
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index f508171bab73..4704b5fc3085 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -463,10 +463,17 @@ int ip6_forward(struct sk_buff *skb)
463 */ 463 */
464 if (xrlim_allow(dst, 1*HZ)) 464 if (xrlim_allow(dst, 1*HZ))
465 ndisc_send_redirect(skb, n, target); 465 ndisc_send_redirect(skb, n, target);
466 } else if (ipv6_addr_type(&hdr->saddr)&(IPV6_ADDR_MULTICAST|IPV6_ADDR_LOOPBACK 466 } else {
467 |IPV6_ADDR_LINKLOCAL)) { 467 int addrtype = ipv6_addr_type(&hdr->saddr);
468
468 /* This check is security critical. */ 469 /* This check is security critical. */
469 goto error; 470 if (addrtype & (IPV6_ADDR_MULTICAST|IPV6_ADDR_LOOPBACK))
471 goto error;
472 if (addrtype & IPV6_ADDR_LINKLOCAL) {
473 icmpv6_send(skb, ICMPV6_DEST_UNREACH,
474 ICMPV6_NOT_NEIGHBOUR, 0, skb->dev);
475 goto error;
476 }
470 } 477 }
471 478
472 if (skb->len > dst_mtu(dst)) { 479 if (skb->len > dst_mtu(dst)) {
diff --git a/net/ipv6/netfilter/ip6table_filter.c b/net/ipv6/netfilter/ip6table_filter.c
index 76f0cf66f95c..7e32e2aaf7f7 100644
--- a/net/ipv6/netfilter/ip6table_filter.c
+++ b/net/ipv6/netfilter/ip6table_filter.c
@@ -24,53 +24,29 @@ static struct
24 struct ip6t_replace repl; 24 struct ip6t_replace repl;
25 struct ip6t_standard entries[3]; 25 struct ip6t_standard entries[3];
26 struct ip6t_error term; 26 struct ip6t_error term;
27} initial_table __initdata 27} initial_table __initdata = {
28= { { "filter", FILTER_VALID_HOOKS, 4, 28 .repl = {
29 sizeof(struct ip6t_standard) * 3 + sizeof(struct ip6t_error), 29 .name = "filter",
30 { [NF_IP6_LOCAL_IN] = 0, 30 .valid_hooks = FILTER_VALID_HOOKS,
31 [NF_IP6_FORWARD] = sizeof(struct ip6t_standard), 31 .num_entries = 4,
32 [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 2 }, 32 .size = sizeof(struct ip6t_standard) * 3 + sizeof(struct ip6t_error),
33 { [NF_IP6_LOCAL_IN] = 0, 33 .hook_entry = {
34 [NF_IP6_FORWARD] = sizeof(struct ip6t_standard), 34 [NF_IP6_LOCAL_IN] = 0,
35 [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 2 }, 35 [NF_IP6_FORWARD] = sizeof(struct ip6t_standard),
36 0, NULL, { } }, 36 [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 2
37 { 37 },
38 /* LOCAL_IN */ 38 .underflow = {
39 { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, 39 [NF_IP6_LOCAL_IN] = 0,
40 0, 40 [NF_IP6_FORWARD] = sizeof(struct ip6t_standard),
41 sizeof(struct ip6t_entry), 41 [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 2
42 sizeof(struct ip6t_standard), 42 },
43 0, { 0, 0 }, { } }, 43 },
44 { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } }, 44 .entries = {
45 -NF_ACCEPT - 1 } }, 45 IP6T_STANDARD_INIT(NF_ACCEPT), /* LOCAL_IN */
46 /* FORWARD */ 46 IP6T_STANDARD_INIT(NF_ACCEPT), /* FORWARD */
47 { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, 47 IP6T_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */
48 0, 48 },
49 sizeof(struct ip6t_entry), 49 .term = IP6T_ERROR_INIT, /* ERROR */
50 sizeof(struct ip6t_standard),
51 0, { 0, 0 }, { } },
52 { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
53 -NF_ACCEPT - 1 } },
54 /* LOCAL_OUT */
55 { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
56 0,
57 sizeof(struct ip6t_entry),
58 sizeof(struct ip6t_standard),
59 0, { 0, 0 }, { } },
60 { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
61 -NF_ACCEPT - 1 } }
62 },
63 /* ERROR */
64 { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
65 0,
66 sizeof(struct ip6t_entry),
67 sizeof(struct ip6t_error),
68 0, { 0, 0 }, { } },
69 { { { { IP6T_ALIGN(sizeof(struct ip6t_error_target)), IP6T_ERROR_TARGET } },
70 { } },
71 "ERROR"
72 }
73 }
74}; 50};
75 51
76static struct xt_table packet_filter = { 52static struct xt_table packet_filter = {
diff --git a/net/ipv6/netfilter/ip6table_mangle.c b/net/ipv6/netfilter/ip6table_mangle.c
index a9f10e32c163..f2d26495f413 100644
--- a/net/ipv6/netfilter/ip6table_mangle.c
+++ b/net/ipv6/netfilter/ip6table_mangle.c
@@ -32,73 +32,35 @@ static struct
32 struct ip6t_replace repl; 32 struct ip6t_replace repl;
33 struct ip6t_standard entries[5]; 33 struct ip6t_standard entries[5];
34 struct ip6t_error term; 34 struct ip6t_error term;
35} initial_table __initdata 35} initial_table __initdata = {
36= { { "mangle", MANGLE_VALID_HOOKS, 6, 36 .repl = {
37 sizeof(struct ip6t_standard) * 5 + sizeof(struct ip6t_error), 37 .name = "mangle",
38 { [NF_IP6_PRE_ROUTING] = 0, 38 .valid_hooks = MANGLE_VALID_HOOKS,
39 [NF_IP6_LOCAL_IN] = sizeof(struct ip6t_standard), 39 .num_entries = 6,
40 [NF_IP6_FORWARD] = sizeof(struct ip6t_standard) * 2, 40 .size = sizeof(struct ip6t_standard) * 5 + sizeof(struct ip6t_error),
41 [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 3, 41 .hook_entry = {
42 [NF_IP6_POST_ROUTING] = sizeof(struct ip6t_standard) * 4}, 42 [NF_IP6_PRE_ROUTING] = 0,
43 { [NF_IP6_PRE_ROUTING] = 0, 43 [NF_IP6_LOCAL_IN] = sizeof(struct ip6t_standard),
44 [NF_IP6_LOCAL_IN] = sizeof(struct ip6t_standard), 44 [NF_IP6_FORWARD] = sizeof(struct ip6t_standard) * 2,
45 [NF_IP6_FORWARD] = sizeof(struct ip6t_standard) * 2, 45 [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 3,
46 [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 3, 46 [NF_IP6_POST_ROUTING] = sizeof(struct ip6t_standard) * 4,
47 [NF_IP6_POST_ROUTING] = sizeof(struct ip6t_standard) * 4}, 47 },
48 0, NULL, { } }, 48 .underflow = {
49 { 49 [NF_IP6_PRE_ROUTING] = 0,
50 /* PRE_ROUTING */ 50 [NF_IP6_LOCAL_IN] = sizeof(struct ip6t_standard),
51 { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, 51 [NF_IP6_FORWARD] = sizeof(struct ip6t_standard) * 2,
52 0, 52 [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 3,
53 sizeof(struct ip6t_entry), 53 [NF_IP6_POST_ROUTING] = sizeof(struct ip6t_standard) * 4,
54 sizeof(struct ip6t_standard), 54 },
55 0, { 0, 0 }, { } }, 55 },
56 { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } }, 56 .entries = {
57 -NF_ACCEPT - 1 } }, 57 IP6T_STANDARD_INIT(NF_ACCEPT), /* PRE_ROUTING */
58 /* LOCAL_IN */ 58 IP6T_STANDARD_INIT(NF_ACCEPT), /* LOCAL_IN */
59 { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, 59 IP6T_STANDARD_INIT(NF_ACCEPT), /* FORWARD */
60 0, 60 IP6T_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */
61 sizeof(struct ip6t_entry), 61 IP6T_STANDARD_INIT(NF_ACCEPT), /* POST_ROUTING */
62 sizeof(struct ip6t_standard), 62 },
63 0, { 0, 0 }, { } }, 63 .term = IP6T_ERROR_INIT, /* ERROR */
64 { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
65 -NF_ACCEPT - 1 } },
66 /* FORWARD */
67 { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
68 0,
69 sizeof(struct ip6t_entry),
70 sizeof(struct ip6t_standard),
71 0, { 0, 0 }, { } },
72 { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
73 -NF_ACCEPT - 1 } },
74 /* LOCAL_OUT */
75 { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
76 0,
77 sizeof(struct ip6t_entry),
78 sizeof(struct ip6t_standard),
79 0, { 0, 0 }, { } },
80 { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
81 -NF_ACCEPT - 1 } },
82 /* POST_ROUTING */
83 { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
84 0,
85 sizeof(struct ip6t_entry),
86 sizeof(struct ip6t_standard),
87 0, { 0, 0 }, { } },
88 { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } },
89 -NF_ACCEPT - 1 } }
90 },
91 /* ERROR */
92 { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 },
93 0,
94 sizeof(struct ip6t_entry),
95 sizeof(struct ip6t_error),
96 0, { 0, 0 }, { } },
97 { { { { IP6T_ALIGN(sizeof(struct ip6t_error_target)), IP6T_ERROR_TARGET } },
98 { } },
99 "ERROR"
100 }
101 }
102}; 64};
103 65
104static struct xt_table packet_mangler = { 66static struct xt_table packet_mangler = {
diff --git a/net/ipv6/netfilter/ip6table_raw.c b/net/ipv6/netfilter/ip6table_raw.c
index a3eb5b8ce18d..0acda45d455d 100644
--- a/net/ipv6/netfilter/ip6table_raw.c
+++ b/net/ipv6/netfilter/ip6table_raw.c
@@ -35,56 +35,10 @@ static struct
35 }, 35 },
36 }, 36 },
37 .entries = { 37 .entries = {
38 /* PRE_ROUTING */ 38 IP6T_STANDARD_INIT(NF_ACCEPT), /* PRE_ROUTING */
39 { 39 IP6T_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */
40 .entry = {
41 .target_offset = sizeof(struct ip6t_entry),
42 .next_offset = sizeof(struct ip6t_standard),
43 },
44 .target = {
45 .target = {
46 .u = {
47 .target_size = IP6T_ALIGN(sizeof(struct ip6t_standard_target)),
48 },
49 },
50 .verdict = -NF_ACCEPT - 1,
51 },
52 },
53
54 /* LOCAL_OUT */
55 {
56 .entry = {
57 .target_offset = sizeof(struct ip6t_entry),
58 .next_offset = sizeof(struct ip6t_standard),
59 },
60 .target = {
61 .target = {
62 .u = {
63 .target_size = IP6T_ALIGN(sizeof(struct ip6t_standard_target)),
64 },
65 },
66 .verdict = -NF_ACCEPT - 1,
67 },
68 },
69 }, 40 },
70 /* ERROR */ 41 .term = IP6T_ERROR_INIT, /* ERROR */
71 .term = {
72 .entry = {
73 .target_offset = sizeof(struct ip6t_entry),
74 .next_offset = sizeof(struct ip6t_error),
75 },
76 .target = {
77 .target = {
78 .u = {
79 .user = {
80 .target_size = IP6T_ALIGN(sizeof(struct ip6t_error_target)),
81 .name = IP6T_ERROR_TARGET,
82 },
83 },
84 },
85 .errorname = "ERROR",
86 },
87 }
88}; 42};
89 43
90static struct xt_table packet_raw = { 44static struct xt_table packet_raw = {
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index b083c09e3d2d..a7ae59c954d5 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -52,9 +52,28 @@
52 52
53DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly; 53DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
54 54
55static int ipv6_rcv_saddr_any(const struct sock *sk)
56{
57 struct ipv6_pinfo *np = inet6_sk(sk);
58
59 return ipv6_addr_any(&np->rcv_saddr);
60}
61
62static unsigned int ipv6_hash_port_and_rcv_saddr(__u16 port,
63 const struct sock *sk)
64{
65 return port;
66}
67
68const struct udp_get_port_ops udp_ipv6_ops = {
69 .saddr_cmp = ipv6_rcv_saddr_equal,
70 .saddr_any = ipv6_rcv_saddr_any,
71 .hash_port_and_rcv_saddr = ipv6_hash_port_and_rcv_saddr,
72};
73
55static inline int udp_v6_get_port(struct sock *sk, unsigned short snum) 74static inline int udp_v6_get_port(struct sock *sk, unsigned short snum)
56{ 75{
57 return udp_get_port(sk, snum, ipv6_rcv_saddr_equal); 76 return udp_get_port(sk, snum, &udp_ipv6_ops);
58} 77}
59 78
60static struct sock *__udp6_lib_lookup(struct in6_addr *saddr, __be16 sport, 79static struct sock *__udp6_lib_lookup(struct in6_addr *saddr, __be16 sport,
diff --git a/net/ipv6/udp_impl.h b/net/ipv6/udp_impl.h
index 6e252f318f7c..36b0c11a28a3 100644
--- a/net/ipv6/udp_impl.h
+++ b/net/ipv6/udp_impl.h
@@ -6,6 +6,8 @@
6#include <net/addrconf.h> 6#include <net/addrconf.h>
7#include <net/inet_common.h> 7#include <net/inet_common.h>
8 8
9extern const struct udp_get_port_ops udp_ipv6_ops;
10
9extern int __udp6_lib_rcv(struct sk_buff **, struct hlist_head [], int ); 11extern int __udp6_lib_rcv(struct sk_buff **, struct hlist_head [], int );
10extern void __udp6_lib_err(struct sk_buff *, struct inet6_skb_parm *, 12extern void __udp6_lib_err(struct sk_buff *, struct inet6_skb_parm *,
11 int , int , int , __be32 , struct hlist_head []); 13 int , int , int , __be32 , struct hlist_head []);
diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c
index f54016a55004..c40a51362f89 100644
--- a/net/ipv6/udplite.c
+++ b/net/ipv6/udplite.c
@@ -37,7 +37,7 @@ static struct inet6_protocol udplitev6_protocol = {
37 37
38static int udplite_v6_get_port(struct sock *sk, unsigned short snum) 38static int udplite_v6_get_port(struct sock *sk, unsigned short snum)
39{ 39{
40 return udplite_get_port(sk, snum, ipv6_rcv_saddr_equal); 40 return udplite_get_port(sk, snum, &udp_ipv6_ops);
41} 41}
42 42
43struct proto udplitev6_prot = { 43struct proto udplitev6_prot = {
diff --git a/net/mac80211/ieee80211_sta.c b/net/mac80211/ieee80211_sta.c
index 822917debeff..3e07e9d6fa42 100644
--- a/net/mac80211/ieee80211_sta.c
+++ b/net/mac80211/ieee80211_sta.c
@@ -17,6 +17,7 @@
17 * scan result table filtering (by capability (privacy, IBSS/BSS, WPA/RSN IE, 17 * scan result table filtering (by capability (privacy, IBSS/BSS, WPA/RSN IE,
18 * SSID) 18 * SSID)
19 */ 19 */
20#include <linux/delay.h>
20#include <linux/if_ether.h> 21#include <linux/if_ether.h>
21#include <linux/skbuff.h> 22#include <linux/skbuff.h>
22#include <linux/netdevice.h> 23#include <linux/netdevice.h>
@@ -27,7 +28,6 @@
27#include <linux/rtnetlink.h> 28#include <linux/rtnetlink.h>
28#include <net/iw_handler.h> 29#include <net/iw_handler.h>
29#include <asm/types.h> 30#include <asm/types.h>
30#include <asm/delay.h>
31 31
32#include <net/mac80211.h> 32#include <net/mac80211.h>
33#include "ieee80211_i.h" 33#include "ieee80211_i.h"
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index e132c8ae8784..e8b5c2d7db62 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -299,7 +299,6 @@ destroy_conntrack(struct nf_conntrack *nfct)
299{ 299{
300 struct nf_conn *ct = (struct nf_conn *)nfct; 300 struct nf_conn *ct = (struct nf_conn *)nfct;
301 struct nf_conn_help *help = nfct_help(ct); 301 struct nf_conn_help *help = nfct_help(ct);
302 struct nf_conntrack_l3proto *l3proto;
303 struct nf_conntrack_l4proto *l4proto; 302 struct nf_conntrack_l4proto *l4proto;
304 typeof(nf_conntrack_destroyed) destroyed; 303 typeof(nf_conntrack_destroyed) destroyed;
305 304
@@ -317,10 +316,6 @@ destroy_conntrack(struct nf_conntrack *nfct)
317 * destroy_conntrack() MUST NOT be called with a write lock 316 * destroy_conntrack() MUST NOT be called with a write lock
318 * to nf_conntrack_lock!!! -HW */ 317 * to nf_conntrack_lock!!! -HW */
319 rcu_read_lock(); 318 rcu_read_lock();
320 l3proto = __nf_ct_l3proto_find(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.l3num);
321 if (l3proto && l3proto->destroy)
322 l3proto->destroy(ct);
323
324 l4proto = __nf_ct_l4proto_find(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.l3num, 319 l4proto = __nf_ct_l4proto_find(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.l3num,
325 ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.protonum); 320 ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.protonum);
326 if (l4proto && l4proto->destroy) 321 if (l4proto && l4proto->destroy)
@@ -893,8 +888,13 @@ void nf_conntrack_alter_reply(struct nf_conn *ct,
893 NF_CT_DUMP_TUPLE(newreply); 888 NF_CT_DUMP_TUPLE(newreply);
894 889
895 ct->tuplehash[IP_CT_DIR_REPLY].tuple = *newreply; 890 ct->tuplehash[IP_CT_DIR_REPLY].tuple = *newreply;
896 if (!ct->master && help && help->expecting == 0) 891 if (!ct->master && help && help->expecting == 0) {
897 help->helper = __nf_ct_helper_find(newreply); 892 struct nf_conntrack_helper *helper;
893 helper = __nf_ct_helper_find(newreply);
894 if (helper)
895 memset(&help->help, 0, sizeof(help->help));
896 help->helper = helper;
897 }
898 write_unlock_bh(&nf_conntrack_lock); 898 write_unlock_bh(&nf_conntrack_lock);
899} 899}
900EXPORT_SYMBOL_GPL(nf_conntrack_alter_reply); 900EXPORT_SYMBOL_GPL(nf_conntrack_alter_reply);
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index aa1a97ee514b..d6d39e241327 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -830,11 +830,6 @@ ctnetlink_change_helper(struct nf_conn *ct, struct nfattr *cda[])
830 char *helpname; 830 char *helpname;
831 int err; 831 int err;
832 832
833 if (!help) {
834 /* FIXME: we need to reallocate and rehash */
835 return -EBUSY;
836 }
837
838 /* don't change helper of sibling connections */ 833 /* don't change helper of sibling connections */
839 if (ct->master) 834 if (ct->master)
840 return -EINVAL; 835 return -EINVAL;
@@ -843,25 +838,34 @@ ctnetlink_change_helper(struct nf_conn *ct, struct nfattr *cda[])
843 if (err < 0) 838 if (err < 0)
844 return err; 839 return err;
845 840
846 helper = __nf_conntrack_helper_find_byname(helpname); 841 if (!strcmp(helpname, "")) {
847 if (!helper) { 842 if (help && help->helper) {
848 if (!strcmp(helpname, ""))
849 helper = NULL;
850 else
851 return -EINVAL;
852 }
853
854 if (help->helper) {
855 if (!helper) {
856 /* we had a helper before ... */ 843 /* we had a helper before ... */
857 nf_ct_remove_expectations(ct); 844 nf_ct_remove_expectations(ct);
858 help->helper = NULL; 845 help->helper = NULL;
859 } else {
860 /* need to zero data of old helper */
861 memset(&help->help, 0, sizeof(help->help));
862 } 846 }
847
848 return 0;
863 } 849 }
864 850
851 if (!help) {
852 /* FIXME: we need to reallocate and rehash */
853 return -EBUSY;
854 }
855
856 helper = __nf_conntrack_helper_find_byname(helpname);
857 if (helper == NULL)
858 return -EINVAL;
859
860 if (help->helper == helper)
861 return 0;
862
863 if (help->helper)
864 /* we had a helper before ... */
865 nf_ct_remove_expectations(ct);
866
867 /* need to zero data of old helper */
868 memset(&help->help, 0, sizeof(help->help));
865 help->helper = helper; 869 help->helper = helper;
866 870
867 return 0; 871 return 0;
diff --git a/net/netfilter/xt_conntrack.c b/net/netfilter/xt_conntrack.c
index f4ea8fe07a53..189ded5f378b 100644
--- a/net/netfilter/xt_conntrack.c
+++ b/net/netfilter/xt_conntrack.c
@@ -134,12 +134,66 @@ static void destroy(const struct xt_match *match, void *matchinfo)
134 nf_ct_l3proto_module_put(match->family); 134 nf_ct_l3proto_module_put(match->family);
135} 135}
136 136
137#ifdef CONFIG_COMPAT
138struct compat_xt_conntrack_info
139{
140 compat_uint_t statemask;
141 compat_uint_t statusmask;
142 struct ip_conntrack_old_tuple tuple[IP_CT_DIR_MAX];
143 struct in_addr sipmsk[IP_CT_DIR_MAX];
144 struct in_addr dipmsk[IP_CT_DIR_MAX];
145 compat_ulong_t expires_min;
146 compat_ulong_t expires_max;
147 u_int8_t flags;
148 u_int8_t invflags;
149};
150
151static void compat_from_user(void *dst, void *src)
152{
153 struct compat_xt_conntrack_info *cm = src;
154 struct xt_conntrack_info m = {
155 .statemask = cm->statemask,
156 .statusmask = cm->statusmask,
157 .expires_min = cm->expires_min,
158 .expires_max = cm->expires_max,
159 .flags = cm->flags,
160 .invflags = cm->invflags,
161 };
162 memcpy(m.tuple, cm->tuple, sizeof(m.tuple));
163 memcpy(m.sipmsk, cm->sipmsk, sizeof(m.sipmsk));
164 memcpy(m.dipmsk, cm->dipmsk, sizeof(m.dipmsk));
165 memcpy(dst, &m, sizeof(m));
166}
167
168static int compat_to_user(void __user *dst, void *src)
169{
170 struct xt_conntrack_info *m = src;
171 struct compat_xt_conntrack_info cm = {
172 .statemask = m->statemask,
173 .statusmask = m->statusmask,
174 .expires_min = m->expires_min,
175 .expires_max = m->expires_max,
176 .flags = m->flags,
177 .invflags = m->invflags,
178 };
179 memcpy(cm.tuple, m->tuple, sizeof(cm.tuple));
180 memcpy(cm.sipmsk, m->sipmsk, sizeof(cm.sipmsk));
181 memcpy(cm.dipmsk, m->dipmsk, sizeof(cm.dipmsk));
182 return copy_to_user(dst, &cm, sizeof(cm)) ? -EFAULT : 0;
183}
184#endif
185
137static struct xt_match conntrack_match = { 186static struct xt_match conntrack_match = {
138 .name = "conntrack", 187 .name = "conntrack",
139 .match = match, 188 .match = match,
140 .checkentry = checkentry, 189 .checkentry = checkentry,
141 .destroy = destroy, 190 .destroy = destroy,
142 .matchsize = sizeof(struct xt_conntrack_info), 191 .matchsize = sizeof(struct xt_conntrack_info),
192#ifdef CONFIG_COMPAT
193 .compatsize = sizeof(struct compat_xt_conntrack_info),
194 .compat_from_user = compat_from_user,
195 .compat_to_user = compat_to_user,
196#endif
143 .family = AF_INET, 197 .family = AF_INET,
144 .me = THIS_MODULE, 198 .me = THIS_MODULE,
145}; 199};
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 3385ee592541..f28bb2dc58d0 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -71,12 +71,9 @@ void qdisc_unlock_tree(struct net_device *dev)
71 71
72 72
73/* Kick device. 73/* Kick device.
74 Note, that this procedure can be called by a watchdog timer, so that
75 we do not check dev->tbusy flag here.
76 74
77 Returns: 0 - queue is empty. 75 Returns: 0 - queue is empty or throttled.
78 >0 - queue is not empty, but throttled. 76 >0 - queue is not empty.
79 <0 - queue is not empty. Device is throttled, if dev->tbusy != 0.
80 77
81 NOTE: Called under dev->queue_lock with locally disabled BH. 78 NOTE: Called under dev->queue_lock with locally disabled BH.
82*/ 79*/
@@ -115,7 +112,7 @@ static inline int qdisc_restart(struct net_device *dev)
115 kfree_skb(skb); 112 kfree_skb(skb);
116 if (net_ratelimit()) 113 if (net_ratelimit())
117 printk(KERN_DEBUG "Dead loop on netdevice %s, fix it urgently!\n", dev->name); 114 printk(KERN_DEBUG "Dead loop on netdevice %s, fix it urgently!\n", dev->name);
118 return -1; 115 goto out;
119 } 116 }
120 __get_cpu_var(netdev_rx_stat).cpu_collision++; 117 __get_cpu_var(netdev_rx_stat).cpu_collision++;
121 goto requeue; 118 goto requeue;
@@ -135,10 +132,12 @@ static inline int qdisc_restart(struct net_device *dev)
135 netif_tx_unlock(dev); 132 netif_tx_unlock(dev);
136 } 133 }
137 spin_lock(&dev->queue_lock); 134 spin_lock(&dev->queue_lock);
138 return -1; 135 q = dev->qdisc;
136 goto out;
139 } 137 }
140 if (ret == NETDEV_TX_LOCKED && nolock) { 138 if (ret == NETDEV_TX_LOCKED && nolock) {
141 spin_lock(&dev->queue_lock); 139 spin_lock(&dev->queue_lock);
140 q = dev->qdisc;
142 goto collision; 141 goto collision;
143 } 142 }
144 } 143 }
@@ -163,26 +162,28 @@ static inline int qdisc_restart(struct net_device *dev)
163 */ 162 */
164 163
165requeue: 164requeue:
166 if (skb->next) 165 if (unlikely(q == &noop_qdisc))
166 kfree_skb(skb);
167 else if (skb->next)
167 dev->gso_skb = skb; 168 dev->gso_skb = skb;
168 else 169 else
169 q->ops->requeue(skb, q); 170 q->ops->requeue(skb, q);
170 netif_schedule(dev); 171 netif_schedule(dev);
171 return 1; 172 return 0;
172 } 173 }
174
175out:
173 BUG_ON((int) q->q.qlen < 0); 176 BUG_ON((int) q->q.qlen < 0);
174 return q->q.qlen; 177 return q->q.qlen;
175} 178}
176 179
177void __qdisc_run(struct net_device *dev) 180void __qdisc_run(struct net_device *dev)
178{ 181{
179 if (unlikely(dev->qdisc == &noop_qdisc)) 182 do {
180 goto out; 183 if (!qdisc_restart(dev))
181 184 break;
182 while (qdisc_restart(dev) < 0 && !netif_queue_stopped(dev)) 185 } while (!netif_queue_stopped(dev));
183 /* NOTHING */;
184 186
185out:
186 clear_bit(__LINK_STATE_QDISC_RUNNING, &dev->state); 187 clear_bit(__LINK_STATE_QDISC_RUNNING, &dev->state);
187} 188}
188 189
@@ -544,6 +545,7 @@ void dev_activate(struct net_device *dev)
544void dev_deactivate(struct net_device *dev) 545void dev_deactivate(struct net_device *dev)
545{ 546{
546 struct Qdisc *qdisc; 547 struct Qdisc *qdisc;
548 struct sk_buff *skb;
547 549
548 spin_lock_bh(&dev->queue_lock); 550 spin_lock_bh(&dev->queue_lock);
549 qdisc = dev->qdisc; 551 qdisc = dev->qdisc;
@@ -551,8 +553,12 @@ void dev_deactivate(struct net_device *dev)
551 553
552 qdisc_reset(qdisc); 554 qdisc_reset(qdisc);
553 555
556 skb = dev->gso_skb;
557 dev->gso_skb = NULL;
554 spin_unlock_bh(&dev->queue_lock); 558 spin_unlock_bh(&dev->queue_lock);
555 559
560 kfree_skb(skb);
561
556 dev_watchdog_down(dev); 562 dev_watchdog_down(dev);
557 563
558 /* Wait for outstanding dev_queue_xmit calls. */ 564 /* Wait for outstanding dev_queue_xmit calls. */
@@ -561,11 +567,6 @@ void dev_deactivate(struct net_device *dev)
561 /* Wait for outstanding qdisc_run calls. */ 567 /* Wait for outstanding qdisc_run calls. */
562 while (test_bit(__LINK_STATE_QDISC_RUNNING, &dev->state)) 568 while (test_bit(__LINK_STATE_QDISC_RUNNING, &dev->state))
563 yield(); 569 yield();
564
565 if (dev->gso_skb) {
566 kfree_skb(dev->gso_skb);
567 dev->gso_skb = NULL;
568 }
569} 570}
570 571
571void dev_init_scheduler(struct net_device *dev) 572void dev_init_scheduler(struct net_device *dev)
diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
index d24914db7861..f05ad9a30b4c 100644
--- a/net/sched/sch_teql.c
+++ b/net/sched/sch_teql.c
@@ -94,14 +94,13 @@ teql_enqueue(struct sk_buff *skb, struct Qdisc* sch)
94 struct net_device *dev = sch->dev; 94 struct net_device *dev = sch->dev;
95 struct teql_sched_data *q = qdisc_priv(sch); 95 struct teql_sched_data *q = qdisc_priv(sch);
96 96
97 __skb_queue_tail(&q->q, skb); 97 if (q->q.qlen < dev->tx_queue_len) {
98 if (q->q.qlen <= dev->tx_queue_len) { 98 __skb_queue_tail(&q->q, skb);
99 sch->bstats.bytes += skb->len; 99 sch->bstats.bytes += skb->len;
100 sch->bstats.packets++; 100 sch->bstats.packets++;
101 return 0; 101 return 0;
102 } 102 }
103 103
104 __skb_unlink(skb, &q->q);
105 kfree_skb(skb); 104 kfree_skb(skb);
106 sch->qstats.drops++; 105 sch->qstats.drops++;
107 return NET_XMIT_DROP; 106 return NET_XMIT_DROP;
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 83a76ba9d7b3..4dcdabf56473 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4164,6 +4164,7 @@ static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len,
4164 rwlock_t *addr_lock; 4164 rwlock_t *addr_lock;
4165 int err = 0; 4165 int err = 0;
4166 void *addrs; 4166 void *addrs;
4167 void *buf;
4167 int bytes_copied = 0; 4168 int bytes_copied = 0;
4168 4169
4169 if (len != sizeof(struct sctp_getaddrs_old)) 4170 if (len != sizeof(struct sctp_getaddrs_old))
@@ -4217,13 +4218,14 @@ static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len,
4217 } 4218 }
4218 } 4219 }
4219 4220
4221 buf = addrs;
4220 list_for_each(pos, &bp->address_list) { 4222 list_for_each(pos, &bp->address_list) {
4221 addr = list_entry(pos, struct sctp_sockaddr_entry, list); 4223 addr = list_entry(pos, struct sctp_sockaddr_entry, list);
4222 memcpy(&temp, &addr->a, sizeof(temp)); 4224 memcpy(&temp, &addr->a, sizeof(temp));
4223 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); 4225 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp);
4224 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; 4226 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
4225 memcpy(addrs, &temp, addrlen); 4227 memcpy(buf, &temp, addrlen);
4226 to += addrlen; 4228 buf += addrlen;
4227 bytes_copied += addrlen; 4229 bytes_copied += addrlen;
4228 cnt ++; 4230 cnt ++;
4229 if (cnt >= getaddrs.addr_num) break; 4231 if (cnt >= getaddrs.addr_num) break;
@@ -4266,6 +4268,7 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
4266 size_t space_left; 4268 size_t space_left;
4267 int bytes_copied = 0; 4269 int bytes_copied = 0;
4268 void *addrs; 4270 void *addrs;
4271 void *buf;
4269 4272
4270 if (len <= sizeof(struct sctp_getaddrs)) 4273 if (len <= sizeof(struct sctp_getaddrs))
4271 return -EINVAL; 4274 return -EINVAL;
@@ -4316,6 +4319,7 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
4316 } 4319 }
4317 } 4320 }
4318 4321
4322 buf = addrs;
4319 list_for_each(pos, &bp->address_list) { 4323 list_for_each(pos, &bp->address_list) {
4320 addr = list_entry(pos, struct sctp_sockaddr_entry, list); 4324 addr = list_entry(pos, struct sctp_sockaddr_entry, list);
4321 memcpy(&temp, &addr->a, sizeof(temp)); 4325 memcpy(&temp, &addr->a, sizeof(temp));
@@ -4325,8 +4329,8 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
4325 err = -ENOMEM; /*fixme: right error?*/ 4329 err = -ENOMEM; /*fixme: right error?*/
4326 goto error; 4330 goto error;
4327 } 4331 }
4328 memcpy(addrs, &temp, addrlen); 4332 memcpy(buf, &temp, addrlen);
4329 to += addrlen; 4333 buf += addrlen;
4330 bytes_copied += addrlen; 4334 bytes_copied += addrlen;
4331 cnt ++; 4335 cnt ++;
4332 space_left -= addrlen; 4336 space_left -= addrlen;
@@ -5227,7 +5231,12 @@ int sctp_inet_listen(struct socket *sock, int backlog)
5227 /* Allocate HMAC for generating cookie. */ 5231 /* Allocate HMAC for generating cookie. */
5228 if (sctp_hmac_alg) { 5232 if (sctp_hmac_alg) {
5229 tfm = crypto_alloc_hash(sctp_hmac_alg, 0, CRYPTO_ALG_ASYNC); 5233 tfm = crypto_alloc_hash(sctp_hmac_alg, 0, CRYPTO_ALG_ASYNC);
5230 if (!tfm) { 5234 if (IS_ERR(tfm)) {
5235 if (net_ratelimit()) {
5236 printk(KERN_INFO
5237 "SCTP: failed to load transform for %s: %ld\n",
5238 sctp_hmac_alg, PTR_ERR(tfm));
5239 }
5231 err = -ENOSYS; 5240 err = -ENOSYS;
5232 goto out; 5241 goto out;
5233 } 5242 }
diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c
index 661ea2dd78ba..bfecb353ab3d 100644
--- a/net/sctp/ulpevent.c
+++ b/net/sctp/ulpevent.c
@@ -141,11 +141,6 @@ struct sctp_ulpevent *sctp_ulpevent_make_assoc_change(
141 * an ABORT, so we need to include it in the sac_info. 141 * an ABORT, so we need to include it in the sac_info.
142 */ 142 */
143 if (chunk) { 143 if (chunk) {
144 /* sctp_inqu_pop() has allready pulled off the chunk
145 * header. We need to put it back temporarily
146 */
147 skb_push(chunk->skb, sizeof(sctp_chunkhdr_t));
148
149 /* Copy the chunk data to a new skb and reserve enough 144 /* Copy the chunk data to a new skb and reserve enough
150 * head room to use as notification. 145 * head room to use as notification.
151 */ 146 */
@@ -155,9 +150,6 @@ struct sctp_ulpevent *sctp_ulpevent_make_assoc_change(
155 if (!skb) 150 if (!skb)
156 goto fail; 151 goto fail;
157 152
158 /* put back the chunk header now that we have a copy */
159 skb_pull(chunk->skb, sizeof(sctp_chunkhdr_t));
160
161 /* Embed the event fields inside the cloned skb. */ 153 /* Embed the event fields inside the cloned skb. */
162 event = sctp_skb2event(skb); 154 event = sctp_skb2event(skb);
163 sctp_ulpevent_init(event, MSG_NOTIFICATION, skb->truesize); 155 sctp_ulpevent_init(event, MSG_NOTIFICATION, skb->truesize);
@@ -168,7 +160,8 @@ struct sctp_ulpevent *sctp_ulpevent_make_assoc_change(
168 160
169 /* Trim the buffer to the right length. */ 161 /* Trim the buffer to the right length. */
170 skb_trim(skb, sizeof(struct sctp_assoc_change) + 162 skb_trim(skb, sizeof(struct sctp_assoc_change) +
171 ntohs(chunk->chunk_hdr->length)); 163 ntohs(chunk->chunk_hdr->length) -
164 sizeof(sctp_chunkhdr_t));
172 } else { 165 } else {
173 event = sctp_ulpevent_new(sizeof(struct sctp_assoc_change), 166 event = sctp_ulpevent_new(sizeof(struct sctp_assoc_change),
174 MSG_NOTIFICATION, gfp); 167 MSG_NOTIFICATION, gfp);
diff --git a/sound/aoa/codecs/snd-aoa-codec-onyx.c b/sound/aoa/codecs/snd-aoa-codec-onyx.c
index e91f9f66f395..ded516717940 100644
--- a/sound/aoa/codecs/snd-aoa-codec-onyx.c
+++ b/sound/aoa/codecs/snd-aoa-codec-onyx.c
@@ -1018,7 +1018,7 @@ static int onyx_create(struct i2c_adapter *adapter,
1018 onyx->i2c.driver = &onyx_driver; 1018 onyx->i2c.driver = &onyx_driver;
1019 onyx->i2c.adapter = adapter; 1019 onyx->i2c.adapter = adapter;
1020 onyx->i2c.addr = addr & 0x7f; 1020 onyx->i2c.addr = addr & 0x7f;
1021 strlcpy(onyx->i2c.name, "onyx audio codec", I2C_NAME_SIZE-1); 1021 strlcpy(onyx->i2c.name, "onyx audio codec", I2C_NAME_SIZE);
1022 1022
1023 if (i2c_attach_client(&onyx->i2c)) { 1023 if (i2c_attach_client(&onyx->i2c)) {
1024 printk(KERN_ERR PFX "failed to attach to i2c\n"); 1024 printk(KERN_ERR PFX "failed to attach to i2c\n");
@@ -1033,7 +1033,7 @@ static int onyx_create(struct i2c_adapter *adapter,
1033 goto fail; 1033 goto fail;
1034 } 1034 }
1035 1035
1036 strlcpy(onyx->codec.name, "onyx", MAX_CODEC_NAME_LEN-1); 1036 strlcpy(onyx->codec.name, "onyx", MAX_CODEC_NAME_LEN);
1037 onyx->codec.owner = THIS_MODULE; 1037 onyx->codec.owner = THIS_MODULE;
1038 onyx->codec.init = onyx_init_codec; 1038 onyx->codec.init = onyx_init_codec;
1039 onyx->codec.exit = onyx_exit_codec; 1039 onyx->codec.exit = onyx_exit_codec;
diff --git a/sound/aoa/codecs/snd-aoa-codec-tas.c b/sound/aoa/codecs/snd-aoa-codec-tas.c
index 041fe52cbf29..2f771f57c76f 100644
--- a/sound/aoa/codecs/snd-aoa-codec-tas.c
+++ b/sound/aoa/codecs/snd-aoa-codec-tas.c
@@ -899,14 +899,14 @@ static int tas_create(struct i2c_adapter *adapter,
899 tas->i2c.addr = addr; 899 tas->i2c.addr = addr;
900 /* seems that half is a saner default */ 900 /* seems that half is a saner default */
901 tas->drc_range = TAS3004_DRC_MAX / 2; 901 tas->drc_range = TAS3004_DRC_MAX / 2;
902 strlcpy(tas->i2c.name, "tas audio codec", I2C_NAME_SIZE-1); 902 strlcpy(tas->i2c.name, "tas audio codec", I2C_NAME_SIZE);
903 903
904 if (i2c_attach_client(&tas->i2c)) { 904 if (i2c_attach_client(&tas->i2c)) {
905 printk(KERN_ERR PFX "failed to attach to i2c\n"); 905 printk(KERN_ERR PFX "failed to attach to i2c\n");
906 goto fail; 906 goto fail;
907 } 907 }
908 908
909 strlcpy(tas->codec.name, "tas", MAX_CODEC_NAME_LEN-1); 909 strlcpy(tas->codec.name, "tas", MAX_CODEC_NAME_LEN);
910 tas->codec.owner = THIS_MODULE; 910 tas->codec.owner = THIS_MODULE;
911 tas->codec.init = tas_init_codec; 911 tas->codec.init = tas_init_codec;
912 tas->codec.exit = tas_exit_codec; 912 tas->codec.exit = tas_exit_codec;
diff --git a/sound/aoa/soundbus/core.c b/sound/aoa/soundbus/core.c
index 8b2e9b905cda..64d163914335 100644
--- a/sound/aoa/soundbus/core.c
+++ b/sound/aoa/soundbus/core.c
@@ -163,8 +163,6 @@ static int soundbus_device_resume(struct device * dev)
163 163
164#endif /* CONFIG_PM */ 164#endif /* CONFIG_PM */
165 165
166extern struct device_attribute soundbus_dev_attrs[];
167
168static struct bus_type soundbus_bus_type = { 166static struct bus_type soundbus_bus_type = {
169 .name = "aoa-soundbus", 167 .name = "aoa-soundbus",
170 .probe = soundbus_probe, 168 .probe = soundbus_probe,
diff --git a/sound/aoa/soundbus/i2sbus/i2sbus-core.c b/sound/aoa/soundbus/i2sbus/i2sbus-core.c
index 0fccdbf51663..efb9441b3acf 100644
--- a/sound/aoa/soundbus/i2sbus/i2sbus-core.c
+++ b/sound/aoa/soundbus/i2sbus/i2sbus-core.c
@@ -23,9 +23,6 @@
23MODULE_LICENSE("GPL"); 23MODULE_LICENSE("GPL");
24MODULE_AUTHOR("Johannes Berg <johannes@sipsolutions.net>"); 24MODULE_AUTHOR("Johannes Berg <johannes@sipsolutions.net>");
25MODULE_DESCRIPTION("Apple Soundbus: I2S support"); 25MODULE_DESCRIPTION("Apple Soundbus: I2S support");
26/* for auto-loading, declare that we handle this weird
27 * string that macio puts into the relevant device */
28MODULE_ALIAS("of:Ni2sTi2sC");
29 26
30static int force; 27static int force;
31module_param(force, int, 0444); 28module_param(force, int, 0444);
@@ -37,6 +34,8 @@ static struct of_device_id i2sbus_match[] = {
37 { } 34 { }
38}; 35};
39 36
37MODULE_DEVICE_TABLE(of, i2sbus_match);
38
40static int alloc_dbdma_descriptor_ring(struct i2sbus_dev *i2sdev, 39static int alloc_dbdma_descriptor_ring(struct i2sbus_dev *i2sdev,
41 struct dbdma_command_mem *r, 40 struct dbdma_command_mem *r,
42 int numcmds) 41 int numcmds)
diff --git a/sound/aoa/soundbus/soundbus.h b/sound/aoa/soundbus/soundbus.h
index 5c27297835d7..622cd37a0118 100644
--- a/sound/aoa/soundbus/soundbus.h
+++ b/sound/aoa/soundbus/soundbus.h
@@ -199,4 +199,6 @@ struct soundbus_driver {
199extern int soundbus_register_driver(struct soundbus_driver *drv); 199extern int soundbus_register_driver(struct soundbus_driver *drv);
200extern void soundbus_unregister_driver(struct soundbus_driver *drv); 200extern void soundbus_unregister_driver(struct soundbus_driver *drv);
201 201
202extern struct device_attribute soundbus_dev_attrs[];
203
202#endif /* __SOUNDBUS_H */ 204#endif /* __SOUNDBUS_H */
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 905234817c89..a96733a5beb8 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -712,26 +712,23 @@ static int snd_pcm_action_group(struct action_ops *ops,
712 struct snd_pcm_substream *substream, 712 struct snd_pcm_substream *substream,
713 int state, int do_lock) 713 int state, int do_lock)
714{ 714{
715 struct list_head *pos;
716 struct snd_pcm_substream *s = NULL; 715 struct snd_pcm_substream *s = NULL;
717 struct snd_pcm_substream *s1; 716 struct snd_pcm_substream *s1;
718 int res = 0; 717 int res = 0;
719 718
720 snd_pcm_group_for_each(pos, substream) { 719 snd_pcm_group_for_each_entry(s, substream) {
721 s = snd_pcm_group_substream_entry(pos);
722 if (do_lock && s != substream) 720 if (do_lock && s != substream)
723 spin_lock(&s->self_group.lock); 721 spin_lock_nested(&s->self_group.lock,
722 SINGLE_DEPTH_NESTING);
724 res = ops->pre_action(s, state); 723 res = ops->pre_action(s, state);
725 if (res < 0) 724 if (res < 0)
726 goto _unlock; 725 goto _unlock;
727 } 726 }
728 snd_pcm_group_for_each(pos, substream) { 727 snd_pcm_group_for_each_entry(s, substream) {
729 s = snd_pcm_group_substream_entry(pos);
730 res = ops->do_action(s, state); 728 res = ops->do_action(s, state);
731 if (res < 0) { 729 if (res < 0) {
732 if (ops->undo_action) { 730 if (ops->undo_action) {
733 snd_pcm_group_for_each(pos, substream) { 731 snd_pcm_group_for_each_entry(s1, substream) {
734 s1 = snd_pcm_group_substream_entry(pos);
735 if (s1 == s) /* failed stream */ 732 if (s1 == s) /* failed stream */
736 break; 733 break;
737 ops->undo_action(s1, state); 734 ops->undo_action(s1, state);
@@ -741,15 +738,13 @@ static int snd_pcm_action_group(struct action_ops *ops,
741 goto _unlock; 738 goto _unlock;
742 } 739 }
743 } 740 }
744 snd_pcm_group_for_each(pos, substream) { 741 snd_pcm_group_for_each_entry(s, substream) {
745 s = snd_pcm_group_substream_entry(pos);
746 ops->post_action(s, state); 742 ops->post_action(s, state);
747 } 743 }
748 _unlock: 744 _unlock:
749 if (do_lock) { 745 if (do_lock) {
750 /* unlock streams */ 746 /* unlock streams */
751 snd_pcm_group_for_each(pos, substream) { 747 snd_pcm_group_for_each_entry(s1, substream) {
752 s1 = snd_pcm_group_substream_entry(pos);
753 if (s1 != substream) 748 if (s1 != substream)
754 spin_unlock(&s1->self_group.lock); 749 spin_unlock(&s1->self_group.lock);
755 if (s1 == s) /* end */ 750 if (s1 == s) /* end */
@@ -1438,7 +1433,7 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream)
1438{ 1433{
1439 struct snd_card *card; 1434 struct snd_card *card;
1440 struct snd_pcm_runtime *runtime; 1435 struct snd_pcm_runtime *runtime;
1441 struct list_head *pos; 1436 struct snd_pcm_substream *s;
1442 int result = 0; 1437 int result = 0;
1443 int i, num_drecs; 1438 int i, num_drecs;
1444 struct drain_rec *drec, drec_tmp, *d; 1439 struct drain_rec *drec, drec_tmp, *d;
@@ -1473,8 +1468,7 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream)
1473 1468
1474 /* count only playback streams */ 1469 /* count only playback streams */
1475 num_drecs = 0; 1470 num_drecs = 0;
1476 snd_pcm_group_for_each(pos, substream) { 1471 snd_pcm_group_for_each_entry(s, substream) {
1477 struct snd_pcm_substream *s = snd_pcm_group_substream_entry(pos);
1478 runtime = s->runtime; 1472 runtime = s->runtime;
1479 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { 1473 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1480 d = &drec[num_drecs++]; 1474 d = &drec[num_drecs++];
@@ -1674,7 +1668,7 @@ static void relink_to_local(struct snd_pcm_substream *substream)
1674 1668
1675static int snd_pcm_unlink(struct snd_pcm_substream *substream) 1669static int snd_pcm_unlink(struct snd_pcm_substream *substream)
1676{ 1670{
1677 struct list_head *pos; 1671 struct snd_pcm_substream *s;
1678 int res = 0; 1672 int res = 0;
1679 1673
1680 down_write(&snd_pcm_link_rwsem); 1674 down_write(&snd_pcm_link_rwsem);
@@ -1686,8 +1680,8 @@ static int snd_pcm_unlink(struct snd_pcm_substream *substream)
1686 list_del(&substream->link_list); 1680 list_del(&substream->link_list);
1687 substream->group->count--; 1681 substream->group->count--;
1688 if (substream->group->count == 1) { /* detach the last stream, too */ 1682 if (substream->group->count == 1) { /* detach the last stream, too */
1689 snd_pcm_group_for_each(pos, substream) { 1683 snd_pcm_group_for_each_entry(s, substream) {
1690 relink_to_local(snd_pcm_group_substream_entry(pos)); 1684 relink_to_local(s);
1691 break; 1685 break;
1692 } 1686 }
1693 kfree(substream->group); 1687 kfree(substream->group);
diff --git a/sound/core/rtctimer.c b/sound/core/rtctimer.c
index 9f7b32e1ccde..7cd5e8f5d4ce 100644
--- a/sound/core/rtctimer.c
+++ b/sound/core/rtctimer.c
@@ -24,6 +24,7 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/moduleparam.h> 26#include <linux/moduleparam.h>
27#include <linux/log2.h>
27#include <sound/core.h> 28#include <sound/core.h>
28#include <sound/timer.h> 29#include <sound/timer.h>
29 30
@@ -129,7 +130,7 @@ static int __init rtctimer_init(void)
129 struct snd_timer *timer; 130 struct snd_timer *timer;
130 131
131 if (rtctimer_freq < 2 || rtctimer_freq > 8192 || 132 if (rtctimer_freq < 2 || rtctimer_freq > 8192 ||
132 (rtctimer_freq & (rtctimer_freq - 1)) != 0) { 133 !is_power_of_2(rtctimer_freq)) {
133 snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n", 134 snd_printk(KERN_ERR "rtctimer: invalid frequency %d\n",
134 rtctimer_freq); 135 rtctimer_freq);
135 return -EINVAL; 136 return -EINVAL;
diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c
index 2de181ad0b05..1d563e515c17 100644
--- a/sound/drivers/mpu401/mpu401.c
+++ b/sound/drivers/mpu401/mpu401.c
@@ -42,6 +42,7 @@ static int pnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
42#endif 42#endif
43static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* MPU-401 port number */ 43static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* MPU-401 port number */
44static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* MPU-401 IRQ */ 44static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* MPU-401 IRQ */
45static int uart_enter[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
45 46
46module_param_array(index, int, NULL, 0444); 47module_param_array(index, int, NULL, 0444);
47MODULE_PARM_DESC(index, "Index value for MPU-401 device."); 48MODULE_PARM_DESC(index, "Index value for MPU-401 device.");
@@ -57,6 +58,8 @@ module_param_array(port, long, NULL, 0444);
57MODULE_PARM_DESC(port, "Port # for MPU-401 device."); 58MODULE_PARM_DESC(port, "Port # for MPU-401 device.");
58module_param_array(irq, int, NULL, 0444); 59module_param_array(irq, int, NULL, 0444);
59MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device."); 60MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device.");
61module_param_array(uart_enter, bool, NULL, 0444);
62MODULE_PARM_DESC(uart_enter, "Issue UART_ENTER command at open.");
60 63
61static struct platform_device *platform_devices[SNDRV_CARDS]; 64static struct platform_device *platform_devices[SNDRV_CARDS];
62static int pnp_registered; 65static int pnp_registered;
@@ -80,10 +83,11 @@ static int snd_mpu401_create(int dev, struct snd_card **rcard)
80 strcat(card->longname, "polled"); 83 strcat(card->longname, "polled");
81 } 84 }
82 85
83 if ((err = snd_mpu401_uart_new(card, 0, 86 err = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, port[dev],
84 MPU401_HW_MPU401, 87 uart_enter[dev] ? 0 : MPU401_INFO_UART_ONLY,
85 port[dev], 0, 88 irq[dev], irq[dev] >= 0 ? IRQF_DISABLED : 0,
86 irq[dev], irq[dev] >= 0 ? IRQF_DISABLED : 0, NULL)) < 0) { 89 NULL);
90 if (err < 0) {
87 printk(KERN_ERR "MPU401 not detected at 0x%lx\n", port[dev]); 91 printk(KERN_ERR "MPU401 not detected at 0x%lx\n", port[dev]);
88 goto _err; 92 goto _err;
89 } 93 }
diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c
index 3daa9fa56c0b..85aedc348e2d 100644
--- a/sound/drivers/mpu401/mpu401_uart.c
+++ b/sound/drivers/mpu401/mpu401_uart.c
@@ -266,6 +266,16 @@ static int snd_mpu401_uart_cmd(struct snd_mpu401 * mpu, unsigned char cmd,
266 return 0; 266 return 0;
267} 267}
268 268
269static int snd_mpu401_do_reset(struct snd_mpu401 *mpu)
270{
271 if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1))
272 return -EIO;
273 if (!(mpu->info_flags & MPU401_INFO_UART_ONLY) &&
274 snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1))
275 return -EIO;
276 return 0;
277}
278
269/* 279/*
270 * input/output open/close - protected by open_mutex in rawmidi.c 280 * input/output open/close - protected by open_mutex in rawmidi.c
271 */ 281 */
@@ -278,9 +288,7 @@ static int snd_mpu401_uart_input_open(struct snd_rawmidi_substream *substream)
278 if (mpu->open_input && (err = mpu->open_input(mpu)) < 0) 288 if (mpu->open_input && (err = mpu->open_input(mpu)) < 0)
279 return err; 289 return err;
280 if (! test_bit(MPU401_MODE_BIT_OUTPUT, &mpu->mode)) { 290 if (! test_bit(MPU401_MODE_BIT_OUTPUT, &mpu->mode)) {
281 if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1)) 291 if (snd_mpu401_do_reset(mpu) < 0)
282 goto error_out;
283 if (snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1))
284 goto error_out; 292 goto error_out;
285 } 293 }
286 mpu->substream_input = substream; 294 mpu->substream_input = substream;
@@ -302,9 +310,7 @@ static int snd_mpu401_uart_output_open(struct snd_rawmidi_substream *substream)
302 if (mpu->open_output && (err = mpu->open_output(mpu)) < 0) 310 if (mpu->open_output && (err = mpu->open_output(mpu)) < 0)
303 return err; 311 return err;
304 if (! test_bit(MPU401_MODE_BIT_INPUT, &mpu->mode)) { 312 if (! test_bit(MPU401_MODE_BIT_INPUT, &mpu->mode)) {
305 if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1)) 313 if (snd_mpu401_do_reset(mpu) < 0)
306 goto error_out;
307 if (snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1))
308 goto error_out; 314 goto error_out;
309 } 315 }
310 mpu->substream_output = substream; 316 mpu->substream_output = substream;
diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
index 6c9f4c9bfeb6..ebb1bdac7237 100644
--- a/sound/drivers/mts64.c
+++ b/sound/drivers/mts64.c
@@ -892,13 +892,13 @@ static void __devinit snd_mts64_attach(struct parport *p)
892 struct platform_device *device; 892 struct platform_device *device;
893 893
894 device = platform_device_alloc(PLATFORM_DRIVER, device_count); 894 device = platform_device_alloc(PLATFORM_DRIVER, device_count);
895 if (!device) 895 if (!device)
896 return; 896 return;
897 897
898 /* Temporary assignment to forward the parport */ 898 /* Temporary assignment to forward the parport */
899 platform_set_drvdata(device, p); 899 platform_set_drvdata(device, p);
900 900
901 if (platform_device_register(device) < 0) { 901 if (platform_device_add(device) < 0) {
902 platform_device_put(device); 902 platform_device_put(device);
903 return; 903 return;
904 } 904 }
diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
index b2d0ba4bd184..497cafb57d9b 100644
--- a/sound/drivers/portman2x4.c
+++ b/sound/drivers/portman2x4.c
@@ -676,13 +676,13 @@ static void __devinit snd_portman_attach(struct parport *p)
676 struct platform_device *device; 676 struct platform_device *device;
677 677
678 device = platform_device_alloc(PLATFORM_DRIVER, device_count); 678 device = platform_device_alloc(PLATFORM_DRIVER, device_count);
679 if (!device) 679 if (!device)
680 return; 680 return;
681 681
682 /* Temporary assignment to forward the parport */ 682 /* Temporary assignment to forward the parport */
683 platform_set_drvdata(device, p); 683 platform_set_drvdata(device, p);
684 684
685 if (platform_device_register(device) < 0) { 685 if (platform_device_add(device) < 0) {
686 platform_device_put(device); 686 platform_device_put(device);
687 return; 687 return;
688 } 688 }
diff --git a/sound/drivers/vx/vx_hwdep.c b/sound/drivers/vx/vx_hwdep.c
index e1920af4501d..9a8154c9416e 100644
--- a/sound/drivers/vx/vx_hwdep.c
+++ b/sound/drivers/vx/vx_hwdep.c
@@ -30,6 +30,20 @@
30 30
31#ifdef SND_VX_FW_LOADER 31#ifdef SND_VX_FW_LOADER
32 32
33MODULE_FIRMWARE("vx/bx_1_vxp.b56");
34MODULE_FIRMWARE("vx/bx_1_vp4.b56");
35MODULE_FIRMWARE("vx/x1_1_vx2.xlx");
36MODULE_FIRMWARE("vx/x1_2_v22.xlx");
37MODULE_FIRMWARE("vx/x1_1_vxp.xlx");
38MODULE_FIRMWARE("vx/x1_1_vp4.xlx");
39MODULE_FIRMWARE("vx/bd56002.boot");
40MODULE_FIRMWARE("vx/bd563v2.boot");
41MODULE_FIRMWARE("vx/bd563s3.boot");
42MODULE_FIRMWARE("vx/l_1_vx2.d56");
43MODULE_FIRMWARE("vx/l_1_v22.d56");
44MODULE_FIRMWARE("vx/l_1_vxp.d56");
45MODULE_FIRMWARE("vx/l_1_vp4.d56");
46
33int snd_vx_setup_firmware(struct vx_core *chip) 47int snd_vx_setup_firmware(struct vx_core *chip)
34{ 48{
35 static char *fw_files[VX_TYPE_NUMS][4] = { 49 static char *fw_files[VX_TYPE_NUMS][4] = {
diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c
index adbfd5884d06..1efb973137a6 100644
--- a/sound/i2c/other/ak4114.c
+++ b/sound/i2c/other/ak4114.c
@@ -36,6 +36,7 @@ MODULE_LICENSE("GPL");
36#define AK4114_ADDR 0x00 /* fixed address */ 36#define AK4114_ADDR 0x00 /* fixed address */
37 37
38static void ak4114_stats(struct work_struct *work); 38static void ak4114_stats(struct work_struct *work);
39static void ak4114_init_regs(struct ak4114 *chip);
39 40
40static void reg_write(struct ak4114 *ak4114, unsigned char reg, unsigned char val) 41static void reg_write(struct ak4114 *ak4114, unsigned char reg, unsigned char val)
41{ 42{
@@ -105,7 +106,7 @@ int snd_ak4114_create(struct snd_card *card,
105 for (reg = 0; reg < 5; reg++) 106 for (reg = 0; reg < 5; reg++)
106 chip->txcsb[reg] = txcsb[reg]; 107 chip->txcsb[reg] = txcsb[reg];
107 108
108 snd_ak4114_reinit(chip); 109 ak4114_init_regs(chip);
109 110
110 chip->rcs0 = reg_read(chip, AK4114_REG_RCS0) & ~(AK4114_QINT | AK4114_CINT); 111 chip->rcs0 = reg_read(chip, AK4114_REG_RCS0) & ~(AK4114_QINT | AK4114_CINT);
111 chip->rcs1 = reg_read(chip, AK4114_REG_RCS1); 112 chip->rcs1 = reg_read(chip, AK4114_REG_RCS1);
@@ -131,13 +132,10 @@ void snd_ak4114_reg_write(struct ak4114 *chip, unsigned char reg, unsigned char
131 (chip->txcsb[reg-AK4114_REG_TXCSB0] & ~mask) | val); 132 (chip->txcsb[reg-AK4114_REG_TXCSB0] & ~mask) | val);
132} 133}
133 134
134void snd_ak4114_reinit(struct ak4114 *chip) 135static void ak4114_init_regs(struct ak4114 *chip)
135{ 136{
136 unsigned char old = chip->regmap[AK4114_REG_PWRDN], reg; 137 unsigned char old = chip->regmap[AK4114_REG_PWRDN], reg;
137 138
138 chip->init = 1;
139 mb();
140 flush_scheduled_work();
141 /* bring the chip to reset state and powerdown state */ 139 /* bring the chip to reset state and powerdown state */
142 reg_write(chip, AK4114_REG_PWRDN, old & ~(AK4114_RST|AK4114_PWN)); 140 reg_write(chip, AK4114_REG_PWRDN, old & ~(AK4114_RST|AK4114_PWN));
143 udelay(200); 141 udelay(200);
@@ -150,9 +148,18 @@ void snd_ak4114_reinit(struct ak4114 *chip)
150 reg_write(chip, reg + AK4114_REG_TXCSB0, chip->txcsb[reg]); 148 reg_write(chip, reg + AK4114_REG_TXCSB0, chip->txcsb[reg]);
151 /* release powerdown, everything is initialized now */ 149 /* release powerdown, everything is initialized now */
152 reg_write(chip, AK4114_REG_PWRDN, old | AK4114_RST | AK4114_PWN); 150 reg_write(chip, AK4114_REG_PWRDN, old | AK4114_RST | AK4114_PWN);
151}
152
153void snd_ak4114_reinit(struct ak4114 *chip)
154{
155 chip->init = 1;
156 mb();
157 flush_scheduled_work();
158 ak4114_init_regs(chip);
153 /* bring up statistics / event queing */ 159 /* bring up statistics / event queing */
154 chip->init = 0; 160 chip->init = 0;
155 schedule_delayed_work(&chip->work, HZ / 10); 161 if (chip->kctls[0])
162 schedule_delayed_work(&chip->work, HZ / 10);
156} 163}
157 164
158static unsigned int external_rate(unsigned char rcs1) 165static unsigned int external_rate(unsigned char rcs1)
@@ -428,7 +435,7 @@ static struct snd_kcontrol_new snd_ak4114_iec958_controls[] = {
428 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, 435 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
429 .info = snd_ak4114_in_bit_info, 436 .info = snd_ak4114_in_bit_info,
430 .get = snd_ak4114_in_bit_get, 437 .get = snd_ak4114_in_bit_get,
431 .private_value = (6<<8) | AK4114_REG_RCS1, 438 .private_value = (6<<8) | AK4114_REG_RCS0,
432}, 439},
433{ 440{
434 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 441 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
@@ -436,7 +443,15 @@ static struct snd_kcontrol_new snd_ak4114_iec958_controls[] = {
436 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, 443 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
437 .info = snd_ak4114_in_bit_info, 444 .info = snd_ak4114_in_bit_info,
438 .get = snd_ak4114_in_bit_get, 445 .get = snd_ak4114_in_bit_get,
439 .private_value = (3<<8) | AK4114_REG_RCS1, 446 .private_value = (3<<8) | AK4114_REG_RCS0,
447},
448{
449 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
450 .name = "IEC958 PPL Lock Status",
451 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
452 .info = snd_ak4114_in_bit_info,
453 .get = snd_ak4114_in_bit_get,
454 .private_value = (1<<31) | (4<<8) | AK4114_REG_RCS0,
440} 455}
441}; 456};
442 457
@@ -455,7 +470,7 @@ int snd_ak4114_build(struct ak4114 *ak4114,
455 kctl = snd_ctl_new1(&snd_ak4114_iec958_controls[idx], ak4114); 470 kctl = snd_ctl_new1(&snd_ak4114_iec958_controls[idx], ak4114);
456 if (kctl == NULL) 471 if (kctl == NULL)
457 return -ENOMEM; 472 return -ENOMEM;
458 if (!strstr(kctl->id.name, "Playback")) { 473 if (strstr(kctl->id.name, "Playback")) {
459 if (ply_substream == NULL) { 474 if (ply_substream == NULL) {
460 snd_ctl_free_one(kctl); 475 snd_ctl_free_one(kctl);
461 ak4114->kctls[idx] = NULL; 476 ak4114->kctls[idx] = NULL;
@@ -472,9 +487,58 @@ int snd_ak4114_build(struct ak4114 *ak4114,
472 return err; 487 return err;
473 ak4114->kctls[idx] = kctl; 488 ak4114->kctls[idx] = kctl;
474 } 489 }
490 /* trigger workq */
491 schedule_delayed_work(&ak4114->work, HZ / 10);
475 return 0; 492 return 0;
476} 493}
477 494
495/* notify kcontrols if any parameters are changed */
496static void ak4114_notify(struct ak4114 *ak4114,
497 unsigned char rcs0, unsigned char rcs1,
498 unsigned char c0, unsigned char c1)
499{
500 if (!ak4114->kctls[0])
501 return;
502
503 if (rcs0 & AK4114_PAR)
504 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
505 &ak4114->kctls[0]->id);
506 if (rcs0 & AK4114_V)
507 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
508 &ak4114->kctls[1]->id);
509 if (rcs1 & AK4114_CCRC)
510 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
511 &ak4114->kctls[2]->id);
512 if (rcs1 & AK4114_QCRC)
513 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
514 &ak4114->kctls[3]->id);
515
516 /* rate change */
517 if (c1 & 0xf0)
518 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
519 &ak4114->kctls[4]->id);
520
521 if ((c0 & AK4114_PEM) | (c0 & AK4114_CINT))
522 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
523 &ak4114->kctls[9]->id);
524 if (c0 & AK4114_QINT)
525 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
526 &ak4114->kctls[10]->id);
527
528 if (c0 & AK4114_AUDION)
529 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
530 &ak4114->kctls[11]->id);
531 if (c0 & AK4114_AUTO)
532 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
533 &ak4114->kctls[12]->id);
534 if (c0 & AK4114_DTSCD)
535 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
536 &ak4114->kctls[13]->id);
537 if (c0 & AK4114_UNLCK)
538 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE,
539 &ak4114->kctls[14]->id);
540}
541
478int snd_ak4114_external_rate(struct ak4114 *ak4114) 542int snd_ak4114_external_rate(struct ak4114 *ak4114)
479{ 543{
480 unsigned char rcs1; 544 unsigned char rcs1;
@@ -511,31 +575,7 @@ int snd_ak4114_check_rate_and_errors(struct ak4114 *ak4114, unsigned int flags)
511 ak4114->rcs1 = rcs1; 575 ak4114->rcs1 = rcs1;
512 spin_unlock_irqrestore(&ak4114->lock, _flags); 576 spin_unlock_irqrestore(&ak4114->lock, _flags);
513 577
514 if (rcs0 & AK4114_PAR) 578 ak4114_notify(ak4114, rcs0, rcs1, c0, c1);
515 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[0]->id);
516 if (rcs0 & AK4114_V)
517 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[1]->id);
518 if (rcs1 & AK4114_CCRC)
519 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[2]->id);
520 if (rcs1 & AK4114_QCRC)
521 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[3]->id);
522
523 /* rate change */
524 if (c1 & 0xf0)
525 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[4]->id);
526
527 if ((c0 & AK4114_PEM) | (c0 & AK4114_CINT))
528 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[9]->id);
529 if (c0 & AK4114_QINT)
530 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[10]->id);
531
532 if (c0 & AK4114_AUDION)
533 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[11]->id);
534 if (c0 & AK4114_AUTO)
535 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[12]->id);
536 if (c0 & AK4114_DTSCD)
537 snd_ctl_notify(ak4114->card, SNDRV_CTL_EVENT_MASK_VALUE, &ak4114->kctls[13]->id);
538
539 if (ak4114->change_callback && (c0 | c1) != 0) 579 if (ak4114->change_callback && (c0 | c1) != 0)
540 ak4114->change_callback(ak4114, c0, c1); 580 ak4114->change_callback(ak4114, c0, c1);
541 581
@@ -558,9 +598,9 @@ static void ak4114_stats(struct work_struct *work)
558{ 598{
559 struct ak4114 *chip = container_of(work, struct ak4114, work.work); 599 struct ak4114 *chip = container_of(work, struct ak4114, work.work);
560 600
561 if (chip->init) 601 if (!chip->init)
562 return; 602 snd_ak4114_check_rate_and_errors(chip, 0);
563 snd_ak4114_check_rate_and_errors(chip, 0); 603
564 schedule_delayed_work(&chip->work, HZ / 10); 604 schedule_delayed_work(&chip->work, HZ / 10);
565} 605}
566 606
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig
index 4e3a9729f569..cf3803cd579c 100644
--- a/sound/isa/Kconfig
+++ b/sound/isa/Kconfig
@@ -358,12 +358,21 @@ config SND_SBAWE
358config SND_SB16_CSP 358config SND_SB16_CSP
359 bool "Sound Blaster 16/AWE CSP support" 359 bool "Sound Blaster 16/AWE CSP support"
360 depends on (SND_SB16 || SND_SBAWE) && (BROKEN || !PPC) 360 depends on (SND_SB16 || SND_SBAWE) && (BROKEN || !PPC)
361 select FW_LOADER 361 select FW_LOADER if !SND_SB16_CSP_FIRMWARE_IN_KERNEL
362 help 362 help
363 Say Y here to include support for the CSP core. This special 363 Say Y here to include support for the CSP core. This special
364 coprocessor can do variable tasks like various compression and 364 coprocessor can do variable tasks like various compression and
365 decompression algorithms. 365 decompression algorithms.
366 366
367config SND_SB16_CSP_FIRMWARE_IN_KERNEL
368 bool "In-kernel firmware for SB16 CSP"
369 depends on SND_SB16_CSP
370 default y
371 help
372 Say Y here to include the static firmware built in the kernel
373 for the SB16 CSP controller. If you choose N here, you need
374 to install the firmware files from the alsa-firmware package.
375
367config SND_SGALAXY 376config SND_SGALAXY
368 tristate "Aztech Sound Galaxy" 377 tristate "Aztech Sound Galaxy"
369 depends on SND 378 depends on SND
@@ -391,7 +400,7 @@ config SND_SSCAPE
391config SND_WAVEFRONT 400config SND_WAVEFRONT
392 tristate "Turtle Beach Maui,Tropez,Tropez+ (Wavefront)" 401 tristate "Turtle Beach Maui,Tropez,Tropez+ (Wavefront)"
393 depends on SND 402 depends on SND
394 select FW_LOADER 403 select FW_LOADER if !SND_WAVEFRONT_FIRMWARE_IN_KERNEL
395 select SND_OPL3_LIB 404 select SND_OPL3_LIB
396 select SND_MPU401_UART 405 select SND_MPU401_UART
397 select SND_CS4231_LIB 406 select SND_CS4231_LIB
@@ -402,4 +411,13 @@ config SND_WAVEFRONT
402 To compile this driver as a module, choose M here: the module 411 To compile this driver as a module, choose M here: the module
403 will be called snd-wavefront. 412 will be called snd-wavefront.
404 413
414config SND_WAVEFRONT_FIRMWARE_IN_KERNEL
415 bool "In-kernel firmware for Wavefront"
416 depends on SND_WAVEFRONT
417 default y
418 help
419 Say Y here to include the static firmware built in the kernel
420 for the Wavefront driver. If you choose N here, you need to
421 install the firmware files from the alsa-firmware package.
422
405endmenu 423endmenu
diff --git a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c
index 59034507175b..fc88a31da6f5 100644
--- a/sound/isa/ad1816a/ad1816a.c
+++ b/sound/isa/ad1816a/ad1816a.c
@@ -129,8 +129,8 @@ static int __devinit snd_card_ad1816a_pnp(int dev, struct snd_card_ad1816a *acar
129 } 129 }
130 acard->devmpu = pnp_request_card_device(card, id->devs[1].id, NULL); 130 acard->devmpu = pnp_request_card_device(card, id->devs[1].id, NULL);
131 if (acard->devmpu == NULL) { 131 if (acard->devmpu == NULL) {
132 kfree(cfg); 132 mpu_port[dev] = -1;
133 return -EBUSY; 133 snd_printk(KERN_WARNING PFX "MPU401 device busy, skipping.\n");
134 } 134 }
135 135
136 pdev = acard->dev; 136 pdev = acard->dev;
@@ -162,6 +162,10 @@ static int __devinit snd_card_ad1816a_pnp(int dev, struct snd_card_ad1816a *acar
162 dma2[dev] = pnp_dma(pdev, 1); 162 dma2[dev] = pnp_dma(pdev, 1);
163 irq[dev] = pnp_irq(pdev, 0); 163 irq[dev] = pnp_irq(pdev, 0);
164 164
165 if (acard->devmpu == NULL) {
166 kfree(cfg);
167 return 0;
168 }
165 pdev = acard->devmpu; 169 pdev = acard->devmpu;
166 pnp_init_resource_table(cfg); 170 pnp_init_resource_table(cfg);
167 171
diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c
index 74e501dea8b1..d09a7fa86545 100644
--- a/sound/isa/ad1848/ad1848.c
+++ b/sound/isa/ad1848/ad1848.c
@@ -24,7 +24,7 @@
24#include <sound/driver.h> 24#include <sound/driver.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/platform_device.h> 27#include <linux/isa.h>
28#include <linux/time.h> 28#include <linux/time.h>
29#include <linux/wait.h> 29#include <linux/wait.h>
30#include <linux/moduleparam.h> 30#include <linux/moduleparam.h>
@@ -32,8 +32,11 @@
32#include <sound/ad1848.h> 32#include <sound/ad1848.h>
33#include <sound/initval.h> 33#include <sound/initval.h>
34 34
35#define CRD_NAME "Generic AD1848/AD1847/CS4248"
36#define DEV_NAME "ad1848"
37
38MODULE_DESCRIPTION(CRD_NAME);
35MODULE_AUTHOR("Tugrul Galatali <galatalt@stuy.edu>, Jaroslav Kysela <perex@suse.cz>"); 39MODULE_AUTHOR("Tugrul Galatali <galatalt@stuy.edu>, Jaroslav Kysela <perex@suse.cz>");
36MODULE_DESCRIPTION("AD1848/AD1847/CS4248");
37MODULE_LICENSE("GPL"); 40MODULE_LICENSE("GPL");
38MODULE_SUPPORTED_DEVICE("{{Analog Devices,AD1848}," 41MODULE_SUPPORTED_DEVICE("{{Analog Devices,AD1848},"
39 "{Analog Devices,AD1847}," 42 "{Analog Devices,AD1847},"
@@ -48,95 +51,98 @@ static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
48static int thinkpad[SNDRV_CARDS]; /* Thinkpad special case */ 51static int thinkpad[SNDRV_CARDS]; /* Thinkpad special case */
49 52
50module_param_array(index, int, NULL, 0444); 53module_param_array(index, int, NULL, 0444);
51MODULE_PARM_DESC(index, "Index value for AD1848 soundcard."); 54MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard.");
52module_param_array(id, charp, NULL, 0444); 55module_param_array(id, charp, NULL, 0444);
53MODULE_PARM_DESC(id, "ID string for AD1848 soundcard."); 56MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard.");
54module_param_array(enable, bool, NULL, 0444); 57module_param_array(enable, bool, NULL, 0444);
55MODULE_PARM_DESC(enable, "Enable AD1848 soundcard."); 58MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
56module_param_array(port, long, NULL, 0444); 59module_param_array(port, long, NULL, 0444);
57MODULE_PARM_DESC(port, "Port # for AD1848 driver."); 60MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
58module_param_array(irq, int, NULL, 0444); 61module_param_array(irq, int, NULL, 0444);
59MODULE_PARM_DESC(irq, "IRQ # for AD1848 driver."); 62MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
60module_param_array(dma1, int, NULL, 0444); 63module_param_array(dma1, int, NULL, 0444);
61MODULE_PARM_DESC(dma1, "DMA1 # for AD1848 driver."); 64MODULE_PARM_DESC(dma1, "DMA1 # for " CRD_NAME " driver.");
62module_param_array(thinkpad, bool, NULL, 0444); 65module_param_array(thinkpad, bool, NULL, 0444);
63MODULE_PARM_DESC(thinkpad, "Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series."); 66MODULE_PARM_DESC(thinkpad, "Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series.");
64 67
65static struct platform_device *devices[SNDRV_CARDS]; 68static int __devinit snd_ad1848_match(struct device *dev, unsigned int n)
69{
70 if (!enable[n])
71 return 0;
66 72
73 if (port[n] == SNDRV_AUTO_PORT) {
74 snd_printk(KERN_ERR "%s: please specify port\n", dev->bus_id);
75 return 0;
76 }
77 if (irq[n] == SNDRV_AUTO_IRQ) {
78 snd_printk(KERN_ERR "%s: please specify irq\n", dev->bus_id);
79 return 0;
80 }
81 if (dma1[n] == SNDRV_AUTO_DMA) {
82 snd_printk(KERN_ERR "%s: please specify dma1\n", dev->bus_id);
83 return 0;
84 }
85 return 1;
86}
67 87
68static int __devinit snd_ad1848_probe(struct platform_device *pdev) 88static int __devinit snd_ad1848_probe(struct device *dev, unsigned int n)
69{ 89{
70 int dev = pdev->id;
71 struct snd_card *card; 90 struct snd_card *card;
72 struct snd_ad1848 *chip; 91 struct snd_ad1848 *chip;
73 struct snd_pcm *pcm; 92 struct snd_pcm *pcm;
74 int err; 93 int error;
75 94
76 if (port[dev] == SNDRV_AUTO_PORT) { 95 card = snd_card_new(index[n], id[n], THIS_MODULE, 0);
77 snd_printk(KERN_ERR "ad1848: specify port\n"); 96 if (!card)
78 return -EINVAL; 97 return -EINVAL;
79 }
80 if (irq[dev] == SNDRV_AUTO_IRQ) {
81 snd_printk(KERN_ERR "ad1848: specify irq\n");
82 return -EINVAL;
83 }
84 if (dma1[dev] == SNDRV_AUTO_DMA) {
85 snd_printk(KERN_ERR "ad1848: specify dma1\n");
86 return -EINVAL;
87 }
88 98
89 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 99 error = snd_ad1848_create(card, port[n], irq[n], dma1[n],
90 if (card == NULL) 100 thinkpad[n] ? AD1848_HW_THINKPAD : AD1848_HW_DETECT, &chip);
91 return -ENOMEM; 101 if (error < 0)
102 goto out;
92 103
93 if ((err = snd_ad1848_create(card, port[dev],
94 irq[dev],
95 dma1[dev],
96 thinkpad[dev] ? AD1848_HW_THINKPAD : AD1848_HW_DETECT,
97 &chip)) < 0)
98 goto _err;
99 card->private_data = chip; 104 card->private_data = chip;
100 105
101 if ((err = snd_ad1848_pcm(chip, 0, &pcm)) < 0) 106 error = snd_ad1848_pcm(chip, 0, &pcm);
102 goto _err; 107 if (error < 0)
108 goto out;
103 109
104 if ((err = snd_ad1848_mixer(chip)) < 0) 110 error = snd_ad1848_mixer(chip);
105 goto _err; 111 if (error < 0)
112 goto out;
106 113
107 strcpy(card->driver, "AD1848"); 114 strcpy(card->driver, "AD1848");
108 strcpy(card->shortname, pcm->name); 115 strcpy(card->shortname, pcm->name);
109 116
110 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", 117 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
111 pcm->name, chip->port, irq[dev], dma1[dev]); 118 pcm->name, chip->port, irq[n], dma1[n]);
112 119 if (thinkpad[n])
113 if (thinkpad[dev])
114 strcat(card->longname, " [Thinkpad]"); 120 strcat(card->longname, " [Thinkpad]");
115 121
116 snd_card_set_dev(card, &pdev->dev); 122 snd_card_set_dev(card, dev);
117 123
118 if ((err = snd_card_register(card)) < 0) 124 error = snd_card_register(card);
119 goto _err; 125 if (error < 0)
126 goto out;
120 127
121 platform_set_drvdata(pdev, card); 128 dev_set_drvdata(dev, card);
122 return 0; 129 return 0;
123 130
124 _err: 131out: snd_card_free(card);
125 snd_card_free(card); 132 return error;
126 return err;
127} 133}
128 134
129static int __devexit snd_ad1848_remove(struct platform_device *devptr) 135static int __devexit snd_ad1848_remove(struct device *dev, unsigned int n)
130{ 136{
131 snd_card_free(platform_get_drvdata(devptr)); 137 snd_card_free(dev_get_drvdata(dev));
132 platform_set_drvdata(devptr, NULL); 138 dev_set_drvdata(dev, NULL);
133 return 0; 139 return 0;
134} 140}
135 141
136#ifdef CONFIG_PM 142#ifdef CONFIG_PM
137static int snd_ad1848_suspend(struct platform_device *pdev, pm_message_t state) 143static int snd_ad1848_suspend(struct device *dev, unsigned int n, pm_message_t state)
138{ 144{
139 struct snd_card *card = platform_get_drvdata(pdev); 145 struct snd_card *card = dev_get_drvdata(dev);
140 struct snd_ad1848 *chip = card->private_data; 146 struct snd_ad1848 *chip = card->private_data;
141 147
142 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 148 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
@@ -144,9 +150,9 @@ static int snd_ad1848_suspend(struct platform_device *pdev, pm_message_t state)
144 return 0; 150 return 0;
145} 151}
146 152
147static int snd_ad1848_resume(struct platform_device *pdev) 153static int snd_ad1848_resume(struct device *dev, unsigned int n)
148{ 154{
149 struct snd_card *card = platform_get_drvdata(pdev); 155 struct snd_card *card = dev_get_drvdata(dev);
150 struct snd_ad1848 *chip = card->private_data; 156 struct snd_ad1848 *chip = card->private_data;
151 157
152 chip->resume(chip); 158 chip->resume(chip);
@@ -155,9 +161,8 @@ static int snd_ad1848_resume(struct platform_device *pdev)
155} 161}
156#endif 162#endif
157 163
158#define SND_AD1848_DRIVER "snd_ad1848" 164static struct isa_driver snd_ad1848_driver = {
159 165 .match = snd_ad1848_match,
160static struct platform_driver snd_ad1848_driver = {
161 .probe = snd_ad1848_probe, 166 .probe = snd_ad1848_probe,
162 .remove = __devexit_p(snd_ad1848_remove), 167 .remove = __devexit_p(snd_ad1848_remove),
163#ifdef CONFIG_PM 168#ifdef CONFIG_PM
@@ -165,57 +170,19 @@ static struct platform_driver snd_ad1848_driver = {
165 .resume = snd_ad1848_resume, 170 .resume = snd_ad1848_resume,
166#endif 171#endif
167 .driver = { 172 .driver = {
168 .name = SND_AD1848_DRIVER 173 .name = DEV_NAME
169 }, 174 }
170}; 175};
171 176
172static void __init_or_module snd_ad1848_unregister_all(void)
173{
174 int i;
175
176 for (i = 0; i < ARRAY_SIZE(devices); ++i)
177 platform_device_unregister(devices[i]);
178 platform_driver_unregister(&snd_ad1848_driver);
179}
180
181static int __init alsa_card_ad1848_init(void) 177static int __init alsa_card_ad1848_init(void)
182{ 178{
183 int i, cards, err; 179 return isa_register_driver(&snd_ad1848_driver, SNDRV_CARDS);
184
185 err = platform_driver_register(&snd_ad1848_driver);
186 if (err < 0)
187 return err;
188
189 cards = 0;
190 for (i = 0; i < SNDRV_CARDS; i++) {
191 struct platform_device *device;
192 if (! enable[i])
193 continue;
194 device = platform_device_register_simple(SND_AD1848_DRIVER,
195 i, NULL, 0);
196 if (IS_ERR(device))
197 continue;
198 if (!platform_get_drvdata(device)) {
199 platform_device_unregister(device);
200 continue;
201 }
202 devices[i] = device;
203 cards++;
204 }
205 if (!cards) {
206#ifdef MODULE
207 printk(KERN_ERR "AD1848 soundcard not found or device busy\n");
208#endif
209 snd_ad1848_unregister_all();
210 return -ENODEV;
211 }
212 return 0;
213} 180}
214 181
215static void __exit alsa_card_ad1848_exit(void) 182static void __exit alsa_card_ad1848_exit(void)
216{ 183{
217 snd_ad1848_unregister_all(); 184 isa_unregister_driver(&snd_ad1848_driver);
218} 185}
219 186
220module_init(alsa_card_ad1848_init) 187module_init(alsa_card_ad1848_init);
221module_exit(alsa_card_ad1848_exit) 188module_exit(alsa_card_ad1848_exit);
diff --git a/sound/isa/adlib.c b/sound/isa/adlib.c
index 1124344ed948..d68720724c91 100644
--- a/sound/isa/adlib.c
+++ b/sound/isa/adlib.c
@@ -5,13 +5,13 @@
5#include <sound/driver.h> 5#include <sound/driver.h>
6#include <linux/kernel.h> 6#include <linux/kernel.h>
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/platform_device.h> 8#include <linux/isa.h>
9#include <sound/core.h> 9#include <sound/core.h>
10#include <sound/initval.h> 10#include <sound/initval.h>
11#include <sound/opl3.h> 11#include <sound/opl3.h>
12 12
13#define CRD_NAME "AdLib FM" 13#define CRD_NAME "AdLib FM"
14#define DRV_NAME "snd_adlib" 14#define DEV_NAME "adlib"
15 15
16MODULE_DESCRIPTION(CRD_NAME); 16MODULE_DESCRIPTION(CRD_NAME);
17MODULE_AUTHOR("Rene Herman"); 17MODULE_AUTHOR("Rene Herman");
@@ -31,133 +31,99 @@ MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
31module_param_array(port, long, NULL, 0444); 31module_param_array(port, long, NULL, 0444);
32MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver."); 32MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
33 33
34static struct platform_device *devices[SNDRV_CARDS]; 34static int __devinit snd_adlib_match(struct device *dev, unsigned int n)
35{
36 if (!enable[n])
37 return 0;
38
39 if (port[n] == SNDRV_AUTO_PORT) {
40 snd_printk(KERN_ERR "%s: please specify port\n", dev->bus_id);
41 return 0;
42 }
43 return 1;
44}
35 45
36static void snd_adlib_free(struct snd_card *card) 46static void snd_adlib_free(struct snd_card *card)
37{ 47{
38 release_and_free_resource(card->private_data); 48 release_and_free_resource(card->private_data);
39} 49}
40 50
41static int __devinit snd_adlib_probe(struct platform_device *device) 51static int __devinit snd_adlib_probe(struct device *dev, unsigned int n)
42{ 52{
43 struct snd_card *card; 53 struct snd_card *card;
44 struct snd_opl3 *opl3; 54 struct snd_opl3 *opl3;
55 int error;
45 56
46 int error, i = device->id; 57 card = snd_card_new(index[n], id[n], THIS_MODULE, 0);
47
48 if (port[i] == SNDRV_AUTO_PORT) {
49 snd_printk(KERN_ERR DRV_NAME ": please specify port\n");
50 error = -EINVAL;
51 goto out0;
52 }
53
54 card = snd_card_new(index[i], id[i], THIS_MODULE, 0);
55 if (!card) { 58 if (!card) {
56 snd_printk(KERN_ERR DRV_NAME ": could not create card\n"); 59 snd_printk(KERN_ERR "%s: could not create card\n", dev->bus_id);
57 error = -EINVAL; 60 return -EINVAL;
58 goto out0;
59 } 61 }
60 62
61 card->private_data = request_region(port[i], 4, CRD_NAME); 63 card->private_data = request_region(port[n], 4, CRD_NAME);
62 if (!card->private_data) { 64 if (!card->private_data) {
63 snd_printk(KERN_ERR DRV_NAME ": could not grab ports\n"); 65 snd_printk(KERN_ERR "%s: could not grab ports\n", dev->bus_id);
64 error = -EBUSY; 66 error = -EBUSY;
65 goto out1; 67 goto out;
66 } 68 }
67 card->private_free = snd_adlib_free; 69 card->private_free = snd_adlib_free;
68 70
69 error = snd_opl3_create(card, port[i], port[i] + 2, OPL3_HW_AUTO, 1, &opl3); 71 strcpy(card->driver, DEV_NAME);
72 strcpy(card->shortname, CRD_NAME);
73 sprintf(card->longname, CRD_NAME " at %#lx", port[n]);
74
75 error = snd_opl3_create(card, port[n], port[n] + 2, OPL3_HW_AUTO, 1, &opl3);
70 if (error < 0) { 76 if (error < 0) {
71 snd_printk(KERN_ERR DRV_NAME ": could not create OPL\n"); 77 snd_printk(KERN_ERR "%s: could not create OPL\n", dev->bus_id);
72 goto out1; 78 goto out;
73 } 79 }
74 80
75 error = snd_opl3_hwdep_new(opl3, 0, 0, NULL); 81 error = snd_opl3_hwdep_new(opl3, 0, 0, NULL);
76 if (error < 0) { 82 if (error < 0) {
77 snd_printk(KERN_ERR DRV_NAME ": could not create FM\n"); 83 snd_printk(KERN_ERR "%s: could not create FM\n", dev->bus_id);
78 goto out1; 84 goto out;
79 } 85 }
80 86
81 strcpy(card->driver, DRV_NAME); 87 snd_card_set_dev(card, dev);
82 strcpy(card->shortname, CRD_NAME);
83 sprintf(card->longname, CRD_NAME " at %#lx", port[i]);
84
85 snd_card_set_dev(card, &device->dev);
86 88
87 error = snd_card_register(card); 89 error = snd_card_register(card);
88 if (error < 0) { 90 if (error < 0) {
89 snd_printk(KERN_ERR DRV_NAME ": could not register card\n"); 91 snd_printk(KERN_ERR "%s: could not register card\n", dev->bus_id);
90 goto out1; 92 goto out;
91 } 93 }
92 94
93 platform_set_drvdata(device, card); 95 dev_set_drvdata(dev, card);
94 return 0; 96 return 0;
95 97
96out1: snd_card_free(card); 98out: snd_card_free(card);
97out0: return error; 99 return error;
98} 100}
99 101
100static int __devexit snd_adlib_remove(struct platform_device *device) 102static int __devexit snd_adlib_remove(struct device *dev, unsigned int n)
101{ 103{
102 snd_card_free(platform_get_drvdata(device)); 104 snd_card_free(dev_get_drvdata(dev));
103 platform_set_drvdata(device, NULL); 105 dev_set_drvdata(dev, NULL);
104 return 0; 106 return 0;
105} 107}
106 108
107static struct platform_driver snd_adlib_driver = { 109static struct isa_driver snd_adlib_driver = {
110 .match = snd_adlib_match,
108 .probe = snd_adlib_probe, 111 .probe = snd_adlib_probe,
109 .remove = __devexit_p(snd_adlib_remove), 112 .remove = __devexit_p(snd_adlib_remove),
110 113
111 .driver = { 114 .driver = {
112 .name = DRV_NAME 115 .name = DEV_NAME
113 } 116 }
114}; 117};
115 118
116static int __init alsa_card_adlib_init(void) 119static int __init alsa_card_adlib_init(void)
117{ 120{
118 int i, cards; 121 return isa_register_driver(&snd_adlib_driver, SNDRV_CARDS);
119
120 if (platform_driver_register(&snd_adlib_driver) < 0) {
121 snd_printk(KERN_ERR DRV_NAME ": could not register driver\n");
122 return -ENODEV;
123 }
124
125 for (cards = 0, i = 0; i < SNDRV_CARDS; i++) {
126 struct platform_device *device;
127
128 if (!enable[i])
129 continue;
130
131 device = platform_device_register_simple(DRV_NAME, i, NULL, 0);
132 if (IS_ERR(device))
133 continue;
134
135 if (!platform_get_drvdata(device)) {
136 platform_device_unregister(device);
137 continue;
138 }
139
140 devices[i] = device;
141 cards++;
142 }
143
144 if (!cards) {
145#ifdef MODULE
146 printk(KERN_ERR CRD_NAME " soundcard not found or device busy\n");
147#endif
148 platform_driver_unregister(&snd_adlib_driver);
149 return -ENODEV;
150 }
151 return 0;
152} 122}
153 123
154static void __exit alsa_card_adlib_exit(void) 124static void __exit alsa_card_adlib_exit(void)
155{ 125{
156 int i; 126 isa_unregister_driver(&snd_adlib_driver);
157
158 for (i = 0; i < SNDRV_CARDS; i++)
159 platform_device_unregister(devices[i]);
160 platform_driver_unregister(&snd_adlib_driver);
161} 127}
162 128
163module_init(alsa_card_adlib_init); 129module_init(alsa_card_adlib_init);
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c
index c09a8009d2fa..214d65d94c45 100644
--- a/sound/isa/cmi8330.c
+++ b/sound/isa/cmi8330.c
@@ -46,7 +46,7 @@
46#include <sound/driver.h> 46#include <sound/driver.h>
47#include <linux/init.h> 47#include <linux/init.h>
48#include <linux/err.h> 48#include <linux/err.h>
49#include <linux/platform_device.h> 49#include <linux/isa.h>
50#include <linux/slab.h> 50#include <linux/slab.h>
51#include <linux/pnp.h> 51#include <linux/pnp.h>
52#include <linux/moduleparam.h> 52#include <linux/moduleparam.h>
@@ -108,7 +108,6 @@ MODULE_PARM_DESC(wssirq, "IRQ # for CMI8330 WSS driver.");
108module_param_array(wssdma, int, NULL, 0444); 108module_param_array(wssdma, int, NULL, 0444);
109MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver."); 109MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver.");
110 110
111static struct platform_device *platform_devices[SNDRV_CARDS];
112#ifdef CONFIG_PNP 111#ifdef CONFIG_PNP
113static int pnp_registered; 112static int pnp_registered;
114#endif 113#endif
@@ -547,70 +546,78 @@ static int __devinit snd_cmi8330_probe(struct snd_card *card, int dev)
547 return snd_card_register(card); 546 return snd_card_register(card);
548} 547}
549 548
550static int __devinit snd_cmi8330_nonpnp_probe(struct platform_device *pdev) 549static int __devinit snd_cmi8330_isa_match(struct device *pdev,
550 unsigned int dev)
551{ 551{
552 struct snd_card *card; 552 if (!enable[dev] || is_isapnp_selected(dev))
553 int err; 553 return 0;
554 int dev = pdev->id;
555
556 if (wssport[dev] == SNDRV_AUTO_PORT) { 554 if (wssport[dev] == SNDRV_AUTO_PORT) {
557 snd_printk(KERN_ERR PFX "specify wssport\n"); 555 snd_printk(KERN_ERR PFX "specify wssport\n");
558 return -EINVAL; 556 return 0;
559 } 557 }
560 if (sbport[dev] == SNDRV_AUTO_PORT) { 558 if (sbport[dev] == SNDRV_AUTO_PORT) {
561 snd_printk(KERN_ERR PFX "specify sbport\n"); 559 snd_printk(KERN_ERR PFX "specify sbport\n");
562 return -EINVAL; 560 return 0;
563 } 561 }
562 return 1;
563}
564
565static int __devinit snd_cmi8330_isa_probe(struct device *pdev,
566 unsigned int dev)
567{
568 struct snd_card *card;
569 int err;
564 570
565 card = snd_cmi8330_card_new(dev); 571 card = snd_cmi8330_card_new(dev);
566 if (! card) 572 if (! card)
567 return -ENOMEM; 573 return -ENOMEM;
568 snd_card_set_dev(card, &pdev->dev); 574 snd_card_set_dev(card, pdev);
569 if ((err = snd_cmi8330_probe(card, dev)) < 0) { 575 if ((err = snd_cmi8330_probe(card, dev)) < 0) {
570 snd_card_free(card); 576 snd_card_free(card);
571 return err; 577 return err;
572 } 578 }
573 platform_set_drvdata(pdev, card); 579 dev_set_drvdata(pdev, card);
574 return 0; 580 return 0;
575} 581}
576 582
577static int __devexit snd_cmi8330_nonpnp_remove(struct platform_device *devptr) 583static int __devexit snd_cmi8330_isa_remove(struct device *devptr,
584 unsigned int dev)
578{ 585{
579 snd_card_free(platform_get_drvdata(devptr)); 586 snd_card_free(dev_get_drvdata(devptr));
580 platform_set_drvdata(devptr, NULL); 587 dev_set_drvdata(devptr, NULL);
581 return 0; 588 return 0;
582} 589}
583 590
584#ifdef CONFIG_PM 591#ifdef CONFIG_PM
585static int snd_cmi8330_nonpnp_suspend(struct platform_device *dev, pm_message_t state) 592static int snd_cmi8330_isa_suspend(struct device *dev, unsigned int n,
593 pm_message_t state)
586{ 594{
587 return snd_cmi8330_suspend(platform_get_drvdata(dev)); 595 return snd_cmi8330_suspend(dev_get_drvdata(dev));
588} 596}
589 597
590static int snd_cmi8330_nonpnp_resume(struct platform_device *dev) 598static int snd_cmi8330_isa_resume(struct device *dev, unsigned int n)
591{ 599{
592 return snd_cmi8330_resume(platform_get_drvdata(dev)); 600 return snd_cmi8330_resume(dev_get_drvdata(dev));
593} 601}
594#endif 602#endif
595 603
596#define CMI8330_DRIVER "snd_cmi8330" 604#define DEV_NAME "cmi8330"
597 605
598static struct platform_driver snd_cmi8330_driver = { 606static struct isa_driver snd_cmi8330_driver = {
599 .probe = snd_cmi8330_nonpnp_probe, 607 .match = snd_cmi8330_isa_match,
600 .remove = __devexit_p(snd_cmi8330_nonpnp_remove), 608 .probe = snd_cmi8330_isa_probe,
609 .remove = __devexit_p(snd_cmi8330_isa_remove),
601#ifdef CONFIG_PM 610#ifdef CONFIG_PM
602 .suspend = snd_cmi8330_nonpnp_suspend, 611 .suspend = snd_cmi8330_isa_suspend,
603 .resume = snd_cmi8330_nonpnp_resume, 612 .resume = snd_cmi8330_isa_resume,
604#endif 613#endif
605 .driver = { 614 .driver = {
606 .name = CMI8330_DRIVER 615 .name = DEV_NAME
607 }, 616 },
608}; 617};
609 618
610 619
611#ifdef CONFIG_PNP 620#ifdef CONFIG_PNP
612static unsigned int __devinitdata cmi8330_pnp_devices;
613
614static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *pcard, 621static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *pcard,
615 const struct pnp_card_device_id *pid) 622 const struct pnp_card_device_id *pid)
616{ 623{
@@ -640,7 +647,6 @@ static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *pcard,
640 } 647 }
641 pnp_set_card_drvdata(pcard, card); 648 pnp_set_card_drvdata(pcard, card);
642 dev++; 649 dev++;
643 cmi8330_pnp_devices++;
644 return 0; 650 return 0;
645} 651}
646 652
@@ -675,63 +681,28 @@ static struct pnp_card_driver cmi8330_pnpc_driver = {
675}; 681};
676#endif /* CONFIG_PNP */ 682#endif /* CONFIG_PNP */
677 683
678static void __init_or_module snd_cmi8330_unregister_all(void)
679{
680 int i;
681
682#ifdef CONFIG_PNP
683 if (pnp_registered)
684 pnp_unregister_card_driver(&cmi8330_pnpc_driver);
685#endif
686 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
687 platform_device_unregister(platform_devices[i]);
688 platform_driver_unregister(&snd_cmi8330_driver);
689}
690
691static int __init alsa_card_cmi8330_init(void) 684static int __init alsa_card_cmi8330_init(void)
692{ 685{
693 int i, err, cards = 0; 686 int err;
694 687
695 if ((err = platform_driver_register(&snd_cmi8330_driver)) < 0) 688 err = isa_register_driver(&snd_cmi8330_driver, SNDRV_CARDS);
689 if (err < 0)
696 return err; 690 return err;
697
698 for (i = 0; i < SNDRV_CARDS; i++) {
699 struct platform_device *device;
700 if (! enable[i] || is_isapnp_selected(i))
701 continue;
702 device = platform_device_register_simple(CMI8330_DRIVER,
703 i, NULL, 0);
704 if (IS_ERR(device))
705 continue;
706 if (!platform_get_drvdata(device)) {
707 platform_device_unregister(device);
708 continue;
709 }
710 platform_devices[i] = device;
711 cards++;
712 }
713
714#ifdef CONFIG_PNP 691#ifdef CONFIG_PNP
715 err = pnp_register_card_driver(&cmi8330_pnpc_driver); 692 err = pnp_register_card_driver(&cmi8330_pnpc_driver);
716 if (!err) { 693 if (!err)
717 pnp_registered = 1; 694 pnp_registered = 1;
718 cards += cmi8330_pnp_devices;
719 }
720#endif 695#endif
721
722 if (!cards) {
723#ifdef MODULE
724 snd_printk(KERN_ERR "CMI8330 not found or device busy\n");
725#endif
726 snd_cmi8330_unregister_all();
727 return -ENODEV;
728 }
729 return 0; 696 return 0;
730} 697}
731 698
732static void __exit alsa_card_cmi8330_exit(void) 699static void __exit alsa_card_cmi8330_exit(void)
733{ 700{
734 snd_cmi8330_unregister_all(); 701#ifdef CONFIG_PNP
702 if (pnp_registered)
703 pnp_unregister_card_driver(&cmi8330_pnpc_driver);
704#endif
705 isa_unregister_driver(&snd_cmi8330_driver);
735} 706}
736 707
737module_init(alsa_card_cmi8330_init) 708module_init(alsa_card_cmi8330_init)
diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c
index 696a5c86bcfa..ac4041134150 100644
--- a/sound/isa/cs423x/cs4231.c
+++ b/sound/isa/cs423x/cs4231.c
@@ -23,7 +23,7 @@
23#include <sound/driver.h> 23#include <sound/driver.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/err.h> 25#include <linux/err.h>
26#include <linux/platform_device.h> 26#include <linux/isa.h>
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/wait.h> 28#include <linux/wait.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
@@ -32,8 +32,11 @@
32#include <sound/mpu401.h> 32#include <sound/mpu401.h>
33#include <sound/initval.h> 33#include <sound/initval.h>
34 34
35#define CRD_NAME "Generic CS4231"
36#define DEV_NAME "cs4231"
37
38MODULE_DESCRIPTION(CRD_NAME);
35MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 39MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
36MODULE_DESCRIPTION("Generic CS4231");
37MODULE_LICENSE("GPL"); 40MODULE_LICENSE("GPL");
38MODULE_SUPPORTED_DEVICE("{{Crystal Semiconductors,CS4231}}"); 41MODULE_SUPPORTED_DEVICE("{{Crystal Semiconductors,CS4231}}");
39 42
@@ -48,132 +51,136 @@ static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
48static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */ 51static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3,5,6,7 */
49 52
50module_param_array(index, int, NULL, 0444); 53module_param_array(index, int, NULL, 0444);
51MODULE_PARM_DESC(index, "Index value for CS4231 soundcard."); 54MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard.");
52module_param_array(id, charp, NULL, 0444); 55module_param_array(id, charp, NULL, 0444);
53MODULE_PARM_DESC(id, "ID string for CS4231 soundcard."); 56MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard.");
54module_param_array(enable, bool, NULL, 0444); 57module_param_array(enable, bool, NULL, 0444);
55MODULE_PARM_DESC(enable, "Enable CS4231 soundcard."); 58MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
56module_param_array(port, long, NULL, 0444); 59module_param_array(port, long, NULL, 0444);
57MODULE_PARM_DESC(port, "Port # for CS4231 driver."); 60MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
58module_param_array(mpu_port, long, NULL, 0444); 61module_param_array(mpu_port, long, NULL, 0444);
59MODULE_PARM_DESC(mpu_port, "MPU-401 port # for CS4231 driver."); 62MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " CRD_NAME " driver.");
60module_param_array(irq, int, NULL, 0444); 63module_param_array(irq, int, NULL, 0444);
61MODULE_PARM_DESC(irq, "IRQ # for CS4231 driver."); 64MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
62module_param_array(mpu_irq, int, NULL, 0444); 65module_param_array(mpu_irq, int, NULL, 0444);
63MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for CS4231 driver."); 66MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " CRD_NAME " driver.");
64module_param_array(dma1, int, NULL, 0444); 67module_param_array(dma1, int, NULL, 0444);
65MODULE_PARM_DESC(dma1, "DMA1 # for CS4231 driver."); 68MODULE_PARM_DESC(dma1, "DMA1 # for " CRD_NAME " driver.");
66module_param_array(dma2, int, NULL, 0444); 69module_param_array(dma2, int, NULL, 0444);
67MODULE_PARM_DESC(dma2, "DMA2 # for CS4231 driver."); 70MODULE_PARM_DESC(dma2, "DMA2 # for " CRD_NAME " driver.");
68 71
69static struct platform_device *devices[SNDRV_CARDS]; 72static int __devinit snd_cs4231_match(struct device *dev, unsigned int n)
73{
74 if (!enable[n])
75 return 0;
70 76
77 if (port[n] == SNDRV_AUTO_PORT) {
78 snd_printk(KERN_ERR "%s: please specify port\n", dev->bus_id);
79 return 0;
80 }
81 if (irq[n] == SNDRV_AUTO_IRQ) {
82 snd_printk(KERN_ERR "%s: please specify irq\n", dev->bus_id);
83 return 0;
84 }
85 if (dma1[n] == SNDRV_AUTO_DMA) {
86 snd_printk(KERN_ERR "%s: please specify dma1\n", dev->bus_id);
87 return 0;
88 }
89 return 1;
90}
71 91
72static int __init snd_cs4231_probe(struct platform_device *pdev) 92static int __devinit snd_cs4231_probe(struct device *dev, unsigned int n)
73{ 93{
74 int dev = pdev->id;
75 struct snd_card *card; 94 struct snd_card *card;
76 struct snd_pcm *pcm;
77 struct snd_cs4231 *chip; 95 struct snd_cs4231 *chip;
78 int err; 96 struct snd_pcm *pcm;
97 int error;
79 98
80 if (port[dev] == SNDRV_AUTO_PORT) { 99 card = snd_card_new(index[n], id[n], THIS_MODULE, 0);
81 snd_printk(KERN_ERR "specify port\n"); 100 if (!card)
82 return -EINVAL;
83 }
84 if (irq[dev] == SNDRV_AUTO_IRQ) {
85 snd_printk(KERN_ERR "specify irq\n");
86 return -EINVAL;
87 }
88 if (dma1[dev] == SNDRV_AUTO_DMA) {
89 snd_printk(KERN_ERR "specify dma1\n");
90 return -EINVAL; 101 return -EINVAL;
91 } 102
92 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 103 error = snd_cs4231_create(card, port[n], -1, irq[n], dma1[n], dma2[n],
93 if (card == NULL) 104 CS4231_HW_DETECT, 0, &chip);
94 return -ENOMEM; 105 if (error < 0)
95 if ((err = snd_cs4231_create(card, port[dev], -1, 106 goto out;
96 irq[dev], 107
97 dma1[dev],
98 dma2[dev],
99 CS4231_HW_DETECT,
100 0, &chip)) < 0)
101 goto _err;
102 card->private_data = chip; 108 card->private_data = chip;
103 109
104 if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) 110 error = snd_cs4231_pcm(chip, 0, &pcm);
105 goto _err; 111 if (error < 0)
112 goto out;
106 113
107 strcpy(card->driver, "CS4231"); 114 strcpy(card->driver, "CS4231");
108 strcpy(card->shortname, pcm->name); 115 strcpy(card->shortname, pcm->name);
116
109 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", 117 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
110 pcm->name, chip->port, irq[dev], dma1[dev]); 118 pcm->name, chip->port, irq[n], dma1[n]);
111 if (dma2[dev] >= 0) 119 if (dma2[n] >= 0)
112 sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]); 120 sprintf(card->longname + strlen(card->longname), "&%d", dma2[n]);
113 121
114 if ((err = snd_cs4231_mixer(chip)) < 0) 122 error = snd_cs4231_mixer(chip);
115 goto _err; 123 if (error < 0)
116 if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0) 124 goto out;
117 goto _err; 125
118 126 error = snd_cs4231_timer(chip, 0, NULL);
119 if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { 127 if (error < 0)
120 if (mpu_irq[dev] == SNDRV_AUTO_IRQ) 128 goto out;
121 mpu_irq[dev] = -1; 129
130 if (mpu_port[n] > 0 && mpu_port[n] != SNDRV_AUTO_PORT) {
131 if (mpu_irq[n] == SNDRV_AUTO_IRQ)
132 mpu_irq[n] = -1;
122 if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232, 133 if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232,
123 mpu_port[dev], 0, 134 mpu_port[n], 0, mpu_irq[n],
124 mpu_irq[dev], 135 mpu_irq[n] >= 0 ? IRQF_DISABLED : 0,
125 mpu_irq[dev] >= 0 ? IRQF_DISABLED : 0,
126 NULL) < 0) 136 NULL) < 0)
127 printk(KERN_WARNING "cs4231: MPU401 not detected\n"); 137 printk(KERN_WARNING "%s: MPU401 not detected\n", dev->bus_id);
128 } 138 }
129 139
130 snd_card_set_dev(card, &pdev->dev); 140 snd_card_set_dev(card, dev);
131 141
132 if ((err = snd_card_register(card)) < 0) 142 error = snd_card_register(card);
133 goto _err; 143 if (error < 0)
144 goto out;
134 145
135 platform_set_drvdata(pdev, card); 146 dev_set_drvdata(dev, card);
136 return 0; 147 return 0;
137 148
138 _err: 149out: snd_card_free(card);
139 snd_card_free(card); 150 return error;
140 return err;
141} 151}
142 152
143static int __devexit snd_cs4231_remove(struct platform_device *devptr) 153static int __devexit snd_cs4231_remove(struct device *dev, unsigned int n)
144{ 154{
145 snd_card_free(platform_get_drvdata(devptr)); 155 snd_card_free(dev_get_drvdata(dev));
146 platform_set_drvdata(devptr, NULL); 156 dev_set_drvdata(dev, NULL);
147 return 0; 157 return 0;
148} 158}
149 159
150#ifdef CONFIG_PM 160#ifdef CONFIG_PM
151static int snd_cs4231_suspend(struct platform_device *dev, pm_message_t state) 161static int snd_cs4231_suspend(struct device *dev, unsigned int n, pm_message_t state)
152{ 162{
153 struct snd_card *card; 163 struct snd_card *card = dev_get_drvdata(dev);
154 struct snd_cs4231 *chip; 164 struct snd_cs4231 *chip = card->private_data;
155 card = platform_get_drvdata(dev); 165
156 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 166 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
157 chip = card->private_data;
158 chip->suspend(chip); 167 chip->suspend(chip);
159 return 0; 168 return 0;
160} 169}
161 170
162static int snd_cs4231_resume(struct platform_device *dev) 171static int snd_cs4231_resume(struct device *dev, unsigned int n)
163{ 172{
164 struct snd_card *card; 173 struct snd_card *card = dev_get_drvdata(dev);
165 struct snd_cs4231 *chip; 174 struct snd_cs4231 *chip = card->private_data;
166 card = platform_get_drvdata(dev); 175
167 chip = card->private_data;
168 chip->resume(chip); 176 chip->resume(chip);
169 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 177 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
170 return 0; 178 return 0;
171} 179}
172#endif 180#endif
173 181
174#define SND_CS4231_DRIVER "snd_cs4231" 182static struct isa_driver snd_cs4231_driver = {
175 183 .match = snd_cs4231_match,
176static struct platform_driver snd_cs4231_driver = {
177 .probe = snd_cs4231_probe, 184 .probe = snd_cs4231_probe,
178 .remove = __devexit_p(snd_cs4231_remove), 185 .remove = __devexit_p(snd_cs4231_remove),
179#ifdef CONFIG_PM 186#ifdef CONFIG_PM
@@ -181,57 +188,19 @@ static struct platform_driver snd_cs4231_driver = {
181 .resume = snd_cs4231_resume, 188 .resume = snd_cs4231_resume,
182#endif 189#endif
183 .driver = { 190 .driver = {
184 .name = SND_CS4231_DRIVER 191 .name = DEV_NAME
185 }, 192 }
186}; 193};
187 194
188static void __init_or_module snd_cs4231_unregister_all(void)
189{
190 int i;
191
192 for (i = 0; i < ARRAY_SIZE(devices); ++i)
193 platform_device_unregister(devices[i]);
194 platform_driver_unregister(&snd_cs4231_driver);
195}
196
197static int __init alsa_card_cs4231_init(void) 195static int __init alsa_card_cs4231_init(void)
198{ 196{
199 int i, cards, err; 197 return isa_register_driver(&snd_cs4231_driver, SNDRV_CARDS);
200
201 err = platform_driver_register(&snd_cs4231_driver);
202 if (err < 0)
203 return err;
204
205 cards = 0;
206 for (i = 0; i < SNDRV_CARDS; i++) {
207 struct platform_device *device;
208 if (! enable[i])
209 continue;
210 device = platform_device_register_simple(SND_CS4231_DRIVER,
211 i, NULL, 0);
212 if (IS_ERR(device))
213 continue;
214 if (!platform_get_drvdata(device)) {
215 platform_device_unregister(device);
216 continue;
217 }
218 devices[i] = device;
219 cards++;
220 }
221 if (!cards) {
222#ifdef MODULE
223 printk(KERN_ERR "CS4231 soundcard not found or device busy\n");
224#endif
225 snd_cs4231_unregister_all();
226 return -ENODEV;
227 }
228 return 0;
229} 198}
230 199
231static void __exit alsa_card_cs4231_exit(void) 200static void __exit alsa_card_cs4231_exit(void)
232{ 201{
233 snd_cs4231_unregister_all(); 202 isa_unregister_driver(&snd_cs4231_driver);
234} 203}
235 204
236module_init(alsa_card_cs4231_init) 205module_init(alsa_card_cs4231_init);
237module_exit(alsa_card_cs4231_exit) 206module_exit(alsa_card_cs4231_exit);
diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c
index 75c7c5f01989..914d77b61b0c 100644
--- a/sound/isa/cs423x/cs4231_lib.c
+++ b/sound/isa/cs423x/cs4231_lib.c
@@ -405,7 +405,6 @@ static int snd_cs4231_trigger(struct snd_pcm_substream *substream,
405 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); 405 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream);
406 int result = 0; 406 int result = 0;
407 unsigned int what; 407 unsigned int what;
408 struct list_head *pos;
409 struct snd_pcm_substream *s; 408 struct snd_pcm_substream *s;
410 int do_start; 409 int do_start;
411 410
@@ -425,8 +424,7 @@ static int snd_cs4231_trigger(struct snd_pcm_substream *substream,
425 } 424 }
426 425
427 what = 0; 426 what = 0;
428 snd_pcm_group_for_each(pos, substream) { 427 snd_pcm_group_for_each_entry(s, substream) {
429 s = snd_pcm_group_substream_entry(pos);
430 if (s == chip->playback_substream) { 428 if (s == chip->playback_substream) {
431 what |= CS4231_PLAYBACK_ENABLE; 429 what |= CS4231_PLAYBACK_ENABLE;
432 snd_pcm_trigger_done(s, substream); 430 snd_pcm_trigger_done(s, substream);
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
index 07ffd5c22e81..87f1392a2fa7 100644
--- a/sound/isa/cs423x/cs4236.c
+++ b/sound/isa/cs423x/cs4236.c
@@ -22,7 +22,7 @@
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h> 25#include <linux/isa.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/pnp.h> 27#include <linux/pnp.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
@@ -75,10 +75,10 @@ MODULE_SUPPORTED_DEVICE("{{Crystal Semiconductors,CS4235},"
75 75
76#ifdef CS4232 76#ifdef CS4232
77#define IDENT "CS4232" 77#define IDENT "CS4232"
78#define CS423X_DRIVER "snd_cs4232" 78#define DEV_NAME "cs4232"
79#else 79#else
80#define IDENT "CS4236+" 80#define IDENT "CS4236+"
81#define CS423X_DRIVER "snd_cs4236" 81#define DEV_NAME "cs4236"
82#endif 82#endif
83 83
84static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 84static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
@@ -126,14 +126,12 @@ MODULE_PARM_DESC(dma1, "DMA1 # for " IDENT " driver.");
126module_param_array(dma2, int, NULL, 0444); 126module_param_array(dma2, int, NULL, 0444);
127MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver."); 127MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver.");
128 128
129static struct platform_device *platform_devices[SNDRV_CARDS];
130#ifdef CONFIG_PNP 129#ifdef CONFIG_PNP
131static int pnpc_registered; 130static int pnpc_registered;
132#ifdef CS4232 131#ifdef CS4232
133static int pnp_registered; 132static int pnp_registered;
134#endif 133#endif
135#endif /* CONFIG_PNP */ 134#endif /* CONFIG_PNP */
136static unsigned int snd_cs423x_devices;
137 135
138struct snd_card_cs4236 { 136struct snd_card_cs4236 {
139 struct snd_cs4231 *chip; 137 struct snd_cs4231 *chip;
@@ -542,38 +540,55 @@ static int __devinit snd_cs423x_probe(struct snd_card *card, int dev)
542 return snd_card_register(card); 540 return snd_card_register(card);
543} 541}
544 542
545static int __init snd_cs423x_nonpnp_probe(struct platform_device *pdev) 543static int __devinit snd_cs423x_isa_match(struct device *pdev,
544 unsigned int dev)
546{ 545{
547 int dev = pdev->id; 546 if (!enable[dev] || is_isapnp_selected(dev))
548 struct snd_card *card; 547 return 0;
549 int err;
550 548
551 if (port[dev] == SNDRV_AUTO_PORT) { 549 if (port[dev] == SNDRV_AUTO_PORT) {
552 snd_printk(KERN_ERR "specify port\n"); 550 snd_printk(KERN_ERR "%s: please specify port\n", pdev->bus_id);
553 return -EINVAL; 551 return 0;
554 } 552 }
555 if (cport[dev] == SNDRV_AUTO_PORT) { 553 if (cport[dev] == SNDRV_AUTO_PORT) {
556 snd_printk(KERN_ERR "specify cport\n"); 554 snd_printk(KERN_ERR "%s: please specify cport\n", pdev->bus_id);
557 return -EINVAL; 555 return 0;
556 }
557 if (irq[dev] == SNDRV_AUTO_IRQ) {
558 snd_printk(KERN_ERR "%s: please specify irq\n", pdev->bus_id);
559 return 0;
558 } 560 }
561 if (dma1[dev] == SNDRV_AUTO_DMA) {
562 snd_printk(KERN_ERR "%s: please specify dma1\n", pdev->bus_id);
563 return 0;
564 }
565 return 1;
566}
567
568static int __devinit snd_cs423x_isa_probe(struct device *pdev,
569 unsigned int dev)
570{
571 struct snd_card *card;
572 int err;
559 573
560 card = snd_cs423x_card_new(dev); 574 card = snd_cs423x_card_new(dev);
561 if (! card) 575 if (! card)
562 return -ENOMEM; 576 return -ENOMEM;
563 snd_card_set_dev(card, &pdev->dev); 577 snd_card_set_dev(card, pdev);
564 if ((err = snd_cs423x_probe(card, dev)) < 0) { 578 if ((err = snd_cs423x_probe(card, dev)) < 0) {
565 snd_card_free(card); 579 snd_card_free(card);
566 return err; 580 return err;
567 } 581 }
568 582
569 platform_set_drvdata(pdev, card); 583 dev_set_drvdata(pdev, card);
570 return 0; 584 return 0;
571} 585}
572 586
573static int __devexit snd_cs423x_nonpnp_remove(struct platform_device *devptr) 587static int __devexit snd_cs423x_isa_remove(struct device *pdev,
588 unsigned int dev)
574{ 589{
575 snd_card_free(platform_get_drvdata(devptr)); 590 snd_card_free(dev_get_drvdata(pdev));
576 platform_set_drvdata(devptr, NULL); 591 dev_set_drvdata(pdev, NULL);
577 return 0; 592 return 0;
578} 593}
579 594
@@ -594,26 +609,28 @@ static int snd_cs423x_resume(struct snd_card *card)
594 return 0; 609 return 0;
595} 610}
596 611
597static int snd_cs423x_nonpnp_suspend(struct platform_device *dev, pm_message_t state) 612static int snd_cs423x_isa_suspend(struct device *dev, unsigned int n,
613 pm_message_t state)
598{ 614{
599 return snd_cs423x_suspend(platform_get_drvdata(dev)); 615 return snd_cs423x_suspend(dev_get_drvdata(dev));
600} 616}
601 617
602static int snd_cs423x_nonpnp_resume(struct platform_device *dev) 618static int snd_cs423x_isa_resume(struct device *dev, unsigned int n)
603{ 619{
604 return snd_cs423x_resume(platform_get_drvdata(dev)); 620 return snd_cs423x_resume(dev_get_drvdata(dev));
605} 621}
606#endif 622#endif
607 623
608static struct platform_driver cs423x_nonpnp_driver = { 624static struct isa_driver cs423x_isa_driver = {
609 .probe = snd_cs423x_nonpnp_probe, 625 .match = snd_cs423x_isa_match,
610 .remove = __devexit_p(snd_cs423x_nonpnp_remove), 626 .probe = snd_cs423x_isa_probe,
627 .remove = __devexit_p(snd_cs423x_isa_remove),
611#ifdef CONFIG_PM 628#ifdef CONFIG_PM
612 .suspend = snd_cs423x_nonpnp_suspend, 629 .suspend = snd_cs423x_isa_suspend,
613 .resume = snd_cs423x_nonpnp_resume, 630 .resume = snd_cs423x_isa_resume,
614#endif 631#endif
615 .driver = { 632 .driver = {
616 .name = CS423X_DRIVER 633 .name = DEV_NAME
617 }, 634 },
618}; 635};
619 636
@@ -651,7 +668,6 @@ static int __devinit snd_cs4232_pnpbios_detect(struct pnp_dev *pdev,
651 } 668 }
652 pnp_set_drvdata(pdev, card); 669 pnp_set_drvdata(pdev, card);
653 dev++; 670 dev++;
654 snd_cs423x_devices++;
655 return 0; 671 return 0;
656} 672}
657 673
@@ -715,7 +731,6 @@ static int __devinit snd_cs423x_pnpc_detect(struct pnp_card_link *pcard,
715 } 731 }
716 pnp_set_card_drvdata(pcard, card); 732 pnp_set_card_drvdata(pcard, card);
717 dev++; 733 dev++;
718 snd_cs423x_devices++;
719 return 0; 734 return 0;
720} 735}
721 736
@@ -750,45 +765,13 @@ static struct pnp_card_driver cs423x_pnpc_driver = {
750}; 765};
751#endif /* CONFIG_PNP */ 766#endif /* CONFIG_PNP */
752 767
753static void __init_or_module snd_cs423x_unregister_all(void)
754{
755 int i;
756
757#ifdef CONFIG_PNP
758 if (pnpc_registered)
759 pnp_unregister_card_driver(&cs423x_pnpc_driver);
760#ifdef CS4232
761 if (pnp_registered)
762 pnp_unregister_driver(&cs4232_pnp_driver);
763#endif
764#endif /* CONFIG_PNP */
765 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
766 platform_device_unregister(platform_devices[i]);
767 platform_driver_unregister(&cs423x_nonpnp_driver);
768}
769
770static int __init alsa_card_cs423x_init(void) 768static int __init alsa_card_cs423x_init(void)
771{ 769{
772 int i, err; 770 int err;
773 771
774 if ((err = platform_driver_register(&cs423x_nonpnp_driver)) < 0) 772 err = isa_register_driver(&cs423x_isa_driver, SNDRV_CARDS);
773 if (err < 0)
775 return err; 774 return err;
776
777 for (i = 0; i < SNDRV_CARDS; i++) {
778 struct platform_device *device;
779 if (! enable[i] || is_isapnp_selected(i))
780 continue;
781 device = platform_device_register_simple(CS423X_DRIVER,
782 i, NULL, 0);
783 if (IS_ERR(device))
784 continue;
785 if (!platform_get_drvdata(device)) {
786 platform_device_unregister(device);
787 continue;
788 }
789 platform_devices[i] = device;
790 snd_cs423x_devices++;
791 }
792#ifdef CONFIG_PNP 775#ifdef CONFIG_PNP
793#ifdef CS4232 776#ifdef CS4232
794 err = pnp_register_driver(&cs4232_pnp_driver); 777 err = pnp_register_driver(&cs4232_pnp_driver);
@@ -799,20 +782,20 @@ static int __init alsa_card_cs423x_init(void)
799 if (!err) 782 if (!err)
800 pnpc_registered = 1; 783 pnpc_registered = 1;
801#endif /* CONFIG_PNP */ 784#endif /* CONFIG_PNP */
802
803 if (!snd_cs423x_devices) {
804#ifdef MODULE
805 printk(KERN_ERR IDENT " soundcard not found or device busy\n");
806#endif
807 snd_cs423x_unregister_all();
808 return -ENODEV;
809 }
810 return 0; 785 return 0;
811} 786}
812 787
813static void __exit alsa_card_cs423x_exit(void) 788static void __exit alsa_card_cs423x_exit(void)
814{ 789{
815 snd_cs423x_unregister_all(); 790#ifdef CONFIG_PNP
791 if (pnpc_registered)
792 pnp_unregister_card_driver(&cs423x_pnpc_driver);
793#ifdef CS4232
794 if (pnp_registered)
795 pnp_unregister_driver(&cs4232_pnp_driver);
796#endif
797#endif /* CONFIG_PNP */
798 isa_unregister_driver(&cs423x_isa_driver);
816} 799}
817 800
818module_init(alsa_card_cs423x_init) 801module_init(alsa_card_cs423x_init)
diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c
index 65f97ff4eef1..edc398712e8b 100644
--- a/sound/isa/es1688/es1688.c
+++ b/sound/isa/es1688/es1688.c
@@ -22,7 +22,7 @@
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h> 25#include <linux/isa.h>
26#include <linux/time.h> 26#include <linux/time.h>
27#include <linux/wait.h> 27#include <linux/wait.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
@@ -35,8 +35,11 @@
35#define SNDRV_LEGACY_FIND_FREE_DMA 35#define SNDRV_LEGACY_FIND_FREE_DMA
36#include <sound/initval.h> 36#include <sound/initval.h>
37 37
38#define CRD_NAME "Generic ESS ES1688/ES688 AudioDrive"
39#define DEV_NAME "es1688"
40
41MODULE_DESCRIPTION(CRD_NAME);
38MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 42MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
39MODULE_DESCRIPTION("ESS ESx688 AudioDrive");
40MODULE_LICENSE("GPL"); 43MODULE_LICENSE("GPL");
41MODULE_SUPPORTED_DEVICE("{{ESS,ES688 PnP AudioDrive,pnp:ESS0100}," 44MODULE_SUPPORTED_DEVICE("{{ESS,ES688 PnP AudioDrive,pnp:ESS0100},"
42 "{ESS,ES1688 PnP AudioDrive,pnp:ESS0102}," 45 "{ESS,ES1688 PnP AudioDrive,pnp:ESS0102},"
@@ -53,189 +56,157 @@ static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,10 */
53static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3 */ 56static int dma8[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 0,1,3 */
54 57
55module_param_array(index, int, NULL, 0444); 58module_param_array(index, int, NULL, 0444);
56MODULE_PARM_DESC(index, "Index value for ESx688 soundcard."); 59MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard.");
57module_param_array(id, charp, NULL, 0444); 60module_param_array(id, charp, NULL, 0444);
58MODULE_PARM_DESC(id, "ID string for ESx688 soundcard."); 61MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard.");
59module_param_array(enable, bool, NULL, 0444); 62module_param_array(enable, bool, NULL, 0444);
60MODULE_PARM_DESC(enable, "Enable ESx688 soundcard."); 63MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
61module_param_array(port, long, NULL, 0444); 64module_param_array(port, long, NULL, 0444);
62MODULE_PARM_DESC(port, "Port # for ESx688 driver."); 65MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
63module_param_array(mpu_port, long, NULL, 0444); 66module_param_array(mpu_port, long, NULL, 0444);
64MODULE_PARM_DESC(mpu_port, "MPU-401 port # for ESx688 driver."); 67MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " CRD_NAME " driver.");
65module_param_array(irq, int, NULL, 0444); 68module_param_array(irq, int, NULL, 0444);
66MODULE_PARM_DESC(irq, "IRQ # for ESx688 driver."); 69MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
67module_param_array(mpu_irq, int, NULL, 0444); 70module_param_array(mpu_irq, int, NULL, 0444);
68MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for ESx688 driver."); 71MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " CRD_NAME " driver.");
69module_param_array(dma8, int, NULL, 0444); 72module_param_array(dma8, int, NULL, 0444);
70MODULE_PARM_DESC(dma8, "8-bit DMA # for ESx688 driver."); 73MODULE_PARM_DESC(dma8, "8-bit DMA # for " CRD_NAME " driver.");
71
72static struct platform_device *devices[SNDRV_CARDS];
73 74
74#define PFX "es1688: " 75static int __devinit snd_es1688_match(struct device *dev, unsigned int n)
76{
77 return enable[n];
78}
75 79
76static int __devinit snd_es1688_probe(struct platform_device *pdev) 80static int __devinit snd_es1688_legacy_create(struct snd_card *card,
81 struct device *dev, unsigned int n, struct snd_es1688 **rchip)
77{ 82{
78 int dev = pdev->id; 83 static long possible_ports[] = {0x220, 0x240, 0x260};
79 static int possible_irqs[] = {5, 9, 10, 7, -1}; 84 static int possible_irqs[] = {5, 9, 10, 7, -1};
80 static int possible_dmas[] = {1, 3, 0, -1}; 85 static int possible_dmas[] = {1, 3, 0, -1};
81 int xirq, xdma, xmpu_irq; 86
82 struct snd_card *card; 87 int i, error;
83 struct snd_es1688 *chip; 88
84 struct snd_opl3 *opl3; 89 if (irq[n] == SNDRV_AUTO_IRQ) {
85 struct snd_pcm *pcm; 90 irq[n] = snd_legacy_find_free_irq(possible_irqs);
86 int err; 91 if (irq[n] < 0) {
87 92 snd_printk(KERN_ERR "%s: unable to find a free IRQ\n",
88 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 93 dev->bus_id);
89 if (card == NULL) 94 return -EBUSY;
90 return -ENOMEM;
91
92 xirq = irq[dev];
93 if (xirq == SNDRV_AUTO_IRQ) {
94 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
95 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
96 err = -EBUSY;
97 goto _err;
98 } 95 }
99 } 96 }
100 xmpu_irq = mpu_irq[dev]; 97 if (dma8[n] == SNDRV_AUTO_DMA) {
101 xdma = dma8[dev]; 98 dma8[n] = snd_legacy_find_free_dma(possible_dmas);
102 if (xdma == SNDRV_AUTO_DMA) { 99 if (dma8[n] < 0) {
103 if ((xdma = snd_legacy_find_free_dma(possible_dmas)) < 0) { 100 snd_printk(KERN_ERR "%s: unable to find a free DMA\n",
104 snd_printk(KERN_ERR PFX "unable to find a free DMA\n"); 101 dev->bus_id);
105 err = -EBUSY; 102 return -EBUSY;
106 goto _err;
107 } 103 }
108 } 104 }
109 105
110 if (port[dev] != SNDRV_AUTO_PORT) { 106 if (port[n] != SNDRV_AUTO_PORT)
111 if ((err = snd_es1688_create(card, port[dev], mpu_port[dev], 107 return snd_es1688_create(card, port[n], mpu_port[n], irq[n],
112 xirq, xmpu_irq, xdma, 108 mpu_irq[n], dma8[n], ES1688_HW_AUTO, rchip);
113 ES1688_HW_AUTO, &chip)) < 0) 109
114 goto _err; 110 i = 0;
115 } else { 111 do {
116 /* auto-probe legacy ports */ 112 port[n] = possible_ports[i];
117 static unsigned long possible_ports[] = { 113 error = snd_es1688_create(card, port[n], mpu_port[n], irq[n],
118 0x220, 0x240, 0x260, 114 mpu_irq[n], dma8[n], ES1688_HW_AUTO, rchip);
119 }; 115 } while (error < 0 && ++i < ARRAY_SIZE(possible_ports));
120 int i; 116
121 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { 117 return error;
122 err = snd_es1688_create(card, possible_ports[i], 118}
123 mpu_port[dev], 119
124 xirq, xmpu_irq, xdma, 120static int __devinit snd_es1688_probe(struct device *dev, unsigned int n)
125 ES1688_HW_AUTO, &chip); 121{
126 if (err >= 0) { 122 struct snd_card *card;
127 port[dev] = possible_ports[i]; 123 struct snd_es1688 *chip;
128 break; 124 struct snd_opl3 *opl3;
129 } 125 struct snd_pcm *pcm;
130 } 126 int error;
131 if (i >= ARRAY_SIZE(possible_ports)) 127
132 goto _err; 128 card = snd_card_new(index[n], id[n], THIS_MODULE, 0);
133 } 129 if (!card)
130 return -EINVAL;
131
132 error = snd_es1688_legacy_create(card, dev, n, &chip);
133 if (error < 0)
134 goto out;
134 135
135 if ((err = snd_es1688_pcm(chip, 0, &pcm)) < 0) 136 error = snd_es1688_pcm(chip, 0, &pcm);
136 goto _err; 137 if (error < 0)
138 goto out;
137 139
138 if ((err = snd_es1688_mixer(chip)) < 0) 140 error = snd_es1688_mixer(chip);
139 goto _err; 141 if (error < 0)
142 goto out;
140 143
141 strcpy(card->driver, "ES1688"); 144 strcpy(card->driver, "ES1688");
142 strcpy(card->shortname, pcm->name); 145 strcpy(card->shortname, pcm->name);
143 sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", pcm->name, chip->port, xirq, xdma); 146 sprintf(card->longname, "%s at 0x%lx, irq %i, dma %i", pcm->name,
144 147 chip->port, chip->irq, chip->dma8);
145 if ((snd_opl3_create(card, chip->port, chip->port + 2, OPL3_HW_OPL3, 0, &opl3)) < 0) { 148
146 printk(KERN_WARNING PFX "opl3 not detected at 0x%lx\n", chip->port); 149 if (snd_opl3_create(card, chip->port, chip->port + 2,
147 } else { 150 OPL3_HW_OPL3, 0, &opl3) < 0)
148 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) 151 printk(KERN_WARNING "%s: opl3 not detected at 0x%lx\n",
149 goto _err; 152 dev->bus_id, chip->port);
153 else {
154 error = snd_opl3_hwdep_new(opl3, 0, 1, NULL);
155 if (error < 0)
156 goto out;
150 } 157 }
151 158
152 if (xmpu_irq >= 0 && xmpu_irq != SNDRV_AUTO_IRQ && chip->mpu_port > 0) { 159 if (mpu_irq[n] >= 0 && mpu_irq[n] != SNDRV_AUTO_IRQ &&
153 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688, 160 chip->mpu_port > 0) {
154 chip->mpu_port, 0, 161 error = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688,
155 xmpu_irq, 162 chip->mpu_port, 0,
156 IRQF_DISABLED, 163 mpu_irq[n], IRQF_DISABLED, NULL);
157 NULL)) < 0) 164 if (error < 0)
158 goto _err; 165 goto out;
159 } 166 }
160 167
161 snd_card_set_dev(card, &pdev->dev); 168 snd_card_set_dev(card, dev);
162 169
163 if ((err = snd_card_register(card)) < 0) 170 error = snd_card_register(card);
164 goto _err; 171 if (error < 0)
172 goto out;
165 173
166 platform_set_drvdata(pdev, card); 174 dev_set_drvdata(dev, card);
167 return 0; 175 return 0;
168 176
169 _err: 177out: snd_card_free(card);
170 snd_card_free(card); 178 return error;
171 return err;
172} 179}
173 180
174static int __devexit snd_es1688_remove(struct platform_device *devptr) 181static int __devexit snd_es1688_remove(struct device *dev, unsigned int n)
175{ 182{
176 snd_card_free(platform_get_drvdata(devptr)); 183 snd_card_free(dev_get_drvdata(dev));
177 platform_set_drvdata(devptr, NULL); 184 dev_set_drvdata(dev, NULL);
178 return 0; 185 return 0;
179} 186}
180 187
181#define ES1688_DRIVER "snd_es1688" 188static struct isa_driver snd_es1688_driver = {
182 189 .match = snd_es1688_match,
183static struct platform_driver snd_es1688_driver = {
184 .probe = snd_es1688_probe, 190 .probe = snd_es1688_probe,
185 .remove = __devexit_p(snd_es1688_remove), 191 .remove = snd_es1688_remove,
186 /* FIXME: suspend/resume */ 192#if 0 /* FIXME */
193 .suspend = snd_es1688_suspend,
194 .resume = snd_es1688_resume,
195#endif
187 .driver = { 196 .driver = {
188 .name = ES1688_DRIVER 197 .name = DEV_NAME
189 }, 198 }
190}; 199};
191 200
192static void __init_or_module snd_es1688_unregister_all(void)
193{
194 int i;
195
196 for (i = 0; i < ARRAY_SIZE(devices); ++i)
197 platform_device_unregister(devices[i]);
198 platform_driver_unregister(&snd_es1688_driver);
199}
200
201static int __init alsa_card_es1688_init(void) 201static int __init alsa_card_es1688_init(void)
202{ 202{
203 int i, cards, err; 203 return isa_register_driver(&snd_es1688_driver, SNDRV_CARDS);
204
205 err = platform_driver_register(&snd_es1688_driver);
206 if (err < 0)
207 return err;
208
209 cards = 0;
210 for (i = 0; i < SNDRV_CARDS; i++) {
211 struct platform_device *device;
212 if (! enable[i])
213 continue;
214 device = platform_device_register_simple(ES1688_DRIVER,
215 i, NULL, 0);
216 if (IS_ERR(device))
217 continue;
218 if (!platform_get_drvdata(device)) {
219 platform_device_unregister(device);
220 continue;
221 }
222 devices[i] = device;
223 cards++;
224 }
225 if (!cards) {
226#ifdef MODULE
227 printk(KERN_ERR "ESS AudioDrive ES1688 soundcard not found or device busy\n");
228#endif
229 snd_es1688_unregister_all();
230 return -ENODEV;
231 }
232 return 0;
233} 204}
234 205
235static void __exit alsa_card_es1688_exit(void) 206static void __exit alsa_card_es1688_exit(void)
236{ 207{
237 snd_es1688_unregister_all(); 208 isa_unregister_driver(&snd_es1688_driver);
238} 209}
239 210
240module_init(alsa_card_es1688_init) 211module_init(alsa_card_es1688_init);
241module_exit(alsa_card_es1688_exit) 212module_exit(alsa_card_es1688_exit);
diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c
index 725c115ff97d..d2a9c7df0ce5 100644
--- a/sound/isa/es18xx.c
+++ b/sound/isa/es18xx.c
@@ -80,7 +80,7 @@
80#include <sound/driver.h> 80#include <sound/driver.h>
81#include <linux/init.h> 81#include <linux/init.h>
82#include <linux/err.h> 82#include <linux/err.h>
83#include <linux/platform_device.h> 83#include <linux/isa.h>
84#include <linux/slab.h> 84#include <linux/slab.h>
85#include <linux/pnp.h> 85#include <linux/pnp.h>
86#include <linux/isapnp.h> 86#include <linux/isapnp.h>
@@ -2035,8 +2035,6 @@ MODULE_PARM_DESC(dma1, "DMA 1 # for ES18xx driver.");
2035module_param_array(dma2, int, NULL, 0444); 2035module_param_array(dma2, int, NULL, 0444);
2036MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver."); 2036MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver.");
2037 2037
2038static struct platform_device *platform_devices[SNDRV_CARDS];
2039
2040#ifdef CONFIG_PNP 2038#ifdef CONFIG_PNP
2041static int pnp_registered, pnpc_registered; 2039static int pnp_registered, pnpc_registered;
2042 2040
@@ -2237,7 +2235,12 @@ static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev)
2237 return snd_card_register(card); 2235 return snd_card_register(card);
2238} 2236}
2239 2237
2240static int __devinit snd_es18xx_nonpnp_probe1(int dev, struct platform_device *devptr) 2238static int __devinit snd_es18xx_isa_match(struct device *pdev, unsigned int dev)
2239{
2240 return enable[dev] && !is_isapnp_selected(dev);
2241}
2242
2243static int __devinit snd_es18xx_isa_probe1(int dev, struct device *devptr)
2241{ 2244{
2242 struct snd_card *card; 2245 struct snd_card *card;
2243 int err; 2246 int err;
@@ -2245,18 +2248,17 @@ static int __devinit snd_es18xx_nonpnp_probe1(int dev, struct platform_device *d
2245 card = snd_es18xx_card_new(dev); 2248 card = snd_es18xx_card_new(dev);
2246 if (! card) 2249 if (! card)
2247 return -ENOMEM; 2250 return -ENOMEM;
2248 snd_card_set_dev(card, &devptr->dev); 2251 snd_card_set_dev(card, devptr);
2249 if ((err = snd_audiodrive_probe(card, dev)) < 0) { 2252 if ((err = snd_audiodrive_probe(card, dev)) < 0) {
2250 snd_card_free(card); 2253 snd_card_free(card);
2251 return err; 2254 return err;
2252 } 2255 }
2253 platform_set_drvdata(devptr, card); 2256 dev_set_drvdata(devptr, card);
2254 return 0; 2257 return 0;
2255} 2258}
2256 2259
2257static int __devinit snd_es18xx_nonpnp_probe(struct platform_device *pdev) 2260static int __devinit snd_es18xx_isa_probe(struct device *pdev, unsigned int dev)
2258{ 2261{
2259 int dev = pdev->id;
2260 int err; 2262 int err;
2261 static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1}; 2263 static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1};
2262 static int possible_dmas[] = {1, 0, 3, 5, -1}; 2264 static int possible_dmas[] = {1, 0, 3, 5, -1};
@@ -2281,13 +2283,13 @@ static int __devinit snd_es18xx_nonpnp_probe(struct platform_device *pdev)
2281 } 2283 }
2282 2284
2283 if (port[dev] != SNDRV_AUTO_PORT) { 2285 if (port[dev] != SNDRV_AUTO_PORT) {
2284 return snd_es18xx_nonpnp_probe1(dev, pdev); 2286 return snd_es18xx_isa_probe1(dev, pdev);
2285 } else { 2287 } else {
2286 static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280}; 2288 static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280};
2287 int i; 2289 int i;
2288 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { 2290 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
2289 port[dev] = possible_ports[i]; 2291 port[dev] = possible_ports[i];
2290 err = snd_es18xx_nonpnp_probe1(dev, pdev); 2292 err = snd_es18xx_isa_probe1(dev, pdev);
2291 if (! err) 2293 if (! err)
2292 return 0; 2294 return 0;
2293 } 2295 }
@@ -2295,43 +2297,44 @@ static int __devinit snd_es18xx_nonpnp_probe(struct platform_device *pdev)
2295 } 2297 }
2296} 2298}
2297 2299
2298static int __devexit snd_es18xx_nonpnp_remove(struct platform_device *devptr) 2300static int __devexit snd_es18xx_isa_remove(struct device *devptr,
2301 unsigned int dev)
2299{ 2302{
2300 snd_card_free(platform_get_drvdata(devptr)); 2303 snd_card_free(dev_get_drvdata(devptr));
2301 platform_set_drvdata(devptr, NULL); 2304 dev_set_drvdata(devptr, NULL);
2302 return 0; 2305 return 0;
2303} 2306}
2304 2307
2305#ifdef CONFIG_PM 2308#ifdef CONFIG_PM
2306static int snd_es18xx_nonpnp_suspend(struct platform_device *dev, pm_message_t state) 2309static int snd_es18xx_isa_suspend(struct device *dev, unsigned int n,
2310 pm_message_t state)
2307{ 2311{
2308 return snd_es18xx_suspend(platform_get_drvdata(dev), state); 2312 return snd_es18xx_suspend(dev_get_drvdata(dev), state);
2309} 2313}
2310 2314
2311static int snd_es18xx_nonpnp_resume(struct platform_device *dev) 2315static int snd_es18xx_isa_resume(struct device *dev, unsigned int n)
2312{ 2316{
2313 return snd_es18xx_resume(platform_get_drvdata(dev)); 2317 return snd_es18xx_resume(dev_get_drvdata(dev));
2314} 2318}
2315#endif 2319#endif
2316 2320
2317#define ES18XX_DRIVER "snd_es18xx" 2321#define DEV_NAME "es18xx"
2318 2322
2319static struct platform_driver snd_es18xx_nonpnp_driver = { 2323static struct isa_driver snd_es18xx_isa_driver = {
2320 .probe = snd_es18xx_nonpnp_probe, 2324 .match = snd_es18xx_isa_match,
2321 .remove = __devexit_p(snd_es18xx_nonpnp_remove), 2325 .probe = snd_es18xx_isa_probe,
2326 .remove = __devexit_p(snd_es18xx_isa_remove),
2322#ifdef CONFIG_PM 2327#ifdef CONFIG_PM
2323 .suspend = snd_es18xx_nonpnp_suspend, 2328 .suspend = snd_es18xx_isa_suspend,
2324 .resume = snd_es18xx_nonpnp_resume, 2329 .resume = snd_es18xx_isa_resume,
2325#endif 2330#endif
2326 .driver = { 2331 .driver = {
2327 .name = ES18XX_DRIVER 2332 .name = DEV_NAME
2328 }, 2333 },
2329}; 2334};
2330 2335
2331 2336
2332#ifdef CONFIG_PNP 2337#ifdef CONFIG_PNP
2333static unsigned int __devinitdata es18xx_pnp_devices;
2334
2335static int __devinit snd_audiodrive_pnp_detect(struct pnp_dev *pdev, 2338static int __devinit snd_audiodrive_pnp_detect(struct pnp_dev *pdev,
2336 const struct pnp_device_id *id) 2339 const struct pnp_device_id *id)
2337{ 2340{
@@ -2362,7 +2365,6 @@ static int __devinit snd_audiodrive_pnp_detect(struct pnp_dev *pdev,
2362 } 2365 }
2363 pnp_set_drvdata(pdev, card); 2366 pnp_set_drvdata(pdev, card);
2364 dev++; 2367 dev++;
2365 es18xx_pnp_devices++;
2366 return 0; 2368 return 0;
2367} 2369}
2368 2370
@@ -2424,7 +2426,6 @@ static int __devinit snd_audiodrive_pnpc_detect(struct pnp_card_link *pcard,
2424 2426
2425 pnp_set_card_drvdata(pcard, card); 2427 pnp_set_card_drvdata(pcard, card);
2426 dev++; 2428 dev++;
2427 es18xx_pnp_devices++;
2428 return 0; 2429 return 0;
2429} 2430}
2430 2431
@@ -2460,44 +2461,14 @@ static struct pnp_card_driver es18xx_pnpc_driver = {
2460}; 2461};
2461#endif /* CONFIG_PNP */ 2462#endif /* CONFIG_PNP */
2462 2463
2463static void __init_or_module snd_es18xx_unregister_all(void)
2464{
2465 int i;
2466
2467#ifdef CONFIG_PNP
2468 if (pnpc_registered)
2469 pnp_unregister_card_driver(&es18xx_pnpc_driver);
2470 if (pnp_registered)
2471 pnp_unregister_driver(&es18xx_pnp_driver);
2472#endif
2473 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
2474 platform_device_unregister(platform_devices[i]);
2475 platform_driver_unregister(&snd_es18xx_nonpnp_driver);
2476}
2477
2478static int __init alsa_card_es18xx_init(void) 2464static int __init alsa_card_es18xx_init(void)
2479{ 2465{
2480 int i, err, cards = 0; 2466 int err;
2481 2467
2482 if ((err = platform_driver_register(&snd_es18xx_nonpnp_driver)) < 0) 2468 err = isa_register_driver(&snd_es18xx_isa_driver, SNDRV_CARDS);
2469 if (err < 0)
2483 return err; 2470 return err;
2484 2471
2485 for (i = 0; i < SNDRV_CARDS; i++) {
2486 struct platform_device *device;
2487 if (! enable[i] || is_isapnp_selected(i))
2488 continue;
2489 device = platform_device_register_simple(ES18XX_DRIVER,
2490 i, NULL, 0);
2491 if (IS_ERR(device))
2492 continue;
2493 if (!platform_get_drvdata(device)) {
2494 platform_device_unregister(device);
2495 continue;
2496 }
2497 platform_devices[i] = device;
2498 cards++;
2499 }
2500
2501#ifdef CONFIG_PNP 2472#ifdef CONFIG_PNP
2502 err = pnp_register_driver(&es18xx_pnp_driver); 2473 err = pnp_register_driver(&es18xx_pnp_driver);
2503 if (!err) 2474 if (!err)
@@ -2505,22 +2476,19 @@ static int __init alsa_card_es18xx_init(void)
2505 err = pnp_register_card_driver(&es18xx_pnpc_driver); 2476 err = pnp_register_card_driver(&es18xx_pnpc_driver);
2506 if (!err) 2477 if (!err)
2507 pnpc_registered = 1; 2478 pnpc_registered = 1;
2508 cards += es18xx_pnp_devices;
2509#endif
2510
2511 if(!cards) {
2512#ifdef MODULE
2513 snd_printk(KERN_ERR "ESS AudioDrive ES18xx soundcard not found or device busy\n");
2514#endif 2479#endif
2515 snd_es18xx_unregister_all();
2516 return -ENODEV;
2517 }
2518 return 0; 2480 return 0;
2519} 2481}
2520 2482
2521static void __exit alsa_card_es18xx_exit(void) 2483static void __exit alsa_card_es18xx_exit(void)
2522{ 2484{
2523 snd_es18xx_unregister_all(); 2485#ifdef CONFIG_PNP
2486 if (pnpc_registered)
2487 pnp_unregister_card_driver(&es18xx_pnpc_driver);
2488 if (pnp_registered)
2489 pnp_unregister_driver(&es18xx_pnp_driver);
2490#endif
2491 isa_unregister_driver(&snd_es18xx_isa_driver);
2524} 2492}
2525 2493
2526module_init(alsa_card_es18xx_init) 2494module_init(alsa_card_es18xx_init)
diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c
index 0395e2e0dd03..8f23f433d491 100644
--- a/sound/isa/gus/gusclassic.c
+++ b/sound/isa/gus/gusclassic.c
@@ -22,7 +22,7 @@
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h> 25#include <linux/isa.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
@@ -33,8 +33,11 @@
33#define SNDRV_LEGACY_FIND_FREE_DMA 33#define SNDRV_LEGACY_FIND_FREE_DMA
34#include <sound/initval.h> 34#include <sound/initval.h>
35 35
36#define CRD_NAME "Gravis UltraSound Classic"
37#define DEV_NAME "gusclassic"
38
39MODULE_DESCRIPTION(CRD_NAME);
36MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 40MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
37MODULE_DESCRIPTION("Gravis UltraSound Classic");
38MODULE_LICENSE("GPL"); 41MODULE_LICENSE("GPL");
39MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Classic}}"); 42MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Classic}}");
40 43
@@ -51,32 +54,80 @@ static int channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 24};
51static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; 54static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
52 55
53module_param_array(index, int, NULL, 0444); 56module_param_array(index, int, NULL, 0444);
54MODULE_PARM_DESC(index, "Index value for GUS Classic soundcard."); 57MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard.");
55module_param_array(id, charp, NULL, 0444); 58module_param_array(id, charp, NULL, 0444);
56MODULE_PARM_DESC(id, "ID string for GUS Classic soundcard."); 59MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard.");
57module_param_array(enable, bool, NULL, 0444); 60module_param_array(enable, bool, NULL, 0444);
58MODULE_PARM_DESC(enable, "Enable GUS Classic soundcard."); 61MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
59module_param_array(port, long, NULL, 0444); 62module_param_array(port, long, NULL, 0444);
60MODULE_PARM_DESC(port, "Port # for GUS Classic driver."); 63MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
61module_param_array(irq, int, NULL, 0444); 64module_param_array(irq, int, NULL, 0444);
62MODULE_PARM_DESC(irq, "IRQ # for GUS Classic driver."); 65MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
63module_param_array(dma1, int, NULL, 0444); 66module_param_array(dma1, int, NULL, 0444);
64MODULE_PARM_DESC(dma1, "DMA1 # for GUS Classic driver."); 67MODULE_PARM_DESC(dma1, "DMA1 # for " CRD_NAME " driver.");
65module_param_array(dma2, int, NULL, 0444); 68module_param_array(dma2, int, NULL, 0444);
66MODULE_PARM_DESC(dma2, "DMA2 # for GUS Classic driver."); 69MODULE_PARM_DESC(dma2, "DMA2 # for " CRD_NAME " driver.");
67module_param_array(joystick_dac, int, NULL, 0444); 70module_param_array(joystick_dac, int, NULL, 0444);
68MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for GUS Classic driver."); 71MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for " CRD_NAME " driver.");
69module_param_array(channels, int, NULL, 0444); 72module_param_array(channels, int, NULL, 0444);
70MODULE_PARM_DESC(channels, "GF1 channels for GUS Classic driver."); 73MODULE_PARM_DESC(channels, "GF1 channels for " CRD_NAME " driver.");
71module_param_array(pcm_channels, int, NULL, 0444); 74module_param_array(pcm_channels, int, NULL, 0444);
72MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver."); 75MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for " CRD_NAME " driver.");
76
77static int __devinit snd_gusclassic_match(struct device *dev, unsigned int n)
78{
79 return enable[n];
80}
81
82static int __devinit snd_gusclassic_create(struct snd_card *card,
83 struct device *dev, unsigned int n, struct snd_gus_card **rgus)
84{
85 static long possible_ports[] = {0x220, 0x230, 0x240, 0x250, 0x260};
86 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1};
87 static int possible_dmas[] = {5, 6, 7, 1, 3, -1};
88
89 int i, error;
90
91 if (irq[n] == SNDRV_AUTO_IRQ) {
92 irq[n] = snd_legacy_find_free_irq(possible_irqs);
93 if (irq[n] < 0) {
94 snd_printk(KERN_ERR "%s: unable to find a free IRQ\n",
95 dev->bus_id);
96 return -EBUSY;
97 }
98 }
99 if (dma1[n] == SNDRV_AUTO_DMA) {
100 dma1[n] = snd_legacy_find_free_dma(possible_dmas);
101 if (dma1[n] < 0) {
102 snd_printk(KERN_ERR "%s: unable to find a free DMA1\n",
103 dev->bus_id);
104 return -EBUSY;
105 }
106 }
107 if (dma2[n] == SNDRV_AUTO_DMA) {
108 dma2[n] = snd_legacy_find_free_dma(possible_dmas);
109 if (dma2[n] < 0) {
110 snd_printk(KERN_ERR "%s: unable to find a free DMA2\n",
111 dev->bus_id);
112 return -EBUSY;
113 }
114 }
73 115
74static struct platform_device *devices[SNDRV_CARDS]; 116 if (port[n] != SNDRV_AUTO_PORT)
117 return snd_gus_create(card, port[n], irq[n], dma1[n], dma2[n],
118 0, channels[n], pcm_channels[n], 0, rgus);
75 119
120 i = 0;
121 do {
122 port[n] = possible_ports[i];
123 error = snd_gus_create(card, port[n], irq[n], dma1[n], dma2[n],
124 0, channels[n], pcm_channels[n], 0, rgus);
125 } while (error < 0 && ++i < ARRAY_SIZE(possible_ports));
76 126
77#define PFX "gusclassic: " 127 return error;
128}
78 129
79static int __devinit snd_gusclassic_detect(struct snd_gus_card * gus) 130static int __devinit snd_gusclassic_detect(struct snd_gus_card *gus)
80{ 131{
81 unsigned char d; 132 unsigned char d;
82 133
@@ -95,187 +146,104 @@ static int __devinit snd_gusclassic_detect(struct snd_gus_card * gus)
95 return 0; 146 return 0;
96} 147}
97 148
98static void __devinit snd_gusclassic_init(int dev, struct snd_gus_card * gus) 149static int __devinit snd_gusclassic_probe(struct device *dev, unsigned int n)
99{
100 gus->equal_irq = 0;
101 gus->codec_flag = 0;
102 gus->max_flag = 0;
103 gus->joystick_dac = joystick_dac[dev];
104}
105
106static int __devinit snd_gusclassic_probe(struct platform_device *pdev)
107{ 150{
108 int dev = pdev->id;
109 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1};
110 static int possible_dmas[] = {5, 6, 7, 1, 3, -1};
111 int xirq, xdma1, xdma2;
112 struct snd_card *card; 151 struct snd_card *card;
113 struct snd_gus_card *gus = NULL; 152 struct snd_gus_card *gus;
114 int err; 153 int error;
115
116 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
117 if (card == NULL)
118 return -ENOMEM;
119 if (pcm_channels[dev] < 2)
120 pcm_channels[dev] = 2;
121
122 xirq = irq[dev];
123 if (xirq == SNDRV_AUTO_IRQ) {
124 if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
125 snd_printk(KERN_ERR PFX "unable to find a free IRQ\n");
126 err = -EBUSY;
127 goto _err;
128 }
129 }
130 xdma1 = dma1[dev];
131 if (xdma1 == SNDRV_AUTO_DMA) {
132 if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
133 snd_printk(KERN_ERR PFX "unable to find a free DMA1\n");
134 err = -EBUSY;
135 goto _err;
136 }
137 }
138 xdma2 = dma2[dev];
139 if (xdma2 == SNDRV_AUTO_DMA) {
140 if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) {
141 snd_printk(KERN_ERR PFX "unable to find a free DMA2\n");
142 err = -EBUSY;
143 goto _err;
144 }
145 }
146 154
147 if (port[dev] != SNDRV_AUTO_PORT) { 155 card = snd_card_new(index[n], id[n], THIS_MODULE, 0);
148 err = snd_gus_create(card, 156 if (!card)
149 port[dev], 157 return -EINVAL;
150 xirq, xdma1, xdma2,
151 0, channels[dev], pcm_channels[dev],
152 0, &gus);
153 } else {
154 /* auto-probe legacy ports */
155 static unsigned long possible_ports[] = {
156 0x220, 0x230, 0x240, 0x250, 0x260,
157 };
158 int i;
159 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
160 err = snd_gus_create(card,
161 possible_ports[i],
162 xirq, xdma1, xdma2,
163 0, channels[dev], pcm_channels[dev],
164 0, &gus);
165 if (err >= 0) {
166 port[dev] = possible_ports[i];
167 break;
168 }
169 }
170 }
171 if (err < 0)
172 goto _err;
173 158
174 if ((err = snd_gusclassic_detect(gus)) < 0) 159 if (pcm_channels[n] < 2)
175 goto _err; 160 pcm_channels[n] = 2;
176 161
177 snd_gusclassic_init(dev, gus); 162 error = snd_gusclassic_create(card, dev, n, &gus);
178 if ((err = snd_gus_initialize(gus)) < 0) 163 if (error < 0)
179 goto _err; 164 goto out;
180 165
166 error = snd_gusclassic_detect(gus);
167 if (error < 0)
168 goto out;
169
170 gus->joystick_dac = joystick_dac[n];
171
172 error = snd_gus_initialize(gus);
173 if (error < 0)
174 goto out;
175
176 error = -ENODEV;
181 if (gus->max_flag || gus->ess_flag) { 177 if (gus->max_flag || gus->ess_flag) {
182 snd_printk(KERN_ERR PFX "GUS Classic or ACE soundcard was not detected at 0x%lx\n", gus->gf1.port); 178 snd_printk(KERN_ERR "%s: GUS Classic or ACE soundcard was "
183 err = -ENODEV; 179 "not detected at 0x%lx\n", dev->bus_id, gus->gf1.port);
184 goto _err; 180 goto out;
185 } 181 }
186 182
187 if ((err = snd_gf1_new_mixer(gus)) < 0) 183 error = snd_gf1_new_mixer(gus);
188 goto _err; 184 if (error < 0)
185 goto out;
189 186
190 if ((err = snd_gf1_pcm_new(gus, 0, 0, NULL)) < 0) 187 error = snd_gf1_pcm_new(gus, 0, 0, NULL);
191 goto _err; 188 if (error < 0)
189 goto out;
192 190
193 if (!gus->ace_flag) { 191 if (!gus->ace_flag) {
194 if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) 192 error = snd_gf1_rawmidi_new(gus, 0, NULL);
195 goto _err; 193 if (error < 0)
194 goto out;
196 } 195 }
197 sprintf(card->longname + strlen(card->longname), " at 0x%lx, irq %d, dma %d", gus->gf1.port, xirq, xdma1);
198 if (xdma2 >= 0)
199 sprintf(card->longname + strlen(card->longname), "&%d", xdma2);
200 196
201 snd_card_set_dev(card, &pdev->dev); 197 sprintf(card->longname + strlen(card->longname),
198 " at 0x%lx, irq %d, dma %d",
199 gus->gf1.port, gus->gf1.irq, gus->gf1.dma1);
202 200
203 if ((err = snd_card_register(card)) < 0) 201 if (gus->gf1.dma2 >= 0)
204 goto _err; 202 sprintf(card->longname + strlen(card->longname),
203 "&%d", gus->gf1.dma2);
205 204
206 platform_set_drvdata(pdev, card); 205 snd_card_set_dev(card, dev);
206
207 error = snd_card_register(card);
208 if (error < 0)
209 goto out;
210
211 dev_set_drvdata(dev, card);
207 return 0; 212 return 0;
208 213
209 _err: 214out: snd_card_free(card);
210 snd_card_free(card); 215 return error;
211 return err;
212} 216}
213 217
214static int __devexit snd_gusclassic_remove(struct platform_device *devptr) 218static int __devexit snd_gusclassic_remove(struct device *dev, unsigned int n)
215{ 219{
216 snd_card_free(platform_get_drvdata(devptr)); 220 snd_card_free(dev_get_drvdata(dev));
217 platform_set_drvdata(devptr, NULL); 221 dev_set_drvdata(dev, NULL);
218 return 0; 222 return 0;
219} 223}
220 224
221#define GUSCLASSIC_DRIVER "snd_gusclassic" 225static struct isa_driver snd_gusclassic_driver = {
222 226 .match = snd_gusclassic_match,
223static struct platform_driver snd_gusclassic_driver = {
224 .probe = snd_gusclassic_probe, 227 .probe = snd_gusclassic_probe,
225 .remove = __devexit_p(snd_gusclassic_remove), 228 .remove = __devexit_p(snd_gusclassic_remove),
226 /* FIXME: suspend/resume */ 229#if 0 /* FIXME */
230 .suspend = snd_gusclassic_suspend,
231 .remove = snd_gusclassic_remove,
232#endif
227 .driver = { 233 .driver = {
228 .name = GUSCLASSIC_DRIVER 234 .name = DEV_NAME
229 }, 235 }
230}; 236};
231 237
232static void __init_or_module snd_gusclassic_unregister_all(void)
233{
234 int i;
235
236 for (i = 0; i < ARRAY_SIZE(devices); ++i)
237 platform_device_unregister(devices[i]);
238 platform_driver_unregister(&snd_gusclassic_driver);
239}
240
241static int __init alsa_card_gusclassic_init(void) 238static int __init alsa_card_gusclassic_init(void)
242{ 239{
243 int i, cards, err; 240 return isa_register_driver(&snd_gusclassic_driver, SNDRV_CARDS);
244
245 err = platform_driver_register(&snd_gusclassic_driver);
246 if (err < 0)
247 return err;
248
249 cards = 0;
250 for (i = 0; i < SNDRV_CARDS; i++) {
251 struct platform_device *device;
252 if (! enable[i])
253 continue;
254 device = platform_device_register_simple(GUSCLASSIC_DRIVER,
255 i, NULL, 0);
256 if (IS_ERR(device))
257 continue;
258 if (!platform_get_drvdata(device)) {
259 platform_device_unregister(device);
260 continue;
261 }
262 devices[i] = device;
263 cards++;
264 }
265 if (!cards) {
266#ifdef MODULE
267 printk(KERN_ERR "GUS Classic soundcard not found or device busy\n");
268#endif
269 snd_gusclassic_unregister_all();
270 return -ENODEV;
271 }
272 return 0;
273} 241}
274 242
275static void __exit alsa_card_gusclassic_exit(void) 243static void __exit alsa_card_gusclassic_exit(void)
276{ 244{
277 snd_gusclassic_unregister_all(); 245 isa_unregister_driver(&snd_gusclassic_driver);
278} 246}
279 247
280module_init(alsa_card_gusclassic_init) 248module_init(alsa_card_gusclassic_init);
281module_exit(alsa_card_gusclassic_exit) 249module_exit(alsa_card_gusclassic_exit);
diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c
index 4f55fc3e66c1..0aeaa6cf6cf0 100644
--- a/sound/isa/gus/gusextreme.c
+++ b/sound/isa/gus/gusextreme.c
@@ -22,7 +22,7 @@
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h> 25#include <linux/isa.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
@@ -37,8 +37,11 @@
37#define SNDRV_LEGACY_FIND_FREE_DMA 37#define SNDRV_LEGACY_FIND_FREE_DMA
38#include <sound/initval.h> 38#include <sound/initval.h>
39 39
40#define CRD_NAME "Gravis UltraSound Extreme"
41#define DEV_NAME "gusextreme"
42
43MODULE_DESCRIPTION(CRD_NAME);
40MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 44MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
41MODULE_DESCRIPTION("Gravis UltraSound Extreme");
42MODULE_LICENSE("GPL"); 45MODULE_LICENSE("GPL");
43MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Extreme}}"); 46MODULE_SUPPORTED_DEVICE("{{Gravis,UltraSound Extreme}}");
44 47
@@ -59,43 +62,107 @@ static int channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 24};
59static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2}; 62static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
60 63
61module_param_array(index, int, NULL, 0444); 64module_param_array(index, int, NULL, 0444);
62MODULE_PARM_DESC(index, "Index value for GUS Extreme soundcard."); 65MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard.");
63module_param_array(id, charp, NULL, 0444); 66module_param_array(id, charp, NULL, 0444);
64MODULE_PARM_DESC(id, "ID string for GUS Extreme soundcard."); 67MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard.");
65module_param_array(enable, bool, NULL, 0444); 68module_param_array(enable, bool, NULL, 0444);
66MODULE_PARM_DESC(enable, "Enable GUS Extreme soundcard."); 69MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard.");
67module_param_array(port, long, NULL, 0444); 70module_param_array(port, long, NULL, 0444);
68MODULE_PARM_DESC(port, "Port # for GUS Extreme driver."); 71MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver.");
69module_param_array(gf1_port, long, NULL, 0444); 72module_param_array(gf1_port, long, NULL, 0444);
70MODULE_PARM_DESC(gf1_port, "GF1 port # for GUS Extreme driver (optional)."); 73MODULE_PARM_DESC(gf1_port, "GF1 port # for " CRD_NAME " driver (optional).");
71module_param_array(mpu_port, long, NULL, 0444); 74module_param_array(mpu_port, long, NULL, 0444);
72MODULE_PARM_DESC(mpu_port, "MPU-401 port # for GUS Extreme driver."); 75MODULE_PARM_DESC(mpu_port, "MPU-401 port # for " CRD_NAME " driver.");
73module_param_array(irq, int, NULL, 0444); 76module_param_array(irq, int, NULL, 0444);
74MODULE_PARM_DESC(irq, "IRQ # for GUS Extreme driver."); 77MODULE_PARM_DESC(irq, "IRQ # for " CRD_NAME " driver.");
75module_param_array(mpu_irq, int, NULL, 0444); 78module_param_array(mpu_irq, int, NULL, 0444);
76MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for GUS Extreme driver."); 79MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for " CRD_NAME " driver.");
77module_param_array(gf1_irq, int, NULL, 0444); 80module_param_array(gf1_irq, int, NULL, 0444);
78MODULE_PARM_DESC(gf1_irq, "GF1 IRQ # for GUS Extreme driver."); 81MODULE_PARM_DESC(gf1_irq, "GF1 IRQ # for " CRD_NAME " driver.");
79module_param_array(dma8, int, NULL, 0444); 82module_param_array(dma8, int, NULL, 0444);
80MODULE_PARM_DESC(dma8, "8-bit DMA # for GUS Extreme driver."); 83MODULE_PARM_DESC(dma8, "8-bit DMA # for " CRD_NAME " driver.");
81module_param_array(dma1, int, NULL, 0444); 84module_param_array(dma1, int, NULL, 0444);
82MODULE_PARM_DESC(dma1, "GF1 DMA # for GUS Extreme driver."); 85MODULE_PARM_DESC(dma1, "GF1 DMA # for " CRD_NAME " driver.");
83module_param_array(joystick_dac, int, NULL, 0444); 86module_param_array(joystick_dac, int, NULL, 0444);
84MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for GUS Extreme driver."); 87MODULE_PARM_DESC(joystick_dac, "Joystick DAC level 0.59V-4.52V or 0.389V-2.98V for " CRD_NAME " driver.");
85module_param_array(channels, int, NULL, 0444); 88module_param_array(channels, int, NULL, 0444);
86MODULE_PARM_DESC(channels, "GF1 channels for GUS Extreme driver."); 89MODULE_PARM_DESC(channels, "GF1 channels for " CRD_NAME " driver.");
87module_param_array(pcm_channels, int, NULL, 0444); 90module_param_array(pcm_channels, int, NULL, 0444);
88MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver."); 91MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for " CRD_NAME " driver.");
92
93static int __devinit snd_gusextreme_match(struct device *dev, unsigned int n)
94{
95 return enable[n];
96}
97
98static int __devinit snd_gusextreme_es1688_create(struct snd_card *card,
99 struct device *dev, unsigned int n, struct snd_es1688 **rchip)
100{
101 static long possible_ports[] = {0x220, 0x240, 0x260};
102 static int possible_irqs[] = {5, 9, 10, 7, -1};
103 static int possible_dmas[] = {1, 3, 0, -1};
104
105 int i, error;
106
107 if (irq[n] == SNDRV_AUTO_IRQ) {
108 irq[n] = snd_legacy_find_free_irq(possible_irqs);
109 if (irq[n] < 0) {
110 snd_printk(KERN_ERR "%s: unable to find a free IRQ "
111 "for ES1688\n", dev->bus_id);
112 return -EBUSY;
113 }
114 }
115 if (dma8[n] == SNDRV_AUTO_DMA) {
116 dma8[n] = snd_legacy_find_free_dma(possible_dmas);
117 if (dma8[n] < 0) {
118 snd_printk(KERN_ERR "%s: unable to find a free DMA "
119 "for ES1688\n", dev->bus_id);
120 return -EBUSY;
121 }
122 }
89 123
90static struct platform_device *devices[SNDRV_CARDS]; 124 if (port[n] != SNDRV_AUTO_PORT)
125 return snd_es1688_create(card, port[n], mpu_port[n], irq[n],
126 mpu_irq[n], dma8[n], ES1688_HW_1688, rchip);
91 127
128 i = 0;
129 do {
130 port[n] = possible_ports[i];
131 error = snd_es1688_create(card, port[n], mpu_port[n], irq[n],
132 mpu_irq[n], dma8[n], ES1688_HW_1688, rchip);
133 } while (error < 0 && ++i < ARRAY_SIZE(possible_ports));
92 134
93#define PFX "gusextreme: " 135 return error;
136}
94 137
95static int __devinit snd_gusextreme_detect(int dev, 138static int __devinit snd_gusextreme_gus_card_create(struct snd_card *card,
96 struct snd_card *card, 139 struct device *dev, unsigned int n, struct snd_gus_card **rgus)
97 struct snd_gus_card * gus, 140{
98 struct snd_es1688 *es1688) 141 static int possible_irqs[] = {11, 12, 15, 9, 5, 7, 3, -1};
142 static int possible_dmas[] = {5, 6, 7, 3, 1, -1};
143
144 if (gf1_irq[n] == SNDRV_AUTO_IRQ) {
145 gf1_irq[n] = snd_legacy_find_free_irq(possible_irqs);
146 if (gf1_irq[n] < 0) {
147 snd_printk(KERN_ERR "%s: unable to find a free IRQ "
148 "for GF1\n", dev->bus_id);
149 return -EBUSY;
150 }
151 }
152 if (dma1[n] == SNDRV_AUTO_DMA) {
153 dma1[n] = snd_legacy_find_free_dma(possible_dmas);
154 if (dma1[n] < 0) {
155 snd_printk(KERN_ERR "%s: unable to find a free DMA "
156 "for GF1\n", dev->bus_id);
157 return -EBUSY;
158 }
159 }
160 return snd_gus_create(card, gf1_port[n], gf1_irq[n], dma1[n], -1,
161 0, channels[n], pcm_channels[n], 0, rgus);
162}
163
164static int __devinit snd_gusextreme_detect(struct snd_gus_card *gus,
165 struct snd_es1688 *es1688)
99{ 166{
100 unsigned long flags; 167 unsigned long flags;
101 unsigned char d; 168 unsigned char d;
@@ -117,12 +184,13 @@ static int __devinit snd_gusextreme_detect(int dev,
117 spin_lock_irqsave(&es1688->mixer_lock, flags); 184 spin_lock_irqsave(&es1688->mixer_lock, flags);
118 snd_es1688_mixer_write(es1688, 0x40, 0x0b); /* don't change!!! */ 185 snd_es1688_mixer_write(es1688, 0x40, 0x0b); /* don't change!!! */
119 spin_unlock_irqrestore(&es1688->mixer_lock, flags); 186 spin_unlock_irqrestore(&es1688->mixer_lock, flags);
187
120 spin_lock_irqsave(&es1688->reg_lock, flags); 188 spin_lock_irqsave(&es1688->reg_lock, flags);
121 outb(gf1_port[dev] & 0x040 ? 2 : 0, ES1688P(es1688, INIT1)); 189 outb(gus->gf1.port & 0x040 ? 2 : 0, ES1688P(es1688, INIT1));
122 outb(0, 0x201); 190 outb(0, 0x201);
123 outb(gf1_port[dev] & 0x020 ? 2 : 0, ES1688P(es1688, INIT1)); 191 outb(gus->gf1.port & 0x020 ? 2 : 0, ES1688P(es1688, INIT1));
124 outb(0, 0x201); 192 outb(0, 0x201);
125 outb(gf1_port[dev] & 0x010 ? 3 : 1, ES1688P(es1688, INIT1)); 193 outb(gus->gf1.port & 0x010 ? 3 : 1, ES1688P(es1688, INIT1));
126 spin_unlock_irqrestore(&es1688->reg_lock, flags); 194 spin_unlock_irqrestore(&es1688->reg_lock, flags);
127 195
128 udelay(100); 196 udelay(100);
@@ -139,253 +207,172 @@ static int __devinit snd_gusextreme_detect(int dev,
139 snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d); 207 snd_printdd("[0x%lx] check 2 failed - 0x%x\n", gus->gf1.port, d);
140 return -EIO; 208 return -EIO;
141 } 209 }
142 return 0;
143}
144 210
145static void __devinit snd_gusextreme_init(int dev, struct snd_gus_card * gus) 211 return 0;
146{
147 gus->joystick_dac = joystick_dac[dev];
148} 212}
149 213
150static int __devinit snd_gusextreme_mixer(struct snd_es1688 *chip) 214static int __devinit snd_gusextreme_mixer(struct snd_es1688 *chip)
151{ 215{
152 struct snd_card *card = chip->card; 216 struct snd_card *card = chip->card;
153 struct snd_ctl_elem_id id1, id2; 217 struct snd_ctl_elem_id id1, id2;
154 int err; 218 int error;
155 219
156 memset(&id1, 0, sizeof(id1)); 220 memset(&id1, 0, sizeof(id1));
157 memset(&id2, 0, sizeof(id2)); 221 memset(&id2, 0, sizeof(id2));
158 id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 222 id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
223
159 /* reassign AUX to SYNTHESIZER */ 224 /* reassign AUX to SYNTHESIZER */
160 strcpy(id1.name, "Aux Playback Volume"); 225 strcpy(id1.name, "Aux Playback Volume");
161 strcpy(id2.name, "Synth Playback Volume"); 226 strcpy(id2.name, "Synth Playback Volume");
162 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) 227 error = snd_ctl_rename_id(card, &id1, &id2);
163 return err; 228 if (error < 0)
229 return error;
230
164 /* reassign Master Playback Switch to Synth Playback Switch */ 231 /* reassign Master Playback Switch to Synth Playback Switch */
165 strcpy(id1.name, "Master Playback Switch"); 232 strcpy(id1.name, "Master Playback Switch");
166 strcpy(id2.name, "Synth Playback Switch"); 233 strcpy(id2.name, "Synth Playback Switch");
167 if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) 234 error = snd_ctl_rename_id(card, &id1, &id2);
168 return err; 235 if (error < 0)
236 return error;
237
169 return 0; 238 return 0;
170} 239}
171 240
172static int __devinit snd_gusextreme_probe(struct platform_device *pdev) 241static int __devinit snd_gusextreme_probe(struct device *dev, unsigned int n)
173{ 242{
174 int dev = pdev->id;
175 static int possible_ess_irqs[] = {5, 9, 10, 7, -1};
176 static int possible_ess_dmas[] = {1, 3, 0, -1};
177 static int possible_gf1_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
178 static int possible_gf1_dmas[] = {5, 6, 7, 1, 3, -1};
179 int xgf1_irq, xgf1_dma, xess_irq, xmpu_irq, xess_dma;
180 struct snd_card *card; 243 struct snd_card *card;
181 struct snd_gus_card *gus; 244 struct snd_gus_card *gus;
182 struct snd_es1688 *es1688; 245 struct snd_es1688 *es1688;
183 struct snd_opl3 *opl3; 246 struct snd_opl3 *opl3;
184 int err; 247 int error;
185 248
186 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 249 card = snd_card_new(index[n], id[n], THIS_MODULE, 0);
187 if (card == NULL) 250 if (!card)
188 return -ENOMEM; 251 return -EINVAL;
189 252
190 xgf1_irq = gf1_irq[dev]; 253 if (mpu_port[n] == SNDRV_AUTO_PORT)
191 if (xgf1_irq == SNDRV_AUTO_IRQ) { 254 mpu_port[n] = 0;
192 if ((xgf1_irq = snd_legacy_find_free_irq(possible_gf1_irqs)) < 0) {
193 snd_printk(KERN_ERR PFX "unable to find a free IRQ for GF1\n");
194 err = -EBUSY;
195 goto out;
196 }
197 }
198 xess_irq = irq[dev];
199 if (xess_irq == SNDRV_AUTO_IRQ) {
200 if ((xess_irq = snd_legacy_find_free_irq(possible_ess_irqs)) < 0) {
201 snd_printk(KERN_ERR PFX "unable to find a free IRQ for ES1688\n");
202 err = -EBUSY;
203 goto out;
204 }
205 }
206 if (mpu_port[dev] == SNDRV_AUTO_PORT)
207 mpu_port[dev] = 0;
208 xmpu_irq = mpu_irq[dev];
209 if (xmpu_irq > 15)
210 xmpu_irq = -1;
211 xgf1_dma = dma1[dev];
212 if (xgf1_dma == SNDRV_AUTO_DMA) {
213 if ((xgf1_dma = snd_legacy_find_free_dma(possible_gf1_dmas)) < 0) {
214 snd_printk(KERN_ERR PFX "unable to find a free DMA for GF1\n");
215 err = -EBUSY;
216 goto out;
217 }
218 }
219 xess_dma = dma8[dev];
220 if (xess_dma == SNDRV_AUTO_DMA) {
221 if ((xess_dma = snd_legacy_find_free_dma(possible_ess_dmas)) < 0) {
222 snd_printk(KERN_ERR PFX "unable to find a free DMA for ES1688\n");
223 err = -EBUSY;
224 goto out;
225 }
226 }
227 255
228 if (port[dev] != SNDRV_AUTO_PORT) { 256 if (mpu_irq[n] > 15)
229 err = snd_es1688_create(card, port[dev], mpu_port[dev], 257 mpu_irq[n] = -1;
230 xess_irq, xmpu_irq, xess_dma, 258
231 ES1688_HW_1688, &es1688); 259 error = snd_gusextreme_es1688_create(card, dev, n, &es1688);
232 } else { 260 if (error < 0)
233 /* auto-probe legacy ports */
234 static unsigned long possible_ports[] = {0x220, 0x240, 0x260};
235 int i;
236 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
237 err = snd_es1688_create(card,
238 possible_ports[i],
239 mpu_port[dev],
240 xess_irq, xmpu_irq, xess_dma,
241 ES1688_HW_1688, &es1688);
242 if (err >= 0) {
243 port[dev] = possible_ports[i];
244 break;
245 }
246 }
247 }
248 if (err < 0)
249 goto out; 261 goto out;
250 262
251 if (gf1_port[dev] < 0) 263 if (gf1_port[n] < 0)
252 gf1_port[dev] = port[dev] + 0x20; 264 gf1_port[n] = es1688->port + 0x20;
253 if ((err = snd_gus_create(card, 265
254 gf1_port[dev], 266 error = snd_gusextreme_gus_card_create(card, dev, n, &gus);
255 xgf1_irq, 267 if (error < 0)
256 xgf1_dma,
257 -1,
258 0, channels[dev],
259 pcm_channels[dev], 0,
260 &gus)) < 0)
261 goto out; 268 goto out;
262 269
263 if ((err = snd_gusextreme_detect(dev, card, gus, es1688)) < 0) 270 error = snd_gusextreme_detect(gus, es1688);
271 if (error < 0)
264 goto out; 272 goto out;
265 273
266 snd_gusextreme_init(dev, gus); 274 gus->joystick_dac = joystick_dac[n];
267 if ((err = snd_gus_initialize(gus)) < 0) 275
276 error = snd_gus_initialize(gus);
277 if (error < 0)
268 goto out; 278 goto out;
269 279
280 error = -ENODEV;
270 if (!gus->ess_flag) { 281 if (!gus->ess_flag) {
271 snd_printk(KERN_ERR PFX "GUS Extreme soundcard was not detected at 0x%lx\n", gus->gf1.port); 282 snd_printk(KERN_ERR "%s: GUS Extreme soundcard was not "
272 err = -ENODEV; 283 "detected at 0x%lx\n", dev->bus_id, gus->gf1.port);
273 goto out; 284 goto out;
274 } 285 }
275 if ((err = snd_es1688_pcm(es1688, 0, NULL)) < 0) 286 gus->codec_flag = 1;
287
288 error = snd_es1688_pcm(es1688, 0, NULL);
289 if (error < 0)
276 goto out; 290 goto out;
277 291
278 if ((err = snd_es1688_mixer(es1688)) < 0) 292 error = snd_es1688_mixer(es1688);
293 if (error < 0)
279 goto out; 294 goto out;
280 295
281 snd_component_add(card, "ES1688"); 296 snd_component_add(card, "ES1688");
282 if (pcm_channels[dev] > 0) { 297
283 if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) 298 if (pcm_channels[n] > 0) {
299 error = snd_gf1_pcm_new(gus, 1, 1, NULL);
300 if (error < 0)
284 goto out; 301 goto out;
285 } 302 }
286 if ((err = snd_gf1_new_mixer(gus)) < 0) 303
304 error = snd_gf1_new_mixer(gus);
305 if (error < 0)
287 goto out; 306 goto out;
288 307
289 if ((err = snd_gusextreme_mixer(es1688)) < 0) 308 error = snd_gusextreme_mixer(es1688);
309 if (error < 0)
290 goto out; 310 goto out;
291 311
292 if (snd_opl3_create(card, es1688->port, es1688->port + 2, 312 if (snd_opl3_create(card, es1688->port, es1688->port + 2,
293 OPL3_HW_OPL3, 0, &opl3) < 0) { 313 OPL3_HW_OPL3, 0, &opl3) < 0)
294 printk(KERN_ERR PFX "gusextreme: opl3 not detected at 0x%lx\n", es1688->port); 314 printk(KERN_ERR "%s: opl3 not detected at 0x%lx\n",
295 } else { 315 dev->bus_id, es1688->port);
296 if ((err = snd_opl3_hwdep_new(opl3, 0, 2, NULL)) < 0) 316 else {
317 error = snd_opl3_hwdep_new(opl3, 0, 2, NULL);
318 if (error < 0)
297 goto out; 319 goto out;
298 } 320 }
299 321
300 if (es1688->mpu_port >= 0x300 && 322 if (es1688->mpu_port >= 0x300) {
301 (err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688, 323 error = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688,
302 es1688->mpu_port, 0, 324 es1688->mpu_port, 0,
303 xmpu_irq, 325 mpu_irq[n], IRQF_DISABLED, NULL);
304 IRQF_DISABLED, 326 if (error < 0)
305 NULL)) < 0) 327 goto out;
306 goto out; 328 }
307 329
308 sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, irq %i&%i, dma %i&%i", 330 sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, "
309 es1688->port, xgf1_irq, xess_irq, xgf1_dma, xess_dma); 331 "irq %i&%i, dma %i&%i", es1688->port,
332 gus->gf1.irq, es1688->irq, gus->gf1.dma1, es1688->dma8);
310 333
311 snd_card_set_dev(card, &pdev->dev); 334 snd_card_set_dev(card, dev);
312 335
313 if ((err = snd_card_register(card)) < 0) 336 error = snd_card_register(card);
337 if (error < 0)
314 goto out; 338 goto out;
315 339
316 platform_set_drvdata(pdev, card); 340 dev_set_drvdata(dev, card);
317 return 0; 341 return 0;
318 342
319 out: 343out: snd_card_free(card);
320 snd_card_free(card); 344 return error;
321 return err;
322} 345}
323 346
324static int __devexit snd_gusextreme_remove(struct platform_device *devptr) 347static int __devexit snd_gusextreme_remove(struct device *dev, unsigned int n)
325{ 348{
326 snd_card_free(platform_get_drvdata(devptr)); 349 snd_card_free(dev_get_drvdata(dev));
327 platform_set_drvdata(devptr, NULL); 350 dev_set_drvdata(dev, NULL);
328 return 0; 351 return 0;
329} 352}
330 353
331#define GUSEXTREME_DRIVER "snd_gusextreme" 354static struct isa_driver snd_gusextreme_driver = {
332 355 .match = snd_gusextreme_match,
333static struct platform_driver snd_gusextreme_driver = {
334 .probe = snd_gusextreme_probe, 356 .probe = snd_gusextreme_probe,
335 .remove = __devexit_p(snd_gusextreme_remove), 357 .remove = snd_gusextreme_remove,
336 /* FIXME: suspend/resume */ 358#if 0 /* FIXME */
359 .suspend = snd_gusextreme_suspend,
360 .resume = snd_gusextreme_resume,
361#endif
337 .driver = { 362 .driver = {
338 .name = GUSEXTREME_DRIVER 363 .name = DEV_NAME
339 }, 364 }
340}; 365};
341 366
342static void __init_or_module snd_gusextreme_unregister_all(void)
343{
344 int i;
345
346 for (i = 0; i < ARRAY_SIZE(devices); ++i)
347 platform_device_unregister(devices[i]);
348 platform_driver_unregister(&snd_gusextreme_driver);
349}
350
351static int __init alsa_card_gusextreme_init(void) 367static int __init alsa_card_gusextreme_init(void)
352{ 368{
353 int i, cards, err; 369 return isa_register_driver(&snd_gusextreme_driver, SNDRV_CARDS);
354
355 err = platform_driver_register(&snd_gusextreme_driver);
356 if (err < 0)
357 return err;
358
359 cards = 0;
360 for (i = 0; i < SNDRV_CARDS; i++) {
361 struct platform_device *device;
362 if (! enable[i])
363 continue;
364 device = platform_device_register_simple(GUSEXTREME_DRIVER,
365 i, NULL, 0);
366 if (IS_ERR(device))
367 continue;
368 if (!platform_get_drvdata(device)) {
369 platform_device_unregister(device);
370 continue;
371 }
372 devices[i] = device;
373 cards++;
374 }
375 if (!cards) {
376#ifdef MODULE
377 printk(KERN_ERR "GUS Extreme soundcard not found or device busy\n");
378#endif
379 snd_gusextreme_unregister_all();
380 return -ENODEV;
381 }
382 return 0;
383} 370}
384 371
385static void __exit alsa_card_gusextreme_exit(void) 372static void __exit alsa_card_gusextreme_exit(void)
386{ 373{
387 snd_gusextreme_unregister_all(); 374 isa_unregister_driver(&snd_gusextreme_driver);
388} 375}
389 376
390module_init(alsa_card_gusextreme_init) 377module_init(alsa_card_gusextreme_init);
391module_exit(alsa_card_gusextreme_exit) 378module_exit(alsa_card_gusextreme_exit);
diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c
index d1ad90ca035d..708783d4351f 100644
--- a/sound/isa/gus/gusmax.c
+++ b/sound/isa/gus/gusmax.c
@@ -22,7 +22,7 @@
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h> 25#include <linux/isa.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
@@ -72,8 +72,6 @@ MODULE_PARM_DESC(channels, "Used GF1 channels for GUS MAX driver.");
72module_param_array(pcm_channels, int, NULL, 0444); 72module_param_array(pcm_channels, int, NULL, 0444);
73MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver."); 73MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver.");
74 74
75static struct platform_device *devices[SNDRV_CARDS];
76
77struct snd_gusmax { 75struct snd_gusmax {
78 int irq; 76 int irq;
79 struct snd_card *card; 77 struct snd_card *card;
@@ -205,9 +203,13 @@ static void snd_gusmax_free(struct snd_card *card)
205 free_irq(maxcard->irq, (void *)maxcard); 203 free_irq(maxcard->irq, (void *)maxcard);
206} 204}
207 205
208static int __devinit snd_gusmax_probe(struct platform_device *pdev) 206static int __devinit snd_gusmax_match(struct device *pdev, unsigned int dev)
207{
208 return enable[dev];
209}
210
211static int __devinit snd_gusmax_probe(struct device *pdev, unsigned int dev)
209{ 212{
210 int dev = pdev->id;
211 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; 213 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
212 static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; 214 static int possible_dmas[] = {5, 6, 7, 1, 3, -1};
213 int xirq, xdma1, xdma2, err; 215 int xirq, xdma1, xdma2, err;
@@ -333,7 +335,7 @@ static int __devinit snd_gusmax_probe(struct platform_device *pdev)
333 if (xdma2 >= 0) 335 if (xdma2 >= 0)
334 sprintf(card->longname + strlen(card->longname), "&%i", xdma2); 336 sprintf(card->longname + strlen(card->longname), "&%i", xdma2);
335 337
336 snd_card_set_dev(card, &pdev->dev); 338 snd_card_set_dev(card, pdev);
337 339
338 if ((err = snd_card_register(card)) < 0) 340 if ((err = snd_card_register(card)) < 0)
339 goto _err; 341 goto _err;
@@ -341,7 +343,7 @@ static int __devinit snd_gusmax_probe(struct platform_device *pdev)
341 maxcard->gus = gus; 343 maxcard->gus = gus;
342 maxcard->cs4231 = cs4231; 344 maxcard->cs4231 = cs4231;
343 345
344 platform_set_drvdata(pdev, card); 346 dev_set_drvdata(pdev, card);
345 return 0; 347 return 0;
346 348
347 _err: 349 _err:
@@ -349,70 +351,33 @@ static int __devinit snd_gusmax_probe(struct platform_device *pdev)
349 return err; 351 return err;
350} 352}
351 353
352static int __devexit snd_gusmax_remove(struct platform_device *devptr) 354static int __devexit snd_gusmax_remove(struct device *devptr, unsigned int dev)
353{ 355{
354 snd_card_free(platform_get_drvdata(devptr)); 356 snd_card_free(dev_get_drvdata(devptr));
355 platform_set_drvdata(devptr, NULL); 357 dev_set_drvdata(devptr, NULL);
356 return 0; 358 return 0;
357} 359}
358 360
359#define GUSMAX_DRIVER "snd_gusmax" 361#define DEV_NAME "gusmax"
360 362
361static struct platform_driver snd_gusmax_driver = { 363static struct isa_driver snd_gusmax_driver = {
364 .match = snd_gusmax_match,
362 .probe = snd_gusmax_probe, 365 .probe = snd_gusmax_probe,
363 .remove = __devexit_p(snd_gusmax_remove), 366 .remove = __devexit_p(snd_gusmax_remove),
364 /* FIXME: suspend/resume */ 367 /* FIXME: suspend/resume */
365 .driver = { 368 .driver = {
366 .name = GUSMAX_DRIVER 369 .name = DEV_NAME
367 }, 370 },
368}; 371};
369 372
370static void __init_or_module snd_gusmax_unregister_all(void)
371{
372 int i;
373
374 for (i = 0; i < ARRAY_SIZE(devices); ++i)
375 platform_device_unregister(devices[i]);
376 platform_driver_unregister(&snd_gusmax_driver);
377}
378
379static int __init alsa_card_gusmax_init(void) 373static int __init alsa_card_gusmax_init(void)
380{ 374{
381 int i, cards, err; 375 return isa_register_driver(&snd_gusmax_driver, SNDRV_CARDS);
382
383 err = platform_driver_register(&snd_gusmax_driver);
384 if (err < 0)
385 return err;
386
387 cards = 0;
388 for (i = 0; i < SNDRV_CARDS; i++) {
389 struct platform_device *device;
390 if (! enable[i])
391 continue;
392 device = platform_device_register_simple(GUSMAX_DRIVER,
393 i, NULL, 0);
394 if (IS_ERR(device))
395 continue;
396 if (!platform_get_drvdata(device)) {
397 platform_device_unregister(device);
398 continue;
399 }
400 devices[i] = device;
401 cards++;
402 }
403 if (!cards) {
404#ifdef MODULE
405 printk(KERN_ERR "GUS MAX soundcard not found or device busy\n");
406#endif
407 snd_gusmax_unregister_all();
408 return -ENODEV;
409 }
410 return 0;
411} 376}
412 377
413static void __exit alsa_card_gusmax_exit(void) 378static void __exit alsa_card_gusmax_exit(void)
414{ 379{
415 snd_gusmax_unregister_all(); 380 isa_unregister_driver(&snd_gusmax_driver);
416} 381}
417 382
418module_init(alsa_card_gusmax_init) 383module_init(alsa_card_gusmax_init)
diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c
index 4ec2d79431fc..3e4657255536 100644
--- a/sound/isa/gus/interwave.c
+++ b/sound/isa/gus/interwave.c
@@ -25,7 +25,7 @@
25#include <sound/driver.h> 25#include <sound/driver.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/err.h> 27#include <linux/err.h>
28#include <linux/platform_device.h> 28#include <linux/isa.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/pnp.h> 31#include <linux/pnp.h>
@@ -115,9 +115,6 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for InterWave driver.");
115module_param_array(effect, int, NULL, 0444); 115module_param_array(effect, int, NULL, 0444);
116MODULE_PARM_DESC(effect, "Effects enable for InterWave driver."); 116MODULE_PARM_DESC(effect, "Effects enable for InterWave driver.");
117 117
118static struct platform_device *platform_devices[SNDRV_CARDS];
119static int pnp_registered;
120
121struct snd_interwave { 118struct snd_interwave {
122 int irq; 119 int irq;
123 struct snd_card *card; 120 struct snd_card *card;
@@ -138,6 +135,7 @@ struct snd_interwave {
138 135
139 136
140#ifdef CONFIG_PNP 137#ifdef CONFIG_PNP
138static int pnp_registered;
141 139
142static struct pnp_card_device_id snd_interwave_pnpids[] = { 140static struct pnp_card_device_id snd_interwave_pnpids[] = {
143#ifndef SNDRV_STB 141#ifndef SNDRV_STB
@@ -793,7 +791,7 @@ static int __devinit snd_interwave_probe(struct snd_card *card, int dev)
793 return 0; 791 return 0;
794} 792}
795 793
796static int __devinit snd_interwave_nonpnp_probe1(int dev, struct platform_device *devptr) 794static int __devinit snd_interwave_isa_probe1(int dev, struct device *devptr)
797{ 795{
798 struct snd_card *card; 796 struct snd_card *card;
799 int err; 797 int err;
@@ -802,18 +800,30 @@ static int __devinit snd_interwave_nonpnp_probe1(int dev, struct platform_device
802 if (! card) 800 if (! card)
803 return -ENOMEM; 801 return -ENOMEM;
804 802
805 snd_card_set_dev(card, &devptr->dev); 803 snd_card_set_dev(card, devptr);
806 if ((err = snd_interwave_probe(card, dev)) < 0) { 804 if ((err = snd_interwave_probe(card, dev)) < 0) {
807 snd_card_free(card); 805 snd_card_free(card);
808 return err; 806 return err;
809 } 807 }
810 platform_set_drvdata(devptr, card); 808 dev_set_drvdata(devptr, card);
811 return 0; 809 return 0;
812} 810}
813 811
814static int __devinit snd_interwave_nonpnp_probe(struct platform_device *pdev) 812static int __devinit snd_interwave_isa_match(struct device *pdev,
813 unsigned int dev)
814{
815 if (!enable[dev])
816 return 0;
817#ifdef CONFIG_PNP
818 if (isapnp[dev])
819 return 0;
820#endif
821 return 1;
822}
823
824static int __devinit snd_interwave_isa_probe(struct device *pdev,
825 unsigned int dev)
815{ 826{
816 int dev = pdev->id;
817 int err; 827 int err;
818 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; 828 static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1};
819 static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1}; 829 static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1};
@@ -838,13 +848,13 @@ static int __devinit snd_interwave_nonpnp_probe(struct platform_device *pdev)
838 } 848 }
839 849
840 if (port[dev] != SNDRV_AUTO_PORT) 850 if (port[dev] != SNDRV_AUTO_PORT)
841 return snd_interwave_nonpnp_probe1(dev, pdev); 851 return snd_interwave_isa_probe1(dev, pdev);
842 else { 852 else {
843 static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260}; 853 static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260};
844 int i; 854 int i;
845 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { 855 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
846 port[dev] = possible_ports[i]; 856 port[dev] = possible_ports[i];
847 err = snd_interwave_nonpnp_probe1(dev, pdev); 857 err = snd_interwave_isa_probe1(dev, pdev);
848 if (! err) 858 if (! err)
849 return 0; 859 return 0;
850 } 860 }
@@ -852,16 +862,17 @@ static int __devinit snd_interwave_nonpnp_probe(struct platform_device *pdev)
852 } 862 }
853} 863}
854 864
855static int __devexit snd_interwave_nonpnp_remove(struct platform_device *devptr) 865static int __devexit snd_interwave_isa_remove(struct device *devptr, unsigned int dev)
856{ 866{
857 snd_card_free(platform_get_drvdata(devptr)); 867 snd_card_free(dev_get_drvdata(devptr));
858 platform_set_drvdata(devptr, NULL); 868 dev_set_drvdata(devptr, NULL);
859 return 0; 869 return 0;
860} 870}
861 871
862static struct platform_driver snd_interwave_driver = { 872static struct isa_driver snd_interwave_driver = {
863 .probe = snd_interwave_nonpnp_probe, 873 .match = snd_interwave_isa_match,
864 .remove = __devexit_p(snd_interwave_nonpnp_remove), 874 .probe = snd_interwave_isa_probe,
875 .remove = __devexit_p(snd_interwave_isa_remove),
865 /* FIXME: suspend,resume */ 876 /* FIXME: suspend,resume */
866 .driver = { 877 .driver = {
867 .name = INTERWAVE_DRIVER 878 .name = INTERWAVE_DRIVER
@@ -869,8 +880,6 @@ static struct platform_driver snd_interwave_driver = {
869}; 880};
870 881
871#ifdef CONFIG_PNP 882#ifdef CONFIG_PNP
872static unsigned int __devinitdata interwave_pnp_devices;
873
874static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard, 883static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard,
875 const struct pnp_card_device_id *pid) 884 const struct pnp_card_device_id *pid)
876{ 885{
@@ -900,7 +909,6 @@ static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard,
900 } 909 }
901 pnp_set_card_drvdata(pcard, card); 910 pnp_set_card_drvdata(pcard, card);
902 dev++; 911 dev++;
903 interwave_pnp_devices++;
904 return 0; 912 return 0;
905} 913}
906 914
@@ -921,64 +929,29 @@ static struct pnp_card_driver interwave_pnpc_driver = {
921 929
922#endif /* CONFIG_PNP */ 930#endif /* CONFIG_PNP */
923 931
924static void __init_or_module snd_interwave_unregister_all(void)
925{
926 int i;
927
928 if (pnp_registered)
929 pnp_unregister_card_driver(&interwave_pnpc_driver);
930 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
931 platform_device_unregister(platform_devices[i]);
932 platform_driver_unregister(&snd_interwave_driver);
933}
934
935static int __init alsa_card_interwave_init(void) 932static int __init alsa_card_interwave_init(void)
936{ 933{
937 int i, err, cards = 0; 934 int err;
938 935
939 if ((err = platform_driver_register(&snd_interwave_driver)) < 0) 936 err = isa_register_driver(&snd_interwave_driver, SNDRV_CARDS);
937 if (err < 0)
940 return err; 938 return err;
941
942 for (i = 0; i < SNDRV_CARDS; i++) {
943 struct platform_device *device;
944 if (! enable[i])
945 continue;
946#ifdef CONFIG_PNP 939#ifdef CONFIG_PNP
947 if (isapnp[i])
948 continue;
949#endif
950 device = platform_device_register_simple(INTERWAVE_DRIVER,
951 i, NULL, 0);
952 if (IS_ERR(device))
953 continue;
954 if (!platform_get_drvdata(device)) {
955 platform_device_unregister(device);
956 continue;
957 }
958 platform_devices[i] = device;
959 cards++;
960 }
961
962 /* ISA PnP cards */ 940 /* ISA PnP cards */
963 err = pnp_register_card_driver(&interwave_pnpc_driver); 941 err = pnp_register_card_driver(&interwave_pnpc_driver);
964 if (!err) { 942 if (!err)
965 pnp_registered = 1; 943 pnp_registered = 1;
966 cards += interwave_pnp_devices;;
967 }
968
969 if (!cards) {
970#ifdef MODULE
971 printk(KERN_ERR "InterWave soundcard not found or device busy\n");
972#endif 944#endif
973 snd_interwave_unregister_all();
974 return -ENODEV;
975 }
976 return 0; 945 return 0;
977} 946}
978 947
979static void __exit alsa_card_interwave_exit(void) 948static void __exit alsa_card_interwave_exit(void)
980{ 949{
981 snd_interwave_unregister_all(); 950#ifdef CONFIG_PNP
951 if (pnp_registered)
952 pnp_unregister_card_driver(&interwave_pnpc_driver);
953#endif
954 isa_unregister_driver(&snd_interwave_driver);
982} 955}
983 956
984module_init(alsa_card_interwave_init) 957module_init(alsa_card_interwave_init)
diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c
index f3db686b1c0c..48743eb85fb6 100644
--- a/sound/isa/opl3sa2.c
+++ b/sound/isa/opl3sa2.c
@@ -22,7 +22,7 @@
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h> 25#include <linux/isa.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/pm.h> 27#include <linux/pm.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
@@ -91,12 +91,10 @@ MODULE_PARM_DESC(dma2, "DMA2 # for OPL3-SA driver.");
91module_param_array(opl3sa3_ymode, int, NULL, 0444); 91module_param_array(opl3sa3_ymode, int, NULL, 0444);
92MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi."); 92MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi.");
93 93
94static struct platform_device *platform_devices[SNDRV_CARDS];
95#ifdef CONFIG_PNP 94#ifdef CONFIG_PNP
96static int pnp_registered; 95static int pnp_registered;
97static int pnpc_registered; 96static int pnpc_registered;
98#endif 97#endif
99static unsigned int snd_opl3sa2_devices;
100 98
101/* control ports */ 99/* control ports */
102#define OPL3SA2_PM_CTRL 0x01 100#define OPL3SA2_PM_CTRL 0x01
@@ -783,7 +781,6 @@ static int __devinit snd_opl3sa2_pnp_detect(struct pnp_dev *pdev,
783 } 781 }
784 pnp_set_drvdata(pdev, card); 782 pnp_set_drvdata(pdev, card);
785 dev++; 783 dev++;
786 snd_opl3sa2_devices++;
787 return 0; 784 return 0;
788} 785}
789 786
@@ -850,7 +847,6 @@ static int __devinit snd_opl3sa2_pnp_cdetect(struct pnp_card_link *pcard,
850 } 847 }
851 pnp_set_card_drvdata(pcard, card); 848 pnp_set_card_drvdata(pcard, card);
852 dev++; 849 dev++;
853 snd_opl3sa2_devices++;
854 return 0; 850 return 0;
855} 851}
856 852
@@ -884,116 +880,95 @@ static struct pnp_card_driver opl3sa2_pnpc_driver = {
884}; 880};
885#endif /* CONFIG_PNP */ 881#endif /* CONFIG_PNP */
886 882
887static int __devinit snd_opl3sa2_nonpnp_probe(struct platform_device *pdev) 883static int __devinit snd_opl3sa2_isa_match(struct device *pdev,
884 unsigned int dev)
888{ 885{
889 struct snd_card *card; 886 if (!enable[dev])
890 int err; 887 return 0;
891 int dev = pdev->id; 888#ifdef CONFIG_PNP
892 889 if (isapnp[dev])
890 return 0;
891#endif
893 if (port[dev] == SNDRV_AUTO_PORT) { 892 if (port[dev] == SNDRV_AUTO_PORT) {
894 snd_printk(KERN_ERR PFX "specify port\n"); 893 snd_printk(KERN_ERR PFX "specify port\n");
895 return -EINVAL; 894 return 0;
896 } 895 }
897 if (wss_port[dev] == SNDRV_AUTO_PORT) { 896 if (wss_port[dev] == SNDRV_AUTO_PORT) {
898 snd_printk(KERN_ERR PFX "specify wss_port\n"); 897 snd_printk(KERN_ERR PFX "specify wss_port\n");
899 return -EINVAL; 898 return 0;
900 } 899 }
901 if (fm_port[dev] == SNDRV_AUTO_PORT) { 900 if (fm_port[dev] == SNDRV_AUTO_PORT) {
902 snd_printk(KERN_ERR PFX "specify fm_port\n"); 901 snd_printk(KERN_ERR PFX "specify fm_port\n");
903 return -EINVAL; 902 return 0;
904 } 903 }
905 if (midi_port[dev] == SNDRV_AUTO_PORT) { 904 if (midi_port[dev] == SNDRV_AUTO_PORT) {
906 snd_printk(KERN_ERR PFX "specify midi_port\n"); 905 snd_printk(KERN_ERR PFX "specify midi_port\n");
907 return -EINVAL; 906 return 0;
908 } 907 }
908 return 1;
909}
910
911static int __devinit snd_opl3sa2_isa_probe(struct device *pdev,
912 unsigned int dev)
913{
914 struct snd_card *card;
915 int err;
909 916
910 card = snd_opl3sa2_card_new(dev); 917 card = snd_opl3sa2_card_new(dev);
911 if (! card) 918 if (! card)
912 return -ENOMEM; 919 return -ENOMEM;
913 snd_card_set_dev(card, &pdev->dev); 920 snd_card_set_dev(card, pdev);
914 if ((err = snd_opl3sa2_probe(card, dev)) < 0) { 921 if ((err = snd_opl3sa2_probe(card, dev)) < 0) {
915 snd_card_free(card); 922 snd_card_free(card);
916 return err; 923 return err;
917 } 924 }
918 platform_set_drvdata(pdev, card); 925 dev_set_drvdata(pdev, card);
919 return 0; 926 return 0;
920} 927}
921 928
922static int __devexit snd_opl3sa2_nonpnp_remove(struct platform_device *devptr) 929static int __devexit snd_opl3sa2_isa_remove(struct device *devptr,
930 unsigned int dev)
923{ 931{
924 snd_card_free(platform_get_drvdata(devptr)); 932 snd_card_free(dev_get_drvdata(devptr));
925 platform_set_drvdata(devptr, NULL); 933 dev_set_drvdata(devptr, NULL);
926 return 0; 934 return 0;
927} 935}
928 936
929#ifdef CONFIG_PM 937#ifdef CONFIG_PM
930static int snd_opl3sa2_nonpnp_suspend(struct platform_device *dev, pm_message_t state) 938static int snd_opl3sa2_isa_suspend(struct device *dev, unsigned int n,
939 pm_message_t state)
931{ 940{
932 return snd_opl3sa2_suspend(platform_get_drvdata(dev), state); 941 return snd_opl3sa2_suspend(dev_get_drvdata(dev), state);
933} 942}
934 943
935static int snd_opl3sa2_nonpnp_resume(struct platform_device *dev) 944static int snd_opl3sa2_isa_resume(struct device *dev, unsigned int n)
936{ 945{
937 return snd_opl3sa2_resume(platform_get_drvdata(dev)); 946 return snd_opl3sa2_resume(dev_get_drvdata(dev));
938} 947}
939#endif 948#endif
940 949
941#define OPL3SA2_DRIVER "snd_opl3sa2" 950#define DEV_NAME "opl3sa2"
942 951
943static struct platform_driver snd_opl3sa2_nonpnp_driver = { 952static struct isa_driver snd_opl3sa2_isa_driver = {
944 .probe = snd_opl3sa2_nonpnp_probe, 953 .match = snd_opl3sa2_isa_match,
945 .remove = __devexit( snd_opl3sa2_nonpnp_remove), 954 .probe = snd_opl3sa2_isa_probe,
955 .remove = __devexit( snd_opl3sa2_isa_remove),
946#ifdef CONFIG_PM 956#ifdef CONFIG_PM
947 .suspend = snd_opl3sa2_nonpnp_suspend, 957 .suspend = snd_opl3sa2_isa_suspend,
948 .resume = snd_opl3sa2_nonpnp_resume, 958 .resume = snd_opl3sa2_isa_resume,
949#endif 959#endif
950 .driver = { 960 .driver = {
951 .name = OPL3SA2_DRIVER 961 .name = DEV_NAME
952 }, 962 },
953}; 963};
954 964
955static void __init_or_module snd_opl3sa2_unregister_all(void)
956{
957 int i;
958
959#ifdef CONFIG_PNP
960 if (pnpc_registered)
961 pnp_unregister_card_driver(&opl3sa2_pnpc_driver);
962 if (pnp_registered)
963 pnp_unregister_driver(&opl3sa2_pnp_driver);
964#endif
965 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
966 platform_device_unregister(platform_devices[i]);
967 platform_driver_unregister(&snd_opl3sa2_nonpnp_driver);
968}
969
970static int __init alsa_card_opl3sa2_init(void) 965static int __init alsa_card_opl3sa2_init(void)
971{ 966{
972 int i, err; 967 int err;
973 968
974 if ((err = platform_driver_register(&snd_opl3sa2_nonpnp_driver)) < 0) 969 err = isa_register_driver(&snd_opl3sa2_isa_driver, SNDRV_CARDS);
970 if (err < 0)
975 return err; 971 return err;
976
977 for (i = 0; i < SNDRV_CARDS; i++) {
978 struct platform_device *device;
979 if (! enable[i])
980 continue;
981#ifdef CONFIG_PNP
982 if (isapnp[i])
983 continue;
984#endif
985 device = platform_device_register_simple(OPL3SA2_DRIVER,
986 i, NULL, 0);
987 if (IS_ERR(device))
988 continue;
989 if (!platform_get_drvdata(device)) {
990 platform_device_unregister(device);
991 continue;
992 }
993 platform_devices[i] = device;
994 snd_opl3sa2_devices++;
995 }
996
997#ifdef CONFIG_PNP 972#ifdef CONFIG_PNP
998 err = pnp_register_driver(&opl3sa2_pnp_driver); 973 err = pnp_register_driver(&opl3sa2_pnp_driver);
999 if (!err) 974 if (!err)
@@ -1002,20 +977,18 @@ static int __init alsa_card_opl3sa2_init(void)
1002 if (!err) 977 if (!err)
1003 pnpc_registered = 1; 978 pnpc_registered = 1;
1004#endif 979#endif
1005
1006 if (!snd_opl3sa2_devices) {
1007#ifdef MODULE
1008 snd_printk(KERN_ERR "Yamaha OPL3-SA soundcard not found or device busy\n");
1009#endif
1010 snd_opl3sa2_unregister_all();
1011 return -ENODEV;
1012 }
1013 return 0; 980 return 0;
1014} 981}
1015 982
1016static void __exit alsa_card_opl3sa2_exit(void) 983static void __exit alsa_card_opl3sa2_exit(void)
1017{ 984{
1018 snd_opl3sa2_unregister_all(); 985#ifdef CONFIG_PNP
986 if (pnpc_registered)
987 pnp_unregister_card_driver(&opl3sa2_pnpc_driver);
988 if (pnp_registered)
989 pnp_unregister_driver(&opl3sa2_pnp_driver);
990#endif
991 isa_unregister_driver(&snd_opl3sa2_isa_driver);
1019} 992}
1020 993
1021module_init(alsa_card_opl3sa2_init) 994module_init(alsa_card_opl3sa2_init)
diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c
index 1dd98375ac85..cd29b30b362e 100644
--- a/sound/isa/opti9xx/miro.c
+++ b/sound/isa/opti9xx/miro.c
@@ -25,7 +25,7 @@
25#include <sound/driver.h> 25#include <sound/driver.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/err.h> 27#include <linux/err.h>
28#include <linux/platform_device.h> 28#include <linux/isa.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/ioport.h> 31#include <linux/ioport.h>
@@ -137,10 +137,6 @@ struct snd_miro {
137 137
138static void snd_miro_proc_init(struct snd_miro * miro); 138static void snd_miro_proc_init(struct snd_miro * miro);
139 139
140#define DRIVER_NAME "snd-miro"
141
142static struct platform_device *device;
143
144static char * snd_opti9xx_names[] = { 140static char * snd_opti9xx_names[] = {
145 "unkown", 141 "unkown",
146 "82C928", "82C929", 142 "82C928", "82C929",
@@ -558,7 +554,7 @@ static int snd_miro_put_double(struct snd_kcontrol *kcontrol,
558 return change; 554 return change;
559} 555}
560 556
561static struct snd_kcontrol_new snd_miro_controls[] = { 557static struct snd_kcontrol_new snd_miro_controls[] __devinitdata = {
562MIRO_DOUBLE("Master Playback Volume", 0, ACI_GET_MASTER, ACI_SET_MASTER), 558MIRO_DOUBLE("Master Playback Volume", 0, ACI_GET_MASTER, ACI_SET_MASTER),
563MIRO_DOUBLE("Mic Playback Volume", 1, ACI_GET_MIC, ACI_SET_MIC), 559MIRO_DOUBLE("Mic Playback Volume", 1, ACI_GET_MIC, ACI_SET_MIC),
564MIRO_DOUBLE("Line Playback Volume", 1, ACI_GET_LINE, ACI_SET_LINE), 560MIRO_DOUBLE("Line Playback Volume", 1, ACI_GET_LINE, ACI_SET_LINE),
@@ -570,7 +566,7 @@ MIRO_DOUBLE("Aux Playback Volume", 2, ACI_GET_LINE2, ACI_SET_LINE2),
570 566
571/* Equalizer with seven bands (only PCM20) 567/* Equalizer with seven bands (only PCM20)
572 from -12dB up to +12dB on each band */ 568 from -12dB up to +12dB on each band */
573static struct snd_kcontrol_new snd_miro_eq_controls[] = { 569static struct snd_kcontrol_new snd_miro_eq_controls[] __devinitdata = {
574MIRO_DOUBLE("Tone Control - 28 Hz", 0, ACI_GET_EQ1, ACI_SET_EQ1), 570MIRO_DOUBLE("Tone Control - 28 Hz", 0, ACI_GET_EQ1, ACI_SET_EQ1),
575MIRO_DOUBLE("Tone Control - 160 Hz", 0, ACI_GET_EQ2, ACI_SET_EQ2), 571MIRO_DOUBLE("Tone Control - 160 Hz", 0, ACI_GET_EQ2, ACI_SET_EQ2),
576MIRO_DOUBLE("Tone Control - 400 Hz", 0, ACI_GET_EQ3, ACI_SET_EQ3), 572MIRO_DOUBLE("Tone Control - 400 Hz", 0, ACI_GET_EQ3, ACI_SET_EQ3),
@@ -580,15 +576,15 @@ MIRO_DOUBLE("Tone Control - 6.3 kHz", 0, ACI_GET_EQ6, ACI_SET_EQ6),
580MIRO_DOUBLE("Tone Control - 16 kHz", 0, ACI_GET_EQ7, ACI_SET_EQ7), 576MIRO_DOUBLE("Tone Control - 16 kHz", 0, ACI_GET_EQ7, ACI_SET_EQ7),
581}; 577};
582 578
583static struct snd_kcontrol_new snd_miro_radio_control[] = { 579static struct snd_kcontrol_new snd_miro_radio_control[] __devinitdata = {
584MIRO_DOUBLE("Radio Playback Volume", 0, ACI_GET_LINE1, ACI_SET_LINE1), 580MIRO_DOUBLE("Radio Playback Volume", 0, ACI_GET_LINE1, ACI_SET_LINE1),
585}; 581};
586 582
587static struct snd_kcontrol_new snd_miro_line_control[] = { 583static struct snd_kcontrol_new snd_miro_line_control[] __devinitdata = {
588MIRO_DOUBLE("Line Playback Volume", 2, ACI_GET_LINE1, ACI_SET_LINE1), 584MIRO_DOUBLE("Line Playback Volume", 2, ACI_GET_LINE1, ACI_SET_LINE1),
589}; 585};
590 586
591static struct snd_kcontrol_new snd_miro_preamp_control[] = { 587static struct snd_kcontrol_new snd_miro_preamp_control[] __devinitdata = {
592{ 588{
593 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 589 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
594 .name = "Mic Boost", 590 .name = "Mic Boost",
@@ -598,7 +594,7 @@ static struct snd_kcontrol_new snd_miro_preamp_control[] = {
598 .put = snd_miro_put_preamp, 594 .put = snd_miro_put_preamp,
599}}; 595}};
600 596
601static struct snd_kcontrol_new snd_miro_amp_control[] = { 597static struct snd_kcontrol_new snd_miro_amp_control[] __devinitdata = {
602{ 598{
603 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 599 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
604 .name = "Line Boost", 600 .name = "Line Boost",
@@ -608,7 +604,7 @@ static struct snd_kcontrol_new snd_miro_amp_control[] = {
608 .put = snd_miro_put_amp, 604 .put = snd_miro_put_amp,
609}}; 605}};
610 606
611static struct snd_kcontrol_new snd_miro_capture_control[] = { 607static struct snd_kcontrol_new snd_miro_capture_control[] __devinitdata = {
612{ 608{
613 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 609 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
614 .name = "PCM Capture Switch", 610 .name = "PCM Capture Switch",
@@ -618,7 +614,7 @@ static struct snd_kcontrol_new snd_miro_capture_control[] = {
618 .put = snd_miro_put_capture, 614 .put = snd_miro_put_capture,
619}}; 615}};
620 616
621static unsigned char aci_init_values[][2] __initdata = { 617static unsigned char aci_init_values[][2] __devinitdata = {
622 { ACI_SET_MUTE, 0x00 }, 618 { ACI_SET_MUTE, 0x00 },
623 { ACI_SET_POWERAMP, 0x00 }, 619 { ACI_SET_POWERAMP, 0x00 },
624 { ACI_SET_PREAMP, 0x00 }, 620 { ACI_SET_PREAMP, 0x00 },
@@ -641,7 +637,7 @@ static unsigned char aci_init_values[][2] __initdata = {
641 { ACI_SET_MASTER + 1, 0x20 }, 637 { ACI_SET_MASTER + 1, 0x20 },
642}; 638};
643 639
644static int __init snd_set_aci_init_values(struct snd_miro *miro) 640static int __devinit snd_set_aci_init_values(struct snd_miro *miro)
645{ 641{
646 int idx, error; 642 int idx, error;
647 643
@@ -751,7 +747,8 @@ static long snd_legacy_find_free_ioport(long *port_table, long size)
751 return -1; 747 return -1;
752} 748}
753 749
754static int __init snd_miro_init(struct snd_miro *chip, unsigned short hardware) 750static int __devinit snd_miro_init(struct snd_miro *chip,
751 unsigned short hardware)
755{ 752{
756 static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2}; 753 static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2};
757 754
@@ -962,7 +959,7 @@ static void snd_miro_proc_read(struct snd_info_entry * entry,
962 snd_iprintf(buffer, " preamp : 0x%x\n", miro->aci_preamp); 959 snd_iprintf(buffer, " preamp : 0x%x\n", miro->aci_preamp);
963} 960}
964 961
965static void __init snd_miro_proc_init(struct snd_miro * miro) 962static void __devinit snd_miro_proc_init(struct snd_miro * miro)
966{ 963{
967 struct snd_info_entry *entry; 964 struct snd_info_entry *entry;
968 965
@@ -974,7 +971,7 @@ static void __init snd_miro_proc_init(struct snd_miro * miro)
974 * Init 971 * Init
975 */ 972 */
976 973
977static int __init snd_miro_configure(struct snd_miro *chip) 974static int __devinit snd_miro_configure(struct snd_miro *chip)
978{ 975{
979 unsigned char wss_base_bits; 976 unsigned char wss_base_bits;
980 unsigned char irq_bits; 977 unsigned char irq_bits;
@@ -1131,7 +1128,8 @@ __skip_mpu:
1131 return 0; 1128 return 0;
1132} 1129}
1133 1130
1134static int __init snd_card_miro_detect(struct snd_card *card, struct snd_miro *chip) 1131static int __devinit snd_card_miro_detect(struct snd_card *card,
1132 struct snd_miro *chip)
1135{ 1133{
1136 int i, err; 1134 int i, err;
1137 unsigned char value; 1135 unsigned char value;
@@ -1157,7 +1155,8 @@ static int __init snd_card_miro_detect(struct snd_card *card, struct snd_miro *c
1157 return -ENODEV; 1155 return -ENODEV;
1158} 1156}
1159 1157
1160static int __init snd_card_miro_aci_detect(struct snd_card *card, struct snd_miro * miro) 1158static int __devinit snd_card_miro_aci_detect(struct snd_card *card,
1159 struct snd_miro * miro)
1161{ 1160{
1162 unsigned char regval; 1161 unsigned char regval;
1163 int i; 1162 int i;
@@ -1213,7 +1212,12 @@ static void snd_card_miro_free(struct snd_card *card)
1213 release_and_free_resource(miro->res_mc_base); 1212 release_and_free_resource(miro->res_mc_base);
1214} 1213}
1215 1214
1216static int __init snd_miro_probe(struct platform_device *devptr) 1215static int __devinit snd_miro_match(struct device *devptr, unsigned int n)
1216{
1217 return 1;
1218}
1219
1220static int __devinit snd_miro_probe(struct device *devptr, unsigned int n)
1217{ 1221{
1218 static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; 1222 static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1};
1219 static long possible_mpu_ports[] = {0x330, 0x300, 0x310, 0x320, -1}; 1223 static long possible_mpu_ports[] = {0x330, 0x300, 0x310, 0x320, -1};
@@ -1399,56 +1403,44 @@ static int __init snd_miro_probe(struct platform_device *devptr)
1399 return error; 1403 return error;
1400 } 1404 }
1401 1405
1402 snd_card_set_dev(card, &devptr->dev); 1406 snd_card_set_dev(card, devptr);
1403 1407
1404 if ((error = snd_card_register(card))) { 1408 if ((error = snd_card_register(card))) {
1405 snd_card_free(card); 1409 snd_card_free(card);
1406 return error; 1410 return error;
1407 } 1411 }
1408 1412
1409 platform_set_drvdata(devptr, card); 1413 dev_set_drvdata(devptr, card);
1410 return 0; 1414 return 0;
1411} 1415}
1412 1416
1413static int __devexit snd_miro_remove(struct platform_device *devptr) 1417static int __devexit snd_miro_remove(struct device *devptr, unsigned int dev)
1414{ 1418{
1415 snd_card_free(platform_get_drvdata(devptr)); 1419 snd_card_free(dev_get_drvdata(devptr));
1416 platform_set_drvdata(devptr, NULL); 1420 dev_set_drvdata(devptr, NULL);
1417 return 0; 1421 return 0;
1418} 1422}
1419 1423
1420static struct platform_driver snd_miro_driver = { 1424#define DEV_NAME "miro"
1425
1426static struct isa_driver snd_miro_driver = {
1427 .match = snd_miro_match,
1421 .probe = snd_miro_probe, 1428 .probe = snd_miro_probe,
1422 .remove = __devexit_p(snd_miro_remove), 1429 .remove = __devexit_p(snd_miro_remove),
1423 /* FIXME: suspend/resume */ 1430 /* FIXME: suspend/resume */
1424 .driver = { 1431 .driver = {
1425 .name = DRIVER_NAME 1432 .name = DEV_NAME
1426 }, 1433 },
1427}; 1434};
1428 1435
1429static int __init alsa_card_miro_init(void) 1436static int __init alsa_card_miro_init(void)
1430{ 1437{
1431 int error; 1438 return isa_register_driver(&snd_miro_driver, 1);
1432
1433 if ((error = platform_driver_register(&snd_miro_driver)) < 0)
1434 return error;
1435 device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
1436 if (! IS_ERR(device)) {
1437 if (platform_get_drvdata(device))
1438 return 0;
1439 platform_device_unregister(device);
1440 }
1441#ifdef MODULE
1442 printk(KERN_ERR "no miro soundcard found\n");
1443#endif
1444 platform_driver_unregister(&snd_miro_driver);
1445 return PTR_ERR(device);
1446} 1439}
1447 1440
1448static void __exit alsa_card_miro_exit(void) 1441static void __exit alsa_card_miro_exit(void)
1449{ 1442{
1450 platform_device_unregister(device); 1443 isa_unregister_driver(&snd_miro_driver);
1451 platform_driver_unregister(&snd_miro_driver);
1452} 1444}
1453 1445
1454module_init(alsa_card_miro_init) 1446module_init(alsa_card_miro_init)
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
index df227377c333..60c120ffb9de 100644
--- a/sound/isa/opti9xx/opti92x-ad1848.c
+++ b/sound/isa/opti9xx/opti92x-ad1848.c
@@ -26,7 +26,7 @@
26#include <sound/driver.h> 26#include <sound/driver.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/err.h> 28#include <linux/err.h>
29#include <linux/platform_device.h> 29#include <linux/isa.h>
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/pnp.h> 32#include <linux/pnp.h>
@@ -259,7 +259,6 @@ struct snd_opti9xx {
259}; 259};
260 260
261static int snd_opti9xx_pnp_is_probed; 261static int snd_opti9xx_pnp_is_probed;
262static struct platform_device *snd_opti9xx_platform_device;
263 262
264#ifdef CONFIG_PNP 263#ifdef CONFIG_PNP
265 264
@@ -281,10 +280,10 @@ MODULE_DEVICE_TABLE(pnp_card, snd_opti9xx_pnpids);
281#endif /* CONFIG_PNP */ 280#endif /* CONFIG_PNP */
282 281
283#ifdef OPTi93X 282#ifdef OPTi93X
284#define DRIVER_NAME "snd-card-opti93x" 283#define DEV_NAME "opti93x"
285#else 284#else
286#define DRIVER_NAME "snd-card-opti92x" 285#define DEV_NAME "opti92x"
287#endif /* OPTi93X */ 286#endif
288 287
289static char * snd_opti9xx_names[] = { 288static char * snd_opti9xx_names[] = {
290 "unkown", 289 "unkown",
@@ -294,7 +293,7 @@ static char * snd_opti9xx_names[] = {
294}; 293};
295 294
296 295
297static long __init snd_legacy_find_free_ioport(long *port_table, long size) 296static long __devinit snd_legacy_find_free_ioport(long *port_table, long size)
298{ 297{
299 while (*port_table != -1) { 298 while (*port_table != -1) {
300 if (request_region(*port_table, size, "ALSA test")) { 299 if (request_region(*port_table, size, "ALSA test")) {
@@ -306,7 +305,8 @@ static long __init snd_legacy_find_free_ioport(long *port_table, long size)
306 return -1; 305 return -1;
307} 306}
308 307
309static int __init snd_opti9xx_init(struct snd_opti9xx *chip, unsigned short hardware) 308static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip,
309 unsigned short hardware)
310{ 310{
311 static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2}; 311 static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2};
312 312
@@ -451,7 +451,7 @@ static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg,
451 (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) 451 (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask)))
452 452
453 453
454static int __init snd_opti9xx_configure(struct snd_opti9xx *chip) 454static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip)
455{ 455{
456 unsigned char wss_base_bits; 456 unsigned char wss_base_bits;
457 unsigned char irq_bits; 457 unsigned char irq_bits;
@@ -934,10 +934,8 @@ static int snd_opti93x_trigger(struct snd_pcm_substream *substream,
934 case SNDRV_PCM_TRIGGER_STOP: 934 case SNDRV_PCM_TRIGGER_STOP:
935 { 935 {
936 unsigned int what = 0; 936 unsigned int what = 0;
937 struct list_head *pos;
938 struct snd_pcm_substream *s; 937 struct snd_pcm_substream *s;
939 snd_pcm_group_for_each(pos, substream) { 938 snd_pcm_group_for_each_entry(s, substream) {
940 s = snd_pcm_group_substream_entry(pos);
941 if (s == chip->playback_substream) { 939 if (s == chip->playback_substream) {
942 what |= OPTi93X_PLAYBACK_ENABLE; 940 what |= OPTi93X_PLAYBACK_ENABLE;
943 snd_pcm_trigger_done(s, substream); 941 snd_pcm_trigger_done(s, substream);
@@ -1291,7 +1289,7 @@ static int snd_opti93x_create(struct snd_card *card, struct snd_opti9xx *chip,
1291 } 1289 }
1292 codec->dma2 = chip->dma2; 1290 codec->dma2 = chip->dma2;
1293 1291
1294 if (request_irq(chip->irq, snd_opti93x_interrupt, IRQF_DISABLED, DRIVER_NAME" - WSS", codec)) { 1292 if (request_irq(chip->irq, snd_opti93x_interrupt, IRQF_DISABLED, DEV_NAME" - WSS", codec)) {
1295 snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", chip->irq); 1293 snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", chip->irq);
1296 snd_opti93x_free(codec); 1294 snd_opti93x_free(codec);
1297 return -EBUSY; 1295 return -EBUSY;
@@ -1561,7 +1559,7 @@ static int snd_opti93x_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_
1561 return change; 1559 return change;
1562} 1560}
1563 1561
1564static struct snd_kcontrol_new snd_opti93x_controls[] = { 1562static struct snd_kcontrol_new snd_opti93x_controls[] __devinitdata = {
1565OPTi93X_DOUBLE("Master Playback Switch", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), 1563OPTi93X_DOUBLE("Master Playback Switch", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1),
1566OPTi93X_DOUBLE("Master Playback Volume", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1), 1564OPTi93X_DOUBLE("Master Playback Volume", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1),
1567OPTi93X_DOUBLE("PCM Playback Switch", 0, OPTi93X_DAC_LEFT, OPTi93X_DAC_RIGHT, 7, 7, 1, 1), 1565OPTi93X_DOUBLE("PCM Playback Switch", 0, OPTi93X_DAC_LEFT, OPTi93X_DAC_RIGHT, 7, 7, 1, 1),
@@ -1622,7 +1620,8 @@ static int snd_opti93x_mixer(struct snd_opti93x *chip)
1622 1620
1623#endif /* OPTi93X */ 1621#endif /* OPTi93X */
1624 1622
1625static int __init snd_card_opti9xx_detect(struct snd_card *card, struct snd_opti9xx *chip) 1623static int __devinit snd_card_opti9xx_detect(struct snd_card *card,
1624 struct snd_opti9xx *chip)
1626{ 1625{
1627 int i, err; 1626 int i, err;
1628 1627
@@ -1676,8 +1675,9 @@ static int __init snd_card_opti9xx_detect(struct snd_card *card, struct snd_opti
1676} 1675}
1677 1676
1678#ifdef CONFIG_PNP 1677#ifdef CONFIG_PNP
1679static int __init snd_card_opti9xx_pnp(struct snd_opti9xx *chip, struct pnp_card_link *card, 1678static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip,
1680 const struct pnp_card_device_id *pid) 1679 struct pnp_card_link *card,
1680 const struct pnp_card_device_id *pid)
1681{ 1681{
1682 struct pnp_dev *pdev; 1682 struct pnp_dev *pdev;
1683 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); 1683 struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
@@ -1778,7 +1778,7 @@ static void snd_card_opti9xx_free(struct snd_card *card)
1778 release_and_free_resource(chip->res_mc_base); 1778 release_and_free_resource(chip->res_mc_base);
1779} 1779}
1780 1780
1781static int __init snd_opti9xx_probe(struct snd_card *card) 1781static int __devinit snd_opti9xx_probe(struct snd_card *card)
1782{ 1782{
1783 static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; 1783 static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1};
1784 int error; 1784 int error;
@@ -1924,7 +1924,18 @@ static struct snd_card *snd_opti9xx_card_new(void)
1924 return card; 1924 return card;
1925} 1925}
1926 1926
1927static int __init snd_opti9xx_nonpnp_probe(struct platform_device *devptr) 1927static int __devinit snd_opti9xx_isa_match(struct device *devptr,
1928 unsigned int dev)
1929{
1930 if (snd_opti9xx_pnp_is_probed)
1931 return 0;
1932 if (isapnp)
1933 return 0;
1934 return 1;
1935}
1936
1937static int __devinit snd_opti9xx_isa_probe(struct device *devptr,
1938 unsigned int dev)
1928{ 1939{
1929 struct snd_card *card; 1940 struct snd_card *card;
1930 int error; 1941 int error;
@@ -1940,9 +1951,6 @@ static int __init snd_opti9xx_nonpnp_probe(struct platform_device *devptr)
1940 static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}}; 1951 static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}};
1941#endif /* CS4231 || OPTi93X */ 1952#endif /* CS4231 || OPTi93X */
1942 1953
1943 if (snd_opti9xx_pnp_is_probed)
1944 return -EBUSY;
1945
1946 if (mpu_port == SNDRV_AUTO_PORT) { 1954 if (mpu_port == SNDRV_AUTO_PORT) {
1947 if ((mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) { 1955 if ((mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) {
1948 snd_printk(KERN_ERR "unable to find a free MPU401 port\n"); 1956 snd_printk(KERN_ERR "unable to find a free MPU401 port\n");
@@ -1984,34 +1992,36 @@ static int __init snd_opti9xx_nonpnp_probe(struct platform_device *devptr)
1984 snd_card_free(card); 1992 snd_card_free(card);
1985 return error; 1993 return error;
1986 } 1994 }
1987 snd_card_set_dev(card, &devptr->dev); 1995 snd_card_set_dev(card, devptr);
1988 if ((error = snd_opti9xx_probe(card)) < 0) { 1996 if ((error = snd_opti9xx_probe(card)) < 0) {
1989 snd_card_free(card); 1997 snd_card_free(card);
1990 return error; 1998 return error;
1991 } 1999 }
1992 platform_set_drvdata(devptr, card); 2000 dev_set_drvdata(devptr, card);
1993 return 0; 2001 return 0;
1994} 2002}
1995 2003
1996static int __devexit snd_opti9xx_nonpnp_remove(struct platform_device *devptr) 2004static int __devexit snd_opti9xx_isa_remove(struct device *devptr,
2005 unsigned int dev)
1997{ 2006{
1998 snd_card_free(platform_get_drvdata(devptr)); 2007 snd_card_free(dev_get_drvdata(devptr));
1999 platform_set_drvdata(devptr, NULL); 2008 dev_set_drvdata(devptr, NULL);
2000 return 0; 2009 return 0;
2001} 2010}
2002 2011
2003static struct platform_driver snd_opti9xx_driver = { 2012static struct isa_driver snd_opti9xx_driver = {
2004 .probe = snd_opti9xx_nonpnp_probe, 2013 .match = snd_opti9xx_isa_match,
2005 .remove = __devexit_p(snd_opti9xx_nonpnp_remove), 2014 .probe = snd_opti9xx_isa_probe,
2015 .remove = __devexit_p(snd_opti9xx_isa_remove),
2006 /* FIXME: suspend/resume */ 2016 /* FIXME: suspend/resume */
2007 .driver = { 2017 .driver = {
2008 .name = DRIVER_NAME 2018 .name = DEV_NAME
2009 }, 2019 },
2010}; 2020};
2011 2021
2012#ifdef CONFIG_PNP 2022#ifdef CONFIG_PNP
2013static int __init snd_opti9xx_pnp_probe(struct pnp_card_link *pcard, 2023static int __devinit snd_opti9xx_pnp_probe(struct pnp_card_link *pcard,
2014 const struct pnp_card_device_id *pid) 2024 const struct pnp_card_device_id *pid)
2015{ 2025{
2016 struct snd_card *card; 2026 struct snd_card *card;
2017 int error, hw; 2027 int error, hw;
@@ -2074,11 +2084,6 @@ static struct pnp_card_driver opti9xx_pnpc_driver = {
2074}; 2084};
2075#endif 2085#endif
2076 2086
2077#ifdef CONFIG_PNP
2078#define is_isapnp_selected() isapnp
2079#else
2080#define is_isapnp_selected() 0
2081#endif
2082#ifdef OPTi93X 2087#ifdef OPTi93X
2083#define CHIP_NAME "82C93x" 2088#define CHIP_NAME "82C93x"
2084#else 2089#else
@@ -2087,42 +2092,19 @@ static struct pnp_card_driver opti9xx_pnpc_driver = {
2087 2092
2088static int __init alsa_card_opti9xx_init(void) 2093static int __init alsa_card_opti9xx_init(void)
2089{ 2094{
2090 int error;
2091 struct platform_device *device;
2092
2093#ifdef CONFIG_PNP 2095#ifdef CONFIG_PNP
2094 pnp_register_card_driver(&opti9xx_pnpc_driver); 2096 pnp_register_card_driver(&opti9xx_pnpc_driver);
2095 if (snd_opti9xx_pnp_is_probed) 2097 if (snd_opti9xx_pnp_is_probed)
2096 return 0; 2098 return 0;
2097#endif 2099#endif
2098 if (! is_isapnp_selected()) { 2100 return isa_register_driver(&snd_opti9xx_driver, 1);
2099 error = platform_driver_register(&snd_opti9xx_driver);
2100 if (error < 0)
2101 return error;
2102 device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
2103 if (!IS_ERR(device)) {
2104 if (platform_get_drvdata(device)) {
2105 snd_opti9xx_platform_device = device;
2106 return 0;
2107 }
2108 platform_device_unregister(device);
2109 }
2110 platform_driver_unregister(&snd_opti9xx_driver);
2111 }
2112#ifdef CONFIG_PNP
2113 pnp_unregister_card_driver(&opti9xx_pnpc_driver);
2114#endif
2115#ifdef MODULE
2116 printk(KERN_ERR "no OPTi " CHIP_NAME " soundcard found\n");
2117#endif
2118 return -ENODEV;
2119} 2101}
2120 2102
2121static void __exit alsa_card_opti9xx_exit(void) 2103static void __exit alsa_card_opti9xx_exit(void)
2122{ 2104{
2123 if (!snd_opti9xx_pnp_is_probed) { 2105 if (!snd_opti9xx_pnp_is_probed) {
2124 platform_device_unregister(snd_opti9xx_platform_device); 2106 isa_unregister_driver(&snd_opti9xx_driver);
2125 platform_driver_unregister(&snd_opti9xx_driver); 2107 return;
2126 } 2108 }
2127#ifdef CONFIG_PNP 2109#ifdef CONFIG_PNP
2128 pnp_unregister_card_driver(&opti9xx_pnpc_driver); 2110 pnp_unregister_card_driver(&opti9xx_pnpc_driver);
diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c
index d64e67f2bafa..2a19b0a39eda 100644
--- a/sound/isa/sb/sb16.c
+++ b/sound/isa/sb/sb16.c
@@ -25,7 +25,7 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/pnp.h> 26#include <linux/pnp.h>
27#include <linux/err.h> 27#include <linux/err.h>
28#include <linux/platform_device.h> 28#include <linux/isa.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <sound/core.h> 30#include <sound/core.h>
31#include <sound/sb.h> 31#include <sound/sb.h>
@@ -128,7 +128,6 @@ module_param_array(seq_ports, int, NULL, 0444);
128MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth."); 128MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth.");
129#endif 129#endif
130 130
131static struct platform_device *platform_devices[SNDRV_CARDS];
132#ifdef CONFIG_PNP 131#ifdef CONFIG_PNP
133static int pnp_registered; 132static int pnp_registered;
134#endif 133#endif
@@ -519,7 +518,7 @@ static int snd_sb16_resume(struct snd_card *card)
519} 518}
520#endif 519#endif
521 520
522static int __devinit snd_sb16_nonpnp_probe1(int dev, struct platform_device *devptr) 521static int __devinit snd_sb16_isa_probe1(int dev, struct device *pdev)
523{ 522{
524 struct snd_card_sb16 *acard; 523 struct snd_card_sb16 *acard;
525 struct snd_card *card; 524 struct snd_card *card;
@@ -539,19 +538,23 @@ static int __devinit snd_sb16_nonpnp_probe1(int dev, struct platform_device *dev
539 awe_port[dev] = port[dev] + 0x400; 538 awe_port[dev] = port[dev] + 0x400;
540#endif 539#endif
541 540
542 snd_card_set_dev(card, &devptr->dev); 541 snd_card_set_dev(card, pdev);
543 if ((err = snd_sb16_probe(card, dev)) < 0) { 542 if ((err = snd_sb16_probe(card, dev)) < 0) {
544 snd_card_free(card); 543 snd_card_free(card);
545 return err; 544 return err;
546 } 545 }
547 platform_set_drvdata(devptr, card); 546 dev_set_drvdata(pdev, card);
548 return 0; 547 return 0;
549} 548}
550 549
551 550
552static int __devinit snd_sb16_nonpnp_probe(struct platform_device *pdev) 551static int __devinit snd_sb16_isa_match(struct device *pdev, unsigned int dev)
552{
553 return enable[dev] && !is_isapnp_selected(dev);
554}
555
556static int __devinit snd_sb16_isa_probe(struct device *pdev, unsigned int dev)
553{ 557{
554 int dev = pdev->id;
555 int err; 558 int err;
556 static int possible_irqs[] = {5, 9, 10, 7, -1}; 559 static int possible_irqs[] = {5, 9, 10, 7, -1};
557 static int possible_dmas8[] = {1, 3, 0, -1}; 560 static int possible_dmas8[] = {1, 3, 0, -1};
@@ -577,13 +580,13 @@ static int __devinit snd_sb16_nonpnp_probe(struct platform_device *pdev)
577 } 580 }
578 581
579 if (port[dev] != SNDRV_AUTO_PORT) 582 if (port[dev] != SNDRV_AUTO_PORT)
580 return snd_sb16_nonpnp_probe1(dev, pdev); 583 return snd_sb16_isa_probe1(dev, pdev);
581 else { 584 else {
582 static int possible_ports[] = {0x220, 0x240, 0x260, 0x280}; 585 static int possible_ports[] = {0x220, 0x240, 0x260, 0x280};
583 int i; 586 int i;
584 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { 587 for (i = 0; i < ARRAY_SIZE(possible_ports); i++) {
585 port[dev] = possible_ports[i]; 588 port[dev] = possible_ports[i];
586 err = snd_sb16_nonpnp_probe1(dev, pdev); 589 err = snd_sb16_isa_probe1(dev, pdev);
587 if (! err) 590 if (! err)
588 return 0; 591 return 0;
589 } 592 }
@@ -591,47 +594,47 @@ static int __devinit snd_sb16_nonpnp_probe(struct platform_device *pdev)
591 } 594 }
592} 595}
593 596
594static int __devexit snd_sb16_nonpnp_remove(struct platform_device *devptr) 597static int __devexit snd_sb16_isa_remove(struct device *pdev, unsigned int dev)
595{ 598{
596 snd_card_free(platform_get_drvdata(devptr)); 599 snd_card_free(dev_get_drvdata(pdev));
597 platform_set_drvdata(devptr, NULL); 600 dev_set_drvdata(pdev, NULL);
598 return 0; 601 return 0;
599} 602}
600 603
601#ifdef CONFIG_PM 604#ifdef CONFIG_PM
602static int snd_sb16_nonpnp_suspend(struct platform_device *dev, pm_message_t state) 605static int snd_sb16_isa_suspend(struct device *dev, unsigned int n,
606 pm_message_t state)
603{ 607{
604 return snd_sb16_suspend(platform_get_drvdata(dev), state); 608 return snd_sb16_suspend(dev_get_drvdata(dev), state);
605} 609}
606 610
607static int snd_sb16_nonpnp_resume(struct platform_device *dev) 611static int snd_sb16_isa_resume(struct device *dev, unsigned int n)
608{ 612{
609 return snd_sb16_resume(platform_get_drvdata(dev)); 613 return snd_sb16_resume(dev_get_drvdata(dev));
610} 614}
611#endif 615#endif
612 616
613#ifdef SNDRV_SBAWE 617#ifdef SNDRV_SBAWE
614#define SND_SB16_DRIVER "snd_sbawe" 618#define DEV_NAME "sbawe"
615#else 619#else
616#define SND_SB16_DRIVER "snd_sb16" 620#define DEV_NAME "sb16"
617#endif 621#endif
618 622
619static struct platform_driver snd_sb16_nonpnp_driver = { 623static struct isa_driver snd_sb16_isa_driver = {
620 .probe = snd_sb16_nonpnp_probe, 624 .match = snd_sb16_isa_match,
621 .remove = __devexit_p(snd_sb16_nonpnp_remove), 625 .probe = snd_sb16_isa_probe,
626 .remove = __devexit_p(snd_sb16_isa_remove),
622#ifdef CONFIG_PM 627#ifdef CONFIG_PM
623 .suspend = snd_sb16_nonpnp_suspend, 628 .suspend = snd_sb16_isa_suspend,
624 .resume = snd_sb16_nonpnp_resume, 629 .resume = snd_sb16_isa_resume,
625#endif 630#endif
626 .driver = { 631 .driver = {
627 .name = SND_SB16_DRIVER 632 .name = DEV_NAME
628 }, 633 },
629}; 634};
630 635
631 636
632#ifdef CONFIG_PNP 637#ifdef CONFIG_PNP
633static unsigned int __devinitdata sb16_pnp_devices;
634
635static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *pcard, 638static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *pcard,
636 const struct pnp_card_device_id *pid) 639 const struct pnp_card_device_id *pid)
637{ 640{
@@ -653,7 +656,6 @@ static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *pcard,
653 } 656 }
654 pnp_set_card_drvdata(pcard, card); 657 pnp_set_card_drvdata(pcard, card);
655 dev++; 658 dev++;
656 sb16_pnp_devices++;
657 return 0; 659 return 0;
658 } 660 }
659 661
@@ -695,68 +697,29 @@ static struct pnp_card_driver sb16_pnpc_driver = {
695 697
696#endif /* CONFIG_PNP */ 698#endif /* CONFIG_PNP */
697 699
698static void __init_or_module snd_sb16_unregister_all(void)
699{
700 int i;
701
702#ifdef CONFIG_PNP
703 if (pnp_registered)
704 pnp_unregister_card_driver(&sb16_pnpc_driver);
705#endif
706 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
707 platform_device_unregister(platform_devices[i]);
708 platform_driver_unregister(&snd_sb16_nonpnp_driver);
709}
710
711static int __init alsa_card_sb16_init(void) 700static int __init alsa_card_sb16_init(void)
712{ 701{
713 int i, err, cards = 0; 702 int err;
714 703
715 if ((err = platform_driver_register(&snd_sb16_nonpnp_driver)) < 0) 704 err = isa_register_driver(&snd_sb16_isa_driver, SNDRV_CARDS);
705 if (err < 0)
716 return err; 706 return err;
717
718 for (i = 0; i < SNDRV_CARDS; i++) {
719 struct platform_device *device;
720 if (! enable[i] || is_isapnp_selected(i))
721 continue;
722 device = platform_device_register_simple(SND_SB16_DRIVER,
723 i, NULL, 0);
724 if (IS_ERR(device))
725 continue;
726 if (!platform_get_drvdata(device)) {
727 platform_device_unregister(device);
728 continue;
729 }
730 platform_devices[i] = device;
731 cards++;
732 }
733#ifdef CONFIG_PNP 707#ifdef CONFIG_PNP
734 /* PnP cards at last */ 708 /* PnP cards at last */
735 err = pnp_register_card_driver(&sb16_pnpc_driver); 709 err = pnp_register_card_driver(&sb16_pnpc_driver);
736 if (!err) { 710 if (!err)
737 pnp_registered = 1; 711 pnp_registered = 1;
738 cards += sb16_pnp_devices;
739 }
740#endif
741
742 if (!cards) {
743#ifdef MODULE
744 snd_printk(KERN_ERR "Sound Blaster 16 soundcard not found or device busy\n");
745#ifdef SNDRV_SBAWE_EMU8000
746 snd_printk(KERN_ERR "In case, if you have non-AWE card, try snd-sb16 module\n");
747#else
748 snd_printk(KERN_ERR "In case, if you have AWE card, try snd-sbawe module\n");
749#endif 712#endif
750#endif
751 snd_sb16_unregister_all();
752 return -ENODEV;
753 }
754 return 0; 713 return 0;
755} 714}
756 715
757static void __exit alsa_card_sb16_exit(void) 716static void __exit alsa_card_sb16_exit(void)
758{ 717{
759 snd_sb16_unregister_all(); 718#ifdef CONFIG_PNP
719 if (pnp_registered)
720 pnp_unregister_card_driver(&sb16_pnpc_driver);
721#endif
722 isa_unregister_driver(&snd_sb16_isa_driver);
760} 723}
761 724
762module_init(alsa_card_sb16_init) 725module_init(alsa_card_sb16_init)
diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c
index 3d9d7e0107ca..b279f2308aef 100644
--- a/sound/isa/sb/sb16_csp.c
+++ b/sound/isa/sb/sb16_csp.c
@@ -36,6 +36,13 @@
36MODULE_AUTHOR("Uros Bizjak <uros@kss-loka.si>"); 36MODULE_AUTHOR("Uros Bizjak <uros@kss-loka.si>");
37MODULE_DESCRIPTION("ALSA driver for SB16 Creative Signal Processor"); 37MODULE_DESCRIPTION("ALSA driver for SB16 Creative Signal Processor");
38MODULE_LICENSE("GPL"); 38MODULE_LICENSE("GPL");
39#ifndef CONFIG_SND_SB16_CSP_FIRMWARE_IN_KERNEL
40MODULE_FIRMWARE("sb16/mulaw_main.csp");
41MODULE_FIRMWARE("sb16/alaw_main.csp");
42MODULE_FIRMWARE("sb16/ima_adpcm_init.csp");
43MODULE_FIRMWARE("sb16/ima_adpcm_playback.csp");
44MODULE_FIRMWARE("sb16/ima_adpcm_capture.csp");
45#endif
39 46
40#ifdef SNDRV_LITTLE_ENDIAN 47#ifdef SNDRV_LITTLE_ENDIAN
41#define CSP_HDR_VALUE(a,b,c,d) ((a) | ((b)<<8) | ((c)<<16) | ((d)<<24)) 48#define CSP_HDR_VALUE(a,b,c,d) ((a) | ((b)<<8) | ((c)<<16) | ((d)<<24))
@@ -161,13 +168,17 @@ int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep)
161 */ 168 */
162static void snd_sb_csp_free(struct snd_hwdep *hwdep) 169static void snd_sb_csp_free(struct snd_hwdep *hwdep)
163{ 170{
171#ifndef CONFIG_SND_SB16_CSP_FIRMWARE_IN_KERNEL
164 int i; 172 int i;
173#endif
165 struct snd_sb_csp *p = hwdep->private_data; 174 struct snd_sb_csp *p = hwdep->private_data;
166 if (p) { 175 if (p) {
167 if (p->running & SNDRV_SB_CSP_ST_RUNNING) 176 if (p->running & SNDRV_SB_CSP_ST_RUNNING)
168 snd_sb_csp_stop(p); 177 snd_sb_csp_stop(p);
178#ifndef CONFIG_SND_SB16_CSP_FIRMWARE_IN_KERNEL
169 for (i = 0; i < ARRAY_SIZE(p->csp_programs); ++i) 179 for (i = 0; i < ARRAY_SIZE(p->csp_programs); ++i)
170 release_firmware(p->csp_programs[i]); 180 release_firmware(p->csp_programs[i]);
181#endif
171 kfree(p); 182 kfree(p);
172 } 183 }
173} 184}
@@ -690,9 +701,7 @@ static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __use
690 return err; 701 return err;
691} 702}
692 703
693#define FIRMWARE_IN_THE_KERNEL 704#ifdef CONFIG_SND_SB16_CSP_FIRMWARE_IN_KERNEL
694
695#ifdef FIRMWARE_IN_THE_KERNEL
696#include "sb16_csp_codecs.h" 705#include "sb16_csp_codecs.h"
697 706
698static const struct firmware snd_sb_csp_static_programs[] = { 707static const struct firmware snd_sb_csp_static_programs[] = {
@@ -714,22 +723,19 @@ static int snd_sb_csp_firmware_load(struct snd_sb_csp *p, int index, int flags)
714 "sb16/ima_adpcm_capture.csp", 723 "sb16/ima_adpcm_capture.csp",
715 }; 724 };
716 const struct firmware *program; 725 const struct firmware *program;
717 int err;
718 726
719 BUILD_BUG_ON(ARRAY_SIZE(names) != CSP_PROGRAM_COUNT); 727 BUILD_BUG_ON(ARRAY_SIZE(names) != CSP_PROGRAM_COUNT);
720 program = p->csp_programs[index]; 728 program = p->csp_programs[index];
721 if (!program) { 729 if (!program) {
722 err = request_firmware(&program, names[index], 730#ifdef CONFIG_SND_SB16_CSP_FIRMWARE_IN_KERNEL
723 p->chip->card->dev); 731 program = &snd_sb_csp_static_programs[index];
724 if (err >= 0)
725 p->csp_programs[index] = program;
726 else {
727#ifdef FIRMWARE_IN_THE_KERNEL
728 program = &snd_sb_csp_static_programs[index];
729#else 732#else
733 int err = request_firmware(&program, names[index],
734 p->chip->card->dev);
735 if (err < 0)
730 return err; 736 return err;
731#endif 737#endif
732 } 738 p->csp_programs[index] = program;
733 } 739 }
734 return snd_sb_csp_load(p, program->data, program->size, flags); 740 return snd_sb_csp_load(p, program->data, program->size, flags);
735} 741}
diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c
index be1e83e6dea3..a1b3786b391e 100644
--- a/sound/isa/sb/sb8.c
+++ b/sound/isa/sb/sb8.c
@@ -22,7 +22,7 @@
22#include <sound/driver.h> 22#include <sound/driver.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h> 25#include <linux/isa.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/ioport.h> 27#include <linux/ioport.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
@@ -56,8 +56,6 @@ MODULE_PARM_DESC(irq, "IRQ # for SB8 driver.");
56module_param_array(dma8, int, NULL, 0444); 56module_param_array(dma8, int, NULL, 0444);
57MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver."); 57MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver.");
58 58
59static struct platform_device *devices[SNDRV_CARDS];
60
61struct snd_sb8 { 59struct snd_sb8 {
62 struct resource *fm_res; /* used to block FM i/o region for legacy cards */ 60 struct resource *fm_res; /* used to block FM i/o region for legacy cards */
63 struct snd_sb *chip; 61 struct snd_sb *chip;
@@ -83,9 +81,23 @@ static void snd_sb8_free(struct snd_card *card)
83 release_and_free_resource(acard->fm_res); 81 release_and_free_resource(acard->fm_res);
84} 82}
85 83
86static int __devinit snd_sb8_probe(struct platform_device *pdev) 84static int __devinit snd_sb8_match(struct device *pdev, unsigned int dev)
85{
86 if (!enable[dev])
87 return 0;
88 if (irq[dev] == SNDRV_AUTO_IRQ) {
89 snd_printk(KERN_ERR "%s: please specify irq\n", pdev->bus_id);
90 return 0;
91 }
92 if (dma8[dev] == SNDRV_AUTO_DMA) {
93 snd_printk(KERN_ERR "%s: please specify dma8\n", pdev->bus_id);
94 return 0;
95 }
96 return 1;
97}
98
99static int __devinit snd_sb8_probe(struct device *pdev, unsigned int dev)
87{ 100{
88 int dev = pdev->id;
89 struct snd_sb *chip; 101 struct snd_sb *chip;
90 struct snd_card *card; 102 struct snd_card *card;
91 struct snd_sb8 *acard; 103 struct snd_sb8 *acard;
@@ -180,12 +192,12 @@ static int __devinit snd_sb8_probe(struct platform_device *pdev)
180 chip->port, 192 chip->port,
181 irq[dev], dma8[dev]); 193 irq[dev], dma8[dev]);
182 194
183 snd_card_set_dev(card, &pdev->dev); 195 snd_card_set_dev(card, pdev);
184 196
185 if ((err = snd_card_register(card)) < 0) 197 if ((err = snd_card_register(card)) < 0)
186 goto _err; 198 goto _err;
187 199
188 platform_set_drvdata(pdev, card); 200 dev_set_drvdata(pdev, card);
189 return 0; 201 return 0;
190 202
191 _err: 203 _err:
@@ -193,17 +205,18 @@ static int __devinit snd_sb8_probe(struct platform_device *pdev)
193 return err; 205 return err;
194} 206}
195 207
196static int __devexit snd_sb8_remove(struct platform_device *pdev) 208static int __devexit snd_sb8_remove(struct device *pdev, unsigned int dev)
197{ 209{
198 snd_card_free(platform_get_drvdata(pdev)); 210 snd_card_free(dev_get_drvdata(pdev));
199 platform_set_drvdata(pdev, NULL); 211 dev_set_drvdata(pdev, NULL);
200 return 0; 212 return 0;
201} 213}
202 214
203#ifdef CONFIG_PM 215#ifdef CONFIG_PM
204static int snd_sb8_suspend(struct platform_device *dev, pm_message_t state) 216static int snd_sb8_suspend(struct device *dev, unsigned int n,
217 pm_message_t state)
205{ 218{
206 struct snd_card *card = platform_get_drvdata(dev); 219 struct snd_card *card = dev_get_drvdata(dev);
207 struct snd_sb8 *acard = card->private_data; 220 struct snd_sb8 *acard = card->private_data;
208 struct snd_sb *chip = acard->chip; 221 struct snd_sb *chip = acard->chip;
209 222
@@ -213,9 +226,9 @@ static int snd_sb8_suspend(struct platform_device *dev, pm_message_t state)
213 return 0; 226 return 0;
214} 227}
215 228
216static int snd_sb8_resume(struct platform_device *dev) 229static int snd_sb8_resume(struct device *dev, unsigned int n)
217{ 230{
218 struct snd_card *card = platform_get_drvdata(dev); 231 struct snd_card *card = dev_get_drvdata(dev);
219 struct snd_sb8 *acard = card->private_data; 232 struct snd_sb8 *acard = card->private_data;
220 struct snd_sb *chip = acard->chip; 233 struct snd_sb *chip = acard->chip;
221 234
@@ -226,9 +239,10 @@ static int snd_sb8_resume(struct platform_device *dev)
226} 239}
227#endif 240#endif
228 241
229#define SND_SB8_DRIVER "snd_sb8" 242#define DEV_NAME "sb8"
230 243
231static struct platform_driver snd_sb8_driver = { 244static struct isa_driver snd_sb8_driver = {
245 .match = snd_sb8_match,
232 .probe = snd_sb8_probe, 246 .probe = snd_sb8_probe,
233 .remove = __devexit_p(snd_sb8_remove), 247 .remove = __devexit_p(snd_sb8_remove),
234#ifdef CONFIG_PM 248#ifdef CONFIG_PM
@@ -236,56 +250,18 @@ static struct platform_driver snd_sb8_driver = {
236 .resume = snd_sb8_resume, 250 .resume = snd_sb8_resume,
237#endif 251#endif
238 .driver = { 252 .driver = {
239 .name = SND_SB8_DRIVER 253 .name = DEV_NAME
240 }, 254 },
241}; 255};
242 256
243static void __init_or_module snd_sb8_unregister_all(void)
244{
245 int i;
246
247 for (i = 0; i < ARRAY_SIZE(devices); ++i)
248 platform_device_unregister(devices[i]);
249 platform_driver_unregister(&snd_sb8_driver);
250}
251
252static int __init alsa_card_sb8_init(void) 257static int __init alsa_card_sb8_init(void)
253{ 258{
254 int i, cards, err; 259 return isa_register_driver(&snd_sb8_driver, SNDRV_CARDS);
255
256 err = platform_driver_register(&snd_sb8_driver);
257 if (err < 0)
258 return err;
259
260 cards = 0;
261 for (i = 0; i < SNDRV_CARDS; i++) {
262 struct platform_device *device;
263 if (! enable[i])
264 continue;
265 device = platform_device_register_simple(SND_SB8_DRIVER,
266 i, NULL, 0);
267 if (IS_ERR(device))
268 continue;
269 if (!platform_get_drvdata(device)) {
270 platform_device_unregister(device);
271 continue;
272 }
273 devices[i] = device;
274 cards++;
275 }
276 if (!cards) {
277#ifdef MODULE
278 snd_printk(KERN_ERR "Sound Blaster soundcard not found or device busy\n");
279#endif
280 snd_sb8_unregister_all();
281 return -ENODEV;
282 }
283 return 0;
284} 260}
285 261
286static void __exit alsa_card_sb8_exit(void) 262static void __exit alsa_card_sb8_exit(void)
287{ 263{
288 snd_sb8_unregister_all(); 264 isa_unregister_driver(&snd_sb8_driver);
289} 265}
290 266
291module_init(alsa_card_sb8_init) 267module_init(alsa_card_sb8_init)
diff --git a/sound/isa/sgalaxy.c b/sound/isa/sgalaxy.c
index 4fcd0f4e868c..922519def099 100644
--- a/sound/isa/sgalaxy.c
+++ b/sound/isa/sgalaxy.c
@@ -24,7 +24,7 @@
24#include <sound/driver.h> 24#include <sound/driver.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/platform_device.h> 27#include <linux/isa.h>
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/time.h> 29#include <linux/time.h>
30#include <linux/interrupt.h> 30#include <linux/interrupt.h>
@@ -64,8 +64,6 @@ MODULE_PARM_DESC(irq, "IRQ # for Sound Galaxy driver.");
64module_param_array(dma1, int, NULL, 0444); 64module_param_array(dma1, int, NULL, 0444);
65MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver."); 65MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver.");
66 66
67static struct platform_device *devices[SNDRV_CARDS];
68
69#define SGALAXY_AUXC_LEFT 18 67#define SGALAXY_AUXC_LEFT 18
70#define SGALAXY_AUXC_RIGHT 19 68#define SGALAXY_AUXC_RIGHT 19
71 69
@@ -96,7 +94,8 @@ static int snd_sgalaxy_sbdsp_reset(unsigned long port)
96 return 0; 94 return 0;
97} 95}
98 96
99static int __init snd_sgalaxy_sbdsp_command(unsigned long port, unsigned char val) 97static int __devinit snd_sgalaxy_sbdsp_command(unsigned long port,
98 unsigned char val)
100{ 99{
101 int i; 100 int i;
102 101
@@ -114,7 +113,7 @@ static irqreturn_t snd_sgalaxy_dummy_interrupt(int irq, void *dev_id)
114 return IRQ_NONE; 113 return IRQ_NONE;
115} 114}
116 115
117static int __init snd_sgalaxy_setup_wss(unsigned long port, int irq, int dma) 116static int __devinit snd_sgalaxy_setup_wss(unsigned long port, int irq, int dma)
118{ 117{
119 static int interrupt_bits[] = {-1, -1, -1, -1, -1, -1, -1, 0x08, -1, 118 static int interrupt_bits[] = {-1, -1, -1, -1, -1, -1, -1, 0x08, -1,
120 0x10, 0x18, 0x20, -1, -1, -1, -1}; 119 0x10, 0x18, 0x20, -1, -1, -1, -1};
@@ -161,7 +160,7 @@ static int __init snd_sgalaxy_setup_wss(unsigned long port, int irq, int dma)
161 return 0; 160 return 0;
162} 161}
163 162
164static int __init snd_sgalaxy_detect(int dev, int irq, int dma) 163static int __devinit snd_sgalaxy_detect(int dev, int irq, int dma)
165{ 164{
166#if 0 165#if 0
167 snd_printdd(PFX "switching to WSS mode\n"); 166 snd_printdd(PFX "switching to WSS mode\n");
@@ -182,7 +181,7 @@ AD1848_DOUBLE("Aux Playback Switch", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 7
182AD1848_DOUBLE("Aux Playback Volume", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 0, 0, 31, 0) 181AD1848_DOUBLE("Aux Playback Volume", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 0, 0, 31, 0)
183}; 182};
184 183
185static int __init snd_sgalaxy_mixer(struct snd_ad1848 *chip) 184static int __devinit snd_sgalaxy_mixer(struct snd_ad1848 *chip)
186{ 185{
187 struct snd_card *card = chip->card; 186 struct snd_card *card = chip->card;
188 struct snd_ctl_elem_id id1, id2; 187 struct snd_ctl_elem_id id1, id2;
@@ -218,23 +217,29 @@ static int __init snd_sgalaxy_mixer(struct snd_ad1848 *chip)
218 return 0; 217 return 0;
219} 218}
220 219
221static int __init snd_sgalaxy_probe(struct platform_device *devptr) 220static int __devinit snd_sgalaxy_match(struct device *devptr, unsigned int dev)
222{ 221{
223 int dev = devptr->id; 222 if (!enable[dev])
224 static int possible_irqs[] = {7, 9, 10, 11, -1}; 223 return 0;
225 static int possible_dmas[] = {1, 3, 0, -1};
226 int err, xirq, xdma1;
227 struct snd_card *card;
228 struct snd_ad1848 *chip;
229
230 if (sbport[dev] == SNDRV_AUTO_PORT) { 224 if (sbport[dev] == SNDRV_AUTO_PORT) {
231 snd_printk(KERN_ERR PFX "specify SB port\n"); 225 snd_printk(KERN_ERR PFX "specify SB port\n");
232 return -EINVAL; 226 return 0;
233 } 227 }
234 if (wssport[dev] == SNDRV_AUTO_PORT) { 228 if (wssport[dev] == SNDRV_AUTO_PORT) {
235 snd_printk(KERN_ERR PFX "specify WSS port\n"); 229 snd_printk(KERN_ERR PFX "specify WSS port\n");
236 return -EINVAL; 230 return 0;
237 } 231 }
232 return 1;
233}
234
235static int __devinit snd_sgalaxy_probe(struct device *devptr, unsigned int dev)
236{
237 static int possible_irqs[] = {7, 9, 10, 11, -1};
238 static int possible_dmas[] = {1, 3, 0, -1};
239 int err, xirq, xdma1;
240 struct snd_card *card;
241 struct snd_ad1848 *chip;
242
238 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 243 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
239 if (card == NULL) 244 if (card == NULL)
240 return -ENOMEM; 245 return -ENOMEM;
@@ -283,12 +288,12 @@ static int __init snd_sgalaxy_probe(struct platform_device *devptr)
283 sprintf(card->longname, "Sound Galaxy at 0x%lx, irq %d, dma %d", 288 sprintf(card->longname, "Sound Galaxy at 0x%lx, irq %d, dma %d",
284 wssport[dev], xirq, xdma1); 289 wssport[dev], xirq, xdma1);
285 290
286 snd_card_set_dev(card, &devptr->dev); 291 snd_card_set_dev(card, devptr);
287 292
288 if ((err = snd_card_register(card)) < 0) 293 if ((err = snd_card_register(card)) < 0)
289 goto _err; 294 goto _err;
290 295
291 platform_set_drvdata(devptr, card); 296 dev_set_drvdata(devptr, card);
292 return 0; 297 return 0;
293 298
294 _err: 299 _err:
@@ -296,17 +301,18 @@ static int __init snd_sgalaxy_probe(struct platform_device *devptr)
296 return err; 301 return err;
297} 302}
298 303
299static int __devexit snd_sgalaxy_remove(struct platform_device *devptr) 304static int __devexit snd_sgalaxy_remove(struct device *devptr, unsigned int dev)
300{ 305{
301 snd_card_free(platform_get_drvdata(devptr)); 306 snd_card_free(dev_get_drvdata(devptr));
302 platform_set_drvdata(devptr, NULL); 307 dev_set_drvdata(devptr, NULL);
303 return 0; 308 return 0;
304} 309}
305 310
306#ifdef CONFIG_PM 311#ifdef CONFIG_PM
307static int snd_sgalaxy_suspend(struct platform_device *pdev, pm_message_t state) 312static int snd_sgalaxy_suspend(struct device *pdev, unsigned int n,
313 pm_message_t state)
308{ 314{
309 struct snd_card *card = platform_get_drvdata(pdev); 315 struct snd_card *card = dev_get_drvdata(pdev);
310 struct snd_ad1848 *chip = card->private_data; 316 struct snd_ad1848 *chip = card->private_data;
311 317
312 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 318 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
@@ -314,9 +320,9 @@ static int snd_sgalaxy_suspend(struct platform_device *pdev, pm_message_t state)
314 return 0; 320 return 0;
315} 321}
316 322
317static int snd_sgalaxy_resume(struct platform_device *pdev) 323static int snd_sgalaxy_resume(struct device *pdev, unsigned int n)
318{ 324{
319 struct snd_card *card = platform_get_drvdata(pdev); 325 struct snd_card *card = dev_get_drvdata(pdev);
320 struct snd_ad1848 *chip = card->private_data; 326 struct snd_ad1848 *chip = card->private_data;
321 327
322 chip->resume(chip); 328 chip->resume(chip);
@@ -328,9 +334,10 @@ static int snd_sgalaxy_resume(struct platform_device *pdev)
328} 334}
329#endif 335#endif
330 336
331#define SND_SGALAXY_DRIVER "snd_sgalaxy" 337#define DEV_NAME "sgalaxy"
332 338
333static struct platform_driver snd_sgalaxy_driver = { 339static struct isa_driver snd_sgalaxy_driver = {
340 .match = snd_sgalaxy_match,
334 .probe = snd_sgalaxy_probe, 341 .probe = snd_sgalaxy_probe,
335 .remove = __devexit_p(snd_sgalaxy_remove), 342 .remove = __devexit_p(snd_sgalaxy_remove),
336#ifdef CONFIG_PM 343#ifdef CONFIG_PM
@@ -338,56 +345,18 @@ static struct platform_driver snd_sgalaxy_driver = {
338 .resume = snd_sgalaxy_resume, 345 .resume = snd_sgalaxy_resume,
339#endif 346#endif
340 .driver = { 347 .driver = {
341 .name = SND_SGALAXY_DRIVER 348 .name = DEV_NAME
342 }, 349 },
343}; 350};
344 351
345static void __init_or_module snd_sgalaxy_unregister_all(void)
346{
347 int i;
348
349 for (i = 0; i < ARRAY_SIZE(devices); ++i)
350 platform_device_unregister(devices[i]);
351 platform_driver_unregister(&snd_sgalaxy_driver);
352}
353
354static int __init alsa_card_sgalaxy_init(void) 352static int __init alsa_card_sgalaxy_init(void)
355{ 353{
356 int i, cards, err; 354 return isa_register_driver(&snd_sgalaxy_driver, SNDRV_CARDS);
357
358 err = platform_driver_register(&snd_sgalaxy_driver);
359 if (err < 0)
360 return err;
361
362 cards = 0;
363 for (i = 0; i < SNDRV_CARDS; i++) {
364 struct platform_device *device;
365 if (! enable[i])
366 continue;
367 device = platform_device_register_simple(SND_SGALAXY_DRIVER,
368 i, NULL, 0);
369 if (IS_ERR(device))
370 continue;
371 if (!platform_get_drvdata(device)) {
372 platform_device_unregister(device);
373 continue;
374 }
375 devices[i] = device;
376 cards++;
377 }
378 if (!cards) {
379#ifdef MODULE
380 snd_printk(KERN_ERR "Sound Galaxy soundcard not found or device busy\n");
381#endif
382 snd_sgalaxy_unregister_all();
383 return -ENODEV;
384 }
385 return 0;
386} 355}
387 356
388static void __exit alsa_card_sgalaxy_exit(void) 357static void __exit alsa_card_sgalaxy_exit(void)
389{ 358{
390 snd_sgalaxy_unregister_all(); 359 isa_unregister_driver(&snd_sgalaxy_driver);
391} 360}
392 361
393module_init(alsa_card_sgalaxy_init) 362module_init(alsa_card_sgalaxy_init)
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c
index b1f25823c652..08c14978558c 100644
--- a/sound/isa/sscape.c
+++ b/sound/isa/sscape.c
@@ -24,7 +24,7 @@
24#include <sound/driver.h> 24#include <sound/driver.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/platform_device.h> 27#include <linux/isa.h>
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/pnp.h> 29#include <linux/pnp.h>
30#include <linux/spinlock.h> 30#include <linux/spinlock.h>
@@ -68,8 +68,6 @@ MODULE_PARM_DESC(mpu_irq, "MPU401 IRQ # for SoundScape driver.");
68module_param_array(dma, int, NULL, 0444); 68module_param_array(dma, int, NULL, 0444);
69MODULE_PARM_DESC(dma, "DMA # for SoundScape driver."); 69MODULE_PARM_DESC(dma, "DMA # for SoundScape driver.");
70 70
71static struct platform_device *platform_devices[SNDRV_CARDS];
72
73#ifdef CONFIG_PNP 71#ifdef CONFIG_PNP
74static int pnp_registered; 72static int pnp_registered;
75static struct pnp_card_device_id sscape_pnpids[] = { 73static struct pnp_card_device_id sscape_pnpids[] = {
@@ -1254,9 +1252,27 @@ static int __devinit create_sscape(int dev, struct snd_card **rcardp)
1254} 1252}
1255 1253
1256 1254
1257static int __devinit snd_sscape_probe(struct platform_device *pdev) 1255static int __devinit snd_sscape_match(struct device *pdev, unsigned int i)
1256{
1257 /*
1258 * Make sure we were given ALL of the other parameters.
1259 */
1260 if (port[i] == SNDRV_AUTO_PORT)
1261 return 0;
1262
1263 if (irq[i] == SNDRV_AUTO_IRQ ||
1264 mpu_irq[i] == SNDRV_AUTO_IRQ ||
1265 dma[i] == SNDRV_AUTO_DMA) {
1266 printk(KERN_INFO
1267 "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n");
1268 return 0;
1269 }
1270
1271 return 1;
1272}
1273
1274static int __devinit snd_sscape_probe(struct device *pdev, unsigned int dev)
1258{ 1275{
1259 int dev = pdev->id;
1260 struct snd_card *card; 1276 struct snd_card *card;
1261 int ret; 1277 int ret;
1262 1278
@@ -1264,30 +1280,31 @@ static int __devinit snd_sscape_probe(struct platform_device *pdev)
1264 ret = create_sscape(dev, &card); 1280 ret = create_sscape(dev, &card);
1265 if (ret < 0) 1281 if (ret < 0)
1266 return ret; 1282 return ret;
1267 snd_card_set_dev(card, &pdev->dev); 1283 snd_card_set_dev(card, pdev);
1268 if ((ret = snd_card_register(card)) < 0) { 1284 if ((ret = snd_card_register(card)) < 0) {
1269 printk(KERN_ERR "sscape: Failed to register sound card\n"); 1285 printk(KERN_ERR "sscape: Failed to register sound card\n");
1270 return ret; 1286 return ret;
1271 } 1287 }
1272 platform_set_drvdata(pdev, card); 1288 dev_set_drvdata(pdev, card);
1273 return 0; 1289 return 0;
1274} 1290}
1275 1291
1276static int __devexit snd_sscape_remove(struct platform_device *devptr) 1292static int __devexit snd_sscape_remove(struct device *devptr, unsigned int dev)
1277{ 1293{
1278 snd_card_free(platform_get_drvdata(devptr)); 1294 snd_card_free(dev_get_drvdata(devptr));
1279 platform_set_drvdata(devptr, NULL); 1295 dev_set_drvdata(devptr, NULL);
1280 return 0; 1296 return 0;
1281} 1297}
1282 1298
1283#define SSCAPE_DRIVER "snd_sscape" 1299#define DEV_NAME "sscape"
1284 1300
1285static struct platform_driver snd_sscape_driver = { 1301static struct isa_driver snd_sscape_driver = {
1302 .match = snd_sscape_match,
1286 .probe = snd_sscape_probe, 1303 .probe = snd_sscape_probe,
1287 .remove = __devexit_p(snd_sscape_remove), 1304 .remove = __devexit_p(snd_sscape_remove),
1288 /* FIXME: suspend/resume */ 1305 /* FIXME: suspend/resume */
1289 .driver = { 1306 .driver = {
1290 .name = SSCAPE_DRIVER 1307 .name = DEV_NAME
1291 }, 1308 },
1292}; 1309};
1293 1310
@@ -1386,72 +1403,6 @@ static struct pnp_card_driver sscape_pnpc_driver = {
1386 1403
1387#endif /* CONFIG_PNP */ 1404#endif /* CONFIG_PNP */
1388 1405
1389static void __init_or_module sscape_unregister_all(void)
1390{
1391 int i;
1392
1393#ifdef CONFIG_PNP
1394 if (pnp_registered)
1395 pnp_unregister_card_driver(&sscape_pnpc_driver);
1396#endif
1397 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
1398 platform_device_unregister(platform_devices[i]);
1399 platform_driver_unregister(&snd_sscape_driver);
1400}
1401
1402static int __init sscape_manual_probe(void)
1403{
1404 struct platform_device *device;
1405 int i, ret;
1406
1407 ret = platform_driver_register(&snd_sscape_driver);
1408 if (ret < 0)
1409 return ret;
1410
1411 for (i = 0; i < SNDRV_CARDS; ++i) {
1412 /*
1413 * We do NOT probe for ports.
1414 * If we're not given a port number for this
1415 * card then we completely ignore this line
1416 * of parameters.
1417 */
1418 if (port[i] == SNDRV_AUTO_PORT)
1419 continue;
1420
1421 /*
1422 * Make sure we were given ALL of the other parameters.
1423 */
1424 if (irq[i] == SNDRV_AUTO_IRQ ||
1425 mpu_irq[i] == SNDRV_AUTO_IRQ ||
1426 dma[i] == SNDRV_AUTO_DMA) {
1427 printk(KERN_INFO
1428 "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n");
1429 sscape_unregister_all();
1430 return -ENXIO;
1431 }
1432
1433 /*
1434 * This cards looks OK ...
1435 */
1436 device = platform_device_register_simple(SSCAPE_DRIVER,
1437 i, NULL, 0);
1438 if (IS_ERR(device))
1439 continue;
1440 if (!platform_get_drvdata(device)) {
1441 platform_device_unregister(device);
1442 continue;
1443 }
1444 platform_devices[i] = device;
1445 }
1446 return 0;
1447}
1448
1449static void sscape_exit(void)
1450{
1451 sscape_unregister_all();
1452}
1453
1454
1455static int __init sscape_init(void) 1406static int __init sscape_init(void)
1456{ 1407{
1457 int ret; 1408 int ret;
@@ -1462,7 +1413,7 @@ static int __init sscape_init(void)
1462 * of allocating cards, because the operator is 1413 * of allocating cards, because the operator is
1463 * S-P-E-L-L-I-N-G it out for us... 1414 * S-P-E-L-L-I-N-G it out for us...
1464 */ 1415 */
1465 ret = sscape_manual_probe(); 1416 ret = isa_register_driver(&snd_sscape_driver, SNDRV_CARDS);
1466 if (ret < 0) 1417 if (ret < 0)
1467 return ret; 1418 return ret;
1468#ifdef CONFIG_PNP 1419#ifdef CONFIG_PNP
@@ -1472,5 +1423,14 @@ static int __init sscape_init(void)
1472 return 0; 1423 return 0;
1473} 1424}
1474 1425
1426static void __exit sscape_exit(void)
1427{
1428#ifdef CONFIG_PNP
1429 if (pnp_registered)
1430 pnp_unregister_card_driver(&sscape_pnpc_driver);
1431#endif
1432 isa_unregister_driver(&snd_sscape_driver);
1433}
1434
1475module_init(sscape_init); 1435module_init(sscape_init);
1476module_exit(sscape_exit); 1436module_exit(sscape_exit);
diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c
index e2fdd5fd39d0..75673f723857 100644
--- a/sound/isa/wavefront/wavefront.c
+++ b/sound/isa/wavefront/wavefront.c
@@ -24,7 +24,7 @@
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/platform_device.h> 27#include <linux/isa.h>
28#include <linux/pnp.h> 28#include <linux/pnp.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <sound/core.h> 30#include <sound/core.h>
@@ -40,7 +40,9 @@ MODULE_SUPPORTED_DEVICE("{{Turtle Beach,Maui/Tropez/Tropez+}}");
40static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 40static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
41static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 41static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
42static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */ 42static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
43#ifdef CONFIG_PNP
43static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 44static int isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
45#endif
44static long cs4232_pcm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 46static long cs4232_pcm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
45static int cs4232_pcm_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */ 47static int cs4232_pcm_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 5,7,9,11,12,15 */
46static long cs4232_mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */ 48static long cs4232_mpu_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* PnP setup */
@@ -83,8 +85,6 @@ MODULE_PARM_DESC(fm_port, "FM port #.");
83module_param_array(use_cs4232_midi, bool, NULL, 0444); 85module_param_array(use_cs4232_midi, bool, NULL, 0444);
84MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)"); 86MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)");
85 87
86static struct platform_device *platform_devices[SNDRV_CARDS];
87
88#ifdef CONFIG_PNP 88#ifdef CONFIG_PNP
89static int pnp_registered; 89static int pnp_registered;
90 90
@@ -588,56 +588,67 @@ snd_wavefront_probe (struct snd_card *card, int dev)
588 return snd_card_register(card); 588 return snd_card_register(card);
589} 589}
590 590
591static int __devinit snd_wavefront_nonpnp_probe(struct platform_device *pdev) 591static int __devinit snd_wavefront_isa_match(struct device *pdev,
592 unsigned int dev)
592{ 593{
593 int dev = pdev->id; 594 if (!enable[dev])
594 struct snd_card *card; 595 return 0;
595 int err; 596#ifdef CONFIG_PNP
596 597 if (isapnp[dev])
598 return 0;
599#endif
597 if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { 600 if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) {
598 snd_printk("specify CS4232 port\n"); 601 snd_printk("specify CS4232 port\n");
599 return -EINVAL; 602 return 0;
600 } 603 }
601 if (ics2115_port[dev] == SNDRV_AUTO_PORT) { 604 if (ics2115_port[dev] == SNDRV_AUTO_PORT) {
602 snd_printk("specify ICS2115 port\n"); 605 snd_printk("specify ICS2115 port\n");
603 return -ENODEV; 606 return 0;
604 } 607 }
608 return 1;
609}
610
611static int __devinit snd_wavefront_isa_probe(struct device *pdev,
612 unsigned int dev)
613{
614 struct snd_card *card;
615 int err;
605 616
606 card = snd_wavefront_card_new(dev); 617 card = snd_wavefront_card_new(dev);
607 if (! card) 618 if (! card)
608 return -ENOMEM; 619 return -ENOMEM;
609 snd_card_set_dev(card, &pdev->dev); 620 snd_card_set_dev(card, pdev);
610 if ((err = snd_wavefront_probe(card, dev)) < 0) { 621 if ((err = snd_wavefront_probe(card, dev)) < 0) {
611 snd_card_free(card); 622 snd_card_free(card);
612 return err; 623 return err;
613 } 624 }
614 625
615 platform_set_drvdata(pdev, card); 626 dev_set_drvdata(pdev, card);
616 return 0; 627 return 0;
617} 628}
618 629
619static int __devexit snd_wavefront_nonpnp_remove(struct platform_device *devptr) 630static int __devexit snd_wavefront_isa_remove(struct device *devptr,
631 unsigned int dev)
620{ 632{
621 snd_card_free(platform_get_drvdata(devptr)); 633 snd_card_free(dev_get_drvdata(devptr));
622 platform_set_drvdata(devptr, NULL); 634 dev_set_drvdata(devptr, NULL);
623 return 0; 635 return 0;
624} 636}
625 637
626#define WAVEFRONT_DRIVER "snd_wavefront" 638#define DEV_NAME "wavefront"
627 639
628static struct platform_driver snd_wavefront_driver = { 640static struct isa_driver snd_wavefront_driver = {
629 .probe = snd_wavefront_nonpnp_probe, 641 .match = snd_wavefront_isa_match,
630 .remove = __devexit_p(snd_wavefront_nonpnp_remove), 642 .probe = snd_wavefront_isa_probe,
643 .remove = __devexit_p(snd_wavefront_isa_remove),
631 /* FIXME: suspend, resume */ 644 /* FIXME: suspend, resume */
632 .driver = { 645 .driver = {
633 .name = WAVEFRONT_DRIVER 646 .name = DEV_NAME
634 }, 647 },
635}; 648};
636 649
637 650
638#ifdef CONFIG_PNP 651#ifdef CONFIG_PNP
639static unsigned int __devinitdata wavefront_pnp_devices;
640
641static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard, 652static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
642 const struct pnp_card_device_id *pid) 653 const struct pnp_card_device_id *pid)
643{ 654{
@@ -670,7 +681,6 @@ static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard,
670 681
671 pnp_set_card_drvdata(pcard, card); 682 pnp_set_card_drvdata(pcard, card);
672 dev++; 683 dev++;
673 wavefront_pnp_devices++;
674 return 0; 684 return 0;
675} 685}
676 686
@@ -691,67 +701,28 @@ static struct pnp_card_driver wavefront_pnpc_driver = {
691 701
692#endif /* CONFIG_PNP */ 702#endif /* CONFIG_PNP */
693 703
694static void __init_or_module snd_wavefront_unregister_all(void)
695{
696 int i;
697
698#ifdef CONFIG_PNP
699 if (pnp_registered)
700 pnp_unregister_card_driver(&wavefront_pnpc_driver);
701#endif
702 for (i = 0; i < ARRAY_SIZE(platform_devices); ++i)
703 platform_device_unregister(platform_devices[i]);
704 platform_driver_unregister(&snd_wavefront_driver);
705}
706
707static int __init alsa_card_wavefront_init(void) 704static int __init alsa_card_wavefront_init(void)
708{ 705{
709 int i, err, cards = 0; 706 int err;
710 707
711 if ((err = platform_driver_register(&snd_wavefront_driver)) < 0) 708 err = isa_register_driver(&snd_wavefront_driver, SNDRV_CARDS);
709 if (err < 0)
712 return err; 710 return err;
713
714 for (i = 0; i < SNDRV_CARDS; i++) {
715 struct platform_device *device;
716 if (! enable[i])
717 continue;
718#ifdef CONFIG_PNP
719 if (isapnp[i])
720 continue;
721#endif
722 device = platform_device_register_simple(WAVEFRONT_DRIVER,
723 i, NULL, 0);
724 if (IS_ERR(device))
725 continue;
726 if (!platform_get_drvdata(device)) {
727 platform_device_unregister(device);
728 continue;
729 }
730 platform_devices[i] = device;
731 cards++;
732 }
733
734#ifdef CONFIG_PNP 711#ifdef CONFIG_PNP
735 err = pnp_register_card_driver(&wavefront_pnpc_driver); 712 err = pnp_register_card_driver(&wavefront_pnpc_driver);
736 if (!err) { 713 if (!err)
737 pnp_registered = 1; 714 pnp_registered = 1;
738 cards += wavefront_pnp_devices;
739 }
740#endif
741
742 if (!cards) {
743#ifdef MODULE
744 printk (KERN_ERR "No WaveFront cards found or devices busy\n");
745#endif 715#endif
746 snd_wavefront_unregister_all();
747 return -ENODEV;
748 }
749 return 0; 716 return 0;
750} 717}
751 718
752static void __exit alsa_card_wavefront_exit(void) 719static void __exit alsa_card_wavefront_exit(void)
753{ 720{
754 snd_wavefront_unregister_all(); 721#ifdef CONFIG_PNP
722 if (pnp_registered)
723 pnp_unregister_card_driver(&wavefront_pnpc_driver);
724#endif
725 isa_unregister_driver(&snd_wavefront_driver);
755} 726}
756 727
757module_init(alsa_card_wavefront_init) 728module_init(alsa_card_wavefront_init)
diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c
index 15331ed88194..fc95a870f690 100644
--- a/sound/isa/wavefront/wavefront_fx.c
+++ b/sound/isa/wavefront/wavefront_fx.c
@@ -35,9 +35,7 @@
35 35
36#define WAIT_IDLE 0xff 36#define WAIT_IDLE 0xff
37 37
38#define FIRMWARE_IN_THE_KERNEL 38#ifdef CONFIG_SND_WAVEFRONT_FIRMWARE_IN_KERNEL
39
40#ifdef FIRMWARE_IN_THE_KERNEL
41#include "yss225.c" 39#include "yss225.c"
42static const struct firmware yss225_registers_firmware = { 40static const struct firmware yss225_registers_firmware = {
43 .data = (u8 *)yss225_registers, 41 .data = (u8 *)yss225_registers,
@@ -258,21 +256,21 @@ snd_wavefront_fx_start (snd_wavefront_t *dev)
258{ 256{
259 unsigned int i; 257 unsigned int i;
260 int err; 258 int err;
261 const struct firmware *firmware; 259 const struct firmware *firmware = NULL;
262 260
263 if (dev->fx_initialized) 261 if (dev->fx_initialized)
264 return 0; 262 return 0;
265 263
264#ifdef CONFIG_SND_WAVEFRONT_FIRMWARE_IN_KERNEL
265 firmware = &yss225_registers_firmware;
266#else
266 err = request_firmware(&firmware, "yamaha/yss225_registers.bin", 267 err = request_firmware(&firmware, "yamaha/yss225_registers.bin",
267 dev->card->dev); 268 dev->card->dev);
268 if (err < 0) { 269 if (err < 0) {
269#ifdef FIRMWARE_IN_THE_KERNEL
270 firmware = &yss225_registers_firmware;
271#else
272 err = -1; 270 err = -1;
273 goto out; 271 goto out;
274#endif
275 } 272 }
273#endif
276 274
277 for (i = 0; i + 1 < firmware->size; i += 2) { 275 for (i = 0; i + 1 < firmware->size; i += 2) {
278 if (firmware->data[i] >= 8 && firmware->data[i] < 16) { 276 if (firmware->data[i] >= 8 && firmware->data[i] < 16) {
@@ -295,9 +293,12 @@ snd_wavefront_fx_start (snd_wavefront_t *dev)
295 err = 0; 293 err = 0;
296 294
297out: 295out:
298#ifdef FIRMWARE_IN_THE_KERNEL 296#ifndef CONFIG_SND_WAVEFRONT_FIRMWARE_IN_KERNEL
299 if (firmware != &yss225_registers_firmware) 297 release_firmware(firmware);
300#endif 298#endif
301 release_firmware(firmware);
302 return err; 299 return err;
303} 300}
301
302#ifndef CONFIG_SND_WAVEFRONT_FIRMWARE_IN_KERNEL
303MODULE_FIRMWARE("yamaha/yss225_registers.bin");
304#endif
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index 1bcfb3aac18d..61e35ecc57b8 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -576,7 +576,7 @@ config SND_INTEL8X0M
576config SND_KORG1212 576config SND_KORG1212
577 tristate "Korg 1212 IO" 577 tristate "Korg 1212 IO"
578 depends on SND 578 depends on SND
579 select FW_LOADER 579 select FW_LOADER if !SND_KORG1212_FIRMWARE_IN_KERNEL
580 select SND_PCM 580 select SND_PCM
581 help 581 help
582 Say Y here to include support for Korg 1212IO soundcards. 582 Say Y here to include support for Korg 1212IO soundcards.
@@ -584,10 +584,19 @@ config SND_KORG1212
584 To compile this driver as a module, choose M here: the module 584 To compile this driver as a module, choose M here: the module
585 will be called snd-korg1212. 585 will be called snd-korg1212.
586 586
587config SND_KORG1212_FIRMWARE_IN_KERNEL
588 bool "In-kernel firmware for Korg1212 driver"
589 depends on SND_KORG1212
590 default y
591 help
592 Say Y here to include the static firmware built in the kernel
593 for the Korg1212 driver. If you choose N here, you need to
594 install the firmware files from the alsa-firmware package.
595
587config SND_MAESTRO3 596config SND_MAESTRO3
588 tristate "ESS Allegro/Maestro3" 597 tristate "ESS Allegro/Maestro3"
589 depends on SND 598 depends on SND
590 select FW_LOADER 599 select FW_LOADER if !SND_MAESTRO3_FIRMWARE_IN_KERNEL
591 select SND_AC97_CODEC 600 select SND_AC97_CODEC
592 help 601 help
593 Say Y here to include support for soundcards based on ESS Maestro 3 602 Say Y here to include support for soundcards based on ESS Maestro 3
@@ -596,6 +605,15 @@ config SND_MAESTRO3
596 To compile this driver as a module, choose M here: the module 605 To compile this driver as a module, choose M here: the module
597 will be called snd-maestro3. 606 will be called snd-maestro3.
598 607
608config SND_MAESTRO3_FIRMWARE_IN_KERNEL
609 bool "In-kernel firmware for Maestro3 driver"
610 depends on SND_MAESTRO3
611 default y
612 help
613 Say Y here to include the static firmware built in the kernel
614 for the Maestro3 driver. If you choose N here, you need to
615 install the firmware files from the alsa-firmware package.
616
599config SND_MIXART 617config SND_MIXART
600 tristate "Digigram miXart" 618 tristate "Digigram miXart"
601 depends on SND 619 depends on SND
@@ -737,7 +755,7 @@ config SND_VX222
737config SND_YMFPCI 755config SND_YMFPCI
738 tristate "Yamaha YMF724/740/744/754" 756 tristate "Yamaha YMF724/740/744/754"
739 depends on SND 757 depends on SND
740 select FW_LOADER 758 select FW_LOADER if !SND_YMFPCI_FIRMWARE_IN_KERNEL
741 select SND_OPL3_LIB 759 select SND_OPL3_LIB
742 select SND_MPU401_UART 760 select SND_MPU401_UART
743 select SND_AC97_CODEC 761 select SND_AC97_CODEC
@@ -748,6 +766,15 @@ config SND_YMFPCI
748 To compile this driver as a module, choose M here: the module 766 To compile this driver as a module, choose M here: the module
749 will be called snd-ymfpci. 767 will be called snd-ymfpci.
750 768
769config SND_YMFPCI_FIRMWARE_IN_KERNEL
770 bool "In-kernel firmware for YMFPCI driver"
771 depends on SND_YMFPCI
772 default y
773 help
774 Say Y here to include the static firmware built in the kernel
775 for the YMFPCI driver. If you choose N here, you need to
776 install the firmware files from the alsa-firmware package.
777
751config SND_AC97_POWER_SAVE 778config SND_AC97_POWER_SAVE
752 bool "AC97 Power-Saving Mode" 779 bool "AC97 Power-Saving Mode"
753 depends on SND_AC97_CODEC && EXPERIMENTAL 780 depends on SND_AC97_CODEC && EXPERIMENTAL
diff --git a/sound/pci/ac97/Makefile b/sound/pci/ac97/Makefile
index 3c3222122d8b..f5d471896b95 100644
--- a/sound/pci/ac97/Makefile
+++ b/sound/pci/ac97/Makefile
@@ -3,7 +3,7 @@
3# Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz> 3# Copyright (c) 2001 by Jaroslav Kysela <perex@suse.cz>
4# 4#
5 5
6snd-ac97-codec-objs := ac97_codec.o ac97_pcm.o ac97_patch.o 6snd-ac97-codec-objs := ac97_codec.o ac97_pcm.o
7 7
8ifneq ($(CONFIG_PROC_FS),) 8ifneq ($(CONFIG_PROC_FS),)
9snd-ac97-codec-objs += ac97_proc.o 9snd-ac97-codec-objs += ac97_proc.o
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index 3bfb2102fc5d..bbed644bf9c5 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -35,9 +35,9 @@
35#include <sound/ac97_codec.h> 35#include <sound/ac97_codec.h>
36#include <sound/asoundef.h> 36#include <sound/asoundef.h>
37#include <sound/initval.h> 37#include <sound/initval.h>
38#include "ac97_local.h"
39#include "ac97_id.h" 38#include "ac97_id.h"
40#include "ac97_patch.h" 39
40#include "ac97_patch.c"
41 41
42MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 42MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
43MODULE_DESCRIPTION("Universal interface for Audio Codec '97"); 43MODULE_DESCRIPTION("Universal interface for Audio Codec '97");
@@ -432,7 +432,8 @@ static int snd_ac97_ad18xx_update_pcm_bits(struct snd_ac97 *ac97, int codec, uns
432 * Controls 432 * Controls
433 */ 433 */
434 434
435int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 435static int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol,
436 struct snd_ctl_elem_info *uinfo)
436{ 437{
437 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; 438 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value;
438 439
@@ -446,7 +447,8 @@ int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
446 return 0; 447 return 0;
447} 448}
448 449
449int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 450static int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol,
451 struct snd_ctl_elem_value *ucontrol)
450{ 452{
451 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); 453 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
452 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; 454 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value;
@@ -462,7 +464,8 @@ int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
462 return 0; 464 return 0;
463} 465}
464 466
465int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 467static int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol,
468 struct snd_ctl_elem_value *ucontrol)
466{ 469{
467 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); 470 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
468 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; 471 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value;
@@ -508,7 +511,8 @@ static void snd_ac97_page_restore(struct snd_ac97 *ac97, int page_save)
508} 511}
509 512
510/* volume and switch controls */ 513/* volume and switch controls */
511int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 514static int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_info *uinfo)
512{ 516{
513 int mask = (kcontrol->private_value >> 16) & 0xff; 517 int mask = (kcontrol->private_value >> 16) & 0xff;
514 int shift = (kcontrol->private_value >> 8) & 0x0f; 518 int shift = (kcontrol->private_value >> 8) & 0x0f;
@@ -521,7 +525,8 @@ int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info
521 return 0; 525 return 0;
522} 526}
523 527
524int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 528static int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol,
529 struct snd_ctl_elem_value *ucontrol)
525{ 530{
526 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); 531 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
527 int reg = kcontrol->private_value & 0xff; 532 int reg = kcontrol->private_value & 0xff;
@@ -544,7 +549,8 @@ int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value
544 return 0; 549 return 0;
545} 550}
546 551
547int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 552static int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol,
553 struct snd_ctl_elem_value *ucontrol)
548{ 554{
549 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); 555 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
550 int reg = kcontrol->private_value & 0xff; 556 int reg = kcontrol->private_value & 0xff;
@@ -646,7 +652,7 @@ AC97_ENUM("Mic Select", std_enum[3]),
646AC97_SINGLE("ADC/DAC Loopback", AC97_GENERAL_PURPOSE, 7, 1, 0) 652AC97_SINGLE("ADC/DAC Loopback", AC97_GENERAL_PURPOSE, 7, 1, 0)
647}; 653};
648 654
649const struct snd_kcontrol_new snd_ac97_controls_3d[2] = { 655static const struct snd_kcontrol_new snd_ac97_controls_3d[2] = {
650AC97_SINGLE("3D Control - Center", AC97_3D_CONTROL, 8, 15, 0), 656AC97_SINGLE("3D Control - Center", AC97_3D_CONTROL, 8, 15, 0),
651AC97_SINGLE("3D Control - Depth", AC97_3D_CONTROL, 0, 15, 0) 657AC97_SINGLE("3D Control - Depth", AC97_3D_CONTROL, 0, 15, 0)
652}; 658};
@@ -817,7 +823,7 @@ static int snd_ac97_put_spsa(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
817 return change; 823 return change;
818} 824}
819 825
820const struct snd_kcontrol_new snd_ac97_controls_spdif[5] = { 826static const struct snd_kcontrol_new snd_ac97_controls_spdif[5] = {
821 { 827 {
822 .access = SNDRV_CTL_ELEM_ACCESS_READ, 828 .access = SNDRV_CTL_ELEM_ACCESS_READ,
823 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -1097,7 +1103,7 @@ static void check_volume_resolution(struct snd_ac97 *ac97, int reg, unsigned cha
1097 } 1103 }
1098} 1104}
1099 1105
1100int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit) 1106static int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit)
1101{ 1107{
1102 unsigned short mask, val, orig, res; 1108 unsigned short mask, val, orig, res;
1103 1109
@@ -1137,7 +1143,8 @@ static inline int printable(unsigned int x)
1137 return x; 1143 return x;
1138} 1144}
1139 1145
1140struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template, struct snd_ac97 * ac97) 1146static struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template,
1147 struct snd_ac97 * ac97)
1141{ 1148{
1142 struct snd_kcontrol_new template; 1149 struct snd_kcontrol_new template;
1143 memcpy(&template, _template, sizeof(template)); 1150 memcpy(&template, _template, sizeof(template));
@@ -2544,7 +2551,8 @@ static void set_ctl_name(char *dst, const char *src, const char *suffix)
2544} 2551}
2545 2552
2546/* remove the control with the given name and optional suffix */ 2553/* remove the control with the given name and optional suffix */
2547int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name, const char *suffix) 2554static int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name,
2555 const char *suffix)
2548{ 2556{
2549 struct snd_ctl_elem_id id; 2557 struct snd_ctl_elem_id id;
2550 memset(&id, 0, sizeof(id)); 2558 memset(&id, 0, sizeof(id));
@@ -2563,7 +2571,8 @@ static struct snd_kcontrol *ctl_find(struct snd_ac97 *ac97, const char *name, co
2563} 2571}
2564 2572
2565/* rename the control with the given name and optional suffix */ 2573/* rename the control with the given name and optional suffix */
2566int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, const char *dst, const char *suffix) 2574static int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src,
2575 const char *dst, const char *suffix)
2567{ 2576{
2568 struct snd_kcontrol *kctl = ctl_find(ac97, src, suffix); 2577 struct snd_kcontrol *kctl = ctl_find(ac97, src, suffix);
2569 if (kctl) { 2578 if (kctl) {
@@ -2574,14 +2583,16 @@ int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, const char *dst,
2574} 2583}
2575 2584
2576/* rename both Volume and Switch controls - don't check the return value */ 2585/* rename both Volume and Switch controls - don't check the return value */
2577void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src, const char *dst) 2586static void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src,
2587 const char *dst)
2578{ 2588{
2579 snd_ac97_rename_ctl(ac97, src, dst, "Switch"); 2589 snd_ac97_rename_ctl(ac97, src, dst, "Switch");
2580 snd_ac97_rename_ctl(ac97, src, dst, "Volume"); 2590 snd_ac97_rename_ctl(ac97, src, dst, "Volume");
2581} 2591}
2582 2592
2583/* swap controls */ 2593/* swap controls */
2584int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1, const char *s2, const char *suffix) 2594static int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1,
2595 const char *s2, const char *suffix)
2585{ 2596{
2586 struct snd_kcontrol *kctl1, *kctl2; 2597 struct snd_kcontrol *kctl1, *kctl2;
2587 kctl1 = ctl_find(ac97, s1, suffix); 2598 kctl1 = ctl_find(ac97, s1, suffix);
diff --git a/sound/pci/ac97/ac97_local.h b/sound/pci/ac97/ac97_local.h
index a6244c720a1d..78745c5c6df8 100644
--- a/sound/pci/ac97/ac97_local.h
+++ b/sound/pci/ac97/ac97_local.h
@@ -22,59 +22,8 @@
22 * 22 *
23 */ 23 */
24 24
25#define AC97_SINGLE_VALUE(reg,shift,mask,invert) ((reg) | ((shift) << 8) | ((shift) << 12) | ((mask) << 16) | ((invert) << 24)) 25void snd_ac97_get_name(struct snd_ac97 *ac97, unsigned int id, char *name,
26#define AC97_PAGE_SINGLE_VALUE(reg,shift,mask,invert,page) (AC97_SINGLE_VALUE(reg,shift,mask,invert) | (1<<25) | ((page) << 26)) 26 int modem);
27#define AC97_SINGLE(xname, reg, shift, mask, invert) \
28{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_ac97_info_volsw, \
29 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
30 .private_value = AC97_SINGLE_VALUE(reg, shift, mask, invert) }
31#define AC97_PAGE_SINGLE(xname, reg, shift, mask, invert, page) \
32{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_ac97_info_volsw, \
33 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
34 .private_value = AC97_PAGE_SINGLE_VALUE(reg, shift, mask, invert, page) }
35#define AC97_DOUBLE(xname, reg, shift_left, shift_right, mask, invert) \
36{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), .info = snd_ac97_info_volsw, \
37 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
38 .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) | ((mask) << 16) | ((invert) << 24) }
39
40/* enum control */
41struct ac97_enum {
42 unsigned char reg;
43 unsigned char shift_l;
44 unsigned char shift_r;
45 unsigned short mask;
46 const char **texts;
47};
48
49#define AC97_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \
50{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
51 .mask = xmask, .texts = xtexts }
52#define AC97_ENUM_SINGLE(xreg, xshift, xmask, xtexts) \
53 AC97_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xtexts)
54#define AC97_ENUM(xname, xenum) \
55{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_ac97_info_enum_double, \
56 .get = snd_ac97_get_enum_double, .put = snd_ac97_put_enum_double, \
57 .private_value = (unsigned long)&xenum }
58
59/* ac97_codec.c */
60extern const struct snd_kcontrol_new snd_ac97_controls_3d[];
61extern const struct snd_kcontrol_new snd_ac97_controls_spdif[];
62struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template, struct snd_ac97 * ac97);
63void snd_ac97_get_name(struct snd_ac97 *ac97, unsigned int id, char *name, int modem);
64int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo);
65int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
66int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
67int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit);
68int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name, const char *suffix);
69int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, const char *dst, const char *suffix);
70int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1, const char *s2, const char *suffix);
71void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src, const char *dst);
72void snd_ac97_restore_status(struct snd_ac97 *ac97);
73void snd_ac97_restore_iec958(struct snd_ac97 *ac97);
74int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo);
75int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
76int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
77
78int snd_ac97_update_bits_nolock(struct snd_ac97 *ac97, unsigned short reg, 27int snd_ac97_update_bits_nolock(struct snd_ac97 *ac97, unsigned short reg,
79 unsigned short mask, unsigned short value); 28 unsigned short mask, unsigned short value);
80 29
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index b188a4df58cb..3eac0f86266c 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -23,20 +23,8 @@
23 * 23 *
24 */ 24 */
25 25
26#include <sound/driver.h>
27#include <linux/delay.h>
28#include <linux/init.h>
29#include <linux/slab.h>
30#include <linux/mutex.h>
31
32#include <sound/core.h>
33#include <sound/pcm.h>
34#include <sound/control.h>
35#include <sound/tlv.h>
36#include <sound/ac97_codec.h>
37#include "ac97_patch.h"
38#include "ac97_id.h"
39#include "ac97_local.h" 26#include "ac97_local.h"
27#include "ac97_patch.h"
40 28
41/* 29/*
42 * Chip specific initialization 30 * Chip specific initialization
@@ -390,7 +378,7 @@ static struct snd_ac97_build_ops patch_yamaha_ymf753_ops = {
390 .build_post_spdif = patch_yamaha_ymf753_post_spdif 378 .build_post_spdif = patch_yamaha_ymf753_post_spdif
391}; 379};
392 380
393int patch_yamaha_ymf753(struct snd_ac97 * ac97) 381static int patch_yamaha_ymf753(struct snd_ac97 * ac97)
394{ 382{
395 /* Patch for Yamaha YMF753, Copyright (c) by David Shust, dshust@shustring.com. 383 /* Patch for Yamaha YMF753, Copyright (c) by David Shust, dshust@shustring.com.
396 This chip has nonstandard and extended behaviour with regard to its S/PDIF output. 384 This chip has nonstandard and extended behaviour with regard to its S/PDIF output.
@@ -436,7 +424,7 @@ static struct snd_ac97_build_ops patch_wolfson_wm9703_ops = {
436 .build_specific = patch_wolfson_wm9703_specific, 424 .build_specific = patch_wolfson_wm9703_specific,
437}; 425};
438 426
439int patch_wolfson03(struct snd_ac97 * ac97) 427static int patch_wolfson03(struct snd_ac97 * ac97)
440{ 428{
441 ac97->build_ops = &patch_wolfson_wm9703_ops; 429 ac97->build_ops = &patch_wolfson_wm9703_ops;
442 return 0; 430 return 0;
@@ -467,7 +455,7 @@ static struct snd_ac97_build_ops patch_wolfson_wm9704_ops = {
467 .build_specific = patch_wolfson_wm9704_specific, 455 .build_specific = patch_wolfson_wm9704_specific,
468}; 456};
469 457
470int patch_wolfson04(struct snd_ac97 * ac97) 458static int patch_wolfson04(struct snd_ac97 * ac97)
471{ 459{
472 /* WM9704M/9704Q */ 460 /* WM9704M/9704Q */
473 ac97->build_ops = &patch_wolfson_wm9704_ops; 461 ac97->build_ops = &patch_wolfson_wm9704_ops;
@@ -489,7 +477,7 @@ static struct snd_ac97_build_ops patch_wolfson_wm9705_ops = {
489 .build_specific = patch_wolfson_wm9705_specific, 477 .build_specific = patch_wolfson_wm9705_specific,
490}; 478};
491 479
492int patch_wolfson05(struct snd_ac97 * ac97) 480static int patch_wolfson05(struct snd_ac97 * ac97)
493{ 481{
494 /* WM9705, WM9710 */ 482 /* WM9705, WM9710 */
495 ac97->build_ops = &patch_wolfson_wm9705_ops; 483 ac97->build_ops = &patch_wolfson_wm9705_ops;
@@ -625,7 +613,7 @@ static struct snd_ac97_build_ops patch_wolfson_wm9711_ops = {
625 .build_specific = patch_wolfson_wm9711_specific, 613 .build_specific = patch_wolfson_wm9711_specific,
626}; 614};
627 615
628int patch_wolfson11(struct snd_ac97 * ac97) 616static int patch_wolfson11(struct snd_ac97 * ac97)
629{ 617{
630 /* WM9711, WM9712 */ 618 /* WM9711, WM9712 */
631 ac97->build_ops = &patch_wolfson_wm9711_ops; 619 ac97->build_ops = &patch_wolfson_wm9711_ops;
@@ -824,7 +812,7 @@ static struct snd_ac97_build_ops patch_wolfson_wm9713_ops = {
824#endif 812#endif
825}; 813};
826 814
827int patch_wolfson13(struct snd_ac97 * ac97) 815static int patch_wolfson13(struct snd_ac97 * ac97)
828{ 816{
829 /* WM9713, WM9714 */ 817 /* WM9713, WM9714 */
830 ac97->build_ops = &patch_wolfson_wm9713_ops; 818 ac97->build_ops = &patch_wolfson_wm9713_ops;
@@ -844,7 +832,7 @@ int patch_wolfson13(struct snd_ac97 * ac97)
844/* 832/*
845 * Tritech codec 833 * Tritech codec
846 */ 834 */
847int patch_tritech_tr28028(struct snd_ac97 * ac97) 835static int patch_tritech_tr28028(struct snd_ac97 * ac97)
848{ 836{
849 snd_ac97_write_cache(ac97, 0x26, 0x0300); 837 snd_ac97_write_cache(ac97, 0x26, 0x0300);
850 snd_ac97_write_cache(ac97, 0x26, 0x0000); 838 snd_ac97_write_cache(ac97, 0x26, 0x0000);
@@ -922,7 +910,7 @@ static struct snd_ac97_build_ops patch_sigmatel_stac9700_ops = {
922 .build_specific = patch_sigmatel_stac97xx_specific 910 .build_specific = patch_sigmatel_stac97xx_specific
923}; 911};
924 912
925int patch_sigmatel_stac9700(struct snd_ac97 * ac97) 913static int patch_sigmatel_stac9700(struct snd_ac97 * ac97)
926{ 914{
927 ac97->build_ops = &patch_sigmatel_stac9700_ops; 915 ac97->build_ops = &patch_sigmatel_stac9700_ops;
928 return 0; 916 return 0;
@@ -969,7 +957,7 @@ static struct snd_ac97_build_ops patch_sigmatel_stac9708_ops = {
969 .build_specific = patch_sigmatel_stac9708_specific 957 .build_specific = patch_sigmatel_stac9708_specific
970}; 958};
971 959
972int patch_sigmatel_stac9708(struct snd_ac97 * ac97) 960static int patch_sigmatel_stac9708(struct snd_ac97 * ac97)
973{ 961{
974 unsigned int codec72, codec6c; 962 unsigned int codec72, codec6c;
975 963
@@ -995,7 +983,7 @@ int patch_sigmatel_stac9708(struct snd_ac97 * ac97)
995 return 0; 983 return 0;
996} 984}
997 985
998int patch_sigmatel_stac9721(struct snd_ac97 * ac97) 986static int patch_sigmatel_stac9721(struct snd_ac97 * ac97)
999{ 987{
1000 ac97->build_ops = &patch_sigmatel_stac9700_ops; 988 ac97->build_ops = &patch_sigmatel_stac9700_ops;
1001 if (snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) == 0) { 989 if (snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) == 0) {
@@ -1009,7 +997,7 @@ int patch_sigmatel_stac9721(struct snd_ac97 * ac97)
1009 return 0; 997 return 0;
1010} 998}
1011 999
1012int patch_sigmatel_stac9744(struct snd_ac97 * ac97) 1000static int patch_sigmatel_stac9744(struct snd_ac97 * ac97)
1013{ 1001{
1014 // patch for SigmaTel 1002 // patch for SigmaTel
1015 ac97->build_ops = &patch_sigmatel_stac9700_ops; 1003 ac97->build_ops = &patch_sigmatel_stac9700_ops;
@@ -1021,7 +1009,7 @@ int patch_sigmatel_stac9744(struct snd_ac97 * ac97)
1021 return 0; 1009 return 0;
1022} 1010}
1023 1011
1024int patch_sigmatel_stac9756(struct snd_ac97 * ac97) 1012static int patch_sigmatel_stac9756(struct snd_ac97 * ac97)
1025{ 1013{
1026 // patch for SigmaTel 1014 // patch for SigmaTel
1027 ac97->build_ops = &patch_sigmatel_stac9700_ops; 1015 ac97->build_ops = &patch_sigmatel_stac9700_ops;
@@ -1198,7 +1186,7 @@ static struct snd_ac97_build_ops patch_sigmatel_stac9758_ops = {
1198 .build_specific = patch_sigmatel_stac9758_specific 1186 .build_specific = patch_sigmatel_stac9758_specific
1199}; 1187};
1200 1188
1201int patch_sigmatel_stac9758(struct snd_ac97 * ac97) 1189static int patch_sigmatel_stac9758(struct snd_ac97 * ac97)
1202{ 1190{
1203 static unsigned short regs[4] = { 1191 static unsigned short regs[4] = {
1204 AC97_SIGMATEL_OUTSEL, 1192 AC97_SIGMATEL_OUTSEL,
@@ -1272,7 +1260,7 @@ static struct snd_ac97_build_ops patch_cirrus_ops = {
1272 .build_spdif = patch_cirrus_build_spdif 1260 .build_spdif = patch_cirrus_build_spdif
1273}; 1261};
1274 1262
1275int patch_cirrus_spdif(struct snd_ac97 * ac97) 1263static int patch_cirrus_spdif(struct snd_ac97 * ac97)
1276{ 1264{
1277 /* Basically, the cs4201/cs4205/cs4297a has non-standard sp/dif registers. 1265 /* Basically, the cs4201/cs4205/cs4297a has non-standard sp/dif registers.
1278 WHY CAN'T ANYONE FOLLOW THE BLOODY SPEC? *sigh* 1266 WHY CAN'T ANYONE FOLLOW THE BLOODY SPEC? *sigh*
@@ -1293,7 +1281,7 @@ int patch_cirrus_spdif(struct snd_ac97 * ac97)
1293 return 0; 1281 return 0;
1294} 1282}
1295 1283
1296int patch_cirrus_cs4299(struct snd_ac97 * ac97) 1284static int patch_cirrus_cs4299(struct snd_ac97 * ac97)
1297{ 1285{
1298 /* force the detection of PC Beep */ 1286 /* force the detection of PC Beep */
1299 ac97->flags |= AC97_HAS_PC_BEEP; 1287 ac97->flags |= AC97_HAS_PC_BEEP;
@@ -1329,7 +1317,7 @@ static struct snd_ac97_build_ops patch_conexant_ops = {
1329 .build_spdif = patch_conexant_build_spdif 1317 .build_spdif = patch_conexant_build_spdif
1330}; 1318};
1331 1319
1332int patch_conexant(struct snd_ac97 * ac97) 1320static int patch_conexant(struct snd_ac97 * ac97)
1333{ 1321{
1334 ac97->build_ops = &patch_conexant_ops; 1322 ac97->build_ops = &patch_conexant_ops;
1335 ac97->flags |= AC97_CX_SPDIF; 1323 ac97->flags |= AC97_CX_SPDIF;
@@ -1338,7 +1326,7 @@ int patch_conexant(struct snd_ac97 * ac97)
1338 return 0; 1326 return 0;
1339} 1327}
1340 1328
1341int patch_cx20551(struct snd_ac97 *ac97) 1329static int patch_cx20551(struct snd_ac97 *ac97)
1342{ 1330{
1343 snd_ac97_update_bits(ac97, 0x5c, 0x01, 0x01); 1331 snd_ac97_update_bits(ac97, 0x5c, 0x01, 0x01);
1344 return 0; 1332 return 0;
@@ -1430,7 +1418,7 @@ static const struct snd_ac97_res_table ad1819_restbl[] = {
1430 { } /* terminator */ 1418 { } /* terminator */
1431}; 1419};
1432 1420
1433int patch_ad1819(struct snd_ac97 * ac97) 1421static int patch_ad1819(struct snd_ac97 * ac97)
1434{ 1422{
1435 unsigned short scfg; 1423 unsigned short scfg;
1436 1424
@@ -1507,7 +1495,7 @@ static struct snd_ac97_build_ops patch_ad1881_build_ops = {
1507#endif 1495#endif
1508}; 1496};
1509 1497
1510int patch_ad1881(struct snd_ac97 * ac97) 1498static int patch_ad1881(struct snd_ac97 * ac97)
1511{ 1499{
1512 static const char cfg_idxs[3][2] = { 1500 static const char cfg_idxs[3][2] = {
1513 {2, 1}, 1501 {2, 1},
@@ -1595,7 +1583,7 @@ static struct snd_ac97_build_ops patch_ad1885_build_ops = {
1595#endif 1583#endif
1596}; 1584};
1597 1585
1598int patch_ad1885(struct snd_ac97 * ac97) 1586static int patch_ad1885(struct snd_ac97 * ac97)
1599{ 1587{
1600 patch_ad1881(ac97); 1588 patch_ad1881(ac97);
1601 /* This is required to deal with the Intel D815EEAL2 */ 1589 /* This is required to deal with the Intel D815EEAL2 */
@@ -1622,7 +1610,7 @@ static struct snd_ac97_build_ops patch_ad1886_build_ops = {
1622#endif 1610#endif
1623}; 1611};
1624 1612
1625int patch_ad1886(struct snd_ac97 * ac97) 1613static int patch_ad1886(struct snd_ac97 * ac97)
1626{ 1614{
1627 patch_ad1881(ac97); 1615 patch_ad1881(ac97);
1628 /* Presario700 workaround */ 1616 /* Presario700 workaround */
@@ -1844,7 +1832,7 @@ static void check_ad1981_hp_jack_sense(struct snd_ac97 *ac97)
1844 snd_ac97_update_bits(ac97, AC97_AD_JACK_SPDIF, 1<<11, 1<<11); 1832 snd_ac97_update_bits(ac97, AC97_AD_JACK_SPDIF, 1<<11, 1<<11);
1845} 1833}
1846 1834
1847int patch_ad1981a(struct snd_ac97 *ac97) 1835static int patch_ad1981a(struct snd_ac97 *ac97)
1848{ 1836{
1849 patch_ad1881(ac97); 1837 patch_ad1881(ac97);
1850 ac97->build_ops = &patch_ad1981a_build_ops; 1838 ac97->build_ops = &patch_ad1981a_build_ops;
@@ -1877,7 +1865,7 @@ static struct snd_ac97_build_ops patch_ad1981b_build_ops = {
1877#endif 1865#endif
1878}; 1866};
1879 1867
1880int patch_ad1981b(struct snd_ac97 *ac97) 1868static int patch_ad1981b(struct snd_ac97 *ac97)
1881{ 1869{
1882 patch_ad1881(ac97); 1870 patch_ad1881(ac97);
1883 ac97->build_ops = &patch_ad1981b_build_ops; 1871 ac97->build_ops = &patch_ad1981b_build_ops;
@@ -2014,7 +2002,7 @@ static struct snd_ac97_build_ops patch_ad1888_build_ops = {
2014 .update_jacks = ad1888_update_jacks, 2002 .update_jacks = ad1888_update_jacks,
2015}; 2003};
2016 2004
2017int patch_ad1888(struct snd_ac97 * ac97) 2005static int patch_ad1888(struct snd_ac97 * ac97)
2018{ 2006{
2019 unsigned short misc; 2007 unsigned short misc;
2020 2008
@@ -2052,7 +2040,7 @@ static struct snd_ac97_build_ops patch_ad1980_build_ops = {
2052 .update_jacks = ad1888_update_jacks, 2040 .update_jacks = ad1888_update_jacks,
2053}; 2041};
2054 2042
2055int patch_ad1980(struct snd_ac97 * ac97) 2043static int patch_ad1980(struct snd_ac97 * ac97)
2056{ 2044{
2057 patch_ad1888(ac97); 2045 patch_ad1888(ac97);
2058 ac97->build_ops = &patch_ad1980_build_ops; 2046 ac97->build_ops = &patch_ad1980_build_ops;
@@ -2168,7 +2156,7 @@ static struct snd_ac97_build_ops patch_ad1985_build_ops = {
2168 .update_jacks = ad1985_update_jacks, 2156 .update_jacks = ad1985_update_jacks,
2169}; 2157};
2170 2158
2171int patch_ad1985(struct snd_ac97 * ac97) 2159static int patch_ad1985(struct snd_ac97 * ac97)
2172{ 2160{
2173 unsigned short misc; 2161 unsigned short misc;
2174 2162
@@ -2468,7 +2456,7 @@ static struct snd_ac97_build_ops patch_ad1986_build_ops = {
2468 .update_jacks = ad1986_update_jacks, 2456 .update_jacks = ad1986_update_jacks,
2469}; 2457};
2470 2458
2471int patch_ad1986(struct snd_ac97 * ac97) 2459static int patch_ad1986(struct snd_ac97 * ac97)
2472{ 2460{
2473 patch_ad1881(ac97); 2461 patch_ad1881(ac97);
2474 ac97->build_ops = &patch_ad1986_build_ops; 2462 ac97->build_ops = &patch_ad1986_build_ops;
@@ -2561,7 +2549,7 @@ static struct snd_ac97_build_ops patch_alc650_ops = {
2561 .update_jacks = alc650_update_jacks 2549 .update_jacks = alc650_update_jacks
2562}; 2550};
2563 2551
2564int patch_alc650(struct snd_ac97 * ac97) 2552static int patch_alc650(struct snd_ac97 * ac97)
2565{ 2553{
2566 unsigned short val; 2554 unsigned short val;
2567 2555
@@ -2713,7 +2701,7 @@ static struct snd_ac97_build_ops patch_alc655_ops = {
2713 .update_jacks = alc655_update_jacks 2701 .update_jacks = alc655_update_jacks
2714}; 2702};
2715 2703
2716int patch_alc655(struct snd_ac97 * ac97) 2704static int patch_alc655(struct snd_ac97 * ac97)
2717{ 2705{
2718 unsigned int val; 2706 unsigned int val;
2719 2707
@@ -2739,6 +2727,7 @@ int patch_alc655(struct snd_ac97 * ac97)
2739 (ac97->subsystem_device == 0x0131 || /* MSI S270 laptop */ 2727 (ac97->subsystem_device == 0x0131 || /* MSI S270 laptop */
2740 ac97->subsystem_device == 0x0161 || /* LG K1 Express */ 2728 ac97->subsystem_device == 0x0161 || /* LG K1 Express */
2741 ac97->subsystem_device == 0x0351 || /* MSI L725 laptop */ 2729 ac97->subsystem_device == 0x0351 || /* MSI L725 laptop */
2730 ac97->subsystem_device == 0x0471 || /* MSI L720 laptop */
2742 ac97->subsystem_device == 0x0061)) /* MSI S250 laptop */ 2731 ac97->subsystem_device == 0x0061)) /* MSI S250 laptop */
2743 val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */ 2732 val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */
2744 else 2733 else
@@ -2815,7 +2804,7 @@ static struct snd_ac97_build_ops patch_alc850_ops = {
2815 .update_jacks = alc850_update_jacks 2804 .update_jacks = alc850_update_jacks
2816}; 2805};
2817 2806
2818int patch_alc850(struct snd_ac97 *ac97) 2807static int patch_alc850(struct snd_ac97 *ac97)
2819{ 2808{
2820 ac97->build_ops = &patch_alc850_ops; 2809 ac97->build_ops = &patch_alc850_ops;
2821 2810
@@ -2875,7 +2864,7 @@ static struct snd_ac97_build_ops patch_cm9738_ops = {
2875 .update_jacks = cm9738_update_jacks 2864 .update_jacks = cm9738_update_jacks
2876}; 2865};
2877 2866
2878int patch_cm9738(struct snd_ac97 * ac97) 2867static int patch_cm9738(struct snd_ac97 * ac97)
2879{ 2868{
2880 ac97->build_ops = &patch_cm9738_ops; 2869 ac97->build_ops = &patch_cm9738_ops;
2881 /* FIXME: can anyone confirm below? */ 2870 /* FIXME: can anyone confirm below? */
@@ -2967,7 +2956,7 @@ static struct snd_ac97_build_ops patch_cm9739_ops = {
2967 .update_jacks = cm9739_update_jacks 2956 .update_jacks = cm9739_update_jacks
2968}; 2957};
2969 2958
2970int patch_cm9739(struct snd_ac97 * ac97) 2959static int patch_cm9739(struct snd_ac97 * ac97)
2971{ 2960{
2972 unsigned short val; 2961 unsigned short val;
2973 2962
@@ -3141,7 +3130,7 @@ static struct snd_ac97_build_ops patch_cm9761_ops = {
3141 .update_jacks = cm9761_update_jacks 3130 .update_jacks = cm9761_update_jacks
3142}; 3131};
3143 3132
3144int patch_cm9761(struct snd_ac97 *ac97) 3133static int patch_cm9761(struct snd_ac97 *ac97)
3145{ 3134{
3146 unsigned short val; 3135 unsigned short val;
3147 3136
@@ -3236,7 +3225,7 @@ static struct snd_ac97_build_ops patch_cm9780_ops = {
3236 .build_post_spdif = patch_cm9761_post_spdif /* identical with CM9761 */ 3225 .build_post_spdif = patch_cm9761_post_spdif /* identical with CM9761 */
3237}; 3226};
3238 3227
3239int patch_cm9780(struct snd_ac97 *ac97) 3228static int patch_cm9780(struct snd_ac97 *ac97)
3240{ 3229{
3241 unsigned short val; 3230 unsigned short val;
3242 3231
@@ -3279,7 +3268,7 @@ static struct snd_ac97_build_ops patch_vt1616_ops = {
3279 .build_specific = patch_vt1616_specific 3268 .build_specific = patch_vt1616_specific
3280}; 3269};
3281 3270
3282int patch_vt1616(struct snd_ac97 * ac97) 3271static int patch_vt1616(struct snd_ac97 * ac97)
3283{ 3272{
3284 ac97->build_ops = &patch_vt1616_ops; 3273 ac97->build_ops = &patch_vt1616_ops;
3285 return 0; 3274 return 0;
@@ -3288,16 +3277,111 @@ int patch_vt1616(struct snd_ac97 * ac97)
3288/* 3277/*
3289 * VT1617A codec 3278 * VT1617A codec
3290 */ 3279 */
3280
3281/*
3282 * unfortunately, the vt1617a stashes the twiddlers required for
3283 * nooding the i/o jacks on 2 different regs. * thameans that we cant
3284 * use the easy way provided by AC97_ENUM_DOUBLE() we have to write
3285 * are own funcs.
3286 *
3287 * NB: this is absolutely and utterly different from the vt1618. dunno
3288 * about the 1616.
3289 */
3290
3291/* copied from ac97_surround_jack_mode_info() */
3292static int snd_ac97_vt1617a_smart51_info(struct snd_kcontrol *kcontrol,
3293 struct snd_ctl_elem_info *uinfo)
3294{
3295 /* ordering in this list reflects vt1617a docs for Reg 20 and
3296 * 7a and Table 6 that lays out the matrix NB WRT Table6: SM51
3297 * is SM51EN *AND* it's Bit14, not Bit15 so the table is very
3298 * counter-intuitive */
3299
3300 static const char* texts[] = { "LineIn Mic1", "LineIn Mic1 Mic3",
3301 "Surr LFE/C Mic3", "LineIn LFE/C Mic3",
3302 "LineIn Mic2", "LineIn Mic2 Mic1",
3303 "Surr LFE Mic1", "Surr LFE Mic1 Mic2"};
3304 return ac97_enum_text_info(kcontrol, uinfo, texts, 8);
3305}
3306
3307static int snd_ac97_vt1617a_smart51_get(struct snd_kcontrol *kcontrol,
3308 struct snd_ctl_elem_value *ucontrol)
3309{
3310 ushort usSM51, usMS;
3311
3312 struct snd_ac97 *pac97;
3313
3314 pac97 = snd_kcontrol_chip(kcontrol); /* grab codec handle */
3315
3316 /* grab our desirec bits, then mash them together in a manner
3317 * consistent with Table 6 on page 17 in the 1617a docs */
3318
3319 usSM51 = snd_ac97_read(pac97, 0x7a) >> 14;
3320 usMS = snd_ac97_read(pac97, 0x20) >> 8;
3321
3322 ucontrol->value.enumerated.item[0] = (usSM51 << 1) + usMS;
3323
3324 return 0;
3325}
3326
3327static int snd_ac97_vt1617a_smart51_put(struct snd_kcontrol *kcontrol,
3328 struct snd_ctl_elem_value *ucontrol)
3329{
3330 ushort usSM51, usMS, usReg;
3331
3332 struct snd_ac97 *pac97;
3333
3334 pac97 = snd_kcontrol_chip(kcontrol); /* grab codec handle */
3335
3336 usSM51 = ucontrol->value.enumerated.item[0] >> 1;
3337 usMS = ucontrol->value.enumerated.item[0] & 1;
3338
3339 /* push our values into the register - consider that things will be left
3340 * in a funky state if the write fails */
3341
3342 usReg = snd_ac97_read(pac97, 0x7a);
3343 snd_ac97_write_cache(pac97, 0x7a, (usReg & 0x3FFF) + (usSM51 << 14));
3344 usReg = snd_ac97_read(pac97, 0x20);
3345 snd_ac97_write_cache(pac97, 0x20, (usReg & 0xFEFF) + (usMS << 8));
3346
3347 return 0;
3348}
3349
3350static const struct snd_kcontrol_new snd_ac97_controls_vt1617a[] = {
3351
3352 AC97_SINGLE("Center/LFE Exchange", 0x5a, 8, 1, 0),
3353 /*
3354 * These are used to enable/disable surround sound on motherboards
3355 * that have 3 bidirectional analog jacks
3356 */
3357 {
3358 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3359 .name = "Smart 5.1 Select",
3360 .info = snd_ac97_vt1617a_smart51_info,
3361 .get = snd_ac97_vt1617a_smart51_get,
3362 .put = snd_ac97_vt1617a_smart51_put,
3363 },
3364};
3365
3291int patch_vt1617a(struct snd_ac97 * ac97) 3366int patch_vt1617a(struct snd_ac97 * ac97)
3292{ 3367{
3293 /* bring analog power consumption to normal, like WinXP driver 3368 int err = 0;
3294 * for EPIA SP 3369
3370 /* we choose to not fail out at this point, but we tell the
3371 caller when we return */
3372
3373 err = patch_build_controls(ac97, &snd_ac97_controls_vt1617a[0],
3374 ARRAY_SIZE(snd_ac97_controls_vt1617a));
3375
3376 /* bring analog power consumption to normal by turning off the
3377 * headphone amplifier, like WinXP driver for EPIA SP
3295 */ 3378 */
3296 snd_ac97_write_cache(ac97, 0x5c, 0x20); 3379 snd_ac97_write_cache(ac97, 0x5c, 0x20);
3297 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */ 3380 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
3298 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000; 3381 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
3299 ac97->build_ops = &patch_vt1616_ops; 3382 ac97->build_ops = &patch_vt1616_ops;
3300 return 0; 3383
3384 return err;
3301} 3385}
3302 3386
3303/* 3387/*
@@ -3338,7 +3422,7 @@ static struct snd_ac97_build_ops patch_it2646_ops = {
3338 .update_jacks = it2646_update_jacks 3422 .update_jacks = it2646_update_jacks
3339}; 3423};
3340 3424
3341int patch_it2646(struct snd_ac97 * ac97) 3425static int patch_it2646(struct snd_ac97 * ac97)
3342{ 3426{
3343 ac97->build_ops = &patch_it2646_ops; 3427 ac97->build_ops = &patch_it2646_ops;
3344 /* full DAC volume */ 3428 /* full DAC volume */
@@ -3371,7 +3455,7 @@ static struct snd_ac97_build_ops patch_si3036_ops = {
3371 .build_specific = patch_si3036_specific, 3455 .build_specific = patch_si3036_specific,
3372}; 3456};
3373 3457
3374int mpatch_si3036(struct snd_ac97 * ac97) 3458static int mpatch_si3036(struct snd_ac97 * ac97)
3375{ 3459{
3376 ac97->build_ops = &patch_si3036_ops; 3460 ac97->build_ops = &patch_si3036_ops;
3377 snd_ac97_write_cache(ac97, 0x5c, 0xf210 ); 3461 snd_ac97_write_cache(ac97, 0x5c, 0xf210 );
@@ -3403,7 +3487,7 @@ static struct snd_ac97_res_table lm4550_restbl[] = {
3403 { } /* terminator */ 3487 { } /* terminator */
3404}; 3488};
3405 3489
3406int patch_lm4550(struct snd_ac97 *ac97) 3490static int patch_lm4550(struct snd_ac97 *ac97)
3407{ 3491{
3408 ac97->res_table = lm4550_restbl; 3492 ac97->res_table = lm4550_restbl;
3409 return 0; 3493 return 0;
@@ -3438,7 +3522,7 @@ static struct snd_ac97_build_ops patch_ucb1400_ops = {
3438 .build_specific = patch_ucb1400_specific, 3522 .build_specific = patch_ucb1400_specific,
3439}; 3523};
3440 3524
3441int patch_ucb1400(struct snd_ac97 * ac97) 3525static int patch_ucb1400(struct snd_ac97 * ac97)
3442{ 3526{
3443 ac97->build_ops = &patch_ucb1400_ops; 3527 ac97->build_ops = &patch_ucb1400_ops;
3444 /* enable headphone driver and smart low power mode by default */ 3528 /* enable headphone driver and smart low power mode by default */
diff --git a/sound/pci/ac97/ac97_patch.h b/sound/pci/ac97/ac97_patch.h
index 555d1c9a98fd..fd341ce63762 100644
--- a/sound/pci/ac97/ac97_patch.h
+++ b/sound/pci/ac97/ac97_patch.h
@@ -22,44 +22,72 @@
22 * 22 *
23 */ 23 */
24 24
25int patch_yamaha_ymf753(struct snd_ac97 * ac97); 25#define AC97_SINGLE_VALUE(reg,shift,mask,invert) \
26int patch_wolfson00(struct snd_ac97 * ac97); 26 ((reg) | ((shift) << 8) | ((shift) << 12) | ((mask) << 16) | \
27int patch_wolfson03(struct snd_ac97 * ac97); 27 ((invert) << 24))
28int patch_wolfson04(struct snd_ac97 * ac97); 28#define AC97_PAGE_SINGLE_VALUE(reg,shift,mask,invert,page) \
29int patch_wolfson05(struct snd_ac97 * ac97); 29 (AC97_SINGLE_VALUE(reg,shift,mask,invert) | (1<<25) | ((page) << 26))
30int patch_wolfson11(struct snd_ac97 * ac97); 30#define AC97_SINGLE(xname, reg, shift, mask, invert) \
31int patch_wolfson13(struct snd_ac97 * ac97); 31{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
32int patch_tritech_tr28028(struct snd_ac97 * ac97); 32 .info = snd_ac97_info_volsw, \
33int patch_sigmatel_stac9700(struct snd_ac97 * ac97); 33 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
34int patch_sigmatel_stac9708(struct snd_ac97 * ac97); 34 .private_value = AC97_SINGLE_VALUE(reg, shift, mask, invert) }
35int patch_sigmatel_stac9721(struct snd_ac97 * ac97); 35#define AC97_PAGE_SINGLE(xname, reg, shift, mask, invert, page) \
36int patch_sigmatel_stac9744(struct snd_ac97 * ac97); 36{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
37int patch_sigmatel_stac9756(struct snd_ac97 * ac97); 37 .info = snd_ac97_info_volsw, \
38int patch_sigmatel_stac9758(struct snd_ac97 * ac97); 38 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
39int patch_cirrus_cs4299(struct snd_ac97 * ac97); 39 .private_value = AC97_PAGE_SINGLE_VALUE(reg, shift, mask, invert, page) }
40int patch_cirrus_spdif(struct snd_ac97 * ac97); 40#define AC97_DOUBLE(xname, reg, shift_left, shift_right, mask, invert) \
41int patch_conexant(struct snd_ac97 * ac97); 41{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
42int patch_cx20551(struct snd_ac97 * ac97); 42 .info = snd_ac97_info_volsw, \
43int patch_ad1819(struct snd_ac97 * ac97); 43 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
44int patch_ad1881(struct snd_ac97 * ac97); 44 .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) | ((mask) << 16) | ((invert) << 24) }
45int patch_ad1885(struct snd_ac97 * ac97); 45
46int patch_ad1886(struct snd_ac97 * ac97); 46/* enum control */
47int patch_ad1888(struct snd_ac97 * ac97); 47struct ac97_enum {
48int patch_ad1980(struct snd_ac97 * ac97); 48 unsigned char reg;
49int patch_ad1981a(struct snd_ac97 * ac97); 49 unsigned char shift_l;
50int patch_ad1981b(struct snd_ac97 * ac97); 50 unsigned char shift_r;
51int patch_ad1985(struct snd_ac97 * ac97); 51 unsigned short mask;
52int patch_ad1986(struct snd_ac97 * ac97); 52 const char **texts;
53int patch_alc650(struct snd_ac97 * ac97); 53};
54int patch_alc655(struct snd_ac97 * ac97); 54
55int patch_alc850(struct snd_ac97 * ac97); 55#define AC97_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \
56int patch_cm9738(struct snd_ac97 * ac97); 56{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
57int patch_cm9739(struct snd_ac97 * ac97); 57 .mask = xmask, .texts = xtexts }
58int patch_cm9761(struct snd_ac97 * ac97); 58#define AC97_ENUM_SINGLE(xreg, xshift, xmask, xtexts) \
59int patch_cm9780(struct snd_ac97 * ac97); 59 AC97_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xtexts)
60int patch_vt1616(struct snd_ac97 * ac97); 60#define AC97_ENUM(xname, xenum) \
61int patch_vt1617a(struct snd_ac97 * ac97); 61{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
62int patch_it2646(struct snd_ac97 * ac97); 62 .info = snd_ac97_info_enum_double, \
63int patch_ucb1400(struct snd_ac97 * ac97); 63 .get = snd_ac97_get_enum_double, .put = snd_ac97_put_enum_double, \
64int mpatch_si3036(struct snd_ac97 * ac97); 64 .private_value = (unsigned long)&xenum }
65int patch_lm4550(struct snd_ac97 * ac97); 65
66/* ac97_codec.c */
67static const struct snd_kcontrol_new snd_ac97_controls_3d[];
68static const struct snd_kcontrol_new snd_ac97_controls_spdif[];
69static struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template,
70 struct snd_ac97 * ac97);
71static int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol,
72 struct snd_ctl_elem_info *uinfo);
73static int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol,
74 struct snd_ctl_elem_value *ucontrol);
75static int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol,
76 struct snd_ctl_elem_value *ucontrol);
77static int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit);
78static int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name,
79 const char *suffix);
80static int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src,
81 const char *dst, const char *suffix);
82static int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1,
83 const char *s2, const char *suffix);
84static void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src,
85 const char *dst);
86static void snd_ac97_restore_status(struct snd_ac97 *ac97);
87static void snd_ac97_restore_iec958(struct snd_ac97 *ac97);
88static int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol,
89 struct snd_ctl_elem_info *uinfo);
90static int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol,
91 struct snd_ctl_elem_value *ucontrol);
92static int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol,
93 struct snd_ctl_elem_value *ucontrol);
diff --git a/sound/pci/ac97/ac97_pcm.c b/sound/pci/ac97/ac97_pcm.c
index 3758d07182f8..4281e6d0c5b6 100644
--- a/sound/pci/ac97/ac97_pcm.c
+++ b/sound/pci/ac97/ac97_pcm.c
@@ -34,7 +34,6 @@
34#include <sound/control.h> 34#include <sound/control.h>
35#include <sound/ac97_codec.h> 35#include <sound/ac97_codec.h>
36#include <sound/asoundef.h> 36#include <sound/asoundef.h>
37#include "ac97_patch.h"
38#include "ac97_id.h" 37#include "ac97_id.h"
39#include "ac97_local.h" 38#include "ac97_local.h"
40 39
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index ba7fa22b285d..e1ed59549c50 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -69,10 +69,10 @@ module_param(enable, bool, 0444);
69 * Debug part definitions 69 * Debug part definitions
70 */ 70 */
71 71
72//#define ALI_DEBUG 72/* #define ALI_DEBUG */
73 73
74#ifdef ALI_DEBUG 74#ifdef ALI_DEBUG
75#define snd_ali_printk(format, args...) printk(format, ##args); 75#define snd_ali_printk(format, args...) printk(KERN_DEBUG format, ##args);
76#else 76#else
77#define snd_ali_printk(format, args...) 77#define snd_ali_printk(format, args...)
78#endif 78#endif
@@ -105,10 +105,10 @@ module_param(enable, bool, 0444);
105 * Direct Registers 105 * Direct Registers
106 */ 106 */
107 107
108#define ALI_LEGACY_DMAR0 0x00 // ADR0 108#define ALI_LEGACY_DMAR0 0x00 /* ADR0 */
109#define ALI_LEGACY_DMAR4 0x04 // CNT0 109#define ALI_LEGACY_DMAR4 0x04 /* CNT0 */
110#define ALI_LEGACY_DMAR11 0x0b // MOD 110#define ALI_LEGACY_DMAR11 0x0b /* MOD */
111#define ALI_LEGACY_DMAR15 0x0f // MMR 111#define ALI_LEGACY_DMAR15 0x0f /* MMR */
112#define ALI_MPUR0 0x20 112#define ALI_MPUR0 0x20
113#define ALI_MPUR1 0x21 113#define ALI_MPUR1 0x21
114#define ALI_MPUR2 0x22 114#define ALI_MPUR2 0x22
@@ -175,7 +175,7 @@ struct snd_ali;
175struct snd_ali_voice; 175struct snd_ali_voice;
176 176
177struct snd_ali_channel_control { 177struct snd_ali_channel_control {
178 // register data 178 /* register data */
179 struct REGDATA { 179 struct REGDATA {
180 unsigned int start; 180 unsigned int start;
181 unsigned int stop; 181 unsigned int stop;
@@ -183,7 +183,7 @@ struct snd_ali_channel_control {
183 unsigned int ainten; 183 unsigned int ainten;
184 } data; 184 } data;
185 185
186 // register addresses 186 /* register addresses */
187 struct REGS { 187 struct REGS {
188 unsigned int start; 188 unsigned int start;
189 unsigned int stop; 189 unsigned int stop;
@@ -197,19 +197,18 @@ struct snd_ali_channel_control {
197 197
198struct snd_ali_voice { 198struct snd_ali_voice {
199 unsigned int number; 199 unsigned int number;
200 unsigned int use: 1, 200 unsigned int use :1,
201 pcm: 1, 201 pcm :1,
202 midi: 1, 202 midi :1,
203 mode: 1, 203 mode :1,
204 synth: 1; 204 synth :1,
205 running :1;
205 206
206 /* PCM data */ 207 /* PCM data */
207 struct snd_ali *codec; 208 struct snd_ali *codec;
208 struct snd_pcm_substream *substream; 209 struct snd_pcm_substream *substream;
209 struct snd_ali_voice *extra; 210 struct snd_ali_voice *extra;
210 211
211 unsigned int running: 1;
212
213 int eso; /* final ESO value for channel */ 212 int eso; /* final ESO value for channel */
214 int count; /* runtime->period_size */ 213 int count; /* runtime->period_size */
215 214
@@ -231,14 +230,12 @@ struct snd_alidev {
231}; 230};
232 231
233 232
234#ifdef CONFIG_PM
235#define ALI_GLOBAL_REGS 56 233#define ALI_GLOBAL_REGS 56
236#define ALI_CHANNEL_REGS 8 234#define ALI_CHANNEL_REGS 8
237struct snd_ali_image { 235struct snd_ali_image {
238 unsigned long regs[ALI_GLOBAL_REGS]; 236 u32 regs[ALI_GLOBAL_REGS];
239 unsigned long channel_regs[ALI_CHANNELS][ALI_CHANNEL_REGS]; 237 u32 channel_regs[ALI_CHANNELS][ALI_CHANNEL_REGS];
240}; 238};
241#endif
242 239
243 240
244struct snd_ali { 241struct snd_ali {
@@ -246,8 +243,8 @@ struct snd_ali {
246 unsigned long port; 243 unsigned long port;
247 unsigned char revision; 244 unsigned char revision;
248 245
249 unsigned int hw_initialized: 1; 246 unsigned int hw_initialized :1;
250 unsigned int spdif_support: 1; 247 unsigned int spdif_support :1;
251 248
252 struct pci_dev *pci; 249 struct pci_dev *pci;
253 struct pci_dev *pci_m1533; 250 struct pci_dev *pci_m1533;
@@ -287,108 +284,28 @@ MODULE_DEVICE_TABLE(pci, snd_ali_ids);
287 284
288static void snd_ali_clear_voices(struct snd_ali *, unsigned int, unsigned int); 285static void snd_ali_clear_voices(struct snd_ali *, unsigned int, unsigned int);
289static unsigned short snd_ali_codec_peek(struct snd_ali *, int, unsigned short); 286static unsigned short snd_ali_codec_peek(struct snd_ali *, int, unsigned short);
290static void snd_ali_codec_poke(struct snd_ali *, int, unsigned short, unsigned short); 287static void snd_ali_codec_poke(struct snd_ali *, int, unsigned short,
291 288 unsigned short);
292/*
293 * Debug Part
294 */
295
296#ifdef ALI_DEBUG
297
298static void ali_read_regs(struct snd_ali *codec, int channel)
299{
300 int i,j;
301 unsigned int dwVal;
302
303 printk("channel %d registers map:\n", channel);
304 outb((unsigned char)(channel & 0x001f), ALI_REG(codec,ALI_GC_CIR));
305
306 printk(" ");
307 for(j=0;j<8;j++)
308 printk("%2.2x ", j*4);
309 printk("\n");
310
311 for (i=0; i<=0xf8/4;i++) {
312 if(i%8 == 0)
313 printk("%2.2x ", (i*4/0x10)*0x10);
314 dwVal = inl(ALI_REG(codec,i*4));
315 printk("%8.8x ", dwVal);
316 if ((i+1)%8 == 0)
317 printk("\n");
318 }
319 printk("\n");
320}
321static void ali_read_cfg(unsigned int vendor, unsigned deviceid)
322{
323 unsigned int dwVal;
324 struct pci_dev *pci_dev;
325 int i,j;
326
327 pci_dev = pci_get_device(vendor, deviceid, NULL);
328 if (pci_dev == NULL)
329 return ;
330
331 printk("\nM%x PCI CFG\n", deviceid);
332 printk(" ");
333 for(j=0;j<8;j++)
334 printk("%d ",j);
335 printk("\n");
336
337 for(i=0;i<8;i++) {
338 printk("%d ",i);
339 for(j=0;j<8;j++)
340 {
341 pci_read_config_dword(pci_dev, i*0x20+j*4, &dwVal);
342 printk("%8.8x ", dwVal);
343 }
344 printk("\n");
345 }
346 pci_dev_put(pci_dev);
347 }
348static void ali_read_ac97regs(struct snd_ali *codec, int secondary)
349{
350 unsigned short i,j;
351 unsigned short wVal;
352
353 printk("\ncodec %d registers map:\n", secondary);
354
355 printk(" ");
356 for(j=0;j<8;j++)
357 printk("%2.2x ",j*2);
358 printk("\n");
359
360 for (i=0; i<64;i++) {
361 if(i%8 == 0)
362 printk("%2.2x ", (i/8)*0x10);
363 wVal = snd_ali_codec_peek(codec, secondary, i*2);
364 printk("%4.4x ", wVal);
365 if ((i+1)%8 == 0)
366 printk("\n");
367 }
368 printk("\n");
369}
370
371#endif
372 289
373/* 290/*
374 * AC97 ACCESS 291 * AC97 ACCESS
375 */ 292 */
376 293
377static inline unsigned int snd_ali_5451_peek(struct snd_ali *codec, 294static inline unsigned int snd_ali_5451_peek(struct snd_ali *codec,
378 unsigned int port ) 295 unsigned int port)
379{ 296{
380 return (unsigned int)inl(ALI_REG(codec, port)); 297 return (unsigned int)inl(ALI_REG(codec, port));
381} 298}
382 299
383static inline void snd_ali_5451_poke( struct snd_ali *codec, 300static inline void snd_ali_5451_poke(struct snd_ali *codec,
384 unsigned int port, 301 unsigned int port,
385 unsigned int val ) 302 unsigned int val)
386{ 303{
387 outl((unsigned int)val, ALI_REG(codec, port)); 304 outl((unsigned int)val, ALI_REG(codec, port));
388} 305}
389 306
390static int snd_ali_codec_ready( struct snd_ali *codec, 307static int snd_ali_codec_ready(struct snd_ali *codec,
391 unsigned int port ) 308 unsigned int port)
392{ 309{
393 unsigned long end_time; 310 unsigned long end_time;
394 unsigned int res; 311 unsigned int res;
@@ -396,7 +313,7 @@ static int snd_ali_codec_ready( struct snd_ali *codec,
396 end_time = jiffies + msecs_to_jiffies(250); 313 end_time = jiffies + msecs_to_jiffies(250);
397 do { 314 do {
398 res = snd_ali_5451_peek(codec,port); 315 res = snd_ali_5451_peek(codec,port);
399 if (! (res & 0x8000)) 316 if (!(res & 0x8000))
400 return 0; 317 return 0;
401 schedule_timeout_uninterruptible(1); 318 schedule_timeout_uninterruptible(1);
402 } while (time_after_eq(end_time, jiffies)); 319 } while (time_after_eq(end_time, jiffies));
@@ -425,11 +342,11 @@ static int snd_ali_stimer_ready(struct snd_ali *codec)
425} 342}
426 343
427static void snd_ali_codec_poke(struct snd_ali *codec,int secondary, 344static void snd_ali_codec_poke(struct snd_ali *codec,int secondary,
428 unsigned short reg, 345 unsigned short reg,
429 unsigned short val) 346 unsigned short val)
430{ 347{
431 unsigned int dwVal = 0; 348 unsigned int dwVal;
432 unsigned int port = 0; 349 unsigned int port;
433 350
434 if (reg >= 0x80) { 351 if (reg >= 0x80) {
435 snd_printk(KERN_ERR "ali_codec_poke: reg(%xh) invalid.\n", reg); 352 snd_printk(KERN_ERR "ali_codec_poke: reg(%xh) invalid.\n", reg);
@@ -445,20 +362,22 @@ static void snd_ali_codec_poke(struct snd_ali *codec,int secondary,
445 362
446 dwVal = (unsigned int) (reg & 0xff); 363 dwVal = (unsigned int) (reg & 0xff);
447 dwVal |= 0x8000 | (val << 16); 364 dwVal |= 0x8000 | (val << 16);
448 if (secondary) dwVal |= 0x0080; 365 if (secondary)
449 if (codec->revision == ALI_5451_V02) dwVal |= 0x0100; 366 dwVal |= 0x0080;
367 if (codec->revision == ALI_5451_V02)
368 dwVal |= 0x0100;
450 369
451 snd_ali_5451_poke(codec,port,dwVal); 370 snd_ali_5451_poke(codec, port, dwVal);
452 371
453 return ; 372 return ;
454} 373}
455 374
456static unsigned short snd_ali_codec_peek( struct snd_ali *codec, 375static unsigned short snd_ali_codec_peek(struct snd_ali *codec,
457 int secondary, 376 int secondary,
458 unsigned short reg) 377 unsigned short reg)
459{ 378{
460 unsigned int dwVal = 0; 379 unsigned int dwVal;
461 unsigned int port = 0; 380 unsigned int port;
462 381
463 if (reg >= 0x80) { 382 if (reg >= 0x80) {
464 snd_printk(KERN_ERR "ali_codec_peek: reg(%xh) invalid.\n", reg); 383 snd_printk(KERN_ERR "ali_codec_peek: reg(%xh) invalid.\n", reg);
@@ -474,7 +393,8 @@ static unsigned short snd_ali_codec_peek( struct snd_ali *codec,
474 393
475 dwVal = (unsigned int) (reg & 0xff); 394 dwVal = (unsigned int) (reg & 0xff);
476 dwVal |= 0x8000; /* bit 15*/ 395 dwVal |= 0x8000; /* bit 15*/
477 if (secondary) dwVal |= 0x0080; 396 if (secondary)
397 dwVal |= 0x0080;
478 398
479 snd_ali_5451_poke(codec, port, dwVal); 399 snd_ali_5451_poke(codec, port, dwVal);
480 400
@@ -483,7 +403,7 @@ static unsigned short snd_ali_codec_peek( struct snd_ali *codec,
483 if (snd_ali_codec_ready(codec, port) < 0) 403 if (snd_ali_codec_ready(codec, port) < 0)
484 return ~0; 404 return ~0;
485 405
486 return (snd_ali_5451_peek(codec, port) & 0xffff0000)>>16; 406 return (snd_ali_5451_peek(codec, port) & 0xffff0000) >> 16;
487} 407}
488 408
489static void snd_ali_codec_write(struct snd_ac97 *ac97, 409static void snd_ali_codec_write(struct snd_ac97 *ac97,
@@ -493,9 +413,9 @@ static void snd_ali_codec_write(struct snd_ac97 *ac97,
493 struct snd_ali *codec = ac97->private_data; 413 struct snd_ali *codec = ac97->private_data;
494 414
495 snd_ali_printk("codec_write: reg=%xh data=%xh.\n", reg, val); 415 snd_ali_printk("codec_write: reg=%xh data=%xh.\n", reg, val);
496 if(reg == AC97_GPIO_STATUS) { 416 if (reg == AC97_GPIO_STATUS) {
497 outl((val << ALI_AC97_GPIO_DATA_SHIFT)|ALI_AC97_GPIO_ENABLE, 417 outl((val << ALI_AC97_GPIO_DATA_SHIFT) | ALI_AC97_GPIO_ENABLE,
498 ALI_REG(codec, ALI_AC97_GPIO)); 418 ALI_REG(codec, ALI_AC97_GPIO));
499 return; 419 return;
500 } 420 }
501 snd_ali_codec_poke(codec, ac97->num, reg, val); 421 snd_ali_codec_poke(codec, ac97->num, reg, val);
@@ -503,12 +423,13 @@ static void snd_ali_codec_write(struct snd_ac97 *ac97,
503} 423}
504 424
505 425
506static unsigned short snd_ali_codec_read(struct snd_ac97 *ac97, unsigned short reg) 426static unsigned short snd_ali_codec_read(struct snd_ac97 *ac97,
427 unsigned short reg)
507{ 428{
508 struct snd_ali *codec = ac97->private_data; 429 struct snd_ali *codec = ac97->private_data;
509 430
510 snd_ali_printk("codec_read reg=%xh.\n", reg); 431 snd_ali_printk("codec_read reg=%xh.\n", reg);
511 return (snd_ali_codec_peek(codec, ac97->num, reg)); 432 return snd_ali_codec_peek(codec, ac97->num, reg);
512} 433}
513 434
514/* 435/*
@@ -517,11 +438,12 @@ static unsigned short snd_ali_codec_read(struct snd_ac97 *ac97, unsigned short r
517 438
518static int snd_ali_reset_5451(struct snd_ali *codec) 439static int snd_ali_reset_5451(struct snd_ali *codec)
519{ 440{
520 struct pci_dev *pci_dev = NULL; 441 struct pci_dev *pci_dev;
521 unsigned short wCount, wReg; 442 unsigned short wCount, wReg;
522 unsigned int dwVal; 443 unsigned int dwVal;
523 444
524 if ((pci_dev = codec->pci_m1533) != NULL) { 445 pci_dev = codec->pci_m1533;
446 if (pci_dev) {
525 pci_read_config_dword(pci_dev, 0x7c, &dwVal); 447 pci_read_config_dword(pci_dev, 0x7c, &dwVal);
526 pci_write_config_dword(pci_dev, 0x7c, dwVal | 0x08000000); 448 pci_write_config_dword(pci_dev, 0x7c, dwVal | 0x08000000);
527 udelay(5000); 449 udelay(5000);
@@ -541,7 +463,7 @@ static int snd_ali_reset_5451(struct snd_ali *codec)
541 wCount = 200; 463 wCount = 200;
542 while(wCount--) { 464 while(wCount--) {
543 wReg = snd_ali_codec_peek(codec, 0, AC97_POWERDOWN); 465 wReg = snd_ali_codec_peek(codec, 0, AC97_POWERDOWN);
544 if((wReg & 0x000f) == 0x000f) 466 if ((wReg & 0x000f) == 0x000f)
545 return 0; 467 return 0;
546 udelay(5000); 468 udelay(5000);
547 } 469 }
@@ -555,8 +477,8 @@ static int snd_ali_reset_5451(struct snd_ali *codec)
555 477
556static int snd_ali_reset_codec(struct snd_ali *codec) 478static int snd_ali_reset_codec(struct snd_ali *codec)
557{ 479{
558 struct pci_dev *pci_dev = NULL; 480 struct pci_dev *pci_dev;
559 unsigned char bVal = 0; 481 unsigned char bVal;
560 unsigned int dwVal; 482 unsigned int dwVal;
561 unsigned short wCount, wReg; 483 unsigned short wCount, wReg;
562 484
@@ -579,9 +501,9 @@ static int snd_ali_reset_codec(struct snd_ali *codec)
579 udelay(15000); 501 udelay(15000);
580 502
581 wCount = 200; 503 wCount = 200;
582 while(wCount--) { 504 while (wCount--) {
583 wReg = snd_ali_codec_read(codec->ac97, AC97_POWERDOWN); 505 wReg = snd_ali_codec_read(codec->ac97, AC97_POWERDOWN);
584 if((wReg & 0x000f) == 0x000f) 506 if ((wReg & 0x000f) == 0x000f)
585 return 0; 507 return 0;
586 udelay(5000); 508 udelay(5000);
587 } 509 }
@@ -594,25 +516,27 @@ static int snd_ali_reset_codec(struct snd_ali *codec)
594 * ALI 5451 Controller 516 * ALI 5451 Controller
595 */ 517 */
596 518
597static void snd_ali_enable_special_channel(struct snd_ali *codec, unsigned int channel) 519static void snd_ali_enable_special_channel(struct snd_ali *codec,
520 unsigned int channel)
598{ 521{
599 unsigned long dwVal = 0; 522 unsigned long dwVal;
600 523
601 dwVal = inl(ALI_REG(codec,ALI_GLOBAL_CONTROL)); 524 dwVal = inl(ALI_REG(codec, ALI_GLOBAL_CONTROL));
602 dwVal |= 1 << (channel & 0x0000001f); 525 dwVal |= 1 << (channel & 0x0000001f);
603 outl(dwVal, ALI_REG(codec,ALI_GLOBAL_CONTROL)); 526 outl(dwVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
604} 527}
605 528
606static void snd_ali_disable_special_channel(struct snd_ali *codec, unsigned int channel) 529static void snd_ali_disable_special_channel(struct snd_ali *codec,
530 unsigned int channel)
607{ 531{
608 unsigned long dwVal = 0; 532 unsigned long dwVal;
609 533
610 dwVal = inl(ALI_REG(codec,ALI_GLOBAL_CONTROL)); 534 dwVal = inl(ALI_REG(codec, ALI_GLOBAL_CONTROL));
611 dwVal &= ~(1 << (channel & 0x0000001f)); 535 dwVal &= ~(1 << (channel & 0x0000001f));
612 outl(dwVal, ALI_REG(codec,ALI_GLOBAL_CONTROL)); 536 outl(dwVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
613} 537}
614 538
615static void snd_ali_enable_address_interrupt(struct snd_ali * codec) 539static void snd_ali_enable_address_interrupt(struct snd_ali *codec)
616{ 540{
617 unsigned int gc; 541 unsigned int gc;
618 542
@@ -622,7 +546,7 @@ static void snd_ali_enable_address_interrupt(struct snd_ali * codec)
622 outl( gc, ALI_REG(codec, ALI_GC_CIR)); 546 outl( gc, ALI_REG(codec, ALI_GC_CIR));
623} 547}
624 548
625static void snd_ali_disable_address_interrupt(struct snd_ali * codec) 549static void snd_ali_disable_address_interrupt(struct snd_ali *codec)
626{ 550{
627 unsigned int gc; 551 unsigned int gc;
628 552
@@ -632,8 +556,9 @@ static void snd_ali_disable_address_interrupt(struct snd_ali * codec)
632 outl(gc, ALI_REG(codec, ALI_GC_CIR)); 556 outl(gc, ALI_REG(codec, ALI_GC_CIR));
633} 557}
634 558
635#if 0 // not used 559#if 0 /* not used */
636static void snd_ali_enable_voice_irq(struct snd_ali *codec, unsigned int channel) 560static void snd_ali_enable_voice_irq(struct snd_ali *codec,
561 unsigned int channel)
637{ 562{
638 unsigned int mask; 563 unsigned int mask;
639 struct snd_ali_channel_control *pchregs = &(codec->chregs); 564 struct snd_ali_channel_control *pchregs = &(codec->chregs);
@@ -641,13 +566,14 @@ static void snd_ali_enable_voice_irq(struct snd_ali *codec, unsigned int channel
641 snd_ali_printk("enable_voice_irq channel=%d\n",channel); 566 snd_ali_printk("enable_voice_irq channel=%d\n",channel);
642 567
643 mask = 1 << (channel & 0x1f); 568 mask = 1 << (channel & 0x1f);
644 pchregs->data.ainten = inl(ALI_REG(codec,pchregs->regs.ainten)); 569 pchregs->data.ainten = inl(ALI_REG(codec, pchregs->regs.ainten));
645 pchregs->data.ainten |= mask; 570 pchregs->data.ainten |= mask;
646 outl(pchregs->data.ainten,ALI_REG(codec,pchregs->regs.ainten)); 571 outl(pchregs->data.ainten, ALI_REG(codec, pchregs->regs.ainten));
647} 572}
648#endif 573#endif
649 574
650static void snd_ali_disable_voice_irq(struct snd_ali *codec, unsigned int channel) 575static void snd_ali_disable_voice_irq(struct snd_ali *codec,
576 unsigned int channel)
651{ 577{
652 unsigned int mask; 578 unsigned int mask;
653 struct snd_ali_channel_control *pchregs = &(codec->chregs); 579 struct snd_ali_channel_control *pchregs = &(codec->chregs);
@@ -655,9 +581,9 @@ static void snd_ali_disable_voice_irq(struct snd_ali *codec, unsigned int channe
655 snd_ali_printk("disable_voice_irq channel=%d\n",channel); 581 snd_ali_printk("disable_voice_irq channel=%d\n",channel);
656 582
657 mask = 1 << (channel & 0x1f); 583 mask = 1 << (channel & 0x1f);
658 pchregs->data.ainten = inl(ALI_REG(codec,pchregs->regs.ainten)); 584 pchregs->data.ainten = inl(ALI_REG(codec, pchregs->regs.ainten));
659 pchregs->data.ainten &= ~mask; 585 pchregs->data.ainten &= ~mask;
660 outl(pchregs->data.ainten,ALI_REG(codec,pchregs->regs.ainten)); 586 outl(pchregs->data.ainten, ALI_REG(codec, pchregs->regs.ainten));
661} 587}
662 588
663static int snd_ali_alloc_pcm_channel(struct snd_ali *codec, int channel) 589static int snd_ali_alloc_pcm_channel(struct snd_ali *codec, int channel)
@@ -665,7 +591,8 @@ static int snd_ali_alloc_pcm_channel(struct snd_ali *codec, int channel)
665 unsigned int idx = channel & 0x1f; 591 unsigned int idx = channel & 0x1f;
666 592
667 if (codec->synth.chcnt >= ALI_CHANNELS){ 593 if (codec->synth.chcnt >= ALI_CHANNELS){
668 snd_printk(KERN_ERR "ali_alloc_pcm_channel: no free channels.\n"); 594 snd_printk(KERN_ERR
595 "ali_alloc_pcm_channel: no free channels.\n");
669 return -1; 596 return -1;
670 } 597 }
671 598
@@ -685,35 +612,41 @@ static int snd_ali_find_free_channel(struct snd_ali * codec, int rec)
685 612
686 snd_ali_printk("find_free_channel: for %s\n",rec ? "rec" : "pcm"); 613 snd_ali_printk("find_free_channel: for %s\n",rec ? "rec" : "pcm");
687 614
688 // recording 615 /* recording */
689 if (rec) { 616 if (rec) {
690 if (codec->spdif_support && 617 if (codec->spdif_support &&
691 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) & ALI_SPDIF_IN_SUPPORT)) 618 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) &
619 ALI_SPDIF_IN_SUPPORT))
692 idx = ALI_SPDIF_IN_CHANNEL; 620 idx = ALI_SPDIF_IN_CHANNEL;
693 else 621 else
694 idx = ALI_PCM_IN_CHANNEL; 622 idx = ALI_PCM_IN_CHANNEL;
695 623
696 if ((result = snd_ali_alloc_pcm_channel(codec,idx)) >= 0) { 624 result = snd_ali_alloc_pcm_channel(codec, idx);
625 if (result >= 0)
697 return result; 626 return result;
698 } else { 627 else {
699 snd_printk(KERN_ERR "ali_find_free_channel: record channel is busy now.\n"); 628 snd_printk(KERN_ERR "ali_find_free_channel: "
629 "record channel is busy now.\n");
700 return -1; 630 return -1;
701 } 631 }
702 } 632 }
703 633
704 //playback... 634 /* playback... */
705 if (codec->spdif_support && 635 if (codec->spdif_support &&
706 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) & ALI_SPDIF_OUT_CH_ENABLE)) { 636 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) &
637 ALI_SPDIF_OUT_CH_ENABLE)) {
707 idx = ALI_SPDIF_OUT_CHANNEL; 638 idx = ALI_SPDIF_OUT_CHANNEL;
708 if ((result = snd_ali_alloc_pcm_channel(codec,idx)) >= 0) { 639 result = snd_ali_alloc_pcm_channel(codec, idx);
640 if (result >= 0)
709 return result; 641 return result;
710 } else { 642 else
711 snd_printk(KERN_ERR "ali_find_free_channel: S/PDIF out channel is in busy now.\n"); 643 snd_printk(KERN_ERR "ali_find_free_channel: "
712 } 644 "S/PDIF out channel is in busy now.\n");
713 } 645 }
714 646
715 for (idx = 0; idx < ALI_CHANNELS; idx++) { 647 for (idx = 0; idx < ALI_CHANNELS; idx++) {
716 if ((result = snd_ali_alloc_pcm_channel(codec,idx)) >= 0) 648 result = snd_ali_alloc_pcm_channel(codec, idx);
649 if (result >= 0)
717 return result; 650 return result;
718 } 651 }
719 snd_printk(KERN_ERR "ali_find_free_channel: no free channels.\n"); 652 snd_printk(KERN_ERR "ali_find_free_channel: no free channels.\n");
@@ -730,7 +663,8 @@ static void snd_ali_free_channel_pcm(struct snd_ali *codec, int channel)
730 return; 663 return;
731 664
732 if (!(codec->synth.chmap & (1 << idx))) { 665 if (!(codec->synth.chmap & (1 << idx))) {
733 snd_printk(KERN_ERR "ali_free_channel_pcm: channel %d is not in use.\n",channel); 666 snd_printk(KERN_ERR "ali_free_channel_pcm: "
667 "channel %d is not in use.\n", channel);
734 return; 668 return;
735 } else { 669 } else {
736 codec->synth.chmap &= ~(1 << idx); 670 codec->synth.chmap &= ~(1 << idx);
@@ -738,8 +672,8 @@ static void snd_ali_free_channel_pcm(struct snd_ali *codec, int channel)
738 } 672 }
739} 673}
740 674
741#if 0 // not used 675#if 0 /* not used */
742static void snd_ali_start_voice(struct snd_ali * codec, unsigned int channel) 676static void snd_ali_start_voice(struct snd_ali *codec, unsigned int channel)
743{ 677{
744 unsigned int mask = 1 << (channel & 0x1f); 678 unsigned int mask = 1 << (channel & 0x1f);
745 679
@@ -748,7 +682,7 @@ static void snd_ali_start_voice(struct snd_ali * codec, unsigned int channel)
748} 682}
749#endif 683#endif
750 684
751static void snd_ali_stop_voice(struct snd_ali * codec, unsigned int channel) 685static void snd_ali_stop_voice(struct snd_ali *codec, unsigned int channel)
752{ 686{
753 unsigned int mask = 1 << (channel & 0x1f); 687 unsigned int mask = 1 << (channel & 0x1f);
754 688
@@ -768,26 +702,27 @@ static void snd_ali_delay(struct snd_ali *codec,int interval)
768 currenttimer = inl(ALI_REG(codec, ALI_STIMER)); 702 currenttimer = inl(ALI_REG(codec, ALI_STIMER));
769 703
770 while (currenttimer < begintimer + interval) { 704 while (currenttimer < begintimer + interval) {
771 if(snd_ali_stimer_ready(codec) < 0) 705 if (snd_ali_stimer_ready(codec) < 0)
772 break; 706 break;
773 currenttimer = inl(ALI_REG(codec, ALI_STIMER)); 707 currenttimer = inl(ALI_REG(codec, ALI_STIMER));
708 cpu_relax();
774 } 709 }
775} 710}
776 711
777static void snd_ali_detect_spdif_rate(struct snd_ali *codec) 712static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
778{ 713{
779 u16 wval = 0; 714 u16 wval;
780 u16 count = 0; 715 u16 count = 0;
781 u8 bval = 0, R1 = 0, R2 = 0; 716 u8 bval, R1 = 0, R2;
782 717
783 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL + 1)); 718 bval = inb(ALI_REG(codec, ALI_SPDIF_CTRL + 1));
784 bval |= 0x1F; 719 bval |= 0x1F;
785 outb(bval,ALI_REG(codec,ALI_SPDIF_CTRL + 1)); 720 outb(bval, ALI_REG(codec, ALI_SPDIF_CTRL + 1));
786 721
787 while (((R1 < 0x0B )||(R1 > 0x0E)) && (R1 != 0x12) && count <= 50000) { 722 while ((R1 < 0x0b || R1 > 0x0e) && R1 != 0x12 && count <= 50000) {
788 count ++; 723 count ++;
789 snd_ali_delay(codec, 6); 724 snd_ali_delay(codec, 6);
790 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL + 1)); 725 bval = inb(ALI_REG(codec, ALI_SPDIF_CTRL + 1));
791 R1 = bval & 0x1F; 726 R1 = bval & 0x1F;
792 } 727 }
793 728
@@ -801,7 +736,10 @@ static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
801 snd_ali_delay(codec, 6); 736 snd_ali_delay(codec, 6);
802 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL + 1)); 737 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL + 1));
803 R2 = bval & 0x1F; 738 R2 = bval & 0x1F;
804 if (R2 != R1) R1 = R2; else break; 739 if (R2 != R1)
740 R1 = R2;
741 else
742 break;
805 } 743 }
806 744
807 if (count > 50000) { 745 if (count > 50000) {
@@ -810,42 +748,45 @@ static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
810 } 748 }
811 749
812 if (R2 >= 0x0b && R2 <= 0x0e) { 750 if (R2 >= 0x0b && R2 <= 0x0e) {
813 wval = inw(ALI_REG(codec,ALI_SPDIF_CTRL + 2)); 751 wval = inw(ALI_REG(codec, ALI_SPDIF_CTRL + 2));
814 wval &= 0xE0F0; 752 wval &= 0xe0f0;
815 wval |= (u16)0x09 << 8 | (u16)0x05; 753 wval |= (0x09 << 8) | 0x05;
816 outw(wval,ALI_REG(codec,ALI_SPDIF_CTRL + 2)); 754 outw(wval, ALI_REG(codec, ALI_SPDIF_CTRL + 2));
817 755
818 bval = inb(ALI_REG(codec,ALI_SPDIF_CS +3)) & 0xF0; 756 bval = inb(ALI_REG(codec, ALI_SPDIF_CS + 3)) & 0xf0;
819 outb(bval|0x02,ALI_REG(codec,ALI_SPDIF_CS + 3)); 757 outb(bval | 0x02, ALI_REG(codec, ALI_SPDIF_CS + 3));
820 } else if (R2 == 0x12) { 758 } else if (R2 == 0x12) {
821 wval = inw(ALI_REG(codec,ALI_SPDIF_CTRL + 2)); 759 wval = inw(ALI_REG(codec, ALI_SPDIF_CTRL + 2));
822 wval &= 0xE0F0; 760 wval &= 0xe0f0;
823 wval |= (u16)0x0E << 8 | (u16)0x08; 761 wval |= (0x0e << 8) | 0x08;
824 outw(wval,ALI_REG(codec,ALI_SPDIF_CTRL + 2)); 762 outw(wval, ALI_REG(codec, ALI_SPDIF_CTRL + 2));
825 763
826 bval = inb(ALI_REG(codec,ALI_SPDIF_CS +3)) & 0xF0; 764 bval = inb(ALI_REG(codec,ALI_SPDIF_CS + 3)) & 0xf0;
827 outb(bval|0x03,ALI_REG(codec,ALI_SPDIF_CS + 3)); 765 outb(bval | 0x03, ALI_REG(codec, ALI_SPDIF_CS + 3));
828 } 766 }
829} 767}
830 768
831static unsigned int snd_ali_get_spdif_in_rate(struct snd_ali *codec) 769static unsigned int snd_ali_get_spdif_in_rate(struct snd_ali *codec)
832{ 770{
833 u32 dwRate = 0; 771 u32 dwRate;
834 u8 bval = 0; 772 u8 bval;
835 773
836 bval = inb(ALI_REG(codec,ALI_SPDIF_CTRL)); 774 bval = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
837 bval &= 0x7F; 775 bval &= 0x7f;
838 bval |= 0x40; 776 bval |= 0x40;
839 outb(bval, ALI_REG(codec,ALI_SPDIF_CTRL)); 777 outb(bval, ALI_REG(codec, ALI_SPDIF_CTRL));
840 778
841 snd_ali_detect_spdif_rate(codec); 779 snd_ali_detect_spdif_rate(codec);
842 780
843 bval = inb(ALI_REG(codec,ALI_SPDIF_CS + 3)); 781 bval = inb(ALI_REG(codec, ALI_SPDIF_CS + 3));
844 bval &= 0x0F; 782 bval &= 0x0f;
845 783
846 if (bval == 0) dwRate = 44100; 784 switch (bval) {
847 if (bval == 1) dwRate = 48000; 785 case 0: dwRate = 44100; break;
848 if (bval == 2) dwRate = 32000; 786 case 1: dwRate = 48000; break;
787 case 2: dwRate = 32000; break;
788 default: dwRate = 0; break;
789 }
849 790
850 return dwRate; 791 return dwRate;
851} 792}
@@ -880,20 +821,22 @@ static void snd_ali_disable_spdif_in(struct snd_ali *codec)
880static void snd_ali_set_spdif_out_rate(struct snd_ali *codec, unsigned int rate) 821static void snd_ali_set_spdif_out_rate(struct snd_ali *codec, unsigned int rate)
881{ 822{
882 unsigned char bVal; 823 unsigned char bVal;
883 unsigned int dwRate = 0; 824 unsigned int dwRate;
884 825
885 if (rate == 32000) dwRate = 0x300; 826 switch (rate) {
886 if (rate == 44100) dwRate = 0; 827 case 32000: dwRate = 0x300; break;
887 if (rate == 48000) dwRate = 0x200; 828 case 48000: dwRate = 0x200; break;
829 default: dwRate = 0; break;
830 }
888 831
889 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL)); 832 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
890 bVal &= (unsigned char)(~(1<<6)); 833 bVal &= (unsigned char)(~(1<<6));
891 834
892 bVal |= 0x80; //select right 835 bVal |= 0x80; /* select right */
893 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL)); 836 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL));
894 outb(dwRate | 0x20, ALI_REG(codec, ALI_SPDIF_CS + 2)); 837 outb(dwRate | 0x20, ALI_REG(codec, ALI_SPDIF_CS + 2));
895 838
896 bVal &= (~0x80); //select left 839 bVal &= ~0x80; /* select left */
897 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL)); 840 outb(bVal, ALI_REG(codec, ALI_SPDIF_CTRL));
898 outw(rate | 0x10, ALI_REG(codec, ALI_SPDIF_CS + 2)); 841 outw(rate | 0x10, ALI_REG(codec, ALI_SPDIF_CS + 2));
899} 842}
@@ -902,8 +845,7 @@ static void snd_ali_enable_spdif_out(struct snd_ali *codec)
902{ 845{
903 unsigned short wVal; 846 unsigned short wVal;
904 unsigned char bVal; 847 unsigned char bVal;
905 848 struct pci_dev *pci_dev;
906 struct pci_dev *pci_dev = NULL;
907 849
908 pci_dev = codec->pci_m1533; 850 pci_dev = codec->pci_m1533;
909 if (pci_dev == NULL) 851 if (pci_dev == NULL)
@@ -926,17 +868,15 @@ static void snd_ali_enable_spdif_out(struct snd_ali *codec)
926 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL)); 868 bVal = inb(ALI_REG(codec, ALI_SPDIF_CTRL));
927 outb(bVal & ALI_SPDIF_OUT_CH_STATUS, ALI_REG(codec, ALI_SPDIF_CTRL)); 869 outb(bVal & ALI_SPDIF_OUT_CH_STATUS, ALI_REG(codec, ALI_SPDIF_CTRL));
928 870
929 { 871 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL));
930 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL)); 872 wVal |= ALI_SPDIF_OUT_SEL_PCM;
931 wVal |= ALI_SPDIF_OUT_SEL_PCM; 873 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
932 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL)); 874 snd_ali_disable_special_channel(codec, ALI_SPDIF_OUT_CHANNEL);
933 snd_ali_disable_special_channel(codec,ALI_SPDIF_OUT_CHANNEL);
934 }
935} 875}
936 876
937static void snd_ali_enable_spdif_chnout(struct snd_ali *codec) 877static void snd_ali_enable_spdif_chnout(struct snd_ali *codec)
938{ 878{
939 unsigned short wVal = 0; 879 unsigned short wVal;
940 880
941 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL)); 881 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL));
942 wVal &= ~ALI_SPDIF_OUT_SEL_PCM; 882 wVal &= ~ALI_SPDIF_OUT_SEL_PCM;
@@ -949,12 +889,13 @@ static void snd_ali_enable_spdif_chnout(struct snd_ali *codec)
949 wVal &= (~0x0002); 889 wVal &= (~0x0002);
950 outw(wVal, ALI_REG(codec, ALI_SPDIF_CS)); 890 outw(wVal, ALI_REG(codec, ALI_SPDIF_CS));
951*/ 891*/
952 snd_ali_enable_special_channel(codec,ALI_SPDIF_OUT_CHANNEL); 892 snd_ali_enable_special_channel(codec, ALI_SPDIF_OUT_CHANNEL);
953} 893}
954 894
955static void snd_ali_disable_spdif_chnout(struct snd_ali *codec) 895static void snd_ali_disable_spdif_chnout(struct snd_ali *codec)
956{ 896{
957 unsigned short wVal = 0; 897 unsigned short wVal;
898
958 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL)); 899 wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL));
959 wVal |= ALI_SPDIF_OUT_SEL_PCM; 900 wVal |= ALI_SPDIF_OUT_SEL_PCM;
960 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL)); 901 outw(wVal, ALI_REG(codec, ALI_GLOBAL_CONTROL));
@@ -972,11 +913,11 @@ static void snd_ali_disable_spdif_out(struct snd_ali *codec)
972 snd_ali_disable_spdif_chnout(codec); 913 snd_ali_disable_spdif_chnout(codec);
973} 914}
974 915
975static void snd_ali_update_ptr(struct snd_ali *codec,int channel) 916static void snd_ali_update_ptr(struct snd_ali *codec, int channel)
976{ 917{
977 struct snd_ali_voice *pvoice = NULL; 918 struct snd_ali_voice *pvoice;
978 struct snd_pcm_runtime *runtime; 919 struct snd_pcm_runtime *runtime;
979 struct snd_ali_channel_control *pchregs = NULL; 920 struct snd_ali_channel_control *pchregs;
980 unsigned int old, mask; 921 unsigned int old, mask;
981#ifdef ALI_DEBUG 922#ifdef ALI_DEBUG
982 unsigned int temp, cspf; 923 unsigned int temp, cspf;
@@ -984,9 +925,9 @@ static void snd_ali_update_ptr(struct snd_ali *codec,int channel)
984 925
985 pchregs = &(codec->chregs); 926 pchregs = &(codec->chregs);
986 927
987 // check if interrupt occurred for channel 928 /* check if interrupt occurred for channel */
988 old = pchregs->data.aint; 929 old = pchregs->data.aint;
989 mask = ((unsigned int) 1L) << (channel & 0x1f); 930 mask = 1U << (channel & 0x1f);
990 931
991 if (!(old & mask)) 932 if (!(old & mask))
992 return; 933 return;
@@ -1005,7 +946,8 @@ static void snd_ali_update_ptr(struct snd_ali *codec,int channel)
1005 cspf = (inl(ALI_REG(codec, ALI_CSPF)) & mask) == mask; 946 cspf = (inl(ALI_REG(codec, ALI_CSPF)) & mask) == mask;
1006#endif 947#endif
1007 if (pvoice->running) { 948 if (pvoice->running) {
1008 snd_ali_printk("update_ptr: cso=%4.4x cspf=%d.\n",(u16)temp,cspf); 949 snd_ali_printk("update_ptr: cso=%4.4x cspf=%d.\n",
950 (u16)temp, cspf);
1009 spin_unlock(&codec->reg_lock); 951 spin_unlock(&codec->reg_lock);
1010 snd_pcm_period_elapsed(pvoice->substream); 952 snd_pcm_period_elapsed(pvoice->substream);
1011 spin_lock(&codec->reg_lock); 953 spin_lock(&codec->reg_lock);
@@ -1027,49 +969,47 @@ static void snd_ali_update_ptr(struct snd_ali *codec,int channel)
1027 pchregs->data.aint = old & (~mask); 969 pchregs->data.aint = old & (~mask);
1028} 970}
1029 971
1030static void snd_ali_interrupt(struct snd_ali * codec) 972static irqreturn_t snd_ali_card_interrupt(int irq, void *dev_id)
1031{ 973{
974 struct snd_ali *codec = dev_id;
1032 int channel; 975 int channel;
1033 unsigned int audio_int; 976 unsigned int audio_int;
1034 struct snd_ali_channel_control *pchregs = NULL; 977 struct snd_ali_channel_control *pchregs;
1035 pchregs = &(codec->chregs); 978
979 if (codec == NULL || !codec->hw_initialized)
980 return IRQ_NONE;
1036 981
1037 audio_int = inl(ALI_REG(codec, ALI_MISCINT)); 982 audio_int = inl(ALI_REG(codec, ALI_MISCINT));
983 if (!audio_int)
984 return IRQ_NONE;
985
986 pchregs = &(codec->chregs);
1038 if (audio_int & ADDRESS_IRQ) { 987 if (audio_int & ADDRESS_IRQ) {
1039 // get interrupt status for all channels 988 /* get interrupt status for all channels */
1040 pchregs->data.aint = inl(ALI_REG(codec,pchregs->regs.aint)); 989 pchregs->data.aint = inl(ALI_REG(codec, pchregs->regs.aint));
1041 for (channel = 0; channel < ALI_CHANNELS; channel++) { 990 for (channel = 0; channel < ALI_CHANNELS; channel++)
1042 snd_ali_update_ptr(codec, channel); 991 snd_ali_update_ptr(codec, channel);
1043 }
1044 } 992 }
1045 outl((TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW), 993 outl((TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW),
1046 ALI_REG(codec,ALI_MISCINT)); 994 ALI_REG(codec, ALI_MISCINT));
1047}
1048
1049
1050static irqreturn_t snd_ali_card_interrupt(int irq, void *dev_id)
1051{
1052 struct snd_ali *codec = dev_id;
1053 995
1054 if (codec == NULL)
1055 return IRQ_NONE;
1056 snd_ali_interrupt(codec);
1057 return IRQ_HANDLED; 996 return IRQ_HANDLED;
1058} 997}
1059 998
1060 999
1061static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec, int type, int rec, int channel) 1000static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec,
1001 int type, int rec, int channel)
1062{ 1002{
1063 struct snd_ali_voice *pvoice = NULL; 1003 struct snd_ali_voice *pvoice;
1064 int idx; 1004 int idx;
1065 1005
1066 snd_ali_printk("alloc_voice: type=%d rec=%d\n",type,rec); 1006 snd_ali_printk("alloc_voice: type=%d rec=%d\n", type, rec);
1067 1007
1068 spin_lock_irq(&codec->voice_alloc); 1008 spin_lock_irq(&codec->voice_alloc);
1069 if (type == SNDRV_ALI_VOICE_TYPE_PCM) { 1009 if (type == SNDRV_ALI_VOICE_TYPE_PCM) {
1070 idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) : 1010 idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) :
1071 snd_ali_find_free_channel(codec,rec); 1011 snd_ali_find_free_channel(codec,rec);
1072 if(idx < 0) { 1012 if (idx < 0) {
1073 snd_printk(KERN_ERR "ali_alloc_voice: err.\n"); 1013 snd_printk(KERN_ERR "ali_alloc_voice: err.\n");
1074 spin_unlock_irq(&codec->voice_alloc); 1014 spin_unlock_irq(&codec->voice_alloc);
1075 return NULL; 1015 return NULL;
@@ -1087,7 +1027,8 @@ static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec, int typ
1087} 1027}
1088 1028
1089 1029
1090static void snd_ali_free_voice(struct snd_ali * codec, struct snd_ali_voice *pvoice) 1030static void snd_ali_free_voice(struct snd_ali * codec,
1031 struct snd_ali_voice *pvoice)
1091{ 1032{
1092 void (*private_free)(void *); 1033 void (*private_free)(void *);
1093 void *private_data; 1034 void *private_data;
@@ -1101,9 +1042,8 @@ static void snd_ali_free_voice(struct snd_ali * codec, struct snd_ali_voice *pvo
1101 private_data = pvoice->private_data; 1042 private_data = pvoice->private_data;
1102 pvoice->private_free = NULL; 1043 pvoice->private_free = NULL;
1103 pvoice->private_data = NULL; 1044 pvoice->private_data = NULL;
1104 if (pvoice->pcm) { 1045 if (pvoice->pcm)
1105 snd_ali_free_channel_pcm(codec, pvoice->number); 1046 snd_ali_free_channel_pcm(codec, pvoice->number);
1106 }
1107 pvoice->use = pvoice->pcm = pvoice->synth = 0; 1047 pvoice->use = pvoice->pcm = pvoice->synth = 0;
1108 pvoice->substream = NULL; 1048 pvoice->substream = NULL;
1109 spin_unlock_irq(&codec->voice_alloc); 1049 spin_unlock_irq(&codec->voice_alloc);
@@ -1112,9 +1052,9 @@ static void snd_ali_free_voice(struct snd_ali * codec, struct snd_ali_voice *pvo
1112} 1052}
1113 1053
1114 1054
1115static void snd_ali_clear_voices(struct snd_ali * codec, 1055static void snd_ali_clear_voices(struct snd_ali *codec,
1116 unsigned int v_min, 1056 unsigned int v_min,
1117 unsigned int v_max) 1057 unsigned int v_max)
1118{ 1058{
1119 unsigned int i; 1059 unsigned int i;
1120 1060
@@ -1124,7 +1064,7 @@ static void snd_ali_clear_voices(struct snd_ali * codec,
1124 } 1064 }
1125} 1065}
1126 1066
1127static void snd_ali_write_voice_regs(struct snd_ali * codec, 1067static void snd_ali_write_voice_regs(struct snd_ali *codec,
1128 unsigned int Channel, 1068 unsigned int Channel,
1129 unsigned int LBA, 1069 unsigned int LBA,
1130 unsigned int CSO, 1070 unsigned int CSO,
@@ -1139,7 +1079,7 @@ static void snd_ali_write_voice_regs(struct snd_ali * codec,
1139{ 1079{
1140 unsigned int ctlcmds[4]; 1080 unsigned int ctlcmds[4];
1141 1081
1142 outb((unsigned char)(Channel & 0x001f),ALI_REG(codec,ALI_GC_CIR)); 1082 outb((unsigned char)(Channel & 0x001f), ALI_REG(codec, ALI_GC_CIR));
1143 1083
1144 ctlcmds[0] = (CSO << 16) | (ALPHA_FMS & 0x0000ffff); 1084 ctlcmds[0] = (CSO << 16) | (ALPHA_FMS & 0x0000ffff);
1145 ctlcmds[1] = LBA; 1085 ctlcmds[1] = LBA;
@@ -1152,10 +1092,10 @@ static void snd_ali_write_voice_regs(struct snd_ali * codec,
1152 1092
1153 outb(Channel, ALI_REG(codec, ALI_GC_CIR)); 1093 outb(Channel, ALI_REG(codec, ALI_GC_CIR));
1154 1094
1155 outl(ctlcmds[0], ALI_REG(codec,ALI_CSO_ALPHA_FMS)); 1095 outl(ctlcmds[0], ALI_REG(codec, ALI_CSO_ALPHA_FMS));
1156 outl(ctlcmds[1], ALI_REG(codec,ALI_LBA)); 1096 outl(ctlcmds[1], ALI_REG(codec, ALI_LBA));
1157 outl(ctlcmds[2], ALI_REG(codec,ALI_ESO_DELTA)); 1097 outl(ctlcmds[2], ALI_REG(codec, ALI_ESO_DELTA));
1158 outl(ctlcmds[3], ALI_REG(codec,ALI_GVSEL_PAN_VOC_CTRL_EC)); 1098 outl(ctlcmds[3], ALI_REG(codec, ALI_GVSEL_PAN_VOC_CTRL_EC));
1159 1099
1160 outl(0x30000000, ALI_REG(codec, ALI_EBUF1)); /* Still Mode */ 1100 outl(0x30000000, ALI_REG(codec, ALI_EBUF1)); /* Still Mode */
1161 outl(0x30000000, ALI_REG(codec, ALI_EBUF2)); /* Still Mode */ 1101 outl(0x30000000, ALI_REG(codec, ALI_EBUF2)); /* Still Mode */
@@ -1165,8 +1105,10 @@ static unsigned int snd_ali_convert_rate(unsigned int rate, int rec)
1165{ 1105{
1166 unsigned int delta; 1106 unsigned int delta;
1167 1107
1168 if (rate < 4000) rate = 4000; 1108 if (rate < 4000)
1169 if (rate > 48000) rate = 48000; 1109 rate = 4000;
1110 if (rate > 48000)
1111 rate = 48000;
1170 1112
1171 if (rec) { 1113 if (rec) {
1172 if (rate == 44100) 1114 if (rate == 44100)
@@ -1201,11 +1143,11 @@ static unsigned int snd_ali_control_mode(struct snd_pcm_substream *substream)
1201 */ 1143 */
1202 CTRL = 0x00000001; 1144 CTRL = 0x00000001;
1203 if (snd_pcm_format_width(runtime->format) == 16) 1145 if (snd_pcm_format_width(runtime->format) == 16)
1204 CTRL |= 0x00000008; // 16-bit data 1146 CTRL |= 0x00000008; /* 16-bit data */
1205 if (!snd_pcm_format_unsigned(runtime->format)) 1147 if (!snd_pcm_format_unsigned(runtime->format))
1206 CTRL |= 0x00000002; // signed data 1148 CTRL |= 0x00000002; /* signed data */
1207 if (runtime->channels > 1) 1149 if (runtime->channels > 1)
1208 CTRL |= 0x00000004; // stereo data 1150 CTRL |= 0x00000004; /* stereo data */
1209 return CTRL; 1151 return CTRL;
1210} 1152}
1211 1153
@@ -1213,45 +1155,39 @@ static unsigned int snd_ali_control_mode(struct snd_pcm_substream *substream)
1213 * PCM part 1155 * PCM part
1214 */ 1156 */
1215 1157
1216static int snd_ali_ioctl(struct snd_pcm_substream *substream,
1217 unsigned int cmd, void *arg)
1218{
1219 return snd_pcm_lib_ioctl(substream, cmd, arg);
1220}
1221
1222static int snd_ali_trigger(struct snd_pcm_substream *substream, 1158static int snd_ali_trigger(struct snd_pcm_substream *substream,
1223 int cmd) 1159 int cmd)
1224 1160
1225{ 1161{
1226 struct snd_ali *codec = snd_pcm_substream_chip(substream); 1162 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1227 struct list_head *pos;
1228 struct snd_pcm_substream *s; 1163 struct snd_pcm_substream *s;
1229 unsigned int what, whati, capture_flag; 1164 unsigned int what, whati, capture_flag;
1230 struct snd_ali_voice *pvoice = NULL, *evoice = NULL; 1165 struct snd_ali_voice *pvoice, *evoice;
1231 unsigned int val; 1166 unsigned int val;
1232 int do_start; 1167 int do_start;
1233 1168
1234 switch (cmd) { 1169 switch (cmd) {
1235 case SNDRV_PCM_TRIGGER_START: 1170 case SNDRV_PCM_TRIGGER_START:
1236 case SNDRV_PCM_TRIGGER_RESUME: 1171 case SNDRV_PCM_TRIGGER_RESUME:
1237 do_start = 1; break; 1172 do_start = 1;
1173 break;
1238 case SNDRV_PCM_TRIGGER_STOP: 1174 case SNDRV_PCM_TRIGGER_STOP:
1239 case SNDRV_PCM_TRIGGER_SUSPEND: 1175 case SNDRV_PCM_TRIGGER_SUSPEND:
1240 do_start = 0; break; 1176 do_start = 0;
1177 break;
1241 default: 1178 default:
1242 return -EINVAL; 1179 return -EINVAL;
1243 } 1180 }
1244 1181
1245 what = whati = capture_flag = 0; 1182 what = whati = capture_flag = 0;
1246 snd_pcm_group_for_each(pos, substream) { 1183 snd_pcm_group_for_each_entry(s, substream) {
1247 s = snd_pcm_group_substream_entry(pos);
1248 if ((struct snd_ali *) snd_pcm_substream_chip(s) == codec) { 1184 if ((struct snd_ali *) snd_pcm_substream_chip(s) == codec) {
1249 pvoice = s->runtime->private_data; 1185 pvoice = s->runtime->private_data;
1250 evoice = pvoice->extra; 1186 evoice = pvoice->extra;
1251 what |= 1 << (pvoice->number & 0x1f); 1187 what |= 1 << (pvoice->number & 0x1f);
1252 if (evoice == NULL) { 1188 if (evoice == NULL)
1253 whati |= 1 << (pvoice->number & 0x1f); 1189 whati |= 1 << (pvoice->number & 0x1f);
1254 } else { 1190 else {
1255 whati |= 1 << (evoice->number & 0x1f); 1191 whati |= 1 << (evoice->number & 0x1f);
1256 what |= 1 << (evoice->number & 0x1f); 1192 what |= 1 << (evoice->number & 0x1f);
1257 } 1193 }
@@ -1270,48 +1206,51 @@ static int snd_ali_trigger(struct snd_pcm_substream *substream,
1270 } 1206 }
1271 } 1207 }
1272 spin_lock(&codec->reg_lock); 1208 spin_lock(&codec->reg_lock);
1273 if (! do_start) { 1209 if (!do_start)
1274 outl(what, ALI_REG(codec, ALI_STOP)); 1210 outl(what, ALI_REG(codec, ALI_STOP));
1275 }
1276 val = inl(ALI_REG(codec, ALI_AINTEN)); 1211 val = inl(ALI_REG(codec, ALI_AINTEN));
1277 if (do_start) { 1212 if (do_start)
1278 val |= whati; 1213 val |= whati;
1279 } else { 1214 else
1280 val &= ~whati; 1215 val &= ~whati;
1281 }
1282 outl(val, ALI_REG(codec, ALI_AINTEN)); 1216 outl(val, ALI_REG(codec, ALI_AINTEN));
1283 if (do_start) { 1217 if (do_start)
1284 outl(what, ALI_REG(codec, ALI_START)); 1218 outl(what, ALI_REG(codec, ALI_START));
1285 } 1219 snd_ali_printk("trigger: what=%xh whati=%xh\n", what, whati);
1286 snd_ali_printk("trigger: what=%xh whati=%xh\n",what,whati);
1287 spin_unlock(&codec->reg_lock); 1220 spin_unlock(&codec->reg_lock);
1288 1221
1289 return 0; 1222 return 0;
1290} 1223}
1291 1224
1292static int snd_ali_playback_hw_params(struct snd_pcm_substream *substream, 1225static int snd_ali_playback_hw_params(struct snd_pcm_substream *substream,
1293 struct snd_pcm_hw_params *hw_params) 1226 struct snd_pcm_hw_params *hw_params)
1294{ 1227{
1295 struct snd_ali *codec = snd_pcm_substream_chip(substream); 1228 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1296 struct snd_pcm_runtime *runtime = substream->runtime; 1229 struct snd_pcm_runtime *runtime = substream->runtime;
1297 struct snd_ali_voice *pvoice = runtime->private_data; 1230 struct snd_ali_voice *pvoice = runtime->private_data;
1298 struct snd_ali_voice *evoice = pvoice->extra; 1231 struct snd_ali_voice *evoice = pvoice->extra;
1299 int err; 1232 int err;
1300 err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 1233
1301 if (err < 0) return err; 1234 err = snd_pcm_lib_malloc_pages(substream,
1235 params_buffer_bytes(hw_params));
1236 if (err < 0)
1237 return err;
1302 1238
1303 /* voice management */ 1239 /* voice management */
1304 1240
1305 if (params_buffer_size(hw_params)/2 != params_period_size(hw_params)) { 1241 if (params_buffer_size(hw_params) / 2 !=
1306 if (evoice == NULL) { 1242 params_period_size(hw_params)) {
1307 evoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, 0, -1); 1243 if (!evoice) {
1308 if (evoice == NULL) 1244 evoice = snd_ali_alloc_voice(codec,
1245 SNDRV_ALI_VOICE_TYPE_PCM,
1246 0, -1);
1247 if (!evoice)
1309 return -ENOMEM; 1248 return -ENOMEM;
1310 pvoice->extra = evoice; 1249 pvoice->extra = evoice;
1311 evoice->substream = substream; 1250 evoice->substream = substream;
1312 } 1251 }
1313 } else { 1252 } else {
1314 if (evoice != NULL) { 1253 if (!evoice) {
1315 snd_ali_free_voice(codec, evoice); 1254 snd_ali_free_voice(codec, evoice);
1316 pvoice->extra = evoice = NULL; 1255 pvoice->extra = evoice = NULL;
1317 } 1256 }
@@ -1328,7 +1267,7 @@ static int snd_ali_playback_hw_free(struct snd_pcm_substream *substream)
1328 struct snd_ali_voice *evoice = pvoice ? pvoice->extra : NULL; 1267 struct snd_ali_voice *evoice = pvoice ? pvoice->extra : NULL;
1329 1268
1330 snd_pcm_lib_free_pages(substream); 1269 snd_pcm_lib_free_pages(substream);
1331 if (evoice != NULL) { 1270 if (!evoice) {
1332 snd_ali_free_voice(codec, evoice); 1271 snd_ali_free_voice(codec, evoice);
1333 pvoice->extra = NULL; 1272 pvoice->extra = NULL;
1334 } 1273 }
@@ -1336,9 +1275,10 @@ static int snd_ali_playback_hw_free(struct snd_pcm_substream *substream)
1336} 1275}
1337 1276
1338static int snd_ali_hw_params(struct snd_pcm_substream *substream, 1277static int snd_ali_hw_params(struct snd_pcm_substream *substream,
1339 struct snd_pcm_hw_params *hw_params) 1278 struct snd_pcm_hw_params *hw_params)
1340{ 1279{
1341 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 1280 return snd_pcm_lib_malloc_pages(substream,
1281 params_buffer_bytes(hw_params));
1342} 1282}
1343 1283
1344static int snd_ali_hw_free(struct snd_pcm_substream *substream) 1284static int snd_ali_hw_free(struct snd_pcm_substream *substream)
@@ -1369,12 +1309,13 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
1369 /* set Delta (rate) value */ 1309 /* set Delta (rate) value */
1370 Delta = snd_ali_convert_rate(runtime->rate, 0); 1310 Delta = snd_ali_convert_rate(runtime->rate, 0);
1371 1311
1372 if ((pvoice->number == ALI_SPDIF_IN_CHANNEL) || 1312 if (pvoice->number == ALI_SPDIF_IN_CHANNEL ||
1373 (pvoice->number == ALI_PCM_IN_CHANNEL)) 1313 pvoice->number == ALI_PCM_IN_CHANNEL)
1374 snd_ali_disable_special_channel(codec, pvoice->number); 1314 snd_ali_disable_special_channel(codec, pvoice->number);
1375 else if (codec->spdif_support && 1315 else if (codec->spdif_support &&
1376 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) & ALI_SPDIF_OUT_CH_ENABLE) 1316 (inl(ALI_REG(codec, ALI_GLOBAL_CONTROL)) &
1377 && (pvoice->number == ALI_SPDIF_OUT_CHANNEL)) { 1317 ALI_SPDIF_OUT_CH_ENABLE)
1318 && pvoice->number == ALI_SPDIF_OUT_CHANNEL) {
1378 snd_ali_set_spdif_out_rate(codec, runtime->rate); 1319 snd_ali_set_spdif_out_rate(codec, runtime->rate);
1379 Delta = 0x1000; 1320 Delta = 0x1000;
1380 } 1321 }
@@ -1388,7 +1329,8 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
1388 /* set target ESO for channel */ 1329 /* set target ESO for channel */
1389 pvoice->eso = runtime->buffer_size; 1330 pvoice->eso = runtime->buffer_size;
1390 1331
1391 snd_ali_printk("playback_prepare: eso=%xh count=%xh\n",pvoice->eso,pvoice->count); 1332 snd_ali_printk("playback_prepare: eso=%xh count=%xh\n",
1333 pvoice->eso, pvoice->count);
1392 1334
1393 /* set ESO to capture first MIDLP interrupt */ 1335 /* set ESO to capture first MIDLP interrupt */
1394 ESO = pvoice->eso -1; 1336 ESO = pvoice->eso -1;
@@ -1399,35 +1341,37 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
1399 PAN = 0; 1341 PAN = 0;
1400 VOL = 0; 1342 VOL = 0;
1401 EC = 0; 1343 EC = 0;
1402 snd_ali_printk("playback_prepare:\n ch=%d, Rate=%d Delta=%xh,GVSEL=%xh,PAN=%xh,CTRL=%xh\n",pvoice->number,runtime->rate,Delta,GVSEL,PAN,CTRL); 1344 snd_ali_printk("playback_prepare:\n");
1403 snd_ali_write_voice_regs( codec, 1345 snd_ali_printk("ch=%d, Rate=%d Delta=%xh,GVSEL=%xh,PAN=%xh,CTRL=%xh\n",
1404 pvoice->number, 1346 pvoice->number,runtime->rate,Delta,GVSEL,PAN,CTRL);
1405 LBA, 1347 snd_ali_write_voice_regs(codec,
1406 0, /* cso */ 1348 pvoice->number,
1407 ESO, 1349 LBA,
1408 Delta, 1350 0, /* cso */
1409 0, /* alpha */ 1351 ESO,
1410 GVSEL, 1352 Delta,
1411 PAN, 1353 0, /* alpha */
1412 VOL, 1354 GVSEL,
1413 CTRL, 1355 PAN,
1414 EC); 1356 VOL,
1415 if (evoice != NULL) { 1357 CTRL,
1358 EC);
1359 if (!evoice) {
1416 evoice->count = pvoice->count; 1360 evoice->count = pvoice->count;
1417 evoice->eso = pvoice->count << 1; 1361 evoice->eso = pvoice->count << 1;
1418 ESO = evoice->eso - 1; 1362 ESO = evoice->eso - 1;
1419 snd_ali_write_voice_regs(codec, 1363 snd_ali_write_voice_regs(codec,
1420 evoice->number, 1364 evoice->number,
1421 LBA, 1365 LBA,
1422 0, /* cso */ 1366 0, /* cso */
1423 ESO, 1367 ESO,
1424 Delta, 1368 Delta,
1425 0, /* alpha */ 1369 0, /* alpha */
1426 GVSEL, 1370 GVSEL,
1427 (unsigned int)0x7f, 1371 0x7f,
1428 (unsigned int)0x3ff, 1372 0x3ff,
1429 CTRL, 1373 CTRL,
1430 EC); 1374 EC);
1431 } 1375 }
1432 spin_unlock_irq(&codec->reg_lock); 1376 spin_unlock_irq(&codec->reg_lock);
1433 return 0; 1377 return 0;
@@ -1459,7 +1403,7 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
1459 pvoice->number == ALI_MODEM_OUT_CHANNEL) ? 1403 pvoice->number == ALI_MODEM_OUT_CHANNEL) ?
1460 0x1000 : snd_ali_convert_rate(runtime->rate, pvoice->mode); 1404 0x1000 : snd_ali_convert_rate(runtime->rate, pvoice->mode);
1461 1405
1462 // Prepare capture intr channel 1406 /* Prepare capture intr channel */
1463 if (pvoice->number == ALI_SPDIF_IN_CHANNEL) { 1407 if (pvoice->number == ALI_SPDIF_IN_CHANNEL) {
1464 1408
1465 unsigned int rate; 1409 unsigned int rate;
@@ -1470,7 +1414,8 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
1470 1414
1471 rate = snd_ali_get_spdif_in_rate(codec); 1415 rate = snd_ali_get_spdif_in_rate(codec);
1472 if (rate == 0) { 1416 if (rate == 0) {
1473 snd_printk(KERN_WARNING "ali_capture_preapre: spdif rate detect err!\n"); 1417 snd_printk(KERN_WARNING "ali_capture_preapre: "
1418 "spdif rate detect err!\n");
1474 rate = 48000; 1419 rate = 48000;
1475 } 1420 }
1476 spin_lock_irq(&codec->reg_lock); 1421 spin_lock_irq(&codec->reg_lock);
@@ -1481,19 +1426,19 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
1481 } 1426 }
1482 1427
1483 if (rate != 48000) 1428 if (rate != 48000)
1484 Delta = ((rate << 12)/runtime->rate)&0x00ffff; 1429 Delta = ((rate << 12) / runtime->rate) & 0x00ffff;
1485 } 1430 }
1486 1431
1487 // set target ESO for channel 1432 /* set target ESO for channel */
1488 pvoice->eso = runtime->buffer_size; 1433 pvoice->eso = runtime->buffer_size;
1489 1434
1490 // set interrupt count size 1435 /* set interrupt count size */
1491 pvoice->count = runtime->period_size; 1436 pvoice->count = runtime->period_size;
1492 1437
1493 // set Loop Back Address 1438 /* set Loop Back Address */
1494 LBA = runtime->dma_addr; 1439 LBA = runtime->dma_addr;
1495 1440
1496 // set ESO to capture first MIDLP interrupt 1441 /* set ESO to capture first MIDLP interrupt */
1497 ESO = pvoice->eso - 1; 1442 ESO = pvoice->eso - 1;
1498 CTRL = snd_ali_control_mode(substream); 1443 CTRL = snd_ali_control_mode(substream);
1499 GVSEL = 0; 1444 GVSEL = 0;
@@ -1514,14 +1459,14 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
1514 CTRL, 1459 CTRL,
1515 EC); 1460 EC);
1516 1461
1517
1518 spin_unlock_irq(&codec->reg_lock); 1462 spin_unlock_irq(&codec->reg_lock);
1519 1463
1520 return 0; 1464 return 0;
1521} 1465}
1522 1466
1523 1467
1524static snd_pcm_uframes_t snd_ali_playback_pointer(struct snd_pcm_substream *substream) 1468static snd_pcm_uframes_t
1469snd_ali_playback_pointer(struct snd_pcm_substream *substream)
1525{ 1470{
1526 struct snd_ali *codec = snd_pcm_substream_chip(substream); 1471 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1527 struct snd_pcm_runtime *runtime = substream->runtime; 1472 struct snd_pcm_runtime *runtime = substream->runtime;
@@ -1563,14 +1508,14 @@ static snd_pcm_uframes_t snd_ali_pointer(struct snd_pcm_substream *substream)
1563 1508
1564static struct snd_pcm_hardware snd_ali_playback = 1509static struct snd_pcm_hardware snd_ali_playback =
1565{ 1510{
1566 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1511 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1567 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1512 SNDRV_PCM_INFO_BLOCK_TRANSFER |
1568 SNDRV_PCM_INFO_MMAP_VALID | 1513 SNDRV_PCM_INFO_MMAP_VALID |
1569 SNDRV_PCM_INFO_RESUME | 1514 SNDRV_PCM_INFO_RESUME |
1570 SNDRV_PCM_INFO_SYNC_START), 1515 SNDRV_PCM_INFO_SYNC_START),
1571 .formats = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | 1516 .formats = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE |
1572 SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE), 1517 SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE),
1573 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000, 1518 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
1574 .rate_min = 4000, 1519 .rate_min = 4000,
1575 .rate_max = 48000, 1520 .rate_max = 48000,
1576 .channels_min = 1, 1521 .channels_min = 1,
@@ -1589,14 +1534,14 @@ static struct snd_pcm_hardware snd_ali_playback =
1589 1534
1590static struct snd_pcm_hardware snd_ali_capture = 1535static struct snd_pcm_hardware snd_ali_capture =
1591{ 1536{
1592 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1537 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1593 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1538 SNDRV_PCM_INFO_BLOCK_TRANSFER |
1594 SNDRV_PCM_INFO_MMAP_VALID | 1539 SNDRV_PCM_INFO_MMAP_VALID |
1595 SNDRV_PCM_INFO_RESUME | 1540 SNDRV_PCM_INFO_RESUME |
1596 SNDRV_PCM_INFO_SYNC_START), 1541 SNDRV_PCM_INFO_SYNC_START),
1597 .formats = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | 1542 .formats = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE |
1598 SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE), 1543 SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE),
1599 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000, 1544 .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
1600 .rate_min = 4000, 1545 .rate_min = 4000,
1601 .rate_max = 48000, 1546 .rate_max = 48000,
1602 .channels_min = 1, 1547 .channels_min = 1,
@@ -1620,15 +1565,16 @@ static void snd_ali_pcm_free_substream(struct snd_pcm_runtime *runtime)
1620 } 1565 }
1621} 1566}
1622 1567
1623static int snd_ali_open(struct snd_pcm_substream *substream, int rec, int channel, 1568static int snd_ali_open(struct snd_pcm_substream *substream, int rec,
1624 struct snd_pcm_hardware *phw) 1569 int channel, struct snd_pcm_hardware *phw)
1625{ 1570{
1626 struct snd_ali *codec = snd_pcm_substream_chip(substream); 1571 struct snd_ali *codec = snd_pcm_substream_chip(substream);
1627 struct snd_pcm_runtime *runtime = substream->runtime; 1572 struct snd_pcm_runtime *runtime = substream->runtime;
1628 struct snd_ali_voice *pvoice; 1573 struct snd_ali_voice *pvoice;
1629 1574
1630 pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, rec, channel); 1575 pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, rec,
1631 if (pvoice == NULL) 1576 channel);
1577 if (!pvoice)
1632 return -EAGAIN; 1578 return -EAGAIN;
1633 1579
1634 pvoice->substream = substream; 1580 pvoice->substream = substream;
@@ -1637,7 +1583,8 @@ static int snd_ali_open(struct snd_pcm_substream *substream, int rec, int channe
1637 1583
1638 runtime->hw = *phw; 1584 runtime->hw = *phw;
1639 snd_pcm_set_sync(substream); 1585 snd_pcm_set_sync(substream);
1640 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 64*1024); 1586 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
1587 0, 64*1024);
1641 return 0; 1588 return 0;
1642} 1589}
1643 1590
@@ -1669,7 +1616,7 @@ static int snd_ali_close(struct snd_pcm_substream *substream)
1669static struct snd_pcm_ops snd_ali_playback_ops = { 1616static struct snd_pcm_ops snd_ali_playback_ops = {
1670 .open = snd_ali_playback_open, 1617 .open = snd_ali_playback_open,
1671 .close = snd_ali_playback_close, 1618 .close = snd_ali_playback_close,
1672 .ioctl = snd_ali_ioctl, 1619 .ioctl = snd_pcm_lib_ioctl,
1673 .hw_params = snd_ali_playback_hw_params, 1620 .hw_params = snd_ali_playback_hw_params,
1674 .hw_free = snd_ali_playback_hw_free, 1621 .hw_free = snd_ali_playback_hw_free,
1675 .prepare = snd_ali_playback_prepare, 1622 .prepare = snd_ali_playback_prepare,
@@ -1680,7 +1627,7 @@ static struct snd_pcm_ops snd_ali_playback_ops = {
1680static struct snd_pcm_ops snd_ali_capture_ops = { 1627static struct snd_pcm_ops snd_ali_capture_ops = {
1681 .open = snd_ali_capture_open, 1628 .open = snd_ali_capture_open,
1682 .close = snd_ali_close, 1629 .close = snd_ali_close,
1683 .ioctl = snd_ali_ioctl, 1630 .ioctl = snd_pcm_lib_ioctl,
1684 .hw_params = snd_ali_hw_params, 1631 .hw_params = snd_ali_hw_params,
1685 .hw_free = snd_ali_hw_free, 1632 .hw_free = snd_ali_hw_free,
1686 .prepare = snd_ali_prepare, 1633 .prepare = snd_ali_prepare,
@@ -1697,20 +1644,22 @@ static int snd_ali_modem_hw_params(struct snd_pcm_substream *substream,
1697{ 1644{
1698 struct snd_ali *chip = snd_pcm_substream_chip(substream); 1645 struct snd_ali *chip = snd_pcm_substream_chip(substream);
1699 unsigned int modem_num = chip->num_of_codecs - 1; 1646 unsigned int modem_num = chip->num_of_codecs - 1;
1700 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_RATE, params_rate(hw_params)); 1647 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_RATE,
1648 params_rate(hw_params));
1701 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_LEVEL, 0); 1649 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_LEVEL, 0);
1702 return snd_ali_hw_params(substream, hw_params); 1650 return snd_ali_hw_params(substream, hw_params);
1703} 1651}
1704 1652
1705static struct snd_pcm_hardware snd_ali_modem = 1653static struct snd_pcm_hardware snd_ali_modem =
1706{ 1654{
1707 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 1655 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1708 SNDRV_PCM_INFO_BLOCK_TRANSFER | 1656 SNDRV_PCM_INFO_BLOCK_TRANSFER |
1709 SNDRV_PCM_INFO_MMAP_VALID | 1657 SNDRV_PCM_INFO_MMAP_VALID |
1710 SNDRV_PCM_INFO_RESUME | 1658 SNDRV_PCM_INFO_RESUME |
1711 SNDRV_PCM_INFO_SYNC_START), 1659 SNDRV_PCM_INFO_SYNC_START),
1712 .formats = SNDRV_PCM_FMTBIT_S16_LE, 1660 .formats = SNDRV_PCM_FMTBIT_S16_LE,
1713 .rates = SNDRV_PCM_RATE_KNOT|SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000, 1661 .rates = (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000 |
1662 SNDRV_PCM_RATE_16000),
1714 .rate_min = 8000, 1663 .rate_min = 8000,
1715 .rate_max = 16000, 1664 .rate_max = 16000,
1716 .channels_min = 1, 1665 .channels_min = 1,
@@ -1723,15 +1672,17 @@ static struct snd_pcm_hardware snd_ali_modem =
1723 .fifo_size = 0, 1672 .fifo_size = 0,
1724}; 1673};
1725 1674
1726static int snd_ali_modem_open(struct snd_pcm_substream *substream, int rec, int channel) 1675static int snd_ali_modem_open(struct snd_pcm_substream *substream, int rec,
1676 int channel)
1727{ 1677{
1728 static unsigned int rates [] = {8000,9600,12000,16000}; 1678 static unsigned int rates[] = {8000, 9600, 12000, 16000};
1729 static struct snd_pcm_hw_constraint_list hw_constraint_rates = { 1679 static struct snd_pcm_hw_constraint_list hw_constraint_rates = {
1730 .count = ARRAY_SIZE(rates), 1680 .count = ARRAY_SIZE(rates),
1731 .list = rates, 1681 .list = rates,
1732 .mask = 0, 1682 .mask = 0,
1733 }; 1683 };
1734 int err = snd_ali_open(substream, rec, channel, &snd_ali_modem); 1684 int err = snd_ali_open(substream, rec, channel, &snd_ali_modem);
1685
1735 if (err) 1686 if (err)
1736 return err; 1687 return err;
1737 return snd_pcm_hw_constraint_list(substream->runtime, 0, 1688 return snd_pcm_hw_constraint_list(substream->runtime, 0,
@@ -1788,7 +1739,8 @@ static void snd_ali_pcm_free(struct snd_pcm *pcm)
1788} 1739}
1789 1740
1790 1741
1791static int __devinit snd_ali_pcm(struct snd_ali * codec, int device, struct ali_pcm_description *desc) 1742static int __devinit snd_ali_pcm(struct snd_ali * codec, int device,
1743 struct ali_pcm_description *desc)
1792{ 1744{
1793 struct snd_pcm *pcm; 1745 struct snd_pcm *pcm;
1794 int err; 1746 int err;
@@ -1802,12 +1754,15 @@ static int __devinit snd_ali_pcm(struct snd_ali * codec, int device, struct ali_
1802 pcm->private_data = codec; 1754 pcm->private_data = codec;
1803 pcm->private_free = snd_ali_pcm_free; 1755 pcm->private_free = snd_ali_pcm_free;
1804 if (desc->playback_ops) 1756 if (desc->playback_ops)
1805 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, desc->playback_ops); 1757 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
1758 desc->playback_ops);
1806 if (desc->capture_ops) 1759 if (desc->capture_ops)
1807 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, desc->capture_ops); 1760 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
1761 desc->capture_ops);
1808 1762
1809 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1763 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1810 snd_dma_pci_data(codec->pci), 64*1024, 128*1024); 1764 snd_dma_pci_data(codec->pci),
1765 64*1024, 128*1024);
1811 1766
1812 pcm->info_flags = 0; 1767 pcm->info_flags = 0;
1813 pcm->dev_class = desc->class; 1768 pcm->dev_class = desc->class;
@@ -1818,16 +1773,29 @@ static int __devinit snd_ali_pcm(struct snd_ali * codec, int device, struct ali_
1818} 1773}
1819 1774
1820static struct ali_pcm_description ali_pcms[] = { 1775static struct ali_pcm_description ali_pcms[] = {
1821 { "ALI 5451", ALI_CHANNELS, 1, &snd_ali_playback_ops, &snd_ali_capture_ops }, 1776 { .name = "ALI 5451",
1822 { "ALI 5451 modem", 1, 1, &snd_ali_modem_playback_ops, &snd_ali_modem_capture_ops, SNDRV_PCM_CLASS_MODEM } 1777 .playback_num = ALI_CHANNELS,
1778 .capture_num = 1,
1779 .playback_ops = &snd_ali_playback_ops,
1780 .capture_ops = &snd_ali_capture_ops
1781 },
1782 { .name = "ALI 5451 modem",
1783 .playback_num = 1,
1784 .capture_num = 1,
1785 .playback_ops = &snd_ali_modem_playback_ops,
1786 .capture_ops = &snd_ali_modem_capture_ops,
1787 .class = SNDRV_PCM_CLASS_MODEM
1788 }
1823}; 1789};
1824 1790
1825static int __devinit snd_ali_build_pcms(struct snd_ali *codec) 1791static int __devinit snd_ali_build_pcms(struct snd_ali *codec)
1826{ 1792{
1827 int i, err; 1793 int i, err;
1828 for(i = 0 ; i < codec->num_of_codecs && i < ARRAY_SIZE(ali_pcms) ; i++) 1794 for (i = 0; i < codec->num_of_codecs && i < ARRAY_SIZE(ali_pcms); i++) {
1829 if((err = snd_ali_pcm(codec, i, &ali_pcms[i])) < 0) 1795 err = snd_ali_pcm(codec, i, &ali_pcms[i]);
1796 if (err < 0)
1830 return err; 1797 return err;
1798 }
1831 return 0; 1799 return 0;
1832} 1800}
1833 1801
@@ -1837,7 +1805,8 @@ static int __devinit snd_ali_build_pcms(struct snd_ali *codec)
1837.info = snd_ali5451_spdif_info, .get = snd_ali5451_spdif_get, \ 1805.info = snd_ali5451_spdif_info, .get = snd_ali5451_spdif_get, \
1838.put = snd_ali5451_spdif_put, .private_value = value} 1806.put = snd_ali5451_spdif_put, .private_value = value}
1839 1807
1840static int snd_ali5451_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1808static int snd_ali5451_spdif_info(struct snd_kcontrol *kcontrol,
1809 struct snd_ctl_elem_info *uinfo)
1841{ 1810{
1842 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 1811 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1843 uinfo->count = 1; 1812 uinfo->count = 1;
@@ -1846,7 +1815,8 @@ static int snd_ali5451_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
1846 return 0; 1815 return 0;
1847} 1816}
1848 1817
1849static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1818static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol,
1819 struct snd_ctl_elem_value *ucontrol)
1850{ 1820{
1851 struct snd_ali *codec = kcontrol->private_data; 1821 struct snd_ali *codec = kcontrol->private_data;
1852 unsigned int enable; 1822 unsigned int enable;
@@ -1854,12 +1824,13 @@ static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
1854 enable = ucontrol->value.integer.value[0] ? 1 : 0; 1824 enable = ucontrol->value.integer.value[0] ? 1 : 0;
1855 1825
1856 spin_lock_irq(&codec->reg_lock); 1826 spin_lock_irq(&codec->reg_lock);
1857 switch(kcontrol->private_value) { 1827 switch (kcontrol->private_value) {
1858 case 0: 1828 case 0:
1859 enable = (codec->spdif_mask & 0x02) ? 1 : 0; 1829 enable = (codec->spdif_mask & 0x02) ? 1 : 0;
1860 break; 1830 break;
1861 case 1: 1831 case 1:
1862 enable = ((codec->spdif_mask & 0x02) && (codec->spdif_mask & 0x04)) ? 1 : 0; 1832 enable = ((codec->spdif_mask & 0x02) &&
1833 (codec->spdif_mask & 0x04)) ? 1 : 0;
1863 break; 1834 break;
1864 case 2: 1835 case 2:
1865 enable = (codec->spdif_mask & 0x01) ? 1 : 0; 1836 enable = (codec->spdif_mask & 0x01) ? 1 : 0;
@@ -1872,7 +1843,8 @@ static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
1872 return 0; 1843 return 0;
1873} 1844}
1874 1845
1875static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1846static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol,
1847 struct snd_ctl_elem_value *ucontrol)
1876{ 1848{
1877 struct snd_ali *codec = kcontrol->private_data; 1849 struct snd_ali *codec = kcontrol->private_data;
1878 unsigned int change = 0, enable = 0; 1850 unsigned int change = 0, enable = 0;
@@ -1939,18 +1911,6 @@ static struct snd_kcontrol_new snd_ali5451_mixer_spdif[] __devinitdata = {
1939 ALI5451_SPDIF(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 0, 2) 1911 ALI5451_SPDIF(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 0, 2)
1940}; 1912};
1941 1913
1942static void snd_ali_mixer_free_ac97_bus(struct snd_ac97_bus *bus)
1943{
1944 struct snd_ali *codec = bus->private_data;
1945 codec->ac97_bus = NULL;
1946}
1947
1948static void snd_ali_mixer_free_ac97(struct snd_ac97 *ac97)
1949{
1950 struct snd_ali *codec = ac97->private_data;
1951 codec->ac97[ac97->num] = NULL;
1952}
1953
1954static int __devinit snd_ali_mixer(struct snd_ali * codec) 1914static int __devinit snd_ali_mixer(struct snd_ali * codec)
1955{ 1915{
1956 struct snd_ac97_template ac97; 1916 struct snd_ac97_template ac97;
@@ -1961,19 +1921,20 @@ static int __devinit snd_ali_mixer(struct snd_ali * codec)
1961 .read = snd_ali_codec_read, 1921 .read = snd_ali_codec_read,
1962 }; 1922 };
1963 1923
1964 if ((err = snd_ac97_bus(codec->card, 0, &ops, codec, &codec->ac97_bus)) < 0) 1924 err = snd_ac97_bus(codec->card, 0, &ops, codec, &codec->ac97_bus);
1925 if (err < 0)
1965 return err; 1926 return err;
1966 codec->ac97_bus->private_free = snd_ali_mixer_free_ac97_bus;
1967 1927
1968 memset(&ac97, 0, sizeof(ac97)); 1928 memset(&ac97, 0, sizeof(ac97));
1969 ac97.private_data = codec; 1929 ac97.private_data = codec;
1970 ac97.private_free = snd_ali_mixer_free_ac97;
1971 1930
1972 for ( i = 0 ; i < codec->num_of_codecs ; i++) { 1931 for (i = 0; i < codec->num_of_codecs; i++) {
1973 ac97.num = i; 1932 ac97.num = i;
1974 if ((err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i])) < 0) { 1933 err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i]);
1975 snd_printk(KERN_ERR "ali mixer %d creating error.\n", i); 1934 if (err < 0) {
1976 if(i == 0) 1935 snd_printk(KERN_ERR
1936 "ali mixer %d creating error.\n", i);
1937 if (i == 0)
1977 return err; 1938 return err;
1978 codec->num_of_codecs = 1; 1939 codec->num_of_codecs = 1;
1979 break; 1940 break;
@@ -1981,9 +1942,11 @@ static int __devinit snd_ali_mixer(struct snd_ali * codec)
1981 } 1942 }
1982 1943
1983 if (codec->spdif_support) { 1944 if (codec->spdif_support) {
1984 for(idx = 0; idx < ARRAY_SIZE(snd_ali5451_mixer_spdif); idx++) { 1945 for (idx = 0; idx < ARRAY_SIZE(snd_ali5451_mixer_spdif); idx++) {
1985 err=snd_ctl_add(codec->card, snd_ctl_new1(&snd_ali5451_mixer_spdif[idx], codec)); 1946 err = snd_ctl_add(codec->card,
1986 if (err < 0) return err; 1947 snd_ctl_new1(&snd_ali5451_mixer_spdif[idx], codec));
1948 if (err < 0)
1949 return err;
1987 } 1950 }
1988 } 1951 }
1989 return 0; 1952 return 0;
@@ -1998,11 +1961,11 @@ static int ali_suspend(struct pci_dev *pci, pm_message_t state)
1998 int i, j; 1961 int i, j;
1999 1962
2000 im = chip->image; 1963 im = chip->image;
2001 if (! im) 1964 if (!im)
2002 return 0; 1965 return 0;
2003 1966
2004 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1967 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
2005 for(i = 0 ; i < chip->num_of_codecs ; i++) { 1968 for (i = 0; i < chip->num_of_codecs; i++) {
2006 snd_pcm_suspend_all(chip->pcm[i]); 1969 snd_pcm_suspend_all(chip->pcm[i]);
2007 snd_ac97_suspend(chip->ac97[i]); 1970 snd_ac97_suspend(chip->ac97[i]);
2008 } 1971 }
@@ -2010,10 +1973,10 @@ static int ali_suspend(struct pci_dev *pci, pm_message_t state)
2010 spin_lock_irq(&chip->reg_lock); 1973 spin_lock_irq(&chip->reg_lock);
2011 1974
2012 im->regs[ALI_MISCINT >> 2] = inl(ALI_REG(chip, ALI_MISCINT)); 1975 im->regs[ALI_MISCINT >> 2] = inl(ALI_REG(chip, ALI_MISCINT));
2013 // im->regs[ALI_START >> 2] = inl(ALI_REG(chip, ALI_START)); 1976 /* im->regs[ALI_START >> 2] = inl(ALI_REG(chip, ALI_START)); */
2014 im->regs[ALI_STOP >> 2] = inl(ALI_REG(chip, ALI_STOP)); 1977 im->regs[ALI_STOP >> 2] = inl(ALI_REG(chip, ALI_STOP));
2015 1978
2016 // disable all IRQ bits 1979 /* disable all IRQ bits */
2017 outl(0, ALI_REG(chip, ALI_MISCINT)); 1980 outl(0, ALI_REG(chip, ALI_MISCINT));
2018 1981
2019 for (i = 0; i < ALI_GLOBAL_REGS; i++) { 1982 for (i = 0; i < ALI_GLOBAL_REGS; i++) {
@@ -2028,7 +1991,7 @@ static int ali_suspend(struct pci_dev *pci, pm_message_t state)
2028 im->channel_regs[i][j] = inl(ALI_REG(chip, j*4 + 0xe0)); 1991 im->channel_regs[i][j] = inl(ALI_REG(chip, j*4 + 0xe0));
2029 } 1992 }
2030 1993
2031 // stop all HW channel 1994 /* stop all HW channel */
2032 outl(0xffffffff, ALI_REG(chip, ALI_STOP)); 1995 outl(0xffffffff, ALI_REG(chip, ALI_STOP));
2033 1996
2034 spin_unlock_irq(&chip->reg_lock); 1997 spin_unlock_irq(&chip->reg_lock);
@@ -2047,7 +2010,7 @@ static int ali_resume(struct pci_dev *pci)
2047 int i, j; 2010 int i, j;
2048 2011
2049 im = chip->image; 2012 im = chip->image;
2050 if (! im) 2013 if (!im)
2051 return 0; 2014 return 0;
2052 2015
2053 pci_set_power_state(pci, PCI_D0); 2016 pci_set_power_state(pci, PCI_D0);
@@ -2069,19 +2032,20 @@ static int ali_resume(struct pci_dev *pci)
2069 } 2032 }
2070 2033
2071 for (i = 0; i < ALI_GLOBAL_REGS; i++) { 2034 for (i = 0; i < ALI_GLOBAL_REGS; i++) {
2072 if ((i*4 == ALI_MISCINT) || (i*4 == ALI_STOP) || (i*4 == ALI_START)) 2035 if ((i*4 == ALI_MISCINT) || (i*4 == ALI_STOP) ||
2036 (i*4 == ALI_START))
2073 continue; 2037 continue;
2074 outl(im->regs[i], ALI_REG(chip, i*4)); 2038 outl(im->regs[i], ALI_REG(chip, i*4));
2075 } 2039 }
2076 2040
2077 // start HW channel 2041 /* start HW channel */
2078 outl(im->regs[ALI_START >> 2], ALI_REG(chip, ALI_START)); 2042 outl(im->regs[ALI_START >> 2], ALI_REG(chip, ALI_START));
2079 // restore IRQ enable bits 2043 /* restore IRQ enable bits */
2080 outl(im->regs[ALI_MISCINT >> 2], ALI_REG(chip, ALI_MISCINT)); 2044 outl(im->regs[ALI_MISCINT >> 2], ALI_REG(chip, ALI_MISCINT));
2081 2045
2082 spin_unlock_irq(&chip->reg_lock); 2046 spin_unlock_irq(&chip->reg_lock);
2083 2047
2084 for(i = 0 ; i < chip->num_of_codecs ; i++) 2048 for (i = 0 ; i < chip->num_of_codecs; i++)
2085 snd_ac97_resume(chip->ac97[i]); 2049 snd_ac97_resume(chip->ac97[i]);
2086 2050
2087 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 2051 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
@@ -2113,7 +2077,7 @@ static int snd_ali_chip_init(struct snd_ali *codec)
2113{ 2077{
2114 unsigned int legacy; 2078 unsigned int legacy;
2115 unsigned char temp; 2079 unsigned char temp;
2116 struct pci_dev *pci_dev = NULL; 2080 struct pci_dev *pci_dev;
2117 2081
2118 snd_ali_printk("chip initializing ... \n"); 2082 snd_ali_printk("chip initializing ... \n");
2119 2083
@@ -2146,7 +2110,8 @@ static int snd_ali_chip_init(struct snd_ali *codec)
2146 outb(0x10, ALI_REG(codec, ALI_MPUR2)); 2110 outb(0x10, ALI_REG(codec, ALI_MPUR2));
2147 2111
2148 codec->ac97_ext_id = snd_ali_codec_peek(codec, 0, AC97_EXTENDED_ID); 2112 codec->ac97_ext_id = snd_ali_codec_peek(codec, 0, AC97_EXTENDED_ID);
2149 codec->ac97_ext_status = snd_ali_codec_peek(codec, 0, AC97_EXTENDED_STATUS); 2113 codec->ac97_ext_status = snd_ali_codec_peek(codec, 0,
2114 AC97_EXTENDED_STATUS);
2150 if (codec->spdif_support) { 2115 if (codec->spdif_support) {
2151 snd_ali_enable_spdif_out(codec); 2116 snd_ali_enable_spdif_out(codec);
2152 codec->spdif_mask = 0x00000002; 2117 codec->spdif_mask = 0x00000002;
@@ -2158,8 +2123,9 @@ static int snd_ali_chip_init(struct snd_ali *codec)
2158 if (inl(ALI_REG(codec, ALI_SCTRL)) & ALI_SCTRL_CODEC2_READY) { 2123 if (inl(ALI_REG(codec, ALI_SCTRL)) & ALI_SCTRL_CODEC2_READY) {
2159 codec->num_of_codecs++; 2124 codec->num_of_codecs++;
2160 outl(inl(ALI_REG(codec, ALI_SCTRL)) | 2125 outl(inl(ALI_REG(codec, ALI_SCTRL)) |
2161 (ALI_SCTRL_LINE_IN2|ALI_SCTRL_GPIO_IN2|ALI_SCTRL_LINE_OUT_EN), 2126 (ALI_SCTRL_LINE_IN2 | ALI_SCTRL_GPIO_IN2 |
2162 ALI_REG(codec, ALI_SCTRL)); 2127 ALI_SCTRL_LINE_OUT_EN),
2128 ALI_REG(codec, ALI_SCTRL));
2163 } 2129 }
2164 2130
2165 snd_ali_printk("chip initialize succeed.\n"); 2131 snd_ali_printk("chip initialize succeed.\n");
@@ -2168,18 +2134,19 @@ static int snd_ali_chip_init(struct snd_ali *codec)
2168} 2134}
2169 2135
2170/* proc for register dump */ 2136/* proc for register dump */
2171static void snd_ali_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buf) 2137static void snd_ali_proc_read(struct snd_info_entry *entry,
2138 struct snd_info_buffer *buf)
2172{ 2139{
2173 struct snd_ali *codec = entry->private_data; 2140 struct snd_ali *codec = entry->private_data;
2174 int i; 2141 int i;
2175 for(i = 0 ; i < 256 ; i+= 4) 2142 for (i = 0; i < 256 ; i+= 4)
2176 snd_iprintf(buf, "%02x: %08x\n", i, inl(ALI_REG(codec, i))); 2143 snd_iprintf(buf, "%02x: %08x\n", i, inl(ALI_REG(codec, i)));
2177} 2144}
2178 2145
2179static void __devinit snd_ali_proc_init(struct snd_ali *codec) 2146static void __devinit snd_ali_proc_init(struct snd_ali *codec)
2180{ 2147{
2181 struct snd_info_entry *entry; 2148 struct snd_info_entry *entry;
2182 if(!snd_card_proc_new(codec->card, "ali5451", &entry)) 2149 if (!snd_card_proc_new(codec->card, "ali5451", &entry))
2183 snd_info_set_text_ops(entry, codec, snd_ali_proc_read); 2150 snd_info_set_text_ops(entry, codec, snd_ali_proc_read);
2184} 2151}
2185 2152
@@ -2188,7 +2155,8 @@ static int __devinit snd_ali_resources(struct snd_ali *codec)
2188 int err; 2155 int err;
2189 2156
2190 snd_ali_printk("resouces allocation ...\n"); 2157 snd_ali_printk("resouces allocation ...\n");
2191 if ((err = pci_request_regions(codec->pci, "ALI 5451")) < 0) 2158 err = pci_request_regions(codec->pci, "ALI 5451");
2159 if (err < 0)
2192 return err; 2160 return err;
2193 codec->port = pci_resource_start(codec->pci, 0); 2161 codec->port = pci_resource_start(codec->pci, 0);
2194 2162
@@ -2201,9 +2169,9 @@ static int __devinit snd_ali_resources(struct snd_ali *codec)
2201 snd_ali_printk("resouces allocated.\n"); 2169 snd_ali_printk("resouces allocated.\n");
2202 return 0; 2170 return 0;
2203} 2171}
2204static int snd_ali_dev_free(struct snd_device *device) 2172static int snd_ali_dev_free(struct snd_device *device)
2205{ 2173{
2206 struct snd_ali *codec=device->device_data; 2174 struct snd_ali *codec = device->device_data;
2207 snd_ali_free(codec); 2175 snd_ali_free(codec);
2208 return 0; 2176 return 0;
2209} 2177}
@@ -2226,17 +2194,20 @@ static int __devinit snd_ali_create(struct snd_card *card,
2226 snd_ali_printk("creating ...\n"); 2194 snd_ali_printk("creating ...\n");
2227 2195
2228 /* enable PCI device */ 2196 /* enable PCI device */
2229 if ((err = pci_enable_device(pci)) < 0) 2197 err = pci_enable_device(pci);
2198 if (err < 0)
2230 return err; 2199 return err;
2231 /* check, if we can restrict PCI DMA transfers to 31 bits */ 2200 /* check, if we can restrict PCI DMA transfers to 31 bits */
2232 if (pci_set_dma_mask(pci, DMA_31BIT_MASK) < 0 || 2201 if (pci_set_dma_mask(pci, DMA_31BIT_MASK) < 0 ||
2233 pci_set_consistent_dma_mask(pci, DMA_31BIT_MASK) < 0) { 2202 pci_set_consistent_dma_mask(pci, DMA_31BIT_MASK) < 0) {
2234 snd_printk(KERN_ERR "architecture does not support 31bit PCI busmaster DMA\n"); 2203 snd_printk(KERN_ERR "architecture does not support "
2204 "31bit PCI busmaster DMA\n");
2235 pci_disable_device(pci); 2205 pci_disable_device(pci);
2236 return -ENXIO; 2206 return -ENXIO;
2237 } 2207 }
2238 2208
2239 if ((codec = kzalloc(sizeof(*codec), GFP_KERNEL)) == NULL) { 2209 codec = kzalloc(sizeof(*codec), GFP_KERNEL);
2210 if (!codec) {
2240 pci_disable_device(pci); 2211 pci_disable_device(pci);
2241 return -ENOMEM; 2212 return -ENOMEM;
2242 } 2213 }
@@ -2293,21 +2264,22 @@ static int __devinit snd_ali_create(struct snd_card *card,
2293 2264
2294 /* M1533: southbridge */ 2265 /* M1533: southbridge */
2295 codec->pci_m1533 = pci_get_device(0x10b9, 0x1533, NULL); 2266 codec->pci_m1533 = pci_get_device(0x10b9, 0x1533, NULL);
2296 if (! codec->pci_m1533) { 2267 if (!codec->pci_m1533) {
2297 snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n"); 2268 snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n");
2298 snd_ali_free(codec); 2269 snd_ali_free(codec);
2299 return -ENODEV; 2270 return -ENODEV;
2300 } 2271 }
2301 /* M7101: power management */ 2272 /* M7101: power management */
2302 codec->pci_m7101 = pci_get_device(0x10b9, 0x7101, NULL); 2273 codec->pci_m7101 = pci_get_device(0x10b9, 0x7101, NULL);
2303 if (! codec->pci_m7101 && codec->revision == ALI_5451_V02) { 2274 if (!codec->pci_m7101 && codec->revision == ALI_5451_V02) {
2304 snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n"); 2275 snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n");
2305 snd_ali_free(codec); 2276 snd_ali_free(codec);
2306 return -ENODEV; 2277 return -ENODEV;
2307 } 2278 }
2308 2279
2309 snd_ali_printk("snd_device_new is called.\n"); 2280 snd_ali_printk("snd_device_new is called.\n");
2310 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, codec, &ops)) < 0) { 2281 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, codec, &ops);
2282 if (err < 0) {
2311 snd_ali_free(codec); 2283 snd_ali_free(codec);
2312 return err; 2284 return err;
2313 } 2285 }
@@ -2315,18 +2287,18 @@ static int __devinit snd_ali_create(struct snd_card *card,
2315 snd_card_set_dev(card, &pci->dev); 2287 snd_card_set_dev(card, &pci->dev);
2316 2288
2317 /* initialise synth voices*/ 2289 /* initialise synth voices*/
2318 for (i = 0; i < ALI_CHANNELS; i++ ) { 2290 for (i = 0; i < ALI_CHANNELS; i++)
2319 codec->synth.voices[i].number = i; 2291 codec->synth.voices[i].number = i;
2320 }
2321 2292
2322 if ((err = snd_ali_chip_init(codec)) < 0) { 2293 err = snd_ali_chip_init(codec);
2294 if (err < 0) {
2323 snd_printk(KERN_ERR "ali create: chip init error.\n"); 2295 snd_printk(KERN_ERR "ali create: chip init error.\n");
2324 return err; 2296 return err;
2325 } 2297 }
2326 2298
2327#ifdef CONFIG_PM 2299#ifdef CONFIG_PM
2328 codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL); 2300 codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL);
2329 if (! codec->image) 2301 if (!codec->image)
2330 snd_printk(KERN_WARNING "can't allocate apm buffer\n"); 2302 snd_printk(KERN_WARNING "can't allocate apm buffer\n");
2331#endif 2303#endif
2332 2304
@@ -2348,26 +2320,23 @@ static int __devinit snd_ali_probe(struct pci_dev *pci,
2348 snd_ali_printk("probe ...\n"); 2320 snd_ali_printk("probe ...\n");
2349 2321
2350 card = snd_card_new(index, id, THIS_MODULE, 0); 2322 card = snd_card_new(index, id, THIS_MODULE, 0);
2351 if (card == NULL) 2323 if (!card)
2352 return -ENOMEM; 2324 return -ENOMEM;
2353 2325
2354 if ((err = snd_ali_create(card, pci, pcm_channels, spdif, &codec)) < 0) { 2326 err = snd_ali_create(card, pci, pcm_channels, spdif, &codec);
2355 snd_card_free(card); 2327 if (err < 0)
2356 return err; 2328 goto error;
2357 }
2358 card->private_data = codec; 2329 card->private_data = codec;
2359 2330
2360 snd_ali_printk("mixer building ...\n"); 2331 snd_ali_printk("mixer building ...\n");
2361 if ((err = snd_ali_mixer(codec)) < 0) { 2332 err = snd_ali_mixer(codec);
2362 snd_card_free(card); 2333 if (err < 0)
2363 return err; 2334 goto error;
2364 }
2365 2335
2366 snd_ali_printk("pcm building ...\n"); 2336 snd_ali_printk("pcm building ...\n");
2367 if ((err = snd_ali_build_pcms(codec)) < 0) { 2337 err = snd_ali_build_pcms(codec);
2368 snd_card_free(card); 2338 if (err < 0)
2369 return err; 2339 goto error;
2370 }
2371 2340
2372 snd_ali_proc_init(codec); 2341 snd_ali_proc_init(codec);
2373 2342
@@ -2378,12 +2347,16 @@ static int __devinit snd_ali_probe(struct pci_dev *pci,
2378 card->shortname, codec->port, codec->irq); 2347 card->shortname, codec->port, codec->irq);
2379 2348
2380 snd_ali_printk("register card.\n"); 2349 snd_ali_printk("register card.\n");
2381 if ((err = snd_card_register(card)) < 0) { 2350 err = snd_card_register(card);
2382 snd_card_free(card); 2351 if (err < 0)
2383 return err; 2352 goto error;
2384 } 2353
2385 pci_set_drvdata(pci, card); 2354 pci_set_drvdata(pci, card);
2386 return 0; 2355 return 0;
2356
2357 error:
2358 snd_card_free(card);
2359 return err;
2387} 2360}
2388 2361
2389static void __devexit snd_ali_remove(struct pci_dev *pci) 2362static void __devexit snd_ali_remove(struct pci_dev *pci)
diff --git a/sound/pci/au88x0/au88x0_sb.h b/sound/pci/au88x0/au88x0_sb.h
deleted file mode 100644
index 5a4d8fc2bbfc..000000000000
--- a/sound/pci/au88x0/au88x0_sb.h
+++ /dev/null
@@ -1,40 +0,0 @@
1/***************************************************************************
2 * au88x0_sb.h
3 *
4 * Wed Oct 29 22:10:42 2003
5 *
6 ****************************************************************************/
7
8#ifdef CHIP_AU8820
9/* AU8820 starting @ 64KiB offset */
10#define SBEMU_BASE 0x10000
11#else
12/* AU8810? and AU8830 starting @ 164KiB offset */
13#define SBEMU_BASE 0x29000
14#endif
15
16#define FM_A_STATUS (SBEMU_BASE + 0x00) /* read */
17#define FM_A_ADDRESS (SBEMU_BASE + 0x00) /* write */
18#define FM_A_DATA (SBEMU_BASE + 0x04)
19#define FM_B_STATUS (SBEMU_BASE + 0x08)
20#define FM_B_ADDRESS (SBEMU_BASE + 0x08)
21#define FM_B_DATA (SBEMU_BASE + 0x0C)
22#define SB_MIXER_ADDR (SBEMU_BASE + 0x10)
23#define SB_MIXER_DATA (SBEMU_BASE + 0x14)
24#define SB_RESET (SBEMU_BASE + 0x18)
25#define SB_RESET_ALIAS (SBEMU_BASE + 0x1C)
26#define FM_STATUS2 (SBEMU_BASE + 0x20)
27#define FM_ADDR2 (SBEMU_BASE + 0x20)
28#define FM_DATA2 (SBEMU_BASE + 0x24)
29#define SB_DSP_READ (SBEMU_BASE + 0x28)
30#define SB_DSP_WRITE (SBEMU_BASE + 0x30)
31#define SB_DSP_WRITE_STATUS (SBEMU_BASE + 0x30) /* bit 7 */
32#define SB_DSP_READ_STATUS (SBEMU_BASE + 0x38) /* bit 7 */
33#define SB_LACR (SBEMU_BASE + 0x40) /* ? */
34#define SB_LADCR (SBEMU_BASE + 0x44) /* ? */
35#define SB_LAMR (SBEMU_BASE + 0x48) /* ? */
36#define SB_LARR (SBEMU_BASE + 0x4C) /* ? */
37#define SB_VERSION (SBEMU_BASE + 0x50)
38#define SB_CTRLSTAT (SBEMU_BASE + 0x54)
39#define SB_TIMERSTAT (SBEMU_BASE + 0x58)
40#define FM_RAM (SBEMU_BASE + 0x100) /* 0x40 ULONG */
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index 43edd2839b5a..36d3666a5b77 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * azt3328.c - driver for Aztech AZF3328 based soundcards (e.g. PCI168). 2 * azt3328.c - driver for Aztech AZF3328 based soundcards (e.g. PCI168).
3 * Copyright (C) 2002, 2005 by Andreas Mohr <andi AT lisas.de> 3 * Copyright (C) 2002, 2005, 2006, 2007 by Andreas Mohr <andi AT lisas.de>
4 * 4 *
5 * Framework borrowed from Bart Hartgers's als4000.c. 5 * Framework borrowed from Bart Hartgers's als4000.c.
6 * Driver developed on PCI168 AP(W) version (PCI rev. 10, subsystem ID 1801), 6 * Driver developed on PCI168 AP(W) version (PCI rev. 10, subsystem ID 1801),
@@ -52,6 +52,9 @@
52 * - full duplex 16bit playback/record at independent sampling rate 52 * - full duplex 16bit playback/record at independent sampling rate
53 * - MPU401 (+ legacy address support) FIXME: how to enable legacy addr?? 53 * - MPU401 (+ legacy address support) FIXME: how to enable legacy addr??
54 * - game port (legacy address support) 54 * - game port (legacy address support)
55 * - builtin 3D enhancement (said to be YAMAHA Ymersion)
56 * - builtin DirectInput support, helps reduce CPU overhead (interrupt-driven
57 * features supported)
55 * - built-in General DirectX timer having a 20 bits counter 58 * - built-in General DirectX timer having a 20 bits counter
56 * with 1us resolution (see below!) 59 * with 1us resolution (see below!)
57 * - I2S serial port for external DAC 60 * - I2S serial port for external DAC
@@ -94,6 +97,10 @@
94 * 97 *
95 * BUGS 98 * BUGS
96 * - full-duplex might *still* be problematic, not fully tested recently 99 * - full-duplex might *still* be problematic, not fully tested recently
100 * - (non-bug) "Bass/Treble or 3D settings don't work" - they do get evaluated
101 * if you set PCM output switch to "pre 3D" instead of "post 3D".
102 * If this can't be set, then get a mixer application that Isn't Stupid (tm)
103 * (e.g. kmix, gamix) - unfortunately several are!!
97 * 104 *
98 * TODO 105 * TODO
99 * - test MPU401 MIDI playback etc. 106 * - test MPU401 MIDI playback etc.
@@ -622,7 +629,7 @@ snd_azf3328_put_mixer_enum(struct snd_kcontrol *kcontrol,
622 return (nreg != oreg); 629 return (nreg != oreg);
623} 630}
624 631
625static const struct snd_kcontrol_new snd_azf3328_mixer_controls[] __devinitdata = { 632static struct snd_kcontrol_new snd_azf3328_mixer_controls[] __devinitdata = {
626 AZF3328_MIXER_SWITCH("Master Playback Switch", IDX_MIXER_PLAY_MASTER, 15, 1), 633 AZF3328_MIXER_SWITCH("Master Playback Switch", IDX_MIXER_PLAY_MASTER, 15, 1),
627 AZF3328_MIXER_VOL_STEREO("Master Playback Volume", IDX_MIXER_PLAY_MASTER, 0x1f, 1), 634 AZF3328_MIXER_VOL_STEREO("Master Playback Volume", IDX_MIXER_PLAY_MASTER, 0x1f, 1),
628 AZF3328_MIXER_SWITCH("Wave Playback Switch", IDX_MIXER_WAVEOUT, 15, 1), 635 AZF3328_MIXER_SWITCH("Wave Playback Switch", IDX_MIXER_WAVEOUT, 15, 1),
@@ -652,7 +659,7 @@ static const struct snd_kcontrol_new snd_azf3328_mixer_controls[] __devinitdata
652 AZF3328_MIXER_VOL_MONO("Modem Capture Volume", IDX_MIXER_MODEMIN, 0x1f, 1), 659 AZF3328_MIXER_VOL_MONO("Modem Capture Volume", IDX_MIXER_MODEMIN, 0x1f, 1),
653 AZF3328_MIXER_ENUM("Mic Select", IDX_MIXER_ADVCTL2, 2, 8), 660 AZF3328_MIXER_ENUM("Mic Select", IDX_MIXER_ADVCTL2, 2, 8),
654 AZF3328_MIXER_ENUM("Mono Output Select", IDX_MIXER_ADVCTL2, 2, 9), 661 AZF3328_MIXER_ENUM("Mono Output Select", IDX_MIXER_ADVCTL2, 2, 9),
655 AZF3328_MIXER_ENUM("PCM", IDX_MIXER_ADVCTL2, 2, 15), /* PCM Out Path, place in front since it controls *both* 3D and Bass/Treble! */ 662 AZF3328_MIXER_ENUM("PCM Output Route", IDX_MIXER_ADVCTL2, 2, 15), /* PCM Out Path, place in front since it controls *both* 3D and Bass/Treble! */
656 AZF3328_MIXER_VOL_SPECIAL("Tone Control - Treble", IDX_MIXER_BASSTREBLE, 0x07, 1, 0), 663 AZF3328_MIXER_VOL_SPECIAL("Tone Control - Treble", IDX_MIXER_BASSTREBLE, 0x07, 1, 0),
657 AZF3328_MIXER_VOL_SPECIAL("Tone Control - Bass", IDX_MIXER_BASSTREBLE, 0x07, 9, 0), 664 AZF3328_MIXER_VOL_SPECIAL("Tone Control - Bass", IDX_MIXER_BASSTREBLE, 0x07, 9, 0),
658 AZF3328_MIXER_SWITCH("3D Control - Switch", IDX_MIXER_ADVCTL2, 13, 0), 665 AZF3328_MIXER_SWITCH("3D Control - Switch", IDX_MIXER_ADVCTL2, 13, 0),
@@ -678,7 +685,7 @@ static const struct snd_kcontrol_new snd_azf3328_mixer_controls[] __devinitdata
678#endif 685#endif
679}; 686};
680 687
681static const u16 __devinitdata snd_azf3328_init_values[][2] = { 688static u16 __devinitdata snd_azf3328_init_values[][2] = {
682 { IDX_MIXER_PLAY_MASTER, MIXER_MUTE_MASK|0x1f1f }, 689 { IDX_MIXER_PLAY_MASTER, MIXER_MUTE_MASK|0x1f1f },
683 { IDX_MIXER_MODEMOUT, MIXER_MUTE_MASK|0x1f1f }, 690 { IDX_MIXER_MODEMOUT, MIXER_MUTE_MASK|0x1f1f },
684 { IDX_MIXER_BASSTREBLE, 0x0000 }, 691 { IDX_MIXER_BASSTREBLE, 0x0000 },
@@ -1369,7 +1376,6 @@ snd_azf3328_playback_close(struct snd_pcm_substream *substream)
1369 struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); 1376 struct snd_azf3328 *chip = snd_pcm_substream_chip(substream);
1370 1377
1371 snd_azf3328_dbgcallenter(); 1378 snd_azf3328_dbgcallenter();
1372
1373 chip->playback_substream = NULL; 1379 chip->playback_substream = NULL;
1374 snd_azf3328_dbgcallleave(); 1380 snd_azf3328_dbgcallleave();
1375 return 0; 1381 return 0;
@@ -1660,10 +1666,10 @@ snd_azf3328_test_bit(unsigned int reg, int bit)
1660} 1666}
1661#endif 1667#endif
1662 1668
1669#if DEBUG_MISC
1663static void 1670static void
1664snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip) 1671snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip)
1665{ 1672{
1666#if DEBUG_MISC
1667 u16 tmp; 1673 u16 tmp;
1668 1674
1669 snd_azf3328_dbgmisc("codec_port 0x%lx, io2_port 0x%lx, mpu_port 0x%lx, synth_port 0x%lx, mixer_port 0x%lx, irq %d\n", chip->codec_port, chip->io2_port, chip->mpu_port, chip->synth_port, chip->mixer_port, chip->irq); 1675 snd_azf3328_dbgmisc("codec_port 0x%lx, io2_port 0x%lx, mpu_port 0x%lx, synth_port 0x%lx, mixer_port 0x%lx, irq %d\n", chip->codec_port, chip->io2_port, chip->mpu_port, chip->synth_port, chip->mixer_port, chip->irq);
@@ -1673,10 +1679,16 @@ snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip)
1673 for (tmp=0; tmp <= 0x01; tmp += 1) 1679 for (tmp=0; tmp <= 0x01; tmp += 1)
1674 snd_azf3328_dbgmisc("0x%02x: opl 0x%04x, mpu300 0x%04x, mpu310 0x%04x, mpu320 0x%04x, mpu330 0x%04x\n", tmp, inb(0x388 + tmp), inb(0x300 + tmp), inb(0x310 + tmp), inb(0x320 + tmp), inb(0x330 + tmp)); 1680 snd_azf3328_dbgmisc("0x%02x: opl 0x%04x, mpu300 0x%04x, mpu310 0x%04x, mpu320 0x%04x, mpu330 0x%04x\n", tmp, inb(0x388 + tmp), inb(0x300 + tmp), inb(0x310 + tmp), inb(0x320 + tmp), inb(0x330 + tmp));
1675 1681
1676 for (tmp = 0; tmp <= 0x6E; tmp += 2) 1682 for (tmp = 0; tmp < AZF_IO_SIZE_CODEC; tmp += 2)
1677 snd_azf3328_dbgmisc("0x%02x: 0x%04x\n", tmp, snd_azf3328_codec_inb(chip, tmp)); 1683 snd_azf3328_dbgmisc("codec 0x%02x: 0x%04x\n", tmp, snd_azf3328_codec_inw(chip, tmp));
1678#endif 1684
1685 for (tmp = 0; tmp < AZF_IO_SIZE_MIXER; tmp += 2)
1686 snd_azf3328_dbgmisc("mixer 0x%02x: 0x%04x\n", tmp, snd_azf3328_mixer_inw(chip, tmp));
1679} 1687}
1688#else
1689static inline void
1690snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip) {}
1691#endif
1680 1692
1681static int __devinit 1693static int __devinit
1682snd_azf3328_create(struct snd_card *card, 1694snd_azf3328_create(struct snd_card *card,
@@ -1842,8 +1854,8 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
1842 1854
1843#ifdef MODULE 1855#ifdef MODULE
1844 printk( 1856 printk(
1845"azt3328: Sound driver for Aztech AZF3328-based soundcards such as PCI168\n" 1857"azt3328: Sound driver for Aztech AZF3328-based soundcards such as PCI168.\n"
1846"azt3328: (hardware was completely undocumented - ZERO support from Aztech).\n" 1858"azt3328: Hardware was completely undocumented, unfortunately.\n"
1847"azt3328: Feel free to contact andi AT lisas.de for bug reports etc.!\n" 1859"azt3328: Feel free to contact andi AT lisas.de for bug reports etc.!\n"
1848"azt3328: User-scalable sequencer timer set to %dHz (1024000Hz / %d).\n", 1860"azt3328: User-scalable sequencer timer set to %dHz (1024000Hz / %d).\n",
1849 1024000 / seqtimer_scaling, seqtimer_scaling); 1861 1024000 / seqtimer_scaling, seqtimer_scaling);
diff --git a/sound/pci/azt3328.h b/sound/pci/azt3328.h
index b4f3e3cd006b..679fa992e2bc 100644
--- a/sound/pci/azt3328.h
+++ b/sound/pci/azt3328.h
@@ -106,8 +106,8 @@
106 #define IRQ_RECORDING 0x0002 106 #define IRQ_RECORDING 0x0002
107 #define IRQ_MPU401 0x0010 107 #define IRQ_MPU401 0x0010
108 #define IRQ_TIMER 0x0020 /* DirectX timer */ 108 #define IRQ_TIMER 0x0020 /* DirectX timer */
109 #define IRQ_UNKNOWN1 0x0040 /* probably unused */ 109 #define IRQ_UNKNOWN1 0x0040 /* probably unused, or possibly I2S port? or gameport IRQ? */
110 #define IRQ_UNKNOWN2 0x0080 /* probably unused */ 110 #define IRQ_UNKNOWN2 0x0080 /* probably unused, or possibly I2S port? or gameport IRQ? */
111#define IDX_IO_66H 0x66 /* writing 0xffff returns 0x0000 */ 111#define IDX_IO_66H 0x66 /* writing 0xffff returns 0x0000 */
112#define IDX_IO_SOME_VALUE 0x68 /* this is set to e.g. 0x3ff or 0x300, and writable; maybe some buffer limit, but I couldn't find out more, PU:0x00ff */ 112#define IDX_IO_SOME_VALUE 0x68 /* this is set to e.g. 0x3ff or 0x300, and writable; maybe some buffer limit, but I couldn't find out more, PU:0x00ff */
113#define IDX_IO_6AH 0x6A /* this WORD can be set to have bits 0x0028 activated (FIXME: correct??); actually inhibits PCM playback!!! maybe power management?? */ 113#define IDX_IO_6AH 0x6A /* this WORD can be set to have bits 0x0028 activated (FIXME: correct??); actually inhibits PCM playback!!! maybe power management?? */
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index e9b029e1cd6d..6523ba07db96 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -781,6 +781,8 @@ static struct pci_device_id snd_bt87x_ids[] = {
781 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, 0x0070, 0x13eb, 32000), 781 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, 0x0070, 0x13eb, 32000),
782 /* Viewcast Osprey 200 */ 782 /* Viewcast Osprey 200 */
783 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0xff01, 44100), 783 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0xff01, 44100),
784 /* ATI TV-Wonder */
785 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x1002, 0x0001, 32000),
784 /* Leadtek Winfast tv 2000xp delux */ 786 /* Leadtek Winfast tv 2000xp delux */
785 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x107d, 0x6606, 32000), 787 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x107d, 0x6606, 32000),
786 /* Voodoo TV 200 */ 788 /* Voodoo TV 200 */
@@ -833,7 +835,7 @@ static int __devinit snd_bt87x_detect_card(struct pci_dev *pci)
833 pci->device, pci->subsystem_vendor, pci->subsystem_device); 835 pci->device, pci->subsystem_vendor, pci->subsystem_device);
834 snd_printk(KERN_DEBUG "please mail id, board name, and, " 836 snd_printk(KERN_DEBUG "please mail id, board name, and, "
835 "if it works, the correct digital_rate option to " 837 "if it works, the correct digital_rate option to "
836 "<alsa-devel@lists.sf.net>\n"); 838 "<alsa-devel@alsa-project.org>\n");
837 return 32000; /* default rate */ 839 return 32000; /* default rate */
838} 840}
839 841
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index ea6712b63c9f..48f3f17c5170 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -775,7 +775,6 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream,
775 struct snd_ca0106_pcm *epcm; 775 struct snd_ca0106_pcm *epcm;
776 int channel; 776 int channel;
777 int result = 0; 777 int result = 0;
778 struct list_head *pos;
779 struct snd_pcm_substream *s; 778 struct snd_pcm_substream *s;
780 u32 basic = 0; 779 u32 basic = 0;
781 u32 extended = 0; 780 u32 extended = 0;
@@ -790,8 +789,7 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream,
790 running=0; 789 running=0;
791 break; 790 break;
792 } 791 }
793 snd_pcm_group_for_each(pos, substream) { 792 snd_pcm_group_for_each_entry(s, substream) {
794 s = snd_pcm_group_substream_entry(pos);
795 runtime = s->runtime; 793 runtime = s->runtime;
796 epcm = runtime->private_data; 794 epcm = runtime->private_data;
797 channel = epcm->channel_id; 795 channel = epcm->channel_id;
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 2ae539b195fd..bef1f6d1859c 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -3107,7 +3107,7 @@ static int snd_cs46xx_chip_init(struct snd_cs46xx *chip)
3107 snd_printk(KERN_ERR "ERROR: snd-cs46xx: never read ISV3 & ISV4 from AC'97\n"); 3107 snd_printk(KERN_ERR "ERROR: snd-cs46xx: never read ISV3 & ISV4 from AC'97\n");
3108 snd_printk(KERN_ERR " Try reloading the ALSA driver, if you find something\n"); 3108 snd_printk(KERN_ERR " Try reloading the ALSA driver, if you find something\n");
3109 snd_printk(KERN_ERR " broken or not working on your soundcard upon\n"); 3109 snd_printk(KERN_ERR " broken or not working on your soundcard upon\n");
3110 snd_printk(KERN_ERR " this message please report to alsa-devel@lists.sourceforge.net\n"); 3110 snd_printk(KERN_ERR " this message please report to alsa-devel@alsa-project.org\n");
3111 3111
3112 return -EIO; 3112 return -EIO;
3113#endif 3113#endif
diff --git a/sound/pci/cs46xx/imgs/cwcemb80.h b/sound/pci/cs46xx/imgs/cwcemb80.h
deleted file mode 100644
index a64c6ff9983a..000000000000
--- a/sound/pci/cs46xx/imgs/cwcemb80.h
+++ /dev/null
@@ -1,1607 +0,0 @@
1/* generated from cwcemb80.osp DO NOT MODIFY */
2
3#ifndef __HEADER_cwcemb80_H__
4#define __HEADER_cwcemb80_H__
5
6static struct dsp_symbol_entry cwcemb80_symbols[] = {
7 { 0x0000, "BEGINADDRESS",0x00 },
8 { 0x8000, "EXECCHILD",0x03 },
9 { 0x8001, "EXECCHILD_98",0x03 },
10 { 0x8003, "EXECCHILD_PUSH1IND",0x03 },
11 { 0x8008, "EXECSIBLING",0x03 },
12 { 0x800a, "EXECSIBLING_298",0x03 },
13 { 0x800b, "EXECSIBLING_2IND1",0x03 },
14 { 0x8010, "TIMINGMASTER",0x03 },
15 { 0x804f, "S16_CODECINPUTTASK",0x03 },
16 { 0x805e, "PCMSERIALINPUTTASK",0x03 },
17 { 0x806d, "S16_MIX_TO_OSTREAM",0x03 },
18 { 0x809a, "S16_MIX",0x03 },
19 { 0x80bb, "S16_UPSRC",0x03 },
20 { 0x813b, "MIX3_EXP",0x03 },
21 { 0x8164, "DECIMATEBYPOW2",0x03 },
22 { 0x8197, "VARIDECIMATE",0x03 },
23 { 0x81f2, "_3DINPUTTASK",0x03 },
24 { 0x820a, "_3DPRLGCINPTASK",0x03 },
25 { 0x8227, "_3DSTEREOINPUTTASK",0x03 },
26 { 0x8242, "_3DOUTPUTTASK",0x03 },
27 { 0x82c4, "HRTF_MORPH_TASK",0x03 },
28 { 0x82c6, "WAIT4DATA",0x03 },
29 { 0x82fa, "PROLOGIC",0x03 },
30 { 0x8496, "DECORRELATOR",0x03 },
31 { 0x84a4, "STEREO2MONO",0x03 },
32 { 0x0070, "SPOSCB",0x02 },
33 { 0x0105, "TASKTREETHREAD",0x03 },
34 { 0x0136, "TASKTREEHEADERCODE",0x03 },
35 { 0x013f, "FGTASKTREEHEADERCODE",0x03 },
36 { 0x0163, "NULLALGORITHM",0x03 },
37 { 0x0167, "HFGEXECCHILD",0x03 },
38 { 0x0168, "HFGEXECCHILD_98",0x03 },
39 { 0x016a, "HFGEXECCHILD_PUSH1IND",0x03 },
40 { 0x016d, "HFGEXECSIBLING",0x03 },
41 { 0x016f, "HFGEXECSIBLING_298",0x03 },
42 { 0x0170, "HFGEXECSIBLING_2IND1",0x03 },
43 { 0x0173, "S16_CODECOUTPUTTASK",0x03 },
44 { 0x018e, "#CODE_END",0x00 },
45}; /* cwcemb80 symbols */
46
47static u32 cwcemb80_code[] = {
48/* BEGINADDRESS */
49/* 0000 */ 0x00040730,0x00001002,0x000f619e,0x00001003,
50/* 0002 */ 0x00001705,0x00001400,0x000a411e,0x00001003,
51/* 0004 */ 0x00040730,0x00001002,0x000f619e,0x00001003,
52/* 0006 */ 0x00009705,0x00001400,0x000a411e,0x00001003,
53/* 0008 */ 0x00040730,0x00001002,0x000f619e,0x00001003,
54/* 000A */ 0x00011705,0x00001400,0x000a411e,0x00001003,
55/* 000C */ 0x00040730,0x00001002,0x000f619e,0x00001003,
56/* 000E */ 0x00019705,0x00001400,0x000a411e,0x00001003,
57/* 0010 */ 0x00040730,0x00001002,0x000f619e,0x00001003,
58/* 0012 */ 0x00021705,0x00001400,0x000a411e,0x00001003,
59/* 0014 */ 0x00040730,0x00001002,0x000f619e,0x00001003,
60/* 0016 */ 0x00029705,0x00001400,0x000a411e,0x00001003,
61/* 0018 */ 0x00040730,0x00001002,0x000f619e,0x00001003,
62/* 001A */ 0x00031705,0x00001400,0x000a411e,0x00001003,
63/* 001C */ 0x00040730,0x00001002,0x000f619e,0x00001003,
64/* 001E */ 0x00039705,0x00001400,0x000a411e,0x00001003,
65/* 0020 */ 0x000fe19e,0x00001003,0x0009c730,0x00001003,
66/* 0022 */ 0x0008e19c,0x00001003,0x000083c1,0x00093040,
67/* 0024 */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
68/* 0026 */ 0x00009705,0x00001400,0x000a211e,0x00001003,
69/* 0028 */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
70/* 002A */ 0x00011705,0x00001400,0x000a211e,0x00001003,
71/* 002C */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
72/* 002E */ 0x00019705,0x00001400,0x000a211e,0x00001003,
73/* 0030 */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
74/* 0032 */ 0x00021705,0x00001400,0x000a211e,0x00001003,
75/* 0034 */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
76/* 0036 */ 0x00029705,0x00001400,0x000a211e,0x00001003,
77/* 0038 */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
78/* 003A */ 0x00031705,0x00001400,0x000a211e,0x00001003,
79/* 003C */ 0x00098730,0x00001002,0x000ee19e,0x00001003,
80/* 003E */ 0x00039705,0x00001400,0x000a211e,0x00001003,
81/* 0040 */ 0x0000a730,0x00001008,0x000e2730,0x00001002,
82/* 0042 */ 0x0000a731,0x00001002,0x0000a731,0x00001002,
83/* 0044 */ 0x0000a731,0x00001002,0x0000a731,0x00001002,
84/* 0046 */ 0x0000a731,0x00001002,0x0000a731,0x00001002,
85/* 0048 */ 0x00000000,0x00000000,0x000f619c,0x00001003,
86/* 004A */ 0x0007f801,0x000c0000,0x00000037,0x00001000,
87/* 004C */ 0x00000000,0x00000000,0x00000000,0x00000000,
88/* 004E */ 0x00000000,0x00000000,0x00000000,0x00000000,
89/* 0050 */ 0x00000000,0x000c0000,0x00000000,0x00000000,
90/* 0052 */ 0x0000373c,0x00001000,0x00000000,0x00000000,
91/* 0054 */ 0x000ee19c,0x00001003,0x0007f801,0x000c0000,
92/* 0056 */ 0x00000037,0x00001000,0x00000000,0x00000000,
93/* 0058 */ 0x00000000,0x00000000,0x00000000,0x00000000,
94/* 005A */ 0x00000000,0x00000000,0x0000273c,0x00001000,
95/* 005C */ 0x00000033,0x00001000,0x000e679e,0x00001003,
96/* 005E */ 0x00007705,0x00001400,0x000ac71e,0x00001003,
97/* 0060 */ 0x00087fc1,0x000c3be0,0x0007f801,0x000c0000,
98/* 0062 */ 0x00000037,0x00001000,0x00000000,0x00000000,
99/* 0064 */ 0x00000000,0x00000000,0x00000000,0x00000000,
100/* 0066 */ 0x00000000,0x00000000,0x0000a730,0x00001003,
101/* 0068 */ 0x00000033,0x00001000,0x0007f801,0x000c0000,
102/* 006A */ 0x00000037,0x00001000,0x00000000,0x00000000,
103/* 006C */ 0x00000000,0x00000000,0x00000000,0x00000000,
104/* 006E */ 0x00000000,0x00000000,0x00000000,0x000c0000,
105/* 0070 */ 0x00000032,0x00001000,0x0000273d,0x00001000,
106/* 0072 */ 0x0004a730,0x00001003,0x00000f41,0x00097140,
107/* 0074 */ 0x0000a841,0x0009b240,0x0000a0c1,0x0009f040,
108/* 0076 */ 0x0001c641,0x00093540,0x0001cec1,0x0009b5c0,
109/* 0078 */ 0x00000000,0x00000000,0x0001bf05,0x0003fc40,
110/* 007A */ 0x00002725,0x000aa400,0x00013705,0x00093a00,
111/* 007C */ 0x0000002e,0x0009d6c0,0x00038630,0x00001004,
112/* 007E */ 0x0004ef0a,0x000eb785,0x0003fc8a,0x00000000,
113/* 0080 */ 0x00000000,0x000c70e0,0x0007d182,0x0002c640,
114/* 0082 */ 0x00000630,0x00001004,0x000799b8,0x0002c6c0,
115/* 0084 */ 0x00031705,0x00092240,0x00039f05,0x000932c0,
116/* 0086 */ 0x0003520a,0x00000000,0x00040731,0x0000100b,
117/* 0088 */ 0x00010705,0x000b20c0,0x00000000,0x000eba44,
118/* 008A */ 0x00032108,0x000c60c4,0x00065208,0x000c2917,
119/* 008C */ 0x000406b0,0x00001007,0x00012f05,0x00036880,
120/* 008E */ 0x0002818e,0x000c0000,0x0004410a,0x00000000,
121/* 0090 */ 0x00040630,0x00001007,0x00029705,0x000c0000,
122/* 0092 */ 0x00000000,0x00000000,0x00003fc1,0x0003fc40,
123/* 0094 */ 0x000037c1,0x00091b40,0x00003fc1,0x000911c0,
124/* 0096 */ 0x000037c1,0x000957c0,0x00003fc1,0x000951c0,
125/* 0098 */ 0x000037c1,0x00000000,0x00003fc1,0x000991c0,
126/* 009A */ 0x000037c1,0x00000000,0x00003fc1,0x0009d1c0,
127/* 009C */ 0x000037c1,0x00000000,0x0001ccc1,0x000915c0,
128/* 009E */ 0x0001c441,0x0009d800,0x0009cdc1,0x00091240,
129/* 00A0 */ 0x0001c541,0x00091d00,0x0009cfc1,0x00095240,
130/* 00A2 */ 0x0001c741,0x00095c80,0x000e8ca9,0x00099240,
131/* 00A4 */ 0x000e85ad,0x00095640,0x00069ca9,0x00099d80,
132/* 00A6 */ 0x000e952d,0x00099640,0x000eaca9,0x0009d6c0,
133/* 00A8 */ 0x000ea5ad,0x00091a40,0x0006bca9,0x0009de80,
134/* 00AA */ 0x000eb52d,0x00095a40,0x000ecca9,0x00099ac0,
135/* 00AC */ 0x000ec5ad,0x0009da40,0x000edca9,0x0009d300,
136/* 00AE */ 0x000a6e0a,0x00001000,0x000ed52d,0x00091e40,
137/* 00B0 */ 0x000eeca9,0x00095ec0,0x000ee5ad,0x00099e40,
138/* 00B2 */ 0x0006fca9,0x00002500,0x000fb208,0x000c59a0,
139/* 00B4 */ 0x000ef52d,0x0009de40,0x00068ca9,0x000912c1,
140/* 00B6 */ 0x000683ad,0x00095241,0x00020f05,0x000991c1,
141/* 00B8 */ 0x00000000,0x00000000,0x00086f88,0x00001000,
142/* 00BA */ 0x0009cf81,0x000b5340,0x0009c701,0x000b92c0,
143/* 00BC */ 0x0009de81,0x000bd300,0x0009d601,0x000b1700,
144/* 00BE */ 0x0001fd81,0x000b9d80,0x0009f501,0x000b57c0,
145/* 00C0 */ 0x000a0f81,0x000bd740,0x00020701,0x000b5c80,
146/* 00C2 */ 0x000a1681,0x000b97c0,0x00021601,0x00002500,
147/* 00C4 */ 0x000a0701,0x000b9b40,0x000a0f81,0x000b1bc0,
148/* 00C6 */ 0x00021681,0x00002d00,0x00020f81,0x000bd800,
149/* 00C8 */ 0x000a0701,0x000b5bc0,0x00021601,0x00003500,
150/* 00CA */ 0x000a0f81,0x000b5f40,0x000a0701,0x000bdbc0,
151/* 00CC */ 0x00021681,0x00003d00,0x00020f81,0x000b1d00,
152/* 00CE */ 0x000a0701,0x000b1fc0,0x00021601,0x00020500,
153/* 00D0 */ 0x00020f81,0x000b1341,0x000a0701,0x000b9fc0,
154/* 00D2 */ 0x00021681,0x00020d00,0x00020f81,0x000bde80,
155/* 00D4 */ 0x000a0701,0x000bdfc0,0x00021601,0x00021500,
156/* 00D6 */ 0x00020f81,0x000b9341,0x00020701,0x000b53c1,
157/* 00D8 */ 0x00021681,0x00021d00,0x000a0f81,0x000d0380,
158/* 00DA */ 0x0000b601,0x000b15c0,0x00007b01,0x00000000,
159/* 00DC */ 0x00007b81,0x000bd1c0,0x00007b01,0x00000000,
160/* 00DE */ 0x00007b81,0x000b91c0,0x00007b01,0x000b57c0,
161/* 00E0 */ 0x00007b81,0x000b51c0,0x00007b01,0x000b1b40,
162/* 00E2 */ 0x00007b81,0x000b11c0,0x00087b01,0x000c3dc0,
163/* 00E4 */ 0x0007e488,0x000d7e45,0x00000000,0x000d7a44,
164/* 00E6 */ 0x0007e48a,0x00000000,0x00011f05,0x00084080,
165/* 00E8 */ 0x00000000,0x00000000,0x00001705,0x000b3540,
166/* 00EA */ 0x00008a01,0x000bf040,0x00007081,0x000bb5c0,
167/* 00EC */ 0x00055488,0x00000000,0x0000d482,0x0003fc40,
168/* 00EE */ 0x0003fc88,0x00000000,0x0001e401,0x000b3a00,
169/* 00F0 */ 0x0001ec81,0x000bd6c0,0x0004ef08,0x000eb784,
170/* 00F2 */ 0x000c86b0,0x00001007,0x00008281,0x000bb240,
171/* 00F4 */ 0x0000b801,0x000b7140,0x00007888,0x00000000,
172/* 00F6 */ 0x0000073c,0x00001000,0x0007f188,0x000c0000,
173/* 00F8 */ 0x00000000,0x00000000,0x00055288,0x000c555c,
174/* 00FA */ 0x0005528a,0x000c0000,0x0009fa88,0x000c5d00,
175/* 00FC */ 0x0000fa88,0x00000000,0x00000032,0x00001000,
176/* 00FE */ 0x0000073d,0x00001000,0x0007f188,0x000c0000,
177/* 0100 */ 0x00000000,0x00000000,0x0008c01c,0x00001003,
178/* 0102 */ 0x00002705,0x00001008,0x0008b201,0x000c1392,
179/* 0104 */ 0x0000ba01,0x00000000,
180/* TASKTREETHREAD */
181/* 0105 */ 0x00008731,0x00001400,0x0004c108,0x000fe0c4,
182/* 0107 */ 0x00057488,0x00000000,0x000a6388,0x00001001,
183/* 0109 */ 0x0008b334,0x000bc141,0x0003020e,0x00000000,
184/* 010B */ 0x000886b0,0x00001008,0x00003625,0x000c5dfa,
185/* 010D */ 0x000a638a,0x00001001,0x0008020e,0x00001002,
186/* 010F */ 0x0008a6b0,0x00001008,0x0007f301,0x00000000,
187/* 0111 */ 0x00000000,0x00000000,0x00002725,0x000a8c40,
188/* 0113 */ 0x000000ae,0x00000000,0x000d8630,0x00001008,
189/* 0115 */ 0x00000000,0x000c74e0,0x0007d182,0x0002d640,
190/* 0117 */ 0x000a8630,0x00001008,0x000799b8,0x0002d6c0,
191/* 0119 */ 0x0000748a,0x000c3ec5,0x0007420a,0x000c0000,
192/* 011B */ 0x00062208,0x000c4117,0x00070630,0x00001009,
193/* 011D */ 0x00000000,0x000c0000,0x0001022e,0x00000000,
194/* 011F */ 0x0003a630,0x00001009,0x00000000,0x000c0000,
195/* 0121 */ 0x00000036,0x00001000,0x00000000,0x00000000,
196/* 0123 */ 0x00000000,0x00000000,0x00000000,0x00000000,
197/* 0125 */ 0x00000000,0x00000000,0x0002a730,0x00001008,
198/* 0127 */ 0x0007f801,0x000c0000,0x00000037,0x00001000,
199/* 0129 */ 0x00000000,0x00000000,0x00000000,0x00000000,
200/* 012B */ 0x00000000,0x00000000,0x00000000,0x00000000,
201/* 012D */ 0x0002a730,0x00001008,0x00000033,0x00001000,
202/* 012F */ 0x0002a705,0x00001008,0x00007a01,0x000c0000,
203/* 0131 */ 0x000e6288,0x000d550a,0x0006428a,0x00000000,
204/* 0133 */ 0x00060730,0x0000100a,0x00000000,0x000c0000,
205/* 0135 */ 0x00000000,0x00000000,
206/* TASKTREEHEADERCODE */
207/* 0136 */ 0x0007aab0,0x00034880,0x00078fb0,0x0000100b,
208/* 0138 */ 0x00057488,0x00000000,0x00033b94,0x00081140,
209/* 013A */ 0x000183ae,0x00000000,0x000786b0,0x0000100b,
210/* 013C */ 0x00022f05,0x000c3545,0x0000eb8a,0x00000000,
211/* 013E */ 0x00042731,0x00001003,
212/* FGTASKTREEHEADERCODE */
213/* 013F */ 0x0007aab0,0x00034880,0x00048fb0,0x0000100a,
214/* 0141 */ 0x00057488,0x00000000,0x00033b94,0x00081140,
215/* 0143 */ 0x000183ae,0x00000000,0x000806b0,0x0000100b,
216/* 0145 */ 0x00022f05,0x00000000,0x00007401,0x00091140,
217/* 0147 */ 0x00048f05,0x000951c0,0x00042731,0x00001003,
218/* 0149 */ 0x0000473d,0x00001000,0x000f19b0,0x000bbc47,
219/* 014B */ 0x00080000,0x000bffc7,0x000fe19e,0x00001003,
220/* 014D */ 0x00000000,0x00000000,0x0008e19c,0x00001003,
221/* 014F */ 0x000083c1,0x00093040,0x00000f41,0x00097140,
222/* 0151 */ 0x0000a841,0x0009b240,0x0000a0c1,0x0009f040,
223/* 0153 */ 0x0001c641,0x00093540,0x0001cec1,0x0009b5c0,
224/* 0155 */ 0x00000000,0x000fdc44,0x00055208,0x00000000,
225/* 0157 */ 0x00010705,0x000a2880,0x0000a23a,0x00093a00,
226/* 0159 */ 0x0003fc8a,0x000df6c5,0x0004ef0a,0x000c0000,
227/* 015B */ 0x00012f05,0x00036880,0x00065308,0x000c2997,
228/* 015D */ 0x000d86b0,0x0000100a,0x0004410a,0x000d40c7,
229/* 015F */ 0x00000000,0x00000000,0x00080730,0x00001004,
230/* 0161 */ 0x00056f0a,0x000ea105,0x00000000,0x00000000,
231/* NULLALGORITHM */
232/* 0163 */ 0x0000473d,0x00001000,0x000f19b0,0x000bbc47,
233/* 0165 */ 0x00080000,0x000bffc7,0x0000273d,0x00001000,
234/* HFGEXECCHILD */
235/* 0167 */ 0x00000000,0x000eba44,
236/* HFGEXECCHILD_98 */
237/* 0168 */ 0x00048f05,0x0000f440,0x00007401,0x0000f7c0,
238/* HFGEXECCHILD_PUSH1IND */
239/* 016A */ 0x00000734,0x00001000,0x00010705,0x000a6880,
240/* 016C */ 0x00006a88,0x000c75c4,
241/* HFGEXECSIBLING */
242/* 016D */ 0x00000000,0x000e5084,0x00000000,0x000eba44,
243/* HFGEXECSIBLING_298 */
244/* 016F */ 0x00087401,0x000e4782,
245/* HFGEXECSIBLING_2IND1 */
246/* 0170 */ 0x00000734,0x00001000,0x00010705,0x000a6880,
247/* 0172 */ 0x00006a88,0x000c75c4,
248/* S16_CODECOUTPUTTASK */
249/* 0173 */ 0x0007c108,0x000c0000,0x0007e721,0x000bed40,
250/* 0175 */ 0x00005f25,0x000badc0,0x0003ba97,0x000beb80,
251/* 0177 */ 0x00065590,0x000b2e00,0x00033217,0x00003ec0,
252/* 0179 */ 0x00065590,0x000b8e40,0x0003ed80,0x000491c0,
253/* 017B */ 0x00073fb0,0x00074c80,0x000283a0,0x0000100c,
254/* 017D */ 0x000ee388,0x00042970,0x00008301,0x00021ef2,
255/* 017F */ 0x000b8f14,0x0000000f,0x000c4d8d,0x0000001b,
256/* 0181 */ 0x000d6dc2,0x000e06c6,0x000032ac,0x000c3916,
257/* 0183 */ 0x0004edc2,0x00074c80,0x00078898,0x00001000,
258/* 0185 */ 0x00038894,0x00000032,0x000c4d8d,0x00092e1b,
259/* 0187 */ 0x000d6dc2,0x000e06c6,0x0004edc2,0x000c1956,
260/* 0189 */ 0x0000722c,0x00034a00,0x00041705,0x0009ed40,
261/* 018B */ 0x00058730,0x00001400,0x000d7488,0x000c3a00,
262/* 018D */ 0x00048f05,0x00000000
263};
264/* #CODE_END */
265
266static u32 cwcemb80_parameter[] = {
267/* 0000 */ 0x00000000,0x00000000,0x00000000,0x00000000,
268/* 0004 */ 0x00000000,0x00000000,0x00000000,0x00000000,
269/* 0008 */ 0x00000000,0x00000000,0x00000163,0x00000000,
270/* 000C */ 0x00000000,0x00000000,0x00000000,0x00000000,
271/* 0010 */ 0x00000000,0x00000000,0x00000000,0x00000000,
272/* 0014 */ 0x00000000,0x00000000,0x00000000,0x00000000,
273/* 0018 */ 0x00000000,0x00200040,0x00008010,0x00000000,
274/* 001C */ 0x00000000,0x80000001,0x00000001,0x00060000,
275/* 0020 */ 0x00000000,0x00000000,0x00000000,0x00000000,
276/* 0024 */ 0x00000000,0x00000000,0x00000000,0x00000000,
277/* 0028 */ 0x00000000,0x00900080,0x00000173,0x00000000,
278/* 002C */ 0x00000000,0x00000010,0x00800000,0x00900000,
279/* 0030 */ 0xf2c0000f,0x00000200,0x00000000,0x00010600,
280/* 0034 */ 0x00000000,0x00000000,0x00000000,0x00000000,
281/* 0038 */ 0x00000000,0x00000000,0x00000163,0x330300c2,
282/* 003C */ 0x06000000,0x00000000,0x80008000,0x80008000,
283/* 0040 */ 0x3fc0000f,0x00000301,0x00010400,0x00000000,
284/* 0044 */ 0x00000000,0x00000000,0x00000000,0x00000000,
285/* 0048 */ 0x00000000,0x00b00000,0x00d0806d,0x330480c3,
286/* 004C */ 0x04800000,0x00000001,0x00800001,0x0000ffff,
287/* 0050 */ 0x00000000,0x00000000,0x00000000,0x00000000,
288/* 0054 */ 0x00000000,0x00000000,0x00000000,0x00000000,
289/* 0058 */ 0x00000000,0x00000000,0x00000000,0x00000000,
290/* 005C */ 0x00000000,0x00000000,0x00000000,0x00000000,
291/* 0060 */ 0x00000000,0x00000000,0x00000000,0x00000000,
292/* 0064 */ 0x00000000,0x00000000,0x00000000,0x00000000,
293/* 0068 */ 0x00000000,0x00000000,0x00000000,0x00000000,
294/* 006C */ 0x00000000,0x00000000,0x00000000,0x00000000,
295/* 0070 */ 0x066a0600,0x06350070,0x0000929d,0x929d929d,
296/* 0074 */ 0x00000000,0x0000735a,0x00000600,0x00000000,
297/* 0078 */ 0x929d735a,0x00000000,0x00010000,0x735a735a,
298/* 007C */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
299/* 0080 */ 0x00000000,0x00000000,0x00000000,0x00000000,
300/* 0084 */ 0x00000000,0x00000000,0x00000000,0x00000000,
301/* 0088 */ 0x00000000,0x00000000,0x0000804f,0x000000c3,
302/* 008C */ 0x05000000,0x00a00010,0x00000000,0x80008000,
303/* 0090 */ 0x00000000,0x00000000,0x00000700,0x00000000,
304/* 0094 */ 0x00000000,0x00000000,0x00000000,0x00000000,
305/* 0098 */ 0x00000080,0x00a00000,0x0000809a,0x000000c2,
306/* 009C */ 0x07400000,0x00000000,0x80008000,0xffffffff,
307/* 00A0 */ 0x00c80028,0x00005555,0x00000000,0x000107a0,
308/* 00A4 */ 0x00c80028,0x000000c2,0x06800000,0x00000000,
309/* 00A8 */ 0x06e00080,0x00300000,0x000080bb,0x000000c9,
310/* 00AC */ 0x07a00000,0x04000000,0x80008000,0xffffffff,
311/* 00B0 */ 0x00c80028,0x00005555,0x00000000,0x00000780,
312/* 00B4 */ 0x00c80028,0x000000c5,0xff800000,0x00000000,
313/* 00B8 */ 0x00640080,0x00c00000,0x00008197,0x000000c9,
314/* 00BC */ 0x07800000,0x04000000,0x80008000,0xffffffff,
315/* 00C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
316/* 00C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
317/* 00C8 */ 0x00000000,0x00000000,0x0000805e,0x000000c1,
318/* 00CC */ 0x00000000,0x00800000,0x80008000,0x80008000,
319/* 00D0 */ 0x00020000,0x0000ffff,0x00000000,0x00000000,
320/* 00D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
321/* 00D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
322/* 00DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
323/* 00E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
324/* 00E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
325/* 00E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
326/* 00EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
327/* 00F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
328/* 00F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
329/* 00F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
330/* 00FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
331/* 0100 */ 0x00000000,0x00000000,0x00000000,0x00000000,
332/* 0104 */ 0x00000000,0x00000000,0x00000000,0x00000000,
333/* 0108 */ 0x00000000,0x00000000,0x00000000,0x00000000,
334/* 010C */ 0x00000000,0x00000000,0x00000000,0x00000000,
335/* 0110 */ 0x00000000,0x00000000,0x00000000,0x00000000,
336/* 0114 */ 0x00000000,0x00000000,0x00000000,0x00000000,
337/* 0118 */ 0x00000000,0x00000000,0x00000000,0x00000000,
338/* 011C */ 0x00000000,0x00000000,0x00000000,0x00000000,
339/* 0120 */ 0x00000000,0x00000000,0x00000000,0x00000000,
340/* 0124 */ 0x00000000,0x00000000,0x00000000,0x00000000,
341/* 0128 */ 0x00000000,0x00000000,0x00000000,0x00000000,
342/* 012C */ 0x00000000,0x00000000,0x00000000,0x00000000,
343/* 0130 */ 0x00000000,0x00000000,0x00000000,0x00000000,
344/* 0134 */ 0x00000000,0x00000000,0x00000000,0x00000000,
345/* 0138 */ 0x00000000,0x00000000,0x00000000,0x00000000,
346/* 013C */ 0x00000000,0x00000000,0x00000000,0x00000000,
347/* 0140 */ 0x00000000,0x00000000,0x00000000,0x00000000,
348/* 0144 */ 0x00000000,0x00000000,0x00000000,0x00000000,
349/* 0148 */ 0x00000000,0x00000000,0x00000000,0x00000000,
350/* 014C */ 0x00000000,0x00000000,0x00000000,0x00000000,
351/* 0150 */ 0x00000000,0x00000000,0x00000000,0x00000000,
352/* 0154 */ 0x00000000,0x00000000,0x00000000,0x00000000,
353/* 0158 */ 0x00000000,0x00000000,0x00000000,0x00000000,
354/* 015C */ 0x00000000,0x00000000,0x00000000,0x00000000,
355/* 0160 */ 0x00000000,0x00000000,0x00000000,0x00000000,
356/* 0164 */ 0x00000000,0x00000000,0x00000000,0x00000000,
357/* 0168 */ 0x00000000,0x00000000,0x00000000,0x00000000,
358/* 016C */ 0x00000000,0x00000000,0x00000000,0x00000000,
359/* 0170 */ 0x00000000,0x00000000,0x00000000,0x00000000,
360/* 0174 */ 0x00000000,0x00000000,0x00000000,0x00000000,
361/* 0178 */ 0x00000000,0x00000000,0x00000000,0x00000000,
362/* 017C */ 0x00000000,0x00000000,0x00000000,0x00000000,
363/* 0180 */ 0x00000000,0x00000000,0x00000000,0x00000000,
364/* 0184 */ 0x00000000,0x00000000,0x00000000,0x00000000,
365/* 0188 */ 0x00000000,0x00000000,0x00000000,0x00000000,
366/* 018C */ 0x00000000,0x00000000,0x00000000,0x00000000,
367/* 0190 */ 0x00000000,0x00000000,0x00000000,0x00000000,
368/* 0194 */ 0x00000000,0x00000000,0x00000000,0x00000000,
369/* 0198 */ 0x00000000,0x00000000,0x00000000,0x00000000,
370/* 019C */ 0x00000000,0x00000000,0x00000000,0x00000000,
371/* 01A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
372/* 01A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
373/* 01A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
374/* 01AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
375/* 01B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
376/* 01B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
377/* 01B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
378/* 01BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
379/* 01C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
380/* 01C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
381/* 01C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
382/* 01CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
383/* 01D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
384/* 01D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
385/* 01D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
386/* 01DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
387/* 01E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
388/* 01E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
389/* 01E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
390/* 01EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
391/* 01F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
392/* 01F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
393/* 01F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
394/* 01FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
395/* 0200 */ 0x00000000,0x00000000,0x00000000,0x00000000,
396/* 0204 */ 0x00000000,0x00000000,0x00000000,0x00000000,
397/* 0208 */ 0x00000000,0x00000000,0x00000000,0x00000000,
398/* 020C */ 0x00000000,0x00000000,0x00000000,0x00000000,
399/* 0210 */ 0x00000000,0x00000000,0x00000000,0x00000000,
400/* 0214 */ 0x00000000,0x00000000,0x00000000,0x00000000,
401/* 0218 */ 0x00000000,0x00000000,0x00000000,0x00000000,
402/* 021C */ 0x00000000,0x00000000,0x00000000,0x00000000,
403/* 0220 */ 0x00000000,0x00000000,0x00000000,0x00000000,
404/* 0224 */ 0x00000000,0x00000000,0x00000000,0x00000000,
405/* 0228 */ 0x00000000,0x00000000,0x00000000,0x00000000,
406/* 022C */ 0x00000000,0x00000000,0x00000000,0x00000000,
407/* 0230 */ 0x00000000,0x00000000,0x00000000,0x00000000,
408/* 0234 */ 0x00000000,0x00000000,0x00000000,0x00000000,
409/* 0238 */ 0x00000000,0x00000000,0x00000000,0x00000000,
410/* 023C */ 0x00000000,0x00000000,0x00000000,0x00000000,
411/* 0240 */ 0x00000000,0x00000000,0x00000000,0x00000000,
412/* 0244 */ 0x00000000,0x00000000,0x00000000,0x00000000,
413/* 0248 */ 0x00000000,0x00000000,0x00000000,0x00000000,
414/* 024C */ 0x00000000,0x00000000,0x00000000,0x00000000,
415/* 0250 */ 0x00000000,0x00000000,0x00000000,0x00000000,
416/* 0254 */ 0x00000000,0x00000000,0x00000000,0x00000000,
417/* 0258 */ 0x00000000,0x00000000,0x00000000,0x00000000,
418/* 025C */ 0x00000000,0x00000000,0x00000000,0x00000000,
419/* 0260 */ 0x00000000,0x00000000,0x00000000,0x00000000,
420/* 0264 */ 0x00000000,0x00000000,0x00000000,0x00000000,
421/* 0268 */ 0x00000000,0x00000000,0x00000000,0x00000000,
422/* 026C */ 0x00000000,0x00000000,0x00000000,0x00000000,
423/* 0270 */ 0x00000000,0x00000000,0x00000000,0x00000000,
424/* 0274 */ 0x00000000,0x00000000,0x00000000,0x00000000,
425/* 0278 */ 0x00000000,0x00000000,0x00000000,0x00000000,
426/* 027C */ 0x00000000,0x00000000,0x00000000,0x00000000,
427/* 0280 */ 0x00000000,0x00000000,0x00000000,0x00000000,
428/* 0284 */ 0x00000000,0x00000000,0x00000000,0x00000000,
429/* 0288 */ 0x00000000,0x00000000,0x00000000,0x00000000,
430/* 028C */ 0x00000000,0x00000000,0x00000000,0x00000000,
431/* 0290 */ 0x00000000,0x00000000,0x00000000,0x00000000,
432/* 0294 */ 0x00000000,0x00000000,0x00000000,0x00000000,
433/* 0298 */ 0x00000000,0x00000000,0x00000000,0x00000000,
434/* 029C */ 0x00000000,0x00000000,0x00000000,0x00000000,
435/* 02A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
436/* 02A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
437/* 02A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
438/* 02AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
439/* 02B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
440/* 02B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
441/* 02B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
442/* 02BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
443/* 02C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
444/* 02C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
445/* 02C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
446/* 02CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
447/* 02D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
448/* 02D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
449/* 02D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
450/* 02DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
451/* 02E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
452/* 02E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
453/* 02E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
454/* 02EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
455/* 02F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
456/* 02F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
457/* 02F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
458/* 02FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
459/* 0300 */ 0x00000000,0x00000000,0x00000000,0x00000000,
460/* 0304 */ 0x00000000,0x00000000,0x00000000,0x00000000,
461/* 0308 */ 0x00000000,0x00000000,0x00000000,0x00000000,
462/* 030C */ 0x00000000,0x00000000,0x00000000,0x00000000,
463/* 0310 */ 0x00000000,0x00000000,0x00000000,0x00000000,
464/* 0314 */ 0x00000000,0x00000000,0x00000000,0x00000000,
465/* 0318 */ 0x00000000,0x00000000,0x00000000,0x00000000,
466/* 031C */ 0x00000000,0x00000000,0x00000000,0x00000000,
467/* 0320 */ 0x00000000,0x00000000,0x00000000,0x00000000,
468/* 0324 */ 0x00000000,0x00000000,0x00000000,0x00000000,
469/* 0328 */ 0x00000000,0x00000000,0x00000000,0x00000000,
470/* 032C */ 0x00000000,0x00000000,0x00000000,0x00000000,
471/* 0330 */ 0x00000000,0x00000000,0x00000000,0x00000000,
472/* 0334 */ 0x00000000,0x00000000,0x00000000,0x00000000,
473/* 0338 */ 0x00000000,0x00000000,0x00000000,0x00000000,
474/* 033C */ 0x00000000,0x00000000,0x00000000,0x00000000,
475/* 0340 */ 0x00000000,0x00000000,0x00000000,0x00000000,
476/* 0344 */ 0x00000000,0x00000000,0x00000000,0x00000000,
477/* 0348 */ 0x00000000,0x00000000,0x00000000,0x00000000,
478/* 034C */ 0x00000000,0x00000000,0x00000000,0x00000000,
479/* 0350 */ 0x00000000,0x00000000,0x00000000,0x00000000,
480/* 0354 */ 0x00000000,0x00000000,0x00000000,0x00000000,
481/* 0358 */ 0x00000000,0x00000000,0x00000000,0x00000000,
482/* 035C */ 0x00000000,0x00000000,0x00000000,0x00000000,
483/* 0360 */ 0x00000000,0x00000000,0x00000000,0x00000000,
484/* 0364 */ 0x00000000,0x00000000,0x00000000,0x00000000,
485/* 0368 */ 0x00000000,0x00000000,0x00000000,0x00000000,
486/* 036C */ 0x00000000,0x00000000,0x00000000,0x00000000,
487/* 0370 */ 0x00000000,0x00000000,0x00000000,0x00000000,
488/* 0374 */ 0x00000000,0x00000000,0x00000000,0x00000000,
489/* 0378 */ 0x00000000,0x00000000,0x00000000,0x00000000,
490/* 037C */ 0x00000000,0x00000000,0x00000000,0x00000000,
491/* 0380 */ 0x00000000,0x00000000,0x00000000,0x00000000,
492/* 0384 */ 0x00000000,0x00000000,0x00000000,0x00000000,
493/* 0388 */ 0x00000000,0x00000000,0x00000000,0x00000000,
494/* 038C */ 0x00000000,0x00000000,0x00000000,0x00000000,
495/* 0390 */ 0x00000000,0x00000000,0x00000000,0x00000000,
496/* 0394 */ 0x00000000,0x00000000,0x00000000,0x00000000,
497/* 0398 */ 0x00000000,0x00000000,0x00000000,0x00000000,
498/* 039C */ 0x00000000,0x00000000,0x00000000,0x00000000,
499/* 03A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
500/* 03A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
501/* 03A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
502/* 03AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
503/* 03B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
504/* 03B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
505/* 03B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
506/* 03BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
507/* 03C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
508/* 03C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
509/* 03C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
510/* 03CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
511/* 03D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
512/* 03D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
513/* 03D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
514/* 03DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
515/* 03E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
516/* 03E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
517/* 03E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
518/* 03EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
519/* 03F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
520/* 03F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
521/* 03F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
522/* 03FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
523/* 0400 */ 0x00000000,0x00000000,0x00000000,0x00000000,
524/* 0404 */ 0x00000000,0x00000000,0x00000000,0x00000000,
525/* 0408 */ 0x00000000,0x00000000,0x00000000,0x00000000,
526/* 040C */ 0x00000000,0x00000000,0x00000000,0x00000000,
527/* 0410 */ 0x00000000,0x00000000,0x00000000,0x00000000,
528/* 0414 */ 0x00000000,0x00000000,0x00000000,0x00000000,
529/* 0418 */ 0x00000000,0x00000000,0x00000000,0x00000000,
530/* 041C */ 0x00000000,0x00000000,0x00000000,0x00000000,
531/* 0420 */ 0x00000000,0x00000000,0x00000000,0x00000000,
532/* 0424 */ 0x00000000,0x00000000,0x00000000,0x00000000,
533/* 0428 */ 0x00000000,0x00000000,0x00000000,0x00000000,
534/* 042C */ 0x00000000,0x00000000,0x00000000,0x00000000,
535/* 0430 */ 0x00000000,0x00000000,0x00000000,0x00000000,
536/* 0434 */ 0x00000000,0x00000000,0x00000000,0x00000000,
537/* 0438 */ 0x00000000,0x00000000,0x00000000,0x00000000,
538/* 043C */ 0x00000000,0x00000000,0x00000000,0x00000000,
539/* 0440 */ 0x00000000,0x00000000,0x00000000,0x00000000,
540/* 0444 */ 0x00000000,0x00000000,0x00000000,0x00000000,
541/* 0448 */ 0x00000000,0x00000000,0x00000000,0x00000000,
542/* 044C */ 0x00000000,0x00000000,0x00000000,0x00000000,
543/* 0450 */ 0x00000000,0x00000000,0x00000000,0x00000000,
544/* 0454 */ 0x00000000,0x00000000,0x00000000,0x00000000,
545/* 0458 */ 0x00000000,0x00000000,0x00000000,0x00000000,
546/* 045C */ 0x00000000,0x00000000,0x00000000,0x00000000,
547/* 0460 */ 0x00000000,0x00000000,0x00000000,0x00000000,
548/* 0464 */ 0x00000000,0x00000000,0x00000000,0x00000000,
549/* 0468 */ 0x00000000,0x00000000,0x00000000,0x00000000,
550/* 046C */ 0x00000000,0x00000000,0x00000000,0x00000000,
551/* 0470 */ 0x00000000,0x00000000,0x00000000,0x00000000,
552/* 0474 */ 0x00000000,0x00000000,0x00000000,0x00000000,
553/* 0478 */ 0x00000000,0x00000000,0x00000000,0x00000000,
554/* 047C */ 0x00000000,0x00000000,0x00000000,0x00000000,
555/* 0480 */ 0x00000000,0x00000000,0x00000000,0x00000000,
556/* 0484 */ 0x00000000,0x00000000,0x00000000,0x00000000,
557/* 0488 */ 0x00000000,0x00000000,0x00000000,0x00000000,
558/* 048C */ 0x00000000,0x00000000,0x00000000,0x00000000,
559/* 0490 */ 0x00000000,0x00000000,0x00000000,0x00000000,
560/* 0494 */ 0x00000000,0x00000000,0x00000000,0x00000000,
561/* 0498 */ 0x00000000,0x00000000,0x00000000,0x00000000,
562/* 049C */ 0x00000000,0x00000000,0x00000000,0x00000000,
563/* 04A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
564/* 04A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
565/* 04A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
566/* 04AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
567/* 04B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
568/* 04B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
569/* 04B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
570/* 04BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
571/* 04C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
572/* 04C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
573/* 04C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
574/* 04CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
575/* 04D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
576/* 04D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
577/* 04D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
578/* 04DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
579/* 04E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
580/* 04E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
581/* 04E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
582/* 04EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
583/* 04F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
584/* 04F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
585/* 04F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
586/* 04FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
587/* 0500 */ 0x00000000,0x00000000,0x00000000,0x00000000,
588/* 0504 */ 0x00000000,0x00000000,0x00000000,0x00000000,
589/* 0508 */ 0x00000000,0x00000000,0x00000000,0x00000000,
590/* 050C */ 0x00000000,0x00000000,0x00000000,0x00000000,
591/* 0510 */ 0x00000000,0x00000000,0x00000000,0x00000000,
592/* 0514 */ 0x00000000,0x00000000,0x00000000,0x00000000,
593/* 0518 */ 0x00000000,0x00000000,0x00000000,0x00000000,
594/* 051C */ 0x00000000,0x00000000,0x00000000,0x00000000,
595/* 0520 */ 0x00000000,0x00000000,0x00000000,0x00000000,
596/* 0524 */ 0x00000000,0x00000000,0x00000000,0x00000000,
597/* 0528 */ 0x00000000,0x00000000,0x00000000,0x00000000,
598/* 052C */ 0x00000000,0x00000000,0x00000000,0x00000000,
599/* 0530 */ 0x00000000,0x00000000,0x00000000,0x00000000,
600/* 0534 */ 0x00000000,0x00000000,0x00000000,0x00000000,
601/* 0538 */ 0x00000000,0x00000000,0x00000000,0x00000000,
602/* 053C */ 0x00000000,0x00000000,0x00000000,0x00000000,
603/* 0540 */ 0x00000000,0x00000000,0x00000000,0x00000000,
604/* 0544 */ 0x00000000,0x00000000,0x00000000,0x00000000,
605/* 0548 */ 0x00000000,0x00000000,0x00000000,0x00000000,
606/* 054C */ 0x00000000,0x00000000,0x00000000,0x00000000,
607/* 0550 */ 0x00000000,0x00000000,0x00000000,0x00000000,
608/* 0554 */ 0x00000000,0x00000000,0x00000000,0x00000000,
609/* 0558 */ 0x00000000,0x00000000,0x00000000,0x00000000,
610/* 055C */ 0x00000000,0x00000000,0x00000000,0x00000000,
611/* 0560 */ 0x00000000,0x00000000,0x00000000,0x00000000,
612/* 0564 */ 0x00000000,0x00000000,0x00000000,0x00000000,
613/* 0568 */ 0x00000000,0x00000000,0x00000000,0x00000000,
614/* 056C */ 0x00000000,0x00000000,0x00000000,0x00000000,
615/* 0570 */ 0x00000000,0x00000000,0x00000000,0x00000000,
616/* 0574 */ 0x00000000,0x00000000,0x00000000,0x00000000,
617/* 0578 */ 0x00000000,0x00000000,0x00000000,0x00000000,
618/* 057C */ 0x00000000,0x00000000,0x00000000,0x00000000,
619/* 0580 */ 0x00000000,0x00000000,0x00000000,0x00000000,
620/* 0584 */ 0x00000000,0x00000000,0x00000000,0x00000000,
621/* 0588 */ 0x00000000,0x00000000,0x00000000,0x00000000,
622/* 058C */ 0x00000000,0x00000000,0x00000000,0x00000000,
623/* 0590 */ 0x00000000,0x00000000,0x00000000,0x00000000,
624/* 0594 */ 0x00000000,0x00000000,0x00000000,0x00000000,
625/* 0598 */ 0x00000000,0x00000000,0x00000000,0x00000000,
626/* 059C */ 0x00000000,0x00000000,0x00000000,0x00000000,
627/* 05A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
628/* 05A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
629/* 05A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
630/* 05AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
631/* 05B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
632/* 05B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
633/* 05B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
634/* 05BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
635/* 05C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
636/* 05C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
637/* 05C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
638/* 05CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
639/* 05D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
640/* 05D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
641/* 05D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
642/* 05DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
643/* 05E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
644/* 05E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
645/* 05E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
646/* 05EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
647/* 05F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
648/* 05F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
649/* 05F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
650/* 05FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
651/* 0600 */ 0x929d0600,0x929d929d,0x929d929d,0x929d0000,
652/* 0604 */ 0x929d929d,0x929d929d,0x929d929d,0x929d929d,
653/* 0608 */ 0x929d929d,0x00100635,0x060b013f,0x00000004,
654/* 060C */ 0x00000001,0x007a0002,0x00000000,0x066e0610,
655/* 0610 */ 0x0105929d,0x929d929d,0x929d929d,0x929d929d,
656/* 0614 */ 0x929d929d,0xa431ac75,0x0001735a,0xa431ac75,
657/* 0618 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
658/* 061C */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
659/* 0620 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
660/* 0624 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
661/* 0628 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
662/* 062C */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
663/* 0630 */ 0xa431ac75,0xa431ac75,0xa431ac75,0x735a0051,
664/* 0634 */ 0x00000000,0x929d929d,0x929d929d,0x929d929d,
665/* 0638 */ 0x929d929d,0x929d929d,0x929d929d,0x929d929d,
666/* 063C */ 0x929d929d,0x929d929d,0x00000000,0x06400136,
667/* 0640 */ 0x0000270f,0x00010000,0x007a0000,0x00000000,
668/* 0644 */ 0x068e0645,0x0105929d,0x929d929d,0x929d929d,
669/* 0648 */ 0x929d929d,0x929d929d,0xa431ac75,0x0001735a,
670/* 064C */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
671/* 0650 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
672/* 0654 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
673/* 0658 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
674/* 065C */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
675/* 0660 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
676/* 0664 */ 0xa431ac75,0xa431ac75,0xa431ac75,0xa431ac75,
677/* 0668 */ 0x735a0100,0x00000000,0x00000000,0x00000000,
678/* 066C */ 0x00000000,0x00000000,0x00000000,0x00000000,
679/* 0670 */ 0x00000000,0x00000000,0x00000000,0x00000000,
680/* 0674 */ 0x00000000,0x00000000,0x00000000,0x00000000,
681/* 0678 */ 0x00000000,0x00000000,0x00000000,0x00000000,
682/* 067C */ 0x00000000,0x00000000,0x00000000,0x00000000,
683/* 0680 */ 0x00000000,0x00000000,0x00000000,0x00000000,
684/* 0684 */ 0x00000000,0x00000000,0x00000000,0x00000000,
685/* 0688 */ 0x00000000,0x00000000,0x00000000,0x00000000,
686/* 068C */ 0x00000000,0x00000000,0x00000000,0x00000000,
687/* 0690 */ 0x00000000,0x00000000,0x00000000,0x00000000,
688/* 0694 */ 0x00000000,0x00000000,0x00000000
689}; /* #PARAMETER_END */
690
691static u32 cwcemb80_sample[] = {
692/* 0000 */ 0x00000000,0x00000000,0x00000000,0x00000000,
693/* 0004 */ 0x00000000,0x00000000,0x00000000,0x00000000,
694/* 0008 */ 0x00000000,0x00000000,0x00000000,0x00000000,
695/* 000C */ 0x00000000,0x00000000,0x00000000,0x00000000,
696/* 0010 */ 0x00000000,0x00000000,0x00000000,0x00000000,
697/* 0014 */ 0x00000000,0x00000000,0x00000000,0x00000000,
698/* 0018 */ 0x00000000,0x00000000,0x00000000,0x00000000,
699/* 001C */ 0x00000000,0x00000000,0x00000000,0x00000000,
700/* 0020 */ 0x00000000,0x00000000,0x00000000,0x00000000,
701/* 0024 */ 0x00000000,0x00000000,0x00000000,0x00000000,
702/* 0028 */ 0x00000000,0x00000000,0x00000000,0x00000000,
703/* 002C */ 0x00000000,0x00000000,0x00000000,0x00000000,
704/* 0030 */ 0x00000000,0x00000000,0x00000000,0x00000000,
705/* 0034 */ 0x00000000,0x00000000,0x00000000,0x00000000,
706/* 0038 */ 0x00000000,0x00000000,0x00000000,0x00000000,
707/* 003C */ 0x00000000,0x00000000,0x00000000,0x00000000,
708/* 0040 */ 0x00000000,0x00000000,0x00000000,0x00000000,
709/* 0044 */ 0x00000000,0x00000000,0x00000000,0x00000000,
710/* 0048 */ 0x00000000,0x00000000,0x00000000,0x00000000,
711/* 004C */ 0x00000000,0x00000000,0x00000000,0x00000000,
712/* 0050 */ 0x00000000,0x00000000,0x00000000,0x00000000,
713/* 0054 */ 0x00000000,0x00000000,0x00000000,0x00000000,
714/* 0058 */ 0x00000000,0x00000000,0x00000000,0x00000000,
715/* 005C */ 0x00000000,0x00000000,0x00000000,0x00000000,
716/* 0060 */ 0x00000000,0x00000000,0x00000000,0x00000000,
717/* 0064 */ 0x00000000,0x00000000,0x00000000,0x00000000,
718/* 0068 */ 0x00000000,0x00000000,0x00000000,0x00000000,
719/* 006C */ 0x00000000,0x00000000,0x00000000,0x00000000,
720/* 0070 */ 0x00000000,0x00000000,0x00000000,0x00000000,
721/* 0074 */ 0x00000000,0x00000000,0x00000000,0x00000000,
722/* 0078 */ 0x00000000,0x00000000,0x00000000,0x00000000,
723/* 007C */ 0x00000000,0x00000000,0x00000000,0x00000000,
724/* 0080 */ 0x00000000,0x00000000,0x00000000,0x00000000,
725/* 0084 */ 0x00000000,0x00000000,0x00000000,0x00000000,
726/* 0088 */ 0x00000000,0x00000000,0x00000000,0x00000000,
727/* 008C */ 0x00000000,0x00000000,0x00000000,0x00000000,
728/* 0090 */ 0x00000000,0x00000000,0x00000000,0x00000000,
729/* 0094 */ 0x00000000,0x00000000,0x00000000,0x00000000,
730/* 0098 */ 0x00000000,0x00000000,0x00000000,0x00000000,
731/* 009C */ 0x00000000,0x00000000,0x00000000,0x00000000,
732/* 00A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
733/* 00A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
734/* 00A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
735/* 00AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
736/* 00B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
737/* 00B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
738/* 00B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
739/* 00BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
740/* 00C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
741/* 00C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
742/* 00C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
743/* 00CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
744/* 00D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
745/* 00D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
746/* 00D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
747/* 00DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
748/* 00E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
749/* 00E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
750/* 00E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
751/* 00EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
752/* 00F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
753/* 00F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
754/* 00F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
755/* 00FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
756/* 0100 */ 0x00000000,0x00000000,0x00000000,0x00000000,
757/* 0104 */ 0x00000000,0x00000000,0x00000000,0x00000000,
758/* 0108 */ 0x00000000,0x00000000,0x00000000,0x00000000,
759/* 010C */ 0x00000000,0x00000000,0x00000000,0x00000000,
760/* 0110 */ 0x00000000,0x00000000,0x00000000,0x00000000,
761/* 0114 */ 0x00000000,0x00000000,0x00000000,0x00000000,
762/* 0118 */ 0x00000000,0x00000000,0x00000000,0x00000000,
763/* 011C */ 0x00000000,0x00000000,0x00000000,0x00000000,
764/* 0120 */ 0x00000000,0x00000000,0x00000000,0x00000000,
765/* 0124 */ 0x00000000,0x00000000,0x00000000,0x00000000,
766/* 0128 */ 0x00000000,0x00000000,0x00000000,0x00000000,
767/* 012C */ 0x00000000,0x00000000,0x00000000,0x00000000,
768/* 0130 */ 0x00000000,0x00000000,0x00000000,0x00000000,
769/* 0134 */ 0x00000000,0x00000000,0x00000000,0x00000000,
770/* 0138 */ 0x00000000,0x00000000,0x00000000,0x00000000,
771/* 013C */ 0x00000000,0x00000000,0x00000000,0x00000000,
772/* 0140 */ 0x00000000,0x00000000,0x00000000,0x00000000,
773/* 0144 */ 0x00000000,0x00000000,0x00000000,0x00000000,
774/* 0148 */ 0x00000000,0x00000000,0x00000000,0x00000000,
775/* 014C */ 0x00000000,0x00000000,0x00000000,0x00000000,
776/* 0150 */ 0x00000000,0x00000000,0x00000000,0x00000000,
777/* 0154 */ 0x00000000,0x00000000,0x00000000,0x00000000,
778/* 0158 */ 0x00000000,0x00000000,0x00000000,0x00000000,
779/* 015C */ 0x00000000,0x00000000,0x00000000,0x00000000,
780/* 0160 */ 0x00000000,0x00000000,0x00000000,0x00000000,
781/* 0164 */ 0x00000000,0x00000000,0x00000000,0x00000000,
782/* 0168 */ 0x00000000,0x00000000,0x00000000,0x00000000,
783/* 016C */ 0x00000000,0x00000000,0x00000000,0x00000000,
784/* 0170 */ 0x00000000,0x00000000,0x00000000,0x00000000,
785/* 0174 */ 0x00000000,0x00000000,0x00000000,0x00000000,
786/* 0178 */ 0x00000000,0x00000000,0x00000000,0x00000000,
787/* 017C */ 0x00000000,0x00000000,0x00000000,0x00000000,
788/* 0180 */ 0x00000000,0x00000000,0x00000000,0x00000000,
789/* 0184 */ 0x00000000,0x00000000,0x00000000,0x00000000,
790/* 0188 */ 0x00000000,0x00000000,0x00000000,0x00000000,
791/* 018C */ 0x00000000,0x00000000,0x00000000,0x00000000,
792/* 0190 */ 0x00000000,0x00000000,0x00000000,0x00000000,
793/* 0194 */ 0x00000000,0x00000000,0x00000000,0x00000000,
794/* 0198 */ 0x00000000,0x00000000,0x00000000,0x00000000,
795/* 019C */ 0x00000000,0x00000000,0x00000000,0x00000000,
796/* 01A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
797/* 01A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
798/* 01A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
799/* 01AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
800/* 01B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
801/* 01B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
802/* 01B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
803/* 01BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
804/* 01C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
805/* 01C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
806/* 01C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
807/* 01CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
808/* 01D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
809/* 01D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
810/* 01D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
811/* 01DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
812/* 01E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
813/* 01E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
814/* 01E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
815/* 01EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
816/* 01F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
817/* 01F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
818/* 01F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
819/* 01FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
820/* 0200 */ 0x00000000,0x00000000,0x00000000,0x00000000,
821/* 0204 */ 0x00000000,0x00000000,0x00000000,0x00000000,
822/* 0208 */ 0x00000000,0x00000000,0x00000000,0x00000000,
823/* 020C */ 0x00000000,0x00000000,0x00000000,0x00000000,
824/* 0210 */ 0x00000000,0x00000000,0x00000000,0x00000000,
825/* 0214 */ 0x00000000,0x00000000,0x00000000,0x00000000,
826/* 0218 */ 0x00000000,0x00000000,0x00000000,0x00000000,
827/* 021C */ 0x00000000,0x00000000,0x00000000,0x00000000,
828/* 0220 */ 0x00000000,0x00000000,0x00000000,0x00000000,
829/* 0224 */ 0x00000000,0x00000000,0x00000000,0x00000000,
830/* 0228 */ 0x00000000,0x00000000,0x00000000,0x00000000,
831/* 022C */ 0x00000000,0x00000000,0x00000000,0x00000000,
832/* 0230 */ 0x00000000,0x00000000,0x00000000,0x00000000,
833/* 0234 */ 0x00000000,0x00000000,0x00000000,0x00000000,
834/* 0238 */ 0x00000000,0x00000000,0x00000000,0x00000000,
835/* 023C */ 0x00000000,0x00000000,0x00000000,0x00000000,
836/* 0240 */ 0x00000000,0x00000000,0x00000000,0x00000000,
837/* 0244 */ 0x00000000,0x00000000,0x00000000,0x00000000,
838/* 0248 */ 0x00000000,0x00000000,0x00000000,0x00000000,
839/* 024C */ 0x00000000,0x00000000,0x00000000,0x00000000,
840/* 0250 */ 0x00000000,0x00000000,0x00000000,0x00000000,
841/* 0254 */ 0x00000000,0x00000000,0x00000000,0x00000000,
842/* 0258 */ 0x00000000,0x00000000,0x00000000,0x00000000,
843/* 025C */ 0x00000000,0x00000000,0x00000000,0x00000000,
844/* 0260 */ 0x00000000,0x00000000,0x00000000,0x00000000,
845/* 0264 */ 0x00000000,0x00000000,0x00000000,0x00000000,
846/* 0268 */ 0x00000000,0x00000000,0x00000000,0x00000000,
847/* 026C */ 0x00000000,0x00000000,0x00000000,0x00000000,
848/* 0270 */ 0x00000000,0x00000000,0x00000000,0x00000000,
849/* 0274 */ 0x00000000,0x00000000,0x00000000,0x00000000,
850/* 0278 */ 0x00000000,0x00000000,0x00000000,0x00000000,
851/* 027C */ 0x00000000,0x00000000,0x00000000,0x00000000,
852/* 0280 */ 0x00000000,0x00000000,0x00000000,0x00000000,
853/* 0284 */ 0x00000000,0x00000000,0x00000000,0x00000000,
854/* 0288 */ 0x00000000,0x00000000,0x00000000,0x00000000,
855/* 028C */ 0x00000000,0x00000000,0x00000000,0x00000000,
856/* 0290 */ 0x00000000,0x00000000,0x00000000,0x00000000,
857/* 0294 */ 0x00000000,0x00000000,0x00000000,0x00000000,
858/* 0298 */ 0x00000000,0x00000000,0x00000000,0x00000000,
859/* 029C */ 0x00000000,0x00000000,0x00000000,0x00000000,
860/* 02A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
861/* 02A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
862/* 02A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
863/* 02AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
864/* 02B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
865/* 02B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
866/* 02B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
867/* 02BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
868/* 02C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
869/* 02C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
870/* 02C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
871/* 02CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
872/* 02D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
873/* 02D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
874/* 02D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
875/* 02DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
876/* 02E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
877/* 02E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
878/* 02E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
879/* 02EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
880/* 02F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
881/* 02F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
882/* 02F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
883/* 02FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
884/* 0300 */ 0x00000000,0x00000000,0x00000000,0x00000000,
885/* 0304 */ 0x00000000,0x00000000,0x00000000,0x00000000,
886/* 0308 */ 0x00000000,0x00000000,0x00000000,0x00000000,
887/* 030C */ 0x00000000,0x00000000,0x00000000,0x00000000,
888/* 0310 */ 0x00000000,0x00000000,0x00000000,0x00000000,
889/* 0314 */ 0x00000000,0x00000000,0x00000000,0x00000000,
890/* 0318 */ 0x00000000,0x00000000,0x00000000,0x00000000,
891/* 031C */ 0x00000000,0x00000000,0x00000000,0x00000000,
892/* 0320 */ 0x00000000,0x00000000,0x00000000,0x00000000,
893/* 0324 */ 0x00000000,0x00000000,0x00000000,0x00000000,
894/* 0328 */ 0x00000000,0x00000000,0x00000000,0x00000000,
895/* 032C */ 0x00000000,0x00000000,0x00000000,0x00000000,
896/* 0330 */ 0x00000000,0x00000000,0x00000000,0x00000000,
897/* 0334 */ 0x00000000,0x00000000,0x00000000,0x00000000,
898/* 0338 */ 0x00000000,0x00000000,0x00000000,0x00000000,
899/* 033C */ 0x00000000,0x00000000,0x00000000,0x00000000,
900/* 0340 */ 0x00000000,0x00000000,0x00000000,0x00000000,
901/* 0344 */ 0x00000000,0x00000000,0x00000000,0x00000000,
902/* 0348 */ 0x00000000,0x00000000,0x00000000,0x00000000,
903/* 034C */ 0x00000000,0x00000000,0x00000000,0x00000000,
904/* 0350 */ 0x00000000,0x00000000,0x00000000,0x00000000,
905/* 0354 */ 0x00000000,0x00000000,0x00000000,0x00000000,
906/* 0358 */ 0x00000000,0x00000000,0x00000000,0x00000000,
907/* 035C */ 0x00000000,0x00000000,0x00000000,0x00000000,
908/* 0360 */ 0x00000000,0x00000000,0x00000000,0x00000000,
909/* 0364 */ 0x00000000,0x00000000,0x00000000,0x00000000,
910/* 0368 */ 0x00000000,0x00000000,0x00000000,0x00000000,
911/* 036C */ 0x00000000,0x00000000,0x00000000,0x00000000,
912/* 0370 */ 0x00000000,0x00000000,0x00000000,0x00000000,
913/* 0374 */ 0x00000000,0x00000000,0x00000000,0x00000000,
914/* 0378 */ 0x00000000,0x00000000,0x00000000,0x00000000,
915/* 037C */ 0x00000000,0x00000000,0x00000000,0x00000000,
916/* 0380 */ 0x00000000,0x00000000,0x00000000,0x00000000,
917/* 0384 */ 0x00000000,0x00000000,0x00000000,0x00000000,
918/* 0388 */ 0x00000000,0x00000000,0x00000000,0x00000000,
919/* 038C */ 0x00000000,0x00000000,0x00000000,0x00000000,
920/* 0390 */ 0x00000000,0x00000000,0x00000000,0x00000000,
921/* 0394 */ 0x00000000,0x00000000,0x00000000,0x00000000,
922/* 0398 */ 0x00000000,0x00000000,0x00000000,0x00000000,
923/* 039C */ 0x00000000,0x00000000,0x00000000,0x00000000,
924/* 03A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
925/* 03A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
926/* 03A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
927/* 03AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
928/* 03B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
929/* 03B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
930/* 03B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
931/* 03BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
932/* 03C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
933/* 03C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
934/* 03C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
935/* 03CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
936/* 03D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
937/* 03D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
938/* 03D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
939/* 03DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
940/* 03E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
941/* 03E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
942/* 03E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
943/* 03EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
944/* 03F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
945/* 03F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
946/* 03F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
947/* 03FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
948/* 0400 */ 0x00000000,0x00000000,0x00000000,0x00000000,
949/* 0404 */ 0x00000000,0x00000000,0x00000000,0x00000000,
950/* 0408 */ 0x00000000,0x00000000,0x00000000,0x00000000,
951/* 040C */ 0x00000000,0x00000000,0x00000000,0x00000000,
952/* 0410 */ 0x00000000,0x00000000,0x00000000,0x00000000,
953/* 0414 */ 0x00000000,0x00000000,0x00000000,0x00000000,
954/* 0418 */ 0x00000000,0x00000000,0x00000000,0x00000000,
955/* 041C */ 0x00000000,0x00000000,0x00000000,0x00000000,
956/* 0420 */ 0x00000000,0x00000000,0x00000000,0x00000000,
957/* 0424 */ 0x00000000,0x00000000,0x00000000,0x00000000,
958/* 0428 */ 0x00000000,0x00000000,0x00000000,0x00000000,
959/* 042C */ 0x00000000,0x00000000,0x00000000,0x00000000,
960/* 0430 */ 0x00000000,0x00000000,0x00000000,0x00000000,
961/* 0434 */ 0x00000000,0x00000000,0x00000000,0x00000000,
962/* 0438 */ 0x00000000,0x00000000,0x00000000,0x00000000,
963/* 043C */ 0x00000000,0x00000000,0x00000000,0x00000000,
964/* 0440 */ 0x00000000,0x00000000,0x00000000,0x00000000,
965/* 0444 */ 0x00000000,0x00000000,0x00000000,0x00000000,
966/* 0448 */ 0x00000000,0x00000000,0x00000000,0x00000000,
967/* 044C */ 0x00000000,0x00000000,0x00000000,0x00000000,
968/* 0450 */ 0x00000000,0x00000000,0x00000000,0x00000000,
969/* 0454 */ 0x00000000,0x00000000,0x00000000,0x00000000,
970/* 0458 */ 0x00000000,0x00000000,0x00000000,0x00000000,
971/* 045C */ 0x00000000,0x00000000,0x00000000,0x00000000,
972/* 0460 */ 0x00000000,0x00000000,0x00000000,0x00000000,
973/* 0464 */ 0x00000000,0x00000000,0x00000000,0x00000000,
974/* 0468 */ 0x00000000,0x00000000,0x00000000,0x00000000,
975/* 046C */ 0x00000000,0x00000000,0x00000000,0x00000000,
976/* 0470 */ 0x00000000,0x00000000,0x00000000,0x00000000,
977/* 0474 */ 0x00000000,0x00000000,0x00000000,0x00000000,
978/* 0478 */ 0x00000000,0x00000000,0x00000000,0x00000000,
979/* 047C */ 0x00000000,0x00000000,0x00000000,0x00000000,
980/* 0480 */ 0x00000000,0x00000000,0x00000000,0x00000000,
981/* 0484 */ 0x00000000,0x00000000,0x00000000,0x00000000,
982/* 0488 */ 0x00000000,0x00000000,0x00000000,0x00000000,
983/* 048C */ 0x00000000,0x00000000,0x00000000,0x00000000,
984/* 0490 */ 0x00000000,0x00000000,0x00000000,0x00000000,
985/* 0494 */ 0x00000000,0x00000000,0x00000000,0x00000000,
986/* 0498 */ 0x00000000,0x00000000,0x00000000,0x00000000,
987/* 049C */ 0x00000000,0x00000000,0x00000000,0x00000000,
988/* 04A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
989/* 04A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
990/* 04A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
991/* 04AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
992/* 04B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
993/* 04B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
994/* 04B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
995/* 04BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
996/* 04C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
997/* 04C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
998/* 04C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
999/* 04CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1000/* 04D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1001/* 04D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1002/* 04D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1003/* 04DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1004/* 04E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1005/* 04E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1006/* 04E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1007/* 04EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1008/* 04F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1009/* 04F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1010/* 04F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1011/* 04FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1012/* 0500 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1013/* 0504 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1014/* 0508 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1015/* 050C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1016/* 0510 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1017/* 0514 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1018/* 0518 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1019/* 051C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1020/* 0520 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1021/* 0524 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1022/* 0528 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1023/* 052C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1024/* 0530 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1025/* 0534 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1026/* 0538 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1027/* 053C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1028/* 0540 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1029/* 0544 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1030/* 0548 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1031/* 054C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1032/* 0550 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1033/* 0554 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1034/* 0558 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1035/* 055C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1036/* 0560 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1037/* 0564 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1038/* 0568 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1039/* 056C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1040/* 0570 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1041/* 0574 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1042/* 0578 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1043/* 057C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1044/* 0580 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1045/* 0584 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1046/* 0588 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1047/* 058C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1048/* 0590 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1049/* 0594 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1050/* 0598 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1051/* 059C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1052/* 05A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1053/* 05A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1054/* 05A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1055/* 05AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1056/* 05B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1057/* 05B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1058/* 05B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1059/* 05BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1060/* 05C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1061/* 05C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1062/* 05C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1063/* 05CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1064/* 05D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1065/* 05D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1066/* 05D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1067/* 05DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1068/* 05E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1069/* 05E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1070/* 05E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1071/* 05EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1072/* 05F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1073/* 05F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1074/* 05F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1075/* 05FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1076/* 0600 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1077/* 0604 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1078/* 0608 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1079/* 060C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1080/* 0610 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1081/* 0614 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1082/* 0618 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1083/* 061C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1084/* 0620 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1085/* 0624 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1086/* 0628 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1087/* 062C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1088/* 0630 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1089/* 0634 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1090/* 0638 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1091/* 063C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1092/* 0640 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1093/* 0644 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1094/* 0648 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1095/* 064C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1096/* 0650 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1097/* 0654 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1098/* 0658 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1099/* 065C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1100/* 0660 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1101/* 0664 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1102/* 0668 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1103/* 066C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1104/* 0670 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1105/* 0674 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1106/* 0678 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1107/* 067C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1108/* 0680 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1109/* 0684 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1110/* 0688 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1111/* 068C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1112/* 0690 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1113/* 0694 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1114/* 0698 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1115/* 069C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1116/* 06A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1117/* 06A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1118/* 06A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1119/* 06AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1120/* 06B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1121/* 06B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1122/* 06B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1123/* 06BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1124/* 06C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1125/* 06C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1126/* 06C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1127/* 06CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1128/* 06D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1129/* 06D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1130/* 06D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1131/* 06DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1132/* 06E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1133/* 06E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1134/* 06E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1135/* 06EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1136/* 06F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1137/* 06F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1138/* 06F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1139/* 06FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1140/* 0700 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1141/* 0704 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1142/* 0708 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1143/* 070C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1144/* 0710 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1145/* 0714 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1146/* 0718 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1147/* 071C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1148/* 0720 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1149/* 0724 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1150/* 0728 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1151/* 072C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1152/* 0730 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1153/* 0734 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1154/* 0738 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1155/* 073C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1156/* 0740 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1157/* 0744 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1158/* 0748 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1159/* 074C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1160/* 0750 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1161/* 0754 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1162/* 0758 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1163/* 075C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1164/* 0760 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1165/* 0764 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1166/* 0768 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1167/* 076C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1168/* 0770 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1169/* 0774 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1170/* 0778 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1171/* 077C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1172/* 0780 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1173/* 0784 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1174/* 0788 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1175/* 078C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1176/* 0790 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1177/* 0794 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1178/* 0798 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1179/* 079C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1180/* 07A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1181/* 07A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1182/* 07A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1183/* 07AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1184/* 07B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1185/* 07B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1186/* 07B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1187/* 07BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1188/* 07C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1189/* 07C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1190/* 07C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1191/* 07CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1192/* 07D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1193/* 07D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1194/* 07D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1195/* 07DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1196/* 07E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1197/* 07E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1198/* 07E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1199/* 07EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1200/* 07F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1201/* 07F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1202/* 07F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1203/* 07FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1204/* 0800 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1205/* 0804 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1206/* 0808 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1207/* 080C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1208/* 0810 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1209/* 0814 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1210/* 0818 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1211/* 081C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1212/* 0820 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1213/* 0824 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1214/* 0828 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1215/* 082C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1216/* 0830 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1217/* 0834 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1218/* 0838 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1219/* 083C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1220/* 0840 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1221/* 0844 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1222/* 0848 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1223/* 084C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1224/* 0850 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1225/* 0854 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1226/* 0858 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1227/* 085C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1228/* 0860 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1229/* 0864 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1230/* 0868 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1231/* 086C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1232/* 0870 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1233/* 0874 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1234/* 0878 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1235/* 087C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1236/* 0880 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1237/* 0884 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1238/* 0888 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1239/* 088C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1240/* 0890 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1241/* 0894 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1242/* 0898 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1243/* 089C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1244/* 08A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1245/* 08A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1246/* 08A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1247/* 08AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1248/* 08B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1249/* 08B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1250/* 08B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1251/* 08BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1252/* 08C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1253/* 08C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1254/* 08C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1255/* 08CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1256/* 08D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1257/* 08D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1258/* 08D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1259/* 08DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1260/* 08E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1261/* 08E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1262/* 08E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1263/* 08EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1264/* 08F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1265/* 08F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1266/* 08F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1267/* 08FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1268/* 0900 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1269/* 0904 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1270/* 0908 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1271/* 090C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1272/* 0910 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1273/* 0914 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1274/* 0918 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1275/* 091C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1276/* 0920 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1277/* 0924 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1278/* 0928 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1279/* 092C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1280/* 0930 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1281/* 0934 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1282/* 0938 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1283/* 093C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1284/* 0940 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1285/* 0944 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1286/* 0948 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1287/* 094C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1288/* 0950 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1289/* 0954 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1290/* 0958 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1291/* 095C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1292/* 0960 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1293/* 0964 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1294/* 0968 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1295/* 096C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1296/* 0970 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1297/* 0974 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1298/* 0978 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1299/* 097C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1300/* 0980 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1301/* 0984 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1302/* 0988 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1303/* 098C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1304/* 0990 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1305/* 0994 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1306/* 0998 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1307/* 099C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1308/* 09A0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1309/* 09A4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1310/* 09A8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1311/* 09AC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1312/* 09B0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1313/* 09B4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1314/* 09B8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1315/* 09BC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1316/* 09C0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1317/* 09C4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1318/* 09C8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1319/* 09CC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1320/* 09D0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1321/* 09D4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1322/* 09D8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1323/* 09DC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1324/* 09E0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1325/* 09E4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1326/* 09E8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1327/* 09EC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1328/* 09F0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1329/* 09F4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1330/* 09F8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1331/* 09FC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1332/* 0A00 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1333/* 0A04 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1334/* 0A08 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1335/* 0A0C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1336/* 0A10 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1337/* 0A14 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1338/* 0A18 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1339/* 0A1C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1340/* 0A20 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1341/* 0A24 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1342/* 0A28 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1343/* 0A2C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1344/* 0A30 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1345/* 0A34 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1346/* 0A38 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1347/* 0A3C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1348/* 0A40 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1349/* 0A44 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1350/* 0A48 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1351/* 0A4C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1352/* 0A50 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1353/* 0A54 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1354/* 0A58 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1355/* 0A5C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1356/* 0A60 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1357/* 0A64 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1358/* 0A68 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1359/* 0A6C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1360/* 0A70 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1361/* 0A74 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1362/* 0A78 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1363/* 0A7C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1364/* 0A80 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1365/* 0A84 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1366/* 0A88 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1367/* 0A8C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1368/* 0A90 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1369/* 0A94 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1370/* 0A98 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1371/* 0A9C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1372/* 0AA0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1373/* 0AA4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1374/* 0AA8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1375/* 0AAC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1376/* 0AB0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1377/* 0AB4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1378/* 0AB8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1379/* 0ABC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1380/* 0AC0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1381/* 0AC4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1382/* 0AC8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1383/* 0ACC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1384/* 0AD0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1385/* 0AD4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1386/* 0AD8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1387/* 0ADC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1388/* 0AE0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1389/* 0AE4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1390/* 0AE8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1391/* 0AEC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1392/* 0AF0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1393/* 0AF4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1394/* 0AF8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1395/* 0AFC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1396/* 0B00 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1397/* 0B04 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1398/* 0B08 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1399/* 0B0C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1400/* 0B10 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1401/* 0B14 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1402/* 0B18 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1403/* 0B1C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1404/* 0B20 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1405/* 0B24 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1406/* 0B28 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1407/* 0B2C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1408/* 0B30 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1409/* 0B34 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1410/* 0B38 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1411/* 0B3C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1412/* 0B40 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1413/* 0B44 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1414/* 0B48 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1415/* 0B4C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1416/* 0B50 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1417/* 0B54 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1418/* 0B58 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1419/* 0B5C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1420/* 0B60 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1421/* 0B64 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1422/* 0B68 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1423/* 0B6C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1424/* 0B70 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1425/* 0B74 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1426/* 0B78 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1427/* 0B7C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1428/* 0B80 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1429/* 0B84 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1430/* 0B88 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1431/* 0B8C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1432/* 0B90 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1433/* 0B94 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1434/* 0B98 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1435/* 0B9C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1436/* 0BA0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1437/* 0BA4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1438/* 0BA8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1439/* 0BAC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1440/* 0BB0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1441/* 0BB4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1442/* 0BB8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1443/* 0BBC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1444/* 0BC0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1445/* 0BC4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1446/* 0BC8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1447/* 0BCC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1448/* 0BD0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1449/* 0BD4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1450/* 0BD8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1451/* 0BDC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1452/* 0BE0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1453/* 0BE4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1454/* 0BE8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1455/* 0BEC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1456/* 0BF0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1457/* 0BF4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1458/* 0BF8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1459/* 0BFC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1460/* 0C00 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1461/* 0C04 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1462/* 0C08 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1463/* 0C0C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1464/* 0C10 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1465/* 0C14 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1466/* 0C18 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1467/* 0C1C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1468/* 0C20 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1469/* 0C24 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1470/* 0C28 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1471/* 0C2C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1472/* 0C30 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1473/* 0C34 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1474/* 0C38 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1475/* 0C3C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1476/* 0C40 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1477/* 0C44 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1478/* 0C48 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1479/* 0C4C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1480/* 0C50 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1481/* 0C54 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1482/* 0C58 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1483/* 0C5C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1484/* 0C60 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1485/* 0C64 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1486/* 0C68 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1487/* 0C6C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1488/* 0C70 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1489/* 0C74 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1490/* 0C78 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1491/* 0C7C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1492/* 0C80 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1493/* 0C84 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1494/* 0C88 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1495/* 0C8C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1496/* 0C90 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1497/* 0C94 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1498/* 0C98 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1499/* 0C9C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1500/* 0CA0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1501/* 0CA4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1502/* 0CA8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1503/* 0CAC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1504/* 0CB0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1505/* 0CB4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1506/* 0CB8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1507/* 0CBC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1508/* 0CC0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1509/* 0CC4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1510/* 0CC8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1511/* 0CCC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1512/* 0CD0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1513/* 0CD4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1514/* 0CD8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1515/* 0CDC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1516/* 0CE0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1517/* 0CE4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1518/* 0CE8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1519/* 0CEC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1520/* 0CF0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1521/* 0CF4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1522/* 0CF8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1523/* 0CFC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1524/* 0D00 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1525/* 0D04 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1526/* 0D08 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1527/* 0D0C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1528/* 0D10 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1529/* 0D14 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1530/* 0D18 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1531/* 0D1C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1532/* 0D20 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1533/* 0D24 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1534/* 0D28 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1535/* 0D2C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1536/* 0D30 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1537/* 0D34 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1538/* 0D38 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1539/* 0D3C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1540/* 0D40 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1541/* 0D44 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1542/* 0D48 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1543/* 0D4C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1544/* 0D50 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1545/* 0D54 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1546/* 0D58 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1547/* 0D5C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1548/* 0D60 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1549/* 0D64 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1550/* 0D68 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1551/* 0D6C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1552/* 0D70 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1553/* 0D74 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1554/* 0D78 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1555/* 0D7C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1556/* 0D80 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1557/* 0D84 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1558/* 0D88 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1559/* 0D8C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1560/* 0D90 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1561/* 0D94 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1562/* 0D98 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1563/* 0D9C */ 0x00000000,0x00000000,0x00000000,0x00000000,
1564/* 0DA0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1565/* 0DA4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1566/* 0DA8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1567/* 0DAC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1568/* 0DB0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1569/* 0DB4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1570/* 0DB8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1571/* 0DBC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1572/* 0DC0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1573/* 0DC4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1574/* 0DC8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1575/* 0DCC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1576/* 0DD0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1577/* 0DD4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1578/* 0DD8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1579/* 0DDC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1580/* 0DE0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1581/* 0DE4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1582/* 0DE8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1583/* 0DEC */ 0x00000000,0x00000000,0x00000000,0x00000000,
1584/* 0DF0 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1585/* 0DF4 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1586/* 0DF8 */ 0x00000000,0x00000000,0x00000000,0x00000000,
1587/* 0DFC */ 0x00000000,0x00000000,0x00000000,0x00010004
1588}; /* #SAMPLE_END */
1589
1590
1591static struct dsp_segment_desc cwcemb80_segments[] = {
1592 { SEGTYPE_SP_PROGRAM, 0x00000000, 0x0000031c, cwcemb80_code },
1593 { SEGTYPE_SP_PARAMETER, 0x00000000, 0x00000697, cwcemb80_parameter },
1594 { SEGTYPE_SP_SAMPLE, 0x00000000, 0x00000e00, cwcemb80_sample },
1595};
1596
1597static struct dsp_module_desc cwcemb80_module = {
1598 "cwcemb80",
1599 {
1600 38,
1601 cwcemb80_symbols
1602 },
1603 3,
1604 cwcemb80_segments,
1605};
1606
1607#endif /* __HEADER_cwcemb80_H__ */
diff --git a/sound/pci/echoaudio/darla20.c b/sound/pci/echoaudio/darla20.c
index 8e7fe033270f..87078d3a6854 100644
--- a/sound/pci/echoaudio/darla20.c
+++ b/sound/pci/echoaudio/darla20.c
@@ -56,6 +56,8 @@
56#include <asm/atomic.h> 56#include <asm/atomic.h>
57#include "echoaudio.h" 57#include "echoaudio.h"
58 58
59MODULE_FIRMWARE("ea/darla20_dsp.fw");
60
59#define FW_DARLA20_DSP 0 61#define FW_DARLA20_DSP 0
60 62
61static const struct firmware card_fw[] = { 63static const struct firmware card_fw[] = {
diff --git a/sound/pci/echoaudio/darla24.c b/sound/pci/echoaudio/darla24.c
index a13c623eb999..42b48f9d2128 100644
--- a/sound/pci/echoaudio/darla24.c
+++ b/sound/pci/echoaudio/darla24.c
@@ -60,6 +60,8 @@
60#include <asm/atomic.h> 60#include <asm/atomic.h>
61#include "echoaudio.h" 61#include "echoaudio.h"
62 62
63MODULE_FIRMWARE("ea/darla24_dsp.fw");
64
63#define FW_DARLA24_DSP 0 65#define FW_DARLA24_DSP 0
64 66
65static const struct firmware card_fw[] = { 67static const struct firmware card_fw[] = {
diff --git a/sound/pci/echoaudio/echo3g.c b/sound/pci/echoaudio/echo3g.c
index 8fb15823aca5..8dbb7ac865c1 100644
--- a/sound/pci/echoaudio/echo3g.c
+++ b/sound/pci/echoaudio/echo3g.c
@@ -68,6 +68,10 @@
68#include <asm/atomic.h> 68#include <asm/atomic.h>
69#include "echoaudio.h" 69#include "echoaudio.h"
70 70
71MODULE_FIRMWARE("ea/loader_dsp.fw");
72MODULE_FIRMWARE("ea/echo3g_dsp.fw");
73MODULE_FIRMWARE("ea/3g_asic.fw");
74
71#define FW_361_LOADER 0 75#define FW_361_LOADER 0
72#define FW_ECHO3G_DSP 1 76#define FW_ECHO3G_DSP 1
73#define FW_3G_ASIC 2 77#define FW_3G_ASIC 2
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index e413da00759b..f27b6a733b96 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -705,11 +705,9 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
705 struct audiopipe *pipe = runtime->private_data; 705 struct audiopipe *pipe = runtime->private_data;
706 int i, err; 706 int i, err;
707 u32 channelmask = 0; 707 u32 channelmask = 0;
708 struct list_head *pos;
709 struct snd_pcm_substream *s; 708 struct snd_pcm_substream *s;
710 709
711 snd_pcm_group_for_each(pos, substream) { 710 snd_pcm_group_for_each_entry(s, substream) {
712 s = snd_pcm_group_substream_entry(pos);
713 for (i = 0; i < DSP_MAXPIPES; i++) { 711 for (i = 0; i < DSP_MAXPIPES; i++) {
714 if (s == chip->substream[i]) { 712 if (s == chip->substream[i]) {
715 channelmask |= 1 << i; 713 channelmask |= 1 << i;
diff --git a/sound/pci/echoaudio/echoaudio_3g.c b/sound/pci/echoaudio/echoaudio_3g.c
index 9f439ea459f4..52a933189576 100644
--- a/sound/pci/echoaudio/echoaudio_3g.c
+++ b/sound/pci/echoaudio/echoaudio_3g.c
@@ -233,8 +233,8 @@ static int load_asic(struct echoaudio *chip)
233 233
234 chip->asic_code = &card_fw[FW_3G_ASIC]; 234 chip->asic_code = &card_fw[FW_3G_ASIC];
235 235
236 /* Now give the new ASIC a little time to set up */ 236 /* Now give the new ASIC some time to set up */
237 mdelay(2); 237 msleep(1000);
238 /* See if it worked */ 238 /* See if it worked */
239 box_type = check_asic_status(chip); 239 box_type = check_asic_status(chip);
240 240
diff --git a/sound/pci/echoaudio/gina20.c b/sound/pci/echoaudio/gina20.c
index af4d32026e4a..fee2d4831732 100644
--- a/sound/pci/echoaudio/gina20.c
+++ b/sound/pci/echoaudio/gina20.c
@@ -60,6 +60,8 @@
60#include <asm/atomic.h> 60#include <asm/atomic.h>
61#include "echoaudio.h" 61#include "echoaudio.h"
62 62
63MODULE_FIRMWARE("ea/gina20_dsp.fw");
64
63#define FW_GINA20_DSP 0 65#define FW_GINA20_DSP 0
64 66
65static const struct firmware card_fw[] = { 67static const struct firmware card_fw[] = {
diff --git a/sound/pci/echoaudio/gina24.c b/sound/pci/echoaudio/gina24.c
index 9ff454a947ed..d5eae470fe9a 100644
--- a/sound/pci/echoaudio/gina24.c
+++ b/sound/pci/echoaudio/gina24.c
@@ -66,6 +66,12 @@
66#include <asm/atomic.h> 66#include <asm/atomic.h>
67#include "echoaudio.h" 67#include "echoaudio.h"
68 68
69MODULE_FIRMWARE("ea/loader_dsp.fw");
70MODULE_FIRMWARE("ea/gina24_301_dsp.fw");
71MODULE_FIRMWARE("ea/gina24_361_dsp.fw");
72MODULE_FIRMWARE("ea/gina24_301_asic.fw");
73MODULE_FIRMWARE("ea/gina24_361_asic.fw");
74
69#define FW_361_LOADER 0 75#define FW_361_LOADER 0
70#define FW_GINA24_301_DSP 1 76#define FW_GINA24_301_DSP 1
71#define FW_GINA24_361_DSP 2 77#define FW_GINA24_361_DSP 2
diff --git a/sound/pci/echoaudio/indigo.c b/sound/pci/echoaudio/indigo.c
index 37eb726fd03d..40f601cd016f 100644
--- a/sound/pci/echoaudio/indigo.c
+++ b/sound/pci/echoaudio/indigo.c
@@ -58,6 +58,9 @@
58#include <asm/atomic.h> 58#include <asm/atomic.h>
59#include "echoaudio.h" 59#include "echoaudio.h"
60 60
61MODULE_FIRMWARE("ea/loader_dsp.fw");
62MODULE_FIRMWARE("ea/indigo_dsp.fw");
63
61#define FW_361_LOADER 0 64#define FW_361_LOADER 0
62#define FW_INDIGO_DSP 1 65#define FW_INDIGO_DSP 1
63 66
diff --git a/sound/pci/echoaudio/indigodj.c b/sound/pci/echoaudio/indigodj.c
index dc8b91824181..771c5383210d 100644
--- a/sound/pci/echoaudio/indigodj.c
+++ b/sound/pci/echoaudio/indigodj.c
@@ -58,6 +58,9 @@
58#include <asm/atomic.h> 58#include <asm/atomic.h>
59#include "echoaudio.h" 59#include "echoaudio.h"
60 60
61MODULE_FIRMWARE("ea/loader_dsp.fw");
62MODULE_FIRMWARE("ea/indigo_dj_dsp.fw");
63
61#define FW_361_LOADER 0 64#define FW_361_LOADER 0
62#define FW_INDIGO_DJ_DSP 1 65#define FW_INDIGO_DJ_DSP 1
63 66
diff --git a/sound/pci/echoaudio/indigoio.c b/sound/pci/echoaudio/indigoio.c
index eadf3263453a..49c550defcf9 100644
--- a/sound/pci/echoaudio/indigoio.c
+++ b/sound/pci/echoaudio/indigoio.c
@@ -59,6 +59,9 @@
59#include <asm/atomic.h> 59#include <asm/atomic.h>
60#include "echoaudio.h" 60#include "echoaudio.h"
61 61
62MODULE_FIRMWARE("ea/loader_dsp.fw");
63MODULE_FIRMWARE("ea/indigo_io_dsp.fw");
64
62#define FW_361_LOADER 0 65#define FW_361_LOADER 0
63#define FW_INDIGO_IO_DSP 1 66#define FW_INDIGO_IO_DSP 1
64 67
diff --git a/sound/pci/echoaudio/layla20.c b/sound/pci/echoaudio/layla20.c
index 6cede497579e..8f5483a405ae 100644
--- a/sound/pci/echoaudio/layla20.c
+++ b/sound/pci/echoaudio/layla20.c
@@ -66,6 +66,9 @@
66#include <asm/atomic.h> 66#include <asm/atomic.h>
67#include "echoaudio.h" 67#include "echoaudio.h"
68 68
69MODULE_FIRMWARE("ea/layla20_dsp.fw");
70MODULE_FIRMWARE("ea/layla20_asic.fw");
71
69#define FW_LAYLA20_DSP 0 72#define FW_LAYLA20_DSP 0
70#define FW_LAYLA20_ASIC 1 73#define FW_LAYLA20_ASIC 1
71 74
diff --git a/sound/pci/echoaudio/layla24.c b/sound/pci/echoaudio/layla24.c
index 44f735426aa0..0524667c02f7 100644
--- a/sound/pci/echoaudio/layla24.c
+++ b/sound/pci/echoaudio/layla24.c
@@ -68,6 +68,12 @@
68#include <asm/atomic.h> 68#include <asm/atomic.h>
69#include "echoaudio.h" 69#include "echoaudio.h"
70 70
71MODULE_FIRMWARE("ea/loader_dsp.fw");
72MODULE_FIRMWARE("ea/layla24_dsp.fw");
73MODULE_FIRMWARE("ea/layla24_1_asic.fw");
74MODULE_FIRMWARE("ea/layla24_2A_asic.fw");
75MODULE_FIRMWARE("ea/layla24_2S_asic.fw");
76
71#define FW_361_LOADER 0 77#define FW_361_LOADER 0
72#define FW_LAYLA24_DSP 1 78#define FW_LAYLA24_DSP 1
73#define FW_LAYLA24_1_ASIC 2 79#define FW_LAYLA24_1_ASIC 2
diff --git a/sound/pci/echoaudio/mia.c b/sound/pci/echoaudio/mia.c
index dc172d03ac3f..893c7c20dd70 100644
--- a/sound/pci/echoaudio/mia.c
+++ b/sound/pci/echoaudio/mia.c
@@ -66,6 +66,9 @@
66#include <asm/atomic.h> 66#include <asm/atomic.h>
67#include "echoaudio.h" 67#include "echoaudio.h"
68 68
69MODULE_FIRMWARE("ea/loader_dsp.fw");
70MODULE_FIRMWARE("ea/mia_dsp.fw");
71
69#define FW_361_LOADER 0 72#define FW_361_LOADER 0
70#define FW_MIA_DSP 1 73#define FW_MIA_DSP 1
71 74
diff --git a/sound/pci/echoaudio/mona.c b/sound/pci/echoaudio/mona.c
index c856ed50dd9a..3a5d5b0020df 100644
--- a/sound/pci/echoaudio/mona.c
+++ b/sound/pci/echoaudio/mona.c
@@ -64,6 +64,15 @@
64#include <asm/atomic.h> 64#include <asm/atomic.h>
65#include "echoaudio.h" 65#include "echoaudio.h"
66 66
67MODULE_FIRMWARE("ea/loader_dsp.fw");
68MODULE_FIRMWARE("ea/mona_301_dsp.fw");
69MODULE_FIRMWARE("ea/mona_361_dsp.fw");
70MODULE_FIRMWARE("ea/mona_301_1_asic_48.fw");
71MODULE_FIRMWARE("ea/mona_301_1_asic_96.fw");
72MODULE_FIRMWARE("ea/mona_361_1_asic_48.fw");
73MODULE_FIRMWARE("ea/mona_361_1_asic_96.fw");
74MODULE_FIRMWARE("ea/mona_2_asic.fw");
75
67#define FW_361_LOADER 0 76#define FW_361_LOADER 0
68#define FW_MONA_301_DSP 1 77#define FW_MONA_301_DSP 1
69#define FW_MONA_361_DSP 2 78#define FW_MONA_361_DSP 2
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 80aa585eade4..dbc805c33fc4 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -49,6 +49,13 @@
49#include "p17v.h" 49#include "p17v.h"
50 50
51 51
52#define HANA_FILENAME "emu/hana.fw"
53#define DOCK_FILENAME "emu/audio_dock.fw"
54
55MODULE_FIRMWARE(HANA_FILENAME);
56MODULE_FIRMWARE(DOCK_FILENAME);
57
58
52/************************************************************************* 59/*************************************************************************
53 * EMU10K1 init / done 60 * EMU10K1 init / done
54 *************************************************************************/ 61 *************************************************************************/
@@ -693,8 +700,6 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
693 int tmp,tmp2; 700 int tmp,tmp2;
694 int reg; 701 int reg;
695 int err; 702 int err;
696 const char *hana_filename = "emu/hana.fw";
697 const char *dock_filename = "emu/audio_dock.fw";
698 703
699 snd_printk(KERN_INFO "emu1010: Special config.\n"); 704 snd_printk(KERN_INFO "emu1010: Special config.\n");
700 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, 705 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave,
@@ -735,8 +740,8 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
735 return -ENODEV; 740 return -ENODEV;
736 } 741 }
737 snd_printk(KERN_INFO "emu1010: EMU_HANA_ID=0x%x\n",reg); 742 snd_printk(KERN_INFO "emu1010: EMU_HANA_ID=0x%x\n",reg);
738 if ((err = snd_emu1010_load_firmware(emu, hana_filename)) != 0) { 743 if ((err = snd_emu1010_load_firmware(emu, HANA_FILENAME)) != 0) {
739 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file %s failed\n", hana_filename); 744 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file %s failed\n", HANA_FILENAME);
740 return err; 745 return err;
741 } 746 }
742 747
@@ -938,7 +943,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
938 /* Return to Audio Dock programming mode */ 943 /* Return to Audio Dock programming mode */
939 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n"); 944 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n");
940 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK ); 945 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK );
941 if ((err = snd_emu1010_load_firmware(emu, dock_filename)) != 0) { 946 if ((err = snd_emu1010_load_firmware(emu, DOCK_FILENAME)) != 0) {
942 return err; 947 return err;
943 } 948 }
944 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0 ); 949 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0 );
@@ -1216,6 +1221,15 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1216 .spi_dac = 1, 1221 .spi_dac = 1,
1217 .i2c_adc = 1, 1222 .i2c_adc = 1,
1218 .spk71 = 1} , 1223 .spk71 = 1} ,
1224 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x42011102,
1225 .driver = "Audigy2", .name = "E-mu 1010 Notebook [MAEM8950]",
1226 .id = "EMU1010",
1227 .emu10k2_chip = 1,
1228 .ca0108_chip = 1,
1229 .ca_cardbus_chip = 1,
1230 .spi_dac = 1,
1231 .i2c_adc = 1,
1232 .spk71 = 1} ,
1219 {.vendor = 0x1102, .device = 0x0008, 1233 {.vendor = 0x1102, .device = 0x0008,
1220 .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", 1234 .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]",
1221 .id = "Audigy2", 1235 .id = "Audigy2",
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c
index 465f8d505329..7ee19c63c2c8 100644
--- a/sound/pci/emu10k1/p16v.c
+++ b/sound/pci/emu10k1/p16v.c
@@ -433,7 +433,6 @@ static int snd_p16v_pcm_trigger_playback(struct snd_pcm_substream *substream,
433 struct snd_emu10k1_pcm *epcm; 433 struct snd_emu10k1_pcm *epcm;
434 int channel; 434 int channel;
435 int result = 0; 435 int result = 0;
436 struct list_head *pos;
437 struct snd_pcm_substream *s; 436 struct snd_pcm_substream *s;
438 u32 basic = 0; 437 u32 basic = 0;
439 u32 inte = 0; 438 u32 inte = 0;
@@ -448,8 +447,7 @@ static int snd_p16v_pcm_trigger_playback(struct snd_pcm_substream *substream,
448 running = 0; 447 running = 0;
449 break; 448 break;
450 } 449 }
451 snd_pcm_group_for_each(pos, substream) { 450 snd_pcm_group_for_each_entry(s, substream) {
452 s = snd_pcm_group_substream_entry(pos);
453 runtime = s->runtime; 451 runtime = s->runtime;
454 epcm = runtime->private_data; 452 epcm = runtime->private_data;
455 channel = substream->pcm->device-emu->p16v_device_offset; 453 channel = substream->pcm->device-emu->p16v_device_offset;
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index 425b167522d5..6a0ddcf00884 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -798,10 +798,8 @@ static int snd_ensoniq_trigger(struct snd_pcm_substream *substream, int cmd)
798 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 798 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
799 { 799 {
800 unsigned int what = 0; 800 unsigned int what = 0;
801 struct list_head *pos;
802 struct snd_pcm_substream *s; 801 struct snd_pcm_substream *s;
803 snd_pcm_group_for_each(pos, substream) { 802 snd_pcm_group_for_each_entry(s, substream) {
804 s = snd_pcm_group_substream_entry(pos);
805 if (s == ensoniq->playback1_substream) { 803 if (s == ensoniq->playback1_substream) {
806 what |= ES_P1_PAUSE; 804 what |= ES_P1_PAUSE;
807 snd_pcm_trigger_done(s, substream); 805 snd_pcm_trigger_done(s, substream);
@@ -824,10 +822,8 @@ static int snd_ensoniq_trigger(struct snd_pcm_substream *substream, int cmd)
824 case SNDRV_PCM_TRIGGER_STOP: 822 case SNDRV_PCM_TRIGGER_STOP:
825 { 823 {
826 unsigned int what = 0; 824 unsigned int what = 0;
827 struct list_head *pos;
828 struct snd_pcm_substream *s; 825 struct snd_pcm_substream *s;
829 snd_pcm_group_for_each(pos, substream) { 826 snd_pcm_group_for_each_entry(s, substream) {
830 s = snd_pcm_group_substream_entry(pos);
831 if (s == ensoniq->playback1_substream) { 827 if (s == ensoniq->playback1_substream) {
832 what |= ES_DAC1_EN; 828 what |= ES_DAC1_EN;
833 snd_pcm_trigger_done(s, substream); 829 snd_pcm_trigger_done(s, substream);
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index dc84c189b05f..2faf009076bb 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -1554,10 +1554,7 @@ static int snd_es1968_playback_open(struct snd_pcm_substream *substream)
1554 runtime->hw = snd_es1968_playback; 1554 runtime->hw = snd_es1968_playback;
1555 runtime->hw.buffer_bytes_max = runtime->hw.period_bytes_max = 1555 runtime->hw.buffer_bytes_max = runtime->hw.period_bytes_max =
1556 calc_available_memory_size(chip); 1556 calc_available_memory_size(chip);
1557#if 0 1557
1558 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
1559 1024);
1560#endif
1561 spin_lock_irq(&chip->substream_lock); 1558 spin_lock_irq(&chip->substream_lock);
1562 list_add(&es->list, &chip->substream_list); 1559 list_add(&es->list, &chip->substream_list);
1563 spin_unlock_irq(&chip->substream_lock); 1560 spin_unlock_irq(&chip->substream_lock);
@@ -1613,10 +1610,8 @@ static int snd_es1968_capture_open(struct snd_pcm_substream *substream)
1613 runtime->hw = snd_es1968_capture; 1610 runtime->hw = snd_es1968_capture;
1614 runtime->hw.buffer_bytes_max = runtime->hw.period_bytes_max = 1611 runtime->hw.buffer_bytes_max = runtime->hw.period_bytes_max =
1615 calc_available_memory_size(chip) - 1024; /* keep MIXBUF size */ 1612 calc_available_memory_size(chip) - 1024; /* keep MIXBUF size */
1616#if 0 1613 snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES);
1617 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 1614
1618 1024);
1619#endif
1620 spin_lock_irq(&chip->substream_lock); 1615 spin_lock_irq(&chip->substream_lock);
1621 list_add(&es->list, &chip->substream_list); 1616 list_add(&es->list, &chip->substream_list);
1622 spin_unlock_irq(&chip->substream_lock); 1617 spin_unlock_irq(&chip->substream_lock);
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
index 60d7b05a204a..b2484bbdcc1d 100644
--- a/sound/pci/hda/Makefile
+++ b/sound/pci/hda/Makefile
@@ -1,5 +1,8 @@
1snd-hda-intel-objs := hda_intel.o 1snd-hda-intel-objs := hda_intel.o
2snd-hda-codec-objs := hda_codec.o \ 2# since snd-hda-intel is the only driver using hda-codec,
3# merge it into a single module although it was originally
4# designed to be individual modules
5snd-hda-intel-objs += hda_codec.o \
3 hda_generic.o \ 6 hda_generic.o \
4 patch_realtek.o \ 7 patch_realtek.o \
5 patch_cmedia.o \ 8 patch_cmedia.o \
@@ -10,7 +13,7 @@ snd-hda-codec-objs := hda_codec.o \
10 patch_conexant.o \ 13 patch_conexant.o \
11 patch_via.o 14 patch_via.o
12ifdef CONFIG_PROC_FS 15ifdef CONFIG_PROC_FS
13snd-hda-codec-objs += hda_proc.o 16snd-hda-intel-objs += hda_proc.o
14endif 17endif
15 18
16obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-intel.o snd-hda-codec.o 19obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-intel.o
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 8f34fb447983..14649d54b493 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -24,7 +24,6 @@
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <linux/moduleparam.h>
28#include <linux/mutex.h> 27#include <linux/mutex.h>
29#include <sound/core.h> 28#include <sound/core.h>
30#include "hda_codec.h" 29#include "hda_codec.h"
@@ -34,11 +33,6 @@
34#include "hda_local.h" 33#include "hda_local.h"
35 34
36 35
37MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
38MODULE_DESCRIPTION("Universal interface for High Definition Audio Codec");
39MODULE_LICENSE("GPL");
40
41
42/* 36/*
43 * vendor / preset table 37 * vendor / preset table
44 */ 38 */
@@ -77,12 +71,13 @@ static struct hda_vendor_id hda_vendor_ids[] = {
77 * 71 *
78 * Returns the obtained response value, or -1 for an error. 72 * Returns the obtained response value, or -1 for an error.
79 */ 73 */
80unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid, int direct, 74unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid,
75 int direct,
81 unsigned int verb, unsigned int parm) 76 unsigned int verb, unsigned int parm)
82{ 77{
83 unsigned int res; 78 unsigned int res;
84 mutex_lock(&codec->bus->cmd_mutex); 79 mutex_lock(&codec->bus->cmd_mutex);
85 if (! codec->bus->ops.command(codec, nid, direct, verb, parm)) 80 if (!codec->bus->ops.command(codec, nid, direct, verb, parm))
86 res = codec->bus->ops.get_response(codec); 81 res = codec->bus->ops.get_response(codec);
87 else 82 else
88 res = (unsigned int)-1; 83 res = (unsigned int)-1;
@@ -90,8 +85,6 @@ unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid, int dire
90 return res; 85 return res;
91} 86}
92 87
93EXPORT_SYMBOL(snd_hda_codec_read);
94
95/** 88/**
96 * snd_hda_codec_write - send a single command without waiting for response 89 * snd_hda_codec_write - send a single command without waiting for response
97 * @codec: the HDA codec 90 * @codec: the HDA codec
@@ -114,8 +107,6 @@ int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int direct,
114 return err; 107 return err;
115} 108}
116 109
117EXPORT_SYMBOL(snd_hda_codec_write);
118
119/** 110/**
120 * snd_hda_sequence_write - sequence writes 111 * snd_hda_sequence_write - sequence writes
121 * @codec: the HDA codec 112 * @codec: the HDA codec
@@ -130,8 +121,6 @@ void snd_hda_sequence_write(struct hda_codec *codec, const struct hda_verb *seq)
130 snd_hda_codec_write(codec, seq->nid, 0, seq->verb, seq->param); 121 snd_hda_codec_write(codec, seq->nid, 0, seq->verb, seq->param);
131} 122}
132 123
133EXPORT_SYMBOL(snd_hda_sequence_write);
134
135/** 124/**
136 * snd_hda_get_sub_nodes - get the range of sub nodes 125 * snd_hda_get_sub_nodes - get the range of sub nodes
137 * @codec: the HDA codec 126 * @codec: the HDA codec
@@ -141,7 +130,8 @@ EXPORT_SYMBOL(snd_hda_sequence_write);
141 * Parse the NID and store the start NID of its sub-nodes. 130 * Parse the NID and store the start NID of its sub-nodes.
142 * Returns the number of sub-nodes. 131 * Returns the number of sub-nodes.
143 */ 132 */
144int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid, hda_nid_t *start_id) 133int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid,
134 hda_nid_t *start_id)
145{ 135{
146 unsigned int parm; 136 unsigned int parm;
147 137
@@ -150,8 +140,6 @@ int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid, hda_nid_t *sta
150 return (int)(parm & 0x7fff); 140 return (int)(parm & 0x7fff);
151} 141}
152 142
153EXPORT_SYMBOL(snd_hda_get_sub_nodes);
154
155/** 143/**
156 * snd_hda_get_connections - get connection list 144 * snd_hda_get_connections - get connection list
157 * @codec: the HDA codec 145 * @codec: the HDA codec
@@ -187,12 +175,13 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
187 conn_len = parm & AC_CLIST_LENGTH; 175 conn_len = parm & AC_CLIST_LENGTH;
188 mask = (1 << (shift-1)) - 1; 176 mask = (1 << (shift-1)) - 1;
189 177
190 if (! conn_len) 178 if (!conn_len)
191 return 0; /* no connection */ 179 return 0; /* no connection */
192 180
193 if (conn_len == 1) { 181 if (conn_len == 1) {
194 /* single connection */ 182 /* single connection */
195 parm = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_LIST, 0); 183 parm = snd_hda_codec_read(codec, nid, 0,
184 AC_VERB_GET_CONNECT_LIST, 0);
196 conn_list[0] = parm & mask; 185 conn_list[0] = parm & mask;
197 return 1; 186 return 1;
198 } 187 }
@@ -207,18 +196,21 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
207 if (i % num_elems == 0) 196 if (i % num_elems == 0)
208 parm = snd_hda_codec_read(codec, nid, 0, 197 parm = snd_hda_codec_read(codec, nid, 0,
209 AC_VERB_GET_CONNECT_LIST, i); 198 AC_VERB_GET_CONNECT_LIST, i);
210 range_val = !! (parm & (1 << (shift-1))); /* ranges */ 199 range_val = !!(parm & (1 << (shift-1))); /* ranges */
211 val = parm & mask; 200 val = parm & mask;
212 parm >>= shift; 201 parm >>= shift;
213 if (range_val) { 202 if (range_val) {
214 /* ranges between the previous and this one */ 203 /* ranges between the previous and this one */
215 if (! prev_nid || prev_nid >= val) { 204 if (!prev_nid || prev_nid >= val) {
216 snd_printk(KERN_WARNING "hda_codec: invalid dep_range_val %x:%x\n", prev_nid, val); 205 snd_printk(KERN_WARNING "hda_codec: "
206 "invalid dep_range_val %x:%x\n",
207 prev_nid, val);
217 continue; 208 continue;
218 } 209 }
219 for (n = prev_nid + 1; n <= val; n++) { 210 for (n = prev_nid + 1; n <= val; n++) {
220 if (conns >= max_conns) { 211 if (conns >= max_conns) {
221 snd_printk(KERN_ERR "Too many connections\n"); 212 snd_printk(KERN_ERR
213 "Too many connections\n");
222 return -EINVAL; 214 return -EINVAL;
223 } 215 }
224 conn_list[conns++] = n; 216 conn_list[conns++] = n;
@@ -253,7 +245,8 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
253 struct hda_bus_unsolicited *unsol; 245 struct hda_bus_unsolicited *unsol;
254 unsigned int wp; 246 unsigned int wp;
255 247
256 if ((unsol = bus->unsol) == NULL) 248 unsol = bus->unsol;
249 if (!unsol)
257 return 0; 250 return 0;
258 251
259 wp = (unsol->wp + 1) % HDA_UNSOL_QUEUE_SIZE; 252 wp = (unsol->wp + 1) % HDA_UNSOL_QUEUE_SIZE;
@@ -268,8 +261,6 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
268 return 0; 261 return 0;
269} 262}
270 263
271EXPORT_SYMBOL(snd_hda_queue_unsol_event);
272
273/* 264/*
274 * process queueud unsolicited events 265 * process queueud unsolicited events
275 */ 266 */
@@ -287,7 +278,7 @@ static void process_unsol_events(struct work_struct *work)
287 rp <<= 1; 278 rp <<= 1;
288 res = unsol->queue[rp]; 279 res = unsol->queue[rp];
289 caddr = unsol->queue[rp + 1]; 280 caddr = unsol->queue[rp + 1];
290 if (! (caddr & (1 << 4))) /* no unsolicited event? */ 281 if (!(caddr & (1 << 4))) /* no unsolicited event? */
291 continue; 282 continue;
292 codec = bus->caddr_tbl[caddr & 0x0f]; 283 codec = bus->caddr_tbl[caddr & 0x0f];
293 if (codec && codec->patch_ops.unsol_event) 284 if (codec && codec->patch_ops.unsol_event)
@@ -298,7 +289,7 @@ static void process_unsol_events(struct work_struct *work)
298/* 289/*
299 * initialize unsolicited queue 290 * initialize unsolicited queue
300 */ 291 */
301static int init_unsol_queue(struct hda_bus *bus) 292static int __devinit init_unsol_queue(struct hda_bus *bus)
302{ 293{
303 struct hda_bus_unsolicited *unsol; 294 struct hda_bus_unsolicited *unsol;
304 295
@@ -306,8 +297,9 @@ static int init_unsol_queue(struct hda_bus *bus)
306 return 0; 297 return 0;
307 298
308 unsol = kzalloc(sizeof(*unsol), GFP_KERNEL); 299 unsol = kzalloc(sizeof(*unsol), GFP_KERNEL);
309 if (! unsol) { 300 if (!unsol) {
310 snd_printk(KERN_ERR "hda_codec: can't allocate unsolicited queue\n"); 301 snd_printk(KERN_ERR "hda_codec: "
302 "can't allocate unsolicited queue\n");
311 return -ENOMEM; 303 return -ENOMEM;
312 } 304 }
313 INIT_WORK(&unsol->work, process_unsol_events); 305 INIT_WORK(&unsol->work, process_unsol_events);
@@ -323,16 +315,15 @@ static void snd_hda_codec_free(struct hda_codec *codec);
323 315
324static int snd_hda_bus_free(struct hda_bus *bus) 316static int snd_hda_bus_free(struct hda_bus *bus)
325{ 317{
326 struct list_head *p, *n; 318 struct hda_codec *codec, *n;
327 319
328 if (! bus) 320 if (!bus)
329 return 0; 321 return 0;
330 if (bus->unsol) { 322 if (bus->unsol) {
331 flush_scheduled_work(); 323 flush_scheduled_work();
332 kfree(bus->unsol); 324 kfree(bus->unsol);
333 } 325 }
334 list_for_each_safe(p, n, &bus->codec_list) { 326 list_for_each_entry_safe(codec, n, &bus->codec_list, list) {
335 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
336 snd_hda_codec_free(codec); 327 snd_hda_codec_free(codec);
337 } 328 }
338 if (bus->ops.private_free) 329 if (bus->ops.private_free)
@@ -355,8 +346,9 @@ static int snd_hda_bus_dev_free(struct snd_device *device)
355 * 346 *
356 * Returns 0 if successful, or a negative error code. 347 * Returns 0 if successful, or a negative error code.
357 */ 348 */
358int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp, 349int __devinit snd_hda_bus_new(struct snd_card *card,
359 struct hda_bus **busp) 350 const struct hda_bus_template *temp,
351 struct hda_bus **busp)
360{ 352{
361 struct hda_bus *bus; 353 struct hda_bus *bus;
362 int err; 354 int err;
@@ -385,7 +377,8 @@ int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp,
385 mutex_init(&bus->cmd_mutex); 377 mutex_init(&bus->cmd_mutex);
386 INIT_LIST_HEAD(&bus->codec_list); 378 INIT_LIST_HEAD(&bus->codec_list);
387 379
388 if ((err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops)) < 0) { 380 err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops);
381 if (err < 0) {
389 snd_hda_bus_free(bus); 382 snd_hda_bus_free(bus);
390 return err; 383 return err;
391 } 384 }
@@ -394,22 +387,24 @@ int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp,
394 return 0; 387 return 0;
395} 388}
396 389
397EXPORT_SYMBOL(snd_hda_bus_new);
398
399/* 390/*
400 * find a matching codec preset 391 * find a matching codec preset
401 */ 392 */
402static const struct hda_codec_preset *find_codec_preset(struct hda_codec *codec) 393static const struct hda_codec_preset __devinit *
394find_codec_preset(struct hda_codec *codec)
403{ 395{
404 const struct hda_codec_preset **tbl, *preset; 396 const struct hda_codec_preset **tbl, *preset;
405 397
398 if (codec->bus->modelname && !strcmp(codec->bus->modelname, "generic"))
399 return NULL; /* use the generic parser */
400
406 for (tbl = hda_preset_tables; *tbl; tbl++) { 401 for (tbl = hda_preset_tables; *tbl; tbl++) {
407 for (preset = *tbl; preset->id; preset++) { 402 for (preset = *tbl; preset->id; preset++) {
408 u32 mask = preset->mask; 403 u32 mask = preset->mask;
409 if (! mask) 404 if (!mask)
410 mask = ~0; 405 mask = ~0;
411 if (preset->id == (codec->vendor_id & mask) && 406 if (preset->id == (codec->vendor_id & mask) &&
412 (! preset->rev || 407 (!preset->rev ||
413 preset->rev == codec->revision_id)) 408 preset->rev == codec->revision_id))
414 return preset; 409 return preset;
415 } 410 }
@@ -434,27 +429,30 @@ void snd_hda_get_codec_name(struct hda_codec *codec,
434 break; 429 break;
435 } 430 }
436 } 431 }
437 if (! vendor) { 432 if (!vendor) {
438 sprintf(tmp, "Generic %04x", vendor_id); 433 sprintf(tmp, "Generic %04x", vendor_id);
439 vendor = tmp; 434 vendor = tmp;
440 } 435 }
441 if (codec->preset && codec->preset->name) 436 if (codec->preset && codec->preset->name)
442 snprintf(name, namelen, "%s %s", vendor, codec->preset->name); 437 snprintf(name, namelen, "%s %s", vendor, codec->preset->name);
443 else 438 else
444 snprintf(name, namelen, "%s ID %x", vendor, codec->vendor_id & 0xffff); 439 snprintf(name, namelen, "%s ID %x", vendor,
440 codec->vendor_id & 0xffff);
445} 441}
446 442
447/* 443/*
448 * look for an AFG and MFG nodes 444 * look for an AFG and MFG nodes
449 */ 445 */
450static void setup_fg_nodes(struct hda_codec *codec) 446static void __devinit setup_fg_nodes(struct hda_codec *codec)
451{ 447{
452 int i, total_nodes; 448 int i, total_nodes;
453 hda_nid_t nid; 449 hda_nid_t nid;
454 450
455 total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid); 451 total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid);
456 for (i = 0; i < total_nodes; i++, nid++) { 452 for (i = 0; i < total_nodes; i++, nid++) {
457 switch((snd_hda_param_read(codec, nid, AC_PAR_FUNCTION_TYPE) & 0xff)) { 453 unsigned int func;
454 func = snd_hda_param_read(codec, nid, AC_PAR_FUNCTION_TYPE);
455 switch (func & 0xff) {
458 case AC_GRP_AUDIO_FUNCTION: 456 case AC_GRP_AUDIO_FUNCTION:
459 codec->afg = nid; 457 codec->afg = nid;
460 break; 458 break;
@@ -478,7 +476,7 @@ static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node)
478 codec->num_nodes = snd_hda_get_sub_nodes(codec, fg_node, 476 codec->num_nodes = snd_hda_get_sub_nodes(codec, fg_node,
479 &codec->start_nid); 477 &codec->start_nid);
480 codec->wcaps = kmalloc(codec->num_nodes * 4, GFP_KERNEL); 478 codec->wcaps = kmalloc(codec->num_nodes * 4, GFP_KERNEL);
481 if (! codec->wcaps) 479 if (!codec->wcaps)
482 return -ENOMEM; 480 return -ENOMEM;
483 nid = codec->start_nid; 481 nid = codec->start_nid;
484 for (i = 0; i < codec->num_nodes; i++, nid++) 482 for (i = 0; i < codec->num_nodes; i++, nid++)
@@ -493,7 +491,7 @@ static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node)
493 */ 491 */
494static void snd_hda_codec_free(struct hda_codec *codec) 492static void snd_hda_codec_free(struct hda_codec *codec)
495{ 493{
496 if (! codec) 494 if (!codec)
497 return; 495 return;
498 list_del(&codec->list); 496 list_del(&codec->list);
499 codec->bus->caddr_tbl[codec->addr] = NULL; 497 codec->bus->caddr_tbl[codec->addr] = NULL;
@@ -514,8 +512,8 @@ static void init_amp_hash(struct hda_codec *codec);
514 * 512 *
515 * Returns 0 if successful, or a negative error code. 513 * Returns 0 if successful, or a negative error code.
516 */ 514 */
517int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, 515int __devinit snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
518 struct hda_codec **codecp) 516 struct hda_codec **codecp)
519{ 517{
520 struct hda_codec *codec; 518 struct hda_codec *codec;
521 char component[13]; 519 char component[13];
@@ -525,7 +523,8 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
525 snd_assert(codec_addr <= HDA_MAX_CODEC_ADDRESS, return -EINVAL); 523 snd_assert(codec_addr <= HDA_MAX_CODEC_ADDRESS, return -EINVAL);
526 524
527 if (bus->caddr_tbl[codec_addr]) { 525 if (bus->caddr_tbl[codec_addr]) {
528 snd_printk(KERN_ERR "hda_codec: address 0x%x is already occupied\n", codec_addr); 526 snd_printk(KERN_ERR "hda_codec: "
527 "address 0x%x is already occupied\n", codec_addr);
529 return -EBUSY; 528 return -EBUSY;
530 } 529 }
531 530
@@ -543,18 +542,21 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
543 list_add_tail(&codec->list, &bus->codec_list); 542 list_add_tail(&codec->list, &bus->codec_list);
544 bus->caddr_tbl[codec_addr] = codec; 543 bus->caddr_tbl[codec_addr] = codec;
545 544
546 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT, AC_PAR_VENDOR_ID); 545 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT,
546 AC_PAR_VENDOR_ID);
547 if (codec->vendor_id == -1) 547 if (codec->vendor_id == -1)
548 /* read again, hopefully the access method was corrected 548 /* read again, hopefully the access method was corrected
549 * in the last read... 549 * in the last read...
550 */ 550 */
551 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT, 551 codec->vendor_id = snd_hda_param_read(codec, AC_NODE_ROOT,
552 AC_PAR_VENDOR_ID); 552 AC_PAR_VENDOR_ID);
553 codec->subsystem_id = snd_hda_param_read(codec, AC_NODE_ROOT, AC_PAR_SUBSYSTEM_ID); 553 codec->subsystem_id = snd_hda_param_read(codec, AC_NODE_ROOT,
554 codec->revision_id = snd_hda_param_read(codec, AC_NODE_ROOT, AC_PAR_REV_ID); 554 AC_PAR_SUBSYSTEM_ID);
555 codec->revision_id = snd_hda_param_read(codec, AC_NODE_ROOT,
556 AC_PAR_REV_ID);
555 557
556 setup_fg_nodes(codec); 558 setup_fg_nodes(codec);
557 if (! codec->afg && ! codec->mfg) { 559 if (!codec->afg && !codec->mfg) {
558 snd_printdd("hda_codec: no AFG or MFG node found\n"); 560 snd_printdd("hda_codec: no AFG or MFG node found\n");
559 snd_hda_codec_free(codec); 561 snd_hda_codec_free(codec);
560 return -ENODEV; 562 return -ENODEV;
@@ -566,15 +568,16 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
566 return -ENOMEM; 568 return -ENOMEM;
567 } 569 }
568 570
569 if (! codec->subsystem_id) { 571 if (!codec->subsystem_id) {
570 hda_nid_t nid = codec->afg ? codec->afg : codec->mfg; 572 hda_nid_t nid = codec->afg ? codec->afg : codec->mfg;
571 codec->subsystem_id = snd_hda_codec_read(codec, nid, 0, 573 codec->subsystem_id =
572 AC_VERB_GET_SUBSYSTEM_ID, 574 snd_hda_codec_read(codec, nid, 0,
573 0); 575 AC_VERB_GET_SUBSYSTEM_ID, 0);
574 } 576 }
575 577
576 codec->preset = find_codec_preset(codec); 578 codec->preset = find_codec_preset(codec);
577 if (! *bus->card->mixername) 579 /* audio codec should override the mixer name */
580 if (codec->afg || !*bus->card->mixername)
578 snd_hda_get_codec_name(codec, bus->card->mixername, 581 snd_hda_get_codec_name(codec, bus->card->mixername,
579 sizeof(bus->card->mixername)); 582 sizeof(bus->card->mixername));
580 583
@@ -600,8 +603,6 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
600 return 0; 603 return 0;
601} 604}
602 605
603EXPORT_SYMBOL(snd_hda_codec_new);
604
605/** 606/**
606 * snd_hda_codec_setup_stream - set up the codec for streaming 607 * snd_hda_codec_setup_stream - set up the codec for streaming
607 * @codec: the CODEC to set up 608 * @codec: the CODEC to set up
@@ -610,13 +611,15 @@ EXPORT_SYMBOL(snd_hda_codec_new);
610 * @channel_id: channel id to pass, zero based. 611 * @channel_id: channel id to pass, zero based.
611 * @format: stream format. 612 * @format: stream format.
612 */ 613 */
613void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag, 614void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
615 u32 stream_tag,
614 int channel_id, int format) 616 int channel_id, int format)
615{ 617{
616 if (! nid) 618 if (!nid)
617 return; 619 return;
618 620
619 snd_printdd("hda_codec_setup_stream: NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n", 621 snd_printdd("hda_codec_setup_stream: "
622 "NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n",
620 nid, stream_tag, channel_id, format); 623 nid, stream_tag, channel_id, format);
621 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, 624 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID,
622 (stream_tag << 4) | channel_id); 625 (stream_tag << 4) | channel_id);
@@ -624,8 +627,6 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stre
624 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format); 627 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format);
625} 628}
626 629
627EXPORT_SYMBOL(snd_hda_codec_setup_stream);
628
629/* 630/*
630 * amp access functions 631 * amp access functions
631 */ 632 */
@@ -636,7 +637,7 @@ EXPORT_SYMBOL(snd_hda_codec_setup_stream);
636#define INFO_AMP_VOL(ch) (1 << (1 + (ch))) 637#define INFO_AMP_VOL(ch) (1 << (1 + (ch)))
637 638
638/* initialize the hash table */ 639/* initialize the hash table */
639static void init_amp_hash(struct hda_codec *codec) 640static void __devinit init_amp_hash(struct hda_codec *codec)
640{ 641{
641 memset(codec->amp_hash, 0xff, sizeof(codec->amp_hash)); 642 memset(codec->amp_hash, 0xff, sizeof(codec->amp_hash));
642 codec->num_amp_entries = 0; 643 codec->num_amp_entries = 0;
@@ -662,15 +663,18 @@ static struct hda_amp_info *get_alloc_amp_hash(struct hda_codec *codec, u32 key)
662 if (codec->num_amp_entries >= codec->amp_info_size) { 663 if (codec->num_amp_entries >= codec->amp_info_size) {
663 /* reallocate the array */ 664 /* reallocate the array */
664 int new_size = codec->amp_info_size + 64; 665 int new_size = codec->amp_info_size + 64;
665 struct hda_amp_info *new_info = kcalloc(new_size, sizeof(struct hda_amp_info), 666 struct hda_amp_info *new_info;
666 GFP_KERNEL); 667 new_info = kcalloc(new_size, sizeof(struct hda_amp_info),
667 if (! new_info) { 668 GFP_KERNEL);
668 snd_printk(KERN_ERR "hda_codec: can't malloc amp_info\n"); 669 if (!new_info) {
670 snd_printk(KERN_ERR "hda_codec: "
671 "can't malloc amp_info\n");
669 return NULL; 672 return NULL;
670 } 673 }
671 if (codec->amp_info) { 674 if (codec->amp_info) {
672 memcpy(new_info, codec->amp_info, 675 memcpy(new_info, codec->amp_info,
673 codec->amp_info_size * sizeof(struct hda_amp_info)); 676 codec->amp_info_size *
677 sizeof(struct hda_amp_info));
674 kfree(codec->amp_info); 678 kfree(codec->amp_info);
675 } 679 }
676 codec->amp_info_size = new_size; 680 codec->amp_info_size = new_size;
@@ -691,15 +695,18 @@ static struct hda_amp_info *get_alloc_amp_hash(struct hda_codec *codec, u32 key)
691 */ 695 */
692static u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction) 696static u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction)
693{ 697{
694 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, 0)); 698 struct hda_amp_info *info;
695 699
696 if (! info) 700 info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, 0));
701 if (!info)
697 return 0; 702 return 0;
698 if (! (info->status & INFO_AMP_CAPS)) { 703 if (!(info->status & INFO_AMP_CAPS)) {
699 if (! (get_wcaps(codec, nid) & AC_WCAP_AMP_OVRD)) 704 if (!(get_wcaps(codec, nid) & AC_WCAP_AMP_OVRD))
700 nid = codec->afg; 705 nid = codec->afg;
701 info->amp_caps = snd_hda_param_read(codec, nid, direction == HDA_OUTPUT ? 706 info->amp_caps = snd_hda_param_read(codec, nid,
702 AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP); 707 direction == HDA_OUTPUT ?
708 AC_PAR_AMP_OUT_CAP :
709 AC_PAR_AMP_IN_CAP);
703 info->status |= INFO_AMP_CAPS; 710 info->status |= INFO_AMP_CAPS;
704 } 711 }
705 return info->amp_caps; 712 return info->amp_caps;
@@ -709,8 +716,9 @@ static u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction)
709 * read the current volume to info 716 * read the current volume to info
710 * if the cache exists, read the cache value. 717 * if the cache exists, read the cache value.
711 */ 718 */
712static unsigned int get_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, 719static unsigned int get_vol_mute(struct hda_codec *codec,
713 hda_nid_t nid, int ch, int direction, int index) 720 struct hda_amp_info *info, hda_nid_t nid,
721 int ch, int direction, int index)
714{ 722{
715 u32 val, parm; 723 u32 val, parm;
716 724
@@ -720,7 +728,8 @@ static unsigned int get_vol_mute(struct hda_codec *codec, struct hda_amp_info *i
720 parm = ch ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT; 728 parm = ch ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT;
721 parm |= direction == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT; 729 parm |= direction == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT;
722 parm |= index; 730 parm |= index;
723 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, parm); 731 val = snd_hda_codec_read(codec, nid, 0,
732 AC_VERB_GET_AMP_GAIN_MUTE, parm);
724 info->vol[ch] = val & 0xff; 733 info->vol[ch] = val & 0xff;
725 info->status |= INFO_AMP_VOL(ch); 734 info->status |= INFO_AMP_VOL(ch);
726 return info->vol[ch]; 735 return info->vol[ch];
@@ -730,7 +739,8 @@ static unsigned int get_vol_mute(struct hda_codec *codec, struct hda_amp_info *i
730 * write the current volume in info to the h/w and update the cache 739 * write the current volume in info to the h/w and update the cache
731 */ 740 */
732static void put_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, 741static void put_vol_mute(struct hda_codec *codec, struct hda_amp_info *info,
733 hda_nid_t nid, int ch, int direction, int index, int val) 742 hda_nid_t nid, int ch, int direction, int index,
743 int val)
734{ 744{
735 u32 parm; 745 u32 parm;
736 746
@@ -748,8 +758,9 @@ static void put_vol_mute(struct hda_codec *codec, struct hda_amp_info *info,
748int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, 758int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch,
749 int direction, int index) 759 int direction, int index)
750{ 760{
751 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, index)); 761 struct hda_amp_info *info;
752 if (! info) 762 info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, index));
763 if (!info)
753 return 0; 764 return 0;
754 return get_vol_mute(codec, info, nid, ch, direction, index); 765 return get_vol_mute(codec, info, nid, ch, direction, index);
755} 766}
@@ -760,13 +771,14 @@ int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch,
760int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch, 771int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
761 int direction, int idx, int mask, int val) 772 int direction, int idx, int mask, int val)
762{ 773{
763 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx)); 774 struct hda_amp_info *info;
764 775
765 if (! info) 776 info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx));
777 if (!info)
766 return 0; 778 return 0;
767 val &= mask; 779 val &= mask;
768 val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask; 780 val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask;
769 if (info->vol[ch] == val && ! codec->in_resume) 781 if (info->vol[ch] == val && !codec->in_resume)
770 return 0; 782 return 0;
771 put_vol_mute(codec, info, nid, ch, direction, idx, val); 783 put_vol_mute(codec, info, nid, ch, direction, idx, val);
772 return 1; 784 return 1;
@@ -783,7 +795,8 @@ int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
783#define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf) 795#define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf)
784 796
785/* volume */ 797/* volume */
786int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 798int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol,
799 struct snd_ctl_elem_info *uinfo)
787{ 800{
788 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 801 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
789 u16 nid = get_amp_nid(kcontrol); 802 u16 nid = get_amp_nid(kcontrol);
@@ -792,9 +805,11 @@ int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
792 u32 caps; 805 u32 caps;
793 806
794 caps = query_amp_caps(codec, nid, dir); 807 caps = query_amp_caps(codec, nid, dir);
795 caps = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; /* num steps */ 808 /* num steps */
796 if (! caps) { 809 caps = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
797 printk(KERN_WARNING "hda_codec: num_steps = 0 for NID=0x%x\n", nid); 810 if (!caps) {
811 printk(KERN_WARNING "hda_codec: "
812 "num_steps = 0 for NID=0x%x\n", nid);
798 return -EINVAL; 813 return -EINVAL;
799 } 814 }
800 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 815 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
@@ -804,7 +819,8 @@ int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
804 return 0; 819 return 0;
805} 820}
806 821
807int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 822int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
823 struct snd_ctl_elem_value *ucontrol)
808{ 824{
809 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 825 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
810 hda_nid_t nid = get_amp_nid(kcontrol); 826 hda_nid_t nid = get_amp_nid(kcontrol);
@@ -820,7 +836,8 @@ int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
820 return 0; 836 return 0;
821} 837}
822 838
823int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 839int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol,
840 struct snd_ctl_elem_value *ucontrol)
824{ 841{
825 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 842 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
826 hda_nid_t nid = get_amp_nid(kcontrol); 843 hda_nid_t nid = get_amp_nid(kcontrol);
@@ -852,7 +869,8 @@ int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
852 if (size < 4 * sizeof(unsigned int)) 869 if (size < 4 * sizeof(unsigned int))
853 return -ENOMEM; 870 return -ENOMEM;
854 caps = query_amp_caps(codec, nid, dir); 871 caps = query_amp_caps(codec, nid, dir);
855 val2 = (((caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT) + 1) * 25; 872 val2 = (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT;
873 val2 = (val2 + 1) * 25;
856 val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT); 874 val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT);
857 val1 = ((int)val1) * ((int)val2); 875 val1 = ((int)val1) * ((int)val2);
858 if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv)) 876 if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv))
@@ -867,7 +885,8 @@ int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
867} 885}
868 886
869/* switch */ 887/* switch */
870int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 888int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol,
889 struct snd_ctl_elem_info *uinfo)
871{ 890{
872 int chs = get_amp_channels(kcontrol); 891 int chs = get_amp_channels(kcontrol);
873 892
@@ -878,7 +897,8 @@ int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_
878 return 0; 897 return 0;
879} 898}
880 899
881int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 900int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol,
901 struct snd_ctl_elem_value *ucontrol)
882{ 902{
883 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 903 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
884 hda_nid_t nid = get_amp_nid(kcontrol); 904 hda_nid_t nid = get_amp_nid(kcontrol);
@@ -888,13 +908,16 @@ int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_e
888 long *valp = ucontrol->value.integer.value; 908 long *valp = ucontrol->value.integer.value;
889 909
890 if (chs & 1) 910 if (chs & 1)
891 *valp++ = (snd_hda_codec_amp_read(codec, nid, 0, dir, idx) & 0x80) ? 0 : 1; 911 *valp++ = (snd_hda_codec_amp_read(codec, nid, 0, dir, idx) &
912 0x80) ? 0 : 1;
892 if (chs & 2) 913 if (chs & 2)
893 *valp = (snd_hda_codec_amp_read(codec, nid, 1, dir, idx) & 0x80) ? 0 : 1; 914 *valp = (snd_hda_codec_amp_read(codec, nid, 1, dir, idx) &
915 0x80) ? 0 : 1;
894 return 0; 916 return 0;
895} 917}
896 918
897int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 919int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol,
920 struct snd_ctl_elem_value *ucontrol)
898{ 921{
899 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 922 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
900 hda_nid_t nid = get_amp_nid(kcontrol); 923 hda_nid_t nid = get_amp_nid(kcontrol);
@@ -925,7 +948,8 @@ int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
925#define AMP_VAL_IDX_SHIFT 19 948#define AMP_VAL_IDX_SHIFT 19
926#define AMP_VAL_IDX_MASK (0x0f<<19) 949#define AMP_VAL_IDX_MASK (0x0f<<19)
927 950
928int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 951int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol,
952 struct snd_ctl_elem_value *ucontrol)
929{ 953{
930 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 954 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
931 unsigned long pval; 955 unsigned long pval;
@@ -940,7 +964,8 @@ int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_
940 return err; 964 return err;
941} 965}
942 966
943int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 967int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol,
968 struct snd_ctl_elem_value *ucontrol)
944{ 969{
945 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 970 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
946 unsigned long pval; 971 unsigned long pval;
@@ -950,7 +975,8 @@ int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
950 pval = kcontrol->private_value; 975 pval = kcontrol->private_value;
951 indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT; 976 indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT;
952 for (i = 0; i < indices; i++) { 977 for (i = 0; i < indices; i++) {
953 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | (i << AMP_VAL_IDX_SHIFT); 978 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) |
979 (i << AMP_VAL_IDX_SHIFT);
954 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); 980 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
955 if (err < 0) 981 if (err < 0)
956 break; 982 break;
@@ -965,14 +991,16 @@ int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
965 * SPDIF out controls 991 * SPDIF out controls
966 */ 992 */
967 993
968static int snd_hda_spdif_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 994static int snd_hda_spdif_mask_info(struct snd_kcontrol *kcontrol,
995 struct snd_ctl_elem_info *uinfo)
969{ 996{
970 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; 997 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
971 uinfo->count = 1; 998 uinfo->count = 1;
972 return 0; 999 return 0;
973} 1000}
974 1001
975static int snd_hda_spdif_cmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1002static int snd_hda_spdif_cmask_get(struct snd_kcontrol *kcontrol,
1003 struct snd_ctl_elem_value *ucontrol)
976{ 1004{
977 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | 1005 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL |
978 IEC958_AES0_NONAUDIO | 1006 IEC958_AES0_NONAUDIO |
@@ -983,7 +1011,8 @@ static int snd_hda_spdif_cmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl
983 return 0; 1011 return 0;
984} 1012}
985 1013
986static int snd_hda_spdif_pmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1014static int snd_hda_spdif_pmask_get(struct snd_kcontrol *kcontrol,
1015 struct snd_ctl_elem_value *ucontrol)
987{ 1016{
988 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | 1017 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL |
989 IEC958_AES0_NONAUDIO | 1018 IEC958_AES0_NONAUDIO |
@@ -991,7 +1020,8 @@ static int snd_hda_spdif_pmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl
991 return 0; 1020 return 0;
992} 1021}
993 1022
994static int snd_hda_spdif_default_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1023static int snd_hda_spdif_default_get(struct snd_kcontrol *kcontrol,
1024 struct snd_ctl_elem_value *ucontrol)
995{ 1025{
996 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1026 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
997 1027
@@ -1011,19 +1041,21 @@ static unsigned short convert_from_spdif_status(unsigned int sbits)
1011 unsigned short val = 0; 1041 unsigned short val = 0;
1012 1042
1013 if (sbits & IEC958_AES0_PROFESSIONAL) 1043 if (sbits & IEC958_AES0_PROFESSIONAL)
1014 val |= 1 << 6; 1044 val |= AC_DIG1_PROFESSIONAL;
1015 if (sbits & IEC958_AES0_NONAUDIO) 1045 if (sbits & IEC958_AES0_NONAUDIO)
1016 val |= 1 << 5; 1046 val |= AC_DIG1_NONAUDIO;
1017 if (sbits & IEC958_AES0_PROFESSIONAL) { 1047 if (sbits & IEC958_AES0_PROFESSIONAL) {
1018 if ((sbits & IEC958_AES0_PRO_EMPHASIS) == IEC958_AES0_PRO_EMPHASIS_5015) 1048 if ((sbits & IEC958_AES0_PRO_EMPHASIS) ==
1019 val |= 1 << 3; 1049 IEC958_AES0_PRO_EMPHASIS_5015)
1050 val |= AC_DIG1_EMPHASIS;
1020 } else { 1051 } else {
1021 if ((sbits & IEC958_AES0_CON_EMPHASIS) == IEC958_AES0_CON_EMPHASIS_5015) 1052 if ((sbits & IEC958_AES0_CON_EMPHASIS) ==
1022 val |= 1 << 3; 1053 IEC958_AES0_CON_EMPHASIS_5015)
1023 if (! (sbits & IEC958_AES0_CON_NOT_COPYRIGHT)) 1054 val |= AC_DIG1_EMPHASIS;
1024 val |= 1 << 4; 1055 if (!(sbits & IEC958_AES0_CON_NOT_COPYRIGHT))
1056 val |= AC_DIG1_COPYRIGHT;
1025 if (sbits & (IEC958_AES1_CON_ORIGINAL << 8)) 1057 if (sbits & (IEC958_AES1_CON_ORIGINAL << 8))
1026 val |= 1 << 7; 1058 val |= AC_DIG1_LEVEL;
1027 val |= sbits & (IEC958_AES1_CON_CATEGORY << 8); 1059 val |= sbits & (IEC958_AES1_CON_CATEGORY << 8);
1028 } 1060 }
1029 return val; 1061 return val;
@@ -1035,26 +1067,27 @@ static unsigned int convert_to_spdif_status(unsigned short val)
1035{ 1067{
1036 unsigned int sbits = 0; 1068 unsigned int sbits = 0;
1037 1069
1038 if (val & (1 << 5)) 1070 if (val & AC_DIG1_NONAUDIO)
1039 sbits |= IEC958_AES0_NONAUDIO; 1071 sbits |= IEC958_AES0_NONAUDIO;
1040 if (val & (1 << 6)) 1072 if (val & AC_DIG1_PROFESSIONAL)
1041 sbits |= IEC958_AES0_PROFESSIONAL; 1073 sbits |= IEC958_AES0_PROFESSIONAL;
1042 if (sbits & IEC958_AES0_PROFESSIONAL) { 1074 if (sbits & IEC958_AES0_PROFESSIONAL) {
1043 if (sbits & (1 << 3)) 1075 if (sbits & AC_DIG1_EMPHASIS)
1044 sbits |= IEC958_AES0_PRO_EMPHASIS_5015; 1076 sbits |= IEC958_AES0_PRO_EMPHASIS_5015;
1045 } else { 1077 } else {
1046 if (val & (1 << 3)) 1078 if (val & AC_DIG1_EMPHASIS)
1047 sbits |= IEC958_AES0_CON_EMPHASIS_5015; 1079 sbits |= IEC958_AES0_CON_EMPHASIS_5015;
1048 if (! (val & (1 << 4))) 1080 if (!(val & AC_DIG1_COPYRIGHT))
1049 sbits |= IEC958_AES0_CON_NOT_COPYRIGHT; 1081 sbits |= IEC958_AES0_CON_NOT_COPYRIGHT;
1050 if (val & (1 << 7)) 1082 if (val & AC_DIG1_LEVEL)
1051 sbits |= (IEC958_AES1_CON_ORIGINAL << 8); 1083 sbits |= (IEC958_AES1_CON_ORIGINAL << 8);
1052 sbits |= val & (0x7f << 8); 1084 sbits |= val & (0x7f << 8);
1053 } 1085 }
1054 return sbits; 1086 return sbits;
1055} 1087}
1056 1088
1057static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1089static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol,
1090 struct snd_ctl_elem_value *ucontrol)
1058{ 1091{
1059 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1092 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1060 hda_nid_t nid = kcontrol->private_value; 1093 hda_nid_t nid = kcontrol->private_value;
@@ -1072,15 +1105,18 @@ static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_c
1072 codec->spdif_ctls = val; 1105 codec->spdif_ctls = val;
1073 1106
1074 if (change || codec->in_resume) { 1107 if (change || codec->in_resume) {
1075 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val & 0xff); 1108 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
1076 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_2, val >> 8); 1109 val & 0xff);
1110 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_2,
1111 val >> 8);
1077 } 1112 }
1078 1113
1079 mutex_unlock(&codec->spdif_mutex); 1114 mutex_unlock(&codec->spdif_mutex);
1080 return change; 1115 return change;
1081} 1116}
1082 1117
1083static int snd_hda_spdif_out_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1118static int snd_hda_spdif_out_switch_info(struct snd_kcontrol *kcontrol,
1119 struct snd_ctl_elem_info *uinfo)
1084{ 1120{
1085 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 1121 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1086 uinfo->count = 1; 1122 uinfo->count = 1;
@@ -1089,15 +1125,17 @@ static int snd_hda_spdif_out_switch_info(struct snd_kcontrol *kcontrol, struct s
1089 return 0; 1125 return 0;
1090} 1126}
1091 1127
1092static int snd_hda_spdif_out_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1128static int snd_hda_spdif_out_switch_get(struct snd_kcontrol *kcontrol,
1129 struct snd_ctl_elem_value *ucontrol)
1093{ 1130{
1094 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1131 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1095 1132
1096 ucontrol->value.integer.value[0] = codec->spdif_ctls & 1; 1133 ucontrol->value.integer.value[0] = codec->spdif_ctls & AC_DIG1_ENABLE;
1097 return 0; 1134 return 0;
1098} 1135}
1099 1136
1100static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1137static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol,
1138 struct snd_ctl_elem_value *ucontrol)
1101{ 1139{
1102 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1140 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1103 hda_nid_t nid = kcontrol->private_value; 1141 hda_nid_t nid = kcontrol->private_value;
@@ -1105,16 +1143,21 @@ static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol, struct sn
1105 int change; 1143 int change;
1106 1144
1107 mutex_lock(&codec->spdif_mutex); 1145 mutex_lock(&codec->spdif_mutex);
1108 val = codec->spdif_ctls & ~1; 1146 val = codec->spdif_ctls & ~AC_DIG1_ENABLE;
1109 if (ucontrol->value.integer.value[0]) 1147 if (ucontrol->value.integer.value[0])
1110 val |= 1; 1148 val |= AC_DIG1_ENABLE;
1111 change = codec->spdif_ctls != val; 1149 change = codec->spdif_ctls != val;
1112 if (change || codec->in_resume) { 1150 if (change || codec->in_resume) {
1113 codec->spdif_ctls = val; 1151 codec->spdif_ctls = val;
1114 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val & 0xff); 1152 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
1115 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1153 val & 0xff);
1116 AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | 1154 /* unmute amp switch (if any) */
1117 AC_AMP_SET_OUTPUT | ((val & 1) ? 0 : 0x80)); 1155 if ((get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) &&
1156 (val & AC_DIG1_ENABLE))
1157 snd_hda_codec_write(codec, nid, 0,
1158 AC_VERB_SET_AMP_GAIN_MUTE,
1159 AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT |
1160 AC_AMP_SET_OUTPUT);
1118 } 1161 }
1119 mutex_unlock(&codec->spdif_mutex); 1162 mutex_unlock(&codec->spdif_mutex);
1120 return change; 1163 return change;
@@ -1162,7 +1205,8 @@ static struct snd_kcontrol_new dig_mixes[] = {
1162 * 1205 *
1163 * Returns 0 if successful, or a negative error code. 1206 * Returns 0 if successful, or a negative error code.
1164 */ 1207 */
1165int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid) 1208int __devinit snd_hda_create_spdif_out_ctls(struct hda_codec *codec,
1209 hda_nid_t nid)
1166{ 1210{
1167 int err; 1211 int err;
1168 struct snd_kcontrol *kctl; 1212 struct snd_kcontrol *kctl;
@@ -1171,10 +1215,12 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)
1171 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) { 1215 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) {
1172 kctl = snd_ctl_new1(dig_mix, codec); 1216 kctl = snd_ctl_new1(dig_mix, codec);
1173 kctl->private_value = nid; 1217 kctl->private_value = nid;
1174 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0) 1218 err = snd_ctl_add(codec->bus->card, kctl);
1219 if (err < 0)
1175 return err; 1220 return err;
1176 } 1221 }
1177 codec->spdif_ctls = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0); 1222 codec->spdif_ctls =
1223 snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0);
1178 codec->spdif_status = convert_to_spdif_status(codec->spdif_ctls); 1224 codec->spdif_status = convert_to_spdif_status(codec->spdif_ctls);
1179 return 0; 1225 return 0;
1180} 1226}
@@ -1185,7 +1231,8 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)
1185 1231
1186#define snd_hda_spdif_in_switch_info snd_hda_spdif_out_switch_info 1232#define snd_hda_spdif_in_switch_info snd_hda_spdif_out_switch_info
1187 1233
1188static int snd_hda_spdif_in_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1234static int snd_hda_spdif_in_switch_get(struct snd_kcontrol *kcontrol,
1235 struct snd_ctl_elem_value *ucontrol)
1189{ 1236{
1190 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1237 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1191 1238
@@ -1193,7 +1240,8 @@ static int snd_hda_spdif_in_switch_get(struct snd_kcontrol *kcontrol, struct snd
1193 return 0; 1240 return 0;
1194} 1241}
1195 1242
1196static int snd_hda_spdif_in_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1243static int snd_hda_spdif_in_switch_put(struct snd_kcontrol *kcontrol,
1244 struct snd_ctl_elem_value *ucontrol)
1197{ 1245{
1198 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1246 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1199 hda_nid_t nid = kcontrol->private_value; 1247 hda_nid_t nid = kcontrol->private_value;
@@ -1204,13 +1252,15 @@ static int snd_hda_spdif_in_switch_put(struct snd_kcontrol *kcontrol, struct snd
1204 change = codec->spdif_in_enable != val; 1252 change = codec->spdif_in_enable != val;
1205 if (change || codec->in_resume) { 1253 if (change || codec->in_resume) {
1206 codec->spdif_in_enable = val; 1254 codec->spdif_in_enable = val;
1207 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val); 1255 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
1256 val);
1208 } 1257 }
1209 mutex_unlock(&codec->spdif_mutex); 1258 mutex_unlock(&codec->spdif_mutex);
1210 return change; 1259 return change;
1211} 1260}
1212 1261
1213static int snd_hda_spdif_in_status_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1262static int snd_hda_spdif_in_status_get(struct snd_kcontrol *kcontrol,
1263 struct snd_ctl_elem_value *ucontrol)
1214{ 1264{
1215 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1265 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1216 hda_nid_t nid = kcontrol->private_value; 1266 hda_nid_t nid = kcontrol->private_value;
@@ -1254,7 +1304,8 @@ static struct snd_kcontrol_new dig_in_ctls[] = {
1254 * 1304 *
1255 * Returns 0 if successful, or a negative error code. 1305 * Returns 0 if successful, or a negative error code.
1256 */ 1306 */
1257int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid) 1307int __devinit snd_hda_create_spdif_in_ctls(struct hda_codec *codec,
1308 hda_nid_t nid)
1258{ 1309{
1259 int err; 1310 int err;
1260 struct snd_kcontrol *kctl; 1311 struct snd_kcontrol *kctl;
@@ -1263,10 +1314,13 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid)
1263 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) { 1314 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) {
1264 kctl = snd_ctl_new1(dig_mix, codec); 1315 kctl = snd_ctl_new1(dig_mix, codec);
1265 kctl->private_value = nid; 1316 kctl->private_value = nid;
1266 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0) 1317 err = snd_ctl_add(codec->bus->card, kctl);
1318 if (err < 0)
1267 return err; 1319 return err;
1268 } 1320 }
1269 codec->spdif_in_enable = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0) & 1; 1321 codec->spdif_in_enable =
1322 snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0) &
1323 AC_DIG1_ENABLE;
1270 return 0; 1324 return 0;
1271} 1325}
1272 1326
@@ -1304,15 +1358,14 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
1304 * 1358 *
1305 * Returns 0 if successful, otherwise a negative error code. 1359 * Returns 0 if successful, otherwise a negative error code.
1306 */ 1360 */
1307int snd_hda_build_controls(struct hda_bus *bus) 1361int __devinit snd_hda_build_controls(struct hda_bus *bus)
1308{ 1362{
1309 struct list_head *p; 1363 struct hda_codec *codec;
1310 1364
1311 /* build controls */ 1365 /* build controls */
1312 list_for_each(p, &bus->codec_list) { 1366 list_for_each_entry(codec, &bus->codec_list, list) {
1313 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
1314 int err; 1367 int err;
1315 if (! codec->patch_ops.build_controls) 1368 if (!codec->patch_ops.build_controls)
1316 continue; 1369 continue;
1317 err = codec->patch_ops.build_controls(codec); 1370 err = codec->patch_ops.build_controls(codec);
1318 if (err < 0) 1371 if (err < 0)
@@ -1320,13 +1373,12 @@ int snd_hda_build_controls(struct hda_bus *bus)
1320 } 1373 }
1321 1374
1322 /* initialize */ 1375 /* initialize */
1323 list_for_each(p, &bus->codec_list) { 1376 list_for_each_entry(codec, &bus->codec_list, list) {
1324 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
1325 int err; 1377 int err;
1326 hda_set_power_state(codec, 1378 hda_set_power_state(codec,
1327 codec->afg ? codec->afg : codec->mfg, 1379 codec->afg ? codec->afg : codec->mfg,
1328 AC_PWRST_D0); 1380 AC_PWRST_D0);
1329 if (! codec->patch_ops.init) 1381 if (!codec->patch_ops.init)
1330 continue; 1382 continue;
1331 err = codec->patch_ops.init(codec); 1383 err = codec->patch_ops.init(codec);
1332 if (err < 0) 1384 if (err < 0)
@@ -1335,8 +1387,6 @@ int snd_hda_build_controls(struct hda_bus *bus)
1335 return 0; 1387 return 0;
1336} 1388}
1337 1389
1338EXPORT_SYMBOL(snd_hda_build_controls);
1339
1340/* 1390/*
1341 * stream formats 1391 * stream formats
1342 */ 1392 */
@@ -1361,6 +1411,11 @@ static struct hda_rate_tbl rate_bits[] = {
1361 { 96000, SNDRV_PCM_RATE_96000, 0x0800 }, /* 2 x 48 */ 1411 { 96000, SNDRV_PCM_RATE_96000, 0x0800 }, /* 2 x 48 */
1362 { 176400, SNDRV_PCM_RATE_176400, 0x5800 },/* 4 x 44 */ 1412 { 176400, SNDRV_PCM_RATE_176400, 0x5800 },/* 4 x 44 */
1363 { 192000, SNDRV_PCM_RATE_192000, 0x1800 }, /* 4 x 48 */ 1413 { 192000, SNDRV_PCM_RATE_192000, 0x1800 }, /* 4 x 48 */
1414#define AC_PAR_PCM_RATE_BITS 11
1415 /* up to bits 10, 384kHZ isn't supported properly */
1416
1417 /* not autodetected value */
1418 { 9600, SNDRV_PCM_RATE_KNOT, 0x0400 }, /* 1/5 x 48 */
1364 1419
1365 { 0 } /* terminator */ 1420 { 0 } /* terminator */
1366}; 1421};
@@ -1389,7 +1444,7 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
1389 val = rate_bits[i].hda_fmt; 1444 val = rate_bits[i].hda_fmt;
1390 break; 1445 break;
1391 } 1446 }
1392 if (! rate_bits[i].hz) { 1447 if (!rate_bits[i].hz) {
1393 snd_printdd("invalid rate %d\n", rate); 1448 snd_printdd("invalid rate %d\n", rate);
1394 return 0; 1449 return 0;
1395 } 1450 }
@@ -1414,15 +1469,14 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
1414 val |= 0x20; 1469 val |= 0x20;
1415 break; 1470 break;
1416 default: 1471 default:
1417 snd_printdd("invalid format width %d\n", snd_pcm_format_width(format)); 1472 snd_printdd("invalid format width %d\n",
1473 snd_pcm_format_width(format));
1418 return 0; 1474 return 0;
1419 } 1475 }
1420 1476
1421 return val; 1477 return val;
1422} 1478}
1423 1479
1424EXPORT_SYMBOL(snd_hda_calc_stream_format);
1425
1426/** 1480/**
1427 * snd_hda_query_supported_pcm - query the supported PCM rates and formats 1481 * snd_hda_query_supported_pcm - query the supported PCM rates and formats
1428 * @codec: the HDA codec 1482 * @codec: the HDA codec
@@ -1449,12 +1503,12 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1449 if (val == -1) 1503 if (val == -1)
1450 return -EIO; 1504 return -EIO;
1451 } 1505 }
1452 if (! val) 1506 if (!val)
1453 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM); 1507 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM);
1454 1508
1455 if (ratesp) { 1509 if (ratesp) {
1456 u32 rates = 0; 1510 u32 rates = 0;
1457 for (i = 0; rate_bits[i].hz; i++) { 1511 for (i = 0; i < AC_PAR_PCM_RATE_BITS; i++) {
1458 if (val & (1 << i)) 1512 if (val & (1 << i))
1459 rates |= rate_bits[i].alsa_bits; 1513 rates |= rate_bits[i].alsa_bits;
1460 } 1514 }
@@ -1470,8 +1524,9 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1470 streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM); 1524 streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
1471 if (streams == -1) 1525 if (streams == -1)
1472 return -EIO; 1526 return -EIO;
1473 if (! streams) { 1527 if (!streams) {
1474 streams = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM); 1528 streams = snd_hda_param_read(codec, codec->afg,
1529 AC_PAR_STREAM);
1475 if (streams == -1) 1530 if (streams == -1)
1476 return -EIO; 1531 return -EIO;
1477 } 1532 }
@@ -1495,7 +1550,8 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1495 bps = 24; 1550 bps = 24;
1496 else if (val & AC_SUPPCM_BITS_20) 1551 else if (val & AC_SUPPCM_BITS_20)
1497 bps = 20; 1552 bps = 20;
1498 } else if (val & (AC_SUPPCM_BITS_20|AC_SUPPCM_BITS_24|AC_SUPPCM_BITS_32)) { 1553 } else if (val & (AC_SUPPCM_BITS_20|AC_SUPPCM_BITS_24|
1554 AC_SUPPCM_BITS_32)) {
1499 formats |= SNDRV_PCM_FMTBIT_S32_LE; 1555 formats |= SNDRV_PCM_FMTBIT_S32_LE;
1500 if (val & AC_SUPPCM_BITS_32) 1556 if (val & AC_SUPPCM_BITS_32)
1501 bps = 32; 1557 bps = 32;
@@ -1505,10 +1561,12 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1505 bps = 20; 1561 bps = 20;
1506 } 1562 }
1507 } 1563 }
1508 else if (streams == AC_SUPFMT_FLOAT32) { /* should be exclusive */ 1564 else if (streams == AC_SUPFMT_FLOAT32) {
1565 /* should be exclusive */
1509 formats |= SNDRV_PCM_FMTBIT_FLOAT_LE; 1566 formats |= SNDRV_PCM_FMTBIT_FLOAT_LE;
1510 bps = 32; 1567 bps = 32;
1511 } else if (streams == AC_SUPFMT_AC3) { /* should be exclusive */ 1568 } else if (streams == AC_SUPFMT_AC3) {
1569 /* should be exclusive */
1512 /* temporary hack: we have still no proper support 1570 /* temporary hack: we have still no proper support
1513 * for the direct AC3 stream... 1571 * for the direct AC3 stream...
1514 */ 1572 */
@@ -1525,7 +1583,8 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
1525} 1583}
1526 1584
1527/** 1585/**
1528 * snd_hda_is_supported_format - check whether the given node supports the format val 1586 * snd_hda_is_supported_format - check whether the given node supports
1587 * the format val
1529 * 1588 *
1530 * Returns 1 if supported, 0 if not. 1589 * Returns 1 if supported, 0 if not.
1531 */ 1590 */
@@ -1541,50 +1600,50 @@ int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid,
1541 if (val == -1) 1600 if (val == -1)
1542 return 0; 1601 return 0;
1543 } 1602 }
1544 if (! val) { 1603 if (!val) {
1545 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM); 1604 val = snd_hda_param_read(codec, codec->afg, AC_PAR_PCM);
1546 if (val == -1) 1605 if (val == -1)
1547 return 0; 1606 return 0;
1548 } 1607 }
1549 1608
1550 rate = format & 0xff00; 1609 rate = format & 0xff00;
1551 for (i = 0; rate_bits[i].hz; i++) 1610 for (i = 0; i < AC_PAR_PCM_RATE_BITS; i++)
1552 if (rate_bits[i].hda_fmt == rate) { 1611 if (rate_bits[i].hda_fmt == rate) {
1553 if (val & (1 << i)) 1612 if (val & (1 << i))
1554 break; 1613 break;
1555 return 0; 1614 return 0;
1556 } 1615 }
1557 if (! rate_bits[i].hz) 1616 if (i >= AC_PAR_PCM_RATE_BITS)
1558 return 0; 1617 return 0;
1559 1618
1560 stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM); 1619 stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
1561 if (stream == -1) 1620 if (stream == -1)
1562 return 0; 1621 return 0;
1563 if (! stream && nid != codec->afg) 1622 if (!stream && nid != codec->afg)
1564 stream = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM); 1623 stream = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM);
1565 if (! stream || stream == -1) 1624 if (!stream || stream == -1)
1566 return 0; 1625 return 0;
1567 1626
1568 if (stream & AC_SUPFMT_PCM) { 1627 if (stream & AC_SUPFMT_PCM) {
1569 switch (format & 0xf0) { 1628 switch (format & 0xf0) {
1570 case 0x00: 1629 case 0x00:
1571 if (! (val & AC_SUPPCM_BITS_8)) 1630 if (!(val & AC_SUPPCM_BITS_8))
1572 return 0; 1631 return 0;
1573 break; 1632 break;
1574 case 0x10: 1633 case 0x10:
1575 if (! (val & AC_SUPPCM_BITS_16)) 1634 if (!(val & AC_SUPPCM_BITS_16))
1576 return 0; 1635 return 0;
1577 break; 1636 break;
1578 case 0x20: 1637 case 0x20:
1579 if (! (val & AC_SUPPCM_BITS_20)) 1638 if (!(val & AC_SUPPCM_BITS_20))
1580 return 0; 1639 return 0;
1581 break; 1640 break;
1582 case 0x30: 1641 case 0x30:
1583 if (! (val & AC_SUPPCM_BITS_24)) 1642 if (!(val & AC_SUPPCM_BITS_24))
1584 return 0; 1643 return 0;
1585 break; 1644 break;
1586 case 0x40: 1645 case 0x40:
1587 if (! (val & AC_SUPPCM_BITS_32)) 1646 if (!(val & AC_SUPPCM_BITS_32))
1588 return 0; 1647 return 0;
1589 break; 1648 break;
1590 default: 1649 default:
@@ -1625,15 +1684,15 @@ static int hda_pcm_default_cleanup(struct hda_pcm_stream *hinfo,
1625 return 0; 1684 return 0;
1626} 1685}
1627 1686
1628static int set_pcm_default_values(struct hda_codec *codec, struct hda_pcm_stream *info) 1687static int __devinit set_pcm_default_values(struct hda_codec *codec,
1688 struct hda_pcm_stream *info)
1629{ 1689{
1630 if (info->nid) { 1690 /* query support PCM information from the given NID */
1631 /* query support PCM information from the given NID */ 1691 if (info->nid && (!info->rates || !info->formats)) {
1632 if (! info->rates || ! info->formats) 1692 snd_hda_query_supported_pcm(codec, info->nid,
1633 snd_hda_query_supported_pcm(codec, info->nid, 1693 info->rates ? NULL : &info->rates,
1634 info->rates ? NULL : &info->rates, 1694 info->formats ? NULL : &info->formats,
1635 info->formats ? NULL : &info->formats, 1695 info->maxbps ? NULL : &info->maxbps);
1636 info->maxbps ? NULL : &info->maxbps);
1637 } 1696 }
1638 if (info->ops.open == NULL) 1697 if (info->ops.open == NULL)
1639 info->ops.open = hda_pcm_default_open_close; 1698 info->ops.open = hda_pcm_default_open_close;
@@ -1676,15 +1735,14 @@ static int set_pcm_default_values(struct hda_codec *codec, struct hda_pcm_stream
1676 * 1735 *
1677 * This function returns 0 if successfull, or a negative error code. 1736 * This function returns 0 if successfull, or a negative error code.
1678 */ 1737 */
1679int snd_hda_build_pcms(struct hda_bus *bus) 1738int __devinit snd_hda_build_pcms(struct hda_bus *bus)
1680{ 1739{
1681 struct list_head *p; 1740 struct hda_codec *codec;
1682 1741
1683 list_for_each(p, &bus->codec_list) { 1742 list_for_each_entry(codec, &bus->codec_list, list) {
1684 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
1685 unsigned int pcm, s; 1743 unsigned int pcm, s;
1686 int err; 1744 int err;
1687 if (! codec->patch_ops.build_pcms) 1745 if (!codec->patch_ops.build_pcms)
1688 continue; 1746 continue;
1689 err = codec->patch_ops.build_pcms(codec); 1747 err = codec->patch_ops.build_pcms(codec);
1690 if (err < 0) 1748 if (err < 0)
@@ -1693,7 +1751,7 @@ int snd_hda_build_pcms(struct hda_bus *bus)
1693 for (s = 0; s < 2; s++) { 1751 for (s = 0; s < 2; s++) {
1694 struct hda_pcm_stream *info; 1752 struct hda_pcm_stream *info;
1695 info = &codec->pcm_info[pcm].stream[s]; 1753 info = &codec->pcm_info[pcm].stream[s];
1696 if (! info->substreams) 1754 if (!info->substreams)
1697 continue; 1755 continue;
1698 err = set_pcm_default_values(codec, info); 1756 err = set_pcm_default_values(codec, info);
1699 if (err < 0) 1757 if (err < 0)
@@ -1704,8 +1762,6 @@ int snd_hda_build_pcms(struct hda_bus *bus)
1704 return 0; 1762 return 0;
1705} 1763}
1706 1764
1707EXPORT_SYMBOL(snd_hda_build_pcms);
1708
1709/** 1765/**
1710 * snd_hda_check_board_config - compare the current codec with the config table 1766 * snd_hda_check_board_config - compare the current codec with the config table
1711 * @codec: the HDA codec 1767 * @codec: the HDA codec
@@ -1719,9 +1775,9 @@ EXPORT_SYMBOL(snd_hda_build_pcms);
1719 * 1775 *
1720 * If no entries are matching, the function returns a negative value. 1776 * If no entries are matching, the function returns a negative value.
1721 */ 1777 */
1722int snd_hda_check_board_config(struct hda_codec *codec, 1778int __devinit snd_hda_check_board_config(struct hda_codec *codec,
1723 int num_configs, const char **models, 1779 int num_configs, const char **models,
1724 const struct snd_pci_quirk *tbl) 1780 const struct snd_pci_quirk *tbl)
1725{ 1781{
1726 if (codec->bus->modelname && models) { 1782 if (codec->bus->modelname && models) {
1727 int i; 1783 int i;
@@ -1771,24 +1827,26 @@ int snd_hda_check_board_config(struct hda_codec *codec,
1771 * 1827 *
1772 * Returns 0 if successful, or a negative error code. 1828 * Returns 0 if successful, or a negative error code.
1773 */ 1829 */
1774int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew) 1830int __devinit snd_hda_add_new_ctls(struct hda_codec *codec,
1831 struct snd_kcontrol_new *knew)
1775{ 1832{
1776 int err; 1833 int err;
1777 1834
1778 for (; knew->name; knew++) { 1835 for (; knew->name; knew++) {
1779 struct snd_kcontrol *kctl; 1836 struct snd_kcontrol *kctl;
1780 kctl = snd_ctl_new1(knew, codec); 1837 kctl = snd_ctl_new1(knew, codec);
1781 if (! kctl) 1838 if (!kctl)
1782 return -ENOMEM; 1839 return -ENOMEM;
1783 err = snd_ctl_add(codec->bus->card, kctl); 1840 err = snd_ctl_add(codec->bus->card, kctl);
1784 if (err < 0) { 1841 if (err < 0) {
1785 if (! codec->addr) 1842 if (!codec->addr)
1786 return err; 1843 return err;
1787 kctl = snd_ctl_new1(knew, codec); 1844 kctl = snd_ctl_new1(knew, codec);
1788 if (! kctl) 1845 if (!kctl)
1789 return -ENOMEM; 1846 return -ENOMEM;
1790 kctl->id.device = codec->addr; 1847 kctl->id.device = codec->addr;
1791 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0) 1848 err = snd_ctl_add(codec->bus->card, kctl);
1849 if (err < 0)
1792 return err; 1850 return err;
1793 } 1851 }
1794 } 1852 }
@@ -1799,8 +1857,10 @@ int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew)
1799/* 1857/*
1800 * Channel mode helper 1858 * Channel mode helper
1801 */ 1859 */
1802int snd_hda_ch_mode_info(struct hda_codec *codec, struct snd_ctl_elem_info *uinfo, 1860int snd_hda_ch_mode_info(struct hda_codec *codec,
1803 const struct hda_channel_mode *chmode, int num_chmodes) 1861 struct snd_ctl_elem_info *uinfo,
1862 const struct hda_channel_mode *chmode,
1863 int num_chmodes)
1804{ 1864{
1805 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1865 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1806 uinfo->count = 1; 1866 uinfo->count = 1;
@@ -1812,8 +1872,10 @@ int snd_hda_ch_mode_info(struct hda_codec *codec, struct snd_ctl_elem_info *uinf
1812 return 0; 1872 return 0;
1813} 1873}
1814 1874
1815int snd_hda_ch_mode_get(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol, 1875int snd_hda_ch_mode_get(struct hda_codec *codec,
1816 const struct hda_channel_mode *chmode, int num_chmodes, 1876 struct snd_ctl_elem_value *ucontrol,
1877 const struct hda_channel_mode *chmode,
1878 int num_chmodes,
1817 int max_channels) 1879 int max_channels)
1818{ 1880{
1819 int i; 1881 int i;
@@ -1827,15 +1889,17 @@ int snd_hda_ch_mode_get(struct hda_codec *codec, struct snd_ctl_elem_value *ucon
1827 return 0; 1889 return 0;
1828} 1890}
1829 1891
1830int snd_hda_ch_mode_put(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol, 1892int snd_hda_ch_mode_put(struct hda_codec *codec,
1831 const struct hda_channel_mode *chmode, int num_chmodes, 1893 struct snd_ctl_elem_value *ucontrol,
1894 const struct hda_channel_mode *chmode,
1895 int num_chmodes,
1832 int *max_channelsp) 1896 int *max_channelsp)
1833{ 1897{
1834 unsigned int mode; 1898 unsigned int mode;
1835 1899
1836 mode = ucontrol->value.enumerated.item[0]; 1900 mode = ucontrol->value.enumerated.item[0];
1837 snd_assert(mode < num_chmodes, return -EINVAL); 1901 snd_assert(mode < num_chmodes, return -EINVAL);
1838 if (*max_channelsp == chmode[mode].channels && ! codec->in_resume) 1902 if (*max_channelsp == chmode[mode].channels && !codec->in_resume)
1839 return 0; 1903 return 0;
1840 /* change the current channel setting */ 1904 /* change the current channel setting */
1841 *max_channelsp = chmode[mode].channels; 1905 *max_channelsp = chmode[mode].channels;
@@ -1847,7 +1911,8 @@ int snd_hda_ch_mode_put(struct hda_codec *codec, struct snd_ctl_elem_value *ucon
1847/* 1911/*
1848 * input MUX helper 1912 * input MUX helper
1849 */ 1913 */
1850int snd_hda_input_mux_info(const struct hda_input_mux *imux, struct snd_ctl_elem_info *uinfo) 1914int snd_hda_input_mux_info(const struct hda_input_mux *imux,
1915 struct snd_ctl_elem_info *uinfo)
1851{ 1916{
1852 unsigned int index; 1917 unsigned int index;
1853 1918
@@ -1861,8 +1926,10 @@ int snd_hda_input_mux_info(const struct hda_input_mux *imux, struct snd_ctl_elem
1861 return 0; 1926 return 0;
1862} 1927}
1863 1928
1864int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *imux, 1929int snd_hda_input_mux_put(struct hda_codec *codec,
1865 struct snd_ctl_elem_value *ucontrol, hda_nid_t nid, 1930 const struct hda_input_mux *imux,
1931 struct snd_ctl_elem_value *ucontrol,
1932 hda_nid_t nid,
1866 unsigned int *cur_val) 1933 unsigned int *cur_val)
1867{ 1934{
1868 unsigned int idx; 1935 unsigned int idx;
@@ -1870,7 +1937,7 @@ int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *i
1870 idx = ucontrol->value.enumerated.item[0]; 1937 idx = ucontrol->value.enumerated.item[0];
1871 if (idx >= imux->num_items) 1938 if (idx >= imux->num_items)
1872 idx = imux->num_items - 1; 1939 idx = imux->num_items - 1;
1873 if (*cur_val == idx && ! codec->in_resume) 1940 if (*cur_val == idx && !codec->in_resume)
1874 return 0; 1941 return 0;
1875 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, 1942 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
1876 imux->items[idx].index); 1943 imux->items[idx].index);
@@ -1883,25 +1950,53 @@ int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *i
1883 * Multi-channel / digital-out PCM helper functions 1950 * Multi-channel / digital-out PCM helper functions
1884 */ 1951 */
1885 1952
1953/* setup SPDIF output stream */
1954static void setup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid,
1955 unsigned int stream_tag, unsigned int format)
1956{
1957 /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */
1958 if (codec->spdif_ctls & AC_DIG1_ENABLE)
1959 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
1960 codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff);
1961 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
1962 /* turn on again (if needed) */
1963 if (codec->spdif_ctls & AC_DIG1_ENABLE)
1964 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
1965 codec->spdif_ctls & 0xff);
1966}
1967
1886/* 1968/*
1887 * open the digital out in the exclusive mode 1969 * open the digital out in the exclusive mode
1888 */ 1970 */
1889int snd_hda_multi_out_dig_open(struct hda_codec *codec, struct hda_multi_out *mout) 1971int snd_hda_multi_out_dig_open(struct hda_codec *codec,
1972 struct hda_multi_out *mout)
1890{ 1973{
1891 mutex_lock(&codec->spdif_mutex); 1974 mutex_lock(&codec->spdif_mutex);
1892 if (mout->dig_out_used) { 1975 if (mout->dig_out_used == HDA_DIG_ANALOG_DUP)
1893 mutex_unlock(&codec->spdif_mutex); 1976 /* already opened as analog dup; reset it once */
1894 return -EBUSY; /* already being used */ 1977 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0);
1895 }
1896 mout->dig_out_used = HDA_DIG_EXCLUSIVE; 1978 mout->dig_out_used = HDA_DIG_EXCLUSIVE;
1897 mutex_unlock(&codec->spdif_mutex); 1979 mutex_unlock(&codec->spdif_mutex);
1898 return 0; 1980 return 0;
1899} 1981}
1900 1982
1983int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
1984 struct hda_multi_out *mout,
1985 unsigned int stream_tag,
1986 unsigned int format,
1987 struct snd_pcm_substream *substream)
1988{
1989 mutex_lock(&codec->spdif_mutex);
1990 setup_dig_out_stream(codec, mout->dig_out_nid, stream_tag, format);
1991 mutex_unlock(&codec->spdif_mutex);
1992 return 0;
1993}
1994
1901/* 1995/*
1902 * release the digital out 1996 * release the digital out
1903 */ 1997 */
1904int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *mout) 1998int snd_hda_multi_out_dig_close(struct hda_codec *codec,
1999 struct hda_multi_out *mout)
1905{ 2000{
1906 mutex_lock(&codec->spdif_mutex); 2001 mutex_lock(&codec->spdif_mutex);
1907 mout->dig_out_used = 0; 2002 mout->dig_out_used = 0;
@@ -1912,7 +2007,8 @@ int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *m
1912/* 2007/*
1913 * set up more restrictions for analog out 2008 * set up more restrictions for analog out
1914 */ 2009 */
1915int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out *mout, 2010int snd_hda_multi_out_analog_open(struct hda_codec *codec,
2011 struct hda_multi_out *mout,
1916 struct snd_pcm_substream *substream) 2012 struct snd_pcm_substream *substream)
1917{ 2013{
1918 substream->runtime->hw.channels_max = mout->max_channels; 2014 substream->runtime->hw.channels_max = mout->max_channels;
@@ -1924,7 +2020,8 @@ int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out
1924 * set up the i/o for analog out 2020 * set up the i/o for analog out
1925 * when the digital out is available, copy the front out to digital out, too. 2021 * when the digital out is available, copy the front out to digital out, too.
1926 */ 2022 */
1927int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout, 2023int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
2024 struct hda_multi_out *mout,
1928 unsigned int stream_tag, 2025 unsigned int stream_tag,
1929 unsigned int format, 2026 unsigned int format,
1930 struct snd_pcm_substream *substream) 2027 struct snd_pcm_substream *substream)
@@ -1936,24 +2033,27 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_o
1936 mutex_lock(&codec->spdif_mutex); 2033 mutex_lock(&codec->spdif_mutex);
1937 if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) { 2034 if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) {
1938 if (chs == 2 && 2035 if (chs == 2 &&
1939 snd_hda_is_supported_format(codec, mout->dig_out_nid, format) && 2036 snd_hda_is_supported_format(codec, mout->dig_out_nid,
1940 ! (codec->spdif_status & IEC958_AES0_NONAUDIO)) { 2037 format) &&
2038 !(codec->spdif_status & IEC958_AES0_NONAUDIO)) {
1941 mout->dig_out_used = HDA_DIG_ANALOG_DUP; 2039 mout->dig_out_used = HDA_DIG_ANALOG_DUP;
1942 /* setup digital receiver */ 2040 setup_dig_out_stream(codec, mout->dig_out_nid,
1943 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 2041 stream_tag, format);
1944 stream_tag, 0, format);
1945 } else { 2042 } else {
1946 mout->dig_out_used = 0; 2043 mout->dig_out_used = 0;
1947 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0); 2044 snd_hda_codec_setup_stream(codec, mout->dig_out_nid,
2045 0, 0, 0);
1948 } 2046 }
1949 } 2047 }
1950 mutex_unlock(&codec->spdif_mutex); 2048 mutex_unlock(&codec->spdif_mutex);
1951 2049
1952 /* front */ 2050 /* front */
1953 snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag, 0, format); 2051 snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag,
2052 0, format);
1954 if (mout->hp_nid && mout->hp_nid != nids[HDA_FRONT]) 2053 if (mout->hp_nid && mout->hp_nid != nids[HDA_FRONT])
1955 /* headphone out will just decode front left/right (stereo) */ 2054 /* headphone out will just decode front left/right (stereo) */
1956 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 0, format); 2055 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag,
2056 0, format);
1957 /* extra outputs copied from front */ 2057 /* extra outputs copied from front */
1958 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++) 2058 for (i = 0; i < ARRAY_SIZE(mout->extra_out_nid); i++)
1959 if (mout->extra_out_nid[i]) 2059 if (mout->extra_out_nid[i])
@@ -1964,11 +2064,11 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_o
1964 /* surrounds */ 2064 /* surrounds */
1965 for (i = 1; i < mout->num_dacs; i++) { 2065 for (i = 1; i < mout->num_dacs; i++) {
1966 if (chs >= (i + 1) * 2) /* independent out */ 2066 if (chs >= (i + 1) * 2) /* independent out */
1967 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, i * 2, 2067 snd_hda_codec_setup_stream(codec, nids[i], stream_tag,
1968 format); 2068 i * 2, format);
1969 else /* copy front */ 2069 else /* copy front */
1970 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, 0, 2070 snd_hda_codec_setup_stream(codec, nids[i], stream_tag,
1971 format); 2071 0, format);
1972 } 2072 }
1973 return 0; 2073 return 0;
1974} 2074}
@@ -1976,7 +2076,8 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_o
1976/* 2076/*
1977 * clean up the setting for analog out 2077 * clean up the setting for analog out
1978 */ 2078 */
1979int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, struct hda_multi_out *mout) 2079int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec,
2080 struct hda_multi_out *mout)
1980{ 2081{
1981 hda_nid_t *nids = mout->dac_nids; 2082 hda_nid_t *nids = mout->dac_nids;
1982 int i; 2083 int i;
@@ -2003,7 +2104,7 @@ int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, struct hda_multi_o
2003 * Helper for automatic ping configuration 2104 * Helper for automatic ping configuration
2004 */ 2105 */
2005 2106
2006static int is_in_nid_list(hda_nid_t nid, hda_nid_t *list) 2107static int __devinit is_in_nid_list(hda_nid_t nid, hda_nid_t *list)
2007{ 2108{
2008 for (; *list; list++) 2109 for (; *list; list++)
2009 if (*list == nid) 2110 if (*list == nid)
@@ -2011,6 +2112,32 @@ static int is_in_nid_list(hda_nid_t nid, hda_nid_t *list)
2011 return 0; 2112 return 0;
2012} 2113}
2013 2114
2115
2116/*
2117 * Sort an associated group of pins according to their sequence numbers.
2118 */
2119static void sort_pins_by_sequence(hda_nid_t * pins, short * sequences,
2120 int num_pins)
2121{
2122 int i, j;
2123 short seq;
2124 hda_nid_t nid;
2125
2126 for (i = 0; i < num_pins; i++) {
2127 for (j = i + 1; j < num_pins; j++) {
2128 if (sequences[i] > sequences[j]) {
2129 seq = sequences[i];
2130 sequences[i] = sequences[j];
2131 sequences[j] = seq;
2132 nid = pins[i];
2133 pins[i] = pins[j];
2134 pins[j] = nid;
2135 }
2136 }
2137 }
2138}
2139
2140
2014/* 2141/*
2015 * Parse all pin widgets and store the useful pin nids to cfg 2142 * Parse all pin widgets and store the useful pin nids to cfg
2016 * 2143 *
@@ -2028,22 +2155,27 @@ static int is_in_nid_list(hda_nid_t nid, hda_nid_t *list)
2028 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin, 2155 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin,
2029 * respectively. 2156 * respectively.
2030 */ 2157 */
2031int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg, 2158int __devinit snd_hda_parse_pin_def_config(struct hda_codec *codec,
2032 hda_nid_t *ignore_nids) 2159 struct auto_pin_cfg *cfg,
2160 hda_nid_t *ignore_nids)
2033{ 2161{
2034 hda_nid_t nid, nid_start; 2162 hda_nid_t nid, nid_start;
2035 int i, j, nodes; 2163 int nodes;
2036 short seq, assoc_line_out, sequences[ARRAY_SIZE(cfg->line_out_pins)]; 2164 short seq, assoc_line_out, assoc_speaker;
2165 short sequences_line_out[ARRAY_SIZE(cfg->line_out_pins)];
2166 short sequences_speaker[ARRAY_SIZE(cfg->speaker_pins)];
2037 2167
2038 memset(cfg, 0, sizeof(*cfg)); 2168 memset(cfg, 0, sizeof(*cfg));
2039 2169
2040 memset(sequences, 0, sizeof(sequences)); 2170 memset(sequences_line_out, 0, sizeof(sequences_line_out));
2041 assoc_line_out = 0; 2171 memset(sequences_speaker, 0, sizeof(sequences_speaker));
2172 assoc_line_out = assoc_speaker = 0;
2042 2173
2043 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid_start); 2174 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid_start);
2044 for (nid = nid_start; nid < nodes + nid_start; nid++) { 2175 for (nid = nid_start; nid < nodes + nid_start; nid++) {
2045 unsigned int wid_caps = get_wcaps(codec, nid); 2176 unsigned int wid_caps = get_wcaps(codec, nid);
2046 unsigned int wid_type = (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 2177 unsigned int wid_type =
2178 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2047 unsigned int def_conf; 2179 unsigned int def_conf;
2048 short assoc, loc; 2180 short assoc, loc;
2049 2181
@@ -2054,7 +2186,8 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
2054 if (ignore_nids && is_in_nid_list(nid, ignore_nids)) 2186 if (ignore_nids && is_in_nid_list(nid, ignore_nids))
2055 continue; 2187 continue;
2056 2188
2057 def_conf = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 2189 def_conf = snd_hda_codec_read(codec, nid, 0,
2190 AC_VERB_GET_CONFIG_DEFAULT, 0);
2058 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) 2191 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2059 continue; 2192 continue;
2060 loc = get_defcfg_location(def_conf); 2193 loc = get_defcfg_location(def_conf);
@@ -2062,22 +2195,31 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
2062 case AC_JACK_LINE_OUT: 2195 case AC_JACK_LINE_OUT:
2063 seq = get_defcfg_sequence(def_conf); 2196 seq = get_defcfg_sequence(def_conf);
2064 assoc = get_defcfg_association(def_conf); 2197 assoc = get_defcfg_association(def_conf);
2065 if (! assoc) 2198 if (!assoc)
2066 continue; 2199 continue;
2067 if (! assoc_line_out) 2200 if (!assoc_line_out)
2068 assoc_line_out = assoc; 2201 assoc_line_out = assoc;
2069 else if (assoc_line_out != assoc) 2202 else if (assoc_line_out != assoc)
2070 continue; 2203 continue;
2071 if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins)) 2204 if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins))
2072 continue; 2205 continue;
2073 cfg->line_out_pins[cfg->line_outs] = nid; 2206 cfg->line_out_pins[cfg->line_outs] = nid;
2074 sequences[cfg->line_outs] = seq; 2207 sequences_line_out[cfg->line_outs] = seq;
2075 cfg->line_outs++; 2208 cfg->line_outs++;
2076 break; 2209 break;
2077 case AC_JACK_SPEAKER: 2210 case AC_JACK_SPEAKER:
2211 seq = get_defcfg_sequence(def_conf);
2212 assoc = get_defcfg_association(def_conf);
2213 if (! assoc)
2214 continue;
2215 if (! assoc_speaker)
2216 assoc_speaker = assoc;
2217 else if (assoc_speaker != assoc)
2218 continue;
2078 if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins)) 2219 if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins))
2079 continue; 2220 continue;
2080 cfg->speaker_pins[cfg->speaker_outs] = nid; 2221 cfg->speaker_pins[cfg->speaker_outs] = nid;
2222 sequences_speaker[cfg->speaker_outs] = seq;
2081 cfg->speaker_outs++; 2223 cfg->speaker_outs++;
2082 break; 2224 break;
2083 case AC_JACK_HP_OUT: 2225 case AC_JACK_HP_OUT:
@@ -2123,34 +2265,45 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
2123 } 2265 }
2124 2266
2125 /* sort by sequence */ 2267 /* sort by sequence */
2126 for (i = 0; i < cfg->line_outs; i++) 2268 sort_pins_by_sequence(cfg->line_out_pins, sequences_line_out,
2127 for (j = i + 1; j < cfg->line_outs; j++) 2269 cfg->line_outs);
2128 if (sequences[i] > sequences[j]) { 2270 sort_pins_by_sequence(cfg->speaker_pins, sequences_speaker,
2129 seq = sequences[i]; 2271 cfg->speaker_outs);
2130 sequences[i] = sequences[j]; 2272
2131 sequences[j] = seq; 2273 /*
2132 nid = cfg->line_out_pins[i]; 2274 * FIX-UP: if no line-outs are detected, try to use speaker or HP pin
2133 cfg->line_out_pins[i] = cfg->line_out_pins[j]; 2275 * as a primary output
2134 cfg->line_out_pins[j] = nid; 2276 */
2135 } 2277 if (!cfg->line_outs) {
2278 if (cfg->speaker_outs) {
2279 cfg->line_outs = cfg->speaker_outs;
2280 memcpy(cfg->line_out_pins, cfg->speaker_pins,
2281 sizeof(cfg->speaker_pins));
2282 cfg->speaker_outs = 0;
2283 memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins));
2284 cfg->line_out_type = AUTO_PIN_SPEAKER_OUT;
2285 } else if (cfg->hp_outs) {
2286 cfg->line_outs = cfg->hp_outs;
2287 memcpy(cfg->line_out_pins, cfg->hp_pins,
2288 sizeof(cfg->hp_pins));
2289 cfg->hp_outs = 0;
2290 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins));
2291 cfg->line_out_type = AUTO_PIN_HP_OUT;
2292 }
2293 }
2136 2294
2137 /* Reorder the surround channels 2295 /* Reorder the surround channels
2138 * ALSA sequence is front/surr/clfe/side 2296 * ALSA sequence is front/surr/clfe/side
2139 * HDA sequence is: 2297 * HDA sequence is:
2140 * 4-ch: front/surr => OK as it is 2298 * 4-ch: front/surr => OK as it is
2141 * 6-ch: front/clfe/surr 2299 * 6-ch: front/clfe/surr
2142 * 8-ch: front/clfe/side/surr 2300 * 8-ch: front/clfe/rear/side|fc
2143 */ 2301 */
2144 switch (cfg->line_outs) { 2302 switch (cfg->line_outs) {
2145 case 3: 2303 case 3:
2146 nid = cfg->line_out_pins[1];
2147 cfg->line_out_pins[1] = cfg->line_out_pins[2];
2148 cfg->line_out_pins[2] = nid;
2149 break;
2150 case 4: 2304 case 4:
2151 nid = cfg->line_out_pins[1]; 2305 nid = cfg->line_out_pins[1];
2152 cfg->line_out_pins[1] = cfg->line_out_pins[3]; 2306 cfg->line_out_pins[1] = cfg->line_out_pins[2];
2153 cfg->line_out_pins[3] = cfg->line_out_pins[2];
2154 cfg->line_out_pins[2] = nid; 2307 cfg->line_out_pins[2] = nid;
2155 break; 2308 break;
2156 } 2309 }
@@ -2179,26 +2332,6 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
2179 cfg->input_pins[AUTO_PIN_CD], 2332 cfg->input_pins[AUTO_PIN_CD],
2180 cfg->input_pins[AUTO_PIN_AUX]); 2333 cfg->input_pins[AUTO_PIN_AUX]);
2181 2334
2182 /*
2183 * FIX-UP: if no line-outs are detected, try to use speaker or HP pin
2184 * as a primary output
2185 */
2186 if (! cfg->line_outs) {
2187 if (cfg->speaker_outs) {
2188 cfg->line_outs = cfg->speaker_outs;
2189 memcpy(cfg->line_out_pins, cfg->speaker_pins,
2190 sizeof(cfg->speaker_pins));
2191 cfg->speaker_outs = 0;
2192 memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins));
2193 } else if (cfg->hp_outs) {
2194 cfg->line_outs = cfg->hp_outs;
2195 memcpy(cfg->line_out_pins, cfg->hp_pins,
2196 sizeof(cfg->hp_pins));
2197 cfg->hp_outs = 0;
2198 memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins));
2199 }
2200 }
2201
2202 return 0; 2335 return 0;
2203} 2336}
2204 2337
@@ -2222,11 +2355,10 @@ const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = {
2222 */ 2355 */
2223int snd_hda_suspend(struct hda_bus *bus, pm_message_t state) 2356int snd_hda_suspend(struct hda_bus *bus, pm_message_t state)
2224{ 2357{
2225 struct list_head *p; 2358 struct hda_codec *codec;
2226 2359
2227 /* FIXME: should handle power widget capabilities */ 2360 /* FIXME: should handle power widget capabilities */
2228 list_for_each(p, &bus->codec_list) { 2361 list_for_each_entry(codec, &bus->codec_list, list) {
2229 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
2230 if (codec->patch_ops.suspend) 2362 if (codec->patch_ops.suspend)
2231 codec->patch_ops.suspend(codec, state); 2363 codec->patch_ops.suspend(codec, state);
2232 hda_set_power_state(codec, 2364 hda_set_power_state(codec,
@@ -2236,8 +2368,6 @@ int snd_hda_suspend(struct hda_bus *bus, pm_message_t state)
2236 return 0; 2368 return 0;
2237} 2369}
2238 2370
2239EXPORT_SYMBOL(snd_hda_suspend);
2240
2241/** 2371/**
2242 * snd_hda_resume - resume the codecs 2372 * snd_hda_resume - resume the codecs
2243 * @bus: the HDA bus 2373 * @bus: the HDA bus
@@ -2247,10 +2377,9 @@ EXPORT_SYMBOL(snd_hda_suspend);
2247 */ 2377 */
2248int snd_hda_resume(struct hda_bus *bus) 2378int snd_hda_resume(struct hda_bus *bus)
2249{ 2379{
2250 struct list_head *p; 2380 struct hda_codec *codec;
2251 2381
2252 list_for_each(p, &bus->codec_list) { 2382 list_for_each_entry(codec, &bus->codec_list, list) {
2253 struct hda_codec *codec = list_entry(p, struct hda_codec, list);
2254 hda_set_power_state(codec, 2383 hda_set_power_state(codec,
2255 codec->afg ? codec->afg : codec->mfg, 2384 codec->afg ? codec->afg : codec->mfg,
2256 AC_PWRST_D0); 2385 AC_PWRST_D0);
@@ -2260,8 +2389,6 @@ int snd_hda_resume(struct hda_bus *bus)
2260 return 0; 2389 return 0;
2261} 2390}
2262 2391
2263EXPORT_SYMBOL(snd_hda_resume);
2264
2265/** 2392/**
2266 * snd_hda_resume_ctls - resume controls in the new control list 2393 * snd_hda_resume_ctls - resume controls in the new control list
2267 * @codec: the HDA codec 2394 * @codec: the HDA codec
@@ -2276,7 +2403,7 @@ int snd_hda_resume_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew)
2276 struct snd_ctl_elem_value *val; 2403 struct snd_ctl_elem_value *val;
2277 2404
2278 val = kmalloc(sizeof(*val), GFP_KERNEL); 2405 val = kmalloc(sizeof(*val), GFP_KERNEL);
2279 if (! val) 2406 if (!val)
2280 return -ENOMEM; 2407 return -ENOMEM;
2281 codec->in_resume = 1; 2408 codec->in_resume = 1;
2282 for (; knew->name; knew++) { 2409 for (; knew->name; knew++) {
@@ -2320,19 +2447,3 @@ int snd_hda_resume_spdif_in(struct hda_codec *codec)
2320 return snd_hda_resume_ctls(codec, dig_in_ctls); 2447 return snd_hda_resume_ctls(codec, dig_in_ctls);
2321} 2448}
2322#endif 2449#endif
2323
2324/*
2325 * INIT part
2326 */
2327
2328static int __init alsa_hda_init(void)
2329{
2330 return 0;
2331}
2332
2333static void __exit alsa_hda_exit(void)
2334{
2335}
2336
2337module_init(alsa_hda_init)
2338module_exit(alsa_hda_exit)
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index c12bc4e8840f..56c26e7ccdf1 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -233,7 +233,7 @@ enum {
233 */ 233 */
234 234
235/* Amp gain/mute */ 235/* Amp gain/mute */
236#define AC_AMP_MUTE (1<<8) 236#define AC_AMP_MUTE (1<<7)
237#define AC_AMP_GAIN (0x7f) 237#define AC_AMP_GAIN (0x7f)
238#define AC_AMP_GET_INDEX (0xf<<0) 238#define AC_AMP_GET_INDEX (0xf<<0)
239 239
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 1e5ff0cd3709..000287f7da43 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -133,7 +133,7 @@ static int add_new_node(struct hda_codec *codec, struct hda_gspec *spec, hda_nid
133 return -ENOMEM; 133 return -ENOMEM;
134 } 134 }
135 } 135 }
136 memcpy(node->conn_list, conn_list, nconns); 136 memcpy(node->conn_list, conn_list, nconns * sizeof(hda_nid_t));
137 node->nconns = nconns; 137 node->nconns = nconns;
138 node->wid_caps = get_wcaps(codec, nid); 138 node->wid_caps = get_wcaps(codec, nid);
139 node->type = (node->wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 139 node->type = (node->wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 1672cace1ae7..2fa281cbef91 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -88,6 +88,8 @@ MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
88 "{ATI, SB600}," 88 "{ATI, SB600},"
89 "{ATI, RS600}," 89 "{ATI, RS600},"
90 "{ATI, RS690}," 90 "{ATI, RS690},"
91 "{ATI, RS780},"
92 "{ATI, R600},"
91 "{VIA, VT8251}," 93 "{VIA, VT8251},"
92 "{VIA, VT8237A}," 94 "{VIA, VT8237A},"
93 "{SiS, SIS966}," 95 "{SiS, SIS966},"
@@ -198,6 +200,7 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
198#define RIRB_INT_MASK 0x05 200#define RIRB_INT_MASK 0x05
199 201
200/* STATESTS int mask: SD2,SD1,SD0 */ 202/* STATESTS int mask: SD2,SD1,SD0 */
203#define AZX_MAX_CODECS 3
201#define STATESTS_INT_MASK 0x07 204#define STATESTS_INT_MASK 0x07
202 205
203/* SD_CTL bits */ 206/* SD_CTL bits */
@@ -978,7 +981,7 @@ static unsigned int azx_max_codecs[] __devinitdata = {
978static int __devinit azx_codec_create(struct azx *chip, const char *model) 981static int __devinit azx_codec_create(struct azx *chip, const char *model)
979{ 982{
980 struct hda_bus_template bus_temp; 983 struct hda_bus_template bus_temp;
981 int c, codecs, err; 984 int c, codecs, audio_codecs, err;
982 985
983 memset(&bus_temp, 0, sizeof(bus_temp)); 986 memset(&bus_temp, 0, sizeof(bus_temp));
984 bus_temp.private_data = chip; 987 bus_temp.private_data = chip;
@@ -990,16 +993,30 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model)
990 if ((err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus)) < 0) 993 if ((err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus)) < 0)
991 return err; 994 return err;
992 995
993 codecs = 0; 996 codecs = audio_codecs = 0;
994 for (c = 0; c < azx_max_codecs[chip->driver_type]; c++) { 997 for (c = 0; c < AZX_MAX_CODECS; c++) {
995 if ((chip->codec_mask & (1 << c)) & probe_mask) { 998 if ((chip->codec_mask & (1 << c)) & probe_mask) {
996 err = snd_hda_codec_new(chip->bus, c, NULL); 999 struct hda_codec *codec;
1000 err = snd_hda_codec_new(chip->bus, c, &codec);
997 if (err < 0) 1001 if (err < 0)
998 continue; 1002 continue;
999 codecs++; 1003 codecs++;
1004 if (codec->afg)
1005 audio_codecs++;
1000 } 1006 }
1001 } 1007 }
1002 if (! codecs) { 1008 if (!audio_codecs) {
1009 /* probe additional slots if no codec is found */
1010 for (; c < azx_max_codecs[chip->driver_type]; c++) {
1011 if ((chip->codec_mask & (1 << c)) & probe_mask) {
1012 err = snd_hda_codec_new(chip->bus, c, NULL);
1013 if (err < 0)
1014 continue;
1015 codecs++;
1016 }
1017 }
1018 }
1019 if (!codecs) {
1003 snd_printk(KERN_ERR SFX "no codecs initialized\n"); 1020 snd_printk(KERN_ERR SFX "no codecs initialized\n");
1004 return -ENXIO; 1021 return -ENXIO;
1005 } 1022 }
@@ -1518,7 +1535,7 @@ static int azx_dev_free(struct snd_device *device)
1518/* 1535/*
1519 * white/black-listing for position_fix 1536 * white/black-listing for position_fix
1520 */ 1537 */
1521static const struct snd_pci_quirk position_fix_list[] __devinitdata = { 1538static struct snd_pci_quirk position_fix_list[] __devinitdata = {
1522 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_NONE), 1539 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_NONE),
1523 {} 1540 {}
1524}; 1541};
@@ -1758,6 +1775,8 @@ static struct pci_device_id azx_ids[] = {
1758 { 0x1002, 0x4383, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB600 */ 1775 { 0x1002, 0x4383, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB600 */
1759 { 0x1002, 0x793b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS600 HDMI */ 1776 { 0x1002, 0x793b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS600 HDMI */
1760 { 0x1002, 0x7919, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS690 HDMI */ 1777 { 0x1002, 0x7919, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS690 HDMI */
1778 { 0x1002, 0x960c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI RS780 HDMI */
1779 { 0x1002, 0xaa00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATIHDMI }, /* ATI R600 HDMI */
1761 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */ 1780 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */
1762 { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */ 1781 { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */
1763 { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */ 1782 { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 39718d6cdadd..be12b8814c39 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -148,6 +148,11 @@ struct hda_multi_out {
148 148
149int snd_hda_multi_out_dig_open(struct hda_codec *codec, struct hda_multi_out *mout); 149int snd_hda_multi_out_dig_open(struct hda_codec *codec, struct hda_multi_out *mout);
150int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *mout); 150int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *mout);
151int snd_hda_multi_out_dig_prepare(struct hda_codec *codec,
152 struct hda_multi_out *mout,
153 unsigned int stream_tag,
154 unsigned int format,
155 struct snd_pcm_substream *substream);
151int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out *mout, 156int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out *mout,
152 struct snd_pcm_substream *substream); 157 struct snd_pcm_substream *substream);
153int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout, 158int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout,
@@ -217,6 +222,12 @@ enum {
217 AUTO_PIN_LAST 222 AUTO_PIN_LAST
218}; 223};
219 224
225enum {
226 AUTO_PIN_LINE_OUT,
227 AUTO_PIN_SPEAKER_OUT,
228 AUTO_PIN_HP_OUT
229};
230
220extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST]; 231extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST];
221 232
222struct auto_pin_cfg { 233struct auto_pin_cfg {
@@ -225,6 +236,7 @@ struct auto_pin_cfg {
225 int speaker_outs; 236 int speaker_outs;
226 hda_nid_t speaker_pins[5]; 237 hda_nid_t speaker_pins[5];
227 int hp_outs; 238 int hp_outs;
239 int line_out_type; /* AUTO_PIN_XXX_OUT */
228 hda_nid_t hp_pins[5]; 240 hda_nid_t hp_pins[5];
229 hda_nid_t input_pins[AUTO_PIN_LAST]; 241 hda_nid_t input_pins[AUTO_PIN_LAST];
230 hda_nid_t dig_out_pin; 242 hda_nid_t dig_out_pin;
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index f94f1f22889e..0e1a879663fa 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -192,6 +192,17 @@ static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
192 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 192 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
193} 193}
194 194
195static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
196 struct hda_codec *codec,
197 unsigned int stream_tag,
198 unsigned int format,
199 struct snd_pcm_substream *substream)
200{
201 struct ad198x_spec *spec = codec->spec;
202 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
203 format, substream);
204}
205
195/* 206/*
196 * Analog capture 207 * Analog capture
197 */ 208 */
@@ -250,7 +261,8 @@ static struct hda_pcm_stream ad198x_pcm_digital_playback = {
250 .nid = 0, /* fill later */ 261 .nid = 0, /* fill later */
251 .ops = { 262 .ops = {
252 .open = ad198x_dig_playback_pcm_open, 263 .open = ad198x_dig_playback_pcm_open,
253 .close = ad198x_dig_playback_pcm_close 264 .close = ad198x_dig_playback_pcm_close,
265 .prepare = ad198x_dig_playback_pcm_prepare
254 }, 266 },
255}; 267};
256 268
@@ -739,41 +751,35 @@ static struct hda_verb ad1986a_init_verbs[] = {
739 { } /* end */ 751 { } /* end */
740}; 752};
741 753
742/* additional verbs for 3-stack model */
743static struct hda_verb ad1986a_3st_init_verbs[] = {
744 /* Mic and line-in selectors */
745 {0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
746 {0x10, AC_VERB_SET_CONNECT_SEL, 0x1},
747 { } /* end */
748};
749
750static struct hda_verb ad1986a_ch2_init[] = { 754static struct hda_verb ad1986a_ch2_init[] = {
751 /* Surround out -> Line In */ 755 /* Surround out -> Line In */
752 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 756 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
753 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 757 /* Line-in selectors */
758 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x1 },
754 /* CLFE -> Mic in */ 759 /* CLFE -> Mic in */
755 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 760 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
756 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 761 /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
762 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
757 { } /* end */ 763 { } /* end */
758}; 764};
759 765
760static struct hda_verb ad1986a_ch4_init[] = { 766static struct hda_verb ad1986a_ch4_init[] = {
761 /* Surround out -> Surround */ 767 /* Surround out -> Surround */
762 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 768 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
763 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 769 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
764 /* CLFE -> Mic in */ 770 /* CLFE -> Mic in */
765 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 771 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
766 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 772 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
767 { } /* end */ 773 { } /* end */
768}; 774};
769 775
770static struct hda_verb ad1986a_ch6_init[] = { 776static struct hda_verb ad1986a_ch6_init[] = {
771 /* Surround out -> Surround out */ 777 /* Surround out -> Surround out */
772 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 778 { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
773 { 0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 779 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
774 /* CLFE -> CLFE */ 780 /* CLFE -> CLFE */
775 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 781 { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
776 { 0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 782 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x0 },
777 { } /* end */ 783 { } /* end */
778}; 784};
779 785
@@ -828,6 +834,7 @@ static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
828 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD), 834 SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD),
829 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD), 835 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD),
830 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD), 836 SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD),
837 SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK),
831 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK), 838 SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK),
832 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP), 839 SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP),
833 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK), 840 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK),
@@ -882,9 +889,8 @@ static int patch_ad1986a(struct hda_codec *codec)
882 case AD1986A_3STACK: 889 case AD1986A_3STACK:
883 spec->num_mixers = 2; 890 spec->num_mixers = 2;
884 spec->mixers[1] = ad1986a_3st_mixers; 891 spec->mixers[1] = ad1986a_3st_mixers;
885 spec->num_init_verbs = 3; 892 spec->num_init_verbs = 2;
886 spec->init_verbs[1] = ad1986a_3st_init_verbs; 893 spec->init_verbs[1] = ad1986a_ch2_init;
887 spec->init_verbs[2] = ad1986a_ch2_init;
888 spec->channel_mode = ad1986a_modes; 894 spec->channel_mode = ad1986a_modes;
889 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes); 895 spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes);
890 spec->need_dac_fix = 1; 896 spec->need_dac_fix = 1;
@@ -1892,8 +1898,9 @@ static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol,
1892 1898
1893 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0); 1899 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0);
1894 if (sel > 0) { 1900 if (sel > 0) {
1895 sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0); 1901 sel = snd_hda_codec_read(codec, 0x0b, 0,
1896 if (sel <= 3) 1902 AC_VERB_GET_CONNECT_SEL, 0);
1903 if (sel < 3)
1897 sel++; 1904 sel++;
1898 else 1905 else
1899 sel = 0; 1906 sel = 0;
@@ -1906,23 +1913,27 @@ static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol,
1906 struct snd_ctl_elem_value *ucontrol) 1913 struct snd_ctl_elem_value *ucontrol)
1907{ 1914{
1908 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1915 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1909 unsigned int sel; 1916 unsigned int val, sel;
1910 int change; 1917 int change;
1911 1918
1919 val = ucontrol->value.enumerated.item[0];
1912 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0); 1920 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0);
1913 if (! ucontrol->value.enumerated.item[0]) { 1921 if (!val) {
1914 change = sel != 0; 1922 change = sel != 0;
1915 if (change) 1923 if (change || codec->in_resume)
1916 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 0); 1924 snd_hda_codec_write(codec, 0x02, 0,
1925 AC_VERB_SET_CONNECT_SEL, 0);
1917 } else { 1926 } else {
1918 change = sel == 0; 1927 change = sel == 0;
1919 if (change) 1928 if (change || codec->in_resume)
1920 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 1); 1929 snd_hda_codec_write(codec, 0x02, 0,
1921 sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0) + 1; 1930 AC_VERB_SET_CONNECT_SEL, 1);
1922 change |= sel == ucontrol->value.enumerated.item[0]; 1931 sel = snd_hda_codec_read(codec, 0x0b, 0,
1923 if (change) 1932 AC_VERB_GET_CONNECT_SEL, 0) + 1;
1924 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 1933 change |= sel != val;
1925 ucontrol->value.enumerated.item[0] - 1); 1934 if (change || codec->in_resume)
1935 snd_hda_codec_write(codec, 0x0b, 0,
1936 AC_VERB_SET_CONNECT_SEL, val - 1);
1926 } 1937 }
1927 return change; 1938 return change;
1928} 1939}
diff --git a/sound/pci/hda/patch_atihdmi.c b/sound/pci/hda/patch_atihdmi.c
index 831469d3a923..f8eb4c90f801 100644
--- a/sound/pci/hda/patch_atihdmi.c
+++ b/sound/pci/hda/patch_atihdmi.c
@@ -94,6 +94,17 @@ static int atihdmi_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
94 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 94 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
95} 95}
96 96
97static int atihdmi_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
98 struct hda_codec *codec,
99 unsigned int stream_tag,
100 unsigned int format,
101 struct snd_pcm_substream *substream)
102{
103 struct atihdmi_spec *spec = codec->spec;
104 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
105 format, substream);
106}
107
97static struct hda_pcm_stream atihdmi_pcm_digital_playback = { 108static struct hda_pcm_stream atihdmi_pcm_digital_playback = {
98 .substreams = 1, 109 .substreams = 1,
99 .channels_min = 2, 110 .channels_min = 2,
@@ -101,7 +112,8 @@ static struct hda_pcm_stream atihdmi_pcm_digital_playback = {
101 .nid = 0x2, /* NID to query formats and rates and setup streams */ 112 .nid = 0x2, /* NID to query formats and rates and setup streams */
102 .ops = { 113 .ops = {
103 .open = atihdmi_dig_playback_pcm_open, 114 .open = atihdmi_dig_playback_pcm_open,
104 .close = atihdmi_dig_playback_pcm_close 115 .close = atihdmi_dig_playback_pcm_close,
116 .prepare = atihdmi_dig_playback_pcm_prepare
105 }, 117 },
106}; 118};
107 119
@@ -160,6 +172,7 @@ static int patch_atihdmi(struct hda_codec *codec)
160 */ 172 */
161struct hda_codec_preset snd_hda_preset_atihdmi[] = { 173struct hda_codec_preset snd_hda_preset_atihdmi[] = {
162 { .id = 0x1002793c, .name = "ATI RS600 HDMI", .patch = patch_atihdmi }, 174 { .id = 0x1002793c, .name = "ATI RS600 HDMI", .patch = patch_atihdmi },
163 { .id = 0x1002791a, .name = "ATI RS690 HDMI", .patch = patch_atihdmi }, 175 { .id = 0x1002791a, .name = "ATI RS690/780 HDMI", .patch = patch_atihdmi },
176 { .id = 0x1002aa01, .name = "ATI R600 HDMI", .patch = patch_atihdmi },
164 {} /* terminator */ 177 {} /* terminator */
165}; 178};
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c
index 5b9d3a31a1ae..3c722e667bc8 100644
--- a/sound/pci/hda/patch_cmedia.c
+++ b/sound/pci/hda/patch_cmedia.c
@@ -497,6 +497,17 @@ static int cmi9880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
497 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 497 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
498} 498}
499 499
500static int cmi9880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
501 struct hda_codec *codec,
502 unsigned int stream_tag,
503 unsigned int format,
504 struct snd_pcm_substream *substream)
505{
506 struct cmi_spec *spec = codec->spec;
507 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
508 format, substream);
509}
510
500/* 511/*
501 * Analog capture 512 * Analog capture
502 */ 513 */
@@ -556,7 +567,8 @@ static struct hda_pcm_stream cmi9880_pcm_digital_playback = {
556 /* NID is set in cmi9880_build_pcms */ 567 /* NID is set in cmi9880_build_pcms */
557 .ops = { 568 .ops = {
558 .open = cmi9880_dig_playback_pcm_open, 569 .open = cmi9880_dig_playback_pcm_open,
559 .close = cmi9880_dig_playback_pcm_close 570 .close = cmi9880_dig_playback_pcm_close,
571 .prepare = cmi9880_dig_playback_pcm_prepare
560 }, 572 },
561}; 573};
562 574
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 46e93c6b9a42..a5a4b2bddf20 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -136,6 +136,18 @@ static int conexant_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
136 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 136 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
137} 137}
138 138
139static int conexant_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
140 struct hda_codec *codec,
141 unsigned int stream_tag,
142 unsigned int format,
143 struct snd_pcm_substream *substream)
144{
145 struct conexant_spec *spec = codec->spec;
146 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
147 stream_tag,
148 format, substream);
149}
150
139/* 151/*
140 * Analog capture 152 * Analog capture
141 */ 153 */
@@ -194,7 +206,8 @@ static struct hda_pcm_stream conexant_pcm_digital_playback = {
194 .nid = 0, /* fill later */ 206 .nid = 0, /* fill later */
195 .ops = { 207 .ops = {
196 .open = conexant_dig_playback_pcm_open, 208 .open = conexant_dig_playback_pcm_open,
197 .close = conexant_dig_playback_pcm_close 209 .close = conexant_dig_playback_pcm_close,
210 .prepare = conexant_dig_playback_pcm_prepare
198 }, 211 },
199}; 212};
200 213
@@ -452,115 +465,6 @@ static int conexant_ch_mode_put(struct snd_kcontrol *kcontrol,
452 .put = conexant_ch_mode_put, \ 465 .put = conexant_ch_mode_put, \
453 .private_value = nid | (dir<<16) } 466 .private_value = nid | (dir<<16) }
454 467
455static int cxt_gpio_data_info(struct snd_kcontrol *kcontrol,
456 struct snd_ctl_elem_info *uinfo)
457{
458 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
459 uinfo->count = 1;
460 uinfo->value.integer.min = 0;
461 uinfo->value.integer.max = 1;
462 return 0;
463}
464
465static int cxt_gpio_data_get(struct snd_kcontrol *kcontrol,
466 struct snd_ctl_elem_value *ucontrol)
467{
468 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
469 hda_nid_t nid = kcontrol->private_value & 0xffff;
470 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
471 long *valp = ucontrol->value.integer.value;
472 unsigned int val = snd_hda_codec_read(codec, nid, 0,
473 AC_VERB_GET_GPIO_DATA, 0x00);
474
475 *valp = (val & mask) != 0;
476 return 0;
477}
478
479static int cxt_gpio_data_put(struct snd_kcontrol *kcontrol,
480 struct snd_ctl_elem_value *ucontrol)
481{
482 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
483 hda_nid_t nid = kcontrol->private_value & 0xffff;
484 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
485 long val = *ucontrol->value.integer.value;
486 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
487 AC_VERB_GET_GPIO_DATA,
488 0x00);
489 unsigned int old_data = gpio_data;
490
491 /* Set/unset the masked GPIO bit(s) as needed */
492 if (val == 0)
493 gpio_data &= ~mask;
494 else
495 gpio_data |= mask;
496 if (gpio_data == old_data && !codec->in_resume)
497 return 0;
498 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
499 return 1;
500}
501
502#define CXT_GPIO_DATA_SWITCH(xname, nid, mask) \
503 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
504 .info = cxt_gpio_data_info, \
505 .get = cxt_gpio_data_get, \
506 .put = cxt_gpio_data_put, \
507 .private_value = nid | (mask<<16) }
508#if 0
509static int cxt_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
510 struct snd_ctl_elem_info *uinfo)
511{
512 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
513 uinfo->count = 1;
514 uinfo->value.integer.min = 0;
515 uinfo->value.integer.max = 1;
516 return 0;
517}
518
519static int cxt_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
520 struct snd_ctl_elem_value *ucontrol)
521{
522 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
523 hda_nid_t nid = kcontrol->private_value & 0xffff;
524 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
525 long *valp = ucontrol->value.integer.value;
526 unsigned int val = snd_hda_codec_read(codec, nid, 0,
527 AC_VERB_GET_DIGI_CONVERT, 0x00);
528
529 *valp = (val & mask) != 0;
530 return 0;
531}
532
533static int cxt_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
534 struct snd_ctl_elem_value *ucontrol)
535{
536 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
537 hda_nid_t nid = kcontrol->private_value & 0xffff;
538 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
539 long val = *ucontrol->value.integer.value;
540 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
541 AC_VERB_GET_DIGI_CONVERT,
542 0x00);
543 unsigned int old_data = ctrl_data;
544
545 /* Set/unset the masked control bit(s) as needed */
546 if (val == 0)
547 ctrl_data &= ~mask;
548 else
549 ctrl_data |= mask;
550 if (ctrl_data == old_data && !codec->in_resume)
551 return 0;
552 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
553 ctrl_data);
554 return 1;
555}
556
557#define CXT_SPDIF_CTRL_SWITCH(xname, nid, mask) \
558 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
559 .info = cxt_spdif_ctrl_info, \
560 .get = cxt_spdif_ctrl_get, \
561 .put = cxt_spdif_ctrl_put, \
562 .private_value = nid | (mask<<16) }
563#endif
564#endif /* CONFIG_SND_DEBUG */ 468#endif /* CONFIG_SND_DEBUG */
565 469
566/* Conexant 5045 specific */ 470/* Conexant 5045 specific */
@@ -599,6 +503,7 @@ static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
599 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : 0x80; 503 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : 0x80;
600 snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits); 504 snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits);
601 snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits); 505 snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits);
506
602 bits = spec->cur_eapd ? 0 : 0x80; 507 bits = spec->cur_eapd ? 0 : 0x80;
603 snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0, 0x80, bits); 508 snd_hda_codec_amp_update(codec, 0x11, 0, HDA_OUTPUT, 0, 0x80, bits);
604 snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0, 0x80, bits); 509 snd_hda_codec_amp_update(codec, 0x11, 1, HDA_OUTPUT, 0, 0x80, bits);
@@ -624,6 +529,29 @@ static int cxt5045_hp_master_vol_put(struct snd_kcontrol *kcontrol,
624 return change; 529 return change;
625} 530}
626 531
532/* toggle input of built-in and mic jack appropriately */
533static void cxt5045_hp_automic(struct hda_codec *codec)
534{
535 static struct hda_verb mic_jack_on[] = {
536 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
537 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
538 {}
539 };
540 static struct hda_verb mic_jack_off[] = {
541 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
542 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
543 {}
544 };
545 unsigned int present;
546
547 present = snd_hda_codec_read(codec, 0x12, 0,
548 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
549 if (present)
550 snd_hda_sequence_write(codec, mic_jack_on);
551 else
552 snd_hda_sequence_write(codec, mic_jack_off);
553}
554
627 555
628/* mute internal speaker if HP is plugged */ 556/* mute internal speaker if HP is plugged */
629static void cxt5045_hp_automute(struct hda_codec *codec) 557static void cxt5045_hp_automute(struct hda_codec *codec)
@@ -634,7 +562,7 @@ static void cxt5045_hp_automute(struct hda_codec *codec)
634 spec->hp_present = snd_hda_codec_read(codec, 0x11, 0, 562 spec->hp_present = snd_hda_codec_read(codec, 0x11, 0,
635 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 563 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
636 564
637 bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0; 565 bits = (spec->hp_present || !spec->cur_eapd) ? 0x80 : 0;
638 snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits); 566 snd_hda_codec_amp_update(codec, 0x10, 0, HDA_OUTPUT, 0, 0x80, bits);
639 snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits); 567 snd_hda_codec_amp_update(codec, 0x10, 1, HDA_OUTPUT, 0, 0x80, bits);
640} 568}
@@ -648,6 +576,10 @@ static void cxt5045_hp_unsol_event(struct hda_codec *codec,
648 case CONEXANT_HP_EVENT: 576 case CONEXANT_HP_EVENT:
649 cxt5045_hp_automute(codec); 577 cxt5045_hp_automute(codec);
650 break; 578 break;
579 case CONEXANT_MIC_EVENT:
580 cxt5045_hp_automic(codec);
581 break;
582
651 } 583 }
652} 584}
653 585
@@ -659,12 +591,10 @@ static struct snd_kcontrol_new cxt5045_mixers[] = {
659 .get = conexant_mux_enum_get, 591 .get = conexant_mux_enum_get,
660 .put = conexant_mux_enum_put 592 .put = conexant_mux_enum_put
661 }, 593 },
662 HDA_CODEC_VOLUME("Int Mic Volume", 0x17, 0x01, HDA_INPUT), 594 HDA_CODEC_VOLUME("Int Mic Volume", 0x1a, 0x01, HDA_INPUT),
663 HDA_CODEC_MUTE("Int Mic Switch", 0x17, 0x01, HDA_INPUT), 595 HDA_CODEC_MUTE("Int Mic Switch", 0x1a, 0x01, HDA_INPUT),
664 HDA_CODEC_VOLUME("Ext Mic Volume", 0x17, 0x02, HDA_INPUT), 596 HDA_CODEC_VOLUME("Ext Mic Volume", 0x1a, 0x02, HDA_INPUT),
665 HDA_CODEC_MUTE("Ext Mic Switch", 0x17, 0x02, HDA_INPUT), 597 HDA_CODEC_MUTE("Ext Mic Switch", 0x1a, 0x02, HDA_INPUT),
666 HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x0, HDA_INPUT),
667 HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT),
668 { 598 {
669 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 599 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
670 .name = "Master Playback Volume", 600 .name = "Master Playback Volume",
@@ -688,7 +618,7 @@ static struct snd_kcontrol_new cxt5045_mixers[] = {
688static struct hda_verb cxt5045_init_verbs[] = { 618static struct hda_verb cxt5045_init_verbs[] = {
689 /* Line in, Mic */ 619 /* Line in, Mic */
690 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 620 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
691 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
692 /* HP, Amp */ 622 /* HP, Amp */
693 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 623 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
694 {0x17, AC_VERB_SET_CONNECT_SEL,0x01}, 624 {0x17, AC_VERB_SET_CONNECT_SEL,0x01},
@@ -701,18 +631,29 @@ static struct hda_verb cxt5045_init_verbs[] = {
701 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 631 {0x17, AC_VERB_SET_AMP_GAIN_MUTE,
702 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x04}, 632 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x04},
703 /* Record selector: Int mic */ 633 /* Record selector: Int mic */
704 {0x1a, AC_VERB_SET_CONNECT_SEL,0x0}, 634 {0x1a, AC_VERB_SET_CONNECT_SEL,0x1},
705 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 635 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE,
706 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 636 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
707 /* SPDIF route: PCM */ 637 /* SPDIF route: PCM */
708 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 }, 638 { 0x13, AC_VERB_SET_CONNECT_SEL, 0x0 },
709 /* pin sensing on HP and Mic jacks */
710 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
711 /* EAPD */ 639 /* EAPD */
712 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */ 640 {0x10, AC_VERB_SET_EAPD_BTLENABLE, 0x2 }, /* default on */
713 { } /* end */ 641 { } /* end */
714}; 642};
715 643
644
645static struct hda_verb cxt5045_hp_sense_init_verbs[] = {
646 /* pin sensing on HP jack */
647 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
648 { } /* end */
649};
650
651static struct hda_verb cxt5045_mic_sense_init_verbs[] = {
652 /* pin sensing on HP jack */
653 {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
654 { } /* end */
655};
656
716#ifdef CONFIG_SND_DEBUG 657#ifdef CONFIG_SND_DEBUG
717/* Test configuration for debugging, modelled after the ALC260 test 658/* Test configuration for debugging, modelled after the ALC260 test
718 * configuration. 659 * configuration.
@@ -733,6 +674,10 @@ static struct snd_kcontrol_new cxt5045_test_mixer[] = {
733 /* Output controls */ 674 /* Output controls */
734 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT), 675 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x10, 0x0, HDA_OUTPUT),
735 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT), 676 HDA_CODEC_MUTE("Speaker Playback Switch", 0x10, 0x0, HDA_OUTPUT),
677 HDA_CODEC_VOLUME("Node 11 Playback Volume", 0x11, 0x0, HDA_OUTPUT),
678 HDA_CODEC_MUTE("Node 11 Playback Switch", 0x11, 0x0, HDA_OUTPUT),
679 HDA_CODEC_VOLUME("Node 12 Playback Volume", 0x12, 0x0, HDA_OUTPUT),
680 HDA_CODEC_MUTE("Node 12 Playback Switch", 0x12, 0x0, HDA_OUTPUT),
736 681
737 /* Modes for retasking pin widgets */ 682 /* Modes for retasking pin widgets */
738 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT), 683 CXT_PIN_MODE("HP-OUT pin mode", 0x11, CXT_PIN_DIR_INOUT),
@@ -742,25 +687,17 @@ static struct snd_kcontrol_new cxt5045_test_mixer[] = {
742 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0), 687 CXT_EAPD_SWITCH("External Amplifier", 0x10, 0x0),
743 688
744 /* Loopback mixer controls */ 689 /* Loopback mixer controls */
745 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x17, 0x01, HDA_INPUT), 690
746 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x17, 0x01, HDA_INPUT), 691 HDA_CODEC_VOLUME("Mixer-1 Volume", 0x17, 0x0, HDA_INPUT),
747 HDA_CODEC_VOLUME("LINE loopback Playback Volume", 0x17, 0x02, HDA_INPUT), 692 HDA_CODEC_MUTE("Mixer-1 Switch", 0x17, 0x0, HDA_INPUT),
748 HDA_CODEC_MUTE("LINE loopback Playback Switch", 0x17, 0x02, HDA_INPUT), 693 HDA_CODEC_VOLUME("Mixer-2 Volume", 0x17, 0x1, HDA_INPUT),
749 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x17, 0x03, HDA_INPUT), 694 HDA_CODEC_MUTE("Mixer-2 Switch", 0x17, 0x1, HDA_INPUT),
750 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x17, 0x03, HDA_INPUT), 695 HDA_CODEC_VOLUME("Mixer-3 Volume", 0x17, 0x2, HDA_INPUT),
751 HDA_CODEC_VOLUME("CD Playback Volume", 0x17, 0x04, HDA_INPUT), 696 HDA_CODEC_MUTE("Mixer-3 Switch", 0x17, 0x2, HDA_INPUT),
752 HDA_CODEC_MUTE("CD Playback Switch", 0x17, 0x04, HDA_INPUT), 697 HDA_CODEC_VOLUME("Mixer-4 Volume", 0x17, 0x3, HDA_INPUT),
753 698 HDA_CODEC_MUTE("Mixer-4 Switch", 0x17, 0x3, HDA_INPUT),
754 HDA_CODEC_VOLUME("Capture-1 Volume", 0x17, 0x0, HDA_INPUT), 699 HDA_CODEC_VOLUME("Mixer-5 Volume", 0x17, 0x4, HDA_INPUT),
755 HDA_CODEC_MUTE("Capture-1 Switch", 0x17, 0x0, HDA_INPUT), 700 HDA_CODEC_MUTE("Mixer-5 Switch", 0x17, 0x4, HDA_INPUT),
756 HDA_CODEC_VOLUME("Capture-2 Volume", 0x17, 0x1, HDA_INPUT),
757 HDA_CODEC_MUTE("Capture-2 Switch", 0x17, 0x1, HDA_INPUT),
758 HDA_CODEC_VOLUME("Capture-3 Volume", 0x17, 0x2, HDA_INPUT),
759 HDA_CODEC_MUTE("Capture-3 Switch", 0x17, 0x2, HDA_INPUT),
760 HDA_CODEC_VOLUME("Capture-4 Volume", 0x17, 0x3, HDA_INPUT),
761 HDA_CODEC_MUTE("Capture-4 Switch", 0x17, 0x3, HDA_INPUT),
762 HDA_CODEC_VOLUME("Capture-5 Volume", 0x17, 0x4, HDA_INPUT),
763 HDA_CODEC_MUTE("Capture-5 Switch", 0x17, 0x4, HDA_INPUT),
764 { 701 {
765 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
766 .name = "Input Source", 703 .name = "Input Source",
@@ -768,14 +705,17 @@ static struct snd_kcontrol_new cxt5045_test_mixer[] = {
768 .get = conexant_mux_enum_get, 705 .get = conexant_mux_enum_get,
769 .put = conexant_mux_enum_put, 706 .put = conexant_mux_enum_put,
770 }, 707 },
771
772 { } /* end */ 708 { } /* end */
773}; 709};
774 710
775static struct hda_verb cxt5045_test_init_verbs[] = { 711static struct hda_verb cxt5045_test_init_verbs[] = {
712 /* Set connections */
713 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
714 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x0 },
715 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x0 },
776 /* Enable retasking pins as output, initially without power amp */ 716 /* Enable retasking pins as output, initially without power amp */
777 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 717 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
778 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 718 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
779 719
780 /* Disable digital (SPDIF) pins initially, but users can enable 720 /* Disable digital (SPDIF) pins initially, but users can enable
781 * them via a mixer switch. In the case of SPDIF-out, this initverb 721 * them via a mixer switch. In the case of SPDIF-out, this initverb
@@ -804,6 +744,7 @@ static struct hda_verb cxt5045_test_init_verbs[] = {
804 * pin) 744 * pin)
805 */ 745 */
806 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00}, 746 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
747 {0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
807 748
808 /* Mute all inputs to mixer widget (even unconnected ones) */ 749 /* Mute all inputs to mixer widget (even unconnected ones) */
809 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */ 750 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* Mixer pin */
@@ -827,7 +768,8 @@ static int cxt5045_init(struct hda_codec *codec)
827 768
828 769
829enum { 770enum {
830 CXT5045_LAPTOP, /* Laptops w/ EAPD support */ 771 CXT5045_LAPTOP, /* Laptops w/ EAPD support */
772 CXT5045_FUJITSU, /* Laptops w/ EAPD support */
831#ifdef CONFIG_SND_DEBUG 773#ifdef CONFIG_SND_DEBUG
832 CXT5045_TEST, 774 CXT5045_TEST,
833#endif 775#endif
@@ -836,6 +778,7 @@ enum {
836 778
837static const char *cxt5045_models[CXT5045_MODELS] = { 779static const char *cxt5045_models[CXT5045_MODELS] = {
838 [CXT5045_LAPTOP] = "laptop", 780 [CXT5045_LAPTOP] = "laptop",
781 [CXT5045_FUJITSU] = "fujitsu",
839#ifdef CONFIG_SND_DEBUG 782#ifdef CONFIG_SND_DEBUG
840 [CXT5045_TEST] = "test", 783 [CXT5045_TEST] = "test",
841#endif 784#endif
@@ -844,7 +787,11 @@ static const char *cxt5045_models[CXT5045_MODELS] = {
844static struct snd_pci_quirk cxt5045_cfg_tbl[] = { 787static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
845 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP), 788 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP),
846 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP), 789 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP),
847 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP), 790 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP),
791 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP),
792 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP),
793 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_FUJITSU),
794 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP),
848 {} 795 {}
849}; 796};
850 797
@@ -877,16 +824,23 @@ static int patch_cxt5045(struct hda_codec *codec)
877 824
878 825
879 codec->patch_ops = conexant_patch_ops; 826 codec->patch_ops = conexant_patch_ops;
880 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
881 827
882 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS, 828 board_config = snd_hda_check_board_config(codec, CXT5045_MODELS,
883 cxt5045_models, 829 cxt5045_models,
884 cxt5045_cfg_tbl); 830 cxt5045_cfg_tbl);
885 switch (board_config) { 831 switch (board_config) {
886 case CXT5045_LAPTOP: 832 case CXT5045_LAPTOP:
833 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
834 spec->input_mux = &cxt5045_capture_source;
835 spec->num_init_verbs = 2;
836 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
837 spec->mixers[0] = cxt5045_mixers;
838 codec->patch_ops.init = cxt5045_init;
839 break;
840 case CXT5045_FUJITSU:
887 spec->input_mux = &cxt5045_capture_source; 841 spec->input_mux = &cxt5045_capture_source;
888 spec->num_init_verbs = 2; 842 spec->num_init_verbs = 2;
889 spec->init_verbs[1] = cxt5045_init_verbs; 843 spec->init_verbs[1] = cxt5045_mic_sense_init_verbs;
890 spec->mixers[0] = cxt5045_mixers; 844 spec->mixers[0] = cxt5045_mixers;
891 codec->patch_ops.init = cxt5045_init; 845 codec->patch_ops.init = cxt5045_init;
892 break; 846 break;
@@ -913,10 +867,9 @@ static struct hda_channel_mode cxt5047_modes[1] = {
913}; 867};
914 868
915static struct hda_input_mux cxt5047_capture_source = { 869static struct hda_input_mux cxt5047_capture_source = {
916 .num_items = 2, 870 .num_items = 1,
917 .items = { 871 .items = {
918 { "ExtMic", 0x0 }, 872 { "Mic", 0x2 },
919 { "IntMic", 0x1 },
920 } 873 }
921}; 874};
922 875
@@ -1009,7 +962,7 @@ static void cxt5047_hp_automic(struct hda_codec *codec)
1009 }; 962 };
1010 unsigned int present; 963 unsigned int present;
1011 964
1012 present = snd_hda_codec_read(codec, 0x08, 0, 965 present = snd_hda_codec_read(codec, 0x15, 0,
1013 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 966 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1014 if (present) 967 if (present)
1015 snd_hda_sequence_write(codec, mic_jack_on); 968 snd_hda_sequence_write(codec, mic_jack_on);
@@ -1033,37 +986,20 @@ static void cxt5047_hp_unsol_event(struct hda_codec *codec,
1033} 986}
1034 987
1035static struct snd_kcontrol_new cxt5047_mixers[] = { 988static struct snd_kcontrol_new cxt5047_mixers[] = {
1036 {
1037 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1038 .name = "Capture Source",
1039 .info = conexant_mux_enum_info,
1040 .get = conexant_mux_enum_get,
1041 .put = conexant_mux_enum_put
1042 },
1043 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT), 989 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1044 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT), 990 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
991 HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT),
992 HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT),
1045 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), 993 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1046 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), 994 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1047 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), 995 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1048 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), 996 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1049 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT), 997 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
1050 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT), 998 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
1051 { 999 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT),
1052 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1000 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x00, HDA_OUTPUT),
1053 .name = "Master Playback Volume", 1001 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1054 .info = snd_hda_mixer_amp_volume_info, 1002 HDA_CODEC_MUTE("Headphone Playback Switch", 0x13, 0x00, HDA_OUTPUT),
1055 .get = snd_hda_mixer_amp_volume_get,
1056 .put = cxt5047_hp_master_vol_put,
1057 .private_value = HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
1058 },
1059 {
1060 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1061 .name = "Master Playback Switch",
1062 .info = cxt_eapd_info,
1063 .get = cxt_eapd_get,
1064 .put = cxt5047_hp_master_sw_put,
1065 .private_value = 0x13,
1066 },
1067 1003
1068 {} 1004 {}
1069}; 1005};
@@ -1133,18 +1069,19 @@ static struct hda_verb cxt5047_init_verbs[] = {
1133 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 1069 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1134 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 1070 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1135 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 1071 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1136 /* HP, Amp, Speaker */ 1072 /* HP, Speaker */
1137 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 1073 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1138 {0x1A, AC_VERB_SET_CONNECT_SEL,0x00}, 1074 {0x13, AC_VERB_SET_CONNECT_SEL,0x1},
1139 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1140 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1141 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1142 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1143 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0}, 1075 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0},
1144 /* Record selector: Front mic */ 1076 /* Record selector: Mic */
1145 {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, 1077 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1146 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 1078 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1147 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 1079 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1080 {0x1A, AC_VERB_SET_CONNECT_SEL,0x02},
1081 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1082 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x00},
1083 {0x1A, AC_VERB_SET_AMP_GAIN_MUTE,
1084 AC_AMP_SET_OUTPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x03},
1148 /* SPDIF route: PCM */ 1085 /* SPDIF route: PCM */
1149 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 }, 1086 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x0 },
1150 /* Enable unsolicited events */ 1087 /* Enable unsolicited events */
@@ -1161,8 +1098,6 @@ static struct hda_verb cxt5047_toshiba_init_verbs[] = {
1161 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, 1098 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1162 /* Speaker routing */ 1099 /* Speaker routing */
1163 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1}, 1100 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1164 /* Change default to ExtMic for recording */
1165 {0x1a, AC_VERB_SET_CONNECT_SEL,0x2},
1166 {} 1101 {}
1167}; 1102};
1168 1103
@@ -1172,7 +1107,6 @@ static struct hda_verb cxt5047_hp_init_verbs[] = {
1172 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, 1107 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1173 /* Record selector: Ext Mic */ 1108 /* Record selector: Ext Mic */
1174 {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, 1109 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1175 {0x1a, AC_VERB_SET_CONNECT_SEL,0x02},
1176 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 1110 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1177 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17}, 1111 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1178 /* Speaker routing */ 1112 /* Speaker routing */
@@ -1242,14 +1176,6 @@ static struct snd_kcontrol_new cxt5047_test_mixer[] = {
1242 .get = conexant_mux_enum_get, 1176 .get = conexant_mux_enum_get,
1243 .put = conexant_mux_enum_put, 1177 .put = conexant_mux_enum_put,
1244 }, 1178 },
1245 /* Controls for GPIO pins, assuming they exist and are configured
1246 * as outputs
1247 */
1248 CXT_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
1249 CXT_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
1250 CXT_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
1251 CXT_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
1252
1253 { } /* end */ 1179 { } /* end */
1254}; 1180};
1255 1181
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index fba3cb11bc2a..a4ede27af021 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -74,6 +74,8 @@ enum {
74 ALC260_HP_3013, 74 ALC260_HP_3013,
75 ALC260_FUJITSU_S702X, 75 ALC260_FUJITSU_S702X,
76 ALC260_ACER, 76 ALC260_ACER,
77 ALC260_WILL,
78 ALC260_REPLACER_672V,
77#ifdef CONFIG_SND_DEBUG 79#ifdef CONFIG_SND_DEBUG
78 ALC260_TEST, 80 ALC260_TEST,
79#endif 81#endif
@@ -115,15 +117,28 @@ enum {
115 ALC861VD_3ST, 117 ALC861VD_3ST,
116 ALC861VD_3ST_DIG, 118 ALC861VD_3ST_DIG,
117 ALC861VD_6ST_DIG, 119 ALC861VD_6ST_DIG,
120 ALC861VD_LENOVO,
118 ALC861VD_AUTO, 121 ALC861VD_AUTO,
119 ALC861VD_MODEL_LAST, 122 ALC861VD_MODEL_LAST,
120}; 123};
121 124
125/* ALC662 models */
126enum {
127 ALC662_3ST_2ch_DIG,
128 ALC662_3ST_6ch_DIG,
129 ALC662_3ST_6ch,
130 ALC662_5ST_DIG,
131 ALC662_LENOVO_101E,
132 ALC662_AUTO,
133 ALC662_MODEL_LAST,
134};
135
122/* ALC882 models */ 136/* ALC882 models */
123enum { 137enum {
124 ALC882_3ST_DIG, 138 ALC882_3ST_DIG,
125 ALC882_6ST_DIG, 139 ALC882_6ST_DIG,
126 ALC882_ARIMA, 140 ALC882_ARIMA,
141 ALC882_W2JC,
127 ALC882_AUTO, 142 ALC882_AUTO,
128 ALC885_MACPRO, 143 ALC885_MACPRO,
129 ALC882_MODEL_LAST, 144 ALC882_MODEL_LAST,
@@ -141,6 +156,7 @@ enum {
141 ALC883_ACER, 156 ALC883_ACER,
142 ALC883_MEDION, 157 ALC883_MEDION,
143 ALC883_LAPTOP_EAPD, 158 ALC883_LAPTOP_EAPD,
159 ALC883_LENOVO_101E_2ch,
144 ALC883_AUTO, 160 ALC883_AUTO,
145 ALC883_MODEL_LAST, 161 ALC883_MODEL_LAST,
146}; 162};
@@ -163,7 +179,7 @@ struct alc_spec {
163 struct hda_pcm_stream *stream_analog_playback; 179 struct hda_pcm_stream *stream_analog_playback;
164 struct hda_pcm_stream *stream_analog_capture; 180 struct hda_pcm_stream *stream_analog_capture;
165 181
166 char *stream_name_digital; /* digital PCM stream */ 182 char *stream_name_digital; /* digital PCM stream */
167 struct hda_pcm_stream *stream_digital_playback; 183 struct hda_pcm_stream *stream_digital_playback;
168 struct hda_pcm_stream *stream_digital_capture; 184 struct hda_pcm_stream *stream_digital_capture;
169 185
@@ -401,7 +417,7 @@ static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
401 AC_VERB_GET_PIN_WIDGET_CONTROL, 417 AC_VERB_GET_PIN_WIDGET_CONTROL,
402 0x00); 418 0x00);
403 419
404 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir)) 420 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
405 val = alc_pin_mode_min(dir); 421 val = alc_pin_mode_min(dir);
406 422
407 change = pinctl != alc_pin_mode_values[val]; 423 change = pinctl != alc_pin_mode_values[val];
@@ -460,7 +476,8 @@ static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
460 uinfo->value.integer.min = 0; 476 uinfo->value.integer.min = 0;
461 uinfo->value.integer.max = 1; 477 uinfo->value.integer.max = 1;
462 return 0; 478 return 0;
463} 479}
480
464static int alc_gpio_data_get(struct snd_kcontrol *kcontrol, 481static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_value *ucontrol) 482 struct snd_ctl_elem_value *ucontrol)
466{ 483{
@@ -520,7 +537,8 @@ static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
520 uinfo->value.integer.min = 0; 537 uinfo->value.integer.min = 0;
521 uinfo->value.integer.max = 1; 538 uinfo->value.integer.max = 1;
522 return 0; 539 return 0;
523} 540}
541
524static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol, 542static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
525 struct snd_ctl_elem_value *ucontrol) 543 struct snd_ctl_elem_value *ucontrol)
526{ 544{
@@ -592,7 +610,7 @@ static void setup_preset(struct alc_spec *spec,
592 spec->multiout.hp_nid = preset->hp_nid; 610 spec->multiout.hp_nid = preset->hp_nid;
593 611
594 spec->num_mux_defs = preset->num_mux_defs; 612 spec->num_mux_defs = preset->num_mux_defs;
595 if (! spec->num_mux_defs) 613 if (!spec->num_mux_defs)
596 spec->num_mux_defs = 1; 614 spec->num_mux_defs = 1;
597 spec->input_mux = preset->input_mux; 615 spec->input_mux = preset->input_mux;
598 616
@@ -604,6 +622,90 @@ static void setup_preset(struct alc_spec *spec,
604 spec->init_hook = preset->init_hook; 622 spec->init_hook = preset->init_hook;
605} 623}
606 624
625/* Enable GPIO mask and set output */
626static struct hda_verb alc_gpio1_init_verbs[] = {
627 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
628 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
629 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
630 { }
631};
632
633static struct hda_verb alc_gpio2_init_verbs[] = {
634 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
635 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
636 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
637 { }
638};
639
640static struct hda_verb alc_gpio3_init_verbs[] = {
641 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
642 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
643 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
644 { }
645};
646
647/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
648 * 31 ~ 16 : Manufacture ID
649 * 15 ~ 8 : SKU ID
650 * 7 ~ 0 : Assembly ID
651 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
652 */
653static void alc_subsystem_id(struct hda_codec *codec,
654 unsigned int porta, unsigned int porte,
655 unsigned int portd)
656{
657 unsigned int ass, tmp;
658
659 ass = codec->subsystem_id;
660 if (!(ass & 1))
661 return;
662
663 /* Override */
664 tmp = (ass & 0x38) >> 3; /* external Amp control */
665 switch (tmp) {
666 case 1:
667 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
668 break;
669 case 3:
670 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
671 break;
672 case 7:
673 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
674 break;
675 case 5:
676 switch (codec->vendor_id) {
677 case 0x10ec0862:
678 case 0x10ec0660:
679 case 0x10ec0662:
680 case 0x10ec0267:
681 case 0x10ec0268:
682 snd_hda_codec_write(codec, 0x14, 0,
683 AC_VERB_SET_EAPD_BTLENABLE, 2);
684 snd_hda_codec_write(codec, 0x15, 0,
685 AC_VERB_SET_EAPD_BTLENABLE, 2);
686 return;
687 }
688 case 6:
689 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
690 hda_nid_t port = 0;
691 tmp = (ass & 0x1800) >> 11;
692 switch (tmp) {
693 case 0: port = porta; break;
694 case 1: port = porte; break;
695 case 2: port = portd; break;
696 }
697 if (port)
698 snd_hda_codec_write(codec, port, 0,
699 AC_VERB_SET_EAPD_BTLENABLE,
700 2);
701 }
702 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
703 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
704 (tmp == 5 ? 0x3040 : 0x3050));
705 break;
706 }
707}
708
607/* 709/*
608 * ALC880 3-stack model 710 * ALC880 3-stack model
609 * 711 *
@@ -801,7 +903,7 @@ static struct hda_channel_mode alc880_fivestack_modes[2] = {
801static hda_nid_t alc880_6st_dac_nids[4] = { 903static hda_nid_t alc880_6st_dac_nids[4] = {
802 /* front, rear, clfe, rear_surr */ 904 /* front, rear, clfe, rear_surr */
803 0x02, 0x03, 0x04, 0x05 905 0x02, 0x03, 0x04, 0x05
804}; 906};
805 907
806static struct hda_input_mux alc880_6stack_capture_source = { 908static struct hda_input_mux alc880_6stack_capture_source = {
807 .num_items = 4, 909 .num_items = 4,
@@ -1409,25 +1511,43 @@ static struct hda_verb alc880_beep_init_verbs[] = {
1409}; 1511};
1410 1512
1411/* toggle speaker-output according to the hp-jack state */ 1513/* toggle speaker-output according to the hp-jack state */
1412static void alc880_uniwill_automute(struct hda_codec *codec) 1514static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1413{ 1515{
1414 unsigned int present; 1516 unsigned int present;
1517 unsigned char bits;
1415 1518
1416 present = snd_hda_codec_read(codec, 0x14, 0, 1519 present = snd_hda_codec_read(codec, 0x14, 0,
1417 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1520 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1521 bits = present ? 0x80 : 0;
1418 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0, 1522 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
1419 0x80, present ? 0x80 : 0); 1523 0x80, bits);
1420 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0, 1524 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
1421 0x80, present ? 0x80 : 0); 1525 0x80, bits);
1422 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0, 1526 snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
1423 0x80, present ? 0x80 : 0); 1527 0x80, bits);
1424 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0, 1528 snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
1425 0x80, present ? 0x80 : 0); 1529 0x80, bits);
1530}
1531
1532/* auto-toggle front mic */
1533static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1534{
1535 unsigned int present;
1536 unsigned char bits;
1426 1537
1427 present = snd_hda_codec_read(codec, 0x18, 0, 1538 present = snd_hda_codec_read(codec, 0x18, 0,
1428 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1539 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1429 snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1540 bits = present ? 0x80 : 0;
1430 0x7000 | (0x01 << 8) | (present ? 0x80 : 0)); 1541 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
1542 0x80, bits);
1543 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
1544 0x80, bits);
1545}
1546
1547static void alc880_uniwill_automute(struct hda_codec *codec)
1548{
1549 alc880_uniwill_hp_automute(codec);
1550 alc880_uniwill_mic_automute(codec);
1431} 1551}
1432 1552
1433static void alc880_uniwill_unsol_event(struct hda_codec *codec, 1553static void alc880_uniwill_unsol_event(struct hda_codec *codec,
@@ -1436,22 +1556,28 @@ static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1436 /* Looks like the unsol event is incompatible with the standard 1556 /* Looks like the unsol event is incompatible with the standard
1437 * definition. 4bit tag is placed at 28 bit! 1557 * definition. 4bit tag is placed at 28 bit!
1438 */ 1558 */
1439 if ((res >> 28) == ALC880_HP_EVENT || 1559 switch (res >> 28) {
1440 (res >> 28) == ALC880_MIC_EVENT) 1560 case ALC880_HP_EVENT:
1441 alc880_uniwill_automute(codec); 1561 alc880_uniwill_hp_automute(codec);
1562 break;
1563 case ALC880_MIC_EVENT:
1564 alc880_uniwill_mic_automute(codec);
1565 break;
1566 }
1442} 1567}
1443 1568
1444static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec) 1569static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1445{ 1570{
1446 unsigned int present; 1571 unsigned int present;
1572 unsigned char bits;
1447 1573
1448 present = snd_hda_codec_read(codec, 0x14, 0, 1574 present = snd_hda_codec_read(codec, 0x14, 0,
1449 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1575 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1450 1576 bits = present ? 0x80 : 0;
1451 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0, 1577 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
1452 0x80, present ? 0x80 : 0); 1578 0x80, bits);
1453 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0, 1579 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
1454 0x80, present ? 0x80 : 0); 1580 0x80, bits);
1455} 1581}
1456 1582
1457static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec) 1583static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
@@ -1480,7 +1606,7 @@ static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1480 */ 1606 */
1481 if ((res >> 28) == ALC880_HP_EVENT) 1607 if ((res >> 28) == ALC880_HP_EVENT)
1482 alc880_uniwill_p53_hp_automute(codec); 1608 alc880_uniwill_p53_hp_automute(codec);
1483 if ((res >> 28) == ALC880_DCVOL_EVENT) 1609 if ((res >> 28) == ALC880_DCVOL_EVENT)
1484 alc880_uniwill_p53_dcvol_automute(codec); 1610 alc880_uniwill_p53_dcvol_automute(codec);
1485} 1611}
1486 1612
@@ -1547,22 +1673,8 @@ static struct hda_verb alc880_pin_asus_init_verbs[] = {
1547}; 1673};
1548 1674
1549/* Enable GPIO mask and set output */ 1675/* Enable GPIO mask and set output */
1550static struct hda_verb alc880_gpio1_init_verbs[] = { 1676#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1551 {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, 1677#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
1552 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
1553 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
1554
1555 { }
1556};
1557
1558/* Enable GPIO mask and set output */
1559static struct hda_verb alc880_gpio2_init_verbs[] = {
1560 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
1561 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
1562 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
1563
1564 { }
1565};
1566 1678
1567/* Clevo m520g init */ 1679/* Clevo m520g init */
1568static struct hda_verb alc880_pin_clevo_init_verbs[] = { 1680static struct hda_verb alc880_pin_clevo_init_verbs[] = {
@@ -1734,13 +1846,15 @@ static struct hda_verb alc880_lg_init_verbs[] = {
1734static void alc880_lg_automute(struct hda_codec *codec) 1846static void alc880_lg_automute(struct hda_codec *codec)
1735{ 1847{
1736 unsigned int present; 1848 unsigned int present;
1849 unsigned char bits;
1737 1850
1738 present = snd_hda_codec_read(codec, 0x1b, 0, 1851 present = snd_hda_codec_read(codec, 0x1b, 0,
1739 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1852 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1853 bits = present ? 0x80 : 0;
1740 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0, 1854 snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
1741 0x80, present ? 0x80 : 0); 1855 0x80, bits);
1742 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0, 1856 snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
1743 0x80, present ? 0x80 : 0); 1857 0x80, bits);
1744} 1858}
1745 1859
1746static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res) 1860static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -1810,13 +1924,15 @@ static struct hda_verb alc880_lg_lw_init_verbs[] = {
1810static void alc880_lg_lw_automute(struct hda_codec *codec) 1924static void alc880_lg_lw_automute(struct hda_codec *codec)
1811{ 1925{
1812 unsigned int present; 1926 unsigned int present;
1927 unsigned char bits;
1813 1928
1814 present = snd_hda_codec_read(codec, 0x1b, 0, 1929 present = snd_hda_codec_read(codec, 0x1b, 0,
1815 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1930 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1931 bits = present ? 0x80 : 0;
1816 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0, 1932 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
1817 0x80, present ? 0x80 : 0); 1933 0x80, bits);
1818 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0, 1934 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
1819 0x80, present ? 0x80 : 0); 1935 0x80, bits);
1820} 1936}
1821 1937
1822static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res) 1938static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -1916,6 +2032,17 @@ static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1916 return snd_hda_multi_out_dig_open(codec, &spec->multiout); 2032 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1917} 2033}
1918 2034
2035static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2036 struct hda_codec *codec,
2037 unsigned int stream_tag,
2038 unsigned int format,
2039 struct snd_pcm_substream *substream)
2040{
2041 struct alc_spec *spec = codec->spec;
2042 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2043 stream_tag, format, substream);
2044}
2045
1919static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 2046static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1920 struct hda_codec *codec, 2047 struct hda_codec *codec,
1921 struct snd_pcm_substream *substream) 2048 struct snd_pcm_substream *substream)
@@ -1984,7 +2111,8 @@ static struct hda_pcm_stream alc880_pcm_digital_playback = {
1984 /* NID is set in alc_build_pcms */ 2111 /* NID is set in alc_build_pcms */
1985 .ops = { 2112 .ops = {
1986 .open = alc880_dig_playback_pcm_open, 2113 .open = alc880_dig_playback_pcm_open,
1987 .close = alc880_dig_playback_pcm_close 2114 .close = alc880_dig_playback_pcm_close,
2115 .prepare = alc880_dig_playback_pcm_prepare
1988 }, 2116 },
1989}; 2117};
1990 2118
@@ -2075,7 +2203,7 @@ static void alc_free(struct hda_codec *codec)
2075 struct alc_spec *spec = codec->spec; 2203 struct alc_spec *spec = codec->spec;
2076 unsigned int i; 2204 unsigned int i;
2077 2205
2078 if (! spec) 2206 if (!spec)
2079 return; 2207 return;
2080 2208
2081 if (spec->kctl_alloc) { 2209 if (spec->kctl_alloc) {
@@ -2477,7 +2605,8 @@ static struct snd_pci_quirk alc880_cfg_tbl[] = {
2477static struct alc_config_preset alc880_presets[] = { 2605static struct alc_config_preset alc880_presets[] = {
2478 [ALC880_3ST] = { 2606 [ALC880_3ST] = {
2479 .mixers = { alc880_three_stack_mixer }, 2607 .mixers = { alc880_three_stack_mixer },
2480 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, 2608 .init_verbs = { alc880_volume_init_verbs,
2609 alc880_pin_3stack_init_verbs },
2481 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2610 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2482 .dac_nids = alc880_dac_nids, 2611 .dac_nids = alc880_dac_nids,
2483 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 2612 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
@@ -2487,7 +2616,8 @@ static struct alc_config_preset alc880_presets[] = {
2487 }, 2616 },
2488 [ALC880_3ST_DIG] = { 2617 [ALC880_3ST_DIG] = {
2489 .mixers = { alc880_three_stack_mixer }, 2618 .mixers = { alc880_three_stack_mixer },
2490 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, 2619 .init_verbs = { alc880_volume_init_verbs,
2620 alc880_pin_3stack_init_verbs },
2491 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2621 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2492 .dac_nids = alc880_dac_nids, 2622 .dac_nids = alc880_dac_nids,
2493 .dig_out_nid = ALC880_DIGOUT_NID, 2623 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2509,8 +2639,10 @@ static struct alc_config_preset alc880_presets[] = {
2509 .input_mux = &alc880_capture_source, 2639 .input_mux = &alc880_capture_source,
2510 }, 2640 },
2511 [ALC880_5ST] = { 2641 [ALC880_5ST] = {
2512 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer}, 2642 .mixers = { alc880_three_stack_mixer,
2513 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, 2643 alc880_five_stack_mixer},
2644 .init_verbs = { alc880_volume_init_verbs,
2645 alc880_pin_5stack_init_verbs },
2514 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2646 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2515 .dac_nids = alc880_dac_nids, 2647 .dac_nids = alc880_dac_nids,
2516 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), 2648 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
@@ -2518,8 +2650,10 @@ static struct alc_config_preset alc880_presets[] = {
2518 .input_mux = &alc880_capture_source, 2650 .input_mux = &alc880_capture_source,
2519 }, 2651 },
2520 [ALC880_5ST_DIG] = { 2652 [ALC880_5ST_DIG] = {
2521 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer }, 2653 .mixers = { alc880_three_stack_mixer,
2522 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, 2654 alc880_five_stack_mixer },
2655 .init_verbs = { alc880_volume_init_verbs,
2656 alc880_pin_5stack_init_verbs },
2523 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 2657 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2524 .dac_nids = alc880_dac_nids, 2658 .dac_nids = alc880_dac_nids,
2525 .dig_out_nid = ALC880_DIGOUT_NID, 2659 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2529,7 +2663,8 @@ static struct alc_config_preset alc880_presets[] = {
2529 }, 2663 },
2530 [ALC880_6ST] = { 2664 [ALC880_6ST] = {
2531 .mixers = { alc880_six_stack_mixer }, 2665 .mixers = { alc880_six_stack_mixer },
2532 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, 2666 .init_verbs = { alc880_volume_init_verbs,
2667 alc880_pin_6stack_init_verbs },
2533 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), 2668 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2534 .dac_nids = alc880_6st_dac_nids, 2669 .dac_nids = alc880_6st_dac_nids,
2535 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), 2670 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
@@ -2538,7 +2673,8 @@ static struct alc_config_preset alc880_presets[] = {
2538 }, 2673 },
2539 [ALC880_6ST_DIG] = { 2674 [ALC880_6ST_DIG] = {
2540 .mixers = { alc880_six_stack_mixer }, 2675 .mixers = { alc880_six_stack_mixer },
2541 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, 2676 .init_verbs = { alc880_volume_init_verbs,
2677 alc880_pin_6stack_init_verbs },
2542 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), 2678 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2543 .dac_nids = alc880_6st_dac_nids, 2679 .dac_nids = alc880_6st_dac_nids,
2544 .dig_out_nid = ALC880_DIGOUT_NID, 2680 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2548,7 +2684,8 @@ static struct alc_config_preset alc880_presets[] = {
2548 }, 2684 },
2549 [ALC880_W810] = { 2685 [ALC880_W810] = {
2550 .mixers = { alc880_w810_base_mixer }, 2686 .mixers = { alc880_w810_base_mixer },
2551 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs, 2687 .init_verbs = { alc880_volume_init_verbs,
2688 alc880_pin_w810_init_verbs,
2552 alc880_gpio2_init_verbs }, 2689 alc880_gpio2_init_verbs },
2553 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), 2690 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2554 .dac_nids = alc880_w810_dac_nids, 2691 .dac_nids = alc880_w810_dac_nids,
@@ -2559,7 +2696,8 @@ static struct alc_config_preset alc880_presets[] = {
2559 }, 2696 },
2560 [ALC880_Z71V] = { 2697 [ALC880_Z71V] = {
2561 .mixers = { alc880_z71v_mixer }, 2698 .mixers = { alc880_z71v_mixer },
2562 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs }, 2699 .init_verbs = { alc880_volume_init_verbs,
2700 alc880_pin_z71v_init_verbs },
2563 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), 2701 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2564 .dac_nids = alc880_z71v_dac_nids, 2702 .dac_nids = alc880_z71v_dac_nids,
2565 .dig_out_nid = ALC880_DIGOUT_NID, 2703 .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2570,7 +2708,8 @@ static struct alc_config_preset alc880_presets[] = {
2570 }, 2708 },
2571 [ALC880_F1734] = { 2709 [ALC880_F1734] = {
2572 .mixers = { alc880_f1734_mixer }, 2710 .mixers = { alc880_f1734_mixer },
2573 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs }, 2711 .init_verbs = { alc880_volume_init_verbs,
2712 alc880_pin_f1734_init_verbs },
2574 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), 2713 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2575 .dac_nids = alc880_f1734_dac_nids, 2714 .dac_nids = alc880_f1734_dac_nids,
2576 .hp_nid = 0x02, 2715 .hp_nid = 0x02,
@@ -2580,7 +2719,8 @@ static struct alc_config_preset alc880_presets[] = {
2580 }, 2719 },
2581 [ALC880_ASUS] = { 2720 [ALC880_ASUS] = {
2582 .mixers = { alc880_asus_mixer }, 2721 .mixers = { alc880_asus_mixer },
2583 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2722 .init_verbs = { alc880_volume_init_verbs,
2723 alc880_pin_asus_init_verbs,
2584 alc880_gpio1_init_verbs }, 2724 alc880_gpio1_init_verbs },
2585 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2725 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2586 .dac_nids = alc880_asus_dac_nids, 2726 .dac_nids = alc880_asus_dac_nids,
@@ -2591,7 +2731,8 @@ static struct alc_config_preset alc880_presets[] = {
2591 }, 2731 },
2592 [ALC880_ASUS_DIG] = { 2732 [ALC880_ASUS_DIG] = {
2593 .mixers = { alc880_asus_mixer }, 2733 .mixers = { alc880_asus_mixer },
2594 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2734 .init_verbs = { alc880_volume_init_verbs,
2735 alc880_pin_asus_init_verbs,
2595 alc880_gpio1_init_verbs }, 2736 alc880_gpio1_init_verbs },
2596 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2737 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2597 .dac_nids = alc880_asus_dac_nids, 2738 .dac_nids = alc880_asus_dac_nids,
@@ -2603,7 +2744,8 @@ static struct alc_config_preset alc880_presets[] = {
2603 }, 2744 },
2604 [ALC880_ASUS_DIG2] = { 2745 [ALC880_ASUS_DIG2] = {
2605 .mixers = { alc880_asus_mixer }, 2746 .mixers = { alc880_asus_mixer },
2606 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2747 .init_verbs = { alc880_volume_init_verbs,
2748 alc880_pin_asus_init_verbs,
2607 alc880_gpio2_init_verbs }, /* use GPIO2 */ 2749 alc880_gpio2_init_verbs }, /* use GPIO2 */
2608 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2750 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2609 .dac_nids = alc880_asus_dac_nids, 2751 .dac_nids = alc880_asus_dac_nids,
@@ -2615,7 +2757,8 @@ static struct alc_config_preset alc880_presets[] = {
2615 }, 2757 },
2616 [ALC880_ASUS_W1V] = { 2758 [ALC880_ASUS_W1V] = {
2617 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, 2759 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2618 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 2760 .init_verbs = { alc880_volume_init_verbs,
2761 alc880_pin_asus_init_verbs,
2619 alc880_gpio1_init_verbs }, 2762 alc880_gpio1_init_verbs },
2620 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 2763 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2621 .dac_nids = alc880_asus_dac_nids, 2764 .dac_nids = alc880_asus_dac_nids,
@@ -2664,7 +2807,7 @@ static struct alc_config_preset alc880_presets[] = {
2664 .init_hook = alc880_uniwill_p53_hp_automute, 2807 .init_hook = alc880_uniwill_p53_hp_automute,
2665 }, 2808 },
2666 [ALC880_FUJITSU] = { 2809 [ALC880_FUJITSU] = {
2667 .mixers = { alc880_fujitsu_mixer, 2810 .mixers = { alc880_fujitsu_mixer,
2668 alc880_pcbeep_mixer, }, 2811 alc880_pcbeep_mixer, },
2669 .init_verbs = { alc880_volume_init_verbs, 2812 .init_verbs = { alc880_volume_init_verbs,
2670 alc880_uniwill_p53_init_verbs, 2813 alc880_uniwill_p53_init_verbs,
@@ -2707,7 +2850,7 @@ static struct alc_config_preset alc880_presets[] = {
2707 .mixers = { alc880_lg_lw_mixer }, 2850 .mixers = { alc880_lg_lw_mixer },
2708 .init_verbs = { alc880_volume_init_verbs, 2851 .init_verbs = { alc880_volume_init_verbs,
2709 alc880_lg_lw_init_verbs }, 2852 alc880_lg_lw_init_verbs },
2710 .num_dacs = 1, 2853 .num_dacs = 1,
2711 .dac_nids = alc880_dac_nids, 2854 .dac_nids = alc880_dac_nids,
2712 .dig_out_nid = ALC880_DIGOUT_NID, 2855 .dig_out_nid = ALC880_DIGOUT_NID,
2713 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 2856 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
@@ -2749,18 +2892,21 @@ static struct snd_kcontrol_new alc880_control_templates[] = {
2749}; 2892};
2750 2893
2751/* add dynamic controls */ 2894/* add dynamic controls */
2752static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val) 2895static int add_control(struct alc_spec *spec, int type, const char *name,
2896 unsigned long val)
2753{ 2897{
2754 struct snd_kcontrol_new *knew; 2898 struct snd_kcontrol_new *knew;
2755 2899
2756 if (spec->num_kctl_used >= spec->num_kctl_alloc) { 2900 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2757 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; 2901 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2758 2902
2759 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ 2903 /* array + terminator */
2760 if (! knew) 2904 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2905 if (!knew)
2761 return -ENOMEM; 2906 return -ENOMEM;
2762 if (spec->kctl_alloc) { 2907 if (spec->kctl_alloc) {
2763 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); 2908 memcpy(knew, spec->kctl_alloc,
2909 sizeof(*knew) * spec->num_kctl_alloc);
2764 kfree(spec->kctl_alloc); 2910 kfree(spec->kctl_alloc);
2765 } 2911 }
2766 spec->kctl_alloc = knew; 2912 spec->kctl_alloc = knew;
@@ -2770,7 +2916,7 @@ static int add_control(struct alc_spec *spec, int type, const char *name, unsign
2770 knew = &spec->kctl_alloc[spec->num_kctl_used]; 2916 knew = &spec->kctl_alloc[spec->num_kctl_used];
2771 *knew = alc880_control_templates[type]; 2917 *knew = alc880_control_templates[type];
2772 knew->name = kstrdup(name, GFP_KERNEL); 2918 knew->name = kstrdup(name, GFP_KERNEL);
2773 if (! knew->name) 2919 if (!knew->name)
2774 return -ENOMEM; 2920 return -ENOMEM;
2775 knew->private_value = val; 2921 knew->private_value = val;
2776 spec->num_kctl_used++; 2922 spec->num_kctl_used++;
@@ -2790,7 +2936,8 @@ static int add_control(struct alc_spec *spec, int type, const char *name, unsign
2790#define ALC880_PIN_CD_NID 0x1c 2936#define ALC880_PIN_CD_NID 0x1c
2791 2937
2792/* fill in the dac_nids table from the parsed pin configuration */ 2938/* fill in the dac_nids table from the parsed pin configuration */
2793static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 2939static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
2940 const struct auto_pin_cfg *cfg)
2794{ 2941{
2795 hda_nid_t nid; 2942 hda_nid_t nid;
2796 int assigned[4]; 2943 int assigned[4];
@@ -2815,8 +2962,9 @@ static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pi
2815 continue; 2962 continue;
2816 /* search for an empty channel */ 2963 /* search for an empty channel */
2817 for (j = 0; j < cfg->line_outs; j++) { 2964 for (j = 0; j < cfg->line_outs; j++) {
2818 if (! assigned[j]) { 2965 if (!assigned[j]) {
2819 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j); 2966 spec->multiout.dac_nids[i] =
2967 alc880_idx_to_dac(j);
2820 assigned[j] = 1; 2968 assigned[j] = 1;
2821 break; 2969 break;
2822 } 2970 }
@@ -2831,36 +2979,54 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
2831 const struct auto_pin_cfg *cfg) 2979 const struct auto_pin_cfg *cfg)
2832{ 2980{
2833 char name[32]; 2981 char name[32];
2834 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; 2982 static const char *chname[4] = {
2983 "Front", "Surround", NULL /*CLFE*/, "Side"
2984 };
2835 hda_nid_t nid; 2985 hda_nid_t nid;
2836 int i, err; 2986 int i, err;
2837 2987
2838 for (i = 0; i < cfg->line_outs; i++) { 2988 for (i = 0; i < cfg->line_outs; i++) {
2839 if (! spec->multiout.dac_nids[i]) 2989 if (!spec->multiout.dac_nids[i])
2840 continue; 2990 continue;
2841 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); 2991 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
2842 if (i == 2) { 2992 if (i == 2) {
2843 /* Center/LFE */ 2993 /* Center/LFE */
2844 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume", 2994 err = add_control(spec, ALC_CTL_WIDGET_VOL,
2845 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) 2995 "Center Playback Volume",
2996 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
2997 HDA_OUTPUT));
2998 if (err < 0)
2846 return err; 2999 return err;
2847 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume", 3000 err = add_control(spec, ALC_CTL_WIDGET_VOL,
2848 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 3001 "LFE Playback Volume",
3002 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3003 HDA_OUTPUT));
3004 if (err < 0)
2849 return err; 3005 return err;
2850 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", 3006 err = add_control(spec, ALC_CTL_BIND_MUTE,
2851 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0) 3007 "Center Playback Switch",
3008 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3009 HDA_INPUT));
3010 if (err < 0)
2852 return err; 3011 return err;
2853 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", 3012 err = add_control(spec, ALC_CTL_BIND_MUTE,
2854 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0) 3013 "LFE Playback Switch",
3014 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3015 HDA_INPUT));
3016 if (err < 0)
2855 return err; 3017 return err;
2856 } else { 3018 } else {
2857 sprintf(name, "%s Playback Volume", chname[i]); 3019 sprintf(name, "%s Playback Volume", chname[i]);
2858 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3020 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2859 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 3021 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3022 HDA_OUTPUT));
3023 if (err < 0)
2860 return err; 3024 return err;
2861 sprintf(name, "%s Playback Switch", chname[i]); 3025 sprintf(name, "%s Playback Switch", chname[i]);
2862 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 3026 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2863 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) 3027 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3028 HDA_INPUT));
3029 if (err < 0)
2864 return err; 3030 return err;
2865 } 3031 }
2866 } 3032 }
@@ -2875,51 +3041,57 @@ static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
2875 int err; 3041 int err;
2876 char name[32]; 3042 char name[32];
2877 3043
2878 if (! pin) 3044 if (!pin)
2879 return 0; 3045 return 0;
2880 3046
2881 if (alc880_is_fixed_pin(pin)) { 3047 if (alc880_is_fixed_pin(pin)) {
2882 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 3048 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
2883 /* specify the DAC as the extra output */ 3049 /* specify the DAC as the extra output */
2884 if (! spec->multiout.hp_nid) 3050 if (!spec->multiout.hp_nid)
2885 spec->multiout.hp_nid = nid; 3051 spec->multiout.hp_nid = nid;
2886 else 3052 else
2887 spec->multiout.extra_out_nid[0] = nid; 3053 spec->multiout.extra_out_nid[0] = nid;
2888 /* control HP volume/switch on the output mixer amp */ 3054 /* control HP volume/switch on the output mixer amp */
2889 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); 3055 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
2890 sprintf(name, "%s Playback Volume", pfx); 3056 sprintf(name, "%s Playback Volume", pfx);
2891 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3057 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2892 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 3058 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3059 if (err < 0)
2893 return err; 3060 return err;
2894 sprintf(name, "%s Playback Switch", pfx); 3061 sprintf(name, "%s Playback Switch", pfx);
2895 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 3062 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
2896 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) 3063 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3064 if (err < 0)
2897 return err; 3065 return err;
2898 } else if (alc880_is_multi_pin(pin)) { 3066 } else if (alc880_is_multi_pin(pin)) {
2899 /* set manual connection */ 3067 /* set manual connection */
2900 /* we have only a switch on HP-out PIN */ 3068 /* we have only a switch on HP-out PIN */
2901 sprintf(name, "%s Playback Switch", pfx); 3069 sprintf(name, "%s Playback Switch", pfx);
2902 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 3070 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2903 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0) 3071 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3072 if (err < 0)
2904 return err; 3073 return err;
2905 } 3074 }
2906 return 0; 3075 return 0;
2907} 3076}
2908 3077
2909/* create input playback/capture controls for the given pin */ 3078/* create input playback/capture controls for the given pin */
2910static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname, 3079static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3080 const char *ctlname,
2911 int idx, hda_nid_t mix_nid) 3081 int idx, hda_nid_t mix_nid)
2912{ 3082{
2913 char name[32]; 3083 char name[32];
2914 int err; 3084 int err;
2915 3085
2916 sprintf(name, "%s Playback Volume", ctlname); 3086 sprintf(name, "%s Playback Volume", ctlname);
2917 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 3087 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
2918 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) 3088 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3089 if (err < 0)
2919 return err; 3090 return err;
2920 sprintf(name, "%s Playback Switch", ctlname); 3091 sprintf(name, "%s Playback Switch", ctlname);
2921 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 3092 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
2922 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) 3093 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3094 if (err < 0)
2923 return err; 3095 return err;
2924 return 0; 3096 return 0;
2925} 3097}
@@ -2939,8 +3111,10 @@ static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2939 idx, 0x0b); 3111 idx, 0x0b);
2940 if (err < 0) 3112 if (err < 0)
2941 return err; 3113 return err;
2942 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 3114 imux->items[imux->num_items].label =
2943 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]); 3115 auto_pin_cfg_labels[i];
3116 imux->items[imux->num_items].index =
3117 alc880_input_pin_idx(cfg->input_pins[i]);
2944 imux->num_items++; 3118 imux->num_items++;
2945 } 3119 }
2946 } 3120 }
@@ -2952,8 +3126,10 @@ static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2952 int dac_idx) 3126 int dac_idx)
2953{ 3127{
2954 /* set as output */ 3128 /* set as output */
2955 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 3129 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2956 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 3130 pin_type);
3131 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3132 AMP_OUT_UNMUTE);
2957 /* need the manual connection? */ 3133 /* need the manual connection? */
2958 if (alc880_is_multi_pin(nid)) { 3134 if (alc880_is_multi_pin(nid)) {
2959 struct alc_spec *spec = codec->spec; 3135 struct alc_spec *spec = codec->spec;
@@ -2964,14 +3140,24 @@ static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
2964 } 3140 }
2965} 3141}
2966 3142
3143static int get_pin_type(int line_out_type)
3144{
3145 if (line_out_type == AUTO_PIN_HP_OUT)
3146 return PIN_HP;
3147 else
3148 return PIN_OUT;
3149}
3150
2967static void alc880_auto_init_multi_out(struct hda_codec *codec) 3151static void alc880_auto_init_multi_out(struct hda_codec *codec)
2968{ 3152{
2969 struct alc_spec *spec = codec->spec; 3153 struct alc_spec *spec = codec->spec;
2970 int i; 3154 int i;
2971 3155
3156 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
2972 for (i = 0; i < spec->autocfg.line_outs; i++) { 3157 for (i = 0; i < spec->autocfg.line_outs; i++) {
2973 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 3158 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2974 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); 3159 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3160 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
2975 } 3161 }
2976} 3162}
2977 3163
@@ -2996,37 +3182,52 @@ static void alc880_auto_init_analog_input(struct hda_codec *codec)
2996 for (i = 0; i < AUTO_PIN_LAST; i++) { 3182 for (i = 0; i < AUTO_PIN_LAST; i++) {
2997 hda_nid_t nid = spec->autocfg.input_pins[i]; 3183 hda_nid_t nid = spec->autocfg.input_pins[i];
2998 if (alc880_is_input_pin(nid)) { 3184 if (alc880_is_input_pin(nid)) {
2999 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 3185 snd_hda_codec_write(codec, nid, 0,
3000 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 3186 AC_VERB_SET_PIN_WIDGET_CONTROL,
3187 i <= AUTO_PIN_FRONT_MIC ?
3188 PIN_VREF80 : PIN_IN);
3001 if (nid != ALC880_PIN_CD_NID) 3189 if (nid != ALC880_PIN_CD_NID)
3002 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 3190 snd_hda_codec_write(codec, nid, 0,
3191 AC_VERB_SET_AMP_GAIN_MUTE,
3003 AMP_OUT_MUTE); 3192 AMP_OUT_MUTE);
3004 } 3193 }
3005 } 3194 }
3006} 3195}
3007 3196
3008/* parse the BIOS configuration and set up the alc_spec */ 3197/* parse the BIOS configuration and set up the alc_spec */
3009/* return 1 if successful, 0 if the proper config is not found, or a negative error code */ 3198/* return 1 if successful, 0 if the proper config is not found,
3199 * or a negative error code
3200 */
3010static int alc880_parse_auto_config(struct hda_codec *codec) 3201static int alc880_parse_auto_config(struct hda_codec *codec)
3011{ 3202{
3012 struct alc_spec *spec = codec->spec; 3203 struct alc_spec *spec = codec->spec;
3013 int err; 3204 int err;
3014 static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; 3205 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3015 3206
3016 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 3207 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3017 alc880_ignore)) < 0) 3208 alc880_ignore);
3209 if (err < 0)
3018 return err; 3210 return err;
3019 if (! spec->autocfg.line_outs) 3211 if (!spec->autocfg.line_outs)
3020 return 0; /* can't find valid BIOS pin config */ 3212 return 0; /* can't find valid BIOS pin config */
3021 3213
3022 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 3214 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3023 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 3215 if (err < 0)
3024 (err = alc880_auto_create_extra_out(spec, 3216 return err;
3025 spec->autocfg.speaker_pins[0], 3217 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3026 "Speaker")) < 0 || 3218 if (err < 0)
3027 (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0], 3219 return err;
3028 "Headphone")) < 0 || 3220 err = alc880_auto_create_extra_out(spec,
3029 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 3221 spec->autocfg.speaker_pins[0],
3222 "Speaker");
3223 if (err < 0)
3224 return err;
3225 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3226 "Headphone");
3227 if (err < 0)
3228 return err;
3229 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3230 if (err < 0)
3030 return err; 3231 return err;
3031 3232
3032 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 3233 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -3086,7 +3287,7 @@ static int patch_alc880(struct hda_codec *codec)
3086 if (err < 0) { 3287 if (err < 0) {
3087 alc_free(codec); 3288 alc_free(codec);
3088 return err; 3289 return err;
3089 } else if (! err) { 3290 } else if (!err) {
3090 printk(KERN_INFO 3291 printk(KERN_INFO
3091 "hda_codec: Cannot set up configuration " 3292 "hda_codec: Cannot set up configuration "
3092 "from BIOS. Using 3-stack mode...\n"); 3293 "from BIOS. Using 3-stack mode...\n");
@@ -3105,14 +3306,16 @@ static int patch_alc880(struct hda_codec *codec)
3105 spec->stream_digital_playback = &alc880_pcm_digital_playback; 3306 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3106 spec->stream_digital_capture = &alc880_pcm_digital_capture; 3307 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3107 3308
3108 if (! spec->adc_nids && spec->input_mux) { 3309 if (!spec->adc_nids && spec->input_mux) {
3109 /* check whether NID 0x07 is valid */ 3310 /* check whether NID 0x07 is valid */
3110 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); 3311 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3111 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 3312 /* get type */
3313 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3112 if (wcap != AC_WID_AUD_IN) { 3314 if (wcap != AC_WID_AUD_IN) {
3113 spec->adc_nids = alc880_adc_nids_alt; 3315 spec->adc_nids = alc880_adc_nids_alt;
3114 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); 3316 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3115 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer; 3317 spec->mixers[spec->num_mixers] =
3318 alc880_capture_alt_mixer;
3116 spec->num_mixers++; 3319 spec->num_mixers++;
3117 } else { 3320 } else {
3118 spec->adc_nids = alc880_adc_nids; 3321 spec->adc_nids = alc880_adc_nids;
@@ -3254,7 +3457,7 @@ static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3254 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 3457 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3255 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), 3458 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3256 { } /* end */ 3459 { } /* end */
3257}; 3460};
3258 3461
3259static struct snd_kcontrol_new alc260_input_mixer[] = { 3462static struct snd_kcontrol_new alc260_input_mixer[] = {
3260 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 3463 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
@@ -3349,6 +3552,42 @@ static struct snd_kcontrol_new alc260_acer_mixer[] = {
3349 { } /* end */ 3552 { } /* end */
3350}; 3553};
3351 3554
3555/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3556 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3557 */
3558static struct snd_kcontrol_new alc260_will_mixer[] = {
3559 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3560 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3561 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3562 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3563 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3564 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3565 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3566 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3567 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3568 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3569 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3570 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3571 { } /* end */
3572};
3573
3574/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3575 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3576 */
3577static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3578 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3579 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3580 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3581 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3582 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3583 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3584 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3585 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3586 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3587 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3588 { } /* end */
3589};
3590
3352/* capture mixer elements */ 3591/* capture mixer elements */
3353static struct snd_kcontrol_new alc260_capture_mixer[] = { 3592static struct snd_kcontrol_new alc260_capture_mixer[] = {
3354 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), 3593 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
@@ -3434,7 +3673,9 @@ static struct hda_verb alc260_init_verbs[] = {
3434 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3673 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3435 /* unmute LINE-2 out pin */ 3674 /* unmute LINE-2 out pin */
3436 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3675 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3437 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 3676 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3677 * Line In 2 = 0x03
3678 */
3438 /* mute CD */ 3679 /* mute CD */
3439 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 3680 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
3440 /* mute Line In */ 3681 /* mute Line In */
@@ -3482,7 +3723,9 @@ static struct hda_verb alc260_hp_init_verbs[] = {
3482 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 3723 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3483 /* mute pin widget amp left and right (no gain on this amp) */ 3724 /* mute pin widget amp left and right (no gain on this amp) */
3484 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 3725 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3485 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 3726 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3727 * Line In 2 = 0x03
3728 */
3486 /* unmute CD */ 3729 /* unmute CD */
3487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 3730 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3488 /* unmute Line In */ 3731 /* unmute Line In */
@@ -3530,7 +3773,9 @@ static struct hda_verb alc260_hp_3013_init_verbs[] = {
3530 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 3773 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3531 /* mute pin widget amp left and right (no gain on this amp) */ 3774 /* mute pin widget amp left and right (no gain on this amp) */
3532 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 3775 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3533 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 3776 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3777 * Line In 2 = 0x03
3778 */
3534 /* unmute CD */ 3779 /* unmute CD */
3535 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 3780 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
3536 /* unmute Line In */ 3781 /* unmute Line In */
@@ -3680,7 +3925,9 @@ static struct hda_verb alc260_acer_init_verbs[] = {
3680 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3925 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3681 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3926 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3682 3927
3683 /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */ 3928 /* Unmute Line-out pin widget amp left and right
3929 * (no equiv mixer ctrl)
3930 */
3684 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3931 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3685 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */ 3932 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3686 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3933 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
@@ -3719,6 +3966,55 @@ static struct hda_verb alc260_acer_init_verbs[] = {
3719 { } 3966 { }
3720}; 3967};
3721 3968
3969static struct hda_verb alc260_will_verbs[] = {
3970 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3971 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
3972 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
3973 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3974 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
3975 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
3976 {}
3977};
3978
3979static struct hda_verb alc260_replacer_672v_verbs[] = {
3980 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
3981 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
3982 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
3983
3984 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3985 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3986 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
3987
3988 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3989 {}
3990};
3991
3992/* toggle speaker-output according to the hp-jack state */
3993static void alc260_replacer_672v_automute(struct hda_codec *codec)
3994{
3995 unsigned int present;
3996
3997 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
3998 present = snd_hda_codec_read(codec, 0x0f, 0,
3999 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4000 if (present) {
4001 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
4002 snd_hda_codec_write(codec, 0x0f, 0,
4003 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
4004 } else {
4005 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
4006 snd_hda_codec_write(codec, 0x0f, 0,
4007 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
4008 }
4009}
4010
4011static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4012 unsigned int res)
4013{
4014 if ((res >> 26) == ALC880_HP_EVENT)
4015 alc260_replacer_672v_automute(codec);
4016}
4017
3722/* Test configuration for debugging, modelled after the ALC880 test 4018/* Test configuration for debugging, modelled after the ALC880 test
3723 * configuration. 4019 * configuration.
3724 */ 4020 */
@@ -3946,10 +4242,12 @@ static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
3946 return 0; /* N/A */ 4242 return 0; /* N/A */
3947 4243
3948 snprintf(name, sizeof(name), "%s Playback Volume", pfx); 4244 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
3949 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0) 4245 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4246 if (err < 0)
3950 return err; 4247 return err;
3951 snprintf(name, sizeof(name), "%s Playback Switch", pfx); 4248 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
3952 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0) 4249 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4250 if (err < 0)
3953 return err; 4251 return err;
3954 return 1; 4252 return 1;
3955} 4253}
@@ -3985,7 +4283,7 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
3985 if (err < 0) 4283 if (err < 0)
3986 return err; 4284 return err;
3987 } 4285 }
3988 return 0; 4286 return 0;
3989} 4287}
3990 4288
3991/* create playback/capture controls for input pins */ 4289/* create playback/capture controls for input pins */
@@ -3999,20 +4297,24 @@ static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
3999 if (cfg->input_pins[i] >= 0x12) { 4297 if (cfg->input_pins[i] >= 0x12) {
4000 idx = cfg->input_pins[i] - 0x12; 4298 idx = cfg->input_pins[i] - 0x12;
4001 err = new_analog_input(spec, cfg->input_pins[i], 4299 err = new_analog_input(spec, cfg->input_pins[i],
4002 auto_pin_cfg_labels[i], idx, 0x07); 4300 auto_pin_cfg_labels[i], idx,
4301 0x07);
4003 if (err < 0) 4302 if (err < 0)
4004 return err; 4303 return err;
4005 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 4304 imux->items[imux->num_items].label =
4305 auto_pin_cfg_labels[i];
4006 imux->items[imux->num_items].index = idx; 4306 imux->items[imux->num_items].index = idx;
4007 imux->num_items++; 4307 imux->num_items++;
4008 } 4308 }
4009 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){ 4309 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4010 idx = cfg->input_pins[i] - 0x09; 4310 idx = cfg->input_pins[i] - 0x09;
4011 err = new_analog_input(spec, cfg->input_pins[i], 4311 err = new_analog_input(spec, cfg->input_pins[i],
4012 auto_pin_cfg_labels[i], idx, 0x07); 4312 auto_pin_cfg_labels[i], idx,
4313 0x07);
4013 if (err < 0) 4314 if (err < 0)
4014 return err; 4315 return err;
4015 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 4316 imux->items[imux->num_items].label =
4317 auto_pin_cfg_labels[i];
4016 imux->items[imux->num_items].index = idx; 4318 imux->items[imux->num_items].index = idx;
4017 imux->num_items++; 4319 imux->num_items++;
4018 } 4320 }
@@ -4025,14 +4327,15 @@ static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4025 int sel_idx) 4327 int sel_idx)
4026{ 4328{
4027 /* set as output */ 4329 /* set as output */
4028 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 4330 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4029 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 4331 pin_type);
4332 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4333 AMP_OUT_UNMUTE);
4030 /* need the manual connection? */ 4334 /* need the manual connection? */
4031 if (nid >= 0x12) { 4335 if (nid >= 0x12) {
4032 int idx = nid - 0x12; 4336 int idx = nid - 0x12;
4033 snd_hda_codec_write(codec, idx + 0x0b, 0, 4337 snd_hda_codec_write(codec, idx + 0x0b, 0,
4034 AC_VERB_SET_CONNECT_SEL, sel_idx); 4338 AC_VERB_SET_CONNECT_SEL, sel_idx);
4035
4036 } 4339 }
4037} 4340}
4038 4341
@@ -4041,9 +4344,12 @@ static void alc260_auto_init_multi_out(struct hda_codec *codec)
4041 struct alc_spec *spec = codec->spec; 4344 struct alc_spec *spec = codec->spec;
4042 hda_nid_t nid; 4345 hda_nid_t nid;
4043 4346
4044 nid = spec->autocfg.line_out_pins[0]; 4347 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4045 if (nid) 4348 nid = spec->autocfg.line_out_pins[0];
4046 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); 4349 if (nid) {
4350 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4351 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4352 }
4047 4353
4048 nid = spec->autocfg.speaker_pins[0]; 4354 nid = spec->autocfg.speaker_pins[0];
4049 if (nid) 4355 if (nid)
@@ -4051,8 +4357,8 @@ static void alc260_auto_init_multi_out(struct hda_codec *codec)
4051 4357
4052 nid = spec->autocfg.hp_pins[0]; 4358 nid = spec->autocfg.hp_pins[0];
4053 if (nid) 4359 if (nid)
4054 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); 4360 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
4055} 4361}
4056 4362
4057#define ALC260_PIN_CD_NID 0x16 4363#define ALC260_PIN_CD_NID 0x16
4058static void alc260_auto_init_analog_input(struct hda_codec *codec) 4364static void alc260_auto_init_analog_input(struct hda_codec *codec)
@@ -4063,10 +4369,13 @@ static void alc260_auto_init_analog_input(struct hda_codec *codec)
4063 for (i = 0; i < AUTO_PIN_LAST; i++) { 4369 for (i = 0; i < AUTO_PIN_LAST; i++) {
4064 hda_nid_t nid = spec->autocfg.input_pins[i]; 4370 hda_nid_t nid = spec->autocfg.input_pins[i];
4065 if (nid >= 0x12) { 4371 if (nid >= 0x12) {
4066 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4372 snd_hda_codec_write(codec, nid, 0,
4067 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 4373 AC_VERB_SET_PIN_WIDGET_CONTROL,
4374 i <= AUTO_PIN_FRONT_MIC ?
4375 PIN_VREF80 : PIN_IN);
4068 if (nid != ALC260_PIN_CD_NID) 4376 if (nid != ALC260_PIN_CD_NID)
4069 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 4377 snd_hda_codec_write(codec, nid, 0,
4378 AC_VERB_SET_AMP_GAIN_MUTE,
4070 AMP_OUT_MUTE); 4379 AMP_OUT_MUTE);
4071 } 4380 }
4072 } 4381 }
@@ -4086,8 +4395,8 @@ static struct hda_verb alc260_volume_init_verbs[] = {
4086 4395
4087 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 4396 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4088 * mixer widget 4397 * mixer widget
4089 * Note: PASD motherboards uses the Line In 2 as the input for front panel 4398 * Note: PASD motherboards uses the Line In 2 as the input for
4090 * mic (mic 2) 4399 * front panel mic (mic 2)
4091 */ 4400 */
4092 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 4401 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4093 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -4122,14 +4431,17 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
4122 int err; 4431 int err;
4123 static hda_nid_t alc260_ignore[] = { 0x17, 0 }; 4432 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4124 4433
4125 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 4434 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4126 alc260_ignore)) < 0) 4435 alc260_ignore);
4436 if (err < 0)
4127 return err; 4437 return err;
4128 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0) 4438 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4439 if (err < 0)
4129 return err; 4440 return err;
4130 if (! spec->kctl_alloc) 4441 if (!spec->kctl_alloc)
4131 return 0; /* can't find valid BIOS pin config */ 4442 return 0; /* can't find valid BIOS pin config */
4132 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 4443 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4444 if (err < 0)
4133 return err; 4445 return err;
4134 4446
4135 spec->multiout.max_channels = 2; 4447 spec->multiout.max_channels = 2;
@@ -4177,6 +4489,8 @@ static const char *alc260_models[ALC260_MODEL_LAST] = {
4177 [ALC260_HP_3013] = "hp-3013", 4489 [ALC260_HP_3013] = "hp-3013",
4178 [ALC260_FUJITSU_S702X] = "fujitsu", 4490 [ALC260_FUJITSU_S702X] = "fujitsu",
4179 [ALC260_ACER] = "acer", 4491 [ALC260_ACER] = "acer",
4492 [ALC260_WILL] = "will",
4493 [ALC260_REPLACER_672V] = "replacer",
4180#ifdef CONFIG_SND_DEBUG 4494#ifdef CONFIG_SND_DEBUG
4181 [ALC260_TEST] = "test", 4495 [ALC260_TEST] = "test",
4182#endif 4496#endif
@@ -4200,6 +4514,8 @@ static struct snd_pci_quirk alc260_cfg_tbl[] = {
4200 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC), 4514 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4201 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X), 4515 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4202 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC), 4516 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
4517 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4518 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
4203 {} 4519 {}
4204}; 4520};
4205 4521
@@ -4270,6 +4586,34 @@ static struct alc_config_preset alc260_presets[] = {
4270 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), 4586 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4271 .input_mux = alc260_acer_capture_sources, 4587 .input_mux = alc260_acer_capture_sources,
4272 }, 4588 },
4589 [ALC260_WILL] = {
4590 .mixers = { alc260_will_mixer,
4591 alc260_capture_mixer },
4592 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4593 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4594 .dac_nids = alc260_dac_nids,
4595 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4596 .adc_nids = alc260_adc_nids,
4597 .dig_out_nid = ALC260_DIGOUT_NID,
4598 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4599 .channel_mode = alc260_modes,
4600 .input_mux = &alc260_capture_source,
4601 },
4602 [ALC260_REPLACER_672V] = {
4603 .mixers = { alc260_replacer_672v_mixer,
4604 alc260_capture_mixer },
4605 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4606 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4607 .dac_nids = alc260_dac_nids,
4608 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4609 .adc_nids = alc260_adc_nids,
4610 .dig_out_nid = ALC260_DIGOUT_NID,
4611 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4612 .channel_mode = alc260_modes,
4613 .input_mux = &alc260_capture_source,
4614 .unsol_event = alc260_replacer_672v_unsol_event,
4615 .init_hook = alc260_replacer_672v_automute,
4616 },
4273#ifdef CONFIG_SND_DEBUG 4617#ifdef CONFIG_SND_DEBUG
4274 [ALC260_TEST] = { 4618 [ALC260_TEST] = {
4275 .mixers = { alc260_test_mixer, 4619 .mixers = { alc260_test_mixer,
@@ -4313,7 +4657,7 @@ static int patch_alc260(struct hda_codec *codec)
4313 if (err < 0) { 4657 if (err < 0) {
4314 alc_free(codec); 4658 alc_free(codec);
4315 return err; 4659 return err;
4316 } else if (! err) { 4660 } else if (!err) {
4317 printk(KERN_INFO 4661 printk(KERN_INFO
4318 "hda_codec: Cannot set up configuration " 4662 "hda_codec: Cannot set up configuration "
4319 "from BIOS. Using base mode...\n"); 4663 "from BIOS. Using base mode...\n");
@@ -4382,7 +4726,8 @@ static struct hda_input_mux alc882_capture_source = {
4382#define alc882_mux_enum_info alc_mux_enum_info 4726#define alc882_mux_enum_info alc_mux_enum_info
4383#define alc882_mux_enum_get alc_mux_enum_get 4727#define alc882_mux_enum_get alc_mux_enum_get
4384 4728
4385static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 4729static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4730 struct snd_ctl_elem_value *ucontrol)
4386{ 4731{
4387 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 4732 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4388 struct alc_spec *spec = codec->spec; 4733 struct alc_spec *spec = codec->spec;
@@ -4396,7 +4741,7 @@ static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
4396 idx = ucontrol->value.enumerated.item[0]; 4741 idx = ucontrol->value.enumerated.item[0];
4397 if (idx >= imux->num_items) 4742 if (idx >= imux->num_items)
4398 idx = imux->num_items - 1; 4743 idx = imux->num_items - 1;
4399 if (*cur_val == idx && ! codec->in_resume) 4744 if (*cur_val == idx && !codec->in_resume)
4400 return 0; 4745 return 0;
4401 for (i = 0; i < imux->num_items; i++) { 4746 for (i = 0; i < imux->num_items; i++) {
4402 unsigned int v = (i == idx) ? 0x7000 : 0x7080; 4747 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
@@ -4464,6 +4809,21 @@ static struct snd_kcontrol_new alc882_base_mixer[] = {
4464 { } /* end */ 4809 { } /* end */
4465}; 4810};
4466 4811
4812static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4813 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4814 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4815 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4816 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4817 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4818 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4820 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4821 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4822 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4823 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4824 { } /* end */
4825};
4826
4467static struct snd_kcontrol_new alc882_chmode_mixer[] = { 4827static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4468 { 4828 {
4469 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -4559,7 +4919,7 @@ static struct hda_verb alc882_eapd_verbs[] = {
4559 /* change to EAPD mode */ 4919 /* change to EAPD mode */
4560 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 4920 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
4561 {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, 4921 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
4562 { } 4922 { }
4563}; 4923};
4564 4924
4565/* Mac Pro test */ 4925/* Mac Pro test */
@@ -4624,6 +4984,7 @@ static struct hda_verb alc882_macpro_init_verbs[] = {
4624 4984
4625 { } 4985 { }
4626}; 4986};
4987
4627static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) 4988static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
4628{ 4989{
4629 unsigned int gpiostate, gpiomask, gpiodir; 4990 unsigned int gpiostate, gpiomask, gpiodir;
@@ -4672,8 +5033,8 @@ static struct hda_verb alc882_auto_init_verbs[] = {
4672 5033
4673 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 5034 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4674 * mixer widget 5035 * mixer widget
4675 * Note: PASD motherboards uses the Line In 2 as the input for front panel 5036 * Note: PASD motherboards uses the Line In 2 as the input for
4676 * mic (mic 2) 5037 * front panel mic (mic 2)
4677 */ 5038 */
4678 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 5039 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4679 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -4782,6 +5143,7 @@ static const char *alc882_models[ALC882_MODEL_LAST] = {
4782 [ALC882_3ST_DIG] = "3stack-dig", 5143 [ALC882_3ST_DIG] = "3stack-dig",
4783 [ALC882_6ST_DIG] = "6stack-dig", 5144 [ALC882_6ST_DIG] = "6stack-dig",
4784 [ALC882_ARIMA] = "arima", 5145 [ALC882_ARIMA] = "arima",
5146 [ALC882_W2JC] = "w2jc",
4785 [ALC885_MACPRO] = "macpro", 5147 [ALC885_MACPRO] = "macpro",
4786 [ALC882_AUTO] = "auto", 5148 [ALC882_AUTO] = "auto",
4787}; 5149};
@@ -4792,6 +5154,7 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = {
4792 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG), 5154 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
4793 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), 5155 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
4794 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG), 5156 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
5157 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
4795 {} 5158 {}
4796}; 5159};
4797 5160
@@ -4828,6 +5191,18 @@ static struct alc_config_preset alc882_presets[] = {
4828 .channel_mode = alc882_sixstack_modes, 5191 .channel_mode = alc882_sixstack_modes,
4829 .input_mux = &alc882_capture_source, 5192 .input_mux = &alc882_capture_source,
4830 }, 5193 },
5194 [ALC882_W2JC] = {
5195 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5196 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5197 alc880_gpio1_init_verbs },
5198 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5199 .dac_nids = alc882_dac_nids,
5200 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5201 .channel_mode = alc880_threestack_modes,
5202 .need_dac_fix = 1,
5203 .input_mux = &alc882_capture_source,
5204 .dig_out_nid = ALC882_DIGOUT_NID,
5205 },
4831 [ALC885_MACPRO] = { 5206 [ALC885_MACPRO] = {
4832 .mixers = { alc882_macpro_mixer }, 5207 .mixers = { alc882_macpro_mixer },
4833 .init_verbs = { alc882_macpro_init_verbs }, 5208 .init_verbs = { alc882_macpro_init_verbs },
@@ -4851,15 +5226,17 @@ static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
4851{ 5226{
4852 /* set as output */ 5227 /* set as output */
4853 struct alc_spec *spec = codec->spec; 5228 struct alc_spec *spec = codec->spec;
4854 int idx; 5229 int idx;
4855 5230
4856 if (spec->multiout.dac_nids[dac_idx] == 0x25) 5231 if (spec->multiout.dac_nids[dac_idx] == 0x25)
4857 idx = 4; 5232 idx = 4;
4858 else 5233 else
4859 idx = spec->multiout.dac_nids[dac_idx] - 2; 5234 idx = spec->multiout.dac_nids[dac_idx] - 2;
4860 5235
4861 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 5236 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4862 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 5237 pin_type);
5238 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5239 AMP_OUT_UNMUTE);
4863 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); 5240 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
4864 5241
4865} 5242}
@@ -4869,10 +5246,13 @@ static void alc882_auto_init_multi_out(struct hda_codec *codec)
4869 struct alc_spec *spec = codec->spec; 5246 struct alc_spec *spec = codec->spec;
4870 int i; 5247 int i;
4871 5248
5249 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
4872 for (i = 0; i <= HDA_SIDE; i++) { 5250 for (i = 0; i <= HDA_SIDE; i++) {
4873 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 5251 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5252 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4874 if (nid) 5253 if (nid)
4875 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); 5254 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
5255 i);
4876 } 5256 }
4877} 5257}
4878 5258
@@ -4883,7 +5263,8 @@ static void alc882_auto_init_hp_out(struct hda_codec *codec)
4883 5263
4884 pin = spec->autocfg.hp_pins[0]; 5264 pin = spec->autocfg.hp_pins[0];
4885 if (pin) /* connect to front */ 5265 if (pin) /* connect to front */
4886 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */ 5266 /* use dac 0 */
5267 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4887} 5268}
4888 5269
4889#define alc882_is_input_pin(nid) alc880_is_input_pin(nid) 5270#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
@@ -4897,10 +5278,13 @@ static void alc882_auto_init_analog_input(struct hda_codec *codec)
4897 for (i = 0; i < AUTO_PIN_LAST; i++) { 5278 for (i = 0; i < AUTO_PIN_LAST; i++) {
4898 hda_nid_t nid = spec->autocfg.input_pins[i]; 5279 hda_nid_t nid = spec->autocfg.input_pins[i];
4899 if (alc882_is_input_pin(nid)) { 5280 if (alc882_is_input_pin(nid)) {
4900 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 5281 snd_hda_codec_write(codec, nid, 0,
4901 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 5282 AC_VERB_SET_PIN_WIDGET_CONTROL,
5283 i <= AUTO_PIN_FRONT_MIC ?
5284 PIN_VREF80 : PIN_IN);
4902 if (nid != ALC882_PIN_CD_NID) 5285 if (nid != ALC882_PIN_CD_NID)
4903 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 5286 snd_hda_codec_write(codec, nid, 0,
5287 AC_VERB_SET_AMP_GAIN_MUTE,
4904 AMP_OUT_MUTE); 5288 AMP_OUT_MUTE);
4905 } 5289 }
4906 } 5290 }
@@ -4962,7 +5346,7 @@ static int patch_alc882(struct hda_codec *codec)
4962 if (err < 0) { 5346 if (err < 0) {
4963 alc_free(codec); 5347 alc_free(codec);
4964 return err; 5348 return err;
4965 } else if (! err) { 5349 } else if (!err) {
4966 printk(KERN_INFO 5350 printk(KERN_INFO
4967 "hda_codec: Cannot set up configuration " 5351 "hda_codec: Cannot set up configuration "
4968 "from BIOS. Using base mode...\n"); 5352 "from BIOS. Using base mode...\n");
@@ -4986,14 +5370,16 @@ static int patch_alc882(struct hda_codec *codec)
4986 spec->stream_digital_playback = &alc882_pcm_digital_playback; 5370 spec->stream_digital_playback = &alc882_pcm_digital_playback;
4987 spec->stream_digital_capture = &alc882_pcm_digital_capture; 5371 spec->stream_digital_capture = &alc882_pcm_digital_capture;
4988 5372
4989 if (! spec->adc_nids && spec->input_mux) { 5373 if (!spec->adc_nids && spec->input_mux) {
4990 /* check whether NID 0x07 is valid */ 5374 /* check whether NID 0x07 is valid */
4991 unsigned int wcap = get_wcaps(codec, 0x07); 5375 unsigned int wcap = get_wcaps(codec, 0x07);
4992 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 5376 /* get type */
5377 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
4993 if (wcap != AC_WID_AUD_IN) { 5378 if (wcap != AC_WID_AUD_IN) {
4994 spec->adc_nids = alc882_adc_nids_alt; 5379 spec->adc_nids = alc882_adc_nids_alt;
4995 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); 5380 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
4996 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer; 5381 spec->mixers[spec->num_mixers] =
5382 alc882_capture_alt_mixer;
4997 spec->num_mixers++; 5383 spec->num_mixers++;
4998 } else { 5384 } else {
4999 spec->adc_nids = alc882_adc_nids; 5385 spec->adc_nids = alc882_adc_nids;
@@ -5033,6 +5419,7 @@ static hda_nid_t alc883_adc_nids[2] = {
5033 /* ADC1-2 */ 5419 /* ADC1-2 */
5034 0x08, 0x09, 5420 0x08, 0x09,
5035}; 5421};
5422
5036/* input MUX */ 5423/* input MUX */
5037/* FIXME: should be a matrix-type input source selection */ 5424/* FIXME: should be a matrix-type input source selection */
5038 5425
@@ -5045,6 +5432,15 @@ static struct hda_input_mux alc883_capture_source = {
5045 { "CD", 0x4 }, 5432 { "CD", 0x4 },
5046 }, 5433 },
5047}; 5434};
5435
5436static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5437 .num_items = 2,
5438 .items = {
5439 { "Mic", 0x1 },
5440 { "Line", 0x2 },
5441 },
5442};
5443
5048#define alc883_mux_enum_info alc_mux_enum_info 5444#define alc883_mux_enum_info alc_mux_enum_info
5049#define alc883_mux_enum_get alc_mux_enum_get 5445#define alc883_mux_enum_get alc_mux_enum_get
5050 5446
@@ -5063,7 +5459,7 @@ static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5063 idx = ucontrol->value.enumerated.item[0]; 5459 idx = ucontrol->value.enumerated.item[0];
5064 if (idx >= imux->num_items) 5460 if (idx >= imux->num_items)
5065 idx = imux->num_items - 1; 5461 idx = imux->num_items - 1;
5066 if (*cur_val == idx && ! codec->in_resume) 5462 if (*cur_val == idx && !codec->in_resume)
5067 return 0; 5463 return 0;
5068 for (i = 0; i < imux->num_items; i++) { 5464 for (i = 0; i < imux->num_items; i++) {
5069 unsigned int v = (i == idx) ? 0x7000 : 0x7080; 5465 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
@@ -5073,6 +5469,7 @@ static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5073 *cur_val = idx; 5469 *cur_val = idx;
5074 return 1; 5470 return 1;
5075} 5471}
5472
5076/* 5473/*
5077 * 2ch mode 5474 * 2ch mode
5078 */ 5475 */
@@ -5325,7 +5722,7 @@ static struct snd_kcontrol_new alc883_tagra_mixer[] = {
5325 .put = alc883_mux_enum_put, 5722 .put = alc883_mux_enum_put,
5326 }, 5723 },
5327 { } /* end */ 5724 { } /* end */
5328}; 5725};
5329 5726
5330static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = { 5727static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5331 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 5728 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -5350,7 +5747,30 @@ static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
5350 .put = alc883_mux_enum_put, 5747 .put = alc883_mux_enum_put,
5351 }, 5748 },
5352 { } /* end */ 5749 { } /* end */
5353}; 5750};
5751
5752static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
5753 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5754 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5755 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5756 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
5757 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5758 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5759 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5760 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5761 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5762 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5763 {
5764 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5765 /* .name = "Capture Source", */
5766 .name = "Input Source",
5767 .count = 1,
5768 .info = alc883_mux_enum_info,
5769 .get = alc883_mux_enum_get,
5770 .put = alc883_mux_enum_put,
5771 },
5772 { } /* end */
5773};
5354 5774
5355static struct snd_kcontrol_new alc883_chmode_mixer[] = { 5775static struct snd_kcontrol_new alc883_chmode_mixer[] = {
5356 { 5776 {
@@ -5452,10 +5872,17 @@ static struct hda_verb alc883_tagra_verbs[] = {
5452 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 5872 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5453 5873
5454 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 5874 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5455 {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 5875 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5456 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, 5876 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5457 {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, 5877 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5878
5879 { } /* end */
5880};
5458 5881
5882static struct hda_verb alc883_lenovo_101e_verbs[] = {
5883 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5884 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
5885 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
5459 { } /* end */ 5886 { } /* end */
5460}; 5887};
5461 5888
@@ -5463,14 +5890,17 @@ static struct hda_verb alc883_tagra_verbs[] = {
5463static void alc883_tagra_automute(struct hda_codec *codec) 5890static void alc883_tagra_automute(struct hda_codec *codec)
5464{ 5891{
5465 unsigned int present; 5892 unsigned int present;
5893 unsigned char bits;
5466 5894
5467 present = snd_hda_codec_read(codec, 0x14, 0, 5895 present = snd_hda_codec_read(codec, 0x14, 0,
5468 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 5896 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5897 bits = present ? 0x80 : 0;
5469 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0, 5898 snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
5470 0x80, present ? 0x80 : 0); 5899 0x80, bits);
5471 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0, 5900 snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
5472 0x80, present ? 0x80 : 0); 5901 0x80, bits);
5473 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3); 5902 snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5903 present ? 1 : 3);
5474} 5904}
5475 5905
5476static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res) 5906static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
@@ -5479,6 +5909,47 @@ static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
5479 alc883_tagra_automute(codec); 5909 alc883_tagra_automute(codec);
5480} 5910}
5481 5911
5912static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
5913{
5914 unsigned int present;
5915 unsigned char bits;
5916
5917 present = snd_hda_codec_read(codec, 0x14, 0,
5918 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5919 bits = present ? 0x80 : 0;
5920 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5921 0x80, bits);
5922 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5923 0x80, bits);
5924}
5925
5926static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
5927{
5928 unsigned int present;
5929 unsigned char bits;
5930
5931 present = snd_hda_codec_read(codec, 0x1b, 0,
5932 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5933 bits = present ? 0x80 : 0;
5934 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
5935 0x80, bits);
5936 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
5937 0x80, bits);
5938 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
5939 0x80, bits);
5940 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
5941 0x80, bits);
5942}
5943
5944static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
5945 unsigned int res)
5946{
5947 if ((res >> 26) == ALC880_HP_EVENT)
5948 alc883_lenovo_101e_all_automute(codec);
5949 if ((res >> 26) == ALC880_FRONT_EVENT)
5950 alc883_lenovo_101e_ispeaker_automute(codec);
5951}
5952
5482/* 5953/*
5483 * generic initialization of ADC, input mixers and output mixers 5954 * generic initialization of ADC, input mixers and output mixers
5484 */ 5955 */
@@ -5493,8 +5964,8 @@ static struct hda_verb alc883_auto_init_verbs[] = {
5493 5964
5494 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 5965 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5495 * mixer widget 5966 * mixer widget
5496 * Note: PASD motherboards uses the Line In 2 as the input for front panel 5967 * Note: PASD motherboards uses the Line In 2 as the input for
5497 * mic (mic 2) 5968 * front panel mic (mic 2)
5498 */ 5969 */
5499 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 5970 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 5971 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -5530,13 +6001,13 @@ static struct hda_verb alc883_auto_init_verbs[] = {
5530 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6001 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5531 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6002 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5532 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 6003 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5533 //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 6004 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
5534 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 6005 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5535 /* Input mixer2 */ 6006 /* Input mixer2 */
5536 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6007 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5537 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 6008 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5538 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 6009 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
5539 //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 6010 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
5540 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 6011 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
5541 6012
5542 { } 6013 { }
@@ -5584,6 +6055,7 @@ static const char *alc883_models[ALC883_MODEL_LAST] = {
5584 [ALC883_ACER] = "acer", 6055 [ALC883_ACER] = "acer",
5585 [ALC883_MEDION] = "medion", 6056 [ALC883_MEDION] = "medion",
5586 [ALC883_LAPTOP_EAPD] = "laptop-eapd", 6057 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
6058 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
5587 [ALC883_AUTO] = "auto", 6059 [ALC883_AUTO] = "auto",
5588}; 6060};
5589 6061
@@ -5592,6 +6064,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
5592 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch), 6064 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
5593 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), 6065 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
5594 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG), 6066 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
6067 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
5595 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG), 6068 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
5596 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG), 6069 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
5597 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG), 6070 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
@@ -5609,6 +6082,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
5609 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), 6082 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
5610 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD), 6083 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
5611 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), 6084 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
6085 SND_PCI_QUIRK(0x17aa, 0x101e, "lenovo 101e", ALC883_LENOVO_101E_2ch),
5612 {} 6086 {}
5613}; 6087};
5614 6088
@@ -5639,7 +6113,7 @@ static struct alc_config_preset alc883_presets[] = {
5639 .channel_mode = alc883_3ST_6ch_modes, 6113 .channel_mode = alc883_3ST_6ch_modes,
5640 .need_dac_fix = 1, 6114 .need_dac_fix = 1,
5641 .input_mux = &alc883_capture_source, 6115 .input_mux = &alc883_capture_source,
5642 }, 6116 },
5643 [ALC883_3ST_6ch] = { 6117 [ALC883_3ST_6ch] = {
5644 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer }, 6118 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
5645 .init_verbs = { alc883_init_verbs }, 6119 .init_verbs = { alc883_init_verbs },
@@ -5651,7 +6125,7 @@ static struct alc_config_preset alc883_presets[] = {
5651 .channel_mode = alc883_3ST_6ch_modes, 6125 .channel_mode = alc883_3ST_6ch_modes,
5652 .need_dac_fix = 1, 6126 .need_dac_fix = 1,
5653 .input_mux = &alc883_capture_source, 6127 .input_mux = &alc883_capture_source,
5654 }, 6128 },
5655 [ALC883_6ST_DIG] = { 6129 [ALC883_6ST_DIG] = {
5656 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 6130 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
5657 .init_verbs = { alc883_init_verbs }, 6131 .init_verbs = { alc883_init_verbs },
@@ -5749,6 +6223,19 @@ static struct alc_config_preset alc883_presets[] = {
5749 .channel_mode = alc883_3ST_2ch_modes, 6223 .channel_mode = alc883_3ST_2ch_modes,
5750 .input_mux = &alc883_capture_source, 6224 .input_mux = &alc883_capture_source,
5751 }, 6225 },
6226 [ALC883_LENOVO_101E_2ch] = {
6227 .mixers = { alc883_lenovo_101e_2ch_mixer},
6228 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6229 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6230 .dac_nids = alc883_dac_nids,
6231 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6232 .adc_nids = alc883_adc_nids,
6233 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6234 .channel_mode = alc883_3ST_2ch_modes,
6235 .input_mux = &alc883_lenovo_101e_capture_source,
6236 .unsol_event = alc883_lenovo_101e_unsol_event,
6237 .init_hook = alc883_lenovo_101e_all_automute,
6238 },
5752}; 6239};
5753 6240
5754 6241
@@ -5761,8 +6248,8 @@ static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
5761{ 6248{
5762 /* set as output */ 6249 /* set as output */
5763 struct alc_spec *spec = codec->spec; 6250 struct alc_spec *spec = codec->spec;
5764 int idx; 6251 int idx;
5765 6252
5766 if (spec->multiout.dac_nids[dac_idx] == 0x25) 6253 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5767 idx = 4; 6254 idx = 4;
5768 else 6255 else
@@ -5781,10 +6268,13 @@ static void alc883_auto_init_multi_out(struct hda_codec *codec)
5781 struct alc_spec *spec = codec->spec; 6268 struct alc_spec *spec = codec->spec;
5782 int i; 6269 int i;
5783 6270
6271 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
5784 for (i = 0; i <= HDA_SIDE; i++) { 6272 for (i = 0; i <= HDA_SIDE; i++) {
5785 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 6273 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6274 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5786 if (nid) 6275 if (nid)
5787 alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); 6276 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
6277 i);
5788 } 6278 }
5789} 6279}
5790 6280
@@ -5833,8 +6323,8 @@ static int alc883_parse_auto_config(struct hda_codec *codec)
5833 else if (err > 0) 6323 else if (err > 0)
5834 /* hack - override the init verbs */ 6324 /* hack - override the init verbs */
5835 spec->init_verbs[0] = alc883_auto_init_verbs; 6325 spec->init_verbs[0] = alc883_auto_init_verbs;
5836 spec->mixers[spec->num_mixers] = alc883_capture_mixer; 6326 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
5837 spec->num_mixers++; 6327 spec->num_mixers++;
5838 return err; 6328 return err;
5839} 6329}
5840 6330
@@ -5872,7 +6362,7 @@ static int patch_alc883(struct hda_codec *codec)
5872 if (err < 0) { 6362 if (err < 0) {
5873 alc_free(codec); 6363 alc_free(codec);
5874 return err; 6364 return err;
5875 } else if (! err) { 6365 } else if (!err) {
5876 printk(KERN_INFO 6366 printk(KERN_INFO
5877 "hda_codec: Cannot set up configuration " 6367 "hda_codec: Cannot set up configuration "
5878 "from BIOS. Using base mode...\n"); 6368 "from BIOS. Using base mode...\n");
@@ -5891,7 +6381,7 @@ static int patch_alc883(struct hda_codec *codec)
5891 spec->stream_digital_playback = &alc883_pcm_digital_playback; 6381 spec->stream_digital_playback = &alc883_pcm_digital_playback;
5892 spec->stream_digital_capture = &alc883_pcm_digital_capture; 6382 spec->stream_digital_capture = &alc883_pcm_digital_capture;
5893 6383
5894 if (! spec->adc_nids && spec->input_mux) { 6384 if (!spec->adc_nids && spec->input_mux) {
5895 spec->adc_nids = alc883_adc_nids; 6385 spec->adc_nids = alc883_adc_nids;
5896 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids); 6386 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
5897 } 6387 }
@@ -6028,8 +6518,8 @@ static struct hda_verb alc262_init_verbs[] = {
6028 6518
6029 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 6519 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6030 * mixer widget 6520 * mixer widget
6031 * Note: PASD motherboards uses the Line In 2 as the input for front panel 6521 * Note: PASD motherboards uses the Line In 2 as the input for
6032 * mic (mic 2) 6522 * front panel mic (mic 2)
6033 */ 6523 */
6034 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 6524 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6035 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6525 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -6086,7 +6576,7 @@ static struct hda_verb alc262_init_verbs[] = {
6086 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 6576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 6577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 6578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 6579 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6090 6580
6091 { } 6581 { }
6092}; 6582};
@@ -6113,7 +6603,7 @@ static void alc262_hippo_automute(struct hda_codec *codec, int force)
6113 struct alc_spec *spec = codec->spec; 6603 struct alc_spec *spec = codec->spec;
6114 unsigned int mute; 6604 unsigned int mute;
6115 6605
6116 if (force || ! spec->sense_updated) { 6606 if (force || !spec->sense_updated) {
6117 unsigned int present; 6607 unsigned int present;
6118 /* need to execute and sync at first */ 6608 /* need to execute and sync at first */
6119 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0); 6609 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
@@ -6153,7 +6643,7 @@ static void alc262_hippo1_automute(struct hda_codec *codec, int force)
6153 struct alc_spec *spec = codec->spec; 6643 struct alc_spec *spec = codec->spec;
6154 unsigned int mute; 6644 unsigned int mute;
6155 6645
6156 if (force || ! spec->sense_updated) { 6646 if (force || !spec->sense_updated) {
6157 unsigned int present; 6647 unsigned int present;
6158 /* need to execute and sync at first */ 6648 /* need to execute and sync at first */
6159 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0); 6649 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
@@ -6226,7 +6716,7 @@ static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
6226 struct alc_spec *spec = codec->spec; 6716 struct alc_spec *spec = codec->spec;
6227 unsigned int mute; 6717 unsigned int mute;
6228 6718
6229 if (force || ! spec->sense_updated) { 6719 if (force || !spec->sense_updated) {
6230 unsigned int present; 6720 unsigned int present;
6231 /* need to execute and sync at first */ 6721 /* need to execute and sync at first */
6232 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0); 6722 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
@@ -6331,7 +6821,8 @@ static struct hda_verb alc262_EAPD_verbs[] = {
6331}; 6821};
6332 6822
6333/* add playback controls from the parsed DAC table */ 6823/* add playback controls from the parsed DAC table */
6334static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 6824static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
6825 const struct auto_pin_cfg *cfg)
6335{ 6826{
6336 hda_nid_t nid; 6827 hda_nid_t nid;
6337 int err; 6828 int err;
@@ -6342,26 +6833,39 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct
6342 6833
6343 nid = cfg->line_out_pins[0]; 6834 nid = cfg->line_out_pins[0];
6344 if (nid) { 6835 if (nid) {
6345 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume", 6836 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6346 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0) 6837 "Front Playback Volume",
6838 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
6839 if (err < 0)
6347 return err; 6840 return err;
6348 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch", 6841 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6349 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 6842 "Front Playback Switch",
6843 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
6844 if (err < 0)
6350 return err; 6845 return err;
6351 } 6846 }
6352 6847
6353 nid = cfg->speaker_pins[0]; 6848 nid = cfg->speaker_pins[0];
6354 if (nid) { 6849 if (nid) {
6355 if (nid == 0x16) { 6850 if (nid == 0x16) {
6356 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume", 6851 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6357 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) 6852 "Speaker Playback Volume",
6853 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
6854 HDA_OUTPUT));
6855 if (err < 0)
6358 return err; 6856 return err;
6359 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", 6857 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6360 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 6858 "Speaker Playback Switch",
6859 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
6860 HDA_OUTPUT));
6861 if (err < 0)
6361 return err; 6862 return err;
6362 } else { 6863 } else {
6363 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", 6864 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6364 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 6865 "Speaker Playback Switch",
6866 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
6867 HDA_OUTPUT));
6868 if (err < 0)
6365 return err; 6869 return err;
6366 } 6870 }
6367 } 6871 }
@@ -6369,23 +6873,33 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct
6369 if (nid) { 6873 if (nid) {
6370 /* spec->multiout.hp_nid = 2; */ 6874 /* spec->multiout.hp_nid = 2; */
6371 if (nid == 0x16) { 6875 if (nid == 0x16) {
6372 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume", 6876 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6373 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) 6877 "Headphone Playback Volume",
6878 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
6879 HDA_OUTPUT));
6880 if (err < 0)
6374 return err; 6881 return err;
6375 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 6882 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6376 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 6883 "Headphone Playback Switch",
6884 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
6885 HDA_OUTPUT));
6886 if (err < 0)
6377 return err; 6887 return err;
6378 } else { 6888 } else {
6379 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 6889 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
6380 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 6890 "Headphone Playback Switch",
6891 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
6892 HDA_OUTPUT));
6893 if (err < 0)
6381 return err; 6894 return err;
6382 } 6895 }
6383 } 6896 }
6384 return 0; 6897 return 0;
6385} 6898}
6386 6899
6387/* identical with ALC880 */ 6900/* identical with ALC880 */
6388#define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls 6901#define alc262_auto_create_analog_input_ctls \
6902 alc880_auto_create_analog_input_ctls
6389 6903
6390/* 6904/*
6391 * generic initialization of ADC, input mixers and output mixers 6905 * generic initialization of ADC, input mixers and output mixers
@@ -6403,8 +6917,8 @@ static struct hda_verb alc262_volume_init_verbs[] = {
6403 6917
6404 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 6918 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6405 * mixer widget 6919 * mixer widget
6406 * Note: PASD motherboards uses the Line In 2 as the input for front panel 6920 * Note: PASD motherboards uses the Line In 2 as the input for
6407 * mic (mic 2) 6921 * front panel mic (mic 2)
6408 */ 6922 */
6409 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 6923 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6410 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6924 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -6464,8 +6978,8 @@ static struct hda_verb alc262_HP_BPC_init_verbs[] = {
6464 6978
6465 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 6979 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6466 * mixer widget 6980 * mixer widget
6467 * Note: PASD motherboards uses the Line In 2 as the input for front panel 6981 * Note: PASD motherboards uses the Line In 2 as the input for
6468 * mic (mic 2) 6982 * front panel mic (mic 2)
6469 */ 6983 */
6470 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 6984 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6471 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 6985 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -6647,13 +7161,17 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
6647 int err; 7161 int err;
6648 static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; 7162 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
6649 7163
6650 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 7164 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6651 alc262_ignore)) < 0) 7165 alc262_ignore);
7166 if (err < 0)
6652 return err; 7167 return err;
6653 if (! spec->autocfg.line_outs) 7168 if (!spec->autocfg.line_outs)
6654 return 0; /* can't find valid BIOS pin config */ 7169 return 0; /* can't find valid BIOS pin config */
6655 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 7170 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
6656 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 7171 if (err < 0)
7172 return err;
7173 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7174 if (err < 0)
6657 return err; 7175 return err;
6658 7176
6659 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 7177 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -6777,7 +7295,7 @@ static struct alc_config_preset alc262_presets[] = {
6777 .num_channel_mode = ARRAY_SIZE(alc262_modes), 7295 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6778 .channel_mode = alc262_modes, 7296 .channel_mode = alc262_modes,
6779 .input_mux = &alc262_HP_capture_source, 7297 .input_mux = &alc262_HP_capture_source,
6780 }, 7298 },
6781 [ALC262_HP_BPC_D7000_WF] = { 7299 [ALC262_HP_BPC_D7000_WF] = {
6782 .mixers = { alc262_HP_BPC_WildWest_mixer }, 7300 .mixers = { alc262_HP_BPC_WildWest_mixer },
6783 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs }, 7301 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
@@ -6787,7 +7305,7 @@ static struct alc_config_preset alc262_presets[] = {
6787 .num_channel_mode = ARRAY_SIZE(alc262_modes), 7305 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6788 .channel_mode = alc262_modes, 7306 .channel_mode = alc262_modes,
6789 .input_mux = &alc262_HP_capture_source, 7307 .input_mux = &alc262_HP_capture_source,
6790 }, 7308 },
6791 [ALC262_HP_BPC_D7000_WL] = { 7309 [ALC262_HP_BPC_D7000_WL] = {
6792 .mixers = { alc262_HP_BPC_WildWest_mixer, 7310 .mixers = { alc262_HP_BPC_WildWest_mixer,
6793 alc262_HP_BPC_WildWest_option_mixer }, 7311 alc262_HP_BPC_WildWest_option_mixer },
@@ -6798,7 +7316,7 @@ static struct alc_config_preset alc262_presets[] = {
6798 .num_channel_mode = ARRAY_SIZE(alc262_modes), 7316 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6799 .channel_mode = alc262_modes, 7317 .channel_mode = alc262_modes,
6800 .input_mux = &alc262_HP_capture_source, 7318 .input_mux = &alc262_HP_capture_source,
6801 }, 7319 },
6802 [ALC262_BENQ_ED8] = { 7320 [ALC262_BENQ_ED8] = {
6803 .mixers = { alc262_base_mixer }, 7321 .mixers = { alc262_base_mixer },
6804 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs }, 7322 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
@@ -6808,7 +7326,7 @@ static struct alc_config_preset alc262_presets[] = {
6808 .num_channel_mode = ARRAY_SIZE(alc262_modes), 7326 .num_channel_mode = ARRAY_SIZE(alc262_modes),
6809 .channel_mode = alc262_modes, 7327 .channel_mode = alc262_modes,
6810 .input_mux = &alc262_capture_source, 7328 .input_mux = &alc262_capture_source,
6811 }, 7329 },
6812}; 7330};
6813 7331
6814static int patch_alc262(struct hda_codec *codec) 7332static int patch_alc262(struct hda_codec *codec)
@@ -6823,7 +7341,9 @@ static int patch_alc262(struct hda_codec *codec)
6823 7341
6824 codec->spec = spec; 7342 codec->spec = spec;
6825#if 0 7343#if 0
6826 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */ 7344 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
7345 * under-run
7346 */
6827 { 7347 {
6828 int tmp; 7348 int tmp;
6829 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); 7349 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
@@ -6849,7 +7369,7 @@ static int patch_alc262(struct hda_codec *codec)
6849 if (err < 0) { 7369 if (err < 0) {
6850 alc_free(codec); 7370 alc_free(codec);
6851 return err; 7371 return err;
6852 } else if (! err) { 7372 } else if (!err) {
6853 printk(KERN_INFO 7373 printk(KERN_INFO
6854 "hda_codec: Cannot set up configuration " 7374 "hda_codec: Cannot set up configuration "
6855 "from BIOS. Using base mode...\n"); 7375 "from BIOS. Using base mode...\n");
@@ -6868,15 +7388,17 @@ static int patch_alc262(struct hda_codec *codec)
6868 spec->stream_digital_playback = &alc262_pcm_digital_playback; 7388 spec->stream_digital_playback = &alc262_pcm_digital_playback;
6869 spec->stream_digital_capture = &alc262_pcm_digital_capture; 7389 spec->stream_digital_capture = &alc262_pcm_digital_capture;
6870 7390
6871 if (! spec->adc_nids && spec->input_mux) { 7391 if (!spec->adc_nids && spec->input_mux) {
6872 /* check whether NID 0x07 is valid */ 7392 /* check whether NID 0x07 is valid */
6873 unsigned int wcap = get_wcaps(codec, 0x07); 7393 unsigned int wcap = get_wcaps(codec, 0x07);
6874 7394
6875 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 7395 /* get type */
7396 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6876 if (wcap != AC_WID_AUD_IN) { 7397 if (wcap != AC_WID_AUD_IN) {
6877 spec->adc_nids = alc262_adc_nids_alt; 7398 spec->adc_nids = alc262_adc_nids_alt;
6878 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); 7399 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
6879 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer; 7400 spec->mixers[spec->num_mixers] =
7401 alc262_capture_alt_mixer;
6880 spec->num_mixers++; 7402 spec->num_mixers++;
6881 } else { 7403 } else {
6882 spec->adc_nids = alc262_adc_nids; 7404 spec->adc_nids = alc262_adc_nids;
@@ -6904,7 +7426,9 @@ static int patch_alc262(struct hda_codec *codec)
6904static struct hda_verb alc861_threestack_ch2_init[] = { 7426static struct hda_verb alc861_threestack_ch2_init[] = {
6905 /* set pin widget 1Ah (line in) for input */ 7427 /* set pin widget 1Ah (line in) for input */
6906 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 7428 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6907 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */ 7429 /* set pin widget 18h (mic1/2) for input, for mic also enable
7430 * the vref
7431 */
6908 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 7432 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6909 7433
6910 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, 7434 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
@@ -6961,7 +7485,9 @@ static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
6961static struct hda_verb alc861_asus_ch2_init[] = { 7485static struct hda_verb alc861_asus_ch2_init[] = {
6962 /* set pin widget 1Ah (line in) for input */ 7486 /* set pin widget 1Ah (line in) for input */
6963 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 7487 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
6964 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */ 7488 /* set pin widget 18h (mic1/2) for input, for mic also enable
7489 * the vref
7490 */
6965 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 7491 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
6966 7492
6967 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, 7493 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
@@ -7016,7 +7542,7 @@ static struct snd_kcontrol_new alc861_base_mixer[] = {
7016 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 7542 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7017 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 7543 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7018 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 7544 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7019 7545
7020 /* Capture mixer control */ 7546 /* Capture mixer control */
7021 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7547 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7022 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7548 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7050,7 +7576,7 @@ static struct snd_kcontrol_new alc861_3ST_mixer[] = {
7050 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 7576 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7051 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 7577 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7052 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 7578 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7053 7579
7054 /* Capture mixer control */ 7580 /* Capture mixer control */
7055 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7581 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7056 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7582 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7092,7 +7618,7 @@ static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
7092 }, 7618 },
7093 7619
7094 { } /* end */ 7620 { } /* end */
7095}; 7621};
7096 7622
7097static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = { 7623static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
7098 /* output mixer control */ 7624 /* output mixer control */
@@ -7113,7 +7639,7 @@ static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
7113 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 7639 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7114 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 7640 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7115 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 7641 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
7116 7642
7117 /* Capture mixer control */ 7643 /* Capture mixer control */
7118 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7644 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7119 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7645 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7134,7 +7660,7 @@ static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
7134 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes), 7660 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
7135 }, 7661 },
7136 { } /* end */ 7662 { } /* end */
7137}; 7663};
7138 7664
7139static struct snd_kcontrol_new alc861_asus_mixer[] = { 7665static struct snd_kcontrol_new alc861_asus_mixer[] = {
7140 /* output mixer control */ 7666 /* output mixer control */
@@ -7154,8 +7680,8 @@ static struct snd_kcontrol_new alc861_asus_mixer[] = {
7154 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), 7680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
7155 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 7681 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
7156 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 7682 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
7157 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */ 7683 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
7158 7684
7159 /* Capture mixer control */ 7685 /* Capture mixer control */
7160 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 7686 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7161 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 7687 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
@@ -7239,7 +7765,7 @@ static struct hda_verb alc861_base_init_verbs[] = {
7239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7765 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7766 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7241 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7767 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7242 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step 7768 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7243 7769
7244 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7770 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7245 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7771 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7249,7 +7775,8 @@ static struct hda_verb alc861_base_init_verbs[] = {
7249 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7250 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7776 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7251 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7777 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7252 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) 7778 /* hp used DAC 3 (Front) */
7779 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7253 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7780 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7254 7781
7255 { } 7782 { }
@@ -7300,7 +7827,7 @@ static struct hda_verb alc861_threestack_init_verbs[] = {
7300 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7827 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7301 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7828 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7302 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7829 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7303 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step 7830 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7304 7831
7305 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7832 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7306 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7833 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7310,7 +7837,8 @@ static struct hda_verb alc861_threestack_init_verbs[] = {
7310 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7837 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7311 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7838 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7312 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7839 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7313 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) 7840 /* hp used DAC 3 (Front) */
7841 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7842 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7315 { } 7843 { }
7316}; 7844};
@@ -7329,7 +7857,8 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7329 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 7857 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7330 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 7858 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7331 /* port-E for HP out (front panel) */ 7859 /* port-E for HP out (front panel) */
7332 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80 7860 /* this has to be set to VREF80 */
7861 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7333 /* route front PCM to HP */ 7862 /* route front PCM to HP */
7334 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 7863 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7335 /* port-F for mic-in (front panel) with vref */ 7864 /* port-F for mic-in (front panel) with vref */
@@ -7360,7 +7889,7 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7360 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7889 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7361 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7890 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7362 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7891 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7363 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step 7892 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7364 7893
7365 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7894 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7366 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7895 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7370,7 +7899,8 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
7370 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7899 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7371 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7900 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7372 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7901 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7373 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) 7902 /* hp used DAC 3 (Front) */
7903 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7374 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7904 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7375 { } 7905 { }
7376}; 7906};
@@ -7379,7 +7909,9 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7379 /* 7909 /*
7380 * Unmute ADC0 and set the default input to mic-in 7910 * Unmute ADC0 and set the default input to mic-in
7381 */ 7911 */
7382 /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/ 7912 /* port-A for surround (rear panel)
7913 * according to codec#0 this is the HP jack
7914 */
7383 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */ 7915 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
7384 /* route front PCM to HP */ 7916 /* route front PCM to HP */
7385 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 }, 7917 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
@@ -7391,7 +7923,8 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7391 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 7923 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
7392 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 7924 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
7393 /* port-E for HP out (front panel) */ 7925 /* port-E for HP out (front panel) */
7394 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */ 7926 /* this has to be set to VREF80 */
7927 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
7395 /* route front PCM to HP */ 7928 /* route front PCM to HP */
7396 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 7929 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
7397 /* port-F for mic-in (front panel) with vref */ 7930 /* port-F for mic-in (front panel) with vref */
@@ -7421,7 +7954,7 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7421 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7954 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7422 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7955 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7423 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7956 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7424 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, /* Output 0~12 step */ 7957 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
7425 7958
7426 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7959 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7427 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7960 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
@@ -7431,7 +7964,8 @@ static struct hda_verb alc861_asus_init_verbs[] = {
7431 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7964 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7432 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7965 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7433 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 7966 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7434 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */ 7967 /* hp used DAC 3 (Front) */
7968 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7435 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 7969 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7436 { } 7970 { }
7437}; 7971};
@@ -7450,7 +7984,7 @@ static struct hda_verb alc861_auto_init_verbs[] = {
7450 /* 7984 /*
7451 * Unmute ADC0 and set the default input to mic-in 7985 * Unmute ADC0 and set the default input to mic-in
7452 */ 7986 */
7453// {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 7987 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
7454 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 7988 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7455 7989
7456 /* Unmute DAC0~3 & spdif out*/ 7990 /* Unmute DAC0~3 & spdif out*/
@@ -7483,21 +8017,21 @@ static struct hda_verb alc861_auto_init_verbs[] = {
7483 8017
7484 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8018 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7485 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 8019 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7486 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 8020 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7487 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 8021 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7488 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 8022 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7489 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 8023 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7490 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 8024 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7491 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 8025 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7492 8026
7493 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1 8027 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
7494 8028
7495 { } 8029 { }
7496}; 8030};
7497 8031
7498static struct hda_verb alc861_toshiba_init_verbs[] = { 8032static struct hda_verb alc861_toshiba_init_verbs[] = {
7499 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT}, 8033 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7500 8034
7501 { } 8035 { }
7502}; 8036};
7503 8037
@@ -7521,9 +8055,6 @@ static void alc861_toshiba_automute(struct hda_codec *codec)
7521static void alc861_toshiba_unsol_event(struct hda_codec *codec, 8055static void alc861_toshiba_unsol_event(struct hda_codec *codec,
7522 unsigned int res) 8056 unsigned int res)
7523{ 8057{
7524 /* Looks like the unsol event is incompatible with the standard
7525 * definition. 6bit tag is placed at 26 bit!
7526 */
7527 if ((res >> 26) == ALC880_HP_EVENT) 8058 if ((res >> 26) == ALC880_HP_EVENT)
7528 alc861_toshiba_automute(codec); 8059 alc861_toshiba_automute(codec);
7529} 8060}
@@ -7568,7 +8099,8 @@ static struct hda_input_mux alc861_capture_source = {
7568}; 8099};
7569 8100
7570/* fill in the dac_nids table from the parsed pin configuration */ 8101/* fill in the dac_nids table from the parsed pin configuration */
7571static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 8102static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
8103 const struct auto_pin_cfg *cfg)
7572{ 8104{
7573 int i; 8105 int i;
7574 hda_nid_t nid; 8106 hda_nid_t nid;
@@ -7591,29 +8123,40 @@ static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
7591 const struct auto_pin_cfg *cfg) 8123 const struct auto_pin_cfg *cfg)
7592{ 8124{
7593 char name[32]; 8125 char name[32];
7594 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; 8126 static const char *chname[4] = {
8127 "Front", "Surround", NULL /*CLFE*/, "Side"
8128 };
7595 hda_nid_t nid; 8129 hda_nid_t nid;
7596 int i, idx, err; 8130 int i, idx, err;
7597 8131
7598 for (i = 0; i < cfg->line_outs; i++) { 8132 for (i = 0; i < cfg->line_outs; i++) {
7599 nid = spec->multiout.dac_nids[i]; 8133 nid = spec->multiout.dac_nids[i];
7600 if (! nid) 8134 if (!nid)
7601 continue; 8135 continue;
7602 if (nid == 0x05) { 8136 if (nid == 0x05) {
7603 /* Center/LFE */ 8137 /* Center/LFE */
7604 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", 8138 err = add_control(spec, ALC_CTL_BIND_MUTE,
7605 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) 8139 "Center Playback Switch",
8140 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
8141 HDA_OUTPUT));
8142 if (err < 0)
7606 return err; 8143 return err;
7607 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", 8144 err = add_control(spec, ALC_CTL_BIND_MUTE,
7608 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 8145 "LFE Playback Switch",
8146 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8147 HDA_OUTPUT));
8148 if (err < 0)
7609 return err; 8149 return err;
7610 } else { 8150 } else {
7611 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++) 8151 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
8152 idx++)
7612 if (nid == alc861_dac_nids[idx]) 8153 if (nid == alc861_dac_nids[idx])
7613 break; 8154 break;
7614 sprintf(name, "%s Playback Switch", chname[idx]); 8155 sprintf(name, "%s Playback Switch", chname[idx]);
7615 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 8156 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
7616 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 8157 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8158 HDA_OUTPUT));
8159 if (err < 0)
7617 return err; 8160 return err;
7618 } 8161 }
7619 } 8162 }
@@ -7625,13 +8168,15 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
7625 int err; 8168 int err;
7626 hda_nid_t nid; 8169 hda_nid_t nid;
7627 8170
7628 if (! pin) 8171 if (!pin)
7629 return 0; 8172 return 0;
7630 8173
7631 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { 8174 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
7632 nid = 0x03; 8175 nid = 0x03;
7633 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 8176 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7634 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 8177 "Headphone Playback Switch",
8178 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8179 if (err < 0)
7635 return err; 8180 return err;
7636 spec->multiout.hp_nid = nid; 8181 spec->multiout.hp_nid = nid;
7637 } 8182 }
@@ -7639,32 +8184,33 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
7639} 8184}
7640 8185
7641/* create playback/capture controls for input pins */ 8186/* create playback/capture controls for input pins */
7642static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 8187static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
8188 const struct auto_pin_cfg *cfg)
7643{ 8189{
7644 struct hda_input_mux *imux = &spec->private_imux; 8190 struct hda_input_mux *imux = &spec->private_imux;
7645 int i, err, idx, idx1; 8191 int i, err, idx, idx1;
7646 8192
7647 for (i = 0; i < AUTO_PIN_LAST; i++) { 8193 for (i = 0; i < AUTO_PIN_LAST; i++) {
7648 switch(cfg->input_pins[i]) { 8194 switch (cfg->input_pins[i]) {
7649 case 0x0c: 8195 case 0x0c:
7650 idx1 = 1; 8196 idx1 = 1;
7651 idx = 2; // Line In 8197 idx = 2; /* Line In */
7652 break; 8198 break;
7653 case 0x0f: 8199 case 0x0f:
7654 idx1 = 2; 8200 idx1 = 2;
7655 idx = 2; // Line In 8201 idx = 2; /* Line In */
7656 break; 8202 break;
7657 case 0x0d: 8203 case 0x0d:
7658 idx1 = 0; 8204 idx1 = 0;
7659 idx = 1; // Mic In 8205 idx = 1; /* Mic In */
7660 break; 8206 break;
7661 case 0x10: 8207 case 0x10:
7662 idx1 = 3; 8208 idx1 = 3;
7663 idx = 1; // Mic In 8209 idx = 1; /* Mic In */
7664 break; 8210 break;
7665 case 0x11: 8211 case 0x11:
7666 idx1 = 4; 8212 idx1 = 4;
7667 idx = 0; // CD 8213 idx = 0; /* CD */
7668 break; 8214 break;
7669 default: 8215 default:
7670 continue; 8216 continue;
@@ -7677,7 +8223,7 @@ static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const str
7677 8223
7678 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 8224 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
7679 imux->items[imux->num_items].index = idx1; 8225 imux->items[imux->num_items].index = idx1;
7680 imux->num_items++; 8226 imux->num_items++;
7681 } 8227 }
7682 return 0; 8228 return 0;
7683} 8229}
@@ -7702,13 +8248,16 @@ static struct snd_kcontrol_new alc861_capture_mixer[] = {
7702 { } /* end */ 8248 { } /* end */
7703}; 8249};
7704 8250
7705static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, 8251static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
8252 hda_nid_t nid,
7706 int pin_type, int dac_idx) 8253 int pin_type, int dac_idx)
7707{ 8254{
7708 /* set as output */ 8255 /* set as output */
7709 8256
7710 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 8257 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7711 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 8258 pin_type);
8259 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8260 AMP_OUT_UNMUTE);
7712 8261
7713} 8262}
7714 8263
@@ -7717,10 +8266,13 @@ static void alc861_auto_init_multi_out(struct hda_codec *codec)
7717 struct alc_spec *spec = codec->spec; 8266 struct alc_spec *spec = codec->spec;
7718 int i; 8267 int i;
7719 8268
8269 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
7720 for (i = 0; i < spec->autocfg.line_outs; i++) { 8270 for (i = 0; i < spec->autocfg.line_outs; i++) {
7721 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 8271 hda_nid_t nid = spec->autocfg.line_out_pins[i];
8272 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7722 if (nid) 8273 if (nid)
7723 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]); 8274 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
8275 spec->multiout.dac_nids[i]);
7724 } 8276 }
7725} 8277}
7726 8278
@@ -7731,7 +8283,8 @@ static void alc861_auto_init_hp_out(struct hda_codec *codec)
7731 8283
7732 pin = spec->autocfg.hp_pins[0]; 8284 pin = spec->autocfg.hp_pins[0];
7733 if (pin) /* connect to front */ 8285 if (pin) /* connect to front */
7734 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]); 8286 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
8287 spec->multiout.dac_nids[0]);
7735} 8288}
7736 8289
7737static void alc861_auto_init_analog_input(struct hda_codec *codec) 8290static void alc861_auto_init_analog_input(struct hda_codec *codec)
@@ -7741,31 +8294,43 @@ static void alc861_auto_init_analog_input(struct hda_codec *codec)
7741 8294
7742 for (i = 0; i < AUTO_PIN_LAST; i++) { 8295 for (i = 0; i < AUTO_PIN_LAST; i++) {
7743 hda_nid_t nid = spec->autocfg.input_pins[i]; 8296 hda_nid_t nid = spec->autocfg.input_pins[i];
7744 if ((nid>=0x0c) && (nid <=0x11)) { 8297 if (nid >= 0x0c && nid <= 0x11) {
7745 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 8298 snd_hda_codec_write(codec, nid, 0,
7746 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 8299 AC_VERB_SET_PIN_WIDGET_CONTROL,
8300 i <= AUTO_PIN_FRONT_MIC ?
8301 PIN_VREF80 : PIN_IN);
7747 } 8302 }
7748 } 8303 }
7749} 8304}
7750 8305
7751/* parse the BIOS configuration and set up the alc_spec */ 8306/* parse the BIOS configuration and set up the alc_spec */
7752/* return 1 if successful, 0 if the proper config is not found, or a negative error code */ 8307/* return 1 if successful, 0 if the proper config is not found,
8308 * or a negative error code
8309 */
7753static int alc861_parse_auto_config(struct hda_codec *codec) 8310static int alc861_parse_auto_config(struct hda_codec *codec)
7754{ 8311{
7755 struct alc_spec *spec = codec->spec; 8312 struct alc_spec *spec = codec->spec;
7756 int err; 8313 int err;
7757 static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; 8314 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
7758 8315
7759 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 8316 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7760 alc861_ignore)) < 0) 8317 alc861_ignore);
8318 if (err < 0)
7761 return err; 8319 return err;
7762 if (! spec->autocfg.line_outs) 8320 if (!spec->autocfg.line_outs)
7763 return 0; /* can't find valid BIOS pin config */ 8321 return 0; /* can't find valid BIOS pin config */
7764 8322
7765 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 8323 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
7766 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 8324 if (err < 0)
7767 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 || 8325 return err;
7768 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 8326 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
8327 if (err < 0)
8328 return err;
8329 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
8330 if (err < 0)
8331 return err;
8332 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
8333 if (err < 0)
7769 return err; 8334 return err;
7770 8335
7771 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 8336 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -7817,12 +8382,14 @@ static struct snd_pci_quirk alc861_cfg_tbl[] = {
7817 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST), 8382 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
7818 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP), 8383 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
7819 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP), 8384 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
8385 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
7820 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS), 8386 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
7821 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST), 8387 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST),
7822 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA), 8388 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
7823 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), 8389 SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
7824 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31), 8390 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
7825 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31), 8391 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
8392 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
7826 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST), 8393 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
7827 {} 8394 {}
7828}; 8395};
@@ -7892,7 +8459,8 @@ static struct alc_config_preset alc861_presets[] = {
7892 }, 8459 },
7893 [ALC861_TOSHIBA] = { 8460 [ALC861_TOSHIBA] = {
7894 .mixers = { alc861_toshiba_mixer }, 8461 .mixers = { alc861_toshiba_mixer },
7895 .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs }, 8462 .init_verbs = { alc861_base_init_verbs,
8463 alc861_toshiba_init_verbs },
7896 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 8464 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
7897 .dac_nids = alc861_dac_nids, 8465 .dac_nids = alc861_dac_nids,
7898 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes), 8466 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
@@ -7944,7 +8512,7 @@ static int patch_alc861(struct hda_codec *codec)
7944 if (spec == NULL) 8512 if (spec == NULL)
7945 return -ENOMEM; 8513 return -ENOMEM;
7946 8514
7947 codec->spec = spec; 8515 codec->spec = spec;
7948 8516
7949 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST, 8517 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
7950 alc861_models, 8518 alc861_models,
@@ -7962,7 +8530,7 @@ static int patch_alc861(struct hda_codec *codec)
7962 if (err < 0) { 8530 if (err < 0) {
7963 alc_free(codec); 8531 alc_free(codec);
7964 return err; 8532 return err;
7965 } else if (! err) { 8533 } else if (!err) {
7966 printk(KERN_INFO 8534 printk(KERN_INFO
7967 "hda_codec: Cannot set up configuration " 8535 "hda_codec: Cannot set up configuration "
7968 "from BIOS. Using base mode...\n"); 8536 "from BIOS. Using base mode...\n");
@@ -8049,7 +8617,7 @@ static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
8049 idx = ucontrol->value.enumerated.item[0]; 8617 idx = ucontrol->value.enumerated.item[0];
8050 if (idx >= imux->num_items) 8618 if (idx >= imux->num_items)
8051 idx = imux->num_items - 1; 8619 idx = imux->num_items - 1;
8052 if (*cur_val == idx && ! codec->in_resume) 8620 if (*cur_val == idx && !codec->in_resume)
8053 return 0; 8621 return 0;
8054 for (i = 0; i < imux->num_items; i++) { 8622 for (i = 0; i < imux->num_items; i++) {
8055 unsigned int v = (i == idx) ? 0x7000 : 0x7080; 8623 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
@@ -8193,6 +8761,27 @@ static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
8193 { } /* end */ 8761 { } /* end */
8194}; 8762};
8195 8763
8764static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
8765 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
8766 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
8767 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8768
8769 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8770
8771 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8772 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8773 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8774
8775 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8776 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8777 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8778
8779 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8780 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8781
8782 { } /* end */
8783};
8784
8196/* 8785/*
8197 * generic initialization of ADC, input mixers and output mixers 8786 * generic initialization of ADC, input mixers and output mixers
8198 */ 8787 */
@@ -8214,10 +8803,10 @@ static struct hda_verb alc861vd_volume_init_verbs[] = {
8214 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 8803 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8215 8804
8216 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */ 8805 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
8806 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8807 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8808 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 8809 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
8219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
8220 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(8)},
8221 8810
8222 /* 8811 /*
8223 * Set up output mixers (0x02 - 0x05) 8812 * Set up output mixers (0x02 - 0x05)
@@ -8318,6 +8907,68 @@ static struct hda_verb alc861vd_6stack_init_verbs[] = {
8318 { } 8907 { }
8319}; 8908};
8320 8909
8910static struct hda_verb alc861vd_eapd_verbs[] = {
8911 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8912 { }
8913};
8914
8915static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
8916 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8917 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8918 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8919 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8920 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
8921 {}
8922};
8923
8924/* toggle speaker-output according to the hp-jack state */
8925static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
8926{
8927 unsigned int present;
8928 unsigned char bits;
8929
8930 present = snd_hda_codec_read(codec, 0x1b, 0,
8931 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8932 bits = present ? 0x80 : 0;
8933 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
8934 0x80, bits);
8935 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
8936 0x80, bits);
8937}
8938
8939static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
8940{
8941 unsigned int present;
8942 unsigned char bits;
8943
8944 present = snd_hda_codec_read(codec, 0x18, 0,
8945 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8946 bits = present ? 0x80 : 0;
8947 snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
8948 0x80, bits);
8949 snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
8950 0x80, bits);
8951}
8952
8953static void alc861vd_lenovo_automute(struct hda_codec *codec)
8954{
8955 alc861vd_lenovo_hp_automute(codec);
8956 alc861vd_lenovo_mic_automute(codec);
8957}
8958
8959static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
8960 unsigned int res)
8961{
8962 switch (res >> 26) {
8963 case ALC880_HP_EVENT:
8964 alc861vd_lenovo_hp_automute(codec);
8965 break;
8966 case ALC880_MIC_EVENT:
8967 alc861vd_lenovo_mic_automute(codec);
8968 break;
8969 }
8970}
8971
8321/* pcm configuration: identiacal with ALC880 */ 8972/* pcm configuration: identiacal with ALC880 */
8322#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback 8973#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
8323#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture 8974#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
@@ -8332,15 +8983,18 @@ static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
8332 [ALC861VD_3ST] = "3stack", 8983 [ALC861VD_3ST] = "3stack",
8333 [ALC861VD_3ST_DIG] = "3stack-digout", 8984 [ALC861VD_3ST_DIG] = "3stack-digout",
8334 [ALC861VD_6ST_DIG] = "6stack-digout", 8985 [ALC861VD_6ST_DIG] = "6stack-digout",
8986 [ALC861VD_LENOVO] = "lenovo",
8335 [ALC861VD_AUTO] = "auto", 8987 [ALC861VD_AUTO] = "auto",
8336}; 8988};
8337 8989
8338static struct snd_pci_quirk alc861vd_cfg_tbl[] = { 8990static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
8991 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
8339 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST), 8992 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
8340 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), 8993 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
8341 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST), 8994 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
8342 8995
8343 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_3ST), 8996 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
8997 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
8344 {} 8998 {}
8345}; 8999};
8346 9000
@@ -8389,6 +9043,22 @@ static struct alc_config_preset alc861vd_presets[] = {
8389 .channel_mode = alc861vd_6stack_modes, 9043 .channel_mode = alc861vd_6stack_modes,
8390 .input_mux = &alc861vd_capture_source, 9044 .input_mux = &alc861vd_capture_source,
8391 }, 9045 },
9046 [ALC861VD_LENOVO] = {
9047 .mixers = { alc861vd_lenovo_mixer },
9048 .init_verbs = { alc861vd_volume_init_verbs,
9049 alc861vd_3stack_init_verbs,
9050 alc861vd_eapd_verbs,
9051 alc861vd_lenovo_unsol_verbs },
9052 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
9053 .dac_nids = alc660vd_dac_nids,
9054 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
9055 .adc_nids = alc861vd_adc_nids,
9056 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
9057 .channel_mode = alc861vd_3stack_2ch_modes,
9058 .input_mux = &alc861vd_capture_source,
9059 .unsol_event = alc861vd_lenovo_unsol_event,
9060 .init_hook = alc861vd_lenovo_automute,
9061 },
8392}; 9062};
8393 9063
8394/* 9064/*
@@ -8409,11 +9079,13 @@ static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
8409 struct alc_spec *spec = codec->spec; 9079 struct alc_spec *spec = codec->spec;
8410 int i; 9080 int i;
8411 9081
9082 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
8412 for (i = 0; i <= HDA_SIDE; i++) { 9083 for (i = 0; i <= HDA_SIDE; i++) {
8413 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 9084 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9085 int pin_type = get_pin_type(spec->autocfg.line_out_type);
8414 if (nid) 9086 if (nid)
8415 alc861vd_auto_set_output_and_unmute(codec, nid, 9087 alc861vd_auto_set_output_and_unmute(codec, nid,
8416 PIN_OUT, i); 9088 pin_type, i);
8417 } 9089 }
8418} 9090}
8419 9091
@@ -8466,7 +9138,7 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
8466 int i, err; 9138 int i, err;
8467 9139
8468 for (i = 0; i < cfg->line_outs; i++) { 9140 for (i = 0; i < cfg->line_outs; i++) {
8469 if (! spec->multiout.dac_nids[i]) 9141 if (!spec->multiout.dac_nids[i])
8470 continue; 9142 continue;
8471 nid_v = alc861vd_idx_to_mixer_vol( 9143 nid_v = alc861vd_idx_to_mixer_vol(
8472 alc880_dac_to_idx( 9144 alc880_dac_to_idx(
@@ -8477,36 +9149,42 @@ static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
8477 9149
8478 if (i == 2) { 9150 if (i == 2) {
8479 /* Center/LFE */ 9151 /* Center/LFE */
8480 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, 9152 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8481 "Center Playback Volume", 9153 "Center Playback Volume",
8482 HDA_COMPOSE_AMP_VAL(nid_v, 1, 9154 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
8483 0, HDA_OUTPUT))) < 0) 9155 HDA_OUTPUT));
9156 if (err < 0)
8484 return err; 9157 return err;
8485 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, 9158 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8486 "LFE Playback Volume", 9159 "LFE Playback Volume",
8487 HDA_COMPOSE_AMP_VAL(nid_v, 2, 9160 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
8488 0, HDA_OUTPUT))) < 0) 9161 HDA_OUTPUT));
9162 if (err < 0)
8489 return err; 9163 return err;
8490 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, 9164 err = add_control(spec, ALC_CTL_BIND_MUTE,
8491 "Center Playback Switch", 9165 "Center Playback Switch",
8492 HDA_COMPOSE_AMP_VAL(nid_s, 1, 9166 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
8493 2, HDA_INPUT))) < 0) 9167 HDA_INPUT));
9168 if (err < 0)
8494 return err; 9169 return err;
8495 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, 9170 err = add_control(spec, ALC_CTL_BIND_MUTE,
8496 "LFE Playback Switch", 9171 "LFE Playback Switch",
8497 HDA_COMPOSE_AMP_VAL(nid_s, 2, 9172 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
8498 2, HDA_INPUT))) < 0) 9173 HDA_INPUT));
9174 if (err < 0)
8499 return err; 9175 return err;
8500 } else { 9176 } else {
8501 sprintf(name, "%s Playback Volume", chname[i]); 9177 sprintf(name, "%s Playback Volume", chname[i]);
8502 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 9178 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8503 HDA_COMPOSE_AMP_VAL(nid_v, 3, 9179 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
8504 0, HDA_OUTPUT))) < 0) 9180 HDA_OUTPUT));
9181 if (err < 0)
8505 return err; 9182 return err;
8506 sprintf(name, "%s Playback Switch", chname[i]); 9183 sprintf(name, "%s Playback Switch", chname[i]);
8507 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 9184 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
8508 HDA_COMPOSE_AMP_VAL(nid_v, 3, 9185 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
8509 2, HDA_INPUT))) < 0) 9186 HDA_INPUT));
9187 if (err < 0)
8510 return err; 9188 return err;
8511 } 9189 }
8512 } 9190 }
@@ -8523,13 +9201,13 @@ static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
8523 int err; 9201 int err;
8524 char name[32]; 9202 char name[32];
8525 9203
8526 if (! pin) 9204 if (!pin)
8527 return 0; 9205 return 0;
8528 9206
8529 if (alc880_is_fixed_pin(pin)) { 9207 if (alc880_is_fixed_pin(pin)) {
8530 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 9208 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
8531 /* specify the DAC as the extra output */ 9209 /* specify the DAC as the extra output */
8532 if (! spec->multiout.hp_nid) 9210 if (!spec->multiout.hp_nid)
8533 spec->multiout.hp_nid = nid_v; 9211 spec->multiout.hp_nid = nid_v;
8534 else 9212 else
8535 spec->multiout.extra_out_nid[0] = nid_v; 9213 spec->multiout.extra_out_nid[0] = nid_v;
@@ -8540,22 +9218,22 @@ static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
8540 alc880_fixed_pin_idx(pin)); 9218 alc880_fixed_pin_idx(pin));
8541 9219
8542 sprintf(name, "%s Playback Volume", pfx); 9220 sprintf(name, "%s Playback Volume", pfx);
8543 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 9221 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8544 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, 9222 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
8545 HDA_OUTPUT))) < 0) 9223 if (err < 0)
8546 return err; 9224 return err;
8547 sprintf(name, "%s Playback Switch", pfx); 9225 sprintf(name, "%s Playback Switch", pfx);
8548 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 9226 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
8549 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, 9227 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
8550 HDA_INPUT))) < 0) 9228 if (err < 0)
8551 return err; 9229 return err;
8552 } else if (alc880_is_multi_pin(pin)) { 9230 } else if (alc880_is_multi_pin(pin)) {
8553 /* set manual connection */ 9231 /* set manual connection */
8554 /* we have only a switch on HP-out PIN */ 9232 /* we have only a switch on HP-out PIN */
8555 sprintf(name, "%s Playback Switch", pfx); 9233 sprintf(name, "%s Playback Switch", pfx);
8556 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 9234 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8557 HDA_COMPOSE_AMP_VAL(pin, 3, 0, 9235 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
8558 HDA_OUTPUT))) < 0) 9236 if (err < 0)
8559 return err; 9237 return err;
8560 } 9238 }
8561 return 0; 9239 return 0;
@@ -8572,21 +9250,31 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
8572 int err; 9250 int err;
8573 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; 9251 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
8574 9252
8575 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 9253 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8576 alc861vd_ignore)) < 0) 9254 alc861vd_ignore);
9255 if (err < 0)
8577 return err; 9256 return err;
8578 if (! spec->autocfg.line_outs) 9257 if (!spec->autocfg.line_outs)
8579 return 0; /* can't find valid BIOS pin config */ 9258 return 0; /* can't find valid BIOS pin config */
8580 9259
8581 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 9260 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
8582 (err = alc861vd_auto_create_multi_out_ctls(spec, 9261 if (err < 0)
8583 &spec->autocfg)) < 0 || 9262 return err;
8584 (err = alc861vd_auto_create_extra_out(spec, 9263 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
8585 spec->autocfg.speaker_pins[0], "Speaker")) < 0 || 9264 if (err < 0)
8586 (err = alc861vd_auto_create_extra_out(spec, 9265 return err;
8587 spec->autocfg.hp_pins[0], "Headphone")) < 0 || 9266 err = alc861vd_auto_create_extra_out(spec,
8588 (err = alc880_auto_create_analog_input_ctls(spec, 9267 spec->autocfg.speaker_pins[0],
8589 &spec->autocfg)) < 0) 9268 "Speaker");
9269 if (err < 0)
9270 return err;
9271 err = alc861vd_auto_create_extra_out(spec,
9272 spec->autocfg.hp_pins[0],
9273 "Headphone");
9274 if (err < 0)
9275 return err;
9276 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
9277 if (err < 0)
8590 return err; 9278 return err;
8591 9279
8592 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 9280 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
@@ -8641,7 +9329,7 @@ static int patch_alc861vd(struct hda_codec *codec)
8641 if (err < 0) { 9329 if (err < 0) {
8642 alc_free(codec); 9330 alc_free(codec);
8643 return err; 9331 return err;
8644 } else if (! err) { 9332 } else if (!err) {
8645 printk(KERN_INFO 9333 printk(KERN_INFO
8646 "hda_codec: Cannot set up configuration " 9334 "hda_codec: Cannot set up configuration "
8647 "from BIOS. Using base mode...\n"); 9335 "from BIOS. Using base mode...\n");
@@ -8675,16 +9363,875 @@ static int patch_alc861vd(struct hda_codec *codec)
8675} 9363}
8676 9364
8677/* 9365/*
9366 * ALC662 support
9367 *
9368 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
9369 * configuration. Each pin widget can choose any input DACs and a mixer.
9370 * Each ADC is connected from a mixer of all inputs. This makes possible
9371 * 6-channel independent captures.
9372 *
9373 * In addition, an independent DAC for the multi-playback (not used in this
9374 * driver yet).
9375 */
9376#define ALC662_DIGOUT_NID 0x06
9377#define ALC662_DIGIN_NID 0x0a
9378
9379static hda_nid_t alc662_dac_nids[4] = {
9380 /* front, rear, clfe, rear_surr */
9381 0x02, 0x03, 0x04
9382};
9383
9384static hda_nid_t alc662_adc_nids[1] = {
9385 /* ADC1-2 */
9386 0x09,
9387};
9388/* input MUX */
9389/* FIXME: should be a matrix-type input source selection */
9390
9391static struct hda_input_mux alc662_capture_source = {
9392 .num_items = 4,
9393 .items = {
9394 { "Mic", 0x0 },
9395 { "Front Mic", 0x1 },
9396 { "Line", 0x2 },
9397 { "CD", 0x4 },
9398 },
9399};
9400
9401static struct hda_input_mux alc662_lenovo_101e_capture_source = {
9402 .num_items = 2,
9403 .items = {
9404 { "Mic", 0x1 },
9405 { "Line", 0x2 },
9406 },
9407};
9408#define alc662_mux_enum_info alc_mux_enum_info
9409#define alc662_mux_enum_get alc_mux_enum_get
9410
9411static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
9412 struct snd_ctl_elem_value *ucontrol)
9413{
9414 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9415 struct alc_spec *spec = codec->spec;
9416 const struct hda_input_mux *imux = spec->input_mux;
9417 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9418 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
9419 hda_nid_t nid = capture_mixers[adc_idx];
9420 unsigned int *cur_val = &spec->cur_mux[adc_idx];
9421 unsigned int i, idx;
9422
9423 idx = ucontrol->value.enumerated.item[0];
9424 if (idx >= imux->num_items)
9425 idx = imux->num_items - 1;
9426 if (*cur_val == idx && !codec->in_resume)
9427 return 0;
9428 for (i = 0; i < imux->num_items; i++) {
9429 unsigned int v = (i == idx) ? 0x7000 : 0x7080;
9430 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9431 v | (imux->items[i].index << 8));
9432 }
9433 *cur_val = idx;
9434 return 1;
9435}
9436/*
9437 * 2ch mode
9438 */
9439static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
9440 { 2, NULL }
9441};
9442
9443/*
9444 * 2ch mode
9445 */
9446static struct hda_verb alc662_3ST_ch2_init[] = {
9447 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9448 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9449 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9450 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9451 { } /* end */
9452};
9453
9454/*
9455 * 6ch mode
9456 */
9457static struct hda_verb alc662_3ST_ch6_init[] = {
9458 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9459 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9460 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
9461 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9462 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9463 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
9464 { } /* end */
9465};
9466
9467static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
9468 { 2, alc662_3ST_ch2_init },
9469 { 6, alc662_3ST_ch6_init },
9470};
9471
9472/*
9473 * 2ch mode
9474 */
9475static struct hda_verb alc662_sixstack_ch6_init[] = {
9476 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9477 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9478 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9479 { } /* end */
9480};
9481
9482/*
9483 * 6ch mode
9484 */
9485static struct hda_verb alc662_sixstack_ch8_init[] = {
9486 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9487 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9488 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9489 { } /* end */
9490};
9491
9492static struct hda_channel_mode alc662_5stack_modes[2] = {
9493 { 2, alc662_sixstack_ch6_init },
9494 { 6, alc662_sixstack_ch8_init },
9495};
9496
9497/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
9498 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
9499 */
9500
9501static struct snd_kcontrol_new alc662_base_mixer[] = {
9502 /* output mixer control */
9503 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9504 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
9505 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9506 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9507 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
9508 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
9509 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
9510 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
9511 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9512
9513 /*Input mixer control */
9514 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
9515 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
9516 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
9517 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
9518 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
9519 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
9520 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
9521 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
9522
9523 /* Capture mixer control */
9524 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9525 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9526 {
9527 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9528 .name = "Capture Source",
9529 .count = 1,
9530 .info = alc_mux_enum_info,
9531 .get = alc_mux_enum_get,
9532 .put = alc_mux_enum_put,
9533 },
9534 { } /* end */
9535};
9536
9537static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
9538 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9539 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
9540 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9541 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9542 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9543 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9544 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9546 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9547 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9548 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9549 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9550 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9551 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9552 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9553 {
9554 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9555 /* .name = "Capture Source", */
9556 .name = "Input Source",
9557 .count = 1,
9558 .info = alc662_mux_enum_info,
9559 .get = alc662_mux_enum_get,
9560 .put = alc662_mux_enum_put,
9561 },
9562 { } /* end */
9563};
9564
9565static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
9566 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9567 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
9568 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9569 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
9570 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
9571 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
9572 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
9573 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
9574 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9575 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9576 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9577 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9578 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9579 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9580 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9581 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9582 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9583 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
9584 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
9585 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9586 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9587 {
9588 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9589 /* .name = "Capture Source", */
9590 .name = "Input Source",
9591 .count = 1,
9592 .info = alc662_mux_enum_info,
9593 .get = alc662_mux_enum_get,
9594 .put = alc662_mux_enum_put,
9595 },
9596 { } /* end */
9597};
9598
9599static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
9600 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9601 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
9602 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9603 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
9604 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9605 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9606 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9607 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9608 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9609 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9610 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9611 {
9612 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9613 /* .name = "Capture Source", */
9614 .name = "Input Source",
9615 .count = 1,
9616 .info = alc662_mux_enum_info,
9617 .get = alc662_mux_enum_get,
9618 .put = alc662_mux_enum_put,
9619 },
9620 { } /* end */
9621};
9622
9623static struct snd_kcontrol_new alc662_chmode_mixer[] = {
9624 {
9625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9626 .name = "Channel Mode",
9627 .info = alc_ch_mode_info,
9628 .get = alc_ch_mode_get,
9629 .put = alc_ch_mode_put,
9630 },
9631 { } /* end */
9632};
9633
9634static struct hda_verb alc662_init_verbs[] = {
9635 /* ADC: mute amp left and right */
9636 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9637 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9638 /* Front mixer: unmute input/output amp left and right (volume = 0) */
9639
9640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9645
9646 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9647 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9648 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9649 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9650 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9651 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9652
9653 /* Front Pin: output 0 (0x0c) */
9654 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9655 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9656
9657 /* Rear Pin: output 1 (0x0d) */
9658 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9659 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9660
9661 /* CLFE Pin: output 2 (0x0e) */
9662 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9663 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9664
9665 /* Mic (rear) pin: input vref at 80% */
9666 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9667 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9668 /* Front Mic pin: input vref at 80% */
9669 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9670 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9671 /* Line In pin: input */
9672 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9673 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9674 /* Line-2 In: Headphone output (output 0 - 0x0c) */
9675 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9676 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9677 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9678 /* CD pin widget for input */
9679 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9680
9681 /* FIXME: use matrix-type input source selection */
9682 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9683 /* Input mixer */
9684 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9685 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9686 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9687 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9688 { }
9689};
9690
9691static struct hda_verb alc662_sue_init_verbs[] = {
9692 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
9693 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
9694 {}
9695};
9696
9697/*
9698 * generic initialization of ADC, input mixers and output mixers
9699 */
9700static struct hda_verb alc662_auto_init_verbs[] = {
9701 /*
9702 * Unmute ADC and set the default input to mic-in
9703 */
9704 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9705 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9706
9707 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
9708 * mixer widget
9709 * Note: PASD motherboards uses the Line In 2 as the input for front
9710 * panel mic (mic 2)
9711 */
9712 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9713 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9714 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9715 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9716 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9717 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9718
9719 /*
9720 * Set up output mixers (0x0c - 0x0f)
9721 */
9722 /* set vol=0 to output mixers */
9723 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9724 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9725 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9726
9727 /* set up input amps for analog loopback */
9728 /* Amp Indices: DAC = 0, mixer = 1 */
9729 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9730 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9731 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9732 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9733 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9734 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9735
9736
9737 /* FIXME: use matrix-type input source selection */
9738 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9739 /* Input mixer */
9740 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9741 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9742 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9743 /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
9744 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
9745
9746 { }
9747};
9748
9749/* capture mixer elements */
9750static struct snd_kcontrol_new alc662_capture_mixer[] = {
9751 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9752 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9753 {
9754 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9755 /* The multiple "Capture Source" controls confuse alsamixer
9756 * So call somewhat different..
9757 * FIXME: the controls appear in the "playback" view!
9758 */
9759 /* .name = "Capture Source", */
9760 .name = "Input Source",
9761 .count = 1,
9762 .info = alc882_mux_enum_info,
9763 .get = alc882_mux_enum_get,
9764 .put = alc882_mux_enum_put,
9765 },
9766 { } /* end */
9767};
9768
9769static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9770{
9771 unsigned int present;
9772 unsigned char bits;
9773
9774 present = snd_hda_codec_read(codec, 0x14, 0,
9775 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9776 bits = present ? 0x80 : 0;
9777 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9778 0x80, bits);
9779 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9780 0x80, bits);
9781}
9782
9783static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
9784{
9785 unsigned int present;
9786 unsigned char bits;
9787
9788 present = snd_hda_codec_read(codec, 0x1b, 0,
9789 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9790 bits = present ? 0x80 : 0;
9791 snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9792 0x80, bits);
9793 snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9794 0x80, bits);
9795 snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9796 0x80, bits);
9797 snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9798 0x80, bits);
9799}
9800
9801static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
9802 unsigned int res)
9803{
9804 if ((res >> 26) == ALC880_HP_EVENT)
9805 alc662_lenovo_101e_all_automute(codec);
9806 if ((res >> 26) == ALC880_FRONT_EVENT)
9807 alc662_lenovo_101e_ispeaker_automute(codec);
9808}
9809
9810
9811/* pcm configuration: identiacal with ALC880 */
9812#define alc662_pcm_analog_playback alc880_pcm_analog_playback
9813#define alc662_pcm_analog_capture alc880_pcm_analog_capture
9814#define alc662_pcm_digital_playback alc880_pcm_digital_playback
9815#define alc662_pcm_digital_capture alc880_pcm_digital_capture
9816
9817/*
9818 * configuration and preset
9819 */
9820static const char *alc662_models[ALC662_MODEL_LAST] = {
9821 [ALC662_3ST_2ch_DIG] = "3stack-dig",
9822 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
9823 [ALC662_3ST_6ch] = "3stack-6ch",
9824 [ALC662_5ST_DIG] = "6stack-dig",
9825 [ALC662_LENOVO_101E] = "lenovo-101e",
9826 [ALC662_AUTO] = "auto",
9827};
9828
9829static struct snd_pci_quirk alc662_cfg_tbl[] = {
9830 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
9831 {}
9832};
9833
9834static struct alc_config_preset alc662_presets[] = {
9835 [ALC662_3ST_2ch_DIG] = {
9836 .mixers = { alc662_3ST_2ch_mixer },
9837 .init_verbs = { alc662_init_verbs },
9838 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
9839 .dac_nids = alc662_dac_nids,
9840 .dig_out_nid = ALC662_DIGOUT_NID,
9841 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
9842 .adc_nids = alc662_adc_nids,
9843 .dig_in_nid = ALC662_DIGIN_NID,
9844 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
9845 .channel_mode = alc662_3ST_2ch_modes,
9846 .input_mux = &alc662_capture_source,
9847 },
9848 [ALC662_3ST_6ch_DIG] = {
9849 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
9850 .init_verbs = { alc662_init_verbs },
9851 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
9852 .dac_nids = alc662_dac_nids,
9853 .dig_out_nid = ALC662_DIGOUT_NID,
9854 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
9855 .adc_nids = alc662_adc_nids,
9856 .dig_in_nid = ALC662_DIGIN_NID,
9857 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
9858 .channel_mode = alc662_3ST_6ch_modes,
9859 .need_dac_fix = 1,
9860 .input_mux = &alc662_capture_source,
9861 },
9862 [ALC662_3ST_6ch] = {
9863 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
9864 .init_verbs = { alc662_init_verbs },
9865 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
9866 .dac_nids = alc662_dac_nids,
9867 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
9868 .adc_nids = alc662_adc_nids,
9869 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
9870 .channel_mode = alc662_3ST_6ch_modes,
9871 .need_dac_fix = 1,
9872 .input_mux = &alc662_capture_source,
9873 },
9874 [ALC662_5ST_DIG] = {
9875 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
9876 .init_verbs = { alc662_init_verbs },
9877 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
9878 .dac_nids = alc662_dac_nids,
9879 .dig_out_nid = ALC662_DIGOUT_NID,
9880 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
9881 .adc_nids = alc662_adc_nids,
9882 .dig_in_nid = ALC662_DIGIN_NID,
9883 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
9884 .channel_mode = alc662_5stack_modes,
9885 .input_mux = &alc662_capture_source,
9886 },
9887 [ALC662_LENOVO_101E] = {
9888 .mixers = { alc662_lenovo_101e_mixer },
9889 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
9890 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
9891 .dac_nids = alc662_dac_nids,
9892 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
9893 .adc_nids = alc662_adc_nids,
9894 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
9895 .channel_mode = alc662_3ST_2ch_modes,
9896 .input_mux = &alc662_lenovo_101e_capture_source,
9897 .unsol_event = alc662_lenovo_101e_unsol_event,
9898 .init_hook = alc662_lenovo_101e_all_automute,
9899 },
9900
9901};
9902
9903
9904/*
9905 * BIOS auto configuration
9906 */
9907
9908/* add playback controls from the parsed DAC table */
9909static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
9910 const struct auto_pin_cfg *cfg)
9911{
9912 char name[32];
9913 static const char *chname[4] = {
9914 "Front", "Surround", NULL /*CLFE*/, "Side"
9915 };
9916 hda_nid_t nid;
9917 int i, err;
9918
9919 for (i = 0; i < cfg->line_outs; i++) {
9920 if (!spec->multiout.dac_nids[i])
9921 continue;
9922 nid = alc880_idx_to_dac(i);
9923 if (i == 2) {
9924 /* Center/LFE */
9925 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9926 "Center Playback Volume",
9927 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9928 HDA_OUTPUT));
9929 if (err < 0)
9930 return err;
9931 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9932 "LFE Playback Volume",
9933 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9934 HDA_OUTPUT));
9935 if (err < 0)
9936 return err;
9937 err = add_control(spec, ALC_CTL_BIND_MUTE,
9938 "Center Playback Switch",
9939 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
9940 HDA_INPUT));
9941 if (err < 0)
9942 return err;
9943 err = add_control(spec, ALC_CTL_BIND_MUTE,
9944 "LFE Playback Switch",
9945 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
9946 HDA_INPUT));
9947 if (err < 0)
9948 return err;
9949 } else {
9950 sprintf(name, "%s Playback Volume", chname[i]);
9951 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9952 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9953 HDA_OUTPUT));
9954 if (err < 0)
9955 return err;
9956 sprintf(name, "%s Playback Switch", chname[i]);
9957 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9958 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
9959 HDA_INPUT));
9960 if (err < 0)
9961 return err;
9962 }
9963 }
9964 return 0;
9965}
9966
9967/* add playback controls for speaker and HP outputs */
9968static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
9969 const char *pfx)
9970{
9971 hda_nid_t nid;
9972 int err;
9973 char name[32];
9974
9975 if (!pin)
9976 return 0;
9977
9978 if (alc880_is_fixed_pin(pin)) {
9979 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
9980 /* printk("DAC nid=%x\n",nid); */
9981 /* specify the DAC as the extra output */
9982 if (!spec->multiout.hp_nid)
9983 spec->multiout.hp_nid = nid;
9984 else
9985 spec->multiout.extra_out_nid[0] = nid;
9986 /* control HP volume/switch on the output mixer amp */
9987 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
9988 sprintf(name, "%s Playback Volume", pfx);
9989 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9990 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9991 if (err < 0)
9992 return err;
9993 sprintf(name, "%s Playback Switch", pfx);
9994 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9995 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
9996 if (err < 0)
9997 return err;
9998 } else if (alc880_is_multi_pin(pin)) {
9999 /* set manual connection */
10000 /* we have only a switch on HP-out PIN */
10001 sprintf(name, "%s Playback Switch", pfx);
10002 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10003 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10004 if (err < 0)
10005 return err;
10006 }
10007 return 0;
10008}
10009
10010/* create playback/capture controls for input pins */
10011static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
10012 const struct auto_pin_cfg *cfg)
10013{
10014 struct hda_input_mux *imux = &spec->private_imux;
10015 int i, err, idx;
10016
10017 for (i = 0; i < AUTO_PIN_LAST; i++) {
10018 if (alc880_is_input_pin(cfg->input_pins[i])) {
10019 idx = alc880_input_pin_idx(cfg->input_pins[i]);
10020 err = new_analog_input(spec, cfg->input_pins[i],
10021 auto_pin_cfg_labels[i],
10022 idx, 0x0b);
10023 if (err < 0)
10024 return err;
10025 imux->items[imux->num_items].label =
10026 auto_pin_cfg_labels[i];
10027 imux->items[imux->num_items].index =
10028 alc880_input_pin_idx(cfg->input_pins[i]);
10029 imux->num_items++;
10030 }
10031 }
10032 return 0;
10033}
10034
10035static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
10036 hda_nid_t nid, int pin_type,
10037 int dac_idx)
10038{
10039 /* set as output */
10040 snd_hda_codec_write(codec, nid, 0,
10041 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10042 snd_hda_codec_write(codec, nid, 0,
10043 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10044 /* need the manual connection? */
10045 if (alc880_is_multi_pin(nid)) {
10046 struct alc_spec *spec = codec->spec;
10047 int idx = alc880_multi_pin_idx(nid);
10048 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
10049 AC_VERB_SET_CONNECT_SEL,
10050 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
10051 }
10052}
10053
10054static void alc662_auto_init_multi_out(struct hda_codec *codec)
10055{
10056 struct alc_spec *spec = codec->spec;
10057 int i;
10058
10059 for (i = 0; i <= HDA_SIDE; i++) {
10060 hda_nid_t nid = spec->autocfg.line_out_pins[i];
10061 int pin_type = get_pin_type(spec->autocfg.line_out_type);
10062 if (nid)
10063 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
10064 i);
10065 }
10066}
10067
10068static void alc662_auto_init_hp_out(struct hda_codec *codec)
10069{
10070 struct alc_spec *spec = codec->spec;
10071 hda_nid_t pin;
10072
10073 pin = spec->autocfg.hp_pins[0];
10074 if (pin) /* connect to front */
10075 /* use dac 0 */
10076 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10077}
10078
10079#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
10080#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
10081
10082static void alc662_auto_init_analog_input(struct hda_codec *codec)
10083{
10084 struct alc_spec *spec = codec->spec;
10085 int i;
10086
10087 for (i = 0; i < AUTO_PIN_LAST; i++) {
10088 hda_nid_t nid = spec->autocfg.input_pins[i];
10089 if (alc662_is_input_pin(nid)) {
10090 snd_hda_codec_write(codec, nid, 0,
10091 AC_VERB_SET_PIN_WIDGET_CONTROL,
10092 (i <= AUTO_PIN_FRONT_MIC ?
10093 PIN_VREF80 : PIN_IN));
10094 if (nid != ALC662_PIN_CD_NID)
10095 snd_hda_codec_write(codec, nid, 0,
10096 AC_VERB_SET_AMP_GAIN_MUTE,
10097 AMP_OUT_MUTE);
10098 }
10099 }
10100}
10101
10102static int alc662_parse_auto_config(struct hda_codec *codec)
10103{
10104 struct alc_spec *spec = codec->spec;
10105 int err;
10106 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
10107
10108 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10109 alc662_ignore);
10110 if (err < 0)
10111 return err;
10112 if (!spec->autocfg.line_outs)
10113 return 0; /* can't find valid BIOS pin config */
10114
10115 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10116 if (err < 0)
10117 return err;
10118 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
10119 if (err < 0)
10120 return err;
10121 err = alc662_auto_create_extra_out(spec,
10122 spec->autocfg.speaker_pins[0],
10123 "Speaker");
10124 if (err < 0)
10125 return err;
10126 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10127 "Headphone");
10128 if (err < 0)
10129 return err;
10130 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
10131 if (err < 0)
10132 return err;
10133
10134 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10135
10136 if (spec->autocfg.dig_out_pin)
10137 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
10138
10139 if (spec->kctl_alloc)
10140 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10141
10142 spec->num_mux_defs = 1;
10143 spec->input_mux = &spec->private_imux;
10144
10145 if (err < 0)
10146 return err;
10147 else if (err > 0)
10148 /* hack - override the init verbs */
10149 spec->init_verbs[0] = alc662_auto_init_verbs;
10150 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
10151 spec->num_mixers++;
10152 return err;
10153}
10154
10155/* additional initialization for auto-configuration model */
10156static void alc662_auto_init(struct hda_codec *codec)
10157{
10158 alc662_auto_init_multi_out(codec);
10159 alc662_auto_init_hp_out(codec);
10160 alc662_auto_init_analog_input(codec);
10161}
10162
10163static int patch_alc662(struct hda_codec *codec)
10164{
10165 struct alc_spec *spec;
10166 int err, board_config;
10167
10168 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10169 if (!spec)
10170 return -ENOMEM;
10171
10172 codec->spec = spec;
10173
10174 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
10175 alc662_models,
10176 alc662_cfg_tbl);
10177 if (board_config < 0) {
10178 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
10179 "trying auto-probe from BIOS...\n");
10180 board_config = ALC662_AUTO;
10181 }
10182
10183 if (board_config == ALC662_AUTO) {
10184 /* automatic parse from the BIOS config */
10185 err = alc662_parse_auto_config(codec);
10186 if (err < 0) {
10187 alc_free(codec);
10188 return err;
10189 } else if (err) {
10190 printk(KERN_INFO
10191 "hda_codec: Cannot set up configuration "
10192 "from BIOS. Using base mode...\n");
10193 board_config = ALC662_3ST_2ch_DIG;
10194 }
10195 }
10196
10197 if (board_config != ALC662_AUTO)
10198 setup_preset(spec, &alc662_presets[board_config]);
10199
10200 spec->stream_name_analog = "ALC662 Analog";
10201 spec->stream_analog_playback = &alc662_pcm_analog_playback;
10202 spec->stream_analog_capture = &alc662_pcm_analog_capture;
10203
10204 spec->stream_name_digital = "ALC662 Digital";
10205 spec->stream_digital_playback = &alc662_pcm_digital_playback;
10206 spec->stream_digital_capture = &alc662_pcm_digital_capture;
10207
10208 if (!spec->adc_nids && spec->input_mux) {
10209 spec->adc_nids = alc662_adc_nids;
10210 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
10211 }
10212
10213 codec->patch_ops = alc_patch_ops;
10214 if (board_config == ALC662_AUTO)
10215 spec->init_hook = alc662_auto_init;
10216
10217 return 0;
10218}
10219
10220/*
8678 * patch entries 10221 * patch entries
8679 */ 10222 */
8680struct hda_codec_preset snd_hda_preset_realtek[] = { 10223struct hda_codec_preset snd_hda_preset_realtek[] = {
8681 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, 10224 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
8682 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, 10225 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
8683 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", 10226 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
8684 .patch = patch_alc861 }, 10227 .patch = patch_alc861 },
8685 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, 10228 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
8686 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, 10229 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
8687 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, 10230 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
10231 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
10232 .patch = patch_alc883 },
10233 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
10234 .patch = patch_alc662 },
8688 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, 10235 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
8689 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, 10236 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
8690 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 }, 10237 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index c94291bc5367..93ae9c250767 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -62,6 +62,7 @@ enum {
62 STAC_MACBOOK, 62 STAC_MACBOOK,
63 STAC_MACBOOK_PRO_V1, 63 STAC_MACBOOK_PRO_V1,
64 STAC_MACBOOK_PRO_V2, 64 STAC_MACBOOK_PRO_V2,
65 STAC_IMAC_INTEL,
65 STAC_922X_MODELS 66 STAC_922X_MODELS
66}; 67};
67 68
@@ -175,8 +176,8 @@ static hda_nid_t stac9205_mux_nids[2] = {
175 0x19, 0x1a 176 0x19, 0x1a
176}; 177};
177 178
178static hda_nid_t stac9205_dmic_nids[3] = { 179static hda_nid_t stac9205_dmic_nids[2] = {
179 0x17, 0x18, 0 180 0x17, 0x18,
180}; 181};
181 182
182static hda_nid_t stac9200_pin_nids[8] = { 183static hda_nid_t stac9200_pin_nids[8] = {
@@ -524,12 +525,6 @@ static unsigned int d945gtp5_pin_configs[10] = {
524 0x02a19320, 0x40000100, 525 0x02a19320, 0x40000100,
525}; 526};
526 527
527static unsigned int macbook_pin_configs[10] = {
528 0x0321e230, 0x03a1e020, 0x400000fd, 0x9017e110,
529 0x400000fe, 0x0381e021, 0x1345e240, 0x13c5e22e,
530 0x400000fc, 0x400000fb,
531};
532
533static unsigned int macbook_pro_v1_pin_configs[10] = { 528static unsigned int macbook_pro_v1_pin_configs[10] = {
534 0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010, 529 0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010,
535 0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e, 530 0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e,
@@ -542,14 +537,21 @@ static unsigned int macbook_pro_v2_pin_configs[10] = {
542 0x400000fc, 0x400000fb, 537 0x400000fc, 0x400000fb,
543}; 538};
544 539
540static unsigned int imac_intel_pin_configs[10] = {
541 0x0121e230, 0x90a70120, 0x9017e110, 0x400000fe,
542 0x400000fd, 0x0181e021, 0x1145e040, 0x400000fa,
543 0x400000fc, 0x400000fb,
544};
545
545static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { 546static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
546 [STAC_D945_REF] = ref922x_pin_configs, 547 [STAC_D945_REF] = ref922x_pin_configs,
547 [STAC_D945GTP3] = d945gtp3_pin_configs, 548 [STAC_D945GTP3] = d945gtp3_pin_configs,
548 [STAC_D945GTP5] = d945gtp5_pin_configs, 549 [STAC_D945GTP5] = d945gtp5_pin_configs,
549 [STAC_MACMINI] = d945gtp5_pin_configs, 550 [STAC_MACMINI] = macbook_pro_v1_pin_configs,
550 [STAC_MACBOOK] = macbook_pin_configs, 551 [STAC_MACBOOK] = macbook_pro_v1_pin_configs,
551 [STAC_MACBOOK_PRO_V1] = macbook_pro_v1_pin_configs, 552 [STAC_MACBOOK_PRO_V1] = macbook_pro_v1_pin_configs,
552 [STAC_MACBOOK_PRO_V2] = macbook_pro_v2_pin_configs, 553 [STAC_MACBOOK_PRO_V2] = macbook_pro_v2_pin_configs,
554 [STAC_IMAC_INTEL] = imac_intel_pin_configs,
553}; 555};
554 556
555static const char *stac922x_models[STAC_922X_MODELS] = { 557static const char *stac922x_models[STAC_922X_MODELS] = {
@@ -560,6 +562,7 @@ static const char *stac922x_models[STAC_922X_MODELS] = {
560 [STAC_MACBOOK] = "macbook", 562 [STAC_MACBOOK] = "macbook",
561 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1", 563 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
562 [STAC_MACBOOK_PRO_V2] = "macbook-pro", 564 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
565 [STAC_IMAC_INTEL] = "imac-intel",
563}; 566};
564 567
565static struct snd_pci_quirk stac922x_cfg_tbl[] = { 568static struct snd_pci_quirk stac922x_cfg_tbl[] = {
@@ -820,6 +823,17 @@ static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
820 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 823 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
821} 824}
822 825
826static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
827 struct hda_codec *codec,
828 unsigned int stream_tag,
829 unsigned int format,
830 struct snd_pcm_substream *substream)
831{
832 struct sigmatel_spec *spec = codec->spec;
833 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
834 stream_tag, format, substream);
835}
836
823 837
824/* 838/*
825 * Analog capture callbacks 839 * Analog capture callbacks
@@ -854,7 +868,8 @@ static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
854 /* NID is set in stac92xx_build_pcms */ 868 /* NID is set in stac92xx_build_pcms */
855 .ops = { 869 .ops = {
856 .open = stac92xx_dig_playback_pcm_open, 870 .open = stac92xx_dig_playback_pcm_open,
857 .close = stac92xx_dig_playback_pcm_close 871 .close = stac92xx_dig_playback_pcm_close,
872 .prepare = stac92xx_dig_playback_pcm_prepare
858 }, 873 },
859}; 874};
860 875
@@ -1055,11 +1070,23 @@ static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char
1055static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg) 1070static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
1056{ 1071{
1057 struct sigmatel_spec *spec = codec->spec; 1072 struct sigmatel_spec *spec = codec->spec;
1073 unsigned int wcaps, wtype;
1074 int i, num_dacs = 0;
1075
1076 /* use the wcaps cache to count all DACs available for line-outs */
1077 for (i = 0; i < codec->num_nodes; i++) {
1078 wcaps = codec->wcaps[i];
1079 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1080 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
1081 num_dacs++;
1082 }
1058 1083
1084 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
1085
1059 switch (cfg->line_outs) { 1086 switch (cfg->line_outs) {
1060 case 3: 1087 case 3:
1061 /* add line-in as side */ 1088 /* add line-in as side */
1062 if (cfg->input_pins[AUTO_PIN_LINE]) { 1089 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
1063 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE]; 1090 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE];
1064 spec->line_switch = 1; 1091 spec->line_switch = 1;
1065 cfg->line_outs++; 1092 cfg->line_outs++;
@@ -1067,12 +1094,12 @@ static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cf
1067 break; 1094 break;
1068 case 2: 1095 case 2:
1069 /* add line-in as clfe and mic as side */ 1096 /* add line-in as clfe and mic as side */
1070 if (cfg->input_pins[AUTO_PIN_LINE]) { 1097 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
1071 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE]; 1098 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE];
1072 spec->line_switch = 1; 1099 spec->line_switch = 1;
1073 cfg->line_outs++; 1100 cfg->line_outs++;
1074 } 1101 }
1075 if (cfg->input_pins[AUTO_PIN_MIC]) { 1102 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
1076 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC]; 1103 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC];
1077 spec->mic_switch = 1; 1104 spec->mic_switch = 1;
1078 cfg->line_outs++; 1105 cfg->line_outs++;
@@ -1080,12 +1107,12 @@ static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cf
1080 break; 1107 break;
1081 case 1: 1108 case 1:
1082 /* add line-in as surr and mic as clfe */ 1109 /* add line-in as surr and mic as clfe */
1083 if (cfg->input_pins[AUTO_PIN_LINE]) { 1110 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
1084 cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE]; 1111 cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE];
1085 spec->line_switch = 1; 1112 spec->line_switch = 1;
1086 cfg->line_outs++; 1113 cfg->line_outs++;
1087 } 1114 }
1088 if (cfg->input_pins[AUTO_PIN_MIC]) { 1115 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
1089 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC]; 1116 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC];
1090 spec->mic_switch = 1; 1117 spec->mic_switch = 1;
1091 cfg->line_outs++; 1118 cfg->line_outs++;
@@ -1096,33 +1123,76 @@ static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cf
1096 return 0; 1123 return 0;
1097} 1124}
1098 1125
1126
1127static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1128{
1129 int i;
1130
1131 for (i = 0; i < spec->multiout.num_dacs; i++) {
1132 if (spec->multiout.dac_nids[i] == nid)
1133 return 1;
1134 }
1135
1136 return 0;
1137}
1138
1099/* 1139/*
1100 * XXX The line_out pin widget connection list may not be set to the 1140 * Fill in the dac_nids table from the parsed pin configuration
1101 * desired DAC nid. This is the case on 927x where ports A and B can 1141 * This function only works when every pin in line_out_pins[]
1102 * be routed to several DACs. 1142 * contains atleast one DAC in its connection list. Some 92xx
1103 * 1143 * codecs are not connected directly to a DAC, such as the 9200
1104 * This requires an analysis of the line-out/hp pin configuration 1144 * and 9202/925x. For those, dac_nids[] must be hard-coded.
1105 * to provide a best fit for pin/DAC configurations that are routable.
1106 * For now, 927x DAC4 is not supported and 927x DAC1 output to ports
1107 * A and B is not supported.
1108 */ 1145 */
1109/* fill in the dac_nids table from the parsed pin configuration */
1110static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, 1146static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
1111 const struct auto_pin_cfg *cfg) 1147 const struct auto_pin_cfg *cfg)
1112{ 1148{
1113 struct sigmatel_spec *spec = codec->spec; 1149 struct sigmatel_spec *spec = codec->spec;
1114 hda_nid_t nid; 1150 int i, j, conn_len = 0;
1115 int i; 1151 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
1116 1152 unsigned int wcaps, wtype;
1117 /* check the pins hardwired to audio widget */ 1153
1118 for (i = 0; i < cfg->line_outs; i++) { 1154 for (i = 0; i < cfg->line_outs; i++) {
1119 nid = cfg->line_out_pins[i]; 1155 nid = cfg->line_out_pins[i];
1120 spec->multiout.dac_nids[i] = snd_hda_codec_read(codec, nid, 0, 1156 conn_len = snd_hda_get_connections(codec, nid, conn,
1121 AC_VERB_GET_CONNECT_LIST, 0) & 0xff; 1157 HDA_MAX_CONNECTIONS);
1122 } 1158 for (j = 0; j < conn_len; j++) {
1159 wcaps = snd_hda_param_read(codec, conn[j],
1160 AC_PAR_AUDIO_WIDGET_CAP);
1161 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1162
1163 if (wtype != AC_WID_AUD_OUT ||
1164 (wcaps & AC_WCAP_DIGITAL))
1165 continue;
1166 /* conn[j] is a DAC routed to this line-out */
1167 if (!is_in_dac_nids(spec, conn[j]))
1168 break;
1169 }
1170
1171 if (j == conn_len) {
1172 /* error out, no available DAC found */
1173 snd_printk(KERN_ERR
1174 "%s: No available DAC for pin 0x%x\n",
1175 __func__, nid);
1176 return -ENODEV;
1177 }
1123 1178
1124 spec->multiout.num_dacs = cfg->line_outs; 1179 spec->multiout.dac_nids[i] = conn[j];
1180 spec->multiout.num_dacs++;
1181 if (conn_len > 1) {
1182 /* select this DAC in the pin's input mux */
1183 snd_hda_codec_write(codec, nid, 0,
1184 AC_VERB_SET_CONNECT_SEL, j);
1185
1186 }
1187 }
1125 1188
1189 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
1190 spec->multiout.num_dacs,
1191 spec->multiout.dac_nids[0],
1192 spec->multiout.dac_nids[1],
1193 spec->multiout.dac_nids[2],
1194 spec->multiout.dac_nids[3],
1195 spec->multiout.dac_nids[4]);
1126 return 0; 1196 return 0;
1127} 1197}
1128 1198
@@ -1189,12 +1259,8 @@ static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec,
1189 1259
1190static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) 1260static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1191{ 1261{
1192 int i; 1262 if (is_in_dac_nids(spec, nid))
1193 1263 return 1;
1194 for (i = 0; i < spec->multiout.num_dacs; i++) {
1195 if (spec->multiout.dac_nids[i] == nid)
1196 return 1;
1197 }
1198 if (spec->multiout.hp_nid == nid) 1264 if (spec->multiout.hp_nid == nid)
1199 return 1; 1265 return 1;
1200 return 0; 1266 return 0;
@@ -1236,12 +1302,10 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
1236 add_spec_dacs(spec, nid); 1302 add_spec_dacs(spec, nid);
1237 } 1303 }
1238 for (i = 0; i < cfg->speaker_outs; i++) { 1304 for (i = 0; i < cfg->speaker_outs; i++) {
1239 nid = snd_hda_codec_read(codec, cfg->speaker_pins[0], 0, 1305 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
1240 AC_VERB_GET_CONNECT_LIST, 0) & 0xff; 1306 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1241 if (check_in_dac_nids(spec, nid)) 1307 if (check_in_dac_nids(spec, nid))
1242 nid = 0; 1308 nid = 0;
1243 if (check_in_dac_nids(spec, nid))
1244 nid = 0;
1245 if (! nid) 1309 if (! nid)
1246 continue; 1310 continue;
1247 add_spec_dacs(spec, nid); 1311 add_spec_dacs(spec, nid);
@@ -1355,7 +1419,7 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const
1355 imux->num_items++; 1419 imux->num_items++;
1356 } 1420 }
1357 1421
1358 if (imux->num_items == 1) { 1422 if (imux->num_items) {
1359 /* 1423 /*
1360 * Set the current input for the muxes. 1424 * Set the current input for the muxes.
1361 * The STAC9221 has two input muxes with identical source 1425 * The STAC9221 has two input muxes with identical source
@@ -1675,8 +1739,12 @@ static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
1675{ 1739{
1676 unsigned int pin_ctl = snd_hda_codec_read(codec, nid, 1740 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
1677 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); 1741 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
1678 if (flag == AC_PINCTL_OUT_EN && (pin_ctl & AC_PINCTL_IN_EN)) 1742
1679 return; 1743 /* if setting pin direction bits, clear the current
1744 direction bits first */
1745 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
1746 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
1747
1680 snd_hda_codec_write(codec, nid, 0, 1748 snd_hda_codec_write(codec, nid, 0,
1681 AC_VERB_SET_PIN_WIDGET_CONTROL, 1749 AC_VERB_SET_PIN_WIDGET_CONTROL,
1682 pin_ctl | flag); 1750 pin_ctl | flag);
@@ -1751,6 +1819,7 @@ static int stac92xx_resume(struct hda_codec *codec)
1751 1819
1752 stac92xx_init(codec); 1820 stac92xx_init(codec);
1753 stac92xx_set_config_regs(codec); 1821 stac92xx_set_config_regs(codec);
1822 snd_hda_resume_ctls(codec, spec->mixer);
1754 for (i = 0; i < spec->num_mixers; i++) 1823 for (i = 0; i < spec->num_mixers; i++)
1755 snd_hda_resume_ctls(codec, spec->mixers[i]); 1824 snd_hda_resume_ctls(codec, spec->mixers[i]);
1756 if (spec->multiout.dig_out_nid) 1825 if (spec->multiout.dig_out_nid)
@@ -1905,12 +1974,18 @@ static int patch_stac922x(struct hda_codec *codec)
1905 */ 1974 */
1906 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id); 1975 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
1907 switch (codec->subsystem_id) { 1976 switch (codec->subsystem_id) {
1977 case 0x106b0a00: /* MacBook First generatoin */
1978 spec->board_config = STAC_MACBOOK;
1979 break;
1908 case 0x106b0200: /* MacBook Pro first generation */ 1980 case 0x106b0200: /* MacBook Pro first generation */
1909 spec->board_config = STAC_MACBOOK_PRO_V1; 1981 spec->board_config = STAC_MACBOOK_PRO_V1;
1910 break; 1982 break;
1911 case 0x106b1e00: /* MacBook Pro second generation */ 1983 case 0x106b1e00: /* MacBook Pro second generation */
1912 spec->board_config = STAC_MACBOOK_PRO_V2; 1984 spec->board_config = STAC_MACBOOK_PRO_V2;
1913 break; 1985 break;
1986 case 0x106b0700: /* Intel-based iMac */
1987 spec->board_config = STAC_IMAC_INTEL;
1988 break;
1914 } 1989 }
1915 } 1990 }
1916 1991
@@ -1931,7 +2006,7 @@ static int patch_stac922x(struct hda_codec *codec)
1931 2006
1932 spec->adc_nids = stac922x_adc_nids; 2007 spec->adc_nids = stac922x_adc_nids;
1933 spec->mux_nids = stac922x_mux_nids; 2008 spec->mux_nids = stac922x_mux_nids;
1934 spec->num_muxes = 2; 2009 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
1935 spec->num_dmics = 0; 2010 spec->num_dmics = 0;
1936 2011
1937 spec->init = stac922x_core_init; 2012 spec->init = stac922x_core_init;
@@ -1992,7 +2067,7 @@ static int patch_stac927x(struct hda_codec *codec)
1992 case STAC_D965_3ST: 2067 case STAC_D965_3ST:
1993 spec->adc_nids = stac927x_adc_nids; 2068 spec->adc_nids = stac927x_adc_nids;
1994 spec->mux_nids = stac927x_mux_nids; 2069 spec->mux_nids = stac927x_mux_nids;
1995 spec->num_muxes = 3; 2070 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
1996 spec->num_dmics = 0; 2071 spec->num_dmics = 0;
1997 spec->init = d965_core_init; 2072 spec->init = d965_core_init;
1998 spec->mixer = stac9227_mixer; 2073 spec->mixer = stac9227_mixer;
@@ -2000,7 +2075,7 @@ static int patch_stac927x(struct hda_codec *codec)
2000 case STAC_D965_5ST: 2075 case STAC_D965_5ST:
2001 spec->adc_nids = stac927x_adc_nids; 2076 spec->adc_nids = stac927x_adc_nids;
2002 spec->mux_nids = stac927x_mux_nids; 2077 spec->mux_nids = stac927x_mux_nids;
2003 spec->num_muxes = 3; 2078 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2004 spec->num_dmics = 0; 2079 spec->num_dmics = 0;
2005 spec->init = d965_core_init; 2080 spec->init = d965_core_init;
2006 spec->mixer = stac9227_mixer; 2081 spec->mixer = stac9227_mixer;
@@ -2008,7 +2083,7 @@ static int patch_stac927x(struct hda_codec *codec)
2008 default: 2083 default:
2009 spec->adc_nids = stac927x_adc_nids; 2084 spec->adc_nids = stac927x_adc_nids;
2010 spec->mux_nids = stac927x_mux_nids; 2085 spec->mux_nids = stac927x_mux_nids;
2011 spec->num_muxes = 3; 2086 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2012 spec->num_dmics = 0; 2087 spec->num_dmics = 0;
2013 spec->init = stac927x_core_init; 2088 spec->init = stac927x_core_init;
2014 spec->mixer = stac927x_mixer; 2089 spec->mixer = stac927x_mixer;
@@ -2067,9 +2142,9 @@ static int patch_stac9205(struct hda_codec *codec)
2067 2142
2068 spec->adc_nids = stac9205_adc_nids; 2143 spec->adc_nids = stac9205_adc_nids;
2069 spec->mux_nids = stac9205_mux_nids; 2144 spec->mux_nids = stac9205_mux_nids;
2070 spec->num_muxes = 2; 2145 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
2071 spec->dmic_nids = stac9205_dmic_nids; 2146 spec->dmic_nids = stac9205_dmic_nids;
2072 spec->num_dmics = 2; 2147 spec->num_dmics = ARRAY_SIZE(stac9205_dmic_nids);
2073 spec->dmux_nid = 0x1d; 2148 spec->dmux_nid = 0x1d;
2074 2149
2075 spec->init = stac9205_core_init; 2150 spec->init = stac9205_core_init;
@@ -2294,6 +2369,7 @@ static struct snd_pci_quirk stac9872_cfg_tbl[] = {
2294 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO), 2369 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
2295 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO), 2370 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
2296 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO), 2371 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
2372 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
2297 {} 2373 {}
2298}; 2374};
2299 2375
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 2b11ac8689b9..ba32d1e52cb8 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -377,6 +377,17 @@ static int via_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
377 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 377 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
378} 378}
379 379
380static int via_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
381 struct hda_codec *codec,
382 unsigned int stream_tag,
383 unsigned int format,
384 struct snd_pcm_substream *substream)
385{
386 struct via_spec *spec = codec->spec;
387 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
388 stream_tag, format, substream);
389}
390
380/* 391/*
381 * Analog capture 392 * Analog capture
382 */ 393 */
@@ -433,7 +444,8 @@ static struct hda_pcm_stream vt1708_pcm_digital_playback = {
433 /* NID is set in via_build_pcms */ 444 /* NID is set in via_build_pcms */
434 .ops = { 445 .ops = {
435 .open = via_dig_playback_pcm_open, 446 .open = via_dig_playback_pcm_open,
436 .close = via_dig_playback_pcm_close 447 .close = via_dig_playback_pcm_close,
448 .prepare = via_dig_playback_pcm_prepare
437 }, 449 },
438}; 450};
439 451
diff --git a/sound/pci/ice1712/amp.c b/sound/pci/ice1712/amp.c
index 6e22d326df32..44bbb630b949 100644
--- a/sound/pci/ice1712/amp.c
+++ b/sound/pci/ice1712/amp.c
@@ -75,7 +75,7 @@ static int __devinit snd_vt1724_amp_add_controls(struct snd_ice1712 *ice)
75 75
76 76
77/* entry point */ 77/* entry point */
78const struct snd_ice1712_card_info snd_vt1724_amp_cards[] __devinitdata = { 78struct snd_ice1712_card_info snd_vt1724_amp_cards[] __devinitdata = {
79 { 79 {
80 .subvendor = VT1724_SUBDEVICE_AV710, 80 .subvendor = VT1724_SUBDEVICE_AV710,
81 .name = "Chaintech AV-710", 81 .name = "Chaintech AV-710",
diff --git a/sound/pci/ice1712/amp.h b/sound/pci/ice1712/amp.h
index 7b667bad0c6b..a0fc89b48122 100644
--- a/sound/pci/ice1712/amp.h
+++ b/sound/pci/ice1712/amp.h
@@ -42,7 +42,7 @@
42#define WM_DAC_CTRL 0x02 42#define WM_DAC_CTRL 0x02
43#define WM_INT_CTRL 0x03 43#define WM_INT_CTRL 0x03
44 44
45extern const struct snd_ice1712_card_info snd_vt1724_amp_cards[]; 45extern struct snd_ice1712_card_info snd_vt1724_amp_cards[];
46 46
47 47
48#endif /* __SOUND_AMP_H */ 48#endif /* __SOUND_AMP_H */
diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c
index 6941d85dfec9..66bacde1ead3 100644
--- a/sound/pci/ice1712/aureon.c
+++ b/sound/pci/ice1712/aureon.c
@@ -1411,7 +1411,7 @@ static int aureon_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ctl
1411 * mixers 1411 * mixers
1412 */ 1412 */
1413 1413
1414static const struct snd_kcontrol_new aureon_dac_controls[] __devinitdata = { 1414static struct snd_kcontrol_new aureon_dac_controls[] __devinitdata = {
1415 { 1415 {
1416 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1416 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1417 .name = "Master Playback Switch", 1417 .name = "Master Playback Switch",
@@ -1526,7 +1526,7 @@ static const struct snd_kcontrol_new aureon_dac_controls[] __devinitdata = {
1526 } 1526 }
1527}; 1527};
1528 1528
1529static const struct snd_kcontrol_new wm_controls[] __devinitdata = { 1529static struct snd_kcontrol_new wm_controls[] __devinitdata = {
1530 { 1530 {
1531 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1531 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1532 .name = "PCM Playback Switch", 1532 .name = "PCM Playback Switch",
@@ -1592,7 +1592,7 @@ static const struct snd_kcontrol_new wm_controls[] __devinitdata = {
1592 } 1592 }
1593}; 1593};
1594 1594
1595static const struct snd_kcontrol_new ac97_controls[] __devinitdata = { 1595static struct snd_kcontrol_new ac97_controls[] __devinitdata = {
1596 { 1596 {
1597 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1597 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1598 .name = "AC97 Playback Switch", 1598 .name = "AC97 Playback Switch",
@@ -1697,7 +1697,7 @@ static const struct snd_kcontrol_new ac97_controls[] __devinitdata = {
1697 } 1697 }
1698}; 1698};
1699 1699
1700static const struct snd_kcontrol_new universe_ac97_controls[] __devinitdata = { 1700static struct snd_kcontrol_new universe_ac97_controls[] __devinitdata = {
1701 { 1701 {
1702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1703 .name = "AC97 Playback Switch", 1703 .name = "AC97 Playback Switch",
@@ -1829,7 +1829,7 @@ static const struct snd_kcontrol_new universe_ac97_controls[] __devinitdata = {
1829 1829
1830}; 1830};
1831 1831
1832static const struct snd_kcontrol_new cs8415_controls[] __devinitdata = { 1832static struct snd_kcontrol_new cs8415_controls[] __devinitdata = {
1833 { 1833 {
1834 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1834 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1835 .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 1835 .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH),
@@ -2107,7 +2107,7 @@ static int __devinit aureon_init(struct snd_ice1712 *ice)
2107 * hence the driver needs to sets up it properly. 2107 * hence the driver needs to sets up it properly.
2108 */ 2108 */
2109 2109
2110static const unsigned char aureon51_eeprom[] __devinitdata = { 2110static unsigned char aureon51_eeprom[] __devinitdata = {
2111 [ICE_EEP2_SYSCONF] = 0x0a, /* clock 512, spdif-in/ADC, 3DACs */ 2111 [ICE_EEP2_SYSCONF] = 0x0a, /* clock 512, spdif-in/ADC, 3DACs */
2112 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 2112 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
2113 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */ 2113 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
@@ -2123,7 +2123,7 @@ static const unsigned char aureon51_eeprom[] __devinitdata = {
2123 [ICE_EEP2_GPIO_STATE2] = 0x00, 2123 [ICE_EEP2_GPIO_STATE2] = 0x00,
2124}; 2124};
2125 2125
2126static const unsigned char aureon71_eeprom[] __devinitdata = { 2126static unsigned char aureon71_eeprom[] __devinitdata = {
2127 [ICE_EEP2_SYSCONF] = 0x0b, /* clock 512, spdif-in/ADC, 4DACs */ 2127 [ICE_EEP2_SYSCONF] = 0x0b, /* clock 512, spdif-in/ADC, 4DACs */
2128 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 2128 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
2129 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */ 2129 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
@@ -2140,7 +2140,7 @@ static const unsigned char aureon71_eeprom[] __devinitdata = {
2140}; 2140};
2141#define prodigy71_eeprom aureon71_eeprom 2141#define prodigy71_eeprom aureon71_eeprom
2142 2142
2143static const unsigned char prodigy71lt_eeprom[] __devinitdata = { 2143static unsigned char prodigy71lt_eeprom[] __devinitdata = {
2144 [ICE_EEP2_SYSCONF] = 0x4b, /* clock 384, spdif-in/ADC, 4DACs */ 2144 [ICE_EEP2_SYSCONF] = 0x4b, /* clock 384, spdif-in/ADC, 4DACs */
2145 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 2145 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
2146 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */ 2146 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
@@ -2158,7 +2158,7 @@ static const unsigned char prodigy71lt_eeprom[] __devinitdata = {
2158#define prodigy71xt_eeprom prodigy71lt_eeprom 2158#define prodigy71xt_eeprom prodigy71lt_eeprom
2159 2159
2160/* entry point */ 2160/* entry point */
2161const struct snd_ice1712_card_info snd_vt1724_aureon_cards[] __devinitdata = { 2161struct snd_ice1712_card_info snd_vt1724_aureon_cards[] __devinitdata = {
2162 { 2162 {
2163 .subvendor = VT1724_SUBDEVICE_AUREON51_SKY, 2163 .subvendor = VT1724_SUBDEVICE_AUREON51_SKY,
2164 .name = "Terratec Aureon 5.1-Sky", 2164 .name = "Terratec Aureon 5.1-Sky",
diff --git a/sound/pci/ice1712/aureon.h b/sound/pci/ice1712/aureon.h
index 79e58e88ed47..c253b8e2c789 100644
--- a/sound/pci/ice1712/aureon.h
+++ b/sound/pci/ice1712/aureon.h
@@ -38,7 +38,7 @@
38#define VT1724_SUBDEVICE_PRODIGY71LT 0x32315441 /* PRODIGY 7.1 LT */ 38#define VT1724_SUBDEVICE_PRODIGY71LT 0x32315441 /* PRODIGY 7.1 LT */
39#define VT1724_SUBDEVICE_PRODIGY71XT 0x36315441 /* PRODIGY 7.1 XT*/ 39#define VT1724_SUBDEVICE_PRODIGY71XT 0x36315441 /* PRODIGY 7.1 XT*/
40 40
41extern const struct snd_ice1712_card_info snd_vt1724_aureon_cards[]; 41extern struct snd_ice1712_card_info snd_vt1724_aureon_cards[];
42 42
43/* GPIO bits */ 43/* GPIO bits */
44#define AUREON_CS8415_CS (1 << 22) 44#define AUREON_CS8415_CS (1 << 22)
diff --git a/sound/pci/ice1712/delta.c b/sound/pci/ice1712/delta.c
index 3eeb36c6e985..af659800c9b0 100644
--- a/sound/pci/ice1712/delta.c
+++ b/sound/pci/ice1712/delta.c
@@ -416,7 +416,7 @@ static int snd_ice1712_delta1010lt_wordclock_status_get(struct snd_kcontrol *kco
416 return 0; 416 return 0;
417} 417}
418 418
419static const struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_status __devinitdata = 419static struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_status __devinitdata =
420{ 420{
421 .access = (SNDRV_CTL_ELEM_ACCESS_READ), 421 .access = (SNDRV_CTL_ELEM_ACCESS_READ),
422 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 422 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -429,7 +429,7 @@ static const struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_status __
429 * initialize the chips on M-Audio cards 429 * initialize the chips on M-Audio cards
430 */ 430 */
431 431
432static const struct snd_akm4xxx akm_audiophile __devinitdata = { 432static struct snd_akm4xxx akm_audiophile __devinitdata = {
433 .type = SND_AK4528, 433 .type = SND_AK4528,
434 .num_adcs = 2, 434 .num_adcs = 2,
435 .num_dacs = 2, 435 .num_dacs = 2,
@@ -438,7 +438,7 @@ static const struct snd_akm4xxx akm_audiophile __devinitdata = {
438 } 438 }
439}; 439};
440 440
441static const struct snd_ak4xxx_private akm_audiophile_priv __devinitdata = { 441static struct snd_ak4xxx_private akm_audiophile_priv __devinitdata = {
442 .caddr = 2, 442 .caddr = 2,
443 .cif = 0, 443 .cif = 0,
444 .data_mask = ICE1712_DELTA_AP_DOUT, 444 .data_mask = ICE1712_DELTA_AP_DOUT,
@@ -450,7 +450,7 @@ static const struct snd_ak4xxx_private akm_audiophile_priv __devinitdata = {
450 .mask_flags = 0, 450 .mask_flags = 0,
451}; 451};
452 452
453static const struct snd_akm4xxx akm_delta410 __devinitdata = { 453static struct snd_akm4xxx akm_delta410 __devinitdata = {
454 .type = SND_AK4529, 454 .type = SND_AK4529,
455 .num_adcs = 2, 455 .num_adcs = 2,
456 .num_dacs = 8, 456 .num_dacs = 8,
@@ -459,7 +459,7 @@ static const struct snd_akm4xxx akm_delta410 __devinitdata = {
459 } 459 }
460}; 460};
461 461
462static const struct snd_ak4xxx_private akm_delta410_priv __devinitdata = { 462static struct snd_ak4xxx_private akm_delta410_priv __devinitdata = {
463 .caddr = 0, 463 .caddr = 0,
464 .cif = 0, 464 .cif = 0,
465 .data_mask = ICE1712_DELTA_AP_DOUT, 465 .data_mask = ICE1712_DELTA_AP_DOUT,
@@ -471,7 +471,7 @@ static const struct snd_ak4xxx_private akm_delta410_priv __devinitdata = {
471 .mask_flags = 0, 471 .mask_flags = 0,
472}; 472};
473 473
474static const struct snd_akm4xxx akm_delta1010lt __devinitdata = { 474static struct snd_akm4xxx akm_delta1010lt __devinitdata = {
475 .type = SND_AK4524, 475 .type = SND_AK4524,
476 .num_adcs = 8, 476 .num_adcs = 8,
477 .num_dacs = 8, 477 .num_dacs = 8,
@@ -481,7 +481,7 @@ static const struct snd_akm4xxx akm_delta1010lt __devinitdata = {
481 } 481 }
482}; 482};
483 483
484static const struct snd_ak4xxx_private akm_delta1010lt_priv __devinitdata = { 484static struct snd_ak4xxx_private akm_delta1010lt_priv __devinitdata = {
485 .caddr = 2, 485 .caddr = 2,
486 .cif = 0, /* the default level of the CIF pin from AK4524 */ 486 .cif = 0, /* the default level of the CIF pin from AK4524 */
487 .data_mask = ICE1712_DELTA_1010LT_DOUT, 487 .data_mask = ICE1712_DELTA_1010LT_DOUT,
@@ -493,7 +493,7 @@ static const struct snd_ak4xxx_private akm_delta1010lt_priv __devinitdata = {
493 .mask_flags = 0, 493 .mask_flags = 0,
494}; 494};
495 495
496static const struct snd_akm4xxx akm_delta44 __devinitdata = { 496static struct snd_akm4xxx akm_delta44 __devinitdata = {
497 .type = SND_AK4524, 497 .type = SND_AK4524,
498 .num_adcs = 4, 498 .num_adcs = 4,
499 .num_dacs = 4, 499 .num_dacs = 4,
@@ -503,7 +503,7 @@ static const struct snd_akm4xxx akm_delta44 __devinitdata = {
503 } 503 }
504}; 504};
505 505
506static const struct snd_ak4xxx_private akm_delta44_priv __devinitdata = { 506static struct snd_ak4xxx_private akm_delta44_priv __devinitdata = {
507 .caddr = 2, 507 .caddr = 2,
508 .cif = 0, /* the default level of the CIF pin from AK4524 */ 508 .cif = 0, /* the default level of the CIF pin from AK4524 */
509 .data_mask = ICE1712_DELTA_CODEC_SERIAL_DATA, 509 .data_mask = ICE1712_DELTA_CODEC_SERIAL_DATA,
@@ -515,7 +515,7 @@ static const struct snd_ak4xxx_private akm_delta44_priv __devinitdata = {
515 .mask_flags = 0, 515 .mask_flags = 0,
516}; 516};
517 517
518static const struct snd_akm4xxx akm_vx442 __devinitdata = { 518static struct snd_akm4xxx akm_vx442 __devinitdata = {
519 .type = SND_AK4524, 519 .type = SND_AK4524,
520 .num_adcs = 4, 520 .num_adcs = 4,
521 .num_dacs = 4, 521 .num_dacs = 4,
@@ -525,7 +525,7 @@ static const struct snd_akm4xxx akm_vx442 __devinitdata = {
525 } 525 }
526}; 526};
527 527
528static const struct snd_ak4xxx_private akm_vx442_priv __devinitdata = { 528static struct snd_ak4xxx_private akm_vx442_priv __devinitdata = {
529 .caddr = 2, 529 .caddr = 2,
530 .cif = 0, 530 .cif = 0,
531 .data_mask = ICE1712_VX442_DOUT, 531 .data_mask = ICE1712_VX442_DOUT,
@@ -650,15 +650,15 @@ static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice)
650 * additional controls for M-Audio cards 650 * additional controls for M-Audio cards
651 */ 651 */
652 652
653static const struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_select __devinitdata = 653static struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_select __devinitdata =
654ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Sync", 0, ICE1712_DELTA_WORD_CLOCK_SELECT, 1, 0); 654ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Sync", 0, ICE1712_DELTA_WORD_CLOCK_SELECT, 1, 0);
655static const struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_select __devinitdata = 655static struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_select __devinitdata =
656ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Sync", 0, ICE1712_DELTA_1010LT_WORDCLOCK, 0, 0); 656ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Sync", 0, ICE1712_DELTA_1010LT_WORDCLOCK, 0, 0);
657static const struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_status __devinitdata = 657static struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_status __devinitdata =
658ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Status", 0, ICE1712_DELTA_WORD_CLOCK_STATUS, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE); 658ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Status", 0, ICE1712_DELTA_WORD_CLOCK_STATUS, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE);
659static const struct snd_kcontrol_new snd_ice1712_deltadio2496_spdif_in_select __devinitdata = 659static struct snd_kcontrol_new snd_ice1712_deltadio2496_spdif_in_select __devinitdata =
660ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, ICE1712_DELTA_SPDIF_INPUT_SELECT, 0, 0); 660ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, ICE1712_DELTA_SPDIF_INPUT_SELECT, 0, 0);
661static const struct snd_kcontrol_new snd_ice1712_delta_spdif_in_status __devinitdata = 661static struct snd_kcontrol_new snd_ice1712_delta_spdif_in_status __devinitdata =
662ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Delta IEC958 Input Status", 0, ICE1712_DELTA_SPDIF_IN_STAT, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE); 662ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Delta IEC958 Input Status", 0, ICE1712_DELTA_SPDIF_IN_STAT, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE);
663 663
664 664
@@ -735,7 +735,7 @@ static int __devinit snd_ice1712_delta_add_controls(struct snd_ice1712 *ice)
735 735
736 736
737/* entry point */ 737/* entry point */
738const struct snd_ice1712_card_info snd_ice1712_delta_cards[] __devinitdata = { 738struct snd_ice1712_card_info snd_ice1712_delta_cards[] __devinitdata = {
739 { 739 {
740 .subvendor = ICE1712_SUBDEVICE_DELTA1010, 740 .subvendor = ICE1712_SUBDEVICE_DELTA1010,
741 .name = "M Audio Delta 1010", 741 .name = "M Audio Delta 1010",
diff --git a/sound/pci/ice1712/delta.h b/sound/pci/ice1712/delta.h
index e47861ccd6e7..2697156607e4 100644
--- a/sound/pci/ice1712/delta.h
+++ b/sound/pci/ice1712/delta.h
@@ -46,7 +46,7 @@
46#define ICE1712_SUBDEVICE_MEDIASTATION 0x694c0100 46#define ICE1712_SUBDEVICE_MEDIASTATION 0x694c0100
47 47
48/* entry point */ 48/* entry point */
49extern const struct snd_ice1712_card_info snd_ice1712_delta_cards[]; 49extern struct snd_ice1712_card_info snd_ice1712_delta_cards[];
50 50
51 51
52/* 52/*
diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c
index 9b7ff302c072..b135389fec6c 100644
--- a/sound/pci/ice1712/ews.c
+++ b/sound/pci/ice1712/ews.c
@@ -332,7 +332,7 @@ static void ews88_setup_spdif(struct snd_ice1712 *ice, int rate)
332 332
333/* 333/*
334 */ 334 */
335static const struct snd_akm4xxx akm_ews88mt __devinitdata = { 335static struct snd_akm4xxx akm_ews88mt __devinitdata = {
336 .num_adcs = 8, 336 .num_adcs = 8,
337 .num_dacs = 8, 337 .num_dacs = 8,
338 .type = SND_AK4524, 338 .type = SND_AK4524,
@@ -342,7 +342,7 @@ static const struct snd_akm4xxx akm_ews88mt __devinitdata = {
342 } 342 }
343}; 343};
344 344
345static const struct snd_ak4xxx_private akm_ews88mt_priv __devinitdata = { 345static struct snd_ak4xxx_private akm_ews88mt_priv __devinitdata = {
346 .caddr = 2, 346 .caddr = 2,
347 .cif = 1, /* CIF high */ 347 .cif = 1, /* CIF high */
348 .data_mask = ICE1712_EWS88_SERIAL_DATA, 348 .data_mask = ICE1712_EWS88_SERIAL_DATA,
@@ -354,7 +354,7 @@ static const struct snd_ak4xxx_private akm_ews88mt_priv __devinitdata = {
354 .mask_flags = 0, 354 .mask_flags = 0,
355}; 355};
356 356
357static const struct snd_akm4xxx akm_ewx2496 __devinitdata = { 357static struct snd_akm4xxx akm_ewx2496 __devinitdata = {
358 .num_adcs = 2, 358 .num_adcs = 2,
359 .num_dacs = 2, 359 .num_dacs = 2,
360 .type = SND_AK4524, 360 .type = SND_AK4524,
@@ -363,7 +363,7 @@ static const struct snd_akm4xxx akm_ewx2496 __devinitdata = {
363 } 363 }
364}; 364};
365 365
366static const struct snd_ak4xxx_private akm_ewx2496_priv __devinitdata = { 366static struct snd_ak4xxx_private akm_ewx2496_priv __devinitdata = {
367 .caddr = 2, 367 .caddr = 2,
368 .cif = 1, /* CIF high */ 368 .cif = 1, /* CIF high */
369 .data_mask = ICE1712_EWS88_SERIAL_DATA, 369 .data_mask = ICE1712_EWS88_SERIAL_DATA,
@@ -375,7 +375,7 @@ static const struct snd_ak4xxx_private akm_ewx2496_priv __devinitdata = {
375 .mask_flags = 0, 375 .mask_flags = 0,
376}; 376};
377 377
378static const struct snd_akm4xxx akm_6fire __devinitdata = { 378static struct snd_akm4xxx akm_6fire __devinitdata = {
379 .num_adcs = 6, 379 .num_adcs = 6,
380 .num_dacs = 6, 380 .num_dacs = 6,
381 .type = SND_AK4524, 381 .type = SND_AK4524,
@@ -384,7 +384,7 @@ static const struct snd_akm4xxx akm_6fire __devinitdata = {
384 } 384 }
385}; 385};
386 386
387static const struct snd_ak4xxx_private akm_6fire_priv __devinitdata = { 387static struct snd_ak4xxx_private akm_6fire_priv __devinitdata = {
388 .caddr = 2, 388 .caddr = 2,
389 .cif = 1, /* CIF high */ 389 .cif = 1, /* CIF high */
390 .data_mask = ICE1712_6FIRE_SERIAL_DATA, 390 .data_mask = ICE1712_6FIRE_SERIAL_DATA,
@@ -578,7 +578,7 @@ static int snd_ice1712_ewx_io_sense_put(struct snd_kcontrol *kcontrol, struct sn
578 return val != nval; 578 return val != nval;
579} 579}
580 580
581static const struct snd_kcontrol_new snd_ice1712_ewx2496_controls[] __devinitdata = { 581static struct snd_kcontrol_new snd_ice1712_ewx2496_controls[] __devinitdata = {
582 { 582 {
583 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 583 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
584 .name = "Input Sensitivity Switch", 584 .name = "Input Sensitivity Switch",
@@ -678,7 +678,7 @@ static int snd_ice1712_ews88mt_input_sense_put(struct snd_kcontrol *kcontrol, st
678 return ndata != data; 678 return ndata != data;
679} 679}
680 680
681static const struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense __devinitdata = { 681static struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense __devinitdata = {
682 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 682 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
683 .name = "Input Sensitivity Switch", 683 .name = "Input Sensitivity Switch",
684 .info = snd_ice1712_ewx_io_sense_info, 684 .info = snd_ice1712_ewx_io_sense_info,
@@ -687,7 +687,7 @@ static const struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense __devinitda
687 .count = 8, 687 .count = 8,
688}; 688};
689 689
690static const struct snd_kcontrol_new snd_ice1712_ews88mt_output_sense __devinitdata = { 690static struct snd_kcontrol_new snd_ice1712_ews88mt_output_sense __devinitdata = {
691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
692 .name = "Output Sensitivity Switch", 692 .name = "Output Sensitivity Switch",
693 .info = snd_ice1712_ewx_io_sense_info, 693 .info = snd_ice1712_ewx_io_sense_info,
@@ -769,7 +769,7 @@ static int snd_ice1712_ews88d_control_put(struct snd_kcontrol *kcontrol, struct
769 .private_value = xshift | (xinvert << 8),\ 769 .private_value = xshift | (xinvert << 8),\
770} 770}
771 771
772static const struct snd_kcontrol_new snd_ice1712_ews88d_controls[] __devinitdata = { 772static struct snd_kcontrol_new snd_ice1712_ews88d_controls[] __devinitdata = {
773 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, 1, 0), /* inverted */ 773 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, 1, 0), /* inverted */
774 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Output Optical", 1, 0, 0), 774 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Output Optical", 1, 0, 0),
775 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT External Master Clock", 2, 0, 0), 775 EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT External Master Clock", 2, 0, 0),
@@ -909,7 +909,7 @@ static int snd_ice1712_6fire_select_input_put(struct snd_kcontrol *kcontrol, str
909 .private_value = xshift | (xinvert << 8),\ 909 .private_value = xshift | (xinvert << 8),\
910} 910}
911 911
912static const struct snd_kcontrol_new snd_ice1712_6fire_controls[] __devinitdata = { 912static struct snd_kcontrol_new snd_ice1712_6fire_controls[] __devinitdata = {
913 { 913 {
914 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 914 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
915 .name = "Analog Input Select", 915 .name = "Analog Input Select",
@@ -989,7 +989,7 @@ static int __devinit snd_ice1712_ews_add_controls(struct snd_ice1712 *ice)
989 989
990 990
991/* entry point */ 991/* entry point */
992const struct snd_ice1712_card_info snd_ice1712_ews_cards[] __devinitdata = { 992struct snd_ice1712_card_info snd_ice1712_ews_cards[] __devinitdata = {
993 { 993 {
994 .subvendor = ICE1712_SUBDEVICE_EWX2496, 994 .subvendor = ICE1712_SUBDEVICE_EWX2496,
995 .name = "TerraTec EWX24/96", 995 .name = "TerraTec EWX24/96",
diff --git a/sound/pci/ice1712/ews.h b/sound/pci/ice1712/ews.h
index df449b4741f6..a12a0b053558 100644
--- a/sound/pci/ice1712/ews.h
+++ b/sound/pci/ice1712/ews.h
@@ -40,7 +40,7 @@
40#define ICE1712_SUBDEVICE_PHASE88 0x3b155111 40#define ICE1712_SUBDEVICE_PHASE88 0x3b155111
41 41
42/* entry point */ 42/* entry point */
43extern const struct snd_ice1712_card_info snd_ice1712_ews_cards[]; 43extern struct snd_ice1712_card_info snd_ice1712_ews_cards[];
44 44
45 45
46/* TerraTec EWX 24/96 configuration definitions */ 46/* TerraTec EWX 24/96 configuration definitions */
diff --git a/sound/pci/ice1712/hoontech.c b/sound/pci/ice1712/hoontech.c
index df97313aaf83..8203562ef7e7 100644
--- a/sound/pci/ice1712/hoontech.c
+++ b/sound/pci/ice1712/hoontech.c
@@ -239,7 +239,7 @@ static void stdsp24_ak4524_lock(struct snd_akm4xxx *ak, int chip)
239static int __devinit snd_ice1712_value_init(struct snd_ice1712 *ice) 239static int __devinit snd_ice1712_value_init(struct snd_ice1712 *ice)
240{ 240{
241 /* Hoontech STDSP24 with modified hardware */ 241 /* Hoontech STDSP24 with modified hardware */
242 static const struct snd_akm4xxx akm_stdsp24_mv __devinitdata = { 242 static struct snd_akm4xxx akm_stdsp24_mv __devinitdata = {
243 .num_adcs = 2, 243 .num_adcs = 2,
244 .num_dacs = 2, 244 .num_dacs = 2,
245 .type = SND_AK4524, 245 .type = SND_AK4524,
@@ -248,7 +248,7 @@ static int __devinit snd_ice1712_value_init(struct snd_ice1712 *ice)
248 } 248 }
249 }; 249 };
250 250
251 static const struct snd_ak4xxx_private akm_stdsp24_mv_priv __devinitdata = { 251 static struct snd_ak4xxx_private akm_stdsp24_mv_priv __devinitdata = {
252 .caddr = 2, 252 .caddr = 2,
253 .cif = 1, /* CIF high */ 253 .cif = 1, /* CIF high */
254 .data_mask = ICE1712_STDSP24_SERIAL_DATA, 254 .data_mask = ICE1712_STDSP24_SERIAL_DATA,
@@ -298,7 +298,7 @@ static int __devinit snd_ice1712_ez8_init(struct snd_ice1712 *ice)
298 298
299 299
300/* entry point */ 300/* entry point */
301const struct snd_ice1712_card_info snd_ice1712_hoontech_cards[] __devinitdata = { 301struct snd_ice1712_card_info snd_ice1712_hoontech_cards[] __devinitdata = {
302 { 302 {
303 .subvendor = ICE1712_SUBDEVICE_STDSP24, 303 .subvendor = ICE1712_SUBDEVICE_STDSP24,
304 .name = "Hoontech SoundTrack Audio DSP24", 304 .name = "Hoontech SoundTrack Audio DSP24",
diff --git a/sound/pci/ice1712/hoontech.h b/sound/pci/ice1712/hoontech.h
index b62d6e4f6c71..1ee538b20fbf 100644
--- a/sound/pci/ice1712/hoontech.h
+++ b/sound/pci/ice1712/hoontech.h
@@ -35,7 +35,7 @@
35#define ICE1712_SUBDEVICE_STDSP24_MEDIA7_1 0x16141217 /* Hoontech ST Audio DSP24 Media 7.1 */ 35#define ICE1712_SUBDEVICE_STDSP24_MEDIA7_1 0x16141217 /* Hoontech ST Audio DSP24 Media 7.1 */
36#define ICE1712_SUBDEVICE_EVENT_EZ8 0x00010001 /* A dummy id for EZ8 */ 36#define ICE1712_SUBDEVICE_EVENT_EZ8 0x00010001 /* A dummy id for EZ8 */
37 37
38extern const struct snd_ice1712_card_info snd_ice1712_hoontech_cards[]; 38extern struct snd_ice1712_card_info snd_ice1712_hoontech_cards[];
39 39
40 40
41/* Hoontech SoundTrack Audio DSP 24 GPIO definitions */ 41/* Hoontech SoundTrack Audio DSP 24 GPIO definitions */
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 830a1bbd7110..6630a0ae9527 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -287,7 +287,7 @@ static int snd_ice1712_digmix_route_ac97_put(struct snd_kcontrol *kcontrol, stru
287 return val != nval; 287 return val != nval;
288} 288}
289 289
290static const struct snd_kcontrol_new snd_ice1712_mixer_digmix_route_ac97 __devinitdata = { 290static struct snd_kcontrol_new snd_ice1712_mixer_digmix_route_ac97 __devinitdata = {
291 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 291 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
292 .name = "Digital Mixer To AC97", 292 .name = "Digital Mixer To AC97",
293 .info = snd_ice1712_digmix_route_ac97_info, 293 .info = snd_ice1712_digmix_route_ac97_info,
@@ -977,11 +977,9 @@ static int snd_ice1712_pro_trigger(struct snd_pcm_substream *substream,
977 { 977 {
978 unsigned int what = 0; 978 unsigned int what = 0;
979 unsigned int old; 979 unsigned int old;
980 struct list_head *pos;
981 struct snd_pcm_substream *s; 980 struct snd_pcm_substream *s;
982 981
983 snd_pcm_group_for_each(pos, substream) { 982 snd_pcm_group_for_each_entry(s, substream) {
984 s = snd_pcm_group_substream_entry(pos);
985 if (s == ice->playback_pro_substream) { 983 if (s == ice->playback_pro_substream) {
986 what |= ICE1712_PLAYBACK_START; 984 what |= ICE1712_PLAYBACK_START;
987 snd_pcm_trigger_done(s, substream); 985 snd_pcm_trigger_done(s, substream);
@@ -1380,7 +1378,7 @@ static int snd_ice1712_pro_mixer_volume_put(struct snd_kcontrol *kcontrol, struc
1380 1378
1381static const DECLARE_TLV_DB_SCALE(db_scale_playback, -14400, 150, 0); 1379static const DECLARE_TLV_DB_SCALE(db_scale_playback, -14400, 150, 0);
1382 1380
1383static const struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] __devinitdata = { 1381static struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] __devinitdata = {
1384 { 1382 {
1385 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1383 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1386 .name = "Multi Playback Switch", 1384 .name = "Multi Playback Switch",
@@ -1404,7 +1402,7 @@ static const struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] __devini
1404 }, 1402 },
1405}; 1403};
1406 1404
1407static const struct snd_kcontrol_new snd_ice1712_multi_capture_analog_switch __devinitdata = { 1405static struct snd_kcontrol_new snd_ice1712_multi_capture_analog_switch __devinitdata = {
1408 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1406 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1409 .name = "H/W Multi Capture Switch", 1407 .name = "H/W Multi Capture Switch",
1410 .info = snd_ice1712_pro_mixer_switch_info, 1408 .info = snd_ice1712_pro_mixer_switch_info,
@@ -1413,7 +1411,7 @@ static const struct snd_kcontrol_new snd_ice1712_multi_capture_analog_switch __d
1413 .private_value = 10, 1411 .private_value = 10,
1414}; 1412};
1415 1413
1416static const struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_switch __devinitdata = { 1414static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_switch __devinitdata = {
1417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1415 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1418 .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,SWITCH), 1416 .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,SWITCH),
1419 .info = snd_ice1712_pro_mixer_switch_info, 1417 .info = snd_ice1712_pro_mixer_switch_info,
@@ -1423,7 +1421,7 @@ static const struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_switch __de
1423 .count = 2, 1421 .count = 2,
1424}; 1422};
1425 1423
1426static const struct snd_kcontrol_new snd_ice1712_multi_capture_analog_volume __devinitdata = { 1424static struct snd_kcontrol_new snd_ice1712_multi_capture_analog_volume __devinitdata = {
1427 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1425 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1428 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 1426 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1429 SNDRV_CTL_ELEM_ACCESS_TLV_READ), 1427 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
@@ -1435,7 +1433,7 @@ static const struct snd_kcontrol_new snd_ice1712_multi_capture_analog_volume __d
1435 .tlv = { .p = db_scale_playback } 1433 .tlv = { .p = db_scale_playback }
1436}; 1434};
1437 1435
1438static const struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_volume __devinitdata = { 1436static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_volume __devinitdata = {
1439 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1437 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1440 .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,VOLUME), 1438 .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,VOLUME),
1441 .info = snd_ice1712_pro_mixer_volume_info, 1439 .info = snd_ice1712_pro_mixer_volume_info,
@@ -1627,7 +1625,7 @@ static int snd_ice1712_eeprom_get(struct snd_kcontrol *kcontrol,
1627 return 0; 1625 return 0;
1628} 1626}
1629 1627
1630static const struct snd_kcontrol_new snd_ice1712_eeprom __devinitdata = { 1628static struct snd_kcontrol_new snd_ice1712_eeprom __devinitdata = {
1631 .iface = SNDRV_CTL_ELEM_IFACE_CARD, 1629 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
1632 .name = "ICE1712 EEPROM", 1630 .name = "ICE1712 EEPROM",
1633 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1631 .access = SNDRV_CTL_ELEM_ACCESS_READ,
@@ -1663,7 +1661,7 @@ static int snd_ice1712_spdif_default_put(struct snd_kcontrol *kcontrol,
1663 return 0; 1661 return 0;
1664} 1662}
1665 1663
1666static const struct snd_kcontrol_new snd_ice1712_spdif_default __devinitdata = 1664static struct snd_kcontrol_new snd_ice1712_spdif_default __devinitdata =
1667{ 1665{
1668 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1666 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
1669 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), 1667 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
@@ -1714,7 +1712,7 @@ static int snd_ice1712_spdif_maskp_get(struct snd_kcontrol *kcontrol,
1714 return 0; 1712 return 0;
1715} 1713}
1716 1714
1717static const struct snd_kcontrol_new snd_ice1712_spdif_maskc __devinitdata = 1715static struct snd_kcontrol_new snd_ice1712_spdif_maskc __devinitdata =
1718{ 1716{
1719 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1717 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1720 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1718 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
@@ -1723,7 +1721,7 @@ static const struct snd_kcontrol_new snd_ice1712_spdif_maskc __devinitdata =
1723 .get = snd_ice1712_spdif_maskc_get, 1721 .get = snd_ice1712_spdif_maskc_get,
1724}; 1722};
1725 1723
1726static const struct snd_kcontrol_new snd_ice1712_spdif_maskp __devinitdata = 1724static struct snd_kcontrol_new snd_ice1712_spdif_maskp __devinitdata =
1727{ 1725{
1728 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1726 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1729 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1727 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
@@ -1750,7 +1748,7 @@ static int snd_ice1712_spdif_stream_put(struct snd_kcontrol *kcontrol,
1750 return 0; 1748 return 0;
1751} 1749}
1752 1750
1753static const struct snd_kcontrol_new snd_ice1712_spdif_stream __devinitdata = 1751static struct snd_kcontrol_new snd_ice1712_spdif_stream __devinitdata =
1754{ 1752{
1755 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 1753 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
1756 SNDRV_CTL_ELEM_ACCESS_INACTIVE), 1754 SNDRV_CTL_ELEM_ACCESS_INACTIVE),
@@ -1891,7 +1889,7 @@ static int snd_ice1712_pro_internal_clock_put(struct snd_kcontrol *kcontrol,
1891 return change; 1889 return change;
1892} 1890}
1893 1891
1894static const struct snd_kcontrol_new snd_ice1712_pro_internal_clock __devinitdata = { 1892static struct snd_kcontrol_new snd_ice1712_pro_internal_clock __devinitdata = {
1895 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1893 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1896 .name = "Multi Track Internal Clock", 1894 .name = "Multi Track Internal Clock",
1897 .info = snd_ice1712_pro_internal_clock_info, 1895 .info = snd_ice1712_pro_internal_clock_info,
@@ -1962,7 +1960,7 @@ static int snd_ice1712_pro_internal_clock_default_put(struct snd_kcontrol *kcont
1962 return change; 1960 return change;
1963} 1961}
1964 1962
1965static const struct snd_kcontrol_new snd_ice1712_pro_internal_clock_default __devinitdata = { 1963static struct snd_kcontrol_new snd_ice1712_pro_internal_clock_default __devinitdata = {
1966 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1964 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1967 .name = "Multi Track Internal Clock Default", 1965 .name = "Multi Track Internal Clock Default",
1968 .info = snd_ice1712_pro_internal_clock_default_info, 1966 .info = snd_ice1712_pro_internal_clock_default_info,
@@ -2001,7 +1999,7 @@ static int snd_ice1712_pro_rate_locking_put(struct snd_kcontrol *kcontrol,
2001 return change; 1999 return change;
2002} 2000}
2003 2001
2004static const struct snd_kcontrol_new snd_ice1712_pro_rate_locking __devinitdata = { 2002static struct snd_kcontrol_new snd_ice1712_pro_rate_locking __devinitdata = {
2005 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2003 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2006 .name = "Multi Track Rate Locking", 2004 .name = "Multi Track Rate Locking",
2007 .info = snd_ice1712_pro_rate_locking_info, 2005 .info = snd_ice1712_pro_rate_locking_info,
@@ -2040,7 +2038,7 @@ static int snd_ice1712_pro_rate_reset_put(struct snd_kcontrol *kcontrol,
2040 return change; 2038 return change;
2041} 2039}
2042 2040
2043static const struct snd_kcontrol_new snd_ice1712_pro_rate_reset __devinitdata = { 2041static struct snd_kcontrol_new snd_ice1712_pro_rate_reset __devinitdata = {
2044 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2042 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2045 .name = "Multi Track Rate Reset", 2043 .name = "Multi Track Rate Reset",
2046 .info = snd_ice1712_pro_rate_reset_info, 2044 .info = snd_ice1712_pro_rate_reset_info,
@@ -2207,7 +2205,7 @@ static int snd_ice1712_pro_route_spdif_put(struct snd_kcontrol *kcontrol,
2207 return change; 2205 return change;
2208} 2206}
2209 2207
2210static const struct snd_kcontrol_new snd_ice1712_mixer_pro_analog_route __devinitdata = { 2208static struct snd_kcontrol_new snd_ice1712_mixer_pro_analog_route __devinitdata = {
2211 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2209 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2212 .name = "H/W Playback Route", 2210 .name = "H/W Playback Route",
2213 .info = snd_ice1712_pro_route_info, 2211 .info = snd_ice1712_pro_route_info,
@@ -2215,7 +2213,7 @@ static const struct snd_kcontrol_new snd_ice1712_mixer_pro_analog_route __devini
2215 .put = snd_ice1712_pro_route_analog_put, 2213 .put = snd_ice1712_pro_route_analog_put,
2216}; 2214};
2217 2215
2218static const struct snd_kcontrol_new snd_ice1712_mixer_pro_spdif_route __devinitdata = { 2216static struct snd_kcontrol_new snd_ice1712_mixer_pro_spdif_route __devinitdata = {
2219 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2217 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2220 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route", 2218 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route",
2221 .info = snd_ice1712_pro_route_info, 2219 .info = snd_ice1712_pro_route_info,
@@ -2257,7 +2255,7 @@ static int snd_ice1712_pro_volume_rate_put(struct snd_kcontrol *kcontrol,
2257 return change; 2255 return change;
2258} 2256}
2259 2257
2260static const struct snd_kcontrol_new snd_ice1712_mixer_pro_volume_rate __devinitdata = { 2258static struct snd_kcontrol_new snd_ice1712_mixer_pro_volume_rate __devinitdata = {
2261 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2259 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2262 .name = "Multi Track Volume Rate", 2260 .name = "Multi Track Volume Rate",
2263 .info = snd_ice1712_pro_volume_rate_info, 2261 .info = snd_ice1712_pro_volume_rate_info,
@@ -2290,7 +2288,7 @@ static int snd_ice1712_pro_peak_get(struct snd_kcontrol *kcontrol,
2290 return 0; 2288 return 0;
2291} 2289}
2292 2290
2293static const struct snd_kcontrol_new snd_ice1712_mixer_pro_peak __devinitdata = { 2291static struct snd_kcontrol_new snd_ice1712_mixer_pro_peak __devinitdata = {
2294 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2292 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2295 .name = "Multi Track Peak", 2293 .name = "Multi Track Peak",
2296 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, 2294 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
@@ -2305,7 +2303,7 @@ static const struct snd_kcontrol_new snd_ice1712_mixer_pro_peak __devinitdata =
2305/* 2303/*
2306 * list of available boards 2304 * list of available boards
2307 */ 2305 */
2308static const struct snd_ice1712_card_info *card_tables[] __devinitdata = { 2306static struct snd_ice1712_card_info *card_tables[] __devinitdata = {
2309 snd_ice1712_hoontech_cards, 2307 snd_ice1712_hoontech_cards,
2310 snd_ice1712_delta_cards, 2308 snd_ice1712_delta_cards,
2311 snd_ice1712_ews_cards, 2309 snd_ice1712_ews_cards,
@@ -2329,7 +2327,7 @@ static int __devinit snd_ice1712_read_eeprom(struct snd_ice1712 *ice,
2329{ 2327{
2330 int dev = 0xa0; /* EEPROM device address */ 2328 int dev = 0xa0; /* EEPROM device address */
2331 unsigned int i, size; 2329 unsigned int i, size;
2332 const struct snd_ice1712_card_info **tbl, *c; 2330 struct snd_ice1712_card_info * const *tbl, *c;
2333 2331
2334 if (! modelname || ! *modelname) { 2332 if (! modelname || ! *modelname) {
2335 ice->eeprom.subvendor = 0; 2333 ice->eeprom.subvendor = 0;
@@ -2658,7 +2656,7 @@ static int __devinit snd_ice1712_create(struct snd_card *card,
2658 * 2656 *
2659 */ 2657 */
2660 2658
2661static const struct snd_ice1712_card_info no_matched __devinitdata; 2659static struct snd_ice1712_card_info no_matched __devinitdata;
2662 2660
2663static int __devinit snd_ice1712_probe(struct pci_dev *pci, 2661static int __devinit snd_ice1712_probe(struct pci_dev *pci,
2664 const struct pci_device_id *pci_id) 2662 const struct pci_device_id *pci_id)
@@ -2667,7 +2665,7 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci,
2667 struct snd_card *card; 2665 struct snd_card *card;
2668 struct snd_ice1712 *ice; 2666 struct snd_ice1712 *ice;
2669 int pcm_dev = 0, err; 2667 int pcm_dev = 0, err;
2670 const struct snd_ice1712_card_info **tbl, *c; 2668 struct snd_ice1712_card_info * const *tbl, *c;
2671 2669
2672 if (dev >= SNDRV_CARDS) 2670 if (dev >= SNDRV_CARDS)
2673 return -ENODEV; 2671 return -ENODEV;
diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h
index c3d9feaaf57d..6ac486d9c138 100644
--- a/sound/pci/ice1712/ice1712.h
+++ b/sound/pci/ice1712/ice1712.h
@@ -397,6 +397,9 @@ struct snd_ice1712 {
397 struct ak4114 *ak4114; 397 struct ak4114 *ak4114;
398 unsigned int analog: 1; 398 unsigned int analog: 1;
399 } juli; 399 } juli;
400 struct {
401 struct ak4114 *ak4114;
402 } prodigy192;
400 } spec; 403 } spec;
401 404
402}; 405};
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 1127ebdf5fec..ee620dea7ef3 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -337,13 +337,11 @@ static int snd_vt1724_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
337 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 337 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
338 unsigned char what; 338 unsigned char what;
339 unsigned char old; 339 unsigned char old;
340 struct list_head *pos;
341 struct snd_pcm_substream *s; 340 struct snd_pcm_substream *s;
342 341
343 what = 0; 342 what = 0;
344 snd_pcm_group_for_each(pos, substream) { 343 snd_pcm_group_for_each_entry(s, substream) {
345 const struct vt1724_pcm_reg *reg; 344 const struct vt1724_pcm_reg *reg;
346 s = snd_pcm_group_substream_entry(pos);
347 reg = s->runtime->private_data; 345 reg = s->runtime->private_data;
348 what |= reg->start; 346 what |= reg->start;
349 snd_pcm_trigger_done(s, substream); 347 snd_pcm_trigger_done(s, substream);
@@ -1318,7 +1316,7 @@ static int snd_vt1724_eeprom_get(struct snd_kcontrol *kcontrol,
1318 return 0; 1316 return 0;
1319} 1317}
1320 1318
1321static const struct snd_kcontrol_new snd_vt1724_eeprom __devinitdata = { 1319static struct snd_kcontrol_new snd_vt1724_eeprom __devinitdata = {
1322 .iface = SNDRV_CTL_ELEM_IFACE_CARD, 1320 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
1323 .name = "ICE1724 EEPROM", 1321 .name = "ICE1724 EEPROM",
1324 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1322 .access = SNDRV_CTL_ELEM_ACCESS_READ,
@@ -1431,7 +1429,7 @@ static int snd_vt1724_spdif_default_put(struct snd_kcontrol *kcontrol,
1431 return (val != old); 1429 return (val != old);
1432} 1430}
1433 1431
1434static const struct snd_kcontrol_new snd_vt1724_spdif_default __devinitdata = 1432static struct snd_kcontrol_new snd_vt1724_spdif_default __devinitdata =
1435{ 1433{
1436 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1434 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
1437 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), 1435 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
@@ -1463,7 +1461,7 @@ static int snd_vt1724_spdif_maskp_get(struct snd_kcontrol *kcontrol,
1463 return 0; 1461 return 0;
1464} 1462}
1465 1463
1466static const struct snd_kcontrol_new snd_vt1724_spdif_maskc __devinitdata = 1464static struct snd_kcontrol_new snd_vt1724_spdif_maskc __devinitdata =
1467{ 1465{
1468 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1466 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1469 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1467 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
@@ -1472,7 +1470,7 @@ static const struct snd_kcontrol_new snd_vt1724_spdif_maskc __devinitdata =
1472 .get = snd_vt1724_spdif_maskc_get, 1470 .get = snd_vt1724_spdif_maskc_get,
1473}; 1471};
1474 1472
1475static const struct snd_kcontrol_new snd_vt1724_spdif_maskp __devinitdata = 1473static struct snd_kcontrol_new snd_vt1724_spdif_maskp __devinitdata =
1476{ 1474{
1477 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1475 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1478 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 1476 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
@@ -1517,7 +1515,7 @@ static int snd_vt1724_spdif_sw_put(struct snd_kcontrol *kcontrol,
1517 return old != val; 1515 return old != val;
1518} 1516}
1519 1517
1520static const struct snd_kcontrol_new snd_vt1724_spdif_switch __devinitdata = 1518static struct snd_kcontrol_new snd_vt1724_spdif_switch __devinitdata =
1521{ 1519{
1522 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1520 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1523 /* FIXME: the following conflict with IEC958 Playback Route */ 1521 /* FIXME: the following conflict with IEC958 Playback Route */
@@ -1668,7 +1666,12 @@ static int snd_vt1724_pro_internal_clock_put(struct snd_kcontrol *kcontrol,
1668 spin_lock_irq(&ice->reg_lock); 1666 spin_lock_irq(&ice->reg_lock);
1669 oval = inb(ICEMT1724(ice, RATE)); 1667 oval = inb(ICEMT1724(ice, RATE));
1670 if (ucontrol->value.enumerated.item[0] == spdif) { 1668 if (ucontrol->value.enumerated.item[0] == spdif) {
1669 unsigned char i2s_oval;
1671 outb(oval | VT1724_SPDIF_MASTER, ICEMT1724(ice, RATE)); 1670 outb(oval | VT1724_SPDIF_MASTER, ICEMT1724(ice, RATE));
1671 /* setting 256fs */
1672 i2s_oval = inb(ICEMT1724(ice, I2S_FORMAT));
1673 outb(i2s_oval & ~VT1724_MT_I2S_MCLK_128X,
1674 ICEMT1724(ice, I2S_FORMAT));
1672 } else { 1675 } else {
1673 rate = rates[ucontrol->value.integer.value[0] % 15]; 1676 rate = rates[ucontrol->value.integer.value[0] % 15];
1674 if (rate <= get_max_rate(ice)) { 1677 if (rate <= get_max_rate(ice)) {
@@ -1695,7 +1698,7 @@ static int snd_vt1724_pro_internal_clock_put(struct snd_kcontrol *kcontrol,
1695 return change; 1698 return change;
1696} 1699}
1697 1700
1698static const struct snd_kcontrol_new snd_vt1724_pro_internal_clock __devinitdata = { 1701static struct snd_kcontrol_new snd_vt1724_pro_internal_clock __devinitdata = {
1699 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1702 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1700 .name = "Multi Track Internal Clock", 1703 .name = "Multi Track Internal Clock",
1701 .info = snd_vt1724_pro_internal_clock_info, 1704 .info = snd_vt1724_pro_internal_clock_info,
@@ -1734,7 +1737,7 @@ static int snd_vt1724_pro_rate_locking_put(struct snd_kcontrol *kcontrol,
1734 return change; 1737 return change;
1735} 1738}
1736 1739
1737static const struct snd_kcontrol_new snd_vt1724_pro_rate_locking __devinitdata = { 1740static struct snd_kcontrol_new snd_vt1724_pro_rate_locking __devinitdata = {
1738 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1741 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1739 .name = "Multi Track Rate Locking", 1742 .name = "Multi Track Rate Locking",
1740 .info = snd_vt1724_pro_rate_locking_info, 1743 .info = snd_vt1724_pro_rate_locking_info,
@@ -1773,7 +1776,7 @@ static int snd_vt1724_pro_rate_reset_put(struct snd_kcontrol *kcontrol,
1773 return change; 1776 return change;
1774} 1777}
1775 1778
1776static const struct snd_kcontrol_new snd_vt1724_pro_rate_reset __devinitdata = { 1779static struct snd_kcontrol_new snd_vt1724_pro_rate_reset __devinitdata = {
1777 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1780 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1778 .name = "Multi Track Rate Reset", 1781 .name = "Multi Track Rate Reset",
1779 .info = snd_vt1724_pro_rate_reset_info, 1782 .info = snd_vt1724_pro_rate_reset_info,
@@ -1892,7 +1895,7 @@ static int snd_vt1724_pro_route_spdif_put(struct snd_kcontrol *kcontrol,
1892 digital_route_shift(idx)); 1895 digital_route_shift(idx));
1893} 1896}
1894 1897
1895static const struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route __devinitdata = { 1898static struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route __devinitdata = {
1896 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1899 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1897 .name = "H/W Playback Route", 1900 .name = "H/W Playback Route",
1898 .info = snd_vt1724_pro_route_info, 1901 .info = snd_vt1724_pro_route_info,
@@ -1900,7 +1903,7 @@ static const struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route __devinit
1900 .put = snd_vt1724_pro_route_analog_put, 1903 .put = snd_vt1724_pro_route_analog_put,
1901}; 1904};
1902 1905
1903static const struct snd_kcontrol_new snd_vt1724_mixer_pro_spdif_route __devinitdata = { 1906static struct snd_kcontrol_new snd_vt1724_mixer_pro_spdif_route __devinitdata = {
1904 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1907 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1905 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route", 1908 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route",
1906 .info = snd_vt1724_pro_route_info, 1909 .info = snd_vt1724_pro_route_info,
@@ -1936,7 +1939,7 @@ static int snd_vt1724_pro_peak_get(struct snd_kcontrol *kcontrol,
1936 return 0; 1939 return 0;
1937} 1940}
1938 1941
1939static const struct snd_kcontrol_new snd_vt1724_mixer_pro_peak __devinitdata = { 1942static struct snd_kcontrol_new snd_vt1724_mixer_pro_peak __devinitdata = {
1940 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1941 .name = "Multi Track Peak", 1944 .name = "Multi Track Peak",
1942 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, 1945 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
@@ -1948,9 +1951,9 @@ static const struct snd_kcontrol_new snd_vt1724_mixer_pro_peak __devinitdata = {
1948 * 1951 *
1949 */ 1952 */
1950 1953
1951static const struct snd_ice1712_card_info no_matched __devinitdata; 1954static struct snd_ice1712_card_info no_matched __devinitdata;
1952 1955
1953static const struct snd_ice1712_card_info *card_tables[] __devinitdata = { 1956static struct snd_ice1712_card_info *card_tables[] __devinitdata = {
1954 snd_vt1724_revo_cards, 1957 snd_vt1724_revo_cards,
1955 snd_vt1724_amp_cards, 1958 snd_vt1724_amp_cards,
1956 snd_vt1724_aureon_cards, 1959 snd_vt1724_aureon_cards,
@@ -2009,7 +2012,7 @@ static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
2009{ 2012{
2010 const int dev = 0xa0; /* EEPROM device address */ 2013 const int dev = 0xa0; /* EEPROM device address */
2011 unsigned int i, size; 2014 unsigned int i, size;
2012 const struct snd_ice1712_card_info **tbl, *c; 2015 struct snd_ice1712_card_info * const *tbl, *c;
2013 2016
2014 if (! modelname || ! *modelname) { 2017 if (! modelname || ! *modelname) {
2015 ice->eeprom.subvendor = 0; 2018 ice->eeprom.subvendor = 0;
@@ -2308,7 +2311,7 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci,
2308 struct snd_card *card; 2311 struct snd_card *card;
2309 struct snd_ice1712 *ice; 2312 struct snd_ice1712 *ice;
2310 int pcm_dev = 0, err; 2313 int pcm_dev = 0, err;
2311 const struct snd_ice1712_card_info **tbl, *c; 2314 struct snd_ice1712_card_info * const *tbl, *c;
2312 2315
2313 if (dev >= SNDRV_CARDS) 2316 if (dev >= SNDRV_CARDS)
2314 return -ENODEV; 2317 return -ENODEV;
@@ -2347,6 +2350,14 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci,
2347 } 2350 }
2348 c = &no_matched; 2351 c = &no_matched;
2349 __found: 2352 __found:
2353 /*
2354 * VT1724 has separate DMAs for the analog and the SPDIF streams while
2355 * ICE1712 has only one for both (mixed up).
2356 *
2357 * Confusingly the analog PCM is named "professional" here because it
2358 * was called so in ice1712 driver, and vt1724 driver is derived from
2359 * ice1712 driver.
2360 */
2350 2361
2351 if ((err = snd_vt1724_pcm_profi(ice, pcm_dev++)) < 0) { 2362 if ((err = snd_vt1724_pcm_profi(ice, pcm_dev++)) < 0) {
2352 snd_card_free(card); 2363 snd_card_free(card);
diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c
index d88172fa95da..3d8e74e493d7 100644
--- a/sound/pci/ice1712/juli.c
+++ b/sound/pci/ice1712/juli.c
@@ -125,7 +125,7 @@ static void juli_akm_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
125 snd_akm4xxx_reset(ak, 0); 125 snd_akm4xxx_reset(ak, 0);
126} 126}
127 127
128static const struct snd_akm4xxx akm_juli_dac __devinitdata = { 128static struct snd_akm4xxx akm_juli_dac __devinitdata = {
129 .type = SND_AK4358, 129 .type = SND_AK4358,
130 .num_dacs = 2, 130 .num_dacs = 2,
131 .ops = { 131 .ops = {
@@ -138,7 +138,16 @@ static const struct snd_akm4xxx akm_juli_dac __devinitdata = {
138 138
139static int __devinit juli_add_controls(struct snd_ice1712 *ice) 139static int __devinit juli_add_controls(struct snd_ice1712 *ice)
140{ 140{
141 return snd_ice1712_akm4xxx_build_controls(ice); 141 int err;
142 err = snd_ice1712_akm4xxx_build_controls(ice);
143 if (err < 0)
144 return err;
145 /* only capture SPDIF over AK4114 */
146 err = snd_ak4114_build(ice->spec.juli.ak4114, NULL,
147 ice->pcm_pro->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
148 if (err < 0)
149 return err;
150 return 0;
142} 151}
143 152
144/* 153/*
@@ -160,13 +169,6 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
160 int err; 169 int err;
161 struct snd_akm4xxx *ak; 170 struct snd_akm4xxx *ak;
162 171
163#if 0
164 for (err = 0; err < 0x20; err++)
165 juli_ak4114_read(ice, err);
166 juli_ak4114_write(ice, 0, 0x0f);
167 juli_ak4114_read(ice, 0);
168 juli_ak4114_read(ice, 1);
169#endif
170 err = snd_ak4114_create(ice->card, 172 err = snd_ak4114_create(ice->card,
171 juli_ak4114_read, 173 juli_ak4114_read,
172 juli_ak4114_write, 174 juli_ak4114_write,
@@ -206,7 +208,7 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
206 * hence the driver needs to sets up it properly. 208 * hence the driver needs to sets up it properly.
207 */ 209 */
208 210
209static const unsigned char juli_eeprom[] __devinitdata = { 211static unsigned char juli_eeprom[] __devinitdata = {
210 [ICE_EEP2_SYSCONF] = 0x20, /* clock 512, mpu401, 1xADC, 1xDACs */ 212 [ICE_EEP2_SYSCONF] = 0x20, /* clock 512, mpu401, 1xADC, 1xDACs */
211 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 213 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
212 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */ 214 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */
@@ -223,7 +225,7 @@ static const unsigned char juli_eeprom[] __devinitdata = {
223}; 225};
224 226
225/* entry point */ 227/* entry point */
226const struct snd_ice1712_card_info snd_vt1724_juli_cards[] __devinitdata = { 228struct snd_ice1712_card_info snd_vt1724_juli_cards[] __devinitdata = {
227 { 229 {
228 .subvendor = VT1724_SUBDEVICE_JULI, 230 .subvendor = VT1724_SUBDEVICE_JULI,
229 .name = "ESI Juli@", 231 .name = "ESI Juli@",
diff --git a/sound/pci/ice1712/juli.h b/sound/pci/ice1712/juli.h
index 1b9294f8bce3..d9f8534fd92e 100644
--- a/sound/pci/ice1712/juli.h
+++ b/sound/pci/ice1712/juli.h
@@ -5,6 +5,6 @@
5 5
6#define VT1724_SUBDEVICE_JULI 0x31305345 /* Juli@ */ 6#define VT1724_SUBDEVICE_JULI 0x31305345 /* Juli@ */
7 7
8extern const struct snd_ice1712_card_info snd_vt1724_juli_cards[]; 8extern struct snd_ice1712_card_info snd_vt1724_juli_cards[];
9 9
10#endif /* __SOUND_JULI_H */ 10#endif /* __SOUND_JULI_H */
diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c
index 0751718f4d7b..40a9098af777 100644
--- a/sound/pci/ice1712/phase.c
+++ b/sound/pci/ice1712/phase.c
@@ -89,13 +89,13 @@ static const unsigned char wm_vol[256] = {
89#define WM_VOL_MAX (sizeof(wm_vol) - 1) 89#define WM_VOL_MAX (sizeof(wm_vol) - 1)
90#define WM_VOL_MUTE 0x8000 90#define WM_VOL_MUTE 0x8000
91 91
92static const struct snd_akm4xxx akm_phase22 __devinitdata = { 92static struct snd_akm4xxx akm_phase22 __devinitdata = {
93 .type = SND_AK4524, 93 .type = SND_AK4524,
94 .num_dacs = 2, 94 .num_dacs = 2,
95 .num_adcs = 2, 95 .num_adcs = 2,
96}; 96};
97 97
98static const struct snd_ak4xxx_private akm_phase22_priv __devinitdata = { 98static struct snd_ak4xxx_private akm_phase22_priv __devinitdata = {
99 .caddr = 2, 99 .caddr = 2,
100 .cif = 1, 100 .cif = 1,
101 .data_mask = 1 << 4, 101 .data_mask = 1 << 4,
@@ -152,7 +152,7 @@ static int __devinit phase22_add_controls(struct snd_ice1712 *ice)
152 return 0; 152 return 0;
153} 153}
154 154
155static const unsigned char phase22_eeprom[] __devinitdata = { 155static unsigned char phase22_eeprom[] __devinitdata = {
156 [ICE_EEP2_SYSCONF] = 0x00, /* 1xADC, 1xDACs */ 156 [ICE_EEP2_SYSCONF] = 0x00, /* 1xADC, 1xDACs */
157 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 157 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
158 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit */ 158 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit */
@@ -168,7 +168,7 @@ static const unsigned char phase22_eeprom[] __devinitdata = {
168 [ICE_EEP2_GPIO_STATE2] = 0x00, 168 [ICE_EEP2_GPIO_STATE2] = 0x00,
169}; 169};
170 170
171static const unsigned char phase28_eeprom[] __devinitdata = { 171static unsigned char phase28_eeprom[] __devinitdata = {
172 [ICE_EEP2_SYSCONF] = 0x0b, /* clock 512, spdif-in/ADC, 4DACs */ 172 [ICE_EEP2_SYSCONF] = 0x0b, /* clock 512, spdif-in/ADC, 4DACs */
173 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 173 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
174 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */ 174 [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
@@ -700,7 +700,7 @@ static int phase28_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ct
700static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1); 700static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1);
701static const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1); 701static const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1);
702 702
703static const struct snd_kcontrol_new phase28_dac_controls[] __devinitdata = { 703static struct snd_kcontrol_new phase28_dac_controls[] __devinitdata = {
704 { 704 {
705 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 705 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
706 .name = "Master Playback Switch", 706 .name = "Master Playback Switch",
@@ -815,7 +815,7 @@ static const struct snd_kcontrol_new phase28_dac_controls[] __devinitdata = {
815 } 815 }
816}; 816};
817 817
818static const struct snd_kcontrol_new wm_controls[] __devinitdata = { 818static struct snd_kcontrol_new wm_controls[] __devinitdata = {
819 { 819 {
820 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 820 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
821 .name = "PCM Playback Switch", 821 .name = "PCM Playback Switch",
@@ -870,7 +870,7 @@ static int __devinit phase28_add_controls(struct snd_ice1712 *ice)
870 return 0; 870 return 0;
871} 871}
872 872
873const struct snd_ice1712_card_info snd_vt1724_phase_cards[] __devinitdata = { 873struct snd_ice1712_card_info snd_vt1724_phase_cards[] __devinitdata = {
874 { 874 {
875 .subvendor = VT1724_SUBDEVICE_PHASE22, 875 .subvendor = VT1724_SUBDEVICE_PHASE22,
876 .name = "Terratec PHASE 22", 876 .name = "Terratec PHASE 22",
diff --git a/sound/pci/ice1712/phase.h b/sound/pci/ice1712/phase.h
index ad379a99bf92..13e841b55488 100644
--- a/sound/pci/ice1712/phase.h
+++ b/sound/pci/ice1712/phase.h
@@ -31,7 +31,7 @@
31#define VT1724_SUBDEVICE_PHASE28 0x3b154911 31#define VT1724_SUBDEVICE_PHASE28 0x3b154911
32 32
33/* entry point */ 33/* entry point */
34extern const struct snd_ice1712_card_info snd_vt1724_phase_cards[]; 34extern struct snd_ice1712_card_info snd_vt1724_phase_cards[];
35 35
36/* PHASE28 GPIO bits */ 36/* PHASE28 GPIO bits */
37#define PHASE28_SPI_MISO (1 << 21) 37#define PHASE28_SPI_MISO (1 << 21)
diff --git a/sound/pci/ice1712/pontis.c b/sound/pci/ice1712/pontis.c
index 9552497f0765..01c69453ddeb 100644
--- a/sound/pci/ice1712/pontis.c
+++ b/sound/pci/ice1712/pontis.c
@@ -571,7 +571,7 @@ static const DECLARE_TLV_DB_SCALE(db_scale_volume, -6400, 50, 1);
571 * mixers 571 * mixers
572 */ 572 */
573 573
574static const struct snd_kcontrol_new pontis_controls[] __devinitdata = { 574static struct snd_kcontrol_new pontis_controls[] __devinitdata = {
575 { 575 {
576 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 576 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
577 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 577 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
@@ -826,7 +826,7 @@ static int __devinit pontis_init(struct snd_ice1712 *ice)
826 * hence the driver needs to sets up it properly. 826 * hence the driver needs to sets up it properly.
827 */ 827 */
828 828
829static const unsigned char pontis_eeprom[] __devinitdata = { 829static unsigned char pontis_eeprom[] __devinitdata = {
830 [ICE_EEP2_SYSCONF] = 0x08, /* clock 256, mpu401, spdif-in/ADC, 1DAC */ 830 [ICE_EEP2_SYSCONF] = 0x08, /* clock 256, mpu401, spdif-in/ADC, 1DAC */
831 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 831 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
832 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */ 832 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */
@@ -843,7 +843,7 @@ static const unsigned char pontis_eeprom[] __devinitdata = {
843}; 843};
844 844
845/* entry point */ 845/* entry point */
846const struct snd_ice1712_card_info snd_vt1720_pontis_cards[] __devinitdata = { 846struct snd_ice1712_card_info snd_vt1720_pontis_cards[] __devinitdata = {
847 { 847 {
848 .subvendor = VT1720_SUBDEVICE_PONTIS_MS300, 848 .subvendor = VT1720_SUBDEVICE_PONTIS_MS300,
849 .name = "Pontis MS300", 849 .name = "Pontis MS300",
diff --git a/sound/pci/ice1712/pontis.h b/sound/pci/ice1712/pontis.h
index 1a418255c19e..d0d1378b935c 100644
--- a/sound/pci/ice1712/pontis.h
+++ b/sound/pci/ice1712/pontis.h
@@ -28,6 +28,6 @@
28 28
29#define VT1720_SUBDEVICE_PONTIS_MS300 0x00020002 /* a dummy id for MS300 */ 29#define VT1720_SUBDEVICE_PONTIS_MS300 0x00020002 /* a dummy id for MS300 */
30 30
31extern const struct snd_ice1712_card_info snd_vt1720_pontis_cards[]; 31extern struct snd_ice1712_card_info snd_vt1720_pontis_cards[];
32 32
33#endif /* __SOUND_PONTIS_H */ 33#endif /* __SOUND_PONTIS_H */
diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c
index 31cc66eb9f8f..f03c02c07743 100644
--- a/sound/pci/ice1712/prodigy192.c
+++ b/sound/pci/ice1712/prodigy192.c
@@ -2,6 +2,37 @@
2 * ALSA driver for ICEnsemble VT1724 (Envy24HT) 2 * ALSA driver for ICEnsemble VT1724 (Envy24HT)
3 * 3 *
4 * Lowlevel functions for AudioTrak Prodigy 192 cards 4 * Lowlevel functions for AudioTrak Prodigy 192 cards
5 * Supported IEC958 input from optional MI/ODI/O add-on card.
6 *
7 * Specifics (SW, HW):
8 * -------------------
9 * * 49.5MHz crystal
10 * * SPDIF-OUT on the card:
11 * - coax (through isolation transformer)/toslink supplied by
12 * 74HC04 gates - 3 in parallel
13 * - output switched between on-board CD drive dig-out connector
14 * and ice1724 SPDTX pin, using 74HC02 NOR gates, controlled
15 * by GPIO20 (0 = CD dig-out, 1 = SPDTX)
16 * * SPDTX goes straight to MI/ODI/O card's SPDIF-OUT coax
17 *
18 * * MI/ODI/O card: AK4114 based, used for iec958 input only
19 * - toslink input -> RX0
20 * - coax input -> RX1
21 * - 4wire protocol:
22 * AK4114 ICE1724
23 * ------------------------------
24 * CDTO (pin 32) -- GPIO11 pin 86
25 * CDTI (pin 33) -- GPIO10 pin 77
26 * CCLK (pin 34) -- GPIO9 pin 76
27 * CSN (pin 35) -- GPIO8 pin 75
28 * - output data Mode 7 (24bit, I2S, slave)
29 * - both MCKO1 and MCKO2 of ak4114 are fed to FPGA, which
30 * outputs master clock to SPMCLKIN of ice1724.
31 * Experimentally I found out that only a combination of
32 * OCKS0=1, OCKS1=1 (128fs, 64fs output) and ice1724 -
33 * VT1724_MT_I2S_MCLK_128X=0 (256fs input) yields correct
34 * sampling rate. That means the the FPGA doubles the
35 * MCK01 rate.
5 * 36 *
6 * Copyright (c) 2003 Takashi Iwai <tiwai@suse.de> 37 * Copyright (c) 2003 Takashi Iwai <tiwai@suse.de>
7 * Copyright (c) 2003 Dimitromanolakis Apostolos <apostol@cs.utoronto.ca> 38 * Copyright (c) 2003 Dimitromanolakis Apostolos <apostol@cs.utoronto.ca>
@@ -356,6 +387,47 @@ static int aureon_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ctl
356 return 0; 387 return 0;
357} 388}
358#endif 389#endif
390static int stac9460_mic_sw_info(struct snd_kcontrol *kcontrol,
391 struct snd_ctl_elem_info *uinfo)
392{
393 static char *texts[2] = { "Line In", "Mic" };
394
395 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
396 uinfo->count = 1;
397 uinfo->value.enumerated.items = 2;
398
399 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
400 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
401 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
402
403 return 0;
404}
405
406
407static int stac9460_mic_sw_get(struct snd_kcontrol *kcontrol,
408 struct snd_ctl_elem_value *ucontrol)
409{
410 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
411 unsigned char val;
412
413 val = stac9460_get(ice, STAC946X_GENERAL_PURPOSE);
414 ucontrol->value.enumerated.item[0] = (val >> 7) & 0x1;
415 return 0;
416}
417
418static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol,
419 struct snd_ctl_elem_value *ucontrol)
420{
421 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
422 unsigned char new, old;
423 int change;
424 old = stac9460_get(ice, STAC946X_GENERAL_PURPOSE);
425 new = (ucontrol->value.enumerated.item[0] << 7 & 0x80) | (old & ~0x80);
426 change = (new != old);
427 if (change)
428 stac9460_put(ice, STAC946X_GENERAL_PURPOSE, new);
429 return change;
430}
359 431
360static const DECLARE_TLV_DB_SCALE(db_scale_dac, -19125, 75, 0); 432static const DECLARE_TLV_DB_SCALE(db_scale_dac, -19125, 75, 0);
361static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0); 433static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0);
@@ -364,7 +436,7 @@ static const DECLARE_TLV_DB_SCALE(db_scale_adc, 0, 150, 0);
364 * mixers 436 * mixers
365 */ 437 */
366 438
367static const struct snd_kcontrol_new stac_controls[] __devinitdata = { 439static struct snd_kcontrol_new stac_controls[] __devinitdata = {
368 { 440 {
369 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 441 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
370 .name = "Master Playback Switch", 442 .name = "Master Playback Switch",
@@ -406,7 +478,7 @@ static const struct snd_kcontrol_new stac_controls[] __devinitdata = {
406 }, 478 },
407 { 479 {
408 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 480 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
409 .name = "ADC Switch", 481 .name = "ADC Capture Switch",
410 .count = 1, 482 .count = 1,
411 .info = stac9460_adc_mute_info, 483 .info = stac9460_adc_mute_info,
412 .get = stac9460_adc_mute_get, 484 .get = stac9460_adc_mute_get,
@@ -417,13 +489,21 @@ static const struct snd_kcontrol_new stac_controls[] __devinitdata = {
417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
418 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 490 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
419 SNDRV_CTL_ELEM_ACCESS_TLV_READ), 491 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
420 .name = "ADC Volume", 492 .name = "ADC Capture Volume",
421 .count = 1, 493 .count = 1,
422 .info = stac9460_adc_vol_info, 494 .info = stac9460_adc_vol_info,
423 .get = stac9460_adc_vol_get, 495 .get = stac9460_adc_vol_get,
424 .put = stac9460_adc_vol_put, 496 .put = stac9460_adc_vol_put,
425 .tlv = { .p = db_scale_adc } 497 .tlv = { .p = db_scale_adc }
426 }, 498 },
499 {
500 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
501 .name = "Analog Capture Input",
502 .info = stac9460_mic_sw_info,
503 .get = stac9460_mic_sw_get,
504 .put = stac9460_mic_sw_put,
505
506 },
427#if 0 507#if 0
428 { 508 {
429 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 509 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -456,19 +536,261 @@ static const struct snd_kcontrol_new stac_controls[] __devinitdata = {
456#endif 536#endif
457}; 537};
458 538
539
540/* AK4114 - ICE1724 connections on Prodigy192 + MI/ODI/O */
541/* CDTO (pin 32) -- GPIO11 pin 86
542 * CDTI (pin 33) -- GPIO10 pin 77
543 * CCLK (pin 34) -- GPIO9 pin 76
544 * CSN (pin 35) -- GPIO8 pin 75
545 */
546#define AK4114_ADDR 0x00 /* C1-C0: Chip Address
547 * (According to datasheet fixed to “00â€)
548 */
549
550/*
551 * 4wire ak4114 protocol - writing data
552 */
553static void write_data(struct snd_ice1712 *ice, unsigned int gpio,
554 unsigned int data, int idx)
555{
556 for (; idx >= 0; idx--) {
557 /* drop clock */
558 gpio &= ~VT1724_PRODIGY192_CCLK;
559 snd_ice1712_gpio_write(ice, gpio);
560 udelay(1);
561 /* set data */
562 if (data & (1 << idx))
563 gpio |= VT1724_PRODIGY192_CDOUT;
564 else
565 gpio &= ~VT1724_PRODIGY192_CDOUT;
566 snd_ice1712_gpio_write(ice, gpio);
567 udelay(1);
568 /* raise clock */
569 gpio |= VT1724_PRODIGY192_CCLK;
570 snd_ice1712_gpio_write(ice, gpio);
571 udelay(1);
572 }
573}
574
575/*
576 * 4wire ak4114 protocol - reading data
577 */
578static unsigned char read_data(struct snd_ice1712 *ice, unsigned int gpio,
579 int idx)
580{
581 unsigned char data = 0;
582
583 for (; idx >= 0; idx--) {
584 /* drop clock */
585 gpio &= ~VT1724_PRODIGY192_CCLK;
586 snd_ice1712_gpio_write(ice, gpio);
587 udelay(1);
588 /* read data */
589 if (snd_ice1712_gpio_read(ice) & VT1724_PRODIGY192_CDIN)
590 data |= (1 << idx);
591 udelay(1);
592 /* raise clock */
593 gpio |= VT1724_PRODIGY192_CCLK;
594 snd_ice1712_gpio_write(ice, gpio);
595 udelay(1);
596 }
597 return data;
598}
599/*
600 * 4wire ak4114 protocol - starting sequence
601 */
602static unsigned int prodigy192_4wire_start(struct snd_ice1712 *ice)
603{
604 unsigned int tmp;
605
606 snd_ice1712_save_gpio_status(ice);
607 tmp = snd_ice1712_gpio_read(ice);
608
609 tmp |= VT1724_PRODIGY192_CCLK; /* high at init */
610 tmp &= ~VT1724_PRODIGY192_CS; /* drop chip select */
611 snd_ice1712_gpio_write(ice, tmp);
612 udelay(1);
613 return tmp;
614}
615
616/*
617 * 4wire ak4114 protocol - final sequence
618 */
619static void prodigy192_4wire_finish(struct snd_ice1712 *ice, unsigned int tmp)
620{
621 tmp |= VT1724_PRODIGY192_CS; /* raise chip select */
622 snd_ice1712_gpio_write(ice, tmp);
623 udelay(1);
624 snd_ice1712_restore_gpio_status(ice);
625}
626
627/*
628 * Write data to addr register of ak4114
629 */
630static void prodigy192_ak4114_write(void *private_data, unsigned char addr,
631 unsigned char data)
632{
633 struct snd_ice1712 *ice = private_data;
634 unsigned int tmp, addrdata;
635 tmp = prodigy192_4wire_start(ice);
636 addrdata = (AK4114_ADDR << 6) | 0x20 | (addr & 0x1f);
637 addrdata = (addrdata << 8) | data;
638 write_data(ice, tmp, addrdata, 15);
639 prodigy192_4wire_finish(ice, tmp);
640}
641
642/*
643 * Read data from addr register of ak4114
644 */
645static unsigned char prodigy192_ak4114_read(void *private_data,
646 unsigned char addr)
647{
648 struct snd_ice1712 *ice = private_data;
649 unsigned int tmp;
650 unsigned char data;
651
652 tmp = prodigy192_4wire_start(ice);
653 write_data(ice, tmp, (AK4114_ADDR << 6) | (addr & 0x1f), 7);
654 data = read_data(ice, tmp, 7);
655 prodigy192_4wire_finish(ice, tmp);
656 return data;
657}
658
659
660static int ak4114_input_sw_info(struct snd_kcontrol *kcontrol,
661 struct snd_ctl_elem_info *uinfo)
662{
663 static char *texts[2] = { "Toslink", "Coax" };
664
665 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
666 uinfo->count = 1;
667 uinfo->value.enumerated.items = 2;
668 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
669 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
670 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
671 return 0;
672}
673
674
675static int ak4114_input_sw_get(struct snd_kcontrol *kcontrol,
676 struct snd_ctl_elem_value *ucontrol)
677{
678 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
679 unsigned char val;
680
681 val = prodigy192_ak4114_read(ice, AK4114_REG_IO1);
682 /* AK4114_IPS0 bit = 0 -> RX0 = Toslink
683 * AK4114_IPS0 bit = 1 -> RX1 = Coax
684 */
685 ucontrol->value.enumerated.item[0] = (val & AK4114_IPS0) ? 1 : 0;
686 return 0;
687}
688
689static int ak4114_input_sw_put(struct snd_kcontrol *kcontrol,
690 struct snd_ctl_elem_value *ucontrol)
691{
692 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
693 unsigned char new, old, itemvalue;
694 int change;
695
696 old = prodigy192_ak4114_read(ice, AK4114_REG_IO1);
697 /* AK4114_IPS0 could be any bit */
698 itemvalue = (ucontrol->value.enumerated.item[0]) ? 0xff : 0x00;
699
700 new = (itemvalue & AK4114_IPS0) | (old & ~AK4114_IPS0);
701 change = (new != old);
702 if (change)
703 prodigy192_ak4114_write(ice, AK4114_REG_IO1, new);
704 return change;
705}
706
707
708static const struct snd_kcontrol_new ak4114_controls[] __devinitdata = {
709 {
710 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
711 .name = "MIODIO IEC958 Capture Input",
712 .info = ak4114_input_sw_info,
713 .get = ak4114_input_sw_get,
714 .put = ak4114_input_sw_put,
715
716 }
717};
718
719
720static int prodigy192_ak4114_init(struct snd_ice1712 *ice)
721{
722 static const unsigned char ak4114_init_vals[] = {
723 AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1,
724 /* ice1724 expects I2S and provides clock,
725 * DEM0 disables the deemphasis filter
726 */
727 AK4114_DIF_I24I2S | AK4114_DEM0 ,
728 AK4114_TX1E,
729 AK4114_EFH_1024 | AK4114_DIT, /* default input RX0 */
730 0,
731 0
732 };
733 static const unsigned char ak4114_init_txcsb[] = {
734 0x41, 0x02, 0x2c, 0x00, 0x00
735 };
736
737 return snd_ak4114_create(ice->card,
738 prodigy192_ak4114_read,
739 prodigy192_ak4114_write,
740 ak4114_init_vals, ak4114_init_txcsb,
741 ice, &ice->spec.prodigy192.ak4114);
742}
743
459static int __devinit prodigy192_add_controls(struct snd_ice1712 *ice) 744static int __devinit prodigy192_add_controls(struct snd_ice1712 *ice)
460{ 745{
461 unsigned int i; 746 unsigned int i;
462 int err; 747 int err;
463 748
464 for (i = 0; i < ARRAY_SIZE(stac_controls); i++) { 749 for (i = 0; i < ARRAY_SIZE(stac_controls); i++) {
465 err = snd_ctl_add(ice->card, snd_ctl_new1(&stac_controls[i], ice)); 750 err = snd_ctl_add(ice->card,
751 snd_ctl_new1(&stac_controls[i], ice));
752 if (err < 0)
753 return err;
754 }
755 if (ice->spec.prodigy192.ak4114) {
756 /* ak4114 is connected */
757 for (i = 0; i < ARRAY_SIZE(ak4114_controls); i++) {
758 err = snd_ctl_add(ice->card,
759 snd_ctl_new1(&ak4114_controls[i],
760 ice));
761 if (err < 0)
762 return err;
763 }
764 err = snd_ak4114_build(ice->spec.prodigy192.ak4114,
765 NULL, /* ak4114 in MIO/DI/O handles no IEC958 output */
766 ice->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
466 if (err < 0) 767 if (err < 0)
467 return err; 768 return err;
468 } 769 }
469 return 0; 770 return 0;
470} 771}
471 772
773/*
774 * check for presence of MI/ODI/O add-on card with digital inputs
775 */
776static int prodigy192_miodio_exists(struct snd_ice1712 *ice)
777{
778
779 unsigned char orig_value;
780 const unsigned char test_data = 0xd1; /* random value */
781 unsigned char addr = AK4114_REG_INT0_MASK; /* random SAFE address */
782 int exists = 0;
783
784 orig_value = prodigy192_ak4114_read(ice, addr);
785 prodigy192_ak4114_write(ice, addr, test_data);
786 if (prodigy192_ak4114_read(ice, addr) == test_data) {
787 /* ak4114 seems to communicate, apparently exists */
788 /* writing back original value */
789 prodigy192_ak4114_write(ice, addr, orig_value);
790 exists = 1;
791 }
792 return exists;
793}
472 794
473/* 795/*
474 * initialize the chip 796 * initialize the chip
@@ -487,16 +809,30 @@ static int __devinit prodigy192_init(struct snd_ice1712 *ice)
487 (unsigned short)-1 809 (unsigned short)-1
488 }; 810 };
489 const unsigned short *p; 811 const unsigned short *p;
812 int err = 0;
490 813
491 /* prodigy 192 */ 814 /* prodigy 192 */
492 ice->num_total_dacs = 6; 815 ice->num_total_dacs = 6;
493 ice->num_total_adcs = 2; 816 ice->num_total_adcs = 2;
817 ice->vt1720 = 0; /* ice1724, e.g. 23 GPIOs */
494 818
495 /* initialize codec */ 819 /* initialize codec */
496 p = stac_inits_prodigy; 820 p = stac_inits_prodigy;
497 for (; *p != (unsigned short)-1; p += 2) 821 for (; *p != (unsigned short)-1; p += 2)
498 stac9460_put(ice, p[0], p[1]); 822 stac9460_put(ice, p[0], p[1]);
499 823
824 /* MI/ODI/O add on card with AK4114 */
825 if (prodigy192_miodio_exists(ice)) {
826 err = prodigy192_ak4114_init(ice);
827 /* from this moment if err = 0 then
828 * ice->spec.prodigy192.ak4114 should not be null
829 */
830 snd_printdd("AK4114 initialized with status %d\n", err);
831 } else
832 snd_printdd("AK4114 not found\n");
833 if (err < 0)
834 return err;
835
500 return 0; 836 return 0;
501} 837}
502 838
@@ -506,25 +842,31 @@ static int __devinit prodigy192_init(struct snd_ice1712 *ice)
506 * hence the driver needs to sets up it properly. 842 * hence the driver needs to sets up it properly.
507 */ 843 */
508 844
509static const unsigned char prodigy71_eeprom[] __devinitdata = { 845static unsigned char prodigy71_eeprom[] __devinitdata = {
510 [ICE_EEP2_SYSCONF] = 0x2b, /* clock 512, mpu401, spdif-in/ADC, 4DACs */ 846 [ICE_EEP2_SYSCONF] = 0x6a, /* 49MHz crystal, mpu401,
847 * spdif-in+ 1 stereo ADC,
848 * 3 stereo DACs
849 */
511 [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 850 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
512 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */ 851 [ICE_EEP2_I2S] = 0xf8, /* vol, 96k, 24bit, 192k */
513 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */ 852 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
514 [ICE_EEP2_GPIO_DIR] = 0xff, 853 [ICE_EEP2_GPIO_DIR] = 0xff,
515 [ICE_EEP2_GPIO_DIR1] = 0xff, 854 [ICE_EEP2_GPIO_DIR1] = ~(VT1724_PRODIGY192_CDIN >> 8) ,
516 [ICE_EEP2_GPIO_DIR2] = 0xbf, 855 [ICE_EEP2_GPIO_DIR2] = 0xbf,
517 [ICE_EEP2_GPIO_MASK] = 0x00, 856 [ICE_EEP2_GPIO_MASK] = 0x00,
518 [ICE_EEP2_GPIO_MASK1] = 0x00, 857 [ICE_EEP2_GPIO_MASK1] = 0x00,
519 [ICE_EEP2_GPIO_MASK2] = 0x00, 858 [ICE_EEP2_GPIO_MASK2] = 0x00,
520 [ICE_EEP2_GPIO_STATE] = 0x00, 859 [ICE_EEP2_GPIO_STATE] = 0x00,
521 [ICE_EEP2_GPIO_STATE1] = 0x00, 860 [ICE_EEP2_GPIO_STATE1] = 0x00,
522 [ICE_EEP2_GPIO_STATE2] = 0x00, 861 [ICE_EEP2_GPIO_STATE2] = 0x10, /* GPIO20: 0 = CD drive dig. input
862 * passthrough,
863 * 1 = SPDIF-OUT from ice1724
864 */
523}; 865};
524 866
525 867
526/* entry point */ 868/* entry point */
527const struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[] __devinitdata = { 869struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[] __devinitdata = {
528 { 870 {
529 .subvendor = VT1724_SUBDEVICE_PRODIGY192VE, 871 .subvendor = VT1724_SUBDEVICE_PRODIGY192VE,
530 .name = "Audiotrak Prodigy 192", 872 .name = "Audiotrak Prodigy 192",
diff --git a/sound/pci/ice1712/prodigy192.h b/sound/pci/ice1712/prodigy192.h
index 2fa2e62b9e04..16a53b459c72 100644
--- a/sound/pci/ice1712/prodigy192.h
+++ b/sound/pci/ice1712/prodigy192.h
@@ -5,7 +5,15 @@
5#define PRODIGY192_STAC9460_ADDR 0x54 5#define PRODIGY192_STAC9460_ADDR 0x54
6 6
7#define VT1724_SUBDEVICE_PRODIGY192VE 0x34495345 /* PRODIGY 192 VE */ 7#define VT1724_SUBDEVICE_PRODIGY192VE 0x34495345 /* PRODIGY 192 VE */
8/*
9 * AudioTrak Prodigy192 GPIO definitions for MI/ODI/O card with
10 * AK4114 (SPDIF-IN)
11 */
12#define VT1724_PRODIGY192_CS (1 << 8) /* GPIO8, pin 75 */
13#define VT1724_PRODIGY192_CCLK (1 << 9) /* GPIO9, pin 76 */
14#define VT1724_PRODIGY192_CDOUT (1 << 10) /* GPIO10, pin 77 */
15#define VT1724_PRODIGY192_CDIN (1 << 11) /* GPIO11, pin 86 */
8 16
9extern const struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[]; 17extern struct snd_ice1712_card_info snd_vt1724_prodigy192_cards[];
10 18
11#endif /* __SOUND_PRODIGY192_H */ 19#endif /* __SOUND_PRODIGY192_H */
diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c
index 025a7e8497c3..690ceb340644 100644
--- a/sound/pci/ice1712/revo.c
+++ b/sound/pci/ice1712/revo.c
@@ -219,7 +219,7 @@ static const struct snd_akm4xxx_adc_channel revo51_adc[] = {
219 }, 219 },
220}; 220};
221 221
222static const struct snd_akm4xxx akm_revo_front __devinitdata = { 222static struct snd_akm4xxx akm_revo_front __devinitdata = {
223 .type = SND_AK4381, 223 .type = SND_AK4381,
224 .num_dacs = 2, 224 .num_dacs = 2,
225 .ops = { 225 .ops = {
@@ -228,7 +228,7 @@ static const struct snd_akm4xxx akm_revo_front __devinitdata = {
228 .dac_info = revo71_front, 228 .dac_info = revo71_front,
229}; 229};
230 230
231static const struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = { 231static struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
232 .caddr = 1, 232 .caddr = 1,
233 .cif = 0, 233 .cif = 0,
234 .data_mask = VT1724_REVO_CDOUT, 234 .data_mask = VT1724_REVO_CDOUT,
@@ -240,7 +240,7 @@ static const struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
240 .mask_flags = 0, 240 .mask_flags = 0,
241}; 241};
242 242
243static const struct snd_akm4xxx akm_revo_surround __devinitdata = { 243static struct snd_akm4xxx akm_revo_surround __devinitdata = {
244 .type = SND_AK4355, 244 .type = SND_AK4355,
245 .idx_offset = 1, 245 .idx_offset = 1,
246 .num_dacs = 6, 246 .num_dacs = 6,
@@ -250,7 +250,7 @@ static const struct snd_akm4xxx akm_revo_surround __devinitdata = {
250 .dac_info = revo71_surround, 250 .dac_info = revo71_surround,
251}; 251};
252 252
253static const struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = { 253static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
254 .caddr = 3, 254 .caddr = 3,
255 .cif = 0, 255 .cif = 0,
256 .data_mask = VT1724_REVO_CDOUT, 256 .data_mask = VT1724_REVO_CDOUT,
@@ -262,7 +262,7 @@ static const struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
262 .mask_flags = 0, 262 .mask_flags = 0,
263}; 263};
264 264
265static const struct snd_akm4xxx akm_revo51 __devinitdata = { 265static struct snd_akm4xxx akm_revo51 __devinitdata = {
266 .type = SND_AK4358, 266 .type = SND_AK4358,
267 .num_dacs = 6, 267 .num_dacs = 6,
268 .ops = { 268 .ops = {
@@ -271,7 +271,7 @@ static const struct snd_akm4xxx akm_revo51 __devinitdata = {
271 .dac_info = revo51_dac, 271 .dac_info = revo51_dac,
272}; 272};
273 273
274static const struct snd_ak4xxx_private akm_revo51_priv __devinitdata = { 274static struct snd_ak4xxx_private akm_revo51_priv __devinitdata = {
275 .caddr = 2, 275 .caddr = 2,
276 .cif = 0, 276 .cif = 0,
277 .data_mask = VT1724_REVO_CDOUT, 277 .data_mask = VT1724_REVO_CDOUT,
@@ -283,13 +283,13 @@ static const struct snd_ak4xxx_private akm_revo51_priv __devinitdata = {
283 .mask_flags = 0, 283 .mask_flags = 0,
284}; 284};
285 285
286static const struct snd_akm4xxx akm_revo51_adc __devinitdata = { 286static struct snd_akm4xxx akm_revo51_adc __devinitdata = {
287 .type = SND_AK5365, 287 .type = SND_AK5365,
288 .num_adcs = 2, 288 .num_adcs = 2,
289 .adc_info = revo51_adc, 289 .adc_info = revo51_adc,
290}; 290};
291 291
292static const struct snd_ak4xxx_private akm_revo51_adc_priv __devinitdata = { 292static struct snd_ak4xxx_private akm_revo51_adc_priv __devinitdata = {
293 .caddr = 2, 293 .caddr = 2,
294 .cif = 0, 294 .cif = 0,
295 .data_mask = VT1724_REVO_CDOUT, 295 .data_mask = VT1724_REVO_CDOUT,
@@ -324,7 +324,7 @@ static const struct snd_akm4xxx_dac_channel ap192_dac[] = {
324 AK_DAC("PCM Playback Volume", 2) 324 AK_DAC("PCM Playback Volume", 2)
325}; 325};
326 326
327static const struct snd_akm4xxx akm_ap192 __devinitdata = { 327static struct snd_akm4xxx akm_ap192 __devinitdata = {
328 .type = SND_AK4358, 328 .type = SND_AK4358,
329 .num_dacs = 2, 329 .num_dacs = 2,
330 .ops = { 330 .ops = {
@@ -333,7 +333,7 @@ static const struct snd_akm4xxx akm_ap192 __devinitdata = {
333 .dac_info = ap192_dac, 333 .dac_info = ap192_dac,
334}; 334};
335 335
336static const struct snd_ak4xxx_private akm_ap192_priv __devinitdata = { 336static struct snd_ak4xxx_private akm_ap192_priv __devinitdata = {
337 .caddr = 2, 337 .caddr = 2,
338 .cif = 0, 338 .cif = 0,
339 .data_mask = VT1724_REVO_CDOUT, 339 .data_mask = VT1724_REVO_CDOUT,
@@ -405,7 +405,7 @@ static unsigned char read_data(struct snd_ice1712 *ice, unsigned int gpio,
405 return data; 405 return data;
406} 406}
407 407
408static unsigned char ap192_4wire_start(struct snd_ice1712 *ice) 408static unsigned int ap192_4wire_start(struct snd_ice1712 *ice)
409{ 409{
410 unsigned int tmp; 410 unsigned int tmp;
411 411
@@ -454,7 +454,7 @@ static unsigned char ap192_ak4114_read(void *private_data, unsigned char addr)
454 return data; 454 return data;
455} 455}
456 456
457static int ap192_ak4114_init(struct snd_ice1712 *ice) 457static int __devinit ap192_ak4114_init(struct snd_ice1712 *ice)
458{ 458{
459 static const unsigned char ak4114_init_vals[] = { 459 static const unsigned char ak4114_init_vals[] = {
460 AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1, 460 AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1,
@@ -582,7 +582,7 @@ static int __devinit revo_add_controls(struct snd_ice1712 *ice)
582} 582}
583 583
584/* entry point */ 584/* entry point */
585const struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = { 585struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = {
586 { 586 {
587 .subvendor = VT1724_SUBDEVICE_REVOLUTION71, 587 .subvendor = VT1724_SUBDEVICE_REVOLUTION71,
588 .name = "M Audio Revolution-7.1", 588 .name = "M Audio Revolution-7.1",
diff --git a/sound/pci/ice1712/revo.h b/sound/pci/ice1712/revo.h
index 2a24488fad80..a3ba425911cc 100644
--- a/sound/pci/ice1712/revo.h
+++ b/sound/pci/ice1712/revo.h
@@ -34,7 +34,7 @@
34#define VT1724_SUBDEVICE_AUDIOPHILE192 0x12143236 34#define VT1724_SUBDEVICE_AUDIOPHILE192 0x12143236
35 35
36/* entry point */ 36/* entry point */
37extern const struct snd_ice1712_card_info snd_vt1724_revo_cards[]; 37extern struct snd_ice1712_card_info snd_vt1724_revo_cards[];
38 38
39 39
40/* 40/*
diff --git a/sound/pci/ice1712/vt1720_mobo.c b/sound/pci/ice1712/vt1720_mobo.c
index 72b060d63c29..239524158fe7 100644
--- a/sound/pci/ice1712/vt1720_mobo.c
+++ b/sound/pci/ice1712/vt1720_mobo.c
@@ -56,7 +56,7 @@ static int __devinit k8x800_add_controls(struct snd_ice1712 *ice)
56 56
57/* EEPROM image */ 57/* EEPROM image */
58 58
59static const unsigned char k8x800_eeprom[] __devinitdata = { 59static unsigned char k8x800_eeprom[] __devinitdata = {
60 [ICE_EEP2_SYSCONF] = 0x01, /* clock 256, 1ADC, 2DACs */ 60 [ICE_EEP2_SYSCONF] = 0x01, /* clock 256, 1ADC, 2DACs */
61 [ICE_EEP2_ACLINK] = 0x02, /* ACLINK, packed */ 61 [ICE_EEP2_ACLINK] = 0x02, /* ACLINK, packed */
62 [ICE_EEP2_I2S] = 0x00, /* - */ 62 [ICE_EEP2_I2S] = 0x00, /* - */
@@ -72,7 +72,7 @@ static const unsigned char k8x800_eeprom[] __devinitdata = {
72 [ICE_EEP2_GPIO_STATE2] = 0x00, /* - */ 72 [ICE_EEP2_GPIO_STATE2] = 0x00, /* - */
73}; 73};
74 74
75static const unsigned char sn25p_eeprom[] __devinitdata = { 75static unsigned char sn25p_eeprom[] __devinitdata = {
76 [ICE_EEP2_SYSCONF] = 0x01, /* clock 256, 1ADC, 2DACs */ 76 [ICE_EEP2_SYSCONF] = 0x01, /* clock 256, 1ADC, 2DACs */
77 [ICE_EEP2_ACLINK] = 0x02, /* ACLINK, packed */ 77 [ICE_EEP2_ACLINK] = 0x02, /* ACLINK, packed */
78 [ICE_EEP2_I2S] = 0x00, /* - */ 78 [ICE_EEP2_I2S] = 0x00, /* - */
@@ -90,7 +90,7 @@ static const unsigned char sn25p_eeprom[] __devinitdata = {
90 90
91 91
92/* entry point */ 92/* entry point */
93const struct snd_ice1712_card_info snd_vt1720_mobo_cards[] __devinitdata = { 93struct snd_ice1712_card_info snd_vt1720_mobo_cards[] __devinitdata = {
94 { 94 {
95 .subvendor = VT1720_SUBDEVICE_K8X800, 95 .subvendor = VT1720_SUBDEVICE_K8X800,
96 .name = "Albatron K8X800 Pro II", 96 .name = "Albatron K8X800 Pro II",
diff --git a/sound/pci/ice1712/vt1720_mobo.h b/sound/pci/ice1712/vt1720_mobo.h
index 70af3ad64a5d..0b1b0ee1bea7 100644
--- a/sound/pci/ice1712/vt1720_mobo.h
+++ b/sound/pci/ice1712/vt1720_mobo.h
@@ -36,6 +36,6 @@
36#define VT1720_SUBDEVICE_9CJS 0x0f272327 36#define VT1720_SUBDEVICE_9CJS 0x0f272327
37#define VT1720_SUBDEVICE_SN25P 0x97123650 37#define VT1720_SUBDEVICE_SN25P 0x97123650
38 38
39extern const struct snd_ice1712_card_info snd_vt1720_mobo_cards[]; 39extern struct snd_ice1712_card_info snd_vt1720_mobo_cards[];
40 40
41#endif /* __SOUND_VT1720_MOBO_H */ 41#endif /* __SOUND_VT1720_MOBO_H */
diff --git a/sound/pci/ice1712/wtm.c b/sound/pci/ice1712/wtm.c
index 4a706b16a0b9..04e535c8542b 100644
--- a/sound/pci/ice1712/wtm.c
+++ b/sound/pci/ice1712/wtm.c
@@ -409,7 +409,7 @@ static int stac9460_mic_sw_put(struct snd_kcontrol *kcontrol,
409/* 409/*
410 * Control tabs 410 * Control tabs
411 */ 411 */
412static const struct snd_kcontrol_new stac9640_controls[] __devinitdata = { 412static struct snd_kcontrol_new stac9640_controls[] __devinitdata = {
413 { 413 {
414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
415 .name = "Master Playback Switch", 415 .name = "Master Playback Switch",
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 7cf2dcb9d8d4..202f720b34b9 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -2493,6 +2493,7 @@ static int intel8x0_resume(struct pci_dev *pci)
2493 return -EIO; 2493 return -EIO;
2494 } 2494 }
2495 pci_set_master(pci); 2495 pci_set_master(pci);
2496 snd_intel8x0_chip_init(chip, 0);
2496 if (request_irq(pci->irq, snd_intel8x0_interrupt, 2497 if (request_irq(pci->irq, snd_intel8x0_interrupt,
2497 IRQF_SHARED, card->shortname, chip)) { 2498 IRQF_SHARED, card->shortname, chip)) {
2498 printk(KERN_ERR "intel8x0: unable to grab IRQ %d, " 2499 printk(KERN_ERR "intel8x0: unable to grab IRQ %d, "
@@ -2502,7 +2503,6 @@ static int intel8x0_resume(struct pci_dev *pci)
2502 } 2503 }
2503 chip->irq = pci->irq; 2504 chip->irq = pci->irq;
2504 synchronize_irq(chip->irq); 2505 synchronize_irq(chip->irq);
2505 snd_intel8x0_chip_init(chip, 0);
2506 2506
2507 /* re-initialize mixer stuff */ 2507 /* re-initialize mixer stuff */
2508 if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) { 2508 if (chip->device_type == DEVICE_INTEL_ICH4 && !spdif_aclink) {
@@ -2862,16 +2862,7 @@ static int __devinit snd_intel8x0_create(struct snd_card *card,
2862 ICH_REG_ALI_INTERRUPTSR : ICH_REG_GLOB_STA; 2862 ICH_REG_ALI_INTERRUPTSR : ICH_REG_GLOB_STA;
2863 chip->int_sta_mask = int_sta_masks; 2863 chip->int_sta_mask = int_sta_masks;
2864 2864
2865 /* request irq after initializaing int_sta_mask, etc */
2866 if (request_irq(pci->irq, snd_intel8x0_interrupt,
2867 IRQF_SHARED, card->shortname, chip)) {
2868 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
2869 snd_intel8x0_free(chip);
2870 return -EBUSY;
2871 }
2872 chip->irq = pci->irq;
2873 pci_set_master(pci); 2865 pci_set_master(pci);
2874 synchronize_irq(chip->irq);
2875 2866
2876 switch(chip->device_type) { 2867 switch(chip->device_type) {
2877 case DEVICE_INTEL_ICH4: 2868 case DEVICE_INTEL_ICH4:
@@ -2901,6 +2892,15 @@ static int __devinit snd_intel8x0_create(struct snd_card *card,
2901 return err; 2892 return err;
2902 } 2893 }
2903 2894
2895 /* request irq after initializaing int_sta_mask, etc */
2896 if (request_irq(pci->irq, snd_intel8x0_interrupt,
2897 IRQF_SHARED, card->shortname, chip)) {
2898 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
2899 snd_intel8x0_free(chip);
2900 return -EBUSY;
2901 }
2902 chip->irq = pci->irq;
2903
2904 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { 2904 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
2905 snd_intel8x0_free(chip); 2905 snd_intel8x0_free(chip);
2906 return err; 2906 return err;
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 21d0899ac382..5338243fb035 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -264,9 +264,7 @@ enum MonitorModeSelector {
264#define COMMAND_ACK_DELAY 13 // number of RTC ticks to wait for an acknowledgement 264#define COMMAND_ACK_DELAY 13 // number of RTC ticks to wait for an acknowledgement
265 // from the card after sending a command. 265 // from the card after sending a command.
266 266
267#define FIRMWARE_IN_THE_KERNEL 267#ifdef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
268
269#ifdef FIRMWARE_IN_THE_KERNEL
270#include "korg1212-firmware.h" 268#include "korg1212-firmware.h"
271static const struct firmware static_dsp_code = { 269static const struct firmware static_dsp_code = {
272 .data = (u8 *)dspCode, 270 .data = (u8 *)dspCode,
@@ -418,6 +416,9 @@ struct snd_korg1212 {
418MODULE_DESCRIPTION("korg1212"); 416MODULE_DESCRIPTION("korg1212");
419MODULE_LICENSE("GPL"); 417MODULE_LICENSE("GPL");
420MODULE_SUPPORTED_DEVICE("{{KORG,korg1212}}"); 418MODULE_SUPPORTED_DEVICE("{{KORG,korg1212}}");
419#ifndef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
420MODULE_FIRMWARE("korg/k1212.dsp");
421#endif
421 422
422static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 423static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
423static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 424static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
@@ -2342,26 +2343,25 @@ static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *
2342 korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy + 2343 korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy +
2343 offsetof(struct KorgSharedBuffer, AdatTimeCode); 2344 offsetof(struct KorgSharedBuffer, AdatTimeCode);
2344 2345
2346#ifdef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
2347 dsp_code = &static_dsp_code;
2348#else
2345 err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev); 2349 err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev);
2346 if (err < 0) { 2350 if (err < 0) {
2347 release_firmware(dsp_code); 2351 release_firmware(dsp_code);
2348#ifdef FIRMWARE_IN_THE_KERNEL
2349 dsp_code = &static_dsp_code;
2350#else
2351 snd_printk(KERN_ERR "firmware not available\n"); 2352 snd_printk(KERN_ERR "firmware not available\n");
2352 snd_korg1212_free(korg1212); 2353 snd_korg1212_free(korg1212);
2353 return err; 2354 return err;
2354#endif
2355 } 2355 }
2356#endif
2356 2357
2357 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 2358 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
2358 dsp_code->size, &korg1212->dma_dsp) < 0) { 2359 dsp_code->size, &korg1212->dma_dsp) < 0) {
2359 snd_printk(KERN_ERR "korg1212: cannot allocate dsp code memory (%zd bytes)\n", dsp_code->size); 2360 snd_printk(KERN_ERR "korg1212: cannot allocate dsp code memory (%zd bytes)\n", dsp_code->size);
2360 snd_korg1212_free(korg1212); 2361 snd_korg1212_free(korg1212);
2361#ifdef FIRMWARE_IN_THE_KERNEL 2362#ifndef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
2362 if (dsp_code != &static_dsp_code) 2363 release_firmware(dsp_code);
2363#endif 2364#endif
2364 release_firmware(dsp_code);
2365 return -ENOMEM; 2365 return -ENOMEM;
2366 } 2366 }
2367 2367
@@ -2371,10 +2371,9 @@ static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *
2371 2371
2372 memcpy(korg1212->dma_dsp.area, dsp_code->data, dsp_code->size); 2372 memcpy(korg1212->dma_dsp.area, dsp_code->data, dsp_code->size);
2373 2373
2374#ifdef FIRMWARE_IN_THE_KERNEL 2374#ifndef CONFIG_SND_KORG1212_FIRMWARE_IN_KERNEL
2375 if (dsp_code != &static_dsp_code) 2375 release_firmware(dsp_code);
2376#endif 2376#endif
2377 release_firmware(dsp_code);
2378 2377
2379 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0); 2378 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0);
2380 2379
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 4526904e3f86..8a5ff1cb5362 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -59,6 +59,10 @@ MODULE_SUPPORTED_DEVICE("{{ESS,Maestro3 PCI},"
59 "{ESS,Allegro PCI}," 59 "{ESS,Allegro PCI},"
60 "{ESS,Allegro-1 PCI}," 60 "{ESS,Allegro-1 PCI},"
61 "{ESS,Canyon3D-2/LE PCI}}"); 61 "{ESS,Canyon3D-2/LE PCI}}");
62#ifndef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL
63MODULE_FIRMWARE("ess/maestro3_assp_kernel.fw");
64MODULE_FIRMWARE("ess/maestro3_assp_minisrc.fw");
65#endif
62 66
63static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 67static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
64static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 68static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
@@ -2101,9 +2105,7 @@ static int __devinit snd_m3_mixer(struct snd_m3 *chip)
2101} 2105}
2102 2106
2103 2107
2104#define FIRMWARE_IN_THE_KERNEL 2108#ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL
2105
2106#ifdef FIRMWARE_IN_THE_KERNEL
2107 2109
2108/* 2110/*
2109 * DSP Code images 2111 * DSP Code images
@@ -2242,7 +2244,7 @@ static const struct firmware assp_minisrc = {
2242 .size = sizeof assp_minisrc_image 2244 .size = sizeof assp_minisrc_image
2243}; 2245};
2244 2246
2245#endif /* FIRMWARE_IN_THE_KERNEL */ 2247#else /* CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL */
2246 2248
2247#ifdef __LITTLE_ENDIAN 2249#ifdef __LITTLE_ENDIAN
2248static inline void snd_m3_convert_from_le(const struct firmware *fw) { } 2250static inline void snd_m3_convert_from_le(const struct firmware *fw) { }
@@ -2257,6 +2259,8 @@ static void snd_m3_convert_from_le(const struct firmware *fw)
2257} 2259}
2258#endif 2260#endif
2259 2261
2262#endif /* CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL */
2263
2260 2264
2261/* 2265/*
2262 * initialize ASSP 2266 * initialize ASSP
@@ -2550,14 +2554,10 @@ static int snd_m3_free(struct snd_m3 *chip)
2550 if (chip->iobase) 2554 if (chip->iobase)
2551 pci_release_regions(chip->pci); 2555 pci_release_regions(chip->pci);
2552 2556
2553#ifdef FIRMWARE_IN_THE_KERNEL 2557#ifndef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL
2554 if (chip->assp_kernel_image != &assp_kernel) 2558 release_firmware(chip->assp_kernel_image);
2559 release_firmware(chip->assp_minisrc_image);
2555#endif 2560#endif
2556 release_firmware(chip->assp_kernel_image);
2557#ifdef FIRMWARE_IN_THE_KERNEL
2558 if (chip->assp_minisrc_image != &assp_minisrc)
2559#endif
2560 release_firmware(chip->assp_minisrc_image);
2561 2561
2562 pci_disable_device(chip->pci); 2562 pci_disable_device(chip->pci);
2563 kfree(chip); 2563 kfree(chip);
@@ -2747,29 +2747,29 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
2747 return -ENOMEM; 2747 return -ENOMEM;
2748 } 2748 }
2749 2749
2750#ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL
2751 chip->assp_kernel_image = &assp_kernel;
2752#else
2750 err = request_firmware(&chip->assp_kernel_image, 2753 err = request_firmware(&chip->assp_kernel_image,
2751 "ess/maestro3_assp_kernel.fw", &pci->dev); 2754 "ess/maestro3_assp_kernel.fw", &pci->dev);
2752 if (err < 0) { 2755 if (err < 0) {
2753#ifdef FIRMWARE_IN_THE_KERNEL
2754 chip->assp_kernel_image = &assp_kernel;
2755#else
2756 snd_m3_free(chip); 2756 snd_m3_free(chip);
2757 return err; 2757 return err;
2758#endif
2759 } else 2758 } else
2760 snd_m3_convert_from_le(chip->assp_kernel_image); 2759 snd_m3_convert_from_le(chip->assp_kernel_image);
2760#endif
2761 2761
2762#ifdef CONFIG_SND_MAESTRO3_FIRMWARE_IN_KERNEL
2763 chip->assp_minisrc_image = &assp_minisrc;
2764#else
2762 err = request_firmware(&chip->assp_minisrc_image, 2765 err = request_firmware(&chip->assp_minisrc_image,
2763 "ess/maestro3_assp_minisrc.fw", &pci->dev); 2766 "ess/maestro3_assp_minisrc.fw", &pci->dev);
2764 if (err < 0) { 2767 if (err < 0) {
2765#ifdef FIRMWARE_IN_THE_KERNEL
2766 chip->assp_minisrc_image = &assp_minisrc;
2767#else
2768 snd_m3_free(chip); 2768 snd_m3_free(chip);
2769 return err; 2769 return err;
2770#endif
2771 } else 2770 } else
2772 snd_m3_convert_from_le(chip->assp_minisrc_image); 2771 snd_m3_convert_from_le(chip->assp_minisrc_image);
2772#endif
2773 2773
2774 if ((err = pci_request_regions(pci, card->driver)) < 0) { 2774 if ((err = pci_request_regions(pci, card->driver)) < 0) {
2775 snd_m3_free(chip); 2775 snd_m3_free(chip);
diff --git a/sound/pci/mixart/mixart_hwdep.c b/sound/pci/mixart/mixart_hwdep.c
index ca05075c67c6..1d9232d2db34 100644
--- a/sound/pci/mixart/mixart_hwdep.c
+++ b/sound/pci/mixart/mixart_hwdep.c
@@ -565,6 +565,9 @@ int snd_mixart_setup_firmware(struct mixart_mgr *mgr)
565 return 0; 565 return 0;
566} 566}
567 567
568MODULE_FIRMWARE("mixart/miXart8.xlx");
569MODULE_FIRMWARE("mixart/miXart8.elf");
570MODULE_FIRMWARE("mixart/miXart8AES.xlx");
568 571
569#else /* old style firmware loading */ 572#else /* old style firmware loading */
570 573
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index d97413484ae9..f7f6a687f033 100644
--- a/sound/pci/pcxhr/pcxhr.c
+++ b/sound/pci/pcxhr/pcxhr.c
@@ -638,22 +638,22 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
638static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd) 638static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd)
639{ 639{
640 struct pcxhr_stream *stream; 640 struct pcxhr_stream *stream;
641 struct list_head *pos;
642 struct snd_pcm_substream *s; 641 struct snd_pcm_substream *s;
643 int i;
644 642
645 switch (cmd) { 643 switch (cmd) {
646 case SNDRV_PCM_TRIGGER_START: 644 case SNDRV_PCM_TRIGGER_START:
647 snd_printdd("SNDRV_PCM_TRIGGER_START\n"); 645 snd_printdd("SNDRV_PCM_TRIGGER_START\n");
648 i = 0; 646 if (snd_pcm_stream_linked(subs)) {
649 snd_pcm_group_for_each(pos, subs) { 647 struct snd_pcxhr *chip = snd_pcm_substream_chip(subs);
650 s = snd_pcm_group_substream_entry(pos); 648 snd_pcm_group_for_each_entry(s, subs) {
651 stream = s->runtime->private_data; 649 stream = s->runtime->private_data;
652 stream->status = PCXHR_STREAM_STATUS_SCHEDULE_RUN; 650 stream->status =
653 snd_pcm_trigger_done(s, subs); 651 PCXHR_STREAM_STATUS_SCHEDULE_RUN;
654 i++; 652 snd_pcm_trigger_done(s, subs);
655 } 653 }
656 if (i==1) { 654 tasklet_hi_schedule(&chip->mgr->trigger_taskq);
655 } else {
656 stream = subs->runtime->private_data;
657 snd_printdd("Only one Substream %c %d\n", 657 snd_printdd("Only one Substream %c %d\n",
658 stream->pipe->is_capture ? 'C' : 'P', 658 stream->pipe->is_capture ? 'C' : 'P',
659 stream->pipe->first_audio); 659 stream->pipe->first_audio);
@@ -665,15 +665,11 @@ static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd)
665 if (pcxhr_set_stream_state(stream)) 665 if (pcxhr_set_stream_state(stream))
666 return -EINVAL; 666 return -EINVAL;
667 stream->status = PCXHR_STREAM_STATUS_RUNNING; 667 stream->status = PCXHR_STREAM_STATUS_RUNNING;
668 } else {
669 struct snd_pcxhr *chip = snd_pcm_substream_chip(subs);
670 tasklet_hi_schedule(&chip->mgr->trigger_taskq);
671 } 668 }
672 break; 669 break;
673 case SNDRV_PCM_TRIGGER_STOP: 670 case SNDRV_PCM_TRIGGER_STOP:
674 snd_printdd("SNDRV_PCM_TRIGGER_STOP\n"); 671 snd_printdd("SNDRV_PCM_TRIGGER_STOP\n");
675 snd_pcm_group_for_each(pos, subs) { 672 snd_pcm_group_for_each_entry(s, subs) {
676 s = snd_pcm_group_substream_entry(pos);
677 stream = s->runtime->private_data; 673 stream = s->runtime->private_data;
678 stream->status = PCXHR_STREAM_STATUS_SCHEDULE_STOP; 674 stream->status = PCXHR_STREAM_STATUS_SCHEDULE_STOP;
679 if (pcxhr_set_stream_state(stream)) 675 if (pcxhr_set_stream_state(stream))
diff --git a/sound/pci/pcxhr/pcxhr_hwdep.c b/sound/pci/pcxhr/pcxhr_hwdep.c
index 369c19fea985..d55d8bc90eee 100644
--- a/sound/pci/pcxhr/pcxhr_hwdep.c
+++ b/sound/pci/pcxhr/pcxhr_hwdep.c
@@ -356,6 +356,12 @@ int pcxhr_setup_firmware(struct pcxhr_mgr *mgr)
356 return 0; 356 return 0;
357} 357}
358 358
359MODULE_FIRMWARE("pcxhr/xi_1_882.dat");
360MODULE_FIRMWARE("pcxhr/xc_1_882.dat");
361MODULE_FIRMWARE("pcxhr/e321_512.e56");
362MODULE_FIRMWARE("pcxhr/b321_512.b56");
363MODULE_FIRMWARE("pcxhr/d321_512.d56");
364
359#else /* old style firmware loading */ 365#else /* old style firmware loading */
360 366
361/* pcxhr hwdep interface id string */ 367/* pcxhr hwdep interface id string */
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index 952625dead58..8e5410483e67 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -117,6 +117,7 @@ MODULE_AUTHOR("Peter Gruber <nokos@gmx.net>");
117MODULE_DESCRIPTION("riptide"); 117MODULE_DESCRIPTION("riptide");
118MODULE_LICENSE("GPL"); 118MODULE_LICENSE("GPL");
119MODULE_SUPPORTED_DEVICE("{{Conexant,Riptide}}"); 119MODULE_SUPPORTED_DEVICE("{{Conexant,Riptide}}");
120MODULE_FIRMWARE("riptide.hex");
120 121
121static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 122static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
122static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 123static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c
index 6bb7ac650ec4..618653e22561 100644
--- a/sound/pci/rme32.c
+++ b/sound/pci/rme32.c
@@ -1078,12 +1078,10 @@ static int
1078snd_rme32_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 1078snd_rme32_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1079{ 1079{
1080 struct rme32 *rme32 = snd_pcm_substream_chip(substream); 1080 struct rme32 *rme32 = snd_pcm_substream_chip(substream);
1081 struct list_head *pos;
1082 struct snd_pcm_substream *s; 1081 struct snd_pcm_substream *s;
1083 1082
1084 spin_lock(&rme32->lock); 1083 spin_lock(&rme32->lock);
1085 snd_pcm_group_for_each(pos, substream) { 1084 snd_pcm_group_for_each_entry(s, substream) {
1086 s = snd_pcm_group_substream_entry(pos);
1087 if (s != rme32->playback_substream && 1085 if (s != rme32->playback_substream &&
1088 s != rme32->capture_substream) 1086 s != rme32->capture_substream)
1089 continue; 1087 continue;
@@ -1110,8 +1108,7 @@ snd_rme32_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1110 1108
1111 /* prefill playback buffer */ 1109 /* prefill playback buffer */
1112 if (cmd == SNDRV_PCM_TRIGGER_START && rme32->fullduplex_mode) { 1110 if (cmd == SNDRV_PCM_TRIGGER_START && rme32->fullduplex_mode) {
1113 snd_pcm_group_for_each(pos, substream) { 1111 snd_pcm_group_for_each_entry(s, substream) {
1114 s = snd_pcm_group_substream_entry(pos);
1115 if (s == rme32->playback_substream) { 1112 if (s == rme32->playback_substream) {
1116 s->ops->ack(s); 1113 s->ops->ack(s);
1117 break; 1114 break;
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index 89b3c7ff5037..3b3ef657f73e 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -60,6 +60,12 @@ MODULE_LICENSE("GPL");
60MODULE_SUPPORTED_DEVICE("{{RME Hammerfall-DSP}," 60MODULE_SUPPORTED_DEVICE("{{RME Hammerfall-DSP},"
61 "{RME HDSP-9652}," 61 "{RME HDSP-9652},"
62 "{RME HDSP-9632}}"); 62 "{RME HDSP-9632}}");
63#ifdef HDSP_FW_LOADER
64MODULE_FIRMWARE("multiface_firmware.bin");
65MODULE_FIRMWARE("multiface_firmware_rev11.bin");
66MODULE_FIRMWARE("digiface_firmware.bin");
67MODULE_FIRMWARE("digiface_firmware_rev11.bin");
68#endif
63 69
64#define HDSP_MAX_CHANNELS 26 70#define HDSP_MAX_CHANNELS 26
65#define HDSP_MAX_DS_CHANNELS 14 71#define HDSP_MAX_DS_CHANNELS 14
@@ -275,6 +281,11 @@ MODULE_SUPPORTED_DEVICE("{{RME Hammerfall-DSP},"
275#define HDSP_Frequency128KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency0) 281#define HDSP_Frequency128KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency0)
276#define HDSP_Frequency176_4KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency1) 282#define HDSP_Frequency176_4KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency1)
277#define HDSP_Frequency192KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency1|HDSP_Frequency0) 283#define HDSP_Frequency192KHz (HDSP_QuadSpeed|HDSP_DoubleSpeed|HDSP_Frequency1|HDSP_Frequency0)
284/* RME says n = 104857600000000, but in the windows MADI driver, I see:
285 return 104857600000000 / rate; // 100 MHz
286 return 110100480000000 / rate; // 105 MHz
287*/
288#define DDS_NUMERATOR 104857600000000ULL; /* = 2^20 * 10^8 */
278 289
279#define hdsp_encode_latency(x) (((x)<<1) & HDSP_LatencyMask) 290#define hdsp_encode_latency(x) (((x)<<1) & HDSP_LatencyMask)
280#define hdsp_decode_latency(x) (((x) & HDSP_LatencyMask)>>1) 291#define hdsp_decode_latency(x) (((x) & HDSP_LatencyMask)>>1)
@@ -1001,11 +1012,7 @@ static void hdsp_set_dds_value(struct hdsp *hdsp, int rate)
1001 else if (rate >= 56000) 1012 else if (rate >= 56000)
1002 rate /= 2; 1013 rate /= 2;
1003 1014
1004 /* RME says n = 104857600000000, but in the windows MADI driver, I see: 1015 n = DDS_NUMERATOR;
1005// return 104857600000000 / rate; // 100 MHz
1006 return 110100480000000 / rate; // 105 MHz
1007 */
1008 n = 104857600000000ULL; /* = 2^20 * 10^8 */
1009 div64_32(&n, rate, &r); 1016 div64_32(&n, rate, &r);
1010 /* n should be less than 2^32 for being written to FREQ register */ 1017 /* n should be less than 2^32 for being written to FREQ register */
1011 snd_assert((n >> 32) == 0); 1018 snd_assert((n >> 32) == 0);
@@ -3085,11 +3092,83 @@ static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct sn
3085 return 0; 3092 return 0;
3086} 3093}
3087 3094
3095#define HDSP_DDS_OFFSET(xname, xindex) \
3096{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3097 .name = xname, \
3098 .index = xindex, \
3099 .info = snd_hdsp_info_dds_offset, \
3100 .get = snd_hdsp_get_dds_offset, \
3101 .put = snd_hdsp_put_dds_offset \
3102}
3103
3104static int hdsp_dds_offset(struct hdsp *hdsp)
3105{
3106 u64 n;
3107 u32 r;
3108 unsigned int dds_value = hdsp->dds_value;
3109 int system_sample_rate = hdsp->system_sample_rate;
3110
3111 n = DDS_NUMERATOR;
3112 /*
3113 * dds_value = n / rate
3114 * rate = n / dds_value
3115 */
3116 div64_32(&n, dds_value, &r);
3117 if (system_sample_rate >= 112000)
3118 n *= 4;
3119 else if (system_sample_rate >= 56000)
3120 n *= 2;
3121 return ((int)n) - system_sample_rate;
3122}
3123
3124static int hdsp_set_dds_offset(struct hdsp *hdsp, int offset_hz)
3125{
3126 int rate = hdsp->system_sample_rate + offset_hz;
3127 hdsp_set_dds_value(hdsp, rate);
3128 return 0;
3129}
3130
3131static int snd_hdsp_info_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
3132{
3133 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
3134 uinfo->count = 1;
3135 uinfo->value.integer.min = -5000;
3136 uinfo->value.integer.max = 5000;
3137 return 0;
3138}
3139
3140static int snd_hdsp_get_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3141{
3142 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
3143
3144 ucontrol->value.enumerated.item[0] = hdsp_dds_offset(hdsp);
3145 return 0;
3146}
3147
3148static int snd_hdsp_put_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3149{
3150 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
3151 int change;
3152 int val;
3153
3154 if (!snd_hdsp_use_is_exclusive(hdsp))
3155 return -EBUSY;
3156 val = ucontrol->value.enumerated.item[0];
3157 spin_lock_irq(&hdsp->lock);
3158 if (val != hdsp_dds_offset(hdsp))
3159 change = (hdsp_set_dds_offset(hdsp, val) == 0) ? 1 : 0;
3160 else
3161 change = 0;
3162 spin_unlock_irq(&hdsp->lock);
3163 return change;
3164}
3165
3088static struct snd_kcontrol_new snd_hdsp_9632_controls[] = { 3166static struct snd_kcontrol_new snd_hdsp_9632_controls[] = {
3089HDSP_DA_GAIN("DA Gain", 0), 3167HDSP_DA_GAIN("DA Gain", 0),
3090HDSP_AD_GAIN("AD Gain", 0), 3168HDSP_AD_GAIN("AD Gain", 0),
3091HDSP_PHONE_GAIN("Phones Gain", 0), 3169HDSP_PHONE_GAIN("Phones Gain", 0),
3092HDSP_XLR_BREAKOUT_CABLE("XLR Breakout Cable", 0) 3170HDSP_XLR_BREAKOUT_CABLE("XLR Breakout Cable", 0),
3171HDSP_DDS_OFFSET("DDS Sample Rate Offset", 0)
3093}; 3172};
3094 3173
3095static struct snd_kcontrol_new snd_hdsp_controls[] = { 3174static struct snd_kcontrol_new snd_hdsp_controls[] = {
@@ -3780,11 +3859,9 @@ static int snd_hdsp_reset(struct snd_pcm_substream *substream)
3780 else 3859 else
3781 runtime->status->hw_ptr = 0; 3860 runtime->status->hw_ptr = 0;
3782 if (other) { 3861 if (other) {
3783 struct list_head *pos;
3784 struct snd_pcm_substream *s; 3862 struct snd_pcm_substream *s;
3785 struct snd_pcm_runtime *oruntime = other->runtime; 3863 struct snd_pcm_runtime *oruntime = other->runtime;
3786 snd_pcm_group_for_each(pos, substream) { 3864 snd_pcm_group_for_each_entry(s, substream) {
3787 s = snd_pcm_group_substream_entry(pos);
3788 if (s == other) { 3865 if (s == other) {
3789 oruntime->status->hw_ptr = runtime->status->hw_ptr; 3866 oruntime->status->hw_ptr = runtime->status->hw_ptr;
3790 break; 3867 break;
@@ -3933,10 +4010,8 @@ static int snd_hdsp_trigger(struct snd_pcm_substream *substream, int cmd)
3933 other = hdsp->playback_substream; 4010 other = hdsp->playback_substream;
3934 4011
3935 if (other) { 4012 if (other) {
3936 struct list_head *pos;
3937 struct snd_pcm_substream *s; 4013 struct snd_pcm_substream *s;
3938 snd_pcm_group_for_each(pos, substream) { 4014 snd_pcm_group_for_each_entry(s, substream) {
3939 s = snd_pcm_group_substream_entry(pos);
3940 if (s == other) { 4015 if (s == other) {
3941 snd_pcm_trigger_done(s, substream); 4016 snd_pcm_trigger_done(s, substream);
3942 if (cmd == SNDRV_PCM_TRIGGER_START) 4017 if (cmd == SNDRV_PCM_TRIGGER_START)
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index 6e95857e4e67..143185e7e4dc 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -91,8 +91,10 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
91#define HDSPM_controlRegister 64 91#define HDSPM_controlRegister 64
92#define HDSPM_interruptConfirmation 96 92#define HDSPM_interruptConfirmation 96
93#define HDSPM_control2Reg 256 /* not in specs ???????? */ 93#define HDSPM_control2Reg 256 /* not in specs ???????? */
94#define HDSPM_freqReg 256 /* for AES32 */
94#define HDSPM_midiDataOut0 352 /* just believe in old code */ 95#define HDSPM_midiDataOut0 352 /* just believe in old code */
95#define HDSPM_midiDataOut1 356 96#define HDSPM_midiDataOut1 356
97#define HDSPM_eeprom_wr 384 /* for AES32 */
96 98
97/* DMA enable for 64 channels, only Bit 0 is relevant */ 99/* DMA enable for 64 channels, only Bit 0 is relevant */
98#define HDSPM_outputEnableBase 512 /* 512-767 input DMA */ 100#define HDSPM_outputEnableBase 512 /* 512-767 input DMA */
@@ -389,9 +391,8 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
389 size is the same regardless of the number of channels, and 391 size is the same regardless of the number of channels, and
390 also the latency to use. 392 also the latency to use.
391 for one direction !!! 393 for one direction !!!
392 => need to mupltiply by 2!!
393*/ 394*/
394#define HDSPM_DMA_AREA_BYTES (2 * HDSPM_MAX_CHANNELS * HDSPM_CHANNEL_BUFFER_BYTES) 395#define HDSPM_DMA_AREA_BYTES (HDSPM_MAX_CHANNELS * HDSPM_CHANNEL_BUFFER_BYTES)
395#define HDSPM_DMA_AREA_KILOBYTES (HDSPM_DMA_AREA_BYTES/1024) 396#define HDSPM_DMA_AREA_KILOBYTES (HDSPM_DMA_AREA_BYTES/1024)
396 397
397/* revisions >= 230 indicate AES32 card */ 398/* revisions >= 230 indicate AES32 card */
@@ -484,28 +485,6 @@ static char channel_map_madi_ss[HDSPM_MAX_CHANNELS] = {
484 56, 57, 58, 59, 60, 61, 62, 63 485 56, 57, 58, 59, 60, 61, 62, 63
485}; 486};
486 487
487static char channel_map_madi_ds[HDSPM_MAX_CHANNELS] = {
488 0, 2, 4, 6, 8, 10, 12, 14,
489 16, 18, 20, 22, 24, 26, 28, 30,
490 32, 34, 36, 38, 40, 42, 44, 46,
491 48, 50, 52, 54, 56, 58, 60, 62,
492 -1, -1, -1, -1, -1, -1, -1, -1,
493 -1, -1, -1, -1, -1, -1, -1, -1,
494 -1, -1, -1, -1, -1, -1, -1, -1,
495 -1, -1, -1, -1, -1, -1, -1, -1
496};
497
498static char channel_map_madi_qs[HDSPM_MAX_CHANNELS] = {
499 0, 4, 8, 12, 16, 20, 24, 28,
500 32, 36, 40, 44, 48, 52, 56, 60
501 -1, -1, -1, -1, -1, -1, -1, -1,
502 -1, -1, -1, -1, -1, -1, -1, -1,
503 -1, -1, -1, -1, -1, -1, -1, -1,
504 -1, -1, -1, -1, -1, -1, -1, -1,
505 -1, -1, -1, -1, -1, -1, -1, -1,
506 -1, -1, -1, -1, -1, -1, -1, -1
507};
508
509 488
510static struct pci_device_id snd_hdspm_ids[] __devinitdata = { 489static struct pci_device_id snd_hdspm_ids[] __devinitdata = {
511 { 490 {
@@ -818,6 +797,27 @@ static int hdspm_set_interrupt_interval(struct hdspm * s, unsigned int frames)
818 return 0; 797 return 0;
819} 798}
820 799
800static void hdspm_set_dds_value(struct hdspm *hdspm, int rate)
801{
802 u64 n;
803 u32 r;
804
805 if (rate >= 112000)
806 rate /= 4;
807 else if (rate >= 56000)
808 rate /= 2;
809
810 /* RME says n = 104857600000000, but in the windows MADI driver, I see:
811// return 104857600000000 / rate; // 100 MHz
812 return 110100480000000 / rate; // 105 MHz
813 */
814 //n = 104857600000000ULL; /* = 2^20 * 10^8 */
815 n = 110100480000000ULL; /* Value checked for AES32 and MADI */
816 div64_32(&n, rate, &r);
817 /* n should be less than 2^32 for being written to FREQ register */
818 snd_assert((n >> 32) == 0);
819 hdspm_write(hdspm, HDSPM_freqReg, (u32)n);
820}
821 821
822/* dummy set rate lets see what happens */ 822/* dummy set rate lets see what happens */
823static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally) 823static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally)
@@ -943,12 +943,16 @@ static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally)
943 hdspm->control_register |= rate_bits; 943 hdspm->control_register |= rate_bits;
944 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); 944 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
945 945
946 if (rate > 96000 /* 64000*/) 946 /* For AES32, need to set DDS value in FREQ register
947 hdspm->channel_map = channel_map_madi_qs; 947 For MADI, also apparently */
948 else if (rate > 48000) 948 hdspm_set_dds_value(hdspm, rate);
949 hdspm->channel_map = channel_map_madi_ds; 949
950 else 950 if (hdspm->is_aes32 && rate != current_rate)
951 hdspm->channel_map = channel_map_madi_ss; 951 hdspm_write(hdspm, HDSPM_eeprom_wr, 0);
952
953 /* For AES32 and for MADI (at least rev 204), channel_map needs to
954 * always be channel_map_madi_ss, whatever the sample rate */
955 hdspm->channel_map = channel_map_madi_ss;
952 956
953 hdspm->system_sample_rate = rate; 957 hdspm->system_sample_rate = rate;
954 958
@@ -3184,8 +3188,8 @@ snd_hdspm_proc_read_aes32(struct snd_info_entry * entry,
3184 hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xFF, 3188 hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xFF,
3185 hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xFF); 3189 hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xFF);
3186 snd_iprintf(buffer, 3190 snd_iprintf(buffer,
3187 "Register: ctrl1=0x%x, ctrl2=0x%x, status1=0x%x, status2=0x%x, timecode=0x%x\n", 3191 "Register: ctrl1=0x%x, status1=0x%x, status2=0x%x, timecode=0x%x\n",
3188 hdspm->control_register, hdspm->control2_register, 3192 hdspm->control_register,
3189 status, status2, timecode); 3193 status, status2, timecode);
3190 3194
3191 snd_iprintf(buffer, "--- Settings ---\n"); 3195 snd_iprintf(buffer, "--- Settings ---\n");
@@ -3377,13 +3381,16 @@ static int snd_hdspm_set_defaults(struct hdspm * hdspm)
3377 3381
3378 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); 3382 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
3379 3383
3384 if (!hdspm->is_aes32) {
3385 /* No control2 register for AES32 */
3380#ifdef SNDRV_BIG_ENDIAN 3386#ifdef SNDRV_BIG_ENDIAN
3381 hdspm->control2_register = HDSPM_BIGENDIAN_MODE; 3387 hdspm->control2_register = HDSPM_BIGENDIAN_MODE;
3382#else 3388#else
3383 hdspm->control2_register = 0; 3389 hdspm->control2_register = 0;
3384#endif 3390#endif
3385 3391
3386 hdspm_write(hdspm, HDSPM_control2Reg, hdspm->control2_register); 3392 hdspm_write(hdspm, HDSPM_control2Reg, hdspm->control2_register);
3393 }
3387 hdspm_compute_period_size(hdspm); 3394 hdspm_compute_period_size(hdspm);
3388 3395
3389 /* silence everything */ 3396 /* silence everything */
@@ -3575,11 +3582,9 @@ static int snd_hdspm_reset(struct snd_pcm_substream *substream)
3575 else 3582 else
3576 runtime->status->hw_ptr = 0; 3583 runtime->status->hw_ptr = 0;
3577 if (other) { 3584 if (other) {
3578 struct list_head *pos;
3579 struct snd_pcm_substream *s; 3585 struct snd_pcm_substream *s;
3580 struct snd_pcm_runtime *oruntime = other->runtime; 3586 struct snd_pcm_runtime *oruntime = other->runtime;
3581 snd_pcm_group_for_each(pos, substream) { 3587 snd_pcm_group_for_each_entry(s, substream) {
3582 s = snd_pcm_group_substream_entry(pos);
3583 if (s == other) { 3588 if (s == other) {
3584 oruntime->status->hw_ptr = 3589 oruntime->status->hw_ptr =
3585 runtime->status->hw_ptr; 3590 runtime->status->hw_ptr;
@@ -3658,11 +3663,10 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
3658 3663
3659 /* Memory allocation, takashi's method, dont know if we should spinlock */ 3664 /* Memory allocation, takashi's method, dont know if we should spinlock */
3660 /* malloc all buffer even if not enabled to get sure */ 3665 /* malloc all buffer even if not enabled to get sure */
3661 /* malloc only needed bytes */ 3666 /* Update for MADI rev 204: we need to allocate for all channels,
3667 * otherwise it doesn't work at 96kHz */
3662 err = 3668 err =
3663 snd_pcm_lib_malloc_pages(substream, 3669 snd_pcm_lib_malloc_pages(substream, HDSPM_DMA_AREA_BYTES);
3664 HDSPM_CHANNEL_BUFFER_BYTES *
3665 params_channels(params));
3666 if (err < 0) 3670 if (err < 0)
3667 return err; 3671 return err;
3668 3672
@@ -3698,6 +3702,13 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
3698 "playback" : "capture", 3702 "playback" : "capture",
3699 snd_pcm_sgbuf_get_addr(sgbuf, 0)); 3703 snd_pcm_sgbuf_get_addr(sgbuf, 0));
3700 */ 3704 */
3705 /*
3706 snd_printdd("set_hwparams: %s %d Hz, %d channels, bs = %d\n",
3707 substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
3708 "playback" : "capture",
3709 params_rate(params), params_channels(params),
3710 params_buffer_size(params));
3711 */
3701 return 0; 3712 return 0;
3702} 3713}
3703 3714
@@ -3791,10 +3802,8 @@ static int snd_hdspm_trigger(struct snd_pcm_substream *substream, int cmd)
3791 other = hdspm->playback_substream; 3802 other = hdspm->playback_substream;
3792 3803
3793 if (other) { 3804 if (other) {
3794 struct list_head *pos;
3795 struct snd_pcm_substream *s; 3805 struct snd_pcm_substream *s;
3796 snd_pcm_group_for_each(pos, substream) { 3806 snd_pcm_group_for_each_entry(s, substream) {
3797 s = snd_pcm_group_substream_entry(pos);
3798 if (s == other) { 3807 if (s == other) {
3799 snd_pcm_trigger_done(s, substream); 3808 snd_pcm_trigger_done(s, substream);
3800 if (cmd == SNDRV_PCM_TRIGGER_START) 3809 if (cmd == SNDRV_PCM_TRIGGER_START)
@@ -3904,16 +3913,16 @@ static int snd_hdspm_hw_rule_channels_rate(struct snd_pcm_hw_params *params,
3904 struct snd_interval *r = 3913 struct snd_interval *r =
3905 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); 3914 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
3906 3915
3907 if (r->min > 48000) { 3916 if (r->min > 48000 && r->max <= 96000) {
3908 struct snd_interval t = { 3917 struct snd_interval t = {
3909 .min = 1, 3918 .min = hdspm->ds_channels,
3910 .max = hdspm->ds_channels, 3919 .max = hdspm->ds_channels,
3911 .integer = 1, 3920 .integer = 1,
3912 }; 3921 };
3913 return snd_interval_refine(c, &t); 3922 return snd_interval_refine(c, &t);
3914 } else if (r->max < 64000) { 3923 } else if (r->max < 64000) {
3915 struct snd_interval t = { 3924 struct snd_interval t = {
3916 .min = 1, 3925 .min = hdspm->ss_channels,
3917 .max = hdspm->ss_channels, 3926 .max = hdspm->ss_channels,
3918 .integer = 1, 3927 .integer = 1,
3919 }; 3928 };
@@ -3931,14 +3940,14 @@ static int snd_hdspm_hw_rule_rate_channels(struct snd_pcm_hw_params *params,
3931 struct snd_interval *r = 3940 struct snd_interval *r =
3932 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); 3941 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
3933 3942
3934 if (c->min <= hdspm->ss_channels) { 3943 if (c->min >= hdspm->ss_channels) {
3935 struct snd_interval t = { 3944 struct snd_interval t = {
3936 .min = 32000, 3945 .min = 32000,
3937 .max = 48000, 3946 .max = 48000,
3938 .integer = 1, 3947 .integer = 1,
3939 }; 3948 };
3940 return snd_interval_refine(r, &t); 3949 return snd_interval_refine(r, &t);
3941 } else if (c->max > hdspm->ss_channels) { 3950 } else if (c->max <= hdspm->ds_channels) {
3942 struct snd_interval t = { 3951 struct snd_interval t = {
3943 .min = 64000, 3952 .min = 64000,
3944 .max = 96000, 3953 .max = 96000,
@@ -3950,13 +3959,39 @@ static int snd_hdspm_hw_rule_rate_channels(struct snd_pcm_hw_params *params,
3950 return 0; 3959 return 0;
3951} 3960}
3952 3961
3962static int snd_hdspm_hw_rule_channels(struct snd_pcm_hw_params *params,
3963 struct snd_pcm_hw_rule *rule)
3964{
3965 unsigned int list[3];
3966 struct hdspm *hdspm = rule->private;
3967 struct snd_interval *c = hw_param_interval(params,
3968 SNDRV_PCM_HW_PARAM_CHANNELS);
3969 if (hdspm->is_aes32) {
3970 list[0] = hdspm->qs_channels;
3971 list[1] = hdspm->ds_channels;
3972 list[2] = hdspm->ss_channels;
3973 return snd_interval_list(c, 3, list, 0);
3974 } else {
3975 list[0] = hdspm->ds_channels;
3976 list[1] = hdspm->ss_channels;
3977 return snd_interval_list(c, 2, list, 0);
3978 }
3979}
3980
3981
3982static unsigned int hdspm_aes32_sample_rates[] = { 32000, 44100, 48000, 64000, 88200, 96000, 128000, 176400, 192000 };
3983
3984static struct snd_pcm_hw_constraint_list hdspm_hw_constraints_aes32_sample_rates = {
3985 .count = ARRAY_SIZE(hdspm_aes32_sample_rates),
3986 .list = hdspm_aes32_sample_rates,
3987 .mask = 0
3988};
3989
3953static int snd_hdspm_playback_open(struct snd_pcm_substream *substream) 3990static int snd_hdspm_playback_open(struct snd_pcm_substream *substream)
3954{ 3991{
3955 struct hdspm *hdspm = snd_pcm_substream_chip(substream); 3992 struct hdspm *hdspm = snd_pcm_substream_chip(substream);
3956 struct snd_pcm_runtime *runtime = substream->runtime; 3993 struct snd_pcm_runtime *runtime = substream->runtime;
3957 3994
3958 snd_printdd("Open device substream %d\n", substream->stream);
3959
3960 spin_lock_irq(&hdspm->lock); 3995 spin_lock_irq(&hdspm->lock);
3961 3996
3962 snd_pcm_set_sync(substream); 3997 snd_pcm_set_sync(substream);
@@ -3977,14 +4012,21 @@ static int snd_hdspm_playback_open(struct snd_pcm_substream *substream)
3977 SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 4012 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
3978 &hw_constraints_period_sizes); 4013 &hw_constraints_period_sizes);
3979 4014
3980 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 4015 if (hdspm->is_aes32) {
3981 snd_hdspm_hw_rule_channels_rate, hdspm, 4016 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
3982 SNDRV_PCM_HW_PARAM_RATE, -1); 4017 &hdspm_hw_constraints_aes32_sample_rates);
3983 4018 } else {
3984 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, 4019 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
3985 snd_hdspm_hw_rule_rate_channels, hdspm, 4020 snd_hdspm_hw_rule_channels, hdspm,
3986 SNDRV_PCM_HW_PARAM_CHANNELS, -1); 4021 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
3987 4022 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
4023 snd_hdspm_hw_rule_channels_rate, hdspm,
4024 SNDRV_PCM_HW_PARAM_RATE, -1);
4025
4026 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
4027 snd_hdspm_hw_rule_rate_channels, hdspm,
4028 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
4029 }
3988 return 0; 4030 return 0;
3989} 4031}
3990 4032
@@ -4024,14 +4066,21 @@ static int snd_hdspm_capture_open(struct snd_pcm_substream *substream)
4024 snd_pcm_hw_constraint_list(runtime, 0, 4066 snd_pcm_hw_constraint_list(runtime, 0,
4025 SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 4067 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
4026 &hw_constraints_period_sizes); 4068 &hw_constraints_period_sizes);
4027 4069 if (hdspm->is_aes32) {
4028 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 4070 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
4029 snd_hdspm_hw_rule_channels_rate, hdspm, 4071 &hdspm_hw_constraints_aes32_sample_rates);
4030 SNDRV_PCM_HW_PARAM_RATE, -1); 4072 } else {
4031 4073 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
4032 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, 4074 snd_hdspm_hw_rule_channels, hdspm,
4033 snd_hdspm_hw_rule_rate_channels, hdspm, 4075 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
4034 SNDRV_PCM_HW_PARAM_CHANNELS, -1); 4076 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
4077 snd_hdspm_hw_rule_channels_rate, hdspm,
4078 SNDRV_PCM_HW_PARAM_RATE, -1);
4079
4080 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
4081 snd_hdspm_hw_rule_rate_channels, hdspm,
4082 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
4083 }
4035 return 0; 4084 return 0;
4036} 4085}
4037 4086
diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
index cc3bdececce7..bd7dbd267ed1 100644
--- a/sound/pci/rme9652/rme9652.c
+++ b/sound/pci/rme9652/rme9652.c
@@ -1992,11 +1992,9 @@ static int snd_rme9652_reset(struct snd_pcm_substream *substream)
1992 else 1992 else
1993 runtime->status->hw_ptr = 0; 1993 runtime->status->hw_ptr = 0;
1994 if (other) { 1994 if (other) {
1995 struct list_head *pos;
1996 struct snd_pcm_substream *s; 1995 struct snd_pcm_substream *s;
1997 struct snd_pcm_runtime *oruntime = other->runtime; 1996 struct snd_pcm_runtime *oruntime = other->runtime;
1998 snd_pcm_group_for_each(pos, substream) { 1997 snd_pcm_group_for_each_entry(s, substream) {
1999 s = snd_pcm_group_substream_entry(pos);
2000 if (s == other) { 1998 if (s == other) {
2001 oruntime->status->hw_ptr = runtime->status->hw_ptr; 1999 oruntime->status->hw_ptr = runtime->status->hw_ptr;
2002 break; 2000 break;
@@ -2140,10 +2138,8 @@ static int snd_rme9652_trigger(struct snd_pcm_substream *substream,
2140 other = rme9652->playback_substream; 2138 other = rme9652->playback_substream;
2141 2139
2142 if (other) { 2140 if (other) {
2143 struct list_head *pos;
2144 struct snd_pcm_substream *s; 2141 struct snd_pcm_substream *s;
2145 snd_pcm_group_for_each(pos, substream) { 2142 snd_pcm_group_for_each_entry(s, substream) {
2146 s = snd_pcm_group_substream_entry(pos);
2147 if (s == other) { 2143 if (s == other) {
2148 snd_pcm_trigger_done(s, substream); 2144 snd_pcm_trigger_done(s, substream);
2149 if (cmd == SNDRV_PCM_TRIGGER_START) 2145 if (cmd == SNDRV_PCM_TRIGGER_START)
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
index 3bff32167f66..7ca606272460 100644
--- a/sound/pci/trident/trident_main.c
+++ b/sound/pci/trident/trident_main.c
@@ -1540,7 +1540,6 @@ static int snd_trident_trigger(struct snd_pcm_substream *substream,
1540 1540
1541{ 1541{
1542 struct snd_trident *trident = snd_pcm_substream_chip(substream); 1542 struct snd_trident *trident = snd_pcm_substream_chip(substream);
1543 struct list_head *pos;
1544 struct snd_pcm_substream *s; 1543 struct snd_pcm_substream *s;
1545 unsigned int what, whati, capture_flag, spdif_flag; 1544 unsigned int what, whati, capture_flag, spdif_flag;
1546 struct snd_trident_voice *voice, *evoice; 1545 struct snd_trident_voice *voice, *evoice;
@@ -1563,8 +1562,7 @@ static int snd_trident_trigger(struct snd_pcm_substream *substream,
1563 what = whati = capture_flag = spdif_flag = 0; 1562 what = whati = capture_flag = spdif_flag = 0;
1564 spin_lock(&trident->reg_lock); 1563 spin_lock(&trident->reg_lock);
1565 val = inl(TRID_REG(trident, T4D_STIMER)) & 0x00ffffff; 1564 val = inl(TRID_REG(trident, T4D_STIMER)) & 0x00ffffff;
1566 snd_pcm_group_for_each(pos, substream) { 1565 snd_pcm_group_for_each_entry(s, substream) {
1567 s = snd_pcm_group_substream_entry(pos);
1568 if ((struct snd_trident *) snd_pcm_substream_chip(s) == trident) { 1566 if ((struct snd_trident *) snd_pcm_substream_chip(s) == trident) {
1569 voice = s->runtime->private_data; 1567 voice = s->runtime->private_data;
1570 evoice = voice->extra; 1568 evoice = voice->extra;
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index fd12674d0394..ea861bceaddf 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -1998,9 +1998,7 @@ static void snd_ymfpci_disable_dsp(struct snd_ymfpci *chip)
1998 } 1998 }
1999} 1999}
2000 2000
2001#define FIRMWARE_IN_THE_KERNEL 2001#ifdef CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL
2002
2003#ifdef FIRMWARE_IN_THE_KERNEL
2004 2002
2005#include "ymfpci_image.h" 2003#include "ymfpci_image.h"
2006 2004
@@ -2018,6 +2016,24 @@ static struct firmware snd_ymfpci_controller_1e_microcode = {
2018}; 2016};
2019#endif 2017#endif
2020 2018
2019#ifdef CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL
2020static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)
2021{
2022 chip->dsp_microcode = &snd_ymfpci_dsp_microcode;
2023 if (chip->device_id == PCI_DEVICE_ID_YAMAHA_724F ||
2024 chip->device_id == PCI_DEVICE_ID_YAMAHA_740C ||
2025 chip->device_id == PCI_DEVICE_ID_YAMAHA_744 ||
2026 chip->device_id == PCI_DEVICE_ID_YAMAHA_754)
2027 chip->controller_microcode =
2028 &snd_ymfpci_controller_1e_microcode;
2029 else
2030 chip->controller_microcode =
2031 &snd_ymfpci_controller_microcode;
2032 return 0;
2033}
2034
2035#else /* use fw_loader */
2036
2021#ifdef __LITTLE_ENDIAN 2037#ifdef __LITTLE_ENDIAN
2022static inline void snd_ymfpci_convert_from_le(const struct firmware *fw) { } 2038static inline void snd_ymfpci_convert_from_le(const struct firmware *fw) { }
2023#else 2039#else
@@ -2046,13 +2062,8 @@ static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)
2046 err = -EINVAL; 2062 err = -EINVAL;
2047 } 2063 }
2048 } 2064 }
2049 if (err < 0) { 2065 if (err < 0)
2050#ifdef FIRMWARE_IN_THE_KERNEL
2051 chip->dsp_microcode = &snd_ymfpci_dsp_microcode;
2052#else
2053 return err; 2066 return err;
2054#endif
2055 }
2056 is_1e = chip->device_id == PCI_DEVICE_ID_YAMAHA_724F || 2067 is_1e = chip->device_id == PCI_DEVICE_ID_YAMAHA_724F ||
2057 chip->device_id == PCI_DEVICE_ID_YAMAHA_740C || 2068 chip->device_id == PCI_DEVICE_ID_YAMAHA_740C ||
2058 chip->device_id == PCI_DEVICE_ID_YAMAHA_744 || 2069 chip->device_id == PCI_DEVICE_ID_YAMAHA_744 ||
@@ -2069,18 +2080,17 @@ static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)
2069 err = -EINVAL; 2080 err = -EINVAL;
2070 } 2081 }
2071 } 2082 }
2072 if (err < 0) { 2083 if (err < 0)
2073#ifdef FIRMWARE_IN_THE_KERNEL
2074 chip->controller_microcode =
2075 is_1e ? &snd_ymfpci_controller_1e_microcode
2076 : &snd_ymfpci_controller_microcode;
2077#else
2078 return err; 2084 return err;
2079#endif
2080 }
2081 return 0; 2085 return 0;
2082} 2086}
2083 2087
2088MODULE_FIRMWARE("yamaha/ds1_dsp.fw");
2089MODULE_FIRMWARE("yamaha/ds1_ctrl.fw");
2090MODULE_FIRMWARE("yamaha/ds1e_ctrl.fw");
2091
2092#endif
2093
2084static void snd_ymfpci_download_image(struct snd_ymfpci *chip) 2094static void snd_ymfpci_download_image(struct snd_ymfpci *chip)
2085{ 2095{
2086 int i; 2096 int i;
@@ -2259,15 +2269,10 @@ static int snd_ymfpci_free(struct snd_ymfpci *chip)
2259 pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl); 2269 pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl);
2260 2270
2261 pci_disable_device(chip->pci); 2271 pci_disable_device(chip->pci);
2262#ifdef FIRMWARE_IN_THE_KERNEL 2272#ifndef CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL
2263 if (chip->dsp_microcode != &snd_ymfpci_dsp_microcode) 2273 release_firmware(chip->dsp_microcode);
2264#endif 2274 release_firmware(chip->controller_microcode);
2265 release_firmware(chip->dsp_microcode);
2266#ifdef FIRMWARE_IN_THE_KERNEL
2267 if (chip->controller_microcode != &snd_ymfpci_controller_microcode &&
2268 chip->controller_microcode != &snd_ymfpci_controller_1e_microcode)
2269#endif 2275#endif
2270 release_firmware(chip->controller_microcode);
2271 kfree(chip); 2276 kfree(chip);
2272 return 0; 2277 return 0;
2273} 2278}
diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c
index 363bcb5f08e6..c57e127d9ccb 100644
--- a/sound/pcmcia/vx/vxpocket.c
+++ b/sound/pcmcia/vx/vxpocket.c
@@ -297,7 +297,7 @@ static int vxpocket_probe(struct pcmcia_device *p_dev)
297 297
298 /* find an empty slot from the card list */ 298 /* find an empty slot from the card list */
299 for (i = 0; i < SNDRV_CARDS; i++) { 299 for (i = 0; i < SNDRV_CARDS; i++) {
300 if (! card_alloc & (1 << i)) 300 if (!(card_alloc & (1 << i)))
301 break; 301 break;
302 } 302 }
303 if (i >= SNDRV_CARDS) { 303 if (i >= SNDRV_CARDS) {
diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
index dccaa4be679e..10cffc087181 100644
--- a/sound/soc/Kconfig
+++ b/sound/soc/Kconfig
@@ -2,31 +2,31 @@
2# SoC audio configuration 2# SoC audio configuration
3# 3#
4 4
5menu "SoC audio support" 5menu "System on Chip audio support"
6 depends on SND!=n 6 depends on SND!=n
7 7
8config SND_SOC_AC97_BUS 8config SND_SOC_AC97_BUS
9 bool 9 bool
10 10
11config SND_SOC 11config SND_SOC
12 tristate "SoC audio support" 12 tristate "ALSA for SoC audio support"
13 depends on SND 13 depends on SND
14 select SND_PCM 14 select SND_PCM
15 ---help--- 15 ---help---
16 16
17 If you want SoC support, you should say Y here and also to the 17 If you want ASoC support, you should say Y here and also to the
18 specific driver for your SoC below. You will also need to select the 18 specific driver for your SoC platform below.
19 specific codec(s) attached to the SoC 19
20 ASoC provides power efficient ALSA support for embedded battery powered
21 SoC based systems like PDA's, Phones and Personal Media Players.
20 22
21 This SoC audio support can also be built as a module. If so, the module 23 This ASoC audio support can also be built as a module. If so, the module
22 will be called snd-soc-core. 24 will be called snd-soc-core.
23 25
24# All the supported Soc's 26# All the supported Soc's
25menu "SoC Platforms"
26depends on SND_SOC
27source "sound/soc/at91/Kconfig" 27source "sound/soc/at91/Kconfig"
28source "sound/soc/pxa/Kconfig" 28source "sound/soc/pxa/Kconfig"
29endmenu 29source "sound/soc/s3c24xx/Kconfig"
30 30
31# Supported codecs 31# Supported codecs
32source "sound/soc/codecs/Kconfig" 32source "sound/soc/codecs/Kconfig"
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index 98e6f49dafc2..0ae2e49036f9 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -1,4 +1,4 @@
1snd-soc-core-objs := soc-core.o soc-dapm.o 1snd-soc-core-objs := soc-core.o soc-dapm.o
2 2
3obj-$(CONFIG_SND_SOC) += snd-soc-core.o 3obj-$(CONFIG_SND_SOC) += snd-soc-core.o
4obj-$(CONFIG_SND_SOC) += codecs/ at91/ pxa/ 4obj-$(CONFIG_SND_SOC) += codecs/ at91/ pxa/ s3c24xx/
diff --git a/sound/soc/at91/Kconfig b/sound/soc/at91/Kconfig
index a5b2558916c1..5cb93fd3a407 100644
--- a/sound/soc/at91/Kconfig
+++ b/sound/soc/at91/Kconfig
@@ -1,5 +1,3 @@
1menu "SoC Audio for the Atmel AT91"
2
3config SND_AT91_SOC 1config SND_AT91_SOC
4 tristate "SoC Audio for the Atmel AT91 System-on-Chip" 2 tristate "SoC Audio for the Atmel AT91 System-on-Chip"
5 depends on ARCH_AT91 && SND_SOC 3 depends on ARCH_AT91 && SND_SOC
@@ -8,13 +6,13 @@ config SND_AT91_SOC
8 the AT91 SSC interface. You will also need 6 the AT91 SSC interface. You will also need
9 to select the audio interfaces to support below. 7 to select the audio interfaces to support below.
10 8
11config SND_AT91_SOC_I2S 9config SND_AT91_SOC_SSC
12 tristate 10 tristate
13 11
14config SND_AT91_SOC_ETI_B1_WM8731 12config SND_AT91_SOC_ETI_B1_WM8731
15 tristate "SoC I2S Audio support for WM8731-based Endrelia ETI-B1 boards" 13 tristate "SoC Audio support for WM8731-based Endrelia ETI-B1 boards"
16 depends on SND_AT91_SOC && (MACH_ETI_B1 || MACH_ETI_C1) 14 depends on SND_AT91_SOC && (MACH_ETI_B1 || MACH_ETI_C1)
17 select SND_AT91_SOC_I2S 15 select SND_AT91_SOC_SSC
18 select SND_SOC_WM8731 16 select SND_SOC_WM8731
19 help 17 help
20 Say Y if you want to add support for SoC audio on WM8731-based 18 Say Y if you want to add support for SoC audio on WM8731-based
@@ -27,5 +25,3 @@ config SND_AT91_SOC_ETI_SLAVE
27 help 25 help
28 Say Y if you want to run with the AT91 SSC generating the BCLK 26 Say Y if you want to run with the AT91 SSC generating the BCLK
29 and LRC signals on Endrelia boards. 27 and LRC signals on Endrelia boards.
30
31endmenu
diff --git a/sound/soc/at91/Makefile b/sound/soc/at91/Makefile
index b77b01ab2028..f23da17cc328 100644
--- a/sound/soc/at91/Makefile
+++ b/sound/soc/at91/Makefile
@@ -1,9 +1,9 @@
1# AT91 Platform Support 1# AT91 Platform Support
2snd-soc-at91-objs := at91-pcm.o 2snd-soc-at91-objs := at91-pcm.o
3snd-soc-at91-i2s-objs := at91-i2s.o 3snd-soc-at91-ssc-objs := at91-ssc.o
4 4
5obj-$(CONFIG_SND_AT91_SOC) += snd-soc-at91.o 5obj-$(CONFIG_SND_AT91_SOC) += snd-soc-at91.o
6obj-$(CONFIG_SND_AT91_SOC_I2S) += snd-soc-at91-i2s.o 6obj-$(CONFIG_SND_AT91_SOC_SSC) += snd-soc-at91-ssc.o
7 7
8# AT91 Machine Support 8# AT91 Machine Support
9snd-soc-eti-b1-wm8731-objs := eti_b1_wm8731.o 9snd-soc-eti-b1-wm8731-objs := eti_b1_wm8731.o
diff --git a/sound/soc/at91/at91-i2s.c b/sound/soc/at91/at91-ssc.c
index 9fc0c0388881..3d4e32cff75e 100644
--- a/sound/soc/at91/at91-i2s.c
+++ b/sound/soc/at91/at91-ssc.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * at91-i2s.c -- ALSA SoC I2S Audio Layer Platform driver 2 * at91-ssc.c -- ALSA SoC AT91 SSC Audio Layer Platform driver
3 * 3 *
4 * Author: Frank Mandarino <fmandarino@endrelia.com> 4 * Author: Frank Mandarino <fmandarino@endrelia.com>
5 * Endrelia Technologies Inc. 5 * Endrelia Technologies Inc.
@@ -25,6 +25,7 @@
25#include <sound/driver.h> 25#include <sound/driver.h>
26#include <sound/core.h> 26#include <sound/core.h>
27#include <sound/pcm.h> 27#include <sound/pcm.h>
28#include <sound/pcm_params.h>
28#include <sound/initval.h> 29#include <sound/initval.h>
29#include <sound/soc.h> 30#include <sound/soc.h>
30 31
@@ -33,10 +34,10 @@
33#include <asm/arch/at91_ssc.h> 34#include <asm/arch/at91_ssc.h>
34 35
35#include "at91-pcm.h" 36#include "at91-pcm.h"
36#include "at91-i2s.h" 37#include "at91-ssc.h"
37 38
38#if 0 39#if 0
39#define DBG(x...) printk(KERN_DEBUG "at91-i2s:" x) 40#define DBG(x...) printk(KERN_DEBUG "at91-ssc:" x)
40#else 41#else
41#define DBG(x...) 42#define DBG(x...)
42#endif 43#endif
@@ -92,33 +93,33 @@ static struct at91_ssc_mask ssc_rx_mask = {
92 */ 93 */
93static struct at91_pcm_dma_params ssc_dma_params[NUM_SSC_DEVICES][2] = { 94static struct at91_pcm_dma_params ssc_dma_params[NUM_SSC_DEVICES][2] = {
94 {{ 95 {{
95 .name = "SSC0/I2S PCM Stereo out", 96 .name = "SSC0 PCM out",
96 .pdc = &pdc_tx_reg, 97 .pdc = &pdc_tx_reg,
97 .mask = &ssc_tx_mask, 98 .mask = &ssc_tx_mask,
98 }, 99 },
99 { 100 {
100 .name = "SSC0/I2S PCM Stereo in", 101 .name = "SSC0 PCM in",
101 .pdc = &pdc_rx_reg, 102 .pdc = &pdc_rx_reg,
102 .mask = &ssc_rx_mask, 103 .mask = &ssc_rx_mask,
103 }}, 104 }},
104#if NUM_SSC_DEVICES == 3 105#if NUM_SSC_DEVICES == 3
105 {{ 106 {{
106 .name = "SSC1/I2S PCM Stereo out", 107 .name = "SSC1 PCM out",
107 .pdc = &pdc_tx_reg, 108 .pdc = &pdc_tx_reg,
108 .mask = &ssc_tx_mask, 109 .mask = &ssc_tx_mask,
109 }, 110 },
110 { 111 {
111 .name = "SSC1/I2S PCM Stereo in", 112 .name = "SSC1 PCM in",
112 .pdc = &pdc_rx_reg, 113 .pdc = &pdc_rx_reg,
113 .mask = &ssc_rx_mask, 114 .mask = &ssc_rx_mask,
114 }}, 115 }},
115 {{ 116 {{
116 .name = "SSC2/I2S PCM Stereo out", 117 .name = "SSC2 PCM out",
117 .pdc = &pdc_tx_reg, 118 .pdc = &pdc_tx_reg,
118 .mask = &ssc_tx_mask, 119 .mask = &ssc_tx_mask,
119 }, 120 },
120 { 121 {
121 .name = "SSC1/I2S PCM Stereo in", 122 .name = "SSC2 PCM in",
122 .pdc = &pdc_rx_reg, 123 .pdc = &pdc_rx_reg,
123 .mask = &ssc_rx_mask, 124 .mask = &ssc_rx_mask,
124 }}, 125 }},
@@ -151,33 +152,33 @@ static struct at91_ssc_info {
151} ssc_info[NUM_SSC_DEVICES] = { 152} ssc_info[NUM_SSC_DEVICES] = {
152 { 153 {
153 .name = "ssc0", 154 .name = "ssc0",
154 .lock = SPIN_LOCK_UNLOCKED, 155 .lock = __SPIN_LOCK_UNLOCKED(ssc_info[0].lock),
155 .dir_mask = 0, 156 .dir_mask = 0,
156 .initialized = 0, 157 .initialized = 0,
157 }, 158 },
158#if NUM_SSC_DEVICES == 3 159#if NUM_SSC_DEVICES == 3
159 { 160 {
160 .name = "ssc1", 161 .name = "ssc1",
161 .lock = SPIN_LOCK_UNLOCKED, 162 .lock = __SPIN_LOCK_UNLOCKED(ssc_info[1].lock),
162 .dir_mask = 0, 163 .dir_mask = 0,
163 .initialized = 0, 164 .initialized = 0,
164 }, 165 },
165 { 166 {
166 .name = "ssc2", 167 .name = "ssc2",
167 .lock = SPIN_LOCK_UNLOCKED, 168 .lock = __SPIN_LOCK_UNLOCKED(ssc_info[2].lock),
168 .dir_mask = 0, 169 .dir_mask = 0,
169 .initialized = 0, 170 .initialized = 0,
170 }, 171 },
171#endif 172#endif
172}; 173};
173 174
174static unsigned int at91_i2s_sysclk; 175static unsigned int at91_ssc_sysclk;
175 176
176/* 177/*
177 * SSC interrupt handler. Passes PDC interrupts to the DMA 178 * SSC interrupt handler. Passes PDC interrupts to the DMA
178 * interrupt handler in the PCM driver. 179 * interrupt handler in the PCM driver.
179 */ 180 */
180static irqreturn_t at91_i2s_interrupt(int irq, void *dev_id) 181static irqreturn_t at91_ssc_interrupt(int irq, void *dev_id)
181{ 182{
182 struct at91_ssc_info *ssc_p = dev_id; 183 struct at91_ssc_info *ssc_p = dev_id;
183 struct at91_pcm_dma_params *dma_params; 184 struct at91_pcm_dma_params *dma_params;
@@ -209,13 +210,13 @@ static irqreturn_t at91_i2s_interrupt(int irq, void *dev_id)
209/* 210/*
210 * Startup. Only that one substream allowed in each direction. 211 * Startup. Only that one substream allowed in each direction.
211 */ 212 */
212static int at91_i2s_startup(struct snd_pcm_substream *substream) 213static int at91_ssc_startup(struct snd_pcm_substream *substream)
213{ 214{
214 struct snd_soc_pcm_runtime *rtd = substream->private_data; 215 struct snd_soc_pcm_runtime *rtd = substream->private_data;
215 struct at91_ssc_info *ssc_p = &ssc_info[rtd->dai->cpu_dai->id]; 216 struct at91_ssc_info *ssc_p = &ssc_info[rtd->dai->cpu_dai->id];
216 int dir_mask; 217 int dir_mask;
217 218
218 DBG("i2s_startup: SSC_SR=0x%08lx\n", 219 DBG("ssc_startup: SSC_SR=0x%08lx\n",
219 at91_ssc_read(ssc_p->ssc.base + AT91_SSC_SR)); 220 at91_ssc_read(ssc_p->ssc.base + AT91_SSC_SR));
220 dir_mask = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0x1 : 0x2; 221 dir_mask = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 0x1 : 0x2;
221 222
@@ -234,7 +235,7 @@ static int at91_i2s_startup(struct snd_pcm_substream *substream)
234 * Shutdown. Clear DMA parameters and shutdown the SSC if there 235 * Shutdown. Clear DMA parameters and shutdown the SSC if there
235 * are no other substreams open. 236 * are no other substreams open.
236 */ 237 */
237static void at91_i2s_shutdown(struct snd_pcm_substream *substream) 238static void at91_ssc_shutdown(struct snd_pcm_substream *substream)
238{ 239{
239 struct snd_soc_pcm_runtime *rtd = substream->private_data; 240 struct snd_soc_pcm_runtime *rtd = substream->private_data;
240 struct at91_ssc_info *ssc_p = &ssc_info[rtd->dai->cpu_dai->id]; 241 struct at91_ssc_info *ssc_p = &ssc_info[rtd->dai->cpu_dai->id];
@@ -281,7 +282,7 @@ static void at91_i2s_shutdown(struct snd_pcm_substream *substream)
281/* 282/*
282 * Record the SSC system clock rate. 283 * Record the SSC system clock rate.
283 */ 284 */
284static int at91_i2s_set_dai_sysclk(struct snd_soc_cpu_dai *cpu_dai, 285static int at91_ssc_set_dai_sysclk(struct snd_soc_cpu_dai *cpu_dai,
285 int clk_id, unsigned int freq, int dir) 286 int clk_id, unsigned int freq, int dir)
286{ 287{
287 /* 288 /*
@@ -291,7 +292,7 @@ static int at91_i2s_set_dai_sysclk(struct snd_soc_cpu_dai *cpu_dai,
291 */ 292 */
292 switch (clk_id) { 293 switch (clk_id) {
293 case AT91_SYSCLK_MCK: 294 case AT91_SYSCLK_MCK:
294 at91_i2s_sysclk = freq; 295 at91_ssc_sysclk = freq;
295 break; 296 break;
296 default: 297 default:
297 return -EINVAL; 298 return -EINVAL;
@@ -303,14 +304,11 @@ static int at91_i2s_set_dai_sysclk(struct snd_soc_cpu_dai *cpu_dai,
303/* 304/*
304 * Record the DAI format for use in hw_params(). 305 * Record the DAI format for use in hw_params().
305 */ 306 */
306static int at91_i2s_set_dai_fmt(struct snd_soc_cpu_dai *cpu_dai, 307static int at91_ssc_set_dai_fmt(struct snd_soc_cpu_dai *cpu_dai,
307 unsigned int fmt) 308 unsigned int fmt)
308{ 309{
309 struct at91_ssc_info *ssc_p = &ssc_info[cpu_dai->id]; 310 struct at91_ssc_info *ssc_p = &ssc_info[cpu_dai->id];
310 311
311 if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_I2S)
312 return -EINVAL;
313
314 ssc_p->daifmt = fmt; 312 ssc_p->daifmt = fmt;
315 return 0; 313 return 0;
316} 314}
@@ -318,7 +316,7 @@ static int at91_i2s_set_dai_fmt(struct snd_soc_cpu_dai *cpu_dai,
318/* 316/*
319 * Record SSC clock dividers for use in hw_params(). 317 * Record SSC clock dividers for use in hw_params().
320 */ 318 */
321static int at91_i2s_set_dai_clkdiv(struct snd_soc_cpu_dai *cpu_dai, 319static int at91_ssc_set_dai_clkdiv(struct snd_soc_cpu_dai *cpu_dai,
322 int div_id, int div) 320 int div_id, int div)
323{ 321{
324 struct at91_ssc_info *ssc_p = &ssc_info[cpu_dai->id]; 322 struct at91_ssc_info *ssc_p = &ssc_info[cpu_dai->id];
@@ -355,7 +353,7 @@ static int at91_i2s_set_dai_clkdiv(struct snd_soc_cpu_dai *cpu_dai,
355/* 353/*
356 * Configure the SSC. 354 * Configure the SSC.
357 */ 355 */
358static int at91_i2s_hw_params(struct snd_pcm_substream *substream, 356static int at91_ssc_hw_params(struct snd_pcm_substream *substream,
359 struct snd_pcm_hw_params *params) 357 struct snd_pcm_hw_params *params)
360{ 358{
361 struct snd_soc_pcm_runtime *rtd = substream->private_data; 359 struct snd_soc_pcm_runtime *rtd = substream->private_data;
@@ -391,20 +389,50 @@ static int at91_i2s_hw_params(struct snd_pcm_substream *substream,
391 channels = params_channels(params); 389 channels = params_channels(params);
392 390
393 /* 391 /*
392 * Determine sample size in bits and the PDC increment.
393 */
394 switch(params_format(params)) {
395 case SNDRV_PCM_FORMAT_S8:
396 bits = 8;
397 dma_params->pdc_xfer_size = 1;
398 break;
399 case SNDRV_PCM_FORMAT_S16_LE:
400 bits = 16;
401 dma_params->pdc_xfer_size = 2;
402 break;
403 case SNDRV_PCM_FORMAT_S24_LE:
404 bits = 24;
405 dma_params->pdc_xfer_size = 4;
406 break;
407 case SNDRV_PCM_FORMAT_S32_LE:
408 bits = 32;
409 dma_params->pdc_xfer_size = 4;
410 break;
411 default:
412 printk(KERN_WARNING "at91-ssc: unsupported PCM format");
413 return -EINVAL;
414 }
415
416 /*
394 * The SSC only supports up to 16-bit samples in I2S format, due 417 * The SSC only supports up to 16-bit samples in I2S format, due
395 * to the size of the Frame Mode Register FSLEN field. Also, I2S 418 * to the size of the Frame Mode Register FSLEN field.
396 * implies signed data.
397 */ 419 */
398 bits = 16; 420 if ((ssc_p->daifmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_I2S
399 dma_params->pdc_xfer_size = 2; 421 && bits > 16) {
422 printk(KERN_WARNING
423 "at91-ssc: sample size %d is too large for I2S\n", bits);
424 return -EINVAL;
425 }
400 426
401 /* 427 /*
402 * Compute SSC register settings. 428 * Compute SSC register settings.
403 */ 429 */
404 switch (ssc_p->daifmt) { 430 switch (ssc_p->daifmt
405 case SND_SOC_DAIFMT_CBS_CFS: 431 & (SND_SOC_DAIFMT_FORMAT_MASK | SND_SOC_DAIFMT_MASTER_MASK)) {
432
433 case SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS:
406 /* 434 /*
407 * SSC provides BCLK and LRC clocks. 435 * I2S format, SSC provides BCLK and LRC clocks.
408 * 436 *
409 * The SSC transmit and receive clocks are generated from the 437 * The SSC transmit and receive clocks are generated from the
410 * MCK divider, and the BCLK signal is output on the SSC TK line. 438 * MCK divider, and the BCLK signal is output on the SSC TK line.
@@ -441,10 +469,9 @@ static int at91_i2s_hw_params(struct snd_pcm_substream *substream,
441 | (((bits - 1) << 0) & AT91_SSC_DATALEN); 469 | (((bits - 1) << 0) & AT91_SSC_DATALEN);
442 break; 470 break;
443 471
444 case SND_SOC_DAIFMT_CBM_CFM: 472 case SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM:
445
446 /* 473 /*
447 * CODEC supplies BCLK and LRC clocks. 474 * I2S format, CODEC supplies BCLK and LRC clocks.
448 * 475 *
449 * The SSC transmit clock is obtained from the BCLK signal on 476 * The SSC transmit clock is obtained from the BCLK signal on
450 * on the TK line, and the SSC receive clock is generated from the 477 * on the TK line, and the SSC receive clock is generated from the
@@ -490,10 +517,51 @@ static int at91_i2s_hw_params(struct snd_pcm_substream *substream,
490 | (((bits - 1) << 0) & AT91_SSC_DATALEN); 517 | (((bits - 1) << 0) & AT91_SSC_DATALEN);
491 break; 518 break;
492 519
493 case SND_SOC_DAIFMT_CBS_CFM: 520 case SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_CBS_CFS:
494 case SND_SOC_DAIFMT_CBM_CFS: 521 /*
522 * DSP/PCM Mode A format, SSC provides BCLK and LRC clocks.
523 *
524 * The SSC transmit and receive clocks are generated from the
525 * MCK divider, and the BCLK signal is output on the SSC TK line.
526 */
527 rcmr = (( ssc_p->rcmr_period << 24) & AT91_SSC_PERIOD)
528 | (( 1 << 16) & AT91_SSC_STTDLY)
529 | (( AT91_SSC_START_RISING_RF ) & AT91_SSC_START)
530 | (( AT91_SSC_CK_RISING ) & AT91_SSC_CKI)
531 | (( AT91_SSC_CKO_NONE ) & AT91_SSC_CKO)
532 | (( AT91_SSC_CKS_DIV ) & AT91_SSC_CKS);
533
534 rfmr = (( AT91_SSC_FSEDGE_POSITIVE ) & AT91_SSC_FSEDGE)
535 | (( AT91_SSC_FSOS_POSITIVE ) & AT91_SSC_FSOS)
536 | (( 0 << 16) & AT91_SSC_FSLEN)
537 | (((channels - 1) << 8) & AT91_SSC_DATNB)
538 | (( 1 << 7) & AT91_SSC_MSBF)
539 | (( 0 << 5) & AT91_SSC_LOOP)
540 | (((bits - 1) << 0) & AT91_SSC_DATALEN);
541
542 tcmr = (( ssc_p->tcmr_period << 24) & AT91_SSC_PERIOD)
543 | (( 1 << 16) & AT91_SSC_STTDLY)
544 | (( AT91_SSC_START_RISING_RF ) & AT91_SSC_START)
545 | (( AT91_SSC_CK_RISING ) & AT91_SSC_CKI)
546 | (( AT91_SSC_CKO_CONTINUOUS ) & AT91_SSC_CKO)
547 | (( AT91_SSC_CKS_DIV ) & AT91_SSC_CKS);
548
549 tfmr = (( AT91_SSC_FSEDGE_POSITIVE ) & AT91_SSC_FSEDGE)
550 | (( 0 << 23) & AT91_SSC_FSDEN)
551 | (( AT91_SSC_FSOS_POSITIVE ) & AT91_SSC_FSOS)
552 | (( 0 << 16) & AT91_SSC_FSLEN)
553 | (((channels - 1) << 8) & AT91_SSC_DATNB)
554 | (( 1 << 7) & AT91_SSC_MSBF)
555 | (( 0 << 5) & AT91_SSC_DATDEF)
556 | (((bits - 1) << 0) & AT91_SSC_DATALEN);
557
558
559
560 break;
561
562 case SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_CBM_CFM:
495 default: 563 default:
496 printk(KERN_WARNING "at91-i2s: unsupported DAI format 0x%x.\n", 564 printk(KERN_WARNING "at91-ssc: unsupported DAI format 0x%x.\n",
497 ssc_p->daifmt); 565 ssc_p->daifmt);
498 return -EINVAL; 566 return -EINVAL;
499 break; 567 break;
@@ -518,9 +586,9 @@ static int at91_i2s_hw_params(struct snd_pcm_substream *substream,
518 at91_ssc_write(ssc_p->ssc.base + ATMEL_PDC_TNPR, 0); 586 at91_ssc_write(ssc_p->ssc.base + ATMEL_PDC_TNPR, 0);
519 at91_ssc_write(ssc_p->ssc.base + ATMEL_PDC_TNCR, 0); 587 at91_ssc_write(ssc_p->ssc.base + ATMEL_PDC_TNCR, 0);
520 588
521 if ((ret = request_irq(ssc_p->ssc.pid, at91_i2s_interrupt, 589 if ((ret = request_irq(ssc_p->ssc.pid, at91_ssc_interrupt,
522 0, ssc_p->name, ssc_p)) < 0) { 590 0, ssc_p->name, ssc_p)) < 0) {
523 printk(KERN_WARNING "at91-i2s: request_irq failure\n"); 591 printk(KERN_WARNING "at91-ssc: request_irq failure\n");
524 592
525 DBG("Stopping pid %d clock\n", ssc_p->ssc.pid); 593 DBG("Stopping pid %d clock\n", ssc_p->ssc.pid);
526 at91_sys_write(AT91_PMC_PCER, 1<<ssc_p->ssc.pid); 594 at91_sys_write(AT91_PMC_PCER, 1<<ssc_p->ssc.pid);
@@ -546,7 +614,7 @@ static int at91_i2s_hw_params(struct snd_pcm_substream *substream,
546} 614}
547 615
548 616
549static int at91_i2s_prepare(struct snd_pcm_substream *substream) 617static int at91_ssc_prepare(struct snd_pcm_substream *substream)
550{ 618{
551 struct snd_soc_pcm_runtime *rtd = substream->private_data; 619 struct snd_soc_pcm_runtime *rtd = substream->private_data;
552 struct at91_ssc_info *ssc_p = &ssc_info[rtd->dai->cpu_dai->id]; 620 struct at91_ssc_info *ssc_p = &ssc_info[rtd->dai->cpu_dai->id];
@@ -566,7 +634,7 @@ static int at91_i2s_prepare(struct snd_pcm_substream *substream)
566 634
567 635
568#ifdef CONFIG_PM 636#ifdef CONFIG_PM
569static int at91_i2s_suspend(struct platform_device *pdev, 637static int at91_ssc_suspend(struct platform_device *pdev,
570 struct snd_soc_cpu_dai *cpu_dai) 638 struct snd_soc_cpu_dai *cpu_dai)
571{ 639{
572 struct at91_ssc_info *ssc_p; 640 struct at91_ssc_info *ssc_p;
@@ -594,7 +662,7 @@ static int at91_i2s_suspend(struct platform_device *pdev,
594 return 0; 662 return 0;
595} 663}
596 664
597static int at91_i2s_resume(struct platform_device *pdev, 665static int at91_ssc_resume(struct platform_device *pdev,
598 struct snd_soc_cpu_dai *cpu_dai) 666 struct snd_soc_cpu_dai *cpu_dai)
599{ 667{
600 struct at91_ssc_info *ssc_p; 668 struct at91_ssc_info *ssc_p;
@@ -620,102 +688,105 @@ static int at91_i2s_resume(struct platform_device *pdev,
620} 688}
621 689
622#else 690#else
623#define at91_i2s_suspend NULL 691#define at91_ssc_suspend NULL
624#define at91_i2s_resume NULL 692#define at91_ssc_resume NULL
625#endif 693#endif
626 694
627#define AT91_I2S_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ 695#define AT91_SSC_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
628 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\ 696 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\
629 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\ 697 SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\
630 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |\ 698 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |\
631 SNDRV_PCM_RATE_96000) 699 SNDRV_PCM_RATE_96000)
632 700
633struct snd_soc_cpu_dai at91_i2s_dai[NUM_SSC_DEVICES] = { 701#define AT91_SSC_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE |\
634 { .name = "at91_ssc0/i2s", 702 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
703
704struct snd_soc_cpu_dai at91_ssc_dai[NUM_SSC_DEVICES] = {
705 { .name = "at91-ssc0",
635 .id = 0, 706 .id = 0,
636 .type = SND_SOC_DAI_I2S, 707 .type = SND_SOC_DAI_PCM,
637 .suspend = at91_i2s_suspend, 708 .suspend = at91_ssc_suspend,
638 .resume = at91_i2s_resume, 709 .resume = at91_ssc_resume,
639 .playback = { 710 .playback = {
640 .channels_min = 1, 711 .channels_min = 1,
641 .channels_max = 2, 712 .channels_max = 2,
642 .rates = AT91_I2S_RATES, 713 .rates = AT91_SSC_RATES,
643 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 714 .formats = AT91_SSC_FORMATS,},
644 .capture = { 715 .capture = {
645 .channels_min = 1, 716 .channels_min = 1,
646 .channels_max = 2, 717 .channels_max = 2,
647 .rates = AT91_I2S_RATES, 718 .rates = AT91_SSC_RATES,
648 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 719 .formats = AT91_SSC_FORMATS,},
649 .ops = { 720 .ops = {
650 .startup = at91_i2s_startup, 721 .startup = at91_ssc_startup,
651 .shutdown = at91_i2s_shutdown, 722 .shutdown = at91_ssc_shutdown,
652 .prepare = at91_i2s_prepare, 723 .prepare = at91_ssc_prepare,
653 .hw_params = at91_i2s_hw_params,}, 724 .hw_params = at91_ssc_hw_params,},
654 .dai_ops = { 725 .dai_ops = {
655 .set_sysclk = at91_i2s_set_dai_sysclk, 726 .set_sysclk = at91_ssc_set_dai_sysclk,
656 .set_fmt = at91_i2s_set_dai_fmt, 727 .set_fmt = at91_ssc_set_dai_fmt,
657 .set_clkdiv = at91_i2s_set_dai_clkdiv,}, 728 .set_clkdiv = at91_ssc_set_dai_clkdiv,},
658 .private_data = &ssc_info[0].ssc, 729 .private_data = &ssc_info[0].ssc,
659 }, 730 },
660#if NUM_SSC_DEVICES == 3 731#if NUM_SSC_DEVICES == 3
661 { .name = "at91_ssc1/i2s", 732 { .name = "at91-ssc1",
662 .id = 1, 733 .id = 1,
663 .type = SND_SOC_DAI_I2S, 734 .type = SND_SOC_DAI_PCM,
664 .suspend = at91_i2s_suspend, 735 .suspend = at91_ssc_suspend,
665 .resume = at91_i2s_resume, 736 .resume = at91_ssc_resume,
666 .playback = { 737 .playback = {
667 .channels_min = 1, 738 .channels_min = 1,
668 .channels_max = 2, 739 .channels_max = 2,
669 .rates = AT91_I2S_RATES, 740 .rates = AT91_SSC_RATES,
670 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 741 .formats = AT91_SSC_FORMATS,},
671 .capture = { 742 .capture = {
672 .channels_min = 1, 743 .channels_min = 1,
673 .channels_max = 2, 744 .channels_max = 2,
674 .rates = AT91_I2S_RATES, 745 .rates = AT91_SSC_RATES,
675 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 746 .formats = AT91_SSC_FORMATS,},
676 .ops = { 747 .ops = {
677 .startup = at91_i2s_startup, 748 .startup = at91_ssc_startup,
678 .shutdown = at91_i2s_shutdown, 749 .shutdown = at91_ssc_shutdown,
679 .prepare = at91_i2s_prepare, 750 .prepare = at91_ssc_prepare,
680 .hw_params = at91_i2s_hw_params,}, 751 .hw_params = at91_ssc_hw_params,},
681 .dai_ops = { 752 .dai_ops = {
682 .set_sysclk = at91_i2s_set_dai_sysclk, 753 .set_sysclk = at91_ssc_set_dai_sysclk,
683 .set_fmt = at91_i2s_set_dai_fmt, 754 .set_fmt = at91_ssc_set_dai_fmt,
684 .set_clkdiv = at91_i2s_set_dai_clkdiv,}, 755 .set_clkdiv = at91_ssc_set_dai_clkdiv,},
685 .private_data = &ssc_info[1].ssc, 756 .private_data = &ssc_info[1].ssc,
686 }, 757 },
687 { .name = "at91_ssc2/i2s", 758 { .name = "at91-ssc2",
688 .id = 2, 759 .id = 2,
689 .type = SND_SOC_DAI_I2S, 760 .type = SND_SOC_DAI_PCM,
690 .suspend = at91_i2s_suspend, 761 .suspend = at91_ssc_suspend,
691 .resume = at91_i2s_resume, 762 .resume = at91_ssc_resume,
692 .playback = { 763 .playback = {
693 .channels_min = 1, 764 .channels_min = 1,
694 .channels_max = 2, 765 .channels_max = 2,
695 .rates = AT91_I2S_RATES, 766 .rates = AT91_SSC_RATES,
696 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 767 .formats = AT91_SSC_FORMATS,},
697 .capture = { 768 .capture = {
698 .channels_min = 1, 769 .channels_min = 1,
699 .channels_max = 2, 770 .channels_max = 2,
700 .rates = AT91_I2S_RATES, 771 .rates = AT91_SSC_RATES,
701 .formats = SNDRV_PCM_FMTBIT_S16_LE,}, 772 .formats = AT91_SSC_FORMATS,},
702 .ops = { 773 .ops = {
703 .startup = at91_i2s_startup, 774 .startup = at91_ssc_startup,
704 .shutdown = at91_i2s_shutdown, 775 .shutdown = at91_ssc_shutdown,
705 .prepare = at91_i2s_prepare, 776 .prepare = at91_ssc_prepare,
706 .hw_params = at91_i2s_hw_params,}, 777 .hw_params = at91_ssc_hw_params,},
707 .dai_ops = { 778 .dai_ops = {
708 .set_sysclk = at91_i2s_set_dai_sysclk, 779 .set_sysclk = at91_ssc_set_dai_sysclk,
709 .set_fmt = at91_i2s_set_dai_fmt, 780 .set_fmt = at91_ssc_set_dai_fmt,
710 .set_clkdiv = at91_i2s_set_dai_clkdiv,}, 781 .set_clkdiv = at91_ssc_set_dai_clkdiv,},
711 .private_data = &ssc_info[2].ssc, 782 .private_data = &ssc_info[2].ssc,
712 }, 783 },
713#endif 784#endif
714}; 785};
715 786
716EXPORT_SYMBOL_GPL(at91_i2s_dai); 787EXPORT_SYMBOL_GPL(at91_ssc_dai);
717 788
718/* Module information */ 789/* Module information */
719MODULE_AUTHOR("Frank Mandarino, fmandarino@endrelia.com, www.endrelia.com"); 790MODULE_AUTHOR("Frank Mandarino, fmandarino@endrelia.com, www.endrelia.com");
720MODULE_DESCRIPTION("AT91 I2S ASoC Interface"); 791MODULE_DESCRIPTION("AT91 SSC ASoC Interface");
721MODULE_LICENSE("GPL"); 792MODULE_LICENSE("GPL");
diff --git a/sound/soc/at91/at91-i2s.h b/sound/soc/at91/at91-ssc.h
index f8a875ba0ccc..b188f973df9f 100644
--- a/sound/soc/at91/at91-i2s.h
+++ b/sound/soc/at91/at91-ssc.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * at91-i2s.h - ALSA I2S interface for the Atmel AT91 SoC 2 * at91-ssc.h - ALSA SSC interface for the Atmel AT91 SoC
3 * 3 *
4 * Author: Frank Mandarino <fmandarino@endrelia.com> 4 * Author: Frank Mandarino <fmandarino@endrelia.com>
5 * Endrelia Technologies Inc. 5 * Endrelia Technologies Inc.
@@ -10,18 +10,18 @@
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 */ 11 */
12 12
13#ifndef _AT91_I2S_H 13#ifndef _AT91_SSC_H
14#define _AT91_I2S_H 14#define _AT91_SSC_H
15 15
16/* I2S system clock ids */ 16/* SSC system clock ids */
17#define AT91_SYSCLK_MCK 0 /* SSC uses AT91 MCK as system clock */ 17#define AT91_SYSCLK_MCK 0 /* SSC uses AT91 MCK as system clock */
18 18
19/* I2S divider ids */ 19/* SSC divider ids */
20#define AT91SSC_CMR_DIV 0 /* MCK divider for BCLK */ 20#define AT91SSC_CMR_DIV 0 /* MCK divider for BCLK */
21#define AT91SSC_TCMR_PERIOD 1 /* BCLK divider for transmit FS */ 21#define AT91SSC_TCMR_PERIOD 1 /* BCLK divider for transmit FS */
22#define AT91SSC_RCMR_PERIOD 2 /* BCLK divider for receive FS */ 22#define AT91SSC_RCMR_PERIOD 2 /* BCLK divider for receive FS */
23 23
24extern struct snd_soc_cpu_dai at91_i2s_dai[]; 24extern struct snd_soc_cpu_dai at91_ssc_dai[];
25 25
26#endif /* _AT91_I2S_H */ 26#endif /* _AT91_SSC_H */
27 27
diff --git a/sound/soc/at91/eti_b1_wm8731.c b/sound/soc/at91/eti_b1_wm8731.c
index 8179df3bb2f3..820a676c56bf 100644
--- a/sound/soc/at91/eti_b1_wm8731.c
+++ b/sound/soc/at91/eti_b1_wm8731.c
@@ -40,7 +40,7 @@
40 40
41#include "../codecs/wm8731.h" 41#include "../codecs/wm8731.h"
42#include "at91-pcm.h" 42#include "at91-pcm.h"
43#include "at91-i2s.h" 43#include "at91-ssc.h"
44 44
45#if 0 45#if 0
46#define DBG(x...) printk(KERN_INFO "eti_b1_wm8731: " x) 46#define DBG(x...) printk(KERN_INFO "eti_b1_wm8731: " x)
@@ -248,15 +248,15 @@ static int eti_b1_wm8731_init(struct snd_soc_codec *codec)
248 248
249static struct snd_soc_dai_link eti_b1_dai = { 249static struct snd_soc_dai_link eti_b1_dai = {
250 .name = "WM8731", 250 .name = "WM8731",
251 .stream_name = "WM8731", 251 .stream_name = "WM8731 PCM",
252 .cpu_dai = &at91_i2s_dai[1], 252 .cpu_dai = &at91_ssc_dai[1],
253 .codec_dai = &wm8731_dai, 253 .codec_dai = &wm8731_dai,
254 .init = eti_b1_wm8731_init, 254 .init = eti_b1_wm8731_init,
255 .ops = &eti_b1_ops, 255 .ops = &eti_b1_ops,
256}; 256};
257 257
258static struct snd_soc_machine snd_soc_machine_eti_b1 = { 258static struct snd_soc_machine snd_soc_machine_eti_b1 = {
259 .name = "ETI_B1", 259 .name = "ETI_B1_WM8731",
260 .dai_link = &eti_b1_dai, 260 .dai_link = &eti_b1_dai,
261 .num_links = 1, 261 .num_links = 1,
262}; 262};
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index ec2a2787957a..e5fb437b86e8 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -10,6 +10,10 @@ config SND_SOC_WM8750
10 tristate 10 tristate
11 depends on SND_SOC 11 depends on SND_SOC
12 12
13config SND_SOC_WM8753
14 tristate
15 depends on SND_SOC
16
13config SND_SOC_WM9712 17config SND_SOC_WM9712
14 tristate 18 tristate
15 depends on SND_SOC 19 depends on SND_SOC
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 3249a6e4f1d0..e39a747a17cf 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -1,9 +1,11 @@
1snd-soc-ac97-objs := ac97.o 1snd-soc-ac97-objs := ac97.o
2snd-soc-wm8731-objs := wm8731.o 2snd-soc-wm8731-objs := wm8731.o
3snd-soc-wm8750-objs := wm8750.o 3snd-soc-wm8750-objs := wm8750.o
4snd-soc-wm8753-objs := wm8753.o
4snd-soc-wm9712-objs := wm9712.o 5snd-soc-wm9712-objs := wm9712.o
5 6
6obj-$(CONFIG_SND_SOC_AC97_CODEC) += snd-soc-ac97.o 7obj-$(CONFIG_SND_SOC_AC97_CODEC) += snd-soc-ac97.o
7obj-$(CONFIG_SND_SOC_WM8731) += snd-soc-wm8731.o 8obj-$(CONFIG_SND_SOC_WM8731) += snd-soc-wm8731.o
8obj-$(CONFIG_SND_SOC_WM8750) += snd-soc-wm8750.o 9obj-$(CONFIG_SND_SOC_WM8750) += snd-soc-wm8750.o
10obj-$(CONFIG_SND_SOC_WM8753) += snd-soc-wm8753.o
9obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o 11obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o
diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c
index 55bc55eb6e24..0cdef971cbd3 100644
--- a/sound/soc/codecs/ac97.c
+++ b/sound/soc/codecs/ac97.c
@@ -60,6 +60,7 @@ static struct snd_soc_codec_dai ac97_dai = {
60 .ops = { 60 .ops = {
61 .prepare = ac97_prepare,}, 61 .prepare = ac97_prepare,},
62}; 62};
63EXPORT_SYMBOL_GPL(ac97_dai);
63 64
64static unsigned int ac97_read(struct snd_soc_codec *codec, 65static unsigned int ac97_read(struct snd_soc_codec *codec,
65 unsigned int reg) 66 unsigned int reg)
diff --git a/sound/soc/codecs/ac97.h b/sound/soc/codecs/ac97.h
index 930ddfc2321a..2bf6d69fd069 100644
--- a/sound/soc/codecs/ac97.h
+++ b/sound/soc/codecs/ac97.h
@@ -14,5 +14,6 @@
14#define __LINUX_SND_SOC_AC97_H 14#define __LINUX_SND_SOC_AC97_H
15 15
16extern struct snd_soc_codec_device soc_codec_dev_ac97; 16extern struct snd_soc_codec_device soc_codec_dev_ac97;
17extern struct snd_soc_codec_dai ac97_dai;
17 18
18#endif 19#endif
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c
index 7073e8e294fc..28684eeda738 100644
--- a/sound/soc/codecs/wm8750.c
+++ b/sound/soc/codecs/wm8750.c
@@ -808,7 +808,7 @@ static int wm8750_init(struct snd_soc_device *socdev)
808 codec->dai = &wm8750_dai; 808 codec->dai = &wm8750_dai;
809 codec->num_dai = 1; 809 codec->num_dai = 1;
810 codec->reg_cache_size = sizeof(wm8750_reg); 810 codec->reg_cache_size = sizeof(wm8750_reg);
811 codec->reg_cache = kmemdup(wm8750_reg, sizeof(wm8750_reg), GFP_KRENEL); 811 codec->reg_cache = kmemdup(wm8750_reg, sizeof(wm8750_reg), GFP_KERNEL);
812 if (codec->reg_cache == NULL) 812 if (codec->reg_cache == NULL)
813 return -ENOMEM; 813 return -ENOMEM;
814 814
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c
new file mode 100644
index 000000000000..efced934566d
--- /dev/null
+++ b/sound/soc/codecs/wm8753.c
@@ -0,0 +1,1811 @@
1/*
2 * wm8753.c -- WM8753 ALSA Soc Audio driver
3 *
4 * Copyright 2003 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood
6 * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * Notes:
14 * The WM8753 is a low power, high quality stereo codec with integrated PCM
15 * codec designed for portable digital telephony applications.
16 *
17 * Dual DAI:-
18 *
19 * This driver support 2 DAI PCM's. This makes the default PCM available for
20 * HiFi audio (e.g. MP3, ogg) playback/capture and the other PCM available for
21 * voice.
22 *
23 * Please note that the voice PCM can be connected directly to a Bluetooth
24 * codec or GSM modem and thus cannot be read or written to, although it is
25 * available to be configured with snd_hw_params(), etc and kcontrols in the
26 * normal alsa manner.
27 *
28 * Fast DAI switching:-
29 *
30 * The driver can now fast switch between the DAI configurations via a
31 * an alsa kcontrol. This allows the PCM to remain open.
32 *
33 */
34
35#include <linux/module.h>
36#include <linux/moduleparam.h>
37#include <linux/version.h>
38#include <linux/kernel.h>
39#include <linux/init.h>
40#include <linux/delay.h>
41#include <linux/pm.h>
42#include <linux/i2c.h>
43#include <linux/platform_device.h>
44#include <sound/driver.h>
45#include <sound/core.h>
46#include <sound/pcm.h>
47#include <sound/pcm_params.h>
48#include <sound/soc.h>
49#include <sound/soc-dapm.h>
50#include <sound/initval.h>
51#include <asm/div64.h>
52
53#include "wm8753.h"
54
55#define AUDIO_NAME "wm8753"
56#define WM8753_VERSION "0.16"
57
58/*
59 * Debug
60 */
61
62#define WM8753_DEBUG 0
63
64#ifdef WM8753_DEBUG
65#define dbg(format, arg...) \
66 printk(KERN_DEBUG AUDIO_NAME ": " format "\n" , ## arg)
67#else
68#define dbg(format, arg...) do {} while (0)
69#endif
70#define err(format, arg...) \
71 printk(KERN_ERR AUDIO_NAME ": " format "\n" , ## arg)
72#define info(format, arg...) \
73 printk(KERN_INFO AUDIO_NAME ": " format "\n" , ## arg)
74#define warn(format, arg...) \
75 printk(KERN_WARNING AUDIO_NAME ": " format "\n" , ## arg)
76
77static int caps_charge = 2000;
78module_param(caps_charge, int, 0);
79MODULE_PARM_DESC(caps_charge, "WM8753 cap charge time (msecs)");
80
81static void wm8753_set_dai_mode(struct snd_soc_codec *codec,
82 unsigned int mode);
83
84/* codec private data */
85struct wm8753_priv {
86 unsigned int sysclk;
87 unsigned int pcmclk;
88};
89
90/*
91 * wm8753 register cache
92 * We can't read the WM8753 register space when we
93 * are using 2 wire for device control, so we cache them instead.
94 */
95static const u16 wm8753_reg[] = {
96 0x0008, 0x0000, 0x000a, 0x000a,
97 0x0033, 0x0000, 0x0007, 0x00ff,
98 0x00ff, 0x000f, 0x000f, 0x007b,
99 0x0000, 0x0032, 0x0000, 0x00c3,
100 0x00c3, 0x00c0, 0x0000, 0x0000,
101 0x0000, 0x0000, 0x0000, 0x0000,
102 0x0000, 0x0000, 0x0000, 0x0000,
103 0x0000, 0x0000, 0x0000, 0x0055,
104 0x0005, 0x0050, 0x0055, 0x0050,
105 0x0055, 0x0050, 0x0055, 0x0079,
106 0x0079, 0x0079, 0x0079, 0x0079,
107 0x0000, 0x0000, 0x0000, 0x0000,
108 0x0097, 0x0097, 0x0000, 0x0004,
109 0x0000, 0x0083, 0x0024, 0x01ba,
110 0x0000, 0x0083, 0x0024, 0x01ba,
111 0x0000, 0x0000
112};
113
114/*
115 * read wm8753 register cache
116 */
117static inline unsigned int wm8753_read_reg_cache(struct snd_soc_codec *codec,
118 unsigned int reg)
119{
120 u16 *cache = codec->reg_cache;
121 if (reg < 1 || reg > (ARRAY_SIZE(wm8753_reg) + 1))
122 return -1;
123 return cache[reg - 1];
124}
125
126/*
127 * write wm8753 register cache
128 */
129static inline void wm8753_write_reg_cache(struct snd_soc_codec *codec,
130 unsigned int reg, unsigned int value)
131{
132 u16 *cache = codec->reg_cache;
133 if (reg < 1 || reg > 0x3f)
134 return;
135 cache[reg - 1] = value;
136}
137
138/*
139 * write to the WM8753 register space
140 */
141static int wm8753_write(struct snd_soc_codec *codec, unsigned int reg,
142 unsigned int value)
143{
144 u8 data[2];
145
146 /* data is
147 * D15..D9 WM8753 register offset
148 * D8...D0 register data
149 */
150 data[0] = (reg << 1) | ((value >> 8) & 0x0001);
151 data[1] = value & 0x00ff;
152
153 wm8753_write_reg_cache (codec, reg, value);
154 if (codec->hw_write(codec->control_data, data, 2) == 2)
155 return 0;
156 else
157 return -EIO;
158}
159
160#define wm8753_reset(c) wm8753_write(c, WM8753_RESET, 0)
161
162/*
163 * WM8753 Controls
164 */
165static const char *wm8753_base[] = {"Linear Control", "Adaptive Boost"};
166static const char *wm8753_base_filter[] =
167 {"130Hz @ 48kHz", "200Hz @ 48kHz", "100Hz @ 16kHz", "400Hz @ 48kHz",
168 "100Hz @ 8kHz", "200Hz @ 8kHz"};
169static const char *wm8753_treble[] = {"8kHz", "4kHz"};
170static const char *wm8753_alc_func[] = {"Off", "Right", "Left", "Stereo"};
171static const char *wm8753_ng_type[] = {"Constant PGA Gain", "Mute ADC Output"};
172static const char *wm8753_3d_func[] = {"Capture", "Playback"};
173static const char *wm8753_3d_uc[] = {"2.2kHz", "1.5kHz"};
174static const char *wm8753_3d_lc[] = {"200Hz", "500Hz"};
175static const char *wm8753_deemp[] = {"None", "32kHz", "44.1kHz", "48kHz"};
176static const char *wm8753_mono_mix[] = {"Stereo", "Left", "Right", "Mono"};
177static const char *wm8753_dac_phase[] = {"Non Inverted", "Inverted"};
178static const char *wm8753_line_mix[] = {"Line 1 + 2", "Line 1 - 2",
179 "Line 1", "Line 2"};
180static const char *wm8753_mono_mux[] = {"Line Mix", "Rx Mix"};
181static const char *wm8753_right_mux[] = {"Line 2", "Rx Mix"};
182static const char *wm8753_left_mux[] = {"Line 1", "Rx Mix"};
183static const char *wm8753_rxmsel[] = {"RXP - RXN", "RXP + RXN", "RXP", "RXN"};
184static const char *wm8753_sidetone_mux[] = {"Left PGA", "Mic 1", "Mic 2",
185 "Right PGA"};
186static const char *wm8753_mono2_src[] = {"Inverted Mono 1", "Left", "Right",
187 "Left + Right"};
188static const char *wm8753_out3[] = {"VREF", "ROUT2", "Left + Right"};
189static const char *wm8753_out4[] = {"VREF", "Capture ST", "LOUT2"};
190static const char *wm8753_radcsel[] = {"PGA", "Line or RXP-RXN", "Sidetone"};
191static const char *wm8753_ladcsel[] = {"PGA", "Line or RXP-RXN", "Line"};
192static const char *wm8753_mono_adc[] = {"Stereo", "Analogue Mix Left",
193 "Analogue Mix Right", "Digital Mono Mix"};
194static const char *wm8753_adc_hp[] = {"3.4Hz @ 48kHz", "82Hz @ 16k",
195 "82Hz @ 8kHz", "170Hz @ 8kHz"};
196static const char *wm8753_adc_filter[] = {"HiFi", "Voice"};
197static const char *wm8753_mic_sel[] = {"Mic 1", "Mic 2", "Mic 3"};
198static const char *wm8753_dai_mode[] = {"DAI 0", "DAI 1", "DAI 2", "DAI 3"};
199static const char *wm8753_dat_sel[] = {"Stereo", "Left ADC", "Right ADC",
200 "Channel Swap"};
201
202static const struct soc_enum wm8753_enum[] = {
203SOC_ENUM_SINGLE(WM8753_BASS, 7, 2, wm8753_base),
204SOC_ENUM_SINGLE(WM8753_BASS, 4, 6, wm8753_base_filter),
205SOC_ENUM_SINGLE(WM8753_TREBLE, 6, 2, wm8753_treble),
206SOC_ENUM_SINGLE(WM8753_ALC1, 7, 4, wm8753_alc_func),
207SOC_ENUM_SINGLE(WM8753_NGATE, 1, 2, wm8753_ng_type),
208SOC_ENUM_SINGLE(WM8753_3D, 7, 2, wm8753_3d_func),
209SOC_ENUM_SINGLE(WM8753_3D, 6, 2, wm8753_3d_uc),
210SOC_ENUM_SINGLE(WM8753_3D, 5, 2, wm8753_3d_lc),
211SOC_ENUM_SINGLE(WM8753_DAC, 1, 4, wm8753_deemp),
212SOC_ENUM_SINGLE(WM8753_DAC, 4, 4, wm8753_mono_mix),
213SOC_ENUM_SINGLE(WM8753_DAC, 6, 2, wm8753_dac_phase),
214SOC_ENUM_SINGLE(WM8753_INCTL1, 3, 4, wm8753_line_mix),
215SOC_ENUM_SINGLE(WM8753_INCTL1, 2, 2, wm8753_mono_mux),
216SOC_ENUM_SINGLE(WM8753_INCTL1, 1, 2, wm8753_right_mux),
217SOC_ENUM_SINGLE(WM8753_INCTL1, 0, 2, wm8753_left_mux),
218SOC_ENUM_SINGLE(WM8753_INCTL2, 6, 4, wm8753_rxmsel),
219SOC_ENUM_SINGLE(WM8753_INCTL2, 4, 4, wm8753_sidetone_mux),
220SOC_ENUM_SINGLE(WM8753_OUTCTL, 7, 4, wm8753_mono2_src),
221SOC_ENUM_SINGLE(WM8753_OUTCTL, 0, 3, wm8753_out3),
222SOC_ENUM_SINGLE(WM8753_ADCTL2, 7, 3, wm8753_out4),
223SOC_ENUM_SINGLE(WM8753_ADCIN, 2, 3, wm8753_radcsel),
224SOC_ENUM_SINGLE(WM8753_ADCIN, 0, 3, wm8753_ladcsel),
225SOC_ENUM_SINGLE(WM8753_ADCIN, 4, 4, wm8753_mono_adc),
226SOC_ENUM_SINGLE(WM8753_ADC, 2, 4, wm8753_adc_hp),
227SOC_ENUM_SINGLE(WM8753_ADC, 4, 2, wm8753_adc_filter),
228SOC_ENUM_SINGLE(WM8753_MICBIAS, 6, 3, wm8753_mic_sel),
229SOC_ENUM_SINGLE(WM8753_IOCTL, 2, 4, wm8753_dai_mode),
230SOC_ENUM_SINGLE(WM8753_ADC, 7, 4, wm8753_dat_sel),
231};
232
233
234static int wm8753_get_dai(struct snd_kcontrol *kcontrol,
235 struct snd_ctl_elem_value *ucontrol)
236{
237 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
238 int mode = wm8753_read_reg_cache(codec, WM8753_IOCTL);
239
240 ucontrol->value.integer.value[0] = (mode & 0xc) >> 2;
241 return 0;
242}
243
244static int wm8753_set_dai(struct snd_kcontrol *kcontrol,
245 struct snd_ctl_elem_value *ucontrol)
246{
247 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
248 int mode = wm8753_read_reg_cache(codec, WM8753_IOCTL);
249
250 if (((mode &0xc) >> 2) == ucontrol->value.integer.value[0])
251 return 0;
252
253 mode &= 0xfff3;
254 mode |= (ucontrol->value.integer.value[0] << 2);
255
256 wm8753_write(codec, WM8753_IOCTL, mode);
257 wm8753_set_dai_mode(codec, ucontrol->value.integer.value[0]);
258 return 1;
259}
260
261static const struct snd_kcontrol_new wm8753_snd_controls[] = {
262SOC_DOUBLE_R("PCM Volume", WM8753_LDAC, WM8753_RDAC, 0, 255, 0),
263
264SOC_DOUBLE_R("ADC Capture Volume", WM8753_LADC, WM8753_RADC, 0, 255, 0),
265
266SOC_DOUBLE_R("Headphone Playback Volume", WM8753_LOUT1V, WM8753_ROUT1V, 0, 127, 0),
267SOC_DOUBLE_R("Speaker Playback Volume", WM8753_LOUT2V, WM8753_ROUT2V, 0, 127, 0),
268
269SOC_SINGLE("Mono Playback Volume", WM8753_MOUTV, 0, 127, 0),
270
271SOC_DOUBLE_R("Bypass Playback Volume", WM8753_LOUTM1, WM8753_ROUTM1, 4, 7, 1),
272SOC_DOUBLE_R("Sidetone Playback Volume", WM8753_LOUTM2, WM8753_ROUTM2, 4, 7, 1),
273SOC_DOUBLE_R("Voice Playback Volume", WM8753_LOUTM2, WM8753_ROUTM2, 0, 7, 1),
274
275SOC_DOUBLE_R("Headphone Playback ZC Switch", WM8753_LOUT1V, WM8753_ROUT1V, 7, 1, 0),
276SOC_DOUBLE_R("Speaker Playback ZC Switch", WM8753_LOUT2V, WM8753_ROUT2V, 7, 1, 0),
277
278SOC_SINGLE("Mono Bypass Playback Volume", WM8753_MOUTM1, 4, 7, 1),
279SOC_SINGLE("Mono Sidetone Playback Volume", WM8753_MOUTM2, 4, 7, 1),
280SOC_SINGLE("Mono Voice Playback Volume", WM8753_MOUTM2, 4, 7, 1),
281SOC_SINGLE("Mono Playback ZC Switch", WM8753_MOUTV, 7, 1, 0),
282
283SOC_ENUM("Bass Boost", wm8753_enum[0]),
284SOC_ENUM("Bass Filter", wm8753_enum[1]),
285SOC_SINGLE("Bass Volume", WM8753_BASS, 0, 15, 1),
286
287SOC_SINGLE("Treble Volume", WM8753_TREBLE, 0, 15, 1),
288SOC_ENUM("Treble Cut-off", wm8753_enum[2]),
289
290SOC_DOUBLE("Sidetone Capture Volume", WM8753_RECMIX1, 0, 4, 7, 1),
291SOC_SINGLE("Voice Sidetone Capture Volume", WM8753_RECMIX2, 0, 7, 1),
292
293SOC_DOUBLE_R("Capture Volume", WM8753_LINVOL, WM8753_RINVOL, 0, 63, 0),
294SOC_DOUBLE_R("Capture ZC Switch", WM8753_LINVOL, WM8753_RINVOL, 6, 1, 0),
295SOC_DOUBLE_R("Capture Switch", WM8753_LINVOL, WM8753_RINVOL, 7, 1, 1),
296
297SOC_ENUM("Capture Filter Select", wm8753_enum[23]),
298SOC_ENUM("Capture Filter Cut-off", wm8753_enum[24]),
299SOC_SINGLE("Capture Filter Switch", WM8753_ADC, 0, 1, 1),
300
301SOC_SINGLE("ALC Capture Target Volume", WM8753_ALC1, 0, 7, 0),
302SOC_SINGLE("ALC Capture Max Volume", WM8753_ALC1, 4, 7, 0),
303SOC_ENUM("ALC Capture Function", wm8753_enum[3]),
304SOC_SINGLE("ALC Capture ZC Switch", WM8753_ALC2, 8, 1, 0),
305SOC_SINGLE("ALC Capture Hold Time", WM8753_ALC2, 0, 15, 1),
306SOC_SINGLE("ALC Capture Decay Time", WM8753_ALC3, 4, 15, 1),
307SOC_SINGLE("ALC Capture Attack Time", WM8753_ALC3, 0, 15, 0),
308SOC_SINGLE("ALC Capture NG Threshold", WM8753_NGATE, 3, 31, 0),
309SOC_ENUM("ALC Capture NG Type", wm8753_enum[4]),
310SOC_SINGLE("ALC Capture NG Switch", WM8753_NGATE, 0, 1, 0),
311
312SOC_ENUM("3D Function", wm8753_enum[5]),
313SOC_ENUM("3D Upper Cut-off", wm8753_enum[6]),
314SOC_ENUM("3D Lower Cut-off", wm8753_enum[7]),
315SOC_SINGLE("3D Volume", WM8753_3D, 1, 15, 0),
316SOC_SINGLE("3D Switch", WM8753_3D, 0, 1, 0),
317
318SOC_SINGLE("Capture 6dB Attenuate", WM8753_ADCTL1, 2, 1, 0),
319SOC_SINGLE("Playback 6dB Attenuate", WM8753_ADCTL1, 1, 1, 0),
320
321SOC_ENUM("De-emphasis", wm8753_enum[8]),
322SOC_ENUM("Playback Mono Mix", wm8753_enum[9]),
323SOC_ENUM("Playback Phase", wm8753_enum[10]),
324
325SOC_SINGLE("Mic2 Capture Volume", WM8753_INCTL1, 7, 3, 0),
326SOC_SINGLE("Mic1 Capture Volume", WM8753_INCTL1, 5, 3, 0),
327
328SOC_ENUM_EXT("DAI Mode", wm8753_enum[26], wm8753_get_dai, wm8753_set_dai),
329
330SOC_ENUM("ADC Data Select", wm8753_enum[27]),
331};
332
333/* add non dapm controls */
334static int wm8753_add_controls(struct snd_soc_codec *codec)
335{
336 int err, i;
337
338 for (i = 0; i < ARRAY_SIZE(wm8753_snd_controls); i++) {
339 err = snd_ctl_add(codec->card,
340 snd_soc_cnew(&wm8753_snd_controls[i],codec, NULL));
341 if (err < 0)
342 return err;
343 }
344 return 0;
345}
346
347/*
348 * _DAPM_ Controls
349 */
350
351/* Left Mixer */
352static const struct snd_kcontrol_new wm8753_left_mixer_controls[] = {
353SOC_DAPM_SINGLE("Voice Playback Switch", WM8753_LOUTM2, 8, 1, 0),
354SOC_DAPM_SINGLE("Sidetone Playback Switch", WM8753_LOUTM2, 7, 1, 0),
355SOC_DAPM_SINGLE("Left Playback Switch", WM8753_LOUTM1, 8, 1, 0),
356SOC_DAPM_SINGLE("Bypass Playback Switch", WM8753_LOUTM1, 7, 1, 0),
357};
358
359/* Right mixer */
360static const struct snd_kcontrol_new wm8753_right_mixer_controls[] = {
361SOC_DAPM_SINGLE("Voice Playback Switch", WM8753_ROUTM2, 8, 1, 0),
362SOC_DAPM_SINGLE("Sidetone Playback Switch", WM8753_ROUTM2, 7, 1, 0),
363SOC_DAPM_SINGLE("Right Playback Switch", WM8753_ROUTM1, 8, 1, 0),
364SOC_DAPM_SINGLE("Bypass Playback Switch", WM8753_ROUTM1, 7, 1, 0),
365};
366
367/* Mono mixer */
368static const struct snd_kcontrol_new wm8753_mono_mixer_controls[] = {
369SOC_DAPM_SINGLE("Left Playback Switch", WM8753_MOUTM1, 8, 1, 0),
370SOC_DAPM_SINGLE("Right Playback Switch", WM8753_MOUTM2, 8, 1, 0),
371SOC_DAPM_SINGLE("Voice Playback Switch", WM8753_MOUTM2, 3, 1, 0),
372SOC_DAPM_SINGLE("Sidetone Playback Switch", WM8753_MOUTM2, 7, 1, 0),
373SOC_DAPM_SINGLE("Bypass Playback Switch", WM8753_MOUTM1, 7, 1, 0),
374};
375
376/* Mono 2 Mux */
377static const struct snd_kcontrol_new wm8753_mono2_controls =
378SOC_DAPM_ENUM("Route", wm8753_enum[17]);
379
380/* Out 3 Mux */
381static const struct snd_kcontrol_new wm8753_out3_controls =
382SOC_DAPM_ENUM("Route", wm8753_enum[18]);
383
384/* Out 4 Mux */
385static const struct snd_kcontrol_new wm8753_out4_controls =
386SOC_DAPM_ENUM("Route", wm8753_enum[19]);
387
388/* ADC Mono Mix */
389static const struct snd_kcontrol_new wm8753_adc_mono_controls =
390SOC_DAPM_ENUM("Route", wm8753_enum[22]);
391
392/* Record mixer */
393static const struct snd_kcontrol_new wm8753_record_mixer_controls[] = {
394SOC_DAPM_SINGLE("Voice Capture Switch", WM8753_RECMIX2, 3, 1, 0),
395SOC_DAPM_SINGLE("Left Capture Switch", WM8753_RECMIX1, 3, 1, 0),
396SOC_DAPM_SINGLE("Right Capture Switch", WM8753_RECMIX1, 7, 1, 0),
397};
398
399/* Left ADC mux */
400static const struct snd_kcontrol_new wm8753_adc_left_controls =
401SOC_DAPM_ENUM("Route", wm8753_enum[21]);
402
403/* Right ADC mux */
404static const struct snd_kcontrol_new wm8753_adc_right_controls =
405SOC_DAPM_ENUM("Route", wm8753_enum[20]);
406
407/* MIC mux */
408static const struct snd_kcontrol_new wm8753_mic_mux_controls =
409SOC_DAPM_ENUM("Route", wm8753_enum[16]);
410
411/* ALC mixer */
412static const struct snd_kcontrol_new wm8753_alc_mixer_controls[] = {
413SOC_DAPM_SINGLE("Line Capture Switch", WM8753_INCTL2, 3, 1, 0),
414SOC_DAPM_SINGLE("Mic2 Capture Switch", WM8753_INCTL2, 2, 1, 0),
415SOC_DAPM_SINGLE("Mic1 Capture Switch", WM8753_INCTL2, 1, 1, 0),
416SOC_DAPM_SINGLE("Rx Capture Switch", WM8753_INCTL2, 0, 1, 0),
417};
418
419/* Left Line mux */
420static const struct snd_kcontrol_new wm8753_line_left_controls =
421SOC_DAPM_ENUM("Route", wm8753_enum[14]);
422
423/* Right Line mux */
424static const struct snd_kcontrol_new wm8753_line_right_controls =
425SOC_DAPM_ENUM("Route", wm8753_enum[13]);
426
427/* Mono Line mux */
428static const struct snd_kcontrol_new wm8753_line_mono_controls =
429SOC_DAPM_ENUM("Route", wm8753_enum[12]);
430
431/* Line mux and mixer */
432static const struct snd_kcontrol_new wm8753_line_mux_mix_controls =
433SOC_DAPM_ENUM("Route", wm8753_enum[11]);
434
435/* Rx mux and mixer */
436static const struct snd_kcontrol_new wm8753_rx_mux_mix_controls =
437SOC_DAPM_ENUM("Route", wm8753_enum[15]);
438
439/* Mic Selector Mux */
440static const struct snd_kcontrol_new wm8753_mic_sel_mux_controls =
441SOC_DAPM_ENUM("Route", wm8753_enum[25]);
442
443static const struct snd_soc_dapm_widget wm8753_dapm_widgets[] = {
444SND_SOC_DAPM_MICBIAS("Mic Bias", WM8753_PWR1, 5, 0),
445SND_SOC_DAPM_MIXER("Left Mixer", WM8753_PWR4, 0, 0,
446 &wm8753_left_mixer_controls[0], ARRAY_SIZE(wm8753_left_mixer_controls)),
447SND_SOC_DAPM_PGA("Left Out 1", WM8753_PWR3, 8, 0, NULL, 0),
448SND_SOC_DAPM_PGA("Left Out 2", WM8753_PWR3, 6, 0, NULL, 0),
449SND_SOC_DAPM_DAC("Left DAC", "Left HiFi Playback", WM8753_PWR1, 3, 0),
450SND_SOC_DAPM_OUTPUT("LOUT1"),
451SND_SOC_DAPM_OUTPUT("LOUT2"),
452SND_SOC_DAPM_MIXER("Right Mixer", WM8753_PWR4, 1, 0,
453 &wm8753_right_mixer_controls[0], ARRAY_SIZE(wm8753_right_mixer_controls)),
454SND_SOC_DAPM_PGA("Right Out 1", WM8753_PWR3, 7, 0, NULL, 0),
455SND_SOC_DAPM_PGA("Right Out 2", WM8753_PWR3, 5, 0, NULL, 0),
456SND_SOC_DAPM_DAC("Right DAC", "Right HiFi Playback", WM8753_PWR1, 2, 0),
457SND_SOC_DAPM_OUTPUT("ROUT1"),
458SND_SOC_DAPM_OUTPUT("ROUT2"),
459SND_SOC_DAPM_MIXER("Mono Mixer", WM8753_PWR4, 2, 0,
460 &wm8753_mono_mixer_controls[0], ARRAY_SIZE(wm8753_mono_mixer_controls)),
461SND_SOC_DAPM_PGA("Mono Out 1", WM8753_PWR3, 2, 0, NULL, 0),
462SND_SOC_DAPM_PGA("Mono Out 2", WM8753_PWR3, 1, 0, NULL, 0),
463SND_SOC_DAPM_DAC("Voice DAC", "Voice Playback", WM8753_PWR1, 4, 0),
464SND_SOC_DAPM_OUTPUT("MONO1"),
465SND_SOC_DAPM_MUX("Mono 2 Mux", SND_SOC_NOPM, 0, 0, &wm8753_mono2_controls),
466SND_SOC_DAPM_OUTPUT("MONO2"),
467SND_SOC_DAPM_MIXER("Out3 Left + Right", -1, 0, 0, NULL, 0),
468SND_SOC_DAPM_MUX("Out3 Mux", SND_SOC_NOPM, 0, 0, &wm8753_out3_controls),
469SND_SOC_DAPM_PGA("Out 3", WM8753_PWR3, 4, 0, NULL, 0),
470SND_SOC_DAPM_OUTPUT("OUT3"),
471SND_SOC_DAPM_MUX("Out4 Mux", SND_SOC_NOPM, 0, 0, &wm8753_out4_controls),
472SND_SOC_DAPM_PGA("Out 4", WM8753_PWR3, 3, 0, NULL, 0),
473SND_SOC_DAPM_OUTPUT("OUT4"),
474SND_SOC_DAPM_MIXER("Playback Mixer", WM8753_PWR4, 3, 0,
475 &wm8753_record_mixer_controls[0],
476 ARRAY_SIZE(wm8753_record_mixer_controls)),
477SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8753_PWR2, 3, 0),
478SND_SOC_DAPM_ADC("Right ADC", "Right Capture", WM8753_PWR2, 2, 0),
479SND_SOC_DAPM_MUX("Capture Left Mixer", SND_SOC_NOPM, 0, 0,
480 &wm8753_adc_mono_controls),
481SND_SOC_DAPM_MUX("Capture Right Mixer", SND_SOC_NOPM, 0, 0,
482 &wm8753_adc_mono_controls),
483SND_SOC_DAPM_MUX("Capture Left Mux", SND_SOC_NOPM, 0, 0,
484 &wm8753_adc_left_controls),
485SND_SOC_DAPM_MUX("Capture Right Mux", SND_SOC_NOPM, 0, 0,
486 &wm8753_adc_right_controls),
487SND_SOC_DAPM_MUX("Mic Sidetone Mux", SND_SOC_NOPM, 0, 0,
488 &wm8753_mic_mux_controls),
489SND_SOC_DAPM_PGA("Left Capture Volume", WM8753_PWR2, 5, 0, NULL, 0),
490SND_SOC_DAPM_PGA("Right Capture Volume", WM8753_PWR2, 4, 0, NULL, 0),
491SND_SOC_DAPM_MIXER("ALC Mixer", WM8753_PWR2, 6, 0,
492 &wm8753_alc_mixer_controls[0], ARRAY_SIZE(wm8753_alc_mixer_controls)),
493SND_SOC_DAPM_MUX("Line Left Mux", SND_SOC_NOPM, 0, 0,
494 &wm8753_line_left_controls),
495SND_SOC_DAPM_MUX("Line Right Mux", SND_SOC_NOPM, 0, 0,
496 &wm8753_line_right_controls),
497SND_SOC_DAPM_MUX("Line Mono Mux", SND_SOC_NOPM, 0, 0,
498 &wm8753_line_mono_controls),
499SND_SOC_DAPM_MUX("Line Mixer", WM8753_PWR2, 0, 0,
500 &wm8753_line_mux_mix_controls),
501SND_SOC_DAPM_MUX("Rx Mixer", WM8753_PWR2, 1, 0,
502 &wm8753_rx_mux_mix_controls),
503SND_SOC_DAPM_PGA("Mic 1 Volume", WM8753_PWR2, 8, 0, NULL, 0),
504SND_SOC_DAPM_PGA("Mic 2 Volume", WM8753_PWR2, 7, 0, NULL, 0),
505SND_SOC_DAPM_MUX("Mic Selection Mux", SND_SOC_NOPM, 0, 0,
506 &wm8753_mic_sel_mux_controls),
507SND_SOC_DAPM_INPUT("LINE1"),
508SND_SOC_DAPM_INPUT("LINE2"),
509SND_SOC_DAPM_INPUT("RXP"),
510SND_SOC_DAPM_INPUT("RXN"),
511SND_SOC_DAPM_INPUT("ACIN"),
512SND_SOC_DAPM_OUTPUT("ACOP"),
513SND_SOC_DAPM_INPUT("MIC1N"),
514SND_SOC_DAPM_INPUT("MIC1"),
515SND_SOC_DAPM_INPUT("MIC2N"),
516SND_SOC_DAPM_INPUT("MIC2"),
517SND_SOC_DAPM_VMID("VREF"),
518};
519
520static const char *audio_map[][3] = {
521 /* left mixer */
522 {"Left Mixer", "Left Playback Switch", "Left DAC"},
523 {"Left Mixer", "Voice Playback Switch", "Voice DAC"},
524 {"Left Mixer", "Sidetone Playback Switch", "Mic Sidetone Mux"},
525 {"Left Mixer", "Bypass Playback Switch", "Line Left Mux"},
526
527 /* right mixer */
528 {"Right Mixer", "Right Playback Switch", "Right DAC"},
529 {"Right Mixer", "Voice Playback Switch", "Voice DAC"},
530 {"Right Mixer", "Sidetone Playback Switch", "Mic Sidetone Mux"},
531 {"Right Mixer", "Bypass Playback Switch", "Line Right Mux"},
532
533 /* mono mixer */
534 {"Mono Mixer", "Voice Playback Switch", "Voice DAC"},
535 {"Mono Mixer", "Left Playback Switch", "Left DAC"},
536 {"Mono Mixer", "Right Playback Switch", "Right DAC"},
537 {"Mono Mixer", "Sidetone Playback Switch", "Mic Sidetone Mux"},
538 {"Mono Mixer", "Bypass Playback Switch", "Line Mono Mux"},
539
540 /* left out */
541 {"Left Out 1", NULL, "Left Mixer"},
542 {"Left Out 2", NULL, "Left Mixer"},
543 {"LOUT1", NULL, "Left Out 1"},
544 {"LOUT2", NULL, "Left Out 2"},
545
546 /* right out */
547 {"Right Out 1", NULL, "Right Mixer"},
548 {"Right Out 2", NULL, "Right Mixer"},
549 {"ROUT1", NULL, "Right Out 1"},
550 {"ROUT2", NULL, "Right Out 2"},
551
552 /* mono 1 out */
553 {"Mono Out 1", NULL, "Mono Mixer"},
554 {"MONO1", NULL, "Mono Out 1"},
555
556 /* mono 2 out */
557 {"Mono 2 Mux", "Left + Right", "Out3 Left + Right"},
558 {"Mono 2 Mux", "Inverted Mono 1", "MONO1"},
559 {"Mono 2 Mux", "Left", "Left Mixer"},
560 {"Mono 2 Mux", "Right", "Right Mixer"},
561 {"Mono Out 2", NULL, "Mono 2 Mux"},
562 {"MONO2", NULL, "Mono Out 2"},
563
564 /* out 3 */
565 {"Out3 Left + Right", NULL, "Left Mixer"},
566 {"Out3 Left + Right", NULL, "Right Mixer"},
567 {"Out3 Mux", "VREF", "VREF"},
568 {"Out3 Mux", "Left + Right", "Out3 Left + Right"},
569 {"Out3 Mux", "ROUT2", "ROUT2"},
570 {"Out 3", NULL, "Out3 Mux"},
571 {"OUT3", NULL, "Out 3"},
572
573 /* out 4 */
574 {"Out4 Mux", "VREF", "VREF"},
575 {"Out4 Mux", "Capture ST", "Capture ST Mixer"},
576 {"Out4 Mux", "LOUT2", "LOUT2"},
577 {"Out 4", NULL, "Out4 Mux"},
578 {"OUT4", NULL, "Out 4"},
579
580 /* record mixer */
581 {"Playback Mixer", "Left Capture Switch", "Left Mixer"},
582 {"Playback Mixer", "Voice Capture Switch", "Mono Mixer"},
583 {"Playback Mixer", "Right Capture Switch", "Right Mixer"},
584
585 /* Mic/SideTone Mux */
586 {"Mic Sidetone Mux", "Left PGA", "Left Capture Volume"},
587 {"Mic Sidetone Mux", "Right PGA", "Right Capture Volume"},
588 {"Mic Sidetone Mux", "Mic 1", "Mic 1 Volume"},
589 {"Mic Sidetone Mux", "Mic 2", "Mic 2 Volume"},
590
591 /* Capture Left Mux */
592 {"Capture Left Mux", "PGA", "Left Capture Volume"},
593 {"Capture Left Mux", "Line or RXP-RXN", "Line Left Mux"},
594 {"Capture Left Mux", "Line", "LINE1"},
595
596 /* Capture Right Mux */
597 {"Capture Right Mux", "PGA", "Right Capture Volume"},
598 {"Capture Right Mux", "Line or RXP-RXN", "Line Right Mux"},
599 {"Capture Right Mux", "Sidetone", "Capture ST Mixer"},
600
601 /* Mono Capture mixer-mux */
602 {"Capture Right Mixer", "Stereo", "Capture Right Mux"},
603 {"Capture Left Mixer", "Analogue Mix Left", "Capture Left Mux"},
604 {"Capture Left Mixer", "Analogue Mix Left", "Capture Right Mux"},
605 {"Capture Right Mixer", "Analogue Mix Right", "Capture Left Mux"},
606 {"Capture Right Mixer", "Analogue Mix Right", "Capture Right Mux"},
607 {"Capture Left Mixer", "Digital Mono Mix", "Capture Left Mux"},
608 {"Capture Left Mixer", "Digital Mono Mix", "Capture Right Mux"},
609 {"Capture Right Mixer", "Digital Mono Mix", "Capture Left Mux"},
610 {"Capture Right Mixer", "Digital Mono Mix", "Capture Right Mux"},
611
612 /* ADC */
613 {"Left ADC", NULL, "Capture Left Mixer"},
614 {"Right ADC", NULL, "Capture Right Mixer"},
615
616 /* Left Capture Volume */
617 {"Left Capture Volume", NULL, "ACIN"},
618
619 /* Right Capture Volume */
620 {"Right Capture Volume", NULL, "Mic 2 Volume"},
621
622 /* ALC Mixer */
623 {"ALC Mixer", "Line Capture Switch", "Line Mixer"},
624 {"ALC Mixer", "Mic2 Capture Switch", "Mic 2 Volume"},
625 {"ALC Mixer", "Mic1 Capture Switch", "Mic 1 Volume"},
626 {"ALC Mixer", "Rx Capture Switch", "Rx Mixer"},
627
628 /* Line Left Mux */
629 {"Line Left Mux", "Line 1", "LINE1"},
630 {"Line Left Mux", "Rx Mix", "Rx Mixer"},
631
632 /* Line Right Mux */
633 {"Line Right Mux", "Line 2", "LINE2"},
634 {"Line Right Mux", "Rx Mix", "Rx Mixer"},
635
636 /* Line Mono Mux */
637 {"Line Mono Mux", "Line Mix", "Line Mixer"},
638 {"Line Mono Mux", "Rx Mix", "Rx Mixer"},
639
640 /* Line Mixer/Mux */
641 {"Line Mixer", "Line 1 + 2", "LINE1"},
642 {"Line Mixer", "Line 1 - 2", "LINE1"},
643 {"Line Mixer", "Line 1 + 2", "LINE2"},
644 {"Line Mixer", "Line 1 - 2", "LINE2"},
645 {"Line Mixer", "Line 1", "LINE1"},
646 {"Line Mixer", "Line 2", "LINE2"},
647
648 /* Rx Mixer/Mux */
649 {"Rx Mixer", "RXP - RXN", "RXP"},
650 {"Rx Mixer", "RXP + RXN", "RXP"},
651 {"Rx Mixer", "RXP - RXN", "RXN"},
652 {"Rx Mixer", "RXP + RXN", "RXN"},
653 {"Rx Mixer", "RXP", "RXP"},
654 {"Rx Mixer", "RXN", "RXN"},
655
656 /* Mic 1 Volume */
657 {"Mic 1 Volume", NULL, "MIC1N"},
658 {"Mic 1 Volume", NULL, "Mic Selection Mux"},
659
660 /* Mic 2 Volume */
661 {"Mic 2 Volume", NULL, "MIC2N"},
662 {"Mic 2 Volume", NULL, "MIC2"},
663
664 /* Mic Selector Mux */
665 {"Mic Selection Mux", "Mic 1", "MIC1"},
666 {"Mic Selection Mux", "Mic 2", "MIC2N"},
667 {"Mic Selection Mux", "Mic 3", "MIC2"},
668
669 /* ACOP */
670 {"ACOP", NULL, "ALC Mixer"},
671
672 /* terminator */
673 {NULL, NULL, NULL},
674};
675
676static int wm8753_add_widgets(struct snd_soc_codec *codec)
677{
678 int i;
679
680 for (i = 0; i < ARRAY_SIZE(wm8753_dapm_widgets); i++)
681 snd_soc_dapm_new_control(codec, &wm8753_dapm_widgets[i]);
682
683 /* set up the WM8753 audio map */
684 for (i = 0; audio_map[i][0] != NULL; i++) {
685 snd_soc_dapm_connect_input(codec, audio_map[i][0],
686 audio_map[i][1], audio_map[i][2]);
687 }
688
689 snd_soc_dapm_new_widgets(codec);
690 return 0;
691}
692
693/* PLL divisors */
694struct _pll_div {
695 u32 div2:1;
696 u32 n:4;
697 u32 k:24;
698};
699
700/* The size in bits of the pll divide multiplied by 10
701 * to allow rounding later */
702#define FIXED_PLL_SIZE ((1 << 22) * 10)
703
704static void pll_factors(struct _pll_div *pll_div, unsigned int target,
705 unsigned int source)
706{
707 u64 Kpart;
708 unsigned int K, Ndiv, Nmod;
709
710 Ndiv = target / source;
711 if (Ndiv < 6) {
712 source >>= 1;
713 pll_div->div2 = 1;
714 Ndiv = target / source;
715 } else
716 pll_div->div2 = 0;
717
718 if ((Ndiv < 6) || (Ndiv > 12))
719 printk(KERN_WARNING
720 "WM8753 N value outwith recommended range! N = %d\n",Ndiv);
721
722 pll_div->n = Ndiv;
723 Nmod = target % source;
724 Kpart = FIXED_PLL_SIZE * (long long)Nmod;
725
726 do_div(Kpart, source);
727
728 K = Kpart & 0xFFFFFFFF;
729
730 /* Check if we need to round */
731 if ((K % 10) >= 5)
732 K += 5;
733
734 /* Move down to proper range now rounding is done */
735 K /= 10;
736
737 pll_div->k = K;
738}
739
740static int wm8753_set_dai_pll(struct snd_soc_codec_dai *codec_dai,
741 int pll_id, unsigned int freq_in, unsigned int freq_out)
742{
743 u16 reg, enable;
744 int offset;
745 struct snd_soc_codec *codec = codec_dai->codec;
746
747 if (pll_id < WM8753_PLL1 || pll_id > WM8753_PLL2)
748 return -ENODEV;
749
750 if (pll_id == WM8753_PLL1) {
751 offset = 0;
752 enable = 0x10;
753 reg = wm8753_read_reg_cache(codec, WM8753_CLOCK) & 0xffef;
754 } else {
755 offset = 4;
756 enable = 0x8;
757 reg = wm8753_read_reg_cache(codec, WM8753_CLOCK) & 0xfff7;
758 }
759
760 if (!freq_in || !freq_out) {
761 /* disable PLL */
762 wm8753_write(codec, WM8753_PLL1CTL1 + offset, 0x0026);
763 wm8753_write(codec, WM8753_CLOCK, reg);
764 return 0;
765 } else {
766 u16 value = 0;
767 struct _pll_div pll_div;
768
769 pll_factors(&pll_div, freq_out * 8, freq_in);
770
771 /* set up N and K PLL divisor ratios */
772 /* bits 8:5 = PLL_N, bits 3:0 = PLL_K[21:18] */
773 value = (pll_div.n << 5) + ((pll_div.k & 0x3c0000) >> 18);
774 wm8753_write(codec, WM8753_PLL1CTL2 + offset, value);
775
776 /* bits 8:0 = PLL_K[17:9] */
777 value = (pll_div.k & 0x03fe00) >> 9;
778 wm8753_write(codec, WM8753_PLL1CTL3 + offset, value);
779
780 /* bits 8:0 = PLL_K[8:0] */
781 value = pll_div.k & 0x0001ff;
782 wm8753_write(codec, WM8753_PLL1CTL4 + offset, value);
783
784 /* set PLL as input and enable */
785 wm8753_write(codec, WM8753_PLL1CTL1 + offset, 0x0027 |
786 (pll_div.div2 << 3));
787 wm8753_write(codec, WM8753_CLOCK, reg | enable);
788 }
789 return 0;
790}
791
792struct _coeff_div {
793 u32 mclk;
794 u32 rate;
795 u8 sr:5;
796 u8 usb:1;
797};
798
799/* codec hifi mclk (after PLL) clock divider coefficients */
800static const struct _coeff_div coeff_div[] = {
801 /* 8k */
802 {12288000, 8000, 0x6, 0x0},
803 {11289600, 8000, 0x16, 0x0},
804 {18432000, 8000, 0x7, 0x0},
805 {16934400, 8000, 0x17, 0x0},
806 {12000000, 8000, 0x6, 0x1},
807
808 /* 11.025k */
809 {11289600, 11025, 0x18, 0x0},
810 {16934400, 11025, 0x19, 0x0},
811 {12000000, 11025, 0x19, 0x1},
812
813 /* 16k */
814 {12288000, 16000, 0xa, 0x0},
815 {18432000, 16000, 0xb, 0x0},
816 {12000000, 16000, 0xa, 0x1},
817
818 /* 22.05k */
819 {11289600, 22050, 0x1a, 0x0},
820 {16934400, 22050, 0x1b, 0x0},
821 {12000000, 22050, 0x1b, 0x1},
822
823 /* 32k */
824 {12288000, 32000, 0xc, 0x0},
825 {18432000, 32000, 0xd, 0x0},
826 {12000000, 32000, 0xa, 0x1},
827
828 /* 44.1k */
829 {11289600, 44100, 0x10, 0x0},
830 {16934400, 44100, 0x11, 0x0},
831 {12000000, 44100, 0x11, 0x1},
832
833 /* 48k */
834 {12288000, 48000, 0x0, 0x0},
835 {18432000, 48000, 0x1, 0x0},
836 {12000000, 48000, 0x0, 0x1},
837
838 /* 88.2k */
839 {11289600, 88200, 0x1e, 0x0},
840 {16934400, 88200, 0x1f, 0x0},
841 {12000000, 88200, 0x1f, 0x1},
842
843 /* 96k */
844 {12288000, 96000, 0xe, 0x0},
845 {18432000, 96000, 0xf, 0x0},
846 {12000000, 96000, 0xe, 0x1},
847};
848
849static int get_coeff(int mclk, int rate)
850{
851 int i;
852
853 for (i = 0; i < ARRAY_SIZE(coeff_div); i++) {
854 if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk)
855 return i;
856 }
857 return -EINVAL;
858}
859
860/*
861 * Clock after PLL and dividers
862 */
863static int wm8753_set_dai_sysclk(struct snd_soc_codec_dai *codec_dai,
864 int clk_id, unsigned int freq, int dir)
865{
866 struct snd_soc_codec *codec = codec_dai->codec;
867 struct wm8753_priv *wm8753 = codec->private_data;
868
869 switch (freq) {
870 case 11289600:
871 case 12000000:
872 case 12288000:
873 case 16934400:
874 case 18432000:
875 if (clk_id == WM8753_MCLK) {
876 wm8753->sysclk = freq;
877 return 0;
878 } else if (clk_id == WM8753_PCMCLK) {
879 wm8753->pcmclk = freq;
880 return 0;
881 }
882 break;
883 }
884 return -EINVAL;
885}
886
887/*
888 * Set's ADC and Voice DAC format.
889 */
890static int wm8753_vdac_adc_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
891 unsigned int fmt)
892{
893 struct snd_soc_codec *codec = codec_dai->codec;
894 u16 voice = wm8753_read_reg_cache(codec, WM8753_PCM) & 0x01ec;
895
896 /* interface format */
897 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
898 case SND_SOC_DAIFMT_I2S:
899 voice |= 0x0002;
900 break;
901 case SND_SOC_DAIFMT_RIGHT_J:
902 break;
903 case SND_SOC_DAIFMT_LEFT_J:
904 voice |= 0x0001;
905 break;
906 case SND_SOC_DAIFMT_DSP_A:
907 voice |= 0x0003;
908 break;
909 case SND_SOC_DAIFMT_DSP_B:
910 voice |= 0x0013;
911 break;
912 default:
913 return -EINVAL;
914 }
915
916 wm8753_write(codec, WM8753_PCM, voice);
917 return 0;
918}
919
920/*
921 * Set PCM DAI bit size and sample rate.
922 */
923static int wm8753_pcm_hw_params(struct snd_pcm_substream *substream,
924 struct snd_pcm_hw_params *params)
925{
926 struct snd_soc_pcm_runtime *rtd = substream->private_data;
927 struct snd_soc_device *socdev = rtd->socdev;
928 struct snd_soc_codec *codec = socdev->codec;
929 struct wm8753_priv *wm8753 = codec->private_data;
930 u16 voice = wm8753_read_reg_cache(codec, WM8753_PCM) & 0x01f3;
931 u16 srate = wm8753_read_reg_cache(codec, WM8753_SRATE1) & 0x017f;
932
933 /* bit size */
934 switch (params_format(params)) {
935 case SNDRV_PCM_FORMAT_S16_LE:
936 break;
937 case SNDRV_PCM_FORMAT_S20_3LE:
938 voice |= 0x0004;
939 break;
940 case SNDRV_PCM_FORMAT_S24_LE:
941 voice |= 0x0008;
942 break;
943 case SNDRV_PCM_FORMAT_S32_LE:
944 voice |= 0x000c;
945 break;
946 }
947
948 /* sample rate */
949 if (params_rate(params) * 384 == wm8753->pcmclk)
950 srate |= 0x80;
951 wm8753_write(codec, WM8753_SRATE1, srate);
952
953 wm8753_write(codec, WM8753_PCM, voice);
954 return 0;
955}
956
957/*
958 * Set's PCM dai fmt and BCLK.
959 */
960static int wm8753_pcm_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
961 unsigned int fmt)
962{
963 struct snd_soc_codec *codec = codec_dai->codec;
964 u16 voice, ioctl;
965
966 voice = wm8753_read_reg_cache(codec, WM8753_PCM) & 0x011f;
967 ioctl = wm8753_read_reg_cache(codec, WM8753_IOCTL) & 0x015d;
968
969 /* set master/slave audio interface */
970 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
971 case SND_SOC_DAIFMT_CBS_CFS:
972 break;
973 case SND_SOC_DAIFMT_CBM_CFM:
974 ioctl |= 0x2;
975 case SND_SOC_DAIFMT_CBM_CFS:
976 voice |= 0x0040;
977 break;
978 default:
979 return -EINVAL;
980 }
981
982 /* clock inversion */
983 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
984 case SND_SOC_DAIFMT_DSP_A:
985 case SND_SOC_DAIFMT_DSP_B:
986 /* frame inversion not valid for DSP modes */
987 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
988 case SND_SOC_DAIFMT_NB_NF:
989 break;
990 case SND_SOC_DAIFMT_IB_NF:
991 voice |= 0x0080;
992 break;
993 default:
994 return -EINVAL;
995 }
996 break;
997 case SND_SOC_DAIFMT_I2S:
998 case SND_SOC_DAIFMT_RIGHT_J:
999 case SND_SOC_DAIFMT_LEFT_J:
1000 voice &= ~0x0010;
1001 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
1002 case SND_SOC_DAIFMT_NB_NF:
1003 break;
1004 case SND_SOC_DAIFMT_IB_IF:
1005 voice |= 0x0090;
1006 break;
1007 case SND_SOC_DAIFMT_IB_NF:
1008 voice |= 0x0080;
1009 break;
1010 case SND_SOC_DAIFMT_NB_IF:
1011 voice |= 0x0010;
1012 break;
1013 default:
1014 return -EINVAL;
1015 }
1016 break;
1017 default:
1018 return -EINVAL;
1019 }
1020
1021 wm8753_write(codec, WM8753_PCM, voice);
1022 wm8753_write(codec, WM8753_IOCTL, ioctl);
1023 return 0;
1024}
1025
1026static int wm8753_set_dai_clkdiv(struct snd_soc_codec_dai *codec_dai,
1027 int div_id, int div)
1028{
1029 struct snd_soc_codec *codec = codec_dai->codec;
1030 u16 reg;
1031
1032 switch (div_id) {
1033 case WM8753_PCMDIV:
1034 reg = wm8753_read_reg_cache(codec, WM8753_CLOCK) & 0x003f;
1035 wm8753_write(codec, WM8753_CLOCK, reg | div);
1036 break;
1037 case WM8753_BCLKDIV:
1038 reg = wm8753_read_reg_cache(codec, WM8753_SRATE2) & 0x01c7;
1039 wm8753_write(codec, WM8753_SRATE2, reg | div);
1040 break;
1041 case WM8753_VXCLKDIV:
1042 reg = wm8753_read_reg_cache(codec, WM8753_SRATE2) & 0x003f;
1043 wm8753_write(codec, WM8753_SRATE2, reg | div);
1044 break;
1045 default:
1046 return -EINVAL;
1047 }
1048 return 0;
1049}
1050
1051/*
1052 * Set's HiFi DAC format.
1053 */
1054static int wm8753_hdac_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
1055 unsigned int fmt)
1056{
1057 struct snd_soc_codec *codec = codec_dai->codec;
1058 u16 hifi = wm8753_read_reg_cache(codec, WM8753_HIFI) & 0x01e0;
1059
1060 /* interface format */
1061 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
1062 case SND_SOC_DAIFMT_I2S:
1063 hifi |= 0x0002;
1064 break;
1065 case SND_SOC_DAIFMT_RIGHT_J:
1066 break;
1067 case SND_SOC_DAIFMT_LEFT_J:
1068 hifi |= 0x0001;
1069 break;
1070 case SND_SOC_DAIFMT_DSP_A:
1071 hifi |= 0x0003;
1072 break;
1073 case SND_SOC_DAIFMT_DSP_B:
1074 hifi |= 0x0013;
1075 break;
1076 default:
1077 return -EINVAL;
1078 }
1079
1080 wm8753_write(codec, WM8753_HIFI, hifi);
1081 return 0;
1082}
1083
1084/*
1085 * Set's I2S DAI format.
1086 */
1087static int wm8753_i2s_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
1088 unsigned int fmt)
1089{
1090 struct snd_soc_codec *codec = codec_dai->codec;
1091 u16 ioctl, hifi;
1092
1093 hifi = wm8753_read_reg_cache(codec, WM8753_HIFI) & 0x011f;
1094 ioctl = wm8753_read_reg_cache(codec, WM8753_IOCTL) & 0x00ae;
1095
1096 /* set master/slave audio interface */
1097 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
1098 case SND_SOC_DAIFMT_CBS_CFS:
1099 break;
1100 case SND_SOC_DAIFMT_CBM_CFM:
1101 ioctl |= 0x1;
1102 case SND_SOC_DAIFMT_CBM_CFS:
1103 hifi |= 0x0040;
1104 break;
1105 default:
1106 return -EINVAL;
1107 }
1108
1109 /* clock inversion */
1110 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
1111 case SND_SOC_DAIFMT_DSP_A:
1112 case SND_SOC_DAIFMT_DSP_B:
1113 /* frame inversion not valid for DSP modes */
1114 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
1115 case SND_SOC_DAIFMT_NB_NF:
1116 break;
1117 case SND_SOC_DAIFMT_IB_NF:
1118 hifi |= 0x0080;
1119 break;
1120 default:
1121 return -EINVAL;
1122 }
1123 break;
1124 case SND_SOC_DAIFMT_I2S:
1125 case SND_SOC_DAIFMT_RIGHT_J:
1126 case SND_SOC_DAIFMT_LEFT_J:
1127 hifi &= ~0x0010;
1128 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
1129 case SND_SOC_DAIFMT_NB_NF:
1130 break;
1131 case SND_SOC_DAIFMT_IB_IF:
1132 hifi |= 0x0090;
1133 break;
1134 case SND_SOC_DAIFMT_IB_NF:
1135 hifi |= 0x0080;
1136 break;
1137 case SND_SOC_DAIFMT_NB_IF:
1138 hifi |= 0x0010;
1139 break;
1140 default:
1141 return -EINVAL;
1142 }
1143 break;
1144 default:
1145 return -EINVAL;
1146 }
1147
1148 wm8753_write(codec, WM8753_HIFI, hifi);
1149 wm8753_write(codec, WM8753_IOCTL, ioctl);
1150 return 0;
1151}
1152
1153/*
1154 * Set PCM DAI bit size and sample rate.
1155 */
1156static int wm8753_i2s_hw_params(struct snd_pcm_substream *substream,
1157 struct snd_pcm_hw_params *params)
1158{
1159 struct snd_soc_pcm_runtime *rtd = substream->private_data;
1160 struct snd_soc_device *socdev = rtd->socdev;
1161 struct snd_soc_codec *codec = socdev->codec;
1162 struct wm8753_priv *wm8753 = codec->private_data;
1163 u16 srate = wm8753_read_reg_cache(codec, WM8753_SRATE1) & 0x01c0;
1164 u16 hifi = wm8753_read_reg_cache(codec, WM8753_HIFI) & 0x01f3;
1165 int coeff;
1166
1167 /* is digital filter coefficient valid ? */
1168 coeff = get_coeff(wm8753->sysclk, params_rate(params));
1169 if (coeff < 0) {
1170 printk(KERN_ERR "wm8753 invalid MCLK or rate\n");
1171 return coeff;
1172 }
1173 wm8753_write(codec, WM8753_SRATE1, srate | (coeff_div[coeff].sr << 1) |
1174 coeff_div[coeff].usb);
1175
1176 /* bit size */
1177 switch (params_format(params)) {
1178 case SNDRV_PCM_FORMAT_S16_LE:
1179 break;
1180 case SNDRV_PCM_FORMAT_S20_3LE:
1181 hifi |= 0x0004;
1182 break;
1183 case SNDRV_PCM_FORMAT_S24_LE:
1184 hifi |= 0x0008;
1185 break;
1186 case SNDRV_PCM_FORMAT_S32_LE:
1187 hifi |= 0x000c;
1188 break;
1189 }
1190
1191 wm8753_write(codec, WM8753_HIFI, hifi);
1192 return 0;
1193}
1194
1195static int wm8753_mode1v_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
1196 unsigned int fmt)
1197{
1198 struct snd_soc_codec *codec = codec_dai->codec;
1199 u16 clock;
1200
1201 /* set clk source as pcmclk */
1202 clock = wm8753_read_reg_cache(codec, WM8753_CLOCK) & 0xfffb;
1203 wm8753_write(codec, WM8753_CLOCK, clock);
1204
1205 if (wm8753_vdac_adc_set_dai_fmt(codec_dai, fmt) < 0)
1206 return -EINVAL;
1207 return wm8753_pcm_set_dai_fmt(codec_dai, fmt);
1208}
1209
1210static int wm8753_mode1h_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
1211 unsigned int fmt)
1212{
1213 if (wm8753_hdac_set_dai_fmt(codec_dai, fmt) < 0)
1214 return -EINVAL;
1215 return wm8753_i2s_set_dai_fmt(codec_dai, fmt);
1216}
1217
1218static int wm8753_mode2_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
1219 unsigned int fmt)
1220{
1221 struct snd_soc_codec *codec = codec_dai->codec;
1222 u16 clock;
1223
1224 /* set clk source as pcmclk */
1225 clock = wm8753_read_reg_cache(codec, WM8753_CLOCK) & 0xfffb;
1226 wm8753_write(codec, WM8753_CLOCK, clock);
1227
1228 if (wm8753_vdac_adc_set_dai_fmt(codec_dai, fmt) < 0)
1229 return -EINVAL;
1230 return wm8753_i2s_set_dai_fmt(codec_dai, fmt);
1231}
1232
1233static int wm8753_mode3_4_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
1234 unsigned int fmt)
1235{
1236 struct snd_soc_codec *codec = codec_dai->codec;
1237 u16 clock;
1238
1239 /* set clk source as mclk */
1240 clock = wm8753_read_reg_cache(codec, WM8753_CLOCK) & 0xfffb;
1241 wm8753_write(codec, WM8753_CLOCK, clock | 0x4);
1242
1243 if (wm8753_hdac_set_dai_fmt(codec_dai, fmt) < 0)
1244 return -EINVAL;
1245 if (wm8753_vdac_adc_set_dai_fmt(codec_dai, fmt) < 0)
1246 return -EINVAL;
1247 return wm8753_i2s_set_dai_fmt(codec_dai, fmt);
1248}
1249
1250static int wm8753_mute(struct snd_soc_codec_dai *dai, int mute)
1251{
1252 struct snd_soc_codec *codec = dai->codec;
1253 u16 mute_reg = wm8753_read_reg_cache(codec, WM8753_DAC) & 0xfff7;
1254
1255 /* the digital mute covers the HiFi and Voice DAC's on the WM8753.
1256 * make sure we check if they are not both active when we mute */
1257 if (mute && dai->id == 1) {
1258 if (!wm8753_dai[WM8753_DAI_VOICE].playback.active ||
1259 !wm8753_dai[WM8753_DAI_HIFI].playback.active)
1260 wm8753_write(codec, WM8753_DAC, mute_reg | 0x8);
1261 } else {
1262 if (mute)
1263 wm8753_write(codec, WM8753_DAC, mute_reg | 0x8);
1264 else
1265 wm8753_write(codec, WM8753_DAC, mute_reg);
1266 }
1267
1268 return 0;
1269}
1270
1271static int wm8753_dapm_event(struct snd_soc_codec *codec, int event)
1272{
1273 u16 pwr_reg = wm8753_read_reg_cache(codec, WM8753_PWR1) & 0xfe3e;
1274
1275 switch (event) {
1276 case SNDRV_CTL_POWER_D0: /* full On */
1277 /* set vmid to 50k and unmute dac */
1278 wm8753_write(codec, WM8753_PWR1, pwr_reg | 0x00c0);
1279 break;
1280 case SNDRV_CTL_POWER_D1: /* partial On */
1281 case SNDRV_CTL_POWER_D2: /* partial On */
1282 /* set vmid to 5k for quick power up */
1283 wm8753_write(codec, WM8753_PWR1, pwr_reg | 0x01c1);
1284 break;
1285 case SNDRV_CTL_POWER_D3hot: /* Off, with power */
1286 /* mute dac and set vmid to 500k, enable VREF */
1287 wm8753_write(codec, WM8753_PWR1, pwr_reg | 0x0141);
1288 break;
1289 case SNDRV_CTL_POWER_D3cold: /* Off, without power */
1290 wm8753_write(codec, WM8753_PWR1, 0x0001);
1291 break;
1292 }
1293 codec->dapm_state = event;
1294 return 0;
1295}
1296
1297#define WM8753_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
1298 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \
1299 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
1300
1301#define WM8753_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
1302 SNDRV_PCM_FMTBIT_S24_LE)
1303
1304/*
1305 * The WM8753 supports upto 4 different and mutually exclusive DAI
1306 * configurations. This gives 2 PCM's available for use, hifi and voice.
1307 * NOTE: The Voice PCM cannot play or capture audio to the CPU as it's DAI
1308 * is connected between the wm8753 and a BT codec or GSM modem.
1309 *
1310 * 1. Voice over PCM DAI - HIFI DAC over HIFI DAI
1311 * 2. Voice over HIFI DAI - HIFI disabled
1312 * 3. Voice disabled - HIFI over HIFI
1313 * 4. Voice disabled - HIFI over HIFI, uses voice DAI LRC for capture
1314 */
1315static const struct snd_soc_codec_dai wm8753_all_dai[] = {
1316/* DAI HiFi mode 1 */
1317{ .name = "WM8753 HiFi",
1318 .id = 1,
1319 .playback = {
1320 .stream_name = "HiFi Playback",
1321 .channels_min = 1,
1322 .channels_max = 2,
1323 .rates = WM8753_RATES,
1324 .formats = WM8753_FORMATS,},
1325 .capture = { /* dummy for fast DAI switching */
1326 .stream_name = "Capture",
1327 .channels_min = 1,
1328 .channels_max = 2,
1329 .rates = WM8753_RATES,
1330 .formats = WM8753_FORMATS,},
1331 .ops = {
1332 .hw_params = wm8753_i2s_hw_params,},
1333 .dai_ops = {
1334 .digital_mute = wm8753_mute,
1335 .set_fmt = wm8753_mode1h_set_dai_fmt,
1336 .set_clkdiv = wm8753_set_dai_clkdiv,
1337 .set_pll = wm8753_set_dai_pll,
1338 .set_sysclk = wm8753_set_dai_sysclk,
1339 },
1340},
1341/* DAI Voice mode 1 */
1342{ .name = "WM8753 Voice",
1343 .id = 1,
1344 .playback = {
1345 .stream_name = "Voice Playback",
1346 .channels_min = 1,
1347 .channels_max = 1,
1348 .rates = WM8753_RATES,
1349 .formats = WM8753_FORMATS,},
1350 .capture = {
1351 .stream_name = "Capture",
1352 .channels_min = 1,
1353 .channels_max = 2,
1354 .rates = WM8753_RATES,
1355 .formats = WM8753_FORMATS,},
1356 .ops = {
1357 .hw_params = wm8753_pcm_hw_params,},
1358 .dai_ops = {
1359 .digital_mute = wm8753_mute,
1360 .set_fmt = wm8753_mode1v_set_dai_fmt,
1361 .set_clkdiv = wm8753_set_dai_clkdiv,
1362 .set_pll = wm8753_set_dai_pll,
1363 .set_sysclk = wm8753_set_dai_sysclk,
1364 },
1365},
1366/* DAI HiFi mode 2 - dummy */
1367{ .name = "WM8753 HiFi",
1368 .id = 2,
1369},
1370/* DAI Voice mode 2 */
1371{ .name = "WM8753 Voice",
1372 .id = 2,
1373 .playback = {
1374 .stream_name = "Voice Playback",
1375 .channels_min = 1,
1376 .channels_max = 1,
1377 .rates = WM8753_RATES,
1378 .formats = WM8753_FORMATS,},
1379 .capture = {
1380 .stream_name = "Capture",
1381 .channels_min = 1,
1382 .channels_max = 2,
1383 .rates = WM8753_RATES,
1384 .formats = WM8753_FORMATS,},
1385 .ops = {
1386 .hw_params = wm8753_pcm_hw_params,},
1387 .dai_ops = {
1388 .digital_mute = wm8753_mute,
1389 .set_fmt = wm8753_mode2_set_dai_fmt,
1390 .set_clkdiv = wm8753_set_dai_clkdiv,
1391 .set_pll = wm8753_set_dai_pll,
1392 .set_sysclk = wm8753_set_dai_sysclk,
1393 },
1394},
1395/* DAI HiFi mode 3 */
1396{ .name = "WM8753 HiFi",
1397 .id = 3,
1398 .playback = {
1399 .stream_name = "HiFi Playback",
1400 .channels_min = 1,
1401 .channels_max = 2,
1402 .rates = WM8753_RATES,
1403 .formats = WM8753_FORMATS,},
1404 .capture = {
1405 .stream_name = "Capture",
1406 .channels_min = 1,
1407 .channels_max = 2,
1408 .rates = WM8753_RATES,
1409 .formats = WM8753_FORMATS,},
1410 .ops = {
1411 .hw_params = wm8753_i2s_hw_params,},
1412 .dai_ops = {
1413 .digital_mute = wm8753_mute,
1414 .set_fmt = wm8753_mode3_4_set_dai_fmt,
1415 .set_clkdiv = wm8753_set_dai_clkdiv,
1416 .set_pll = wm8753_set_dai_pll,
1417 .set_sysclk = wm8753_set_dai_sysclk,
1418 },
1419},
1420/* DAI Voice mode 3 - dummy */
1421{ .name = "WM8753 Voice",
1422 .id = 3,
1423},
1424/* DAI HiFi mode 4 */
1425{ .name = "WM8753 HiFi",
1426 .id = 4,
1427 .playback = {
1428 .stream_name = "HiFi Playback",
1429 .channels_min = 1,
1430 .channels_max = 2,
1431 .rates = WM8753_RATES,
1432 .formats = WM8753_FORMATS,},
1433 .capture = {
1434 .stream_name = "Capture",
1435 .channels_min = 1,
1436 .channels_max = 2,
1437 .rates = WM8753_RATES,
1438 .formats = WM8753_FORMATS,},
1439 .ops = {
1440 .hw_params = wm8753_i2s_hw_params,},
1441 .dai_ops = {
1442 .digital_mute = wm8753_mute,
1443 .set_fmt = wm8753_mode3_4_set_dai_fmt,
1444 .set_clkdiv = wm8753_set_dai_clkdiv,
1445 .set_pll = wm8753_set_dai_pll,
1446 .set_sysclk = wm8753_set_dai_sysclk,
1447 },
1448},
1449/* DAI Voice mode 4 - dummy */
1450{ .name = "WM8753 Voice",
1451 .id = 4,
1452},
1453};
1454
1455struct snd_soc_codec_dai wm8753_dai[2];
1456EXPORT_SYMBOL_GPL(wm8753_dai);
1457
1458static void wm8753_set_dai_mode(struct snd_soc_codec *codec, unsigned int mode)
1459{
1460 if (mode < 4) {
1461 int playback_active, capture_active, codec_active, pop_wait;
1462 void *private_data;
1463
1464 playback_active = wm8753_dai[0].playback.active;
1465 capture_active = wm8753_dai[0].capture.active;
1466 codec_active = wm8753_dai[0].active;
1467 private_data = wm8753_dai[0].private_data;
1468 pop_wait = wm8753_dai[0].pop_wait;
1469 wm8753_dai[0] = wm8753_all_dai[mode << 1];
1470 wm8753_dai[0].playback.active = playback_active;
1471 wm8753_dai[0].capture.active = capture_active;
1472 wm8753_dai[0].active = codec_active;
1473 wm8753_dai[0].private_data = private_data;
1474 wm8753_dai[0].pop_wait = pop_wait;
1475
1476 playback_active = wm8753_dai[1].playback.active;
1477 capture_active = wm8753_dai[1].capture.active;
1478 codec_active = wm8753_dai[1].active;
1479 private_data = wm8753_dai[1].private_data;
1480 pop_wait = wm8753_dai[1].pop_wait;
1481 wm8753_dai[1] = wm8753_all_dai[(mode << 1) + 1];
1482 wm8753_dai[1].playback.active = playback_active;
1483 wm8753_dai[1].capture.active = capture_active;
1484 wm8753_dai[1].active = codec_active;
1485 wm8753_dai[1].private_data = private_data;
1486 wm8753_dai[1].pop_wait = pop_wait;
1487 }
1488 wm8753_dai[0].codec = codec;
1489 wm8753_dai[1].codec = codec;
1490}
1491
1492static void wm8753_work(struct work_struct *work)
1493{
1494 struct snd_soc_codec *codec =
1495 container_of(work, struct snd_soc_codec, delayed_work.work);
1496 wm8753_dapm_event(codec, codec->dapm_state);
1497}
1498
1499static int wm8753_suspend(struct platform_device *pdev, pm_message_t state)
1500{
1501 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1502 struct snd_soc_codec *codec = socdev->codec;
1503
1504 /* we only need to suspend if we are a valid card */
1505 if(!codec->card)
1506 return 0;
1507
1508 wm8753_dapm_event(codec, SNDRV_CTL_POWER_D3cold);
1509 return 0;
1510}
1511
1512static int wm8753_resume(struct platform_device *pdev)
1513{
1514 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1515 struct snd_soc_codec *codec = socdev->codec;
1516 int i;
1517 u8 data[2];
1518 u16 *cache = codec->reg_cache;
1519
1520 /* we only need to resume if we are a valid card */
1521 if(!codec->card)
1522 return 0;
1523
1524 /* Sync reg_cache with the hardware */
1525 for (i = 0; i < ARRAY_SIZE(wm8753_reg); i++) {
1526 if (i + 1 == WM8753_RESET)
1527 continue;
1528 data[0] = ((i + 1) << 1) | ((cache[i] >> 8) & 0x0001);
1529 data[1] = cache[i] & 0x00ff;
1530 codec->hw_write(codec->control_data, data, 2);
1531 }
1532
1533 wm8753_dapm_event(codec, SNDRV_CTL_POWER_D3hot);
1534
1535 /* charge wm8753 caps */
1536 if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0) {
1537 wm8753_dapm_event(codec, SNDRV_CTL_POWER_D2);
1538 codec->dapm_state = SNDRV_CTL_POWER_D0;
1539 schedule_delayed_work(&codec->delayed_work,
1540 msecs_to_jiffies(caps_charge));
1541 }
1542
1543 return 0;
1544}
1545
1546/*
1547 * initialise the WM8753 driver
1548 * register the mixer and dsp interfaces with the kernel
1549 */
1550static int wm8753_init(struct snd_soc_device *socdev)
1551{
1552 struct snd_soc_codec *codec = socdev->codec;
1553 int reg, ret = 0;
1554
1555 codec->name = "WM8753";
1556 codec->owner = THIS_MODULE;
1557 codec->read = wm8753_read_reg_cache;
1558 codec->write = wm8753_write;
1559 codec->dapm_event = wm8753_dapm_event;
1560 codec->dai = wm8753_dai;
1561 codec->num_dai = 2;
1562 codec->reg_cache_size = sizeof(wm8753_reg);
1563 codec->reg_cache = kmemdup(wm8753_reg, sizeof(wm8753_reg), GFP_KERNEL);
1564
1565 if (codec->reg_cache == NULL)
1566 return -ENOMEM;
1567
1568 wm8753_set_dai_mode(codec, 0);
1569
1570 wm8753_reset(codec);
1571
1572 /* register pcms */
1573 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
1574 if (ret < 0) {
1575 printk(KERN_ERR "wm8753: failed to create pcms\n");
1576 goto pcm_err;
1577 }
1578
1579 /* charge output caps */
1580 wm8753_dapm_event(codec, SNDRV_CTL_POWER_D2);
1581 codec->dapm_state = SNDRV_CTL_POWER_D3hot;
1582 schedule_delayed_work(&codec->delayed_work,
1583 msecs_to_jiffies(caps_charge));
1584
1585 /* set the update bits */
1586 reg = wm8753_read_reg_cache(codec, WM8753_LDAC);
1587 wm8753_write(codec, WM8753_LDAC, reg | 0x0100);
1588 reg = wm8753_read_reg_cache(codec, WM8753_RDAC);
1589 wm8753_write(codec, WM8753_RDAC, reg | 0x0100);
1590 reg = wm8753_read_reg_cache(codec, WM8753_LADC);
1591 wm8753_write(codec, WM8753_LADC, reg | 0x0100);
1592 reg = wm8753_read_reg_cache(codec, WM8753_RADC);
1593 wm8753_write(codec, WM8753_RADC, reg | 0x0100);
1594 reg = wm8753_read_reg_cache(codec, WM8753_LOUT1V);
1595 wm8753_write(codec, WM8753_LOUT1V, reg | 0x0100);
1596 reg = wm8753_read_reg_cache(codec, WM8753_ROUT1V);
1597 wm8753_write(codec, WM8753_ROUT1V, reg | 0x0100);
1598 reg = wm8753_read_reg_cache(codec, WM8753_LOUT2V);
1599 wm8753_write(codec, WM8753_LOUT2V, reg | 0x0100);
1600 reg = wm8753_read_reg_cache(codec, WM8753_ROUT2V);
1601 wm8753_write(codec, WM8753_ROUT2V, reg | 0x0100);
1602 reg = wm8753_read_reg_cache(codec, WM8753_LINVOL);
1603 wm8753_write(codec, WM8753_LINVOL, reg | 0x0100);
1604 reg = wm8753_read_reg_cache(codec, WM8753_RINVOL);
1605 wm8753_write(codec, WM8753_RINVOL, reg | 0x0100);
1606
1607 wm8753_add_controls(codec);
1608 wm8753_add_widgets(codec);
1609 ret = snd_soc_register_card(socdev);
1610 if (ret < 0) {
1611 printk(KERN_ERR "wm8753: failed to register card\n");
1612 goto card_err;
1613 }
1614 return ret;
1615
1616card_err:
1617 snd_soc_free_pcms(socdev);
1618 snd_soc_dapm_free(socdev);
1619pcm_err:
1620 kfree(codec->reg_cache);
1621 return ret;
1622}
1623
1624/* If the i2c layer weren't so broken, we could pass this kind of data
1625 around */
1626static struct snd_soc_device *wm8753_socdev;
1627
1628#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
1629
1630/*
1631 * WM8753 2 wire address is determined by GPIO5
1632 * state during powerup.
1633 * low = 0x1a
1634 * high = 0x1b
1635 */
1636static unsigned short normal_i2c[] = { 0, I2C_CLIENT_END };
1637
1638/* Magic definition of all other variables and things */
1639I2C_CLIENT_INSMOD;
1640
1641static struct i2c_driver wm8753_i2c_driver;
1642static struct i2c_client client_template;
1643
1644static int wm8753_codec_probe(struct i2c_adapter *adap, int addr, int kind)
1645{
1646 struct snd_soc_device *socdev = wm8753_socdev;
1647 struct wm8753_setup_data *setup = socdev->codec_data;
1648 struct snd_soc_codec *codec = socdev->codec;
1649 struct i2c_client *i2c;
1650 int ret;
1651
1652 if (addr != setup->i2c_address)
1653 return -ENODEV;
1654
1655 client_template.adapter = adap;
1656 client_template.addr = addr;
1657
1658 i2c = kmemdup(&client_template, sizeof(client_template), GFP_KERNEL);
1659 if (i2c == NULL){
1660 kfree(codec);
1661 return -ENOMEM;
1662 }
1663 i2c_set_clientdata(i2c, codec);
1664 codec->control_data = i2c;
1665
1666 ret = i2c_attach_client(i2c);
1667 if (ret < 0) {
1668 err("failed to attach codec at addr %x\n", addr);
1669 goto err;
1670 }
1671
1672 ret = wm8753_init(socdev);
1673 if (ret < 0) {
1674 err("failed to initialise WM8753\n");
1675 goto err;
1676 }
1677
1678 return ret;
1679
1680err:
1681 kfree(codec);
1682 kfree(i2c);
1683 return ret;
1684}
1685
1686static int wm8753_i2c_detach(struct i2c_client *client)
1687{
1688 struct snd_soc_codec *codec = i2c_get_clientdata(client);
1689 i2c_detach_client(client);
1690 kfree(codec->reg_cache);
1691 kfree(client);
1692 return 0;
1693}
1694
1695static int wm8753_i2c_attach(struct i2c_adapter *adap)
1696{
1697 return i2c_probe(adap, &addr_data, wm8753_codec_probe);
1698}
1699
1700/* corgi i2c codec control layer */
1701static struct i2c_driver wm8753_i2c_driver = {
1702 .driver = {
1703 .name = "WM8753 I2C Codec",
1704 .owner = THIS_MODULE,
1705 },
1706 .id = I2C_DRIVERID_WM8753,
1707 .attach_adapter = wm8753_i2c_attach,
1708 .detach_client = wm8753_i2c_detach,
1709 .command = NULL,
1710};
1711
1712static struct i2c_client client_template = {
1713 .name = "WM8753",
1714 .driver = &wm8753_i2c_driver,
1715};
1716#endif
1717
1718static int wm8753_probe(struct platform_device *pdev)
1719{
1720 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1721 struct wm8753_setup_data *setup;
1722 struct snd_soc_codec *codec;
1723 struct wm8753_priv *wm8753;
1724 int ret = 0;
1725
1726 info("WM8753 Audio Codec %s", WM8753_VERSION);
1727
1728 setup = socdev->codec_data;
1729 codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
1730 if (codec == NULL)
1731 return -ENOMEM;
1732
1733 wm8753 = kzalloc(sizeof(struct wm8753_priv), GFP_KERNEL);
1734 if (wm8753 == NULL) {
1735 kfree(codec);
1736 return -ENOMEM;
1737 }
1738
1739 codec->private_data = wm8753;
1740 socdev->codec = codec;
1741 mutex_init(&codec->mutex);
1742 INIT_LIST_HEAD(&codec->dapm_widgets);
1743 INIT_LIST_HEAD(&codec->dapm_paths);
1744 wm8753_socdev = socdev;
1745 INIT_DELAYED_WORK(&codec->delayed_work, wm8753_work);
1746
1747#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
1748 if (setup->i2c_address) {
1749 normal_i2c[0] = setup->i2c_address;
1750 codec->hw_write = (hw_write_t)i2c_master_send;
1751 ret = i2c_add_driver(&wm8753_i2c_driver);
1752 if (ret != 0)
1753 printk(KERN_ERR "can't add i2c driver");
1754 }
1755#else
1756 /* Add other interfaces here */
1757#endif
1758 return ret;
1759}
1760
1761/*
1762 * This function forces any delayed work to be queued and run.
1763 */
1764static int run_delayed_work(struct delayed_work *dwork)
1765{
1766 int ret;
1767
1768 /* cancel any work waiting to be queued. */
1769 ret = cancel_delayed_work(dwork);
1770
1771 /* if there was any work waiting then we run it now and
1772 * wait for it's completion */
1773 if (ret) {
1774 schedule_delayed_work(dwork, 0);
1775 flush_scheduled_work();
1776 }
1777 return ret;
1778}
1779
1780/* power down chip */
1781static int wm8753_remove(struct platform_device *pdev)
1782{
1783 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1784 struct snd_soc_codec *codec = socdev->codec;
1785
1786 if (codec->control_data)
1787 wm8753_dapm_event(codec, SNDRV_CTL_POWER_D3cold);
1788 run_delayed_work(&codec->delayed_work);
1789 snd_soc_free_pcms(socdev);
1790 snd_soc_dapm_free(socdev);
1791#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
1792 i2c_del_driver(&wm8753_i2c_driver);
1793#endif
1794 kfree(codec->private_data);
1795 kfree(codec);
1796
1797 return 0;
1798}
1799
1800struct snd_soc_codec_device soc_codec_dev_wm8753 = {
1801 .probe = wm8753_probe,
1802 .remove = wm8753_remove,
1803 .suspend = wm8753_suspend,
1804 .resume = wm8753_resume,
1805};
1806
1807EXPORT_SYMBOL_GPL(soc_codec_dev_wm8753);
1808
1809MODULE_DESCRIPTION("ASoC WM8753 driver");
1810MODULE_AUTHOR("Liam Girdwood");
1811MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/wm8753.h b/sound/soc/codecs/wm8753.h
new file mode 100644
index 000000000000..95e2a1f53169
--- /dev/null
+++ b/sound/soc/codecs/wm8753.h
@@ -0,0 +1,126 @@
1/*
2 * wm8753.h -- audio driver for WM8753
3 *
4 * Copyright 2003 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood
6 * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */
14
15#ifndef _WM8753_H
16#define _WM8753_H
17
18/* WM8753 register space */
19
20#define WM8753_DAC 0x01
21#define WM8753_ADC 0x02
22#define WM8753_PCM 0x03
23#define WM8753_HIFI 0x04
24#define WM8753_IOCTL 0x05
25#define WM8753_SRATE1 0x06
26#define WM8753_SRATE2 0x07
27#define WM8753_LDAC 0x08
28#define WM8753_RDAC 0x09
29#define WM8753_BASS 0x0a
30#define WM8753_TREBLE 0x0b
31#define WM8753_ALC1 0x0c
32#define WM8753_ALC2 0x0d
33#define WM8753_ALC3 0x0e
34#define WM8753_NGATE 0x0f
35#define WM8753_LADC 0x10
36#define WM8753_RADC 0x11
37#define WM8753_ADCTL1 0x12
38#define WM8753_3D 0x13
39#define WM8753_PWR1 0x14
40#define WM8753_PWR2 0x15
41#define WM8753_PWR3 0x16
42#define WM8753_PWR4 0x17
43#define WM8753_ID 0x18
44#define WM8753_INTPOL 0x19
45#define WM8753_INTEN 0x1a
46#define WM8753_GPIO1 0x1b
47#define WM8753_GPIO2 0x1c
48#define WM8753_RESET 0x1f
49#define WM8753_RECMIX1 0x20
50#define WM8753_RECMIX2 0x21
51#define WM8753_LOUTM1 0x22
52#define WM8753_LOUTM2 0x23
53#define WM8753_ROUTM1 0x24
54#define WM8753_ROUTM2 0x25
55#define WM8753_MOUTM1 0x26
56#define WM8753_MOUTM2 0x27
57#define WM8753_LOUT1V 0x28
58#define WM8753_ROUT1V 0x29
59#define WM8753_LOUT2V 0x2a
60#define WM8753_ROUT2V 0x2b
61#define WM8753_MOUTV 0x2c
62#define WM8753_OUTCTL 0x2d
63#define WM8753_ADCIN 0x2e
64#define WM8753_INCTL1 0x2f
65#define WM8753_INCTL2 0x30
66#define WM8753_LINVOL 0x31
67#define WM8753_RINVOL 0x32
68#define WM8753_MICBIAS 0x33
69#define WM8753_CLOCK 0x34
70#define WM8753_PLL1CTL1 0x35
71#define WM8753_PLL1CTL2 0x36
72#define WM8753_PLL1CTL3 0x37
73#define WM8753_PLL1CTL4 0x38
74#define WM8753_PLL2CTL1 0x39
75#define WM8753_PLL2CTL2 0x3a
76#define WM8753_PLL2CTL3 0x3b
77#define WM8753_PLL2CTL4 0x3c
78#define WM8753_BIASCTL 0x3d
79#define WM8753_ADCTL2 0x3f
80
81struct wm8753_setup_data {
82 unsigned short i2c_address;
83};
84
85#define WM8753_PLL1 0
86#define WM8753_PLL2 1
87
88/* clock inputs */
89#define WM8753_MCLK 0
90#define WM8753_PCMCLK 1
91
92/* clock divider id's */
93#define WM8753_PCMDIV 0
94#define WM8753_BCLKDIV 1
95#define WM8753_VXCLKDIV 2
96
97/* PCM clock dividers */
98#define WM8753_PCM_DIV_1 (0 << 6)
99#define WM8753_PCM_DIV_3 (2 << 6)
100#define WM8753_PCM_DIV_5_5 (3 << 6)
101#define WM8753_PCM_DIV_2 (4 << 6)
102#define WM8753_PCM_DIV_4 (5 << 6)
103#define WM8753_PCM_DIV_6 (6 << 6)
104#define WM8753_PCM_DIV_8 (7 << 6)
105
106/* BCLK clock dividers */
107#define WM8753_BCLK_DIV_1 (0 << 3)
108#define WM8753_BCLK_DIV_2 (1 << 3)
109#define WM8753_BCLK_DIV_4 (2 << 3)
110#define WM8753_BCLK_DIV_8 (3 << 3)
111#define WM8753_BCLK_DIV_16 (4 << 3)
112
113/* VXCLK clock dividers */
114#define WM8753_VXCLK_DIV_1 (0 << 6)
115#define WM8753_VXCLK_DIV_2 (1 << 6)
116#define WM8753_VXCLK_DIV_4 (2 << 6)
117#define WM8753_VXCLK_DIV_8 (3 << 6)
118#define WM8753_VXCLK_DIV_16 (4 << 6)
119
120#define WM8753_DAI_HIFI 0
121#define WM8753_DAI_VOICE 1
122
123extern struct snd_soc_codec_dai wm8753_dai[2];
124extern struct snd_soc_codec_device soc_codec_dev_wm8753;
125
126#endif
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c
index ee7a691a9ba1..264413a00cac 100644
--- a/sound/soc/codecs/wm9712.c
+++ b/sound/soc/codecs/wm9712.c
@@ -676,14 +676,13 @@ static int wm9712_soc_probe(struct platform_device *pdev)
676 codec = socdev->codec; 676 codec = socdev->codec;
677 mutex_init(&codec->mutex); 677 mutex_init(&codec->mutex);
678 678
679 codec->reg_cache = 679 codec->reg_cache = kmemdup(wm9712_reg, sizeof(wm9712_reg), GFP_KERNEL);
680 kzalloc(sizeof(u16) * ARRAY_SIZE(wm9712_reg), GFP_KERNEL); 680
681 if (codec->reg_cache == NULL) { 681 if (codec->reg_cache == NULL) {
682 ret = -ENOMEM; 682 ret = -ENOMEM;
683 goto cache_err; 683 goto cache_err;
684 } 684 }
685 memcpy(codec->reg_cache, wm9712_reg, sizeof(u16) * ARRAY_SIZE(wm9712_reg)); 685 codec->reg_cache_size = sizeof(wm9712_reg);
686 codec->reg_cache_size = sizeof(u16) * ARRAY_SIZE(wm9712_reg);
687 codec->reg_cache_step = 2; 686 codec->reg_cache_step = 2;
688 687
689 codec->name = "WM9712"; 688 codec->name = "WM9712";
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig
index b9ab3b8e1d3e..a83e22937c27 100644
--- a/sound/soc/pxa/Kconfig
+++ b/sound/soc/pxa/Kconfig
@@ -1,5 +1,3 @@
1menu "SoC Audio for the Intel PXA2xx"
2
3config SND_PXA2XX_SOC 1config SND_PXA2XX_SOC
4 tristate "SoC Audio for the Intel PXA2xx chip" 2 tristate "SoC Audio for the Intel PXA2xx chip"
5 depends on ARCH_PXA && SND_SOC 3 depends on ARCH_PXA && SND_SOC
@@ -55,5 +53,3 @@ config SND_PXA2XX_SOC_TOSA
55 help 53 help
56 Say Y if you want to add support for SoC audio on Sharp 54 Say Y if you want to add support for SoC audio on Sharp
57 Zaurus SL-C6000x models (Tosa). 55 Zaurus SL-C6000x models (Tosa).
58
59endmenu
diff --git a/sound/soc/s3c24xx/Kconfig b/sound/soc/s3c24xx/Kconfig
new file mode 100644
index 000000000000..044a3712077a
--- /dev/null
+++ b/sound/soc/s3c24xx/Kconfig
@@ -0,0 +1,10 @@
1config SND_S3C24XX_SOC
2 tristate "SoC Audio for the Samsung S3C24XX chips"
3 depends on ARCH_S3C2410 && SND_SOC
4 help
5 Say Y or M if you want to add support for codecs attached to
6 the S3C24XX AC97, I2S or SSP interface. You will also need
7 to select the audio interfaces to support below.
8
9config SND_S3C24XX_SOC_I2S
10 tristate
diff --git a/sound/soc/s3c24xx/Makefile b/sound/soc/s3c24xx/Makefile
new file mode 100644
index 000000000000..6f0fffcb30f5
--- /dev/null
+++ b/sound/soc/s3c24xx/Makefile
@@ -0,0 +1,6 @@
1# S3c24XX Platform Support
2snd-soc-s3c24xx-objs := s3c24xx-pcm.o
3snd-soc-s3c24xx-i2s-objs := s3c24xx-i2s.o
4
5obj-$(CONFIG_SND_S3C24XX_SOC) += snd-soc-s3c24xx.o
6obj-$(CONFIG_SND_S3C24XX_SOC_I2S) += snd-soc-s3c24xx-i2s.o
diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.c b/sound/soc/s3c24xx/s3c24xx-i2s.c
new file mode 100644
index 000000000000..8ca314dc8891
--- /dev/null
+++ b/sound/soc/s3c24xx/s3c24xx-i2s.c
@@ -0,0 +1,441 @@
1/*
2 * s3c24xx-i2s.c -- ALSA Soc Audio Layer
3 *
4 * (c) 2006 Wolfson Microelectronics PLC.
5 * Graeme Gregory graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com
6 *
7 * (c) 2004-2005 Simtec Electronics
8 * http://armlinux.simtec.co.uk/
9 * Ben Dooks <ben@simtec.co.uk>
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 *
17 * Revision history
18 * 11th Dec 2006 Merged with Simtec driver
19 * 10th Nov 2006 Initial version.
20 */
21
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/device.h>
25#include <linux/delay.h>
26#include <linux/clk.h>
27#include <sound/driver.h>
28#include <sound/core.h>
29#include <sound/pcm.h>
30#include <sound/pcm_params.h>
31#include <sound/initval.h>
32#include <sound/soc.h>
33
34#include <asm/hardware.h>
35#include <asm/io.h>
36#include <asm/arch/regs-iis.h>
37#include <asm/arch/regs-gpio.h>
38#include <asm/arch/regs-clock.h>
39#include <asm/arch/audio.h>
40#include <asm/dma.h>
41#include <asm/arch/dma.h>
42
43#include "s3c24xx-pcm.h"
44#include "s3c24xx-i2s.h"
45
46#define S3C24XX_I2S_DEBUG 0
47#if S3C24XX_I2S_DEBUG
48#define DBG(x...) printk(KERN_DEBUG x)
49#else
50#define DBG(x...)
51#endif
52
53static struct s3c2410_dma_client s3c24xx_dma_client_out = {
54 .name = "I2S PCM Stereo out"
55};
56
57static struct s3c2410_dma_client s3c24xx_dma_client_in = {
58 .name = "I2S PCM Stereo in"
59};
60
61static struct s3c24xx_pcm_dma_params s3c24xx_i2s_pcm_stereo_out = {
62 .client = &s3c24xx_dma_client_out,
63 .channel = DMACH_I2S_OUT,
64 .dma_addr = S3C2410_PA_IIS + S3C2410_IISFIFO,
65 .dma_size = 2,
66};
67
68static struct s3c24xx_pcm_dma_params s3c24xx_i2s_pcm_stereo_in = {
69 .client = &s3c24xx_dma_client_in,
70 .channel = DMACH_I2S_IN,
71 .dma_addr = S3C2410_PA_IIS + S3C2410_IISFIFO,
72 .dma_size = 2,
73};
74
75struct s3c24xx_i2s_info {
76 void __iomem *regs;
77 struct clk *iis_clk;
78};
79static struct s3c24xx_i2s_info s3c24xx_i2s;
80
81static void s3c24xx_snd_txctrl(int on)
82{
83 u32 iisfcon;
84 u32 iiscon;
85 u32 iismod;
86
87 DBG("Entered %s\n", __FUNCTION__);
88
89 iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON);
90 iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON);
91 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
92
93 DBG("r: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon);
94
95 if (on) {
96 iisfcon |= S3C2410_IISFCON_TXDMA | S3C2410_IISFCON_TXENABLE;
97 iiscon |= S3C2410_IISCON_TXDMAEN | S3C2410_IISCON_IISEN;
98 iiscon &= ~S3C2410_IISCON_TXIDLE;
99 iismod |= S3C2410_IISMOD_TXMODE;
100
101 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
102 writel(iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON);
103 writel(iiscon, s3c24xx_i2s.regs + S3C2410_IISCON);
104 } else {
105 /* note, we have to disable the FIFOs otherwise bad things
106 * seem to happen when the DMA stops. According to the
107 * Samsung supplied kernel, this should allow the DMA
108 * engine and FIFOs to reset. If this isn't allowed, the
109 * DMA engine will simply freeze randomly.
110 */
111
112 iisfcon &= ~S3C2410_IISFCON_TXENABLE;
113 iisfcon &= ~S3C2410_IISFCON_TXDMA;
114 iiscon |= S3C2410_IISCON_TXIDLE;
115 iiscon &= ~S3C2410_IISCON_TXDMAEN;
116 iismod &= ~S3C2410_IISMOD_TXMODE;
117
118 writel(iiscon, s3c24xx_i2s.regs + S3C2410_IISCON);
119 writel(iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON);
120 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
121 }
122
123 DBG("w: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon);
124}
125
126static void s3c24xx_snd_rxctrl(int on)
127{
128 u32 iisfcon;
129 u32 iiscon;
130 u32 iismod;
131
132 DBG("Entered %s\n", __FUNCTION__);
133
134 iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON);
135 iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON);
136 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
137
138 DBG("r: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon);
139
140 if (on) {
141 iisfcon |= S3C2410_IISFCON_RXDMA | S3C2410_IISFCON_RXENABLE;
142 iiscon |= S3C2410_IISCON_RXDMAEN | S3C2410_IISCON_IISEN;
143 iiscon &= ~S3C2410_IISCON_RXIDLE;
144 iismod |= S3C2410_IISMOD_RXMODE;
145
146 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
147 writel(iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON);
148 writel(iiscon, s3c24xx_i2s.regs + S3C2410_IISCON);
149 } else {
150 /* note, we have to disable the FIFOs otherwise bad things
151 * seem to happen when the DMA stops. According to the
152 * Samsung supplied kernel, this should allow the DMA
153 * engine and FIFOs to reset. If this isn't allowed, the
154 * DMA engine will simply freeze randomly.
155 */
156
157 iisfcon &= ~S3C2410_IISFCON_RXENABLE;
158 iisfcon &= ~S3C2410_IISFCON_RXDMA;
159 iiscon |= S3C2410_IISCON_RXIDLE;
160 iiscon &= ~S3C2410_IISCON_RXDMAEN;
161 iismod &= ~S3C2410_IISMOD_RXMODE;
162
163 writel(iisfcon, s3c24xx_i2s.regs + S3C2410_IISFCON);
164 writel(iiscon, s3c24xx_i2s.regs + S3C2410_IISCON);
165 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
166 }
167
168 DBG("w: IISCON: %lx IISMOD: %lx IISFCON: %lx\n", iiscon, iismod, iisfcon);
169}
170
171/*
172 * Wait for the LR signal to allow synchronisation to the L/R clock
173 * from the codec. May only be needed for slave mode.
174 */
175static int s3c24xx_snd_lrsync(void)
176{
177 u32 iiscon;
178 unsigned long timeout = jiffies + msecs_to_jiffies(5);
179
180 DBG("Entered %s\n", __FUNCTION__);
181
182 while (1) {
183 iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON);
184 if (iiscon & S3C2410_IISCON_LRINDEX)
185 break;
186
187 if (timeout < jiffies)
188 return -ETIMEDOUT;
189 }
190
191 return 0;
192}
193
194/*
195 * Check whether CPU is the master or slave
196 */
197static inline int s3c24xx_snd_is_clkmaster(void)
198{
199 DBG("Entered %s\n", __FUNCTION__);
200
201 return (readl(s3c24xx_i2s.regs + S3C2410_IISMOD) & S3C2410_IISMOD_SLAVE) ? 0:1;
202}
203
204/*
205 * Set S3C24xx I2S DAI format
206 */
207static int s3c24xx_i2s_set_fmt(struct snd_soc_cpu_dai *cpu_dai,
208 unsigned int fmt)
209{
210 u32 iismod;
211
212 DBG("Entered %s\n", __FUNCTION__);
213
214 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
215 DBG("hw_params r: IISMOD: %lx \n", iismod);
216
217 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
218 case SND_SOC_DAIFMT_CBM_CFM:
219 iismod |= S3C2410_IISMOD_SLAVE;
220 break;
221 case SND_SOC_DAIFMT_CBS_CFS:
222 break;
223 default:
224 return -EINVAL;
225 }
226
227 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
228 case SND_SOC_DAIFMT_LEFT_J:
229 iismod |= S3C2410_IISMOD_MSB;
230 break;
231 case SND_SOC_DAIFMT_I2S:
232 break;
233 default:
234 return -EINVAL;
235 }
236
237 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
238 DBG("hw_params w: IISMOD: %lx \n", iismod);
239 return 0;
240}
241
242static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream,
243 struct snd_pcm_hw_params *params)
244{
245 struct snd_soc_pcm_runtime *rtd = substream->private_data;
246 u32 iismod;
247
248 DBG("Entered %s\n", __FUNCTION__);
249
250 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
251 rtd->dai->cpu_dai->dma_data = &s3c24xx_i2s_pcm_stereo_out;
252 else
253 rtd->dai->cpu_dai->dma_data = &s3c24xx_i2s_pcm_stereo_in;
254
255 /* Working copies of register */
256 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
257 DBG("hw_params r: IISMOD: %lx\n", iismod);
258
259 switch (params_format(params)) {
260 case SNDRV_PCM_FORMAT_S8:
261 break;
262 case SNDRV_PCM_FORMAT_S16_LE:
263 iismod |= S3C2410_IISMOD_16BIT;
264 break;
265 }
266
267 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
268 DBG("hw_params w: IISMOD: %lx\n", iismod);
269 return 0;
270}
271
272static int s3c24xx_i2s_trigger(struct snd_pcm_substream *substream, int cmd)
273{
274 int ret = 0;
275
276 DBG("Entered %s\n", __FUNCTION__);
277
278 switch (cmd) {
279 case SNDRV_PCM_TRIGGER_START:
280 case SNDRV_PCM_TRIGGER_RESUME:
281 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
282 if (!s3c24xx_snd_is_clkmaster()) {
283 ret = s3c24xx_snd_lrsync();
284 if (ret)
285 goto exit_err;
286 }
287
288 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
289 s3c24xx_snd_rxctrl(1);
290 else
291 s3c24xx_snd_txctrl(1);
292 break;
293 case SNDRV_PCM_TRIGGER_STOP:
294 case SNDRV_PCM_TRIGGER_SUSPEND:
295 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
296 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
297 s3c24xx_snd_rxctrl(0);
298 else
299 s3c24xx_snd_txctrl(0);
300 break;
301 default:
302 ret = -EINVAL;
303 break;
304 }
305
306exit_err:
307 return ret;
308}
309
310/*
311 * Set S3C24xx Clock source
312 */
313static int s3c24xx_i2s_set_sysclk(struct snd_soc_cpu_dai *cpu_dai,
314 int clk_id, unsigned int freq, int dir)
315{
316 u32 iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
317
318 DBG("Entered %s\n", __FUNCTION__);
319
320 iismod &= ~S3C2440_IISMOD_MPLL;
321
322 switch (clk_id) {
323 case S3C24XX_CLKSRC_PCLK:
324 break;
325 case S3C24XX_CLKSRC_MPLL:
326 iismod |= S3C2440_IISMOD_MPLL;
327 break;
328 default:
329 return -EINVAL;
330 }
331
332 writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
333 return 0;
334}
335
336/*
337 * Set S3C24xx Clock dividers
338 */
339static int s3c24xx_i2s_set_clkdiv(struct snd_soc_cpu_dai *cpu_dai,
340 int div_id, int div)
341{
342 u32 reg;
343
344 DBG("Entered %s\n", __FUNCTION__);
345
346 switch (div_id) {
347 case S3C24XX_DIV_MCLK:
348 reg = readl(s3c24xx_i2s.regs + S3C2410_IISMOD) & ~S3C2410_IISMOD_FS_MASK;
349 writel(reg | div, s3c24xx_i2s.regs + S3C2410_IISMOD);
350 break;
351 case S3C24XX_DIV_BCLK:
352 reg = readl(s3c24xx_i2s.regs + S3C2410_IISMOD) & ~(S3C2410_IISMOD_384FS);
353 writel(reg | div, s3c24xx_i2s.regs + S3C2410_IISMOD);
354 break;
355 case S3C24XX_DIV_PRESCALER:
356 writel(div, s3c24xx_i2s.regs + S3C2410_IISPSR);
357 reg = readl(s3c24xx_i2s.regs + S3C2410_IISCON);
358 writel(reg | S3C2410_IISCON_PSCEN, s3c24xx_i2s.regs + S3C2410_IISCON);
359 break;
360 default:
361 return -EINVAL;
362 }
363
364 return 0;
365}
366
367/*
368 * To avoid duplicating clock code, allow machine driver to
369 * get the clockrate from here.
370 */
371u32 s3c24xx_i2s_get_clockrate(void)
372{
373 return clk_get_rate(s3c24xx_i2s.iis_clk);
374}
375EXPORT_SYMBOL_GPL(s3c24xx_i2s_get_clockrate);
376
377static int s3c24xx_i2s_probe(struct platform_device *pdev)
378{
379 DBG("Entered %s\n", __FUNCTION__);
380
381 s3c24xx_i2s.regs = ioremap(S3C2410_PA_IIS, 0x100);
382 if (s3c24xx_i2s.regs == NULL)
383 return -ENXIO;
384
385 s3c24xx_i2s.iis_clk=clk_get(&pdev->dev, "iis");
386 if (s3c24xx_i2s.iis_clk == NULL) {
387 DBG("failed to get iis_clock\n");
388 return -ENODEV;
389 }
390 clk_enable(s3c24xx_i2s.iis_clk);
391
392 /* Configure the I2S pins in correct mode */
393 s3c2410_gpio_cfgpin(S3C2410_GPE0, S3C2410_GPE0_I2SLRCK);
394 s3c2410_gpio_cfgpin(S3C2410_GPE1, S3C2410_GPE1_I2SSCLK);
395 s3c2410_gpio_cfgpin(S3C2410_GPE2, S3C2410_GPE2_CDCLK);
396 s3c2410_gpio_cfgpin(S3C2410_GPE3, S3C2410_GPE3_I2SSDI);
397 s3c2410_gpio_cfgpin(S3C2410_GPE4, S3C2410_GPE4_I2SSDO);
398
399 writel(S3C2410_IISCON_IISEN, s3c24xx_i2s.regs + S3C2410_IISCON);
400
401 s3c24xx_snd_txctrl(0);
402 s3c24xx_snd_rxctrl(0);
403
404 return 0;
405}
406
407#define S3C24XX_I2S_RATES \
408 (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_16000 | \
409 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \
410 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
411
412struct snd_soc_cpu_dai s3c24xx_i2s_dai = {
413 .name = "s3c24xx-i2s",
414 .id = 0,
415 .type = SND_SOC_DAI_I2S,
416 .probe = s3c24xx_i2s_probe,
417 .playback = {
418 .channels_min = 2,
419 .channels_max = 2,
420 .rates = S3C24XX_I2S_RATES,
421 .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE,},
422 .capture = {
423 .channels_min = 2,
424 .channels_max = 2,
425 .rates = S3C24XX_I2S_RATES,
426 .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE,},
427 .ops = {
428 .trigger = s3c24xx_i2s_trigger,
429 .hw_params = s3c24xx_i2s_hw_params,},
430 .dai_ops = {
431 .set_fmt = s3c24xx_i2s_set_fmt,
432 .set_clkdiv = s3c24xx_i2s_set_clkdiv,
433 .set_sysclk = s3c24xx_i2s_set_sysclk,
434 },
435};
436EXPORT_SYMBOL_GPL(s3c24xx_i2s_dai);
437
438/* Module information */
439MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>");
440MODULE_DESCRIPTION("s3c24xx I2S SoC Interface");
441MODULE_LICENSE("GPL");
diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.h b/sound/soc/s3c24xx/s3c24xx-i2s.h
new file mode 100644
index 000000000000..537b4ecce8a3
--- /dev/null
+++ b/sound/soc/s3c24xx/s3c24xx-i2s.h
@@ -0,0 +1,37 @@
1/*
2 * s3c24xx-i2s.c -- ALSA Soc Audio Layer
3 *
4 * Copyright 2005 Wolfson Microelectronics PLC.
5 * Author: Graeme Gregory
6 * graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * Revision history
14 * 10th Nov 2006 Initial version.
15 */
16
17#ifndef S3C24XXI2S_H_
18#define S3C24XXI2S_H_
19
20/* clock sources */
21#define S3C24XX_CLKSRC_PCLK 0
22#define S3C24XX_CLKSRC_MPLL 1
23
24/* Clock dividers */
25#define S3C24XX_DIV_MCLK 0
26#define S3C24XX_DIV_BCLK 1
27#define S3C24XX_DIV_PRESCALER 2
28
29/* prescaler */
30#define S3C24XX_PRESCALE(a,b) \
31 (((a - 1) << S3C2410_IISPSR_INTSHIFT) | ((b - 1) << S3C2410_IISPSR_EXTSHFIT))
32
33u32 s3c24xx_i2s_get_clockrate(void);
34
35extern struct snd_soc_cpu_dai s3c24xx_i2s_dai;
36
37#endif /*S3C24XXI2S_H_*/
diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.c b/sound/soc/s3c24xx/s3c24xx-pcm.c
new file mode 100644
index 000000000000..21dc6974d6a3
--- /dev/null
+++ b/sound/soc/s3c24xx/s3c24xx-pcm.c
@@ -0,0 +1,468 @@
1/*
2 * s3c24xx-pcm.c -- ALSA Soc Audio Layer
3 *
4 * (c) 2006 Wolfson Microelectronics PLC.
5 * Graeme Gregory graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com
6 *
7 * (c) 2004-2005 Simtec Electronics
8 * http://armlinux.simtec.co.uk/
9 * Ben Dooks <ben@simtec.co.uk>
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 * Revision history
17 * 11th Dec 2006 Merged with Simtec driver
18 * 10th Nov 2006 Initial version.
19 */
20
21#include <linux/module.h>
22#include <linux/init.h>
23#include <linux/platform_device.h>
24#include <linux/slab.h>
25#include <linux/dma-mapping.h>
26
27#include <sound/driver.h>
28#include <sound/core.h>
29#include <sound/pcm.h>
30#include <sound/pcm_params.h>
31#include <sound/soc.h>
32
33#include <asm/dma.h>
34#include <asm/io.h>
35#include <asm/hardware.h>
36#include <asm/arch/dma.h>
37#include <asm/arch/audio.h>
38
39#include "s3c24xx-pcm.h"
40
41#define S3C24XX_PCM_DEBUG 0
42#if S3C24XX_PCM_DEBUG
43#define DBG(x...) printk(KERN_DEBUG x)
44#else
45#define DBG(x...)
46#endif
47
48static const struct snd_pcm_hardware s3c24xx_pcm_hardware = {
49 .info = SNDRV_PCM_INFO_INTERLEAVED |
50 SNDRV_PCM_INFO_BLOCK_TRANSFER |
51 SNDRV_PCM_INFO_MMAP |
52 SNDRV_PCM_INFO_MMAP_VALID,
53 .formats = SNDRV_PCM_FMTBIT_S16_LE |
54 SNDRV_PCM_FMTBIT_U16_LE |
55 SNDRV_PCM_FMTBIT_U8 |
56 SNDRV_PCM_FMTBIT_S8,
57 .channels_min = 2,
58 .channels_max = 2,
59 .buffer_bytes_max = 128*1024,
60 .period_bytes_min = PAGE_SIZE,
61 .period_bytes_max = PAGE_SIZE*2,
62 .periods_min = 2,
63 .periods_max = 128,
64 .fifo_size = 32,
65};
66
67struct s3c24xx_runtime_data {
68 spinlock_t lock;
69 int state;
70 unsigned int dma_loaded;
71 unsigned int dma_limit;
72 unsigned int dma_period;
73 dma_addr_t dma_start;
74 dma_addr_t dma_pos;
75 dma_addr_t dma_end;
76 struct s3c24xx_pcm_dma_params *params;
77};
78
79/* s3c24xx_pcm_enqueue
80 *
81 * place a dma buffer onto the queue for the dma system
82 * to handle.
83*/
84static void s3c24xx_pcm_enqueue(struct snd_pcm_substream *substream)
85{
86 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
87 dma_addr_t pos = prtd->dma_pos;
88 int ret;
89
90 DBG("Entered %s\n", __FUNCTION__);
91
92 while (prtd->dma_loaded < prtd->dma_limit) {
93 unsigned long len = prtd->dma_period;
94
95 DBG("dma_loaded: %d\n",prtd->dma_loaded);
96
97 if ((pos + len) > prtd->dma_end) {
98 len = prtd->dma_end - pos;
99 DBG(KERN_DEBUG "%s: corrected dma len %ld\n",
100 __FUNCTION__, len);
101 }
102
103 ret = s3c2410_dma_enqueue(prtd->params->channel,
104 substream, pos, len);
105
106 if (ret == 0) {
107 prtd->dma_loaded++;
108 pos += prtd->dma_period;
109 if (pos >= prtd->dma_end)
110 pos = prtd->dma_start;
111 } else
112 break;
113 }
114
115 prtd->dma_pos = pos;
116}
117
118static void s3c24xx_audio_buffdone(struct s3c2410_dma_chan *channel,
119 void *dev_id, int size,
120 enum s3c2410_dma_buffresult result)
121{
122 struct snd_pcm_substream *substream = dev_id;
123 struct s3c24xx_runtime_data *prtd;
124
125 DBG("Entered %s\n", __FUNCTION__);
126
127 if (result == S3C2410_RES_ABORT || result == S3C2410_RES_ERR)
128 return;
129
130 prtd = substream->runtime->private_data;
131
132 if (substream)
133 snd_pcm_period_elapsed(substream);
134
135 spin_lock(&prtd->lock);
136 if (prtd->state & ST_RUNNING) {
137 prtd->dma_loaded--;
138 s3c24xx_pcm_enqueue(substream);
139 }
140
141 spin_unlock(&prtd->lock);
142}
143
144static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream,
145 struct snd_pcm_hw_params *params)
146{
147 struct snd_pcm_runtime *runtime = substream->runtime;
148 struct s3c24xx_runtime_data *prtd = runtime->private_data;
149 struct snd_soc_pcm_runtime *rtd = substream->private_data;
150 struct s3c24xx_pcm_dma_params *dma = rtd->dai->cpu_dai->dma_data;
151 unsigned long totbytes = params_buffer_bytes(params);
152 int ret=0;
153
154 DBG("Entered %s\n", __FUNCTION__);
155
156 /* return if this is a bufferless transfer e.g.
157 * codec <--> BT codec or GSM modem -- lg FIXME */
158 if (!dma)
159 return 0;
160
161 /* prepare DMA */
162 prtd->params = dma;
163
164 DBG("params %p, client %p, channel %d\n", prtd->params,
165 prtd->params->client, prtd->params->channel);
166
167 ret = s3c2410_dma_request(prtd->params->channel,
168 prtd->params->client, NULL);
169
170 if (ret) {
171 DBG(KERN_ERR "failed to get dma channel\n");
172 return ret;
173 }
174
175 /* channel needs configuring for mem=>device, increment memory addr,
176 * sync to pclk, half-word transfers to the IIS-FIFO. */
177 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
178 s3c2410_dma_devconfig(prtd->params->channel,
179 S3C2410_DMASRC_MEM, S3C2410_DISRCC_INC |
180 S3C2410_DISRCC_APB, prtd->params->dma_addr);
181
182 s3c2410_dma_config(prtd->params->channel,
183 prtd->params->dma_size,
184 S3C2410_DCON_SYNC_PCLK |
185 S3C2410_DCON_HANDSHAKE);
186 } else {
187 s3c2410_dma_config(prtd->params->channel,
188 prtd->params->dma_size,
189 S3C2410_DCON_HANDSHAKE |
190 S3C2410_DCON_SYNC_PCLK);
191
192 s3c2410_dma_devconfig(prtd->params->channel,
193 S3C2410_DMASRC_HW, 0x3,
194 prtd->params->dma_addr);
195 }
196
197 s3c2410_dma_set_buffdone_fn(prtd->params->channel,
198 s3c24xx_audio_buffdone);
199
200 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
201
202 runtime->dma_bytes = totbytes;
203
204 spin_lock_irq(&prtd->lock);
205 prtd->dma_loaded = 0;
206 prtd->dma_limit = runtime->hw.periods_min;
207 prtd->dma_period = params_period_bytes(params);
208 prtd->dma_start = runtime->dma_addr;
209 prtd->dma_pos = prtd->dma_start;
210 prtd->dma_end = prtd->dma_start + totbytes;
211 spin_unlock_irq(&prtd->lock);
212
213 return 0;
214}
215
216static int s3c24xx_pcm_hw_free(struct snd_pcm_substream *substream)
217{
218 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
219
220 DBG("Entered %s\n", __FUNCTION__);
221
222 /* TODO - do we need to ensure DMA flushed */
223 snd_pcm_set_runtime_buffer(substream, NULL);
224
225 if (prtd->params) {
226 s3c2410_dma_free(prtd->params->channel, prtd->params->client);
227 prtd->params = NULL;
228 }
229
230 return 0;
231}
232
233static int s3c24xx_pcm_prepare(struct snd_pcm_substream *substream)
234{
235 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
236 int ret = 0;
237
238 DBG("Entered %s\n", __FUNCTION__);
239
240 /* return if this is a bufferless transfer e.g.
241 * codec <--> BT codec or GSM modem -- lg FIXME */
242 if (!prtd->params)
243 return 0;
244
245 /* flush the DMA channel */
246 s3c2410_dma_ctrl(prtd->params->channel, S3C2410_DMAOP_FLUSH);
247 prtd->dma_loaded = 0;
248 prtd->dma_pos = prtd->dma_start;
249
250 /* enqueue dma buffers */
251 s3c24xx_pcm_enqueue(substream);
252
253 return ret;
254}
255
256static int s3c24xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
257{
258 struct s3c24xx_runtime_data *prtd = substream->runtime->private_data;
259 int ret = 0;
260
261 DBG("Entered %s\n", __FUNCTION__);
262
263 spin_lock(&prtd->lock);
264
265 switch (cmd) {
266 case SNDRV_PCM_TRIGGER_START:
267 case SNDRV_PCM_TRIGGER_RESUME:
268 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
269 prtd->state |= ST_RUNNING;
270 s3c2410_dma_ctrl(prtd->params->channel, S3C2410_DMAOP_START);
271 s3c2410_dma_ctrl(prtd->params->channel, S3C2410_DMAOP_STARTED);
272 break;
273
274 case SNDRV_PCM_TRIGGER_STOP:
275 case SNDRV_PCM_TRIGGER_SUSPEND:
276 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
277 prtd->state &= ~ST_RUNNING;
278 s3c2410_dma_ctrl(prtd->params->channel, S3C2410_DMAOP_STOP);
279 break;
280
281 default:
282 ret = -EINVAL;
283 break;
284 }
285
286 spin_unlock(&prtd->lock);
287
288 return ret;
289}
290
291static snd_pcm_uframes_t
292 s3c24xx_pcm_pointer(struct snd_pcm_substream *substream)
293{
294 struct snd_pcm_runtime *runtime = substream->runtime;
295 struct s3c24xx_runtime_data *prtd = runtime->private_data;
296 unsigned long res;
297 dma_addr_t src, dst;
298
299 DBG("Entered %s\n", __FUNCTION__);
300
301 spin_lock(&prtd->lock);
302 s3c2410_dma_getposition(prtd->params->channel, &src, &dst);
303
304 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
305 res = dst - prtd->dma_start;
306 else
307 res = src - prtd->dma_start;
308
309 spin_unlock(&prtd->lock);
310
311 DBG("Pointer %x %x\n",src,dst);
312
313 /* we seem to be getting the odd error from the pcm library due
314 * to out-of-bounds pointers. this is maybe due to the dma engine
315 * not having loaded the new values for the channel before being
316 * callled... (todo - fix )
317 */
318
319 if (res >= snd_pcm_lib_buffer_bytes(substream)) {
320 if (res == snd_pcm_lib_buffer_bytes(substream))
321 res = 0;
322 }
323
324 return bytes_to_frames(substream->runtime, res);
325}
326
327static int s3c24xx_pcm_open(struct snd_pcm_substream *substream)
328{
329 struct snd_pcm_runtime *runtime = substream->runtime;
330 struct s3c24xx_runtime_data *prtd;
331
332 DBG("Entered %s\n", __FUNCTION__);
333
334 snd_soc_set_runtime_hwparams(substream, &s3c24xx_pcm_hardware);
335
336 prtd = kzalloc(sizeof(struct s3c24xx_runtime_data), GFP_KERNEL);
337 if (prtd == NULL)
338 return -ENOMEM;
339
340 runtime->private_data = prtd;
341 return 0;
342}
343
344static int s3c24xx_pcm_close(struct snd_pcm_substream *substream)
345{
346 struct snd_pcm_runtime *runtime = substream->runtime;
347 struct s3c24xx_runtime_data *prtd = runtime->private_data;
348
349 DBG("Entered %s\n", __FUNCTION__);
350
351 if (prtd)
352 kfree(prtd);
353 else
354 DBG("s3c24xx_pcm_close called with prtd == NULL\n");
355
356 return 0;
357}
358
359static int s3c24xx_pcm_mmap(struct snd_pcm_substream *substream,
360 struct vm_area_struct *vma)
361{
362 struct snd_pcm_runtime *runtime = substream->runtime;
363
364 DBG("Entered %s\n", __FUNCTION__);
365
366 return dma_mmap_writecombine(substream->pcm->card->dev, vma,
367 runtime->dma_area,
368 runtime->dma_addr,
369 runtime->dma_bytes);
370}
371
372static struct snd_pcm_ops s3c24xx_pcm_ops = {
373 .open = s3c24xx_pcm_open,
374 .close = s3c24xx_pcm_close,
375 .ioctl = snd_pcm_lib_ioctl,
376 .hw_params = s3c24xx_pcm_hw_params,
377 .hw_free = s3c24xx_pcm_hw_free,
378 .prepare = s3c24xx_pcm_prepare,
379 .trigger = s3c24xx_pcm_trigger,
380 .pointer = s3c24xx_pcm_pointer,
381 .mmap = s3c24xx_pcm_mmap,
382};
383
384static int s3c24xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream)
385{
386 struct snd_pcm_substream *substream = pcm->streams[stream].substream;
387 struct snd_dma_buffer *buf = &substream->dma_buffer;
388 size_t size = s3c24xx_pcm_hardware.buffer_bytes_max;
389
390 DBG("Entered %s\n", __FUNCTION__);
391
392 buf->dev.type = SNDRV_DMA_TYPE_DEV;
393 buf->dev.dev = pcm->card->dev;
394 buf->private_data = NULL;
395 buf->area = dma_alloc_writecombine(pcm->card->dev, size,
396 &buf->addr, GFP_KERNEL);
397 if (!buf->area)
398 return -ENOMEM;
399 buf->bytes = size;
400 return 0;
401}
402
403static void s3c24xx_pcm_free_dma_buffers(struct snd_pcm *pcm)
404{
405 struct snd_pcm_substream *substream;
406 struct snd_dma_buffer *buf;
407 int stream;
408
409 DBG("Entered %s\n", __FUNCTION__);
410
411 for (stream = 0; stream < 2; stream++) {
412 substream = pcm->streams[stream].substream;
413 if (!substream)
414 continue;
415
416 buf = &substream->dma_buffer;
417 if (!buf->area)
418 continue;
419
420 dma_free_writecombine(pcm->card->dev, buf->bytes,
421 buf->area, buf->addr);
422 buf->area = NULL;
423 }
424}
425
426static u64 s3c24xx_pcm_dmamask = DMA_32BIT_MASK;
427
428static int s3c24xx_pcm_new(struct snd_card *card,
429 struct snd_soc_codec_dai *dai, struct snd_pcm *pcm)
430{
431 int ret = 0;
432
433 DBG("Entered %s\n", __FUNCTION__);
434
435 if (!card->dev->dma_mask)
436 card->dev->dma_mask = &s3c24xx_pcm_dmamask;
437 if (!card->dev->coherent_dma_mask)
438 card->dev->coherent_dma_mask = 0xffffffff;
439
440 if (dai->playback.channels_min) {
441 ret = s3c24xx_pcm_preallocate_dma_buffer(pcm,
442 SNDRV_PCM_STREAM_PLAYBACK);
443 if (ret)
444 goto out;
445 }
446
447 if (dai->capture.channels_min) {
448 ret = s3c24xx_pcm_preallocate_dma_buffer(pcm,
449 SNDRV_PCM_STREAM_CAPTURE);
450 if (ret)
451 goto out;
452 }
453 out:
454 return ret;
455}
456
457struct snd_soc_platform s3c24xx_soc_platform = {
458 .name = "s3c24xx-audio",
459 .pcm_ops = &s3c24xx_pcm_ops,
460 .pcm_new = s3c24xx_pcm_new,
461 .pcm_free = s3c24xx_pcm_free_dma_buffers,
462};
463
464EXPORT_SYMBOL_GPL(s3c24xx_soc_platform);
465
466MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>");
467MODULE_DESCRIPTION("Samsung S3C24XX PCM DMA module");
468MODULE_LICENSE("GPL");
diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.h b/sound/soc/s3c24xx/s3c24xx-pcm.h
new file mode 100644
index 000000000000..0088c79822ea
--- /dev/null
+++ b/sound/soc/s3c24xx/s3c24xx-pcm.h
@@ -0,0 +1,31 @@
1/*
2 * s3c24xx-pcm.h --
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * ALSA PCM interface for the Samsung S3C24xx CPU
10 */
11
12#ifndef _S3C24XX_PCM_H
13#define _S3C24XX_PCM_H
14
15#define ST_RUNNING (1<<0)
16#define ST_OPENED (1<<1)
17
18struct s3c24xx_pcm_dma_params {
19 struct s3c2410_dma_client *client; /* stream identifier */
20 int channel; /* Channel ID */
21 dma_addr_t dma_addr;
22 int dma_size; /* Size of the DMA transfer */
23};
24
25#define S3C24XX_DAI_I2S 0
26
27/* platform data */
28extern struct snd_soc_platform s3c24xx_soc_platform;
29extern struct snd_ac97_bus_ops s3c24xx_ac97_ops;
30
31#endif
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 7caf8c7b0ac5..96bce55572a0 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -882,13 +882,15 @@ int snd_soc_dapm_connect_input(struct snd_soc_codec *codec, const char *sink,
882 if (wsink->id == snd_soc_dapm_input) { 882 if (wsink->id == snd_soc_dapm_input) {
883 if (wsource->id == snd_soc_dapm_micbias || 883 if (wsource->id == snd_soc_dapm_micbias ||
884 wsource->id == snd_soc_dapm_mic || 884 wsource->id == snd_soc_dapm_mic ||
885 wsink->id == snd_soc_dapm_line) 885 wsink->id == snd_soc_dapm_line ||
886 wsink->id == snd_soc_dapm_output)
886 wsink->ext = 1; 887 wsink->ext = 1;
887 } 888 }
888 if (wsource->id == snd_soc_dapm_output) { 889 if (wsource->id == snd_soc_dapm_output) {
889 if (wsink->id == snd_soc_dapm_spk || 890 if (wsink->id == snd_soc_dapm_spk ||
890 wsink->id == snd_soc_dapm_hp || 891 wsink->id == snd_soc_dapm_hp ||
891 wsink->id == snd_soc_dapm_line) 892 wsink->id == snd_soc_dapm_line ||
893 wsink->id == snd_soc_dapm_input)
892 wsource->ext = 1; 894 wsource->ext = 1;
893 } 895 }
894 896
diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c
index 900a00de35fd..dca0344cc1bc 100644
--- a/sound/sparc/cs4231.c
+++ b/sound/sparc/cs4231.c
@@ -661,11 +661,9 @@ static int snd_cs4231_trigger(struct snd_pcm_substream *substream, int cmd)
661 { 661 {
662 unsigned int what = 0; 662 unsigned int what = 0;
663 struct snd_pcm_substream *s; 663 struct snd_pcm_substream *s;
664 struct list_head *pos;
665 unsigned long flags; 664 unsigned long flags;
666 665
667 snd_pcm_group_for_each(pos, substream) { 666 snd_pcm_group_for_each_entry(s, substream) {
668 s = snd_pcm_group_substream_entry(pos);
669 if (s == chip->playback_substream) { 667 if (s == chip->playback_substream) {
670 what |= CS4231_PLAYBACK_ENABLE; 668 what |= CS4231_PLAYBACK_ENABLE;
671 snd_pcm_trigger_done(s, substream); 669 snd_pcm_trigger_done(s, substream);
diff --git a/sound/usb/Kconfig b/sound/usb/Kconfig
index f05d02f5b69f..315360f31278 100644
--- a/sound/usb/Kconfig
+++ b/sound/usb/Kconfig
@@ -29,5 +29,33 @@ config SND_USB_USX2Y
29 To compile this driver as a module, choose M here: the module 29 To compile this driver as a module, choose M here: the module
30 will be called snd-usb-usx2y. 30 will be called snd-usb-usx2y.
31 31
32config SND_USB_CAIAQ
33 tristate "Native Instruments USB audio devices"
34 depends on SND && USB
35 select SND_HWDEP
36 select SND_RAWMIDI
37 select SND_PCM
38 help
39 Say Y here to include support for caiaq USB audio interfaces,
40 namely:
41
42 * Native Instruments RigKontrol2
43 * Native Instruments Kore Controller
44 * Native Instruments Audio Kontrol 1
45 * Native Instruments Audio 8 DJ
46
47 To compile this driver as a module, choose M here: the module
48 will be called snd-usb-caiaq.
49
50config SND_USB_CAIAQ_INPUT
51 bool "enable input device for controllers"
52 depends on SND_USB_CAIAQ
53 help
54 Say Y here to support input controllers like buttons, knobs,
55 alpha dials and analog pedals on the following products:
56
57 * Native Instruments RigKontrol2
58 * Native Instruments Audio Kontrol 1
59
32endmenu 60endmenu
33 61
diff --git a/sound/usb/Makefile b/sound/usb/Makefile
index 2c1dc11a72e2..aa252ef2ebfb 100644
--- a/sound/usb/Makefile
+++ b/sound/usb/Makefile
@@ -9,4 +9,4 @@ snd-usb-lib-objs := usbmidi.o
9obj-$(CONFIG_SND_USB_AUDIO) += snd-usb-audio.o snd-usb-lib.o 9obj-$(CONFIG_SND_USB_AUDIO) += snd-usb-audio.o snd-usb-lib.o
10obj-$(CONFIG_SND_USB_USX2Y) += snd-usb-lib.o 10obj-$(CONFIG_SND_USB_USX2Y) += snd-usb-lib.o
11 11
12obj-$(CONFIG_SND) += usx2y/ 12obj-$(CONFIG_SND) += usx2y/ caiaq/
diff --git a/sound/usb/caiaq/Makefile b/sound/usb/caiaq/Makefile
new file mode 100644
index 000000000000..455c8c58a1bd
--- /dev/null
+++ b/sound/usb/caiaq/Makefile
@@ -0,0 +1,3 @@
1snd-usb-caiaq-objs := caiaq-device.o caiaq-audio.o caiaq-midi.o caiaq-input.o
2
3obj-$(CONFIG_SND_USB_CAIAQ) += snd-usb-caiaq.o
diff --git a/sound/usb/caiaq/caiaq-audio.c b/sound/usb/caiaq/caiaq-audio.c
new file mode 100644
index 000000000000..0414d766ba07
--- /dev/null
+++ b/sound/usb/caiaq/caiaq-audio.c
@@ -0,0 +1,707 @@
1/*
2 * Copyright (c) 2006,2007 Daniel Mack, Karsten Wiese
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19#include <sound/driver.h>
20#include <linux/init.h>
21#include <linux/module.h>
22#include <linux/moduleparam.h>
23#include <linux/interrupt.h>
24#include <linux/usb.h>
25#include <linux/spinlock.h>
26#include <sound/core.h>
27#include <sound/initval.h>
28#include <sound/pcm.h>
29#include <sound/rawmidi.h>
30#ifdef CONFIG_SND_USB_CAIAQ_INPUT
31#include <linux/input.h>
32#endif
33
34#include "caiaq-device.h"
35#include "caiaq-audio.h"
36
37#define N_URBS 32
38#define CLOCK_DRIFT_TOLERANCE 5
39#define FRAMES_PER_URB 8
40#define BYTES_PER_FRAME 512
41#define CHANNELS_PER_STREAM 2
42#define BYTES_PER_SAMPLE 3
43#define BYTES_PER_SAMPLE_USB 4
44#define MAX_BUFFER_SIZE (128*1024)
45
46#define ENDPOINT_CAPTURE 2
47#define ENDPOINT_PLAYBACK 6
48
49#define MAKE_CHECKBYTE(dev,stream,i) \
50 (stream << 1) | (~(i / (dev->n_streams * BYTES_PER_SAMPLE_USB)) & 1)
51
52static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = {
53 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
54 SNDRV_PCM_INFO_BLOCK_TRANSFER),
55 .formats = SNDRV_PCM_FMTBIT_S24_3BE,
56 .rates = (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
57 SNDRV_PCM_RATE_96000),
58 .rate_min = 44100,
59 .rate_max = 0, /* will overwrite later */
60 .channels_min = CHANNELS_PER_STREAM,
61 .channels_max = CHANNELS_PER_STREAM,
62 .buffer_bytes_max = MAX_BUFFER_SIZE,
63 .period_bytes_min = 4096,
64 .period_bytes_max = MAX_BUFFER_SIZE,
65 .periods_min = 1,
66 .periods_max = 1024,
67};
68
69static void
70activate_substream(struct snd_usb_caiaqdev *dev,
71 struct snd_pcm_substream *sub)
72{
73 if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
74 dev->sub_playback[sub->number] = sub;
75 else
76 dev->sub_capture[sub->number] = sub;
77}
78
79static void
80deactivate_substream(struct snd_usb_caiaqdev *dev,
81 struct snd_pcm_substream *sub)
82{
83 if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
84 dev->sub_playback[sub->number] = NULL;
85 else
86 dev->sub_capture[sub->number] = NULL;
87}
88
89static int
90all_substreams_zero(struct snd_pcm_substream **subs)
91{
92 int i;
93 for (i = 0; i < MAX_STREAMS; i++)
94 if (subs[i] != NULL)
95 return 0;
96 return 1;
97}
98
99static int stream_start(struct snd_usb_caiaqdev *dev)
100{
101 int i, ret;
102
103 debug("stream_start(%p)\n", dev);
104 spin_lock_irq(&dev->spinlock);
105 if (dev->streaming) {
106 spin_unlock_irq(&dev->spinlock);
107 return -EINVAL;
108 }
109
110 dev->input_panic = 0;
111 dev->output_panic = 0;
112 dev->first_packet = 1;
113 dev->streaming = 1;
114
115 for (i = 0; i < N_URBS; i++) {
116 ret = usb_submit_urb(dev->data_urbs_in[i], GFP_ATOMIC);
117 if (ret) {
118 log("unable to trigger initial read #%d! (ret = %d)\n",
119 i, ret);
120 dev->streaming = 0;
121 spin_unlock_irq(&dev->spinlock);
122 return -EPIPE;
123 }
124 }
125
126 spin_unlock_irq(&dev->spinlock);
127 return 0;
128}
129
130static void stream_stop(struct snd_usb_caiaqdev *dev)
131{
132 int i;
133
134 debug("stream_stop(%p)\n", dev);
135 if (!dev->streaming)
136 return;
137
138 dev->streaming = 0;
139 for (i = 0; i < N_URBS; i++) {
140 usb_unlink_urb(dev->data_urbs_in[i]);
141 usb_unlink_urb(dev->data_urbs_out[i]);
142 }
143}
144
145static int snd_usb_caiaq_substream_open(struct snd_pcm_substream *substream)
146{
147 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream);
148 debug("snd_usb_caiaq_substream_open(%p)\n", substream);
149 substream->runtime->hw = dev->pcm_info;
150 snd_pcm_limit_hw_rates(substream->runtime);
151 return 0;
152}
153
154static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream)
155{
156 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream);
157
158 debug("snd_usb_caiaq_substream_close(%p)\n", substream);
159 if (all_substreams_zero(dev->sub_playback) &&
160 all_substreams_zero(dev->sub_capture)) {
161 /* when the last client has stopped streaming,
162 * all sample rates are allowed again */
163 stream_stop(dev);
164 dev->pcm_info.rates = dev->samplerates;
165 }
166
167 return 0;
168}
169
170static int snd_usb_caiaq_pcm_hw_params(struct snd_pcm_substream *sub,
171 struct snd_pcm_hw_params *hw_params)
172{
173 debug("snd_usb_caiaq_pcm_hw_params(%p)\n", sub);
174 return snd_pcm_lib_malloc_pages(sub, params_buffer_bytes(hw_params));
175}
176
177static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub)
178{
179 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub);
180 debug("snd_usb_caiaq_pcm_hw_free(%p)\n", sub);
181 spin_lock_irq(&dev->spinlock);
182 deactivate_substream(dev, sub);
183 spin_unlock_irq(&dev->spinlock);
184 return snd_pcm_lib_free_pages(sub);
185}
186
187/* this should probably go upstream */
188#if SNDRV_PCM_RATE_5512 != 1 << 0 || SNDRV_PCM_RATE_192000 != 1 << 12
189#error "Change this table"
190#endif
191
192static unsigned int rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100,
193 48000, 64000, 88200, 96000, 176400, 192000 };
194
195static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream)
196{
197 int bytes_per_sample, bpp, ret, i;
198 int index = substream->number;
199 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream);
200 struct snd_pcm_runtime *runtime = substream->runtime;
201
202 debug("snd_usb_caiaq_pcm_prepare(%p)\n", substream);
203
204 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
205 dev->audio_out_buf_pos[index] = BYTES_PER_SAMPLE + 1;
206 else
207 dev->audio_in_buf_pos[index] = 0;
208
209 if (dev->streaming)
210 return 0;
211
212 /* the first client that opens a stream defines the sample rate
213 * setting for all subsequent calls, until the last client closed. */
214 for (i=0; i < ARRAY_SIZE(rates); i++)
215 if (runtime->rate == rates[i])
216 dev->pcm_info.rates = 1 << i;
217
218 snd_pcm_limit_hw_rates(runtime);
219
220 bytes_per_sample = BYTES_PER_SAMPLE;
221 if (dev->spec.data_alignment == 2)
222 bytes_per_sample++;
223
224 bpp = ((runtime->rate / 8000) + CLOCK_DRIFT_TOLERANCE)
225 * bytes_per_sample * CHANNELS_PER_STREAM * dev->n_streams;
226
227 ret = snd_usb_caiaq_set_audio_params(dev, runtime->rate,
228 runtime->sample_bits, bpp);
229 if (ret)
230 return ret;
231
232 ret = stream_start(dev);
233 if (ret)
234 return ret;
235
236 dev->output_running = 0;
237 wait_event_timeout(dev->prepare_wait_queue, dev->output_running, HZ);
238 if (!dev->output_running) {
239 stream_stop(dev);
240 return -EPIPE;
241 }
242
243 return 0;
244}
245
246static int snd_usb_caiaq_pcm_trigger(struct snd_pcm_substream *sub, int cmd)
247{
248 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub);
249
250 switch (cmd) {
251 case SNDRV_PCM_TRIGGER_START:
252 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
253 spin_lock(&dev->spinlock);
254 activate_substream(dev, sub);
255 spin_unlock(&dev->spinlock);
256 break;
257 case SNDRV_PCM_TRIGGER_STOP:
258 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
259 spin_lock(&dev->spinlock);
260 deactivate_substream(dev, sub);
261 spin_unlock(&dev->spinlock);
262 break;
263 default:
264 return -EINVAL;
265 }
266
267 return 0;
268}
269
270static snd_pcm_uframes_t
271snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub)
272{
273 int index = sub->number;
274 struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub);
275
276 if (dev->input_panic || dev->output_panic)
277 return SNDRV_PCM_POS_XRUN;
278
279 if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
280 return bytes_to_frames(sub->runtime,
281 dev->audio_out_buf_pos[index]);
282 else
283 return bytes_to_frames(sub->runtime,
284 dev->audio_in_buf_pos[index]);
285}
286
287/* operators for both playback and capture */
288static struct snd_pcm_ops snd_usb_caiaq_ops = {
289 .open = snd_usb_caiaq_substream_open,
290 .close = snd_usb_caiaq_substream_close,
291 .ioctl = snd_pcm_lib_ioctl,
292 .hw_params = snd_usb_caiaq_pcm_hw_params,
293 .hw_free = snd_usb_caiaq_pcm_hw_free,
294 .prepare = snd_usb_caiaq_pcm_prepare,
295 .trigger = snd_usb_caiaq_pcm_trigger,
296 .pointer = snd_usb_caiaq_pcm_pointer
297};
298
299static void check_for_elapsed_periods(struct snd_usb_caiaqdev *dev,
300 struct snd_pcm_substream **subs)
301{
302 int stream, pb, *cnt;
303 struct snd_pcm_substream *sub;
304
305 for (stream = 0; stream < dev->n_streams; stream++) {
306 sub = subs[stream];
307 if (!sub)
308 continue;
309
310 pb = frames_to_bytes(sub->runtime,
311 sub->runtime->period_size);
312 cnt = (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
313 &dev->period_out_count[stream] :
314 &dev->period_in_count[stream];
315
316 if (*cnt >= pb) {
317 snd_pcm_period_elapsed(sub);
318 *cnt %= pb;
319 }
320 }
321}
322
323static void read_in_urb_mode0(struct snd_usb_caiaqdev *dev,
324 const struct urb *urb,
325 const struct usb_iso_packet_descriptor *iso)
326{
327 unsigned char *usb_buf = urb->transfer_buffer + iso->offset;
328 struct snd_pcm_substream *sub;
329 int stream, i;
330
331 if (all_substreams_zero(dev->sub_capture))
332 return;
333
334 spin_lock(&dev->spinlock);
335
336 for (i = 0; i < iso->actual_length;) {
337 for (stream = 0; stream < dev->n_streams; stream++, i++) {
338 sub = dev->sub_capture[stream];
339 if (sub) {
340 struct snd_pcm_runtime *rt = sub->runtime;
341 char *audio_buf = rt->dma_area;
342 int sz = frames_to_bytes(rt, rt->buffer_size);
343 audio_buf[dev->audio_in_buf_pos[stream]++]
344 = usb_buf[i];
345 dev->period_in_count[stream]++;
346 if (dev->audio_in_buf_pos[stream] == sz)
347 dev->audio_in_buf_pos[stream] = 0;
348 }
349 }
350 }
351
352 spin_unlock(&dev->spinlock);
353}
354
355static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev,
356 const struct urb *urb,
357 const struct usb_iso_packet_descriptor *iso)
358{
359 unsigned char *usb_buf = urb->transfer_buffer + iso->offset;
360 unsigned char check_byte;
361 struct snd_pcm_substream *sub;
362 int stream, i;
363
364 spin_lock(&dev->spinlock);
365
366 for (i = 0; i < iso->actual_length;) {
367 if (i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == 0) {
368 for (stream = 0;
369 stream < dev->n_streams;
370 stream++, i++) {
371 if (dev->first_packet)
372 continue;
373
374 check_byte = MAKE_CHECKBYTE(dev, stream, i);
375
376 if ((usb_buf[i] & 0x3f) != check_byte)
377 dev->input_panic = 1;
378
379 if (usb_buf[i] & 0x80)
380 dev->output_panic = 1;
381 }
382 }
383 dev->first_packet = 0;
384
385 for (stream = 0; stream < dev->n_streams; stream++, i++) {
386 sub = dev->sub_capture[stream];
387 if (sub) {
388 struct snd_pcm_runtime *rt = sub->runtime;
389 char *audio_buf = rt->dma_area;
390 int sz = frames_to_bytes(rt, rt->buffer_size);
391 audio_buf[dev->audio_in_buf_pos[stream]++] =
392 usb_buf[i];
393 dev->period_in_count[stream]++;
394 if (dev->audio_in_buf_pos[stream] == sz)
395 dev->audio_in_buf_pos[stream] = 0;
396 }
397 }
398 }
399
400 spin_unlock(&dev->spinlock);
401}
402
403static void read_in_urb(struct snd_usb_caiaqdev *dev,
404 const struct urb *urb,
405 const struct usb_iso_packet_descriptor *iso)
406{
407 if (!dev->streaming)
408 return;
409
410 switch (dev->spec.data_alignment) {
411 case 0:
412 read_in_urb_mode0(dev, urb, iso);
413 break;
414 case 2:
415 read_in_urb_mode2(dev, urb, iso);
416 break;
417 }
418
419 if (dev->input_panic || dev->output_panic) {
420 debug("streaming error detected %s %s\n",
421 dev->input_panic ? "(input)" : "",
422 dev->output_panic ? "(output)" : "");
423 }
424
425 check_for_elapsed_periods(dev, dev->sub_capture);
426}
427
428static void fill_out_urb(struct snd_usb_caiaqdev *dev,
429 struct urb *urb,
430 const struct usb_iso_packet_descriptor *iso)
431{
432 unsigned char *usb_buf = urb->transfer_buffer + iso->offset;
433 struct snd_pcm_substream *sub;
434 int stream, i;
435
436 spin_lock(&dev->spinlock);
437
438 for (i = 0; i < iso->length;) {
439 for (stream = 0; stream < dev->n_streams; stream++, i++) {
440 sub = dev->sub_playback[stream];
441 if (sub) {
442 struct snd_pcm_runtime *rt = sub->runtime;
443 char *audio_buf = rt->dma_area;
444 int sz = frames_to_bytes(rt, rt->buffer_size);
445 usb_buf[i] =
446 audio_buf[dev->audio_out_buf_pos[stream]];
447 dev->period_out_count[stream]++;
448 dev->audio_out_buf_pos[stream]++;
449 if (dev->audio_out_buf_pos[stream] == sz)
450 dev->audio_out_buf_pos[stream] = 0;
451 } else
452 usb_buf[i] = 0;
453 }
454
455 /* fill in the check bytes */
456 if (dev->spec.data_alignment == 2 &&
457 i % (dev->n_streams * BYTES_PER_SAMPLE_USB) ==
458 (dev->n_streams * CHANNELS_PER_STREAM))
459 for (stream = 0; stream < dev->n_streams; stream++, i++)
460 usb_buf[i] = MAKE_CHECKBYTE(dev, stream, i);
461 }
462
463 spin_unlock(&dev->spinlock);
464 check_for_elapsed_periods(dev, dev->sub_playback);
465}
466
467static void read_completed(struct urb *urb)
468{
469 struct snd_usb_caiaq_cb_info *info = urb->context;
470 struct snd_usb_caiaqdev *dev;
471 struct urb *out;
472 int frame, len, send_it = 0, outframe = 0;
473
474 if (urb->status || !info)
475 return;
476
477 dev = info->dev;
478 if (!dev->streaming)
479 return;
480
481 out = dev->data_urbs_out[info->index];
482
483 /* read the recently received packet and send back one which has
484 * the same layout */
485 for (frame = 0; frame < FRAMES_PER_URB; frame++) {
486 if (urb->iso_frame_desc[frame].status)
487 continue;
488
489 len = urb->iso_frame_desc[outframe].actual_length;
490 out->iso_frame_desc[outframe].length = len;
491 out->iso_frame_desc[outframe].actual_length = 0;
492 out->iso_frame_desc[outframe].offset = BYTES_PER_FRAME * frame;
493
494 if (len > 0) {
495 fill_out_urb(dev, out, &out->iso_frame_desc[outframe]);
496 read_in_urb(dev, urb, &urb->iso_frame_desc[frame]);
497 send_it = 1;
498 }
499
500 outframe++;
501 }
502
503 if (send_it) {
504 out->number_of_packets = FRAMES_PER_URB;
505 out->transfer_flags = URB_ISO_ASAP;
506 usb_submit_urb(out, GFP_ATOMIC);
507 }
508
509 /* re-submit inbound urb */
510 for (frame = 0; frame < FRAMES_PER_URB; frame++) {
511 urb->iso_frame_desc[frame].offset = BYTES_PER_FRAME * frame;
512 urb->iso_frame_desc[frame].length = BYTES_PER_FRAME;
513 urb->iso_frame_desc[frame].actual_length = 0;
514 }
515
516 urb->number_of_packets = FRAMES_PER_URB;
517 urb->transfer_flags = URB_ISO_ASAP;
518 usb_submit_urb(urb, GFP_ATOMIC);
519}
520
521static void write_completed(struct urb *urb)
522{
523 struct snd_usb_caiaq_cb_info *info = urb->context;
524 struct snd_usb_caiaqdev *dev = info->dev;
525
526 if (!dev->output_running) {
527 dev->output_running = 1;
528 wake_up(&dev->prepare_wait_queue);
529 }
530}
531
532static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret)
533{
534 int i, frame;
535 struct urb **urbs;
536 struct usb_device *usb_dev = dev->chip.dev;
537 unsigned int pipe;
538
539 pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ?
540 usb_sndisocpipe(usb_dev, ENDPOINT_PLAYBACK) :
541 usb_rcvisocpipe(usb_dev, ENDPOINT_CAPTURE);
542
543 urbs = kmalloc(N_URBS * sizeof(*urbs), GFP_KERNEL);
544 if (!urbs) {
545 log("unable to kmalloc() urbs, OOM!?\n");
546 *ret = -ENOMEM;
547 return NULL;
548 }
549
550 for (i = 0; i < N_URBS; i++) {
551 urbs[i] = usb_alloc_urb(FRAMES_PER_URB, GFP_KERNEL);
552 if (!urbs[i]) {
553 log("unable to usb_alloc_urb(), OOM!?\n");
554 *ret = -ENOMEM;
555 return urbs;
556 }
557
558 urbs[i]->transfer_buffer =
559 kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL);
560 if (!urbs[i]->transfer_buffer) {
561 log("unable to kmalloc() transfer buffer, OOM!?\n");
562 *ret = -ENOMEM;
563 return urbs;
564 }
565
566 for (frame = 0; frame < FRAMES_PER_URB; frame++) {
567 struct usb_iso_packet_descriptor *iso =
568 &urbs[i]->iso_frame_desc[frame];
569
570 iso->offset = BYTES_PER_FRAME * frame;
571 iso->length = BYTES_PER_FRAME;
572 }
573
574 urbs[i]->dev = usb_dev;
575 urbs[i]->pipe = pipe;
576 urbs[i]->transfer_buffer_length = FRAMES_PER_URB
577 * BYTES_PER_FRAME;
578 urbs[i]->context = &dev->data_cb_info[i];
579 urbs[i]->interval = 1;
580 urbs[i]->transfer_flags = URB_ISO_ASAP;
581 urbs[i]->number_of_packets = FRAMES_PER_URB;
582 urbs[i]->complete = (dir == SNDRV_PCM_STREAM_CAPTURE) ?
583 read_completed : write_completed;
584 }
585
586 *ret = 0;
587 return urbs;
588}
589
590static void free_urbs(struct urb **urbs)
591{
592 int i;
593
594 if (!urbs)
595 return;
596
597 for (i = 0; i < N_URBS; i++) {
598 if (!urbs[i])
599 continue;
600
601 usb_kill_urb(urbs[i]);
602 kfree(urbs[i]->transfer_buffer);
603 usb_free_urb(urbs[i]);
604 }
605
606 kfree(urbs);
607}
608
609int __devinit snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev)
610{
611 int i, ret;
612
613 dev->n_audio_in = max(dev->spec.num_analog_audio_in,
614 dev->spec.num_digital_audio_in) /
615 CHANNELS_PER_STREAM;
616 dev->n_audio_out = max(dev->spec.num_analog_audio_out,
617 dev->spec.num_digital_audio_out) /
618 CHANNELS_PER_STREAM;
619 dev->n_streams = max(dev->n_audio_in, dev->n_audio_out);
620
621 debug("dev->n_audio_in = %d\n", dev->n_audio_in);
622 debug("dev->n_audio_out = %d\n", dev->n_audio_out);
623 debug("dev->n_streams = %d\n", dev->n_streams);
624
625 if (dev->n_streams > MAX_STREAMS) {
626 log("unable to initialize device, too many streams.\n");
627 return -EINVAL;
628 }
629
630 ret = snd_pcm_new(dev->chip.card, dev->product_name, 0,
631 dev->n_audio_out, dev->n_audio_in, &dev->pcm);
632
633 if (ret < 0) {
634 log("snd_pcm_new() returned %d\n", ret);
635 return ret;
636 }
637
638 dev->pcm->private_data = dev;
639 strcpy(dev->pcm->name, dev->product_name);
640
641 memset(dev->sub_playback, 0, sizeof(dev->sub_playback));
642 memset(dev->sub_capture, 0, sizeof(dev->sub_capture));
643
644 memcpy(&dev->pcm_info, &snd_usb_caiaq_pcm_hardware,
645 sizeof(snd_usb_caiaq_pcm_hardware));
646
647 /* setup samplerates */
648 dev->samplerates = dev->pcm_info.rates;
649 switch (dev->chip.usb_id) {
650 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
651 dev->samplerates |= SNDRV_PCM_RATE_88200;
652 dev->samplerates |= SNDRV_PCM_RATE_192000;
653 break;
654 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
655 dev->samplerates |= SNDRV_PCM_RATE_88200;
656 break;
657 }
658
659 snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_PLAYBACK,
660 &snd_usb_caiaq_ops);
661 snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_CAPTURE,
662 &snd_usb_caiaq_ops);
663
664 snd_pcm_lib_preallocate_pages_for_all(dev->pcm,
665 SNDRV_DMA_TYPE_CONTINUOUS,
666 snd_dma_continuous_data(GFP_KERNEL),
667 MAX_BUFFER_SIZE, MAX_BUFFER_SIZE);
668
669 dev->data_cb_info =
670 kmalloc(sizeof(struct snd_usb_caiaq_cb_info) * N_URBS,
671 GFP_KERNEL);
672
673 if (!dev->data_cb_info)
674 return -ENOMEM;
675
676 for (i = 0; i < N_URBS; i++) {
677 dev->data_cb_info[i].dev = dev;
678 dev->data_cb_info[i].index = i;
679 }
680
681 dev->data_urbs_in = alloc_urbs(dev, SNDRV_PCM_STREAM_CAPTURE, &ret);
682 if (ret < 0) {
683 kfree(dev->data_cb_info);
684 free_urbs(dev->data_urbs_in);
685 return ret;
686 }
687
688 dev->data_urbs_out = alloc_urbs(dev, SNDRV_PCM_STREAM_PLAYBACK, &ret);
689 if (ret < 0) {
690 kfree(dev->data_cb_info);
691 free_urbs(dev->data_urbs_in);
692 free_urbs(dev->data_urbs_out);
693 return ret;
694 }
695
696 return 0;
697}
698
699void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *dev)
700{
701 debug("snd_usb_caiaq_audio_free (%p)\n", dev);
702 stream_stop(dev);
703 free_urbs(dev->data_urbs_in);
704 free_urbs(dev->data_urbs_out);
705 kfree(dev->data_cb_info);
706}
707
diff --git a/sound/usb/caiaq/caiaq-audio.h b/sound/usb/caiaq/caiaq-audio.h
new file mode 100644
index 000000000000..8ab1f8d9529e
--- /dev/null
+++ b/sound/usb/caiaq/caiaq-audio.h
@@ -0,0 +1,7 @@
1#ifndef CAIAQ_AUDIO_H
2#define CAIAQ_AUDIO_H
3
4int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev);
5void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *dev);
6
7#endif /* CAIAQ_AUDIO_H */
diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/caiaq-device.c
new file mode 100644
index 000000000000..4709347326f9
--- /dev/null
+++ b/sound/usb/caiaq/caiaq-device.c
@@ -0,0 +1,436 @@
1/*
2 * caiaq.c: ALSA driver for caiaq/NativeInstruments devices
3 *
4 * Copyright (c) 2007 Daniel Mack <daniel@caiaq.de>
5 * Karsten Wiese <fzu@wemgehoertderstaat.de>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20*/
21
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/moduleparam.h>
25#include <linux/interrupt.h>
26#include <linux/usb.h>
27#include <linux/input.h>
28#include <linux/spinlock.h>
29#include <sound/driver.h>
30#include <sound/core.h>
31#include <sound/initval.h>
32#include <sound/pcm.h>
33#include <sound/rawmidi.h>
34
35#include "caiaq-device.h"
36#include "caiaq-audio.h"
37#include "caiaq-midi.h"
38
39#ifdef CONFIG_SND_USB_CAIAQ_INPUT
40#include "caiaq-input.h"
41#endif
42
43MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
44MODULE_DESCRIPTION("caiaq USB audio, version 1.1.0");
45MODULE_LICENSE("GPL");
46MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2},"
47 "{Native Instruments, Kore Controller},"
48 "{Native Instruments, Audio Kontrol 1}"
49 "{Native Instruments, Audio 8 DJ}}");
50
51static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-max */
52static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */
53static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
54static int snd_card_used[SNDRV_CARDS];
55
56module_param_array(index, int, NULL, 0444);
57MODULE_PARM_DESC(index, "Index value for the caiaq sound device");
58module_param_array(id, charp, NULL, 0444);
59MODULE_PARM_DESC(id, "ID string for the caiaq soundcard.");
60module_param_array(enable, bool, NULL, 0444);
61MODULE_PARM_DESC(enable, "Enable the caiaq soundcard.");
62
63enum {
64 SAMPLERATE_44100 = 0,
65 SAMPLERATE_48000 = 1,
66 SAMPLERATE_96000 = 2,
67 SAMPLERATE_192000 = 3,
68 SAMPLERATE_88200 = 4,
69 SAMPLERATE_INVALID = 0xff
70};
71
72enum {
73 DEPTH_NONE = 0,
74 DEPTH_16 = 1,
75 DEPTH_24 = 2,
76 DEPTH_32 = 3
77};
78
79static struct usb_device_id snd_usb_id_table[] = {
80 {
81 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
82 .idVendor = USB_VID_NATIVEINSTRUMENTS,
83 .idProduct = USB_PID_RIGKONTROL2
84 },
85 {
86 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
87 .idVendor = USB_VID_NATIVEINSTRUMENTS,
88 .idProduct = USB_PID_KORECONTROLLER
89 },
90 {
91 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
92 .idVendor = USB_VID_NATIVEINSTRUMENTS,
93 .idProduct = USB_PID_AK1
94 },
95 {
96 .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
97 .idVendor = USB_VID_NATIVEINSTRUMENTS,
98 .idProduct = USB_PID_AUDIO8DJ
99 },
100 { /* terminator */ }
101};
102
103static void usb_ep1_command_reply_dispatch (struct urb* urb)
104{
105 int ret;
106 struct snd_usb_caiaqdev *dev = urb->context;
107 unsigned char *buf = urb->transfer_buffer;
108
109 if (urb->status || !dev) {
110 log("received EP1 urb->status = %i\n", urb->status);
111 return;
112 }
113
114 switch(buf[0]) {
115 case EP1_CMD_GET_DEVICE_INFO:
116 memcpy(&dev->spec, buf+1, sizeof(struct caiaq_device_spec));
117 dev->spec.fw_version = le16_to_cpu(dev->spec.fw_version);
118 debug("device spec (firmware %d): audio: %d in, %d out, "
119 "MIDI: %d in, %d out, data alignment %d\n",
120 dev->spec.fw_version,
121 dev->spec.num_analog_audio_in,
122 dev->spec.num_analog_audio_out,
123 dev->spec.num_midi_in,
124 dev->spec.num_midi_out,
125 dev->spec.data_alignment);
126
127 dev->spec_received++;
128 wake_up(&dev->ep1_wait_queue);
129 break;
130 case EP1_CMD_AUDIO_PARAMS:
131 dev->audio_parm_answer = buf[1];
132 wake_up(&dev->ep1_wait_queue);
133 break;
134 case EP1_CMD_MIDI_READ:
135 snd_usb_caiaq_midi_handle_input(dev, buf[1], buf + 3, buf[2]);
136 break;
137
138#ifdef CONFIG_SND_USB_CAIAQ_INPUT
139 case EP1_CMD_READ_ERP:
140 case EP1_CMD_READ_ANALOG:
141 case EP1_CMD_READ_IO:
142 snd_usb_caiaq_input_dispatch(dev, buf, urb->actual_length);
143 break;
144#endif
145 }
146
147 dev->ep1_in_urb.actual_length = 0;
148 ret = usb_submit_urb(&dev->ep1_in_urb, GFP_ATOMIC);
149 if (ret < 0)
150 log("unable to submit urb. OOM!?\n");
151}
152
153static int send_command (struct snd_usb_caiaqdev *dev,
154 unsigned char command,
155 const unsigned char *buffer,
156 int len)
157{
158 int actual_len;
159 struct usb_device *usb_dev = dev->chip.dev;
160
161 if (!usb_dev)
162 return -EIO;
163
164 if (len > EP1_BUFSIZE - 1)
165 len = EP1_BUFSIZE - 1;
166
167 if (buffer && len > 0)
168 memcpy(dev->ep1_out_buf+1, buffer, len);
169
170 dev->ep1_out_buf[0] = command;
171 return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1),
172 dev->ep1_out_buf, len+1, &actual_len, 200);
173}
174
175int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev,
176 int rate, int depth, int bpp)
177{
178 int ret;
179 char tmp[5];
180
181 switch (rate) {
182 case 44100: tmp[0] = SAMPLERATE_44100; break;
183 case 48000: tmp[0] = SAMPLERATE_48000; break;
184 case 88200: tmp[0] = SAMPLERATE_88200; break;
185 case 96000: tmp[0] = SAMPLERATE_96000; break;
186 case 192000: tmp[0] = SAMPLERATE_192000; break;
187 default: return -EINVAL;
188 }
189
190 switch (depth) {
191 case 16: tmp[1] = DEPTH_16; break;
192 case 24: tmp[1] = DEPTH_24; break;
193 default: return -EINVAL;
194 }
195
196 tmp[2] = bpp & 0xff;
197 tmp[3] = bpp >> 8;
198 tmp[4] = 1; /* packets per microframe */
199
200 debug("setting audio params: %d Hz, %d bits, %d bpp\n",
201 rate, depth, bpp);
202
203 dev->audio_parm_answer = -1;
204 ret = send_command(dev, EP1_CMD_AUDIO_PARAMS, tmp, sizeof(tmp));
205
206 if (ret)
207 return ret;
208
209 if (!wait_event_timeout(dev->ep1_wait_queue,
210 dev->audio_parm_answer >= 0, HZ))
211 return -EPIPE;
212
213 if (dev->audio_parm_answer != 1)
214 debug("unable to set the device's audio params\n");
215
216 return dev->audio_parm_answer == 1 ? 0 : -EINVAL;
217}
218
219int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev,
220 int digital, int analog, int erp)
221{
222 char tmp[3] = { digital, analog, erp };
223 return send_command(dev, EP1_CMD_AUTO_MSG, tmp, sizeof(tmp));
224}
225
226static void setup_card(struct snd_usb_caiaqdev *dev)
227{
228 int ret;
229 char val[3];
230
231 /* device-specific startup specials */
232 switch (dev->chip.usb_id) {
233 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
234 /* RigKontrol2 - display centered dash ('-') */
235 val[0] = 0x00;
236 val[1] = 0x00;
237 val[2] = 0x01;
238 send_command(dev, EP1_CMD_WRITE_IO, val, 3);
239 break;
240 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
241 /* Audio Kontrol 1 - make USB-LED stop blinking */
242 val[0] = 0x00;
243 send_command(dev, EP1_CMD_WRITE_IO, val, 1);
244 break;
245 }
246
247 ret = snd_usb_caiaq_audio_init(dev);
248 if (ret < 0)
249 log("Unable to set up audio system (ret=%d)\n", ret);
250
251 ret = snd_usb_caiaq_midi_init(dev);
252 if (ret < 0)
253 log("Unable to set up MIDI system (ret=%d)\n", ret);
254
255#ifdef CONFIG_SND_USB_CAIAQ_INPUT
256 ret = snd_usb_caiaq_input_init(dev);
257 if (ret < 0)
258 log("Unable to set up input system (ret=%d)\n", ret);
259#endif
260
261 /* finally, register the card and all its sub-instances */
262 ret = snd_card_register(dev->chip.card);
263 if (ret < 0) {
264 log("snd_card_register() returned %d\n", ret);
265 snd_card_free(dev->chip.card);
266 }
267}
268
269static struct snd_card* create_card(struct usb_device* usb_dev)
270{
271 int devnum;
272 struct snd_card *card;
273 struct snd_usb_caiaqdev *dev;
274
275 for (devnum = 0; devnum < SNDRV_CARDS; devnum++)
276 if (enable[devnum] && !snd_card_used[devnum])
277 break;
278
279 if (devnum >= SNDRV_CARDS)
280 return NULL;
281
282 card = snd_card_new(index[devnum], id[devnum], THIS_MODULE,
283 sizeof(struct snd_usb_caiaqdev));
284 if (!card)
285 return NULL;
286
287 dev = caiaqdev(card);
288 dev->chip.dev = usb_dev;
289 dev->chip.card = card;
290 dev->chip.usb_id = USB_ID(usb_dev->descriptor.idVendor,
291 usb_dev->descriptor.idProduct);
292 spin_lock_init(&dev->spinlock);
293 snd_card_set_dev(card, &usb_dev->dev);
294
295 return card;
296}
297
298static int init_card(struct snd_usb_caiaqdev *dev)
299{
300 char *c;
301 struct usb_device *usb_dev = dev->chip.dev;
302 struct snd_card *card = dev->chip.card;
303 int err, len;
304
305 if (usb_set_interface(usb_dev, 0, 1) != 0) {
306 log("can't set alt interface.\n");
307 return -EIO;
308 }
309
310 usb_init_urb(&dev->ep1_in_urb);
311 usb_init_urb(&dev->midi_out_urb);
312
313 usb_fill_bulk_urb(&dev->ep1_in_urb, usb_dev,
314 usb_rcvbulkpipe(usb_dev, 0x1),
315 dev->ep1_in_buf, EP1_BUFSIZE,
316 usb_ep1_command_reply_dispatch, dev);
317
318 usb_fill_bulk_urb(&dev->midi_out_urb, usb_dev,
319 usb_sndbulkpipe(usb_dev, 0x1),
320 dev->midi_out_buf, EP1_BUFSIZE,
321 snd_usb_caiaq_midi_output_done, dev);
322
323 init_waitqueue_head(&dev->ep1_wait_queue);
324 init_waitqueue_head(&dev->prepare_wait_queue);
325
326 if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0)
327 return -EIO;
328
329 err = send_command(dev, EP1_CMD_GET_DEVICE_INFO, NULL, 0);
330 if (err)
331 return err;
332
333 if (!wait_event_timeout(dev->ep1_wait_queue, dev->spec_received, HZ))
334 return -ENODEV;
335
336 usb_string(usb_dev, usb_dev->descriptor.iManufacturer,
337 dev->vendor_name, CAIAQ_USB_STR_LEN);
338
339 usb_string(usb_dev, usb_dev->descriptor.iProduct,
340 dev->product_name, CAIAQ_USB_STR_LEN);
341
342 usb_string(usb_dev, usb_dev->descriptor.iSerialNumber,
343 dev->serial, CAIAQ_USB_STR_LEN);
344
345 /* terminate serial string at first white space occurence */
346 c = strchr(dev->serial, ' ');
347 if (c)
348 *c = '\0';
349
350 strcpy(card->driver, MODNAME);
351 strcpy(card->shortname, dev->product_name);
352
353 len = snprintf(card->longname, sizeof(card->longname),
354 "%s %s (serial %s, ",
355 dev->vendor_name, dev->product_name, dev->serial);
356
357 if (len < sizeof(card->longname) - 2)
358 len += usb_make_path(usb_dev, card->longname + len,
359 sizeof(card->longname) - len);
360
361 card->longname[len++] = ')';
362 card->longname[len] = '\0';
363 setup_card(dev);
364 return 0;
365}
366
367static int snd_probe(struct usb_interface *intf,
368 const struct usb_device_id *id)
369{
370 int ret;
371 struct snd_card *card;
372 struct usb_device *device = interface_to_usbdev(intf);
373
374 card = create_card(device);
375
376 if (!card)
377 return -ENOMEM;
378
379 dev_set_drvdata(&intf->dev, card);
380 ret = init_card(caiaqdev(card));
381 if (ret < 0) {
382 log("unable to init card! (ret=%d)\n", ret);
383 snd_card_free(card);
384 return ret;
385 }
386
387 return 0;
388}
389
390static void snd_disconnect(struct usb_interface *intf)
391{
392 struct snd_usb_caiaqdev *dev;
393 struct snd_card *card = dev_get_drvdata(&intf->dev);
394
395 debug("snd_disconnect(%p)\n", intf);
396
397 if (!card)
398 return;
399
400 dev = caiaqdev(card);
401 snd_card_disconnect(card);
402
403#ifdef CONFIG_SND_USB_CAIAQ_INPUT
404 snd_usb_caiaq_input_free(dev);
405#endif
406 snd_usb_caiaq_audio_free(dev);
407
408 usb_kill_urb(&dev->ep1_in_urb);
409 usb_kill_urb(&dev->midi_out_urb);
410
411 snd_card_free(card);
412 usb_reset_device(interface_to_usbdev(intf));
413}
414
415
416MODULE_DEVICE_TABLE(usb, snd_usb_id_table);
417static struct usb_driver snd_usb_driver = {
418 .name = MODNAME,
419 .probe = snd_probe,
420 .disconnect = snd_disconnect,
421 .id_table = snd_usb_id_table,
422};
423
424static int __init snd_module_init(void)
425{
426 return usb_register(&snd_usb_driver);
427}
428
429static void __exit snd_module_exit(void)
430{
431 usb_deregister(&snd_usb_driver);
432}
433
434module_init(snd_module_init)
435module_exit(snd_module_exit)
436
diff --git a/sound/usb/caiaq/caiaq-device.h b/sound/usb/caiaq/caiaq-device.h
new file mode 100644
index 000000000000..088d5ec241f3
--- /dev/null
+++ b/sound/usb/caiaq/caiaq-device.h
@@ -0,0 +1,116 @@
1#ifndef CAIAQ_DEVICE_H
2#define CAIAQ_DEVICE_H
3
4#include "../usbaudio.h"
5
6#define USB_VID_NATIVEINSTRUMENTS 0x17cc
7
8#define USB_PID_RIGKONTROL2 0x1969
9#define USB_PID_KORECONTROLLER 0x4711
10#define USB_PID_AK1 0x0815
11#define USB_PID_AUDIO8DJ 0x1978
12
13#define EP1_BUFSIZE 64
14#define CAIAQ_USB_STR_LEN 0xff
15#define MAX_STREAMS 32
16
17//#define SND_USB_CAIAQ_DEBUG
18
19#define MODNAME "snd-usb-caiaq"
20#define log(x...) snd_printk(KERN_WARNING MODNAME" log: " x)
21
22#ifdef SND_USB_CAIAQ_DEBUG
23#define debug(x...) snd_printk(KERN_WARNING MODNAME " debug: " x)
24#else
25#define debug(x...) do { } while(0)
26#endif
27
28#define EP1_CMD_GET_DEVICE_INFO 0x1
29#define EP1_CMD_READ_ERP 0x2
30#define EP1_CMD_READ_ANALOG 0x3
31#define EP1_CMD_READ_IO 0x4
32#define EP1_CMD_WRITE_IO 0x5
33#define EP1_CMD_MIDI_READ 0x6
34#define EP1_CMD_MIDI_WRITE 0x7
35#define EP1_CMD_AUDIO_PARAMS 0x9
36#define EP1_CMD_AUTO_MSG 0xb
37
38struct caiaq_device_spec {
39 unsigned short fw_version;
40 unsigned char hw_subtype;
41 unsigned char num_erp;
42 unsigned char num_analog_in;
43 unsigned char num_digital_in;
44 unsigned char num_digital_out;
45 unsigned char num_analog_audio_out;
46 unsigned char num_analog_audio_in;
47 unsigned char num_digital_audio_out;
48 unsigned char num_digital_audio_in;
49 unsigned char num_midi_out;
50 unsigned char num_midi_in;
51 unsigned char data_alignment;
52} __attribute__ ((packed));
53
54struct snd_usb_caiaq_cb_info;
55
56struct snd_usb_caiaqdev {
57 struct snd_usb_audio chip;
58
59 struct urb ep1_in_urb;
60 struct urb midi_out_urb;
61 struct urb **data_urbs_in;
62 struct urb **data_urbs_out;
63 struct snd_usb_caiaq_cb_info *data_cb_info;
64
65 unsigned char ep1_in_buf[EP1_BUFSIZE];
66 unsigned char ep1_out_buf[EP1_BUFSIZE];
67 unsigned char midi_out_buf[EP1_BUFSIZE];
68
69 struct caiaq_device_spec spec;
70 spinlock_t spinlock;
71 wait_queue_head_t ep1_wait_queue;
72 wait_queue_head_t prepare_wait_queue;
73 int spec_received, audio_parm_answer;
74
75 char vendor_name[CAIAQ_USB_STR_LEN];
76 char product_name[CAIAQ_USB_STR_LEN];
77 char serial[CAIAQ_USB_STR_LEN];
78
79 int n_streams, n_audio_in, n_audio_out;
80 int streaming, first_packet, output_running;
81 int audio_in_buf_pos[MAX_STREAMS];
82 int audio_out_buf_pos[MAX_STREAMS];
83 int period_in_count[MAX_STREAMS];
84 int period_out_count[MAX_STREAMS];
85 int input_panic, output_panic;
86 char *audio_in_buf, *audio_out_buf;
87 unsigned int samplerates;
88
89 struct snd_pcm_substream *sub_playback[MAX_STREAMS];
90 struct snd_pcm_substream *sub_capture[MAX_STREAMS];
91
92 /* Linux input */
93#ifdef CONFIG_SND_USB_CAIAQ_INPUT
94 struct input_dev *input_dev;
95#endif
96
97 /* ALSA */
98 struct snd_pcm *pcm;
99 struct snd_pcm_hardware pcm_info;
100 struct snd_rawmidi *rmidi;
101 struct snd_rawmidi_substream *midi_receive_substream;
102 struct snd_rawmidi_substream *midi_out_substream;
103};
104
105struct snd_usb_caiaq_cb_info {
106 struct snd_usb_caiaqdev *dev;
107 int index;
108};
109
110#define caiaqdev(c) ((struct snd_usb_caiaqdev*)(c)->private_data)
111
112int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, int rate, int depth, int bbp);
113int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev, int digital, int analog, int erp);
114
115
116#endif /* CAIAQ_DEVICE_H */
diff --git a/sound/usb/caiaq/caiaq-input.c b/sound/usb/caiaq/caiaq-input.c
new file mode 100644
index 000000000000..3acd12db6952
--- /dev/null
+++ b/sound/usb/caiaq/caiaq-input.c
@@ -0,0 +1,246 @@
1/*
2 * Copyright (c) 2006,2007 Daniel Mack, Tim Ruetz
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19#include <linux/init.h>
20#include <linux/module.h>
21#include <linux/moduleparam.h>
22#include <linux/input.h>
23#include <linux/usb.h>
24#include <linux/spinlock.h>
25#include <sound/driver.h>
26#include <sound/core.h>
27#include <sound/rawmidi.h>
28#include <sound/pcm.h>
29#include "caiaq-device.h"
30#include "caiaq-input.h"
31
32#ifdef CONFIG_SND_USB_CAIAQ_INPUT
33
34static unsigned char keycode_ak1[] = { KEY_C, KEY_B, KEY_A };
35static unsigned char keycode_rk2[] = { KEY_1, KEY_2, KEY_3, KEY_4,
36 KEY_5, KEY_6, KEY_7 };
37
38#define DEG90 (range/2)
39#define DEG180 (range)
40#define DEG270 (DEG90 + DEG180)
41#define DEG360 (DEG180 * 2)
42#define HIGH_PEAK (268)
43#define LOW_PEAK (-7)
44
45/* some of these devices have endless rotation potentiometers
46 * built in which use two tapers, 90 degrees phase shifted.
47 * this algorithm decodes them to one single value, ranging
48 * from 0 to 999 */
49static unsigned int decode_erp(unsigned char a, unsigned char b)
50{
51 int weight_a, weight_b;
52 int pos_a, pos_b;
53 int ret;
54 int range = HIGH_PEAK - LOW_PEAK;
55 int mid_value = (HIGH_PEAK + LOW_PEAK) / 2;
56
57 weight_b = abs(mid_value-a) - (range/2 - 100)/2;
58
59 if (weight_b < 0)
60 weight_b = 0;
61
62 if (weight_b > 100)
63 weight_b = 100;
64
65 weight_a = 100 - weight_b;
66
67 if (a < mid_value) {
68 /* 0..90 and 270..360 degrees */
69 pos_b = b - LOW_PEAK + DEG270;
70 if (pos_b >= DEG360)
71 pos_b -= DEG360;
72 } else
73 /* 90..270 degrees */
74 pos_b = HIGH_PEAK - b + DEG90;
75
76
77 if (b > mid_value)
78 /* 0..180 degrees */
79 pos_a = a - LOW_PEAK;
80 else
81 /* 180..360 degrees */
82 pos_a = HIGH_PEAK - a + DEG180;
83
84 /* interpolate both slider values, depending on weight factors */
85 /* 0..99 x DEG360 */
86 ret = pos_a * weight_a + pos_b * weight_b;
87
88 /* normalize to 0..999 */
89 ret *= 10;
90 ret /= DEG360;
91
92 if (ret < 0)
93 ret += 1000;
94
95 if (ret >= 1000)
96 ret -= 1000;
97
98 return ret;
99}
100
101#undef DEG90
102#undef DEG180
103#undef DEG270
104#undef DEG360
105#undef HIGH_PEAK
106#undef LOW_PEAK
107
108
109static void snd_caiaq_input_read_analog(struct snd_usb_caiaqdev *dev,
110 const char *buf, unsigned int len)
111{
112 switch(dev->input_dev->id.product) {
113 case USB_PID_RIGKONTROL2:
114 input_report_abs(dev->input_dev, ABS_X, (buf[4] << 8) |buf[5]);
115 input_report_abs(dev->input_dev, ABS_Y, (buf[0] << 8) |buf[1]);
116 input_report_abs(dev->input_dev, ABS_Z, (buf[2] << 8) |buf[3]);
117 input_sync(dev->input_dev);
118 break;
119 }
120}
121
122static void snd_caiaq_input_read_erp(struct snd_usb_caiaqdev *dev,
123 const char *buf, unsigned int len)
124{
125 int i;
126
127 switch(dev->input_dev->id.product) {
128 case USB_PID_AK1:
129 i = decode_erp(buf[0], buf[1]);
130 input_report_abs(dev->input_dev, ABS_X, i);
131 input_sync(dev->input_dev);
132 break;
133 }
134}
135
136static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev,
137 char *buf, unsigned int len)
138{
139 int i;
140 unsigned char *keycode = dev->input_dev->keycode;
141
142 if (!keycode)
143 return;
144
145 if (dev->input_dev->id.product == USB_PID_RIGKONTROL2)
146 for (i=0; i<len; i++)
147 buf[i] = ~buf[i];
148
149 for (i=0; (i<dev->input_dev->keycodemax) && (i < len); i++)
150 input_report_key(dev->input_dev, keycode[i],
151 buf[i/8] & (1 << (i%8)));
152
153 input_sync(dev->input_dev);
154}
155
156void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *dev,
157 char *buf,
158 unsigned int len)
159{
160 if (!dev->input_dev || (len < 1))
161 return;
162
163 switch (buf[0]) {
164 case EP1_CMD_READ_ANALOG:
165 snd_caiaq_input_read_analog(dev, buf+1, len-1);
166 break;
167 case EP1_CMD_READ_ERP:
168 snd_caiaq_input_read_erp(dev, buf+1, len-1);
169 break;
170 case EP1_CMD_READ_IO:
171 snd_caiaq_input_read_io(dev, buf+1, len-1);
172 break;
173 }
174}
175
176int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev)
177{
178 struct usb_device *usb_dev = dev->chip.dev;
179 struct input_dev *input;
180 int i, ret;
181
182 input = input_allocate_device();
183 if (!input)
184 return -ENOMEM;
185
186 input->name = dev->product_name;
187 input->id.bustype = BUS_USB;
188 input->id.vendor = usb_dev->descriptor.idVendor;
189 input->id.product = usb_dev->descriptor.idProduct;
190 input->id.version = usb_dev->descriptor.bcdDevice;
191
192 switch (dev->chip.usb_id) {
193 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
194 input->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
195 input->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_Z);
196 input->keycode = keycode_rk2;
197 input->keycodesize = sizeof(char);
198 input->keycodemax = ARRAY_SIZE(keycode_rk2);
199 for (i=0; i<ARRAY_SIZE(keycode_rk2); i++)
200 set_bit(keycode_rk2[i], input->keybit);
201
202 input_set_abs_params(input, ABS_X, 0, 4096, 0, 10);
203 input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10);
204 input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10);
205 snd_usb_caiaq_set_auto_msg(dev, 1, 10, 0);
206 break;
207 case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
208 input->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
209 input->absbit[0] = BIT(ABS_X);
210 input->keycode = keycode_ak1;
211 input->keycodesize = sizeof(char);
212 input->keycodemax = ARRAY_SIZE(keycode_ak1);
213 for (i=0; i<ARRAY_SIZE(keycode_ak1); i++)
214 set_bit(keycode_ak1[i], input->keybit);
215
216 input_set_abs_params(input, ABS_X, 0, 999, 0, 10);
217 snd_usb_caiaq_set_auto_msg(dev, 1, 0, 5);
218 break;
219 default:
220 /* no input methods supported on this device */
221 input_free_device(input);
222 return 0;
223 }
224
225 ret = input_register_device(input);
226 if (ret < 0) {
227 input_free_device(input);
228 return ret;
229 }
230
231 dev->input_dev = input;
232 return 0;
233}
234
235void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *dev)
236{
237 if (!dev || !dev->input_dev)
238 return;
239
240 input_unregister_device(dev->input_dev);
241 input_free_device(dev->input_dev);
242 dev->input_dev = NULL;
243}
244
245#endif /* CONFIG_SND_USB_CAIAQ_INPUT */
246
diff --git a/sound/usb/caiaq/caiaq-input.h b/sound/usb/caiaq/caiaq-input.h
new file mode 100644
index 000000000000..ced535577864
--- /dev/null
+++ b/sound/usb/caiaq/caiaq-input.h
@@ -0,0 +1,8 @@
1#ifndef CAIAQ_INPUT_H
2#define CAIAQ_INPUT_H
3
4void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *dev, char *buf, unsigned int len);
5int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev);
6void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *dev);
7
8#endif
diff --git a/sound/usb/caiaq/caiaq-midi.c b/sound/usb/caiaq/caiaq-midi.c
new file mode 100644
index 000000000000..793ca20ce349
--- /dev/null
+++ b/sound/usb/caiaq/caiaq-midi.c
@@ -0,0 +1,177 @@
1/*
2 * Copyright (c) 2006,2007 Daniel Mack
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18
19#include <linux/init.h>
20#include <linux/module.h>
21#include <linux/moduleparam.h>
22#include <linux/interrupt.h>
23#include <linux/usb.h>
24#include <linux/input.h>
25#include <linux/spinlock.h>
26#include <sound/driver.h>
27#include <sound/core.h>
28#include <sound/rawmidi.h>
29#include <sound/pcm.h>
30
31#include "caiaq-device.h"
32#include "caiaq-midi.h"
33
34
35static int snd_usb_caiaq_midi_input_open(struct snd_rawmidi_substream *substream)
36{
37 return 0;
38}
39
40static int snd_usb_caiaq_midi_input_close(struct snd_rawmidi_substream *substream)
41{
42 return 0;
43}
44
45static void snd_usb_caiaq_midi_input_trigger(struct snd_rawmidi_substream *substream, int up)
46{
47 struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
48
49 if (!dev)
50 return;
51
52 dev->midi_receive_substream = up ? substream : NULL;
53}
54
55
56static int snd_usb_caiaq_midi_output_open(struct snd_rawmidi_substream *substream)
57{
58 return 0;
59}
60
61static int snd_usb_caiaq_midi_output_close(struct snd_rawmidi_substream *substream)
62{
63 return 0;
64}
65
66static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev,
67 struct snd_rawmidi_substream *substream)
68{
69 int len, ret;
70
71 dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
72 dev->midi_out_buf[1] = 0; /* port */
73 len = snd_rawmidi_transmit_peek(substream, dev->midi_out_buf+3, EP1_BUFSIZE-3);
74
75 if (len <= 0)
76 return;
77
78 dev->midi_out_buf[2] = len;
79 dev->midi_out_urb.transfer_buffer_length = len+3;
80
81 ret = usb_submit_urb(&dev->midi_out_urb, GFP_ATOMIC);
82 if (ret < 0)
83 log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed, %d\n",
84 substream, ret);
85}
86
87static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
88{
89 struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
90
91 if (dev->midi_out_substream != NULL)
92 return;
93
94 if (!up) {
95 dev->midi_out_substream = NULL;
96 return;
97 }
98
99 dev->midi_out_substream = substream;
100 snd_usb_caiaq_midi_send(dev, substream);
101}
102
103
104static struct snd_rawmidi_ops snd_usb_caiaq_midi_output =
105{
106 .open = snd_usb_caiaq_midi_output_open,
107 .close = snd_usb_caiaq_midi_output_close,
108 .trigger = snd_usb_caiaq_midi_output_trigger,
109};
110
111static struct snd_rawmidi_ops snd_usb_caiaq_midi_input =
112{
113 .open = snd_usb_caiaq_midi_input_open,
114 .close = snd_usb_caiaq_midi_input_close,
115 .trigger = snd_usb_caiaq_midi_input_trigger,
116};
117
118void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev,
119 int port, const char *buf, int len)
120{
121 if (!dev->midi_receive_substream)
122 return;
123
124 snd_rawmidi_receive(dev->midi_receive_substream, buf, len);
125}
126
127int __devinit snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device)
128{
129 int ret;
130 struct snd_rawmidi *rmidi;
131
132 ret = snd_rawmidi_new(device->chip.card, device->product_name, 0,
133 device->spec.num_midi_out,
134 device->spec.num_midi_in,
135 &rmidi);
136
137 if (ret < 0)
138 return ret;
139
140 strcpy(rmidi->name, device->product_name);
141
142 rmidi->info_flags = SNDRV_RAWMIDI_INFO_DUPLEX;
143 rmidi->private_data = device;
144
145 if (device->spec.num_midi_out > 0) {
146 rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT;
147 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT,
148 &snd_usb_caiaq_midi_output);
149 }
150
151 if (device->spec.num_midi_in > 0) {
152 rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT;
153 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT,
154 &snd_usb_caiaq_midi_input);
155 }
156
157 device->rmidi = rmidi;
158
159 return 0;
160}
161
162void snd_usb_caiaq_midi_output_done(struct urb* urb)
163{
164 struct snd_usb_caiaqdev *dev = urb->context;
165 char *buf = urb->transfer_buffer;
166
167 if (urb->status != 0)
168 return;
169
170 if (!dev->midi_out_substream)
171 return;
172
173 snd_rawmidi_transmit_ack(dev->midi_out_substream, buf[2]);
174 dev->midi_out_substream = NULL;
175 snd_usb_caiaq_midi_send(dev, dev->midi_out_substream);
176}
177
diff --git a/sound/usb/caiaq/caiaq-midi.h b/sound/usb/caiaq/caiaq-midi.h
new file mode 100644
index 000000000000..9d16db027fc3
--- /dev/null
+++ b/sound/usb/caiaq/caiaq-midi.h
@@ -0,0 +1,8 @@
1#ifndef CAIAQ_MIDI_H
2#define CAIAQ_MIDI_H
3
4int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *dev);
5void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev, int port, const char *buf, int len);
6void snd_usb_caiaq_midi_output_done(struct urb* urb);
7
8#endif /* CAIAQ_MIDI_H */
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index b6d886373bb0..8ebc1adb5ed9 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -1878,6 +1878,9 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre
1878 } 1878 }
1879 1879
1880 /* set the period time minimum 1ms */ 1880 /* set the period time minimum 1ms */
1881 /* FIXME: high-speed mode allows 125us minimum period, but many parts
1882 * in the current code assume the 1ms period.
1883 */
1881 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME, 1884 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME,
1882 1000 * MIN_PACKS_URB, 1885 1000 * MIN_PACKS_URB,
1883 /*(nrpacks * MAX_URBS) * 1000*/ UINT_MAX); 1886 /*(nrpacks * MAX_URBS) * 1000*/ UINT_MAX);
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
index 24f5a26c5f0c..99295f9b7691 100644
--- a/sound/usb/usbmidi.c
+++ b/sound/usb/usbmidi.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * usbmidi.c - ALSA USB MIDI driver 2 * usbmidi.c - ALSA USB MIDI driver
3 * 3 *
4 * Copyright (c) 2002-2005 Clemens Ladisch 4 * Copyright (c) 2002-2007 Clemens Ladisch
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Based on the OSS usb-midi driver by NAGANO Daisuke, 7 * Based on the OSS usb-midi driver by NAGANO Daisuke,
@@ -145,6 +145,7 @@ struct snd_usb_midi_in_endpoint {
145 struct urb* urb; 145 struct urb* urb;
146 struct usbmidi_in_port { 146 struct usbmidi_in_port {
147 struct snd_rawmidi_substream *substream; 147 struct snd_rawmidi_substream *substream;
148 u8 running_status_length;
148 } ports[0x10]; 149 } ports[0x10];
149 u8 seen_f5; 150 u8 seen_f5;
150 u8 error_resubmit; 151 u8 error_resubmit;
@@ -366,6 +367,46 @@ static void snd_usbmidi_midiman_input(struct snd_usb_midi_in_endpoint* ep,
366} 367}
367 368
368/* 369/*
370 * Buggy M-Audio device: running status on input results in a packet that has
371 * the data bytes but not the status byte and that is marked with CIN 4.
372 */
373static void snd_usbmidi_maudio_broken_running_status_input(
374 struct snd_usb_midi_in_endpoint* ep,
375 uint8_t* buffer, int buffer_length)
376{
377 int i;
378
379 for (i = 0; i + 3 < buffer_length; i += 4)
380 if (buffer[i] != 0) {
381 int cable = buffer[i] >> 4;
382 u8 cin = buffer[i] & 0x0f;
383 struct usbmidi_in_port *port = &ep->ports[cable];
384 int length;
385
386 length = snd_usbmidi_cin_length[cin];
387 if (cin == 0xf && buffer[i + 1] >= 0xf8)
388 ; /* realtime msg: no running status change */
389 else if (cin >= 0x8 && cin <= 0xe)
390 /* channel msg */
391 port->running_status_length = length - 1;
392 else if (cin == 0x4 &&
393 port->running_status_length != 0 &&
394 buffer[i + 1] < 0x80)
395 /* CIN 4 that is not a SysEx */
396 length = port->running_status_length;
397 else
398 /*
399 * All other msgs cannot begin running status.
400 * (A channel msg sent as two or three CIN 0xF
401 * packets could in theory, but this device
402 * doesn't use this format.)
403 */
404 port->running_status_length = 0;
405 snd_usbmidi_input_data(ep, cable, &buffer[i + 1], length);
406 }
407}
408
409/*
369 * Adds one USB MIDI packet to the output buffer. 410 * Adds one USB MIDI packet to the output buffer.
370 */ 411 */
371static void snd_usbmidi_output_standard_packet(struct urb* urb, uint8_t p0, 412static void snd_usbmidi_output_standard_packet(struct urb* urb, uint8_t p0,
@@ -525,6 +566,12 @@ static struct usb_protocol_ops snd_usbmidi_midiman_ops = {
525 .output_packet = snd_usbmidi_output_midiman_packet, 566 .output_packet = snd_usbmidi_output_midiman_packet,
526}; 567};
527 568
569static struct usb_protocol_ops snd_usbmidi_maudio_broken_running_status_ops = {
570 .input = snd_usbmidi_maudio_broken_running_status_input,
571 .output = snd_usbmidi_standard_output,
572 .output_packet = snd_usbmidi_output_standard_packet,
573};
574
528/* 575/*
529 * Novation USB MIDI protocol: number of data bytes is in the first byte 576 * Novation USB MIDI protocol: number of data bytes is in the first byte
530 * (when receiving) (+1!) or in the second byte (when sending); data begins 577 * (when receiving) (+1!) or in the second byte (when sending); data begins
@@ -918,7 +965,11 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi,
918 } 965 }
919 /* we never use interrupt output pipes */ 966 /* we never use interrupt output pipes */
920 pipe = usb_sndbulkpipe(umidi->chip->dev, ep_info->out_ep); 967 pipe = usb_sndbulkpipe(umidi->chip->dev, ep_info->out_ep);
921 ep->max_transfer = usb_maxpacket(umidi->chip->dev, pipe, 1); 968 if (umidi->chip->usb_id == USB_ID(0x0a92, 0x1020)) /* ESI M4U */
969 /* FIXME: we need more URBs to get reasonable bandwidth here: */
970 ep->max_transfer = 4;
971 else
972 ep->max_transfer = usb_maxpacket(umidi->chip->dev, pipe, 1);
922 buffer = usb_buffer_alloc(umidi->chip->dev, ep->max_transfer, 973 buffer = usb_buffer_alloc(umidi->chip->dev, ep->max_transfer,
923 GFP_KERNEL, &ep->urb->transfer_dma); 974 GFP_KERNEL, &ep->urb->transfer_dma);
924 if (!buffer) { 975 if (!buffer) {
@@ -1606,6 +1657,9 @@ int snd_usb_create_midi_interface(struct snd_usb_audio* chip,
1606 switch (quirk ? quirk->type : QUIRK_MIDI_STANDARD_INTERFACE) { 1657 switch (quirk ? quirk->type : QUIRK_MIDI_STANDARD_INTERFACE) {
1607 case QUIRK_MIDI_STANDARD_INTERFACE: 1658 case QUIRK_MIDI_STANDARD_INTERFACE:
1608 err = snd_usbmidi_get_ms_info(umidi, endpoints); 1659 err = snd_usbmidi_get_ms_info(umidi, endpoints);
1660 if (chip->usb_id == USB_ID(0x0763, 0x0150)) /* M-Audio Uno */
1661 umidi->usb_protocol_ops =
1662 &snd_usbmidi_maudio_broken_running_status_ops;
1609 break; 1663 break;
1610 case QUIRK_MIDI_FIXED_ENDPOINT: 1664 case QUIRK_MIDI_FIXED_ENDPOINT:
1611 memcpy(&endpoints[0], quirk->data, 1665 memcpy(&endpoints[0], quirk->data,
diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h
index 858262068f4f..8fcbe93b2589 100644
--- a/sound/usb/usbquirks.h
+++ b/sound/usb/usbquirks.h
@@ -40,6 +40,29 @@
40 .bInterfaceClass = USB_CLASS_VENDOR_SPEC 40 .bInterfaceClass = USB_CLASS_VENDOR_SPEC
41 41
42/* 42/*
43 * Logitech QuickCam: bDeviceClass is vendor-specific, so generic interface
44 * class matches do not take effect without an explicit ID match.
45 */
46{
47 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
48 USB_DEVICE_ID_MATCH_INT_CLASS |
49 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
50 .idVendor = 0x046d,
51 .idProduct = 0x08f0,
52 .bInterfaceClass = USB_CLASS_AUDIO,
53 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL
54},
55{
56 .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
57 USB_DEVICE_ID_MATCH_INT_CLASS |
58 USB_DEVICE_ID_MATCH_INT_SUBCLASS,
59 .idVendor = 0x046d,
60 .idProduct = 0x08f6,
61 .bInterfaceClass = USB_CLASS_AUDIO,
62 .bInterfaceSubClass = USB_SUBCLASS_AUDIO_CONTROL
63},
64
65/*
43 * Yamaha devices 66 * Yamaha devices
44 */ 67 */
45 68