aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CREDITS12
-rw-r--r--Documentation/fb/intelfb.txt135
-rw-r--r--Documentation/feature-removal-schedule.txt10
-rw-r--r--Documentation/filesystems/isofs.txt6
-rw-r--r--Documentation/filesystems/tmpfs.txt6
-rw-r--r--Documentation/i2c/busses/i2c-sis69x2
-rw-r--r--Documentation/i2c/chips/adm1021111
-rw-r--r--Documentation/i2c/chips/adm102551
-rw-r--r--Documentation/i2c/chips/adm102693
-rw-r--r--Documentation/i2c/chips/adm103135
-rw-r--r--Documentation/i2c/chips/adm9240177
-rw-r--r--Documentation/i2c/chips/asb10072
-rw-r--r--Documentation/i2c/chips/ds1621108
-rw-r--r--Documentation/i2c/chips/eeprom96
-rw-r--r--Documentation/i2c/chips/fscher169
-rw-r--r--Documentation/i2c/chips/gl518sm74
-rw-r--r--Documentation/i2c/chips/it8796
-rw-r--r--Documentation/i2c/chips/lm6357
-rw-r--r--Documentation/i2c/chips/lm7565
-rw-r--r--Documentation/i2c/chips/lm7722
-rw-r--r--Documentation/i2c/chips/lm7882
-rw-r--r--Documentation/i2c/chips/lm8056
-rw-r--r--Documentation/i2c/chips/lm8376
-rw-r--r--Documentation/i2c/chips/lm85221
-rw-r--r--Documentation/i2c/chips/lm8773
-rw-r--r--Documentation/i2c/chips/lm90121
-rw-r--r--Documentation/i2c/chips/lm9237
-rw-r--r--Documentation/i2c/chips/max161929
-rw-r--r--Documentation/i2c/chips/max687554
-rw-r--r--Documentation/i2c/chips/pc87360189
-rw-r--r--Documentation/i2c/chips/pca953947
-rw-r--r--Documentation/i2c/chips/pcf857469
-rw-r--r--Documentation/i2c/chips/pcf859190
-rw-r--r--Documentation/i2c/chips/sis5595106
-rw-r--r--Documentation/i2c/chips/smsc47b397 (renamed from Documentation/i2c/chips/smsc47b397.txt)46
-rw-r--r--Documentation/i2c/chips/smsc47m152
-rw-r--r--Documentation/i2c/chips/via686a65
-rw-r--r--Documentation/i2c/chips/w83627hf66
-rw-r--r--Documentation/i2c/chips/w83781d402
-rw-r--r--Documentation/i2c/chips/w83l785ts39
-rw-r--r--Documentation/i2c/porting-clients2
-rw-r--r--Documentation/i2c/userspace-tools39
-rw-r--r--Documentation/i2c/writing-clients62
-rw-r--r--Documentation/s390/CommonIO16
-rw-r--r--Documentation/sgi-ioc4.txt45
-rw-r--r--Documentation/sound/alsa/ALSA-Configuration.txt127
-rw-r--r--Documentation/sound/alsa/CMIPCI.txt41
-rw-r--r--Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl6
-rw-r--r--Documentation/sound/alsa/emu10k1-jack.txt74
-rw-r--r--Documentation/sound/alsa/hdspm.txt362
-rw-r--r--Documentation/w1/w1.generic107
-rw-r--r--MAINTAINERS21
-rw-r--r--arch/arm/mm/mmap.c10
-rw-r--r--arch/frv/mm/init.c1
-rw-r--r--arch/i386/boot/Makefile2
-rw-r--r--arch/i386/kernel/syscall_table.S2
-rw-r--r--arch/i386/kernel/traps.c2
-rw-r--r--arch/i386/lib/delay.c2
-rw-r--r--arch/i386/mm/hugetlbpage.c204
-rw-r--r--arch/i386/mm/init.c1
-rw-r--r--arch/ia64/Kconfig6
-rw-r--r--arch/ia64/configs/sn2_defconfig6
-rw-r--r--arch/ia64/defconfig6
-rw-r--r--arch/ia64/kernel/Makefile1
-rw-r--r--arch/ia64/kernel/efi.c32
-rw-r--r--arch/ia64/kernel/entry.S2
-rw-r--r--arch/ia64/kernel/uncached.c246
-rw-r--r--arch/ia64/mm/hugetlbpage.c158
-rw-r--r--arch/ia64/sn/kernel/xpc_partition.c6
-rw-r--r--arch/m32r/Kconfig7
-rw-r--r--arch/m32r/boot/compressed/m32r_sio.c19
-rw-r--r--arch/m32r/defconfig52
-rw-r--r--arch/m32r/kernel/Makefile2
-rw-r--r--arch/m32r/kernel/io_m32700ut.c92
-rw-r--r--arch/m32r/kernel/io_mappi.c74
-rw-r--r--arch/m32r/kernel/io_mappi2.c92
-rw-r--r--arch/m32r/kernel/io_mappi3.c378
-rw-r--r--arch/m32r/kernel/io_oaks32r.c36
-rw-r--r--arch/m32r/kernel/io_opsput.c79
-rw-r--r--arch/m32r/kernel/io_usrv.c51
-rw-r--r--arch/m32r/kernel/setup.c2
-rw-r--r--arch/m32r/kernel/setup_m32700ut.c56
-rw-r--r--arch/m32r/kernel/setup_mappi.c14
-rw-r--r--arch/m32r/kernel/setup_mappi2.c20
-rw-r--r--arch/m32r/kernel/setup_mappi3.c208
-rw-r--r--arch/m32r/kernel/setup_oaks32r.c14
-rw-r--r--arch/m32r/kernel/setup_opsput.c28
-rw-r--r--arch/m32r/kernel/setup_usrv.c28
-rw-r--r--arch/m32r/m32700ut/defconfig.m32700ut.smp53
-rw-r--r--arch/m32r/m32700ut/defconfig.m32700ut.up52
-rw-r--r--arch/m32r/mappi/defconfig.nommu46
-rw-r--r--arch/m32r/mappi/defconfig.smp49
-rw-r--r--arch/m32r/mappi/defconfig.up48
-rw-r--r--arch/m32r/mappi2/defconfig.vdec246
-rw-r--r--arch/m32r/mappi3/defconfig.smp751
-rw-r--r--arch/m32r/mappi3/dot.gdbinit224
-rw-r--r--arch/m32r/mm/extable.c5
-rw-r--r--arch/m32r/oaks32r/defconfig.nommu50
-rw-r--r--arch/m32r/opsput/defconfig.opsput45
-rw-r--r--arch/mips/mm/init.c1
-rw-r--r--arch/ppc/Kconfig5
-rw-r--r--arch/ppc/boot/ld.script3
-rw-r--r--arch/ppc/boot/openfirmware/Makefile5
-rw-r--r--arch/ppc/boot/openfirmware/common.c16
-rw-r--r--arch/ppc/boot/simple/Makefile4
-rw-r--r--arch/ppc/boot/utils/addSystemMap.c186
-rw-r--r--arch/ppc/configs/mpc8548_cds_defconfig659
-rw-r--r--arch/ppc/kernel/cputable.c14
-rw-r--r--arch/ppc/kernel/entry.S164
-rw-r--r--arch/ppc/kernel/head_4xx.S15
-rw-r--r--arch/ppc/kernel/head_booke.h94
-rw-r--r--arch/ppc/kernel/setup.c11
-rw-r--r--arch/ppc/kernel/traps.c6
-rw-r--r--arch/ppc/lib/locks.c4
-rw-r--r--arch/ppc/mm/fsl_booke_mmu.c2
-rw-r--r--arch/ppc/mm/init.c17
-rw-r--r--arch/ppc/mm/mmu_decl.h2
-rw-r--r--arch/ppc/mm/pgtable.c1
-rw-r--r--arch/ppc/platforms/83xx/mpc834x_sys.c21
-rw-r--r--arch/ppc/platforms/85xx/Kconfig10
-rw-r--r--arch/ppc/platforms/85xx/Makefile1
-rw-r--r--arch/ppc/platforms/85xx/mpc8540_ads.c5
-rw-r--r--arch/ppc/platforms/85xx/mpc8560_ads.c1
-rw-r--r--arch/ppc/platforms/85xx/mpc85xx_ads_common.c37
-rw-r--r--arch/ppc/platforms/85xx/mpc85xx_cds_common.c96
-rw-r--r--arch/ppc/platforms/85xx/sbc8560.c5
-rw-r--r--arch/ppc/platforms/85xx/sbc85xx.c37
-rw-r--r--arch/ppc/platforms/85xx/stx_gp3.c37
-rw-r--r--arch/ppc/platforms/sandpoint.c20
-rw-r--r--arch/ppc/syslib/Makefile3
-rw-r--r--arch/ppc/syslib/mpc10x_common.c203
-rw-r--r--arch/ppc/syslib/mpc85xx_devices.c187
-rw-r--r--arch/ppc/syslib/mpc85xx_sys.c105
-rw-r--r--arch/ppc/syslib/open_pic.c1
-rw-r--r--arch/ppc/syslib/open_pic2.c1
-rw-r--r--arch/ppc/syslib/ppc4xx_kgdb.c124
-rw-r--r--arch/ppc/syslib/ppc83xx_setup.c1
-rw-r--r--arch/ppc/syslib/ppc85xx_setup.c9
-rw-r--r--arch/ppc/xmon/xmon.c270
-rw-r--r--arch/ppc64/Kconfig2
-rw-r--r--arch/ppc64/Makefile6
-rw-r--r--arch/ppc64/kernel/HvLpEvent.c2
-rw-r--r--arch/ppc64/kernel/ItLpQueue.c1
-rw-r--r--arch/ppc64/kernel/Makefile7
-rw-r--r--arch/ppc64/kernel/XmPciLpEvent.c190
-rw-r--r--arch/ppc64/kernel/asm-offsets.c1
-rw-r--r--arch/ppc64/kernel/dma.c4
-rw-r--r--arch/ppc64/kernel/eeh.c2
-rw-r--r--arch/ppc64/kernel/head.S4
-rw-r--r--arch/ppc64/kernel/iSeries_VpdInfo.c220
-rw-r--r--arch/ppc64/kernel/iSeries_iommu.c3
-rw-r--r--arch/ppc64/kernel/iSeries_irq.c312
-rw-r--r--arch/ppc64/kernel/iSeries_pci.c45
-rw-r--r--arch/ppc64/kernel/iSeries_pci_reset.c104
-rw-r--r--arch/ppc64/kernel/iSeries_proc.c3
-rw-r--r--arch/ppc64/kernel/iSeries_setup.c14
-rw-r--r--arch/ppc64/kernel/iSeries_smp.c2
-rw-r--r--arch/ppc64/kernel/idle.c7
-rw-r--r--arch/ppc64/kernel/irq.c2
-rw-r--r--arch/ppc64/kernel/lparcfg.c2
-rw-r--r--arch/ppc64/kernel/mf.c1
-rw-r--r--arch/ppc64/kernel/process.c8
-rw-r--r--arch/ppc64/kernel/prom.c12
-rw-r--r--arch/ppc64/kernel/ras.c1
-rw-r--r--arch/ppc64/kernel/rtc.c2
-rw-r--r--arch/ppc64/kernel/setup.c3
-rw-r--r--arch/ppc64/kernel/sys_ppc32.c3
-rw-r--r--arch/ppc64/kernel/vio.c37
-rw-r--r--arch/ppc64/kernel/viopath.c10
-rw-r--r--arch/ppc64/lib/Makefile2
-rw-r--r--arch/ppc64/mm/hash_utils.c6
-rw-r--r--arch/ppc64/mm/hugetlbpage.c214
-rw-r--r--arch/ppc64/mm/imalloc.c20
-rw-r--r--arch/ppc64/mm/init.c93
-rw-r--r--arch/ppc64/xmon/xmon.c9
-rw-r--r--arch/s390/kernel/compat_ioctl.c6
-rw-r--r--arch/s390/kernel/head.S27
-rw-r--r--arch/s390/kernel/head64.S25
-rw-r--r--arch/s390/kernel/traps.c5
-rw-r--r--arch/s390/mm/cmm.c2
-rw-r--r--arch/sh/kernel/sys_sh.c8
-rw-r--r--arch/sh/lib/delay.c2
-rw-r--r--arch/sh/mm/hugetlbpage.c196
-rw-r--r--arch/sh64/mm/hugetlbpage.c18
-rw-r--r--arch/sparc/mm/init.c1
-rw-r--r--arch/sparc64/kernel/sys_sparc.c8
-rw-r--r--arch/sparc64/lib/delay.c2
-rw-r--r--arch/sparc64/mm/hugetlbpage.c195
-rw-r--r--arch/sparc64/solaris/socket.c6
-rw-r--r--arch/um/Kconfig5
-rw-r--r--arch/um/Makefile2
-rw-r--r--arch/um/drivers/line.c3
-rw-r--r--arch/um/drivers/net_kern.c1
-rw-r--r--arch/um/drivers/port_kern.c1
-rw-r--r--arch/um/drivers/xterm_kern.c1
-rw-r--r--arch/um/kernel/irq.c11
-rw-r--r--arch/um/kernel/irq_user.c2
-rw-r--r--arch/um/kernel/mem.c1
-rw-r--r--arch/um/kernel/tt/Makefile15
-rw-r--r--arch/um/kernel/tt/unmap.c31
-rw-r--r--arch/um/kernel/uml.lds.S15
-rw-r--r--arch/um/scripts/Makefile.rules6
-rw-r--r--arch/um/scripts/Makefile.unmap22
-rw-r--r--arch/um/sys-i386/Makefile2
-rw-r--r--arch/um/sys-i386/unmap.c25
-rw-r--r--arch/um/sys-x86_64/Makefile2
-rw-r--r--arch/um/sys-x86_64/unmap.c25
-rw-r--r--arch/x86_64/ia32/ia32_aout.c1
-rw-r--r--arch/x86_64/ia32/ia32_binfmt.c5
-rw-r--r--arch/x86_64/kernel/process.c4
-rw-r--r--arch/x86_64/kernel/ptrace.c17
-rw-r--r--arch/x86_64/kernel/sys_x86_64.c23
-rw-r--r--arch/x86_64/lib/delay.c2
-rw-r--r--arch/x86_64/mm/fault.c2
-rw-r--r--drivers/Kconfig2
-rw-r--r--drivers/Makefile2
-rw-r--r--drivers/acorn/char/pcf8583.c3
-rw-r--r--drivers/acpi/processor_idle.c2
-rw-r--r--drivers/base/node.c2
-rw-r--r--drivers/char/Kconfig4
-rw-r--r--drivers/char/Makefile1
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c2
-rw-r--r--drivers/char/mem.c8
-rw-r--r--drivers/char/vr41xx_giu.c743
-rw-r--r--drivers/i2c/algos/i2c-algo-pca.c8
-rw-r--r--drivers/i2c/algos/i2c-algo-sibyte.c1
-rw-r--r--drivers/i2c/busses/Kconfig34
-rw-r--r--drivers/i2c/busses/i2c-ali1535.c1
-rw-r--r--drivers/i2c/busses/i2c-ali15x3.c1
-rw-r--r--drivers/i2c/busses/i2c-amd756.c1
-rw-r--r--drivers/i2c/busses/i2c-amd8111.c1
-rw-r--r--drivers/i2c/busses/i2c-au1550.c1
-rw-r--r--drivers/i2c/busses/i2c-elektor.c1
-rw-r--r--drivers/i2c/busses/i2c-frodo.c1
-rw-r--r--drivers/i2c/busses/i2c-i801.c1
-rw-r--r--drivers/i2c/busses/i2c-i810.c1
-rw-r--r--drivers/i2c/busses/i2c-ibm_iic.c2
-rw-r--r--drivers/i2c/busses/i2c-ibm_iic.h1
-rw-r--r--drivers/i2c/busses/i2c-iop3xx.c2
-rw-r--r--drivers/i2c/busses/i2c-isa.c1
-rw-r--r--drivers/i2c/busses/i2c-ite.c1
-rw-r--r--drivers/i2c/busses/i2c-ixp2000.c5
-rw-r--r--drivers/i2c/busses/i2c-ixp4xx.c5
-rw-r--r--drivers/i2c/busses/i2c-keywest.c1
-rw-r--r--drivers/i2c/busses/i2c-mpc.c18
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c1
-rw-r--r--drivers/i2c/busses/i2c-parport-light.c1
-rw-r--r--drivers/i2c/busses/i2c-parport.c3
-rw-r--r--drivers/i2c/busses/i2c-pca-isa.c1
-rw-r--r--drivers/i2c/busses/i2c-piix4.c1
-rw-r--r--drivers/i2c/busses/i2c-prosavage.c1
-rw-r--r--drivers/i2c/busses/i2c-rpx.c1
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c3
-rw-r--r--drivers/i2c/busses/i2c-savage4.c1
-rw-r--r--drivers/i2c/busses/i2c-sibyte.c1
-rw-r--r--drivers/i2c/busses/i2c-sis5595.c1
-rw-r--r--drivers/i2c/busses/i2c-sis630.c1
-rw-r--r--drivers/i2c/busses/i2c-sis96x.c1
-rw-r--r--drivers/i2c/busses/i2c-stub.c1
-rw-r--r--drivers/i2c/busses/i2c-via.c1
-rw-r--r--drivers/i2c/busses/i2c-viapro.c1
-rw-r--r--drivers/i2c/busses/i2c-voodoo3.c1
-rw-r--r--drivers/i2c/busses/scx200_acb.c1
-rw-r--r--drivers/i2c/chips/Kconfig117
-rw-r--r--drivers/i2c/chips/Makefile10
-rw-r--r--drivers/i2c/chips/adm1021.c9
-rw-r--r--drivers/i2c/chips/adm1025.c5
-rw-r--r--drivers/i2c/chips/adm1026.c8
-rw-r--r--drivers/i2c/chips/adm1031.c2
-rw-r--r--drivers/i2c/chips/adm9240.c791
-rw-r--r--drivers/i2c/chips/asb100.c5
-rw-r--r--drivers/i2c/chips/atxp1.c361
-rw-r--r--drivers/i2c/chips/ds1337.c97
-rw-r--r--drivers/i2c/chips/ds1374.c260
-rw-r--r--drivers/i2c/chips/ds1621.c4
-rw-r--r--drivers/i2c/chips/eeprom.c1
-rw-r--r--drivers/i2c/chips/fscher.c1
-rw-r--r--drivers/i2c/chips/gl518sm.c1
-rw-r--r--drivers/i2c/chips/isp1301_omap.c1
-rw-r--r--drivers/i2c/chips/it87.c396
-rw-r--r--drivers/i2c/chips/lm63.c262
-rw-r--r--drivers/i2c/chips/lm75.c1
-rw-r--r--drivers/i2c/chips/lm77.c1
-rw-r--r--drivers/i2c/chips/lm78.c5
-rw-r--r--drivers/i2c/chips/lm80.c1
-rw-r--r--drivers/i2c/chips/lm83.c160
-rw-r--r--drivers/i2c/chips/lm85.c5
-rw-r--r--drivers/i2c/chips/lm87.c1
-rw-r--r--drivers/i2c/chips/lm90.c273
-rw-r--r--drivers/i2c/chips/m41t00.c3
-rw-r--r--drivers/i2c/chips/max1619.c1
-rw-r--r--drivers/i2c/chips/max6875.c473
-rw-r--r--drivers/i2c/chips/pc87360.c1
-rw-r--r--drivers/i2c/chips/pca9539.c192
-rw-r--r--drivers/i2c/chips/pcf8574.c6
-rw-r--r--drivers/i2c/chips/rtc8564.c4
-rw-r--r--drivers/i2c/chips/sis5595.c1
-rw-r--r--drivers/i2c/chips/smsc47m1.c10
-rw-r--r--drivers/i2c/chips/tps65010.c1072
-rw-r--r--drivers/i2c/chips/via686a.c305
-rw-r--r--drivers/i2c/chips/w83627ehf.c846
-rw-r--r--drivers/i2c/chips/w83627hf.c2
-rw-r--r--drivers/i2c/chips/w83781d.c78
-rw-r--r--drivers/i2c/chips/w83l785ts.c1
-rw-r--r--drivers/i2c/i2c-core.c102
-rw-r--r--drivers/i2c/i2c-dev.c3
-rw-r--r--drivers/ide/Kconfig4
-rw-r--r--drivers/ide/pci/sgiioc4.c30
-rw-r--r--drivers/input/gameport/gameport.c2
-rw-r--r--drivers/macintosh/therm_windtunnel.c6
-rw-r--r--drivers/md/Makefile3
-rw-r--r--drivers/md/bitmap.c1586
-rw-r--r--drivers/md/dm-crypt.c3
-rw-r--r--drivers/md/linear.c3
-rw-r--r--drivers/md/md.c525
-rw-r--r--drivers/md/multipath.c3
-rw-r--r--drivers/md/raid0.c12
-rw-r--r--drivers/md/raid1.c242
-rw-r--r--drivers/md/raid10.c30
-rw-r--r--drivers/md/raid5.c12
-rw-r--r--drivers/md/raid6main.c12
-rw-r--r--drivers/media/video/adv7170.c16
-rw-r--r--drivers/media/video/adv7175.c16
-rw-r--r--drivers/media/video/bt819.c16
-rw-r--r--drivers/media/video/bt832.c4
-rw-r--r--drivers/media/video/bt856.c16
-rw-r--r--drivers/media/video/msp3400.c1
-rw-r--r--drivers/media/video/saa5246a.c1
-rw-r--r--drivers/media/video/saa5249.c1
-rw-r--r--drivers/media/video/saa7110.c16
-rw-r--r--drivers/media/video/saa7111.c16
-rw-r--r--drivers/media/video/saa7114.c16
-rw-r--r--drivers/media/video/saa7134/saa6752hs.c1
-rw-r--r--drivers/media/video/saa7185.c16
-rw-r--r--drivers/media/video/tda7432.c1
-rw-r--r--drivers/media/video/tda9840.c1
-rw-r--r--drivers/media/video/tda9875.c1
-rw-r--r--drivers/media/video/tda9887.c1
-rw-r--r--drivers/media/video/tea6415c.c1
-rw-r--r--drivers/media/video/tea6420.c1
-rw-r--r--drivers/media/video/tuner-3036.c17
-rw-r--r--drivers/media/video/tuner-core.c11
-rw-r--r--drivers/media/video/tvaudio.c1
-rw-r--r--drivers/media/video/tveeprom.c1
-rw-r--r--drivers/media/video/vpx3220.c16
-rw-r--r--drivers/misc/ibmasm/command.c30
-rw-r--r--drivers/misc/ibmasm/dot_command.c10
-rw-r--r--drivers/misc/ibmasm/event.c18
-rw-r--r--drivers/misc/ibmasm/heartbeat.c13
-rw-r--r--drivers/misc/ibmasm/ibmasm.h76
-rw-r--r--drivers/misc/ibmasm/ibmasmfs.c125
-rw-r--r--drivers/misc/ibmasm/lowlevel.c18
-rw-r--r--drivers/misc/ibmasm/module.c69
-rw-r--r--drivers/misc/ibmasm/r_heartbeat.c2
-rw-r--r--drivers/misc/ibmasm/remote.c304
-rw-r--r--drivers/misc/ibmasm/remote.h173
-rw-r--r--drivers/net/3c59x.c5
-rw-r--r--drivers/net/8390.c4
-rw-r--r--drivers/oprofile/buffer_sync.c4
-rw-r--r--drivers/pcmcia/Kconfig6
-rw-r--r--drivers/pcmcia/m32r_cfc.c57
-rw-r--r--drivers/pcmcia/m32r_cfc.h8
-rw-r--r--drivers/s390/cio/blacklist.c6
-rw-r--r--drivers/scsi/megaraid.c2
-rw-r--r--drivers/serial/Kconfig11
-rw-r--r--drivers/serial/Makefile2
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm2.c9
-rw-r--r--drivers/serial/ioc4_serial.c336
-rw-r--r--drivers/sn/Kconfig20
-rw-r--r--drivers/sn/Makefile2
-rw-r--r--drivers/sn/ioc4.c418
-rw-r--r--drivers/video/Kconfig16
-rw-r--r--drivers/video/Makefile1
-rw-r--r--drivers/video/arcfb.c684
-rw-r--r--drivers/video/chipsfb.c3
-rw-r--r--drivers/video/console/Kconfig17
-rw-r--r--drivers/video/console/Makefile2
-rw-r--r--drivers/video/console/bitblit.c23
-rw-r--r--drivers/video/console/font_10x18.c5146
-rw-r--r--drivers/video/console/font_7x14.c4118
-rw-r--r--drivers/video/console/font_sun12x22.c1579
-rw-r--r--drivers/video/console/fonts.c8
-rw-r--r--drivers/video/console/vgacon.c17
-rw-r--r--drivers/video/fbmem.c67
-rw-r--r--drivers/video/i810/i810_main.c1
-rw-r--r--drivers/video/intelfb/intelfbdrv.c23
-rw-r--r--drivers/video/matrox/matroxfb_maven.c1
-rw-r--r--drivers/video/nvidia/nvidia.c18
-rw-r--r--drivers/video/pm3fb.c2
-rw-r--r--drivers/video/riva/fbdev.c19
-rw-r--r--drivers/video/s1d13xxxfb.c2
-rw-r--r--drivers/video/savage/savagefb_driver.c2
-rw-r--r--drivers/video/softcursor.c9
-rw-r--r--drivers/video/vesafb.c8
-rw-r--r--drivers/w1/Kconfig16
-rw-r--r--drivers/w1/ds_w1_bridge.c4
-rw-r--r--drivers/w1/matrox_w1.c10
-rw-r--r--drivers/w1/w1.c546
-rw-r--r--drivers/w1/w1.h113
-rw-r--r--drivers/w1/w1_family.c10
-rw-r--r--drivers/w1/w1_family.h18
-rw-r--r--drivers/w1/w1_int.c41
-rw-r--r--drivers/w1/w1_int.h6
-rw-r--r--drivers/w1/w1_io.c117
-rw-r--r--drivers/w1/w1_io.h9
-rw-r--r--drivers/w1/w1_log.h4
-rw-r--r--drivers/w1/w1_netlink.h4
-rw-r--r--drivers/w1/w1_smem.c50
-rw-r--r--drivers/w1/w1_therm.c100
-rw-r--r--fs/autofs4/autofs_i.h13
-rw-r--r--fs/autofs4/expire.c5
-rw-r--r--fs/autofs4/root.c15
-rw-r--r--fs/autofs4/waitq.c7
-rw-r--r--fs/binfmt_aout.c1
-rw-r--r--fs/binfmt_elf.c1
-rw-r--r--fs/buffer.c2
-rw-r--r--fs/hugetlbfs/inode.c3
-rw-r--r--fs/isofs/dir.c17
-rw-r--r--fs/isofs/inode.c128
-rw-r--r--fs/isofs/isofs.h2
-rw-r--r--fs/isofs/namei.c16
-rw-r--r--fs/isofs/rock.c962
-rw-r--r--fs/isofs/rock.h183
-rw-r--r--fs/proc/proc_misc.c14
-rw-r--r--fs/super.c1
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c153
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.h1
-rw-r--r--fs/xfs/linux-2.6/xfs_file.c27
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl.c11
-rw-r--r--fs/xfs/linux-2.6/xfs_linux.h12
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.c34
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.h2
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c12
-rw-r--r--fs/xfs/linux-2.6/xfs_vfs.h1
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.c4
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.h2
-rw-r--r--fs/xfs/quota/xfs_dquot.c105
-rw-r--r--fs/xfs/quota/xfs_dquot.h30
-rw-r--r--fs/xfs/quota/xfs_dquot_item.c6
-rw-r--r--fs/xfs/quota/xfs_qm.c202
-rw-r--r--fs/xfs/quota/xfs_qm.h16
-rw-r--r--fs/xfs/quota/xfs_qm_bhv.c43
-rw-r--r--fs/xfs/quota/xfs_qm_syscalls.c175
-rw-r--r--fs/xfs/quota/xfs_quota_priv.h15
-rw-r--r--fs/xfs/quota/xfs_trans_dquot.c60
-rw-r--r--fs/xfs/support/debug.c1
-rw-r--r--fs/xfs/support/debug.h7
-rw-r--r--fs/xfs/xfs_alloc.c4
-rw-r--r--fs/xfs/xfs_attr.c17
-rw-r--r--fs/xfs/xfs_attr.h7
-rw-r--r--fs/xfs/xfs_attr_leaf.c28
-rw-r--r--fs/xfs/xfs_attr_leaf.h12
-rw-r--r--fs/xfs/xfs_bit.c2
-rw-r--r--fs/xfs/xfs_bmap.c127
-rw-r--r--fs/xfs/xfs_bmap.h13
-rw-r--r--fs/xfs/xfs_bmap_btree.c14
-rw-r--r--fs/xfs/xfs_bmap_btree.h8
-rw-r--r--fs/xfs/xfs_btree.c12
-rw-r--r--fs/xfs/xfs_btree.h10
-rw-r--r--fs/xfs/xfs_buf_item.c24
-rw-r--r--fs/xfs/xfs_buf_item.h2
-rw-r--r--fs/xfs/xfs_da_btree.c9
-rw-r--r--fs/xfs/xfs_da_btree.h3
-rw-r--r--fs/xfs/xfs_dfrag.c7
-rw-r--r--fs/xfs/xfs_dir2_data.c2
-rw-r--r--fs/xfs/xfs_dir2_data.h4
-rw-r--r--fs/xfs/xfs_dir2_leaf.c8
-rw-r--r--fs/xfs/xfs_dir2_leaf.h7
-rw-r--r--fs/xfs/xfs_dir_leaf.c6
-rw-r--r--fs/xfs/xfs_dir_leaf.h2
-rw-r--r--fs/xfs/xfs_dmapi.h19
-rw-r--r--fs/xfs/xfs_error.c2
-rw-r--r--fs/xfs/xfs_error.h3
-rw-r--r--fs/xfs/xfs_extfree_item.c126
-rw-r--r--fs/xfs/xfs_extfree_item.h2
-rw-r--r--fs/xfs/xfs_fs.h3
-rw-r--r--fs/xfs/xfs_fsops.c26
-rw-r--r--fs/xfs/xfs_ialloc_btree.h8
-rw-r--r--fs/xfs/xfs_inode.c185
-rw-r--r--fs/xfs/xfs_inode.h9
-rw-r--r--fs/xfs/xfs_inode_item.c2
-rw-r--r--fs/xfs/xfs_iomap.c65
-rw-r--r--fs/xfs/xfs_log.c6
-rw-r--r--fs/xfs/xfs_log_priv.h2
-rw-r--r--fs/xfs/xfs_log_recover.c31
-rw-r--r--fs/xfs/xfs_macros.c5
-rw-r--r--fs/xfs/xfs_mount.c16
-rw-r--r--fs/xfs/xfs_mount.h7
-rw-r--r--fs/xfs/xfs_quota.h72
-rw-r--r--fs/xfs/xfs_rename.c18
-rw-r--r--fs/xfs/xfs_trans.c21
-rw-r--r--fs/xfs/xfs_trans.h3
-rw-r--r--fs/xfs/xfs_trans_buf.c1
-rw-r--r--fs/xfs/xfs_trans_inode.c18
-rw-r--r--fs/xfs/xfs_types.h2
-rw-r--r--fs/xfs/xfs_utils.c2
-rw-r--r--fs/xfs/xfs_vfsops.c74
-rw-r--r--fs/xfs/xfs_vnodeops.c95
-rw-r--r--include/asm-alpha/smp.h2
-rw-r--r--include/asm-arm/arch-omap/tps65010.h76
-rw-r--r--include/asm-arm/smp.h2
-rw-r--r--include/asm-arm/system.h2
-rw-r--r--include/asm-generic/pgtable.h3
-rw-r--r--include/asm-i386/page.h1
-rw-r--r--include/asm-i386/pgtable.h2
-rw-r--r--include/asm-i386/smp.h2
-rw-r--r--include/asm-i386/unistd.h2
-rw-r--r--include/asm-ia64/mmzone.h14
-rw-r--r--include/asm-ia64/pgtable.h1
-rw-r--r--include/asm-ia64/smp.h2
-rw-r--r--include/asm-ia64/sn/mspec.h59
-rw-r--r--include/asm-ia64/uncached.h12
-rw-r--r--include/asm-ia64/unistd.h1
-rw-r--r--include/asm-m32r/div64.h39
-rw-r--r--include/asm-m32r/ide.h2
-rw-r--r--include/asm-m32r/m32102.h1
-rw-r--r--include/asm-m32r/m32102peri.h468
-rw-r--r--include/asm-m32r/m32r.h5
-rw-r--r--include/asm-m32r/mappi3/mappi3_pld.h143
-rw-r--r--include/asm-m32r/smp.h2
-rw-r--r--include/asm-mips/smp.h2
-rw-r--r--include/asm-mips/vr41xx/giu.h69
-rw-r--r--include/asm-mips/vr41xx/vr41xx.h35
-rw-r--r--include/asm-parisc/smp.h2
-rw-r--r--include/asm-ppc/irq.h34
-rw-r--r--include/asm-ppc/mpc10x.h6
-rw-r--r--include/asm-ppc/mpc85xx.h60
-rw-r--r--include/asm-ppc/pgtable.h2
-rw-r--r--include/asm-ppc/ppc_sys.h2
-rw-r--r--include/asm-ppc/smp.h2
-rw-r--r--include/asm-ppc64/dma.h3
-rw-r--r--include/asm-ppc64/iSeries/HvCall.h156
-rw-r--r--include/asm-ppc64/iSeries/HvCallCfg.h213
-rw-r--r--include/asm-ppc64/iSeries/HvCallEvent.h94
-rw-r--r--include/asm-ppc64/iSeries/HvCallHpt.h112
-rw-r--r--include/asm-ppc64/iSeries/HvCallPci.h486
-rw-r--r--include/asm-ppc64/iSeries/HvCallSc.h40
-rw-r--r--include/asm-ppc64/iSeries/HvCallSm.h36
-rw-r--r--include/asm-ppc64/iSeries/HvCallXm.h113
-rw-r--r--include/asm-ppc64/iSeries/HvLpConfig.h300
-rw-r--r--include/asm-ppc64/iSeries/HvLpEvent.h116
-rw-r--r--include/asm-ppc64/iSeries/HvReleaseData.h78
-rw-r--r--include/asm-ppc64/iSeries/HvTypes.h108
-rw-r--r--include/asm-ppc64/iSeries/IoHriMainStore.h33
-rw-r--r--include/asm-ppc64/iSeries/IoHriProcessorVpd.h32
-rw-r--r--include/asm-ppc64/iSeries/ItExtVpdPanel.h54
-rw-r--r--include/asm-ppc64/iSeries/ItIplParmsReal.h99
-rw-r--r--include/asm-ppc64/iSeries/ItLpNaca.h44
-rw-r--r--include/asm-ppc64/iSeries/ItLpQueue.h84
-rw-r--r--include/asm-ppc64/iSeries/ItLpRegSave.h41
-rw-r--r--include/asm-ppc64/iSeries/ItSpCommArea.h10
-rw-r--r--include/asm-ppc64/iSeries/ItVpdAreas.h125
-rw-r--r--include/asm-ppc64/iSeries/LparData.h49
-rw-r--r--include/asm-ppc64/iSeries/LparMap.h44
-rw-r--r--include/asm-ppc64/iSeries/XmPciLpEvent.h18
-rw-r--r--include/asm-ppc64/iSeries/iSeries_io.h59
-rw-r--r--include/asm-ppc64/iSeries/iSeries_irq.h17
-rw-r--r--include/asm-ppc64/iSeries/iSeries_pci.h142
-rw-r--r--include/asm-ppc64/iSeries/iSeries_proc.h24
-rw-r--r--include/asm-ppc64/iSeries/mf.h5
-rw-r--r--include/asm-ppc64/iSeries/vio.h57
-rw-r--r--include/asm-ppc64/imalloc.h12
-rw-r--r--include/asm-ppc64/iommu.h25
-rw-r--r--include/asm-ppc64/paca.h2
-rw-r--r--include/asm-ppc64/page.h2
-rw-r--r--include/asm-ppc64/pgtable.h9
-rw-r--r--include/asm-ppc64/processor.h10
-rw-r--r--include/asm-ppc64/smp.h2
-rw-r--r--include/asm-s390/smp.h2
-rw-r--r--include/asm-sh/page.h1
-rw-r--r--include/asm-sh/pgtable.h1
-rw-r--r--include/asm-sh/smp.h2
-rw-r--r--include/asm-sh64/page.h1
-rw-r--r--include/asm-sh64/pgtable.h2
-rw-r--r--include/asm-sparc/smp.h2
-rw-r--r--include/asm-sparc64/page.h2
-rw-r--r--include/asm-sparc64/pgtable.h1
-rw-r--r--include/asm-sparc64/processor.h34
-rw-r--r--include/asm-sparc64/smp.h2
-rw-r--r--include/asm-um/smp.h3
-rw-r--r--include/asm-x86_64/a.out.h2
-rw-r--r--include/asm-x86_64/page.h1
-rw-r--r--include/asm-x86_64/pgtable.h3
-rw-r--r--include/asm-x86_64/processor.h11
-rw-r--r--include/asm-x86_64/smp.h2
-rw-r--r--include/linux/arcfb.h8
-rw-r--r--include/linux/auto_fs4.h2
-rw-r--r--include/linux/fb.h19
-rw-r--r--include/linux/font.h26
-rw-r--r--include/linux/fsl_devices.h8
-rw-r--r--include/linux/genalloc.h40
-rw-r--r--include/linux/gfp.h8
-rw-r--r--include/linux/hugetlb.h40
-rw-r--r--include/linux/hwmon-sysfs.h (renamed from include/linux/i2c-sysfs.h)8
-rw-r--r--include/linux/i2c-id.h1
-rw-r--r--include/linux/i2c-vid.h12
-rw-r--r--include/linux/i2c.h12
-rw-r--r--include/linux/ioc4.h179
-rw-r--r--include/linux/ioc4_common.h21
-rw-r--r--include/linux/irq.h4
-rw-r--r--include/linux/mm.h6
-rw-r--r--include/linux/mmzone.h21
-rw-r--r--include/linux/page-flags.h35
-rw-r--r--include/linux/pagemap.h4
-rw-r--r--include/linux/pci_ids.h1
-rw-r--r--include/linux/raid/bitmap.h273
-rw-r--r--include/linux/raid/md.h17
-rw-r--r--include/linux/raid/md_k.h22
-rw-r--r--include/linux/raid/md_p.h9
-rw-r--r--include/linux/raid/md_u.h7
-rw-r--r--include/linux/raid/raid1.h16
-rw-r--r--include/linux/sched.h11
-rw-r--r--include/linux/smp.h40
-rw-r--r--include/linux/swap.h3
-rw-r--r--include/net/route.h2
-rw-r--r--include/net/snmp.h14
-rw-r--r--include/sound/ac97_codec.h8
-rw-r--r--include/sound/asound.h16
-rw-r--r--include/sound/control.h2
-rw-r--r--include/sound/emu10k1.h42
-rw-r--r--include/sound/gus.h23
-rw-r--r--include/sound/hdspm.h131
-rw-r--r--include/sound/pcm.h32
-rw-r--r--include/sound/seq_midi_event.h2
-rw-r--r--include/sound/seq_virmidi.h1
-rw-r--r--include/sound/timer.h2
-rw-r--r--include/sound/version.h4
-rw-r--r--init/main.c1
-rw-r--r--kernel/fork.c7
-rw-r--r--kernel/irq/manage.c8
-rw-r--r--kernel/module.c2
-rw-r--r--kernel/power/smp.c4
-rw-r--r--kernel/sched.c4
-rw-r--r--kernel/stop_machine.c4
-rw-r--r--kernel/sys_ni.c1
-rw-r--r--lib/Kconfig6
-rw-r--r--lib/Makefile2
-rw-r--r--lib/genalloc.c188
-rw-r--r--lib/idr.c2
-rw-r--r--lib/kernel_lock.c55
-rw-r--r--lib/smp_processor_id.c55
-rw-r--r--mm/hugetlb.c177
-rw-r--r--mm/madvise.c103
-rw-r--r--mm/memory.c57
-rw-r--r--mm/mempolicy.c110
-rw-r--r--mm/mmap.c57
-rw-r--r--mm/msync.c2
-rw-r--r--mm/nommu.c2
-rw-r--r--mm/oom_kill.c7
-rw-r--r--mm/page_alloc.c423
-rw-r--r--mm/rmap.c21
-rw-r--r--mm/shmem.c143
-rw-r--r--mm/slab.c1
-rw-r--r--mm/swapfile.c55
-rw-r--r--mm/vmscan.c103
-rw-r--r--net/ipv4/Kconfig2
-rw-r--r--security/selinux/hooks.c1
-rw-r--r--sound/Kconfig5
-rw-r--r--sound/arm/Kconfig6
-rw-r--r--sound/arm/Makefile3
-rw-r--r--sound/arm/aaci.c968
-rw-r--r--sound/arm/aaci.h246
-rw-r--r--sound/arm/devdma.c81
-rw-r--r--sound/arm/devdma.h3
-rw-r--r--sound/core/control.c4
-rw-r--r--sound/core/memalloc.c201
-rw-r--r--sound/core/oss/pcm_oss.c33
-rw-r--r--sound/core/oss/pcm_plugin.c5
-rw-r--r--sound/core/pcm.c3
-rw-r--r--sound/core/pcm_lib.c52
-rw-r--r--sound/core/pcm_memory.c1
-rw-r--r--sound/core/pcm_misc.c16
-rw-r--r--sound/core/pcm_native.c74
-rw-r--r--sound/core/seq/oss/seq_oss_synth.c24
-rw-r--r--sound/core/seq/seq_dummy.c5
-rw-r--r--sound/core/seq/seq_midi.c2
-rw-r--r--sound/core/seq/seq_midi_event.c6
-rw-r--r--sound/core/seq/seq_queue.c3
-rw-r--r--sound/core/seq/seq_queue.h1
-rw-r--r--sound/core/seq/seq_timer.c3
-rw-r--r--sound/core/seq/seq_timer.h2
-rw-r--r--sound/core/seq/seq_virmidi.c8
-rw-r--r--sound/core/sound.c1
-rw-r--r--sound/core/timer.c100
-rw-r--r--sound/core/timer_compat.c5
-rw-r--r--sound/drivers/vx/vx_pcm.c12
-rw-r--r--sound/i2c/tea6330t.c3
-rw-r--r--sound/isa/Kconfig1
-rw-r--r--sound/isa/ad1816a/ad1816a.c2
-rw-r--r--sound/isa/cs423x/cs4236.c3
-rw-r--r--sound/isa/gus/gus_io.c14
-rw-r--r--sound/isa/gus/gus_main.c3
-rw-r--r--sound/isa/gus/gus_mem.c12
-rw-r--r--sound/isa/gus/gus_pcm.c3
-rw-r--r--sound/isa/gus/gus_reset.c3
-rw-r--r--sound/isa/gus/gus_synth.c3
-rw-r--r--sound/isa/gus/gus_tables.h4
-rw-r--r--sound/isa/gus/gus_volume.c8
-rw-r--r--sound/oss/rme96xx.c2
-rw-r--r--sound/pci/Kconfig13
-rw-r--r--sound/pci/ac97/ac97_codec.c71
-rw-r--r--sound/pci/ac97/ac97_patch.c585
-rw-r--r--sound/pci/ac97/ac97_patch.h1
-rw-r--r--sound/pci/ali5451/ali5451.c283
-rw-r--r--sound/pci/als4000.c4
-rw-r--r--sound/pci/atiixp.c6
-rw-r--r--sound/pci/atiixp_modem.c42
-rw-r--r--sound/pci/au88x0/au88x0.c2
-rw-r--r--sound/pci/azt3328.c2
-rw-r--r--sound/pci/bt87x.c2
-rw-r--r--sound/pci/ca0106/ca0106.h70
-rw-r--r--sound/pci/ca0106/ca0106_main.c211
-rw-r--r--sound/pci/ca0106/ca0106_mixer.c76
-rw-r--r--sound/pci/ca0106/ca0106_proc.c31
-rw-r--r--sound/pci/cmipci.c159
-rw-r--r--sound/pci/cs4281.c10
-rw-r--r--sound/pci/cs46xx/cs46xx.c2
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c3
-rw-r--r--sound/pci/emu10k1/emu10k1.c2
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c192
-rw-r--r--sound/pci/emu10k1/emu10k1x.c8
-rw-r--r--sound/pci/emu10k1/emufx.c56
-rw-r--r--sound/pci/emu10k1/emumixer.c14
-rw-r--r--sound/pci/emu10k1/emupcm.c6
-rw-r--r--sound/pci/emu10k1/emuproc.c89
-rw-r--r--sound/pci/emu10k1/irq.c46
-rw-r--r--sound/pci/emu10k1/p16v.c367
-rw-r--r--sound/pci/ens1370.c2
-rw-r--r--sound/pci/es1938.c2
-rw-r--r--sound/pci/es1968.c3
-rw-r--r--sound/pci/fm801.c3
-rw-r--r--sound/pci/hda/Makefile2
-rw-r--r--sound/pci/hda/hda_codec.c206
-rw-r--r--sound/pci/hda/hda_codec.h30
-rw-r--r--sound/pci/hda/hda_generic.c14
-rw-r--r--sound/pci/hda/hda_intel.c119
-rw-r--r--sound/pci/hda/hda_local.h37
-rw-r--r--sound/pci/hda/hda_patch.h3
-rw-r--r--sound/pci/hda/hda_proc.c56
-rw-r--r--sound/pci/hda/patch_analog.c693
-rw-r--r--sound/pci/hda/patch_cmedia.c216
-rw-r--r--sound/pci/hda/patch_realtek.c2503
-rw-r--r--sound/pci/hda/patch_sigmatel.c666
-rw-r--r--sound/pci/ice1712/amp.c30
-rw-r--r--sound/pci/ice1712/amp.h16
-rw-r--r--sound/pci/ice1712/ice1712.c2
-rw-r--r--sound/pci/ice1712/ice1712.h5
-rw-r--r--sound/pci/ice1712/ice1724.c2
-rw-r--r--sound/pci/ice1712/phase.c728
-rw-r--r--sound/pci/ice1712/phase.h19
-rw-r--r--sound/pci/ice1712/vt1720_mobo.c9
-rw-r--r--sound/pci/ice1712/vt1720_mobo.h4
-rw-r--r--sound/pci/intel8x0.c156
-rw-r--r--sound/pci/intel8x0m.c80
-rw-r--r--sound/pci/korg1212/korg1212.c2
-rw-r--r--sound/pci/maestro3.c222
-rw-r--r--sound/pci/mixart/mixart.c2
-rw-r--r--sound/pci/nm256/nm256.c2
-rw-r--r--sound/pci/rme32.c2
-rw-r--r--sound/pci/rme96.c2
-rw-r--r--sound/pci/rme9652/Makefile2
-rw-r--r--sound/pci/rme9652/hdsp.c30
-rw-r--r--sound/pci/rme9652/hdspm.c3671
-rw-r--r--sound/pci/rme9652/rme9652.c16
-rw-r--r--sound/pci/sonicvibes.c2
-rw-r--r--sound/pci/trident/trident.c5
-rw-r--r--sound/pci/via82xx.c145
-rw-r--r--sound/pci/via82xx_modem.c38
-rw-r--r--sound/pci/vx222/vx222.c2
-rw-r--r--sound/pci/ymfpci/ymfpci.c2
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c35
-rw-r--r--sound/pcmcia/vx/vx_entry.c3
-rw-r--r--sound/synth/emux/emux_effect.c6
-rw-r--r--sound/usb/Kconfig1
-rw-r--r--sound/usb/usbaudio.c308
-rw-r--r--sound/usb/usbaudio.h11
-rw-r--r--sound/usb/usbmidi.c128
-rw-r--r--sound/usb/usbmixer.c588
-rw-r--r--sound/usb/usbmixer_maps.c126
-rw-r--r--sound/usb/usbquirks.h298
-rw-r--r--sound/usb/usx2y/usbusx2y.c2
-rw-r--r--sound/usb/usx2y/usbusx2yaudio.c6
782 files changed, 47599 insertions, 14056 deletions
diff --git a/CREDITS b/CREDITS
index d65ffe5a4d08..3b7a1548aaf9 100644
--- a/CREDITS
+++ b/CREDITS
@@ -1880,6 +1880,13 @@ S: Schlehenweg 9
1880S: D-91080 Uttenreuth 1880S: D-91080 Uttenreuth
1881S: Germany 1881S: Germany
1882 1882
1883N: Jaya Kumar
1884E: jayalk@intworks.biz
1885W: http://www.intworks.biz
1886D: Arc monochrome LCD framebuffer driver, x86 reboot fixups
1887S: Gurgaon, India
1888S: Kuala Lumpur, Malaysia
1889
1883N: Gabor Kuti 1890N: Gabor Kuti
1884M: seasons@falcon.sch.bme.hu 1891M: seasons@falcon.sch.bme.hu
1885M: seasons@makosteszta.sote.hu 1892M: seasons@makosteszta.sote.hu
@@ -2373,9 +2380,10 @@ E: tmolina@cablespeed.com
2373D: bug fixes, documentation, minor hackery 2380D: bug fixes, documentation, minor hackery
2374 2381
2375N: James Morris 2382N: James Morris
2376E: jmorris@intercode.com.au 2383E: jmorris@redhat.com
2377W: http://www.intercode.com.au/jmorris/ 2384W: http://www.intercode.com.au/jmorris/
2378D: Netfilter, Linux Security Modules (LSM). 2385D: Netfilter, Linux Security Modules (LSM), SELinux, IPSec,
2386D: Crypto API, general networking, miscellaneous.
2379S: PO Box 707 2387S: PO Box 707
2380S: Spit Junction NSW 2088 2388S: Spit Junction NSW 2088
2381S: Australia 2389S: Australia
diff --git a/Documentation/fb/intelfb.txt b/Documentation/fb/intelfb.txt
new file mode 100644
index 000000000000..c12d39a23c3d
--- /dev/null
+++ b/Documentation/fb/intelfb.txt
@@ -0,0 +1,135 @@
1Intel 830M/845G/852GM/855GM/865G/915G Framebuffer driver
2================================================================
3
4A. Introduction
5 This is a framebuffer driver for various Intel 810/815 compatible
6graphics devices. These would include:
7
8 Intel 830M
9 Intel 810E845G
10 Intel 852GM
11 Intel 855GM
12 Intel 865G
13 Intel 915G
14
15B. List of available options
16
17 a. "video=intelfb"
18 enables the intelfb driver
19
20 Recommendation: required
21
22 b. "mode=<xres>x<yres>[-<bpp>][@<refresh>]"
23 select mode
24
25 Recommendation: user preference
26 (default = 1024x768-32@70)
27
28 c. "vram=<value>"
29 select amount of system RAM in MB to allocate for the video memory
30 if not enough RAM was already allocated by the BIOS.
31
32 Recommendation: 1 - 4 MB.
33 (default = 4 MB)
34
35 d. "voffset=<value>"
36 select at what offset in MB of the logical memory to allocate the
37 framebuffer memory. The intent is to avoid the memory blocks
38 used by standard graphics applications (XFree86). Depending on your
39 usage, adjust the value up or down, (0 for maximum usage, 63/127 MB
40 for the least amount). Note, an arbitrary setting may conflict
41 with XFree86.
42
43 Recommendation: do not set
44 (default = 48 MB)
45
46 e. "accel"
47 enable text acceleration. This can be enabled/reenabled anytime
48 by using 'fbset -accel true/false'.
49
50 Recommendation: enable
51 (default = set)
52
53 f. "hwcursor"
54 enable cursor acceleration.
55
56 Recommendation: enable
57 (default = set)
58
59 g. "mtrr"
60 enable MTRR. This allows data transfers to the framebuffer memory
61 to occur in bursts which can significantly increase performance.
62 Not very helpful with the intel chips because of 'shared memory'.
63
64 Recommendation: set
65 (default = set)
66
67 h. "fixed"
68 disable mode switching.
69
70 Recommendation: do not set
71 (default = not set)
72
73 The binary parameters can be unset with a "no" prefix, example "noaccel".
74 The default parameter (not named) is the mode.
75
76C. Kernel booting
77
78Separate each option/option-pair by commas (,) and the option from its value
79with an equals sign (=) as in the following:
80
81video=i810fb:option1,option2=value2
82
83Sample Usage
84------------
85
86In /etc/lilo.conf, add the line:
87
88append="video=intelfb:800x600-32@75,accel,hwcursor,vram=8"
89
90This will initialize the framebuffer to 800x600 at 32bpp and 75Hz. The
91framebuffer will use 8 MB of System RAM. hw acceleration of text and cursor
92will be enabled.
93
94D. Module options
95
96 The module parameters are essentially similar to the kernel
97parameters. The main difference is that you need to include a Boolean value
98(1 for TRUE, and 0 for FALSE) for those options which don't need a value.
99
100Example, to enable MTRR, include "mtrr=1".
101
102Sample Usage
103------------
104
105Using the same setup as described above, load the module like this:
106
107 modprobe intelfb mode=800x600-32@75 vram=8 accel=1 hwcursor=1
108
109Or just add the following to /etc/modprobe.conf
110
111 options intelfb mode=800x600-32@75 vram=8 accel=1 hwcursor=1
112
113and just do a
114
115 modprobe intelfb
116
117
118E. Acknowledgment:
119
120 1. Geert Uytterhoeven - his excellent howto and the virtual
121 framebuffer driver code made this possible.
122
123 2. Jeff Hartmann for his agpgart code.
124
125 3. David Dawes for his original kernel 2.4 code.
126
127 4. The X developers. Insights were provided just by reading the
128 XFree86 source code.
129
130 5. Antonino A. Daplas for his inspiring i810fb driver.
131
132 6. Andrew Morton for his kernel patches maintenance.
133
134###########################
135Sylvain
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index b9eb209318ab..26414bc87c65 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -83,3 +83,13 @@ Why: Deprecated in favour of the new ioctl-based rawiso interface, which is
83 more efficient. You should really be using libraw1394 for raw1394 83 more efficient. You should really be using libraw1394 for raw1394
84 access anyway. 84 access anyway.
85Who: Jody McIntyre <scjody@steamballoon.com> 85Who: Jody McIntyre <scjody@steamballoon.com>
86
87---------------------------
88
89What: i2c sysfs name change: in1_ref, vid deprecated in favour of cpu0_vid
90When: November 2005
91Files: drivers/i2c/chips/adm1025.c, drivers/i2c/chips/adm1026.c
92Why: Match the other drivers' name for the same function, duplicate names
93 will be available until removal of old names.
94Who: Grant Coady <gcoady@gmail.com>
95
diff --git a/Documentation/filesystems/isofs.txt b/Documentation/filesystems/isofs.txt
index f64a10506689..424585ff6ea1 100644
--- a/Documentation/filesystems/isofs.txt
+++ b/Documentation/filesystems/isofs.txt
@@ -26,7 +26,11 @@ Mount options unique to the isofs filesystem.
26 mode=xxx Sets the permissions on files to xxx 26 mode=xxx Sets the permissions on files to xxx
27 nojoliet Ignore Joliet extensions if they are present. 27 nojoliet Ignore Joliet extensions if they are present.
28 norock Ignore Rock Ridge extensions if they are present. 28 norock Ignore Rock Ridge extensions if they are present.
29 unhide Show hidden files. 29 hide Completely strip hidden files from the file system.
30 showassoc Show files marked with the 'associated' bit
31 unhide Deprecated; showing hidden files is now default;
32 If given, it is a synonym for 'showassoc' which will
33 recreate previous unhide behavior
30 session=x Select number of session on multisession CD 34 session=x Select number of session on multisession CD
31 sbsector=xxx Session begins from sector xxx 35 sbsector=xxx Session begins from sector xxx
32 36
diff --git a/Documentation/filesystems/tmpfs.txt b/Documentation/filesystems/tmpfs.txt
index 417e3095fe39..0d783c504ead 100644
--- a/Documentation/filesystems/tmpfs.txt
+++ b/Documentation/filesystems/tmpfs.txt
@@ -71,8 +71,8 @@ can be changed on remount. The size parameter also accepts a suffix %
71to limit this tmpfs instance to that percentage of your physical RAM: 71to limit this tmpfs instance to that percentage of your physical RAM:
72the default, when neither size nor nr_blocks is specified, is size=50% 72the default, when neither size nor nr_blocks is specified, is size=50%
73 73
74If both nr_blocks (or size) and nr_inodes are set to 0, neither blocks 74If nr_blocks=0 (or size=0), blocks will not be limited in that instance;
75nor inodes will be limited in that instance. It is generally unwise to 75if nr_inodes=0, inodes will not be limited. It is generally unwise to
76mount with such options, since it allows any user with write access to 76mount with such options, since it allows any user with write access to
77use up all the memory on the machine; but enhances the scalability of 77use up all the memory on the machine; but enhances the scalability of
78that instance in a system with many cpus making intensive use of it. 78that instance in a system with many cpus making intensive use of it.
@@ -97,4 +97,4 @@ RAM/SWAP in 10240 inodes and it is only accessible by root.
97Author: 97Author:
98 Christoph Rohland <cr@sap.com>, 1.12.01 98 Christoph Rohland <cr@sap.com>, 1.12.01
99Updated: 99Updated:
100 Hugh Dickins <hugh@veritas.com>, 01 September 2004 100 Hugh Dickins <hugh@veritas.com>, 13 March 2005
diff --git a/Documentation/i2c/busses/i2c-sis69x b/Documentation/i2c/busses/i2c-sis69x
index 5be48769f65b..b88953dfd580 100644
--- a/Documentation/i2c/busses/i2c-sis69x
+++ b/Documentation/i2c/busses/i2c-sis69x
@@ -42,7 +42,7 @@ I suspect that this driver could be made to work for the following SiS
42chipsets as well: 635, and 635T. If anyone owns a board with those chips 42chipsets as well: 635, and 635T. If anyone owns a board with those chips
43AND is willing to risk crashing & burning an otherwise well-behaved kernel 43AND is willing to risk crashing & burning an otherwise well-behaved kernel
44in the name of progress... please contact me at <mhoffman@lightlink.com> or 44in the name of progress... please contact me at <mhoffman@lightlink.com> or
45via the project's mailing list: <sensors@stimpy.netroedge.com>. Please 45via the project's mailing list: <lm-sensors@lm-sensors.org>. Please
46send bug reports and/or success stories as well. 46send bug reports and/or success stories as well.
47 47
48 48
diff --git a/Documentation/i2c/chips/adm1021 b/Documentation/i2c/chips/adm1021
new file mode 100644
index 000000000000..03d02bfb3df1
--- /dev/null
+++ b/Documentation/i2c/chips/adm1021
@@ -0,0 +1,111 @@
1Kernel driver adm1021
2=====================
3
4Supported chips:
5 * Analog Devices ADM1021
6 Prefix: 'adm1021'
7 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e
8 Datasheet: Publicly available at the Analog Devices website
9 * Analog Devices ADM1021A/ADM1023
10 Prefix: 'adm1023'
11 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e
12 Datasheet: Publicly available at the Analog Devices website
13 * Genesys Logic GL523SM
14 Prefix: 'gl523sm'
15 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e
16 Datasheet:
17 * Intel Xeon Processor
18 Prefix: - any other - may require 'force_adm1021' parameter
19 Addresses scanned: none
20 Datasheet: Publicly available at Intel website
21 * Maxim MAX1617
22 Prefix: 'max1617'
23 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e
24 Datasheet: Publicly available at the Maxim website
25 * Maxim MAX1617A
26 Prefix: 'max1617a'
27 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e
28 Datasheet: Publicly available at the Maxim website
29 * National Semiconductor LM84
30 Prefix: 'lm84'
31 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e
32 Datasheet: Publicly available at the National Semiconductor website
33 * Philips NE1617
34 Prefix: 'max1617' (probably detected as a max1617)
35 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e
36 Datasheet: Publicly available at the Philips website
37 * Philips NE1617A
38 Prefix: 'max1617' (probably detected as a max1617)
39 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e
40 Datasheet: Publicly available at the Philips website
41 * TI THMC10
42 Prefix: 'thmc10'
43 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e
44 Datasheet: Publicly available at the TI website
45 * Onsemi MC1066
46 Prefix: 'mc1066'
47 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e
48 Datasheet: Publicly available at the Onsemi website
49
50
51Authors:
52 Frodo Looijaard <frodol@dds.nl>,
53 Philip Edelbrock <phil@netroedge.com>
54
55Module Parameters
56-----------------
57
58* read_only: int
59 Don't set any values, read only mode
60
61
62Description
63-----------
64
65The chips supported by this driver are very similar. The Maxim MAX1617 is
66the oldest; it has the problem that it is not very well detectable. The
67MAX1617A solves that. The ADM1021 is a straight clone of the MAX1617A.
68Ditto for the THMC10. From here on, we will refer to all these chips as
69ADM1021-clones.
70
71The ADM1021 and MAX1617A reports a die code, which is a sort of revision
72code. This can help us pinpoint problems; it is not very useful
73otherwise.
74
75ADM1021-clones implement two temperature sensors. One of them is internal,
76and measures the temperature of the chip itself; the other is external and
77is realised in the form of a transistor-like device. A special alarm
78indicates whether the remote sensor is connected.
79
80Each sensor has its own low and high limits. When they are crossed, the
81corresponding alarm is set and remains on as long as the temperature stays
82out of range. Temperatures are measured in degrees Celsius. Measurements
83are possible between -65 and +127 degrees, with a resolution of one degree.
84
85If an alarm triggers, it will remain triggered until the hardware register
86is read at least once. This means that the cause for the alarm may already
87have disappeared!
88
89This driver only updates its values each 1.5 seconds; reading it more often
90will do no harm, but will return 'old' values. It is possible to make
91ADM1021-clones do faster measurements, but there is really no good reason
92for that.
93
94Xeon support
95------------
96
97Some Xeon processors have real max1617, adm1021, or compatible chips
98within them, with two temperature sensors.
99
100Other Xeons have chips with only one sensor.
101
102If you have a Xeon, and the adm1021 module loads, and both temperatures
103appear valid, then things are good.
104
105If the adm1021 module doesn't load, you should try this:
106 modprobe adm1021 force_adm1021=BUS,ADDRESS
107 ADDRESS can only be 0x18, 0x1a, 0x29, 0x2b, 0x4c, or 0x4e.
108
109If you have dual Xeons you may have appear to have two separate
110adm1021-compatible chips, or two single-temperature sensors, at distinct
111addresses.
diff --git a/Documentation/i2c/chips/adm1025 b/Documentation/i2c/chips/adm1025
new file mode 100644
index 000000000000..39d2b781b5d6
--- /dev/null
+++ b/Documentation/i2c/chips/adm1025
@@ -0,0 +1,51 @@
1Kernel driver adm1025
2=====================
3
4Supported chips:
5 * Analog Devices ADM1025, ADM1025A
6 Prefix: 'adm1025'
7 Addresses scanned: I2C 0x2c - 0x2e
8 Datasheet: Publicly available at the Analog Devices website
9 * Philips NE1619
10 Prefix: 'ne1619'
11 Addresses scanned: I2C 0x2c - 0x2d
12 Datasheet: Publicly available at the Philips website
13
14The NE1619 presents some differences with the original ADM1025:
15 * Only two possible addresses (0x2c - 0x2d).
16 * No temperature offset register, but we don't use it anyway.
17 * No INT mode for pin 16. We don't play with it anyway.
18
19Authors:
20 Chen-Yuan Wu <gwu@esoft.com>,
21 Jean Delvare <khali@linux-fr.org>
22
23Description
24-----------
25
26(This is from Analog Devices.) The ADM1025 is a complete system hardware
27monitor for microprocessor-based systems, providing measurement and limit
28comparison of various system parameters. Five voltage measurement inputs
29are provided, for monitoring +2.5V, +3.3V, +5V and +12V power supplies and
30the processor core voltage. The ADM1025 can monitor a sixth power-supply
31voltage by measuring its own VCC. One input (two pins) is dedicated to a
32remote temperature-sensing diode and an on-chip temperature sensor allows
33ambient temperature to be monitored.
34
35One specificity of this chip is that the pin 11 can be hardwired in two
36different manners. It can act as the +12V power-supply voltage analog
37input, or as the a fifth digital entry for the VID reading (bit 4). It's
38kind of strange since both are useful, and the reason for designing the
39chip that way is obscure at least to me. The bit 5 of the configuration
40register can be used to define how the chip is hardwired. Please note that
41it is not a choice you have to make as the user. The choice was already
42made by your motherboard's maker. If the configuration bit isn't set
43properly, you'll have a wrong +12V reading or a wrong VID reading. The way
44the driver handles that is to preserve this bit through the initialization
45process, assuming that the BIOS set it up properly beforehand. If it turns
46out not to be true in some cases, we'll provide a module parameter to force
47modes.
48
49This driver also supports the ADM1025A, which differs from the ADM1025
50only in that it has "open-drain VID inputs while the ADM1025 has on-chip
51100k pull-ups on the VID inputs". It doesn't make any difference for us.
diff --git a/Documentation/i2c/chips/adm1026 b/Documentation/i2c/chips/adm1026
new file mode 100644
index 000000000000..473c689d7924
--- /dev/null
+++ b/Documentation/i2c/chips/adm1026
@@ -0,0 +1,93 @@
1Kernel driver adm1026
2=====================
3
4Supported chips:
5 * Analog Devices ADM1026
6 Prefix: 'adm1026'
7 Addresses scanned: I2C 0x2c, 0x2d, 0x2e
8 Datasheet: Publicly available at the Analog Devices website
9 http://www.analog.com/en/prod/0,,766_825_ADM1026,00.html
10
11Authors:
12 Philip Pokorny <ppokorny@penguincomputing.com> for Penguin Computing
13 Justin Thiessen <jthiessen@penguincomputing.com>
14
15Module Parameters
16-----------------
17
18* gpio_input: int array (min = 1, max = 17)
19 List of GPIO pins (0-16) to program as inputs
20* gpio_output: int array (min = 1, max = 17)
21 List of GPIO pins (0-16) to program as outputs
22* gpio_inverted: int array (min = 1, max = 17)
23 List of GPIO pins (0-16) to program as inverted
24* gpio_normal: int array (min = 1, max = 17)
25 List of GPIO pins (0-16) to program as normal/non-inverted
26* gpio_fan: int array (min = 1, max = 8)
27 List of GPIO pins (0-7) to program as fan tachs
28
29
30Description
31-----------
32
33This driver implements support for the Analog Devices ADM1026. Analog
34Devices calls it a "complete thermal system management controller."
35
36The ADM1026 implements three (3) temperature sensors, 17 voltage sensors,
3716 general purpose digital I/O lines, eight (8) fan speed sensors (8-bit),
38an analog output and a PWM output along with limit, alarm and mask bits for
39all of the above. There is even 8k bytes of EEPROM memory on chip.
40
41Temperatures are measured in degrees Celsius. There are two external
42sensor inputs and one internal sensor. Each sensor has a high and low
43limit. If the limit is exceeded, an interrupt (#SMBALERT) can be
44generated. The interrupts can be masked. In addition, there are over-temp
45limits for each sensor. If this limit is exceeded, the #THERM output will
46be asserted. The current temperature and limits have a resolution of 1
47degree.
48
49Fan rotation speeds are reported in RPM (rotations per minute) but measured
50in counts of a 22.5kHz internal clock. Each fan has a high limit which
51corresponds to a minimum fan speed. If the limit is exceeded, an interrupt
52can be generated. Each fan can be programmed to divide the reference clock
53by 1, 2, 4 or 8. Not all RPM values can accurately be represented, so some
54rounding is done. With a divider of 8, the slowest measurable speed of a
55two pulse per revolution fan is 661 RPM.
56
57There are 17 voltage sensors. An alarm is triggered if the voltage has
58crossed a programmable minimum or maximum limit. Note that minimum in this
59case always means 'closest to zero'; this is important for negative voltage
60measurements. Several inputs have integrated attenuators so they can measure
61higher voltages directly. 3.3V, 5V, 12V, -12V and battery voltage all have
62dedicated inputs. There are several inputs scaled to 0-3V full-scale range
63for SCSI terminator power. The remaining inputs are not scaled and have
64a 0-2.5V full-scale range. A 2.5V or 1.82V reference voltage is provided
65for negative voltage measurements.
66
67If an alarm triggers, it will remain triggered until the hardware register
68is read at least once. This means that the cause for the alarm may already
69have disappeared! Note that in the current implementation, all hardware
70registers are read whenever any data is read (unless it is less than 2.0
71seconds since the last update). This means that you can easily miss
72once-only alarms.
73
74The ADM1026 measures continuously. Analog inputs are measured about 4
75times a second. Fan speed measurement time depends on fan speed and
76divisor. It can take as long as 1.5 seconds to measure all fan speeds.
77
78The ADM1026 has the ability to automatically control fan speed based on the
79temperature sensor inputs. Both the PWM output and the DAC output can be
80used to control fan speed. Usually only one of these two outputs will be
81used. Write the minimum PWM or DAC value to the appropriate control
82register. Then set the low temperature limit in the tmin values for each
83temperature sensor. The range of control is fixed at 20 °C, and the
84largest difference between current and tmin of the temperature sensors sets
85the control output. See the datasheet for several example circuits for
86controlling fan speed with the PWM and DAC outputs. The fan speed sensors
87do not have PWM compensation, so it is probably best to control the fan
88voltage from the power lead rather than on the ground lead.
89
90The datasheet shows an example application with VID signals attached to
91GPIO lines. Unfortunately, the chip may not be connected to the VID lines
92in this way. The driver assumes that the chips *is* connected this way to
93get a VID voltage.
diff --git a/Documentation/i2c/chips/adm1031 b/Documentation/i2c/chips/adm1031
new file mode 100644
index 000000000000..130a38382b98
--- /dev/null
+++ b/Documentation/i2c/chips/adm1031
@@ -0,0 +1,35 @@
1Kernel driver adm1031
2=====================
3
4Supported chips:
5 * Analog Devices ADM1030
6 Prefix: 'adm1030'
7 Addresses scanned: I2C 0x2c to 0x2e
8 Datasheet: Publicly available at the Analog Devices website
9 http://products.analog.com/products/info.asp?product=ADM1030
10
11 * Analog Devices ADM1031
12 Prefix: 'adm1031'
13 Addresses scanned: I2C 0x2c to 0x2e
14 Datasheet: Publicly available at the Analog Devices website
15 http://products.analog.com/products/info.asp?product=ADM1031
16
17Authors:
18 Alexandre d'Alton <alex@alexdalton.org>
19 Jean Delvare <khali@linux-fr.org>
20
21Description
22-----------
23
24The ADM1030 and ADM1031 are digital temperature sensors and fan controllers.
25They sense their own temperature as well as the temperature of up to one
26(ADM1030) or two (ADM1031) external diodes.
27
28All temperature values are given in degrees Celsius. Resolution is 0.5
29degree for the local temperature, 0.125 degree for the remote temperatures.
30
31Each temperature channel has its own high and low limits, plus a critical
32limit.
33
34The ADM1030 monitors a single fan speed, while the ADM1031 monitors up to
35two. Each fan channel has its own low speed limit.
diff --git a/Documentation/i2c/chips/adm9240 b/Documentation/i2c/chips/adm9240
new file mode 100644
index 000000000000..35f618f32896
--- /dev/null
+++ b/Documentation/i2c/chips/adm9240
@@ -0,0 +1,177 @@
1Kernel driver adm9240
2=====================
3
4Supported chips:
5 * Analog Devices ADM9240
6 Prefix: 'adm9240'
7 Addresses scanned: I2C 0x2c - 0x2f
8 Datasheet: Publicly available at the Analog Devices website
9 http://www.analog.com/UploadedFiles/Data_Sheets/79857778ADM9240_0.pdf
10
11 * Dallas Semiconductor DS1780
12 Prefix: 'ds1780'
13 Addresses scanned: I2C 0x2c - 0x2f
14 Datasheet: Publicly available at the Dallas Semiconductor (Maxim) website
15 http://pdfserv.maxim-ic.com/en/ds/DS1780.pdf
16
17 * National Semiconductor LM81
18 Prefix: 'lm81'
19 Addresses scanned: I2C 0x2c - 0x2f
20 Datasheet: Publicly available at the National Semiconductor website
21 http://www.national.com/ds.cgi/LM/LM81.pdf
22
23Authors:
24 Frodo Looijaard <frodol@dds.nl>,
25 Philip Edelbrock <phil@netroedge.com>,
26 Michiel Rook <michiel@grendelproject.nl>,
27 Grant Coady <gcoady@gmail.com> with guidance
28 from Jean Delvare <khali@linux-fr.org>
29
30Interface
31---------
32The I2C addresses listed above assume BIOS has not changed the
33chip MSB 5-bit address. Each chip reports a unique manufacturer
34identification code as well as the chip revision/stepping level.
35
36Description
37-----------
38[From ADM9240] The ADM9240 is a complete system hardware monitor for
39microprocessor-based systems, providing measurement and limit comparison
40of up to four power supplies and two processor core voltages, plus
41temperature, two fan speeds and chassis intrusion. Measured values can
42be read out via an I2C-compatible serial System Management Bus, and values
43for limit comparisons can be programmed in over the same serial bus. The
44high speed successive approximation ADC allows frequent sampling of all
45analog channels to ensure a fast interrupt response to any out-of-limit
46measurement.
47
48The ADM9240, DS1780 and LM81 are register compatible, the following
49details are common to the three chips. Chip differences are described
50after this section.
51
52
53Measurements
54------------
55The measurement cycle
56
57The adm9240 driver will take a measurement reading no faster than once
58each two seconds. User-space may read sysfs interface faster than the
59measurement update rate and will receive cached data from the most
60recent measurement.
61
62ADM9240 has a very fast 320us temperature and voltage measurement cycle
63with independent fan speed measurement cycles counting alternating rising
64edges of the fan tacho inputs.
65
66DS1780 measurement cycle is about once per second including fan speed.
67
68LM81 measurement cycle is about once per 400ms including fan speed.
69The LM81 12-bit extended temperature measurement mode is not supported.
70
71Temperature
72-----------
73On chip temperature is reported as degrees Celsius as 9-bit signed data
74with resolution of 0.5 degrees Celsius. High and low temperature limits
75are 8-bit signed data with resolution of one degree Celsius.
76
77Temperature alarm is asserted once the temperature exceeds the high limit,
78and is cleared when the temperature falls below the temp1_max_hyst value.
79
80Fan Speed
81---------
82Two fan tacho inputs are provided, the ADM9240 gates an internal 22.5kHz
83clock via a divider to an 8-bit counter. Fan speed (rpm) is calculated by:
84
85rpm = (22500 * 60) / (count * divider)
86
87Automatic fan clock divider
88
89 * User sets 0 to fan_min limit
90 - low speed alarm is disabled
91 - fan clock divider not changed
92 - auto fan clock adjuster enabled for valid fan speed reading
93
94 * User sets fan_min limit too low
95 - low speed alarm is enabled
96 - fan clock divider set to max
97 - fan_min set to register value 254 which corresponds
98 to 664 rpm on adm9240
99 - low speed alarm will be asserted if fan speed is
100 less than minimum measurable speed
101 - auto fan clock adjuster disabled
102
103 * User sets reasonable fan speed
104 - low speed alarm is enabled
105 - fan clock divider set to suit fan_min
106 - auto fan clock adjuster enabled: adjusts fan_min
107
108 * User sets unreasonably high low fan speed limit
109 - resolution of the low speed limit may be reduced
110 - alarm will be asserted
111 - auto fan clock adjuster enabled: adjusts fan_min
112
113 * fan speed may be displayed as zero until the auto fan clock divider
114 adjuster brings fan speed clock divider back into chip measurement
115 range, this will occur within a few measurement cycles.
116
117Analog Output
118-------------
119An analog output provides a 0 to 1.25 volt signal intended for an external
120fan speed amplifier circuit. The analog output is set to maximum value on
121power up or reset. This doesn't do much on the test Intel SE440BX-2.
122
123Voltage Monitor
124
125Voltage (IN) measurement is internally scaled:
126
127 nr label nominal maximum resolution
128 mV mV mV
129 0 +2.5V 2500 3320 13.0
130 1 Vccp1 2700 3600 14.1
131 2 +3.3V 3300 4380 17.2
132 3 +5V 5000 6640 26.0
133 4 +12V 12000 15940 62.5
134 5 Vccp2 2700 3600 14.1
135
136The reading is an unsigned 8-bit value, nominal voltage measurement is
137represented by a reading of 192, being 3/4 of the measurement range.
138
139An alarm is asserted for any voltage going below or above the set limits.
140
141The driver reports and accepts voltage limits scaled to the above table.
142
143VID Monitor
144-----------
145The chip has five inputs to read the 5-bit VID and reports the mV value
146based on detected CPU type.
147
148Chassis Intrusion
149-----------------
150An alarm is asserted when the CI pin goes active high. The ADM9240
151Datasheet has an example of an external temperature sensor driving
152this pin. On an Intel SE440BX-2 the Chassis Intrusion header is
153connected to a normally open switch.
154
155The ADM9240 provides an internal open drain on this line, and may output
156a 20 ms active low pulse to reset an external Chassis Intrusion latch.
157
158Clear the CI latch by writing value 1 to the sysfs chassis_clear file.
159
160Alarm flags reported as 16-bit word
161
162 bit label comment
163 --- ------------- --------------------------
164 0 +2.5 V_Error high or low limit exceeded
165 1 VCCP_Error high or low limit exceeded
166 2 +3.3 V_Error high or low limit exceeded
167 3 +5 V_Error high or low limit exceeded
168 4 Temp_Error temperature error
169 6 FAN1_Error fan low limit exceeded
170 7 FAN2_Error fan low limit exceeded
171 8 +12 V_Error high or low limit exceeded
172 9 VCCP2_Error high or low limit exceeded
173 12 Chassis_Error CI pin went high
174
175Remaining bits are reserved and thus undefined. It is important to note
176that alarm bits may be cleared on read, user-space may latch alarms and
177provide the end-user with a method to clear alarm memory.
diff --git a/Documentation/i2c/chips/asb100 b/Documentation/i2c/chips/asb100
new file mode 100644
index 000000000000..ab7365e139be
--- /dev/null
+++ b/Documentation/i2c/chips/asb100
@@ -0,0 +1,72 @@
1Kernel driver asb100
2====================
3
4Supported Chips:
5 * Asus ASB100 and ASB100-A "Bach"
6 Prefix: 'asb100'
7 Addresses scanned: I2C 0x2d
8 Datasheet: none released
9
10Author: Mark M. Hoffman <mhoffman@lightlink.com>
11
12Description
13-----------
14
15This driver implements support for the Asus ASB100 and ASB100-A "Bach".
16These are custom ASICs available only on Asus mainboards. Asus refuses to
17supply a datasheet for these chips. Thanks go to many people who helped
18investigate their hardware, including:
19
20Vitaly V. Bursov
21Alexander van Kaam (author of MBM for Windows)
22Bertrik Sikken
23
24The ASB100 implements seven voltage sensors, three fan rotation speed
25sensors, four temperature sensors, VID lines and alarms. In addition to
26these, the ASB100-A also implements a single PWM controller for fans 2 and
273 (i.e. one setting controls both.) If you have a plain ASB100, the PWM
28controller will simply not work (or maybe it will for you... it doesn't for
29me).
30
31Temperatures are measured and reported in degrees Celsius.
32
33Fan speeds are reported in RPM (rotations per minute). An alarm is
34triggered if the rotation speed has dropped below a programmable limit.
35
36Voltage sensors (also known as IN sensors) report values in volts.
37
38The VID lines encode the core voltage value: the voltage level your
39processor should work with. This is hardcoded by the mainboard and/or
40processor itself. It is a value in volts.
41
42Alarms: (TODO question marks indicate may or may not work)
43
440x0001 => in0 (?)
450x0002 => in1 (?)
460x0004 => in2
470x0008 => in3
480x0010 => temp1 (1)
490x0020 => temp2
500x0040 => fan1
510x0080 => fan2
520x0100 => in4
530x0200 => in5 (?) (2)
540x0400 => in6 (?) (2)
550x0800 => fan3
560x1000 => chassis switch
570x2000 => temp3
58
59Alarm Notes:
60
61(1) This alarm will only trigger if the hysteresis value is 127C.
62I.e. it behaves the same as w83781d.
63
64(2) The min and max registers for these values appear to
65be read-only or otherwise stuck at 0x00.
66
67TODO:
68* Experiment with fan divisors > 8.
69* Experiment with temp. sensor types.
70* Are there really 13 voltage inputs? Probably not...
71* Cleanups, no doubt...
72
diff --git a/Documentation/i2c/chips/ds1621 b/Documentation/i2c/chips/ds1621
new file mode 100644
index 000000000000..1fee6f1e6bc5
--- /dev/null
+++ b/Documentation/i2c/chips/ds1621
@@ -0,0 +1,108 @@
1Kernel driver ds1621
2====================
3
4Supported chips:
5 * Dallas Semiconductor DS1621
6 Prefix: 'ds1621'
7 Addresses scanned: I2C 0x48 - 0x4f
8 Datasheet: Publicly available at the Dallas Semiconductor website
9 http://www.dalsemi.com/
10 * Dallas Semiconductor DS1625
11 Prefix: 'ds1621'
12 Addresses scanned: I2C 0x48 - 0x4f
13 Datasheet: Publicly available at the Dallas Semiconductor website
14 http://www.dalsemi.com/
15
16Authors:
17 Christian W. Zuckschwerdt <zany@triq.net>
18 valuable contributions by Jan M. Sendler <sendler@sendler.de>
19 ported to 2.6 by Aurelien Jarno <aurelien@aurel32.net>
20 with the help of Jean Delvare <khali@linux-fr.org>
21
22Module Parameters
23------------------
24
25* polarity int
26 Output's polarity: 0 = active high, 1 = active low
27
28Description
29-----------
30
31The DS1621 is a (one instance) digital thermometer and thermostat. It has
32both high and low temperature limits which can be user defined (i.e.
33programmed into non-volatile on-chip registers). Temperature range is -55
34degree Celsius to +125 in 0.5 increments. You may convert this into a
35Fahrenheit range of -67 to +257 degrees with 0.9 steps. If polarity
36parameter is not provided, original value is used.
37
38As for the thermostat, behavior can also be programmed using the polarity
39toggle. On the one hand ("heater"), the thermostat output of the chip,
40Tout, will trigger when the low limit temperature is met or underrun and
41stays high until the high limit is met or exceeded. On the other hand
42("cooler"), vice versa. That way "heater" equals "active low", whereas
43"conditioner" equals "active high". Please note that the DS1621 data sheet
44is somewhat misleading in this point since setting the polarity bit does
45not simply invert Tout.
46
47A second thing is that, during extensive testing, Tout showed a tolerance
48of up to +/- 0.5 degrees even when compared against precise temperature
49readings. Be sure to have a high vs. low temperature limit gap of al least
501.0 degree Celsius to avoid Tout "bouncing", though!
51
52As for alarms, you can read the alarm status of the DS1621 via the 'alarms'
53/sys file interface. The result consists mainly of bit 6 and 5 of the
54configuration register of the chip; bit 6 (0x40 or 64) is the high alarm
55bit and bit 5 (0x20 or 32) the low one. These bits are set when the high or
56low limits are met or exceeded and are reset by the module as soon as the
57respective temperature ranges are left.
58
59The alarm registers are in no way suitable to find out about the actual
60status of Tout. They will only tell you about its history, whether or not
61any of the limits have ever been met or exceeded since last power-up or
62reset. Be aware: When testing, it showed that the status of Tout can change
63with neither of the alarms set.
64
65Temperature conversion of the DS1621 takes up to 1000ms; internal access to
66non-volatile registers may last for 10ms or below.
67
68High Accuracy Temperature Reading
69---------------------------------
70
71As said before, the temperature issued via the 9-bit i2c-bus data is
72somewhat arbitrary. Internally, the temperature conversion is of a
73different kind that is explained (not so...) well in the DS1621 data sheet.
74To cut the long story short: Inside the DS1621 there are two oscillators,
75both of them biassed by a temperature coefficient.
76
77Higher resolution of the temperature reading can be achieved using the
78internal projection, which means taking account of REG_COUNT and REG_SLOPE
79(the driver manages them):
80
81Taken from Dallas Semiconductors App Note 068: 'Increasing Temperature
82Resolution on the DS1620' and App Note 105: 'High Resolution Temperature
83Measurement with Dallas Direct-to-Digital Temperature Sensors'
84
85- Read the 9-bit temperature and strip the LSB (Truncate the .5 degs)
86- The resulting value is TEMP_READ.
87- Then, read REG_COUNT.
88- And then, REG_SLOPE.
89
90 TEMP = TEMP_READ - 0.25 + ((REG_SLOPE - REG_COUNT) / REG_SLOPE)
91
92Note that this is what the DONE bit in the DS1621 configuration register is
93good for: Internally, one temperature conversion takes up to 1000ms. Before
94that conversion is complete you will not be able to read valid things out
95of REG_COUNT and REG_SLOPE. The DONE bit, as you may have guessed by now,
96tells you whether the conversion is complete ("done", in plain English) and
97thus, whether the values you read are good or not.
98
99The DS1621 has two modes of operation: "Continuous" conversion, which can
100be understood as the default stand-alone mode where the chip gets the
101temperature and controls external devices via its Tout pin or tells other
102i2c's about it if they care. The other mode is called "1SHOT", that means
103that it only figures out about the temperature when it is explicitly told
104to do so; this can be seen as power saving mode.
105
106Now if you want to read REG_COUNT and REG_SLOPE, you have to either stop
107the continuous conversions until the contents of these registers are valid,
108or, in 1SHOT mode, you have to have one conversion made.
diff --git a/Documentation/i2c/chips/eeprom b/Documentation/i2c/chips/eeprom
new file mode 100644
index 000000000000..f7e8104b5764
--- /dev/null
+++ b/Documentation/i2c/chips/eeprom
@@ -0,0 +1,96 @@
1Kernel driver eeprom
2====================
3
4Supported chips:
5 * Any EEPROM chip in the designated address range
6 Prefix: 'eeprom'
7 Addresses scanned: I2C 0x50 - 0x57
8 Datasheets: Publicly available from:
9 Atmel (www.atmel.com),
10 Catalyst (www.catsemi.com),
11 Fairchild (www.fairchildsemi.com),
12 Microchip (www.microchip.com),
13 Philips (www.semiconductor.philips.com),
14 Rohm (www.rohm.com),
15 ST (www.st.com),
16 Xicor (www.xicor.com),
17 and others.
18
19 Chip Size (bits) Address
20 24C01 1K 0x50 (shadows at 0x51 - 0x57)
21 24C01A 1K 0x50 - 0x57 (Typical device on DIMMs)
22 24C02 2K 0x50 - 0x57
23 24C04 4K 0x50, 0x52, 0x54, 0x56
24 (additional data at 0x51, 0x53, 0x55, 0x57)
25 24C08 8K 0x50, 0x54 (additional data at 0x51, 0x52,
26 0x53, 0x55, 0x56, 0x57)
27 24C16 16K 0x50 (additional data at 0x51 - 0x57)
28 Sony 2K 0x57
29
30 Atmel 34C02B 2K 0x50 - 0x57, SW write protect at 0x30-37
31 Catalyst 34FC02 2K 0x50 - 0x57, SW write protect at 0x30-37
32 Catalyst 34RC02 2K 0x50 - 0x57, SW write protect at 0x30-37
33 Fairchild 34W02 2K 0x50 - 0x57, SW write protect at 0x30-37
34 Microchip 24AA52 2K 0x50 - 0x57, SW write protect at 0x30-37
35 ST M34C02 2K 0x50 - 0x57, SW write protect at 0x30-37
36
37
38Authors:
39 Frodo Looijaard <frodol@dds.nl>,
40 Philip Edelbrock <phil@netroedge.com>,
41 Jean Delvare <khali@linux-fr.org>,
42 Greg Kroah-Hartman <greg@kroah.com>,
43 IBM Corp.
44
45Description
46-----------
47
48This is a simple EEPROM module meant to enable reading the first 256 bytes
49of an EEPROM (on a SDRAM DIMM for example). However, it will access serial
50EEPROMs on any I2C adapter. The supported devices are generically called
5124Cxx, and are listed above; however the numbering for these
52industry-standard devices may vary by manufacturer.
53
54This module was a programming exercise to get used to the new project
55organization laid out by Frodo, but it should be at least completely
56effective for decoding the contents of EEPROMs on DIMMs.
57
58DIMMS will typically contain a 24C01A or 24C02, or the 34C02 variants.
59The other devices will not be found on a DIMM because they respond to more
60than one address.
61
62DDC Monitors may contain any device. Often a 24C01, which responds to all 8
63addresses, is found.
64
65Recent Sony Vaio laptops have an EEPROM at 0x57. We couldn't get the
66specification, so it is guess work and far from being complete.
67
68The Microchip 24AA52/24LCS52, ST M34C02, and others support an additional
69software write protect register at 0x30 - 0x37 (0x20 less than the memory
70location). The chip responds to "write quick" detection at this address but
71does not respond to byte reads. If this register is present, the lower 128
72bytes of the memory array are not write protected. Any byte data write to
73this address will write protect the memory array permanently, and the
74device will no longer respond at the 0x30-37 address. The eeprom driver
75does not support this register.
76
77Lacking functionality:
78
79* Full support for larger devices (24C04, 24C08, 24C16). These are not
80typically found on a PC. These devices will appear as separate devices at
81multiple addresses.
82
83* Support for really large devices (24C32, 24C64, 24C128, 24C256, 24C512).
84These devices require two-byte address fields and are not supported.
85
86* Enable Writing. Again, no technical reason why not, but making it easy
87to change the contents of the EEPROMs (on DIMMs anyway) also makes it easy
88to disable the DIMMs (potentially preventing the computer from booting)
89until the values are restored somehow.
90
91Use:
92
93After inserting the module (and any other required SMBus/i2c modules), you
94should have some EEPROM directories in /sys/bus/i2c/devices/* of names such
95as "0-0050". Inside each of these is a series of files, the eeprom file
96contains the binary data from EEPROM.
diff --git a/Documentation/i2c/chips/fscher b/Documentation/i2c/chips/fscher
new file mode 100644
index 000000000000..64031659aff3
--- /dev/null
+++ b/Documentation/i2c/chips/fscher
@@ -0,0 +1,169 @@
1Kernel driver fscher
2====================
3
4Supported chips:
5 * Fujitsu-Siemens Hermes chip
6 Prefix: 'fscher'
7 Addresses scanned: I2C 0x73
8
9Authors:
10 Reinhard Nissl <rnissl@gmx.de> based on work
11 from Hermann Jung <hej@odn.de>,
12 Frodo Looijaard <frodol@dds.nl>,
13 Philip Edelbrock <phil@netroedge.com>
14
15Description
16-----------
17
18This driver implements support for the Fujitsu-Siemens Hermes chip. It is
19described in the 'Register Set Specification BMC Hermes based Systemboard'
20from Fujitsu-Siemens.
21
22The Hermes chip implements a hardware-based system management, e.g. for
23controlling fan speed and core voltage. There is also a watchdog counter on
24the chip which can trigger an alarm and even shut the system down.
25
26The chip provides three temperature values (CPU, motherboard and
27auxiliary), three voltage values (+12V, +5V and battery) and three fans
28(power supply, CPU and auxiliary).
29
30Temperatures are measured in degrees Celsius. The resolution is 1 degree.
31
32Fan rotation speeds are reported in RPM (rotations per minute). The value
33can be divided by a programmable divider (1, 2 or 4) which is stored on
34the chip.
35
36Voltage sensors (also known as "in" sensors) report their values in volts.
37
38All values are reported as final values from the driver. There is no need
39for further calculations.
40
41
42Detailed description
43--------------------
44
45Below you'll find a single line description of all the bit values. With
46this information, you're able to decode e. g. alarms, wdog, etc. To make
47use of the watchdog, you'll need to set the watchdog time and enable the
48watchdog. After that it is necessary to restart the watchdog time within
49the specified period of time, or a system reset will occur.
50
51* revision
52 READING & 0xff = 0x??: HERMES revision identification
53
54* alarms
55 READING & 0x80 = 0x80: CPU throttling active
56 READING & 0x80 = 0x00: CPU running at full speed
57
58 READING & 0x10 = 0x10: software event (see control:1)
59 READING & 0x10 = 0x00: no software event
60
61 READING & 0x08 = 0x08: watchdog event (see wdog:2)
62 READING & 0x08 = 0x00: no watchdog event
63
64 READING & 0x02 = 0x02: thermal event (see temp*:1)
65 READING & 0x02 = 0x00: no thermal event
66
67 READING & 0x01 = 0x01: fan event (see fan*:1)
68 READING & 0x01 = 0x00: no fan event
69
70 READING & 0x13 ! 0x00: ALERT LED is flashing
71
72* control
73 READING & 0x01 = 0x01: software event
74 READING & 0x01 = 0x00: no software event
75
76 WRITING & 0x01 = 0x01: set software event
77 WRITING & 0x01 = 0x00: clear software event
78
79* watchdog_control
80 READING & 0x80 = 0x80: power off on watchdog event while thermal event
81 READING & 0x80 = 0x00: watchdog power off disabled (just system reset enabled)
82
83 READING & 0x40 = 0x40: watchdog timebase 60 seconds (see also wdog:1)
84 READING & 0x40 = 0x00: watchdog timebase 2 seconds
85
86 READING & 0x10 = 0x10: watchdog enabled
87 READING & 0x10 = 0x00: watchdog disabled
88
89 WRITING & 0x80 = 0x80: enable "power off on watchdog event while thermal event"
90 WRITING & 0x80 = 0x00: disable "power off on watchdog event while thermal event"
91
92 WRITING & 0x40 = 0x40: set watchdog timebase to 60 seconds
93 WRITING & 0x40 = 0x00: set watchdog timebase to 2 seconds
94
95 WRITING & 0x20 = 0x20: disable watchdog
96
97 WRITING & 0x10 = 0x10: enable watchdog / restart watchdog time
98
99* watchdog_state
100 READING & 0x02 = 0x02: watchdog system reset occurred
101 READING & 0x02 = 0x00: no watchdog system reset occurred
102
103 WRITING & 0x02 = 0x02: clear watchdog event
104
105* watchdog_preset
106 READING & 0xff = 0x??: configured watch dog time in units (see wdog:3 0x40)
107
108 WRITING & 0xff = 0x??: configure watch dog time in units
109
110* in* (0: +5V, 1: +12V, 2: onboard 3V battery)
111 READING: actual voltage value
112
113* temp*_status (1: CPU sensor, 2: onboard sensor, 3: auxiliary sensor)
114 READING & 0x02 = 0x02: thermal event (overtemperature)
115 READING & 0x02 = 0x00: no thermal event
116
117 READING & 0x01 = 0x01: sensor is working
118 READING & 0x01 = 0x00: sensor is faulty
119
120 WRITING & 0x02 = 0x02: clear thermal event
121
122* temp*_input (1: CPU sensor, 2: onboard sensor, 3: auxiliary sensor)
123 READING: actual temperature value
124
125* fan*_status (1: power supply fan, 2: CPU fan, 3: auxiliary fan)
126 READING & 0x04 = 0x04: fan event (fan fault)
127 READING & 0x04 = 0x00: no fan event
128
129 WRITING & 0x04 = 0x04: clear fan event
130
131* fan*_div (1: power supply fan, 2: CPU fan, 3: auxiliary fan)
132 Divisors 2,4 and 8 are supported, both for reading and writing
133
134* fan*_pwm (1: power supply fan, 2: CPU fan, 3: auxiliary fan)
135 READING & 0xff = 0x00: fan may be switched off
136 READING & 0xff = 0x01: fan must run at least at minimum speed (supply: 6V)
137 READING & 0xff = 0xff: fan must run at maximum speed (supply: 12V)
138 READING & 0xff = 0x??: fan must run at least at given speed (supply: 6V..12V)
139
140 WRITING & 0xff = 0x00: fan may be switched off
141 WRITING & 0xff = 0x01: fan must run at least at minimum speed (supply: 6V)
142 WRITING & 0xff = 0xff: fan must run at maximum speed (supply: 12V)
143 WRITING & 0xff = 0x??: fan must run at least at given speed (supply: 6V..12V)
144
145* fan*_input (1: power supply fan, 2: CPU fan, 3: auxiliary fan)
146 READING: actual RPM value
147
148
149Limitations
150-----------
151
152* Measuring fan speed
153It seems that the chip counts "ripples" (typical fans produce 2 ripples per
154rotation while VERAX fans produce 18) in a 9-bit register. This register is
155read out every second, then the ripple prescaler (2, 4 or 8) is applied and
156the result is stored in the 8 bit output register. Due to the limitation of
157the counting register to 9 bits, it is impossible to measure a VERAX fan
158properly (even with a prescaler of 8). At its maximum speed of 3500 RPM the
159fan produces 1080 ripples per second which causes the counting register to
160overflow twice, leading to only 186 RPM.
161
162* Measuring input voltages
163in2 ("battery") reports the voltage of the onboard lithium battery and not
164+3.3V from the power supply.
165
166* Undocumented features
167Fujitsu-Siemens Computers has not documented all features of the chip so
168far. Their software, System Guard, shows that there are a still some
169features which cannot be controlled by this implementation.
diff --git a/Documentation/i2c/chips/gl518sm b/Documentation/i2c/chips/gl518sm
new file mode 100644
index 000000000000..ce0881883bca
--- /dev/null
+++ b/Documentation/i2c/chips/gl518sm
@@ -0,0 +1,74 @@
1Kernel driver gl518sm
2=====================
3
4Supported chips:
5 * Genesys Logic GL518SM release 0x00
6 Prefix: 'gl518sm'
7 Addresses scanned: I2C 0x2c and 0x2d
8 Datasheet: http://www.genesyslogic.com/pdf
9 * Genesys Logic GL518SM release 0x80
10 Prefix: 'gl518sm'
11 Addresses scanned: I2C 0x2c and 0x2d
12 Datasheet: http://www.genesyslogic.com/pdf
13
14Authors:
15 Frodo Looijaard <frodol@dds.nl>,
16 Kyösti Mälkki <kmalkki@cc.hut.fi>
17 Hong-Gunn Chew <hglinux@gunnet.org>
18 Jean Delvare <khali@linux-fr.org>
19
20Description
21-----------
22
23IMPORTANT:
24
25For the revision 0x00 chip, the in0, in1, and in2 values (+5V, +3V,
26and +12V) CANNOT be read. This is a limitation of the chip, not the driver.
27
28This driver supports the Genesys Logic GL518SM chip. There are at least
29two revision of this chip, which we call revision 0x00 and 0x80. Revision
300x80 chips support the reading of all voltages and revision 0x00 only
31for VIN3.
32
33The GL518SM implements one temperature sensor, two fan rotation speed
34sensors, and four voltage sensors. It can report alarms through the
35computer speakers.
36
37Temperatures are measured in degrees Celsius. An alarm goes off while the
38temperature is above the over temperature limit, and has not yet dropped
39below the hysteresis limit. The alarm always reflects the current
40situation. Measurements are guaranteed between -10 degrees and +110
41degrees, with a accuracy of +/-3 degrees.
42
43Rotation speeds are reported in RPM (rotations per minute). An alarm is
44triggered if the rotation speed has dropped below a programmable limit. In
45case when you have selected to turn fan1 off, no fan1 alarm is triggered.
46
47Fan readings can be divided by a programmable divider (1, 2, 4 or 8) to
48give the readings more range or accuracy. Not all RPM values can
49accurately be represented, so some rounding is done. With a divider
50of 2, the lowest representable value is around 1900 RPM.
51
52Voltage sensors (also known as VIN sensors) report their values in volts.
53An alarm is triggered if the voltage has crossed a programmable minimum or
54maximum limit. Note that minimum in this case always means 'closest to
55zero'; this is important for negative voltage measurements. The VDD input
56measures voltages between 0.000 and 5.865 volt, with a resolution of 0.023
57volt. The other inputs measure voltages between 0.000 and 4.845 volt, with
58a resolution of 0.019 volt. Note that revision 0x00 chips do not support
59reading the current voltage of any input except for VIN3; limit setting and
60alarms work fine, though.
61
62When an alarm is triggered, you can be warned by a beeping signal through your
63computer speaker. It is possible to enable all beeping globally, or only the
64beeping for some alarms.
65
66If an alarm triggers, it will remain triggered until the hardware register
67is read at least once (except for temperature alarms). This means that the
68cause for the alarm may already have disappeared! Note that in the current
69implementation, all hardware registers are read whenever any data is read
70(unless it is less than 1.5 seconds since the last update). This means that
71you can easily miss once-only alarms.
72
73The GL518SM only updates its values each 1.5 seconds; reading it more often
74will do no harm, but will return 'old' values.
diff --git a/Documentation/i2c/chips/it87 b/Documentation/i2c/chips/it87
new file mode 100644
index 000000000000..0d0195040d88
--- /dev/null
+++ b/Documentation/i2c/chips/it87
@@ -0,0 +1,96 @@
1Kernel driver it87
2==================
3
4Supported chips:
5 * IT8705F
6 Prefix: 'it87'
7 Addresses scanned: from Super I/O config space, or default ISA 0x290 (8 I/O ports)
8 Datasheet: Publicly available at the ITE website
9 http://www.ite.com.tw/
10 * IT8712F
11 Prefix: 'it8712'
12 Addresses scanned: I2C 0x28 - 0x2f
13 from Super I/O config space, or default ISA 0x290 (8 I/O ports)
14 Datasheet: Publicly available at the ITE website
15 http://www.ite.com.tw/
16 * SiS950 [clone of IT8705F]
17 Prefix: 'sis950'
18 Addresses scanned: from Super I/O config space, or default ISA 0x290 (8 I/O ports)
19 Datasheet: No longer be available
20
21Author: Christophe Gauthron <chrisg@0-in.com>
22
23
24Module Parameters
25-----------------
26
27* update_vbat: int
28
29 0 if vbat should report power on value, 1 if vbat should be updated after
30 each read. Default is 0. On some boards the battery voltage is provided
31 by either the battery or the onboard power supply. Only the first reading
32 at power on will be the actual battery voltage (which the chip does
33 automatically). On other boards the battery voltage is always fed to
34 the chip so can be read at any time. Excessive reading may decrease
35 battery life but no information is given in the datasheet.
36
37* fix_pwm_polarity int
38
39 Force PWM polarity to active high (DANGEROUS). Some chips are
40 misconfigured by BIOS - PWM values would be inverted. This option tries
41 to fix this. Please contact your BIOS manufacturer and ask him for fix.
42
43Description
44-----------
45
46This driver implements support for the IT8705F, IT8712F and SiS950 chips.
47
48This driver also supports IT8712F, which adds SMBus access, and a VID
49input, used to report the Vcore voltage of the Pentium processor.
50The IT8712F additionally features VID inputs.
51
52These chips are 'Super I/O chips', supporting floppy disks, infrared ports,
53joysticks and other miscellaneous stuff. For hardware monitoring, they
54include an 'environment controller' with 3 temperature sensors, 3 fan
55rotation speed sensors, 8 voltage sensors, and associated alarms.
56
57Temperatures are measured in degrees Celsius. An alarm is triggered once
58when the Overtemperature Shutdown limit is crossed.
59
60Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
61triggered if the rotation speed has dropped below a programmable limit. Fan
62readings can be divided by a programmable divider (1, 2, 4 or 8) to give the
63readings more range or accuracy. Not all RPM values can accurately be
64represented, so some rounding is done. With a divider of 2, the lowest
65representable value is around 2600 RPM.
66
67Voltage sensors (also known as IN sensors) report their values in volts. An
68alarm is triggered if the voltage has crossed a programmable minimum or
69maximum limit. Note that minimum in this case always means 'closest to
70zero'; this is important for negative voltage measurements. All voltage
71inputs can measure voltages between 0 and 4.08 volts, with a resolution of
720.016 volt. The battery voltage in8 does not have limit registers.
73
74The VID lines (IT8712F only) encode the core voltage value: the voltage
75level your processor should work with. This is hardcoded by the mainboard
76and/or processor itself. It is a value in volts.
77
78If an alarm triggers, it will remain triggered until the hardware register
79is read at least once. This means that the cause for the alarm may already
80have disappeared! Note that in the current implementation, all hardware
81registers are read whenever any data is read (unless it is less than 1.5
82seconds since the last update). This means that you can easily miss
83once-only alarms.
84
85The IT87xx only updates its values each 1.5 seconds; reading it more often
86will do no harm, but will return 'old' values.
87
88To change sensor N to a thermistor, 'echo 2 > tempN_type' where N is 1, 2,
89or 3. To change sensor N to a thermal diode, 'echo 3 > tempN_type'.
90Give 0 for unused sensor. Any other value is invalid. To configure this at
91startup, consult lm_sensors's /etc/sensors.conf. (2 = thermistor;
923 = thermal diode)
93
94The fan speed control features are limited to manual PWM mode. Automatic
95"Smart Guardian" mode control handling is not implemented. However
96if you want to go for "manual mode" just write 1 to pwmN_enable.
diff --git a/Documentation/i2c/chips/lm63 b/Documentation/i2c/chips/lm63
new file mode 100644
index 000000000000..31660bf97979
--- /dev/null
+++ b/Documentation/i2c/chips/lm63
@@ -0,0 +1,57 @@
1Kernel driver lm63
2==================
3
4Supported chips:
5 * National Semiconductor LM63
6 Prefix: 'lm63'
7 Addresses scanned: I2C 0x4c
8 Datasheet: Publicly available at the National Semiconductor website
9 http://www.national.com/pf/LM/LM63.html
10
11Author: Jean Delvare <khali@linux-fr.org>
12
13Thanks go to Tyan and especially Alex Buckingham for setting up a remote
14access to their S4882 test platform for this driver.
15 http://www.tyan.com/
16
17Description
18-----------
19
20The LM63 is a digital temperature sensor with integrated fan monitoring
21and control.
22
23The LM63 is basically an LM86 with fan speed monitoring and control
24capabilities added. It misses some of the LM86 features though:
25 - No low limit for local temperature.
26 - No critical limit for local temperature.
27 - Critical limit for remote temperature can be changed only once. We
28 will consider that the critical limit is read-only.
29
30The datasheet isn't very clear about what the tachometer reading is.
31
32An explanation from National Semiconductor: The two lower bits of the read
33value have to be masked out. The value is still 16 bit in width.
34
35All temperature values are given in degrees Celsius. Resolution is 1.0
36degree for the local temperature, 0.125 degree for the remote temperature.
37
38The fan speed is measured using a tachometer. Contrary to most chips which
39store the value in an 8-bit register and have a selectable clock divider
40to make sure that the result will fit in the register, the LM63 uses 16-bit
41value for measuring the speed of the fan. It can measure fan speeds down to
4283 RPM, at least in theory.
43
44Note that the pin used for fan monitoring is shared with an alert out
45function. Depending on how the board designer wanted to use the chip, fan
46speed monitoring will or will not be possible. The proper chip configuration
47is left to the BIOS, and the driver will blindly trust it.
48
49A PWM output can be used to control the speed of the fan. The LM63 has two
50PWM modes: manual and automatic. Automatic mode is not fully implemented yet
51(you cannot define your custom PWM/temperature curve), and mode change isn't
52supported either.
53
54The lm63 driver will not update its values more frequently than every
55second; reading them more often will do no harm, but will return 'old'
56values.
57
diff --git a/Documentation/i2c/chips/lm75 b/Documentation/i2c/chips/lm75
new file mode 100644
index 000000000000..8e6356fe05d7
--- /dev/null
+++ b/Documentation/i2c/chips/lm75
@@ -0,0 +1,65 @@
1Kernel driver lm75
2==================
3
4Supported chips:
5 * National Semiconductor LM75
6 Prefix: 'lm75'
7 Addresses scanned: I2C 0x48 - 0x4f
8 Datasheet: Publicly available at the National Semiconductor website
9 http://www.national.com/
10 * Dallas Semiconductor DS75
11 Prefix: 'lm75'
12 Addresses scanned: I2C 0x48 - 0x4f
13 Datasheet: Publicly available at the Dallas Semiconductor website
14 http://www.maxim-ic.com/
15 * Dallas Semiconductor DS1775
16 Prefix: 'lm75'
17 Addresses scanned: I2C 0x48 - 0x4f
18 Datasheet: Publicly available at the Dallas Semiconductor website
19 http://www.maxim-ic.com/
20 * Maxim MAX6625, MAX6626
21 Prefix: 'lm75'
22 Addresses scanned: I2C 0x48 - 0x4b
23 Datasheet: Publicly available at the Maxim website
24 http://www.maxim-ic.com/
25 * Microchip (TelCom) TCN75
26 Prefix: 'lm75'
27 Addresses scanned: I2C 0x48 - 0x4f
28 Datasheet: Publicly available at the Microchip website
29 http://www.microchip.com/
30
31Author: Frodo Looijaard <frodol@dds.nl>
32
33Description
34-----------
35
36The LM75 implements one temperature sensor. Limits can be set through the
37Overtemperature Shutdown register and Hysteresis register. Each value can be
38set and read to half-degree accuracy.
39An alarm is issued (usually to a connected LM78) when the temperature
40gets higher then the Overtemperature Shutdown value; it stays on until
41the temperature falls below the Hysteresis value.
42All temperatures are in degrees Celsius, and are guaranteed within a
43range of -55 to +125 degrees.
44
45The LM75 only updates its values each 1.5 seconds; reading it more often
46will do no harm, but will return 'old' values.
47
48The LM75 is usually used in combination with LM78-like chips, to measure
49the temperature of the processor(s).
50
51The DS75, DS1775, MAX6625, and MAX6626 are supported as well.
52They are not distinguished from an LM75. While most of these chips
53have three additional bits of accuracy (12 vs. 9 for the LM75),
54the additional bits are not supported. Not only that, but these chips will
55not be detected if not in 9-bit precision mode (use the force parameter if
56needed).
57
58The TCN75 is supported as well, and is not distinguished from an LM75.
59
60The LM75 is essentially an industry standard; there may be other
61LM75 clones not listed here, with or without various enhancements,
62that are supported.
63
64The LM77 is not supported, contrary to what we pretended for a long time.
65Both chips are simply not compatible, value encoding differs.
diff --git a/Documentation/i2c/chips/lm77 b/Documentation/i2c/chips/lm77
new file mode 100644
index 000000000000..57c3a46d6370
--- /dev/null
+++ b/Documentation/i2c/chips/lm77
@@ -0,0 +1,22 @@
1Kernel driver lm77
2==================
3
4Supported chips:
5 * National Semiconductor LM77
6 Prefix: 'lm77'
7 Addresses scanned: I2C 0x48 - 0x4b
8 Datasheet: Publicly available at the National Semiconductor website
9 http://www.national.com/
10
11Author: Andras BALI <drewie@freemail.hu>
12
13Description
14-----------
15
16The LM77 implements one temperature sensor. The temperature
17sensor incorporates a band-gap type temperature sensor,
1810-bit ADC, and a digital comparator with user-programmable upper
19and lower limit values.
20
21Limits can be set through the Overtemperature Shutdown register and
22Hysteresis register.
diff --git a/Documentation/i2c/chips/lm78 b/Documentation/i2c/chips/lm78
new file mode 100644
index 000000000000..357086ed7f64
--- /dev/null
+++ b/Documentation/i2c/chips/lm78
@@ -0,0 +1,82 @@
1Kernel driver lm78
2==================
3
4Supported chips:
5 * National Semiconductor LM78
6 Prefix: 'lm78'
7 Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)
8 Datasheet: Publicly available at the National Semiconductor website
9 http://www.national.com/
10 * National Semiconductor LM78-J
11 Prefix: 'lm78-j'
12 Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)
13 Datasheet: Publicly available at the National Semiconductor website
14 http://www.national.com/
15 * National Semiconductor LM79
16 Prefix: 'lm79'
17 Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)
18 Datasheet: Publicly available at the National Semiconductor website
19 http://www.national.com/
20
21Author: Frodo Looijaard <frodol@dds.nl>
22
23Description
24-----------
25
26This driver implements support for the National Semiconductor LM78, LM78-J
27and LM79. They are described as 'Microprocessor System Hardware Monitors'.
28
29There is almost no difference between the three supported chips. Functionally,
30the LM78 and LM78-J are exactly identical. The LM79 has one more VID line,
31which is used to report the lower voltages newer Pentium processors use.
32From here on, LM7* means either of these three types.
33
34The LM7* implements one temperature sensor, three fan rotation speed sensors,
35seven voltage sensors, VID lines, alarms, and some miscellaneous stuff.
36
37Temperatures are measured in degrees Celsius. An alarm is triggered once
38when the Overtemperature Shutdown limit is crossed; it is triggered again
39as soon as it drops below the Hysteresis value. A more useful behavior
40can be found by setting the Hysteresis value to +127 degrees Celsius; in
41this case, alarms are issued during all the time when the actual temperature
42is above the Overtemperature Shutdown value. Measurements are guaranteed
43between -55 and +125 degrees, with a resolution of 1 degree.
44
45Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
46triggered if the rotation speed has dropped below a programmable limit. Fan
47readings can be divided by a programmable divider (1, 2, 4 or 8) to give
48the readings more range or accuracy. Not all RPM values can accurately be
49represented, so some rounding is done. With a divider of 2, the lowest
50representable value is around 2600 RPM.
51
52Voltage sensors (also known as IN sensors) report their values in volts.
53An alarm is triggered if the voltage has crossed a programmable minimum
54or maximum limit. Note that minimum in this case always means 'closest to
55zero'; this is important for negative voltage measurements. All voltage
56inputs can measure voltages between 0 and 4.08 volts, with a resolution
57of 0.016 volt.
58
59The VID lines encode the core voltage value: the voltage level your processor
60should work with. This is hardcoded by the mainboard and/or processor itself.
61It is a value in volts. When it is unconnected, you will often find the
62value 3.50 V here.
63
64In addition to the alarms described above, there are a couple of additional
65ones. There is a BTI alarm, which gets triggered when an external chip has
66crossed its limits. Usually, this is connected to all LM75 chips; if at
67least one crosses its limits, this bit gets set. The CHAS alarm triggers
68if your computer case is open. The FIFO alarms should never trigger; it
69indicates an internal error. The SMI_IN alarm indicates some other chip
70has triggered an SMI interrupt. As we do not use SMI interrupts at all,
71this condition usually indicates there is a problem with some other
72device.
73
74If an alarm triggers, it will remain triggered until the hardware register
75is read at least once. This means that the cause for the alarm may
76already have disappeared! Note that in the current implementation, all
77hardware registers are read whenever any data is read (unless it is less
78than 1.5 seconds since the last update). This means that you can easily
79miss once-only alarms.
80
81The LM7* only updates its values each 1.5 seconds; reading it more often
82will do no harm, but will return 'old' values.
diff --git a/Documentation/i2c/chips/lm80 b/Documentation/i2c/chips/lm80
new file mode 100644
index 000000000000..cb5b407ba3e6
--- /dev/null
+++ b/Documentation/i2c/chips/lm80
@@ -0,0 +1,56 @@
1Kernel driver lm80
2==================
3
4Supported chips:
5 * National Semiconductor LM80
6 Prefix: 'lm80'
7 Addresses scanned: I2C 0x28 - 0x2f
8 Datasheet: Publicly available at the National Semiconductor website
9 http://www.national.com/
10
11Authors:
12 Frodo Looijaard <frodol@dds.nl>,
13 Philip Edelbrock <phil@netroedge.com>
14
15Description
16-----------
17
18This driver implements support for the National Semiconductor LM80.
19It is described as a 'Serial Interface ACPI-Compatible Microprocessor
20System Hardware Monitor'.
21
22The LM80 implements one temperature sensor, two fan rotation speed sensors,
23seven voltage sensors, alarms, and some miscellaneous stuff.
24
25Temperatures are measured in degrees Celsius. There are two sets of limits
26which operate independently. When the HOT Temperature Limit is crossed,
27this will cause an alarm that will be reasserted until the temperature
28drops below the HOT Hysteresis. The Overtemperature Shutdown (OS) limits
29should work in the same way (but this must be checked; the datasheet
30is unclear about this). Measurements are guaranteed between -55 and
31+125 degrees. The current temperature measurement has a resolution of
320.0625 degrees; the limits have a resolution of 1 degree.
33
34Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
35triggered if the rotation speed has dropped below a programmable limit. Fan
36readings can be divided by a programmable divider (1, 2, 4 or 8) to give
37the readings more range or accuracy. Not all RPM values can accurately be
38represented, so some rounding is done. With a divider of 2, the lowest
39representable value is around 2600 RPM.
40
41Voltage sensors (also known as IN sensors) report their values in volts.
42An alarm is triggered if the voltage has crossed a programmable minimum
43or maximum limit. Note that minimum in this case always means 'closest to
44zero'; this is important for negative voltage measurements. All voltage
45inputs can measure voltages between 0 and 2.55 volts, with a resolution
46of 0.01 volt.
47
48If an alarm triggers, it will remain triggered until the hardware register
49is read at least once. This means that the cause for the alarm may
50already have disappeared! Note that in the current implementation, all
51hardware registers are read whenever any data is read (unless it is less
52than 2.0 seconds since the last update). This means that you can easily
53miss once-only alarms.
54
55The LM80 only updates its values each 1.5 seconds; reading it more often
56will do no harm, but will return 'old' values.
diff --git a/Documentation/i2c/chips/lm83 b/Documentation/i2c/chips/lm83
new file mode 100644
index 000000000000..061d9ed8ff43
--- /dev/null
+++ b/Documentation/i2c/chips/lm83
@@ -0,0 +1,76 @@
1Kernel driver lm83
2==================
3
4Supported chips:
5 * National Semiconductor LM83
6 Prefix: 'lm83'
7 Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e
8 Datasheet: Publicly available at the National Semiconductor website
9 http://www.national.com/pf/LM/LM83.html
10
11
12Author: Jean Delvare <khali@linux-fr.org>
13
14Description
15-----------
16
17The LM83 is a digital temperature sensor. It senses its own temperature as
18well as the temperature of up to three external diodes. It is compatible
19with many other devices such as the LM84 and all other ADM1021 clones.
20The main difference between the LM83 and the LM84 in that the later can
21only sense the temperature of one external diode.
22
23Using the adm1021 driver for a LM83 should work, but only two temperatures
24will be reported instead of four.
25
26The LM83 is only found on a handful of motherboards. Both a confirmed
27list and an unconfirmed list follow. If you can confirm or infirm the
28fact that any of these motherboards do actually have an LM83, please
29contact us. Note that the LM90 can easily be misdetected as a LM83.
30
31Confirmed motherboards:
32 SBS P014
33
34Unconfirmed motherboards:
35 Gigabyte GA-8IK1100
36 Iwill MPX2
37 Soltek SL-75DRV5
38
39The driver has been successfully tested by Magnus Forsström, who I'd
40like to thank here. More testers will be of course welcome.
41
42The fact that the LM83 is only scarcely used can be easily explained.
43Most motherboards come with more than just temperature sensors for
44health monitoring. They also have voltage and fan rotation speed
45sensors. This means that temperature-only chips are usually used as
46secondary chips coupled with another chip such as an IT8705F or similar
47chip, which provides more features. Since systems usually need three
48temperature sensors (motherboard, processor, power supply) and primary
49chips provide some temperature sensors, the secondary chip, if needed,
50won't have to handle more than two temperatures. Thus, ADM1021 clones
51are sufficient, and there is no need for a four temperatures sensor
52chip such as the LM83. The only case where using an LM83 would make
53sense is on SMP systems, such as the above-mentioned Iwill MPX2,
54because you want an additional temperature sensor for each additional
55CPU.
56
57On the SBS P014, this is different, since the LM83 is the only hardware
58monitoring chipset. One temperature sensor is used for the motherboard
59(actually measuring the LM83's own temperature), one is used for the
60CPU. The two other sensors must be used to measure the temperature of
61two other points of the motherboard. We suspect these points to be the
62north and south bridges, but this couldn't be confirmed.
63
64All temperature values are given in degrees Celsius. Local temperature
65is given within a range of 0 to +85 degrees. Remote temperatures are
66given within a range of 0 to +125 degrees. Resolution is 1.0 degree,
67accuracy is guaranteed to 3.0 degrees (see the datasheet for more
68details).
69
70Each sensor has its own high limit, but the critical limit is common to
71all four sensors. There is no hysteresis mechanism as found on most
72recent temperature sensors.
73
74The lm83 driver will not update its values more frequently than every
75other second; reading them more often will do no harm, but will return
76'old' values.
diff --git a/Documentation/i2c/chips/lm85 b/Documentation/i2c/chips/lm85
new file mode 100644
index 000000000000..9549237530cf
--- /dev/null
+++ b/Documentation/i2c/chips/lm85
@@ -0,0 +1,221 @@
1Kernel driver lm85
2==================
3
4Supported chips:
5 * National Semiconductor LM85 (B and C versions)
6 Prefix: 'lm85'
7 Addresses scanned: I2C 0x2c, 0x2d, 0x2e
8 Datasheet: http://www.national.com/pf/LM/LM85.html
9 * Analog Devices ADM1027
10 Prefix: 'adm1027'
11 Addresses scanned: I2C 0x2c, 0x2d, 0x2e
12 Datasheet: http://www.analog.com/en/prod/0,,766_825_ADM1027,00.html
13 * Analog Devices ADT7463
14 Prefix: 'adt7463'
15 Addresses scanned: I2C 0x2c, 0x2d, 0x2e
16 Datasheet: http://www.analog.com/en/prod/0,,766_825_ADT7463,00.html
17 * SMSC EMC6D100, SMSC EMC6D101
18 Prefix: 'emc6d100'
19 Addresses scanned: I2C 0x2c, 0x2d, 0x2e
20 Datasheet: http://www.smsc.com/main/tools/discontinued/6d100.pdf
21 * SMSC EMC6D102
22 Prefix: 'emc6d102'
23 Addresses scanned: I2C 0x2c, 0x2d, 0x2e
24 Datasheet: http://www.smsc.com/main/catalog/emc6d102.html
25
26Authors:
27 Philip Pokorny <ppokorny@penguincomputing.com>,
28 Frodo Looijaard <frodol@dds.nl>,
29 Richard Barrington <rich_b_nz@clear.net.nz>,
30 Margit Schubert-While <margitsw@t-online.de>,
31 Justin Thiessen <jthiessen@penguincomputing.com>
32
33Description
34-----------
35
36This driver implements support for the National Semiconductor LM85 and
37compatible chips including the Analog Devices ADM1027, ADT7463 and
38SMSC EMC6D10x chips family.
39
40The LM85 uses the 2-wire interface compatible with the SMBUS 2.0
41specification. Using an analog to digital converter it measures three (3)
42temperatures and five (5) voltages. It has four (4) 16-bit counters for
43measuring fan speed. Five (5) digital inputs are provided for sampling the
44VID signals from the processor to the VRM. Lastly, there are three (3) PWM
45outputs that can be used to control fan speed.
46
47The voltage inputs have internal scaling resistors so that the following
48voltage can be measured without external resistors:
49
50 2.5V, 3.3V, 5V, 12V, and CPU core voltage (2.25V)
51
52The temperatures measured are one internal diode, and two remote diodes.
53Remote 1 is generally the CPU temperature. These inputs are designed to
54measure a thermal diode like the one in a Pentium 4 processor in a socket
55423 or socket 478 package. They can also measure temperature using a
56transistor like the 2N3904.
57
58A sophisticated control system for the PWM outputs is designed into the
59LM85 that allows fan speed to be adjusted automatically based on any of the
60three temperature sensors. Each PWM output is individually adjustable and
61programmable. Once configured, the LM85 will adjust the PWM outputs in
62response to the measured temperatures without further host intervention.
63This feature can also be disabled for manual control of the PWM's.
64
65Each of the measured inputs (voltage, temperature, fan speed) has
66corresponding high/low limit values. The LM85 will signal an ALARM if any
67measured value exceeds either limit.
68
69The LM85 samples all inputs continuously. The lm85 driver will not read
70the registers more often than once a second. Further, configuration data is
71only read once each 5 minutes. There is twice as much config data as
72measurements, so this would seem to be a worthwhile optimization.
73
74Special Features
75----------------
76
77The LM85 has four fan speed monitoring modes. The ADM1027 has only two.
78Both have special circuitry to compensate for PWM interactions with the
79TACH signal from the fans. The ADM1027 can be configured to measure the
80speed of a two wire fan, but the input conditioning circuitry is different
81for 3-wire and 2-wire mode. For this reason, the 2-wire fan modes are not
82exposed to user control. The BIOS should initialize them to the correct
83mode. If you've designed your own ADM1027, you'll have to modify the
84init_client function and add an insmod parameter to set this up.
85
86To smooth the response of fans to changes in temperature, the LM85 has an
87optional filter for smoothing temperatures. The ADM1027 has the same
88config option but uses it to rate limit the changes to fan speed instead.
89
90The ADM1027 and ADT7463 have a 10-bit ADC and can therefore measure
91temperatures with 0.25 degC resolution. They also provide an offset to the
92temperature readings that is automatically applied during measurement.
93This offset can be used to zero out any errors due to traces and placement.
94The documentation says that the offset is in 0.25 degC steps, but in
95initial testing of the ADM1027 it was 1.00 degC steps. Analog Devices has
96confirmed this "bug". The ADT7463 is reported to work as described in the
97documentation. The current lm85 driver does not show the offset register.
98
99The ADT7463 has a THERM asserted counter. This counter has a 22.76ms
100resolution and a range of 5.8 seconds. The driver implements a 32-bit
101accumulator of the counter value to extend the range to over a year. The
102counter will stay at it's max value until read.
103
104See the vendor datasheets for more information. There is application note
105from National (AN-1260) with some additional information about the LM85.
106The Analog Devices datasheet is very detailed and describes a procedure for
107determining an optimal configuration for the automatic PWM control.
108
109The SMSC EMC6D100 & EMC6D101 monitor external voltages, temperatures, and
110fan speeds. They use this monitoring capability to alert the system to out
111of limit conditions and can automatically control the speeds of multiple
112fans in a PC or embedded system. The EMC6D101, available in a 24-pin SSOP
113package, and the EMC6D100, available in a 28-pin SSOP package, are designed
114to be register compatible. The EMC6D100 offers all the features of the
115EMC6D101 plus additional voltage monitoring and system control features.
116Unfortunately it is not possible to distinguish between the package
117versions on register level so these additional voltage inputs may read
118zero. The EMC6D102 features addtional ADC bits thus extending precision
119of voltage and temperature channels.
120
121
122Hardware Configurations
123-----------------------
124
125The LM85 can be jumpered for 3 different SMBus addresses. There are
126no other hardware configuration options for the LM85.
127
128The lm85 driver detects both LM85B and LM85C revisions of the chip. See the
129datasheet for a complete description of the differences. Other than
130identifying the chip, the driver behaves no differently with regard to
131these two chips. The LM85B is recommended for new designs.
132
133The ADM1027 and ADT7463 chips have an optional SMBALERT output that can be
134used to signal the chipset in case a limit is exceeded or the temperature
135sensors fail. Individual sensor interrupts can be masked so they won't
136trigger SMBALERT. The SMBALERT output if configured replaces one of the other
137functions (PWM2 or IN0). This functionality is not implemented in current
138driver.
139
140The ADT7463 also has an optional THERM output/input which can be connected
141to the processor PROC_HOT output. If available, the autofan control
142dynamic Tmin feature can be enabled to keep the system temperature within
143spec (just?!) with the least possible fan noise.
144
145Configuration Notes
146-------------------
147
148Besides standard interfaces driver adds following:
149
150* Temperatures and Zones
151
152Each temperature sensor is associated with a Zone. There are three
153sensors and therefore three zones (# 1, 2 and 3). Each zone has the following
154temperature configuration points:
155
156* temp#_auto_temp_off - temperature below which fans should be off or spinning very low.
157* temp#_auto_temp_min - temperature over which fans start to spin.
158* temp#_auto_temp_max - temperature when fans spin at full speed.
159* temp#_auto_temp_crit - temperature when all fans will run full speed.
160
161* PWM Control
162
163There are three PWM outputs. The LM85 datasheet suggests that the
164pwm3 output control both fan3 and fan4. Each PWM can be individually
165configured and assigned to a zone for it's control value. Each PWM can be
166configured individually according to the following options.
167
168* pwm#_auto_pwm_min - this specifies the PWM value for temp#_auto_temp_off
169 temperature. (PWM value from 0 to 255)
170
171* pwm#_auto_pwm_freq - select base frequency of PWM output. You can select
172 in range of 10.0 to 94.0 Hz in .1 Hz units.
173 (Values 100 to 940).
174
175The pwm#_auto_pwm_freq can be set to one of the following 8 values. Setting the
176frequency to a value not on this list, will result in the next higher frequency
177being selected. The actual device frequency may vary slightly from this
178specification as designed by the manufacturer. Consult the datasheet for more
179details. (PWM Frequency values: 100, 150, 230, 300, 380, 470, 620, 940)
180
181* pwm#_auto_pwm_minctl - this flags selects for temp#_auto_temp_off temperature
182 the bahaviour of fans. Write 1 to let fans spinning at
183 pwm#_auto_pwm_min or write 0 to let them off.
184
185NOTE: It has been reported that there is a bug in the LM85 that causes the flag
186to be associated with the zones not the PWMs. This contradicts all the
187published documentation. Setting pwm#_min_ctl in this case actually affects all
188PWMs controlled by zone '#'.
189
190* PWM Controlling Zone selection
191
192* pwm#_auto_channels - controls zone that is associated with PWM
193
194Configuration choices:
195
196 Value Meaning
197 ------ ------------------------------------------------
198 1 Controlled by Zone 1
199 2 Controlled by Zone 2
200 3 Controlled by Zone 3
201 23 Controlled by higher temp of Zone 2 or 3
202 123 Controlled by highest temp of Zone 1, 2 or 3
203 0 PWM always 0% (off)
204 -1 PWM always 100% (full on)
205 -2 Manual control (write to 'pwm#' to set)
206
207The National LM85's have two vendor specific configuration
208features. Tach. mode and Spinup Control. For more details on these,
209see the LM85 datasheet or Application Note AN-1260.
210
211The Analog Devices ADM1027 has several vendor specific enhancements.
212The number of pulses-per-rev of the fans can be set, Tach monitoring
213can be optimized for PWM operation, and an offset can be applied to
214the temperatures to compensate for systemic errors in the
215measurements.
216
217In addition to the ADM1027 features, the ADT7463 also has Tmin control
218and THERM asserted counts. Automatic Tmin control acts to adjust the
219Tmin value to maintain the measured temperature sensor at a specified
220temperature. There isn't much documentation on this feature in the
221ADT7463 data sheet. This is not supported by current driver.
diff --git a/Documentation/i2c/chips/lm87 b/Documentation/i2c/chips/lm87
new file mode 100644
index 000000000000..c952c57f0e11
--- /dev/null
+++ b/Documentation/i2c/chips/lm87
@@ -0,0 +1,73 @@
1Kernel driver lm87
2==================
3
4Supported chips:
5 * National Semiconductor LM87
6 Prefix: 'lm87'
7 Addresses scanned: I2C 0x2c - 0x2f
8 Datasheet: http://www.national.com/pf/LM/LM87.html
9
10Authors:
11 Frodo Looijaard <frodol@dds.nl>,
12 Philip Edelbrock <phil@netroedge.com>,
13 Mark Studebaker <mdsxyz123@yahoo.com>,
14 Stephen Rousset <stephen.rousset@rocketlogix.com>,
15 Dan Eaton <dan.eaton@rocketlogix.com>,
16 Jean Delvare <khali@linux-fr.org>,
17 Original 2.6 port Jeff Oliver
18
19Description
20-----------
21
22This driver implements support for the National Semiconductor LM87.
23
24The LM87 implements up to three temperature sensors, up to two fan
25rotation speed sensors, up to seven voltage sensors, alarms, and some
26miscellaneous stuff.
27
28Temperatures are measured in degrees Celsius. Each input has a high
29and low alarm settings. A high limit produces an alarm when the value
30goes above it, and an alarm is also produced when the value goes below
31the low limit.
32
33Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
34triggered if the rotation speed has dropped below a programmable limit. Fan
35readings can be divided by a programmable divider (1, 2, 4 or 8) to give
36the readings more range or accuracy. Not all RPM values can accurately be
37represented, so some rounding is done. With a divider of 2, the lowest
38representable value is around 2600 RPM.
39
40Voltage sensors (also known as IN sensors) report their values in
41volts. An alarm is triggered if the voltage has crossed a programmable
42minimum or maximum limit. Note that minimum in this case always means
43'closest to zero'; this is important for negative voltage measurements.
44
45If an alarm triggers, it will remain triggered until the hardware register
46is read at least once. This means that the cause for the alarm may
47already have disappeared! Note that in the current implementation, all
48hardware registers are read whenever any data is read (unless it is less
49than 1.0 seconds since the last update). This means that you can easily
50miss once-only alarms.
51
52The lm87 driver only updates its values each 1.0 seconds; reading it more
53often will do no harm, but will return 'old' values.
54
55
56Hardware Configurations
57-----------------------
58
59The LM87 has four pins which can serve one of two possible functions,
60depending on the hardware configuration.
61
62Some functions share pins, so not all functions are available at the same
63time. Which are depends on the hardware setup. This driver assumes that
64the BIOS configured the chip correctly. In that respect, it differs from
65the original driver (from lm_sensors for Linux 2.4), which would force the
66LM87 to an arbitrary, compile-time chosen mode, regardless of the actual
67chipset wiring.
68
69For reference, here is the list of exclusive functions:
70 - in0+in5 (default) or temp3
71 - fan1 (default) or in6
72 - fan2 (default) or in7
73 - VID lines (default) or IRQ lines (not handled by this driver)
diff --git a/Documentation/i2c/chips/lm90 b/Documentation/i2c/chips/lm90
new file mode 100644
index 000000000000..2c4cf39471f4
--- /dev/null
+++ b/Documentation/i2c/chips/lm90
@@ -0,0 +1,121 @@
1Kernel driver lm90
2==================
3
4Supported chips:
5 * National Semiconductor LM90
6 Prefix: 'lm90'
7 Addresses scanned: I2C 0x4c
8 Datasheet: Publicly available at the National Semiconductor website
9 http://www.national.com/pf/LM/LM90.html
10 * National Semiconductor LM89
11 Prefix: 'lm99'
12 Addresses scanned: I2C 0x4c and 0x4d
13 Datasheet: Publicly available at the National Semiconductor website
14 http://www.national.com/pf/LM/LM89.html
15 * National Semiconductor LM99
16 Prefix: 'lm99'
17 Addresses scanned: I2C 0x4c and 0x4d
18 Datasheet: Publicly available at the National Semiconductor website
19 http://www.national.com/pf/LM/LM99.html
20 * National Semiconductor LM86
21 Prefix: 'lm86'
22 Addresses scanned: I2C 0x4c
23 Datasheet: Publicly available at the National Semiconductor website
24 http://www.national.com/pf/LM/LM86.html
25 * Analog Devices ADM1032
26 Prefix: 'adm1032'
27 Addresses scanned: I2C 0x4c
28 Datasheet: Publicly available at the Analog Devices website
29 http://products.analog.com/products/info.asp?product=ADM1032
30 * Analog Devices ADT7461
31 Prefix: 'adt7461'
32 Addresses scanned: I2C 0x4c
33 Datasheet: Publicly available at the Analog Devices website
34 http://products.analog.com/products/info.asp?product=ADT7461
35 Note: Only if in ADM1032 compatibility mode
36 * Maxim MAX6657
37 Prefix: 'max6657'
38 Addresses scanned: I2C 0x4c
39 Datasheet: Publicly available at the Maxim website
40 http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578
41 * Maxim MAX6658
42 Prefix: 'max6657'
43 Addresses scanned: I2C 0x4c
44 Datasheet: Publicly available at the Maxim website
45 http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578
46 * Maxim MAX6659
47 Prefix: 'max6657'
48 Addresses scanned: I2C 0x4c, 0x4d (unsupported 0x4e)
49 Datasheet: Publicly available at the Maxim website
50 http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578
51
52
53Author: Jean Delvare <khali@linux-fr.org>
54
55
56Description
57-----------
58
59The LM90 is a digital temperature sensor. It senses its own temperature as
60well as the temperature of up to one external diode. It is compatible
61with many other devices such as the LM86, the LM89, the LM99, the ADM1032,
62the MAX6657, MAX6658 and the MAX6659 all of which are supported by this driver.
63Note that there is no easy way to differentiate between the last three
64variants. The extra address and features of the MAX6659 are not supported by
65this driver. Additionally, the ADT7461 is supported if found in ADM1032
66compatibility mode.
67
68The specificity of this family of chipsets over the ADM1021/LM84
69family is that it features critical limits with hysteresis, and an
70increased resolution of the remote temperature measurement.
71
72The different chipsets of the family are not strictly identical, although
73very similar. This driver doesn't handle any specific feature for now,
74but could if there ever was a need for it. For reference, here comes a
75non-exhaustive list of specific features:
76
77LM90:
78 * Filter and alert configuration register at 0xBF.
79 * ALERT is triggered by temperatures over critical limits.
80
81LM86 and LM89:
82 * Same as LM90
83 * Better external channel accuracy
84
85LM99:
86 * Same as LM89
87 * External temperature shifted by 16 degrees down
88
89ADM1032:
90 * Consecutive alert register at 0x22.
91 * Conversion averaging.
92 * Up to 64 conversions/s.
93 * ALERT is triggered by open remote sensor.
94
95ADT7461
96 * Extended temperature range (breaks compatibility)
97 * Lower resolution for remote temperature
98
99MAX6657 and MAX6658:
100 * Remote sensor type selection
101
102MAX6659
103 * Selectable address
104 * Second critical temperature limit
105 * Remote sensor type selection
106
107All temperature values are given in degrees Celsius. Resolution
108is 1.0 degree for the local temperature, 0.125 degree for the remote
109temperature.
110
111Each sensor has its own high and low limits, plus a critical limit.
112Additionally, there is a relative hysteresis value common to both critical
113values. To make life easier to user-space applications, two absolute values
114are exported, one for each channel, but these values are of course linked.
115Only the local hysteresis can be set from user-space, and the same delta
116applies to the remote hysteresis.
117
118The lm90 driver will not update its values more frequently than every
119other second; reading them more often will do no harm, but will return
120'old' values.
121
diff --git a/Documentation/i2c/chips/lm92 b/Documentation/i2c/chips/lm92
new file mode 100644
index 000000000000..7705bfaa0708
--- /dev/null
+++ b/Documentation/i2c/chips/lm92
@@ -0,0 +1,37 @@
1Kernel driver lm92
2==================
3
4Supported chips:
5 * National Semiconductor LM92
6 Prefix: 'lm92'
7 Addresses scanned: I2C 0x48 - 0x4b
8 Datasheet: http://www.national.com/pf/LM/LM92.html
9 * National Semiconductor LM76
10 Prefix: 'lm92'
11 Addresses scanned: none, force parameter needed
12 Datasheet: http://www.national.com/pf/LM/LM76.html
13 * Maxim MAX6633/MAX6634/MAX6635
14 Prefix: 'lm92'
15 Addresses scanned: I2C 0x48 - 0x4b
16 MAX6633 with address in 0x40 - 0x47, 0x4c - 0x4f needs force parameter
17 and MAX6634 with address in 0x4c - 0x4f needs force parameter
18 Datasheet: http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3074
19
20Authors:
21 Abraham van der Merwe <abraham@2d3d.co.za>
22 Jean Delvare <khali@linux-fr.org>
23
24
25Description
26-----------
27
28This driver implements support for the National Semiconductor LM92
29temperature sensor.
30
31Each LM92 temperature sensor supports a single temperature sensor. There are
32alarms for high, low, and critical thresholds. There's also an hysteresis to
33control the thresholds for resetting alarms.
34
35Support was added later for the LM76 and Maxim MAX6633/MAX6634/MAX6635,
36which are mostly compatible. They have not all been tested, so you
37may need to use the force parameter.
diff --git a/Documentation/i2c/chips/max1619 b/Documentation/i2c/chips/max1619
new file mode 100644
index 000000000000..d6f8d9cd7d7f
--- /dev/null
+++ b/Documentation/i2c/chips/max1619
@@ -0,0 +1,29 @@
1Kernel driver max1619
2=====================
3
4Supported chips:
5 * Maxim MAX1619
6 Prefix: 'max1619'
7 Addresses scanned: I2C 0x18-0x1a, 0x29-0x2b, 0x4c-0x4e
8 Datasheet: Publicly available at the Maxim website
9 http://pdfserv.maxim-ic.com/en/ds/MAX1619.pdf
10
11Authors:
12 Alexey Fisher <fishor@mail.ru>,
13 Jean Delvare <khali@linux-fr.org>
14
15Description
16-----------
17
18The MAX1619 is a digital temperature sensor. It senses its own temperature as
19well as the temperature of up to one external diode.
20
21All temperature values are given in degrees Celsius. Resolution
22is 1.0 degree for the local temperature and for the remote temperature.
23
24Only the external sensor has high and low limits.
25
26The max1619 driver will not update its values more frequently than every
27other second; reading them more often will do no harm, but will return
28'old' values.
29
diff --git a/Documentation/i2c/chips/max6875 b/Documentation/i2c/chips/max6875
new file mode 100644
index 000000000000..b4fb49b41813
--- /dev/null
+++ b/Documentation/i2c/chips/max6875
@@ -0,0 +1,54 @@
1Kernel driver max6875
2=====================
3
4Supported chips:
5 * Maxim max6874, max6875
6 Prefixes: 'max6875'
7 Addresses scanned: 0x50, 0x52
8 Datasheets:
9 http://pdfserv.maxim-ic.com/en/ds/MAX6874-MAX6875.pdf
10
11Author: Ben Gardner <bgardner@wabtec.com>
12
13
14Module Parameters
15-----------------
16
17* allow_write int
18 Set to non-zero to enable write permission:
19 *0: Read only
20 1: Read and write
21
22
23Description
24-----------
25
26The MAXIM max6875 is a EEPROM-programmable power-supply sequencer/supervisor.
27It provides timed outputs that can be used as a watchdog, if properly wired.
28It also provides 512 bytes of user EEPROM.
29
30At reset, the max6875 reads the configuration eeprom into its configuration
31registers. The chip then begins to operate according to the values in the
32registers.
33
34See the datasheet for details on how to program the EEPROM.
35
36
37Sysfs entries
38-------------
39
40eeprom_user - 512 bytes of user-defined EEPROM space. Only writable if
41 allow_write was set and register 0x43 is 0.
42
43eeprom_config - 70 bytes of config EEPROM. Note that changes will not get
44 loaded into register space until a power cycle or device reset.
45
46reg_config - 70 bytes of register space. Any changes take affect immediately.
47
48
49General Remarks
50---------------
51
52A typical application will require that the EEPROMs be programmed once and
53never altered afterwards.
54
diff --git a/Documentation/i2c/chips/pc87360 b/Documentation/i2c/chips/pc87360
new file mode 100644
index 000000000000..89a8fcfa78df
--- /dev/null
+++ b/Documentation/i2c/chips/pc87360
@@ -0,0 +1,189 @@
1Kernel driver pc87360
2=====================
3
4Supported chips:
5 * National Semiconductor PC87360, PC87363, PC87364, PC87365 and PC87366
6 Prefixes: 'pc87360', 'pc87363', 'pc87364', 'pc87365', 'pc87366'
7 Addresses scanned: none, address read from Super I/O config space
8 Datasheets:
9 http://www.national.com/pf/PC/PC87360.html
10 http://www.national.com/pf/PC/PC87363.html
11 http://www.national.com/pf/PC/PC87364.html
12 http://www.national.com/pf/PC/PC87365.html
13 http://www.national.com/pf/PC/PC87366.html
14
15Authors: Jean Delvare <khali@linux-fr.org>
16
17Thanks to Sandeep Mehta, Tonko de Rooy and Daniel Ceregatti for testing.
18Thanks to Rudolf Marek for helping me investigate conversion issues.
19
20
21Module Parameters
22-----------------
23
24* init int
25 Chip initialization level:
26 0: None
27 *1: Forcibly enable internal voltage and temperature channels, except in9
28 2: Forcibly enable all voltage and temperature channels, except in9
29 3: Forcibly enable all voltage and temperature channels, including in9
30
31Note that this parameter has no effect for the PC87360, PC87363 and PC87364
32chips.
33
34Also note that for the PC87366, initialization levels 2 and 3 don't enable
35all temperature channels, because some of them share pins with each other,
36so they can't be used at the same time.
37
38
39Description
40-----------
41
42The National Semiconductor PC87360 Super I/O chip contains monitoring and
43PWM control circuitry for two fans. The PC87363 chip is similar, and the
44PC87364 chip has monitoring and PWM control for a third fan.
45
46The National Semiconductor PC87365 and PC87366 Super I/O chips are complete
47hardware monitoring chipsets, not only controlling and monitoring three fans,
48but also monitoring eleven voltage inputs and two (PC87365) or up to four
49(PC87366) temperatures.
50
51 Chip #vin #fan #pwm #temp devid
52
53 PC87360 - 2 2 - 0xE1
54 PC87363 - 2 2 - 0xE8
55 PC87364 - 3 3 - 0xE4
56 PC87365 11 3 3 2 0xE5
57 PC87366 11 3 3 3-4 0xE9
58
59The driver assumes that no more than one chip is present, and one of the
60standard Super I/O addresses is used (0x2E/0x2F or 0x4E/0x4F)
61
62Fan Monitoring
63--------------
64
65Fan rotation speeds are reported in RPM (revolutions per minute). An alarm
66is triggered if the rotation speed has dropped below a programmable limit.
67A different alarm is triggered if the fan speed is too low to be measured.
68
69Fan readings are affected by a programmable clock divider, giving the
70readings more range or accuracy. Usually, users have to learn how it works,
71but this driver implements dynamic clock divider selection, so you don't
72have to care no more.
73
74For reference, here are a few values about clock dividers:
75
76 slowest accuracy highest
77 measurable around 3000 accurate
78 divider speed (RPM) RPM (RPM) speed (RPM)
79 1 1882 18 6928
80 2 941 37 4898
81 4 470 74 3464
82 8 235 150 2449
83
84For the curious, here is how the values above were computed:
85 * slowest measurable speed: clock/(255*divider)
86 * accuracy around 3000 RPM: 3000^2/clock
87 * highest accurate speed: sqrt(clock*100)
88The clock speed for the PC87360 family is 480 kHz. I arbitrarily chose 100
89RPM as the lowest acceptable accuracy.
90
91As mentioned above, you don't have to care about this no more.
92
93Note that not all RPM values can be represented, even when the best clock
94divider is selected. This is not only true for the measured speeds, but
95also for the programmable low limits, so don't be surprised if you try to
96set, say, fan1_min to 2900 and it finally reads 2909.
97
98
99Fan Control
100-----------
101
102PWM (pulse width modulation) values range from 0 to 255, with 0 meaning
103that the fan is stopped, and 255 meaning that the fan goes at full speed.
104
105Be extremely careful when changing PWM values. Low PWM values, even
106non-zero, can stop the fan, which may cause irreversible damage to your
107hardware if temperature increases too much. When changing PWM values, go
108step by step and keep an eye on temperatures.
109
110One user reported problems with PWM. Changing PWM values would break fan
111speed readings. No explanation nor fix could be found.
112
113
114Temperature Monitoring
115----------------------
116
117Temperatures are reported in degrees Celsius. Each temperature measured has
118associated low, high and overtemperature limits, each of which triggers an
119alarm when crossed.
120
121The first two temperature channels are external. The third one (PC87366
122only) is internal.
123
124The PC87366 has three additional temperature channels, based on
125thermistors (as opposed to thermal diodes for the first three temperature
126channels). For technical reasons, these channels are held by the VLM
127(voltage level monitor) logical device, not the TMS (temperature
128measurement) one. As a consequence, these temperatures are exported as
129voltages, and converted into temperatures in user-space.
130
131Note that these three additional channels share their pins with the
132external thermal diode channels, so you (physically) can't use them all at
133the same time. Although it should be possible to mix the two sensor types,
134the documents from National Semiconductor suggest that motherboard
135manufacturers should choose one type and stick to it. So you will more
136likely have either channels 1 to 3 (thermal diodes) or 3 to 6 (internal
137thermal diode, and thermistors).
138
139
140Voltage Monitoring
141------------------
142
143Voltages are reported relatively to a reference voltage, either internal or
144external. Some of them (in7:Vsb, in8:Vdd and in10:AVdd) are divided by two
145internally, you will have to compensate in sensors.conf. Others (in0 to in6)
146are likely to be divided externally. The meaning of each of these inputs as
147well as the values of the resistors used for division is left to the
148motherboard manufacturers, so you will have to document yourself and edit
149sensors.conf accordingly. National Semiconductor has a document with
150recommended resistor values for some voltages, but this still leaves much
151room for per motherboard specificities, unfortunately. Even worse,
152motherboard manufacturers don't seem to care about National Semiconductor's
153recommendations.
154
155Each voltage measured has associated low and high limits, each of which
156triggers an alarm when crossed.
157
158When available, VID inputs are used to provide the nominal CPU Core voltage.
159The driver will default to VRM 9.0, but this can be changed from user-space.
160The chipsets can handle two sets of VID inputs (on dual-CPU systems), but
161the driver will only export one for now. This may change later if there is
162a need.
163
164
165General Remarks
166---------------
167
168If an alarm triggers, it will remain triggered until the hardware register
169is read at least once. This means that the cause for the alarm may already
170have disappeared! Note that all hardware registers are read whenever any
171data is read (unless it is less than 2 seconds since the last update, in
172which case cached values are returned instead). As a consequence, when
173a once-only alarm triggers, it may take 2 seconds for it to show, and 2
174more seconds for it to disappear.
175
176Monitoring of in9 isn't enabled at lower init levels (<3) because that
177channel measures the battery voltage (Vbat). It is a known fact that
178repeatedly sampling the battery voltage reduces its lifetime. National
179Semiconductor smartly designed their chipset so that in9 is sampled only
180once every 1024 sampling cycles (that is every 34 minutes at the default
181sampling rate), so the effect is attenuated, but still present.
182
183
184Limitations
185-----------
186
187The datasheets suggests that some values (fan mins, fan dividers)
188shouldn't be changed once the monitoring has started, but we ignore that
189recommendation. We'll reconsider if it actually causes trouble.
diff --git a/Documentation/i2c/chips/pca9539 b/Documentation/i2c/chips/pca9539
new file mode 100644
index 000000000000..c4fce6a13537
--- /dev/null
+++ b/Documentation/i2c/chips/pca9539
@@ -0,0 +1,47 @@
1Kernel driver pca9539
2=====================
3
4Supported chips:
5 * Philips PCA9539
6 Prefix: 'pca9539'
7 Addresses scanned: 0x74 - 0x77
8 Datasheet:
9 http://www.semiconductors.philips.com/acrobat/datasheets/PCA9539_2.pdf
10
11Author: Ben Gardner <bgardner@wabtec.com>
12
13
14Description
15-----------
16
17The Philips PCA9539 is a 16 bit low power I/O device.
18All 16 lines can be individually configured as an input or output.
19The input sense can also be inverted.
20The 16 lines are split between two bytes.
21
22
23Sysfs entries
24-------------
25
26Each is a byte that maps to the 8 I/O bits.
27A '0' suffix is for bits 0-7, while '1' is for bits 8-15.
28
29input[01] - read the current value
30output[01] - sets the output value
31direction[01] - direction of each bit: 1=input, 0=output
32invert[01] - toggle the input bit sense
33
34input reads the actual state of the line and is always available.
35The direction defaults to input for all channels.
36
37
38General Remarks
39---------------
40
41Note that each output, direction, and invert entry controls 8 lines.
42You should use the read, modify, write sequence.
43For example. to set output bit 0 of 1.
44 val=$(cat output0)
45 val=$(( $val | 1 ))
46 echo $val > output0
47
diff --git a/Documentation/i2c/chips/pcf8574 b/Documentation/i2c/chips/pcf8574
new file mode 100644
index 000000000000..2752c8ce3167
--- /dev/null
+++ b/Documentation/i2c/chips/pcf8574
@@ -0,0 +1,69 @@
1Kernel driver pcf8574
2=====================
3
4Supported chips:
5 * Philips PCF8574
6 Prefix: 'pcf8574'
7 Addresses scanned: I2C 0x20 - 0x27
8 Datasheet: Publicly available at the Philips Semiconductors website
9 http://www.semiconductors.philips.com/pip/PCF8574P.html
10
11 * Philips PCF8574A
12 Prefix: 'pcf8574a'
13 Addresses scanned: I2C 0x38 - 0x3f
14 Datasheet: Publicly available at the Philips Semiconductors website
15 http://www.semiconductors.philips.com/pip/PCF8574P.html
16
17Authors:
18 Frodo Looijaard <frodol@dds.nl>,
19 Philip Edelbrock <phil@netroedge.com>,
20 Dan Eaton <dan.eaton@rocketlogix.com>,
21 Aurelien Jarno <aurelien@aurel32.net>,
22 Jean Delvare <khali@linux-fr.org>,
23
24
25Description
26-----------
27The PCF8574(A) is an 8-bit I/O expander for the I2C bus produced by Philips
28Semiconductors. It is designed to provide a byte I2C interface to up to 16
29separate devices (8 x PCF8574 and 8 x PCF8574A).
30
31This device consists of a quasi-bidirectional port. Each of the eight I/Os
32can be independently used as an input or output. To setup an I/O as an
33input, you have to write a 1 to the corresponding output.
34
35For more informations see the datasheet.
36
37
38Accessing PCF8574(A) via /sys interface
39-------------------------------------
40
41! Be careful !
42The PCF8574(A) is plainly impossible to detect ! Stupid chip.
43So every chip with address in the interval [20..27] and [38..3f] are
44detected as PCF8574(A). If you have other chips in this address
45range, the workaround is to load this module after the one
46for your others chips.
47
48On detection (i.e. insmod, modprobe et al.), directories are being
49created for each detected PCF8574(A):
50
51/sys/bus/i2c/devices/<0>-<1>/
52where <0> is the bus the chip was detected on (e. g. i2c-0)
53and <1> the chip address ([20..27] or [38..3f]):
54
55(example: /sys/bus/i2c/devices/1-0020/)
56
57Inside these directories, there are two files each:
58read and write (and one file with chip name).
59
60The read file is read-only. Reading gives you the current I/O input
61if the corresponding output is set as 1, otherwise the current output
62value, that is to say 0.
63
64The write file is read/write. Writing a value outputs it on the I/O
65port. Reading returns the last written value.
66
67On module initialization the chip is configured as eight inputs (all
68outputs to 1), so you can connect any circuit to the PCF8574(A) without
69being afraid of short-circuit.
diff --git a/Documentation/i2c/chips/pcf8591 b/Documentation/i2c/chips/pcf8591
new file mode 100644
index 000000000000..5628fcf4207f
--- /dev/null
+++ b/Documentation/i2c/chips/pcf8591
@@ -0,0 +1,90 @@
1Kernel driver pcf8591
2=====================
3
4Supported chips:
5 * Philips PCF8591
6 Prefix: 'pcf8591'
7 Addresses scanned: I2C 0x48 - 0x4f
8 Datasheet: Publicly available at the Philips Semiconductor website
9 http://www.semiconductors.philips.com/pip/PCF8591P.html
10
11Authors:
12 Aurelien Jarno <aurelien@aurel32.net>
13 valuable contributions by Jan M. Sendler <sendler@sendler.de>,
14 Jean Delvare <khali@linux-fr.org>
15
16
17Description
18-----------
19The PCF8591 is an 8-bit A/D and D/A converter (4 analog inputs and one
20analog output) for the I2C bus produced by Philips Semiconductors. It
21is designed to provide a byte I2C interface to up to 4 separate devices.
22
23The PCF8591 has 4 analog inputs programmable as single-ended or
24differential inputs :
25- mode 0 : four single ended inputs
26 Pins AIN0 to AIN3 are single ended inputs for channels 0 to 3
27
28- mode 1 : three differential inputs
29 Pins AIN3 is the common negative differential input
30 Pins AIN0 to AIN2 are positive differential inputs for channels 0 to 2
31
32- mode 2 : single ended and differential mixed
33 Pins AIN0 and AIN1 are single ended inputs for channels 0 and 1
34 Pins AIN2 is the positive differential input for channel 3
35 Pins AIN3 is the negative differential input for channel 3
36
37- mode 3 : two differential inputs
38 Pins AIN0 is the positive differential input for channel 0
39 Pins AIN1 is the negative differential input for channel 0
40 Pins AIN2 is the positive differential input for channel 1
41 Pins AIN3 is the negative differential input for channel 1
42
43See the datasheet for details.
44
45Module parameters
46-----------------
47
48* input_mode int
49
50 Analog input mode:
51 0 = four single ended inputs
52 1 = three differential inputs
53 2 = single ended and differential mixed
54 3 = two differential inputs
55
56
57Accessing PCF8591 via /sys interface
58-------------------------------------
59
60! Be careful !
61The PCF8591 is plainly impossible to detect ! Stupid chip.
62So every chip with address in the interval [48..4f] is
63detected as PCF8591. If you have other chips in this address
64range, the workaround is to load this module after the one
65for your others chips.
66
67On detection (i.e. insmod, modprobe et al.), directories are being
68created for each detected PCF8591:
69
70/sys/bus/devices/<0>-<1>/
71where <0> is the bus the chip was detected on (e. g. i2c-0)
72and <1> the chip address ([48..4f])
73
74Inside these directories, there are such files:
75in0, in1, in2, in3, out0_enable, out0_output, name
76
77Name contains chip name.
78
79The in0, in1, in2 and in3 files are RO. Reading gives the value of the
80corresponding channel. Depending on the current analog inputs configuration,
81files in2 and/or in3 do not exist. Values range are from 0 to 255 for single
82ended inputs and -128 to +127 for differential inputs (8-bit ADC).
83
84The out0_enable file is RW. Reading gives "1" for analog output enabled and
85"0" for analog output disabled. Writing accepts "0" and "1" accordingly.
86
87The out0_output file is RW. Writing a number between 0 and 255 (8-bit DAC), send
88the value to the digital-to-analog converter. Note that a voltage will
89only appears on AOUT pin if aout0_enable equals 1. Reading returns the last
90value written.
diff --git a/Documentation/i2c/chips/sis5595 b/Documentation/i2c/chips/sis5595
new file mode 100644
index 000000000000..b7ae36b8cdf5
--- /dev/null
+++ b/Documentation/i2c/chips/sis5595
@@ -0,0 +1,106 @@
1Kernel driver sis5595
2=====================
3
4Supported chips:
5 * Silicon Integrated Systems Corp. SiS5595 Southbridge Hardware Monitor
6 Prefix: 'sis5595'
7 Addresses scanned: ISA in PCI-space encoded address
8 Datasheet: Publicly available at the Silicon Integrated Systems Corp. site.
9
10Authors:
11 Kyösti Mälkki <kmalkki@cc.hut.fi>,
12 Mark D. Studebaker <mdsxyz123@yahoo.com>,
13 Aurelien Jarno <aurelien@aurel32.net> 2.6 port
14
15 SiS southbridge has a LM78-like chip integrated on the same IC.
16 This driver is a customized copy of lm78.c
17
18 Supports following revisions:
19 Version PCI ID PCI Revision
20 1 1039/0008 AF or less
21 2 1039/0008 B0 or greater
22
23 Note: these chips contain a 0008 device which is incompatible with the
24 5595. We recognize these by the presence of the listed
25 "blacklist" PCI ID and refuse to load.
26
27 NOT SUPPORTED PCI ID BLACKLIST PCI ID
28 540 0008 0540
29 550 0008 0550
30 5513 0008 5511
31 5581 0008 5597
32 5582 0008 5597
33 5597 0008 5597
34 630 0008 0630
35 645 0008 0645
36 730 0008 0730
37 735 0008 0735
38
39
40Module Parameters
41-----------------
42force_addr=0xaddr Set the I/O base address. Useful for boards
43 that don't set the address in the BIOS. Does not do a
44 PCI force; the device must still be present in lspci.
45 Don't use this unless the driver complains that the
46 base address is not set.
47 Example: 'modprobe sis5595 force_addr=0x290'
48
49
50Description
51-----------
52
53The SiS5595 southbridge has integrated hardware monitor functions. It also
54has an I2C bus, but this driver only supports the hardware monitor. For the
55I2C bus driver see i2c-sis5595.
56
57The SiS5595 implements zero or one temperature sensor, two fan speed
58sensors, four or five voltage sensors, and alarms.
59
60On the first version of the chip, there are four voltage sensors and one
61temperature sensor.
62
63On the second version of the chip, the temperature sensor (temp) and the
64fifth voltage sensor (in4) share a pin which is configurable, but not
65through the driver. Sorry. The driver senses the configuration of the pin,
66which was hopefully set by the BIOS.
67
68Temperatures are measured in degrees Celsius. An alarm is triggered once
69when the max is crossed; it is also triggered when it drops below the min
70value. Measurements are guaranteed between -55 and +125 degrees, with a
71resolution of 1 degree.
72
73Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
74triggered if the rotation speed has dropped below a programmable limit. Fan
75readings can be divided by a programmable divider (1, 2, 4 or 8) to give
76the readings more range or accuracy. Not all RPM values can accurately be
77represented, so some rounding is done. With a divider of 2, the lowest
78representable value is around 2600 RPM.
79
80Voltage sensors (also known as IN sensors) report their values in volts. An
81alarm is triggered if the voltage has crossed a programmable minimum or
82maximum limit. Note that minimum in this case always means 'closest to
83zero'; this is important for negative voltage measurements. All voltage
84inputs can measure voltages between 0 and 4.08 volts, with a resolution of
850.016 volt.
86
87In addition to the alarms described above, there is a BTI alarm, which gets
88triggered when an external chip has crossed its limits. Usually, this is
89connected to some LM75-like chip; if at least one crosses its limits, this
90bit gets set.
91
92If an alarm triggers, it will remain triggered until the hardware register
93is read at least once. This means that the cause for the alarm may already
94have disappeared! Note that in the current implementation, all hardware
95registers are read whenever any data is read (unless it is less than 1.5
96seconds since the last update). This means that you can easily miss
97once-only alarms.
98
99The SiS5595 only updates its values each 1.5 seconds; reading it more often
100will do no harm, but will return 'old' values.
101
102Problems
103--------
104Some chips refuse to be enabled. We don't know why.
105The driver will recognize this and print a message in dmesg.
106
diff --git a/Documentation/i2c/chips/smsc47b397.txt b/Documentation/i2c/chips/smsc47b397
index 389edae7f8df..da9d80c96432 100644
--- a/Documentation/i2c/chips/smsc47b397.txt
+++ b/Documentation/i2c/chips/smsc47b397
@@ -1,7 +1,19 @@
1Kernel driver smsc47b397
2========================
3
4Supported chips:
5 * SMSC LPC47B397-NC
6 Prefix: 'smsc47b397'
7 Addresses scanned: none, address read from Super I/O config space
8 Datasheet: In this file
9
10Authors: Mark M. Hoffman <mhoffman@lightlink.com>
11 Utilitek Systems, Inc.
12
1November 23, 2004 13November 23, 2004
2 14
3The following specification describes the SMSC LPC47B397-NC sensor chip 15The following specification describes the SMSC LPC47B397-NC sensor chip
4(for which there is no public datasheet available). This document was 16(for which there is no public datasheet available). This document was
5provided by Craig Kelly (In-Store Broadcast Network) and edited/corrected 17provided by Craig Kelly (In-Store Broadcast Network) and edited/corrected
6by Mark M. Hoffman <mhoffman@lightlink.com>. 18by Mark M. Hoffman <mhoffman@lightlink.com>.
7 19
@@ -10,10 +22,10 @@ by Mark M. Hoffman <mhoffman@lightlink.com>.
10Methods for detecting the HP SIO and reading the thermal data on a dc7100. 22Methods for detecting the HP SIO and reading the thermal data on a dc7100.
11 23
12The thermal information on the dc7100 is contained in the SIO Hardware Monitor 24The thermal information on the dc7100 is contained in the SIO Hardware Monitor
13(HWM). The information is accessed through an index/data pair. The index/data 25(HWM). The information is accessed through an index/data pair. The index/data
14pair is located at the HWM Base Address + 0 and the HWM Base Address + 1. The 26pair is located at the HWM Base Address + 0 and the HWM Base Address + 1. The
15HWM Base address can be obtained from Logical Device 8, registers 0x60 (MSB) 27HWM Base address can be obtained from Logical Device 8, registers 0x60 (MSB)
16and 0x61 (LSB). Currently we are using 0x480 for the HWM Base Address and 28and 0x61 (LSB). Currently we are using 0x480 for the HWM Base Address and
170x480 and 0x481 for the index/data pair. 290x480 and 0x481 for the index/data pair.
18 30
19Reading temperature information. 31Reading temperature information.
@@ -50,7 +62,7 @@ Reading the tach LSB locks the tach MSB.
50The LSB Must be read first. 62The LSB Must be read first.
51 63
52How to convert the tach reading to RPM. 64How to convert the tach reading to RPM.
53The tach reading (TCount) is given by: (Tach MSB * 256) + (Tach LSB) 65The tach reading (TCount) is given by: (Tach MSB * 256) + (Tach LSB)
54The SIO counts the number of 90kHz (11.111us) pulses per revolution. 66The SIO counts the number of 90kHz (11.111us) pulses per revolution.
55RPM = 60/(TCount * 11.111us) 67RPM = 60/(TCount * 11.111us)
56 68
@@ -72,20 +84,20 @@ To program the configuration registers, the following sequence must be followed:
72 84
73Enter Configuration Mode 85Enter Configuration Mode
74To place the chip into the Configuration State The config key (0x55) is written 86To place the chip into the Configuration State The config key (0x55) is written
75to the CONFIG PORT (0x2E). 87to the CONFIG PORT (0x2E).
76 88
77Configuration Mode 89Configuration Mode
78In configuration mode, the INDEX PORT is located at the CONFIG PORT address and 90In configuration mode, the INDEX PORT is located at the CONFIG PORT address and
79the DATA PORT is at INDEX PORT address + 1. 91the DATA PORT is at INDEX PORT address + 1.
80 92
81The desired configuration registers are accessed in two steps: 93The desired configuration registers are accessed in two steps:
82a. Write the index of the Logical Device Number Configuration Register 94a. Write the index of the Logical Device Number Configuration Register
83 (i.e., 0x07) to the INDEX PORT and then write the number of the 95 (i.e., 0x07) to the INDEX PORT and then write the number of the
84 desired logical device to the DATA PORT. 96 desired logical device to the DATA PORT.
85 97
86b. Write the address of the desired configuration register within the 98b. Write the address of the desired configuration register within the
87 logical device to the INDEX PORT and then write or read the config- 99 logical device to the INDEX PORT and then write or read the config-
88 uration register through the DATA PORT. 100 uration register through the DATA PORT.
89 101
90Note: If accessing the Global Configuration Registers, step (a) is not required. 102Note: If accessing the Global Configuration Registers, step (a) is not required.
91 103
@@ -96,18 +108,18 @@ The chip returns to the RUN State. (This is important).
96Programming Example 108Programming Example
97The following is an example of how to read the SIO Device ID located at 0x20 109The following is an example of how to read the SIO Device ID located at 0x20
98 110
99; ENTER CONFIGURATION MODE 111; ENTER CONFIGURATION MODE
100MOV DX,02EH 112MOV DX,02EH
101MOV AX,055H 113MOV AX,055H
102OUT DX,AL 114OUT DX,AL
103; GLOBAL CONFIGURATION REGISTER 115; GLOBAL CONFIGURATION REGISTER
104MOV DX,02EH 116MOV DX,02EH
105MOV AL,20H 117MOV AL,20H
106OUT DX,AL 118OUT DX,AL
107; READ THE DATA 119; READ THE DATA
108MOV DX,02FH 120MOV DX,02FH
109IN AL,DX 121IN AL,DX
110; EXIT CONFIGURATION MODE 122; EXIT CONFIGURATION MODE
111MOV DX,02EH 123MOV DX,02EH
112MOV AX,0AAH 124MOV AX,0AAH
113OUT DX,AL 125OUT DX,AL
@@ -122,12 +134,12 @@ Obtaining the HWM Base Address.
122The following is an example of how to read the HWM Base Address located in 134The following is an example of how to read the HWM Base Address located in
123Logical Device 8. 135Logical Device 8.
124 136
125; ENTER CONFIGURATION MODE 137; ENTER CONFIGURATION MODE
126MOV DX,02EH 138MOV DX,02EH
127MOV AX,055H 139MOV AX,055H
128OUT DX,AL 140OUT DX,AL
129; CONFIGURE REGISTER CRE0, 141; CONFIGURE REGISTER CRE0,
130; LOGICAL DEVICE 8 142; LOGICAL DEVICE 8
131MOV DX,02EH 143MOV DX,02EH
132MOV AL,07H 144MOV AL,07H
133OUT DX,AL ;Point to LD# Config Reg 145OUT DX,AL ;Point to LD# Config Reg
@@ -135,12 +147,12 @@ MOV DX,02FH
135MOV AL, 08H 147MOV AL, 08H
136OUT DX,AL;Point to Logical Device 8 148OUT DX,AL;Point to Logical Device 8
137; 149;
138MOV DX,02EH 150MOV DX,02EH
139MOV AL,60H 151MOV AL,60H
140OUT DX,AL ; Point to HWM Base Addr MSB 152OUT DX,AL ; Point to HWM Base Addr MSB
141MOV DX,02FH 153MOV DX,02FH
142IN AL,DX ; Get MSB of HWM Base Addr 154IN AL,DX ; Get MSB of HWM Base Addr
143; EXIT CONFIGURATION MODE 155; EXIT CONFIGURATION MODE
144MOV DX,02EH 156MOV DX,02EH
145MOV AX,0AAH 157MOV AX,0AAH
146OUT DX,AL 158OUT DX,AL
diff --git a/Documentation/i2c/chips/smsc47m1 b/Documentation/i2c/chips/smsc47m1
new file mode 100644
index 000000000000..34e6478c1425
--- /dev/null
+++ b/Documentation/i2c/chips/smsc47m1
@@ -0,0 +1,52 @@
1Kernel driver smsc47m1
2======================
3
4Supported chips:
5 * SMSC LPC47B27x, LPC47M10x, LPC47M13x, LPC47M14x, LPC47M15x and LPC47M192
6 Addresses scanned: none, address read from Super I/O config space
7 Prefix: 'smsc47m1'
8 Datasheets:
9 http://www.smsc.com/main/datasheets/47b27x.pdf
10 http://www.smsc.com/main/datasheets/47m10x.pdf
11 http://www.smsc.com/main/tools/discontinued/47m13x.pdf
12 http://www.smsc.com/main/datasheets/47m14x.pdf
13 http://www.smsc.com/main/tools/discontinued/47m15x.pdf
14 http://www.smsc.com/main/datasheets/47m192.pdf
15
16Authors:
17 Mark D. Studebaker <mdsxyz123@yahoo.com>,
18 With assistance from Bruce Allen <ballen@uwm.edu>, and his
19 fan.c program: http://www.lsc-group.phys.uwm.edu/%7Eballen/driver/
20 Gabriele Gorla <gorlik@yahoo.com>,
21 Jean Delvare <khali@linux-fr.org>
22
23Description
24-----------
25
26The Standard Microsystems Corporation (SMSC) 47M1xx Super I/O chips
27contain monitoring and PWM control circuitry for two fans.
28
29The 47M15x and 47M192 chips contain a full 'hardware monitoring block'
30in addition to the fan monitoring and control. The hardware monitoring
31block is not supported by the driver.
32
33Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
34triggered if the rotation speed has dropped below a programmable limit. Fan
35readings can be divided by a programmable divider (1, 2, 4 or 8) to give
36the readings more range or accuracy. Not all RPM values can accurately be
37represented, so some rounding is done. With a divider of 2, the lowest
38representable value is around 2600 RPM.
39
40PWM values are from 0 to 255.
41
42If an alarm triggers, it will remain triggered until the hardware register
43is read at least once. This means that the cause for the alarm may
44already have disappeared! Note that in the current implementation, all
45hardware registers are read whenever any data is read (unless it is less
46than 1.5 seconds since the last update). This means that you can easily
47miss once-only alarms.
48
49
50**********************
51The lm_sensors project gratefully acknowledges the support of
52Intel in the development of this driver.
diff --git a/Documentation/i2c/chips/via686a b/Documentation/i2c/chips/via686a
new file mode 100644
index 000000000000..b82014cb7c53
--- /dev/null
+++ b/Documentation/i2c/chips/via686a
@@ -0,0 +1,65 @@
1Kernel driver via686a
2=====================
3
4Supported chips:
5 * Via VT82C686A, VT82C686B Southbridge Integrated Hardware Monitor
6 Prefix: 'via686a'
7 Addresses scanned: ISA in PCI-space encoded address
8 Datasheet: On request through web form (http://www.via.com.tw/en/support/datasheets/)
9
10Authors:
11 Kyösti Mälkki <kmalkki@cc.hut.fi>,
12 Mark D. Studebaker <mdsxyz123@yahoo.com>
13 Bob Dougherty <bobd@stanford.edu>
14 (Some conversion-factor data were contributed by
15 Jonathan Teh Soon Yew <j.teh@iname.com>
16 and Alex van Kaam <darkside@chello.nl>.)
17
18Module Parameters
19-----------------
20
21force_addr=0xaddr Set the I/O base address. Useful for Asus A7V boards
22 that don't set the address in the BIOS. Does not do a
23 PCI force; the via686a must still be present in lspci.
24 Don't use this unless the driver complains that the
25 base address is not set.
26 Example: 'modprobe via686a force_addr=0x6000'
27
28Description
29-----------
30
31The driver does not distinguish between the chips and reports
32all as a 686A.
33
34The Via 686a southbridge has integrated hardware monitor functionality.
35It also has an I2C bus, but this driver only supports the hardware monitor.
36For the I2C bus driver, see <file:Documentation/i2c/busses/i2c-viapro>
37
38The Via 686a implements three temperature sensors, two fan rotation speed
39sensors, five voltage sensors and alarms.
40
41Temperatures are measured in degrees Celsius. An alarm is triggered once
42when the Overtemperature Shutdown limit is crossed; it is triggered again
43as soon as it drops below the hysteresis value.
44
45Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
46triggered if the rotation speed has dropped below a programmable limit. Fan
47readings can be divided by a programmable divider (1, 2, 4 or 8) to give
48the readings more range or accuracy. Not all RPM values can accurately be
49represented, so some rounding is done. With a divider of 2, the lowest
50representable value is around 2600 RPM.
51
52Voltage sensors (also known as IN sensors) report their values in volts.
53An alarm is triggered if the voltage has crossed a programmable minimum
54or maximum limit. Voltages are internally scalled, so each voltage channel
55has a different resolution and range.
56
57If an alarm triggers, it will remain triggered until the hardware register
58is read at least once. This means that the cause for the alarm may
59already have disappeared! Note that in the current implementation, all
60hardware registers are read whenever any data is read (unless it is less
61than 1.5 seconds since the last update). This means that you can easily
62miss once-only alarms.
63
64The driver only updates its values each 1.5 seconds; reading it more often
65will do no harm, but will return 'old' values.
diff --git a/Documentation/i2c/chips/w83627hf b/Documentation/i2c/chips/w83627hf
new file mode 100644
index 000000000000..78f37c2d602e
--- /dev/null
+++ b/Documentation/i2c/chips/w83627hf
@@ -0,0 +1,66 @@
1Kernel driver w83627hf
2======================
3
4Supported chips:
5 * Winbond W83627HF (ISA accesses ONLY)
6 Prefix: 'w83627hf'
7 Addresses scanned: ISA address retrieved from Super I/O registers
8 Datasheet: http://www.winbond.com/PDF/sheet/w83627hf.pdf
9 * Winbond W83627THF
10 Prefix: 'w83627thf'
11 Addresses scanned: ISA address retrieved from Super I/O registers
12 Datasheet: http://www.winbond.com/PDF/sheet/w83627thf.pdf
13 * Winbond W83697HF
14 Prefix: 'w83697hf'
15 Addresses scanned: ISA address retrieved from Super I/O registers
16 Datasheet: http://www.winbond.com/PDF/sheet/697hf.pdf
17 * Winbond W83637HF
18 Prefix: 'w83637hf'
19 Addresses scanned: ISA address retrieved from Super I/O registers
20 Datasheet: http://www.winbond.com/PDF/sheet/w83637hf.pdf
21
22Authors:
23 Frodo Looijaard <frodol@dds.nl>,
24 Philip Edelbrock <phil@netroedge.com>,
25 Mark Studebaker <mdsxyz123@yahoo.com>,
26 Bernhard C. Schrenk <clemy@clemy.org>
27
28Module Parameters
29-----------------
30
31* force_addr: int
32 Initialize the ISA address of the sensors
33* force_i2c: int
34 Initialize the I2C address of the sensors
35* init: int
36 (default is 1)
37 Use 'init=0' to bypass initializing the chip.
38 Try this if your computer crashes when you load the module.
39
40Description
41-----------
42
43This driver implements support for ISA accesses *only* for
44the Winbond W83627HF, W83627THF, W83697HF and W83637HF Super I/O chips.
45We will refer to them collectively as Winbond chips.
46
47This driver supports ISA accesses, which should be more reliable
48than i2c accesses. Also, for Tyan boards which contain both a
49Super I/O chip and a second i2c-only Winbond chip (often a W83782D),
50using this driver will avoid i2c address conflicts and complex
51initialization that were required in the w83781d driver.
52
53If you really want i2c accesses for these Super I/O chips,
54use the w83781d driver. However this is not the preferred method
55now that this ISA driver has been developed.
56
57Technically, the w83627thf does not support a VID reading. However, it's
58possible or even likely that your mainboard maker has routed these signals
59to a specific set of general purpose IO pins (the Asus P4C800-E is one such
60board). The w83627thf driver now interprets these as VID. If the VID on
61your board doesn't work, first see doc/vid in the lm_sensors package. If
62that still doesn't help, email us at lm-sensors@lm-sensors.org.
63
64For further information on this driver see the w83781d driver
65documentation.
66
diff --git a/Documentation/i2c/chips/w83781d b/Documentation/i2c/chips/w83781d
new file mode 100644
index 000000000000..e5459333ba68
--- /dev/null
+++ b/Documentation/i2c/chips/w83781d
@@ -0,0 +1,402 @@
1Kernel driver w83781d
2=====================
3
4Supported chips:
5 * Winbond W83781D
6 Prefix: 'w83781d'
7 Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)
8 Datasheet: http://www.winbond-usa.com/products/winbond_products/pdfs/PCIC/w83781d.pdf
9 * Winbond W83782D
10 Prefix: 'w83782d'
11 Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)
12 Datasheet: http://www.winbond.com/PDF/sheet/w83782d.pdf
13 * Winbond W83783S
14 Prefix: 'w83783s'
15 Addresses scanned: I2C 0x2d
16 Datasheet: http://www.winbond-usa.com/products/winbond_products/pdfs/PCIC/w83783s.pdf
17 * Winbond W83627HF
18 Prefix: 'w83627hf'
19 Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)
20 Datasheet: http://www.winbond.com/PDF/sheet/w83627hf.pdf
21 * Asus AS99127F
22 Prefix: 'as99127f'
23 Addresses scanned: I2C 0x28 - 0x2f
24 Datasheet: Unavailable from Asus
25
26Authors:
27 Frodo Looijaard <frodol@dds.nl>,
28 Philip Edelbrock <phil@netroedge.com>,
29 Mark Studebaker <mdsxyz123@yahoo.com>
30
31Module parameters
32-----------------
33
34* init int
35 (default 1)
36 Use 'init=0' to bypass initializing the chip.
37 Try this if your computer crashes when you load the module.
38
39force_subclients=bus,caddr,saddr,saddr
40 This is used to force the i2c addresses for subclients of
41 a certain chip. Typical usage is `force_subclients=0,0x2d,0x4a,0x4b'
42 to force the subclients of chip 0x2d on bus 0 to i2c addresses
43 0x4a and 0x4b. This parameter is useful for certain Tyan boards.
44
45Description
46-----------
47
48This driver implements support for the Winbond W83781D, W83782D, W83783S,
49W83627HF chips, and the Asus AS99127F chips. We will refer to them
50collectively as W8378* chips.
51
52There is quite some difference between these chips, but they are similar
53enough that it was sensible to put them together in one driver.
54The W83627HF chip is assumed to be identical to the ISA W83782D.
55The Asus chips are similar to an I2C-only W83782D.
56
57Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA
58as99127f 7 3 0 3 0x31 0x12c3 yes no
59as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no
60w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes
61w83627hf 9 3 2 3 0x21 0x5ca3 yes yes(LPC)
62w83782d 9 3 2-4 3 0x30 0x5ca3 yes yes
63w83783s 5-6 3 2 1-2 0x40 0x5ca3 yes no
64
65Detection of these chips can sometimes be foiled because they can be in
66an internal state that allows no clean access. If you know the address
67of the chip, use a 'force' parameter; this will put them into a more
68well-behaved state first.
69
70The W8378* implements temperature sensors (three on the W83781D and W83782D,
71two on the W83783S), three fan rotation speed sensors, voltage sensors
72(seven on the W83781D, nine on the W83782D and six on the W83783S), VID
73lines, alarms with beep warnings, and some miscellaneous stuff.
74
75Temperatures are measured in degrees Celsius. There is always one main
76temperature sensor, and one (W83783S) or two (W83781D and W83782D) other
77sensors. An alarm is triggered for the main sensor once when the
78Overtemperature Shutdown limit is crossed; it is triggered again as soon as
79it drops below the Hysteresis value. A more useful behavior
80can be found by setting the Hysteresis value to +127 degrees Celsius; in
81this case, alarms are issued during all the time when the actual temperature
82is above the Overtemperature Shutdown value. The driver sets the
83hysteresis value for temp1 to 127 at initialization.
84
85For the other temperature sensor(s), an alarm is triggered when the
86temperature gets higher then the Overtemperature Shutdown value; it stays
87on until the temperature falls below the Hysteresis value. But on the
88W83781D, there is only one alarm that functions for both other sensors!
89Temperatures are guaranteed within a range of -55 to +125 degrees. The
90main temperature sensors has a resolution of 1 degree; the other sensor(s)
91of 0.5 degree.
92
93Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
94triggered if the rotation speed has dropped below a programmable limit. Fan
95readings can be divided by a programmable divider (1, 2, 4 or 8 for the
96W83781D; 1, 2, 4, 8, 16, 32, 64 or 128 for the others) to give
97the readings more range or accuracy. Not all RPM values can accurately
98be represented, so some rounding is done. With a divider of 2, the lowest
99representable value is around 2600 RPM.
100
101Voltage sensors (also known as IN sensors) report their values in volts.
102An alarm is triggered if the voltage has crossed a programmable minimum
103or maximum limit. Note that minimum in this case always means 'closest to
104zero'; this is important for negative voltage measurements. All voltage
105inputs can measure voltages between 0 and 4.08 volts, with a resolution
106of 0.016 volt.
107
108The VID lines encode the core voltage value: the voltage level your processor
109should work with. This is hardcoded by the mainboard and/or processor itself.
110It is a value in volts. When it is unconnected, you will often find the
111value 3.50 V here.
112
113The W83782D and W83783S temperature conversion machine understands about
114several kinds of temperature probes. You can program the so-called
115beta value in the sensor files. '1' is the PII/Celeron diode, '2' is the
116TN3904 transistor, and 3435 the default thermistor value. Other values
117are (not yet) supported.
118
119In addition to the alarms described above, there is a CHAS alarm on the
120chips which triggers if your computer case is open.
121
122When an alarm goes off, you can be warned by a beeping signal through
123your computer speaker. It is possible to enable all beeping globally,
124or only the beeping for some alarms.
125
126If an alarm triggers, it will remain triggered until the hardware register
127is read at least once. This means that the cause for the alarm may
128already have disappeared! Note that in the current implementation, all
129hardware registers are read whenever any data is read (unless it is less
130than 1.5 seconds since the last update). This means that you can easily
131miss once-only alarms.
132
133The chips only update values each 1.5 seconds; reading them more often
134will do no harm, but will return 'old' values.
135
136AS99127F PROBLEMS
137-----------------
138The as99127f support was developed without the benefit of a datasheet.
139In most cases it is treated as a w83781d (although revision 2 of the
140AS99127F looks more like a w83782d).
141This support will be BETA until a datasheet is released.
142One user has reported problems with fans stopping
143occasionally.
144
145Note that the individual beep bits are inverted from the other chips.
146The driver now takes care of this so that user-space applications
147don't have to know about it.
148
149Known problems:
150 - Problems with diode/thermistor settings (supported?)
151 - One user reports fans stopping under high server load.
152 - Revision 2 seems to have 2 PWM registers but we don't know
153 how to handle them. More details below.
154
155These will not be fixed unless we get a datasheet.
156If you have problems, please lobby Asus to release a datasheet.
157Unfortunately several others have without success.
158Please do not send mail to us asking for better as99127f support.
159We have done the best we can without a datasheet.
160Please do not send mail to the author or the sensors group asking for
161a datasheet or ideas on how to convince Asus. We can't help.
162
163
164NOTES:
165-----
166 783s has no in1 so that in[2-6] are compatible with the 781d/782d.
167
168 783s pin is programmable for -5V or temp1; defaults to -5V,
169 no control in driver so temp1 doesn't work.
170
171 782d and 783s datasheets differ on which is pwm1 and which is pwm2.
172 We chose to follow 782d.
173
174 782d and 783s pin is programmable for fan3 input or pwm2 output;
175 defaults to fan3 input.
176 If pwm2 is enabled (with echo 255 1 > pwm2), then
177 fan3 will report 0.
178
179 782d has pwm1-2 for ISA, pwm1-4 for i2c. (pwm3-4 share pins with
180 the ISA pins)
181
182Data sheet updates:
183------------------
184 - PWM clock registers:
185
186 000: master / 512
187 001: master / 1024
188 010: master / 2048
189 011: master / 4096
190 100: master / 8192
191
192
193Answers from Winbond tech support
194---------------------------------
195>
196> 1) In the W83781D data sheet section 7.2 last paragraph, it talks about
197> reprogramming the R-T table if the Beta of the thermistor is not
198> 3435K. The R-T table is described briefly in section 8.20.
199> What formulas do I use to program a new R-T table for a given Beta?
200>
201 We are sorry that the calculation for R-T table value is
202confidential. If you have another Beta value of thermistor, we can help
203to calculate the R-T table for you. But you should give us real R-T
204Table which can be gotten by thermistor vendor. Therefore we will calculate
205them and obtain 32-byte data, and you can fill the 32-byte data to the
206register in Bank0.CR51 of W83781D.
207
208
209> 2) In the W83782D data sheet, it mentions that pins 38, 39, and 40 are
210> programmable to be either thermistor or Pentium II diode inputs.
211> How do I program them for diode inputs? I can't find any register
212> to program these to be diode inputs.
213 --> You may program Bank0 CR[5Dh] and CR[59h] registers.
214
215 CR[5Dh] bit 1(VTIN1) bit 2(VTIN2) bit 3(VTIN3)
216
217 thermistor 0 0 0
218 diode 1 1 1
219
220
221(error) CR[59h] bit 4(VTIN1) bit 2(VTIN2) bit 3(VTIN3)
222(right) CR[59h] bit 4(VTIN1) bit 5(VTIN2) bit 6(VTIN3)
223
224 PII thermal diode 1 1 1
225 2N3904 diode 0 0 0
226
227
228Asus Clones
229-----------
230
231We have no datasheets for the Asus clones (AS99127F and ASB100 Bach).
232Here are some very useful information that were given to us by Alex Van
233Kaam about how to detect these chips, and how to read their values. He
234also gives advice for another Asus chipset, the Mozart-2 (which we
235don't support yet). Thanks Alex!
236I reworded some parts and added personal comments.
237
238# Detection:
239
240AS99127F rev.1, AS99127F rev.2 and ASB100:
241- I2C address range: 0x29 - 0x2F
242- If register 0x58 holds 0x31 then we have an Asus (either ASB100 or
243 AS99127F)
244- Which one depends on register 0x4F (manufacturer ID):
245 0x06 or 0x94: ASB100
246 0x12 or 0xC3: AS99127F rev.1
247 0x5C or 0xA3: AS99127F rev.2
248 Note that 0x5CA3 is Winbond's ID (WEC), which let us think Asus get their
249 AS99127F rev.2 direct from Winbond. The other codes mean ATT and DVC,
250 respectively. ATT could stand for Asustek something (although it would be
251 very badly chosen IMHO), I don't know what DVC could stand for. Maybe
252 these codes simply aren't meant to be decoded that way.
253
254Mozart-2:
255- I2C address: 0x77
256- If register 0x58 holds 0x56 or 0x10 then we have a Mozart-2
257- Of the Mozart there are 3 types:
258 0x58=0x56, 0x4E=0x94, 0x4F=0x36: Asus ASM58 Mozart-2
259 0x58=0x56, 0x4E=0x94, 0x4F=0x06: Asus AS2K129R Mozart-2
260 0x58=0x10, 0x4E=0x5C, 0x4F=0xA3: Asus ??? Mozart-2
261 You can handle all 3 the exact same way :)
262
263# Temperature sensors:
264
265ASB100:
266- sensor 1: register 0x27
267- sensor 2 & 3 are the 2 LM75's on the SMBus
268- sensor 4: register 0x17
269Remark: I noticed that on Intel boards sensor 2 is used for the CPU
270 and 4 is ignored/stuck, on AMD boards sensor 4 is the CPU and sensor 2 is
271 either ignored or a socket temperature.
272
273AS99127F (rev.1 and 2 alike):
274- sensor 1: register 0x27
275- sensor 2 & 3 are the 2 LM75's on the SMBus
276Remark: Register 0x5b is suspected to be temperature type selector. Bit 1
277 would control temp1, bit 3 temp2 and bit 5 temp3.
278
279Mozart-2:
280- sensor 1: register 0x27
281- sensor 2: register 0x13
282
283# Fan sensors:
284
285ASB100, AS99127F (rev.1 and 2 alike):
286- 3 fans, identical to the W83781D
287
288Mozart-2:
289- 2 fans only, 1350000/RPM/div
290- fan 1: register 0x28, divisor on register 0xA1 (bits 4-5)
291- fan 2: register 0x29, divisor on register 0xA1 (bits 6-7)
292
293# Voltages:
294
295This is where there is a difference between AS99127F rev.1 and 2.
296Remark: The difference is similar to the difference between
297 W83781D and W83782D.
298
299ASB100:
300in0=r(0x20)*0.016
301in1=r(0x21)*0.016
302in2=r(0x22)*0.016
303in3=r(0x23)*0.016*1.68
304in4=r(0x24)*0.016*3.8
305in5=r(0x25)*(-0.016)*3.97
306in6=r(0x26)*(-0.016)*1.666
307
308AS99127F rev.1:
309in0=r(0x20)*0.016
310in1=r(0x21)*0.016
311in2=r(0x22)*0.016
312in3=r(0x23)*0.016*1.68
313in4=r(0x24)*0.016*3.8
314in5=r(0x25)*(-0.016)*3.97
315in6=r(0x26)*(-0.016)*1.503
316
317AS99127F rev.2:
318in0=r(0x20)*0.016
319in1=r(0x21)*0.016
320in2=r(0x22)*0.016
321in3=r(0x23)*0.016*1.68
322in4=r(0x24)*0.016*3.8
323in5=(r(0x25)*0.016-3.6)*5.14+3.6
324in6=(r(0x26)*0.016-3.6)*3.14+3.6
325
326Mozart-2:
327in0=r(0x20)*0.016
328in1=255
329in2=r(0x22)*0.016
330in3=r(0x23)*0.016*1.68
331in4=r(0x24)*0.016*4
332in5=255
333in6=255
334
335
336# PWM
337
338Additional info about PWM on the AS99127F (may apply to other Asus
339chips as well) by Jean Delvare as of 2004-04-09:
340
341AS99127F revision 2 seems to have two PWM registers at 0x59 and 0x5A,
342and a temperature sensor type selector at 0x5B (which basically means
343that they swapped registers 0x59 and 0x5B when you compare with Winbond
344chips).
345Revision 1 of the chip also has the temperature sensor type selector at
3460x5B, but PWM registers have no effect.
347
348We don't know exactly how the temperature sensor type selection works.
349Looks like bits 1-0 are for temp1, bits 3-2 for temp2 and bits 5-4 for
350temp3, although it is possible that only the most significant bit matters
351each time. So far, values other than 0 always broke the readings.
352
353PWM registers seem to be split in two parts: bit 7 is a mode selector,
354while the other bits seem to define a value or threshold.
355
356When bit 7 is clear, bits 6-0 seem to hold a threshold value. If the value
357is below a given limit, the fan runs at low speed. If the value is above
358the limit, the fan runs at full speed. We have no clue as to what the limit
359represents. Note that there seem to be some inertia in this mode, speed
360changes may need some time to trigger. Also, an hysteresis mechanism is
361suspected since walking through all the values increasingly and then
362decreasingly led to slightly different limits.
363
364When bit 7 is set, bits 3-0 seem to hold a threshold value, while bits 6-4
365would not be significant. If the value is below a given limit, the fan runs
366at full speed, while if it is above the limit it runs at low speed (so this
367is the contrary of the other mode, in a way). Here again, we don't know
368what the limit is supposed to represent.
369
370One remarkable thing is that the fans would only have two or three
371different speeds (transitional states left apart), not a whole range as
372you usually get with PWM.
373
374As a conclusion, you can write 0x00 or 0x8F to the PWM registers to make
375fans run at low speed, and 0x7F or 0x80 to make them run at full speed.
376
377Please contact us if you can figure out how it is supposed to work. As
378long as we don't know more, the w83781d driver doesn't handle PWM on
379AS99127F chips at all.
380
381Additional info about PWM on the AS99127F rev.1 by Hector Martin:
382
383I've been fiddling around with the (in)famous 0x59 register and
384found out the following values do work as a form of coarse pwm:
385
3860x80 - seems to turn fans off after some time(1-2 minutes)... might be
387some form of auto-fan-control based on temp? hmm (Qfan? this mobo is an
388old ASUS, it isn't marketed as Qfan. Maybe some beta pre-attemp at Qfan
389that was dropped at the BIOS)
3900x81 - off
3910x82 - slightly "on-ner" than off, but my fans do not get to move. I can
392hear the high-pitched PWM sound that motors give off at too-low-pwm.
3930x83 - now they do move. Estimate about 70% speed or so.
3940x84-0x8f - full on
395
396Changing the high nibble doesn't seem to do much except the high bit
397(0x80) must be set for PWM to work, else the current pwm doesn't seem to
398change.
399
400My mobo is an ASUS A7V266-E. This behavior is similar to what I got
401with speedfan under Windows, where 0-15% would be off, 15-2x% (can't
402remember the exact value) would be 70% and higher would be full on.
diff --git a/Documentation/i2c/chips/w83l785ts b/Documentation/i2c/chips/w83l785ts
new file mode 100644
index 000000000000..1841cedc25b2
--- /dev/null
+++ b/Documentation/i2c/chips/w83l785ts
@@ -0,0 +1,39 @@
1Kernel driver w83l785ts
2=======================
3
4Supported chips:
5 * Winbond W83L785TS-S
6 Prefix: 'w83l785ts'
7 Addresses scanned: I2C 0x2e
8 Datasheet: Publicly available at the Winbond USA website
9 http://www.winbond-usa.com/products/winbond_products/pdfs/PCIC/W83L785TS-S.pdf
10
11Authors:
12 Jean Delvare <khali@linux-fr.org>
13
14Description
15-----------
16
17The W83L785TS-S is a digital temperature sensor. It senses the
18temperature of a single external diode. The high limit is
19theoretically defined as 85 or 100 degrees C through a combination
20of external resistors, so the user cannot change it. Values seen so
21far suggest that the two possible limits are actually 95 and 110
22degrees C. The datasheet is rather poor and obviously inaccurate
23on several points including this one.
24
25All temperature values are given in degrees Celsius. Resolution
26is 1.0 degree. See the datasheet for details.
27
28The w83l785ts driver will not update its values more frequently than
29every other second; reading them more often will do no harm, but will
30return 'old' values.
31
32Known Issues
33------------
34
35On some systems (Asus), the BIOS is known to interfere with the driver
36and cause read errors. The driver will retry a given number of times
37(5 by default) and then give up, returning the old value (or 0 if
38there is no old value). It seems to work well enough so that you should
39not notice anything. Thanks to James Bolt for helping test this feature.
diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients
index 56404918eabc..a7adbdd9ea8a 100644
--- a/Documentation/i2c/porting-clients
+++ b/Documentation/i2c/porting-clients
@@ -57,7 +57,7 @@ Technical changes:
57 Documentation/i2c/sysfs-interface for the individual files. Also 57 Documentation/i2c/sysfs-interface for the individual files. Also
58 convert the units these files read and write to the specified ones. 58 convert the units these files read and write to the specified ones.
59 If you need to add a new type of file, please discuss it on the 59 If you need to add a new type of file, please discuss it on the
60 sensors mailing list <sensors@stimpy.netroedge.com> by providing a 60 sensors mailing list <lm-sensors@lm-sensors.org> by providing a
61 patch to the Documentation/i2c/sysfs-interface file. 61 patch to the Documentation/i2c/sysfs-interface file.
62 62
63* [Attach] For I2C drivers, the attach function should make sure 63* [Attach] For I2C drivers, the attach function should make sure
diff --git a/Documentation/i2c/userspace-tools b/Documentation/i2c/userspace-tools
new file mode 100644
index 000000000000..2622aac65422
--- /dev/null
+++ b/Documentation/i2c/userspace-tools
@@ -0,0 +1,39 @@
1Introduction
2------------
3
4Most mainboards have sensor chips to monitor system health (like temperatures,
5voltages, fans speed). They are often connected through an I2C bus, but some
6are also connected directly through the ISA bus.
7
8The kernel drivers make the data from the sensor chips available in the /sys
9virtual filesystem. Userspace tools are then used to display or set or the
10data in a more friendly manner.
11
12Lm-sensors
13----------
14
15Core set of utilites that will allow you to obtain health information,
16setup monitoring limits etc. You can get them on their homepage
17http://www.lm-sensors.nu/ or as a package from your Linux distribution.
18
19If from website:
20Get lmsensors from project web site. Please note, you need only userspace
21part, so compile with "make user_install" target.
22
23General hints to get things working:
24
250) get lm-sensors userspace utils
261) compile all drivers in I2C section as modules in your kernel
272) run sensors-detect script, it will tell you what modules you need to load.
283) load them and run "sensors" command, you should see some results.
294) fix sensors.conf, labels, limits, fan divisors
305) if any more problems consult FAQ, or documentation
31
32Other utilites
33--------------
34
35If you want some graphical indicators of system health look for applications
36like: gkrellm, ksensors, xsensors, wmtemp, wmsensors, wmgtemp, ksysguardd,
37hardware-monitor
38
39If you are server administrator you can try snmpd or mrtgutils.
diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients
index ad27511e3c7d..f482dae81de3 100644
--- a/Documentation/i2c/writing-clients
+++ b/Documentation/i2c/writing-clients
@@ -171,45 +171,31 @@ The following lists are used internally:
171 171
172 normal_i2c: filled in by the module writer. 172 normal_i2c: filled in by the module writer.
173 A list of I2C addresses which should normally be examined. 173 A list of I2C addresses which should normally be examined.
174 normal_i2c_range: filled in by the module writer.
175 A list of pairs of I2C addresses, each pair being an inclusive range of
176 addresses which should normally be examined.
177 probe: insmod parameter. 174 probe: insmod parameter.
178 A list of pairs. The first value is a bus number (-1 for any I2C bus), 175 A list of pairs. The first value is a bus number (-1 for any I2C bus),
179 the second is the address. These addresses are also probed, as if they 176 the second is the address. These addresses are also probed, as if they
180 were in the 'normal' list. 177 were in the 'normal' list.
181 probe_range: insmod parameter.
182 A list of triples. The first value is a bus number (-1 for any I2C bus),
183 the second and third are addresses. These form an inclusive range of
184 addresses that are also probed, as if they were in the 'normal' list.
185 ignore: insmod parameter. 178 ignore: insmod parameter.
186 A list of pairs. The first value is a bus number (-1 for any I2C bus), 179 A list of pairs. The first value is a bus number (-1 for any I2C bus),
187 the second is the I2C address. These addresses are never probed. 180 the second is the I2C address. These addresses are never probed.
188 This parameter overrules 'normal' and 'probe', but not the 'force' lists. 181 This parameter overrules 'normal' and 'probe', but not the 'force' lists.
189 ignore_range: insmod parameter.
190 A list of triples. The first value is a bus number (-1 for any I2C bus),
191 the second and third are addresses. These form an inclusive range of
192 I2C addresses that are never probed.
193 This parameter overrules 'normal' and 'probe', but not the 'force' lists.
194 force: insmod parameter. 182 force: insmod parameter.
195 A list of pairs. The first value is a bus number (-1 for any I2C bus), 183 A list of pairs. The first value is a bus number (-1 for any I2C bus),
196 the second is the I2C address. A device is blindly assumed to be on 184 the second is the I2C address. A device is blindly assumed to be on
197 the given address, no probing is done. 185 the given address, no probing is done.
198 186
199Fortunately, as a module writer, you just have to define the `normal' 187Fortunately, as a module writer, you just have to define the `normal_i2c'
200and/or `normal_range' parameters. The complete declaration could look 188parameter. The complete declaration could look like this:
201like this:
202 189
203 /* Scan 0x20 to 0x2f, 0x37, and 0x40 to 0x4f */ 190 /* Scan 0x37, and 0x48 to 0x4f */
204 static unsigned short normal_i2c[] = { 0x37,I2C_CLIENT_END }; 191 static unsigned short normal_i2c[] = { 0x37, 0x48, 0x49, 0x4a, 0x4b, 0x4c,
205 static unsigned short normal_i2c_range[] = { 0x20, 0x2f, 0x40, 0x4f, 192 0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
206 I2C_CLIENT_END };
207 193
208 /* Magic definition of all other variables and things */ 194 /* Magic definition of all other variables and things */
209 I2C_CLIENT_INSMOD; 195 I2C_CLIENT_INSMOD;
210 196
211Note that you *have* to call the two defined variables `normal_i2c' and 197Note that you *have* to call the defined variable `normal_i2c',
212`normal_i2c_range', without any prefix! 198without any prefix!
213 199
214 200
215Probing classes (sensors) 201Probing classes (sensors)
@@ -223,39 +209,17 @@ The following lists are used internally. They are all lists of integers.
223 209
224 normal_i2c: filled in by the module writer. Terminated by SENSORS_I2C_END. 210 normal_i2c: filled in by the module writer. Terminated by SENSORS_I2C_END.
225 A list of I2C addresses which should normally be examined. 211 A list of I2C addresses which should normally be examined.
226 normal_i2c_range: filled in by the module writer. Terminated by
227 SENSORS_I2C_END
228 A list of pairs of I2C addresses, each pair being an inclusive range of
229 addresses which should normally be examined.
230 normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END. 212 normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END.
231 A list of ISA addresses which should normally be examined. 213 A list of ISA addresses which should normally be examined.
232 normal_isa_range: filled in by the module writer. Terminated by
233 SENSORS_ISA_END
234 A list of triples. The first two elements are ISA addresses, being an
235 range of addresses which should normally be examined. The third is the
236 modulo parameter: only addresses which are 0 module this value relative
237 to the first address of the range are actually considered.
238 probe: insmod parameter. Initialize this list with SENSORS_I2C_END values. 214 probe: insmod parameter. Initialize this list with SENSORS_I2C_END values.
239 A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for 215 A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for
240 the ISA bus, -1 for any I2C bus), the second is the address. These 216 the ISA bus, -1 for any I2C bus), the second is the address. These
241 addresses are also probed, as if they were in the 'normal' list. 217 addresses are also probed, as if they were in the 'normal' list.
242 probe_range: insmod parameter. Initialize this list with SENSORS_I2C_END
243 values.
244 A list of triples. The first value is a bus number (SENSORS_ISA_BUS for
245 the ISA bus, -1 for any I2C bus), the second and third are addresses.
246 These form an inclusive range of addresses that are also probed, as
247 if they were in the 'normal' list.
248 ignore: insmod parameter. Initialize this list with SENSORS_I2C_END values. 218 ignore: insmod parameter. Initialize this list with SENSORS_I2C_END values.
249 A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for 219 A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for
250 the ISA bus, -1 for any I2C bus), the second is the I2C address. These 220 the ISA bus, -1 for any I2C bus), the second is the I2C address. These
251 addresses are never probed. This parameter overrules 'normal' and 221 addresses are never probed. This parameter overrules 'normal' and
252 'probe', but not the 'force' lists. 222 'probe', but not the 'force' lists.
253 ignore_range: insmod parameter. Initialize this list with SENSORS_I2C_END
254 values.
255 A list of triples. The first value is a bus number (SENSORS_ISA_BUS for
256 the ISA bus, -1 for any I2C bus), the second and third are addresses.
257 These form an inclusive range of I2C addresses that are never probed.
258 This parameter overrules 'normal' and 'probe', but not the 'force' lists.
259 223
260Also used is a list of pointers to sensors_force_data structures: 224Also used is a list of pointers to sensors_force_data structures:
261 force_data: insmod parameters. A list, ending with an element of which 225 force_data: insmod parameters. A list, ending with an element of which
@@ -269,16 +233,14 @@ Also used is a list of pointers to sensors_force_data structures:
269So we have a generic insmod variabled `force', and chip-specific variables 233So we have a generic insmod variabled `force', and chip-specific variables
270`force_CHIPNAME'. 234`force_CHIPNAME'.
271 235
272Fortunately, as a module writer, you just have to define the `normal' 236Fortunately, as a module writer, you just have to define the `normal_i2c'
273and/or `normal_range' parameters, and define what chip names are used. 237and `normal_isa' parameters, and define what chip names are used.
274The complete declaration could look like this: 238The complete declaration could look like this:
275 /* Scan i2c addresses 0x20 to 0x2f, 0x37, and 0x40 to 0x4f 239 /* Scan i2c addresses 0x37, and 0x48 to 0x4f */
276 static unsigned short normal_i2c[] = {0x37,SENSORS_I2C_END}; 240 static unsigned short normal_i2c[] = { 0x37, 0x48, 0x49, 0x4a, 0x4b, 0x4c,
277 static unsigned short normal_i2c_range[] = {0x20,0x2f,0x40,0x4f, 241 0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
278 SENSORS_I2C_END};
279 /* Scan ISA address 0x290 */ 242 /* Scan ISA address 0x290 */
280 static unsigned int normal_isa[] = {0x0290,SENSORS_ISA_END}; 243 static unsigned int normal_isa[] = {0x0290,SENSORS_ISA_END};
281 static unsigned int normal_isa_range[] = {SENSORS_ISA_END};
282 244
283 /* Define chips foo and bar, as well as all module parameters and things */ 245 /* Define chips foo and bar, as well as all module parameters and things */
284 SENSORS_INSMOD_2(foo,bar); 246 SENSORS_INSMOD_2(foo,bar);
diff --git a/Documentation/s390/CommonIO b/Documentation/s390/CommonIO
index a831d9ae5a5e..59d1166d41ee 100644
--- a/Documentation/s390/CommonIO
+++ b/Documentation/s390/CommonIO
@@ -30,7 +30,7 @@ Command line parameters
30 device numbers (0xabcd or abcd, for 2.4 backward compatibility). 30 device numbers (0xabcd or abcd, for 2.4 backward compatibility).
31 You can use the 'all' keyword to ignore all devices. 31 You can use the 'all' keyword to ignore all devices.
32 The '!' operator will cause the I/O-layer to _not_ ignore a device. 32 The '!' operator will cause the I/O-layer to _not_ ignore a device.
33 The order on the command line is not important. 33 The command line is parsed from left to right.
34 34
35 For example, 35 For example,
36 cio_ignore=0.0.0023-0.0.0042,0.0.4711 36 cio_ignore=0.0.0023-0.0.0042,0.0.4711
@@ -72,13 +72,14 @@ Command line parameters
72 /proc/cio_ignore; "add <device range>, <device range>, ..." will ignore the 72 /proc/cio_ignore; "add <device range>, <device range>, ..." will ignore the
73 specified devices. 73 specified devices.
74 74
75 Note: Already known devices cannot be ignored. 75 Note: While already known devices can be added to the list of devices to be
76 ignored, there will be no effect on then. However, if such a device
77 disappears and then reappeares, it will then be ignored.
76 78
77 For example, if device 0.0.abcd is already known and all other devices 79 For example,
78 0.0.a000-0.0.afff are not known,
79 "echo add 0.0.a000-0.0.accc, 0.0.af00-0.0.afff > /proc/cio_ignore" 80 "echo add 0.0.a000-0.0.accc, 0.0.af00-0.0.afff > /proc/cio_ignore"
80 will add 0.0.a000-0.0.abcc, 0.0.abce-0.0.accc and 0.0.af00-0.0.afff to the 81 will add 0.0.a000-0.0.accc and 0.0.af00-0.0.afff to the list of ignored
81 list of ignored devices and skip 0.0.abcd. 82 devices.
82 83
83 The devices can be specified either by bus id (0.0.abcd) or, for 2.4 backward 84 The devices can be specified either by bus id (0.0.abcd) or, for 2.4 backward
84 compatibilty, by the device number in hexadecimal (0xabcd or abcd). 85 compatibilty, by the device number in hexadecimal (0xabcd or abcd).
@@ -98,7 +99,8 @@ Command line parameters
98 99
99 - /proc/s390dbf/cio_trace/hex_ascii 100 - /proc/s390dbf/cio_trace/hex_ascii
100 Logs the calling of functions in the common I/O-layer and, if applicable, 101 Logs the calling of functions in the common I/O-layer and, if applicable,
101 which subchannel they were called for. 102 which subchannel they were called for, as well as dumps of some data
103 structures (like irb in an error case).
102 104
103 The level of logging can be changed to be more or less verbose by piping to 105 The level of logging can be changed to be more or less verbose by piping to
104 /proc/s390dbf/cio_*/level a number between 0 and 6; see the documentation on 106 /proc/s390dbf/cio_*/level a number between 0 and 6; see the documentation on
diff --git a/Documentation/sgi-ioc4.txt b/Documentation/sgi-ioc4.txt
new file mode 100644
index 000000000000..876c96ae38db
--- /dev/null
+++ b/Documentation/sgi-ioc4.txt
@@ -0,0 +1,45 @@
1The SGI IOC4 PCI device is a bit of a strange beast, so some notes on
2it are in order.
3
4First, even though the IOC4 performs multiple functions, such as an
5IDE controller, a serial controller, a PS/2 keyboard/mouse controller,
6and an external interrupt mechanism, it's not implemented as a
7multifunction device. The consequence of this from a software
8standpoint is that all these functions share a single IRQ, and
9they can't all register to own the same PCI device ID. To make
10matters a bit worse, some of the register blocks (and even registers
11themselves) present in IOC4 are mixed-purpose between these several
12functions, meaning that there's no clear "owning" device driver.
13
14The solution is to organize the IOC4 driver into several independent
15drivers, "ioc4", "sgiioc4", and "ioc4_serial". Note that there is no
16PS/2 controller driver as this functionality has never been wired up
17on a shipping IO card.
18
19ioc4
20====
21This is the core (or shim) driver for IOC4. It is responsible for
22initializing the basic functionality of the chip, and allocating
23the PCI resources that are shared between the IOC4 functions.
24
25This driver also provides registration functions that the other
26IOC4 drivers can call to make their presence known. Each driver
27needs to provide a probe and remove function, which are invoked
28by the core driver at appropriate times. The interface of these
29IOC4 function probe and remove operations isn't precisely the same
30as PCI device probe and remove operations, but is logically the
31same operation.
32
33sgiioc4
34=======
35This is the IDE driver for IOC4. Its name isn't very descriptive
36simply for historical reasons (it used to be the only IOC4 driver
37component). There's not much to say about it other than it hooks
38up to the ioc4 driver via the appropriate registration, probe, and
39remove functions.
40
41ioc4_serial
42===========
43This is the serial driver for IOC4. There's not much to say about it
44other than it hooks up to the ioc4 driver via the appropriate registration,
45probe, and remove functions.
diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt
index 71ef0498d5e0..104a994b8289 100644
--- a/Documentation/sound/alsa/ALSA-Configuration.txt
+++ b/Documentation/sound/alsa/ALSA-Configuration.txt
@@ -615,9 +615,11 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
615 Module snd-hda-intel 615 Module snd-hda-intel
616 -------------------- 616 --------------------
617 617
618 Module for Intel HD Audio (ICH6, ICH6M, ICH7) 618 Module for Intel HD Audio (ICH6, ICH6M, ICH7), ATI SB450,
619 VIA VT8251/VT8237A
619 620
620 model - force the model name 621 model - force the model name
622 position_fix - Fix DMA pointer (0 = FIFO size, 1 = none, 2 = POSBUF)
621 623
622 Module supports up to 8 cards. 624 Module supports up to 8 cards.
623 625
@@ -635,6 +637,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
635 5stack 5-jack in back, 2-jack in front 637 5stack 5-jack in back, 2-jack in front
636 5stack-digout 5-jack in back, 2-jack in front, a SPDIF out 638 5stack-digout 5-jack in back, 2-jack in front, a SPDIF out
637 w810 3-jack 639 w810 3-jack
640 z71v 3-jack (HP shared SPDIF)
641 asus 3-jack
642 uniwill 3-jack
643 F1734 2-jack
638 644
639 CMI9880 645 CMI9880
640 minimal 3-jack in back 646 minimal 3-jack in back
@@ -642,6 +648,15 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
642 full 6-jack in back, 2-jack in front 648 full 6-jack in back, 2-jack in front
643 full_dig 6-jack in back, 2-jack in front, SPDIF I/O 649 full_dig 6-jack in back, 2-jack in front, SPDIF I/O
644 allout 5-jack in back, 2-jack in front, SPDIF out 650 allout 5-jack in back, 2-jack in front, SPDIF out
651 auto auto-config reading BIOS (default)
652
653 Note 2: If you get click noises on output, try the module option
654 position_fix=1 or 2. position_fix=1 will use the SD_LPIB
655 register value without FIFO size correction as the current
656 DMA pointer. position_fix=2 will make the driver to use
657 the position buffer instead of reading SD_LPIB register.
658 (Usually SD_LPLIB register is more accurate than the
659 position buffer.)
645 660
646 Module snd-hdsp 661 Module snd-hdsp
647 --------------- 662 ---------------
@@ -660,7 +675,19 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
660 module did formerly. It will allocate the buffers in advance 675 module did formerly. It will allocate the buffers in advance
661 when any HDSP cards are found. To make the buffer 676 when any HDSP cards are found. To make the buffer
662 allocation sure, load snd-page-alloc module in the early 677 allocation sure, load snd-page-alloc module in the early
663 stage of boot sequence. 678 stage of boot sequence. See "Early Buffer Allocation"
679 section.
680
681 Module snd-hdspm
682 ----------------
683
684 Module for RME HDSP MADI board.
685
686 precise_ptr - Enable precise pointer, or disable.
687 line_outs_monitor - Send playback streams to analog outs by default.
688 enable_monitor - Enable Analog Out on Channel 63/64 by default.
689
690 See hdspm.txt for details.
664 691
665 Module snd-ice1712 692 Module snd-ice1712
666 ------------------ 693 ------------------
@@ -677,15 +704,19 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
677 * TerraTec EWS 88D 704 * TerraTec EWS 88D
678 * TerraTec EWX 24/96 705 * TerraTec EWX 24/96
679 * TerraTec DMX 6Fire 706 * TerraTec DMX 6Fire
707 * TerraTec Phase 88
680 * Hoontech SoundTrack DSP 24 708 * Hoontech SoundTrack DSP 24
681 * Hoontech SoundTrack DSP 24 Value 709 * Hoontech SoundTrack DSP 24 Value
682 * Hoontech SoundTrack DSP 24 Media 7.1 710 * Hoontech SoundTrack DSP 24 Media 7.1
711 * Event Electronics, EZ8
683 * Digigram VX442 712 * Digigram VX442
713 * Lionstracs, Mediastaton
684 714
685 model - Use the given board model, one of the following: 715 model - Use the given board model, one of the following:
686 delta1010, dio2496, delta66, delta44, audiophile, delta410, 716 delta1010, dio2496, delta66, delta44, audiophile, delta410,
687 delta1010lt, vx442, ewx2496, ews88mt, ews88mt_new, ews88d, 717 delta1010lt, vx442, ewx2496, ews88mt, ews88mt_new, ews88d,
688 dmx6fire, dsp24, dsp24_value, dsp24_71, ez8 718 dmx6fire, dsp24, dsp24_value, dsp24_71, ez8,
719 phase88, mediastation
689 omni - Omni I/O support for MidiMan M-Audio Delta44/66 720 omni - Omni I/O support for MidiMan M-Audio Delta44/66
690 cs8427_timeout - reset timeout for the CS8427 chip (S/PDIF transciever) 721 cs8427_timeout - reset timeout for the CS8427 chip (S/PDIF transciever)
691 in msec resolution, default value is 500 (0.5 sec) 722 in msec resolution, default value is 500 (0.5 sec)
@@ -694,20 +725,46 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
694 is not used with all Envy24 based cards (for example in the MidiMan Delta 725 is not used with all Envy24 based cards (for example in the MidiMan Delta
695 serie). 726 serie).
696 727
728 Note: The supported board is detected by reading EEPROM or PCI
729 SSID (if EEPROM isn't available). You can override the
730 model by passing "model" module option in case that the
731 driver isn't configured properly or you want to try another
732 type for testing.
733
697 Module snd-ice1724 734 Module snd-ice1724
698 ------------------ 735 ------------------
699 736
700 Module for Envy24HT (VT/ICE1724) based PCI sound cards. 737 Module for Envy24HT (VT/ICE1724), Envy24PT (VT1720) based PCI sound cards.
701 * MidiMan M Audio Revolution 7.1 738 * MidiMan M Audio Revolution 7.1
702 * AMP Ltd AUDIO2000 739 * AMP Ltd AUDIO2000
703 * TerraTec Aureon Sky-5.1, Space-7.1 740 * TerraTec Aureon 5.1 Sky
741 * TerraTec Aureon 7.1 Space
742 * TerraTec Aureon 7.1 Universe
743 * TerraTec Phase 22
744 * TerraTec Phase 28
745 * AudioTrak Prodigy 7.1
746 * AudioTrak Prodigy 192
747 * Pontis MS300
748 * Albatron K8X800 Pro II
749 * Chaintech ZNF3-150
750 * Chaintech ZNF3-250
751 * Chaintech 9CJS
752 * Chaintech AV-710
753 * Shuttle SN25P
704 754
705 model - Use the given board model, one of the following: 755 model - Use the given board model, one of the following:
706 revo71, amp2000, prodigy71, aureon51, aureon71, 756 revo71, amp2000, prodigy71, prodigy192, aureon51,
707 k8x800 757 aureon71, universe, k8x800, phase22, phase28, ms300,
758 av710
708 759
709 Module supports up to 8 cards and autoprobe. 760 Module supports up to 8 cards and autoprobe.
710 761
762 Note: The supported board is detected by reading EEPROM or PCI
763 SSID (if EEPROM isn't available). You can override the
764 model by passing "model" module option in case that the
765 driver isn't configured properly or you want to try another
766 type for testing.
767
711 Module snd-intel8x0 768 Module snd-intel8x0
712 ------------------- 769 -------------------
713 770
@@ -1026,7 +1083,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1026 module did formerly. It will allocate the buffers in advance 1083 module did formerly. It will allocate the buffers in advance
1027 when any RME9652 cards are found. To make the buffer 1084 when any RME9652 cards are found. To make the buffer
1028 allocation sure, load snd-page-alloc module in the early 1085 allocation sure, load snd-page-alloc module in the early
1029 stage of boot sequence. 1086 stage of boot sequence. See "Early Buffer Allocation"
1087 section.
1030 1088
1031 Module snd-sa11xx-uda1341 (on arm only) 1089 Module snd-sa11xx-uda1341 (on arm only)
1032 --------------------------------------- 1090 ---------------------------------------
@@ -1211,16 +1269,18 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1211 ------------------ 1269 ------------------
1212 1270
1213 Module for AC'97 motherboards based on VIA 82C686A/686B, 8233, 1271 Module for AC'97 motherboards based on VIA 82C686A/686B, 8233,
1214 8233A, 8233C, 8235 (south) bridge. 1272 8233A, 8233C, 8235, 8237 (south) bridge.
1215 1273
1216 mpu_port - 0x300,0x310,0x320,0x330, otherwise obtain BIOS setup 1274 mpu_port - 0x300,0x310,0x320,0x330, otherwise obtain BIOS setup
1217 [VIA686A/686B only] 1275 [VIA686A/686B only]
1218 joystick - Enable joystick (default off) [VIA686A/686B only] 1276 joystick - Enable joystick (default off) [VIA686A/686B only]
1219 ac97_clock - AC'97 codec clock base (default 48000Hz) 1277 ac97_clock - AC'97 codec clock base (default 48000Hz)
1220 dxs_support - support DXS channels, 1278 dxs_support - support DXS channels,
1221 0 = auto (defalut), 1 = enable, 2 = disable, 1279 0 = auto (default), 1 = enable, 2 = disable,
1222 3 = 48k only, 4 = no VRA 1280 3 = 48k only, 4 = no VRA, 5 = enable any sample
1223 [VIA8233/C,8235 only] 1281 rate and different sample rates on different
1282 channels
1283 [VIA8233/C, 8235, 8237 only]
1224 ac97_quirk - AC'97 workaround for strange hardware 1284 ac97_quirk - AC'97 workaround for strange hardware
1225 See the description of intel8x0 module for details. 1285 See the description of intel8x0 module for details.
1226 1286
@@ -1232,18 +1292,23 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
1232 default value 1.4. Then the interrupt number will be 1292 default value 1.4. Then the interrupt number will be
1233 assigned under 15. You might also upgrade your BIOS. 1293 assigned under 15. You might also upgrade your BIOS.
1234 1294
1235 Note: VIA8233/5 (not VIA8233A) can support DXS (direct sound) 1295 Note: VIA8233/5/7 (not VIA8233A) can support DXS (direct sound)
1236 channels as the first PCM. On these channels, up to 4 1296 channels as the first PCM. On these channels, up to 4
1237 streams can be played at the same time. 1297 streams can be played at the same time, and the controller
1298 can perform sample rate conversion with separate rates for
1299 each channel.
1238 As default (dxs_support = 0), 48k fixed rate is chosen 1300 As default (dxs_support = 0), 48k fixed rate is chosen
1239 except for the known devices since the output is often 1301 except for the known devices since the output is often
1240 noisy except for 48k on some mother boards due to the 1302 noisy except for 48k on some mother boards due to the
1241 bug of BIOS. 1303 bug of BIOS.
1242 Please try once dxs_support=1 and if it works on other 1304 Please try once dxs_support=5 and if it works on other
1243 sample rates (e.g. 44.1kHz of mp3 playback), please let us 1305 sample rates (e.g. 44.1kHz of mp3 playback), please let us
1244 know the PCI subsystem vendor/device id's (output of 1306 know the PCI subsystem vendor/device id's (output of
1245 "lspci -nv"). 1307 "lspci -nv").
1246 If it doesn't work, try dxs_support=4. If it still doesn't 1308 If dxs_support=5 does not work, try dxs_support=4; if it
1309 doesn't work too, try dxs_support=1. (dxs_support=1 is
1310 usually for old motherboards. The correct implementated
1311 board should work with 4 or 5.) If it still doesn't
1247 work and the default setting is ok, dxs_support=3 is the 1312 work and the default setting is ok, dxs_support=3 is the
1248 right choice. If the default setting doesn't work at all, 1313 right choice. If the default setting doesn't work at all,
1249 try dxs_support=2 to disable the DXS channels. 1314 try dxs_support=2 to disable the DXS channels.
@@ -1497,6 +1562,36 @@ Proc interfaces (/proc/asound)
1497 echo "rvplayer 0 0 block" > /proc/asound/card0/pcm0p/oss 1562 echo "rvplayer 0 0 block" > /proc/asound/card0/pcm0p/oss
1498 1563
1499 1564
1565Early Buffer Allocation
1566=======================
1567
1568Some drivers (e.g. hdsp) require the large contiguous buffers, and
1569sometimes it's too late to find such spaces when the driver module is
1570actually loaded due to memory fragmentation. You can pre-allocate the
1571PCM buffers by loading snd-page-alloc module and write commands to its
1572proc file in prior, for example, in the early boot stage like
1573/etc/init.d/*.local scripts.
1574
1575Reading the proc file /proc/drivers/snd-page-alloc shows the current
1576usage of page allocation. In writing, you can send the following
1577commands to the snd-page-alloc driver:
1578
1579 - add VENDOR DEVICE MASK SIZE BUFFERS
1580
1581 VENDOR and DEVICE are PCI vendor and device IDs. They take
1582 integer numbers (0x prefix is needed for the hex).
1583 MASK is the PCI DMA mask. Pass 0 if not restricted.
1584 SIZE is the size of each buffer to allocate. You can pass
1585 k and m suffix for KB and MB. The max number is 16MB.
1586 BUFFERS is the number of buffers to allocate. It must be greater
1587 than 0. The max number is 4.
1588
1589 - erase
1590
1591 This will erase the all pre-allocated buffers which are not in
1592 use.
1593
1594
1500Links 1595Links
1501===== 1596=====
1502 1597
diff --git a/Documentation/sound/alsa/CMIPCI.txt b/Documentation/sound/alsa/CMIPCI.txt
index 4a7df771b806..1872e24442a4 100644
--- a/Documentation/sound/alsa/CMIPCI.txt
+++ b/Documentation/sound/alsa/CMIPCI.txt
@@ -89,19 +89,22 @@ and use the interleaved 4 channel data.
89 89
90There are some control switchs affecting to the speaker connections: 90There are some control switchs affecting to the speaker connections:
91 91
92"Line-In As Rear" - As mentioned above, the line-in jack is used 92"Line-In Mode" - an enum control to change the behavior of line-in
93 for the rear (3th and 4th channels) output. 93 jack. Either "Line-In", "Rear Output" or "Bass Output" can
94"Line-In As Bass" - The line-in jack is used for the bass (5th 94 be selected. The last item is available only with model 039
95 and 6th channels) output. 95 or newer.
96"Mic As Center/LFE" - The mic jack is used for the bass output. 96 When "Rear Output" is chosen, the surround channels 3 and 4
97 If this switch is on, you cannot use a microphone as a capture 97 are output to line-in jack.
98 source, of course. 98"Mic-In Mode" - an enum control to change the behavior of mic-in
99 99 jack. Either "Mic-In" or "Center/LFE Output" can be
100 selected.
101 When "Center/LFE Output" is chosen, the center and bass
102 channels (channels 5 and 6) are output to mic-in jack.
100 103
101Digital I/O 104Digital I/O
102----------- 105-----------
103 106
104The CM8x38 provides the excellent SPDIF capability with very chip 107The CM8x38 provides the excellent SPDIF capability with very cheap
105price (yes, that's the reason I bought the card :) 108price (yes, that's the reason I bought the card :)
106 109
107The SPDIF playback and capture are done via the third PCM device 110The SPDIF playback and capture are done via the third PCM device
@@ -122,8 +125,9 @@ respectively, so you cannot playback both analog and digital streams
122simultaneously. 125simultaneously.
123 126
124To enable SPDIF output, you need to turn on "IEC958 Output Switch" 127To enable SPDIF output, you need to turn on "IEC958 Output Switch"
125control via mixer or alsactl. Then you'll see the red light on from 128control via mixer or alsactl ("IEC958" is the official name of
126the card so you know that's working obviously :) 129so-called S/PDIF). Then you'll see the red light on from the card so
130you know that's working obviously :)
127The SPDIF input is always enabled, so you can hear SPDIF input data 131The SPDIF input is always enabled, so you can hear SPDIF input data
128from line-out with "IEC958 In Monitor" switch at any time (see 132from line-out with "IEC958 In Monitor" switch at any time (see
129below). 133below).
@@ -205,9 +209,10 @@ In addition to the standard SB mixer, CM8x38 provides more functions.
205MIDI CONTROLLER 209MIDI CONTROLLER
206--------------- 210---------------
207 211
208The MPU401-UART interface is enabled as default only for the first 212The MPU401-UART interface is disabled as default. You need to set
209(CMIPCI) card. You need to set module option "midi_port" properly 213module option "mpu_port" with a valid I/O port address to enable the
210for the 2nd (CMIPCI) card. 214MIDI support. The valid I/O ports are 0x300, 0x310, 0x320 and 0x330.
215Choose the value which doesn't conflict with other cards.
211 216
212There is _no_ hardware wavetable function on this chip (except for 217There is _no_ hardware wavetable function on this chip (except for
213OPL3 synth below). 218OPL3 synth below).
@@ -229,9 +234,11 @@ I don't know why..
229Joystick and Modem 234Joystick and Modem
230------------------ 235------------------
231 236
232The joystick and modem should be available by enabling the control 237The legacy joystick is supported. To enable the joystick support, pass
233switch "Joystick" and "Modem" respectively. But I myself have never 238joystick_port=1 module option. The value 1 means the auto-detection.
234tested them yet. 239If the auto-detection fails, try to pass the exact I/O address.
240
241The modem is enabled dynamically via a card control switch "Modem".
235 242
236 243
237Debugging Information 244Debugging Information
diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
index e789475304b6..db0b7d2dc477 100644
--- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
+++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl
@@ -371,7 +371,7 @@
371 <listitem><para>create <function>probe()</function> callback.</para></listitem> 371 <listitem><para>create <function>probe()</function> callback.</para></listitem>
372 <listitem><para>create <function>remove()</function> callback.</para></listitem> 372 <listitem><para>create <function>remove()</function> callback.</para></listitem>
373 <listitem><para>create pci_driver table which contains the three pointers above.</para></listitem> 373 <listitem><para>create pci_driver table which contains the three pointers above.</para></listitem>
374 <listitem><para>create <function>init()</function> function just calling <function>pci_module_init()</function> to register the pci_driver table defined above.</para></listitem> 374 <listitem><para>create <function>init()</function> function just calling <function>pci_register_driver()</function> to register the pci_driver table defined above.</para></listitem>
375 <listitem><para>create <function>exit()</function> function to call <function>pci_unregister_driver()</function> function.</para></listitem> 375 <listitem><para>create <function>exit()</function> function to call <function>pci_unregister_driver()</function> function.</para></listitem>
376 </itemizedlist> 376 </itemizedlist>
377 </para> 377 </para>
@@ -1198,7 +1198,7 @@
1198 /* initialization of the module */ 1198 /* initialization of the module */
1199 static int __init alsa_card_mychip_init(void) 1199 static int __init alsa_card_mychip_init(void)
1200 { 1200 {
1201 return pci_module_init(&driver); 1201 return pci_register_driver(&driver);
1202 } 1202 }
1203 1203
1204 /* clean up the module */ 1204 /* clean up the module */
@@ -1654,7 +1654,7 @@
1654<![CDATA[ 1654<![CDATA[
1655 static int __init alsa_card_mychip_init(void) 1655 static int __init alsa_card_mychip_init(void)
1656 { 1656 {
1657 return pci_module_init(&driver); 1657 return pci_register_driver(&driver);
1658 } 1658 }
1659 1659
1660 static void __exit alsa_card_mychip_exit(void) 1660 static void __exit alsa_card_mychip_exit(void)
diff --git a/Documentation/sound/alsa/emu10k1-jack.txt b/Documentation/sound/alsa/emu10k1-jack.txt
new file mode 100644
index 000000000000..751d45036a05
--- /dev/null
+++ b/Documentation/sound/alsa/emu10k1-jack.txt
@@ -0,0 +1,74 @@
1This document is a guide to using the emu10k1 based devices with JACK for low
2latency, multichannel recording functionality. All of my recent work to allow
3Linux users to use the full capabilities of their hardware has been inspired
4by the kX Project. Without their work I never would have discovered the true
5power of this hardware.
6
7 http://www.kxproject.com
8 - Lee Revell, 2005.03.30
9
10Low latency, multichannel audio with JACK and the emu10k1/emu10k2
11-----------------------------------------------------------------
12
13Until recently, emu10k1 users on Linux did not have access to the same low
14latency, multichannel features offered by the "kX ASIO" feature of their
15Windows driver. As of ALSA 1.0.9 this is no more!
16
17For those unfamiliar with kX ASIO, this consists of 16 capture and 16 playback
18channels. With a post 2.6.9 Linux kernel, latencies down to 64 (1.33 ms) or
19even 32 (0.66ms) frames should work well.
20
21The configuration is slightly more involved than on Windows, as you have to
22select the correct device for JACK to use. Actually, for qjackctl users it's
23fairly self explanatory - select Duplex, then for capture and playback select
24the multichannel devices, set the in and out channels to 16, and the sample
25rate to 48000Hz. The command line looks like this:
26
27/usr/local/bin/jackd -R -dalsa -r48000 -p64 -n2 -D -Chw:0,2 -Phw:0,3 -S
28
29This will give you 16 input ports and 16 output ports.
30
31The 16 output ports map onto the 16 FX buses (or the first 16 of 64, for the
32Audigy). The mapping from FX bus to physical output is described in
33SB-Live-mixer.txt (or Audigy-mixer.txt).
34
35The 16 input ports are connected to the 16 physical inputs. Contrary to
36popular belief, all emu10k1 cards are multichannel cards. Which of these
37input channels have physical inputs connected to them depends on the card
38model. Trial and error is highly recommended; the pinout diagrams
39for the card have been reverse engineered by some enterprising kX users and are
40available on the internet. Meterbridge is helpful here, and the kX forums are
41packed with useful information.
42
43Each input port will either correspond to a digital (SPDIF) input, an analog
44input, or nothing. The one exception is the SBLive! 5.1. On these devices,
45the second and third input ports are wired to the center/LFE output. You will
46still see 16 capture channels, but only 14 are available for recording inputs.
47
48This chart, borrowed from kxfxlib/da_asio51.cpp, describes the mapping of JACK
49ports to FXBUS2 (multitrack recording input) and EXTOUT (physical output)
50channels.
51
52/*JACK (& ASIO) mappings on 10k1 5.1 SBLive cards:
53--------------------------------------------
54JACK Epilog FXBUS2(nr)
55--------------------------------------------
56capture_1 asio14 FXBUS2(0xe)
57capture_2 asio15 FXBUS2(0xf)
58capture_3 asio0 FXBUS2(0x0)
59~capture_4 Center EXTOUT(0x11) // mapped to by Center
60~capture_5 LFE EXTOUT(0x12) // mapped to by LFE
61capture_6 asio3 FXBUS2(0x3)
62capture_7 asio4 FXBUS2(0x4)
63capture_8 asio5 FXBUS2(0x5)
64capture_9 asio6 FXBUS2(0x6)
65capture_10 asio7 FXBUS2(0x7)
66capture_11 asio8 FXBUS2(0x8)
67capture_12 asio9 FXBUS2(0x9)
68capture_13 asio10 FXBUS2(0xa)
69capture_14 asio11 FXBUS2(0xb)
70capture_15 asio12 FXBUS2(0xc)
71capture_16 asio13 FXBUS2(0xd)
72*/
73
74TODO: describe use of ld10k1/qlo10k1 in conjunction with JACK
diff --git a/Documentation/sound/alsa/hdspm.txt b/Documentation/sound/alsa/hdspm.txt
new file mode 100644
index 000000000000..7a67ff71a9f8
--- /dev/null
+++ b/Documentation/sound/alsa/hdspm.txt
@@ -0,0 +1,362 @@
1Software Interface ALSA-DSP MADI Driver
2
3(translated from German, so no good English ;-),
42004 - winfried ritsch
5
6
7
8 Full functionality has been added to the driver. Since some of
9 the Controls and startup-options are ALSA-Standard and only the
10 special Controls are described and discussed below.
11
12
13 hardware functionality:
14
15
16 Audio transmission:
17
18 number of channels -- depends on transmission mode
19
20 The number of channels chosen is from 1..Nmax. The reason to
21 use for a lower number of channels is only resource allocation,
22 since unused DMA channels are disabled and less memory is
23 allocated. So also the throughput of the PCI system can be
24 scaled. (Only important for low performance boards).
25
26 Single Speed -- 1..64 channels
27
28 (Note: Choosing the 56channel mode for transmission or as
29 receiver, only 56 are transmitted/received over the MADI, but
30 all 64 channels are available for the mixer, so channel count
31 for the driver)
32
33 Double Speed -- 1..32 channels
34
35 Note: Choosing the 56-channel mode for
36 transmission/receive-mode , only 28 are transmitted/received
37 over the MADI, but all 32 channels are available for the mixer,
38 so channel count for the driver
39
40
41 Quad Speed -- 1..16 channels
42
43 Note: Choosing the 56-channel mode for
44 transmission/receive-mode , only 14 are transmitted/received
45 over the MADI, but all 16 channels are available for the mixer,
46 so channel count for the driver
47
48 Format -- signed 32 Bit Little Endian (SNDRV_PCM_FMTBIT_S32_LE)
49
50 Sample Rates --
51
52 Single Speed -- 32000, 44100, 48000
53
54 Double Speed -- 64000, 88200, 96000 (untested)
55
56 Quad Speed -- 128000, 176400, 192000 (untested)
57
58 access-mode -- MMAP (memory mapped), Not interleaved
59 (PCM_NON-INTERLEAVED)
60
61 buffer-sizes -- 64,128,256,512,1024,2048,8192 Samples
62
63 fragments -- 2
64
65 Hardware-pointer -- 2 Modi
66
67
68 The Card supports the readout of the actual Buffer-pointer,
69 where DMA reads/writes. Since of the bulk mode of PCI it is only
70 64 Byte accurate. SO it is not really usable for the
71 ALSA-mid-level functions (here the buffer-ID gives a better
72 result), but if MMAP is used by the application. Therefore it
73 can be configured at load-time with the parameter
74 precise-pointer.
75
76
77 (Hint: Experimenting I found that the pointer is maximum 64 to
78 large never to small. So if you subtract 64 you always have a
79 safe pointer for writing, which is used on this mode inside
80 ALSA. In theory now you can get now a latency as low as 16
81 Samples, which is a quarter of the interrupt possibilities.)
82
83 Precise Pointer -- off
84 interrupt used for pointer-calculation
85
86 Precise Pointer -- on
87 hardware pointer used.
88
89 Controller:
90
91
92 Since DSP-MADI-Mixer has 8152 Fader, it does not make sense to
93 use the standard mixer-controls, since this would break most of
94 (especially graphic) ALSA-Mixer GUIs. So Mixer control has be
95 provided by a 2-dimensional controller using the
96 hwdep-interface.
97
98 Also all 128+256 Peak and RMS-Meter can be accessed via the
99 hwdep-interface. Since it could be a performance problem always
100 copying and converting Peak and RMS-Levels even if you just need
101 one, I decided to export the hardware structure, so that of
102 needed some driver-guru can implement a memory-mapping of mixer
103 or peak-meters over ioctl, or also to do only copying and no
104 conversion. A test-application shows the usage of the controller.
105
106 Latency Controls --- not implemented !!!
107
108
109 Note: Within the windows-driver the latency is accessible of a
110 control-panel, but buffer-sizes are controlled with ALSA from
111 hwparams-calls and should not be changed in run-state, I did not
112 implement it here.
113
114
115 System Clock -- suspended !!!!
116
117 Name -- "System Clock Mode"
118
119 Access -- Read Write
120
121 Values -- "Master" "Slave"
122
123
124 !!!! This is a hardware-function but is in conflict with the
125 Clock-source controller, which is a kind of ALSA-standard. I
126 makes sense to set the card to a special mode (master at some
127 frequency or slave), since even not using an Audio-application
128 a studio should have working synchronisations setup. So use
129 Clock-source-controller instead !!!!
130
131 Clock Source
132
133 Name -- "Sample Clock Source"
134
135 Access -- Read Write
136
137 Values -- "AutoSync", "Internal 32.0 kHz", "Internal 44.1 kHz",
138 "Internal 48.0 kHz", "Internal 64.0 kHz", "Internal 88.2 kHz",
139 "Internal 96.0 kHz"
140
141 Choose between Master at a specific Frequency and so also the
142 Speed-mode or Slave (Autosync). Also see "Preferred Sync Ref"
143
144
145 !!!! This is no pure hardware function but was implemented by
146 ALSA by some ALSA-drivers before, so I use it also. !!!
147
148
149 Preferred Sync Ref
150
151 Name -- "Preferred Sync Reference"
152
153 Access -- Read Write
154
155 Values -- "Word" "MADI"
156
157
158 Within the Auto-sync-Mode the preferred Sync Source can be
159 chosen. If it is not available another is used if possible.
160
161 Note: Since MADI has a much higher bit-rate than word-clock, the
162 card should synchronise better in MADI Mode. But since the
163 RME-PLL is very good, there are almost no problems with
164 word-clock too. I never found a difference.
165
166
167 TX 64 channel ---
168
169 Name -- "TX 64 channels mode"
170
171 Access -- Read Write
172
173 Values -- 0 1
174
175 Using 64-channel-modus (1) or 56-channel-modus for
176 MADI-transmission (0).
177
178
179 Note: This control is for output only. Input-mode is detected
180 automatically from hardware sending MADI.
181
182
183 Clear TMS ---
184
185 Name -- "Clear Track Marker"
186
187 Access -- Read Write
188
189 Values -- 0 1
190
191
192 Don't use to lower 5 Audio-bits on AES as additional Bits.
193
194
195 Safe Mode oder Auto Input ---
196
197 Name -- "Safe Mode"
198
199 Access -- Read Write
200
201 Values -- 0 1
202
203 (default on)
204
205 If on (1), then if either the optical or coaxial connection
206 has a failure, there is a takeover to the working one, with no
207 sample failure. Its only useful if you use the second as a
208 backup connection.
209
210 Input ---
211
212 Name -- "Input Select"
213
214 Access -- Read Write
215
216 Values -- optical coaxial
217
218
219 Choosing the Input, optical or coaxial. If Safe-mode is active,
220 this is the preferred Input.
221
222-------------- Mixer ----------------------
223
224 Mixer
225
226 Name -- "Mixer"
227
228 Access -- Read Write
229
230 Values - <channel-number 0-127> <Value 0-65535>
231
232
233 Here as a first value the channel-index is taken to get/set the
234 corresponding mixer channel, where 0-63 are the input to output
235 fader and 64-127 the playback to outputs fader. Value 0
236 is channel muted 0 and 32768 an amplification of 1.
237
238 Chn 1-64
239
240 fast mixer for the ALSA-mixer utils. The diagonal of the
241 mixer-matrix is implemented from playback to output.
242
243
244 Line Out
245
246 Name -- "Line Out"
247
248 Access -- Read Write
249
250 Values -- 0 1
251
252 Switching on and off the analog out, which has nothing to do
253 with mixing or routing. the analog outs reflects channel 63,64.
254
255
256--- information (only read access):
257
258 Sample Rate
259
260 Name -- "System Sample Rate"
261
262 Access -- Read-only
263
264 getting the sample rate.
265
266
267 External Rate measured
268
269 Name -- "External Rate"
270
271 Access -- Read only
272
273
274 Should be "Autosync Rate", but Name used is
275 ALSA-Scheme. External Sample frequency liked used on Autosync is
276 reported.
277
278
279 MADI Sync Status
280
281 Name -- "MADI Sync Lock Status"
282
283 Access -- Read
284
285 Values -- 0,1,2
286
287 MADI-Input is 0=Unlocked, 1=Locked, or 2=Synced.
288
289
290 Word Clock Sync Status
291
292 Name -- "Word Clock Lock Status"
293
294 Access -- Read
295
296 Values -- 0,1,2
297
298 Word Clock Input is 0=Unlocked, 1=Locked, or 2=Synced.
299
300 AutoSync
301
302 Name -- "AutoSync Reference"
303
304 Access -- Read
305
306 Values -- "WordClock", "MADI", "None"
307
308 Sync-Reference is either "WordClock", "MADI" or none.
309
310 RX 64ch --- noch nicht implementiert
311
312 MADI-Receiver is in 64 channel mode oder 56 channel mode.
313
314
315 AB_inp --- not tested
316
317 Used input for Auto-Input.
318
319
320 actual Buffer Position --- not implemented
321
322 !!! this is a ALSA internal function, so no control is used !!!
323
324
325
326Calling Parameter:
327
328 index int array (min = 1, max = 8),
329 "Index value for RME HDSPM interface." card-index within ALSA
330
331 note: ALSA-standard
332
333 id string array (min = 1, max = 8),
334 "ID string for RME HDSPM interface."
335
336 note: ALSA-standard
337
338 enable int array (min = 1, max = 8),
339 "Enable/disable specific HDSPM sound-cards."
340
341 note: ALSA-standard
342
343 precise_ptr int array (min = 1, max = 8),
344 "Enable precise pointer, or disable."
345
346 note: Use only when the application supports this (which is a special case).
347
348 line_outs_monitor int array (min = 1, max = 8),
349 "Send playback streams to analog outs by default."
350
351
352 note: each playback channel is mixed to the same numbered output
353 channel (routed). This is against the ALSA-convention, where all
354 channels have to be muted on after loading the driver, but was
355 used before on other cards, so i historically use it again)
356
357
358
359 enable_monitor int array (min = 1, max = 8),
360 "Enable Analog Out on Channel 63/64 by default."
361
362 note: here the analog output is enabled (but not routed). \ No newline at end of file
diff --git a/Documentation/w1/w1.generic b/Documentation/w1/w1.generic
index eace3046a858..f937fbe1cacb 100644
--- a/Documentation/w1/w1.generic
+++ b/Documentation/w1/w1.generic
@@ -1,19 +1,92 @@
1Any w1 device must be connected to w1 bus master device - for example 1The 1-wire (w1) subsystem
2ds9490 usb device or w1-over-GPIO or RS232 converter. 2------------------------------------------------------------------
3Driver for w1 bus master must provide several functions(you can find 3The 1-wire bus is a simple master-slave bus that communicates via a single
4them in struct w1_bus_master definition in w1.h) which then will be 4signal wire (plus ground, so two wires).
5called by w1 core to send various commands over w1 bus(by default it is 5
6reset and search commands). When some device is found on the bus, w1 core 6Devices communicate on the bus by pulling the signal to ground via an open
7checks if driver for it's family is loaded. 7drain output and by sampling the logic level of the signal line.
8If driver is loaded w1 core creates new w1_slave object and registers it 8
9in the system(creates some generic sysfs files(struct w1_family_ops in 9The w1 subsystem provides the framework for managing w1 masters and
10w1_family.h), notifies any registered listener and so on...). 10communication with slaves.
11It is device driver's business to provide any communication method 11
12upstream. 12All w1 slave devices must be connected to a w1 bus master device.
13For example w1_therm driver(ds18?20 thermal sensor family driver) 13
14provides temperature reading function which is bound to ->rbin() method 14Example w1 master devices:
15of the above w1_family_ops structure. 15 DS9490 usb device
16w1_smem - driver for simple 64bit memory cell provides ID reading 16 W1-over-GPIO
17method. 17 DS2482 (i2c to w1 bridge)
18 Emulated devices, such as a RS232 converter, parallel port adapter, etc
19
20
21What does the w1 subsystem do?
22------------------------------------------------------------------
23When a w1 master driver registers with the w1 subsystem, the following occurs:
24
25 - sysfs entries for that w1 master are created
26 - the w1 bus is periodically searched for new slave devices
27
28When a device is found on the bus, w1 core checks if driver for it's family is
29loaded. If so, the family driver is attached to the slave.
30If there is no driver for the family, a simple sysfs entry is created
31for the slave device.
32
33
34W1 device families
35------------------------------------------------------------------
36Slave devices are handled by a driver written for a family of w1 devices.
37
38A family driver populates a struct w1_family_ops (see w1_family.h) and
39registers with the w1 subsystem.
40
41Current family drivers:
42w1_therm - (ds18?20 thermal sensor family driver)
43 provides temperature reading function which is bound to ->rbin() method
44 of the above w1_family_ops structure.
45
46w1_smem - driver for simple 64bit memory cell provides ID reading method.
18 47
19You can call above methods by reading appropriate sysfs files. 48You can call above methods by reading appropriate sysfs files.
49
50
51What does a w1 master driver need to implement?
52------------------------------------------------------------------
53
54The driver for w1 bus master must provide at minimum two functions.
55
56Emulated devices must provide the ability to set the output signal level
57(write_bit) and sample the signal level (read_bit).
58
59Devices that support the 1-wire natively must provide the ability to write and
60sample a bit (touch_bit) and reset the bus (reset_bus).
61
62Most hardware provides higher-level functions that offload w1 handling.
63See struct w1_bus_master definition in w1.h for details.
64
65
66w1 master sysfs interface
67------------------------------------------------------------------
68<xx-xxxxxxxxxxxxx> - a directory for a found device. The format is family-serial
69bus - (standard) symlink to the w1 bus
70driver - (standard) symlink to the w1 driver
71w1_master_attempts - the number of times a search was attempted
72w1_master_max_slave_count
73 - the maximum slaves that may be attached to a master
74w1_master_name - the name of the device (w1_bus_masterX)
75w1_master_search - the number of searches left to do, -1=continual (default)
76w1_master_slave_count
77 - the number of slaves found
78w1_master_slaves - the names of the slaves, one per line
79w1_master_timeout - the delay in seconds between searches
80
81If you have a w1 bus that never changes (you don't add or remove devices),
82you can set w1_master_search to a positive value to disable searches.
83
84
85w1 slave sysfs interface
86------------------------------------------------------------------
87bus - (standard) symlink to the w1 bus
88driver - (standard) symlink to the w1 driver
89name - the device name, usually the same as the directory name
90w1_slave - (optional) a binary file whose meaning depends on the
91 family driver
92
diff --git a/MAINTAINERS b/MAINTAINERS
index e3f0f3f157c9..4d44824884ef 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -194,7 +194,7 @@ S: Maintained
194ADM1025 HARDWARE MONITOR DRIVER 194ADM1025 HARDWARE MONITOR DRIVER
195P: Jean Delvare 195P: Jean Delvare
196M: khali@linux-fr.org 196M: khali@linux-fr.org
197L: sensors@stimpy.netroedge.com 197L: lm-sensors@lm-sensors.org
198S: Maintained 198S: Maintained
199 199
200ADT746X FAN DRIVER 200ADT746X FAN DRIVER
@@ -242,7 +242,7 @@ S: Maintained
242ALI1563 I2C DRIVER 242ALI1563 I2C DRIVER
243P: Rudolf Marek 243P: Rudolf Marek
244M: r.marek@sh.cvut.cz 244M: r.marek@sh.cvut.cz
245L: sensors@stimpy.netroedge.com 245L: lm-sensors@lm-sensors.org
246S: Maintained 246S: Maintained
247 247
248ALPHA PORT 248ALPHA PORT
@@ -265,6 +265,11 @@ P: Arnaldo Carvalho de Melo
265M: acme@conectiva.com.br 265M: acme@conectiva.com.br
266S: Maintained 266S: Maintained
267 267
268ARC FRAMEBUFFER DRIVER
269P: Jaya Kumar
270M: jayalk@intworks.biz
271S: Maintained
272
268ARM26 ARCHITECTURE 273ARM26 ARCHITECTURE
269P: Ian Molton 274P: Ian Molton
270M: spyro@f2s.com 275M: spyro@f2s.com
@@ -997,7 +1002,7 @@ P: Greg Kroah-Hartman
997M: greg@kroah.com 1002M: greg@kroah.com
998P: Jean Delvare 1003P: Jean Delvare
999M: khali@linux-fr.org 1004M: khali@linux-fr.org
1000L: sensors@stimpy.netroedge.com 1005L: lm-sensors@lm-sensors.org
1001W: http://www.lm-sensors.nu/ 1006W: http://www.lm-sensors.nu/
1002S: Maintained 1007S: Maintained
1003 1008
@@ -1425,13 +1430,13 @@ S: Supported
1425LM83 HARDWARE MONITOR DRIVER 1430LM83 HARDWARE MONITOR DRIVER
1426P: Jean Delvare 1431P: Jean Delvare
1427M: khali@linux-fr.org 1432M: khali@linux-fr.org
1428L: sensors@stimpy.netroedge.com 1433L: lm-sensors@lm-sensors.org
1429S: Maintained 1434S: Maintained
1430 1435
1431LM90 HARDWARE MONITOR DRIVER 1436LM90 HARDWARE MONITOR DRIVER
1432P: Jean Delvare 1437P: Jean Delvare
1433M: khali@linux-fr.org 1438M: khali@linux-fr.org
1434L: sensors@stimpy.netroedge.com 1439L: lm-sensors@lm-sensors.org
1435S: Maintained 1440S: Maintained
1436 1441
1437LOGICAL DISK MANAGER SUPPORT (LDM, Windows 2000/XP Dynamic Disks) 1442LOGICAL DISK MANAGER SUPPORT (LDM, Windows 2000/XP Dynamic Disks)
@@ -2070,7 +2075,7 @@ S: Maintained
2070SMSC47M1 HARDWARE MONITOR DRIVER 2075SMSC47M1 HARDWARE MONITOR DRIVER
2071P: Jean Delvare 2076P: Jean Delvare
2072M: khali@linux-fr.org 2077M: khali@linux-fr.org
2073L: sensors@stimpy.netroedge.com 2078L: lm-sensors@lm-sensors.org
2074S: Odd Fixes 2079S: Odd Fixes
2075 2080
2076SMB FILESYSTEM 2081SMB FILESYSTEM
@@ -2609,7 +2614,7 @@ S: Orphan
2609W1 DALLAS'S 1-WIRE BUS 2614W1 DALLAS'S 1-WIRE BUS
2610P: Evgeniy Polyakov 2615P: Evgeniy Polyakov
2611M: johnpol@2ka.mipt.ru 2616M: johnpol@2ka.mipt.ru
2612L: sensors@stimpy.netroedge.com 2617L: lm-sensors@lm-sensors.org
2613S: Maintained 2618S: Maintained
2614 2619
2615W83L51xD SD/MMC CARD INTERFACE DRIVER 2620W83L51xD SD/MMC CARD INTERFACE DRIVER
@@ -2622,7 +2627,7 @@ S: Maintained
2622W83L785TS HARDWARE MONITOR DRIVER 2627W83L785TS HARDWARE MONITOR DRIVER
2623P: Jean Delvare 2628P: Jean Delvare
2624M: khali@linux-fr.org 2629M: khali@linux-fr.org
2625L: sensors@stimpy.netroedge.com 2630L: lm-sensors@lm-sensors.org
2626S: Odd Fixes 2631S: Odd Fixes
2627 2632
2628WAN ROUTER & SANGOMA WANPIPE DRIVERS & API (X.25, FRAME RELAY, PPP, CISCO HDLC) 2633WAN ROUTER & SANGOMA WANPIPE DRIVERS & API (X.25, FRAME RELAY, PPP, CISCO HDLC)
diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
index 32c4b0e35b37..3de7f84b53c2 100644
--- a/arch/arm/mm/mmap.c
+++ b/arch/arm/mm/mmap.c
@@ -73,7 +73,12 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
73 (!vma || addr + len <= vma->vm_start)) 73 (!vma || addr + len <= vma->vm_start))
74 return addr; 74 return addr;
75 } 75 }
76 start_addr = addr = mm->free_area_cache; 76 if (len > mm->cached_hole_size) {
77 start_addr = addr = mm->free_area_cache;
78 } else {
79 start_addr = addr = TASK_UNMAPPED_BASE;
80 mm->cached_hole_size = 0;
81 }
77 82
78full_search: 83full_search:
79 if (do_align) 84 if (do_align)
@@ -90,6 +95,7 @@ full_search:
90 */ 95 */
91 if (start_addr != TASK_UNMAPPED_BASE) { 96 if (start_addr != TASK_UNMAPPED_BASE) {
92 start_addr = addr = TASK_UNMAPPED_BASE; 97 start_addr = addr = TASK_UNMAPPED_BASE;
98 mm->cached_hole_size = 0;
93 goto full_search; 99 goto full_search;
94 } 100 }
95 return -ENOMEM; 101 return -ENOMEM;
@@ -101,6 +107,8 @@ full_search:
101 mm->free_area_cache = addr + len; 107 mm->free_area_cache = addr + len;
102 return addr; 108 return addr;
103 } 109 }
110 if (addr + mm->cached_hole_size < vma->vm_start)
111 mm->cached_hole_size = vma->vm_start - addr;
104 addr = vma->vm_end; 112 addr = vma->vm_end;
105 if (do_align) 113 if (do_align)
106 addr = COLOUR_ALIGN(addr, pgoff); 114 addr = COLOUR_ALIGN(addr, pgoff);
diff --git a/arch/frv/mm/init.c b/arch/frv/mm/init.c
index 41958f57c838..79433159b5f0 100644
--- a/arch/frv/mm/init.c
+++ b/arch/frv/mm/init.c
@@ -169,7 +169,6 @@ void __init mem_init(void)
169 struct page *page = &mem_map[pfn]; 169 struct page *page = &mem_map[pfn];
170 170
171 ClearPageReserved(page); 171 ClearPageReserved(page);
172 set_bit(PG_highmem, &page->flags);
173 set_page_count(page, 1); 172 set_page_count(page, 1);
174 __free_page(page); 173 __free_page(page);
175 totalram_pages++; 174 totalram_pages++;
diff --git a/arch/i386/boot/Makefile b/arch/i386/boot/Makefile
index aa7064a75ee6..43cd6220ee49 100644
--- a/arch/i386/boot/Makefile
+++ b/arch/i386/boot/Makefile
@@ -48,7 +48,7 @@ cmd_image = $(obj)/tools/build $(BUILDFLAGS) $(obj)/bootsect $(obj)/setup \
48$(obj)/zImage $(obj)/bzImage: $(obj)/bootsect $(obj)/setup \ 48$(obj)/zImage $(obj)/bzImage: $(obj)/bootsect $(obj)/setup \
49 $(obj)/vmlinux.bin $(obj)/tools/build FORCE 49 $(obj)/vmlinux.bin $(obj)/tools/build FORCE
50 $(call if_changed,image) 50 $(call if_changed,image)
51 @echo 'Kernel: $@ is ready' 51 @echo 'Kernel: $@ is ready' ' (#'`cat .version`')'
52 52
53$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE 53$(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE
54 $(call if_changed,objcopy) 54 $(call if_changed,objcopy)
diff --git a/arch/i386/kernel/syscall_table.S b/arch/i386/kernel/syscall_table.S
index 6cd1ed311f02..d408afaf6495 100644
--- a/arch/i386/kernel/syscall_table.S
+++ b/arch/i386/kernel/syscall_table.S
@@ -251,7 +251,7 @@ ENTRY(sys_call_table)
251 .long sys_io_submit 251 .long sys_io_submit
252 .long sys_io_cancel 252 .long sys_io_cancel
253 .long sys_fadvise64 /* 250 */ 253 .long sys_fadvise64 /* 250 */
254 .long sys_ni_syscall 254 .long sys_set_zone_reclaim
255 .long sys_exit_group 255 .long sys_exit_group
256 .long sys_lookup_dcookie 256 .long sys_lookup_dcookie
257 .long sys_epoll_create 257 .long sys_epoll_create
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index 00c63419c06f..83c579e82a81 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -306,7 +306,7 @@ void die(const char * str, struct pt_regs * regs, long err)
306 }; 306 };
307 static int die_counter; 307 static int die_counter;
308 308
309 if (die.lock_owner != _smp_processor_id()) { 309 if (die.lock_owner != raw_smp_processor_id()) {
310 console_verbose(); 310 console_verbose();
311 spin_lock_irq(&die.lock); 311 spin_lock_irq(&die.lock);
312 die.lock_owner = smp_processor_id(); 312 die.lock_owner = smp_processor_id();
diff --git a/arch/i386/lib/delay.c b/arch/i386/lib/delay.c
index 080639f262b1..eb0cdfe9280f 100644
--- a/arch/i386/lib/delay.c
+++ b/arch/i386/lib/delay.c
@@ -34,7 +34,7 @@ inline void __const_udelay(unsigned long xloops)
34 xloops *= 4; 34 xloops *= 4;
35 __asm__("mull %0" 35 __asm__("mull %0"
36 :"=d" (xloops), "=&a" (d0) 36 :"=d" (xloops), "=&a" (d0)
37 :"1" (xloops),"0" (cpu_data[_smp_processor_id()].loops_per_jiffy * (HZ/4))); 37 :"1" (xloops),"0" (cpu_data[raw_smp_processor_id()].loops_per_jiffy * (HZ/4)));
38 __delay(++xloops); 38 __delay(++xloops);
39} 39}
40 40
diff --git a/arch/i386/mm/hugetlbpage.c b/arch/i386/mm/hugetlbpage.c
index 171fc925e1e4..3b099f32b948 100644
--- a/arch/i386/mm/hugetlbpage.c
+++ b/arch/i386/mm/hugetlbpage.c
@@ -18,7 +18,7 @@
18#include <asm/tlb.h> 18#include <asm/tlb.h>
19#include <asm/tlbflush.h> 19#include <asm/tlbflush.h>
20 20
21static pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr) 21pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
22{ 22{
23 pgd_t *pgd; 23 pgd_t *pgd;
24 pud_t *pud; 24 pud_t *pud;
@@ -30,7 +30,7 @@ static pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
30 return (pte_t *) pmd; 30 return (pte_t *) pmd;
31} 31}
32 32
33static pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr) 33pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
34{ 34{
35 pgd_t *pgd; 35 pgd_t *pgd;
36 pud_t *pud; 36 pud_t *pud;
@@ -42,21 +42,6 @@ static pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
42 return (pte_t *) pmd; 42 return (pte_t *) pmd;
43} 43}
44 44
45static void set_huge_pte(struct mm_struct *mm, struct vm_area_struct *vma, struct page *page, pte_t * page_table, int write_access)
46{
47 pte_t entry;
48
49 add_mm_counter(mm, rss, HPAGE_SIZE / PAGE_SIZE);
50 if (write_access) {
51 entry =
52 pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
53 } else
54 entry = pte_wrprotect(mk_pte(page, vma->vm_page_prot));
55 entry = pte_mkyoung(entry);
56 mk_pte_huge(entry);
57 set_pte(page_table, entry);
58}
59
60/* 45/*
61 * This function checks for proper alignment of input addr and len parameters. 46 * This function checks for proper alignment of input addr and len parameters.
62 */ 47 */
@@ -69,77 +54,6 @@ int is_aligned_hugepage_range(unsigned long addr, unsigned long len)
69 return 0; 54 return 0;
70} 55}
71 56
72int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
73 struct vm_area_struct *vma)
74{
75 pte_t *src_pte, *dst_pte, entry;
76 struct page *ptepage;
77 unsigned long addr = vma->vm_start;
78 unsigned long end = vma->vm_end;
79
80 while (addr < end) {
81 dst_pte = huge_pte_alloc(dst, addr);
82 if (!dst_pte)
83 goto nomem;
84 src_pte = huge_pte_offset(src, addr);
85 entry = *src_pte;
86 ptepage = pte_page(entry);
87 get_page(ptepage);
88 set_pte(dst_pte, entry);
89 add_mm_counter(dst, rss, HPAGE_SIZE / PAGE_SIZE);
90 addr += HPAGE_SIZE;
91 }
92 return 0;
93
94nomem:
95 return -ENOMEM;
96}
97
98int
99follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
100 struct page **pages, struct vm_area_struct **vmas,
101 unsigned long *position, int *length, int i)
102{
103 unsigned long vpfn, vaddr = *position;
104 int remainder = *length;
105
106 WARN_ON(!is_vm_hugetlb_page(vma));
107
108 vpfn = vaddr/PAGE_SIZE;
109 while (vaddr < vma->vm_end && remainder) {
110
111 if (pages) {
112 pte_t *pte;
113 struct page *page;
114
115 pte = huge_pte_offset(mm, vaddr);
116
117 /* hugetlb should be locked, and hence, prefaulted */
118 WARN_ON(!pte || pte_none(*pte));
119
120 page = &pte_page(*pte)[vpfn % (HPAGE_SIZE/PAGE_SIZE)];
121
122 WARN_ON(!PageCompound(page));
123
124 get_page(page);
125 pages[i] = page;
126 }
127
128 if (vmas)
129 vmas[i] = vma;
130
131 vaddr += PAGE_SIZE;
132 ++vpfn;
133 --remainder;
134 ++i;
135 }
136
137 *length = remainder;
138 *position = vaddr;
139
140 return i;
141}
142
143#if 0 /* This is just for testing */ 57#if 0 /* This is just for testing */
144struct page * 58struct page *
145follow_huge_addr(struct mm_struct *mm, unsigned long address, int write) 59follow_huge_addr(struct mm_struct *mm, unsigned long address, int write)
@@ -204,83 +118,15 @@ follow_huge_pmd(struct mm_struct *mm, unsigned long address,
204} 118}
205#endif 119#endif
206 120
207void unmap_hugepage_range(struct vm_area_struct *vma, 121void hugetlb_clean_stale_pgtable(pte_t *pte)
208 unsigned long start, unsigned long end)
209{ 122{
210 struct mm_struct *mm = vma->vm_mm; 123 pmd_t *pmd = (pmd_t *) pte;
211 unsigned long address;
212 pte_t pte, *ptep;
213 struct page *page; 124 struct page *page;
214 125
215 BUG_ON(start & (HPAGE_SIZE - 1)); 126 page = pmd_page(*pmd);
216 BUG_ON(end & (HPAGE_SIZE - 1)); 127 pmd_clear(pmd);
217 128 dec_page_state(nr_page_table_pages);
218 for (address = start; address < end; address += HPAGE_SIZE) { 129 page_cache_release(page);
219 ptep = huge_pte_offset(mm, address);
220 if (!ptep)
221 continue;
222 pte = ptep_get_and_clear(mm, address, ptep);
223 if (pte_none(pte))
224 continue;
225 page = pte_page(pte);
226 put_page(page);
227 }
228 add_mm_counter(mm ,rss, -((end - start) >> PAGE_SHIFT));
229 flush_tlb_range(vma, start, end);
230}
231
232int hugetlb_prefault(struct address_space *mapping, struct vm_area_struct *vma)
233{
234 struct mm_struct *mm = current->mm;
235 unsigned long addr;
236 int ret = 0;
237
238 BUG_ON(vma->vm_start & ~HPAGE_MASK);
239 BUG_ON(vma->vm_end & ~HPAGE_MASK);
240
241 spin_lock(&mm->page_table_lock);
242 for (addr = vma->vm_start; addr < vma->vm_end; addr += HPAGE_SIZE) {
243 unsigned long idx;
244 pte_t *pte = huge_pte_alloc(mm, addr);
245 struct page *page;
246
247 if (!pte) {
248 ret = -ENOMEM;
249 goto out;
250 }
251
252 if (!pte_none(*pte))
253 continue;
254
255 idx = ((addr - vma->vm_start) >> HPAGE_SHIFT)
256 + (vma->vm_pgoff >> (HPAGE_SHIFT - PAGE_SHIFT));
257 page = find_get_page(mapping, idx);
258 if (!page) {
259 /* charge the fs quota first */
260 if (hugetlb_get_quota(mapping)) {
261 ret = -ENOMEM;
262 goto out;
263 }
264 page = alloc_huge_page();
265 if (!page) {
266 hugetlb_put_quota(mapping);
267 ret = -ENOMEM;
268 goto out;
269 }
270 ret = add_to_page_cache(page, mapping, idx, GFP_ATOMIC);
271 if (! ret) {
272 unlock_page(page);
273 } else {
274 hugetlb_put_quota(mapping);
275 free_huge_page(page);
276 goto out;
277 }
278 }
279 set_huge_pte(mm, vma, page, pte, vma->vm_flags & VM_WRITE);
280 }
281out:
282 spin_unlock(&mm->page_table_lock);
283 return ret;
284} 130}
285 131
286/* x86_64 also uses this file */ 132/* x86_64 also uses this file */
@@ -294,7 +140,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
294 struct vm_area_struct *vma; 140 struct vm_area_struct *vma;
295 unsigned long start_addr; 141 unsigned long start_addr;
296 142
297 start_addr = mm->free_area_cache; 143 if (len > mm->cached_hole_size) {
144 start_addr = mm->free_area_cache;
145 } else {
146 start_addr = TASK_UNMAPPED_BASE;
147 mm->cached_hole_size = 0;
148 }
298 149
299full_search: 150full_search:
300 addr = ALIGN(start_addr, HPAGE_SIZE); 151 addr = ALIGN(start_addr, HPAGE_SIZE);
@@ -308,6 +159,7 @@ full_search:
308 */ 159 */
309 if (start_addr != TASK_UNMAPPED_BASE) { 160 if (start_addr != TASK_UNMAPPED_BASE) {
310 start_addr = TASK_UNMAPPED_BASE; 161 start_addr = TASK_UNMAPPED_BASE;
162 mm->cached_hole_size = 0;
311 goto full_search; 163 goto full_search;
312 } 164 }
313 return -ENOMEM; 165 return -ENOMEM;
@@ -316,6 +168,8 @@ full_search:
316 mm->free_area_cache = addr + len; 168 mm->free_area_cache = addr + len;
317 return addr; 169 return addr;
318 } 170 }
171 if (addr + mm->cached_hole_size < vma->vm_start)
172 mm->cached_hole_size = vma->vm_start - addr;
319 addr = ALIGN(vma->vm_end, HPAGE_SIZE); 173 addr = ALIGN(vma->vm_end, HPAGE_SIZE);
320 } 174 }
321} 175}
@@ -327,12 +181,17 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
327 struct mm_struct *mm = current->mm; 181 struct mm_struct *mm = current->mm;
328 struct vm_area_struct *vma, *prev_vma; 182 struct vm_area_struct *vma, *prev_vma;
329 unsigned long base = mm->mmap_base, addr = addr0; 183 unsigned long base = mm->mmap_base, addr = addr0;
184 unsigned long largest_hole = mm->cached_hole_size;
330 int first_time = 1; 185 int first_time = 1;
331 186
332 /* don't allow allocations above current base */ 187 /* don't allow allocations above current base */
333 if (mm->free_area_cache > base) 188 if (mm->free_area_cache > base)
334 mm->free_area_cache = base; 189 mm->free_area_cache = base;
335 190
191 if (len <= largest_hole) {
192 largest_hole = 0;
193 mm->free_area_cache = base;
194 }
336try_again: 195try_again:
337 /* make sure it can fit in the remaining address space */ 196 /* make sure it can fit in the remaining address space */
338 if (mm->free_area_cache < len) 197 if (mm->free_area_cache < len)
@@ -353,13 +212,21 @@ try_again:
353 * vma->vm_start, use it: 212 * vma->vm_start, use it:
354 */ 213 */
355 if (addr + len <= vma->vm_start && 214 if (addr + len <= vma->vm_start &&
356 (!prev_vma || (addr >= prev_vma->vm_end))) 215 (!prev_vma || (addr >= prev_vma->vm_end))) {
357 /* remember the address as a hint for next time */ 216 /* remember the address as a hint for next time */
358 return (mm->free_area_cache = addr); 217 mm->cached_hole_size = largest_hole;
359 else 218 return (mm->free_area_cache = addr);
219 } else {
360 /* pull free_area_cache down to the first hole */ 220 /* pull free_area_cache down to the first hole */
361 if (mm->free_area_cache == vma->vm_end) 221 if (mm->free_area_cache == vma->vm_end) {
362 mm->free_area_cache = vma->vm_start; 222 mm->free_area_cache = vma->vm_start;
223 mm->cached_hole_size = largest_hole;
224 }
225 }
226
227 /* remember the largest hole we saw so far */
228 if (addr + largest_hole < vma->vm_start)
229 largest_hole = vma->vm_start - addr;
363 230
364 /* try just below the current vma->vm_start */ 231 /* try just below the current vma->vm_start */
365 addr = (vma->vm_start - len) & HPAGE_MASK; 232 addr = (vma->vm_start - len) & HPAGE_MASK;
@@ -372,6 +239,7 @@ fail:
372 */ 239 */
373 if (first_time) { 240 if (first_time) {
374 mm->free_area_cache = base; 241 mm->free_area_cache = base;
242 largest_hole = 0;
375 first_time = 0; 243 first_time = 0;
376 goto try_again; 244 goto try_again;
377 } 245 }
@@ -382,6 +250,7 @@ fail:
382 * allocations. 250 * allocations.
383 */ 251 */
384 mm->free_area_cache = TASK_UNMAPPED_BASE; 252 mm->free_area_cache = TASK_UNMAPPED_BASE;
253 mm->cached_hole_size = ~0UL;
385 addr = hugetlb_get_unmapped_area_bottomup(file, addr0, 254 addr = hugetlb_get_unmapped_area_bottomup(file, addr0,
386 len, pgoff, flags); 255 len, pgoff, flags);
387 256
@@ -389,6 +258,7 @@ fail:
389 * Restore the topdown base: 258 * Restore the topdown base:
390 */ 259 */
391 mm->free_area_cache = base; 260 mm->free_area_cache = base;
261 mm->cached_hole_size = ~0UL;
392 262
393 return addr; 263 return addr;
394} 264}
diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c
index 7a7ea3737265..8766c771bb45 100644
--- a/arch/i386/mm/init.c
+++ b/arch/i386/mm/init.c
@@ -269,7 +269,6 @@ void __init one_highpage_init(struct page *page, int pfn, int bad_ppro)
269{ 269{
270 if (page_is_ram(pfn) && !(bad_ppro && page_kills_ppro(pfn))) { 270 if (page_is_ram(pfn) && !(bad_ppro && page_kills_ppro(pfn))) {
271 ClearPageReserved(page); 271 ClearPageReserved(page);
272 set_bit(PG_highmem, &page->flags);
273 set_page_count(page, 1); 272 set_page_count(page, 1);
274 __free_page(page); 273 __free_page(page);
275 totalhigh_pages++; 274 totalhigh_pages++;
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 992bcfff7913..ce4dfa8b834d 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -50,6 +50,10 @@ config SCHED_NO_NO_OMIT_FRAME_POINTER
50 bool 50 bool
51 default y 51 default y
52 52
53config IA64_UNCACHED_ALLOCATOR
54 bool
55 select GENERIC_ALLOCATOR
56
53choice 57choice
54 prompt "System type" 58 prompt "System type"
55 default IA64_GENERIC 59 default IA64_GENERIC
@@ -223,7 +227,7 @@ config IA64_SGI_SN_SIM
223 227
224config IA64_SGI_SN_XP 228config IA64_SGI_SN_XP
225 tristate "Support communication between SGI SSIs" 229 tristate "Support communication between SGI SSIs"
226 depends on MSPEC 230 select IA64_UNCACHED_ALLOCATOR
227 help 231 help
228 An SGI machine can be divided into multiple Single System 232 An SGI machine can be divided into multiple Single System
229 Images which act independently of each other and have 233 Images which act independently of each other and have
diff --git a/arch/ia64/configs/sn2_defconfig b/arch/ia64/configs/sn2_defconfig
index 6ff7107fee4d..a01bb02d074d 100644
--- a/arch/ia64/configs/sn2_defconfig
+++ b/arch/ia64/configs/sn2_defconfig
@@ -588,6 +588,7 @@ CONFIG_SGI_MBCS=m
588CONFIG_SERIAL_CORE=y 588CONFIG_SERIAL_CORE=y
589CONFIG_SERIAL_CORE_CONSOLE=y 589CONFIG_SERIAL_CORE_CONSOLE=y
590CONFIG_SERIAL_SGI_L1_CONSOLE=y 590CONFIG_SERIAL_SGI_L1_CONSOLE=y
591CONFIG_SERIAL_SGI_IOC4=y
591CONFIG_UNIX98_PTYS=y 592CONFIG_UNIX98_PTYS=y
592CONFIG_LEGACY_PTYS=y 593CONFIG_LEGACY_PTYS=y
593CONFIG_LEGACY_PTY_COUNT=256 594CONFIG_LEGACY_PTY_COUNT=256
@@ -788,6 +789,11 @@ CONFIG_INFINIBAND_IPOIB=m
788# CONFIG_INFINIBAND_IPOIB_DEBUG is not set 789# CONFIG_INFINIBAND_IPOIB_DEBUG is not set
789 790
790# 791#
792# SN Devices
793#
794CONFIG_SGI_IOC4=y
795
796#
791# File systems 797# File systems
792# 798#
793CONFIG_EXT2_FS=y 799CONFIG_EXT2_FS=y
diff --git a/arch/ia64/defconfig b/arch/ia64/defconfig
index 2aea0f9e6e1d..7be8096e0561 100644
--- a/arch/ia64/defconfig
+++ b/arch/ia64/defconfig
@@ -657,6 +657,7 @@ CONFIG_SERIAL_8250_SHARE_IRQ=y
657CONFIG_SERIAL_CORE=y 657CONFIG_SERIAL_CORE=y
658CONFIG_SERIAL_CORE_CONSOLE=y 658CONFIG_SERIAL_CORE_CONSOLE=y
659CONFIG_SERIAL_SGI_L1_CONSOLE=y 659CONFIG_SERIAL_SGI_L1_CONSOLE=y
660CONFIG_SERIAL_SGI_IOC4=y
660# CONFIG_SERIAL_JSM is not set 661# CONFIG_SERIAL_JSM is not set
661CONFIG_UNIX98_PTYS=y 662CONFIG_UNIX98_PTYS=y
662CONFIG_LEGACY_PTYS=y 663CONFIG_LEGACY_PTYS=y
@@ -976,6 +977,11 @@ CONFIG_INFINIBAND_IPOIB=m
976# CONFIG_INFINIBAND_IPOIB_DEBUG is not set 977# CONFIG_INFINIBAND_IPOIB_DEBUG is not set
977 978
978# 979#
980# SN Devices
981#
982CONFIG_SGI_IOC4=y
983
984#
979# File systems 985# File systems
980# 986#
981CONFIG_EXT2_FS=y 987CONFIG_EXT2_FS=y
diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile
index c1a02bbc252c..4c73d8ba2e3d 100644
--- a/arch/ia64/kernel/Makefile
+++ b/arch/ia64/kernel/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_SMP) += smp.o smpboot.o domain.o
20obj-$(CONFIG_PERFMON) += perfmon_default_smpl.o 20obj-$(CONFIG_PERFMON) += perfmon_default_smpl.o
21obj-$(CONFIG_IA64_CYCLONE) += cyclone.o 21obj-$(CONFIG_IA64_CYCLONE) += cyclone.o
22obj-$(CONFIG_IA64_MCA_RECOVERY) += mca_recovery.o 22obj-$(CONFIG_IA64_MCA_RECOVERY) += mca_recovery.o
23obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR) += uncached.o
23mca_recovery-y += mca_drv.o mca_drv_asm.o 24mca_recovery-y += mca_drv.o mca_drv_asm.o
24 25
25# The gate DSO image is built using a special linker script. 26# The gate DSO image is built using a special linker script.
diff --git a/arch/ia64/kernel/efi.c b/arch/ia64/kernel/efi.c
index 4a3b1aac43e7..179f230816ed 100644
--- a/arch/ia64/kernel/efi.c
+++ b/arch/ia64/kernel/efi.c
@@ -410,6 +410,38 @@ efi_memmap_walk (efi_freemem_callback_t callback, void *arg)
410} 410}
411 411
412/* 412/*
413 * Walk the EFI memory map to pull out leftover pages in the lower
414 * memory regions which do not end up in the regular memory map and
415 * stick them into the uncached allocator
416 *
417 * The regular walk function is significantly more complex than the
418 * uncached walk which means it really doesn't make sense to try and
419 * marge the two.
420 */
421void __init
422efi_memmap_walk_uc (efi_freemem_callback_t callback)
423{
424 void *efi_map_start, *efi_map_end, *p;
425 efi_memory_desc_t *md;
426 u64 efi_desc_size, start, end;
427
428 efi_map_start = __va(ia64_boot_param->efi_memmap);
429 efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
430 efi_desc_size = ia64_boot_param->efi_memdesc_size;
431
432 for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
433 md = p;
434 if (md->attribute == EFI_MEMORY_UC) {
435 start = PAGE_ALIGN(md->phys_addr);
436 end = PAGE_ALIGN((md->phys_addr+(md->num_pages << EFI_PAGE_SHIFT)) & PAGE_MASK);
437 if ((*callback)(start, end, NULL) < 0)
438 return;
439 }
440 }
441}
442
443
444/*
413 * Look for the PAL_CODE region reported by EFI and maps it using an 445 * Look for the PAL_CODE region reported by EFI and maps it using an
414 * ITR to enable safe PAL calls in virtual mode. See IA-64 Processor 446 * ITR to enable safe PAL calls in virtual mode. See IA-64 Processor
415 * Abstraction Layer chapter 11 in ADAG 447 * Abstraction Layer chapter 11 in ADAG
diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
index d99316c9be28..b1d5d3d5276c 100644
--- a/arch/ia64/kernel/entry.S
+++ b/arch/ia64/kernel/entry.S
@@ -1579,7 +1579,7 @@ sys_call_table:
1579 data8 sys_keyctl 1579 data8 sys_keyctl
1580 data8 sys_ni_syscall 1580 data8 sys_ni_syscall
1581 data8 sys_ni_syscall // 1275 1581 data8 sys_ni_syscall // 1275
1582 data8 sys_ni_syscall 1582 data8 sys_set_zone_reclaim
1583 data8 sys_ni_syscall 1583 data8 sys_ni_syscall
1584 data8 sys_ni_syscall 1584 data8 sys_ni_syscall
1585 data8 sys_ni_syscall 1585 data8 sys_ni_syscall
diff --git a/arch/ia64/kernel/uncached.c b/arch/ia64/kernel/uncached.c
new file mode 100644
index 000000000000..490dfc9ab47f
--- /dev/null
+++ b/arch/ia64/kernel/uncached.c
@@ -0,0 +1,246 @@
1/*
2 * Copyright (C) 2001-2005 Silicon Graphics, Inc. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License
6 * as published by the Free Software Foundation.
7 *
8 * A simple uncached page allocator using the generic allocator. This
9 * allocator first utilizes the spare (spill) pages found in the EFI
10 * memmap and will then start converting cached pages to uncached ones
11 * at a granule at a time. Node awareness is implemented by having a
12 * pool of pages per node.
13 */
14
15#include <linux/types.h>
16#include <linux/kernel.h>
17#include <linux/module.h>
18#include <linux/init.h>
19#include <linux/errno.h>
20#include <linux/string.h>
21#include <linux/slab.h>
22#include <linux/efi.h>
23#include <linux/genalloc.h>
24#include <asm/page.h>
25#include <asm/pal.h>
26#include <asm/system.h>
27#include <asm/pgtable.h>
28#include <asm/atomic.h>
29#include <asm/tlbflush.h>
30#include <asm/sn/arch.h>
31
32#define DEBUG 0
33
34#if DEBUG
35#define dprintk printk
36#else
37#define dprintk(x...) do { } while (0)
38#endif
39
40void __init efi_memmap_walk_uc (efi_freemem_callback_t callback);
41
42#define MAX_UNCACHED_GRANULES 5
43static int allocated_granules;
44
45struct gen_pool *uncached_pool[MAX_NUMNODES];
46
47
48static void uncached_ipi_visibility(void *data)
49{
50 int status;
51
52 status = ia64_pal_prefetch_visibility(PAL_VISIBILITY_PHYSICAL);
53 if ((status != PAL_VISIBILITY_OK) &&
54 (status != PAL_VISIBILITY_OK_REMOTE_NEEDED))
55 printk(KERN_DEBUG "pal_prefetch_visibility() returns %i on "
56 "CPU %i\n", status, get_cpu());
57}
58
59
60static void uncached_ipi_mc_drain(void *data)
61{
62 int status;
63 status = ia64_pal_mc_drain();
64 if (status)
65 printk(KERN_WARNING "ia64_pal_mc_drain() failed with %i on "
66 "CPU %i\n", status, get_cpu());
67}
68
69
70static unsigned long
71uncached_get_new_chunk(struct gen_pool *poolp)
72{
73 struct page *page;
74 void *tmp;
75 int status, i;
76 unsigned long addr, node;
77
78 if (allocated_granules >= MAX_UNCACHED_GRANULES)
79 return 0;
80
81 node = poolp->private;
82 page = alloc_pages_node(node, GFP_KERNEL | __GFP_ZERO,
83 IA64_GRANULE_SHIFT-PAGE_SHIFT);
84
85 dprintk(KERN_INFO "get_new_chunk page %p, addr %lx\n",
86 page, (unsigned long)(page-vmem_map) << PAGE_SHIFT);
87
88 /*
89 * Do magic if no mem on local node! XXX
90 */
91 if (!page)
92 return 0;
93 tmp = page_address(page);
94
95 /*
96 * There's a small race here where it's possible for someone to
97 * access the page through /dev/mem halfway through the conversion
98 * to uncached - not sure it's really worth bothering about
99 */
100 for (i = 0; i < (IA64_GRANULE_SIZE / PAGE_SIZE); i++)
101 SetPageUncached(&page[i]);
102
103 flush_tlb_kernel_range(tmp, tmp + IA64_GRANULE_SIZE);
104
105 status = ia64_pal_prefetch_visibility(PAL_VISIBILITY_PHYSICAL);
106
107 dprintk(KERN_INFO "pal_prefetch_visibility() returns %i on cpu %i\n",
108 status, get_cpu());
109
110 if (!status) {
111 status = smp_call_function(uncached_ipi_visibility, NULL, 0, 1);
112 if (status)
113 printk(KERN_WARNING "smp_call_function failed for "
114 "uncached_ipi_visibility! (%i)\n", status);
115 }
116
117 if (ia64_platform_is("sn2"))
118 sn_flush_all_caches((unsigned long)tmp, IA64_GRANULE_SIZE);
119 else
120 flush_icache_range((unsigned long)tmp,
121 (unsigned long)tmp+IA64_GRANULE_SIZE);
122
123 ia64_pal_mc_drain();
124 status = smp_call_function(uncached_ipi_mc_drain, NULL, 0, 1);
125 if (status)
126 printk(KERN_WARNING "smp_call_function failed for "
127 "uncached_ipi_mc_drain! (%i)\n", status);
128
129 addr = (unsigned long)tmp - PAGE_OFFSET + __IA64_UNCACHED_OFFSET;
130
131 allocated_granules++;
132 return addr;
133}
134
135
136/*
137 * uncached_alloc_page
138 *
139 * Allocate 1 uncached page. Allocates on the requested node. If no
140 * uncached pages are available on the requested node, roundrobin starting
141 * with higher nodes.
142 */
143unsigned long
144uncached_alloc_page(int nid)
145{
146 unsigned long maddr;
147
148 maddr = gen_pool_alloc(uncached_pool[nid], PAGE_SIZE);
149
150 dprintk(KERN_DEBUG "uncached_alloc_page returns %lx on node %i\n",
151 maddr, nid);
152
153 /*
154 * If no memory is availble on our local node, try the
155 * remaining nodes in the system.
156 */
157 if (!maddr) {
158 int i;
159
160 for (i = MAX_NUMNODES - 1; i >= 0; i--) {
161 if (i == nid || !node_online(i))
162 continue;
163 maddr = gen_pool_alloc(uncached_pool[i], PAGE_SIZE);
164 dprintk(KERN_DEBUG "uncached_alloc_page alternate search "
165 "returns %lx on node %i\n", maddr, i);
166 if (maddr) {
167 break;
168 }
169 }
170 }
171
172 return maddr;
173}
174EXPORT_SYMBOL(uncached_alloc_page);
175
176
177/*
178 * uncached_free_page
179 *
180 * Free a single uncached page.
181 */
182void
183uncached_free_page(unsigned long maddr)
184{
185 int node;
186
187 node = nasid_to_cnodeid(NASID_GET(maddr));
188
189 dprintk(KERN_DEBUG "uncached_free_page(%lx) on node %i\n", maddr, node);
190
191 if ((maddr & (0XFUL << 60)) != __IA64_UNCACHED_OFFSET)
192 panic("uncached_free_page invalid address %lx\n", maddr);
193
194 gen_pool_free(uncached_pool[node], maddr, PAGE_SIZE);
195}
196EXPORT_SYMBOL(uncached_free_page);
197
198
199/*
200 * uncached_build_memmap,
201 *
202 * Called at boot time to build a map of pages that can be used for
203 * memory special operations.
204 */
205static int __init
206uncached_build_memmap(unsigned long start, unsigned long end, void *arg)
207{
208 long length;
209 unsigned long vstart, vend;
210 int node;
211
212 length = end - start;
213 vstart = start + __IA64_UNCACHED_OFFSET;
214 vend = end + __IA64_UNCACHED_OFFSET;
215
216 dprintk(KERN_ERR "uncached_build_memmap(%lx %lx)\n", start, end);
217
218 memset((char *)vstart, 0, length);
219
220 node = nasid_to_cnodeid(NASID_GET(start));
221
222 for (; vstart < vend ; vstart += PAGE_SIZE) {
223 dprintk(KERN_INFO "sticking %lx into the pool!\n", vstart);
224 gen_pool_free(uncached_pool[node], vstart, PAGE_SIZE);
225 }
226
227 return 0;
228}
229
230
231static int __init uncached_init(void) {
232 int i;
233
234 for (i = 0; i < MAX_NUMNODES; i++) {
235 if (!node_online(i))
236 continue;
237 uncached_pool[i] = gen_pool_create(0, IA64_GRANULE_SHIFT,
238 &uncached_get_new_chunk, i);
239 }
240
241 efi_memmap_walk_uc(uncached_build_memmap);
242
243 return 0;
244}
245
246__initcall(uncached_init);
diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
index df08ae7634b6..e0a776a3044c 100644
--- a/arch/ia64/mm/hugetlbpage.c
+++ b/arch/ia64/mm/hugetlbpage.c
@@ -24,7 +24,7 @@
24 24
25unsigned int hpage_shift=HPAGE_SHIFT_DEFAULT; 25unsigned int hpage_shift=HPAGE_SHIFT_DEFAULT;
26 26
27static pte_t * 27pte_t *
28huge_pte_alloc (struct mm_struct *mm, unsigned long addr) 28huge_pte_alloc (struct mm_struct *mm, unsigned long addr)
29{ 29{
30 unsigned long taddr = htlbpage_to_page(addr); 30 unsigned long taddr = htlbpage_to_page(addr);
@@ -43,7 +43,7 @@ huge_pte_alloc (struct mm_struct *mm, unsigned long addr)
43 return pte; 43 return pte;
44} 44}
45 45
46static pte_t * 46pte_t *
47huge_pte_offset (struct mm_struct *mm, unsigned long addr) 47huge_pte_offset (struct mm_struct *mm, unsigned long addr)
48{ 48{
49 unsigned long taddr = htlbpage_to_page(addr); 49 unsigned long taddr = htlbpage_to_page(addr);
@@ -67,23 +67,6 @@ huge_pte_offset (struct mm_struct *mm, unsigned long addr)
67 67
68#define mk_pte_huge(entry) { pte_val(entry) |= _PAGE_P; } 68#define mk_pte_huge(entry) { pte_val(entry) |= _PAGE_P; }
69 69
70static void
71set_huge_pte (struct mm_struct *mm, struct vm_area_struct *vma,
72 struct page *page, pte_t * page_table, int write_access)
73{
74 pte_t entry;
75
76 add_mm_counter(mm, rss, HPAGE_SIZE / PAGE_SIZE);
77 if (write_access) {
78 entry =
79 pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
80 } else
81 entry = pte_wrprotect(mk_pte(page, vma->vm_page_prot));
82 entry = pte_mkyoung(entry);
83 mk_pte_huge(entry);
84 set_pte(page_table, entry);
85 return;
86}
87/* 70/*
88 * This function checks for proper alignment of input addr and len parameters. 71 * This function checks for proper alignment of input addr and len parameters.
89 */ 72 */
@@ -99,68 +82,6 @@ int is_aligned_hugepage_range(unsigned long addr, unsigned long len)
99 return 0; 82 return 0;
100} 83}
101 84
102int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
103 struct vm_area_struct *vma)
104{
105 pte_t *src_pte, *dst_pte, entry;
106 struct page *ptepage;
107 unsigned long addr = vma->vm_start;
108 unsigned long end = vma->vm_end;
109
110 while (addr < end) {
111 dst_pte = huge_pte_alloc(dst, addr);
112 if (!dst_pte)
113 goto nomem;
114 src_pte = huge_pte_offset(src, addr);
115 entry = *src_pte;
116 ptepage = pte_page(entry);
117 get_page(ptepage);
118 set_pte(dst_pte, entry);
119 add_mm_counter(dst, rss, HPAGE_SIZE / PAGE_SIZE);
120 addr += HPAGE_SIZE;
121 }
122 return 0;
123nomem:
124 return -ENOMEM;
125}
126
127int
128follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
129 struct page **pages, struct vm_area_struct **vmas,
130 unsigned long *st, int *length, int i)
131{
132 pte_t *ptep, pte;
133 unsigned long start = *st;
134 unsigned long pstart;
135 int len = *length;
136 struct page *page;
137
138 do {
139 pstart = start & HPAGE_MASK;
140 ptep = huge_pte_offset(mm, start);
141 pte = *ptep;
142
143back1:
144 page = pte_page(pte);
145 if (pages) {
146 page += ((start & ~HPAGE_MASK) >> PAGE_SHIFT);
147 get_page(page);
148 pages[i] = page;
149 }
150 if (vmas)
151 vmas[i] = vma;
152 i++;
153 len--;
154 start += PAGE_SIZE;
155 if (((start & HPAGE_MASK) == pstart) && len &&
156 (start < vma->vm_end))
157 goto back1;
158 } while (len && start < vma->vm_end);
159 *length = len;
160 *st = start;
161 return i;
162}
163
164struct page *follow_huge_addr(struct mm_struct *mm, unsigned long addr, int write) 85struct page *follow_huge_addr(struct mm_struct *mm, unsigned long addr, int write)
165{ 86{
166 struct page *page; 87 struct page *page;
@@ -212,81 +133,6 @@ void hugetlb_free_pgd_range(struct mmu_gather **tlb,
212 free_pgd_range(tlb, addr, end, floor, ceiling); 133 free_pgd_range(tlb, addr, end, floor, ceiling);
213} 134}
214 135
215void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start, unsigned long end)
216{
217 struct mm_struct *mm = vma->vm_mm;
218 unsigned long address;
219 pte_t *pte;
220 struct page *page;
221
222 BUG_ON(start & (HPAGE_SIZE - 1));
223 BUG_ON(end & (HPAGE_SIZE - 1));
224
225 for (address = start; address < end; address += HPAGE_SIZE) {
226 pte = huge_pte_offset(mm, address);
227 if (pte_none(*pte))
228 continue;
229 page = pte_page(*pte);
230 put_page(page);
231 pte_clear(mm, address, pte);
232 }
233 add_mm_counter(mm, rss, - ((end - start) >> PAGE_SHIFT));
234 flush_tlb_range(vma, start, end);
235}
236
237int hugetlb_prefault(struct address_space *mapping, struct vm_area_struct *vma)
238{
239 struct mm_struct *mm = current->mm;
240 unsigned long addr;
241 int ret = 0;
242
243 BUG_ON(vma->vm_start & ~HPAGE_MASK);
244 BUG_ON(vma->vm_end & ~HPAGE_MASK);
245
246 spin_lock(&mm->page_table_lock);
247 for (addr = vma->vm_start; addr < vma->vm_end; addr += HPAGE_SIZE) {
248 unsigned long idx;
249 pte_t *pte = huge_pte_alloc(mm, addr);
250 struct page *page;
251
252 if (!pte) {
253 ret = -ENOMEM;
254 goto out;
255 }
256 if (!pte_none(*pte))
257 continue;
258
259 idx = ((addr - vma->vm_start) >> HPAGE_SHIFT)
260 + (vma->vm_pgoff >> (HPAGE_SHIFT - PAGE_SHIFT));
261 page = find_get_page(mapping, idx);
262 if (!page) {
263 /* charge the fs quota first */
264 if (hugetlb_get_quota(mapping)) {
265 ret = -ENOMEM;
266 goto out;
267 }
268 page = alloc_huge_page();
269 if (!page) {
270 hugetlb_put_quota(mapping);
271 ret = -ENOMEM;
272 goto out;
273 }
274 ret = add_to_page_cache(page, mapping, idx, GFP_ATOMIC);
275 if (! ret) {
276 unlock_page(page);
277 } else {
278 hugetlb_put_quota(mapping);
279 page_cache_release(page);
280 goto out;
281 }
282 }
283 set_huge_pte(mm, vma, page, pte, vma->vm_flags & VM_WRITE);
284 }
285out:
286 spin_unlock(&mm->page_table_lock);
287 return ret;
288}
289
290unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, 136unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
291 unsigned long pgoff, unsigned long flags) 137 unsigned long pgoff, unsigned long flags)
292{ 138{
diff --git a/arch/ia64/sn/kernel/xpc_partition.c b/arch/ia64/sn/kernel/xpc_partition.c
index 2c3c4a8af553..cd7ed73f0e7a 100644
--- a/arch/ia64/sn/kernel/xpc_partition.c
+++ b/arch/ia64/sn/kernel/xpc_partition.c
@@ -22,6 +22,7 @@
22#include <linux/cache.h> 22#include <linux/cache.h>
23#include <linux/mmzone.h> 23#include <linux/mmzone.h>
24#include <linux/nodemask.h> 24#include <linux/nodemask.h>
25#include <asm/uncached.h>
25#include <asm/sn/bte.h> 26#include <asm/sn/bte.h>
26#include <asm/sn/intr.h> 27#include <asm/sn/intr.h>
27#include <asm/sn/sn_sal.h> 28#include <asm/sn/sn_sal.h>
@@ -183,7 +184,7 @@ xpc_rsvd_page_init(void)
183 * memory protections are never restricted. 184 * memory protections are never restricted.
184 */ 185 */
185 if ((amos_page = xpc_vars->amos_page) == NULL) { 186 if ((amos_page = xpc_vars->amos_page) == NULL) {
186 amos_page = (AMO_t *) mspec_kalloc_page(0); 187 amos_page = (AMO_t *) TO_AMO(uncached_alloc_page(0));
187 if (amos_page == NULL) { 188 if (amos_page == NULL) {
188 dev_err(xpc_part, "can't allocate page of AMOs\n"); 189 dev_err(xpc_part, "can't allocate page of AMOs\n");
189 return NULL; 190 return NULL;
@@ -200,7 +201,8 @@ xpc_rsvd_page_init(void)
200 if (ret != 0) { 201 if (ret != 0) {
201 dev_err(xpc_part, "can't change memory " 202 dev_err(xpc_part, "can't change memory "
202 "protections\n"); 203 "protections\n");
203 mspec_kfree_page((unsigned long) amos_page); 204 uncached_free_page(__IA64_UNCACHED_OFFSET |
205 TO_PHYS((u64) amos_page));
204 return NULL; 206 return NULL;
205 } 207 }
206 } 208 }
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig
index 0d90ea58a0cb..64c133344afe 100644
--- a/arch/m32r/Kconfig
+++ b/arch/m32r/Kconfig
@@ -78,6 +78,9 @@ config PLAT_OAKS32R
78config PLAT_MAPPI2 78config PLAT_MAPPI2
79 bool "Mappi-II(M3A-ZA36/M3A-ZA52)" 79 bool "Mappi-II(M3A-ZA36/M3A-ZA52)"
80 80
81config PLAT_MAPPI3
82 bool "Mappi-III(M3A-2170)"
83
81endchoice 84endchoice
82 85
83choice 86choice
@@ -134,6 +137,7 @@ config BUS_CLOCK
134 int "Bus Clock [Hz] (integer)" 137 int "Bus Clock [Hz] (integer)"
135 default "70000000" if PLAT_MAPPI 138 default "70000000" if PLAT_MAPPI
136 default "25000000" if PLAT_USRV 139 default "25000000" if PLAT_USRV
140 default "50000000" if PLAT_MAPPI3
137 default "50000000" if PLAT_M32700UT 141 default "50000000" if PLAT_M32700UT
138 default "50000000" if PLAT_OPSPUT 142 default "50000000" if PLAT_OPSPUT
139 default "33333333" if PLAT_OAKS32R 143 default "33333333" if PLAT_OAKS32R
@@ -149,7 +153,7 @@ config CPU_LITTLE_ENDIAN
149 153
150config MEMORY_START 154config MEMORY_START
151 hex "Physical memory start address (hex)" 155 hex "Physical memory start address (hex)"
152 default "08000000" if PLAT_MAPPI || PLAT_MAPPI2 156 default "08000000" if PLAT_MAPPI || PLAT_MAPPI2 || PLAT_MAPPI3
153 default "08000000" if PLAT_USRV 157 default "08000000" if PLAT_USRV
154 default "08000000" if PLAT_M32700UT 158 default "08000000" if PLAT_M32700UT
155 default "08000000" if PLAT_OPSPUT 159 default "08000000" if PLAT_OPSPUT
@@ -157,6 +161,7 @@ config MEMORY_START
157 161
158config MEMORY_SIZE 162config MEMORY_SIZE
159 hex "Physical memory size (hex)" 163 hex "Physical memory size (hex)"
164 default "08000000" if PLAT_MAPPI3
160 default "04000000" if PLAT_MAPPI || PLAT_MAPPI2 165 default "04000000" if PLAT_MAPPI || PLAT_MAPPI2
161 default "02000000" if PLAT_USRV 166 default "02000000" if PLAT_USRV
162 default "01000000" if PLAT_M32700UT 167 default "01000000" if PLAT_M32700UT
diff --git a/arch/m32r/boot/compressed/m32r_sio.c b/arch/m32r/boot/compressed/m32r_sio.c
index bad5475eff90..8f9a57271f83 100644
--- a/arch/m32r/boot/compressed/m32r_sio.c
+++ b/arch/m32r/boot/compressed/m32r_sio.c
@@ -6,6 +6,7 @@
6 */ 6 */
7 7
8#include <linux/config.h> 8#include <linux/config.h>
9#include <asm/processor.h>
9 10
10static void putc(char c); 11static void putc(char c);
11 12
@@ -38,16 +39,17 @@ static int puts(const char *s)
38 39
39static void putc(char c) 40static void putc(char c)
40{ 41{
41 42 while ((*BOOT_SIO0STS & 0x3) != 0x3)
42 while ((*BOOT_SIO0STS & 0x3) != 0x3) ; 43 cpu_relax();
43 if (c == '\n') { 44 if (c == '\n') {
44 *BOOT_SIO0TXB = '\r'; 45 *BOOT_SIO0TXB = '\r';
45 while ((*BOOT_SIO0STS & 0x3) != 0x3) ; 46 while ((*BOOT_SIO0STS & 0x3) != 0x3)
47 cpu_relax();
46 } 48 }
47 *BOOT_SIO0TXB = c; 49 *BOOT_SIO0TXB = c;
48} 50}
49#else /* defined(CONFIG_PLAT_M32700UT_Alpha) || defined(CONFIG_PLAT_M32700UT) */ 51#else /* !(CONFIG_PLAT_M32700UT_Alpha) && !(CONFIG_PLAT_M32700UT) */
50#ifdef CONFIG_MMU 52#if defined(CONFIG_PLAT_MAPPI2)
51#define SIO0STS (volatile unsigned short *)(0xa0efd000 + 14) 53#define SIO0STS (volatile unsigned short *)(0xa0efd000 + 14)
52#define SIO0TXB (volatile unsigned short *)(0xa0efd000 + 30) 54#define SIO0TXB (volatile unsigned short *)(0xa0efd000 + 30)
53#else 55#else
@@ -57,11 +59,12 @@ static void putc(char c)
57 59
58static void putc(char c) 60static void putc(char c)
59{ 61{
60 62 while ((*SIO0STS & 0x1) == 0)
61 while ((*SIO0STS & 0x1) == 0) ; 63 cpu_relax();
62 if (c == '\n') { 64 if (c == '\n') {
63 *SIO0TXB = '\r'; 65 *SIO0TXB = '\r';
64 while ((*SIO0STS & 0x1) == 0) ; 66 while ((*SIO0STS & 0x1) == 0)
67 cpu_relax();
65 } 68 }
66 *SIO0TXB = c; 69 *SIO0TXB = c;
67} 70}
diff --git a/arch/m32r/defconfig b/arch/m32r/defconfig
index 417c95ba87e9..853093093168 100644
--- a/arch/m32r/defconfig
+++ b/arch/m32r/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.11-rc4 3# Linux kernel version: 2.6.12-rc5
4# Wed Feb 16 21:10:44 2005 4# Fri Jun 3 16:20:11 2005
5# 5#
6CONFIG_M32R=y 6CONFIG_M32R=y
7# CONFIG_UID16 is not set 7# CONFIG_UID16 is not set
@@ -16,6 +16,7 @@ CONFIG_EXPERIMENTAL=y
16CONFIG_CLEAN_COMPILE=y 16CONFIG_CLEAN_COMPILE=y
17CONFIG_BROKEN_ON_SMP=y 17CONFIG_BROKEN_ON_SMP=y
18CONFIG_LOCK_KERNEL=y 18CONFIG_LOCK_KERNEL=y
19CONFIG_INIT_ENV_ARG_LIMIT=32
19 20
20# 21#
21# General setup 22# General setup
@@ -28,13 +29,15 @@ CONFIG_BSD_PROCESS_ACCT=y
28# CONFIG_BSD_PROCESS_ACCT_V3 is not set 29# CONFIG_BSD_PROCESS_ACCT_V3 is not set
29CONFIG_SYSCTL=y 30CONFIG_SYSCTL=y
30# CONFIG_AUDIT is not set 31# CONFIG_AUDIT is not set
31CONFIG_LOG_BUF_SHIFT=14
32CONFIG_HOTPLUG=y 32CONFIG_HOTPLUG=y
33CONFIG_KOBJECT_UEVENT=y 33CONFIG_KOBJECT_UEVENT=y
34CONFIG_IKCONFIG=y 34CONFIG_IKCONFIG=y
35# CONFIG_IKCONFIG_PROC is not set 35# CONFIG_IKCONFIG_PROC is not set
36CONFIG_EMBEDDED=y 36CONFIG_EMBEDDED=y
37# CONFIG_KALLSYMS is not set 37# CONFIG_KALLSYMS is not set
38CONFIG_PRINTK=y
39CONFIG_BUG=y
40CONFIG_BASE_FULL=y
38# CONFIG_FUTEX is not set 41# CONFIG_FUTEX is not set
39# CONFIG_EPOLL is not set 42# CONFIG_EPOLL is not set
40# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 43# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -44,6 +47,7 @@ CONFIG_CC_ALIGN_LABELS=0
44CONFIG_CC_ALIGN_LOOPS=0 47CONFIG_CC_ALIGN_LOOPS=0
45CONFIG_CC_ALIGN_JUMPS=0 48CONFIG_CC_ALIGN_JUMPS=0
46# CONFIG_TINY_SHMEM is not set 49# CONFIG_TINY_SHMEM is not set
50CONFIG_BASE_SMALL=0
47 51
48# 52#
49# Loadable module support 53# Loadable module support
@@ -65,6 +69,7 @@ CONFIG_PLAT_M32700UT=y
65# CONFIG_PLAT_OPSPUT is not set 69# CONFIG_PLAT_OPSPUT is not set
66# CONFIG_PLAT_OAKS32R is not set 70# CONFIG_PLAT_OAKS32R is not set
67# CONFIG_PLAT_MAPPI2 is not set 71# CONFIG_PLAT_MAPPI2 is not set
72# CONFIG_PLAT_MAPPI3 is not set
68CONFIG_CHIP_M32700=y 73CONFIG_CHIP_M32700=y
69# CONFIG_CHIP_M32102 is not set 74# CONFIG_CHIP_M32102 is not set
70# CONFIG_CHIP_VDEC2 is not set 75# CONFIG_CHIP_VDEC2 is not set
@@ -268,7 +273,6 @@ CONFIG_NET=y
268# 273#
269CONFIG_PACKET=y 274CONFIG_PACKET=y
270# CONFIG_PACKET_MMAP is not set 275# CONFIG_PACKET_MMAP is not set
271# CONFIG_NETLINK_DEV is not set
272CONFIG_UNIX=y 276CONFIG_UNIX=y
273# CONFIG_NET_KEY is not set 277# CONFIG_NET_KEY is not set
274CONFIG_INET=y 278CONFIG_INET=y
@@ -393,18 +397,6 @@ CONFIG_INPUT=y
393# CONFIG_INPUT_EVBUG is not set 397# CONFIG_INPUT_EVBUG is not set
394 398
395# 399#
396# Input I/O drivers
397#
398# CONFIG_GAMEPORT is not set
399CONFIG_SOUND_GAMEPORT=y
400CONFIG_SERIO=y
401# CONFIG_SERIO_I8042 is not set
402CONFIG_SERIO_SERPORT=y
403# CONFIG_SERIO_CT82C710 is not set
404# CONFIG_SERIO_LIBPS2 is not set
405# CONFIG_SERIO_RAW is not set
406
407#
408# Input Device Drivers 400# Input Device Drivers
409# 401#
410# CONFIG_INPUT_KEYBOARD is not set 402# CONFIG_INPUT_KEYBOARD is not set
@@ -414,6 +406,17 @@ CONFIG_SERIO_SERPORT=y
414# CONFIG_INPUT_MISC is not set 406# CONFIG_INPUT_MISC is not set
415 407
416# 408#
409# Hardware I/O ports
410#
411CONFIG_SERIO=y
412# CONFIG_SERIO_I8042 is not set
413CONFIG_SERIO_SERPORT=y
414# CONFIG_SERIO_LIBPS2 is not set
415# CONFIG_SERIO_RAW is not set
416# CONFIG_GAMEPORT is not set
417CONFIG_SOUND_GAMEPORT=y
418
419#
417# Character devices 420# Character devices
418# 421#
419CONFIG_VT=y 422CONFIG_VT=y
@@ -465,6 +468,10 @@ CONFIG_DS1302=y
465# CONFIG_RAW_DRIVER is not set 468# CONFIG_RAW_DRIVER is not set
466 469
467# 470#
471# TPM devices
472#
473
474#
468# I2C support 475# I2C support
469# 476#
470# CONFIG_I2C is not set 477# CONFIG_I2C is not set
@@ -508,8 +515,14 @@ CONFIG_VIDEO_M32R_AR_M64278=y
508# Graphics support 515# Graphics support
509# 516#
510CONFIG_FB=y 517CONFIG_FB=y
518# CONFIG_FB_CFB_FILLRECT is not set
519# CONFIG_FB_CFB_COPYAREA is not set
520# CONFIG_FB_CFB_IMAGEBLIT is not set
521# CONFIG_FB_SOFT_CURSOR is not set
522# CONFIG_FB_MACMODES is not set
511# CONFIG_FB_MODE_HELPERS is not set 523# CONFIG_FB_MODE_HELPERS is not set
512# CONFIG_FB_TILEBLITTING is not set 524# CONFIG_FB_TILEBLITTING is not set
525# CONFIG_FB_S1D13XXX is not set
513# CONFIG_FB_VIRTUAL is not set 526# CONFIG_FB_VIRTUAL is not set
514 527
515# 528#
@@ -543,10 +556,6 @@ CONFIG_LOGO_LINUX_CLUT224=y
543# CONFIG_USB_ARCH_HAS_OHCI is not set 556# CONFIG_USB_ARCH_HAS_OHCI is not set
544 557
545# 558#
546# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
547#
548
549#
550# USB Gadget Support 559# USB Gadget Support
551# 560#
552# CONFIG_USB_GADGET is not set 561# CONFIG_USB_GADGET is not set
@@ -719,8 +728,9 @@ CONFIG_NLS_DEFAULT="iso8859-1"
719# 728#
720# Kernel hacking 729# Kernel hacking
721# 730#
731# CONFIG_PRINTK_TIME is not set
722# CONFIG_DEBUG_KERNEL is not set 732# CONFIG_DEBUG_KERNEL is not set
723CONFIG_DEBUG_PREEMPT=y 733CONFIG_LOG_BUF_SHIFT=14
724# CONFIG_DEBUG_BUGVERBOSE is not set 734# CONFIG_DEBUG_BUGVERBOSE is not set
725# CONFIG_FRAME_POINTER is not set 735# CONFIG_FRAME_POINTER is not set
726 736
diff --git a/arch/m32r/kernel/Makefile b/arch/m32r/kernel/Makefile
index cfd690bf6d8a..6c6b6c376638 100644
--- a/arch/m32r/kernel/Makefile
+++ b/arch/m32r/kernel/Makefile
@@ -10,6 +10,7 @@ obj-y := process.o entry.o traps.o align.o irq.o setup.o time.o \
10obj-$(CONFIG_SMP) += smp.o smpboot.o 10obj-$(CONFIG_SMP) += smp.o smpboot.o
11obj-$(CONFIG_PLAT_MAPPI) += setup_mappi.o io_mappi.o 11obj-$(CONFIG_PLAT_MAPPI) += setup_mappi.o io_mappi.o
12obj-$(CONFIG_PLAT_MAPPI2) += setup_mappi2.o io_mappi2.o 12obj-$(CONFIG_PLAT_MAPPI2) += setup_mappi2.o io_mappi2.o
13obj-$(CONFIG_PLAT_MAPPI3) += setup_mappi3.o io_mappi3.o
13obj-$(CONFIG_PLAT_USRV) += setup_usrv.o io_usrv.o 14obj-$(CONFIG_PLAT_USRV) += setup_usrv.o io_usrv.o
14obj-$(CONFIG_PLAT_M32700UT) += setup_m32700ut.o io_m32700ut.o 15obj-$(CONFIG_PLAT_M32700UT) += setup_m32700ut.o io_m32700ut.o
15obj-$(CONFIG_PLAT_OPSPUT) += setup_opsput.o io_opsput.o 16obj-$(CONFIG_PLAT_OPSPUT) += setup_opsput.o io_opsput.o
@@ -17,4 +18,3 @@ obj-$(CONFIG_MODULES) += module.o
17obj-$(CONFIG_PLAT_OAKS32R) += setup_oaks32r.o io_oaks32r.o 18obj-$(CONFIG_PLAT_OAKS32R) += setup_oaks32r.o io_oaks32r.o
18 19
19EXTRA_AFLAGS := -traditional 20EXTRA_AFLAGS := -traditional
20
diff --git a/arch/m32r/kernel/io_m32700ut.c b/arch/m32r/kernel/io_m32700ut.c
index 371ba904e968..e545b065f7e9 100644
--- a/arch/m32r/kernel/io_m32700ut.c
+++ b/arch/m32r/kernel/io_m32700ut.c
@@ -3,8 +3,8 @@
3 * 3 *
4 * Typical I/O routines for M32700UT board. 4 * Typical I/O routines for M32700UT board.
5 * 5 *
6 * Copyright (c) 2001, 2002 Hiroyuki Kondo, Hirokazu Takata, 6 * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto, Takeo Takahashi 7 * Hitoshi Yamamoto, Takeo Takahashi
8 * 8 *
9 * This file is subject to the terms and conditions of the GNU General 9 * This file is subject to the terms and conditions of the GNU General
10 * Public License. See the file "COPYING" in the main directory of this 10 * Public License. See the file "COPYING" in the main directory of this
@@ -172,64 +172,21 @@ unsigned long _inl(unsigned long port)
172 172
173unsigned char _inb_p(unsigned long port) 173unsigned char _inb_p(unsigned long port)
174{ 174{
175 unsigned char v; 175 unsigned char v = _inb(port);
176
177 if (port >= LAN_IOSTART && port < LAN_IOEND)
178 v = _ne_inb(PORT2ADDR_NE(port));
179 else
180#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
181 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
182 return *(volatile unsigned char *)__port2addr_ata(port);
183 } else
184#endif
185#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
186 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
187 unsigned char b;
188 pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
189 return b;
190 } else
191#endif
192 v = *(volatile unsigned char *)PORT2ADDR(port);
193
194 delay(); 176 delay();
195 return (v); 177 return (v);
196} 178}
197 179
198unsigned short _inw_p(unsigned long port) 180unsigned short _inw_p(unsigned long port)
199{ 181{
200 unsigned short v; 182 unsigned short v = _inw(port);
201
202 if (port >= LAN_IOSTART && port < LAN_IOEND)
203 v = _ne_inw(PORT2ADDR_NE(port));
204 else
205#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
206 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
207 return *(volatile unsigned short *)__port2addr_ata(port);
208 } else
209#endif
210#if defined(CONFIG_USB)
211 if(port >= 0x340 && port < 0x3a0)
212 return *(volatile unsigned short *)PORT2ADDR_USB(port);
213 else
214#endif
215#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
216 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
217 unsigned short w;
218 pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
219 return w;
220 } else
221#endif
222 v = *(volatile unsigned short *)PORT2ADDR(port);
223
224 delay(); 183 delay();
225 return (v); 184 return (v);
226} 185}
227 186
228unsigned long _inl_p(unsigned long port) 187unsigned long _inl_p(unsigned long port)
229{ 188{
230 unsigned long v; 189 unsigned long v = _inl(port);
231
232 v = *(volatile unsigned long *)PORT2ADDR(port);
233 delay(); 190 delay();
234 return (v); 191 return (v);
235} 192}
@@ -287,52 +244,19 @@ void _outl(unsigned long l, unsigned long port)
287 244
288void _outb_p(unsigned char b, unsigned long port) 245void _outb_p(unsigned char b, unsigned long port)
289{ 246{
290 if (port >= LAN_IOSTART && port < LAN_IOEND) 247 _outb(b, port);
291 _ne_outb(b, PORT2ADDR_NE(port));
292 else
293#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
294 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
295 *(volatile unsigned char *)__port2addr_ata(port) = b;
296 } else
297#endif
298#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
299 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
300 pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
301 } else
302#endif
303 *(volatile unsigned char *)PORT2ADDR(port) = b;
304
305 delay(); 248 delay();
306} 249}
307 250
308void _outw_p(unsigned short w, unsigned long port) 251void _outw_p(unsigned short w, unsigned long port)
309{ 252{
310 if (port >= LAN_IOSTART && port < LAN_IOEND) 253 _outw(w, port);
311 _ne_outw(w, PORT2ADDR_NE(port));
312 else
313#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
314 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
315 *(volatile unsigned short *)__port2addr_ata(port) = w;
316 } else
317#endif
318#if defined(CONFIG_USB)
319 if(port >= 0x340 && port < 0x3a0)
320 *(volatile unsigned short *)PORT2ADDR_USB(port) = w;
321 else
322#endif
323#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
324 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
325 pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
326 } else
327#endif
328 *(volatile unsigned short *)PORT2ADDR(port) = w;
329
330 delay(); 254 delay();
331} 255}
332 256
333void _outl_p(unsigned long l, unsigned long port) 257void _outl_p(unsigned long l, unsigned long port)
334{ 258{
335 *(volatile unsigned long *)PORT2ADDR(port) = l; 259 _outl(l, port);
336 delay(); 260 delay();
337} 261}
338 262
diff --git a/arch/m32r/kernel/io_mappi.c b/arch/m32r/kernel/io_mappi.c
index 85688ffb52f9..78033165fb5c 100644
--- a/arch/m32r/kernel/io_mappi.c
+++ b/arch/m32r/kernel/io_mappi.c
@@ -3,8 +3,8 @@
3 * 3 *
4 * Typical I/O routines for Mappi board. 4 * Typical I/O routines for Mappi board.
5 * 5 *
6 * Copyright (c) 2001, 2002 Hiroyuki Kondo, Hirokazu Takata, 6 * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto 7 * Hitoshi Yamamoto
8 */ 8 */
9 9
10#include <linux/config.h> 10#include <linux/config.h>
@@ -130,57 +130,21 @@ unsigned long _inl(unsigned long port)
130 130
131unsigned char _inb_p(unsigned long port) 131unsigned char _inb_p(unsigned long port)
132{ 132{
133 unsigned char v; 133 unsigned char v = _inb(port);
134
135 if (port >= 0x300 && port < 0x320)
136 v = _ne_inb(PORT2ADDR_NE(port));
137 else
138#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
139 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
140 unsigned char b;
141 pcc_ioread(0, port, &b, sizeof(b), 1, 0);
142 return b;
143 } else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
144 unsigned char b;
145 pcc_ioread(1, port, &b, sizeof(b), 1, 0);
146 return b;
147 } else
148#endif
149 v = *(volatile unsigned char *)PORT2ADDR(port);
150
151 delay(); 134 delay();
152 return (v); 135 return (v);
153} 136}
154 137
155unsigned short _inw_p(unsigned long port) 138unsigned short _inw_p(unsigned long port)
156{ 139{
157 unsigned short v; 140 unsigned short v = _inw(port);
158
159 if (port >= 0x300 && port < 0x320)
160 v = _ne_inw(PORT2ADDR_NE(port));
161 else
162#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
163 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
164 unsigned short w;
165 pcc_ioread(0, port, &w, sizeof(w), 1, 0);
166 return w;
167 } else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
168 unsigned short w;
169 pcc_ioread(1, port, &w, sizeof(w), 1, 0);
170 return w;
171 } else
172#endif
173 v = *(volatile unsigned short *)PORT2ADDR(port);
174
175 delay(); 141 delay();
176 return (v); 142 return (v);
177} 143}
178 144
179unsigned long _inl_p(unsigned long port) 145unsigned long _inl_p(unsigned long port)
180{ 146{
181 unsigned long v; 147 unsigned long v = _inl(port);
182
183 v = *(volatile unsigned long *)PORT2ADDR(port);
184 delay(); 148 delay();
185 return (v); 149 return (v);
186} 150}
@@ -229,41 +193,19 @@ void _outl(unsigned long l, unsigned long port)
229 193
230void _outb_p(unsigned char b, unsigned long port) 194void _outb_p(unsigned char b, unsigned long port)
231{ 195{
232 if (port >= 0x300 && port < 0x320) 196 _outb(b, port);
233 _ne_outb(b, PORT2ADDR_NE(port));
234 else
235#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
236 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
237 pcc_iowrite(0, port, &b, sizeof(b), 1, 0);
238 } else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
239 pcc_iowrite(1, port, &b, sizeof(b), 1, 0);
240 } else
241#endif
242 *(volatile unsigned char *)PORT2ADDR(port) = b;
243
244 delay(); 197 delay();
245} 198}
246 199
247void _outw_p(unsigned short w, unsigned long port) 200void _outw_p(unsigned short w, unsigned long port)
248{ 201{
249 if (port >= 0x300 && port < 0x320) 202 _outw(w, port);
250 _ne_outw(w, PORT2ADDR_NE(port));
251 else
252#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_PCC)
253 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
254 pcc_iowrite(0, port, &w, sizeof(w), 1, 0);
255 } else if (port >= M32R_PCC_IOSTART1 && port <= M32R_PCC_IOEND1) {
256 pcc_iowrite(1, port, &w, sizeof(w), 1, 0);
257 } else
258#endif
259 *(volatile unsigned short *)PORT2ADDR(port) = w;
260
261 delay(); 203 delay();
262} 204}
263 205
264void _outl_p(unsigned long l, unsigned long port) 206void _outl_p(unsigned long l, unsigned long port)
265{ 207{
266 *(volatile unsigned long *)PORT2ADDR(port) = l; 208 _outl(l, port);
267 delay(); 209 delay();
268} 210}
269 211
diff --git a/arch/m32r/kernel/io_mappi2.c b/arch/m32r/kernel/io_mappi2.c
index 4182cd4f97c8..5c03504bf653 100644
--- a/arch/m32r/kernel/io_mappi2.c
+++ b/arch/m32r/kernel/io_mappi2.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Typical I/O routines for Mappi2 board. 4 * Typical I/O routines for Mappi2 board.
5 * 5 *
6 * Copyright (c) 2001-2003 Hiroyuki Kondo, Hirokazu Takata, 6 * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto, Mamoru Sakugawa 7 * Hitoshi Yamamoto, Mamoru Sakugawa
8 */ 8 */
9 9
@@ -25,7 +25,7 @@ extern void pcc_ioread_byte(int, unsigned long, void *, size_t, size_t, int);
25extern void pcc_ioread_word(int, unsigned long, void *, size_t, size_t, int); 25extern void pcc_ioread_word(int, unsigned long, void *, size_t, size_t, int);
26extern void pcc_iowrite_byte(int, unsigned long, void *, size_t, size_t, int); 26extern void pcc_iowrite_byte(int, unsigned long, void *, size_t, size_t, int);
27extern void pcc_iowrite_word(int, unsigned long, void *, size_t, size_t, int); 27extern void pcc_iowrite_word(int, unsigned long, void *, size_t, size_t, int);
28#endif /* CONFIG_PCMCIA && CONFIG_MAPPI2_CFC */ 28#endif /* CONFIG_PCMCIA && CONFIG_M32R_CFC */
29 29
30#define PORT2ADDR(port) _port2addr(port) 30#define PORT2ADDR(port) _port2addr(port)
31#define PORT2ADDR_NE(port) _port2addr_ne(port) 31#define PORT2ADDR_NE(port) _port2addr_ne(port)
@@ -169,64 +169,21 @@ unsigned long _inl(unsigned long port)
169 169
170unsigned char _inb_p(unsigned long port) 170unsigned char _inb_p(unsigned long port)
171{ 171{
172 unsigned char v; 172 unsigned char v = _inb(port);
173
174 if (port >= LAN_IOSTART && port < LAN_IOEND)
175 v = _ne_inb(PORT2ADDR_NE(port));
176 else
177#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
178 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
179 return *(volatile unsigned char *)__port2addr_ata(port);
180 } else
181#endif
182#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
183 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
184 unsigned char b;
185 pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
186 return b;
187 } else
188#endif
189 v = *(volatile unsigned char *)PORT2ADDR(port);
190
191 delay(); 173 delay();
192 return (v); 174 return (v);
193} 175}
194 176
195unsigned short _inw_p(unsigned long port) 177unsigned short _inw_p(unsigned long port)
196{ 178{
197 unsigned short v; 179 unsigned short v = _inw(port);
198
199 if (port >= LAN_IOSTART && port < LAN_IOEND)
200 v = _ne_inw(PORT2ADDR_NE(port));
201 else
202#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
203 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
204 return *(volatile unsigned short *)__port2addr_ata(port);
205 } else
206#endif
207#if defined(CONFIG_USB)
208 if (port >= 0x340 && port < 0x3a0)
209 v = *(volatile unsigned short *)PORT2ADDR_USB(port);
210 else
211#endif
212#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
213 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
214 unsigned short w;
215 pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
216 return w;
217 } else
218#endif
219 v = *(volatile unsigned short *)PORT2ADDR(port);
220
221 delay(); 180 delay();
222 return (v); 181 return (v);
223} 182}
224 183
225unsigned long _inl_p(unsigned long port) 184unsigned long _inl_p(unsigned long port)
226{ 185{
227 unsigned long v; 186 unsigned long v = _inl(port);
228
229 v = *(volatile unsigned long *)PORT2ADDR(port);
230 delay(); 187 delay();
231 return (v); 188 return (v);
232} 189}
@@ -284,52 +241,19 @@ void _outl(unsigned long l, unsigned long port)
284 241
285void _outb_p(unsigned char b, unsigned long port) 242void _outb_p(unsigned char b, unsigned long port)
286{ 243{
287 if (port >= LAN_IOSTART && port < LAN_IOEND) 244 _outb(b, port);
288 _ne_outb(b, PORT2ADDR_NE(port));
289 else
290#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
291 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
292 *(volatile unsigned char *)__port2addr_ata(port) = b;
293 } else
294#endif
295#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
296 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
297 pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
298 } else
299#endif
300 *(volatile unsigned char *)PORT2ADDR(port) = b;
301
302 delay(); 245 delay();
303} 246}
304 247
305void _outw_p(unsigned short w, unsigned long port) 248void _outw_p(unsigned short w, unsigned long port)
306{ 249{
307 if (port >= LAN_IOSTART && port < LAN_IOEND) 250 _outw(w, port);
308 _ne_outw(w, PORT2ADDR_NE(port));
309 else
310#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
311 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
312 *(volatile unsigned short *)__port2addr_ata(port) = w;
313 } else
314#endif
315#if defined(CONFIG_USB)
316 if (port >= 0x340 && port < 0x3a0)
317 *(volatile unsigned short *)PORT2ADDR_USB(port) = w;
318 else
319#endif
320#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
321 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
322 pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
323 } else
324#endif
325 *(volatile unsigned short *)PORT2ADDR(port) = w;
326
327 delay(); 251 delay();
328} 252}
329 253
330void _outl_p(unsigned long l, unsigned long port) 254void _outl_p(unsigned long l, unsigned long port)
331{ 255{
332 *(volatile unsigned long *)PORT2ADDR(port) = l; 256 _outl(l, port);
333 delay(); 257 delay();
334} 258}
335 259
diff --git a/arch/m32r/kernel/io_mappi3.c b/arch/m32r/kernel/io_mappi3.c
new file mode 100644
index 000000000000..c80bde657854
--- /dev/null
+++ b/arch/m32r/kernel/io_mappi3.c
@@ -0,0 +1,378 @@
1/*
2 * linux/arch/m32r/kernel/io_mappi3.c
3 *
4 * Typical I/O routines for Mappi3 board.
5 *
6 * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto, Mamoru Sakugawa
8 */
9
10#include <linux/config.h>
11#include <asm/m32r.h>
12#include <asm/page.h>
13#include <asm/io.h>
14#include <asm/byteorder.h>
15
16#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
17#include <linux/types.h>
18
19#define M32R_PCC_IOMAP_SIZE 0x1000
20
21#define M32R_PCC_IOSTART0 0x1000
22#define M32R_PCC_IOEND0 (M32R_PCC_IOSTART0 + M32R_PCC_IOMAP_SIZE - 1)
23
24extern void pcc_ioread_byte(int, unsigned long, void *, size_t, size_t, int);
25extern void pcc_ioread_word(int, unsigned long, void *, size_t, size_t, int);
26extern void pcc_iowrite_byte(int, unsigned long, void *, size_t, size_t, int);
27extern void pcc_iowrite_word(int, unsigned long, void *, size_t, size_t, int);
28#endif /* CONFIG_PCMCIA && CONFIG_M32R_CFC */
29
30#define PORT2ADDR(port) _port2addr(port)
31#define PORT2ADDR_NE(port) _port2addr_ne(port)
32#define PORT2ADDR_USB(port) _port2addr_usb(port)
33
34static inline void *_port2addr(unsigned long port)
35{
36 return (void *)(port + NONCACHE_OFFSET);
37}
38
39#define LAN_IOSTART 0x300
40#define LAN_IOEND 0x320
41
42#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
43static inline void *__port2addr_ata(unsigned long port)
44{
45 static int dummy_reg;
46
47 switch (port) {
48 case 0x1f0: return (void *)0xb4002000;
49 case 0x1f1: return (void *)0xb4012800;
50 case 0x1f2: return (void *)0xb4012002;
51 case 0x1f3: return (void *)0xb4012802;
52 case 0x1f4: return (void *)0xb4012004;
53 case 0x1f5: return (void *)0xb4012804;
54 case 0x1f6: return (void *)0xb4012006;
55 case 0x1f7: return (void *)0xb4012806;
56 case 0x3f6: return (void *)0xb401200e;
57 default: return (void *)&dummy_reg;
58 }
59}
60#endif
61
62static inline void *_port2addr_ne(unsigned long port)
63{
64 return (void *)(port + NONCACHE_OFFSET + 0x10000000);
65}
66
67static inline void *_port2addr_usb(unsigned long port)
68{
69 return (void *)(port + NONCACHE_OFFSET + 0x12000000);
70}
71static inline void delay(void)
72{
73 __asm__ __volatile__ ("push r0; \n\t pop r0;" : : :"memory");
74}
75
76/*
77 * NIC I/O function
78 */
79
80static inline unsigned char _ne_inb(void *portp)
81{
82 return (unsigned char) *(volatile unsigned char *)portp;
83}
84
85static inline unsigned short _ne_inw(void *portp)
86{
87 return (unsigned short)le16_to_cpu(*(volatile unsigned short *)portp);
88}
89
90static inline void _ne_insb(void *portp, void * addr, unsigned long count)
91{
92 unsigned char *buf = addr;
93
94 while (count--)
95 *buf++ = *(volatile unsigned char *)portp;
96}
97
98static inline void _ne_outb(unsigned char b, void *portp)
99{
100 *(volatile unsigned char *)portp = (unsigned char)b;
101}
102
103static inline void _ne_outw(unsigned short w, void *portp)
104{
105 *(volatile unsigned short *)portp = cpu_to_le16(w);
106}
107
108unsigned char _inb(unsigned long port)
109{
110 if (port >= LAN_IOSTART && port < LAN_IOEND)
111 return _ne_inb(PORT2ADDR_NE(port));
112#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
113 else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
114 return *(volatile unsigned char *)__port2addr_ata(port);
115 }
116#endif
117#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
118 else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
119 unsigned char b;
120 pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
121 return b;
122 } else
123#endif
124 return *(volatile unsigned char *)PORT2ADDR(port);
125}
126
127unsigned short _inw(unsigned long port)
128{
129 if (port >= LAN_IOSTART && port < LAN_IOEND)
130 return _ne_inw(PORT2ADDR_NE(port));
131#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
132 else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
133 return *(volatile unsigned short *)__port2addr_ata(port);
134 }
135#endif
136#if defined(CONFIG_USB)
137 else if (port >= 0x340 && port < 0x3a0)
138 return *(volatile unsigned short *)PORT2ADDR_USB(port);
139#endif
140
141#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
142 else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
143 unsigned short w;
144 pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
145 return w;
146 } else
147#endif
148 return *(volatile unsigned short *)PORT2ADDR(port);
149}
150
151unsigned long _inl(unsigned long port)
152{
153#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
154 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
155 unsigned long l;
156 pcc_ioread_word(0, port, &l, sizeof(l), 1, 0);
157 return l;
158 } else
159#endif
160 return *(volatile unsigned long *)PORT2ADDR(port);
161}
162
163unsigned char _inb_p(unsigned long port)
164{
165 unsigned char v = _inb(port);
166 delay();
167 return (v);
168}
169
170unsigned short _inw_p(unsigned long port)
171{
172 unsigned short v = _inw(port);
173 delay();
174 return (v);
175}
176
177unsigned long _inl_p(unsigned long port)
178{
179 unsigned long v = _inl(port);
180 delay();
181 return (v);
182}
183
184void _outb(unsigned char b, unsigned long port)
185{
186 if (port >= LAN_IOSTART && port < LAN_IOEND)
187 _ne_outb(b, PORT2ADDR_NE(port));
188 else
189#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
190 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
191 *(volatile unsigned char *)__port2addr_ata(port) = b;
192 } else
193#endif
194#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
195 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
196 pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
197 } else
198#endif
199 *(volatile unsigned char *)PORT2ADDR(port) = b;
200}
201
202void _outw(unsigned short w, unsigned long port)
203{
204 if (port >= LAN_IOSTART && port < LAN_IOEND)
205 _ne_outw(w, PORT2ADDR_NE(port));
206 else
207#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
208 if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
209 *(volatile unsigned short *)__port2addr_ata(port) = w;
210 } else
211#endif
212#if defined(CONFIG_USB)
213 if (port >= 0x340 && port < 0x3a0)
214 *(volatile unsigned short *)PORT2ADDR_USB(port) = w;
215 else
216#endif
217#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
218 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
219 pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
220 } else
221#endif
222 *(volatile unsigned short *)PORT2ADDR(port) = w;
223}
224
225void _outl(unsigned long l, unsigned long port)
226{
227#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
228 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
229 pcc_iowrite_word(0, port, &l, sizeof(l), 1, 0);
230 } else
231#endif
232 *(volatile unsigned long *)PORT2ADDR(port) = l;
233}
234
235void _outb_p(unsigned char b, unsigned long port)
236{
237 _outb(b, port);
238 delay();
239}
240
241void _outw_p(unsigned short w, unsigned long port)
242{
243 _outw(w, port);
244 delay();
245}
246
247void _outl_p(unsigned long l, unsigned long port)
248{
249 _outl(l, port);
250 delay();
251}
252
253void _insb(unsigned int port, void * addr, unsigned long count)
254{
255 if (port >= LAN_IOSTART && port < LAN_IOEND)
256 _ne_insb(PORT2ADDR_NE(port), addr, count);
257#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
258 else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
259 unsigned char *buf = addr;
260 unsigned char *portp = __port2addr_ata(port);
261 while (count--)
262 *buf++ = *(volatile unsigned char *)portp;
263 }
264#endif
265#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
266 else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
267 pcc_ioread_byte(0, port, (void *)addr, sizeof(unsigned char),
268 count, 1);
269 }
270#endif
271 else {
272 unsigned char *buf = addr;
273 unsigned char *portp = PORT2ADDR(port);
274 while (count--)
275 *buf++ = *(volatile unsigned char *)portp;
276 }
277}
278
279void _insw(unsigned int port, void * addr, unsigned long count)
280{
281 unsigned short *buf = addr;
282 unsigned short *portp;
283
284 if (port >= LAN_IOSTART && port < LAN_IOEND) {
285 portp = PORT2ADDR_NE(port);
286 while (count--)
287 *buf++ = *(volatile unsigned short *)portp;
288#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
289 } else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
290 pcc_ioread_word(9, port, (void *)addr, sizeof(unsigned short),
291 count, 1);
292#endif
293#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
294 } else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
295 portp = __port2addr_ata(port);
296 while (count--)
297 *buf++ = *(volatile unsigned short *)portp;
298#endif
299 } else {
300 portp = PORT2ADDR(port);
301 while (count--)
302 *buf++ = *(volatile unsigned short *)portp;
303 }
304}
305
306void _insl(unsigned int port, void * addr, unsigned long count)
307{
308 unsigned long *buf = addr;
309 unsigned long *portp;
310
311 portp = PORT2ADDR(port);
312 while (count--)
313 *buf++ = *(volatile unsigned long *)portp;
314}
315
316void _outsb(unsigned int port, const void * addr, unsigned long count)
317{
318 const unsigned char *buf = addr;
319 unsigned char *portp;
320
321 if (port >= LAN_IOSTART && port < LAN_IOEND) {
322 portp = PORT2ADDR_NE(port);
323 while (count--)
324 _ne_outb(*buf++, portp);
325#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
326 } else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
327 portp = __port2addr_ata(port);
328 while (count--)
329 *(volatile unsigned char *)portp = *buf++;
330#endif
331#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
332 } else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
333 pcc_iowrite_byte(0, port, (void *)addr, sizeof(unsigned char),
334 count, 1);
335#endif
336 } else {
337 portp = PORT2ADDR(port);
338 while (count--)
339 *(volatile unsigned char *)portp = *buf++;
340 }
341}
342
343void _outsw(unsigned int port, const void * addr, unsigned long count)
344{
345 const unsigned short *buf = addr;
346 unsigned short *portp;
347
348 if (port >= LAN_IOSTART && port < LAN_IOEND) {
349 portp = PORT2ADDR_NE(port);
350 while (count--)
351 *(volatile unsigned short *)portp = *buf++;
352#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC)
353 } else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) {
354 portp = __port2addr_ata(port);
355 while (count--)
356 *(volatile unsigned short *)portp = *buf++;
357#endif
358#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
359 } else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
360 pcc_iowrite_word(9, port, (void *)addr, sizeof(unsigned short),
361 count, 1);
362#endif
363 } else {
364 portp = PORT2ADDR(port);
365 while (count--)
366 *(volatile unsigned short *)portp = *buf++;
367 }
368}
369
370void _outsl(unsigned int port, const void * addr, unsigned long count)
371{
372 const unsigned long *buf = addr;
373 unsigned char *portp;
374
375 portp = PORT2ADDR(port);
376 while (count--)
377 *(volatile unsigned long *)portp = *buf++;
378}
diff --git a/arch/m32r/kernel/io_oaks32r.c b/arch/m32r/kernel/io_oaks32r.c
index 286964794d51..9997dddd24d7 100644
--- a/arch/m32r/kernel/io_oaks32r.c
+++ b/arch/m32r/kernel/io_oaks32r.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Typical I/O routines for OAKS32R board. 4 * Typical I/O routines for OAKS32R board.
5 * 5 *
6 * Copyright (c) 2001-2004 Hiroyuki Kondo, Hirokazu Takata, 6 * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto, Mamoru Sakugawa 7 * Hitoshi Yamamoto, Mamoru Sakugawa
8 */ 8 */
9 9
@@ -90,35 +90,21 @@ unsigned long _inl(unsigned long port)
90 90
91unsigned char _inb_p(unsigned long port) 91unsigned char _inb_p(unsigned long port)
92{ 92{
93 unsigned char v; 93 unsigned char v = _inb(port);
94
95 if (port >= 0x300 && port < 0x320)
96 v = _ne_inb(PORT2ADDR_NE(port));
97 else
98 v = *(volatile unsigned char *)PORT2ADDR(port);
99
100 delay(); 94 delay();
101 return (v); 95 return (v);
102} 96}
103 97
104unsigned short _inw_p(unsigned long port) 98unsigned short _inw_p(unsigned long port)
105{ 99{
106 unsigned short v; 100 unsigned short v = _inw(port);
107
108 if (port >= 0x300 && port < 0x320)
109 v = _ne_inw(PORT2ADDR_NE(port));
110 else
111 v = *(volatile unsigned short *)PORT2ADDR(port);
112
113 delay(); 101 delay();
114 return (v); 102 return (v);
115} 103}
116 104
117unsigned long _inl_p(unsigned long port) 105unsigned long _inl_p(unsigned long port)
118{ 106{
119 unsigned long v; 107 unsigned long v = _inl(port);
120
121 v = *(volatile unsigned long *)PORT2ADDR(port);
122 delay(); 108 delay();
123 return (v); 109 return (v);
124} 110}
@@ -146,27 +132,19 @@ void _outl(unsigned long l, unsigned long port)
146 132
147void _outb_p(unsigned char b, unsigned long port) 133void _outb_p(unsigned char b, unsigned long port)
148{ 134{
149 if (port >= 0x300 && port < 0x320) 135 _outb(b, port);
150 _ne_outb(b, PORT2ADDR_NE(port));
151 else
152 *(volatile unsigned char *)PORT2ADDR(port) = b;
153
154 delay(); 136 delay();
155} 137}
156 138
157void _outw_p(unsigned short w, unsigned long port) 139void _outw_p(unsigned short w, unsigned long port)
158{ 140{
159 if (port >= 0x300 && port < 0x320) 141 _outw(w, port);
160 _ne_outw(w, PORT2ADDR_NE(port));
161 else
162 *(volatile unsigned short *)PORT2ADDR(port) = w;
163
164 delay(); 142 delay();
165} 143}
166 144
167void _outl_p(unsigned long l, unsigned long port) 145void _outl_p(unsigned long l, unsigned long port)
168{ 146{
169 *(volatile unsigned long *)PORT2ADDR(port) = l; 147 _outl(l, port);
170 delay(); 148 delay();
171} 149}
172 150
diff --git a/arch/m32r/kernel/io_opsput.c b/arch/m32r/kernel/io_opsput.c
index aaf42f9f76da..e34951e8156f 100644
--- a/arch/m32r/kernel/io_opsput.c
+++ b/arch/m32r/kernel/io_opsput.c
@@ -1,10 +1,10 @@
1/* 1/*
2 * linux/arch/m32r/kernel/io_mappi.c 2 * linux/arch/m32r/kernel/io_opsput.c
3 * 3 *
4 * Typical I/O routines for OPSPUT board. 4 * Typical I/O routines for OPSPUT board.
5 * 5 *
6 * Copyright (c) 2001, 2002 Hiroyuki Kondo, Hirokazu Takata, 6 * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto, Takeo Takahashi 7 * Hitoshi Yamamoto, Takeo Takahashi
8 * 8 *
9 * This file is subject to the terms and conditions of the GNU General 9 * This file is subject to the terms and conditions of the GNU General
10 * Public License. See the file "COPYING" in the main directory of this 10 * Public License. See the file "COPYING" in the main directory of this
@@ -98,7 +98,6 @@ unsigned char _inb(unsigned long port)
98{ 98{
99 if (port >= LAN_IOSTART && port < LAN_IOEND) 99 if (port >= LAN_IOSTART && port < LAN_IOEND)
100 return _ne_inb(PORT2ADDR_NE(port)); 100 return _ne_inb(PORT2ADDR_NE(port));
101
102#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) 101#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
103 else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) { 102 else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
104 unsigned char b; 103 unsigned char b;
@@ -118,7 +117,6 @@ unsigned short _inw(unsigned long port)
118 else if(port >= 0x340 && port < 0x3a0) 117 else if(port >= 0x340 && port < 0x3a0)
119 return *(volatile unsigned short *)PORT2ADDR_USB(port); 118 return *(volatile unsigned short *)PORT2ADDR_USB(port);
120#endif 119#endif
121
122#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) 120#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
123 else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) { 121 else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
124 unsigned short w; 122 unsigned short w;
@@ -143,55 +141,21 @@ unsigned long _inl(unsigned long port)
143 141
144unsigned char _inb_p(unsigned long port) 142unsigned char _inb_p(unsigned long port)
145{ 143{
146 unsigned char v; 144 unsigned char v = _inb(port);
147
148 if (port >= LAN_IOSTART && port < LAN_IOEND)
149 v = _ne_inb(PORT2ADDR_NE(port));
150 else
151#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
152 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
153 unsigned char b;
154 pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
155 return b;
156 } else
157#endif
158 v = *(volatile unsigned char *)PORT2ADDR(port);
159
160 delay(); 145 delay();
161 return (v); 146 return (v);
162} 147}
163 148
164unsigned short _inw_p(unsigned long port) 149unsigned short _inw_p(unsigned long port)
165{ 150{
166 unsigned short v; 151 unsigned short v = _inw(port);
167
168 if (port >= LAN_IOSTART && port < LAN_IOEND)
169 v = _ne_inw(PORT2ADDR_NE(port));
170 else
171#if defined(CONFIG_USB)
172 if(port >= 0x340 && port < 0x3a0)
173 return *(volatile unsigned short *)PORT2ADDR_USB(port);
174 else
175#endif
176
177#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
178 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
179 unsigned short w;
180 pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
181 return w;
182 } else
183#endif
184 v = *(volatile unsigned short *)PORT2ADDR(port);
185
186 delay(); 152 delay();
187 return (v); 153 return (v);
188} 154}
189 155
190unsigned long _inl_p(unsigned long port) 156unsigned long _inl_p(unsigned long port)
191{ 157{
192 unsigned long v; 158 unsigned long v = _inl(port);
193
194 v = *(volatile unsigned long *)PORT2ADDR(port);
195 delay(); 159 delay();
196 return (v); 160 return (v);
197} 161}
@@ -219,7 +183,6 @@ void _outw(unsigned short w, unsigned long port)
219 *(volatile unsigned short *)PORT2ADDR_USB(port) = w; 183 *(volatile unsigned short *)PORT2ADDR_USB(port) = w;
220 else 184 else
221#endif 185#endif
222
223#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) 186#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
224 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) { 187 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
225 pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0); 188 pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
@@ -240,43 +203,19 @@ void _outl(unsigned long l, unsigned long port)
240 203
241void _outb_p(unsigned char b, unsigned long port) 204void _outb_p(unsigned char b, unsigned long port)
242{ 205{
243 if (port >= LAN_IOSTART && port < LAN_IOEND) 206 _outb(b, port);
244 _ne_outb(b, PORT2ADDR_NE(port));
245 else
246#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
247 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
248 pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
249 } else
250#endif
251 *(volatile unsigned char *)PORT2ADDR(port) = b;
252
253 delay(); 207 delay();
254} 208}
255 209
256void _outw_p(unsigned short w, unsigned long port) 210void _outw_p(unsigned short w, unsigned long port)
257{ 211{
258 if (port >= LAN_IOSTART && port < LAN_IOEND) 212 _outw(w, port);
259 _ne_outw(w, PORT2ADDR_NE(port));
260 else
261#if defined(CONFIG_USB)
262 if(port >= 0x340 && port < 0x3a0)
263 *(volatile unsigned short *)PORT2ADDR_USB(port) = w;
264 else
265#endif
266
267#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC)
268 if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) {
269 pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
270 } else
271#endif
272 *(volatile unsigned short *)PORT2ADDR(port) = w;
273
274 delay(); 213 delay();
275} 214}
276 215
277void _outl_p(unsigned long l, unsigned long port) 216void _outl_p(unsigned long l, unsigned long port)
278{ 217{
279 *(volatile unsigned long *)PORT2ADDR(port) = l; 218 _outl(l, port);
280 delay(); 219 delay();
281} 220}
282 221
diff --git a/arch/m32r/kernel/io_usrv.c b/arch/m32r/kernel/io_usrv.c
index 27928a0b99ed..9eb161dcc104 100644
--- a/arch/m32r/kernel/io_usrv.c
+++ b/arch/m32r/kernel/io_usrv.c
@@ -3,8 +3,8 @@
3 * 3 *
4 * Typical I/O routines for uServer board. 4 * Typical I/O routines for uServer board.
5 * 5 *
6 * Copyright (c) 2001 - 2003 Hiroyuki Kondo, Hirokazu Takata, 6 * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto, Takeo Takahashi 7 * Hitoshi Yamamoto, Takeo Takahashi
8 * 8 *
9 * This file is subject to the terms and conditions of the GNU General 9 * This file is subject to the terms and conditions of the GNU General
10 * Public License. See the file "COPYING" in the main directory of this 10 * Public License. See the file "COPYING" in the main directory of this
@@ -39,7 +39,7 @@ extern void pcc_iowrite_word(int, unsigned long, void *, size_t, size_t, int);
39 39
40#define PORT2ADDR(port) _port2addr(port) 40#define PORT2ADDR(port) _port2addr(port)
41 41
42static __inline__ void *_port2addr(unsigned long port) 42static inline void *_port2addr(unsigned long port)
43{ 43{
44#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE) 44#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
45 if (port >= UART0_IOSTART && port <= UART0_IOEND) 45 if (port >= UART0_IOSTART && port <= UART0_IOEND)
@@ -50,7 +50,7 @@ static __inline__ void *_port2addr(unsigned long port)
50 return (void *)(port + NONCACHE_OFFSET); 50 return (void *)(port + NONCACHE_OFFSET);
51} 51}
52 52
53static __inline__ void delay(void) 53static inline void delay(void)
54{ 54{
55 __asm__ __volatile__ ("push r0; \n\t pop r0;" : : :"memory"); 55 __asm__ __volatile__ ("push r0; \n\t pop r0;" : : :"memory");
56} 56}
@@ -87,39 +87,22 @@ unsigned long _inl(unsigned long port)
87 87
88unsigned char _inb_p(unsigned long port) 88unsigned char _inb_p(unsigned long port)
89{ 89{
90 unsigned char b; 90 unsigned char v = _inb(port);
91 91 delay();
92 if (port >= CFC_IOSTART && port <= CFC_IOEND) { 92 return v;
93 pcc_ioread_byte(0, port, &b, sizeof(b), 1, 0);
94 return b;
95 } else {
96 b = *(volatile unsigned char *)PORT2ADDR(port);
97 delay();
98 return b;
99 }
100} 93}
101 94
102unsigned short _inw_p(unsigned long port) 95unsigned short _inw_p(unsigned long port)
103{ 96{
104 unsigned short w; 97 unsigned short v = _inw(port);
105 98 delay();
106 if (port >= CFC_IOSTART && port <= CFC_IOEND) { 99 return v;
107 pcc_ioread_word(0, port, &w, sizeof(w), 1, 0);
108 return w;
109 } else {
110 w = *(volatile unsigned short *)PORT2ADDR(port);
111 delay();
112 return w;
113 }
114} 100}
115 101
116unsigned long _inl_p(unsigned long port) 102unsigned long _inl_p(unsigned long port)
117{ 103{
118 unsigned long v; 104 unsigned long v = _inl(port);
119
120 v = *(volatile unsigned long *)PORT2ADDR(port);
121 delay(); 105 delay();
122
123 return v; 106 return v;
124} 107}
125 108
@@ -149,25 +132,19 @@ void _outl(unsigned long l, unsigned long port)
149 132
150void _outb_p(unsigned char b, unsigned long port) 133void _outb_p(unsigned char b, unsigned long port)
151{ 134{
152 if (port >= CFC_IOSTART && port <= CFC_IOEND) 135 _outb(b, port);
153 pcc_iowrite_byte(0, port, &b, sizeof(b), 1, 0);
154 else
155 *(volatile unsigned char *)PORT2ADDR(port) = b;
156 delay(); 136 delay();
157} 137}
158 138
159void _outw_p(unsigned short w, unsigned long port) 139void _outw_p(unsigned short w, unsigned long port)
160{ 140{
161 if (port >= CFC_IOSTART && port <= CFC_IOEND) 141 _outw(w, port);
162 pcc_iowrite_word(0, port, &w, sizeof(w), 1, 0);
163 else
164 *(volatile unsigned short *)PORT2ADDR(port) = w;
165 delay(); 142 delay();
166} 143}
167 144
168void _outl_p(unsigned long l, unsigned long port) 145void _outl_p(unsigned long l, unsigned long port)
169{ 146{
170 *(volatile unsigned long *)PORT2ADDR(port) = l; 147 _outl(l, port);
171 delay(); 148 delay();
172} 149}
173 150
diff --git a/arch/m32r/kernel/setup.c b/arch/m32r/kernel/setup.c
index 4826cd6e40e8..ec5674727e7f 100644
--- a/arch/m32r/kernel/setup.c
+++ b/arch/m32r/kernel/setup.c
@@ -330,6 +330,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
330 seq_printf(m, "Machine\t\t: Mappi Evaluation board\n"); 330 seq_printf(m, "Machine\t\t: Mappi Evaluation board\n");
331#elif CONFIG_PLAT_MAPPI2 331#elif CONFIG_PLAT_MAPPI2
332 seq_printf(m, "Machine\t\t: Mappi-II Evaluation board\n"); 332 seq_printf(m, "Machine\t\t: Mappi-II Evaluation board\n");
333#elif CONFIG_PLAT_MAPPI3
334 seq_printf(m, "Machine\t\t: Mappi-III Evaluation board\n");
333#elif CONFIG_PLAT_M32700UT 335#elif CONFIG_PLAT_M32700UT
334 seq_printf(m, "Machine\t\t: M32700UT Evaluation board\n"); 336 seq_printf(m, "Machine\t\t: M32700UT Evaluation board\n");
335#elif CONFIG_PLAT_OPSPUT 337#elif CONFIG_PLAT_OPSPUT
diff --git a/arch/m32r/kernel/setup_m32700ut.c b/arch/m32r/kernel/setup_m32700ut.c
index 488aa87bab76..b014e2c1e524 100644
--- a/arch/m32r/kernel/setup_m32700ut.c
+++ b/arch/m32r/kernel/setup_m32700ut.c
@@ -78,13 +78,13 @@ static void shutdown_m32700ut_irq(unsigned int irq)
78 78
79static struct hw_interrupt_type m32700ut_irq_type = 79static struct hw_interrupt_type m32700ut_irq_type =
80{ 80{
81 "M32700UT-IRQ", 81 .typename = "M32700UT-IRQ",
82 startup_m32700ut_irq, 82 .startup = startup_m32700ut_irq,
83 shutdown_m32700ut_irq, 83 .shutdown = shutdown_m32700ut_irq,
84 enable_m32700ut_irq, 84 .enable = enable_m32700ut_irq,
85 disable_m32700ut_irq, 85 .disable = disable_m32700ut_irq,
86 mask_and_ack_m32700ut, 86 .ack = mask_and_ack_m32700ut,
87 end_m32700ut_irq 87 .end = end_m32700ut_irq
88}; 88};
89 89
90/* 90/*
@@ -155,13 +155,13 @@ static void shutdown_m32700ut_pld_irq(unsigned int irq)
155 155
156static struct hw_interrupt_type m32700ut_pld_irq_type = 156static struct hw_interrupt_type m32700ut_pld_irq_type =
157{ 157{
158 "M32700UT-PLD-IRQ", 158 .typename = "M32700UT-PLD-IRQ",
159 startup_m32700ut_pld_irq, 159 .startup = startup_m32700ut_pld_irq,
160 shutdown_m32700ut_pld_irq, 160 .shutdown = shutdown_m32700ut_pld_irq,
161 enable_m32700ut_pld_irq, 161 .enable = enable_m32700ut_pld_irq,
162 disable_m32700ut_pld_irq, 162 .disable = disable_m32700ut_pld_irq,
163 mask_and_ack_m32700ut_pld, 163 .ack = mask_and_ack_m32700ut_pld,
164 end_m32700ut_pld_irq 164 .end = end_m32700ut_pld_irq
165}; 165};
166 166
167/* 167/*
@@ -224,13 +224,13 @@ static void shutdown_m32700ut_lanpld_irq(unsigned int irq)
224 224
225static struct hw_interrupt_type m32700ut_lanpld_irq_type = 225static struct hw_interrupt_type m32700ut_lanpld_irq_type =
226{ 226{
227 "M32700UT-PLD-LAN-IRQ", 227 .typename = "M32700UT-PLD-LAN-IRQ",
228 startup_m32700ut_lanpld_irq, 228 .startup = startup_m32700ut_lanpld_irq,
229 shutdown_m32700ut_lanpld_irq, 229 .shutdown = shutdown_m32700ut_lanpld_irq,
230 enable_m32700ut_lanpld_irq, 230 .enable = enable_m32700ut_lanpld_irq,
231 disable_m32700ut_lanpld_irq, 231 .disable = disable_m32700ut_lanpld_irq,
232 mask_and_ack_m32700ut_lanpld, 232 .ack = mask_and_ack_m32700ut_lanpld,
233 end_m32700ut_lanpld_irq 233 .end = end_m32700ut_lanpld_irq
234}; 234};
235 235
236/* 236/*
@@ -293,13 +293,13 @@ static void shutdown_m32700ut_lcdpld_irq(unsigned int irq)
293 293
294static struct hw_interrupt_type m32700ut_lcdpld_irq_type = 294static struct hw_interrupt_type m32700ut_lcdpld_irq_type =
295{ 295{
296 "M32700UT-PLD-LCD-IRQ", 296 .typename = "M32700UT-PLD-LCD-IRQ",
297 startup_m32700ut_lcdpld_irq, 297 .startup = startup_m32700ut_lcdpld_irq,
298 shutdown_m32700ut_lcdpld_irq, 298 .shutdown = shutdown_m32700ut_lcdpld_irq,
299 enable_m32700ut_lcdpld_irq, 299 .enable = enable_m32700ut_lcdpld_irq,
300 disable_m32700ut_lcdpld_irq, 300 .disable = disable_m32700ut_lcdpld_irq,
301 mask_and_ack_m32700ut_lcdpld, 301 .ack = mask_and_ack_m32700ut_lcdpld,
302 end_m32700ut_lcdpld_irq 302 .end = end_m32700ut_lcdpld_irq
303}; 303};
304 304
305void __init init_IRQ(void) 305void __init init_IRQ(void)
diff --git a/arch/m32r/kernel/setup_mappi.c b/arch/m32r/kernel/setup_mappi.c
index 1e74110f0670..aaf8e569b930 100644
--- a/arch/m32r/kernel/setup_mappi.c
+++ b/arch/m32r/kernel/setup_mappi.c
@@ -70,13 +70,13 @@ static void shutdown_mappi_irq(unsigned int irq)
70 70
71static struct hw_interrupt_type mappi_irq_type = 71static struct hw_interrupt_type mappi_irq_type =
72{ 72{
73 "MAPPI-IRQ", 73 .typename = "MAPPI-IRQ",
74 startup_mappi_irq, 74 .startup = startup_mappi_irq,
75 shutdown_mappi_irq, 75 .shutdown = shutdown_mappi_irq,
76 enable_mappi_irq, 76 .enable = enable_mappi_irq,
77 disable_mappi_irq, 77 .disable = disable_mappi_irq,
78 mask_and_ack_mappi, 78 .ack = mask_and_ack_mappi,
79 end_mappi_irq 79 .end = end_mappi_irq
80}; 80};
81 81
82void __init init_IRQ(void) 82void __init init_IRQ(void)
diff --git a/arch/m32r/kernel/setup_mappi2.c b/arch/m32r/kernel/setup_mappi2.c
index 1904d465a507..38d5e9a41427 100644
--- a/arch/m32r/kernel/setup_mappi2.c
+++ b/arch/m32r/kernel/setup_mappi2.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/arch/m32r/kernel/setup_mappi.c 2 * linux/arch/m32r/kernel/setup_mappi2.c
3 * 3 *
4 * Setup routines for Renesas MAPPI-II(M3A-ZA36) Board 4 * Setup routines for Renesas MAPPI-II(M3A-ZA36) Board
5 * 5 *
@@ -79,13 +79,13 @@ static void shutdown_mappi2_irq(unsigned int irq)
79 79
80static struct hw_interrupt_type mappi2_irq_type = 80static struct hw_interrupt_type mappi2_irq_type =
81{ 81{
82 "MAPPI2-IRQ", 82 .typename = "MAPPI2-IRQ",
83 startup_mappi2_irq, 83 .startup = startup_mappi2_irq,
84 shutdown_mappi2_irq, 84 .shutdown = shutdown_mappi2_irq,
85 enable_mappi2_irq, 85 .enable = enable_mappi2_irq,
86 disable_mappi2_irq, 86 .disable = disable_mappi2_irq,
87 mask_and_ack_mappi2, 87 .ack = mask_and_ack_mappi2,
88 end_mappi2_irq 88 .end = end_mappi2_irq
89}; 89};
90 90
91void __init init_IRQ(void) 91void __init init_IRQ(void)
@@ -156,7 +156,6 @@ void __init init_IRQ(void)
156 irq_desc[PLD_IRQ_CFIREQ].handler = &mappi2_irq_type; 156 irq_desc[PLD_IRQ_CFIREQ].handler = &mappi2_irq_type;
157 irq_desc[PLD_IRQ_CFIREQ].action = 0; 157 irq_desc[PLD_IRQ_CFIREQ].action = 0;
158 irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */ 158 irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */
159// icu_data[PLD_IRQ_CFIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00;
160 icu_data[PLD_IRQ_CFIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01; 159 icu_data[PLD_IRQ_CFIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01;
161 disable_mappi2_irq(PLD_IRQ_CFIREQ); 160 disable_mappi2_irq(PLD_IRQ_CFIREQ);
162 161
@@ -167,7 +166,6 @@ void __init init_IRQ(void)
167 irq_desc[PLD_IRQ_CFC_INSERT].action = 0; 166 irq_desc[PLD_IRQ_CFC_INSERT].action = 0;
168 irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */ 167 irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */
169 icu_data[PLD_IRQ_CFC_INSERT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00; 168 icu_data[PLD_IRQ_CFC_INSERT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00;
170// icu_data[PLD_IRQ_CFC_INSERT].icucr = 0;
171 disable_mappi2_irq(PLD_IRQ_CFC_INSERT); 169 disable_mappi2_irq(PLD_IRQ_CFC_INSERT);
172 170
173 /* ICUCR42: CFC Eject */ 171 /* ICUCR42: CFC Eject */
@@ -176,9 +174,7 @@ void __init init_IRQ(void)
176 irq_desc[PLD_IRQ_CFC_EJECT].action = 0; 174 irq_desc[PLD_IRQ_CFC_EJECT].action = 0;
177 irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */ 175 irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */
178 icu_data[PLD_IRQ_CFC_EJECT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; 176 icu_data[PLD_IRQ_CFC_EJECT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
179// icu_data[PLD_IRQ_CFC_EJECT].icucr = 0;
180 disable_mappi2_irq(PLD_IRQ_CFC_EJECT); 177 disable_mappi2_irq(PLD_IRQ_CFC_EJECT);
181
182#endif /* CONFIG_MAPPI2_CFC */ 178#endif /* CONFIG_MAPPI2_CFC */
183} 179}
184 180
diff --git a/arch/m32r/kernel/setup_mappi3.c b/arch/m32r/kernel/setup_mappi3.c
new file mode 100644
index 000000000000..3d60a85aaec5
--- /dev/null
+++ b/arch/m32r/kernel/setup_mappi3.c
@@ -0,0 +1,208 @@
1/*
2 * linux/arch/m32r/kernel/setup_mappi3.c
3 *
4 * Setup routines for Renesas MAPPI-III(M3A-2170) Board
5 *
6 * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata,
7 * Hitoshi Yamamoto, Mamoru Sakugawa
8 */
9
10#include <linux/config.h>
11#include <linux/irq.h>
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/device.h>
15
16#include <asm/system.h>
17#include <asm/m32r.h>
18#include <asm/io.h>
19
20#define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long)))
21
22#ifndef CONFIG_SMP
23typedef struct {
24 unsigned long icucr; /* ICU Control Register */
25} icu_data_t;
26#endif /* CONFIG_SMP */
27
28icu_data_t icu_data[NR_IRQS];
29
30static void disable_mappi3_irq(unsigned int irq)
31{
32 unsigned long port, data;
33
34 if ((irq == 0) ||(irq >= NR_IRQS)) {
35 printk("bad irq 0x%08x\n", irq);
36 return;
37 }
38 port = irq2port(irq);
39 data = icu_data[irq].icucr|M32R_ICUCR_ILEVEL7;
40 outl(data, port);
41}
42
43static void enable_mappi3_irq(unsigned int irq)
44{
45 unsigned long port, data;
46
47 if ((irq == 0) ||(irq >= NR_IRQS)) {
48 printk("bad irq 0x%08x\n", irq);
49 return;
50 }
51 port = irq2port(irq);
52 data = icu_data[irq].icucr|M32R_ICUCR_IEN|M32R_ICUCR_ILEVEL6;
53 outl(data, port);
54}
55
56static void mask_and_ack_mappi3(unsigned int irq)
57{
58 disable_mappi3_irq(irq);
59}
60
61static void end_mappi3_irq(unsigned int irq)
62{
63 enable_mappi3_irq(irq);
64}
65
66static unsigned int startup_mappi3_irq(unsigned int irq)
67{
68 enable_mappi3_irq(irq);
69 return (0);
70}
71
72static void shutdown_mappi3_irq(unsigned int irq)
73{
74 unsigned long port;
75
76 port = irq2port(irq);
77 outl(M32R_ICUCR_ILEVEL7, port);
78}
79
80static struct hw_interrupt_type mappi3_irq_type =
81{
82 .typename = "MAPPI3-IRQ",
83 .startup = startup_mappi3_irq,
84 .shutdown = shutdown_mappi3_irq,
85 .enable = enable_mappi3_irq,
86 .disable = disable_mappi3_irq,
87 .ack = mask_and_ack_mappi3,
88 .end = end_mappi3_irq
89};
90
91void __init init_IRQ(void)
92{
93#if defined(CONFIG_SMC91X)
94 /* INT0 : LAN controller (SMC91111) */
95 irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED;
96 irq_desc[M32R_IRQ_INT0].handler = &mappi3_irq_type;
97 irq_desc[M32R_IRQ_INT0].action = 0;
98 irq_desc[M32R_IRQ_INT0].depth = 1;
99 icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
100 disable_mappi3_irq(M32R_IRQ_INT0);
101#endif /* CONFIG_SMC91X */
102
103 /* MFT2 : system timer */
104 irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED;
105 irq_desc[M32R_IRQ_MFT2].handler = &mappi3_irq_type;
106 irq_desc[M32R_IRQ_MFT2].action = 0;
107 irq_desc[M32R_IRQ_MFT2].depth = 1;
108 icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
109 disable_mappi3_irq(M32R_IRQ_MFT2);
110
111#ifdef CONFIG_SERIAL_M32R_SIO
112 /* SIO0_R : uart receive data */
113 irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED;
114 irq_desc[M32R_IRQ_SIO0_R].handler = &mappi3_irq_type;
115 irq_desc[M32R_IRQ_SIO0_R].action = 0;
116 irq_desc[M32R_IRQ_SIO0_R].depth = 1;
117 icu_data[M32R_IRQ_SIO0_R].icucr = 0;
118 disable_mappi3_irq(M32R_IRQ_SIO0_R);
119
120 /* SIO0_S : uart send data */
121 irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED;
122 irq_desc[M32R_IRQ_SIO0_S].handler = &mappi3_irq_type;
123 irq_desc[M32R_IRQ_SIO0_S].action = 0;
124 irq_desc[M32R_IRQ_SIO0_S].depth = 1;
125 icu_data[M32R_IRQ_SIO0_S].icucr = 0;
126 disable_mappi3_irq(M32R_IRQ_SIO0_S);
127 /* SIO1_R : uart receive data */
128 irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED;
129 irq_desc[M32R_IRQ_SIO1_R].handler = &mappi3_irq_type;
130 irq_desc[M32R_IRQ_SIO1_R].action = 0;
131 irq_desc[M32R_IRQ_SIO1_R].depth = 1;
132 icu_data[M32R_IRQ_SIO1_R].icucr = 0;
133 disable_mappi3_irq(M32R_IRQ_SIO1_R);
134
135 /* SIO1_S : uart send data */
136 irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED;
137 irq_desc[M32R_IRQ_SIO1_S].handler = &mappi3_irq_type;
138 irq_desc[M32R_IRQ_SIO1_S].action = 0;
139 irq_desc[M32R_IRQ_SIO1_S].depth = 1;
140 icu_data[M32R_IRQ_SIO1_S].icucr = 0;
141 disable_mappi3_irq(M32R_IRQ_SIO1_S);
142#endif /* CONFIG_M32R_USE_DBG_CONSOLE */
143
144#if defined(CONFIG_USB)
145 /* INT1 : USB Host controller interrupt */
146 irq_desc[M32R_IRQ_INT1].status = IRQ_DISABLED;
147 irq_desc[M32R_IRQ_INT1].handler = &mappi3_irq_type;
148 irq_desc[M32R_IRQ_INT1].action = 0;
149 irq_desc[M32R_IRQ_INT1].depth = 1;
150 icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_ISMOD01;
151 disable_mappi3_irq(M32R_IRQ_INT1);
152#endif /* CONFIG_USB */
153
154 /* ICUCR40: CFC IREQ */
155 irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED;
156 irq_desc[PLD_IRQ_CFIREQ].handler = &mappi3_irq_type;
157 irq_desc[PLD_IRQ_CFIREQ].action = 0;
158 irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */
159 icu_data[PLD_IRQ_CFIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01;
160 disable_mappi3_irq(PLD_IRQ_CFIREQ);
161
162#if defined(CONFIG_M32R_CFC)
163 /* ICUCR41: CFC Insert */
164 irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED;
165 irq_desc[PLD_IRQ_CFC_INSERT].handler = &mappi3_irq_type;
166 irq_desc[PLD_IRQ_CFC_INSERT].action = 0;
167 irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */
168 icu_data[PLD_IRQ_CFC_INSERT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00;
169 disable_mappi3_irq(PLD_IRQ_CFC_INSERT);
170
171 /* ICUCR42: CFC Eject */
172 irq_desc[PLD_IRQ_CFC_EJECT].status = IRQ_DISABLED;
173 irq_desc[PLD_IRQ_CFC_EJECT].handler = &mappi3_irq_type;
174 irq_desc[PLD_IRQ_CFC_EJECT].action = 0;
175 irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */
176 icu_data[PLD_IRQ_CFC_EJECT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
177 disable_mappi3_irq(PLD_IRQ_CFC_EJECT);
178#endif /* CONFIG_M32R_CFC */
179}
180
181#define LAN_IOSTART 0x300
182#define LAN_IOEND 0x320
183static struct resource smc91x_resources[] = {
184 [0] = {
185 .start = (LAN_IOSTART),
186 .end = (LAN_IOEND),
187 .flags = IORESOURCE_MEM,
188 },
189 [1] = {
190 .start = M32R_IRQ_INT0,
191 .end = M32R_IRQ_INT0,
192 .flags = IORESOURCE_IRQ,
193 }
194};
195
196static struct platform_device smc91x_device = {
197 .name = "smc91x",
198 .id = 0,
199 .num_resources = ARRAY_SIZE(smc91x_resources),
200 .resource = smc91x_resources,
201};
202
203static int __init platform_init(void)
204{
205 platform_device_register(&smc91x_device);
206 return 0;
207}
208arch_initcall(platform_init);
diff --git a/arch/m32r/kernel/setup_oaks32r.c b/arch/m32r/kernel/setup_oaks32r.c
index b04834526c9a..d656640badc9 100644
--- a/arch/m32r/kernel/setup_oaks32r.c
+++ b/arch/m32r/kernel/setup_oaks32r.c
@@ -70,13 +70,13 @@ static void shutdown_oaks32r_irq(unsigned int irq)
70 70
71static struct hw_interrupt_type oaks32r_irq_type = 71static struct hw_interrupt_type oaks32r_irq_type =
72{ 72{
73 "OAKS32R-IRQ", 73 .typename = "OAKS32R-IRQ",
74 startup_oaks32r_irq, 74 .startup = startup_oaks32r_irq,
75 shutdown_oaks32r_irq, 75 .shutdown = shutdown_oaks32r_irq,
76 enable_oaks32r_irq, 76 .enable = enable_oaks32r_irq,
77 disable_oaks32r_irq, 77 .disable = disable_oaks32r_irq,
78 mask_and_ack_mappi, 78 .ack = mask_and_ack_mappi,
79 end_oaks32r_irq 79 .end = end_oaks32r_irq
80}; 80};
81 81
82void __init init_IRQ(void) 82void __init init_IRQ(void)
diff --git a/arch/m32r/kernel/setup_opsput.c b/arch/m32r/kernel/setup_opsput.c
index 84315e344c58..86f4cf2a86c3 100644
--- a/arch/m32r/kernel/setup_opsput.c
+++ b/arch/m32r/kernel/setup_opsput.c
@@ -79,13 +79,13 @@ static void shutdown_opsput_irq(unsigned int irq)
79 79
80static struct hw_interrupt_type opsput_irq_type = 80static struct hw_interrupt_type opsput_irq_type =
81{ 81{
82 "OPSPUT-IRQ", 82 .typename = "OPSPUT-IRQ",
83 startup_opsput_irq, 83 .startup = startup_opsput_irq,
84 shutdown_opsput_irq, 84 .shutdown = shutdown_opsput_irq,
85 enable_opsput_irq, 85 .enable = enable_opsput_irq,
86 disable_opsput_irq, 86 .disable = disable_opsput_irq,
87 mask_and_ack_opsput, 87 .ack = mask_and_ack_opsput,
88 end_opsput_irq 88 .end = end_opsput_irq
89}; 89};
90 90
91/* 91/*
@@ -156,13 +156,13 @@ static void shutdown_opsput_pld_irq(unsigned int irq)
156 156
157static struct hw_interrupt_type opsput_pld_irq_type = 157static struct hw_interrupt_type opsput_pld_irq_type =
158{ 158{
159 "OPSPUT-PLD-IRQ", 159 .typename = "OPSPUT-PLD-IRQ",
160 startup_opsput_pld_irq, 160 .startup = startup_opsput_pld_irq,
161 shutdown_opsput_pld_irq, 161 .shutdown = shutdown_opsput_pld_irq,
162 enable_opsput_pld_irq, 162 .enable = enable_opsput_pld_irq,
163 disable_opsput_pld_irq, 163 .disable = disable_opsput_pld_irq,
164 mask_and_ack_opsput_pld, 164 .ack = mask_and_ack_opsput_pld,
165 end_opsput_pld_irq 165 .end = end_opsput_pld_irq
166}; 166};
167 167
168/* 168/*
diff --git a/arch/m32r/kernel/setup_usrv.c b/arch/m32r/kernel/setup_usrv.c
index fe417be5e3e9..634741bf9d35 100644
--- a/arch/m32r/kernel/setup_usrv.c
+++ b/arch/m32r/kernel/setup_usrv.c
@@ -70,13 +70,13 @@ static void shutdown_mappi_irq(unsigned int irq)
70 70
71static struct hw_interrupt_type mappi_irq_type = 71static struct hw_interrupt_type mappi_irq_type =
72{ 72{
73 "M32700-IRQ", 73 .typename = "M32700-IRQ",
74 startup_mappi_irq, 74 .startup = startup_mappi_irq,
75 shutdown_mappi_irq, 75 .shutdown = shutdown_mappi_irq,
76 enable_mappi_irq, 76 .enable = enable_mappi_irq,
77 disable_mappi_irq, 77 .disable = disable_mappi_irq,
78 mask_and_ack_mappi, 78 .ack = mask_and_ack_mappi,
79 end_mappi_irq 79 .end = end_mappi_irq
80}; 80};
81 81
82/* 82/*
@@ -143,13 +143,13 @@ static void shutdown_m32700ut_pld_irq(unsigned int irq)
143 143
144static struct hw_interrupt_type m32700ut_pld_irq_type = 144static struct hw_interrupt_type m32700ut_pld_irq_type =
145{ 145{
146 "USRV-PLD-IRQ", 146 .typename = "USRV-PLD-IRQ",
147 startup_m32700ut_pld_irq, 147 .startup = startup_m32700ut_pld_irq,
148 shutdown_m32700ut_pld_irq, 148 .shutdown = shutdown_m32700ut_pld_irq,
149 enable_m32700ut_pld_irq, 149 .enable = enable_m32700ut_pld_irq,
150 disable_m32700ut_pld_irq, 150 .disable = disable_m32700ut_pld_irq,
151 mask_and_ack_m32700ut_pld, 151 .ack = mask_and_ack_m32700ut_pld,
152 end_m32700ut_pld_irq 152 .end = end_m32700ut_pld_irq
153}; 153};
154 154
155void __init init_IRQ(void) 155void __init init_IRQ(void)
diff --git a/arch/m32r/m32700ut/defconfig.m32700ut.smp b/arch/m32r/m32700ut/defconfig.m32700ut.smp
index 1c002181df7f..3e607d90b5f4 100644
--- a/arch/m32r/m32700ut/defconfig.m32700ut.smp
+++ b/arch/m32r/m32700ut/defconfig.m32700ut.smp
@@ -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.11-rc4 3# Linux kernel version: 2.6.12-rc5
4# Wed Feb 16 21:10:50 2005 4# Fri Jun 3 16:20:58 2005
5# 5#
6CONFIG_M32R=y 6CONFIG_M32R=y
7# CONFIG_UID16 is not set 7# CONFIG_UID16 is not set
@@ -15,6 +15,7 @@ CONFIG_GENERIC_IRQ_PROBE=y
15CONFIG_EXPERIMENTAL=y 15CONFIG_EXPERIMENTAL=y
16CONFIG_CLEAN_COMPILE=y 16CONFIG_CLEAN_COMPILE=y
17CONFIG_LOCK_KERNEL=y 17CONFIG_LOCK_KERNEL=y
18CONFIG_INIT_ENV_ARG_LIMIT=32
18 19
19# 20#
20# General setup 21# General setup
@@ -27,13 +28,16 @@ CONFIG_BSD_PROCESS_ACCT=y
27# CONFIG_BSD_PROCESS_ACCT_V3 is not set 28# CONFIG_BSD_PROCESS_ACCT_V3 is not set
28CONFIG_SYSCTL=y 29CONFIG_SYSCTL=y
29# CONFIG_AUDIT is not set 30# CONFIG_AUDIT is not set
30CONFIG_LOG_BUF_SHIFT=15
31CONFIG_HOTPLUG=y 31CONFIG_HOTPLUG=y
32CONFIG_KOBJECT_UEVENT=y 32CONFIG_KOBJECT_UEVENT=y
33CONFIG_IKCONFIG=y 33CONFIG_IKCONFIG=y
34# CONFIG_IKCONFIG_PROC is not set 34# CONFIG_IKCONFIG_PROC is not set
35# CONFIG_CPUSETS is not set
35CONFIG_EMBEDDED=y 36CONFIG_EMBEDDED=y
36# CONFIG_KALLSYMS is not set 37# CONFIG_KALLSYMS is not set
38CONFIG_PRINTK=y
39CONFIG_BUG=y
40CONFIG_BASE_FULL=y
37# CONFIG_FUTEX is not set 41# CONFIG_FUTEX is not set
38# CONFIG_EPOLL is not set 42# CONFIG_EPOLL is not set
39# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 43# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -43,6 +47,7 @@ CONFIG_CC_ALIGN_LABELS=0
43CONFIG_CC_ALIGN_LOOPS=0 47CONFIG_CC_ALIGN_LOOPS=0
44CONFIG_CC_ALIGN_JUMPS=0 48CONFIG_CC_ALIGN_JUMPS=0
45# CONFIG_TINY_SHMEM is not set 49# CONFIG_TINY_SHMEM is not set
50CONFIG_BASE_SMALL=0
46 51
47# 52#
48# Loadable module support 53# Loadable module support
@@ -65,6 +70,7 @@ CONFIG_PLAT_M32700UT=y
65# CONFIG_PLAT_OPSPUT is not set 70# CONFIG_PLAT_OPSPUT is not set
66# CONFIG_PLAT_OAKS32R is not set 71# CONFIG_PLAT_OAKS32R is not set
67# CONFIG_PLAT_MAPPI2 is not set 72# CONFIG_PLAT_MAPPI2 is not set
73# CONFIG_PLAT_MAPPI3 is not set
68CONFIG_CHIP_M32700=y 74CONFIG_CHIP_M32700=y
69# CONFIG_CHIP_M32102 is not set 75# CONFIG_CHIP_M32102 is not set
70# CONFIG_CHIP_VDEC2 is not set 76# CONFIG_CHIP_VDEC2 is not set
@@ -271,7 +277,6 @@ CONFIG_NET=y
271# 277#
272CONFIG_PACKET=y 278CONFIG_PACKET=y
273# CONFIG_PACKET_MMAP is not set 279# CONFIG_PACKET_MMAP is not set
274# CONFIG_NETLINK_DEV is not set
275CONFIG_UNIX=y 280CONFIG_UNIX=y
276# CONFIG_NET_KEY is not set 281# CONFIG_NET_KEY is not set
277CONFIG_INET=y 282CONFIG_INET=y
@@ -396,18 +401,6 @@ CONFIG_INPUT=y
396# CONFIG_INPUT_EVBUG is not set 401# CONFIG_INPUT_EVBUG is not set
397 402
398# 403#
399# Input I/O drivers
400#
401# CONFIG_GAMEPORT is not set
402CONFIG_SOUND_GAMEPORT=y
403CONFIG_SERIO=y
404# CONFIG_SERIO_I8042 is not set
405CONFIG_SERIO_SERPORT=y
406# CONFIG_SERIO_CT82C710 is not set
407# CONFIG_SERIO_LIBPS2 is not set
408# CONFIG_SERIO_RAW is not set
409
410#
411# Input Device Drivers 404# Input Device Drivers
412# 405#
413# CONFIG_INPUT_KEYBOARD is not set 406# CONFIG_INPUT_KEYBOARD is not set
@@ -417,6 +410,17 @@ CONFIG_SERIO_SERPORT=y
417# CONFIG_INPUT_MISC is not set 410# CONFIG_INPUT_MISC is not set
418 411
419# 412#
413# Hardware I/O ports
414#
415CONFIG_SERIO=y
416# CONFIG_SERIO_I8042 is not set
417CONFIG_SERIO_SERPORT=y
418# CONFIG_SERIO_LIBPS2 is not set
419# CONFIG_SERIO_RAW is not set
420# CONFIG_GAMEPORT is not set
421CONFIG_SOUND_GAMEPORT=y
422
423#
420# Character devices 424# Character devices
421# 425#
422CONFIG_VT=y 426CONFIG_VT=y
@@ -468,6 +472,10 @@ CONFIG_DS1302=y
468# CONFIG_RAW_DRIVER is not set 472# CONFIG_RAW_DRIVER is not set
469 473
470# 474#
475# TPM devices
476#
477
478#
471# I2C support 479# I2C support
472# 480#
473# CONFIG_I2C is not set 481# CONFIG_I2C is not set
@@ -511,8 +519,14 @@ CONFIG_VIDEO_M32R_AR_M64278=y
511# Graphics support 519# Graphics support
512# 520#
513CONFIG_FB=y 521CONFIG_FB=y
522# CONFIG_FB_CFB_FILLRECT is not set
523# CONFIG_FB_CFB_COPYAREA is not set
524# CONFIG_FB_CFB_IMAGEBLIT is not set
525# CONFIG_FB_SOFT_CURSOR is not set
526# CONFIG_FB_MACMODES is not set
514# CONFIG_FB_MODE_HELPERS is not set 527# CONFIG_FB_MODE_HELPERS is not set
515# CONFIG_FB_TILEBLITTING is not set 528# CONFIG_FB_TILEBLITTING is not set
529# CONFIG_FB_S1D13XXX is not set
516# CONFIG_FB_VIRTUAL is not set 530# CONFIG_FB_VIRTUAL is not set
517 531
518# 532#
@@ -546,10 +560,6 @@ CONFIG_LOGO_LINUX_CLUT224=y
546# CONFIG_USB_ARCH_HAS_OHCI is not set 560# CONFIG_USB_ARCH_HAS_OHCI is not set
547 561
548# 562#
549# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
550#
551
552#
553# USB Gadget Support 563# USB Gadget Support
554# 564#
555# CONFIG_USB_GADGET is not set 565# CONFIG_USB_GADGET is not set
@@ -722,8 +732,9 @@ CONFIG_NLS_DEFAULT="iso8859-1"
722# 732#
723# Kernel hacking 733# Kernel hacking
724# 734#
735# CONFIG_PRINTK_TIME is not set
725# CONFIG_DEBUG_KERNEL is not set 736# CONFIG_DEBUG_KERNEL is not set
726CONFIG_DEBUG_PREEMPT=y 737CONFIG_LOG_BUF_SHIFT=15
727# CONFIG_DEBUG_BUGVERBOSE is not set 738# CONFIG_DEBUG_BUGVERBOSE is not set
728# CONFIG_FRAME_POINTER is not set 739# CONFIG_FRAME_POINTER is not set
729 740
diff --git a/arch/m32r/m32700ut/defconfig.m32700ut.up b/arch/m32r/m32700ut/defconfig.m32700ut.up
index 805357f7bda1..2d3e7cda8f46 100644
--- a/arch/m32r/m32700ut/defconfig.m32700ut.up
+++ b/arch/m32r/m32700ut/defconfig.m32700ut.up
@@ -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.11-rc4 3# Linux kernel version: 2.6.12-rc5
4# Wed Feb 16 21:10:54 2005 4# Fri Jun 3 16:21:34 2005
5# 5#
6CONFIG_M32R=y 6CONFIG_M32R=y
7# CONFIG_UID16 is not set 7# CONFIG_UID16 is not set
@@ -16,6 +16,7 @@ CONFIG_EXPERIMENTAL=y
16CONFIG_CLEAN_COMPILE=y 16CONFIG_CLEAN_COMPILE=y
17CONFIG_BROKEN_ON_SMP=y 17CONFIG_BROKEN_ON_SMP=y
18CONFIG_LOCK_KERNEL=y 18CONFIG_LOCK_KERNEL=y
19CONFIG_INIT_ENV_ARG_LIMIT=32
19 20
20# 21#
21# General setup 22# General setup
@@ -28,13 +29,15 @@ CONFIG_BSD_PROCESS_ACCT=y
28# CONFIG_BSD_PROCESS_ACCT_V3 is not set 29# CONFIG_BSD_PROCESS_ACCT_V3 is not set
29CONFIG_SYSCTL=y 30CONFIG_SYSCTL=y
30# CONFIG_AUDIT is not set 31# CONFIG_AUDIT is not set
31CONFIG_LOG_BUF_SHIFT=14
32CONFIG_HOTPLUG=y 32CONFIG_HOTPLUG=y
33CONFIG_KOBJECT_UEVENT=y 33CONFIG_KOBJECT_UEVENT=y
34CONFIG_IKCONFIG=y 34CONFIG_IKCONFIG=y
35# CONFIG_IKCONFIG_PROC is not set 35# CONFIG_IKCONFIG_PROC is not set
36CONFIG_EMBEDDED=y 36CONFIG_EMBEDDED=y
37# CONFIG_KALLSYMS is not set 37# CONFIG_KALLSYMS is not set
38CONFIG_PRINTK=y
39CONFIG_BUG=y
40CONFIG_BASE_FULL=y
38# CONFIG_FUTEX is not set 41# CONFIG_FUTEX is not set
39# CONFIG_EPOLL is not set 42# CONFIG_EPOLL is not set
40# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 43# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -44,6 +47,7 @@ CONFIG_CC_ALIGN_LABELS=0
44CONFIG_CC_ALIGN_LOOPS=0 47CONFIG_CC_ALIGN_LOOPS=0
45CONFIG_CC_ALIGN_JUMPS=0 48CONFIG_CC_ALIGN_JUMPS=0
46# CONFIG_TINY_SHMEM is not set 49# CONFIG_TINY_SHMEM is not set
50CONFIG_BASE_SMALL=0
47 51
48# 52#
49# Loadable module support 53# Loadable module support
@@ -65,6 +69,7 @@ CONFIG_PLAT_M32700UT=y
65# CONFIG_PLAT_OPSPUT is not set 69# CONFIG_PLAT_OPSPUT is not set
66# CONFIG_PLAT_OAKS32R is not set 70# CONFIG_PLAT_OAKS32R is not set
67# CONFIG_PLAT_MAPPI2 is not set 71# CONFIG_PLAT_MAPPI2 is not set
72# CONFIG_PLAT_MAPPI3 is not set
68CONFIG_CHIP_M32700=y 73CONFIG_CHIP_M32700=y
69# CONFIG_CHIP_M32102 is not set 74# CONFIG_CHIP_M32102 is not set
70# CONFIG_CHIP_VDEC2 is not set 75# CONFIG_CHIP_VDEC2 is not set
@@ -268,7 +273,6 @@ CONFIG_NET=y
268# 273#
269CONFIG_PACKET=y 274CONFIG_PACKET=y
270# CONFIG_PACKET_MMAP is not set 275# CONFIG_PACKET_MMAP is not set
271# CONFIG_NETLINK_DEV is not set
272CONFIG_UNIX=y 276CONFIG_UNIX=y
273# CONFIG_NET_KEY is not set 277# CONFIG_NET_KEY is not set
274CONFIG_INET=y 278CONFIG_INET=y
@@ -393,18 +397,6 @@ CONFIG_INPUT=y
393# CONFIG_INPUT_EVBUG is not set 397# CONFIG_INPUT_EVBUG is not set
394 398
395# 399#
396# Input I/O drivers
397#
398# CONFIG_GAMEPORT is not set
399CONFIG_SOUND_GAMEPORT=y
400CONFIG_SERIO=y
401# CONFIG_SERIO_I8042 is not set
402CONFIG_SERIO_SERPORT=y
403# CONFIG_SERIO_CT82C710 is not set
404# CONFIG_SERIO_LIBPS2 is not set
405# CONFIG_SERIO_RAW is not set
406
407#
408# Input Device Drivers 400# Input Device Drivers
409# 401#
410# CONFIG_INPUT_KEYBOARD is not set 402# CONFIG_INPUT_KEYBOARD is not set
@@ -414,6 +406,17 @@ CONFIG_SERIO_SERPORT=y
414# CONFIG_INPUT_MISC is not set 406# CONFIG_INPUT_MISC is not set
415 407
416# 408#
409# Hardware I/O ports
410#
411CONFIG_SERIO=y
412# CONFIG_SERIO_I8042 is not set
413CONFIG_SERIO_SERPORT=y
414# CONFIG_SERIO_LIBPS2 is not set
415# CONFIG_SERIO_RAW is not set
416# CONFIG_GAMEPORT is not set
417CONFIG_SOUND_GAMEPORT=y
418
419#
417# Character devices 420# Character devices
418# 421#
419CONFIG_VT=y 422CONFIG_VT=y
@@ -465,6 +468,10 @@ CONFIG_DS1302=y
465# CONFIG_RAW_DRIVER is not set 468# CONFIG_RAW_DRIVER is not set
466 469
467# 470#
471# TPM devices
472#
473
474#
468# I2C support 475# I2C support
469# 476#
470# CONFIG_I2C is not set 477# CONFIG_I2C is not set
@@ -508,8 +515,14 @@ CONFIG_VIDEO_M32R_AR_M64278=y
508# Graphics support 515# Graphics support
509# 516#
510CONFIG_FB=y 517CONFIG_FB=y
518# CONFIG_FB_CFB_FILLRECT is not set
519# CONFIG_FB_CFB_COPYAREA is not set
520# CONFIG_FB_CFB_IMAGEBLIT is not set
521# CONFIG_FB_SOFT_CURSOR is not set
522# CONFIG_FB_MACMODES is not set
511# CONFIG_FB_MODE_HELPERS is not set 523# CONFIG_FB_MODE_HELPERS is not set
512# CONFIG_FB_TILEBLITTING is not set 524# CONFIG_FB_TILEBLITTING is not set
525# CONFIG_FB_S1D13XXX is not set
513# CONFIG_FB_VIRTUAL is not set 526# CONFIG_FB_VIRTUAL is not set
514 527
515# 528#
@@ -543,10 +556,6 @@ CONFIG_LOGO_LINUX_CLUT224=y
543# CONFIG_USB_ARCH_HAS_OHCI is not set 556# CONFIG_USB_ARCH_HAS_OHCI is not set
544 557
545# 558#
546# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
547#
548
549#
550# USB Gadget Support 559# USB Gadget Support
551# 560#
552# CONFIG_USB_GADGET is not set 561# CONFIG_USB_GADGET is not set
@@ -719,8 +728,9 @@ CONFIG_NLS_DEFAULT="iso8859-1"
719# 728#
720# Kernel hacking 729# Kernel hacking
721# 730#
731# CONFIG_PRINTK_TIME is not set
722# CONFIG_DEBUG_KERNEL is not set 732# CONFIG_DEBUG_KERNEL is not set
723CONFIG_DEBUG_PREEMPT=y 733CONFIG_LOG_BUF_SHIFT=14
724# CONFIG_DEBUG_BUGVERBOSE is not set 734# CONFIG_DEBUG_BUGVERBOSE is not set
725# CONFIG_FRAME_POINTER is not set 735# CONFIG_FRAME_POINTER is not set
726 736
diff --git a/arch/m32r/mappi/defconfig.nommu b/arch/m32r/mappi/defconfig.nommu
index 714aa6e7034c..a8425fba340b 100644
--- a/arch/m32r/mappi/defconfig.nommu
+++ b/arch/m32r/mappi/defconfig.nommu
@@ -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.11-rc4 3# Linux kernel version: 2.6.12-rc5
4# Wed Feb 16 21:10:57 2005 4# Fri Jun 3 16:21:46 2005
5# 5#
6CONFIG_M32R=y 6CONFIG_M32R=y
7# CONFIG_UID16 is not set 7# CONFIG_UID16 is not set
@@ -16,6 +16,7 @@ CONFIG_EXPERIMENTAL=y
16CONFIG_CLEAN_COMPILE=y 16CONFIG_CLEAN_COMPILE=y
17CONFIG_BROKEN_ON_SMP=y 17CONFIG_BROKEN_ON_SMP=y
18CONFIG_LOCK_KERNEL=y 18CONFIG_LOCK_KERNEL=y
19CONFIG_INIT_ENV_ARG_LIMIT=32
19 20
20# 21#
21# General setup 22# General setup
@@ -26,13 +27,15 @@ CONFIG_BSD_PROCESS_ACCT=y
26# CONFIG_BSD_PROCESS_ACCT_V3 is not set 27# CONFIG_BSD_PROCESS_ACCT_V3 is not set
27CONFIG_SYSCTL=y 28CONFIG_SYSCTL=y
28# CONFIG_AUDIT is not set 29# CONFIG_AUDIT is not set
29CONFIG_LOG_BUF_SHIFT=14
30CONFIG_HOTPLUG=y 30CONFIG_HOTPLUG=y
31CONFIG_KOBJECT_UEVENT=y 31CONFIG_KOBJECT_UEVENT=y
32CONFIG_IKCONFIG=y 32CONFIG_IKCONFIG=y
33# CONFIG_IKCONFIG_PROC is not set 33# CONFIG_IKCONFIG_PROC is not set
34CONFIG_EMBEDDED=y 34CONFIG_EMBEDDED=y
35# CONFIG_KALLSYMS is not set 35# CONFIG_KALLSYMS is not set
36CONFIG_PRINTK=y
37CONFIG_BUG=y
38CONFIG_BASE_FULL=y
36# CONFIG_FUTEX is not set 39# CONFIG_FUTEX is not set
37# CONFIG_EPOLL is not set 40# CONFIG_EPOLL is not set
38# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 41# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -41,6 +44,7 @@ CONFIG_CC_ALIGN_LABELS=0
41CONFIG_CC_ALIGN_LOOPS=0 44CONFIG_CC_ALIGN_LOOPS=0
42CONFIG_CC_ALIGN_JUMPS=0 45CONFIG_CC_ALIGN_JUMPS=0
43CONFIG_TINY_SHMEM=y 46CONFIG_TINY_SHMEM=y
47CONFIG_BASE_SMALL=0
44 48
45# 49#
46# Loadable module support 50# Loadable module support
@@ -62,6 +66,7 @@ CONFIG_PLAT_MAPPI=y
62# CONFIG_PLAT_OPSPUT is not set 66# CONFIG_PLAT_OPSPUT is not set
63# CONFIG_PLAT_OAKS32R is not set 67# CONFIG_PLAT_OAKS32R is not set
64# CONFIG_PLAT_MAPPI2 is not set 68# CONFIG_PLAT_MAPPI2 is not set
69# CONFIG_PLAT_MAPPI3 is not set
65CONFIG_CHIP_M32700=y 70CONFIG_CHIP_M32700=y
66# CONFIG_CHIP_M32102 is not set 71# CONFIG_CHIP_M32102 is not set
67# CONFIG_CHIP_VDEC2 is not set 72# CONFIG_CHIP_VDEC2 is not set
@@ -202,7 +207,6 @@ CONFIG_NET=y
202# 207#
203CONFIG_PACKET=y 208CONFIG_PACKET=y
204# CONFIG_PACKET_MMAP is not set 209# CONFIG_PACKET_MMAP is not set
205# CONFIG_NETLINK_DEV is not set
206CONFIG_UNIX=y 210CONFIG_UNIX=y
207# CONFIG_NET_KEY is not set 211# CONFIG_NET_KEY is not set
208CONFIG_INET=y 212CONFIG_INET=y
@@ -325,18 +329,6 @@ CONFIG_INPUT=y
325# CONFIG_INPUT_EVBUG is not set 329# CONFIG_INPUT_EVBUG is not set
326 330
327# 331#
328# Input I/O drivers
329#
330# CONFIG_GAMEPORT is not set
331CONFIG_SOUND_GAMEPORT=y
332CONFIG_SERIO=y
333# CONFIG_SERIO_I8042 is not set
334CONFIG_SERIO_SERPORT=y
335# CONFIG_SERIO_CT82C710 is not set
336# CONFIG_SERIO_LIBPS2 is not set
337# CONFIG_SERIO_RAW is not set
338
339#
340# Input Device Drivers 332# Input Device Drivers
341# 333#
342# CONFIG_INPUT_KEYBOARD is not set 334# CONFIG_INPUT_KEYBOARD is not set
@@ -346,6 +338,17 @@ CONFIG_SERIO_SERPORT=y
346# CONFIG_INPUT_MISC is not set 338# CONFIG_INPUT_MISC is not set
347 339
348# 340#
341# Hardware I/O ports
342#
343CONFIG_SERIO=y
344# CONFIG_SERIO_I8042 is not set
345CONFIG_SERIO_SERPORT=y
346# CONFIG_SERIO_LIBPS2 is not set
347# CONFIG_SERIO_RAW is not set
348# CONFIG_GAMEPORT is not set
349CONFIG_SOUND_GAMEPORT=y
350
351#
349# Character devices 352# Character devices
350# 353#
351# CONFIG_VT is not set 354# CONFIG_VT is not set
@@ -394,6 +397,10 @@ CONFIG_LEGACY_PTY_COUNT=256
394# CONFIG_RAW_DRIVER is not set 397# CONFIG_RAW_DRIVER is not set
395 398
396# 399#
400# TPM devices
401#
402
403#
397# I2C support 404# I2C support
398# 405#
399# CONFIG_I2C is not set 406# CONFIG_I2C is not set
@@ -434,10 +441,6 @@ CONFIG_LEGACY_PTY_COUNT=256
434# CONFIG_USB_ARCH_HAS_OHCI is not set 441# CONFIG_USB_ARCH_HAS_OHCI is not set
435 442
436# 443#
437# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
438#
439
440#
441# USB Gadget Support 444# USB Gadget Support
442# 445#
443# CONFIG_USB_GADGET is not set 446# CONFIG_USB_GADGET is not set
@@ -595,8 +598,9 @@ CONFIG_NLS_DEFAULT="iso8859-1"
595# 598#
596# Kernel hacking 599# Kernel hacking
597# 600#
601# CONFIG_PRINTK_TIME is not set
598# CONFIG_DEBUG_KERNEL is not set 602# CONFIG_DEBUG_KERNEL is not set
599CONFIG_DEBUG_PREEMPT=y 603CONFIG_LOG_BUF_SHIFT=14
600# CONFIG_DEBUG_BUGVERBOSE is not set 604# CONFIG_DEBUG_BUGVERBOSE is not set
601# CONFIG_FRAME_POINTER is not set 605# CONFIG_FRAME_POINTER is not set
602 606
diff --git a/arch/m32r/mappi/defconfig.smp b/arch/m32r/mappi/defconfig.smp
index 956a8e2f98d6..1a7f3cd42246 100644
--- a/arch/m32r/mappi/defconfig.smp
+++ b/arch/m32r/mappi/defconfig.smp
@@ -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.11-rc4 3# Linux kernel version: 2.6.12-rc5
4# Wed Feb 16 21:11:02 2005 4# Fri Jun 3 16:21:52 2005
5# 5#
6CONFIG_M32R=y 6CONFIG_M32R=y
7# CONFIG_UID16 is not set 7# CONFIG_UID16 is not set
@@ -17,6 +17,7 @@ CONFIG_EXPERIMENTAL=y
17CONFIG_BROKEN=y 17CONFIG_BROKEN=y
18CONFIG_BROKEN_ON_SMP=y 18CONFIG_BROKEN_ON_SMP=y
19CONFIG_LOCK_KERNEL=y 19CONFIG_LOCK_KERNEL=y
20CONFIG_INIT_ENV_ARG_LIMIT=32
20 21
21# 22#
22# General setup 23# General setup
@@ -28,13 +29,16 @@ CONFIG_SYSVIPC=y
28# CONFIG_BSD_PROCESS_ACCT is not set 29# CONFIG_BSD_PROCESS_ACCT is not set
29CONFIG_SYSCTL=y 30CONFIG_SYSCTL=y
30# CONFIG_AUDIT is not set 31# CONFIG_AUDIT is not set
31CONFIG_LOG_BUF_SHIFT=15
32CONFIG_HOTPLUG=y 32CONFIG_HOTPLUG=y
33CONFIG_KOBJECT_UEVENT=y 33CONFIG_KOBJECT_UEVENT=y
34CONFIG_IKCONFIG=y 34CONFIG_IKCONFIG=y
35CONFIG_IKCONFIG_PROC=y 35CONFIG_IKCONFIG_PROC=y
36# CONFIG_CPUSETS is not set
36CONFIG_EMBEDDED=y 37CONFIG_EMBEDDED=y
37# CONFIG_KALLSYMS is not set 38# CONFIG_KALLSYMS is not set
39CONFIG_PRINTK=y
40CONFIG_BUG=y
41CONFIG_BASE_FULL=y
38# CONFIG_FUTEX is not set 42# CONFIG_FUTEX is not set
39# CONFIG_EPOLL is not set 43# CONFIG_EPOLL is not set
40# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 44# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -44,6 +48,7 @@ CONFIG_CC_ALIGN_LABELS=0
44CONFIG_CC_ALIGN_LOOPS=0 48CONFIG_CC_ALIGN_LOOPS=0
45CONFIG_CC_ALIGN_JUMPS=0 49CONFIG_CC_ALIGN_JUMPS=0
46# CONFIG_TINY_SHMEM is not set 50# CONFIG_TINY_SHMEM is not set
51CONFIG_BASE_SMALL=0
47 52
48# 53#
49# Loadable module support 54# Loadable module support
@@ -66,6 +71,7 @@ CONFIG_PLAT_MAPPI=y
66# CONFIG_PLAT_OPSPUT is not set 71# CONFIG_PLAT_OPSPUT is not set
67# CONFIG_PLAT_OAKS32R is not set 72# CONFIG_PLAT_OAKS32R is not set
68# CONFIG_PLAT_MAPPI2 is not set 73# CONFIG_PLAT_MAPPI2 is not set
74# CONFIG_PLAT_MAPPI3 is not set
69CONFIG_CHIP_M32700=y 75CONFIG_CHIP_M32700=y
70# CONFIG_CHIP_M32102 is not set 76# CONFIG_CHIP_M32102 is not set
71# CONFIG_CHIP_VDEC2 is not set 77# CONFIG_CHIP_VDEC2 is not set
@@ -139,8 +145,8 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
139# 145#
140CONFIG_MTD=y 146CONFIG_MTD=y
141# CONFIG_MTD_DEBUG is not set 147# CONFIG_MTD_DEBUG is not set
142CONFIG_MTD_PARTITIONS=y
143# CONFIG_MTD_CONCAT is not set 148# CONFIG_MTD_CONCAT is not set
149CONFIG_MTD_PARTITIONS=y
144CONFIG_MTD_REDBOOT_PARTS=y 150CONFIG_MTD_REDBOOT_PARTS=y
145CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1 151CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
146# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set 152# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
@@ -294,7 +300,6 @@ CONFIG_NET=y
294# Networking options 300# Networking options
295# 301#
296# CONFIG_PACKET is not set 302# CONFIG_PACKET is not set
297# CONFIG_NETLINK_DEV is not set
298CONFIG_UNIX=y 303CONFIG_UNIX=y
299# CONFIG_NET_KEY is not set 304# CONFIG_NET_KEY is not set
300CONFIG_INET=y 305CONFIG_INET=y
@@ -420,18 +425,6 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
420# CONFIG_INPUT_EVBUG is not set 425# CONFIG_INPUT_EVBUG is not set
421 426
422# 427#
423# Input I/O drivers
424#
425# CONFIG_GAMEPORT is not set
426CONFIG_SOUND_GAMEPORT=y
427CONFIG_SERIO=y
428# CONFIG_SERIO_I8042 is not set
429# CONFIG_SERIO_SERPORT is not set
430# CONFIG_SERIO_CT82C710 is not set
431# CONFIG_SERIO_LIBPS2 is not set
432# CONFIG_SERIO_RAW is not set
433
434#
435# Input Device Drivers 428# Input Device Drivers
436# 429#
437# CONFIG_INPUT_KEYBOARD is not set 430# CONFIG_INPUT_KEYBOARD is not set
@@ -441,6 +434,17 @@ CONFIG_SERIO=y
441# CONFIG_INPUT_MISC is not set 434# CONFIG_INPUT_MISC is not set
442 435
443# 436#
437# Hardware I/O ports
438#
439CONFIG_SERIO=y
440# CONFIG_SERIO_I8042 is not set
441# CONFIG_SERIO_SERPORT is not set
442# CONFIG_SERIO_LIBPS2 is not set
443# CONFIG_SERIO_RAW is not set
444# CONFIG_GAMEPORT is not set
445CONFIG_SOUND_GAMEPORT=y
446
447#
444# Character devices 448# Character devices
445# 449#
446# CONFIG_VT is not set 450# CONFIG_VT is not set
@@ -489,6 +493,10 @@ CONFIG_LEGACY_PTY_COUNT=256
489# CONFIG_RAW_DRIVER is not set 493# CONFIG_RAW_DRIVER is not set
490 494
491# 495#
496# TPM devices
497#
498
499#
492# I2C support 500# I2C support
493# 501#
494# CONFIG_I2C is not set 502# CONFIG_I2C is not set
@@ -529,10 +537,6 @@ CONFIG_LEGACY_PTY_COUNT=256
529# CONFIG_USB_ARCH_HAS_OHCI is not set 537# CONFIG_USB_ARCH_HAS_OHCI is not set
530 538
531# 539#
532# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
533#
534
535#
536# USB Gadget Support 540# USB Gadget Support
537# 541#
538# CONFIG_USB_GADGET is not set 542# CONFIG_USB_GADGET is not set
@@ -708,8 +712,9 @@ CONFIG_NLS_DEFAULT="iso8859-1"
708# 712#
709# Kernel hacking 713# Kernel hacking
710# 714#
715# CONFIG_PRINTK_TIME is not set
711# CONFIG_DEBUG_KERNEL is not set 716# CONFIG_DEBUG_KERNEL is not set
712CONFIG_DEBUG_PREEMPT=y 717CONFIG_LOG_BUF_SHIFT=15
713# CONFIG_DEBUG_BUGVERBOSE is not set 718# CONFIG_DEBUG_BUGVERBOSE is not set
714# CONFIG_FRAME_POINTER is not set 719# CONFIG_FRAME_POINTER is not set
715 720
diff --git a/arch/m32r/mappi/defconfig.up b/arch/m32r/mappi/defconfig.up
index c9253e94efbd..38910fb76692 100644
--- a/arch/m32r/mappi/defconfig.up
+++ b/arch/m32r/mappi/defconfig.up
@@ -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.11-rc4 3# Linux kernel version: 2.6.12-rc5
4# Wed Feb 16 21:11:07 2005 4# Fri Jun 3 16:21:59 2005
5# 5#
6CONFIG_M32R=y 6CONFIG_M32R=y
7# CONFIG_UID16 is not set 7# CONFIG_UID16 is not set
@@ -17,6 +17,7 @@ CONFIG_EXPERIMENTAL=y
17CONFIG_BROKEN=y 17CONFIG_BROKEN=y
18CONFIG_BROKEN_ON_SMP=y 18CONFIG_BROKEN_ON_SMP=y
19CONFIG_LOCK_KERNEL=y 19CONFIG_LOCK_KERNEL=y
20CONFIG_INIT_ENV_ARG_LIMIT=32
20 21
21# 22#
22# General setup 23# General setup
@@ -28,13 +29,15 @@ CONFIG_SYSVIPC=y
28# CONFIG_BSD_PROCESS_ACCT is not set 29# CONFIG_BSD_PROCESS_ACCT is not set
29CONFIG_SYSCTL=y 30CONFIG_SYSCTL=y
30# CONFIG_AUDIT is not set 31# CONFIG_AUDIT is not set
31CONFIG_LOG_BUF_SHIFT=14
32CONFIG_HOTPLUG=y 32CONFIG_HOTPLUG=y
33CONFIG_KOBJECT_UEVENT=y 33CONFIG_KOBJECT_UEVENT=y
34CONFIG_IKCONFIG=y 34CONFIG_IKCONFIG=y
35CONFIG_IKCONFIG_PROC=y 35CONFIG_IKCONFIG_PROC=y
36CONFIG_EMBEDDED=y 36CONFIG_EMBEDDED=y
37# CONFIG_KALLSYMS is not set 37# CONFIG_KALLSYMS is not set
38CONFIG_PRINTK=y
39CONFIG_BUG=y
40CONFIG_BASE_FULL=y
38# CONFIG_FUTEX is not set 41# CONFIG_FUTEX is not set
39# CONFIG_EPOLL is not set 42# CONFIG_EPOLL is not set
40# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 43# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -44,6 +47,7 @@ CONFIG_CC_ALIGN_LABELS=0
44CONFIG_CC_ALIGN_LOOPS=0 47CONFIG_CC_ALIGN_LOOPS=0
45CONFIG_CC_ALIGN_JUMPS=0 48CONFIG_CC_ALIGN_JUMPS=0
46# CONFIG_TINY_SHMEM is not set 49# CONFIG_TINY_SHMEM is not set
50CONFIG_BASE_SMALL=0
47 51
48# 52#
49# Loadable module support 53# Loadable module support
@@ -65,6 +69,7 @@ CONFIG_PLAT_MAPPI=y
65# CONFIG_PLAT_OPSPUT is not set 69# CONFIG_PLAT_OPSPUT is not set
66# CONFIG_PLAT_OAKS32R is not set 70# CONFIG_PLAT_OAKS32R is not set
67# CONFIG_PLAT_MAPPI2 is not set 71# CONFIG_PLAT_MAPPI2 is not set
72# CONFIG_PLAT_MAPPI3 is not set
68CONFIG_CHIP_M32700=y 73CONFIG_CHIP_M32700=y
69# CONFIG_CHIP_M32102 is not set 74# CONFIG_CHIP_M32102 is not set
70# CONFIG_CHIP_VDEC2 is not set 75# CONFIG_CHIP_VDEC2 is not set
@@ -135,8 +140,8 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
135# 140#
136CONFIG_MTD=y 141CONFIG_MTD=y
137# CONFIG_MTD_DEBUG is not set 142# CONFIG_MTD_DEBUG is not set
138CONFIG_MTD_PARTITIONS=y
139# CONFIG_MTD_CONCAT is not set 143# CONFIG_MTD_CONCAT is not set
144CONFIG_MTD_PARTITIONS=y
140CONFIG_MTD_REDBOOT_PARTS=y 145CONFIG_MTD_REDBOOT_PARTS=y
141CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1 146CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
142# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set 147# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
@@ -290,7 +295,6 @@ CONFIG_NET=y
290# Networking options 295# Networking options
291# 296#
292# CONFIG_PACKET is not set 297# CONFIG_PACKET is not set
293# CONFIG_NETLINK_DEV is not set
294CONFIG_UNIX=y 298CONFIG_UNIX=y
295# CONFIG_NET_KEY is not set 299# CONFIG_NET_KEY is not set
296CONFIG_INET=y 300CONFIG_INET=y
@@ -416,18 +420,6 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
416# CONFIG_INPUT_EVBUG is not set 420# CONFIG_INPUT_EVBUG is not set
417 421
418# 422#
419# Input I/O drivers
420#
421# CONFIG_GAMEPORT is not set
422CONFIG_SOUND_GAMEPORT=y
423CONFIG_SERIO=y
424# CONFIG_SERIO_I8042 is not set
425# CONFIG_SERIO_SERPORT is not set
426# CONFIG_SERIO_CT82C710 is not set
427# CONFIG_SERIO_LIBPS2 is not set
428# CONFIG_SERIO_RAW is not set
429
430#
431# Input Device Drivers 423# Input Device Drivers
432# 424#
433# CONFIG_INPUT_KEYBOARD is not set 425# CONFIG_INPUT_KEYBOARD is not set
@@ -437,6 +429,17 @@ CONFIG_SERIO=y
437# CONFIG_INPUT_MISC is not set 429# CONFIG_INPUT_MISC is not set
438 430
439# 431#
432# Hardware I/O ports
433#
434CONFIG_SERIO=y
435# CONFIG_SERIO_I8042 is not set
436# CONFIG_SERIO_SERPORT is not set
437# CONFIG_SERIO_LIBPS2 is not set
438# CONFIG_SERIO_RAW is not set
439# CONFIG_GAMEPORT is not set
440CONFIG_SOUND_GAMEPORT=y
441
442#
440# Character devices 443# Character devices
441# 444#
442# CONFIG_VT is not set 445# CONFIG_VT is not set
@@ -485,6 +488,10 @@ CONFIG_LEGACY_PTY_COUNT=256
485# CONFIG_RAW_DRIVER is not set 488# CONFIG_RAW_DRIVER is not set
486 489
487# 490#
491# TPM devices
492#
493
494#
488# I2C support 495# I2C support
489# 496#
490# CONFIG_I2C is not set 497# CONFIG_I2C is not set
@@ -525,10 +532,6 @@ CONFIG_LEGACY_PTY_COUNT=256
525# CONFIG_USB_ARCH_HAS_OHCI is not set 532# CONFIG_USB_ARCH_HAS_OHCI is not set
526 533
527# 534#
528# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
529#
530
531#
532# USB Gadget Support 535# USB Gadget Support
533# 536#
534# CONFIG_USB_GADGET is not set 537# CONFIG_USB_GADGET is not set
@@ -704,8 +707,9 @@ CONFIG_NLS_DEFAULT="iso8859-1"
704# 707#
705# Kernel hacking 708# Kernel hacking
706# 709#
710# CONFIG_PRINTK_TIME is not set
707# CONFIG_DEBUG_KERNEL is not set 711# CONFIG_DEBUG_KERNEL is not set
708CONFIG_DEBUG_PREEMPT=y 712CONFIG_LOG_BUF_SHIFT=14
709# CONFIG_DEBUG_BUGVERBOSE is not set 713# CONFIG_DEBUG_BUGVERBOSE is not set
710# CONFIG_FRAME_POINTER is not set 714# CONFIG_FRAME_POINTER is not set
711 715
diff --git a/arch/m32r/mappi2/defconfig.vdec2 b/arch/m32r/mappi2/defconfig.vdec2
index c14791d27300..56f287b65898 100644
--- a/arch/m32r/mappi2/defconfig.vdec2
+++ b/arch/m32r/mappi2/defconfig.vdec2
@@ -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.11-rc4 3# Linux kernel version: 2.6.12-rc5
4# Wed Feb 16 21:11:10 2005 4# Fri Jun 3 16:22:02 2005
5# 5#
6CONFIG_M32R=y 6CONFIG_M32R=y
7# CONFIG_UID16 is not set 7# CONFIG_UID16 is not set
@@ -16,6 +16,7 @@ CONFIG_EXPERIMENTAL=y
16CONFIG_CLEAN_COMPILE=y 16CONFIG_CLEAN_COMPILE=y
17CONFIG_BROKEN_ON_SMP=y 17CONFIG_BROKEN_ON_SMP=y
18CONFIG_LOCK_KERNEL=y 18CONFIG_LOCK_KERNEL=y
19CONFIG_INIT_ENV_ARG_LIMIT=32
19 20
20# 21#
21# General setup 22# General setup
@@ -28,13 +29,15 @@ CONFIG_BSD_PROCESS_ACCT=y
28# CONFIG_BSD_PROCESS_ACCT_V3 is not set 29# CONFIG_BSD_PROCESS_ACCT_V3 is not set
29CONFIG_SYSCTL=y 30CONFIG_SYSCTL=y
30# CONFIG_AUDIT is not set 31# CONFIG_AUDIT is not set
31CONFIG_LOG_BUF_SHIFT=14
32CONFIG_HOTPLUG=y 32CONFIG_HOTPLUG=y
33CONFIG_KOBJECT_UEVENT=y 33CONFIG_KOBJECT_UEVENT=y
34CONFIG_IKCONFIG=y 34CONFIG_IKCONFIG=y
35# CONFIG_IKCONFIG_PROC is not set 35# CONFIG_IKCONFIG_PROC is not set
36CONFIG_EMBEDDED=y 36CONFIG_EMBEDDED=y
37# CONFIG_KALLSYMS is not set 37# CONFIG_KALLSYMS is not set
38CONFIG_PRINTK=y
39CONFIG_BUG=y
40CONFIG_BASE_FULL=y
38# CONFIG_FUTEX is not set 41# CONFIG_FUTEX is not set
39# CONFIG_EPOLL is not set 42# CONFIG_EPOLL is not set
40# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 43# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -44,6 +47,7 @@ CONFIG_CC_ALIGN_LABELS=0
44CONFIG_CC_ALIGN_LOOPS=0 47CONFIG_CC_ALIGN_LOOPS=0
45CONFIG_CC_ALIGN_JUMPS=0 48CONFIG_CC_ALIGN_JUMPS=0
46# CONFIG_TINY_SHMEM is not set 49# CONFIG_TINY_SHMEM is not set
50CONFIG_BASE_SMALL=0
47 51
48# 52#
49# Loadable module support 53# Loadable module support
@@ -65,6 +69,7 @@ CONFIG_KMOD=y
65# CONFIG_PLAT_OPSPUT is not set 69# CONFIG_PLAT_OPSPUT is not set
66# CONFIG_PLAT_OAKS32R is not set 70# CONFIG_PLAT_OAKS32R is not set
67CONFIG_PLAT_MAPPI2=y 71CONFIG_PLAT_MAPPI2=y
72# CONFIG_PLAT_MAPPI3 is not set
68# CONFIG_CHIP_M32700 is not set 73# CONFIG_CHIP_M32700 is not set
69# CONFIG_CHIP_M32102 is not set 74# CONFIG_CHIP_M32102 is not set
70CONFIG_CHIP_VDEC2=y 75CONFIG_CHIP_VDEC2=y
@@ -264,7 +269,6 @@ CONFIG_NET=y
264# 269#
265CONFIG_PACKET=y 270CONFIG_PACKET=y
266# CONFIG_PACKET_MMAP is not set 271# CONFIG_PACKET_MMAP is not set
267# CONFIG_NETLINK_DEV is not set
268CONFIG_UNIX=y 272CONFIG_UNIX=y
269# CONFIG_NET_KEY is not set 273# CONFIG_NET_KEY is not set
270CONFIG_INET=y 274CONFIG_INET=y
@@ -389,18 +393,6 @@ CONFIG_INPUT=y
389# CONFIG_INPUT_EVBUG is not set 393# CONFIG_INPUT_EVBUG is not set
390 394
391# 395#
392# Input I/O drivers
393#
394# CONFIG_GAMEPORT is not set
395CONFIG_SOUND_GAMEPORT=y
396CONFIG_SERIO=y
397# CONFIG_SERIO_I8042 is not set
398CONFIG_SERIO_SERPORT=y
399# CONFIG_SERIO_CT82C710 is not set
400# CONFIG_SERIO_LIBPS2 is not set
401# CONFIG_SERIO_RAW is not set
402
403#
404# Input Device Drivers 396# Input Device Drivers
405# 397#
406# CONFIG_INPUT_KEYBOARD is not set 398# CONFIG_INPUT_KEYBOARD is not set
@@ -410,6 +402,17 @@ CONFIG_SERIO_SERPORT=y
410# CONFIG_INPUT_MISC is not set 402# CONFIG_INPUT_MISC is not set
411 403
412# 404#
405# Hardware I/O ports
406#
407CONFIG_SERIO=y
408# CONFIG_SERIO_I8042 is not set
409CONFIG_SERIO_SERPORT=y
410# CONFIG_SERIO_LIBPS2 is not set
411# CONFIG_SERIO_RAW is not set
412# CONFIG_GAMEPORT is not set
413CONFIG_SOUND_GAMEPORT=y
414
415#
413# Character devices 416# Character devices
414# 417#
415CONFIG_VT=y 418CONFIG_VT=y
@@ -460,6 +463,10 @@ CONFIG_LEGACY_PTY_COUNT=256
460# CONFIG_RAW_DRIVER is not set 463# CONFIG_RAW_DRIVER is not set
461 464
462# 465#
466# TPM devices
467#
468
469#
463# I2C support 470# I2C support
464# 471#
465# CONFIG_I2C is not set 472# CONFIG_I2C is not set
@@ -521,10 +528,6 @@ CONFIG_DUMMY_CONSOLE=y
521# CONFIG_USB_ARCH_HAS_OHCI is not set 528# CONFIG_USB_ARCH_HAS_OHCI is not set
522 529
523# 530#
524# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
525#
526
527#
528# USB Gadget Support 531# USB Gadget Support
529# 532#
530# CONFIG_USB_GADGET is not set 533# CONFIG_USB_GADGET is not set
@@ -697,8 +700,9 @@ CONFIG_NLS_DEFAULT="iso8859-1"
697# 700#
698# Kernel hacking 701# Kernel hacking
699# 702#
703# CONFIG_PRINTK_TIME is not set
700# CONFIG_DEBUG_KERNEL is not set 704# CONFIG_DEBUG_KERNEL is not set
701CONFIG_DEBUG_PREEMPT=y 705CONFIG_LOG_BUF_SHIFT=14
702# CONFIG_DEBUG_BUGVERBOSE is not set 706# CONFIG_DEBUG_BUGVERBOSE is not set
703# CONFIG_FRAME_POINTER is not set 707# CONFIG_FRAME_POINTER is not set
704 708
diff --git a/arch/m32r/mappi3/defconfig.smp b/arch/m32r/mappi3/defconfig.smp
new file mode 100644
index 000000000000..2eebe75fc071
--- /dev/null
+++ b/arch/m32r/mappi3/defconfig.smp
@@ -0,0 +1,751 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.12-rc5
4# Tue May 31 17:55:34 2005
5#
6CONFIG_M32R=y
7# CONFIG_UID16 is not set
8CONFIG_GENERIC_ISA_DMA=y
9CONFIG_GENERIC_HARDIRQS=y
10CONFIG_GENERIC_IRQ_PROBE=y
11
12#
13# Code maturity level options
14#
15CONFIG_EXPERIMENTAL=y
16# CONFIG_CLEAN_COMPILE is not set
17CONFIG_BROKEN=y
18CONFIG_BROKEN_ON_SMP=y
19CONFIG_LOCK_KERNEL=y
20CONFIG_INIT_ENV_ARG_LIMIT=32
21
22#
23# General setup
24#
25CONFIG_LOCALVERSION=""
26CONFIG_SWAP=y
27CONFIG_SYSVIPC=y
28# CONFIG_POSIX_MQUEUE is not set
29# CONFIG_BSD_PROCESS_ACCT is not set
30CONFIG_SYSCTL=y
31# CONFIG_AUDIT is not set
32CONFIG_HOTPLUG=y
33CONFIG_KOBJECT_UEVENT=y
34CONFIG_IKCONFIG=y
35CONFIG_IKCONFIG_PROC=y
36# CONFIG_CPUSETS is not set
37CONFIG_EMBEDDED=y
38# CONFIG_KALLSYMS is not set
39CONFIG_PRINTK=y
40CONFIG_BUG=y
41CONFIG_BASE_FULL=y
42# CONFIG_FUTEX is not set
43# CONFIG_EPOLL is not set
44# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
45CONFIG_SHMEM=y
46CONFIG_CC_ALIGN_FUNCTIONS=0
47CONFIG_CC_ALIGN_LABELS=0
48CONFIG_CC_ALIGN_LOOPS=0
49CONFIG_CC_ALIGN_JUMPS=0
50# CONFIG_TINY_SHMEM is not set
51CONFIG_BASE_SMALL=0
52
53#
54# Loadable module support
55#
56CONFIG_MODULES=y
57CONFIG_MODULE_UNLOAD=y
58# CONFIG_MODULE_FORCE_UNLOAD is not set
59CONFIG_OBSOLETE_MODPARM=y
60# CONFIG_MODVERSIONS is not set
61# CONFIG_MODULE_SRCVERSION_ALL is not set
62CONFIG_KMOD=y
63CONFIG_STOP_MACHINE=y
64
65#
66# Processor type and features
67#
68# CONFIG_PLAT_MAPPI is not set
69# CONFIG_PLAT_USRV is not set
70# CONFIG_PLAT_M32700UT is not set
71# CONFIG_PLAT_OPSPUT is not set
72# CONFIG_PLAT_OAKS32R is not set
73# CONFIG_PLAT_MAPPI2 is not set
74CONFIG_PLAT_MAPPI3=y
75CONFIG_CHIP_M32700=y
76# CONFIG_CHIP_M32102 is not set
77# CONFIG_CHIP_VDEC2 is not set
78# CONFIG_CHIP_OPSP is not set
79CONFIG_MMU=y
80CONFIG_TLB_ENTRIES=32
81CONFIG_ISA_M32R2=y
82CONFIG_ISA_DSP_LEVEL2=y
83CONFIG_ISA_DUAL_ISSUE=y
84CONFIG_BUS_CLOCK=10000000
85CONFIG_TIMER_DIVIDE=128
86# CONFIG_CPU_LITTLE_ENDIAN is not set
87CONFIG_MEMORY_START=0x08000000
88CONFIG_MEMORY_SIZE=0x08000000
89CONFIG_NOHIGHMEM=y
90CONFIG_DISCONTIGMEM=y
91CONFIG_IRAM_START=0x00f00000
92CONFIG_IRAM_SIZE=0x00080000
93CONFIG_RWSEM_GENERIC_SPINLOCK=y
94# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
95CONFIG_GENERIC_CALIBRATE_DELAY=y
96CONFIG_PREEMPT=y
97# CONFIG_HAVE_DEC_LOCK is not set
98CONFIG_SMP=y
99# CONFIG_CHIP_M32700_TS1 is not set
100CONFIG_NR_CPUS=2
101# CONFIG_NUMA is not set
102
103#
104# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
105#
106# CONFIG_PCI is not set
107# CONFIG_ISA is not set
108
109#
110# PCCARD (PCMCIA/CardBus) support
111#
112CONFIG_PCCARD=y
113# CONFIG_PCMCIA_DEBUG is not set
114CONFIG_PCMCIA=y
115
116#
117# PC-card bridges
118#
119# CONFIG_TCIC is not set
120# CONFIG_M32R_PCC is not set
121# CONFIG_M32R_CFC is not set
122
123#
124# PCI Hotplug Support
125#
126
127#
128# Executable file formats
129#
130CONFIG_BINFMT_ELF=y
131# CONFIG_BINFMT_MISC is not set
132
133#
134# Device Drivers
135#
136
137#
138# Generic Driver Options
139#
140CONFIG_STANDALONE=y
141CONFIG_PREVENT_FIRMWARE_BUILD=y
142CONFIG_FW_LOADER=y
143
144#
145# Memory Technology Devices (MTD)
146#
147CONFIG_MTD=y
148# CONFIG_MTD_DEBUG is not set
149# CONFIG_MTD_CONCAT is not set
150CONFIG_MTD_PARTITIONS=y
151CONFIG_MTD_REDBOOT_PARTS=y
152CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
153# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
154# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
155# CONFIG_MTD_CMDLINE_PARTS is not set
156
157#
158# User Modules And Translation Layers
159#
160CONFIG_MTD_CHAR=y
161CONFIG_MTD_BLOCK=y
162# CONFIG_FTL is not set
163# CONFIG_NFTL is not set
164# CONFIG_INFTL is not set
165
166#
167# RAM/ROM/Flash chip drivers
168#
169# CONFIG_MTD_CFI is not set
170# CONFIG_MTD_JEDECPROBE is not set
171CONFIG_MTD_MAP_BANK_WIDTH_1=y
172CONFIG_MTD_MAP_BANK_WIDTH_2=y
173CONFIG_MTD_MAP_BANK_WIDTH_4=y
174# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
175# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
176# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
177CONFIG_MTD_CFI_I1=y
178CONFIG_MTD_CFI_I2=y
179# CONFIG_MTD_CFI_I4 is not set
180# CONFIG_MTD_CFI_I8 is not set
181# CONFIG_MTD_RAM is not set
182# CONFIG_MTD_ROM is not set
183# CONFIG_MTD_ABSENT is not set
184# CONFIG_MTD_OBSOLETE_CHIPS is not set
185
186#
187# Mapping drivers for chip access
188#
189# CONFIG_MTD_COMPLEX_MAPPINGS is not set
190
191#
192# Self-contained MTD device drivers
193#
194# CONFIG_MTD_SLRAM is not set
195# CONFIG_MTD_PHRAM is not set
196# CONFIG_MTD_MTDRAM is not set
197# CONFIG_MTD_BLKMTD is not set
198# CONFIG_MTD_BLOCK2MTD is not set
199
200#
201# Disk-On-Chip Device Drivers
202#
203# CONFIG_MTD_DOC2000 is not set
204# CONFIG_MTD_DOC2001 is not set
205# CONFIG_MTD_DOC2001PLUS is not set
206
207#
208# NAND Flash Device Drivers
209#
210# CONFIG_MTD_NAND is not set
211
212#
213# Parallel port support
214#
215# CONFIG_PARPORT is not set
216
217#
218# Plug and Play support
219#
220
221#
222# Block devices
223#
224# CONFIG_BLK_DEV_FD is not set
225# CONFIG_BLK_DEV_COW_COMMON is not set
226CONFIG_BLK_DEV_LOOP=y
227# CONFIG_BLK_DEV_CRYPTOLOOP is not set
228CONFIG_BLK_DEV_NBD=m
229CONFIG_BLK_DEV_RAM=y
230CONFIG_BLK_DEV_RAM_COUNT=16
231CONFIG_BLK_DEV_RAM_SIZE=4096
232CONFIG_BLK_DEV_INITRD=y
233CONFIG_INITRAMFS_SOURCE=""
234# CONFIG_CDROM_PKTCDVD is not set
235
236#
237# IO Schedulers
238#
239CONFIG_IOSCHED_NOOP=y
240# CONFIG_IOSCHED_AS is not set
241CONFIG_IOSCHED_DEADLINE=y
242CONFIG_IOSCHED_CFQ=y
243# CONFIG_ATA_OVER_ETH is not set
244
245#
246# ATA/ATAPI/MFM/RLL support
247#
248CONFIG_IDE=y
249CONFIG_BLK_DEV_IDE=y
250
251#
252# Please see Documentation/ide.txt for help/info on IDE drives
253#
254# CONFIG_BLK_DEV_IDE_SATA is not set
255CONFIG_BLK_DEV_IDEDISK=y
256# CONFIG_IDEDISK_MULTI_MODE is not set
257CONFIG_BLK_DEV_IDECS=y
258CONFIG_BLK_DEV_IDECD=m
259# CONFIG_BLK_DEV_IDETAPE is not set
260# CONFIG_BLK_DEV_IDEFLOPPY is not set
261# CONFIG_IDE_TASK_IOCTL is not set
262
263#
264# IDE chipset support/bugfixes
265#
266CONFIG_IDE_GENERIC=y
267# CONFIG_IDE_ARM is not set
268# CONFIG_BLK_DEV_IDEDMA is not set
269# CONFIG_IDEDMA_AUTO is not set
270# CONFIG_BLK_DEV_HD is not set
271
272#
273# SCSI device support
274#
275# CONFIG_SCSI is not set
276
277#
278# Multi-device support (RAID and LVM)
279#
280# CONFIG_MD is not set
281
282#
283# Fusion MPT device support
284#
285
286#
287# IEEE 1394 (FireWire) support
288#
289# CONFIG_IEEE1394 is not set
290
291#
292# I2O device support
293#
294
295#
296# Networking support
297#
298CONFIG_NET=y
299
300#
301# Networking options
302#
303# CONFIG_PACKET is not set
304CONFIG_UNIX=y
305# CONFIG_NET_KEY is not set
306CONFIG_INET=y
307# CONFIG_IP_MULTICAST is not set
308# CONFIG_IP_ADVANCED_ROUTER is not set
309CONFIG_IP_PNP=y
310CONFIG_IP_PNP_DHCP=y
311# CONFIG_IP_PNP_BOOTP is not set
312# CONFIG_IP_PNP_RARP is not set
313# CONFIG_NET_IPIP is not set
314# CONFIG_NET_IPGRE is not set
315# CONFIG_ARPD is not set
316# CONFIG_SYN_COOKIES is not set
317# CONFIG_INET_AH is not set
318# CONFIG_INET_ESP is not set
319# CONFIG_INET_IPCOMP is not set
320# CONFIG_INET_TUNNEL is not set
321CONFIG_IP_TCPDIAG=y
322# CONFIG_IP_TCPDIAG_IPV6 is not set
323# CONFIG_IPV6 is not set
324# CONFIG_NETFILTER is not set
325
326#
327# SCTP Configuration (EXPERIMENTAL)
328#
329# CONFIG_IP_SCTP is not set
330# CONFIG_ATM is not set
331# CONFIG_BRIDGE is not set
332# CONFIG_VLAN_8021Q is not set
333# CONFIG_DECNET is not set
334# CONFIG_LLC2 is not set
335# CONFIG_IPX is not set
336# CONFIG_ATALK is not set
337# CONFIG_X25 is not set
338# CONFIG_LAPB is not set
339# CONFIG_NET_DIVERT is not set
340# CONFIG_ECONET is not set
341# CONFIG_WAN_ROUTER is not set
342
343#
344# QoS and/or fair queueing
345#
346# CONFIG_NET_SCHED is not set
347# CONFIG_NET_CLS_ROUTE is not set
348
349#
350# Network testing
351#
352# CONFIG_NET_PKTGEN is not set
353# CONFIG_NETPOLL is not set
354# CONFIG_NET_POLL_CONTROLLER is not set
355# CONFIG_HAMRADIO is not set
356# CONFIG_IRDA is not set
357# CONFIG_BT is not set
358CONFIG_NETDEVICES=y
359# CONFIG_DUMMY is not set
360# CONFIG_BONDING is not set
361# CONFIG_EQUALIZER is not set
362# CONFIG_TUN is not set
363
364#
365# Ethernet (10 or 100Mbit)
366#
367CONFIG_NET_ETHERNET=y
368CONFIG_MII=y
369CONFIG_SMC91X=y
370# CONFIG_NE2000 is not set
371
372#
373# Ethernet (1000 Mbit)
374#
375
376#
377# Ethernet (10000 Mbit)
378#
379
380#
381# Token Ring devices
382#
383
384#
385# Wireless LAN (non-hamradio)
386#
387# CONFIG_NET_RADIO is not set
388
389#
390# PCMCIA network device support
391#
392# CONFIG_NET_PCMCIA is not set
393
394#
395# Wan interfaces
396#
397# CONFIG_WAN is not set
398# CONFIG_PPP is not set
399# CONFIG_SLIP is not set
400# CONFIG_SHAPER is not set
401# CONFIG_NETCONSOLE is not set
402
403#
404# ISDN subsystem
405#
406# CONFIG_ISDN is not set
407
408#
409# Telephony Support
410#
411# CONFIG_PHONE is not set
412
413#
414# Input device support
415#
416CONFIG_INPUT=y
417
418#
419# Userland interfaces
420#
421CONFIG_INPUT_MOUSEDEV=y
422CONFIG_INPUT_MOUSEDEV_PSAUX=y
423CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
424CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
425# CONFIG_INPUT_JOYDEV is not set
426# CONFIG_INPUT_TSDEV is not set
427# CONFIG_INPUT_EVDEV is not set
428# CONFIG_INPUT_EVBUG is not set
429
430#
431# Input Device Drivers
432#
433# CONFIG_INPUT_KEYBOARD is not set
434# CONFIG_INPUT_MOUSE is not set
435# CONFIG_INPUT_JOYSTICK is not set
436# CONFIG_INPUT_TOUCHSCREEN is not set
437# CONFIG_INPUT_MISC is not set
438
439#
440# Hardware I/O ports
441#
442CONFIG_SERIO=y
443# CONFIG_SERIO_I8042 is not set
444# CONFIG_SERIO_SERPORT is not set
445# CONFIG_SERIO_LIBPS2 is not set
446# CONFIG_SERIO_RAW is not set
447# CONFIG_GAMEPORT is not set
448CONFIG_SOUND_GAMEPORT=y
449
450#
451# Character devices
452#
453# CONFIG_VT is not set
454# CONFIG_SERIAL_NONSTANDARD is not set
455
456#
457# Serial drivers
458#
459# CONFIG_SERIAL_8250 is not set
460
461#
462# Non-8250 serial port support
463#
464CONFIG_SERIAL_CORE=y
465CONFIG_SERIAL_CORE_CONSOLE=y
466CONFIG_SERIAL_M32R_SIO=y
467CONFIG_SERIAL_M32R_SIO_CONSOLE=y
468# CONFIG_SERIAL_M32R_PLDSIO is not set
469CONFIG_UNIX98_PTYS=y
470CONFIG_LEGACY_PTYS=y
471CONFIG_LEGACY_PTY_COUNT=256
472
473#
474# IPMI
475#
476# CONFIG_IPMI_HANDLER is not set
477
478#
479# Watchdog Cards
480#
481# CONFIG_WATCHDOG is not set
482# CONFIG_RTC is not set
483# CONFIG_GEN_RTC is not set
484# CONFIG_DTLK is not set
485# CONFIG_R3964 is not set
486
487#
488# Ftape, the floppy tape device driver
489#
490# CONFIG_DRM is not set
491
492#
493# PCMCIA character devices
494#
495# CONFIG_SYNCLINK_CS is not set
496# CONFIG_RAW_DRIVER is not set
497
498#
499# TPM devices
500#
501
502#
503# I2C support
504#
505# CONFIG_I2C is not set
506
507#
508# Dallas's 1-wire bus
509#
510# CONFIG_W1 is not set
511
512#
513# Misc devices
514#
515
516#
517# Multimedia devices
518#
519# CONFIG_VIDEO_DEV is not set
520
521#
522# Digital Video Broadcasting Devices
523#
524# CONFIG_DVB is not set
525
526#
527# Graphics support
528#
529# CONFIG_FB is not set
530
531#
532# Sound
533#
534# CONFIG_SOUND is not set
535
536#
537# USB support
538#
539# CONFIG_USB_ARCH_HAS_HCD is not set
540# CONFIG_USB_ARCH_HAS_OHCI is not set
541
542#
543# USB Gadget Support
544#
545# CONFIG_USB_GADGET is not set
546
547#
548# MMC/SD Card support
549#
550# CONFIG_MMC is not set
551
552#
553# InfiniBand support
554#
555# CONFIG_INFINIBAND is not set
556
557#
558# File systems
559#
560CONFIG_EXT2_FS=y
561# CONFIG_EXT2_FS_XATTR is not set
562CONFIG_EXT3_FS=y
563CONFIG_EXT3_FS_XATTR=y
564# CONFIG_EXT3_FS_POSIX_ACL is not set
565# CONFIG_EXT3_FS_SECURITY is not set
566CONFIG_JBD=y
567# CONFIG_JBD_DEBUG is not set
568CONFIG_FS_MBCACHE=y
569# CONFIG_REISERFS_FS is not set
570# CONFIG_JFS_FS is not set
571
572#
573# XFS support
574#
575# CONFIG_XFS_FS is not set
576# CONFIG_MINIX_FS is not set
577CONFIG_ROMFS_FS=y
578# CONFIG_QUOTA is not set
579CONFIG_DNOTIFY=y
580# CONFIG_AUTOFS_FS is not set
581# CONFIG_AUTOFS4_FS is not set
582
583#
584# CD-ROM/DVD Filesystems
585#
586CONFIG_ISO9660_FS=y
587# CONFIG_JOLIET is not set
588# CONFIG_ZISOFS is not set
589# CONFIG_UDF_FS is not set
590
591#
592# DOS/FAT/NT Filesystems
593#
594CONFIG_FAT_FS=m
595CONFIG_MSDOS_FS=m
596CONFIG_VFAT_FS=m
597CONFIG_FAT_DEFAULT_CODEPAGE=437
598CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
599# CONFIG_NTFS_FS is not set
600
601#
602# Pseudo filesystems
603#
604CONFIG_PROC_FS=y
605CONFIG_PROC_KCORE=y
606CONFIG_SYSFS=y
607CONFIG_DEVFS_FS=y
608CONFIG_DEVFS_MOUNT=y
609# CONFIG_DEVFS_DEBUG is not set
610# CONFIG_DEVPTS_FS_XATTR is not set
611CONFIG_TMPFS=y
612# CONFIG_TMPFS_XATTR is not set
613# CONFIG_HUGETLBFS is not set
614# CONFIG_HUGETLB_PAGE is not set
615CONFIG_RAMFS=y
616
617#
618# Miscellaneous filesystems
619#
620# CONFIG_ADFS_FS is not set
621# CONFIG_AFFS_FS is not set
622# CONFIG_HFS_FS is not set
623# CONFIG_HFSPLUS_FS is not set
624# CONFIG_BEFS_FS is not set
625# CONFIG_BFS_FS is not set
626# CONFIG_EFS_FS is not set
627CONFIG_JFFS_FS=y
628CONFIG_JFFS_FS_VERBOSE=0
629CONFIG_JFFS_PROC_FS=y
630CONFIG_JFFS2_FS=y
631CONFIG_JFFS2_FS_DEBUG=0
632# CONFIG_JFFS2_FS_NAND is not set
633# CONFIG_JFFS2_FS_NOR_ECC is not set
634# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
635CONFIG_JFFS2_ZLIB=y
636CONFIG_JFFS2_RTIME=y
637# CONFIG_JFFS2_RUBIN is not set
638# CONFIG_CRAMFS is not set
639# CONFIG_VXFS_FS is not set
640# CONFIG_HPFS_FS is not set
641# CONFIG_QNX4FS_FS is not set
642# CONFIG_SYSV_FS is not set
643# CONFIG_UFS_FS is not set
644
645#
646# Network File Systems
647#
648CONFIG_NFS_FS=y
649CONFIG_NFS_V3=y
650# CONFIG_NFS_V4 is not set
651# CONFIG_NFS_DIRECTIO is not set
652# CONFIG_NFSD is not set
653CONFIG_ROOT_NFS=y
654CONFIG_LOCKD=y
655CONFIG_LOCKD_V4=y
656CONFIG_SUNRPC=y
657# CONFIG_RPCSEC_GSS_KRB5 is not set
658# CONFIG_RPCSEC_GSS_SPKM3 is not set
659# CONFIG_SMB_FS is not set
660# CONFIG_CIFS is not set
661# CONFIG_NCP_FS is not set
662# CONFIG_CODA_FS is not set
663# CONFIG_AFS_FS is not set
664
665#
666# Partition Types
667#
668# CONFIG_PARTITION_ADVANCED is not set
669CONFIG_MSDOS_PARTITION=y
670
671#
672# Native Language Support
673#
674CONFIG_NLS=y
675CONFIG_NLS_DEFAULT="iso8859-1"
676# CONFIG_NLS_CODEPAGE_437 is not set
677# CONFIG_NLS_CODEPAGE_737 is not set
678# CONFIG_NLS_CODEPAGE_775 is not set
679# CONFIG_NLS_CODEPAGE_850 is not set
680# CONFIG_NLS_CODEPAGE_852 is not set
681# CONFIG_NLS_CODEPAGE_855 is not set
682# CONFIG_NLS_CODEPAGE_857 is not set
683# CONFIG_NLS_CODEPAGE_860 is not set
684# CONFIG_NLS_CODEPAGE_861 is not set
685# CONFIG_NLS_CODEPAGE_862 is not set
686# CONFIG_NLS_CODEPAGE_863 is not set
687# CONFIG_NLS_CODEPAGE_864 is not set
688# CONFIG_NLS_CODEPAGE_865 is not set
689# CONFIG_NLS_CODEPAGE_866 is not set
690# CONFIG_NLS_CODEPAGE_869 is not set
691# CONFIG_NLS_CODEPAGE_936 is not set
692# CONFIG_NLS_CODEPAGE_950 is not set
693# CONFIG_NLS_CODEPAGE_932 is not set
694# CONFIG_NLS_CODEPAGE_949 is not set
695# CONFIG_NLS_CODEPAGE_874 is not set
696# CONFIG_NLS_ISO8859_8 is not set
697# CONFIG_NLS_CODEPAGE_1250 is not set
698# CONFIG_NLS_CODEPAGE_1251 is not set
699# CONFIG_NLS_ASCII is not set
700# CONFIG_NLS_ISO8859_1 is not set
701# CONFIG_NLS_ISO8859_2 is not set
702# CONFIG_NLS_ISO8859_3 is not set
703# CONFIG_NLS_ISO8859_4 is not set
704# CONFIG_NLS_ISO8859_5 is not set
705# CONFIG_NLS_ISO8859_6 is not set
706# CONFIG_NLS_ISO8859_7 is not set
707# CONFIG_NLS_ISO8859_9 is not set
708# CONFIG_NLS_ISO8859_13 is not set
709# CONFIG_NLS_ISO8859_14 is not set
710# CONFIG_NLS_ISO8859_15 is not set
711# CONFIG_NLS_KOI8_R is not set
712# CONFIG_NLS_KOI8_U is not set
713# CONFIG_NLS_UTF8 is not set
714
715#
716# Profiling support
717#
718# CONFIG_PROFILING is not set
719
720#
721# Kernel hacking
722#
723# CONFIG_PRINTK_TIME is not set
724# CONFIG_DEBUG_KERNEL is not set
725CONFIG_LOG_BUF_SHIFT=15
726# CONFIG_DEBUG_BUGVERBOSE is not set
727# CONFIG_FRAME_POINTER is not set
728
729#
730# Security options
731#
732# CONFIG_KEYS is not set
733# CONFIG_SECURITY is not set
734
735#
736# Cryptographic options
737#
738# CONFIG_CRYPTO is not set
739
740#
741# Hardware crypto devices
742#
743
744#
745# Library routines
746#
747# CONFIG_CRC_CCITT is not set
748CONFIG_CRC32=y
749# CONFIG_LIBCRC32C is not set
750CONFIG_ZLIB_INFLATE=y
751CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/m32r/mappi3/dot.gdbinit b/arch/m32r/mappi3/dot.gdbinit
new file mode 100644
index 000000000000..89c22184e139
--- /dev/null
+++ b/arch/m32r/mappi3/dot.gdbinit
@@ -0,0 +1,224 @@
1# .gdbinit file
2# $Id: dot.gdbinit,v 1.1 2005/04/11 02:21:08 sakugawa Exp $
3
4# setting
5set width 0d70
6set radix 0d16
7use_debug_dma
8
9# Initialize SDRAM controller for Mappi
10define sdram_init
11 # SDIR0
12 set *(unsigned long *)0x00ef6008 = 0x00000182
13 # SDIR1
14 set *(unsigned long *)0x00ef600c = 0x00000001
15 # Initialize wait
16 shell sleep 0.1
17 # MOD
18 set *(unsigned long *)0x00ef602c = 0x00000020
19 set *(unsigned long *)0x00ef604c = 0x00000020
20 # TR
21 set *(unsigned long *)0x00ef6028 = 0x00051502
22 set *(unsigned long *)0x00ef6048 = 0x00051502
23 # ADR
24 set *(unsigned long *)0x00ef6020 = 0x08000004
25 set *(unsigned long *)0x00ef6040 = 0x0c000004
26 # AutoRef On
27 set *(unsigned long *)0x00ef6004 = 0x00010517
28 # Access enable
29 set *(unsigned long *)0x00ef6024 = 0x00000001
30 set *(unsigned long *)0x00ef6044 = 0x00000001
31end
32
33# Initialize LAN controller for Mappi
34define lanc_init
35 # Set BSEL4
36 #set *(unsigned long *)0x00ef5004 = 0x0fff330f
37 #set *(unsigned long *)0x00ef5004 = 0x01113301
38
39# set *(unsigned long *)0x00ef5004 = 0x02011101
40# set *(unsigned long *)0x00ef5004 = 0x04441104
41end
42
43define clock_init
44 set *(unsigned long *)0x00ef4010 = 2
45 set *(unsigned long *)0x00ef4014 = 2
46 set *(unsigned long *)0x00ef4020 = 3
47 set *(unsigned long *)0x00ef4024 = 3
48 set *(unsigned long *)0x00ef4004 = 0x7
49# shell sleep 0.1
50# set *(unsigned long *)0x00ef4004 = 0x5
51 shell sleep 0.1
52 set *(unsigned long *)0x00ef4008 = 0x0200
53end
54
55define port_init
56 set $sfrbase = 0x00ef0000
57 set *(unsigned short *)0x00ef1060 = 0x5555
58 set *(unsigned short *)0x00ef1062 = 0x5555
59 set *(unsigned short *)0x00ef1064 = 0x5555
60 set *(unsigned short *)0x00ef1066 = 0x5555
61 set *(unsigned short *)0x00ef1068 = 0x5555
62 set *(unsigned short *)0x00ef106a = 0x0000
63 set *(unsigned short *)0x00ef106e = 0x5555
64 set *(unsigned short *)0x00ef1070 = 0x5555
65end
66
67# MMU enable
68define mmu_enable
69 set $evb=0x88000000
70 set *(unsigned long *)0xffff0024=1
71end
72
73# MMU disable
74define mmu_disable
75 set $evb=0
76 set *(unsigned long *)0xffff0024=0
77end
78
79# Show TLB entries
80define show_tlb_entries
81 set $i = 0
82 set $addr = $arg0
83 while ($i < 0d16 )
84 set $tlb_tag = *(unsigned long*)$addr
85 set $tlb_data = *(unsigned long*)($addr + 4)
86 printf " [%2d] 0x%08lx : 0x%08lx - 0x%08lx\n", $i, $addr, $tlb_tag, $tlb_data
87 set $i = $i + 1
88 set $addr = $addr + 8
89 end
90end
91define itlb
92 set $itlb=0xfe000000
93 show_tlb_entries $itlb
94end
95define dtlb
96 set $dtlb=0xfe000800
97 show_tlb_entries $dtlb
98end
99
100# Cache ON
101define set_cache_type
102 set $mctype = (void*)0xfffffff8
103# chaos
104# set *(unsigned long *)($mctype) = 0x0000c000
105# m32102 i-cache only
106 set *(unsigned long *)($mctype) = 0x00008000
107# m32102 d-cache only
108# set *(unsigned long *)($mctype) = 0x00004000
109end
110define cache_on
111 set $param = (void*)0x08001000
112 set *(unsigned long *)($param) = 0x60ff6102
113end
114
115
116# Show current task structure
117define show_current
118 set $current = $spi & 0xffffe000
119 printf "$current=0x%08lX\n",$current
120 print *(struct task_struct *)$current
121end
122
123# Show user assigned task structure
124define show_task
125 set $task = $arg0 & 0xffffe000
126 printf "$task=0x%08lX\n",$task
127 print *(struct task_struct *)$task
128end
129document show_task
130 Show user assigned task structure
131 arg0 : task structure address
132end
133
134# Show M32R registers
135define show_regs
136 printf " R0[0x%08lX] R1[0x%08lX] R2[0x%08lX] R3[0x%08lX]\n",$r0,$r1,$r2,$r3
137 printf " R4[0x%08lX] R5[0x%08lX] R6[0x%08lX] R7[0x%08lX]\n",$r4,$r5,$r6,$r7
138 printf " R8[0x%08lX] R9[0x%08lX] R10[0x%08lX] R11[0x%08lX]\n",$r8,$r9,$r10,$r11
139 printf "R12[0x%08lX] FP[0x%08lX] LR[0x%08lX] SP[0x%08lX]\n",$r12,$fp,$lr,$sp
140 printf "PSW[0x%08lX] CBR[0x%08lX] SPI[0x%08lX] SPU[0x%08lX]\n",$psw,$cbr,$spi,$spu
141 printf "BPC[0x%08lX] PC[0x%08lX] ACCL[0x%08lX] ACCH[0x%08lX]\n",$bpc,$pc,$accl,$acch
142 printf "EVB[0x%08lX]\n",$evb
143
144 set $mests = *(unsigned long *)0xffff000c
145 set $mdeva = *(unsigned long *)0xffff0010
146 printf "MESTS[0x%08lX] MDEVA[0x%08lX]\n",$mests,$mdeva
147end
148
149
150# Setup all
151define setup
152 clock_init
153 shell sleep 0.1
154 port_init
155 sdram_init
156# lanc_init
157# dispc_init
158# set $evb=0x08000000
159end
160
161# Load modules
162define load_modules
163 use_debug_dma
164 load
165# load busybox.mot
166end
167
168# Set kernel parameters
169define set_kernel_parameters
170 set $param = (void*)0x08001000
171
172 ## MOUNT_ROOT_RDONLY
173 set {long}($param+0x00)=0
174 ## RAMDISK_FLAGS
175 #set {long}($param+0x04)=0
176 ## ORIG_ROOT_DEV
177 #set {long}($param+0x08)=0x00000100
178 ## LOADER_TYPE
179 #set {long}($param+0x0C)=0
180 ## INITRD_START
181 set {long}($param+0x10)=0x082a0000
182 ## INITRD_SIZE
183 set {long}($param+0x14)=0d6200000
184
185 # M32R_CPUCLK
186 set *(unsigned long *)($param + 0x0018) = 0d100000000
187 # M32R_BUSCLK
188 set *(unsigned long *)($param + 0x001c) = 0d50000000
189 # M32R_TIMER_DIVIDE
190 set *(unsigned long *)($param + 0x0020) = 0d128
191
192
193 set {char[0x200]}($param + 0x100) = "console=ttyS0,115200n8x root=/dev/nfsroot nfsroot=192.168.0.1:/project/m32r-linux/export/root.2.6_04 nfsaddrs=192.168.0.102:192.168.0.1:192.168.0.1:255.255.255.0:mappi: \0"
194
195
196end
197
198# Boot
199define boot
200 set_kernel_parameters
201 debug_chaos
202 set *(unsigned long *)0x00f00000=0x08002000
203 set $pc=0x08002000
204 set $fp=0
205 del b
206 si
207end
208
209# Restart
210define restart
211 sdireset
212 sdireset
213 setup
214 load_modules
215 boot
216end
217
218sdireset
219sdireset
220file vmlinux
221target m32rsdi
222
223restart
224boot
diff --git a/arch/m32r/mm/extable.c b/arch/m32r/mm/extable.c
index 9a97363b6524..1743f23d49a3 100644
--- a/arch/m32r/mm/extable.c
+++ b/arch/m32r/mm/extable.c
@@ -1,10 +1,8 @@
1/* 1/*
2 * linux/arch/i386/mm/extable.c 2 * linux/arch/m32r/mm/extable.c
3 */ 3 */
4 4
5#include <linux/config.h>
6#include <linux/module.h> 5#include <linux/module.h>
7#include <linux/spinlock.h>
8#include <asm/uaccess.h> 6#include <asm/uaccess.h>
9 7
10int fixup_exception(struct pt_regs *regs) 8int fixup_exception(struct pt_regs *regs)
@@ -19,4 +17,3 @@ int fixup_exception(struct pt_regs *regs)
19 17
20 return 0; 18 return 0;
21} 19}
22
diff --git a/arch/m32r/oaks32r/defconfig.nommu b/arch/m32r/oaks32r/defconfig.nommu
index f2da9be726e5..3f9fe519acb2 100644
--- a/arch/m32r/oaks32r/defconfig.nommu
+++ b/arch/m32r/oaks32r/defconfig.nommu
@@ -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.11-rc4 3# Linux kernel version: 2.6.12-rc5
4# Wed Feb 16 21:11:13 2005 4# Fri Jun 3 16:22:04 2005
5# 5#
6CONFIG_M32R=y 6CONFIG_M32R=y
7# CONFIG_UID16 is not set 7# CONFIG_UID16 is not set
@@ -16,6 +16,7 @@ CONFIG_EXPERIMENTAL=y
16CONFIG_CLEAN_COMPILE=y 16CONFIG_CLEAN_COMPILE=y
17CONFIG_BROKEN_ON_SMP=y 17CONFIG_BROKEN_ON_SMP=y
18CONFIG_LOCK_KERNEL=y 18CONFIG_LOCK_KERNEL=y
19CONFIG_INIT_ENV_ARG_LIMIT=32
19 20
20# 21#
21# General setup 22# General setup
@@ -26,12 +27,14 @@ CONFIG_BSD_PROCESS_ACCT=y
26# CONFIG_BSD_PROCESS_ACCT_V3 is not set 27# CONFIG_BSD_PROCESS_ACCT_V3 is not set
27CONFIG_SYSCTL=y 28CONFIG_SYSCTL=y
28# CONFIG_AUDIT is not set 29# CONFIG_AUDIT is not set
29CONFIG_LOG_BUF_SHIFT=14
30CONFIG_HOTPLUG=y 30CONFIG_HOTPLUG=y
31CONFIG_KOBJECT_UEVENT=y 31CONFIG_KOBJECT_UEVENT=y
32# CONFIG_IKCONFIG is not set 32# CONFIG_IKCONFIG is not set
33CONFIG_EMBEDDED=y 33CONFIG_EMBEDDED=y
34# CONFIG_KALLSYMS is not set 34# CONFIG_KALLSYMS is not set
35CONFIG_PRINTK=y
36CONFIG_BUG=y
37CONFIG_BASE_FULL=y
35# CONFIG_FUTEX is not set 38# CONFIG_FUTEX is not set
36# CONFIG_EPOLL is not set 39# CONFIG_EPOLL is not set
37# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 40# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -40,6 +43,7 @@ CONFIG_CC_ALIGN_LABELS=0
40CONFIG_CC_ALIGN_LOOPS=0 43CONFIG_CC_ALIGN_LOOPS=0
41CONFIG_CC_ALIGN_JUMPS=0 44CONFIG_CC_ALIGN_JUMPS=0
42CONFIG_TINY_SHMEM=y 45CONFIG_TINY_SHMEM=y
46CONFIG_BASE_SMALL=0
43 47
44# 48#
45# Loadable module support 49# Loadable module support
@@ -61,6 +65,7 @@ CONFIG_KMOD=y
61# CONFIG_PLAT_OPSPUT is not set 65# CONFIG_PLAT_OPSPUT is not set
62CONFIG_PLAT_OAKS32R=y 66CONFIG_PLAT_OAKS32R=y
63# CONFIG_PLAT_MAPPI2 is not set 67# CONFIG_PLAT_MAPPI2 is not set
68# CONFIG_PLAT_MAPPI3 is not set
64# CONFIG_CHIP_M32700 is not set 69# CONFIG_CHIP_M32700 is not set
65CONFIG_CHIP_M32102=y 70CONFIG_CHIP_M32102=y
66# CONFIG_CHIP_VDEC2 is not set 71# CONFIG_CHIP_VDEC2 is not set
@@ -92,10 +97,6 @@ CONFIG_PREEMPT=y
92# CONFIG_PCCARD is not set 97# CONFIG_PCCARD is not set
93 98
94# 99#
95# PC-card bridges
96#
97
98#
99# PCI Hotplug Support 100# PCI Hotplug Support
100# 101#
101 102
@@ -193,7 +194,6 @@ CONFIG_NET=y
193# 194#
194CONFIG_PACKET=y 195CONFIG_PACKET=y
195# CONFIG_PACKET_MMAP is not set 196# CONFIG_PACKET_MMAP is not set
196# CONFIG_NETLINK_DEV is not set
197CONFIG_UNIX=y 197CONFIG_UNIX=y
198# CONFIG_NET_KEY is not set 198# CONFIG_NET_KEY is not set
199CONFIG_INET=y 199CONFIG_INET=y
@@ -311,18 +311,6 @@ CONFIG_INPUT=y
311# CONFIG_INPUT_EVBUG is not set 311# CONFIG_INPUT_EVBUG is not set
312 312
313# 313#
314# Input I/O drivers
315#
316# CONFIG_GAMEPORT is not set
317CONFIG_SOUND_GAMEPORT=y
318CONFIG_SERIO=y
319# CONFIG_SERIO_I8042 is not set
320CONFIG_SERIO_SERPORT=y
321# CONFIG_SERIO_CT82C710 is not set
322# CONFIG_SERIO_LIBPS2 is not set
323# CONFIG_SERIO_RAW is not set
324
325#
326# Input Device Drivers 314# Input Device Drivers
327# 315#
328# CONFIG_INPUT_KEYBOARD is not set 316# CONFIG_INPUT_KEYBOARD is not set
@@ -332,6 +320,17 @@ CONFIG_SERIO_SERPORT=y
332# CONFIG_INPUT_MISC is not set 320# CONFIG_INPUT_MISC is not set
333 321
334# 322#
323# Hardware I/O ports
324#
325CONFIG_SERIO=y
326# CONFIG_SERIO_I8042 is not set
327CONFIG_SERIO_SERPORT=y
328# CONFIG_SERIO_LIBPS2 is not set
329# CONFIG_SERIO_RAW is not set
330# CONFIG_GAMEPORT is not set
331CONFIG_SOUND_GAMEPORT=y
332
333#
335# Character devices 334# Character devices
336# 335#
337# CONFIG_VT is not set 336# CONFIG_VT is not set
@@ -375,6 +374,10 @@ CONFIG_LEGACY_PTY_COUNT=256
375# CONFIG_RAW_DRIVER is not set 374# CONFIG_RAW_DRIVER is not set
376 375
377# 376#
377# TPM devices
378#
379
380#
378# I2C support 381# I2C support
379# 382#
380# CONFIG_I2C is not set 383# CONFIG_I2C is not set
@@ -415,10 +418,6 @@ CONFIG_LEGACY_PTY_COUNT=256
415# CONFIG_USB_ARCH_HAS_OHCI is not set 418# CONFIG_USB_ARCH_HAS_OHCI is not set
416 419
417# 420#
418# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
419#
420
421#
422# USB Gadget Support 421# USB Gadget Support
423# 422#
424# CONFIG_USB_GADGET is not set 423# CONFIG_USB_GADGET is not set
@@ -574,8 +573,9 @@ CONFIG_NLS_DEFAULT="iso8859-1"
574# 573#
575# Kernel hacking 574# Kernel hacking
576# 575#
576# CONFIG_PRINTK_TIME is not set
577# CONFIG_DEBUG_KERNEL is not set 577# CONFIG_DEBUG_KERNEL is not set
578CONFIG_DEBUG_PREEMPT=y 578CONFIG_LOG_BUF_SHIFT=14
579# CONFIG_DEBUG_BUGVERBOSE is not set 579# CONFIG_DEBUG_BUGVERBOSE is not set
580# CONFIG_FRAME_POINTER is not set 580# CONFIG_FRAME_POINTER is not set
581 581
diff --git a/arch/m32r/opsput/defconfig.opsput b/arch/m32r/opsput/defconfig.opsput
index a87e1ea4c301..66adec6a701a 100644
--- a/arch/m32r/opsput/defconfig.opsput
+++ b/arch/m32r/opsput/defconfig.opsput
@@ -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.11-rc4 3# Linux kernel version: 2.6.12-rc5
4# Wed Feb 16 21:11:41 2005 4# Fri Jun 3 16:22:06 2005
5# 5#
6CONFIG_M32R=y 6CONFIG_M32R=y
7# CONFIG_UID16 is not set 7# CONFIG_UID16 is not set
@@ -15,6 +15,7 @@ CONFIG_GENERIC_IRQ_PROBE=y
15CONFIG_EXPERIMENTAL=y 15CONFIG_EXPERIMENTAL=y
16CONFIG_CLEAN_COMPILE=y 16CONFIG_CLEAN_COMPILE=y
17CONFIG_BROKEN_ON_SMP=y 17CONFIG_BROKEN_ON_SMP=y
18CONFIG_INIT_ENV_ARG_LIMIT=32
18 19
19# 20#
20# General setup 21# General setup
@@ -27,13 +28,15 @@ CONFIG_BSD_PROCESS_ACCT=y
27# CONFIG_BSD_PROCESS_ACCT_V3 is not set 28# CONFIG_BSD_PROCESS_ACCT_V3 is not set
28CONFIG_SYSCTL=y 29CONFIG_SYSCTL=y
29# CONFIG_AUDIT is not set 30# CONFIG_AUDIT is not set
30CONFIG_LOG_BUF_SHIFT=14
31CONFIG_HOTPLUG=y 31CONFIG_HOTPLUG=y
32CONFIG_KOBJECT_UEVENT=y 32CONFIG_KOBJECT_UEVENT=y
33CONFIG_IKCONFIG=y 33CONFIG_IKCONFIG=y
34# CONFIG_IKCONFIG_PROC is not set 34# CONFIG_IKCONFIG_PROC is not set
35CONFIG_EMBEDDED=y 35CONFIG_EMBEDDED=y
36# CONFIG_KALLSYMS is not set 36# CONFIG_KALLSYMS is not set
37CONFIG_PRINTK=y
38CONFIG_BUG=y
39CONFIG_BASE_FULL=y
37# CONFIG_FUTEX is not set 40# CONFIG_FUTEX is not set
38# CONFIG_EPOLL is not set 41# CONFIG_EPOLL is not set
39# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 42# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -43,6 +46,7 @@ CONFIG_CC_ALIGN_LABELS=0
43CONFIG_CC_ALIGN_LOOPS=0 46CONFIG_CC_ALIGN_LOOPS=0
44CONFIG_CC_ALIGN_JUMPS=0 47CONFIG_CC_ALIGN_JUMPS=0
45# CONFIG_TINY_SHMEM is not set 48# CONFIG_TINY_SHMEM is not set
49CONFIG_BASE_SMALL=0
46 50
47# 51#
48# Loadable module support 52# Loadable module support
@@ -64,6 +68,7 @@ CONFIG_KMOD=y
64CONFIG_PLAT_OPSPUT=y 68CONFIG_PLAT_OPSPUT=y
65# CONFIG_PLAT_OAKS32R is not set 69# CONFIG_PLAT_OAKS32R is not set
66# CONFIG_PLAT_MAPPI2 is not set 70# CONFIG_PLAT_MAPPI2 is not set
71# CONFIG_PLAT_MAPPI3 is not set
67# CONFIG_CHIP_M32700 is not set 72# CONFIG_CHIP_M32700 is not set
68# CONFIG_CHIP_M32102 is not set 73# CONFIG_CHIP_M32102 is not set
69# CONFIG_CHIP_VDEC2 is not set 74# CONFIG_CHIP_VDEC2 is not set
@@ -243,7 +248,6 @@ CONFIG_NET=y
243# 248#
244CONFIG_PACKET=y 249CONFIG_PACKET=y
245# CONFIG_PACKET_MMAP is not set 250# CONFIG_PACKET_MMAP is not set
246# CONFIG_NETLINK_DEV is not set
247CONFIG_UNIX=y 251CONFIG_UNIX=y
248# CONFIG_NET_KEY is not set 252# CONFIG_NET_KEY is not set
249CONFIG_INET=y 253CONFIG_INET=y
@@ -368,18 +372,6 @@ CONFIG_INPUT=y
368# CONFIG_INPUT_EVBUG is not set 372# CONFIG_INPUT_EVBUG is not set
369 373
370# 374#
371# Input I/O drivers
372#
373# CONFIG_GAMEPORT is not set
374CONFIG_SOUND_GAMEPORT=y
375CONFIG_SERIO=y
376# CONFIG_SERIO_I8042 is not set
377CONFIG_SERIO_SERPORT=y
378# CONFIG_SERIO_CT82C710 is not set
379# CONFIG_SERIO_LIBPS2 is not set
380# CONFIG_SERIO_RAW is not set
381
382#
383# Input Device Drivers 375# Input Device Drivers
384# 376#
385# CONFIG_INPUT_KEYBOARD is not set 377# CONFIG_INPUT_KEYBOARD is not set
@@ -389,6 +381,17 @@ CONFIG_SERIO_SERPORT=y
389# CONFIG_INPUT_MISC is not set 381# CONFIG_INPUT_MISC is not set
390 382
391# 383#
384# Hardware I/O ports
385#
386CONFIG_SERIO=y
387# CONFIG_SERIO_I8042 is not set
388CONFIG_SERIO_SERPORT=y
389# CONFIG_SERIO_LIBPS2 is not set
390# CONFIG_SERIO_RAW is not set
391# CONFIG_GAMEPORT is not set
392CONFIG_SOUND_GAMEPORT=y
393
394#
392# Character devices 395# Character devices
393# 396#
394# CONFIG_VT is not set 397# CONFIG_VT is not set
@@ -438,6 +441,10 @@ CONFIG_DS1302=y
438# CONFIG_RAW_DRIVER is not set 441# CONFIG_RAW_DRIVER is not set
439 442
440# 443#
444# TPM devices
445#
446
447#
441# I2C support 448# I2C support
442# 449#
443# CONFIG_I2C is not set 450# CONFIG_I2C is not set
@@ -478,10 +485,6 @@ CONFIG_DS1302=y
478# CONFIG_USB_ARCH_HAS_OHCI is not set 485# CONFIG_USB_ARCH_HAS_OHCI is not set
479 486
480# 487#
481# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
482#
483
484#
485# USB Gadget Support 488# USB Gadget Support
486# 489#
487# CONFIG_USB_GADGET is not set 490# CONFIG_USB_GADGET is not set
@@ -654,8 +657,10 @@ CONFIG_NLS_DEFAULT="iso8859-1"
654# 657#
655# Kernel hacking 658# Kernel hacking
656# 659#
660# CONFIG_PRINTK_TIME is not set
657CONFIG_DEBUG_KERNEL=y 661CONFIG_DEBUG_KERNEL=y
658# CONFIG_MAGIC_SYSRQ is not set 662# CONFIG_MAGIC_SYSRQ is not set
663CONFIG_LOG_BUF_SHIFT=14
659# CONFIG_SCHEDSTATS is not set 664# CONFIG_SCHEDSTATS is not set
660# CONFIG_DEBUG_SLAB is not set 665# CONFIG_DEBUG_SLAB is not set
661# CONFIG_DEBUG_SPINLOCK is not set 666# CONFIG_DEBUG_SPINLOCK is not set
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index b027ce7efbc6..73843c528778 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -232,7 +232,6 @@ void __init mem_init(void)
232#ifdef CONFIG_LIMITED_DMA 232#ifdef CONFIG_LIMITED_DMA
233 set_page_address(page, lowmem_page_address(page)); 233 set_page_address(page, lowmem_page_address(page));
234#endif 234#endif
235 set_bit(PG_highmem, &page->flags);
236 set_page_count(page, 1); 235 set_page_count(page, 1);
237 __free_page(page); 236 __free_page(page);
238 totalhigh_pages++; 237 totalhigh_pages++;
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index 54ce6da22644..10162b187bcf 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -826,11 +826,6 @@ config MPC10X_BRIDGE
826 depends on PCORE || POWERPMC250 || LOPEC || SANDPOINT 826 depends on PCORE || POWERPMC250 || LOPEC || SANDPOINT
827 default y 827 default y
828 828
829config FSL_OCP
830 bool
831 depends on MPC10X_BRIDGE
832 default y
833
834config MPC10X_OPENPIC 829config MPC10X_OPENPIC
835 bool 830 bool
836 depends on POWERPMC250 || LOPEC || SANDPOINT 831 depends on POWERPMC250 || LOPEC || SANDPOINT
diff --git a/arch/ppc/boot/ld.script b/arch/ppc/boot/ld.script
index 6ee602d8b6a0..9362193742ac 100644
--- a/arch/ppc/boot/ld.script
+++ b/arch/ppc/boot/ld.script
@@ -58,9 +58,6 @@ SECTIONS
58 *(.ramdisk) 58 *(.ramdisk)
59 __ramdisk_end = .; 59 __ramdisk_end = .;
60 . = ALIGN(4096); 60 . = ALIGN(4096);
61 __sysmap_begin = .;
62 *(.sysmap)
63 __sysmap_end = .;
64 CONSTRUCTORS 61 CONSTRUCTORS
65 } 62 }
66 _edata = .; 63 _edata = .;
diff --git a/arch/ppc/boot/openfirmware/Makefile b/arch/ppc/boot/openfirmware/Makefile
index 4eacbd8c772a..03415238fabf 100644
--- a/arch/ppc/boot/openfirmware/Makefile
+++ b/arch/ppc/boot/openfirmware/Makefile
@@ -54,13 +54,10 @@ $(images)/ramdisk.image.gz:
54 @echo ' RAM disk image must be provided separately' 54 @echo ' RAM disk image must be provided separately'
55 @/bin/false 55 @/bin/false
56 56
57objcpxmon-$(CONFIG_XMON) := --add-section=.sysmap=System.map \
58 --set-section-flags=.sysmap=contents,alloc,load,readonly,data
59quiet_cmd_genimage = GEN $@ 57quiet_cmd_genimage = GEN $@
60 cmd_genimage = $(OBJCOPY) -R .comment \ 58 cmd_genimage = $(OBJCOPY) -R .comment \
61 --add-section=.image=$(images)/vmlinux.gz \ 59 --add-section=.image=$(images)/vmlinux.gz \
62 --set-section-flags=.image=contents,alloc,load,readonly,data \ 60 --set-section-flags=.image=contents,alloc,load,readonly,data $< $@
63 $(objcpxmon-y) $< $@
64 61
65targets += image.o 62targets += image.o
66$(obj)/image.o: $(obj)/dummy.o $(images)/vmlinux.gz FORCE 63$(obj)/image.o: $(obj)/dummy.o $(images)/vmlinux.gz FORCE
diff --git a/arch/ppc/boot/openfirmware/common.c b/arch/ppc/boot/openfirmware/common.c
index 9e6952781f1f..0f46756a903e 100644
--- a/arch/ppc/boot/openfirmware/common.c
+++ b/arch/ppc/boot/openfirmware/common.c
@@ -15,7 +15,6 @@
15#include <asm/page.h> 15#include <asm/page.h>
16 16
17/* Information from the linker */ 17/* Information from the linker */
18extern char __sysmap_begin, __sysmap_end;
19 18
20extern int strcmp(const char *s1, const char *s2); 19extern int strcmp(const char *s1, const char *s2);
21extern char *avail_ram, *avail_high; 20extern char *avail_ram, *avail_high;
@@ -116,14 +115,8 @@ void gunzip(void *dst, int dstlen, unsigned char *src, int *lenp)
116void make_bi_recs(unsigned long addr, char *name, unsigned int mach, 115void make_bi_recs(unsigned long addr, char *name, unsigned int mach,
117 unsigned long progend) 116 unsigned long progend)
118{ 117{
119 unsigned long sysmap_size;
120 struct bi_record *rec; 118 struct bi_record *rec;
121 119
122 /* Figure out the size of a possible System.map we're going to
123 * pass along.
124 * */
125 sysmap_size = (unsigned long)(&__sysmap_end) -
126 (unsigned long)(&__sysmap_begin);
127 120
128 /* leave a 1MB gap then align to the next 1MB boundary */ 121 /* leave a 1MB gap then align to the next 1MB boundary */
129 addr = _ALIGN(addr+ (1<<20) - 1, (1<<20)); 122 addr = _ALIGN(addr+ (1<<20) - 1, (1<<20));
@@ -147,15 +140,6 @@ void make_bi_recs(unsigned long addr, char *name, unsigned int mach,
147 rec->size = sizeof(struct bi_record) + 2 * sizeof(unsigned long); 140 rec->size = sizeof(struct bi_record) + 2 * sizeof(unsigned long);
148 rec = (struct bi_record *)((unsigned long)rec + rec->size); 141 rec = (struct bi_record *)((unsigned long)rec + rec->size);
149 142
150 if (sysmap_size) {
151 rec->tag = BI_SYSMAP;
152 rec->data[0] = (unsigned long)(&__sysmap_begin);
153 rec->data[1] = sysmap_size;
154 rec->size = sizeof(struct bi_record) + 2 *
155 sizeof(unsigned long);
156 rec = (struct bi_record *)((unsigned long)rec + rec->size);
157 }
158
159 rec->tag = BI_LAST; 143 rec->tag = BI_LAST;
160 rec->size = sizeof(struct bi_record); 144 rec->size = sizeof(struct bi_record);
161 rec = (struct bi_record *)((unsigned long)rec + rec->size); 145 rec = (struct bi_record *)((unsigned long)rec + rec->size);
diff --git a/arch/ppc/boot/simple/Makefile b/arch/ppc/boot/simple/Makefile
index c28061ad5982..991b4cbb83c8 100644
--- a/arch/ppc/boot/simple/Makefile
+++ b/arch/ppc/boot/simple/Makefile
@@ -203,7 +203,7 @@ $(obj)/zvmlinux: $(OBJS) $(LIBS) $(srctree)/$(boot)/ld.script \
203 $(obj)/dummy.o $(obj)/image.o 203 $(obj)/dummy.o $(obj)/image.o
204 $(LD) $(LD_ARGS) -o $@ $(OBJS) $(obj)/image.o $(LIBS) 204 $(LD) $(LD_ARGS) -o $@ $(OBJS) $(obj)/image.o $(LIBS)
205 $(OBJCOPY) $(OBJCOPY_ARGS) $@ $@ -R .comment -R .stab \ 205 $(OBJCOPY) $(OBJCOPY_ARGS) $@ $@ -R .comment -R .stab \
206 -R .stabstr -R .ramdisk -R .sysmap 206 -R .stabstr -R .ramdisk
207 207
208$(obj)/zvmlinux.initrd: $(OBJS) $(LIBS) $(srctree)/$(boot)/ld.script \ 208$(obj)/zvmlinux.initrd: $(OBJS) $(LIBS) $(srctree)/$(boot)/ld.script \
209 $(images)/vmlinux.gz $(obj)/dummy.o 209 $(images)/vmlinux.gz $(obj)/dummy.o
@@ -215,7 +215,7 @@ $(obj)/zvmlinux.initrd: $(OBJS) $(LIBS) $(srctree)/$(boot)/ld.script \
215 $(obj)/dummy.o $(obj)/image.o 215 $(obj)/dummy.o $(obj)/image.o
216 $(LD) $(LD_ARGS) -o $@ $(OBJS) $(obj)/image.o $(LIBS) 216 $(LD) $(LD_ARGS) -o $@ $(OBJS) $(obj)/image.o $(LIBS)
217 $(OBJCOPY) $(OBJCOPY_ARGS) $@ $@ -R .comment -R .stab \ 217 $(OBJCOPY) $(OBJCOPY_ARGS) $@ $@ -R .comment -R .stab \
218 -R .stabstr -R .sysmap 218 -R .stabstr
219 219
220# Sort-of dummy rules, that let us format the image we want. 220# Sort-of dummy rules, that let us format the image we want.
221zImage: $(images)/$(zimage-y) $(obj)/zvmlinux 221zImage: $(images)/$(zimage-y) $(obj)/zvmlinux
diff --git a/arch/ppc/boot/utils/addSystemMap.c b/arch/ppc/boot/utils/addSystemMap.c
deleted file mode 100644
index 4654f891b274..000000000000
--- a/arch/ppc/boot/utils/addSystemMap.c
+++ /dev/null
@@ -1,186 +0,0 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <byteswap.h>
4#include <sys/types.h>
5#include <sys/stat.h>
6
7void xlate( char * inb, char * trb, unsigned len )
8{
9 unsigned i;
10 for ( i=0; i<len; ++i ) {
11 char c = *inb++;
12 char c1 = c >> 4;
13 char c2 = c & 0xf;
14 if ( c1 > 9 )
15 c1 = c1 + 'A' - 10;
16 else
17 c1 = c1 + '0';
18 if ( c2 > 9 )
19 c2 = c2 + 'A' - 10;
20 else
21 c2 = c2 + '0';
22 *trb++ = c1;
23 *trb++ = c2;
24 }
25 *trb = 0;
26}
27
28#define ElfHeaderSize (64 * 1024)
29#define ElfPages (ElfHeaderSize / 4096)
30#define KERNELBASE (0xc0000000)
31
32void get4k( /*istream *inf*/FILE *file, char *buf )
33{
34 unsigned j;
35 unsigned num = fread(buf, 1, 4096, file);
36 for ( j=num; j<4096; ++j )
37 buf[j] = 0;
38}
39
40void put4k( /*ostream *outf*/FILE *file, char *buf )
41{
42 fwrite(buf, 1, 4096, file);
43}
44
45int main(int argc, char **argv)
46{
47 char inbuf[4096];
48 FILE *ramDisk = NULL;
49 FILE *inputVmlinux = NULL;
50 FILE *outputVmlinux = NULL;
51 unsigned i = 0;
52 unsigned long ramFileLen = 0;
53 unsigned long ramLen = 0;
54 unsigned long roundR = 0;
55 unsigned long kernelLen = 0;
56 unsigned long actualKernelLen = 0;
57 unsigned long round = 0;
58 unsigned long roundedKernelLen = 0;
59 unsigned long ramStartOffs = 0;
60 unsigned long ramPages = 0;
61 unsigned long roundedKernelPages = 0;
62 if ( argc < 2 ) {
63 printf("Name of System Map file missing.\n");
64 exit(1);
65 }
66
67 if ( argc < 3 ) {
68 printf("Name of vmlinux file missing.\n");
69 exit(1);
70 }
71
72 if ( argc < 4 ) {
73 printf("Name of vmlinux output file missing.\n");
74 exit(1);
75 }
76
77 ramDisk = fopen(argv[1], "r");
78 if ( ! ramDisk ) {
79 printf("System Map file \"%s\" failed to open.\n", argv[1]);
80 exit(1);
81 }
82 inputVmlinux = fopen(argv[2], "r");
83 if ( ! inputVmlinux ) {
84 printf("vmlinux file \"%s\" failed to open.\n", argv[2]);
85 exit(1);
86 }
87 outputVmlinux = fopen(argv[3], "w");
88 if ( ! outputVmlinux ) {
89 printf("output vmlinux file \"%s\" failed to open.\n", argv[3]);
90 exit(1);
91 }
92 fseek(ramDisk, 0, SEEK_END);
93 ramFileLen = ftell(ramDisk);
94 fseek(ramDisk, 0, SEEK_SET);
95 printf("%s file size = %ld\n", argv[1], ramFileLen);
96
97 ramLen = ramFileLen;
98
99 roundR = 4096 - (ramLen % 4096);
100 if ( roundR ) {
101 printf("Rounding System Map file up to a multiple of 4096, adding %ld\n", roundR);
102 ramLen += roundR;
103 }
104
105 printf("Rounded System Map size is %ld\n", ramLen);
106 fseek(inputVmlinux, 0, SEEK_END);
107 kernelLen = ftell(inputVmlinux);
108 fseek(inputVmlinux, 0, SEEK_SET);
109 printf("kernel file size = %ld\n", kernelLen);
110 if ( kernelLen == 0 ) {
111 printf("You must have a linux kernel specified as argv[2]\n");
112 exit(1);
113 }
114
115 actualKernelLen = kernelLen - ElfHeaderSize;
116
117 printf("actual kernel length (minus ELF header) = %ld\n", actualKernelLen);
118
119 round = actualKernelLen % 4096;
120 roundedKernelLen = actualKernelLen;
121 if ( round )
122 roundedKernelLen += (4096 - round);
123
124 printf("actual kernel length rounded up to a 4k multiple = %ld\n", roundedKernelLen);
125
126 ramStartOffs = roundedKernelLen;
127 ramPages = ramLen / 4096;
128
129 printf("System map pages to copy = %ld\n", ramPages);
130
131 // Copy 64K ELF header
132 for (i=0; i<(ElfPages); ++i) {
133 get4k( inputVmlinux, inbuf );
134 put4k( outputVmlinux, inbuf );
135 }
136
137
138
139 roundedKernelPages = roundedKernelLen / 4096;
140
141 fseek(inputVmlinux, ElfHeaderSize, SEEK_SET);
142
143 {
144 for ( i=0; i<roundedKernelPages; ++i ) {
145 get4k( inputVmlinux, inbuf );
146 if ( i == 0 ) {
147 unsigned long * p;
148 printf("Storing embedded_sysmap_start at 0x3c\n");
149 p = (unsigned long *)(inbuf + 0x3c);
150
151#if (BYTE_ORDER == __BIG_ENDIAN)
152 *p = ramStartOffs;
153#else
154 *p = bswap_32(ramStartOffs);
155#endif
156
157 printf("Storing embedded_sysmap_end at 0x44\n");
158 p = (unsigned long *)(inbuf + 0x44);
159#if (BYTE_ORDER == __BIG_ENDIAN)
160 *p = ramStartOffs + ramFileLen;
161#else
162 *p = bswap_32(ramStartOffs + ramFileLen);
163#endif
164 }
165 put4k( outputVmlinux, inbuf );
166 }
167 }
168
169 {
170 for ( i=0; i<ramPages; ++i ) {
171 get4k( ramDisk, inbuf );
172 put4k( outputVmlinux, inbuf );
173 }
174 }
175
176
177 fclose(ramDisk);
178 fclose(inputVmlinux);
179 fclose(outputVmlinux);
180 /* Set permission to executable */
181 chmod(argv[3], S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH);
182
183 return 0;
184
185}
186
diff --git a/arch/ppc/configs/mpc8548_cds_defconfig b/arch/ppc/configs/mpc8548_cds_defconfig
new file mode 100644
index 000000000000..abe034f24b83
--- /dev/null
+++ b/arch/ppc/configs/mpc8548_cds_defconfig
@@ -0,0 +1,659 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.12-rc4
4# Tue May 24 22:36:27 2005
5#
6CONFIG_MMU=y
7CONFIG_GENERIC_HARDIRQS=y
8CONFIG_RWSEM_XCHGADD_ALGORITHM=y
9CONFIG_GENERIC_CALIBRATE_DELAY=y
10CONFIG_HAVE_DEC_LOCK=y
11CONFIG_PPC=y
12CONFIG_PPC32=y
13CONFIG_GENERIC_NVRAM=y
14CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
15
16#
17# Code maturity level options
18#
19CONFIG_EXPERIMENTAL=y
20CONFIG_CLEAN_COMPILE=y
21CONFIG_BROKEN_ON_SMP=y
22CONFIG_INIT_ENV_ARG_LIMIT=32
23
24#
25# General setup
26#
27CONFIG_LOCALVERSION=""
28CONFIG_SWAP=y
29CONFIG_SYSVIPC=y
30# CONFIG_POSIX_MQUEUE is not set
31# CONFIG_BSD_PROCESS_ACCT is not set
32CONFIG_SYSCTL=y
33# CONFIG_AUDIT is not set
34# CONFIG_HOTPLUG is not set
35CONFIG_KOBJECT_UEVENT=y
36# CONFIG_IKCONFIG is not set
37CONFIG_EMBEDDED=y
38# CONFIG_KALLSYMS is not set
39CONFIG_PRINTK=y
40CONFIG_BUG=y
41CONFIG_BASE_FULL=y
42CONFIG_FUTEX=y
43# CONFIG_EPOLL is not set
44# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
45CONFIG_SHMEM=y
46CONFIG_CC_ALIGN_FUNCTIONS=0
47CONFIG_CC_ALIGN_LABELS=0
48CONFIG_CC_ALIGN_LOOPS=0
49CONFIG_CC_ALIGN_JUMPS=0
50# CONFIG_TINY_SHMEM is not set
51CONFIG_BASE_SMALL=0
52
53#
54# Loadable module support
55#
56# CONFIG_MODULES is not set
57
58#
59# Processor
60#
61# CONFIG_6xx is not set
62# CONFIG_40x is not set
63# CONFIG_44x is not set
64# CONFIG_POWER3 is not set
65# CONFIG_POWER4 is not set
66# CONFIG_8xx is not set
67CONFIG_E500=y
68CONFIG_BOOKE=y
69CONFIG_FSL_BOOKE=y
70# CONFIG_PHYS_64BIT is not set
71CONFIG_SPE=y
72CONFIG_MATH_EMULATION=y
73# CONFIG_CPU_FREQ is not set
74# CONFIG_PM is not set
75CONFIG_85xx=y
76CONFIG_PPC_INDIRECT_PCI_BE=y
77
78#
79# Freescale 85xx options
80#
81# CONFIG_MPC8540_ADS is not set
82CONFIG_MPC8548_CDS=y
83# CONFIG_MPC8555_CDS is not set
84# CONFIG_MPC8560_ADS is not set
85# CONFIG_SBC8560 is not set
86# CONFIG_STX_GP3 is not set
87CONFIG_MPC8548=y
88
89#
90# Platform options
91#
92# CONFIG_SMP is not set
93# CONFIG_PREEMPT is not set
94# CONFIG_HIGHMEM is not set
95CONFIG_BINFMT_ELF=y
96# CONFIG_BINFMT_MISC is not set
97# CONFIG_CMDLINE_BOOL is not set
98CONFIG_ISA_DMA_API=y
99
100#
101# Bus options
102#
103# CONFIG_PCI is not set
104# CONFIG_PCI_DOMAINS is not set
105
106#
107# PCCARD (PCMCIA/CardBus) support
108#
109# CONFIG_PCCARD is not set
110
111#
112# Advanced setup
113#
114# CONFIG_ADVANCED_OPTIONS is not set
115
116#
117# Default settings for advanced configuration options are used
118#
119CONFIG_HIGHMEM_START=0xfe000000
120CONFIG_LOWMEM_SIZE=0x30000000
121CONFIG_KERNEL_START=0xc0000000
122CONFIG_TASK_SIZE=0x80000000
123CONFIG_BOOT_LOAD=0x00800000
124
125#
126# Device Drivers
127#
128
129#
130# Generic Driver Options
131#
132CONFIG_STANDALONE=y
133CONFIG_PREVENT_FIRMWARE_BUILD=y
134# CONFIG_FW_LOADER is not set
135
136#
137# Memory Technology Devices (MTD)
138#
139# CONFIG_MTD is not set
140
141#
142# Parallel port support
143#
144# CONFIG_PARPORT is not set
145
146#
147# Plug and Play support
148#
149
150#
151# Block devices
152#
153# CONFIG_BLK_DEV_FD is not set
154# CONFIG_BLK_DEV_COW_COMMON is not set
155CONFIG_BLK_DEV_LOOP=y
156# CONFIG_BLK_DEV_CRYPTOLOOP is not set
157# CONFIG_BLK_DEV_NBD is not set
158CONFIG_BLK_DEV_RAM=y
159CONFIG_BLK_DEV_RAM_COUNT=16
160CONFIG_BLK_DEV_RAM_SIZE=32768
161CONFIG_BLK_DEV_INITRD=y
162CONFIG_INITRAMFS_SOURCE=""
163# CONFIG_LBD is not set
164# CONFIG_CDROM_PKTCDVD is not set
165
166#
167# IO Schedulers
168#
169CONFIG_IOSCHED_NOOP=y
170CONFIG_IOSCHED_AS=y
171CONFIG_IOSCHED_DEADLINE=y
172CONFIG_IOSCHED_CFQ=y
173# CONFIG_ATA_OVER_ETH is not set
174
175#
176# ATA/ATAPI/MFM/RLL support
177#
178# CONFIG_IDE is not set
179
180#
181# SCSI device support
182#
183# CONFIG_SCSI is not set
184
185#
186# Multi-device support (RAID and LVM)
187#
188# CONFIG_MD is not set
189
190#
191# Fusion MPT device support
192#
193
194#
195# IEEE 1394 (FireWire) support
196#
197
198#
199# I2O device support
200#
201
202#
203# Macintosh device drivers
204#
205
206#
207# Networking support
208#
209CONFIG_NET=y
210
211#
212# Networking options
213#
214CONFIG_PACKET=y
215# CONFIG_PACKET_MMAP is not set
216CONFIG_UNIX=y
217# CONFIG_NET_KEY is not set
218CONFIG_INET=y
219CONFIG_IP_MULTICAST=y
220# CONFIG_IP_ADVANCED_ROUTER is not set
221CONFIG_IP_PNP=y
222CONFIG_IP_PNP_DHCP=y
223CONFIG_IP_PNP_BOOTP=y
224# CONFIG_IP_PNP_RARP is not set
225# CONFIG_NET_IPIP is not set
226# CONFIG_NET_IPGRE is not set
227# CONFIG_IP_MROUTE is not set
228# CONFIG_ARPD is not set
229CONFIG_SYN_COOKIES=y
230# CONFIG_INET_AH is not set
231# CONFIG_INET_ESP is not set
232# CONFIG_INET_IPCOMP is not set
233# CONFIG_INET_TUNNEL is not set
234CONFIG_IP_TCPDIAG=y
235# CONFIG_IP_TCPDIAG_IPV6 is not set
236# CONFIG_IPV6 is not set
237# CONFIG_NETFILTER is not set
238
239#
240# SCTP Configuration (EXPERIMENTAL)
241#
242# CONFIG_IP_SCTP is not set
243# CONFIG_ATM is not set
244# CONFIG_BRIDGE is not set
245# CONFIG_VLAN_8021Q is not set
246# CONFIG_DECNET is not set
247# CONFIG_LLC2 is not set
248# CONFIG_IPX is not set
249# CONFIG_ATALK is not set
250# CONFIG_X25 is not set
251# CONFIG_LAPB is not set
252# CONFIG_NET_DIVERT is not set
253# CONFIG_ECONET is not set
254# CONFIG_WAN_ROUTER is not set
255
256#
257# QoS and/or fair queueing
258#
259# CONFIG_NET_SCHED is not set
260# CONFIG_NET_CLS_ROUTE is not set
261
262#
263# Network testing
264#
265# CONFIG_NET_PKTGEN is not set
266# CONFIG_NETPOLL is not set
267# CONFIG_NET_POLL_CONTROLLER is not set
268# CONFIG_HAMRADIO is not set
269# CONFIG_IRDA is not set
270# CONFIG_BT is not set
271CONFIG_NETDEVICES=y
272# CONFIG_DUMMY is not set
273# CONFIG_BONDING is not set
274# CONFIG_EQUALIZER is not set
275# CONFIG_TUN is not set
276
277#
278# Ethernet (10 or 100Mbit)
279#
280CONFIG_NET_ETHERNET=y
281CONFIG_MII=y
282
283#
284# Ethernet (1000 Mbit)
285#
286CONFIG_GIANFAR=y
287CONFIG_GFAR_NAPI=y
288
289#
290# Ethernet (10000 Mbit)
291#
292
293#
294# Token Ring devices
295#
296
297#
298# Wireless LAN (non-hamradio)
299#
300# CONFIG_NET_RADIO is not set
301
302#
303# Wan interfaces
304#
305# CONFIG_WAN is not set
306# CONFIG_PPP is not set
307# CONFIG_SLIP is not set
308# CONFIG_SHAPER is not set
309# CONFIG_NETCONSOLE is not set
310
311#
312# ISDN subsystem
313#
314# CONFIG_ISDN is not set
315
316#
317# Telephony Support
318#
319# CONFIG_PHONE is not set
320
321#
322# Input device support
323#
324CONFIG_INPUT=y
325
326#
327# Userland interfaces
328#
329# CONFIG_INPUT_MOUSEDEV is not set
330# CONFIG_INPUT_JOYDEV is not set
331# CONFIG_INPUT_TSDEV is not set
332# CONFIG_INPUT_EVDEV is not set
333# CONFIG_INPUT_EVBUG is not set
334
335#
336# Input Device Drivers
337#
338# CONFIG_INPUT_KEYBOARD is not set
339# CONFIG_INPUT_MOUSE is not set
340# CONFIG_INPUT_JOYSTICK is not set
341# CONFIG_INPUT_TOUCHSCREEN is not set
342# CONFIG_INPUT_MISC is not set
343
344#
345# Hardware I/O ports
346#
347# CONFIG_SERIO is not set
348# CONFIG_GAMEPORT is not set
349CONFIG_SOUND_GAMEPORT=y
350
351#
352# Character devices
353#
354# CONFIG_VT is not set
355# CONFIG_SERIAL_NONSTANDARD is not set
356
357#
358# Serial drivers
359#
360CONFIG_SERIAL_8250=y
361CONFIG_SERIAL_8250_CONSOLE=y
362CONFIG_SERIAL_8250_NR_UARTS=4
363# CONFIG_SERIAL_8250_EXTENDED is not set
364
365#
366# Non-8250 serial port support
367#
368CONFIG_SERIAL_CORE=y
369CONFIG_SERIAL_CORE_CONSOLE=y
370CONFIG_UNIX98_PTYS=y
371CONFIG_LEGACY_PTYS=y
372CONFIG_LEGACY_PTY_COUNT=256
373
374#
375# IPMI
376#
377# CONFIG_IPMI_HANDLER is not set
378
379#
380# Watchdog Cards
381#
382# CONFIG_WATCHDOG is not set
383# CONFIG_NVRAM is not set
384CONFIG_GEN_RTC=y
385# CONFIG_GEN_RTC_X is not set
386# CONFIG_DTLK is not set
387# CONFIG_R3964 is not set
388
389#
390# Ftape, the floppy tape device driver
391#
392# CONFIG_AGP is not set
393# CONFIG_DRM is not set
394# CONFIG_RAW_DRIVER is not set
395
396#
397# TPM devices
398#
399
400#
401# I2C support
402#
403CONFIG_I2C=y
404CONFIG_I2C_CHARDEV=y
405
406#
407# I2C Algorithms
408#
409# CONFIG_I2C_ALGOBIT is not set
410# CONFIG_I2C_ALGOPCF is not set
411# CONFIG_I2C_ALGOPCA is not set
412
413#
414# I2C Hardware Bus support
415#
416# CONFIG_I2C_ISA is not set
417CONFIG_I2C_MPC=y
418# CONFIG_I2C_PARPORT_LIGHT is not set
419# CONFIG_I2C_PCA_ISA is not set
420
421#
422# Hardware Sensors Chip support
423#
424# CONFIG_I2C_SENSOR is not set
425# CONFIG_SENSORS_ADM1021 is not set
426# CONFIG_SENSORS_ADM1025 is not set
427# CONFIG_SENSORS_ADM1026 is not set
428# CONFIG_SENSORS_ADM1031 is not set
429# CONFIG_SENSORS_ASB100 is not set
430# CONFIG_SENSORS_DS1621 is not set
431# CONFIG_SENSORS_FSCHER is not set
432# CONFIG_SENSORS_FSCPOS is not set
433# CONFIG_SENSORS_GL518SM is not set
434# CONFIG_SENSORS_GL520SM is not set
435# CONFIG_SENSORS_IT87 is not set
436# CONFIG_SENSORS_LM63 is not set
437# CONFIG_SENSORS_LM75 is not set
438# CONFIG_SENSORS_LM77 is not set
439# CONFIG_SENSORS_LM78 is not set
440# CONFIG_SENSORS_LM80 is not set
441# CONFIG_SENSORS_LM83 is not set
442# CONFIG_SENSORS_LM85 is not set
443# CONFIG_SENSORS_LM87 is not set
444# CONFIG_SENSORS_LM90 is not set
445# CONFIG_SENSORS_LM92 is not set
446# CONFIG_SENSORS_MAX1619 is not set
447# CONFIG_SENSORS_PC87360 is not set
448# CONFIG_SENSORS_SMSC47B397 is not set
449# CONFIG_SENSORS_SMSC47M1 is not set
450# CONFIG_SENSORS_W83781D is not set
451# CONFIG_SENSORS_W83L785TS is not set
452# CONFIG_SENSORS_W83627HF is not set
453
454#
455# Other I2C Chip support
456#
457# CONFIG_SENSORS_DS1337 is not set
458# CONFIG_SENSORS_EEPROM is not set
459# CONFIG_SENSORS_PCF8574 is not set
460# CONFIG_SENSORS_PCF8591 is not set
461# CONFIG_SENSORS_RTC8564 is not set
462# CONFIG_SENSORS_M41T00 is not set
463# CONFIG_I2C_DEBUG_CORE is not set
464# CONFIG_I2C_DEBUG_ALGO is not set
465# CONFIG_I2C_DEBUG_BUS is not set
466# CONFIG_I2C_DEBUG_CHIP is not set
467
468#
469# Dallas's 1-wire bus
470#
471# CONFIG_W1 is not set
472
473#
474# Misc devices
475#
476
477#
478# Multimedia devices
479#
480# CONFIG_VIDEO_DEV is not set
481
482#
483# Digital Video Broadcasting Devices
484#
485# CONFIG_DVB is not set
486
487#
488# Graphics support
489#
490# CONFIG_FB is not set
491
492#
493# Sound
494#
495# CONFIG_SOUND is not set
496
497#
498# USB support
499#
500# CONFIG_USB_ARCH_HAS_HCD is not set
501# CONFIG_USB_ARCH_HAS_OHCI is not set
502
503#
504# USB Gadget Support
505#
506# CONFIG_USB_GADGET is not set
507
508#
509# MMC/SD Card support
510#
511# CONFIG_MMC is not set
512
513#
514# InfiniBand support
515#
516# CONFIG_INFINIBAND is not set
517
518#
519# File systems
520#
521CONFIG_EXT2_FS=y
522# CONFIG_EXT2_FS_XATTR is not set
523CONFIG_EXT3_FS=y
524CONFIG_EXT3_FS_XATTR=y
525# CONFIG_EXT3_FS_POSIX_ACL is not set
526# CONFIG_EXT3_FS_SECURITY is not set
527CONFIG_JBD=y
528# CONFIG_JBD_DEBUG is not set
529CONFIG_FS_MBCACHE=y
530# CONFIG_REISERFS_FS is not set
531# CONFIG_JFS_FS is not set
532
533#
534# XFS support
535#
536# CONFIG_XFS_FS is not set
537# CONFIG_MINIX_FS is not set
538# CONFIG_ROMFS_FS is not set
539# CONFIG_QUOTA is not set
540CONFIG_DNOTIFY=y
541# CONFIG_AUTOFS_FS is not set
542# CONFIG_AUTOFS4_FS is not set
543
544#
545# CD-ROM/DVD Filesystems
546#
547# CONFIG_ISO9660_FS is not set
548# CONFIG_UDF_FS is not set
549
550#
551# DOS/FAT/NT Filesystems
552#
553# CONFIG_MSDOS_FS is not set
554# CONFIG_VFAT_FS is not set
555# CONFIG_NTFS_FS is not set
556
557#
558# Pseudo filesystems
559#
560CONFIG_PROC_FS=y
561CONFIG_PROC_KCORE=y
562CONFIG_SYSFS=y
563# CONFIG_DEVFS_FS is not set
564# CONFIG_DEVPTS_FS_XATTR is not set
565CONFIG_TMPFS=y
566# CONFIG_TMPFS_XATTR is not set
567# CONFIG_HUGETLB_PAGE is not set
568CONFIG_RAMFS=y
569
570#
571# Miscellaneous filesystems
572#
573# CONFIG_ADFS_FS is not set
574# CONFIG_AFFS_FS is not set
575# CONFIG_HFS_FS is not set
576# CONFIG_HFSPLUS_FS is not set
577# CONFIG_BEFS_FS is not set
578# CONFIG_BFS_FS is not set
579# CONFIG_EFS_FS is not set
580# CONFIG_CRAMFS is not set
581# CONFIG_VXFS_FS is not set
582# CONFIG_HPFS_FS is not set
583# CONFIG_QNX4FS_FS is not set
584# CONFIG_SYSV_FS is not set
585# CONFIG_UFS_FS is not set
586
587#
588# Network File Systems
589#
590CONFIG_NFS_FS=y
591# CONFIG_NFS_V3 is not set
592# CONFIG_NFS_V4 is not set
593# CONFIG_NFS_DIRECTIO is not set
594# CONFIG_NFSD is not set
595CONFIG_ROOT_NFS=y
596CONFIG_LOCKD=y
597CONFIG_SUNRPC=y
598# CONFIG_RPCSEC_GSS_KRB5 is not set
599# CONFIG_RPCSEC_GSS_SPKM3 is not set
600# CONFIG_SMB_FS is not set
601# CONFIG_CIFS is not set
602# CONFIG_NCP_FS is not set
603# CONFIG_CODA_FS is not set
604# CONFIG_AFS_FS is not set
605
606#
607# Partition Types
608#
609CONFIG_PARTITION_ADVANCED=y
610# CONFIG_ACORN_PARTITION is not set
611# CONFIG_OSF_PARTITION is not set
612# CONFIG_AMIGA_PARTITION is not set
613# CONFIG_ATARI_PARTITION is not set
614# CONFIG_MAC_PARTITION is not set
615# CONFIG_MSDOS_PARTITION is not set
616# CONFIG_LDM_PARTITION is not set
617# CONFIG_SGI_PARTITION is not set
618# CONFIG_ULTRIX_PARTITION is not set
619# CONFIG_SUN_PARTITION is not set
620# CONFIG_EFI_PARTITION is not set
621
622#
623# Native Language Support
624#
625# CONFIG_NLS is not set
626
627#
628# Library routines
629#
630# CONFIG_CRC_CCITT is not set
631CONFIG_CRC32=y
632# CONFIG_LIBCRC32C is not set
633
634#
635# Profiling support
636#
637# CONFIG_PROFILING is not set
638
639#
640# Kernel hacking
641#
642# CONFIG_PRINTK_TIME is not set
643# CONFIG_DEBUG_KERNEL is not set
644CONFIG_LOG_BUF_SHIFT=14
645
646#
647# Security options
648#
649# CONFIG_KEYS is not set
650# CONFIG_SECURITY is not set
651
652#
653# Cryptographic options
654#
655# CONFIG_CRYPTO is not set
656
657#
658# Hardware crypto devices
659#
diff --git a/arch/ppc/kernel/cputable.c b/arch/ppc/kernel/cputable.c
index d44b7dc5390a..01c226008dbf 100644
--- a/arch/ppc/kernel/cputable.c
+++ b/arch/ppc/kernel/cputable.c
@@ -918,6 +918,20 @@ struct cpu_spec cpu_specs[] = {
918 .dcache_bsize = 32, 918 .dcache_bsize = 32,
919 .num_pmcs = 4, 919 .num_pmcs = 4,
920 }, 920 },
921 { /* e500v2 */
922 .pvr_mask = 0xffff0000,
923 .pvr_value = 0x80210000,
924 .cpu_name = "e500v2",
925 /* xxx - galak: add CPU_FTR_MAYBE_CAN_DOZE */
926 .cpu_features = CPU_FTR_SPLIT_ID_CACHE |
927 CPU_FTR_USE_TB | CPU_FTR_BIG_PHYS,
928 .cpu_user_features = PPC_FEATURE_32 |
929 PPC_FEATURE_HAS_MMU | PPC_FEATURE_SPE_COMP |
930 PPC_FEATURE_HAS_EFP_SINGLE | PPC_FEATURE_HAS_EFP_DOUBLE,
931 .icache_bsize = 32,
932 .dcache_bsize = 32,
933 .num_pmcs = 4,
934 },
921#endif 935#endif
922#if !CLASSIC_PPC 936#if !CLASSIC_PPC
923 { /* default match */ 937 { /* default match */
diff --git a/arch/ppc/kernel/entry.S b/arch/ppc/kernel/entry.S
index 661523707e8c..8377b6ca26da 100644
--- a/arch/ppc/kernel/entry.S
+++ b/arch/ppc/kernel/entry.S
@@ -46,26 +46,23 @@
46 46
47#ifdef CONFIG_BOOKE 47#ifdef CONFIG_BOOKE
48#include "head_booke.h" 48#include "head_booke.h"
49#define TRANSFER_TO_HANDLER_EXC_LEVEL(exc_level) \
50 mtspr exc_level##_SPRG,r8; \
51 BOOKE_LOAD_EXC_LEVEL_STACK(exc_level); \
52 lwz r0,GPR10-INT_FRAME_SIZE(r8); \
53 stw r0,GPR10(r11); \
54 lwz r0,GPR11-INT_FRAME_SIZE(r8); \
55 stw r0,GPR11(r11); \
56 mfspr r8,exc_level##_SPRG
57
49 .globl mcheck_transfer_to_handler 58 .globl mcheck_transfer_to_handler
50mcheck_transfer_to_handler: 59mcheck_transfer_to_handler:
51 mtspr MCHECK_SPRG,r8 60 TRANSFER_TO_HANDLER_EXC_LEVEL(MCHECK)
52 BOOKE_LOAD_MCHECK_STACK
53 lwz r0,GPR10-INT_FRAME_SIZE(r8)
54 stw r0,GPR10(r11)
55 lwz r0,GPR11-INT_FRAME_SIZE(r8)
56 stw r0,GPR11(r11)
57 mfspr r8,MCHECK_SPRG
58 b transfer_to_handler_full 61 b transfer_to_handler_full
59 62
60 .globl crit_transfer_to_handler 63 .globl crit_transfer_to_handler
61crit_transfer_to_handler: 64crit_transfer_to_handler:
62 mtspr CRIT_SPRG,r8 65 TRANSFER_TO_HANDLER_EXC_LEVEL(CRIT)
63 BOOKE_LOAD_CRIT_STACK
64 lwz r0,GPR10-INT_FRAME_SIZE(r8)
65 stw r0,GPR10(r11)
66 lwz r0,GPR11-INT_FRAME_SIZE(r8)
67 stw r0,GPR11(r11)
68 mfspr r8,CRIT_SPRG
69 /* fall through */ 66 /* fall through */
70#endif 67#endif
71 68
@@ -783,99 +780,64 @@ exc_exit_restart_end:
783 * time of the critical interrupt. 780 * time of the critical interrupt.
784 * 781 *
785 */ 782 */
786 .globl ret_from_crit_exc
787ret_from_crit_exc:
788 REST_NVGPRS(r1)
789 lwz r3,_MSR(r1)
790 andi. r3,r3,MSR_PR
791 LOAD_MSR_KERNEL(r10,MSR_KERNEL)
792 bne user_exc_return
793
794 lwz r0,GPR0(r1)
795 lwz r2,GPR2(r1)
796 REST_4GPRS(3, r1)
797 REST_2GPRS(7, r1)
798
799 lwz r10,_XER(r1)
800 lwz r11,_CTR(r1)
801 mtspr SPRN_XER,r10
802 mtctr r11
803
804 PPC405_ERR77(0,r1)
805 stwcx. r0,0,r1 /* to clear the reservation */
806
807 lwz r11,_LINK(r1)
808 mtlr r11
809 lwz r10,_CCR(r1)
810 mtcrf 0xff,r10
811#ifdef CONFIG_40x 783#ifdef CONFIG_40x
812 /* avoid any possible TLB misses here by turning off MSR.DR, we 784#define PPC_40x_TURN_OFF_MSR_DR \
813 * assume the instructions here are mapped by a pinned TLB entry */ 785 /* avoid any possible TLB misses here by turning off MSR.DR, we \
814 li r10,MSR_IR 786 * assume the instructions here are mapped by a pinned TLB entry */ \
815 mtmsr r10 787 li r10,MSR_IR; \
816 isync 788 mtmsr r10; \
817 tophys(r1, r1) 789 isync; \
790 tophys(r1, r1);
791#else
792#define PPC_40x_TURN_OFF_MSR_DR
818#endif 793#endif
819 lwz r9,_DEAR(r1) 794
820 lwz r10,_ESR(r1) 795#define RET_FROM_EXC_LEVEL(exc_lvl_srr0, exc_lvl_srr1, exc_lvl_rfi) \
821 mtspr SPRN_DEAR,r9 796 REST_NVGPRS(r1); \
822 mtspr SPRN_ESR,r10 797 lwz r3,_MSR(r1); \
823 lwz r11,_NIP(r1) 798 andi. r3,r3,MSR_PR; \
824 lwz r12,_MSR(r1) 799 LOAD_MSR_KERNEL(r10,MSR_KERNEL); \
825 mtspr SPRN_CSRR0,r11 800 bne user_exc_return; \
826 mtspr SPRN_CSRR1,r12 801 lwz r0,GPR0(r1); \
827 lwz r9,GPR9(r1) 802 lwz r2,GPR2(r1); \
828 lwz r12,GPR12(r1) 803 REST_4GPRS(3, r1); \
829 lwz r10,GPR10(r1) 804 REST_2GPRS(7, r1); \
830 lwz r11,GPR11(r1) 805 lwz r10,_XER(r1); \
831 lwz r1,GPR1(r1) 806 lwz r11,_CTR(r1); \
832 PPC405_ERR77_SYNC 807 mtspr SPRN_XER,r10; \
833 rfci 808 mtctr r11; \
834 b . /* prevent prefetch past rfci */ 809 PPC405_ERR77(0,r1); \
810 stwcx. r0,0,r1; /* to clear the reservation */ \
811 lwz r11,_LINK(r1); \
812 mtlr r11; \
813 lwz r10,_CCR(r1); \
814 mtcrf 0xff,r10; \
815 PPC_40x_TURN_OFF_MSR_DR; \
816 lwz r9,_DEAR(r1); \
817 lwz r10,_ESR(r1); \
818 mtspr SPRN_DEAR,r9; \
819 mtspr SPRN_ESR,r10; \
820 lwz r11,_NIP(r1); \
821 lwz r12,_MSR(r1); \
822 mtspr exc_lvl_srr0,r11; \
823 mtspr exc_lvl_srr1,r12; \
824 lwz r9,GPR9(r1); \
825 lwz r12,GPR12(r1); \
826 lwz r10,GPR10(r1); \
827 lwz r11,GPR11(r1); \
828 lwz r1,GPR1(r1); \
829 PPC405_ERR77_SYNC; \
830 exc_lvl_rfi; \
831 b .; /* prevent prefetch past exc_lvl_rfi */
832
833 .globl ret_from_crit_exc
834ret_from_crit_exc:
835 RET_FROM_EXC_LEVEL(SPRN_CSRR0, SPRN_CSRR1, RFCI)
835 836
836#ifdef CONFIG_BOOKE 837#ifdef CONFIG_BOOKE
837/*
838 * Return from a machine check interrupt, similar to a critical
839 * interrupt.
840 */
841 .globl ret_from_mcheck_exc 838 .globl ret_from_mcheck_exc
842ret_from_mcheck_exc: 839ret_from_mcheck_exc:
843 REST_NVGPRS(r1) 840 RET_FROM_EXC_LEVEL(SPRN_MCSRR0, SPRN_MCSRR1, RFMCI)
844 lwz r3,_MSR(r1)
845 andi. r3,r3,MSR_PR
846 LOAD_MSR_KERNEL(r10,MSR_KERNEL)
847 bne user_exc_return
848
849 lwz r0,GPR0(r1)
850 lwz r2,GPR2(r1)
851 REST_4GPRS(3, r1)
852 REST_2GPRS(7, r1)
853
854 lwz r10,_XER(r1)
855 lwz r11,_CTR(r1)
856 mtspr SPRN_XER,r10
857 mtctr r11
858
859 stwcx. r0,0,r1 /* to clear the reservation */
860
861 lwz r11,_LINK(r1)
862 mtlr r11
863 lwz r10,_CCR(r1)
864 mtcrf 0xff,r10
865 lwz r9,_DEAR(r1)
866 lwz r10,_ESR(r1)
867 mtspr SPRN_DEAR,r9
868 mtspr SPRN_ESR,r10
869 lwz r11,_NIP(r1)
870 lwz r12,_MSR(r1)
871 mtspr SPRN_MCSRR0,r11
872 mtspr SPRN_MCSRR1,r12
873 lwz r9,GPR9(r1)
874 lwz r12,GPR12(r1)
875 lwz r10,GPR10(r1)
876 lwz r11,GPR11(r1)
877 lwz r1,GPR1(r1)
878 RFMCI
879#endif /* CONFIG_BOOKE */ 841#endif /* CONFIG_BOOKE */
880 842
881/* 843/*
diff --git a/arch/ppc/kernel/head_4xx.S b/arch/ppc/kernel/head_4xx.S
index 6f5d380e2345..23fb51819ba5 100644
--- a/arch/ppc/kernel/head_4xx.S
+++ b/arch/ppc/kernel/head_4xx.S
@@ -291,8 +291,9 @@ label:
291 /* If we are faulting a kernel address, we have to use the 291 /* If we are faulting a kernel address, we have to use the
292 * kernel page tables. 292 * kernel page tables.
293 */ 293 */
294 andis. r11, r10, 0x8000 294 lis r11, TASK_SIZE@h
295 beq 3f 295 cmplw r10, r11
296 blt+ 3f
296 lis r11, swapper_pg_dir@h 297 lis r11, swapper_pg_dir@h
297 ori r11, r11, swapper_pg_dir@l 298 ori r11, r11, swapper_pg_dir@l
298 li r9, 0 299 li r9, 0
@@ -479,8 +480,9 @@ label:
479 /* If we are faulting a kernel address, we have to use the 480 /* If we are faulting a kernel address, we have to use the
480 * kernel page tables. 481 * kernel page tables.
481 */ 482 */
482 andis. r11, r10, 0x8000 483 lis r11, TASK_SIZE@h
483 beq 3f 484 cmplw r10, r11
485 blt+ 3f
484 lis r11, swapper_pg_dir@h 486 lis r11, swapper_pg_dir@h
485 ori r11, r11, swapper_pg_dir@l 487 ori r11, r11, swapper_pg_dir@l
486 li r9, 0 488 li r9, 0
@@ -578,8 +580,9 @@ label:
578 /* If we are faulting a kernel address, we have to use the 580 /* If we are faulting a kernel address, we have to use the
579 * kernel page tables. 581 * kernel page tables.
580 */ 582 */
581 andis. r11, r10, 0x8000 583 lis r11, TASK_SIZE@h
582 beq 3f 584 cmplw r10, r11
585 blt+ 3f
583 lis r11, swapper_pg_dir@h 586 lis r11, swapper_pg_dir@h
584 ori r11, r11, swapper_pg_dir@l 587 ori r11, r11, swapper_pg_dir@l
585 li r9, 0 588 li r9, 0
diff --git a/arch/ppc/kernel/head_booke.h b/arch/ppc/kernel/head_booke.h
index f213d12eec08..9c50f9d2657c 100644
--- a/arch/ppc/kernel/head_booke.h
+++ b/arch/ppc/kernel/head_booke.h
@@ -67,46 +67,36 @@
67#define CRIT_STACK_TOP (exception_stack_top) 67#define CRIT_STACK_TOP (exception_stack_top)
68 68
69#ifdef CONFIG_SMP 69#ifdef CONFIG_SMP
70#define BOOKE_LOAD_CRIT_STACK \ 70#define BOOKE_LOAD_EXC_LEVEL_STACK(level) \
71 mfspr r8,SPRN_PIR; \ 71 mfspr r8,SPRN_PIR; \
72 mulli r8,r8,BOOKE_EXCEPTION_STACK_SIZE; \ 72 mulli r8,r8,BOOKE_EXCEPTION_STACK_SIZE; \
73 neg r8,r8; \ 73 neg r8,r8; \
74 addis r8,r8,CRIT_STACK_TOP@ha; \ 74 addis r8,r8,level##_STACK_TOP@ha; \
75 addi r8,r8,CRIT_STACK_TOP@l 75 addi r8,r8,level##_STACK_TOP@l
76#define BOOKE_LOAD_MCHECK_STACK \
77 mfspr r8,SPRN_PIR; \
78 mulli r8,r8,BOOKE_EXCEPTION_STACK_SIZE; \
79 neg r8,r8; \
80 addis r8,r8,MCHECK_STACK_TOP@ha; \
81 addi r8,r8,MCHECK_STACK_TOP@l
82#else 76#else
83#define BOOKE_LOAD_CRIT_STACK \ 77#define BOOKE_LOAD_EXC_LEVEL_STACK(level) \
84 lis r8,CRIT_STACK_TOP@h; \ 78 lis r8,level##_STACK_TOP@h; \
85 ori r8,r8,CRIT_STACK_TOP@l 79 ori r8,r8,level##_STACK_TOP@l
86#define BOOKE_LOAD_MCHECK_STACK \
87 lis r8,MCHECK_STACK_TOP@h; \
88 ori r8,r8,MCHECK_STACK_TOP@l
89#endif 80#endif
90 81
91/* 82/*
92 * Exception prolog for critical exceptions. This is a little different 83 * Exception prolog for critical/machine check exceptions. This is a
93 * from the normal exception prolog above since a critical exception 84 * little different from the normal exception prolog above since a
94 * can potentially occur at any point during normal exception processing. 85 * critical/machine check exception can potentially occur at any point
95 * Thus we cannot use the same SPRG registers as the normal prolog above. 86 * during normal exception processing. Thus we cannot use the same SPRG
96 * Instead we use a portion of the critical exception stack at low physical 87 * registers as the normal prolog above. Instead we use a portion of the
97 * addresses. 88 * critical/machine check exception stack at low physical addresses.
98 */ 89 */
99 90#define EXC_LEVEL_EXCEPTION_PROLOG(exc_level, exc_level_srr0, exc_level_srr1) \
100#define CRITICAL_EXCEPTION_PROLOG \ 91 mtspr exc_level##_SPRG,r8; \
101 mtspr CRIT_SPRG,r8; \ 92 BOOKE_LOAD_EXC_LEVEL_STACK(exc_level);/* r8 points to the exc_level stack*/ \
102 BOOKE_LOAD_CRIT_STACK; /* r8 points to the crit stack */ \
103 stw r10,GPR10-INT_FRAME_SIZE(r8); \ 93 stw r10,GPR10-INT_FRAME_SIZE(r8); \
104 stw r11,GPR11-INT_FRAME_SIZE(r8); \ 94 stw r11,GPR11-INT_FRAME_SIZE(r8); \
105 mfcr r10; /* save CR in r10 for now */\ 95 mfcr r10; /* save CR in r10 for now */\
106 mfspr r11,SPRN_CSRR1; /* check whether user or kernel */\ 96 mfspr r11,exc_level_srr1; /* check whether user or kernel */\
107 andi. r11,r11,MSR_PR; \ 97 andi. r11,r11,MSR_PR; \
108 mr r11,r8; \ 98 mr r11,r8; \
109 mfspr r8,CRIT_SPRG; \ 99 mfspr r8,exc_level##_SPRG; \
110 beq 1f; \ 100 beq 1f; \
111 /* COMING FROM USER MODE */ \ 101 /* COMING FROM USER MODE */ \
112 mfspr r11,SPRN_SPRG3; /* if from user, start at top of */\ 102 mfspr r11,SPRN_SPRG3; /* if from user, start at top of */\
@@ -122,9 +112,9 @@
122 stw r12,_DEAR(r11); /* since they may have had stuff */\ 112 stw r12,_DEAR(r11); /* since they may have had stuff */\
123 mfspr r9,SPRN_ESR; /* in them at the point where the */\ 113 mfspr r9,SPRN_ESR; /* in them at the point where the */\
124 stw r9,_ESR(r11); /* exception was taken */\ 114 stw r9,_ESR(r11); /* exception was taken */\
125 mfspr r12,SPRN_CSRR0; \ 115 mfspr r12,exc_level_srr0; \
126 stw r1,GPR1(r11); \ 116 stw r1,GPR1(r11); \
127 mfspr r9,SPRN_CSRR1; \ 117 mfspr r9,exc_level_srr1; \
128 stw r1,0(r11); \ 118 stw r1,0(r11); \
129 mr r1,r11; \ 119 mr r1,r11; \
130 rlwinm r9,r9,0,14,12; /* clear MSR_WE (necessary?) */\ 120 rlwinm r9,r9,0,14,12; /* clear MSR_WE (necessary?) */\
@@ -132,45 +122,10 @@
132 SAVE_4GPRS(3, r11); \ 122 SAVE_4GPRS(3, r11); \
133 SAVE_2GPRS(7, r11) 123 SAVE_2GPRS(7, r11)
134 124
135/* 125#define CRITICAL_EXCEPTION_PROLOG \
136 * Exception prolog for machine check exceptions. This is similar to 126 EXC_LEVEL_EXCEPTION_PROLOG(CRIT, SPRN_CSRR0, SPRN_CSRR1)
137 * the critical exception prolog, except that machine check exceptions 127#define MCHECK_EXCEPTION_PROLOG \
138 * have their stack. 128 EXC_LEVEL_EXCEPTION_PROLOG(MCHECK, SPRN_MCSRR0, SPRN_MCSRR1)
139 */
140#define MCHECK_EXCEPTION_PROLOG \
141 mtspr MCHECK_SPRG,r8; \
142 BOOKE_LOAD_MCHECK_STACK; /* r8 points to the mcheck stack */\
143 stw r10,GPR10-INT_FRAME_SIZE(r8); \
144 stw r11,GPR11-INT_FRAME_SIZE(r8); \
145 mfcr r10; /* save CR in r10 for now */\
146 mfspr r11,SPRN_MCSRR1; /* check whether user or kernel */\
147 andi. r11,r11,MSR_PR; \
148 mr r11,r8; \
149 mfspr r8,MCHECK_SPRG; \
150 beq 1f; \
151 /* COMING FROM USER MODE */ \
152 mfspr r11,SPRN_SPRG3; /* if from user, start at top of */\
153 lwz r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\
154 addi r11,r11,THREAD_SIZE; \
1551: subi r11,r11,INT_FRAME_SIZE; /* Allocate an exception frame */\
156 stw r10,_CCR(r11); /* save various registers */\
157 stw r12,GPR12(r11); \
158 stw r9,GPR9(r11); \
159 mflr r10; \
160 stw r10,_LINK(r11); \
161 mfspr r12,SPRN_DEAR; /* save DEAR and ESR in the frame */\
162 stw r12,_DEAR(r11); /* since they may have had stuff */\
163 mfspr r9,SPRN_ESR; /* in them at the point where the */\
164 stw r9,_ESR(r11); /* exception was taken */\
165 mfspr r12,SPRN_MCSRR0; \
166 stw r1,GPR1(r11); \
167 mfspr r9,SPRN_MCSRR1; \
168 stw r1,0(r11); \
169 mr r1,r11; \
170 rlwinm r9,r9,0,14,12; /* clear MSR_WE (necessary?) */\
171 stw r0,GPR0(r11); \
172 SAVE_4GPRS(3, r11); \
173 SAVE_2GPRS(7, r11)
174 129
175/* 130/*
176 * Exception vectors. 131 * Exception vectors.
@@ -237,7 +192,6 @@ label:
237 EXC_XFER_TEMPLATE(hdlr, n+1, MSR_KERNEL, COPY_EE, transfer_to_handler, \ 192 EXC_XFER_TEMPLATE(hdlr, n+1, MSR_KERNEL, COPY_EE, transfer_to_handler, \
238 ret_from_except) 193 ret_from_except)
239 194
240
241/* Check for a single step debug exception while in an exception 195/* Check for a single step debug exception while in an exception
242 * handler before state has been saved. This is to catch the case 196 * handler before state has been saved. This is to catch the case
243 * where an instruction that we are trying to single step causes 197 * where an instruction that we are trying to single step causes
@@ -291,7 +245,7 @@ label:
291 lwz r9,GPR9(r11); \ 245 lwz r9,GPR9(r11); \
292 lwz r12,GPR12(r11); \ 246 lwz r12,GPR12(r11); \
293 mtspr CRIT_SPRG,r8; \ 247 mtspr CRIT_SPRG,r8; \
294 BOOKE_LOAD_CRIT_STACK; /* r8 points to the crit stack */ \ 248 BOOKE_LOAD_EXC_LEVEL_STACK(CRIT); /* r8 points to the debug stack */ \
295 lwz r10,GPR10-INT_FRAME_SIZE(r8); \ 249 lwz r10,GPR10-INT_FRAME_SIZE(r8); \
296 lwz r11,GPR11-INT_FRAME_SIZE(r8); \ 250 lwz r11,GPR11-INT_FRAME_SIZE(r8); \
297 mfspr r8,CRIT_SPRG; \ 251 mfspr r8,CRIT_SPRG; \
diff --git a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c
index 5c20266e3b1f..c42f75326939 100644
--- a/arch/ppc/kernel/setup.c
+++ b/arch/ppc/kernel/setup.c
@@ -41,7 +41,7 @@
41#include <asm/xmon.h> 41#include <asm/xmon.h>
42#include <asm/ocp.h> 42#include <asm/ocp.h>
43 43
44#if defined(CONFIG_85xx) || defined(CONFIG_83xx) 44#if defined(CONFIG_85xx) || defined(CONFIG_83xx) || defined(CONFIG_MPC10X_BRIDGE)
45#include <asm/ppc_sys.h> 45#include <asm/ppc_sys.h>
46#endif 46#endif
47 47
@@ -61,8 +61,6 @@ extern void power4_idle(void);
61 61
62extern boot_infos_t *boot_infos; 62extern boot_infos_t *boot_infos;
63struct ide_machdep_calls ppc_ide_md; 63struct ide_machdep_calls ppc_ide_md;
64char *sysmap;
65unsigned long sysmap_size;
66 64
67/* Used with the BI_MEMSIZE bootinfo parameter to store the memory 65/* Used with the BI_MEMSIZE bootinfo parameter to store the memory
68 size value reported by the boot loader. */ 66 size value reported by the boot loader. */
@@ -249,7 +247,7 @@ int show_cpuinfo(struct seq_file *m, void *v)
249 seq_printf(m, "bogomips\t: %lu.%02lu\n", 247 seq_printf(m, "bogomips\t: %lu.%02lu\n",
250 lpj / (500000/HZ), (lpj / (5000/HZ)) % 100); 248 lpj / (500000/HZ), (lpj / (5000/HZ)) % 100);
251 249
252#if defined(CONFIG_85xx) || defined(CONFIG_83xx) 250#if defined(CONFIG_85xx) || defined(CONFIG_83xx) || defined(CONFIG_MPC10X_BRIDGE)
253 if (cur_ppc_sys_spec->ppc_sys_name) 251 if (cur_ppc_sys_spec->ppc_sys_name)
254 seq_printf(m, "chipset\t\t: %s\n", 252 seq_printf(m, "chipset\t\t: %s\n",
255 cur_ppc_sys_spec->ppc_sys_name); 253 cur_ppc_sys_spec->ppc_sys_name);
@@ -578,11 +576,6 @@ void parse_bootinfo(struct bi_record *rec)
578 case BI_CMD_LINE: 576 case BI_CMD_LINE:
579 strlcpy(cmd_line, (void *)data, sizeof(cmd_line)); 577 strlcpy(cmd_line, (void *)data, sizeof(cmd_line));
580 break; 578 break;
581 case BI_SYSMAP:
582 sysmap = (char *)((data[0] >= (KERNELBASE)) ? data[0] :
583 (data[0]+KERNELBASE));
584 sysmap_size = data[1];
585 break;
586#ifdef CONFIG_BLK_DEV_INITRD 579#ifdef CONFIG_BLK_DEV_INITRD
587 case BI_INITRD: 580 case BI_INITRD:
588 initrd_start = data[0] + KERNELBASE; 581 initrd_start = data[0] + KERNELBASE;
diff --git a/arch/ppc/kernel/traps.c b/arch/ppc/kernel/traps.c
index c65731e8bc65..2ca8ecfeefd9 100644
--- a/arch/ppc/kernel/traps.c
+++ b/arch/ppc/kernel/traps.c
@@ -81,8 +81,10 @@ void die(const char * str, struct pt_regs * fp, long err)
81 console_verbose(); 81 console_verbose();
82 spin_lock_irq(&die_lock); 82 spin_lock_irq(&die_lock);
83#ifdef CONFIG_PMAC_BACKLIGHT 83#ifdef CONFIG_PMAC_BACKLIGHT
84 set_backlight_enable(1); 84 if (_machine == _MACH_Pmac) {
85 set_backlight_level(BACKLIGHT_MAX); 85 set_backlight_enable(1);
86 set_backlight_level(BACKLIGHT_MAX);
87 }
86#endif 88#endif
87 printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter); 89 printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
88#ifdef CONFIG_PREEMPT 90#ifdef CONFIG_PREEMPT
diff --git a/arch/ppc/lib/locks.c b/arch/ppc/lib/locks.c
index 694163d696d8..c450dc4b766e 100644
--- a/arch/ppc/lib/locks.c
+++ b/arch/ppc/lib/locks.c
@@ -130,7 +130,7 @@ void _raw_read_lock(rwlock_t *rw)
130 while (!read_can_lock(rw)) { 130 while (!read_can_lock(rw)) {
131 if (--stuck == 0) { 131 if (--stuck == 0) {
132 printk("_read_lock(%p) CPU#%d lock %d\n", 132 printk("_read_lock(%p) CPU#%d lock %d\n",
133 rw, _smp_processor_id(), rw->lock); 133 rw, raw_smp_processor_id(), rw->lock);
134 stuck = INIT_STUCK; 134 stuck = INIT_STUCK;
135 } 135 }
136 } 136 }
@@ -158,7 +158,7 @@ void _raw_write_lock(rwlock_t *rw)
158 while (!write_can_lock(rw)) { 158 while (!write_can_lock(rw)) {
159 if (--stuck == 0) { 159 if (--stuck == 0) {
160 printk("write_lock(%p) CPU#%d lock %d)\n", 160 printk("write_lock(%p) CPU#%d lock %d)\n",
161 rw, _smp_processor_id(), rw->lock); 161 rw, raw_smp_processor_id(), rw->lock);
162 stuck = INIT_STUCK; 162 stuck = INIT_STUCK;
163 } 163 }
164 } 164 }
diff --git a/arch/ppc/mm/fsl_booke_mmu.c b/arch/ppc/mm/fsl_booke_mmu.c
index 36233bdcdf8f..e07990efa046 100644
--- a/arch/ppc/mm/fsl_booke_mmu.c
+++ b/arch/ppc/mm/fsl_booke_mmu.c
@@ -64,6 +64,8 @@ extern unsigned long total_lowmem;
64extern unsigned long __max_low_memory; 64extern unsigned long __max_low_memory;
65#define MAX_LOW_MEM CONFIG_LOWMEM_SIZE 65#define MAX_LOW_MEM CONFIG_LOWMEM_SIZE
66 66
67#define NUM_TLBCAMS (16)
68
67struct tlbcam { 69struct tlbcam {
68 u32 MAS0; 70 u32 MAS0;
69 u32 MAS1; 71 u32 MAS1;
diff --git a/arch/ppc/mm/init.c b/arch/ppc/mm/init.c
index 363c157e3617..334ef4150d92 100644
--- a/arch/ppc/mm/init.c
+++ b/arch/ppc/mm/init.c
@@ -96,9 +96,6 @@ extern struct task_struct *current_set[NR_CPUS];
96char *klimit = _end; 96char *klimit = _end;
97struct mem_pieces phys_avail; 97struct mem_pieces phys_avail;
98 98
99extern char *sysmap;
100extern unsigned long sysmap_size;
101
102/* 99/*
103 * this tells the system to map all of ram with the segregs 100 * this tells the system to map all of ram with the segregs
104 * (i.e. page tables) instead of the bats. 101 * (i.e. page tables) instead of the bats.
@@ -442,12 +439,6 @@ void __init mem_init(void)
442 if (agp_special_page) 439 if (agp_special_page)
443 SetPageReserved(virt_to_page(agp_special_page)); 440 SetPageReserved(virt_to_page(agp_special_page));
444#endif 441#endif
445 if ( sysmap )
446 for (addr = (unsigned long)sysmap;
447 addr < PAGE_ALIGN((unsigned long)sysmap+sysmap_size) ;
448 addr += PAGE_SIZE)
449 SetPageReserved(virt_to_page(addr));
450
451 for (addr = PAGE_OFFSET; addr < (unsigned long)high_memory; 442 for (addr = PAGE_OFFSET; addr < (unsigned long)high_memory;
452 addr += PAGE_SIZE) { 443 addr += PAGE_SIZE) {
453 if (!PageReserved(virt_to_page(addr))) 444 if (!PageReserved(virt_to_page(addr)))
@@ -469,7 +460,6 @@ void __init mem_init(void)
469 struct page *page = mem_map + pfn; 460 struct page *page = mem_map + pfn;
470 461
471 ClearPageReserved(page); 462 ClearPageReserved(page);
472 set_bit(PG_highmem, &page->flags);
473 set_page_count(page, 1); 463 set_page_count(page, 1);
474 __free_page(page); 464 __free_page(page);
475 totalhigh_pages++; 465 totalhigh_pages++;
@@ -483,9 +473,7 @@ void __init mem_init(void)
483 codepages<< (PAGE_SHIFT-10), datapages<< (PAGE_SHIFT-10), 473 codepages<< (PAGE_SHIFT-10), datapages<< (PAGE_SHIFT-10),
484 initpages<< (PAGE_SHIFT-10), 474 initpages<< (PAGE_SHIFT-10),
485 (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10))); 475 (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10)));
486 if (sysmap) 476
487 printk("System.map loaded at 0x%08x for debugger, size: %ld bytes\n",
488 (unsigned int)sysmap, sysmap_size);
489#ifdef CONFIG_PPC_PMAC 477#ifdef CONFIG_PPC_PMAC
490 if (agp_special_page) 478 if (agp_special_page)
491 printk(KERN_INFO "AGP special page: 0x%08lx\n", agp_special_page); 479 printk(KERN_INFO "AGP special page: 0x%08lx\n", agp_special_page);
@@ -535,9 +523,6 @@ set_phys_avail(unsigned long total_memory)
535 if (rtas_data) 523 if (rtas_data)
536 mem_pieces_remove(&phys_avail, rtas_data, rtas_size, 1); 524 mem_pieces_remove(&phys_avail, rtas_data, rtas_size, 1);
537#endif 525#endif
538 /* remove the sysmap pages from the available memory */
539 if (sysmap)
540 mem_pieces_remove(&phys_avail, __pa(sysmap), sysmap_size, 1);
541#ifdef CONFIG_PPC_PMAC 526#ifdef CONFIG_PPC_PMAC
542 /* Because of some uninorth weirdness, we need a page of 527 /* Because of some uninorth weirdness, we need a page of
543 * memory as high as possible (it must be outside of the 528 * memory as high as possible (it must be outside of the
diff --git a/arch/ppc/mm/mmu_decl.h b/arch/ppc/mm/mmu_decl.h
index ffcdb46997dc..540f3292b229 100644
--- a/arch/ppc/mm/mmu_decl.h
+++ b/arch/ppc/mm/mmu_decl.h
@@ -43,6 +43,8 @@ extern int mem_init_done;
43extern PTE *Hash, *Hash_end; 43extern PTE *Hash, *Hash_end;
44extern unsigned long Hash_size, Hash_mask; 44extern unsigned long Hash_size, Hash_mask;
45 45
46extern unsigned int num_tlbcam_entries;
47
46/* ...and now those things that may be slightly different between processor 48/* ...and now those things that may be slightly different between processor
47 * architectures. -- Dan 49 * architectures. -- Dan
48 */ 50 */
diff --git a/arch/ppc/mm/pgtable.c b/arch/ppc/mm/pgtable.c
index 5d2f3f66aefa..81a3d7446d37 100644
--- a/arch/ppc/mm/pgtable.c
+++ b/arch/ppc/mm/pgtable.c
@@ -66,7 +66,6 @@ void setbat(int index, unsigned long virt, unsigned long phys,
66 66
67#ifdef HAVE_TLBCAM 67#ifdef HAVE_TLBCAM
68extern unsigned int tlbcam_index; 68extern unsigned int tlbcam_index;
69extern unsigned int num_tlbcam_entries;
70extern unsigned long v_mapped_by_tlbcam(unsigned long va); 69extern unsigned long v_mapped_by_tlbcam(unsigned long va);
71extern unsigned long p_mapped_by_tlbcam(unsigned long pa); 70extern unsigned long p_mapped_by_tlbcam(unsigned long pa);
72#else /* !HAVE_TLBCAM */ 71#else /* !HAVE_TLBCAM */
diff --git a/arch/ppc/platforms/83xx/mpc834x_sys.c b/arch/ppc/platforms/83xx/mpc834x_sys.c
index e6348b5a1ddc..37ece1542799 100644
--- a/arch/ppc/platforms/83xx/mpc834x_sys.c
+++ b/arch/ppc/platforms/83xx/mpc834x_sys.c
@@ -41,7 +41,6 @@
41#include <asm/time.h> 41#include <asm/time.h>
42#include <asm/io.h> 42#include <asm/io.h>
43#include <asm/machdep.h> 43#include <asm/machdep.h>
44#include <asm/prom.h>
45#include <asm/ipic.h> 44#include <asm/ipic.h>
46#include <asm/bootinfo.h> 45#include <asm/bootinfo.h>
47#include <asm/pci-bridge.h> 46#include <asm/pci-bridge.h>
@@ -186,6 +185,26 @@ mpc834x_sys_init_IRQ(void)
186 ipic_set_default_priority(); 185 ipic_set_default_priority();
187} 186}
188 187
188#if defined(CONFIG_I2C_MPC) && defined(CONFIG_SENSORS_DS1374)
189extern ulong ds1374_get_rtc_time(void);
190extern int ds1374_set_rtc_time(ulong);
191
192static int __init
193mpc834x_rtc_hookup(void)
194{
195 struct timespec tv;
196
197 ppc_md.get_rtc_time = ds1374_get_rtc_time;
198 ppc_md.set_rtc_time = ds1374_set_rtc_time;
199
200 tv.tv_nsec = 0;
201 tv.tv_sec = (ppc_md.get_rtc_time)();
202 do_settimeofday(&tv);
203
204 return 0;
205}
206late_initcall(mpc834x_rtc_hookup);
207#endif
189static __inline__ void 208static __inline__ void
190mpc834x_sys_set_bat(void) 209mpc834x_sys_set_bat(void)
191{ 210{
diff --git a/arch/ppc/platforms/85xx/Kconfig b/arch/ppc/platforms/85xx/Kconfig
index ff92e38e7da1..c5bc2821d991 100644
--- a/arch/ppc/platforms/85xx/Kconfig
+++ b/arch/ppc/platforms/85xx/Kconfig
@@ -21,6 +21,11 @@ config MPC8540_ADS
21 help 21 help
22 This option enables support for the MPC 8540 ADS evaluation board. 22 This option enables support for the MPC 8540 ADS evaluation board.
23 23
24config MPC8548_CDS
25 bool "Freescale MPC8548 CDS"
26 help
27 This option enablese support for the MPC8548 CDS evaluation board.
28
24config MPC8555_CDS 29config MPC8555_CDS
25 bool "Freescale MPC8555 CDS" 30 bool "Freescale MPC8555 CDS"
26 help 31 help
@@ -53,6 +58,11 @@ config MPC8540
53 depends on MPC8540_ADS 58 depends on MPC8540_ADS
54 default y 59 default y
55 60
61config MPC8548
62 bool
63 depends on MPC8548_CDS
64 default y
65
56config MPC8555 66config MPC8555
57 bool 67 bool
58 depends on MPC8555_CDS 68 depends on MPC8555_CDS
diff --git a/arch/ppc/platforms/85xx/Makefile b/arch/ppc/platforms/85xx/Makefile
index 854fbd298ba2..efdf813108f2 100644
--- a/arch/ppc/platforms/85xx/Makefile
+++ b/arch/ppc/platforms/85xx/Makefile
@@ -2,6 +2,7 @@
2# Makefile for the PowerPC 85xx linux kernel. 2# Makefile for the PowerPC 85xx linux kernel.
3# 3#
4obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads_common.o mpc8540_ads.o 4obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads_common.o mpc8540_ads.o
5obj-$(CONFIG_MPC8548_CDS) += mpc85xx_cds_common.o
5obj-$(CONFIG_MPC8555_CDS) += mpc85xx_cds_common.o 6obj-$(CONFIG_MPC8555_CDS) += mpc85xx_cds_common.o
6obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads_common.o mpc8560_ads.o 7obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads_common.o mpc8560_ads.o
7obj-$(CONFIG_SBC8560) += sbc85xx.o sbc8560.o 8obj-$(CONFIG_SBC8560) += sbc85xx.o sbc8560.o
diff --git a/arch/ppc/platforms/85xx/mpc8540_ads.c b/arch/ppc/platforms/85xx/mpc8540_ads.c
index 583838ab02d8..a2ed611cd936 100644
--- a/arch/ppc/platforms/85xx/mpc8540_ads.c
+++ b/arch/ppc/platforms/85xx/mpc8540_ads.c
@@ -41,7 +41,6 @@
41#include <asm/time.h> 41#include <asm/time.h>
42#include <asm/io.h> 42#include <asm/io.h>
43#include <asm/machdep.h> 43#include <asm/machdep.h>
44#include <asm/prom.h>
45#include <asm/open_pic.h> 44#include <asm/open_pic.h>
46#include <asm/bootinfo.h> 45#include <asm/bootinfo.h>
47#include <asm/pci-bridge.h> 46#include <asm/pci-bridge.h>
@@ -88,7 +87,7 @@ mpc8540ads_setup_arch(void)
88#ifdef CONFIG_SERIAL_TEXT_DEBUG 87#ifdef CONFIG_SERIAL_TEXT_DEBUG
89 /* Invalidate the entry we stole earlier the serial ports 88 /* Invalidate the entry we stole earlier the serial ports
90 * should be properly mapped */ 89 * should be properly mapped */
91 invalidate_tlbcam_entry(NUM_TLBCAMS - 1); 90 invalidate_tlbcam_entry(num_tlbcam_entries - 1);
92#endif 91#endif
93 92
94 /* setup the board related information for the enet controllers */ 93 /* setup the board related information for the enet controllers */
@@ -150,7 +149,7 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
150 struct uart_port p; 149 struct uart_port p;
151 150
152 /* Use the last TLB entry to map CCSRBAR to allow access to DUART regs */ 151 /* Use the last TLB entry to map CCSRBAR to allow access to DUART regs */
153 settlbcam(NUM_TLBCAMS - 1, binfo->bi_immr_base, 152 settlbcam(num_tlbcam_entries - 1, binfo->bi_immr_base,
154 binfo->bi_immr_base, MPC85xx_CCSRBAR_SIZE, _PAGE_IO, 0); 153 binfo->bi_immr_base, MPC85xx_CCSRBAR_SIZE, _PAGE_IO, 0);
155 154
156 memset(&p, 0, sizeof (p)); 155 memset(&p, 0, sizeof (p));
diff --git a/arch/ppc/platforms/85xx/mpc8560_ads.c b/arch/ppc/platforms/85xx/mpc8560_ads.c
index 761b8c7b25d2..d87dfd5ce0a2 100644
--- a/arch/ppc/platforms/85xx/mpc8560_ads.c
+++ b/arch/ppc/platforms/85xx/mpc8560_ads.c
@@ -41,7 +41,6 @@
41#include <asm/time.h> 41#include <asm/time.h>
42#include <asm/io.h> 42#include <asm/io.h>
43#include <asm/machdep.h> 43#include <asm/machdep.h>
44#include <asm/prom.h>
45#include <asm/open_pic.h> 44#include <asm/open_pic.h>
46#include <asm/bootinfo.h> 45#include <asm/bootinfo.h>
47#include <asm/pci-bridge.h> 46#include <asm/pci-bridge.h>
diff --git a/arch/ppc/platforms/85xx/mpc85xx_ads_common.c b/arch/ppc/platforms/85xx/mpc85xx_ads_common.c
index ba9f9f562c45..18e952d1767c 100644
--- a/arch/ppc/platforms/85xx/mpc85xx_ads_common.c
+++ b/arch/ppc/platforms/85xx/mpc85xx_ads_common.c
@@ -36,7 +36,6 @@
36#include <asm/time.h> 36#include <asm/time.h>
37#include <asm/io.h> 37#include <asm/io.h>
38#include <asm/machdep.h> 38#include <asm/machdep.h>
39#include <asm/prom.h>
40#include <asm/open_pic.h> 39#include <asm/open_pic.h>
41#include <asm/bootinfo.h> 40#include <asm/bootinfo.h>
42#include <asm/pci-bridge.h> 41#include <asm/pci-bridge.h>
@@ -59,40 +58,8 @@ extern unsigned long total_memory; /* in mm/init */
59unsigned char __res[sizeof (bd_t)]; 58unsigned char __res[sizeof (bd_t)];
60 59
61/* Internal interrupts are all Level Sensitive, and Positive Polarity */ 60/* Internal interrupts are all Level Sensitive, and Positive Polarity */
62
63static u_char mpc85xx_ads_openpic_initsenses[] __initdata = { 61static u_char mpc85xx_ads_openpic_initsenses[] __initdata = {
64 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 0: L2 Cache */ 62 MPC85XX_INTERNAL_IRQ_SENSES,
65 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 1: ECM */
66 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 2: DDR DRAM */
67 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 3: LBIU */
68 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 4: DMA 0 */
69 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 5: DMA 1 */
70 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 6: DMA 2 */
71 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 7: DMA 3 */
72 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 8: PCI/PCI-X */
73 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 9: RIO Inbound Port Write Error */
74 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 10: RIO Doorbell Inbound */
75 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 11: RIO Outbound Message */
76 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 12: RIO Inbound Message */
77 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 13: TSEC 0 Transmit */
78 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 14: TSEC 0 Receive */
79 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 15: Unused */
80 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 16: Unused */
81 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 17: Unused */
82 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 18: TSEC 0 Receive/Transmit Error */
83 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 19: TSEC 1 Transmit */
84 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 20: TSEC 1 Receive */
85 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 21: Unused */
86 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 22: Unused */
87 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 23: Unused */
88 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 24: TSEC 1 Receive/Transmit Error */
89 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 25: Fast Ethernet */
90 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 26: DUART */
91 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 27: I2C */
92 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 28: Performance Monitor */
93 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 29: Unused */
94 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 30: CPM */
95 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 31: Unused */
96 0x0, /* External 0: */ 63 0x0, /* External 0: */
97#if defined(CONFIG_PCI) 64#if defined(CONFIG_PCI)
98 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 1: PCI slot 0 */ 65 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 1: PCI slot 0 */
@@ -159,7 +126,7 @@ mpc85xx_ads_init_IRQ(void)
159 /* Skip reserved space and internal sources */ 126 /* Skip reserved space and internal sources */
160 openpic_set_sources(0, 32, OpenPIC_Addr + 0x10200); 127 openpic_set_sources(0, 32, OpenPIC_Addr + 0x10200);
161 /* Map PIC IRQs 0-11 */ 128 /* Map PIC IRQs 0-11 */
162 openpic_set_sources(32, 12, OpenPIC_Addr + 0x10000); 129 openpic_set_sources(48, 12, OpenPIC_Addr + 0x10000);
163 130
164 /* we let openpic interrupts starting from an offset, to 131 /* we let openpic interrupts starting from an offset, to
165 * leave space for cascading interrupts underneath. 132 * leave space for cascading interrupts underneath.
diff --git a/arch/ppc/platforms/85xx/mpc85xx_cds_common.c b/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
index e7cfa498568c..203b2ca61df8 100644
--- a/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
+++ b/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
@@ -42,7 +42,6 @@
42#include <asm/todc.h> 42#include <asm/todc.h>
43#include <asm/io.h> 43#include <asm/io.h>
44#include <asm/machdep.h> 44#include <asm/machdep.h>
45#include <asm/prom.h>
46#include <asm/open_pic.h> 45#include <asm/open_pic.h>
47#include <asm/i8259.h> 46#include <asm/i8259.h>
48#include <asm/bootinfo.h> 47#include <asm/bootinfo.h>
@@ -73,40 +72,8 @@ static int cds_pci_slot = 2;
73static volatile u8 * cadmus; 72static volatile u8 * cadmus;
74 73
75/* Internal interrupts are all Level Sensitive, and Positive Polarity */ 74/* Internal interrupts are all Level Sensitive, and Positive Polarity */
76
77static u_char mpc85xx_cds_openpic_initsenses[] __initdata = { 75static u_char mpc85xx_cds_openpic_initsenses[] __initdata = {
78 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 0: L2 Cache */ 76 MPC85XX_INTERNAL_IRQ_SENSES,
79 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 1: ECM */
80 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 2: DDR DRAM */
81 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 3: LBIU */
82 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 4: DMA 0 */
83 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 5: DMA 1 */
84 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 6: DMA 2 */
85 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 7: DMA 3 */
86 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 8: PCI/PCI-X */
87 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 9: RIO Inbound Port Write Error */
88 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 10: RIO Doorbell Inbound */
89 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 11: RIO Outbound Message */
90 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 12: RIO Inbound Message */
91 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 13: TSEC 0 Transmit */
92 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 14: TSEC 0 Receive */
93 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 15: Unused */
94 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 16: Unused */
95 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 17: Unused */
96 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 18: TSEC 0 Receive/Transmit Error */
97 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 19: TSEC 1 Transmit */
98 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 20: TSEC 1 Receive */
99 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 21: Unused */
100 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 22: Unused */
101 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 23: Unused */
102 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 24: TSEC 1 Receive/Transmit Error */
103 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 25: Fast Ethernet */
104 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 26: DUART */
105 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 27: I2C */
106 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 28: Performance Monitor */
107 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 29: Unused */
108 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 30: CPM */
109 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 31: Unused */
110#if defined(CONFIG_PCI) 77#if defined(CONFIG_PCI)
111 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 0: PCI1 slot */ 78 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 0: PCI1 slot */
112 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 1: PCI1 slot */ 79 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 1: PCI1 slot */
@@ -182,7 +149,6 @@ void __init
182mpc85xx_cds_init_IRQ(void) 149mpc85xx_cds_init_IRQ(void)
183{ 150{
184 bd_t *binfo = (bd_t *) __res; 151 bd_t *binfo = (bd_t *) __res;
185 int i;
186 152
187 /* Determine the Physical Address of the OpenPIC regs */ 153 /* Determine the Physical Address of the OpenPIC regs */
188 phys_addr_t OpenPIC_PAddr = binfo->bi_immr_base + MPC85xx_OPENPIC_OFFSET; 154 phys_addr_t OpenPIC_PAddr = binfo->bi_immr_base + MPC85xx_OPENPIC_OFFSET;
@@ -191,9 +157,13 @@ mpc85xx_cds_init_IRQ(void)
191 OpenPIC_NumInitSenses = sizeof (mpc85xx_cds_openpic_initsenses); 157 OpenPIC_NumInitSenses = sizeof (mpc85xx_cds_openpic_initsenses);
192 158
193 /* Skip reserved space and internal sources */ 159 /* Skip reserved space and internal sources */
160#ifdef CONFIG_MPC8548
161 openpic_set_sources(0, 48, OpenPIC_Addr + 0x10200);
162#else
194 openpic_set_sources(0, 32, OpenPIC_Addr + 0x10200); 163 openpic_set_sources(0, 32, OpenPIC_Addr + 0x10200);
164#endif
195 /* Map PIC IRQs 0-11 */ 165 /* Map PIC IRQs 0-11 */
196 openpic_set_sources(32, 12, OpenPIC_Addr + 0x10000); 166 openpic_set_sources(48, 12, OpenPIC_Addr + 0x10000);
197 167
198 /* we let openpic interrupts starting from an offset, to 168 /* we let openpic interrupts starting from an offset, to
199 * leave space for cascading interrupts underneath. 169 * leave space for cascading interrupts underneath.
@@ -475,26 +445,52 @@ mpc85xx_cds_setup_arch(void)
475#ifdef CONFIG_SERIAL_TEXT_DEBUG 445#ifdef CONFIG_SERIAL_TEXT_DEBUG
476 /* Invalidate the entry we stole earlier the serial ports 446 /* Invalidate the entry we stole earlier the serial ports
477 * should be properly mapped */ 447 * should be properly mapped */
478 invalidate_tlbcam_entry(NUM_TLBCAMS - 1); 448 invalidate_tlbcam_entry(num_tlbcam_entries - 1);
479#endif 449#endif
480 450
481 /* setup the board related information for the enet controllers */ 451 /* setup the board related information for the enet controllers */
482 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1); 452 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1);
483 pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR; 453 if (pdata) {
484 pdata->interruptPHY = MPC85xx_IRQ_EXT5; 454 pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
485 pdata->phyid = 0; 455 pdata->interruptPHY = MPC85xx_IRQ_EXT5;
486 /* fixup phy address */ 456 pdata->phyid = 0;
487 pdata->phy_reg_addr += binfo->bi_immr_base; 457 /* fixup phy address */
488 memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6); 458 pdata->phy_reg_addr += binfo->bi_immr_base;
459 memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6);
460 }
489 461
490 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC2); 462 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC2);
491 pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR; 463 if (pdata) {
492 pdata->interruptPHY = MPC85xx_IRQ_EXT5; 464 pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
493 pdata->phyid = 1; 465 pdata->interruptPHY = MPC85xx_IRQ_EXT5;
494 /* fixup phy address */ 466 pdata->phyid = 1;
495 pdata->phy_reg_addr += binfo->bi_immr_base; 467 /* fixup phy address */
496 memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6); 468 pdata->phy_reg_addr += binfo->bi_immr_base;
469 memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6);
470 }
471
472 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_eTSEC1);
473 if (pdata) {
474 pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
475 pdata->interruptPHY = MPC85xx_IRQ_EXT5;
476 pdata->phyid = 0;
477 /* fixup phy address */
478 pdata->phy_reg_addr += binfo->bi_immr_base;
479 memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6);
480 }
481
482 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_eTSEC2);
483 if (pdata) {
484 pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
485 pdata->interruptPHY = MPC85xx_IRQ_EXT5;
486 pdata->phyid = 1;
487 /* fixup phy address */
488 pdata->phy_reg_addr += binfo->bi_immr_base;
489 memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6);
490 }
497 491
492 ppc_sys_device_remove(MPC85xx_eTSEC3);
493 ppc_sys_device_remove(MPC85xx_eTSEC4);
498 494
499#ifdef CONFIG_BLK_DEV_INITRD 495#ifdef CONFIG_BLK_DEV_INITRD
500 if (initrd_start) 496 if (initrd_start)
@@ -531,7 +527,7 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
531 struct uart_port p; 527 struct uart_port p;
532 528
533 /* Use the last TLB entry to map CCSRBAR to allow access to DUART regs */ 529 /* Use the last TLB entry to map CCSRBAR to allow access to DUART regs */
534 settlbcam(NUM_TLBCAMS - 1, binfo->bi_immr_base, 530 settlbcam(num_tlbcam_entries - 1, binfo->bi_immr_base,
535 binfo->bi_immr_base, MPC85xx_CCSRBAR_SIZE, _PAGE_IO, 0); 531 binfo->bi_immr_base, MPC85xx_CCSRBAR_SIZE, _PAGE_IO, 0);
536 532
537 memset(&p, 0, sizeof (p)); 533 memset(&p, 0, sizeof (p));
diff --git a/arch/ppc/platforms/85xx/sbc8560.c b/arch/ppc/platforms/85xx/sbc8560.c
index 7b9e1543e175..3dbdd73618eb 100644
--- a/arch/ppc/platforms/85xx/sbc8560.c
+++ b/arch/ppc/platforms/85xx/sbc8560.c
@@ -41,7 +41,6 @@
41#include <asm/time.h> 41#include <asm/time.h>
42#include <asm/io.h> 42#include <asm/io.h>
43#include <asm/machdep.h> 43#include <asm/machdep.h>
44#include <asm/prom.h>
45#include <asm/open_pic.h> 44#include <asm/open_pic.h>
46#include <asm/bootinfo.h> 45#include <asm/bootinfo.h>
47#include <asm/pci-bridge.h> 46#include <asm/pci-bridge.h>
@@ -125,7 +124,7 @@ sbc8560_setup_arch(void)
125#ifdef CONFIG_SERIAL_TEXT_DEBUG 124#ifdef CONFIG_SERIAL_TEXT_DEBUG
126 /* Invalidate the entry we stole earlier the serial ports 125 /* Invalidate the entry we stole earlier the serial ports
127 * should be properly mapped */ 126 * should be properly mapped */
128 invalidate_tlbcam_entry(NUM_TLBCAMS - 1); 127 invalidate_tlbcam_entry(num_tlbcam_entries - 1);
129#endif 128#endif
130 129
131 /* setup the board related information for the enet controllers */ 130 /* setup the board related information for the enet controllers */
@@ -176,7 +175,7 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
176 175
177#ifdef CONFIG_SERIAL_TEXT_DEBUG 176#ifdef CONFIG_SERIAL_TEXT_DEBUG
178 /* Use the last TLB entry to map CCSRBAR to allow access to DUART regs */ 177 /* Use the last TLB entry to map CCSRBAR to allow access to DUART regs */
179 settlbcam(NUM_TLBCAMS - 1, UARTA_ADDR, 178 settlbcam(num_tlbcam_entries - 1, UARTA_ADDR,
180 UARTA_ADDR, 0x1000, _PAGE_IO, 0); 179 UARTA_ADDR, 0x1000, _PAGE_IO, 0);
181#endif 180#endif
182 181
diff --git a/arch/ppc/platforms/85xx/sbc85xx.c b/arch/ppc/platforms/85xx/sbc85xx.c
index 2d638c1c1bd6..4f6d1ddd6fb8 100644
--- a/arch/ppc/platforms/85xx/sbc85xx.c
+++ b/arch/ppc/platforms/85xx/sbc85xx.c
@@ -35,7 +35,6 @@
35#include <asm/time.h> 35#include <asm/time.h>
36#include <asm/io.h> 36#include <asm/io.h>
37#include <asm/machdep.h> 37#include <asm/machdep.h>
38#include <asm/prom.h>
39#include <asm/open_pic.h> 38#include <asm/open_pic.h>
40#include <asm/bootinfo.h> 39#include <asm/bootinfo.h>
41#include <asm/pci-bridge.h> 40#include <asm/pci-bridge.h>
@@ -59,40 +58,8 @@ unsigned long pci_dram_offset = 0;
59extern unsigned long total_memory; /* in mm/init */ 58extern unsigned long total_memory; /* in mm/init */
60 59
61/* Internal interrupts are all Level Sensitive, and Positive Polarity */ 60/* Internal interrupts are all Level Sensitive, and Positive Polarity */
62
63static u_char sbc8560_openpic_initsenses[] __initdata = { 61static u_char sbc8560_openpic_initsenses[] __initdata = {
64 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 0: L2 Cache */ 62 MPC85XX_INTERNAL_IRQ_SENSES,
65 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 1: ECM */
66 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 2: DDR DRAM */
67 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 3: LBIU */
68 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 4: DMA 0 */
69 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 5: DMA 1 */
70 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 6: DMA 2 */
71 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 7: DMA 3 */
72 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 8: PCI/PCI-X */
73 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 9: RIO Inbound Port Write Error */
74 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 10: RIO Doorbell Inbound */
75 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 11: RIO Outbound Message */
76 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 12: RIO Inbound Message */
77 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 13: TSEC 0 Transmit */
78 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 14: TSEC 0 Receive */
79 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 15: Unused */
80 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 16: Unused */
81 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 17: Unused */
82 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 18: TSEC 0 Receive/Transmit Error */
83 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 19: TSEC 1 Transmit */
84 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 20: TSEC 1 Receive */
85 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 21: Unused */
86 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 22: Unused */
87 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 23: Unused */
88 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 24: TSEC 1 Receive/Transmit Error */
89 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 25: Fast Ethernet */
90 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 26: DUART */
91 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 27: I2C */
92 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 28: Performance Monitor */
93 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 29: Unused */
94 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 30: CPM */
95 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 31: Unused */
96 0x0, /* External 0: */ 63 0x0, /* External 0: */
97 0x0, /* External 1: */ 64 0x0, /* External 1: */
98#if defined(CONFIG_PCI) 65#if defined(CONFIG_PCI)
@@ -159,7 +126,7 @@ sbc8560_init_IRQ(void)
159 /* Skip reserved space and internal sources */ 126 /* Skip reserved space and internal sources */
160 openpic_set_sources(0, 32, OpenPIC_Addr + 0x10200); 127 openpic_set_sources(0, 32, OpenPIC_Addr + 0x10200);
161 /* Map PIC IRQs 0-11 */ 128 /* Map PIC IRQs 0-11 */
162 openpic_set_sources(32, 12, OpenPIC_Addr + 0x10000); 129 openpic_set_sources(48, 12, OpenPIC_Addr + 0x10000);
163 130
164 /* we let openpic interrupts starting from an offset, to 131 /* we let openpic interrupts starting from an offset, to
165 * leave space for cascading interrupts underneath. 132 * leave space for cascading interrupts underneath.
diff --git a/arch/ppc/platforms/85xx/stx_gp3.c b/arch/ppc/platforms/85xx/stx_gp3.c
index bc95836e417c..9455bb6b45e9 100644
--- a/arch/ppc/platforms/85xx/stx_gp3.c
+++ b/arch/ppc/platforms/85xx/stx_gp3.c
@@ -46,7 +46,6 @@
46#include <asm/time.h> 46#include <asm/time.h>
47#include <asm/io.h> 47#include <asm/io.h>
48#include <asm/machdep.h> 48#include <asm/machdep.h>
49#include <asm/prom.h>
50#include <asm/open_pic.h> 49#include <asm/open_pic.h>
51#include <asm/bootinfo.h> 50#include <asm/bootinfo.h>
52#include <asm/pci-bridge.h> 51#include <asm/pci-bridge.h>
@@ -72,38 +71,7 @@ unsigned long pci_dram_offset = 0;
72 71
73/* Internal interrupts are all Level Sensitive, and Positive Polarity */ 72/* Internal interrupts are all Level Sensitive, and Positive Polarity */
74static u8 gp3_openpic_initsenses[] __initdata = { 73static u8 gp3_openpic_initsenses[] __initdata = {
75 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 0: L2 Cache */ 74 MPC85XX_INTERNAL_IRQ_SENSES,
76 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 1: ECM */
77 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 2: DDR DRAM */
78 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 3: LBIU */
79 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 4: DMA 0 */
80 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 5: DMA 1 */
81 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 6: DMA 2 */
82 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 7: DMA 3 */
83 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 8: PCI/PCI-X */
84 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 9: RIO Inbound Port Write Error */
85 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 10: RIO Doorbell Inbound */
86 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 11: RIO Outbound Message */
87 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 12: RIO Inbound Message */
88 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 13: TSEC 0 Transmit */
89 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 14: TSEC 0 Receive */
90 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 15: Unused */
91 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 16: Unused */
92 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 17: Unused */
93 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 18: TSEC 0 Receive/Transmit Error */
94 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 19: TSEC 1 Transmit */
95 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 20: TSEC 1 Receive */
96 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 21: Unused */
97 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 22: Unused */
98 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 23: Unused */
99 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 24: TSEC 1 Receive/Transmit Error */
100 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 25: Fast Ethernet */
101 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 26: DUART */
102 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 27: I2C */
103 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 28: Performance Monitor */
104 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 29: Unused */
105 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 30: CPM */
106 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 31: Unused */
107 0x0, /* External 0: */ 75 0x0, /* External 0: */
108#if defined(CONFIG_PCI) 76#if defined(CONFIG_PCI)
109 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 1: PCI slot 0 */ 77 (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 1: PCI slot 0 */
@@ -200,7 +168,6 @@ static struct irqaction cpm2_irqaction = {
200static void __init 168static void __init
201gp3_init_IRQ(void) 169gp3_init_IRQ(void)
202{ 170{
203 int i;
204 bd_t *binfo = (bd_t *) __res; 171 bd_t *binfo = (bd_t *) __res;
205 172
206 /* 173 /*
@@ -218,7 +185,7 @@ gp3_init_IRQ(void)
218 openpic_set_sources(0, 32, OpenPIC_Addr + 0x10200); 185 openpic_set_sources(0, 32, OpenPIC_Addr + 0x10200);
219 186
220 /* Map PIC IRQs 0-11 */ 187 /* Map PIC IRQs 0-11 */
221 openpic_set_sources(32, 12, OpenPIC_Addr + 0x10000); 188 openpic_set_sources(48, 12, OpenPIC_Addr + 0x10000);
222 189
223 /* 190 /*
224 * Let openpic interrupts starting from an offset, to 191 * Let openpic interrupts starting from an offset, to
diff --git a/arch/ppc/platforms/sandpoint.c b/arch/ppc/platforms/sandpoint.c
index 531bfa0e4512..70e58f43f2b8 100644
--- a/arch/ppc/platforms/sandpoint.c
+++ b/arch/ppc/platforms/sandpoint.c
@@ -81,6 +81,7 @@
81#include <linux/serial.h> 81#include <linux/serial.h>
82#include <linux/tty.h> /* for linux/serial_core.h */ 82#include <linux/tty.h> /* for linux/serial_core.h */
83#include <linux/serial_core.h> 83#include <linux/serial_core.h>
84#include <linux/serial_8250.h>
84 85
85#include <asm/system.h> 86#include <asm/system.h>
86#include <asm/pgtable.h> 87#include <asm/pgtable.h>
@@ -99,6 +100,7 @@
99#include <asm/mpc10x.h> 100#include <asm/mpc10x.h>
100#include <asm/pci-bridge.h> 101#include <asm/pci-bridge.h>
101#include <asm/kgdb.h> 102#include <asm/kgdb.h>
103#include <asm/ppc_sys.h>
102 104
103#include "sandpoint.h" 105#include "sandpoint.h"
104 106
@@ -305,6 +307,24 @@ sandpoint_setup_arch(void)
305 /* Lookup PCI host bridges */ 307 /* Lookup PCI host bridges */
306 sandpoint_find_bridges(); 308 sandpoint_find_bridges();
307 309
310 if (strncmp (cur_ppc_sys_spec->ppc_sys_name, "8245", 4) == 0)
311 {
312 bd_t *bp = (bd_t *)__res;
313 struct plat_serial8250_port *pdata;
314 pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(MPC10X_DUART);
315
316 if (pdata)
317 {
318 pdata[0].uartclk = bp->bi_busfreq;
319 pdata[0].membase = ioremap(pdata[0].mapbase, 0x100);
320
321 /* this disables the 2nd serial port on the DUART
322 * since the sandpoint does not have it connected */
323 pdata[1].uartclk = 0;
324 pdata[1].irq = 0;
325 pdata[1].mapbase = 0;
326 }
327
308 printk(KERN_INFO "Motorola SPS Sandpoint Test Platform\n"); 328 printk(KERN_INFO "Motorola SPS Sandpoint Test Platform\n");
309 printk(KERN_INFO "Port by MontaVista Software, Inc. (source@mvista.com)\n"); 329 printk(KERN_INFO "Port by MontaVista Software, Inc. (source@mvista.com)\n");
310 330
diff --git a/arch/ppc/syslib/Makefile b/arch/ppc/syslib/Makefile
index 96acf85800d4..dec5bf4f6879 100644
--- a/arch/ppc/syslib/Makefile
+++ b/arch/ppc/syslib/Makefile
@@ -92,7 +92,7 @@ ifeq ($(CONFIG_SERIAL_MPSC_CONSOLE),y)
92obj-$(CONFIG_SERIAL_TEXT_DEBUG) += mv64x60_dbg.o 92obj-$(CONFIG_SERIAL_TEXT_DEBUG) += mv64x60_dbg.o
93endif 93endif
94obj-$(CONFIG_BOOTX_TEXT) += btext.o 94obj-$(CONFIG_BOOTX_TEXT) += btext.o
95obj-$(CONFIG_MPC10X_BRIDGE) += mpc10x_common.o indirect_pci.o 95obj-$(CONFIG_MPC10X_BRIDGE) += mpc10x_common.o indirect_pci.o ppc_sys.o
96obj-$(CONFIG_MPC10X_OPENPIC) += open_pic.o 96obj-$(CONFIG_MPC10X_OPENPIC) += open_pic.o
97obj-$(CONFIG_40x) += dcr.o 97obj-$(CONFIG_40x) += dcr.o
98obj-$(CONFIG_BOOKE) += dcr.o 98obj-$(CONFIG_BOOKE) += dcr.o
@@ -107,6 +107,7 @@ obj-$(CONFIG_83xx) += ipic.o ppc83xx_setup.o ppc_sys.o \
107ifeq ($(CONFIG_83xx),y) 107ifeq ($(CONFIG_83xx),y)
108obj-$(CONFIG_PCI) += indirect_pci.o pci_auto.o 108obj-$(CONFIG_PCI) += indirect_pci.o pci_auto.o
109endif 109endif
110obj-$(CONFIG_MPC8548_CDS) += todc_time.o
110obj-$(CONFIG_MPC8555_CDS) += todc_time.o 111obj-$(CONFIG_MPC8555_CDS) += todc_time.o
111obj-$(CONFIG_PPC_MPC52xx) += mpc52xx_setup.o mpc52xx_pic.o \ 112obj-$(CONFIG_PPC_MPC52xx) += mpc52xx_setup.o mpc52xx_pic.o \
112 mpc52xx_sys.o mpc52xx_devices.o ppc_sys.o 113 mpc52xx_sys.o mpc52xx_devices.o ppc_sys.o
diff --git a/arch/ppc/syslib/mpc10x_common.c b/arch/ppc/syslib/mpc10x_common.c
index fd93adfd464c..8fc5f4154521 100644
--- a/arch/ppc/syslib/mpc10x_common.c
+++ b/arch/ppc/syslib/mpc10x_common.c
@@ -21,6 +21,9 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/pci.h> 22#include <linux/pci.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/serial_8250.h>
25#include <linux/fsl_devices.h>
26#include <linux/device.h>
24 27
25#include <asm/byteorder.h> 28#include <asm/byteorder.h>
26#include <asm/io.h> 29#include <asm/io.h>
@@ -30,16 +33,7 @@
30#include <asm/pci-bridge.h> 33#include <asm/pci-bridge.h>
31#include <asm/open_pic.h> 34#include <asm/open_pic.h>
32#include <asm/mpc10x.h> 35#include <asm/mpc10x.h>
33#include <asm/ocp.h> 36#include <asm/ppc_sys.h>
34
35/* The OCP structure is fixed by code below, before OCP initialises.
36 paddr depends on where the board places the EUMB.
37 - fixed in mpc10x_bridge_init().
38 irq depends on two things:
39 > does the board use the EPIC at all? (PCORE does not).
40 > is the EPIC in serial or parallel mode?
41 - fixed in mpc10x_set_openpic().
42*/
43 37
44#ifdef CONFIG_MPC10X_OPENPIC 38#ifdef CONFIG_MPC10X_OPENPIC
45#ifdef CONFIG_EPIC_SERIAL_MODE 39#ifdef CONFIG_EPIC_SERIAL_MODE
@@ -50,35 +44,140 @@
50#define MPC10X_I2C_IRQ (EPIC_IRQ_BASE + NUM_8259_INTERRUPTS) 44#define MPC10X_I2C_IRQ (EPIC_IRQ_BASE + NUM_8259_INTERRUPTS)
51#define MPC10X_DMA0_IRQ (EPIC_IRQ_BASE + 1 + NUM_8259_INTERRUPTS) 45#define MPC10X_DMA0_IRQ (EPIC_IRQ_BASE + 1 + NUM_8259_INTERRUPTS)
52#define MPC10X_DMA1_IRQ (EPIC_IRQ_BASE + 2 + NUM_8259_INTERRUPTS) 46#define MPC10X_DMA1_IRQ (EPIC_IRQ_BASE + 2 + NUM_8259_INTERRUPTS)
47#define MPC10X_UART0_IRQ (EPIC_IRQ_BASE + 4 + NUM_8259_INTERRUPTS)
53#else 48#else
54#define MPC10X_I2C_IRQ OCP_IRQ_NA 49#define MPC10X_I2C_IRQ -1
55#define MPC10X_DMA0_IRQ OCP_IRQ_NA 50#define MPC10X_DMA0_IRQ -1
56#define MPC10X_DMA1_IRQ OCP_IRQ_NA 51#define MPC10X_DMA1_IRQ -1
52#define MPC10X_UART0_IRQ -1
57#endif 53#endif
58 54
59 55static struct fsl_i2c_platform_data mpc10x_i2c_pdata = {
60struct ocp_def core_ocp[] = { 56 .device_flags = 0,
61 { .vendor = OCP_VENDOR_INVALID
62 }
63}; 57};
64 58
65static struct ocp_fs_i2c_data mpc10x_i2c_data = { 59static struct plat_serial8250_port serial_platform_data[] = {
66 .flags = 0 60 [0] = {
61 .mapbase = 0x4500,
62 .iotype = UPIO_MEM,
63 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
64 },
65 [1] = {
66 .mapbase = 0x4600,
67 .iotype = UPIO_MEM,
68 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
69 },
70 { },
67}; 71};
68static struct ocp_def mpc10x_i2c_ocp = { 72
69 .vendor = OCP_VENDOR_MOTOROLA, 73struct platform_device ppc_sys_platform_devices[] = {
70 .function = OCP_FUNC_IIC, 74 [MPC10X_IIC1] = {
71 .index = 0, 75 .name = "fsl-i2c",
72 .additions = &mpc10x_i2c_data 76 .id = 1,
77 .dev.platform_data = &mpc10x_i2c_pdata,
78 .num_resources = 2,
79 .resource = (struct resource[]) {
80 {
81 .start = MPC10X_EUMB_I2C_OFFSET,
82 .end = MPC10X_EUMB_I2C_OFFSET +
83 MPC10X_EUMB_I2C_SIZE - 1,
84 .flags = IORESOURCE_MEM,
85 },
86 {
87 .flags = IORESOURCE_IRQ
88 },
89 },
90 },
91 [MPC10X_DMA0] = {
92 .name = "fsl-dma",
93 .id = 0,
94 .num_resources = 2,
95 .resource = (struct resource[]) {
96 {
97 .start = MPC10X_EUMB_DMA_OFFSET + 0x10,
98 .end = MPC10X_EUMB_DMA_OFFSET + 0x1f,
99 .flags = IORESOURCE_MEM,
100 },
101 {
102 .flags = IORESOURCE_IRQ,
103 },
104 },
105 },
106 [MPC10X_DMA1] = {
107 .name = "fsl-dma",
108 .id = 1,
109 .num_resources = 2,
110 .resource = (struct resource[]) {
111 {
112 .start = MPC10X_EUMB_DMA_OFFSET + 0x20,
113 .end = MPC10X_EUMB_DMA_OFFSET + 0x2f,
114 .flags = IORESOURCE_MEM,
115 },
116 {
117 .flags = IORESOURCE_IRQ,
118 },
119 },
120 },
121 [MPC10X_DMA1] = {
122 .name = "fsl-dma",
123 .id = 1,
124 .num_resources = 2,
125 .resource = (struct resource[]) {
126 {
127 .start = MPC10X_EUMB_DMA_OFFSET + 0x20,
128 .end = MPC10X_EUMB_DMA_OFFSET + 0x2f,
129 .flags = IORESOURCE_MEM,
130 },
131 {
132 .flags = IORESOURCE_IRQ,
133 },
134 },
135 },
136 [MPC10X_DUART] = {
137 .name = "serial8250",
138 .id = 0,
139 .dev.platform_data = serial_platform_data,
140 },
73}; 141};
74 142
75static struct ocp_def mpc10x_dma_ocp[2] = { 143/* We use the PCI ID to match on */
76{ .vendor = OCP_VENDOR_MOTOROLA, 144struct ppc_sys_spec *cur_ppc_sys_spec;
77 .function = OCP_FUNC_DMA, 145struct ppc_sys_spec ppc_sys_specs[] = {
78 .index = 0 }, 146 {
79{ .vendor = OCP_VENDOR_MOTOROLA, 147 .ppc_sys_name = "8245",
80 .function = OCP_FUNC_DMA, 148 .mask = 0xFFFFFFFF,
81 .index = 1 } 149 .value = MPC10X_BRIDGE_8245,
150 .num_devices = 4,
151 .device_list = (enum ppc_sys_devices[])
152 {
153 MPC10X_IIC1, MPC10X_DMA0, MPC10X_DMA1, MPC10X_DUART,
154 },
155 },
156 {
157 .ppc_sys_name = "8240",
158 .mask = 0xFFFFFFFF,
159 .value = MPC10X_BRIDGE_8240,
160 .num_devices = 3,
161 .device_list = (enum ppc_sys_devices[])
162 {
163 MPC10X_IIC1, MPC10X_DMA0, MPC10X_DMA1,
164 },
165 },
166 {
167 .ppc_sys_name = "107",
168 .mask = 0xFFFFFFFF,
169 .value = MPC10X_BRIDGE_107,
170 .num_devices = 3,
171 .device_list = (enum ppc_sys_devices[])
172 {
173 MPC10X_IIC1, MPC10X_DMA0, MPC10X_DMA1,
174 },
175 },
176 { /* default match */
177 .ppc_sys_name = "",
178 .mask = 0x00000000,
179 .value = 0x00000000,
180 },
82}; 181};
83 182
84/* Set resources to match bridge memory map */ 183/* Set resources to match bridge memory map */
@@ -132,7 +231,7 @@ mpc10x_bridge_init(struct pci_controller *hose,
132 uint new_map, 231 uint new_map,
133 uint phys_eumb_base) 232 uint phys_eumb_base)
134{ 233{
135 int host_bridge, picr1, picr1_bit; 234 int host_bridge, picr1, picr1_bit, i;
136 ulong pci_config_addr, pci_config_data; 235 ulong pci_config_addr, pci_config_data;
137 u_char pir, byte; 236 u_char pir, byte;
138 237
@@ -273,7 +372,7 @@ mpc10x_bridge_init(struct pci_controller *hose,
273 printk("Host bridge in Agent mode\n"); 372 printk("Host bridge in Agent mode\n");
274 /* Read or Set LMBAR & PCSRBAR? */ 373 /* Read or Set LMBAR & PCSRBAR? */
275 } 374 }
276 375
277 /* Set base addr of the 8240/107 EUMB. */ 376 /* Set base addr of the 8240/107 EUMB. */
278 early_write_config_dword(hose, 377 early_write_config_dword(hose,
279 0, 378 0,
@@ -287,17 +386,6 @@ mpc10x_bridge_init(struct pci_controller *hose,
287 ioremap(phys_eumb_base + MPC10X_EUMB_EPIC_OFFSET, 386 ioremap(phys_eumb_base + MPC10X_EUMB_EPIC_OFFSET,
288 MPC10X_EUMB_EPIC_SIZE); 387 MPC10X_EUMB_EPIC_SIZE);
289#endif 388#endif
290 mpc10x_i2c_ocp.paddr = phys_eumb_base + MPC10X_EUMB_I2C_OFFSET;
291 mpc10x_i2c_ocp.irq = MPC10X_I2C_IRQ;
292 ocp_add_one_device(&mpc10x_i2c_ocp);
293 mpc10x_dma_ocp[0].paddr = phys_eumb_base +
294 MPC10X_EUMB_DMA_OFFSET + 0x100;
295 mpc10x_dma_ocp[0].irq = MPC10X_DMA0_IRQ;
296 ocp_add_one_device(&mpc10x_dma_ocp[0]);
297 mpc10x_dma_ocp[1].paddr = phys_eumb_base +
298 MPC10X_EUMB_DMA_OFFSET + 0x200;
299 mpc10x_dma_ocp[1].irq = MPC10X_DMA1_IRQ;
300 ocp_add_one_device(&mpc10x_dma_ocp[1]);
301 } 389 }
302 390
303#ifdef CONFIG_MPC10X_STORE_GATHERING 391#ifdef CONFIG_MPC10X_STORE_GATHERING
@@ -306,6 +394,29 @@ mpc10x_bridge_init(struct pci_controller *hose,
306 mpc10x_disable_store_gathering(hose); 394 mpc10x_disable_store_gathering(hose);
307#endif 395#endif
308 396
397 /* setup platform devices for MPC10x bridges */
398 identify_ppc_sys_by_id (host_bridge);
399
400 for (i = 0; i < cur_ppc_sys_spec->num_devices; i++) {
401 unsigned int dev_id = cur_ppc_sys_spec->device_list[i];
402 ppc_sys_fixup_mem_resource(&ppc_sys_platform_devices[dev_id],
403 phys_eumb_base);
404 }
405
406 /* IRQ's are determined at runtime */
407 ppc_sys_platform_devices[MPC10X_IIC1].resource[1].start = MPC10X_I2C_IRQ;
408 ppc_sys_platform_devices[MPC10X_IIC1].resource[1].end = MPC10X_I2C_IRQ;
409 ppc_sys_platform_devices[MPC10X_DMA0].resource[1].start = MPC10X_DMA0_IRQ;
410 ppc_sys_platform_devices[MPC10X_DMA0].resource[1].end = MPC10X_DMA0_IRQ;
411 ppc_sys_platform_devices[MPC10X_DMA1].resource[1].start = MPC10X_DMA1_IRQ;
412 ppc_sys_platform_devices[MPC10X_DMA1].resource[1].end = MPC10X_DMA1_IRQ;
413
414 serial_platform_data[0].mapbase += phys_eumb_base;
415 serial_platform_data[0].irq = MPC10X_UART0_IRQ;
416
417 serial_platform_data[1].mapbase += phys_eumb_base;
418 serial_platform_data[1].irq = MPC10X_UART0_IRQ + 1;
419
309 /* 420 /*
310 * 8240 erratum 26, 8241/8245 erratum 29, 107 erratum 23: speculative 421 * 8240 erratum 26, 8241/8245 erratum 29, 107 erratum 23: speculative
311 * PCI reads may return stale data so turn off. 422 * PCI reads may return stale data so turn off.
@@ -330,7 +441,7 @@ mpc10x_bridge_init(struct pci_controller *hose,
330 * 8245 (Rev 2., dated 10/2003) says PICR2[0] is reserverd. 441 * 8245 (Rev 2., dated 10/2003) says PICR2[0] is reserverd.
331 */ 442 */
332 if (host_bridge == MPC10X_BRIDGE_8245) { 443 if (host_bridge == MPC10X_BRIDGE_8245) {
333 ulong picr2; 444 u32 picr2;
334 445
335 early_read_config_dword(hose, 0, PCI_DEVFN(0,0), 446 early_read_config_dword(hose, 0, PCI_DEVFN(0,0),
336 MPC10X_CFG_PICR2_REG, &picr2); 447 MPC10X_CFG_PICR2_REG, &picr2);
@@ -504,6 +615,8 @@ void __init mpc10x_set_openpic(void)
504 openpic_set_sources(EPIC_IRQ_BASE, 3, OpenPIC_Addr + 0x11020); 615 openpic_set_sources(EPIC_IRQ_BASE, 3, OpenPIC_Addr + 0x11020);
505 /* Skip reserved space and map Message Unit Interrupt (I2O) */ 616 /* Skip reserved space and map Message Unit Interrupt (I2O) */
506 openpic_set_sources(EPIC_IRQ_BASE + 3, 1, OpenPIC_Addr + 0x110C0); 617 openpic_set_sources(EPIC_IRQ_BASE + 3, 1, OpenPIC_Addr + 0x110C0);
618 /* Skip reserved space and map Serial Interupts */
619 openpic_set_sources(EPIC_IRQ_BASE + 4, 2, OpenPIC_Addr + 0x11120);
507 620
508 openpic_init(NUM_8259_INTERRUPTS); 621 openpic_init(NUM_8259_INTERRUPTS);
509} 622}
diff --git a/arch/ppc/syslib/mpc85xx_devices.c b/arch/ppc/syslib/mpc85xx_devices.c
index 1e658ef57e75..8af322dd476a 100644
--- a/arch/ppc/syslib/mpc85xx_devices.c
+++ b/arch/ppc/syslib/mpc85xx_devices.c
@@ -40,6 +40,42 @@ static struct gianfar_platform_data mpc85xx_tsec2_pdata = {
40 .phy_reg_addr = MPC85xx_ENET1_OFFSET, 40 .phy_reg_addr = MPC85xx_ENET1_OFFSET,
41}; 41};
42 42
43static struct gianfar_platform_data mpc85xx_etsec1_pdata = {
44 .device_flags = FSL_GIANFAR_DEV_HAS_GIGABIT |
45 FSL_GIANFAR_DEV_HAS_COALESCE | FSL_GIANFAR_DEV_HAS_RMON |
46 FSL_GIANFAR_DEV_HAS_MULTI_INTR |
47 FSL_GIANFAR_DEV_HAS_CSUM | FSL_GIANFAR_DEV_HAS_VLAN |
48 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH,
49 .phy_reg_addr = MPC85xx_ENET1_OFFSET,
50};
51
52static struct gianfar_platform_data mpc85xx_etsec2_pdata = {
53 .device_flags = FSL_GIANFAR_DEV_HAS_GIGABIT |
54 FSL_GIANFAR_DEV_HAS_COALESCE | FSL_GIANFAR_DEV_HAS_RMON |
55 FSL_GIANFAR_DEV_HAS_MULTI_INTR |
56 FSL_GIANFAR_DEV_HAS_CSUM | FSL_GIANFAR_DEV_HAS_VLAN |
57 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH,
58 .phy_reg_addr = MPC85xx_ENET1_OFFSET,
59};
60
61static struct gianfar_platform_data mpc85xx_etsec3_pdata = {
62 .device_flags = FSL_GIANFAR_DEV_HAS_GIGABIT |
63 FSL_GIANFAR_DEV_HAS_COALESCE | FSL_GIANFAR_DEV_HAS_RMON |
64 FSL_GIANFAR_DEV_HAS_MULTI_INTR |
65 FSL_GIANFAR_DEV_HAS_CSUM | FSL_GIANFAR_DEV_HAS_VLAN |
66 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH,
67 .phy_reg_addr = MPC85xx_ENET1_OFFSET,
68};
69
70static struct gianfar_platform_data mpc85xx_etsec4_pdata = {
71 .device_flags = FSL_GIANFAR_DEV_HAS_GIGABIT |
72 FSL_GIANFAR_DEV_HAS_COALESCE | FSL_GIANFAR_DEV_HAS_RMON |
73 FSL_GIANFAR_DEV_HAS_MULTI_INTR |
74 FSL_GIANFAR_DEV_HAS_CSUM | FSL_GIANFAR_DEV_HAS_VLAN |
75 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH,
76 .phy_reg_addr = MPC85xx_ENET1_OFFSET,
77};
78
43static struct gianfar_platform_data mpc85xx_fec_pdata = { 79static struct gianfar_platform_data mpc85xx_fec_pdata = {
44 .phy_reg_addr = MPC85xx_ENET1_OFFSET, 80 .phy_reg_addr = MPC85xx_ENET1_OFFSET,
45}; 81};
@@ -48,6 +84,10 @@ static struct fsl_i2c_platform_data mpc85xx_fsl_i2c_pdata = {
48 .device_flags = FSL_I2C_DEV_SEPARATE_DFSRR, 84 .device_flags = FSL_I2C_DEV_SEPARATE_DFSRR,
49}; 85};
50 86
87static struct fsl_i2c_platform_data mpc85xx_fsl_i2c2_pdata = {
88 .device_flags = FSL_I2C_DEV_SEPARATE_DFSRR,
89};
90
51static struct plat_serial8250_port serial_platform_data[] = { 91static struct plat_serial8250_port serial_platform_data[] = {
52 [0] = { 92 [0] = {
53 .mapbase = 0x4500, 93 .mapbase = 0x4500,
@@ -281,7 +321,6 @@ struct platform_device ppc_sys_platform_devices[] = {
281 }, 321 },
282 }, 322 },
283 }, 323 },
284#ifdef CONFIG_CPM2
285 [MPC85xx_CPM_FCC1] = { 324 [MPC85xx_CPM_FCC1] = {
286 .name = "fsl-cpm-fcc", 325 .name = "fsl-cpm-fcc",
287 .id = 1, 326 .id = 1,
@@ -535,7 +574,151 @@ struct platform_device ppc_sys_platform_devices[] = {
535 }, 574 },
536 }, 575 },
537 }, 576 },
538#endif /* CONFIG_CPM2 */ 577 [MPC85xx_eTSEC1] = {
578 .name = "fsl-gianfar",
579 .id = 1,
580 .dev.platform_data = &mpc85xx_etsec1_pdata,
581 .num_resources = 4,
582 .resource = (struct resource[]) {
583 {
584 .start = MPC85xx_ENET1_OFFSET,
585 .end = MPC85xx_ENET1_OFFSET +
586 MPC85xx_ENET1_SIZE - 1,
587 .flags = IORESOURCE_MEM,
588 },
589 {
590 .name = "tx",
591 .start = MPC85xx_IRQ_TSEC1_TX,
592 .end = MPC85xx_IRQ_TSEC1_TX,
593 .flags = IORESOURCE_IRQ,
594 },
595 {
596 .name = "rx",
597 .start = MPC85xx_IRQ_TSEC1_RX,
598 .end = MPC85xx_IRQ_TSEC1_RX,
599 .flags = IORESOURCE_IRQ,
600 },
601 {
602 .name = "error",
603 .start = MPC85xx_IRQ_TSEC1_ERROR,
604 .end = MPC85xx_IRQ_TSEC1_ERROR,
605 .flags = IORESOURCE_IRQ,
606 },
607 },
608 },
609 [MPC85xx_eTSEC2] = {
610 .name = "fsl-gianfar",
611 .id = 2,
612 .dev.platform_data = &mpc85xx_etsec2_pdata,
613 .num_resources = 4,
614 .resource = (struct resource[]) {
615 {
616 .start = MPC85xx_ENET2_OFFSET,
617 .end = MPC85xx_ENET2_OFFSET +
618 MPC85xx_ENET2_SIZE - 1,
619 .flags = IORESOURCE_MEM,
620 },
621 {
622 .name = "tx",
623 .start = MPC85xx_IRQ_TSEC2_TX,
624 .end = MPC85xx_IRQ_TSEC2_TX,
625 .flags = IORESOURCE_IRQ,
626 },
627 {
628 .name = "rx",
629 .start = MPC85xx_IRQ_TSEC2_RX,
630 .end = MPC85xx_IRQ_TSEC2_RX,
631 .flags = IORESOURCE_IRQ,
632 },
633 {
634 .name = "error",
635 .start = MPC85xx_IRQ_TSEC2_ERROR,
636 .end = MPC85xx_IRQ_TSEC2_ERROR,
637 .flags = IORESOURCE_IRQ,
638 },
639 },
640 },
641 [MPC85xx_eTSEC3] = {
642 .name = "fsl-gianfar",
643 .id = 3,
644 .dev.platform_data = &mpc85xx_etsec3_pdata,
645 .num_resources = 4,
646 .resource = (struct resource[]) {
647 {
648 .start = MPC85xx_ENET3_OFFSET,
649 .end = MPC85xx_ENET3_OFFSET +
650 MPC85xx_ENET3_SIZE - 1,
651 .flags = IORESOURCE_MEM,
652 },
653 {
654 .name = "tx",
655 .start = MPC85xx_IRQ_TSEC3_TX,
656 .end = MPC85xx_IRQ_TSEC3_TX,
657 .flags = IORESOURCE_IRQ,
658 },
659 {
660 .name = "rx",
661 .start = MPC85xx_IRQ_TSEC3_RX,
662 .end = MPC85xx_IRQ_TSEC3_RX,
663 .flags = IORESOURCE_IRQ,
664 },
665 {
666 .name = "error",
667 .start = MPC85xx_IRQ_TSEC3_ERROR,
668 .end = MPC85xx_IRQ_TSEC3_ERROR,
669 .flags = IORESOURCE_IRQ,
670 },
671 },
672 },
673 [MPC85xx_eTSEC4] = {
674 .name = "fsl-gianfar",
675 .id = 4,
676 .dev.platform_data = &mpc85xx_etsec4_pdata,
677 .num_resources = 4,
678 .resource = (struct resource[]) {
679 {
680 .start = 0x27000,
681 .end = 0x27fff,
682 .flags = IORESOURCE_MEM,
683 },
684 {
685 .name = "tx",
686 .start = MPC85xx_IRQ_TSEC4_TX,
687 .end = MPC85xx_IRQ_TSEC4_TX,
688 .flags = IORESOURCE_IRQ,
689 },
690 {
691 .name = "rx",
692 .start = MPC85xx_IRQ_TSEC4_RX,
693 .end = MPC85xx_IRQ_TSEC4_RX,
694 .flags = IORESOURCE_IRQ,
695 },
696 {
697 .name = "error",
698 .start = MPC85xx_IRQ_TSEC4_ERROR,
699 .end = MPC85xx_IRQ_TSEC4_ERROR,
700 .flags = IORESOURCE_IRQ,
701 },
702 },
703 },
704 [MPC85xx_IIC2] = {
705 .name = "fsl-i2c",
706 .id = 2,
707 .dev.platform_data = &mpc85xx_fsl_i2c2_pdata,
708 .num_resources = 2,
709 .resource = (struct resource[]) {
710 {
711 .start = 0x03100,
712 .end = 0x031ff,
713 .flags = IORESOURCE_MEM,
714 },
715 {
716 .start = MPC85xx_IRQ_IIC1,
717 .end = MPC85xx_IRQ_IIC1,
718 .flags = IORESOURCE_IRQ,
719 },
720 },
721 },
539}; 722};
540 723
541static int __init mach_mpc85xx_fixup(struct platform_device *pdev) 724static int __init mach_mpc85xx_fixup(struct platform_device *pdev)
diff --git a/arch/ppc/syslib/mpc85xx_sys.c b/arch/ppc/syslib/mpc85xx_sys.c
index d806a92a9401..6e3184ab354f 100644
--- a/arch/ppc/syslib/mpc85xx_sys.c
+++ b/arch/ppc/syslib/mpc85xx_sys.c
@@ -110,6 +110,111 @@ struct ppc_sys_spec ppc_sys_specs[] = {
110 MPC85xx_CPM_USB, 110 MPC85xx_CPM_USB,
111 }, 111 },
112 }, 112 },
113 /* SVRs on 8548 rev1.0 matches for 8548/8547/8545 */
114 {
115 .ppc_sys_name = "8548E",
116 .mask = 0xFFFF00F0,
117 .value = 0x80390010,
118 .num_devices = 13,
119 .device_list = (enum ppc_sys_devices[])
120 {
121 MPC85xx_eTSEC1, MPC85xx_eTSEC2, MPC85xx_eTSEC3,
122 MPC85xx_eTSEC4, MPC85xx_IIC1, MPC85xx_IIC2,
123 MPC85xx_DMA0, MPC85xx_DMA1, MPC85xx_DMA2, MPC85xx_DMA3,
124 MPC85xx_PERFMON, MPC85xx_DUART, MPC85xx_SEC2,
125 },
126 },
127 {
128 .ppc_sys_name = "8548",
129 .mask = 0xFFFF00F0,
130 .value = 0x80310010,
131 .num_devices = 12,
132 .device_list = (enum ppc_sys_devices[])
133 {
134 MPC85xx_eTSEC1, MPC85xx_eTSEC2, MPC85xx_eTSEC3,
135 MPC85xx_eTSEC4, MPC85xx_IIC1, MPC85xx_IIC2,
136 MPC85xx_DMA0, MPC85xx_DMA1, MPC85xx_DMA2, MPC85xx_DMA3,
137 MPC85xx_PERFMON, MPC85xx_DUART,
138 },
139 },
140 {
141 .ppc_sys_name = "8547E",
142 .mask = 0xFFFF00F0,
143 .value = 0x80390010,
144 .num_devices = 13,
145 .device_list = (enum ppc_sys_devices[])
146 {
147 MPC85xx_eTSEC1, MPC85xx_eTSEC2, MPC85xx_eTSEC3,
148 MPC85xx_eTSEC4, MPC85xx_IIC1, MPC85xx_IIC2,
149 MPC85xx_DMA0, MPC85xx_DMA1, MPC85xx_DMA2, MPC85xx_DMA3,
150 MPC85xx_PERFMON, MPC85xx_DUART, MPC85xx_SEC2,
151 },
152 },
153 {
154 .ppc_sys_name = "8547",
155 .mask = 0xFFFF00F0,
156 .value = 0x80310010,
157 .num_devices = 12,
158 .device_list = (enum ppc_sys_devices[])
159 {
160 MPC85xx_eTSEC1, MPC85xx_eTSEC2, MPC85xx_eTSEC3,
161 MPC85xx_eTSEC4, MPC85xx_IIC1, MPC85xx_IIC2,
162 MPC85xx_DMA0, MPC85xx_DMA1, MPC85xx_DMA2, MPC85xx_DMA3,
163 MPC85xx_PERFMON, MPC85xx_DUART,
164 },
165 },
166 {
167 .ppc_sys_name = "8545E",
168 .mask = 0xFFFF00F0,
169 .value = 0x80390010,
170 .num_devices = 11,
171 .device_list = (enum ppc_sys_devices[])
172 {
173 MPC85xx_eTSEC1, MPC85xx_eTSEC2,
174 MPC85xx_IIC1, MPC85xx_IIC2,
175 MPC85xx_DMA0, MPC85xx_DMA1, MPC85xx_DMA2, MPC85xx_DMA3,
176 MPC85xx_PERFMON, MPC85xx_DUART, MPC85xx_SEC2,
177 },
178 },
179 {
180 .ppc_sys_name = "8545",
181 .mask = 0xFFFF00F0,
182 .value = 0x80310010,
183 .num_devices = 10,
184 .device_list = (enum ppc_sys_devices[])
185 {
186 MPC85xx_eTSEC1, MPC85xx_eTSEC2,
187 MPC85xx_IIC1, MPC85xx_IIC2,
188 MPC85xx_DMA0, MPC85xx_DMA1, MPC85xx_DMA2, MPC85xx_DMA3,
189 MPC85xx_PERFMON, MPC85xx_DUART,
190 },
191 },
192 {
193 .ppc_sys_name = "8543E",
194 .mask = 0xFFFF00F0,
195 .value = 0x803A0010,
196 .num_devices = 11,
197 .device_list = (enum ppc_sys_devices[])
198 {
199 MPC85xx_eTSEC1, MPC85xx_eTSEC2,
200 MPC85xx_IIC1, MPC85xx_IIC2,
201 MPC85xx_DMA0, MPC85xx_DMA1, MPC85xx_DMA2, MPC85xx_DMA3,
202 MPC85xx_PERFMON, MPC85xx_DUART, MPC85xx_SEC2,
203 },
204 },
205 {
206 .ppc_sys_name = "8543",
207 .mask = 0xFFFF00F0,
208 .value = 0x80320010,
209 .num_devices = 10,
210 .device_list = (enum ppc_sys_devices[])
211 {
212 MPC85xx_eTSEC1, MPC85xx_eTSEC2,
213 MPC85xx_IIC1, MPC85xx_IIC2,
214 MPC85xx_DMA0, MPC85xx_DMA1, MPC85xx_DMA2, MPC85xx_DMA3,
215 MPC85xx_PERFMON, MPC85xx_DUART,
216 },
217 },
113 { /* default match */ 218 { /* default match */
114 .ppc_sys_name = "", 219 .ppc_sys_name = "",
115 .mask = 0x00000000, 220 .mask = 0x00000000,
diff --git a/arch/ppc/syslib/open_pic.c b/arch/ppc/syslib/open_pic.c
index 000ba47c67cb..b45d8268bf93 100644
--- a/arch/ppc/syslib/open_pic.c
+++ b/arch/ppc/syslib/open_pic.c
@@ -21,7 +21,6 @@
21#include <asm/signal.h> 21#include <asm/signal.h>
22#include <asm/io.h> 22#include <asm/io.h>
23#include <asm/irq.h> 23#include <asm/irq.h>
24#include <asm/prom.h>
25#include <asm/sections.h> 24#include <asm/sections.h>
26#include <asm/open_pic.h> 25#include <asm/open_pic.h>
27#include <asm/i8259.h> 26#include <asm/i8259.h>
diff --git a/arch/ppc/syslib/open_pic2.c b/arch/ppc/syslib/open_pic2.c
index ea26da0d8b6b..7e272c51a497 100644
--- a/arch/ppc/syslib/open_pic2.c
+++ b/arch/ppc/syslib/open_pic2.c
@@ -25,7 +25,6 @@
25#include <asm/signal.h> 25#include <asm/signal.h>
26#include <asm/io.h> 26#include <asm/io.h>
27#include <asm/irq.h> 27#include <asm/irq.h>
28#include <asm/prom.h>
29#include <asm/sections.h> 28#include <asm/sections.h>
30#include <asm/open_pic.h> 29#include <asm/open_pic.h>
31#include <asm/i8259.h> 30#include <asm/i8259.h>
diff --git a/arch/ppc/syslib/ppc4xx_kgdb.c b/arch/ppc/syslib/ppc4xx_kgdb.c
deleted file mode 100644
index fe8668bf8137..000000000000
--- a/arch/ppc/syslib/ppc4xx_kgdb.c
+++ /dev/null
@@ -1,124 +0,0 @@
1#include <linux/config.h>
2#include <linux/types.h>
3#include <asm/ibm4xx.h>
4#include <linux/kernel.h>
5
6
7
8#define LSR_DR 0x01 /* Data ready */
9#define LSR_OE 0x02 /* Overrun */
10#define LSR_PE 0x04 /* Parity error */
11#define LSR_FE 0x08 /* Framing error */
12#define LSR_BI 0x10 /* Break */
13#define LSR_THRE 0x20 /* Xmit holding register empty */
14#define LSR_TEMT 0x40 /* Xmitter empty */
15#define LSR_ERR 0x80 /* Error */
16
17#include <platforms/4xx/ibm_ocp.h>
18
19extern struct NS16550* COM_PORTS[];
20#ifndef NULL
21#define NULL 0x00
22#endif
23
24static volatile struct NS16550 *kgdb_debugport = NULL;
25
26volatile struct NS16550 *
27NS16550_init(int chan)
28{
29 volatile struct NS16550 *com_port;
30 int quot;
31#ifdef BASE_BAUD
32 quot = BASE_BAUD / 9600;
33#else
34 quot = 0x000c; /* 0xc = 9600 baud (on a pc) */
35#endif
36
37 com_port = (struct NS16550 *) COM_PORTS[chan];
38
39 com_port->lcr = 0x00;
40 com_port->ier = 0xFF;
41 com_port->ier = 0x00;
42 com_port->lcr = com_port->lcr | 0x80; /* Access baud rate */
43 com_port->dll = ( quot & 0x00ff ); /* 0xc = 9600 baud */
44 com_port->dlm = ( quot & 0xff00 ) >> 8;
45 com_port->lcr = 0x03; /* 8 data, 1 stop, no parity */
46 com_port->mcr = 0x00; /* RTS/DTR */
47 com_port->fcr = 0x07; /* Clear & enable FIFOs */
48
49 return( com_port );
50}
51
52
53void
54NS16550_putc(volatile struct NS16550 *com_port, unsigned char c)
55{
56 while ((com_port->lsr & LSR_THRE) == 0)
57 ;
58 com_port->thr = c;
59 return;
60}
61
62unsigned char
63NS16550_getc(volatile struct NS16550 *com_port)
64{
65 while ((com_port->lsr & LSR_DR) == 0)
66 ;
67 return (com_port->rbr);
68}
69
70unsigned char
71NS16550_tstc(volatile struct NS16550 *com_port)
72{
73 return ((com_port->lsr & LSR_DR) != 0);
74}
75
76
77#if defined(CONFIG_KGDB_TTYS0)
78#define KGDB_PORT 0
79#elif defined(CONFIG_KGDB_TTYS1)
80#define KGDB_PORT 1
81#elif defined(CONFIG_KGDB_TTYS2)
82#define KGDB_PORT 2
83#elif defined(CONFIG_KGDB_TTYS3)
84#define KGDB_PORT 3
85#else
86#error "invalid kgdb_tty port"
87#endif
88
89void putDebugChar( unsigned char c )
90{
91 if ( kgdb_debugport == NULL )
92 kgdb_debugport = NS16550_init(KGDB_PORT);
93 NS16550_putc( kgdb_debugport, c );
94}
95
96int getDebugChar( void )
97{
98 if (kgdb_debugport == NULL)
99 kgdb_debugport = NS16550_init(KGDB_PORT);
100
101 return(NS16550_getc(kgdb_debugport));
102}
103
104void kgdb_interruptible(int enable)
105{
106 return;
107}
108
109void putDebugString(char* str)
110{
111 while (*str != '\0') {
112 putDebugChar(*str);
113 str++;
114 }
115 putDebugChar('\r');
116 return;
117}
118
119void
120kgdb_map_scc(void)
121{
122 printk("kgdb init \n");
123 kgdb_debugport = NS16550_init(KGDB_PORT);
124}
diff --git a/arch/ppc/syslib/ppc83xx_setup.c b/arch/ppc/syslib/ppc83xx_setup.c
index 843cf8873e60..602a86891f7f 100644
--- a/arch/ppc/syslib/ppc83xx_setup.c
+++ b/arch/ppc/syslib/ppc83xx_setup.c
@@ -23,7 +23,6 @@
23#include <linux/serial_core.h> 23#include <linux/serial_core.h>
24#include <linux/serial_8250.h> 24#include <linux/serial_8250.h>
25 25
26#include <asm/prom.h>
27#include <asm/time.h> 26#include <asm/time.h>
28#include <asm/mpc83xx.h> 27#include <asm/mpc83xx.h>
29#include <asm/mmu.h> 28#include <asm/mmu.h>
diff --git a/arch/ppc/syslib/ppc85xx_setup.c b/arch/ppc/syslib/ppc85xx_setup.c
index f3277f469e78..ca95d79a704e 100644
--- a/arch/ppc/syslib/ppc85xx_setup.c
+++ b/arch/ppc/syslib/ppc85xx_setup.c
@@ -23,7 +23,6 @@
23#include <linux/serial_core.h> 23#include <linux/serial_core.h>
24#include <linux/serial_8250.h> 24#include <linux/serial_8250.h>
25 25
26#include <asm/prom.h>
27#include <asm/time.h> 26#include <asm/time.h>
28#include <asm/mpc85xx.h> 27#include <asm/mpc85xx.h>
29#include <asm/immap_85xx.h> 28#include <asm/immap_85xx.h>
@@ -33,6 +32,8 @@
33 32
34#include <syslib/ppc85xx_setup.h> 33#include <syslib/ppc85xx_setup.h>
35 34
35extern void abort(void);
36
36/* Return the amount of memory */ 37/* Return the amount of memory */
37unsigned long __init 38unsigned long __init
38mpc85xx_find_end_of_memory(void) 39mpc85xx_find_end_of_memory(void)
@@ -133,7 +134,7 @@ mpc85xx_halt(void)
133 134
134#ifdef CONFIG_PCI 135#ifdef CONFIG_PCI
135 136
136#if defined(CONFIG_MPC8555_CDS) 137#if defined(CONFIG_MPC8555_CDS) || defined(CONFIG_MPC8548_CDS)
137extern void mpc85xx_cds_enable_via(struct pci_controller *hose); 138extern void mpc85xx_cds_enable_via(struct pci_controller *hose);
138extern void mpc85xx_cds_fixup_via(struct pci_controller *hose); 139extern void mpc85xx_cds_fixup_via(struct pci_controller *hose);
139#endif 140#endif
@@ -308,14 +309,14 @@ mpc85xx_setup_hose(void)
308 309
309 ppc_md.pci_exclude_device = mpc85xx_exclude_device; 310 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
310 311
311#if defined(CONFIG_MPC8555_CDS) 312#if defined(CONFIG_MPC8555_CDS) || defined(CONFIG_MPC8548_CDS)
312 /* Pre pciauto_bus_scan VIA init */ 313 /* Pre pciauto_bus_scan VIA init */
313 mpc85xx_cds_enable_via(hose_a); 314 mpc85xx_cds_enable_via(hose_a);
314#endif 315#endif
315 316
316 hose_a->last_busno = pciauto_bus_scan(hose_a, hose_a->first_busno); 317 hose_a->last_busno = pciauto_bus_scan(hose_a, hose_a->first_busno);
317 318
318#if defined(CONFIG_MPC8555_CDS) 319#if defined(CONFIG_MPC8555_CDS) || defined(CONFIG_MPC8548_CDS)
319 /* Post pciauto_bus_scan VIA fixup */ 320 /* Post pciauto_bus_scan VIA fixup */
320 mpc85xx_cds_fixup_via(hose_a); 321 mpc85xx_cds_fixup_via(hose_a);
321#endif 322#endif
diff --git a/arch/ppc/xmon/xmon.c b/arch/ppc/xmon/xmon.c
index 8565f49b8b0b..be7869e39465 100644
--- a/arch/ppc/xmon/xmon.c
+++ b/arch/ppc/xmon/xmon.c
@@ -9,6 +9,7 @@
9#include <linux/smp.h> 9#include <linux/smp.h>
10#include <linux/interrupt.h> 10#include <linux/interrupt.h>
11#include <linux/bitops.h> 11#include <linux/bitops.h>
12#include <linux/kallsyms.h>
12#include <asm/ptrace.h> 13#include <asm/ptrace.h>
13#include <asm/string.h> 14#include <asm/string.h>
14#include <asm/prom.h> 15#include <asm/prom.h>
@@ -93,8 +94,7 @@ static void take_input(char *);
93static unsigned read_spr(int); 94static unsigned read_spr(int);
94static void write_spr(int, unsigned); 95static void write_spr(int, unsigned);
95static void super_regs(void); 96static void super_regs(void);
96static void print_sysmap(void); 97static void symbol_lookup(void);
97static void sysmap_lookup(void);
98static void remove_bpts(void); 98static void remove_bpts(void);
99static void insert_bpts(void); 99static void insert_bpts(void);
100static struct bpt *at_breakpoint(unsigned pc); 100static struct bpt *at_breakpoint(unsigned pc);
@@ -103,7 +103,6 @@ static void cacheflush(void);
103#ifdef CONFIG_SMP 103#ifdef CONFIG_SMP
104static void cpu_cmd(void); 104static void cpu_cmd(void);
105#endif /* CONFIG_SMP */ 105#endif /* CONFIG_SMP */
106static int pretty_print_addr(unsigned long addr);
107static void csum(void); 106static void csum(void);
108#ifdef CONFIG_BOOTX_TEXT 107#ifdef CONFIG_BOOTX_TEXT
109static void vidcmds(void); 108static void vidcmds(void);
@@ -120,8 +119,6 @@ extern void longjmp(u_int *, int);
120 119
121extern void xmon_enter(void); 120extern void xmon_enter(void);
122extern void xmon_leave(void); 121extern void xmon_leave(void);
123extern char* xmon_find_symbol(unsigned long addr, unsigned long* saddr);
124extern unsigned long xmon_symbol_to_addr(char* symbol);
125 122
126static unsigned start_tb[NR_CPUS][2]; 123static unsigned start_tb[NR_CPUS][2];
127static unsigned stop_tb[NR_CPUS][2]; 124static unsigned stop_tb[NR_CPUS][2];
@@ -148,7 +145,6 @@ Commands:\n\
148 mm move a block of memory\n\ 145 mm move a block of memory\n\
149 ms set a block of memory\n\ 146 ms set a block of memory\n\
150 md compare two blocks of memory\n\ 147 md compare two blocks of memory\n\
151 M print System.map\n\
152 r print registers\n\ 148 r print registers\n\
153 S print special registers\n\ 149 S print special registers\n\
154 t print backtrace\n\ 150 t print backtrace\n\
@@ -175,6 +171,35 @@ extern inline void __delay(unsigned int loops)
175 "r" (loops) : "ctr"); 171 "r" (loops) : "ctr");
176} 172}
177 173
174/* Print an address in numeric and symbolic form (if possible) */
175static void xmon_print_symbol(unsigned long address, const char *mid,
176 const char *after)
177{
178 char *modname;
179 const char *name = NULL;
180 unsigned long offset, size;
181 static char tmpstr[128];
182
183 printf("%.8lx", address);
184 if (setjmp(bus_error_jmp) == 0) {
185 debugger_fault_handler = handle_fault;
186 sync();
187 name = kallsyms_lookup(address, &size, &offset, &modname,
188 tmpstr);
189 sync();
190 /* wait a little while to see if we get a machine check */
191 __delay(200);
192 }
193 debugger_fault_handler = NULL;
194
195 if (name) {
196 printf("%s%s+%#lx/%#lx", mid, name, offset, size);
197 if (modname)
198 printf(" [%s]", modname);
199 }
200 printf("%s", after);
201}
202
178static void get_tb(unsigned *p) 203static void get_tb(unsigned *p)
179{ 204{
180 unsigned hi, lo, hiagain; 205 unsigned hi, lo, hiagain;
@@ -454,7 +479,7 @@ cmds(struct pt_regs *excp)
454 dump(); 479 dump();
455 break; 480 break;
456 case 'l': 481 case 'l':
457 sysmap_lookup(); 482 symbol_lookup();
458 break; 483 break;
459 case 'r': 484 case 'r':
460 if (excp != NULL) 485 if (excp != NULL)
@@ -466,9 +491,6 @@ cmds(struct pt_regs *excp)
466 else 491 else
467 excprint(excp); 492 excprint(excp);
468 break; 493 break;
469 case 'M':
470 print_sysmap();
471 break;
472 case 'S': 494 case 'S':
473 super_regs(); 495 super_regs();
474 break; 496 break;
@@ -825,20 +847,19 @@ backtrace(struct pt_regs *excp)
825 for (; sp != 0; sp = stack[0]) { 847 for (; sp != 0; sp = stack[0]) {
826 if (mread(sp, stack, sizeof(stack)) != sizeof(stack)) 848 if (mread(sp, stack, sizeof(stack)) != sizeof(stack))
827 break; 849 break;
828 pretty_print_addr(stack[1]); 850 printf("[%.8lx] ", stack);
829 printf(" "); 851 xmon_print_symbol(stack[1], " ", "\n");
830 if (stack[1] == (unsigned) &ret_from_except 852 if (stack[1] == (unsigned) &ret_from_except
831 || stack[1] == (unsigned) &ret_from_except_full 853 || stack[1] == (unsigned) &ret_from_except_full
832 || stack[1] == (unsigned) &ret_from_syscall) { 854 || stack[1] == (unsigned) &ret_from_syscall) {
833 if (mread(sp+16, &regs, sizeof(regs)) != sizeof(regs)) 855 if (mread(sp+16, &regs, sizeof(regs)) != sizeof(regs))
834 break; 856 break;
835 printf("\nexception:%x [%x] %x ", regs.trap, sp+16, 857 printf("exception:%x [%x] %x\n", regs.trap, sp+16,
836 regs.nip); 858 regs.nip);
837 sp = regs.gpr[1]; 859 sp = regs.gpr[1];
838 if (mread(sp, stack, sizeof(stack)) != sizeof(stack)) 860 if (mread(sp, stack, sizeof(stack)) != sizeof(stack))
839 break; 861 break;
840 } 862 }
841 printf("\n");
842 } 863 }
843} 864}
844 865
@@ -859,11 +880,10 @@ excprint(struct pt_regs *fp)
859#ifdef CONFIG_SMP 880#ifdef CONFIG_SMP
860 printf("cpu %d: ", smp_processor_id()); 881 printf("cpu %d: ", smp_processor_id());
861#endif /* CONFIG_SMP */ 882#endif /* CONFIG_SMP */
862 printf("vector: %x at pc = ", fp->trap); 883 printf("vector: %x at pc=", fp->trap);
863 pretty_print_addr(fp->nip); 884 xmon_print_symbol(fp->nip, ": ", ", lr=");
864 printf(", lr = "); 885 xmon_print_symbol(fp->link, ": ", "\n");
865 pretty_print_addr(fp->link); 886 printf("msr = %x, sp = %x [%x]\n", fp->msr, fp->gpr[1], fp);
866 printf("\nmsr = %x, sp = %x [%x]\n", fp->msr, fp->gpr[1], fp);
867 trap = TRAP(fp); 887 trap = TRAP(fp);
868 if (trap == 0x300 || trap == 0x600) 888 if (trap == 0x300 || trap == 0x600)
869 printf("dar = %x, dsisr = %x\n", fp->dar, fp->dsisr); 889 printf("dar = %x, dsisr = %x\n", fp->dar, fp->dsisr);
@@ -951,24 +971,6 @@ extern char exc_prolog;
951extern char dec_exc; 971extern char dec_exc;
952 972
953void 973void
954print_sysmap(void)
955{
956 extern char *sysmap;
957 if ( sysmap ) {
958 printf("System.map: \n");
959 if( setjmp(bus_error_jmp) == 0 ) {
960 debugger_fault_handler = handle_fault;
961 sync();
962 xmon_puts(sysmap);
963 sync();
964 }
965 debugger_fault_handler = NULL;
966 }
967 else
968 printf("No System.map\n");
969}
970
971void
972super_regs(void) 974super_regs(void)
973{ 975{
974 int i, cmd; 976 int i, cmd;
@@ -1738,7 +1740,7 @@ scanhex(unsigned *vp)
1738 printf("invalid register name '%%%s'\n", regname); 1740 printf("invalid register name '%%%s'\n", regname);
1739 return 0; 1741 return 0;
1740 } else if (c == '$') { 1742 } else if (c == '$') {
1741 static char symname[64]; 1743 static char symname[128];
1742 int i; 1744 int i;
1743 for (i=0; i<63; i++) { 1745 for (i=0; i<63; i++) {
1744 c = inchar(); 1746 c = inchar();
@@ -1749,7 +1751,14 @@ scanhex(unsigned *vp)
1749 symname[i] = c; 1751 symname[i] = c;
1750 } 1752 }
1751 symname[i++] = 0; 1753 symname[i++] = 0;
1752 *vp = xmon_symbol_to_addr(symname); 1754 *vp = 0;
1755 if (setjmp(bus_error_jmp) == 0) {
1756 debugger_fault_handler = handle_fault;
1757 sync();
1758 *vp = kallsyms_lookup_name(symname);
1759 sync();
1760 }
1761 debugger_fault_handler = NULL;
1753 if (!(*vp)) { 1762 if (!(*vp)) {
1754 printf("unknown symbol\n"); 1763 printf("unknown symbol\n");
1755 return 0; 1764 return 0;
@@ -1840,169 +1849,34 @@ take_input(char *str)
1840 lineptr = str; 1849 lineptr = str;
1841} 1850}
1842 1851
1843void 1852static void
1844sysmap_lookup(void) 1853symbol_lookup(void)
1845{ 1854{
1846 int type = inchar(); 1855 int type = inchar();
1847 unsigned addr; 1856 unsigned addr;
1848 static char tmp[64]; 1857 static char tmp[128];
1849 char* cur;
1850
1851 extern char *sysmap;
1852 extern unsigned long sysmap_size;
1853 if ( !sysmap || !sysmap_size )
1854 return;
1855
1856 switch(type) {
1857 case 'a':
1858 if (scanhex(&addr)) {
1859 pretty_print_addr(addr);
1860 printf("\n");
1861 }
1862 termch = 0;
1863 break;
1864 case 's':
1865 getstring(tmp, 64);
1866 if( setjmp(bus_error_jmp) == 0 ) {
1867 debugger_fault_handler = handle_fault;
1868 sync();
1869 cur = sysmap;
1870 do {
1871 cur = strstr(cur, tmp);
1872 if (cur) {
1873 static char res[64];
1874 char *p, *d;
1875 p = cur;
1876 while(p > sysmap && *p != 10)
1877 p--;
1878 if (*p == 10) p++;
1879 d = res;
1880 while(*p && p < (sysmap + sysmap_size) && *p != 10)
1881 *(d++) = *(p++);
1882 *(d++) = 0;
1883 printf("%s\n", res);
1884 cur++;
1885 }
1886 } while (cur);
1887 sync();
1888 }
1889 debugger_fault_handler = NULL;
1890 termch = 0;
1891 break;
1892 }
1893}
1894 1858
1895static int 1859 switch (type) {
1896pretty_print_addr(unsigned long addr) 1860 case 'a':
1897{ 1861 if (scanhex(&addr))
1898 char *sym; 1862 xmon_print_symbol(addr, ": ", "\n");
1899 unsigned long saddr; 1863 termch = 0;
1900 1864 break;
1901 printf("%08x", addr); 1865 case 's':
1902 sym = xmon_find_symbol(addr, &saddr); 1866 getstring(tmp, 64);
1903 if (sym) 1867 if (setjmp(bus_error_jmp) == 0) {
1904 printf(" (%s+0x%x)", sym, addr-saddr); 1868 debugger_fault_handler = handle_fault;
1905 return (sym != 0); 1869 sync();
1906} 1870 addr = kallsyms_lookup_name(tmp);
1907 1871 if (addr)
1908char* 1872 printf("%s: %lx\n", tmp, addr);
1909xmon_find_symbol(unsigned long addr, unsigned long* saddr) 1873 else
1910{ 1874 printf("Symbol '%s' not found.\n", tmp);
1911 static char rbuffer[64]; 1875 sync();
1912 char *p, *ep, *limit; 1876 }
1913 unsigned long prev, next; 1877 debugger_fault_handler = NULL;
1914 char* psym; 1878 termch = 0;
1915 1879 break;
1916 extern char *sysmap;
1917 extern unsigned long sysmap_size;
1918 if ( !sysmap || !sysmap_size )
1919 return NULL;
1920
1921 prev = 0;
1922 psym = NULL;
1923 p = sysmap;
1924 limit = p + sysmap_size;
1925 if( setjmp(bus_error_jmp) == 0 ) {
1926 debugger_fault_handler = handle_fault;
1927 sync();
1928 do {
1929 next = simple_strtoul(p, &p, 16);
1930 if (next > addr && prev <= addr) {
1931 if (!psym)
1932 goto bail;
1933 ep = rbuffer;
1934 p = psym;
1935 while(*p && p < limit && *p == 32)
1936 p++;
1937 while(*p && p < limit && *p != 10 && (ep - rbuffer) < 63)
1938 *(ep++) = *(p++);
1939 *(ep++) = 0;
1940 if (saddr)
1941 *saddr = prev;
1942 debugger_fault_handler = NULL;
1943 return rbuffer;
1944 }
1945 prev = next;
1946 psym = p;
1947 while(*p && p < limit && *p != 10)
1948 p++;
1949 if (*p) p++;
1950 } while(*p && p < limit && next);
1951bail:
1952 sync();
1953 } 1880 }
1954 debugger_fault_handler = NULL;
1955 return NULL;
1956} 1881}
1957 1882
1958unsigned long
1959xmon_symbol_to_addr(char* symbol)
1960{
1961 char *p, *cur;
1962 char *match = NULL;
1963 int goodness = 0;
1964 int result = 0;
1965
1966 extern char *sysmap;
1967 extern unsigned long sysmap_size;
1968 if ( !sysmap || !sysmap_size )
1969 return 0;
1970
1971 if( setjmp(bus_error_jmp) == 0 ) {
1972 debugger_fault_handler = handle_fault;
1973 sync();
1974 cur = sysmap;
1975 while(cur) {
1976 cur = strstr(cur, symbol);
1977 if (cur) {
1978 int gd = 1;
1979
1980 /* best match if equal, better match if
1981 * begins with
1982 */
1983 if (cur == sysmap || *(cur-1) == ' ') {
1984 gd++;
1985 if (cur[strlen(symbol)] == 10)
1986 gd++;
1987 }
1988 if (gd > goodness) {
1989 match = cur;
1990 goodness = gd;
1991 if (gd == 3)
1992 break;
1993 }
1994 cur++;
1995 }
1996 }
1997 if (goodness) {
1998 p = match;
1999 while(p > sysmap && *p != 10)
2000 p--;
2001 if (*p == 10) p++;
2002 result = simple_strtoul(p, &p, 16);
2003 }
2004 sync();
2005 }
2006 debugger_fault_handler = NULL;
2007 return result;
2008}
diff --git a/arch/ppc64/Kconfig b/arch/ppc64/Kconfig
index 5cb343883e4d..0f1fa289744e 100644
--- a/arch/ppc64/Kconfig
+++ b/arch/ppc64/Kconfig
@@ -323,7 +323,7 @@ config EISA
323 bool 323 bool
324 324
325config PCI 325config PCI
326 bool 326 bool "support for PCI devices" if (EMBEDDED && PPC_ISERIES)
327 default y 327 default y
328 help 328 help
329 Find out whether your system includes a PCI bus. PCI is the name of 329 Find out whether your system includes a PCI bus. PCI is the name of
diff --git a/arch/ppc64/Makefile b/arch/ppc64/Makefile
index 691f3008e698..33c752ceca4b 100644
--- a/arch/ppc64/Makefile
+++ b/arch/ppc64/Makefile
@@ -35,9 +35,9 @@ CROSS32AS := $(AS) -a32
35CROSS32LD := $(LD) -m elf32ppc 35CROSS32LD := $(LD) -m elf32ppc
36CROSS32OBJCOPY := $(OBJCOPY) 36CROSS32OBJCOPY := $(OBJCOPY)
37endif 37endif
38AS := $(AS) -a64 38override AS += -a64
39LD := $(LD) -m elf64ppc 39override LD += -m elf64ppc
40CC := $(CC) -m64 40override CC += -m64
41endif 41endif
42 42
43export CROSS32CC CROSS32AS CROSS32LD CROSS32OBJCOPY 43export CROSS32CC CROSS32AS CROSS32LD CROSS32OBJCOPY
diff --git a/arch/ppc64/kernel/HvLpEvent.c b/arch/ppc64/kernel/HvLpEvent.c
index f8f19637f73f..90032b138902 100644
--- a/arch/ppc64/kernel/HvLpEvent.c
+++ b/arch/ppc64/kernel/HvLpEvent.c
@@ -12,7 +12,7 @@
12#include <asm/system.h> 12#include <asm/system.h>
13#include <asm/iSeries/HvLpEvent.h> 13#include <asm/iSeries/HvLpEvent.h>
14#include <asm/iSeries/HvCallEvent.h> 14#include <asm/iSeries/HvCallEvent.h>
15#include <asm/iSeries/LparData.h> 15#include <asm/iSeries/ItLpNaca.h>
16 16
17/* Array of LpEvent handler functions */ 17/* Array of LpEvent handler functions */
18LpEventHandler lpEventHandler[HvLpEvent_Type_NumTypes]; 18LpEventHandler lpEventHandler[HvLpEvent_Type_NumTypes];
diff --git a/arch/ppc64/kernel/ItLpQueue.c b/arch/ppc64/kernel/ItLpQueue.c
index c923a815760e..cdea00d7707f 100644
--- a/arch/ppc64/kernel/ItLpQueue.c
+++ b/arch/ppc64/kernel/ItLpQueue.c
@@ -16,7 +16,6 @@
16#include <asm/iSeries/ItLpQueue.h> 16#include <asm/iSeries/ItLpQueue.h>
17#include <asm/iSeries/HvLpEvent.h> 17#include <asm/iSeries/HvLpEvent.h>
18#include <asm/iSeries/HvCallEvent.h> 18#include <asm/iSeries/HvCallEvent.h>
19#include <asm/iSeries/LparData.h>
20 19
21static __inline__ int set_inUse( struct ItLpQueue * lpQueue ) 20static __inline__ int set_inUse( struct ItLpQueue * lpQueue )
22{ 21{
diff --git a/arch/ppc64/kernel/Makefile b/arch/ppc64/kernel/Makefile
index 96d90b0c5119..b5e167cf1a05 100644
--- a/arch/ppc64/kernel/Makefile
+++ b/arch/ppc64/kernel/Makefile
@@ -16,14 +16,13 @@ obj-y += vdso32/ vdso64/
16 16
17obj-$(CONFIG_PPC_OF) += of_device.o 17obj-$(CONFIG_PPC_OF) += of_device.o
18 18
19pci-obj-$(CONFIG_PPC_ISERIES) += iSeries_pci.o iSeries_pci_reset.o 19pci-obj-$(CONFIG_PPC_ISERIES) += iSeries_pci.o iSeries_irq.o \
20 iSeries_VpdInfo.o
20pci-obj-$(CONFIG_PPC_MULTIPLATFORM) += pci_dn.o pci_direct_iommu.o 21pci-obj-$(CONFIG_PPC_MULTIPLATFORM) += pci_dn.o pci_direct_iommu.o
21 22
22obj-$(CONFIG_PCI) += pci.o pci_iommu.o iomap.o $(pci-obj-y) 23obj-$(CONFIG_PCI) += pci.o pci_iommu.o iomap.o $(pci-obj-y)
23 24
24obj-$(CONFIG_PPC_ISERIES) += iSeries_irq.o \ 25obj-$(CONFIG_PPC_ISERIES) += HvCall.o HvLpConfig.o LparData.o \
25 iSeries_VpdInfo.o XmPciLpEvent.o \
26 HvCall.o HvLpConfig.o LparData.o \
27 iSeries_setup.o ItLpQueue.o hvCall.o \ 26 iSeries_setup.o ItLpQueue.o hvCall.o \
28 mf.o HvLpEvent.o iSeries_proc.o iSeries_htab.o \ 27 mf.o HvLpEvent.o iSeries_proc.o iSeries_htab.o \
29 iSeries_iommu.o 28 iSeries_iommu.o
diff --git a/arch/ppc64/kernel/XmPciLpEvent.c b/arch/ppc64/kernel/XmPciLpEvent.c
deleted file mode 100644
index 809c9bc6678b..000000000000
--- a/arch/ppc64/kernel/XmPciLpEvent.c
+++ /dev/null
@@ -1,190 +0,0 @@
1/*
2 * File XmPciLpEvent.h created by Wayne Holm on Mon Jan 15 2001.
3 *
4 * This module handles PCI interrupt events sent by the iSeries Hypervisor.
5*/
6
7#include <linux/config.h>
8#include <linux/pci.h>
9#include <linux/init.h>
10#include <linux/threads.h>
11#include <linux/smp.h>
12#include <linux/param.h>
13#include <linux/string.h>
14#include <linux/bootmem.h>
15#include <linux/ide.h>
16
17#include <asm/iSeries/HvTypes.h>
18#include <asm/iSeries/HvLpEvent.h>
19#include <asm/iSeries/HvCallPci.h>
20#include <asm/iSeries/XmPciLpEvent.h>
21#include <asm/ppcdebug.h>
22
23static long Pci_Interrupt_Count;
24static long Pci_Event_Count;
25
26enum XmPciLpEvent_Subtype {
27 XmPciLpEvent_BusCreated = 0, // PHB has been created
28 XmPciLpEvent_BusError = 1, // PHB has failed
29 XmPciLpEvent_BusFailed = 2, // Msg to Secondary, Primary failed bus
30 XmPciLpEvent_NodeFailed = 4, // Multi-adapter bridge has failed
31 XmPciLpEvent_NodeRecovered = 5, // Multi-adapter bridge has recovered
32 XmPciLpEvent_BusRecovered = 12, // PHB has been recovered
33 XmPciLpEvent_UnQuiesceBus = 18, // Secondary bus unqiescing
34 XmPciLpEvent_BridgeError = 21, // Bridge Error
35 XmPciLpEvent_SlotInterrupt = 22 // Slot interrupt
36};
37
38struct XmPciLpEvent_BusInterrupt {
39 HvBusNumber busNumber;
40 HvSubBusNumber subBusNumber;
41};
42
43struct XmPciLpEvent_NodeInterrupt {
44 HvBusNumber busNumber;
45 HvSubBusNumber subBusNumber;
46 HvAgentId deviceId;
47};
48
49struct XmPciLpEvent {
50 struct HvLpEvent hvLpEvent;
51
52 union {
53 u64 alignData; // Align on an 8-byte boundary
54
55 struct {
56 u32 fisr;
57 HvBusNumber busNumber;
58 HvSubBusNumber subBusNumber;
59 HvAgentId deviceId;
60 } slotInterrupt;
61
62 struct XmPciLpEvent_BusInterrupt busFailed;
63 struct XmPciLpEvent_BusInterrupt busRecovered;
64 struct XmPciLpEvent_BusInterrupt busCreated;
65
66 struct XmPciLpEvent_NodeInterrupt nodeFailed;
67 struct XmPciLpEvent_NodeInterrupt nodeRecovered;
68
69 } eventData;
70
71};
72
73static void intReceived(struct XmPciLpEvent *eventParm,
74 struct pt_regs *regsParm);
75
76static void XmPciLpEvent_handler(struct HvLpEvent *eventParm,
77 struct pt_regs *regsParm)
78{
79#ifdef CONFIG_PCI
80#if 0
81 PPCDBG(PPCDBG_BUSWALK, "XmPciLpEvent_handler, type 0x%x\n",
82 eventParm->xType);
83#endif
84 ++Pci_Event_Count;
85
86 if (eventParm && (eventParm->xType == HvLpEvent_Type_PciIo)) {
87 switch (eventParm->xFlags.xFunction) {
88 case HvLpEvent_Function_Int:
89 intReceived((struct XmPciLpEvent *)eventParm, regsParm);
90 break;
91 case HvLpEvent_Function_Ack:
92 printk(KERN_ERR
93 "XmPciLpEvent.c: unexpected ack received\n");
94 break;
95 default:
96 printk(KERN_ERR
97 "XmPciLpEvent.c: unexpected event function %d\n",
98 (int)eventParm->xFlags.xFunction);
99 break;
100 }
101 } else if (eventParm)
102 printk(KERN_ERR
103 "XmPciLpEvent.c: Unrecognized PCI event type 0x%x\n",
104 (int)eventParm->xType);
105 else
106 printk(KERN_ERR "XmPciLpEvent.c: NULL event received\n");
107#endif
108}
109
110static void intReceived(struct XmPciLpEvent *eventParm,
111 struct pt_regs *regsParm)
112{
113 int irq;
114
115 ++Pci_Interrupt_Count;
116#if 0
117 PPCDBG(PPCDBG_BUSWALK, "PCI: XmPciLpEvent.c: intReceived\n");
118#endif
119
120 switch (eventParm->hvLpEvent.xSubtype) {
121 case XmPciLpEvent_SlotInterrupt:
122 irq = eventParm->hvLpEvent.xCorrelationToken;
123 /* Dispatch the interrupt handlers for this irq */
124 ppc_irq_dispatch_handler(regsParm, irq);
125 HvCallPci_eoi(eventParm->eventData.slotInterrupt.busNumber,
126 eventParm->eventData.slotInterrupt.subBusNumber,
127 eventParm->eventData.slotInterrupt.deviceId);
128 break;
129 /* Ignore error recovery events for now */
130 case XmPciLpEvent_BusCreated:
131 printk(KERN_INFO "XmPciLpEvent.c: system bus %d created\n",
132 eventParm->eventData.busCreated.busNumber);
133 break;
134 case XmPciLpEvent_BusError:
135 case XmPciLpEvent_BusFailed:
136 printk(KERN_INFO "XmPciLpEvent.c: system bus %d failed\n",
137 eventParm->eventData.busFailed.busNumber);
138 break;
139 case XmPciLpEvent_BusRecovered:
140 case XmPciLpEvent_UnQuiesceBus:
141 printk(KERN_INFO "XmPciLpEvent.c: system bus %d recovered\n",
142 eventParm->eventData.busRecovered.busNumber);
143 break;
144 case XmPciLpEvent_NodeFailed:
145 case XmPciLpEvent_BridgeError:
146 printk(KERN_INFO
147 "XmPciLpEvent.c: multi-adapter bridge %d/%d/%d failed\n",
148 eventParm->eventData.nodeFailed.busNumber,
149 eventParm->eventData.nodeFailed.subBusNumber,
150 eventParm->eventData.nodeFailed.deviceId);
151 break;
152 case XmPciLpEvent_NodeRecovered:
153 printk(KERN_INFO
154 "XmPciLpEvent.c: multi-adapter bridge %d/%d/%d recovered\n",
155 eventParm->eventData.nodeRecovered.busNumber,
156 eventParm->eventData.nodeRecovered.subBusNumber,
157 eventParm->eventData.nodeRecovered.deviceId);
158 break;
159 default:
160 printk(KERN_ERR
161 "XmPciLpEvent.c: unrecognized event subtype 0x%x\n",
162 eventParm->hvLpEvent.xSubtype);
163 break;
164 }
165}
166
167
168/* This should be called sometime prior to buswalk (init_IRQ would be good) */
169int XmPciLpEvent_init()
170{
171 int xRc;
172
173 PPCDBG(PPCDBG_BUSWALK,
174 "XmPciLpEvent_init, Register Event type 0x%04X\n",
175 HvLpEvent_Type_PciIo);
176
177 xRc = HvLpEvent_registerHandler(HvLpEvent_Type_PciIo,
178 &XmPciLpEvent_handler);
179 if (xRc == 0) {
180 xRc = HvLpEvent_openPath(HvLpEvent_Type_PciIo, 0);
181 if (xRc != 0)
182 printk(KERN_ERR
183 "XmPciLpEvent.c: open event path failed with rc 0x%x\n",
184 xRc);
185 } else
186 printk(KERN_ERR
187 "XmPciLpEvent.c: register handler failed with rc 0x%x\n",
188 xRc);
189 return xRc;
190}
diff --git a/arch/ppc64/kernel/asm-offsets.c b/arch/ppc64/kernel/asm-offsets.c
index 0094ac79a18c..abb9e5b5da03 100644
--- a/arch/ppc64/kernel/asm-offsets.c
+++ b/arch/ppc64/kernel/asm-offsets.c
@@ -31,7 +31,6 @@
31 31
32#include <asm/paca.h> 32#include <asm/paca.h>
33#include <asm/lppaca.h> 33#include <asm/lppaca.h>
34#include <asm/iSeries/ItLpQueue.h>
35#include <asm/iSeries/HvLpEvent.h> 34#include <asm/iSeries/HvLpEvent.h>
36#include <asm/rtas.h> 35#include <asm/rtas.h>
37#include <asm/cputable.h> 36#include <asm/cputable.h>
diff --git a/arch/ppc64/kernel/dma.c b/arch/ppc64/kernel/dma.c
index ce714c927134..4da8e31b2b61 100644
--- a/arch/ppc64/kernel/dma.c
+++ b/arch/ppc64/kernel/dma.c
@@ -15,8 +15,10 @@
15 15
16static struct dma_mapping_ops *get_dma_ops(struct device *dev) 16static struct dma_mapping_ops *get_dma_ops(struct device *dev)
17{ 17{
18#ifdef CONFIG_PCI
18 if (dev->bus == &pci_bus_type) 19 if (dev->bus == &pci_bus_type)
19 return &pci_dma_ops; 20 return &pci_dma_ops;
21#endif
20#ifdef CONFIG_IBMVIO 22#ifdef CONFIG_IBMVIO
21 if (dev->bus == &vio_bus_type) 23 if (dev->bus == &vio_bus_type)
22 return &vio_dma_ops; 24 return &vio_dma_ops;
@@ -37,8 +39,10 @@ EXPORT_SYMBOL(dma_supported);
37 39
38int dma_set_mask(struct device *dev, u64 dma_mask) 40int dma_set_mask(struct device *dev, u64 dma_mask)
39{ 41{
42#ifdef CONFIG_PCI
40 if (dev->bus == &pci_bus_type) 43 if (dev->bus == &pci_bus_type)
41 return pci_set_dma_mask(to_pci_dev(dev), dma_mask); 44 return pci_set_dma_mask(to_pci_dev(dev), dma_mask);
45#endif
42#ifdef CONFIG_IBMVIO 46#ifdef CONFIG_IBMVIO
43 if (dev->bus == &vio_bus_type) 47 if (dev->bus == &vio_bus_type)
44 return -EIO; 48 return -EIO;
diff --git a/arch/ppc64/kernel/eeh.c b/arch/ppc64/kernel/eeh.c
index d63d41f3eecf..af5272fedadf 100644
--- a/arch/ppc64/kernel/eeh.c
+++ b/arch/ppc64/kernel/eeh.c
@@ -505,7 +505,7 @@ static inline unsigned long eeh_token_to_phys(unsigned long token)
505 pte_t *ptep; 505 pte_t *ptep;
506 unsigned long pa; 506 unsigned long pa;
507 507
508 ptep = find_linux_pte(ioremap_mm.pgd, token); 508 ptep = find_linux_pte(init_mm.pgd, token);
509 if (!ptep) 509 if (!ptep)
510 return token; 510 return token;
511 pa = pte_pfn(*ptep) << PAGE_SHIFT; 511 pa = pte_pfn(*ptep) << PAGE_SHIFT;
diff --git a/arch/ppc64/kernel/head.S b/arch/ppc64/kernel/head.S
index 346dbf606b5d..02c8f4e3e4bc 100644
--- a/arch/ppc64/kernel/head.S
+++ b/arch/ppc64/kernel/head.S
@@ -2121,10 +2121,6 @@ empty_zero_page:
2121swapper_pg_dir: 2121swapper_pg_dir:
2122 .space 4096 2122 .space 4096
2123 2123
2124 .globl ioremap_dir
2125ioremap_dir:
2126 .space 4096
2127
2128#ifdef CONFIG_SMP 2124#ifdef CONFIG_SMP
2129/* 1 page segment table per cpu (max 48, cpu0 allocated at STAB0_PHYS_ADDR) */ 2125/* 1 page segment table per cpu (max 48, cpu0 allocated at STAB0_PHYS_ADDR) */
2130 .globl stab_array 2126 .globl stab_array
diff --git a/arch/ppc64/kernel/iSeries_VpdInfo.c b/arch/ppc64/kernel/iSeries_VpdInfo.c
index a6f0ff2d0239..d11c732daf81 100644
--- a/arch/ppc64/kernel/iSeries_VpdInfo.c
+++ b/arch/ppc64/kernel/iSeries_VpdInfo.c
@@ -1,31 +1,31 @@
1/************************************************************************/ 1/*
2/* File iSeries_vpdInfo.c created by Allan Trautman on Fri Feb 2 2001. */ 2 * File iSeries_vpdInfo.c created by Allan Trautman on Fri Feb 2 2001.
3/************************************************************************/ 3 *
4/* This code gets the card location of the hardware */ 4 * This code gets the card location of the hardware
5/* Copyright (C) 20yy <Allan H Trautman> <IBM Corp> */ 5 * Copyright (C) 2001 <Allan H Trautman> <IBM Corp>
6/* */ 6 * Copyright (C) 2005 Stephen Rothwel, IBM Corp
7/* This program is free software; you can redistribute it and/or modify */ 7 *
8/* it under the terms of the GNU General Public License as published by */ 8 * This program is free software; you can redistribute it and/or modify
9/* the Free Software Foundation; either version 2 of the License, or */ 9 * it under the terms of the GNU General Public License as published by
10/* (at your option) any later version. */ 10 * the Free Software Foundation; either version 2 of the License, or
11/* */ 11 * (at your option) any later version.
12/* This program is distributed in the hope that it will be useful, */ 12 *
13/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 13 * This program is distributed in the hope that it will be useful,
14/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15/* GNU General Public License for more details. */ 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16/* */ 16 * GNU General Public License for more details.
17/* You should have received a copy of the GNU General Public License */ 17 *
18/* along with this program; if not, write to the: */ 18 * You should have received a copy of the GNU General Public License
19/* Free Software Foundation, Inc., */ 19 * along with this program; if not, write to the:
20/* 59 Temple Place, Suite 330, */ 20 * Free Software Foundation, Inc.,
21/* Boston, MA 02111-1307 USA */ 21 * 59 Temple Place, Suite 330,
22/************************************************************************/ 22 * Boston, MA 02111-1307 USA
23/* Change Activity: */ 23 *
24/* Created, Feb 2, 2001 */ 24 * Change Activity:
25/* Ported to ppc64, August 20, 2001 */ 25 * Created, Feb 2, 2001
26/* End Change Activity */ 26 * Ported to ppc64, August 20, 2001
27/************************************************************************/ 27 * End Change Activity
28#include <linux/config.h> 28 */
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/pci.h> 31#include <linux/pci.h>
@@ -34,30 +34,25 @@
34 34
35#include <asm/iSeries/HvCallPci.h> 35#include <asm/iSeries/HvCallPci.h>
36#include <asm/iSeries/HvTypes.h> 36#include <asm/iSeries/HvTypes.h>
37#include <asm/iSeries/mf.h>
38#include <asm/iSeries/LparData.h>
39#include <asm/iSeries/iSeries_pci.h> 37#include <asm/iSeries/iSeries_pci.h>
40#include "pci.h"
41 38
42/* 39/*
43 * Size of Bus VPD data 40 * Size of Bus VPD data
44 */ 41 */
45#define BUS_VPDSIZE 1024 42#define BUS_VPDSIZE 1024
43
46/* 44/*
47 * Bus Vpd Tags 45 * Bus Vpd Tags
48 */ 46 */
49#define VpdEndOfDataTag 0x78
50#define VpdEndOfAreaTag 0x79 47#define VpdEndOfAreaTag 0x79
51#define VpdIdStringTag 0x82 48#define VpdIdStringTag 0x82
52#define VpdVendorAreaTag 0x84 49#define VpdVendorAreaTag 0x84
50
53/* 51/*
54 * Mfg Area Tags 52 * Mfg Area Tags
55 */ 53 */
56#define VpdFruFlag 0x4647 // "FG"
57#define VpdFruFrameId 0x4649 // "FI" 54#define VpdFruFrameId 0x4649 // "FI"
58#define VpdSlotMapFormat 0x4D46 // "MF" 55#define VpdSlotMapFormat 0x4D46 // "MF"
59#define VpdAsmPartNumber 0x504E // "PN"
60#define VpdFruSerial 0x534E // "SN"
61#define VpdSlotMap 0x534D // "SM" 56#define VpdSlotMap 0x534D // "SM"
62 57
63/* 58/*
@@ -79,74 +74,33 @@ struct SlotMapStruct {
79 char CardLocation[3]; 74 char CardLocation[3];
80 char Parms[8]; 75 char Parms[8];
81 char Reserved[2]; 76 char Reserved[2];
82}; 77};
83typedef struct SlotMapStruct SlotMap; 78typedef struct SlotMapStruct SlotMap;
84#define SLOT_ENTRY_SIZE 16 79#define SLOT_ENTRY_SIZE 16
85 80
86/* 81/*
87 * Formats the device information.
88 * - Pass in pci_dev* pointer to the device.
89 * - Pass in buffer to place the data. Danger here is the buffer must
90 * be as big as the client says it is. Should be at least 128 bytes.
91 * Return will the length of the string data put in the buffer.
92 * Format:
93 * PCI: Bus 0, Device 26, Vendor 0x12AE Frame 1, Card C10 Ethernet
94 * controller
95 */
96int iSeries_Device_Information(struct pci_dev *PciDev, char *buffer,
97 int BufferSize)
98{
99 struct iSeries_Device_Node *DevNode =
100 (struct iSeries_Device_Node *)PciDev->sysdata;
101 int len;
102
103 if (DevNode == NULL)
104 return sprintf(buffer,
105 "PCI: iSeries_Device_Information DevNode is NULL");
106
107 if (BufferSize < 128)
108 return 0;
109
110 len = sprintf(buffer, "PCI: Bus%3d, Device%3d, Vendor %04X ",
111 ISERIES_BUS(DevNode), PCI_SLOT(PciDev->devfn),
112 PciDev->vendor);
113 len += sprintf(buffer + len, "Frame%3d, Card %4s ",
114 DevNode->FrameId, DevNode->CardLocation);
115#ifdef CONFIG_PCI
116 if (pci_class_name(PciDev->class >> 8) == 0)
117 len += sprintf(buffer + len, "0x%04X ",
118 (int)(PciDev->class >> 8));
119 else
120 len += sprintf(buffer + len, "%s",
121 pci_class_name(PciDev->class >> 8));
122#endif
123 return len;
124}
125
126/*
127 * Parse the Slot Area 82 * Parse the Slot Area
128 */ 83 */
129void iSeries_Parse_SlotArea(SlotMap *MapPtr, int MapLen, 84static void __init iSeries_Parse_SlotArea(SlotMap *MapPtr, int MapLen,
130 struct iSeries_Device_Node *DevNode) 85 HvAgentId agent, u8 *PhbId, char card[4])
131{ 86{
132 int SlotMapLen = MapLen; 87 int SlotMapLen = MapLen;
133 SlotMap *SlotMapPtr = MapPtr; 88 SlotMap *SlotMapPtr = MapPtr;
134 89
135 /* 90 /*
136 * Parse Slot label until we find the one requrested 91 * Parse Slot label until we find the one requested
137 */ 92 */
138 while (SlotMapLen > 0) { 93 while (SlotMapLen > 0) {
139 if (SlotMapPtr->AgentId == DevNode->AgentId ) { 94 if (SlotMapPtr->AgentId == agent) {
140 /* 95 /*
141 * If Phb wasn't found, grab the entry first one found. 96 * If Phb wasn't found, grab the entry first one found.
142 */ 97 */
143 if (DevNode->PhbId == 0xff) 98 if (*PhbId == 0xff)
144 DevNode->PhbId = SlotMapPtr->PhbId; 99 *PhbId = SlotMapPtr->PhbId;
145 /* Found it, extract the data. */ 100 /* Found it, extract the data. */
146 if (SlotMapPtr->PhbId == DevNode->PhbId ) { 101 if (SlotMapPtr->PhbId == *PhbId) {
147 memcpy(&DevNode->CardLocation, 102 memcpy(card, &SlotMapPtr->CardLocation, 3);
148 &SlotMapPtr->CardLocation, 3); 103 card[3] = 0;
149 DevNode->CardLocation[3] = 0;
150 break; 104 break;
151 } 105 }
152 } 106 }
@@ -159,8 +113,9 @@ void iSeries_Parse_SlotArea(SlotMap *MapPtr, int MapLen,
159/* 113/*
160 * Parse the Mfg Area 114 * Parse the Mfg Area
161 */ 115 */
162static void iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen, 116static void __init iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen,
163 struct iSeries_Device_Node *DevNode) 117 HvAgentId agent, u8 *PhbId,
118 u8 *frame, char card[4])
164{ 119{
165 MfgArea *MfgAreaPtr = (MfgArea *)AreaData; 120 MfgArea *MfgAreaPtr = (MfgArea *)AreaData;
166 int MfgAreaLen = AreaLen; 121 int MfgAreaLen = AreaLen;
@@ -171,7 +126,7 @@ static void iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen,
171 int MfgTagLen = MfgAreaPtr->TagLength; 126 int MfgTagLen = MfgAreaPtr->TagLength;
172 /* Frame ID (FI 4649020310 ) */ 127 /* Frame ID (FI 4649020310 ) */
173 if (MfgAreaPtr->Tag == VpdFruFrameId) /* FI */ 128 if (MfgAreaPtr->Tag == VpdFruFrameId) /* FI */
174 DevNode->FrameId = MfgAreaPtr->AreaData1; 129 *frame = MfgAreaPtr->AreaData1;
175 /* Slot Map Format (MF 4D46020004 ) */ 130 /* Slot Map Format (MF 4D46020004 ) */
176 else if (MfgAreaPtr->Tag == VpdSlotMapFormat) /* MF */ 131 else if (MfgAreaPtr->Tag == VpdSlotMapFormat) /* MF */
177 SlotMapFmt = (MfgAreaPtr->AreaData1 * 256) 132 SlotMapFmt = (MfgAreaPtr->AreaData1 * 256)
@@ -183,10 +138,11 @@ static void iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen,
183 if (SlotMapFmt == 0x1004) 138 if (SlotMapFmt == 0x1004)
184 SlotMapPtr = (SlotMap *)((char *)MfgAreaPtr 139 SlotMapPtr = (SlotMap *)((char *)MfgAreaPtr
185 + MFG_ENTRY_SIZE + 1); 140 + MFG_ENTRY_SIZE + 1);
186 else 141 else
187 SlotMapPtr = (SlotMap *)((char *)MfgAreaPtr 142 SlotMapPtr = (SlotMap *)((char *)MfgAreaPtr
188 + MFG_ENTRY_SIZE); 143 + MFG_ENTRY_SIZE);
189 iSeries_Parse_SlotArea(SlotMapPtr, MfgTagLen, DevNode); 144 iSeries_Parse_SlotArea(SlotMapPtr, MfgTagLen,
145 agent, PhbId, card);
190 } 146 }
191 /* 147 /*
192 * Point to the next Mfg Area 148 * Point to the next Mfg Area
@@ -194,19 +150,19 @@ static void iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen,
194 */ 150 */
195 MfgAreaPtr = (MfgArea *)((char *)MfgAreaPtr + MfgTagLen 151 MfgAreaPtr = (MfgArea *)((char *)MfgAreaPtr + MfgTagLen
196 + MFG_ENTRY_SIZE); 152 + MFG_ENTRY_SIZE);
197 MfgAreaLen -= (MfgTagLen + MFG_ENTRY_SIZE); 153 MfgAreaLen -= (MfgTagLen + MFG_ENTRY_SIZE);
198 } 154 }
199} 155}
200 156
201/* 157/*
202 * Look for "BUS".. Data is not Null terminated. 158 * Look for "BUS".. Data is not Null terminated.
203 * PHBID of 0xFF indicates PHB was not found in VPD Data. 159 * PHBID of 0xFF indicates PHB was not found in VPD Data.
204 */ 160 */
205static int iSeries_Parse_PhbId(u8 *AreaPtr, int AreaLength) 161static int __init iSeries_Parse_PhbId(u8 *AreaPtr, int AreaLength)
206{ 162{
207 u8 *PhbPtr = AreaPtr; 163 u8 *PhbPtr = AreaPtr;
208 int DataLen = AreaLength; 164 int DataLen = AreaLength;
209 char PhbId = 0xFF; 165 char PhbId = 0xFF;
210 166
211 while (DataLen > 0) { 167 while (DataLen > 0) {
212 if ((*PhbPtr == 'B') && (*(PhbPtr + 1) == 'U') 168 if ((*PhbPtr == 'B') && (*(PhbPtr + 1) == 'U')
@@ -216,7 +172,7 @@ static int iSeries_Parse_PhbId(u8 *AreaPtr, int AreaLength)
216 ++PhbPtr; 172 ++PhbPtr;
217 PhbId = (*PhbPtr & 0x0F); 173 PhbId = (*PhbPtr & 0x0F);
218 break; 174 break;
219 } 175 }
220 ++PhbPtr; 176 ++PhbPtr;
221 --DataLen; 177 --DataLen;
222 } 178 }
@@ -226,52 +182,90 @@ static int iSeries_Parse_PhbId(u8 *AreaPtr, int AreaLength)
226/* 182/*
227 * Parse out the VPD Areas 183 * Parse out the VPD Areas
228 */ 184 */
229static void iSeries_Parse_Vpd(u8 *VpdData, int VpdDataLen, 185static void __init iSeries_Parse_Vpd(u8 *VpdData, int VpdDataLen,
230 struct iSeries_Device_Node *DevNode) 186 HvAgentId agent, u8 *frame, char card[4])
231{ 187{
232 u8 *TagPtr = VpdData; 188 u8 *TagPtr = VpdData;
233 int DataLen = VpdDataLen - 3; 189 int DataLen = VpdDataLen - 3;
190 u8 PhbId;
234 191
235 while ((*TagPtr != VpdEndOfAreaTag) && (DataLen > 0)) { 192 while ((*TagPtr != VpdEndOfAreaTag) && (DataLen > 0)) {
236 int AreaLen = *(TagPtr + 1) + (*(TagPtr + 2) * 256); 193 int AreaLen = *(TagPtr + 1) + (*(TagPtr + 2) * 256);
237 u8 *AreaData = TagPtr + 3; 194 u8 *AreaData = TagPtr + 3;
238 195
239 if (*TagPtr == VpdIdStringTag) 196 if (*TagPtr == VpdIdStringTag)
240 DevNode->PhbId = iSeries_Parse_PhbId(AreaData, AreaLen); 197 PhbId = iSeries_Parse_PhbId(AreaData, AreaLen);
241 else if (*TagPtr == VpdVendorAreaTag) 198 else if (*TagPtr == VpdVendorAreaTag)
242 iSeries_Parse_MfgArea(AreaData, AreaLen, DevNode); 199 iSeries_Parse_MfgArea(AreaData, AreaLen,
200 agent, &PhbId, frame, card);
243 /* Point to next Area. */ 201 /* Point to next Area. */
244 TagPtr = AreaData + AreaLen; 202 TagPtr = AreaData + AreaLen;
245 DataLen -= AreaLen; 203 DataLen -= AreaLen;
246 } 204 }
247} 205}
248 206
249void iSeries_Get_Location_Code(struct iSeries_Device_Node *DevNode) 207static void __init iSeries_Get_Location_Code(u16 bus, HvAgentId agent,
208 u8 *frame, char card[4])
250{ 209{
251 int BusVpdLen = 0; 210 int BusVpdLen = 0;
252 u8 *BusVpdPtr = (u8 *)kmalloc(BUS_VPDSIZE, GFP_KERNEL); 211 u8 *BusVpdPtr = kmalloc(BUS_VPDSIZE, GFP_KERNEL);
253 212
254 if (BusVpdPtr == NULL) { 213 if (BusVpdPtr == NULL) {
255 printk("PCI: Bus VPD Buffer allocation failure.\n"); 214 printk("PCI: Bus VPD Buffer allocation failure.\n");
256 return; 215 return;
257 } 216 }
258 BusVpdLen = HvCallPci_getBusVpd(ISERIES_BUS(DevNode), 217 BusVpdLen = HvCallPci_getBusVpd(bus, ISERIES_HV_ADDR(BusVpdPtr),
259 ISERIES_HV_ADDR(BusVpdPtr),
260 BUS_VPDSIZE); 218 BUS_VPDSIZE);
261 if (BusVpdLen == 0) { 219 if (BusVpdLen == 0) {
262 kfree(BusVpdPtr);
263 printk("PCI: Bus VPD Buffer zero length.\n"); 220 printk("PCI: Bus VPD Buffer zero length.\n");
264 return; 221 goto out_free;
265 } 222 }
266 /* printk("PCI: BusVpdPtr: %p, %d\n",BusVpdPtr, BusVpdLen); */ 223 /* printk("PCI: BusVpdPtr: %p, %d\n",BusVpdPtr, BusVpdLen); */
267 /* Make sure this is what I think it is */ 224 /* Make sure this is what I think it is */
268 if (*BusVpdPtr != VpdIdStringTag) { /* 0x82 */ 225 if (*BusVpdPtr != VpdIdStringTag) { /* 0x82 */
269 printk("PCI: Bus VPD Buffer missing starting tag.\n"); 226 printk("PCI: Bus VPD Buffer missing starting tag.\n");
270 kfree(BusVpdPtr); 227 goto out_free;
271 return;
272 } 228 }
273 iSeries_Parse_Vpd(BusVpdPtr,BusVpdLen, DevNode); 229 iSeries_Parse_Vpd(BusVpdPtr, BusVpdLen, agent, frame, card);
274 sprintf(DevNode->Location, "Frame%3d, Card %-4s", DevNode->FrameId, 230out_free:
275 DevNode->CardLocation);
276 kfree(BusVpdPtr); 231 kfree(BusVpdPtr);
277} 232}
233
234/*
235 * Prints the device information.
236 * - Pass in pci_dev* pointer to the device.
237 * - Pass in the device count
238 *
239 * Format:
240 * PCI: Bus 0, Device 26, Vendor 0x12AE Frame 1, Card C10 Ethernet
241 * controller
242 */
243void __init iSeries_Device_Information(struct pci_dev *PciDev, int count)
244{
245 struct iSeries_Device_Node *DevNode = PciDev->sysdata;
246 u16 bus;
247 u8 frame;
248 char card[4];
249 HvSubBusNumber subbus;
250 HvAgentId agent;
251
252 if (DevNode == NULL) {
253 printk("%d. PCI: iSeries_Device_Information DevNode is NULL\n",
254 count);
255 return;
256 }
257
258 bus = ISERIES_BUS(DevNode);
259 subbus = ISERIES_SUBBUS(DevNode);
260 agent = ISERIES_PCI_AGENTID(ISERIES_GET_DEVICE_FROM_SUBBUS(subbus),
261 ISERIES_GET_FUNCTION_FROM_SUBBUS(subbus));
262 iSeries_Get_Location_Code(bus, agent, &frame, card);
263
264 printk("%d. PCI: Bus%3d, Device%3d, Vendor %04X Frame%3d, Card %4s ",
265 count, bus, PCI_SLOT(PciDev->devfn), PciDev->vendor,
266 frame, card);
267 if (pci_class_name(PciDev->class >> 8) == 0)
268 printk("0x%04X\n", (int)(PciDev->class >> 8));
269 else
270 printk("%s\n", pci_class_name(PciDev->class >> 8));
271}
diff --git a/arch/ppc64/kernel/iSeries_iommu.c b/arch/ppc64/kernel/iSeries_iommu.c
index 4e1a47c8a802..f8ff1bb054dc 100644
--- a/arch/ppc64/kernel/iSeries_iommu.c
+++ b/arch/ppc64/kernel/iSeries_iommu.c
@@ -83,7 +83,7 @@ static void tce_free_iSeries(struct iommu_table *tbl, long index, long npages)
83 } 83 }
84} 84}
85 85
86 86#ifdef CONFIG_PCI
87/* 87/*
88 * This function compares the known tables to find an iommu_table 88 * This function compares the known tables to find an iommu_table
89 * that has already been built for hardware TCEs. 89 * that has already been built for hardware TCEs.
@@ -159,6 +159,7 @@ void iommu_devnode_init_iSeries(struct iSeries_Device_Node *dn)
159 else 159 else
160 kfree(tbl); 160 kfree(tbl);
161} 161}
162#endif
162 163
163static void iommu_dev_setup_iSeries(struct pci_dev *dev) { } 164static void iommu_dev_setup_iSeries(struct pci_dev *dev) { }
164static void iommu_bus_setup_iSeries(struct pci_bus *bus) { } 165static void iommu_bus_setup_iSeries(struct pci_bus *bus) { }
diff --git a/arch/ppc64/kernel/iSeries_irq.c b/arch/ppc64/kernel/iSeries_irq.c
index f831d259dbb7..77376c1bd611 100644
--- a/arch/ppc64/kernel/iSeries_irq.c
+++ b/arch/ppc64/kernel/iSeries_irq.c
@@ -1,27 +1,29 @@
1/************************************************************************/ 1/*
2/* This module supports the iSeries PCI bus interrupt handling */ 2 * This module supports the iSeries PCI bus interrupt handling
3/* Copyright (C) 20yy <Robert L Holtorf> <IBM Corp> */ 3 * Copyright (C) 20yy <Robert L Holtorf> <IBM Corp>
4/* */ 4 * Copyright (C) 2004-2005 IBM Corporation
5/* This program is free software; you can redistribute it and/or modify */ 5 *
6/* it under the terms of the GNU General Public License as published by */ 6 * This program is free software; you can redistribute it and/or modify
7/* the Free Software Foundation; either version 2 of the License, or */ 7 * it under the terms of the GNU General Public License as published by
8/* (at your option) any later version. */ 8 * the Free Software Foundation; either version 2 of the License, or
9/* */ 9 * (at your option) any later version.
10/* This program is distributed in the hope that it will be useful, */ 10 *
11/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 11 * This program is distributed in the hope that it will be useful,
12/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13/* GNU General Public License for more details. */ 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14/* */ 14 * GNU General Public License for more details.
15/* You should have received a copy of the GNU General Public License */ 15 *
16/* along with this program; if not, write to the: */ 16 * You should have received a copy of the GNU General Public License
17/* Free Software Foundation, Inc., */ 17 * along with this program; if not, write to the:
18/* 59 Temple Place, Suite 330, */ 18 * Free Software Foundation, Inc.,
19/* Boston, MA 02111-1307 USA */ 19 * 59 Temple Place, Suite 330,
20/************************************************************************/ 20 * Boston, MA 02111-1307 USA
21/* Change Activity: */ 21 *
22/* Created, December 13, 2000 by Wayne Holm */ 22 * Change Activity:
23/* End Change Activity */ 23 * Created, December 13, 2000 by Wayne Holm
24/************************************************************************/ 24 * End Change Activity
25 */
26#include <linux/config.h>
25#include <linux/pci.h> 27#include <linux/pci.h>
26#include <linux/init.h> 28#include <linux/init.h>
27#include <linux/threads.h> 29#include <linux/threads.h>
@@ -30,30 +32,15 @@
30#include <linux/string.h> 32#include <linux/string.h>
31#include <linux/bootmem.h> 33#include <linux/bootmem.h>
32#include <linux/ide.h> 34#include <linux/ide.h>
33
34#include <linux/irq.h> 35#include <linux/irq.h>
35#include <linux/spinlock.h> 36#include <linux/spinlock.h>
36#include <asm/ppcdebug.h>
37 37
38#include <asm/ppcdebug.h>
39#include <asm/iSeries/HvTypes.h>
40#include <asm/iSeries/HvLpEvent.h>
38#include <asm/iSeries/HvCallPci.h> 41#include <asm/iSeries/HvCallPci.h>
39#include <asm/iSeries/HvCallXm.h> 42#include <asm/iSeries/HvCallXm.h>
40#include <asm/iSeries/iSeries_irq.h> 43#include <asm/iSeries/iSeries_irq.h>
41#include <asm/iSeries/XmPciLpEvent.h>
42
43static unsigned int iSeries_startup_IRQ(unsigned int irq);
44static void iSeries_shutdown_IRQ(unsigned int irq);
45static void iSeries_enable_IRQ(unsigned int irq);
46static void iSeries_disable_IRQ(unsigned int irq);
47static void iSeries_end_IRQ(unsigned int irq);
48
49static hw_irq_controller iSeries_IRQ_handler = {
50 .typename = "iSeries irq controller",
51 .startup = iSeries_startup_IRQ,
52 .shutdown = iSeries_shutdown_IRQ,
53 .enable = iSeries_enable_IRQ,
54 .disable = iSeries_disable_IRQ,
55 .end = iSeries_end_IRQ
56};
57 44
58/* This maps virtual irq numbers to real irqs */ 45/* This maps virtual irq numbers to real irqs */
59unsigned int virt_irq_to_real_map[NR_IRQS]; 46unsigned int virt_irq_to_real_map[NR_IRQS];
@@ -62,37 +49,187 @@ unsigned int virt_irq_to_real_map[NR_IRQS];
62/* Note: the pcnet32 driver assumes irq numbers < 2 aren't valid. :( */ 49/* Note: the pcnet32 driver assumes irq numbers < 2 aren't valid. :( */
63static int next_virtual_irq = 2; 50static int next_virtual_irq = 2;
64 51
65/* This is called by init_IRQ. set in ppc_md.init_IRQ by iSeries_setup.c */ 52static long Pci_Interrupt_Count;
66void __init iSeries_init_IRQ(void) 53static long Pci_Event_Count;
54
55enum XmPciLpEvent_Subtype {
56 XmPciLpEvent_BusCreated = 0, // PHB has been created
57 XmPciLpEvent_BusError = 1, // PHB has failed
58 XmPciLpEvent_BusFailed = 2, // Msg to Secondary, Primary failed bus
59 XmPciLpEvent_NodeFailed = 4, // Multi-adapter bridge has failed
60 XmPciLpEvent_NodeRecovered = 5, // Multi-adapter bridge has recovered
61 XmPciLpEvent_BusRecovered = 12, // PHB has been recovered
62 XmPciLpEvent_UnQuiesceBus = 18, // Secondary bus unqiescing
63 XmPciLpEvent_BridgeError = 21, // Bridge Error
64 XmPciLpEvent_SlotInterrupt = 22 // Slot interrupt
65};
66
67struct XmPciLpEvent_BusInterrupt {
68 HvBusNumber busNumber;
69 HvSubBusNumber subBusNumber;
70};
71
72struct XmPciLpEvent_NodeInterrupt {
73 HvBusNumber busNumber;
74 HvSubBusNumber subBusNumber;
75 HvAgentId deviceId;
76};
77
78struct XmPciLpEvent {
79 struct HvLpEvent hvLpEvent;
80
81 union {
82 u64 alignData; // Align on an 8-byte boundary
83
84 struct {
85 u32 fisr;
86 HvBusNumber busNumber;
87 HvSubBusNumber subBusNumber;
88 HvAgentId deviceId;
89 } slotInterrupt;
90
91 struct XmPciLpEvent_BusInterrupt busFailed;
92 struct XmPciLpEvent_BusInterrupt busRecovered;
93 struct XmPciLpEvent_BusInterrupt busCreated;
94
95 struct XmPciLpEvent_NodeInterrupt nodeFailed;
96 struct XmPciLpEvent_NodeInterrupt nodeRecovered;
97
98 } eventData;
99
100};
101
102static void intReceived(struct XmPciLpEvent *eventParm,
103 struct pt_regs *regsParm)
67{ 104{
68 /* Register PCI event handler and open an event path */ 105 int irq;
69 XmPciLpEvent_init(); 106
107 ++Pci_Interrupt_Count;
108
109 switch (eventParm->hvLpEvent.xSubtype) {
110 case XmPciLpEvent_SlotInterrupt:
111 irq = eventParm->hvLpEvent.xCorrelationToken;
112 /* Dispatch the interrupt handlers for this irq */
113 ppc_irq_dispatch_handler(regsParm, irq);
114 HvCallPci_eoi(eventParm->eventData.slotInterrupt.busNumber,
115 eventParm->eventData.slotInterrupt.subBusNumber,
116 eventParm->eventData.slotInterrupt.deviceId);
117 break;
118 /* Ignore error recovery events for now */
119 case XmPciLpEvent_BusCreated:
120 printk(KERN_INFO "intReceived: system bus %d created\n",
121 eventParm->eventData.busCreated.busNumber);
122 break;
123 case XmPciLpEvent_BusError:
124 case XmPciLpEvent_BusFailed:
125 printk(KERN_INFO "intReceived: system bus %d failed\n",
126 eventParm->eventData.busFailed.busNumber);
127 break;
128 case XmPciLpEvent_BusRecovered:
129 case XmPciLpEvent_UnQuiesceBus:
130 printk(KERN_INFO "intReceived: system bus %d recovered\n",
131 eventParm->eventData.busRecovered.busNumber);
132 break;
133 case XmPciLpEvent_NodeFailed:
134 case XmPciLpEvent_BridgeError:
135 printk(KERN_INFO
136 "intReceived: multi-adapter bridge %d/%d/%d failed\n",
137 eventParm->eventData.nodeFailed.busNumber,
138 eventParm->eventData.nodeFailed.subBusNumber,
139 eventParm->eventData.nodeFailed.deviceId);
140 break;
141 case XmPciLpEvent_NodeRecovered:
142 printk(KERN_INFO
143 "intReceived: multi-adapter bridge %d/%d/%d recovered\n",
144 eventParm->eventData.nodeRecovered.busNumber,
145 eventParm->eventData.nodeRecovered.subBusNumber,
146 eventParm->eventData.nodeRecovered.deviceId);
147 break;
148 default:
149 printk(KERN_ERR
150 "intReceived: unrecognized event subtype 0x%x\n",
151 eventParm->hvLpEvent.xSubtype);
152 break;
153 }
154}
155
156static void XmPciLpEvent_handler(struct HvLpEvent *eventParm,
157 struct pt_regs *regsParm)
158{
159#ifdef CONFIG_PCI
160 ++Pci_Event_Count;
161
162 if (eventParm && (eventParm->xType == HvLpEvent_Type_PciIo)) {
163 switch (eventParm->xFlags.xFunction) {
164 case HvLpEvent_Function_Int:
165 intReceived((struct XmPciLpEvent *)eventParm, regsParm);
166 break;
167 case HvLpEvent_Function_Ack:
168 printk(KERN_ERR
169 "XmPciLpEvent_handler: unexpected ack received\n");
170 break;
171 default:
172 printk(KERN_ERR
173 "XmPciLpEvent_handler: unexpected event function %d\n",
174 (int)eventParm->xFlags.xFunction);
175 break;
176 }
177 } else if (eventParm)
178 printk(KERN_ERR
179 "XmPciLpEvent_handler: Unrecognized PCI event type 0x%x\n",
180 (int)eventParm->xType);
181 else
182 printk(KERN_ERR "XmPciLpEvent_handler: NULL event received\n");
183#endif
70} 184}
71 185
72/* 186/*
73 * This is called out of iSeries_scan_slot to allocate an IRQ for an EADS slot 187 * This is called by init_IRQ. set in ppc_md.init_IRQ by iSeries_setup.c
74 * It calculates the irq value for the slot. 188 * It must be called before the bus walk.
75 * Note that subBusNumber is always 0 (at the moment at least).
76 */ 189 */
77int __init iSeries_allocate_IRQ(HvBusNumber busNumber, 190void __init iSeries_init_IRQ(void)
78 HvSubBusNumber subBusNumber, HvAgentId deviceId)
79{ 191{
80 unsigned int realirq, virtirq; 192 /* Register PCI event handler and open an event path */
81 u8 idsel = (deviceId >> 4); 193 int xRc;
82 u8 function = deviceId & 7;
83
84 virtirq = next_virtual_irq++;
85 realirq = ((busNumber - 1) << 6) + ((idsel - 1) << 3) + function;
86 virt_irq_to_real_map[virtirq] = realirq;
87 194
88 irq_desc[virtirq].handler = &iSeries_IRQ_handler; 195 xRc = HvLpEvent_registerHandler(HvLpEvent_Type_PciIo,
89 return virtirq; 196 &XmPciLpEvent_handler);
197 if (xRc == 0) {
198 xRc = HvLpEvent_openPath(HvLpEvent_Type_PciIo, 0);
199 if (xRc != 0)
200 printk(KERN_ERR "iSeries_init_IRQ: open event path "
201 "failed with rc 0x%x\n", xRc);
202 } else
203 printk(KERN_ERR "iSeries_init_IRQ: register handler "
204 "failed with rc 0x%x\n", xRc);
90} 205}
91 206
92#define REAL_IRQ_TO_BUS(irq) ((((irq) >> 6) & 0xff) + 1) 207#define REAL_IRQ_TO_BUS(irq) ((((irq) >> 6) & 0xff) + 1)
93#define REAL_IRQ_TO_IDSEL(irq) ((((irq) >> 3) & 7) + 1) 208#define REAL_IRQ_TO_IDSEL(irq) ((((irq) >> 3) & 7) + 1)
94#define REAL_IRQ_TO_FUNC(irq) ((irq) & 7) 209#define REAL_IRQ_TO_FUNC(irq) ((irq) & 7)
95 210
211/*
212 * This will be called by device drivers (via enable_IRQ)
213 * to enable INTA in the bridge interrupt status register.
214 */
215static void iSeries_enable_IRQ(unsigned int irq)
216{
217 u32 bus, deviceId, function, mask;
218 const u32 subBus = 0;
219 unsigned int rirq = virt_irq_to_real_map[irq];
220
221 /* The IRQ has already been locked by the caller */
222 bus = REAL_IRQ_TO_BUS(rirq);
223 function = REAL_IRQ_TO_FUNC(rirq);
224 deviceId = (REAL_IRQ_TO_IDSEL(rirq) << 4) + function;
225
226 /* Unmask secondary INTA */
227 mask = 0x80000000;
228 HvCallPci_unmaskInterrupts(bus, subBus, deviceId, mask);
229 PPCDBG(PPCDBG_BUSWALK, "iSeries_enable_IRQ 0x%02X.%02X.%02X 0x%04X\n",
230 bus, subBus, deviceId, irq);
231}
232
96/* This is called by iSeries_activate_IRQs */ 233/* This is called by iSeries_activate_IRQs */
97static unsigned int iSeries_startup_IRQ(unsigned int irq) 234static unsigned int iSeries_startup_IRQ(unsigned int irq)
98{ 235{
@@ -131,7 +268,7 @@ void __init iSeries_activate_IRQs()
131 desc->handler->startup(irq); 268 desc->handler->startup(irq);
132 spin_unlock_irqrestore(&desc->lock, flags); 269 spin_unlock_irqrestore(&desc->lock, flags);
133 } 270 }
134 } 271 }
135} 272}
136 273
137/* this is not called anywhere currently */ 274/* this is not called anywhere currently */
@@ -173,29 +310,7 @@ static void iSeries_disable_IRQ(unsigned int irq)
173 mask = 0x80000000; 310 mask = 0x80000000;
174 HvCallPci_maskInterrupts(bus, subBus, deviceId, mask); 311 HvCallPci_maskInterrupts(bus, subBus, deviceId, mask);
175 PPCDBG(PPCDBG_BUSWALK, "iSeries_disable_IRQ 0x%02X.%02X.%02X 0x%04X\n", 312 PPCDBG(PPCDBG_BUSWALK, "iSeries_disable_IRQ 0x%02X.%02X.%02X 0x%04X\n",
176 bus, subBus, deviceId, irq); 313 bus, subBus, deviceId, irq);
177}
178
179/*
180 * This will be called by device drivers (via enable_IRQ)
181 * to enable INTA in the bridge interrupt status register.
182 */
183static void iSeries_enable_IRQ(unsigned int irq)
184{
185 u32 bus, deviceId, function, mask;
186 const u32 subBus = 0;
187 unsigned int rirq = virt_irq_to_real_map[irq];
188
189 /* The IRQ has already been locked by the caller */
190 bus = REAL_IRQ_TO_BUS(rirq);
191 function = REAL_IRQ_TO_FUNC(rirq);
192 deviceId = (REAL_IRQ_TO_IDSEL(rirq) << 4) + function;
193
194 /* Unmask secondary INTA */
195 mask = 0x80000000;
196 HvCallPci_unmaskInterrupts(bus, subBus, deviceId, mask);
197 PPCDBG(PPCDBG_BUSWALK, "iSeries_enable_IRQ 0x%02X.%02X.%02X 0x%04X\n",
198 bus, subBus, deviceId, irq);
199} 314}
200 315
201/* 316/*
@@ -207,3 +322,32 @@ static void iSeries_enable_IRQ(unsigned int irq)
207static void iSeries_end_IRQ(unsigned int irq) 322static void iSeries_end_IRQ(unsigned int irq)
208{ 323{
209} 324}
325
326static hw_irq_controller iSeries_IRQ_handler = {
327 .typename = "iSeries irq controller",
328 .startup = iSeries_startup_IRQ,
329 .shutdown = iSeries_shutdown_IRQ,
330 .enable = iSeries_enable_IRQ,
331 .disable = iSeries_disable_IRQ,
332 .end = iSeries_end_IRQ
333};
334
335/*
336 * This is called out of iSeries_scan_slot to allocate an IRQ for an EADS slot
337 * It calculates the irq value for the slot.
338 * Note that subBusNumber is always 0 (at the moment at least).
339 */
340int __init iSeries_allocate_IRQ(HvBusNumber busNumber,
341 HvSubBusNumber subBusNumber, HvAgentId deviceId)
342{
343 unsigned int realirq, virtirq;
344 u8 idsel = (deviceId >> 4);
345 u8 function = deviceId & 7;
346
347 virtirq = next_virtual_irq++;
348 realirq = ((busNumber - 1) << 6) + ((idsel - 1) << 3) + function;
349 virt_irq_to_real_map[virtirq] = realirq;
350
351 irq_desc[virtirq].handler = &iSeries_IRQ_handler;
352 return virtirq;
353}
diff --git a/arch/ppc64/kernel/iSeries_pci.c b/arch/ppc64/kernel/iSeries_pci.c
index bd4c2554f1a0..356e4fd9a94f 100644
--- a/arch/ppc64/kernel/iSeries_pci.c
+++ b/arch/ppc64/kernel/iSeries_pci.c
@@ -38,9 +38,7 @@
38#include <asm/iommu.h> 38#include <asm/iommu.h>
39 39
40#include <asm/iSeries/HvCallPci.h> 40#include <asm/iSeries/HvCallPci.h>
41#include <asm/iSeries/HvCallSm.h>
42#include <asm/iSeries/HvCallXm.h> 41#include <asm/iSeries/HvCallXm.h>
43#include <asm/iSeries/LparData.h>
44#include <asm/iSeries/iSeries_irq.h> 42#include <asm/iSeries/iSeries_irq.h>
45#include <asm/iSeries/iSeries_pci.h> 43#include <asm/iSeries/iSeries_pci.h>
46#include <asm/iSeries/mf.h> 44#include <asm/iSeries/mf.h>
@@ -225,10 +223,7 @@ static struct iSeries_Device_Node *build_device_node(HvBusNumber Bus,
225 node->DsaAddr.Dsa.busNumber = Bus; 223 node->DsaAddr.Dsa.busNumber = Bus;
226 node->DsaAddr.Dsa.subBusNumber = SubBus; 224 node->DsaAddr.Dsa.subBusNumber = SubBus;
227 node->DsaAddr.Dsa.deviceId = 0x10; 225 node->DsaAddr.Dsa.deviceId = 0x10;
228 node->AgentId = AgentId;
229 node->DevFn = PCI_DEVFN(ISERIES_ENCODE_DEVICE(AgentId), Function); 226 node->DevFn = PCI_DEVFN(ISERIES_ENCODE_DEVICE(AgentId), Function);
230 node->IoRetry = 0;
231 iSeries_Get_Location_Code(node);
232 return node; 227 return node;
233} 228}
234 229
@@ -302,7 +297,6 @@ void __init iSeries_pci_final_fixup(void)
302{ 297{
303 struct pci_dev *pdev = NULL; 298 struct pci_dev *pdev = NULL;
304 struct iSeries_Device_Node *node; 299 struct iSeries_Device_Node *node;
305 char Buffer[256];
306 int DeviceCount = 0; 300 int DeviceCount = 0;
307 301
308 PPCDBG(PPCDBG_BUSWALK, "iSeries_pcibios_fixup Entry.\n"); 302 PPCDBG(PPCDBG_BUSWALK, "iSeries_pcibios_fixup Entry.\n");
@@ -324,9 +318,7 @@ void __init iSeries_pci_final_fixup(void)
324 "pdev 0x%p <==> DevNode 0x%p\n", 318 "pdev 0x%p <==> DevNode 0x%p\n",
325 pdev, node); 319 pdev, node);
326 allocate_device_bars(pdev); 320 allocate_device_bars(pdev);
327 iSeries_Device_Information(pdev, Buffer, 321 iSeries_Device_Information(pdev, DeviceCount);
328 sizeof(Buffer));
329 printk("%d. %s\n", DeviceCount, Buffer);
330 iommu_devnode_init_iSeries(node); 322 iommu_devnode_init_iSeries(node);
331 } else 323 } else
332 printk("PCI: Device Tree not found for 0x%016lX\n", 324 printk("PCI: Device Tree not found for 0x%016lX\n",
@@ -499,7 +491,6 @@ static int scan_bridge_slot(HvBusNumber Bus,
499 491
500 ++DeviceCount; 492 ++DeviceCount;
501 node = build_device_node(Bus, SubBus, EADsIdSel, Function); 493 node = build_device_node(Bus, SubBus, EADsIdSel, Function);
502 node->Vendor = VendorId;
503 node->Irq = Irq; 494 node->Irq = Irq;
504 node->LogicalSlot = BridgeInfo->logicalSlotNumber; 495 node->LogicalSlot = BridgeInfo->logicalSlotNumber;
505 496
@@ -661,38 +652,34 @@ static struct pci_ops iSeries_pci_ops = {
661 * Check Return Code 652 * Check Return Code
662 * -> On Failure, print and log information. 653 * -> On Failure, print and log information.
663 * Increment Retry Count, if exceeds max, panic partition. 654 * Increment Retry Count, if exceeds max, panic partition.
664 * -> If in retry, print and log success
665 * 655 *
666 * PCI: Device 23.90 ReadL I/O Error( 0): 0x1234 656 * PCI: Device 23.90 ReadL I/O Error( 0): 0x1234
667 * PCI: Device 23.90 ReadL Retry( 1) 657 * PCI: Device 23.90 ReadL Retry( 1)
668 * PCI: Device 23.90 ReadL Retry Successful(1) 658 * PCI: Device 23.90 ReadL Retry Successful(1)
669 */ 659 */
670static int CheckReturnCode(char *TextHdr, struct iSeries_Device_Node *DevNode, 660static int CheckReturnCode(char *TextHdr, struct iSeries_Device_Node *DevNode,
671 u64 ret) 661 int *retry, u64 ret)
672{ 662{
673 if (ret != 0) { 663 if (ret != 0) {
674 ++Pci_Error_Count; 664 ++Pci_Error_Count;
675 ++DevNode->IoRetry; 665 (*retry)++;
676 printk("PCI: %s: Device 0x%04X:%02X I/O Error(%2d): 0x%04X\n", 666 printk("PCI: %s: Device 0x%04X:%02X I/O Error(%2d): 0x%04X\n",
677 TextHdr, DevNode->DsaAddr.Dsa.busNumber, DevNode->DevFn, 667 TextHdr, DevNode->DsaAddr.Dsa.busNumber, DevNode->DevFn,
678 DevNode->IoRetry, (int)ret); 668 *retry, (int)ret);
679 /* 669 /*
680 * Bump the retry and check for retry count exceeded. 670 * Bump the retry and check for retry count exceeded.
681 * If, Exceeded, panic the system. 671 * If, Exceeded, panic the system.
682 */ 672 */
683 if ((DevNode->IoRetry > Pci_Retry_Max) && 673 if (((*retry) > Pci_Retry_Max) &&
684 (Pci_Error_Flag > 0)) { 674 (Pci_Error_Flag > 0)) {
685 mf_display_src(0xB6000103); 675 mf_display_src(0xB6000103);
686 panic_timeout = 0; 676 panic_timeout = 0;
687 panic("PCI: Hardware I/O Error, SRC B6000103, " 677 panic("PCI: Hardware I/O Error, SRC B6000103, "
688 "Automatic Reboot Disabled.\n"); 678 "Automatic Reboot Disabled.\n");
689 } 679 }
690 return -1; /* Retry Try */ 680 return -1; /* Retry Try */
691 } 681 }
692 /* If retry was in progress, log success and rest retry count */ 682 return 0;
693 if (DevNode->IoRetry > 0)
694 DevNode->IoRetry = 0;
695 return 0;
696} 683}
697 684
698/* 685/*
@@ -738,6 +725,7 @@ u8 iSeries_Read_Byte(const volatile void __iomem *IoAddress)
738{ 725{
739 u64 BarOffset; 726 u64 BarOffset;
740 u64 dsa; 727 u64 dsa;
728 int retry = 0;
741 struct HvCallPci_LoadReturn ret; 729 struct HvCallPci_LoadReturn ret;
742 struct iSeries_Device_Node *DevNode = 730 struct iSeries_Device_Node *DevNode =
743 xlate_iomm_address(IoAddress, &dsa, &BarOffset); 731 xlate_iomm_address(IoAddress, &dsa, &BarOffset);
@@ -757,7 +745,7 @@ u8 iSeries_Read_Byte(const volatile void __iomem *IoAddress)
757 do { 745 do {
758 ++Pci_Io_Read_Count; 746 ++Pci_Io_Read_Count;
759 HvCall3Ret16(HvCallPciBarLoad8, &ret, dsa, BarOffset, 0); 747 HvCall3Ret16(HvCallPciBarLoad8, &ret, dsa, BarOffset, 0);
760 } while (CheckReturnCode("RDB", DevNode, ret.rc) != 0); 748 } while (CheckReturnCode("RDB", DevNode, &retry, ret.rc) != 0);
761 749
762 return (u8)ret.value; 750 return (u8)ret.value;
763} 751}
@@ -767,6 +755,7 @@ u16 iSeries_Read_Word(const volatile void __iomem *IoAddress)
767{ 755{
768 u64 BarOffset; 756 u64 BarOffset;
769 u64 dsa; 757 u64 dsa;
758 int retry = 0;
770 struct HvCallPci_LoadReturn ret; 759 struct HvCallPci_LoadReturn ret;
771 struct iSeries_Device_Node *DevNode = 760 struct iSeries_Device_Node *DevNode =
772 xlate_iomm_address(IoAddress, &dsa, &BarOffset); 761 xlate_iomm_address(IoAddress, &dsa, &BarOffset);
@@ -787,7 +776,7 @@ u16 iSeries_Read_Word(const volatile void __iomem *IoAddress)
787 ++Pci_Io_Read_Count; 776 ++Pci_Io_Read_Count;
788 HvCall3Ret16(HvCallPciBarLoad16, &ret, dsa, 777 HvCall3Ret16(HvCallPciBarLoad16, &ret, dsa,
789 BarOffset, 0); 778 BarOffset, 0);
790 } while (CheckReturnCode("RDW", DevNode, ret.rc) != 0); 779 } while (CheckReturnCode("RDW", DevNode, &retry, ret.rc) != 0);
791 780
792 return swab16((u16)ret.value); 781 return swab16((u16)ret.value);
793} 782}
@@ -797,6 +786,7 @@ u32 iSeries_Read_Long(const volatile void __iomem *IoAddress)
797{ 786{
798 u64 BarOffset; 787 u64 BarOffset;
799 u64 dsa; 788 u64 dsa;
789 int retry = 0;
800 struct HvCallPci_LoadReturn ret; 790 struct HvCallPci_LoadReturn ret;
801 struct iSeries_Device_Node *DevNode = 791 struct iSeries_Device_Node *DevNode =
802 xlate_iomm_address(IoAddress, &dsa, &BarOffset); 792 xlate_iomm_address(IoAddress, &dsa, &BarOffset);
@@ -817,7 +807,7 @@ u32 iSeries_Read_Long(const volatile void __iomem *IoAddress)
817 ++Pci_Io_Read_Count; 807 ++Pci_Io_Read_Count;
818 HvCall3Ret16(HvCallPciBarLoad32, &ret, dsa, 808 HvCall3Ret16(HvCallPciBarLoad32, &ret, dsa,
819 BarOffset, 0); 809 BarOffset, 0);
820 } while (CheckReturnCode("RDL", DevNode, ret.rc) != 0); 810 } while (CheckReturnCode("RDL", DevNode, &retry, ret.rc) != 0);
821 811
822 return swab32((u32)ret.value); 812 return swab32((u32)ret.value);
823} 813}
@@ -834,6 +824,7 @@ void iSeries_Write_Byte(u8 data, volatile void __iomem *IoAddress)
834{ 824{
835 u64 BarOffset; 825 u64 BarOffset;
836 u64 dsa; 826 u64 dsa;
827 int retry = 0;
837 u64 rc; 828 u64 rc;
838 struct iSeries_Device_Node *DevNode = 829 struct iSeries_Device_Node *DevNode =
839 xlate_iomm_address(IoAddress, &dsa, &BarOffset); 830 xlate_iomm_address(IoAddress, &dsa, &BarOffset);
@@ -853,7 +844,7 @@ void iSeries_Write_Byte(u8 data, volatile void __iomem *IoAddress)
853 do { 844 do {
854 ++Pci_Io_Write_Count; 845 ++Pci_Io_Write_Count;
855 rc = HvCall4(HvCallPciBarStore8, dsa, BarOffset, data, 0); 846 rc = HvCall4(HvCallPciBarStore8, dsa, BarOffset, data, 0);
856 } while (CheckReturnCode("WWB", DevNode, rc) != 0); 847 } while (CheckReturnCode("WWB", DevNode, &retry, rc) != 0);
857} 848}
858EXPORT_SYMBOL(iSeries_Write_Byte); 849EXPORT_SYMBOL(iSeries_Write_Byte);
859 850
@@ -861,6 +852,7 @@ void iSeries_Write_Word(u16 data, volatile void __iomem *IoAddress)
861{ 852{
862 u64 BarOffset; 853 u64 BarOffset;
863 u64 dsa; 854 u64 dsa;
855 int retry = 0;
864 u64 rc; 856 u64 rc;
865 struct iSeries_Device_Node *DevNode = 857 struct iSeries_Device_Node *DevNode =
866 xlate_iomm_address(IoAddress, &dsa, &BarOffset); 858 xlate_iomm_address(IoAddress, &dsa, &BarOffset);
@@ -880,7 +872,7 @@ void iSeries_Write_Word(u16 data, volatile void __iomem *IoAddress)
880 do { 872 do {
881 ++Pci_Io_Write_Count; 873 ++Pci_Io_Write_Count;
882 rc = HvCall4(HvCallPciBarStore16, dsa, BarOffset, swab16(data), 0); 874 rc = HvCall4(HvCallPciBarStore16, dsa, BarOffset, swab16(data), 0);
883 } while (CheckReturnCode("WWW", DevNode, rc) != 0); 875 } while (CheckReturnCode("WWW", DevNode, &retry, rc) != 0);
884} 876}
885EXPORT_SYMBOL(iSeries_Write_Word); 877EXPORT_SYMBOL(iSeries_Write_Word);
886 878
@@ -888,6 +880,7 @@ void iSeries_Write_Long(u32 data, volatile void __iomem *IoAddress)
888{ 880{
889 u64 BarOffset; 881 u64 BarOffset;
890 u64 dsa; 882 u64 dsa;
883 int retry = 0;
891 u64 rc; 884 u64 rc;
892 struct iSeries_Device_Node *DevNode = 885 struct iSeries_Device_Node *DevNode =
893 xlate_iomm_address(IoAddress, &dsa, &BarOffset); 886 xlate_iomm_address(IoAddress, &dsa, &BarOffset);
@@ -907,6 +900,6 @@ void iSeries_Write_Long(u32 data, volatile void __iomem *IoAddress)
907 do { 900 do {
908 ++Pci_Io_Write_Count; 901 ++Pci_Io_Write_Count;
909 rc = HvCall4(HvCallPciBarStore32, dsa, BarOffset, swab32(data), 0); 902 rc = HvCall4(HvCallPciBarStore32, dsa, BarOffset, swab32(data), 0);
910 } while (CheckReturnCode("WWL", DevNode, rc) != 0); 903 } while (CheckReturnCode("WWL", DevNode, &retry, rc) != 0);
911} 904}
912EXPORT_SYMBOL(iSeries_Write_Long); 905EXPORT_SYMBOL(iSeries_Write_Long);
diff --git a/arch/ppc64/kernel/iSeries_pci_reset.c b/arch/ppc64/kernel/iSeries_pci_reset.c
deleted file mode 100644
index 0f785e4584f7..000000000000
--- a/arch/ppc64/kernel/iSeries_pci_reset.c
+++ /dev/null
@@ -1,104 +0,0 @@
1#define PCIFR(...)
2/************************************************************************/
3/* File iSeries_pci_reset.c created by Allan Trautman on Mar 21 2001. */
4/************************************************************************/
5/* This code supports the pci interface on the IBM iSeries systems. */
6/* Copyright (C) 20yy <Allan H Trautman> <IBM Corp> */
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: */
20/* Free Software Foundation, Inc., */
21/* 59 Temple Place, Suite 330, */
22/* Boston, MA 02111-1307 USA */
23/************************************************************************/
24/* Change Activity: */
25/* Created, March 20, 2001 */
26/* April 30, 2001, Added return codes on functions. */
27/* September 10, 2001, Ported to ppc64. */
28/* End Change Activity */
29/************************************************************************/
30#include <linux/kernel.h>
31#include <linux/init.h>
32#include <linux/module.h>
33#include <linux/pci.h>
34#include <linux/irq.h>
35#include <linux/delay.h>
36
37#include <asm/io.h>
38#include <asm/iSeries/HvCallPci.h>
39#include <asm/iSeries/HvTypes.h>
40#include <asm/iSeries/mf.h>
41#include <asm/pci.h>
42
43#include <asm/iSeries/iSeries_pci.h>
44#include "pci.h"
45
46/*
47 * Interface to toggle the reset line
48 * Time is in .1 seconds, need for seconds.
49 */
50int iSeries_Device_ToggleReset(struct pci_dev *PciDev, int AssertTime,
51 int DelayTime)
52{
53 unsigned int AssertDelay, WaitDelay;
54 struct iSeries_Device_Node *DeviceNode =
55 (struct iSeries_Device_Node *)PciDev->sysdata;
56
57 if (DeviceNode == NULL) {
58 printk("PCI: Pci Reset Failed, Device Node not found for pci_dev %p\n",
59 PciDev);
60 return -1;
61 }
62 /*
63 * Set defaults, Assert is .5 second, Wait is 3 seconds.
64 */
65 if (AssertTime == 0)
66 AssertDelay = 500;
67 else
68 AssertDelay = AssertTime * 100;
69
70 if (DelayTime == 0)
71 WaitDelay = 3000;
72 else
73 WaitDelay = DelayTime * 100;
74
75 /*
76 * Assert reset
77 */
78 DeviceNode->ReturnCode = HvCallPci_setSlotReset(ISERIES_BUS(DeviceNode),
79 0x00, DeviceNode->AgentId, 1);
80 if (DeviceNode->ReturnCode == 0) {
81 msleep(AssertDelay); /* Sleep for the time */
82 DeviceNode->ReturnCode =
83 HvCallPci_setSlotReset(ISERIES_BUS(DeviceNode),
84 0x00, DeviceNode->AgentId, 0);
85
86 /*
87 * Wait for device to reset
88 */
89 msleep(WaitDelay);
90 }
91 if (DeviceNode->ReturnCode == 0)
92 PCIFR("Slot 0x%04X.%02 Reset\n", ISERIES_BUS(DeviceNode),
93 DeviceNode->AgentId);
94 else {
95 printk("PCI: Slot 0x%04X.%02X Reset Failed, RCode: %04X\n",
96 ISERIES_BUS(DeviceNode), DeviceNode->AgentId,
97 DeviceNode->ReturnCode);
98 PCIFR("Slot 0x%04X.%02X Reset Failed, RCode: %04X\n",
99 ISERIES_BUS(DeviceNode), DeviceNode->AgentId,
100 DeviceNode->ReturnCode);
101 }
102 return DeviceNode->ReturnCode;
103}
104EXPORT_SYMBOL(iSeries_Device_ToggleReset);
diff --git a/arch/ppc64/kernel/iSeries_proc.c b/arch/ppc64/kernel/iSeries_proc.c
index 0cc58ddf48de..356bd9931fcc 100644
--- a/arch/ppc64/kernel/iSeries_proc.c
+++ b/arch/ppc64/kernel/iSeries_proc.c
@@ -28,8 +28,7 @@
28#include <asm/iSeries/ItLpQueue.h> 28#include <asm/iSeries/ItLpQueue.h>
29#include <asm/iSeries/HvCallXm.h> 29#include <asm/iSeries/HvCallXm.h>
30#include <asm/iSeries/IoHriMainStore.h> 30#include <asm/iSeries/IoHriMainStore.h>
31#include <asm/iSeries/LparData.h> 31#include <asm/iSeries/IoHriProcessorVpd.h>
32#include <asm/iSeries/iSeries_proc.h>
33 32
34static int __init iseries_proc_create(void) 33static int __init iseries_proc_create(void)
35{ 34{
diff --git a/arch/ppc64/kernel/iSeries_setup.c b/arch/ppc64/kernel/iSeries_setup.c
index 6d06eb550a3f..b31962436fe3 100644
--- a/arch/ppc64/kernel/iSeries_setup.c
+++ b/arch/ppc64/kernel/iSeries_setup.c
@@ -47,7 +47,7 @@
47#include <asm/paca.h> 47#include <asm/paca.h>
48#include <asm/cache.h> 48#include <asm/cache.h>
49#include <asm/sections.h> 49#include <asm/sections.h>
50#include <asm/iSeries/LparData.h> 50#include <asm/abs_addr.h>
51#include <asm/iSeries/HvCallHpt.h> 51#include <asm/iSeries/HvCallHpt.h>
52#include <asm/iSeries/HvLpConfig.h> 52#include <asm/iSeries/HvLpConfig.h>
53#include <asm/iSeries/HvCallEvent.h> 53#include <asm/iSeries/HvCallEvent.h>
@@ -55,10 +55,12 @@
55#include <asm/iSeries/HvCallXm.h> 55#include <asm/iSeries/HvCallXm.h>
56#include <asm/iSeries/ItLpQueue.h> 56#include <asm/iSeries/ItLpQueue.h>
57#include <asm/iSeries/IoHriMainStore.h> 57#include <asm/iSeries/IoHriMainStore.h>
58#include <asm/iSeries/iSeries_proc.h>
59#include <asm/iSeries/mf.h> 58#include <asm/iSeries/mf.h>
60#include <asm/iSeries/HvLpEvent.h> 59#include <asm/iSeries/HvLpEvent.h>
61#include <asm/iSeries/iSeries_irq.h> 60#include <asm/iSeries/iSeries_irq.h>
61#include <asm/iSeries/IoHriProcessorVpd.h>
62#include <asm/iSeries/ItVpdAreas.h>
63#include <asm/iSeries/LparMap.h>
62 64
63extern void hvlog(char *fmt, ...); 65extern void hvlog(char *fmt, ...);
64 66
@@ -74,7 +76,11 @@ extern void ppcdbg_initialize(void);
74static void build_iSeries_Memory_Map(void); 76static void build_iSeries_Memory_Map(void);
75static void setup_iSeries_cache_sizes(void); 77static void setup_iSeries_cache_sizes(void);
76static void iSeries_bolt_kernel(unsigned long saddr, unsigned long eaddr); 78static void iSeries_bolt_kernel(unsigned long saddr, unsigned long eaddr);
79#ifdef CONFIG_PCI
77extern void iSeries_pci_final_fixup(void); 80extern void iSeries_pci_final_fixup(void);
81#else
82static void iSeries_pci_final_fixup(void) { }
83#endif
78 84
79/* Global Variables */ 85/* Global Variables */
80static unsigned long procFreqHz; 86static unsigned long procFreqHz;
@@ -874,6 +880,10 @@ static int set_spread_lpevents(char *str)
874} 880}
875__setup("spread_lpevents=", set_spread_lpevents); 881__setup("spread_lpevents=", set_spread_lpevents);
876 882
883#ifndef CONFIG_PCI
884void __init iSeries_init_IRQ(void) { }
885#endif
886
877void __init iSeries_early_setup(void) 887void __init iSeries_early_setup(void)
878{ 888{
879 iSeries_fixup_klimit(); 889 iSeries_fixup_klimit();
diff --git a/arch/ppc64/kernel/iSeries_smp.c b/arch/ppc64/kernel/iSeries_smp.c
index ba1f084d5462..f74386e31638 100644
--- a/arch/ppc64/kernel/iSeries_smp.c
+++ b/arch/ppc64/kernel/iSeries_smp.c
@@ -38,9 +38,7 @@
38#include <asm/io.h> 38#include <asm/io.h>
39#include <asm/smp.h> 39#include <asm/smp.h>
40#include <asm/paca.h> 40#include <asm/paca.h>
41#include <asm/iSeries/LparData.h>
42#include <asm/iSeries/HvCall.h> 41#include <asm/iSeries/HvCall.h>
43#include <asm/iSeries/HvCallCfg.h>
44#include <asm/time.h> 42#include <asm/time.h>
45#include <asm/ppcdebug.h> 43#include <asm/ppcdebug.h>
46#include <asm/machdep.h> 44#include <asm/machdep.h>
diff --git a/arch/ppc64/kernel/idle.c b/arch/ppc64/kernel/idle.c
index f24ce2b87200..bdf13b4dc1c8 100644
--- a/arch/ppc64/kernel/idle.c
+++ b/arch/ppc64/kernel/idle.c
@@ -42,6 +42,11 @@ static int (*idle_loop)(void);
42static unsigned long maxYieldTime = 0; 42static unsigned long maxYieldTime = 0;
43static unsigned long minYieldTime = 0xffffffffffffffffUL; 43static unsigned long minYieldTime = 0xffffffffffffffffUL;
44 44
45static inline void process_iSeries_events(void)
46{
47 asm volatile ("li 0,0x5555; sc" : : : "r0", "r3");
48}
49
45static void yield_shared_processor(void) 50static void yield_shared_processor(void)
46{ 51{
47 unsigned long tb; 52 unsigned long tb;
@@ -292,7 +297,7 @@ static int native_idle(void)
292 if (need_resched()) 297 if (need_resched())
293 schedule(); 298 schedule();
294 299
295 if (cpu_is_offline(_smp_processor_id()) && 300 if (cpu_is_offline(raw_smp_processor_id()) &&
296 system_state == SYSTEM_RUNNING) 301 system_state == SYSTEM_RUNNING)
297 cpu_die(); 302 cpu_die();
298 } 303 }
diff --git a/arch/ppc64/kernel/irq.c b/arch/ppc64/kernel/irq.c
index 4fd7f203c1e3..d860467b8f09 100644
--- a/arch/ppc64/kernel/irq.c
+++ b/arch/ppc64/kernel/irq.c
@@ -52,7 +52,7 @@
52#include <asm/cache.h> 52#include <asm/cache.h>
53#include <asm/prom.h> 53#include <asm/prom.h>
54#include <asm/ptrace.h> 54#include <asm/ptrace.h>
55#include <asm/iSeries/LparData.h> 55#include <asm/iSeries/ItLpQueue.h>
56#include <asm/machdep.h> 56#include <asm/machdep.h>
57#include <asm/paca.h> 57#include <asm/paca.h>
58 58
diff --git a/arch/ppc64/kernel/lparcfg.c b/arch/ppc64/kernel/lparcfg.c
index a8fd32df848b..387923fcf9b0 100644
--- a/arch/ppc64/kernel/lparcfg.c
+++ b/arch/ppc64/kernel/lparcfg.c
@@ -28,12 +28,12 @@
28#include <asm/uaccess.h> 28#include <asm/uaccess.h>
29#include <asm/iSeries/HvLpConfig.h> 29#include <asm/iSeries/HvLpConfig.h>
30#include <asm/lppaca.h> 30#include <asm/lppaca.h>
31#include <asm/iSeries/LparData.h>
32#include <asm/hvcall.h> 31#include <asm/hvcall.h>
33#include <asm/cputable.h> 32#include <asm/cputable.h>
34#include <asm/rtas.h> 33#include <asm/rtas.h>
35#include <asm/system.h> 34#include <asm/system.h>
36#include <asm/time.h> 35#include <asm/time.h>
36#include <asm/iSeries/ItExtVpdPanel.h>
37 37
38#define MODULE_VERS "1.6" 38#define MODULE_VERS "1.6"
39#define MODULE_NAME "lparcfg" 39#define MODULE_NAME "lparcfg"
diff --git a/arch/ppc64/kernel/mf.c b/arch/ppc64/kernel/mf.c
index 5aca7e8005a8..d98bebf7042f 100644
--- a/arch/ppc64/kernel/mf.c
+++ b/arch/ppc64/kernel/mf.c
@@ -40,7 +40,6 @@
40#include <asm/iSeries/vio.h> 40#include <asm/iSeries/vio.h>
41#include <asm/iSeries/mf.h> 41#include <asm/iSeries/mf.h>
42#include <asm/iSeries/HvLpConfig.h> 42#include <asm/iSeries/HvLpConfig.h>
43#include <asm/iSeries/ItSpCommArea.h>
44#include <asm/iSeries/ItLpQueue.h> 43#include <asm/iSeries/ItLpQueue.h>
45 44
46/* 45/*
diff --git a/arch/ppc64/kernel/process.c b/arch/ppc64/kernel/process.c
index cdfecbeb331f..aba89554d89d 100644
--- a/arch/ppc64/kernel/process.c
+++ b/arch/ppc64/kernel/process.c
@@ -58,14 +58,6 @@ struct task_struct *last_task_used_math = NULL;
58struct task_struct *last_task_used_altivec = NULL; 58struct task_struct *last_task_used_altivec = NULL;
59#endif 59#endif
60 60
61struct mm_struct ioremap_mm = {
62 .pgd = ioremap_dir,
63 .mm_users = ATOMIC_INIT(2),
64 .mm_count = ATOMIC_INIT(1),
65 .cpu_vm_mask = CPU_MASK_ALL,
66 .page_table_lock = SPIN_LOCK_UNLOCKED,
67};
68
69/* 61/*
70 * Make sure the floating-point register state in the 62 * Make sure the floating-point register state in the
71 * the thread_struct is up to date for task tsk. 63 * the thread_struct is up to date for task tsk.
diff --git a/arch/ppc64/kernel/prom.c b/arch/ppc64/kernel/prom.c
index eb6538b58008..47727a6f7346 100644
--- a/arch/ppc64/kernel/prom.c
+++ b/arch/ppc64/kernel/prom.c
@@ -884,6 +884,7 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
884{ 884{
885 char *type = get_flat_dt_prop(node, "device_type", NULL); 885 char *type = get_flat_dt_prop(node, "device_type", NULL);
886 u32 *prop; 886 u32 *prop;
887 unsigned long size;
887 888
888 /* We are scanning "cpu" nodes only */ 889 /* We are scanning "cpu" nodes only */
889 if (type == NULL || strcmp(type, "cpu") != 0) 890 if (type == NULL || strcmp(type, "cpu") != 0)
@@ -929,6 +930,17 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
929 cur_cpu_spec->cpu_user_features |= PPC_FEATURE_HAS_ALTIVEC; 930 cur_cpu_spec->cpu_user_features |= PPC_FEATURE_HAS_ALTIVEC;
930 } 931 }
931 932
933 /*
934 * Check for an SMT capable CPU and set the CPU feature. We do
935 * this by looking at the size of the ibm,ppc-interrupt-server#s
936 * property
937 */
938 prop = (u32 *)get_flat_dt_prop(node, "ibm,ppc-interrupt-server#s",
939 &size);
940 cur_cpu_spec->cpu_features &= ~CPU_FTR_SMT;
941 if (prop && ((size / sizeof(u32)) > 1))
942 cur_cpu_spec->cpu_features |= CPU_FTR_SMT;
943
932 return 0; 944 return 0;
933} 945}
934 946
diff --git a/arch/ppc64/kernel/ras.c b/arch/ppc64/kernel/ras.c
index 1c4c796b212b..3c00f7bfc1b5 100644
--- a/arch/ppc64/kernel/ras.c
+++ b/arch/ppc64/kernel/ras.c
@@ -47,7 +47,6 @@
47#include <asm/cache.h> 47#include <asm/cache.h>
48#include <asm/prom.h> 48#include <asm/prom.h>
49#include <asm/ptrace.h> 49#include <asm/ptrace.h>
50#include <asm/iSeries/LparData.h>
51#include <asm/machdep.h> 50#include <asm/machdep.h>
52#include <asm/rtas.h> 51#include <asm/rtas.h>
53#include <asm/ppcdebug.h> 52#include <asm/ppcdebug.h>
diff --git a/arch/ppc64/kernel/rtc.c b/arch/ppc64/kernel/rtc.c
index 67989055a9fe..de02aedbe080 100644
--- a/arch/ppc64/kernel/rtc.c
+++ b/arch/ppc64/kernel/rtc.c
@@ -42,10 +42,8 @@
42#include <asm/time.h> 42#include <asm/time.h>
43#include <asm/rtas.h> 43#include <asm/rtas.h>
44 44
45#include <asm/iSeries/LparData.h>
46#include <asm/iSeries/mf.h> 45#include <asm/iSeries/mf.h>
47#include <asm/machdep.h> 46#include <asm/machdep.h>
48#include <asm/iSeries/ItSpCommArea.h>
49 47
50extern int piranha_simulator; 48extern int piranha_simulator;
51 49
diff --git a/arch/ppc64/kernel/setup.c b/arch/ppc64/kernel/setup.c
index dce198d39328..8e439a817642 100644
--- a/arch/ppc64/kernel/setup.c
+++ b/arch/ppc64/kernel/setup.c
@@ -41,7 +41,6 @@
41#include <asm/smp.h> 41#include <asm/smp.h>
42#include <asm/elf.h> 42#include <asm/elf.h>
43#include <asm/machdep.h> 43#include <asm/machdep.h>
44#include <asm/iSeries/LparData.h>
45#include <asm/paca.h> 44#include <asm/paca.h>
46#include <asm/ppcdebug.h> 45#include <asm/ppcdebug.h>
47#include <asm/time.h> 46#include <asm/time.h>
@@ -57,6 +56,8 @@
57#include <asm/cache.h> 56#include <asm/cache.h>
58#include <asm/page.h> 57#include <asm/page.h>
59#include <asm/mmu.h> 58#include <asm/mmu.h>
59#include <asm/lmb.h>
60#include <asm/iSeries/ItLpNaca.h>
60 61
61#ifdef DEBUG 62#ifdef DEBUG
62#define DBG(fmt...) udbg_printf(fmt) 63#define DBG(fmt...) udbg_printf(fmt)
diff --git a/arch/ppc64/kernel/sys_ppc32.c b/arch/ppc64/kernel/sys_ppc32.c
index 9c8e317c598d..118436e8085a 100644
--- a/arch/ppc64/kernel/sys_ppc32.c
+++ b/arch/ppc64/kernel/sys_ppc32.c
@@ -741,6 +741,7 @@ asmlinkage int sys32_pciconfig_write(u32 bus, u32 dfn, u32 off, u32 len, u32 ubu
741 741
742asmlinkage int sys32_pciconfig_iobase(u32 which, u32 in_bus, u32 in_devfn) 742asmlinkage int sys32_pciconfig_iobase(u32 which, u32 in_bus, u32 in_devfn)
743{ 743{
744#ifdef CONFIG_PCI
744 struct pci_controller* hose; 745 struct pci_controller* hose;
745 struct list_head *ln; 746 struct list_head *ln;
746 struct pci_bus *bus = NULL; 747 struct pci_bus *bus = NULL;
@@ -786,7 +787,7 @@ asmlinkage int sys32_pciconfig_iobase(u32 which, u32 in_bus, u32 in_devfn)
786 case IOBASE_ISA_MEM: 787 case IOBASE_ISA_MEM:
787 return -EINVAL; 788 return -EINVAL;
788 } 789 }
789 790#endif /* CONFIG_PCI */
790 return -EOPNOTSUPP; 791 return -EOPNOTSUPP;
791} 792}
792 793
diff --git a/arch/ppc64/kernel/vio.c b/arch/ppc64/kernel/vio.c
index 79f2dc7a9833..0c0ba71ac0e8 100644
--- a/arch/ppc64/kernel/vio.c
+++ b/arch/ppc64/kernel/vio.c
@@ -41,20 +41,25 @@ static const struct vio_device_id *vio_match_device(
41static struct iommu_table *vio_build_iommu_table(struct vio_dev *); 41static struct iommu_table *vio_build_iommu_table(struct vio_dev *);
42static int vio_num_address_cells; 42static int vio_num_address_cells;
43#endif 43#endif
44static struct vio_dev *vio_bus_device; /* fake "parent" device */
45
46#ifdef CONFIG_PPC_ISERIES 44#ifdef CONFIG_PPC_ISERIES
47static struct vio_dev *__init vio_register_device_iseries(char *type,
48 uint32_t unit_num);
49
50static struct iommu_table veth_iommu_table; 45static struct iommu_table veth_iommu_table;
51static struct iommu_table vio_iommu_table; 46static struct iommu_table vio_iommu_table;
52 47#endif
53static struct vio_dev _vio_dev = { 48static struct vio_dev vio_bus_device = { /* fake "parent" device */
49 .name = vio_bus_device.dev.bus_id,
50 .type = "",
51#ifdef CONFIG_PPC_ISERIES
54 .iommu_table = &vio_iommu_table, 52 .iommu_table = &vio_iommu_table,
55 .dev.bus = &vio_bus_type 53#endif
54 .dev.bus_id = "vio",
55 .dev.bus = &vio_bus_type,
56}; 56};
57struct device *iSeries_vio_dev = &_vio_dev.dev; 57
58#ifdef CONFIG_PPC_ISERIES
59static struct vio_dev *__init vio_register_device_iseries(char *type,
60 uint32_t unit_num);
61
62struct device *iSeries_vio_dev = &vio_bus_device.dev;
58EXPORT_SYMBOL(iSeries_vio_dev); 63EXPORT_SYMBOL(iSeries_vio_dev);
59 64
60#define device_is_compatible(a, b) 1 65#define device_is_compatible(a, b) 1
@@ -260,18 +265,10 @@ static int __init vio_bus_init(void)
260 } 265 }
261 266
262 /* the fake parent of all vio devices, just to give us a nice directory */ 267 /* the fake parent of all vio devices, just to give us a nice directory */
263 vio_bus_device = kmalloc(sizeof(struct vio_dev), GFP_KERNEL); 268 err = device_register(&vio_bus_device.dev);
264 if (!vio_bus_device) {
265 return 1;
266 }
267 memset(vio_bus_device, 0, sizeof(struct vio_dev));
268 strcpy(vio_bus_device->dev.bus_id, "vio");
269
270 err = device_register(&vio_bus_device->dev);
271 if (err) { 269 if (err) {
272 printk(KERN_WARNING "%s: device_register returned %i\n", __FUNCTION__, 270 printk(KERN_WARNING "%s: device_register returned %i\n", __FUNCTION__,
273 err); 271 err);
274 kfree(vio_bus_device);
275 return err; 272 return err;
276 } 273 }
277 274
@@ -326,7 +323,7 @@ static struct vio_dev * __devinit vio_register_device_common(
326 viodev->unit_address = unit_address; 323 viodev->unit_address = unit_address;
327 viodev->iommu_table = iommu_table; 324 viodev->iommu_table = iommu_table;
328 /* init generic 'struct device' fields: */ 325 /* init generic 'struct device' fields: */
329 viodev->dev.parent = &vio_bus_device->dev; 326 viodev->dev.parent = &vio_bus_device.dev;
330 viodev->dev.bus = &vio_bus_type; 327 viodev->dev.bus = &vio_bus_type;
331 viodev->dev.release = vio_dev_release; 328 viodev->dev.release = vio_dev_release;
332 329
@@ -636,5 +633,3 @@ struct bus_type vio_bus_type = {
636 .name = "vio", 633 .name = "vio",
637 .match = vio_bus_match, 634 .match = vio_bus_match,
638}; 635};
639
640EXPORT_SYMBOL(vio_bus_type);
diff --git a/arch/ppc64/kernel/viopath.c b/arch/ppc64/kernel/viopath.c
index 2ed8ee075680..2a6c4f01c45e 100644
--- a/arch/ppc64/kernel/viopath.c
+++ b/arch/ppc64/kernel/viopath.c
@@ -43,12 +43,10 @@
43#include <asm/system.h> 43#include <asm/system.h>
44#include <asm/uaccess.h> 44#include <asm/uaccess.h>
45#include <asm/iSeries/HvTypes.h> 45#include <asm/iSeries/HvTypes.h>
46#include <asm/iSeries/LparData.h> 46#include <asm/iSeries/ItExtVpdPanel.h>
47#include <asm/iSeries/HvLpEvent.h> 47#include <asm/iSeries/HvLpEvent.h>
48#include <asm/iSeries/HvLpConfig.h> 48#include <asm/iSeries/HvLpConfig.h>
49#include <asm/iSeries/HvCallCfg.h>
50#include <asm/iSeries/mf.h> 49#include <asm/iSeries/mf.h>
51#include <asm/iSeries/iSeries_proc.h>
52#include <asm/iSeries/vio.h> 50#include <asm/iSeries/vio.h>
53 51
54/* Status of the path to each other partition in the system. 52/* Status of the path to each other partition in the system.
@@ -365,7 +363,7 @@ void vio_set_hostlp(void)
365 * while we're active 363 * while we're active
366 */ 364 */
367 viopath_ourLp = HvLpConfig_getLpIndex(); 365 viopath_ourLp = HvLpConfig_getLpIndex();
368 viopath_hostLp = HvCallCfg_getHostingLpIndex(viopath_ourLp); 366 viopath_hostLp = HvLpConfig_getHostingLpIndex(viopath_ourLp);
369 367
370 if (viopath_hostLp != HvLpIndexInvalid) 368 if (viopath_hostLp != HvLpIndexInvalid)
371 vio_setHandler(viomajorsubtype_config, handleConfig); 369 vio_setHandler(viomajorsubtype_config, handleConfig);
@@ -487,7 +485,7 @@ int viopath_open(HvLpIndex remoteLp, int subtype, int numReq)
487 unsigned long flags; 485 unsigned long flags;
488 int tempNumAllocated; 486 int tempNumAllocated;
489 487
490 if ((remoteLp >= HvMaxArchitectedLps) || (remoteLp == HvLpIndexInvalid)) 488 if ((remoteLp >= HVMAXARCHITECTEDLPS) || (remoteLp == HvLpIndexInvalid))
491 return -EINVAL; 489 return -EINVAL;
492 490
493 subtype = subtype >> VIOMAJOR_SUBTYPE_SHIFT; 491 subtype = subtype >> VIOMAJOR_SUBTYPE_SHIFT;
@@ -558,7 +556,7 @@ int viopath_close(HvLpIndex remoteLp, int subtype, int numReq)
558 int numOpen; 556 int numOpen;
559 struct alloc_parms parms; 557 struct alloc_parms parms;
560 558
561 if ((remoteLp >= HvMaxArchitectedLps) || (remoteLp == HvLpIndexInvalid)) 559 if ((remoteLp >= HVMAXARCHITECTEDLPS) || (remoteLp == HvLpIndexInvalid))
562 return -EINVAL; 560 return -EINVAL;
563 561
564 subtype = subtype >> VIOMAJOR_SUBTYPE_SHIFT; 562 subtype = subtype >> VIOMAJOR_SUBTYPE_SHIFT;
diff --git a/arch/ppc64/lib/Makefile b/arch/ppc64/lib/Makefile
index bf7b5bbfc04e..76fbfa9f706f 100644
--- a/arch/ppc64/lib/Makefile
+++ b/arch/ppc64/lib/Makefile
@@ -12,7 +12,7 @@ lib-$(CONFIG_SMP) += locks.o
12 12
13# e2a provides EBCDIC to ASCII conversions. 13# e2a provides EBCDIC to ASCII conversions.
14ifdef CONFIG_PPC_ISERIES 14ifdef CONFIG_PPC_ISERIES
15obj-$(CONFIG_PCI) += e2a.o 15obj-y += e2a.o
16endif 16endif
17 17
18lib-$(CONFIG_DEBUG_KERNEL) += sstep.o 18lib-$(CONFIG_DEBUG_KERNEL) += sstep.o
diff --git a/arch/ppc64/mm/hash_utils.c b/arch/ppc64/mm/hash_utils.c
index 0a0f97008d02..1647b1c6f28e 100644
--- a/arch/ppc64/mm/hash_utils.c
+++ b/arch/ppc64/mm/hash_utils.c
@@ -195,7 +195,7 @@ void __init htab_initialize(void)
195 memset((void *)table, 0, htab_size_bytes); 195 memset((void *)table, 0, htab_size_bytes);
196 } 196 }
197 197
198 mode_rw = _PAGE_ACCESSED | _PAGE_COHERENT | PP_RWXX; 198 mode_rw = _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_COHERENT | PP_RWXX;
199 199
200 /* On U3 based machines, we need to reserve the DART area and 200 /* On U3 based machines, we need to reserve the DART area and
201 * _NOT_ map it to avoid cache paradoxes as it's remapped non 201 * _NOT_ map it to avoid cache paradoxes as it's remapped non
@@ -310,10 +310,6 @@ int hash_page(unsigned long ea, unsigned long access, unsigned long trap)
310 310
311 vsid = get_vsid(mm->context.id, ea); 311 vsid = get_vsid(mm->context.id, ea);
312 break; 312 break;
313 case IO_REGION_ID:
314 mm = &ioremap_mm;
315 vsid = get_kernel_vsid(ea);
316 break;
317 case VMALLOC_REGION_ID: 313 case VMALLOC_REGION_ID:
318 mm = &init_mm; 314 mm = &init_mm;
319 vsid = get_kernel_vsid(ea); 315 vsid = get_kernel_vsid(ea);
diff --git a/arch/ppc64/mm/hugetlbpage.c b/arch/ppc64/mm/hugetlbpage.c
index d3bf86a5c1ad..fdcfe97c75c1 100644
--- a/arch/ppc64/mm/hugetlbpage.c
+++ b/arch/ppc64/mm/hugetlbpage.c
@@ -121,7 +121,7 @@ static pte_t *hugepte_alloc(struct mm_struct *mm, pud_t *dir, unsigned long addr
121 return hugepte_offset(dir, addr); 121 return hugepte_offset(dir, addr);
122} 122}
123 123
124static pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr) 124pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
125{ 125{
126 pud_t *pud; 126 pud_t *pud;
127 127
@@ -134,7 +134,7 @@ static pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
134 return hugepte_offset(pud, addr); 134 return hugepte_offset(pud, addr);
135} 135}
136 136
137static pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr) 137pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
138{ 138{
139 pud_t *pud; 139 pud_t *pud;
140 140
@@ -147,25 +147,6 @@ static pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
147 return hugepte_alloc(mm, pud, addr); 147 return hugepte_alloc(mm, pud, addr);
148} 148}
149 149
150static void set_huge_pte(struct mm_struct *mm, struct vm_area_struct *vma,
151 unsigned long addr, struct page *page,
152 pte_t *ptep, int write_access)
153{
154 pte_t entry;
155
156 add_mm_counter(mm, rss, HPAGE_SIZE / PAGE_SIZE);
157 if (write_access) {
158 entry =
159 pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
160 } else {
161 entry = pte_wrprotect(mk_pte(page, vma->vm_page_prot));
162 }
163 entry = pte_mkyoung(entry);
164 entry = pte_mkhuge(entry);
165
166 set_pte_at(mm, addr, ptep, entry);
167}
168
169/* 150/*
170 * This function checks for proper alignment of input addr and len parameters. 151 * This function checks for proper alignment of input addr and len parameters.
171 */ 152 */
@@ -259,80 +240,6 @@ int prepare_hugepage_range(unsigned long addr, unsigned long len)
259 return -EINVAL; 240 return -EINVAL;
260} 241}
261 242
262int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
263 struct vm_area_struct *vma)
264{
265 pte_t *src_pte, *dst_pte, entry;
266 struct page *ptepage;
267 unsigned long addr = vma->vm_start;
268 unsigned long end = vma->vm_end;
269 int err = -ENOMEM;
270
271 while (addr < end) {
272 dst_pte = huge_pte_alloc(dst, addr);
273 if (!dst_pte)
274 goto out;
275
276 src_pte = huge_pte_offset(src, addr);
277 entry = *src_pte;
278
279 ptepage = pte_page(entry);
280 get_page(ptepage);
281 add_mm_counter(dst, rss, HPAGE_SIZE / PAGE_SIZE);
282 set_pte_at(dst, addr, dst_pte, entry);
283
284 addr += HPAGE_SIZE;
285 }
286
287 err = 0;
288 out:
289 return err;
290}
291
292int
293follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
294 struct page **pages, struct vm_area_struct **vmas,
295 unsigned long *position, int *length, int i)
296{
297 unsigned long vpfn, vaddr = *position;
298 int remainder = *length;
299
300 WARN_ON(!is_vm_hugetlb_page(vma));
301
302 vpfn = vaddr/PAGE_SIZE;
303 while (vaddr < vma->vm_end && remainder) {
304 if (pages) {
305 pte_t *pte;
306 struct page *page;
307
308 pte = huge_pte_offset(mm, vaddr);
309
310 /* hugetlb should be locked, and hence, prefaulted */
311 WARN_ON(!pte || pte_none(*pte));
312
313 page = &pte_page(*pte)[vpfn % (HPAGE_SIZE/PAGE_SIZE)];
314
315 WARN_ON(!PageCompound(page));
316
317 get_page(page);
318 pages[i] = page;
319 }
320
321 if (vmas)
322 vmas[i] = vma;
323
324 vaddr += PAGE_SIZE;
325 ++vpfn;
326 --remainder;
327 ++i;
328 }
329
330 *length = remainder;
331 *position = vaddr;
332
333 return i;
334}
335
336struct page * 243struct page *
337follow_huge_addr(struct mm_struct *mm, unsigned long address, int write) 244follow_huge_addr(struct mm_struct *mm, unsigned long address, int write)
338{ 245{
@@ -363,89 +270,6 @@ follow_huge_pmd(struct mm_struct *mm, unsigned long address,
363 return NULL; 270 return NULL;
364} 271}
365 272
366void unmap_hugepage_range(struct vm_area_struct *vma,
367 unsigned long start, unsigned long end)
368{
369 struct mm_struct *mm = vma->vm_mm;
370 unsigned long addr;
371 pte_t *ptep;
372 struct page *page;
373
374 WARN_ON(!is_vm_hugetlb_page(vma));
375 BUG_ON((start % HPAGE_SIZE) != 0);
376 BUG_ON((end % HPAGE_SIZE) != 0);
377
378 for (addr = start; addr < end; addr += HPAGE_SIZE) {
379 pte_t pte;
380
381 ptep = huge_pte_offset(mm, addr);
382 if (!ptep || pte_none(*ptep))
383 continue;
384
385 pte = *ptep;
386 page = pte_page(pte);
387 pte_clear(mm, addr, ptep);
388
389 put_page(page);
390 }
391 add_mm_counter(mm, rss, -((end - start) >> PAGE_SHIFT));
392 flush_tlb_pending();
393}
394
395int hugetlb_prefault(struct address_space *mapping, struct vm_area_struct *vma)
396{
397 struct mm_struct *mm = current->mm;
398 unsigned long addr;
399 int ret = 0;
400
401 WARN_ON(!is_vm_hugetlb_page(vma));
402 BUG_ON((vma->vm_start % HPAGE_SIZE) != 0);
403 BUG_ON((vma->vm_end % HPAGE_SIZE) != 0);
404
405 spin_lock(&mm->page_table_lock);
406 for (addr = vma->vm_start; addr < vma->vm_end; addr += HPAGE_SIZE) {
407 unsigned long idx;
408 pte_t *pte = huge_pte_alloc(mm, addr);
409 struct page *page;
410
411 if (!pte) {
412 ret = -ENOMEM;
413 goto out;
414 }
415 if (! pte_none(*pte))
416 continue;
417
418 idx = ((addr - vma->vm_start) >> HPAGE_SHIFT)
419 + (vma->vm_pgoff >> (HPAGE_SHIFT - PAGE_SHIFT));
420 page = find_get_page(mapping, idx);
421 if (!page) {
422 /* charge the fs quota first */
423 if (hugetlb_get_quota(mapping)) {
424 ret = -ENOMEM;
425 goto out;
426 }
427 page = alloc_huge_page();
428 if (!page) {
429 hugetlb_put_quota(mapping);
430 ret = -ENOMEM;
431 goto out;
432 }
433 ret = add_to_page_cache(page, mapping, idx, GFP_ATOMIC);
434 if (! ret) {
435 unlock_page(page);
436 } else {
437 hugetlb_put_quota(mapping);
438 free_huge_page(page);
439 goto out;
440 }
441 }
442 set_huge_pte(mm, vma, addr, page, pte, vma->vm_flags & VM_WRITE);
443 }
444out:
445 spin_unlock(&mm->page_table_lock);
446 return ret;
447}
448
449/* Because we have an exclusive hugepage region which lies within the 273/* Because we have an exclusive hugepage region which lies within the
450 * normal user address space, we have to take special measures to make 274 * normal user address space, we have to take special measures to make
451 * non-huge mmap()s evade the hugepage reserved regions. */ 275 * non-huge mmap()s evade the hugepage reserved regions. */
@@ -468,7 +292,12 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
468 && !is_hugepage_only_range(mm, addr,len)) 292 && !is_hugepage_only_range(mm, addr,len))
469 return addr; 293 return addr;
470 } 294 }
471 start_addr = addr = mm->free_area_cache; 295 if (len > mm->cached_hole_size) {
296 start_addr = addr = mm->free_area_cache;
297 } else {
298 start_addr = addr = TASK_UNMAPPED_BASE;
299 mm->cached_hole_size = 0;
300 }
472 301
473full_search: 302full_search:
474 vma = find_vma(mm, addr); 303 vma = find_vma(mm, addr);
@@ -492,6 +321,8 @@ full_search:
492 mm->free_area_cache = addr + len; 321 mm->free_area_cache = addr + len;
493 return addr; 322 return addr;
494 } 323 }
324 if (addr + mm->cached_hole_size < vma->vm_start)
325 mm->cached_hole_size = vma->vm_start - addr;
495 addr = vma->vm_end; 326 addr = vma->vm_end;
496 vma = vma->vm_next; 327 vma = vma->vm_next;
497 } 328 }
@@ -499,6 +330,7 @@ full_search:
499 /* Make sure we didn't miss any holes */ 330 /* Make sure we didn't miss any holes */
500 if (start_addr != TASK_UNMAPPED_BASE) { 331 if (start_addr != TASK_UNMAPPED_BASE) {
501 start_addr = addr = TASK_UNMAPPED_BASE; 332 start_addr = addr = TASK_UNMAPPED_BASE;
333 mm->cached_hole_size = 0;
502 goto full_search; 334 goto full_search;
503 } 335 }
504 return -ENOMEM; 336 return -ENOMEM;
@@ -520,6 +352,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
520 struct vm_area_struct *vma, *prev_vma; 352 struct vm_area_struct *vma, *prev_vma;
521 struct mm_struct *mm = current->mm; 353 struct mm_struct *mm = current->mm;
522 unsigned long base = mm->mmap_base, addr = addr0; 354 unsigned long base = mm->mmap_base, addr = addr0;
355 unsigned long largest_hole = mm->cached_hole_size;
523 int first_time = 1; 356 int first_time = 1;
524 357
525 /* requested length too big for entire address space */ 358 /* requested length too big for entire address space */
@@ -540,6 +373,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
540 return addr; 373 return addr;
541 } 374 }
542 375
376 if (len <= largest_hole) {
377 largest_hole = 0;
378 mm->free_area_cache = base;
379 }
543try_again: 380try_again:
544 /* make sure it can fit in the remaining address space */ 381 /* make sure it can fit in the remaining address space */
545 if (mm->free_area_cache < len) 382 if (mm->free_area_cache < len)
@@ -568,13 +405,21 @@ hugepage_recheck:
568 * vma->vm_start, use it: 405 * vma->vm_start, use it:
569 */ 406 */
570 if (addr+len <= vma->vm_start && 407 if (addr+len <= vma->vm_start &&
571 (!prev_vma || (addr >= prev_vma->vm_end))) 408 (!prev_vma || (addr >= prev_vma->vm_end))) {
572 /* remember the address as a hint for next time */ 409 /* remember the address as a hint for next time */
573 return (mm->free_area_cache = addr); 410 mm->cached_hole_size = largest_hole;
574 else 411 return (mm->free_area_cache = addr);
412 } else {
575 /* pull free_area_cache down to the first hole */ 413 /* pull free_area_cache down to the first hole */
576 if (mm->free_area_cache == vma->vm_end) 414 if (mm->free_area_cache == vma->vm_end) {
577 mm->free_area_cache = vma->vm_start; 415 mm->free_area_cache = vma->vm_start;
416 mm->cached_hole_size = largest_hole;
417 }
418 }
419
420 /* remember the largest hole we saw so far */
421 if (addr + largest_hole < vma->vm_start)
422 largest_hole = vma->vm_start - addr;
578 423
579 /* try just below the current vma->vm_start */ 424 /* try just below the current vma->vm_start */
580 addr = vma->vm_start-len; 425 addr = vma->vm_start-len;
@@ -587,6 +432,7 @@ fail:
587 */ 432 */
588 if (first_time) { 433 if (first_time) {
589 mm->free_area_cache = base; 434 mm->free_area_cache = base;
435 largest_hole = 0;
590 first_time = 0; 436 first_time = 0;
591 goto try_again; 437 goto try_again;
592 } 438 }
@@ -597,11 +443,13 @@ fail:
597 * allocations. 443 * allocations.
598 */ 444 */
599 mm->free_area_cache = TASK_UNMAPPED_BASE; 445 mm->free_area_cache = TASK_UNMAPPED_BASE;
446 mm->cached_hole_size = ~0UL;
600 addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags); 447 addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
601 /* 448 /*
602 * Restore the topdown base: 449 * Restore the topdown base:
603 */ 450 */
604 mm->free_area_cache = base; 451 mm->free_area_cache = base;
452 mm->cached_hole_size = ~0UL;
605 453
606 return addr; 454 return addr;
607} 455}
diff --git a/arch/ppc64/mm/imalloc.c b/arch/ppc64/mm/imalloc.c
index cb8727f3267a..b6e75b891ac0 100644
--- a/arch/ppc64/mm/imalloc.c
+++ b/arch/ppc64/mm/imalloc.c
@@ -15,6 +15,7 @@
15#include <asm/pgtable.h> 15#include <asm/pgtable.h>
16#include <asm/semaphore.h> 16#include <asm/semaphore.h>
17#include <asm/imalloc.h> 17#include <asm/imalloc.h>
18#include <asm/cacheflush.h>
18 19
19static DECLARE_MUTEX(imlist_sem); 20static DECLARE_MUTEX(imlist_sem);
20struct vm_struct * imlist = NULL; 21struct vm_struct * imlist = NULL;
@@ -285,29 +286,32 @@ struct vm_struct * im_get_area(unsigned long v_addr, unsigned long size,
285 return area; 286 return area;
286} 287}
287 288
288unsigned long im_free(void * addr) 289void im_free(void * addr)
289{ 290{
290 struct vm_struct **p, *tmp; 291 struct vm_struct **p, *tmp;
291 unsigned long ret_size = 0;
292 292
293 if (!addr) 293 if (!addr)
294 return ret_size; 294 return;
295 if ((PAGE_SIZE-1) & (unsigned long) addr) { 295 if ((unsigned long) addr & ~PAGE_MASK) {
296 printk(KERN_ERR "Trying to %s bad address (%p)\n", __FUNCTION__, addr); 296 printk(KERN_ERR "Trying to %s bad address (%p)\n", __FUNCTION__, addr);
297 return ret_size; 297 return;
298 } 298 }
299 down(&imlist_sem); 299 down(&imlist_sem);
300 for (p = &imlist ; (tmp = *p) ; p = &tmp->next) { 300 for (p = &imlist ; (tmp = *p) ; p = &tmp->next) {
301 if (tmp->addr == addr) { 301 if (tmp->addr == addr) {
302 ret_size = tmp->size;
303 *p = tmp->next; 302 *p = tmp->next;
303
304 /* XXX: do we need the lock? */
305 spin_lock(&init_mm.page_table_lock);
306 unmap_vm_area(tmp);
307 spin_unlock(&init_mm.page_table_lock);
308
304 kfree(tmp); 309 kfree(tmp);
305 up(&imlist_sem); 310 up(&imlist_sem);
306 return ret_size; 311 return;
307 } 312 }
308 } 313 }
309 up(&imlist_sem); 314 up(&imlist_sem);
310 printk(KERN_ERR "Trying to %s nonexistent area (%p)\n", __FUNCTION__, 315 printk(KERN_ERR "Trying to %s nonexistent area (%p)\n", __FUNCTION__,
311 addr); 316 addr);
312 return ret_size;
313} 317}
diff --git a/arch/ppc64/mm/init.c b/arch/ppc64/mm/init.c
index 4b42aff74d73..6fa1e6490b57 100644
--- a/arch/ppc64/mm/init.c
+++ b/arch/ppc64/mm/init.c
@@ -73,9 +73,6 @@ static unsigned long phbs_io_bot = PHBS_IO_BASE;
73extern pgd_t swapper_pg_dir[]; 73extern pgd_t swapper_pg_dir[];
74extern struct task_struct *current_set[NR_CPUS]; 74extern struct task_struct *current_set[NR_CPUS];
75 75
76extern pgd_t ioremap_dir[];
77pgd_t * ioremap_pgd = (pgd_t *)&ioremap_dir;
78
79unsigned long klimit = (unsigned long)_end; 76unsigned long klimit = (unsigned long)_end;
80 77
81unsigned long _SDR1=0; 78unsigned long _SDR1=0;
@@ -137,69 +134,6 @@ void iounmap(volatile void __iomem *addr)
137 134
138#else 135#else
139 136
140static void unmap_im_area_pte(pmd_t *pmd, unsigned long addr,
141 unsigned long end)
142{
143 pte_t *pte;
144
145 pte = pte_offset_kernel(pmd, addr);
146 do {
147 pte_t ptent = ptep_get_and_clear(&ioremap_mm, addr, pte);
148 WARN_ON(!pte_none(ptent) && !pte_present(ptent));
149 } while (pte++, addr += PAGE_SIZE, addr != end);
150}
151
152static inline void unmap_im_area_pmd(pud_t *pud, unsigned long addr,
153 unsigned long end)
154{
155 pmd_t *pmd;
156 unsigned long next;
157
158 pmd = pmd_offset(pud, addr);
159 do {
160 next = pmd_addr_end(addr, end);
161 if (pmd_none_or_clear_bad(pmd))
162 continue;
163 unmap_im_area_pte(pmd, addr, next);
164 } while (pmd++, addr = next, addr != end);
165}
166
167static inline void unmap_im_area_pud(pgd_t *pgd, unsigned long addr,
168 unsigned long end)
169{
170 pud_t *pud;
171 unsigned long next;
172
173 pud = pud_offset(pgd, addr);
174 do {
175 next = pud_addr_end(addr, end);
176 if (pud_none_or_clear_bad(pud))
177 continue;
178 unmap_im_area_pmd(pud, addr, next);
179 } while (pud++, addr = next, addr != end);
180}
181
182static void unmap_im_area(unsigned long addr, unsigned long end)
183{
184 struct mm_struct *mm = &ioremap_mm;
185 unsigned long next;
186 pgd_t *pgd;
187
188 spin_lock(&mm->page_table_lock);
189
190 pgd = pgd_offset_i(addr);
191 flush_cache_vunmap(addr, end);
192 do {
193 next = pgd_addr_end(addr, end);
194 if (pgd_none_or_clear_bad(pgd))
195 continue;
196 unmap_im_area_pud(pgd, addr, next);
197 } while (pgd++, addr = next, addr != end);
198 flush_tlb_kernel_range(start, end);
199
200 spin_unlock(&mm->page_table_lock);
201}
202
203/* 137/*
204 * map_io_page currently only called by __ioremap 138 * map_io_page currently only called by __ioremap
205 * map_io_page adds an entry to the ioremap page table 139 * map_io_page adds an entry to the ioremap page table
@@ -214,21 +148,21 @@ static int map_io_page(unsigned long ea, unsigned long pa, int flags)
214 unsigned long vsid; 148 unsigned long vsid;
215 149
216 if (mem_init_done) { 150 if (mem_init_done) {
217 spin_lock(&ioremap_mm.page_table_lock); 151 spin_lock(&init_mm.page_table_lock);
218 pgdp = pgd_offset_i(ea); 152 pgdp = pgd_offset_k(ea);
219 pudp = pud_alloc(&ioremap_mm, pgdp, ea); 153 pudp = pud_alloc(&init_mm, pgdp, ea);
220 if (!pudp) 154 if (!pudp)
221 return -ENOMEM; 155 return -ENOMEM;
222 pmdp = pmd_alloc(&ioremap_mm, pudp, ea); 156 pmdp = pmd_alloc(&init_mm, pudp, ea);
223 if (!pmdp) 157 if (!pmdp)
224 return -ENOMEM; 158 return -ENOMEM;
225 ptep = pte_alloc_kernel(&ioremap_mm, pmdp, ea); 159 ptep = pte_alloc_kernel(&init_mm, pmdp, ea);
226 if (!ptep) 160 if (!ptep)
227 return -ENOMEM; 161 return -ENOMEM;
228 pa = abs_to_phys(pa); 162 pa = abs_to_phys(pa);
229 set_pte_at(&ioremap_mm, ea, ptep, pfn_pte(pa >> PAGE_SHIFT, 163 set_pte_at(&init_mm, ea, ptep, pfn_pte(pa >> PAGE_SHIFT,
230 __pgprot(flags))); 164 __pgprot(flags)));
231 spin_unlock(&ioremap_mm.page_table_lock); 165 spin_unlock(&init_mm.page_table_lock);
232 } else { 166 } else {
233 unsigned long va, vpn, hash, hpteg; 167 unsigned long va, vpn, hash, hpteg;
234 168
@@ -267,13 +201,9 @@ static void __iomem * __ioremap_com(unsigned long addr, unsigned long pa,
267 201
268 for (i = 0; i < size; i += PAGE_SIZE) 202 for (i = 0; i < size; i += PAGE_SIZE)
269 if (map_io_page(ea+i, pa+i, flags)) 203 if (map_io_page(ea+i, pa+i, flags))
270 goto failure; 204 return NULL;
271 205
272 return (void __iomem *) (ea + (addr & ~PAGE_MASK)); 206 return (void __iomem *) (ea + (addr & ~PAGE_MASK));
273 failure:
274 if (mem_init_done)
275 unmap_im_area(ea, ea + size);
276 return NULL;
277} 207}
278 208
279 209
@@ -381,19 +311,14 @@ int __ioremap_explicit(unsigned long pa, unsigned long ea,
381 */ 311 */
382void iounmap(volatile void __iomem *token) 312void iounmap(volatile void __iomem *token)
383{ 313{
384 unsigned long address, size;
385 void *addr; 314 void *addr;
386 315
387 if (!mem_init_done) 316 if (!mem_init_done)
388 return; 317 return;
389 318
390 addr = (void *) ((unsigned long __force) token & PAGE_MASK); 319 addr = (void *) ((unsigned long __force) token & PAGE_MASK);
391
392 if ((size = im_free(addr)) == 0)
393 return;
394 320
395 address = (unsigned long)addr; 321 im_free(addr);
396 unmap_im_area(address, address + size);
397} 322}
398 323
399static int iounmap_subset_regions(unsigned long addr, unsigned long size) 324static int iounmap_subset_regions(unsigned long addr, unsigned long size)
diff --git a/arch/ppc64/xmon/xmon.c b/arch/ppc64/xmon/xmon.c
index 3c0ccb2623ae..7f6e13a4b71e 100644
--- a/arch/ppc64/xmon/xmon.c
+++ b/arch/ppc64/xmon/xmon.c
@@ -2247,7 +2247,14 @@ scanhex(unsigned long *vp)
2247 tmpstr[i] = c; 2247 tmpstr[i] = c;
2248 } 2248 }
2249 tmpstr[i++] = 0; 2249 tmpstr[i++] = 0;
2250 *vp = kallsyms_lookup_name(tmpstr); 2250 *vp = 0;
2251 if (setjmp(bus_error_jmp) == 0) {
2252 catch_memory_errors = 1;
2253 sync();
2254 *vp = kallsyms_lookup_name(tmpstr);
2255 sync();
2256 }
2257 catch_memory_errors = 0;
2251 if (!(*vp)) { 2258 if (!(*vp)) {
2252 printf("unknown symbol '%s'\n", tmpstr); 2259 printf("unknown symbol '%s'\n", tmpstr);
2253 return 0; 2260 return 0;
diff --git a/arch/s390/kernel/compat_ioctl.c b/arch/s390/kernel/compat_ioctl.c
index 03d03c6d3cbb..24a1e9f069a7 100644
--- a/arch/s390/kernel/compat_ioctl.c
+++ b/arch/s390/kernel/compat_ioctl.c
@@ -42,7 +42,6 @@ struct ioctl_trans ioctl_start[] = {
42#include "../../../fs/compat_ioctl.c" 42#include "../../../fs/compat_ioctl.c"
43 43
44/* s390 only ioctls */ 44/* s390 only ioctls */
45#if defined(CONFIG_DASD) || defined(CONFIG_DASD_MODULE)
46COMPATIBLE_IOCTL(DASDAPIVER) 45COMPATIBLE_IOCTL(DASDAPIVER)
47COMPATIBLE_IOCTL(BIODASDDISABLE) 46COMPATIBLE_IOCTL(BIODASDDISABLE)
48COMPATIBLE_IOCTL(BIODASDENABLE) 47COMPATIBLE_IOCTL(BIODASDENABLE)
@@ -59,16 +58,11 @@ COMPATIBLE_IOCTL(BIODASDPRRD)
59COMPATIBLE_IOCTL(BIODASDPSRD) 58COMPATIBLE_IOCTL(BIODASDPSRD)
60COMPATIBLE_IOCTL(BIODASDGATTR) 59COMPATIBLE_IOCTL(BIODASDGATTR)
61COMPATIBLE_IOCTL(BIODASDSATTR) 60COMPATIBLE_IOCTL(BIODASDSATTR)
62#if defined(CONFIG_DASD_CMB) || defined(CONFIG_DASD_CMB_MODULE)
63COMPATIBLE_IOCTL(BIODASDCMFENABLE) 61COMPATIBLE_IOCTL(BIODASDCMFENABLE)
64COMPATIBLE_IOCTL(BIODASDCMFDISABLE) 62COMPATIBLE_IOCTL(BIODASDCMFDISABLE)
65COMPATIBLE_IOCTL(BIODASDREADALLCMB) 63COMPATIBLE_IOCTL(BIODASDREADALLCMB)
66#endif
67#endif
68 64
69#if defined(CONFIG_S390_TAPE) || defined(CONFIG_S390_TAPE_MODULE)
70COMPATIBLE_IOCTL(TAPE390_DISPLAY) 65COMPATIBLE_IOCTL(TAPE390_DISPLAY)
71#endif
72 66
73/* s390 doesn't need handlers here */ 67/* s390 doesn't need handlers here */
74COMPATIBLE_IOCTL(TIOCGSERIAL) 68COMPATIBLE_IOCTL(TIOCGSERIAL)
diff --git a/arch/s390/kernel/head.S b/arch/s390/kernel/head.S
index b804c55bd919..fc8bf5e285f6 100644
--- a/arch/s390/kernel/head.S
+++ b/arch/s390/kernel/head.S
@@ -345,10 +345,25 @@ iplstart:
345 bno .Lnoreset 345 bno .Lnoreset
346 la %r2,.Lreset 346 la %r2,.Lreset
347 lhi %r3,26 347 lhi %r3,26
348 .long 0x83230008 348 diag %r2,%r3,8
349 mvc 0x78(8),.Lrdrnewpsw # set up IO interrupt psw
350.Lwaitrdrirq:
351 lpsw .Lrdrwaitpsw
352.Lrdrint:
353 c %r1,0xb8 # compare subchannel number
354 bne .Lwaitrdrirq
355 la %r5,.Lirb
356 tsch 0(%r5)
349.Lnoreset: 357.Lnoreset:
358 b .Lnoload
359
360 .align 8
361.Lrdrnewpsw:
362 .long 0x00080000,0x80000000+.Lrdrint
363.Lrdrwaitpsw:
364 .long 0x020a0000,0x80000000+.Lrdrint
350#endif 365#endif
351 366
352# 367#
353# everything loaded, go for it 368# everything loaded, go for it
354# 369#
@@ -517,10 +532,10 @@ startup:basr %r13,0 # get base
517 l %r2, .Lrcp2-.LPG1(%r13) # try with Read SCP 532 l %r2, .Lrcp2-.LPG1(%r13) # try with Read SCP
518 b .Lservicecall-.LPG1(%r13) 533 b .Lservicecall-.LPG1(%r13)
519.Lprocsccb: 534.Lprocsccb:
520 lh %r1,.Lscpincr1-PARMAREA(%r4) # use this one if != 0 535 lhi %r1,0
521 chi %r1,0x00 536 icm %r1,3,.Lscpincr1-PARMAREA(%r4) # use this one if != 0
522 jne .Lscnd 537 jnz .Lscnd
523 l %r1,.Lscpincr2-PARMAREA(%r4) # otherwise use this one 538 l %r1,.Lscpincr2-PARMAREA+4(%r4) # otherwise use this one
524.Lscnd: 539.Lscnd:
525 xr %r3,%r3 # same logic 540 xr %r3,%r3 # same logic
526 ic %r3,.Lscpa1-PARMAREA(%r4) 541 ic %r3,.Lscpa1-PARMAREA(%r4)
diff --git a/arch/s390/kernel/head64.S b/arch/s390/kernel/head64.S
index 8366793bc371..f525c0c21250 100644
--- a/arch/s390/kernel/head64.S
+++ b/arch/s390/kernel/head64.S
@@ -344,10 +344,25 @@ iplstart:
344 bno .Lnoreset 344 bno .Lnoreset
345 la %r2,.Lreset 345 la %r2,.Lreset
346 lhi %r3,26 346 lhi %r3,26
347 .long 0x83230008 347 diag %r2,%r3,8
348 mvc 0x78(8),.Lrdrnewpsw # set up IO interrupt psw
349.Lwaitrdrirq:
350 lpsw .Lrdrwaitpsw
351.Lrdrint:
352 c %r1,0xb8 # compare subchannel number
353 bne .Lwaitrdrirq
354 la %r5,.Lirb
355 tsch 0(%r5)
348.Lnoreset: 356.Lnoreset:
357 b .Lnoload
358
359 .align 8
360.Lrdrnewpsw:
361 .long 0x00080000,0x80000000+.Lrdrint
362.Lrdrwaitpsw:
363 .long 0x020a0000,0x80000000+.Lrdrint
349#endif 364#endif
350 365
351# 366#
352# everything loaded, go for it 367# everything loaded, go for it
353# 368#
@@ -518,9 +533,9 @@ startup:basr %r13,0 # get base
518 l %r2,.Lrcp2-.LPG1(%r13) # try with Read SCP 533 l %r2,.Lrcp2-.LPG1(%r13) # try with Read SCP
519 b .Lservicecall-.LPG1(%r13) 534 b .Lservicecall-.LPG1(%r13)
520.Lprocsccb: 535.Lprocsccb:
521 lh %r1,.Lscpincr1-PARMAREA(%r4) # use this one if != 0 536 lghi %r1,0
522 chi %r1,0x00 537 icm %r1,3,.Lscpincr1-PARMAREA(%r4) # use this one if != 0
523 jne .Lscnd 538 jnz .Lscnd
524 lg %r1,.Lscpincr2-PARMAREA(%r4) # otherwise use this one 539 lg %r1,.Lscpincr2-PARMAREA(%r4) # otherwise use this one
525.Lscnd: 540.Lscnd:
526 xr %r3,%r3 # same logic 541 xr %r3,%r3 # same logic
diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c
index 8b90e9528b91..ca34b6f34b38 100644
--- a/arch/s390/kernel/traps.c
+++ b/arch/s390/kernel/traps.c
@@ -668,7 +668,10 @@ asmlinkage void space_switch_exception(struct pt_regs * regs, long int_code)
668 668
669asmlinkage void kernel_stack_overflow(struct pt_regs * regs) 669asmlinkage void kernel_stack_overflow(struct pt_regs * regs)
670{ 670{
671 die("Kernel stack overflow", regs, 0); 671 bust_spinlocks(1);
672 printk("Kernel stack overflow.\n");
673 show_regs(regs);
674 bust_spinlocks(0);
672 panic("Corrupt kernel stack, can't continue."); 675 panic("Corrupt kernel stack, can't continue.");
673} 676}
674 677
diff --git a/arch/s390/mm/cmm.c b/arch/s390/mm/cmm.c
index f5a5bc09b8fa..2d5cb1385753 100644
--- a/arch/s390/mm/cmm.c
+++ b/arch/s390/mm/cmm.c
@@ -21,7 +21,7 @@
21#include <asm/uaccess.h> 21#include <asm/uaccess.h>
22 22
23static char *sender = "VMRMSVM"; 23static char *sender = "VMRMSVM";
24module_param(sender, charp, 0); 24module_param(sender, charp, 0400);
25MODULE_PARM_DESC(sender, 25MODULE_PARM_DESC(sender,
26 "Guest name that may send SMSG messages (default VMRMSVM)"); 26 "Guest name that may send SMSG messages (default VMRMSVM)");
27 27
diff --git a/arch/sh/kernel/sys_sh.c b/arch/sh/kernel/sys_sh.c
index df5ac294c379..917b2f32f260 100644
--- a/arch/sh/kernel/sys_sh.c
+++ b/arch/sh/kernel/sys_sh.c
@@ -79,6 +79,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
79 (!vma || addr + len <= vma->vm_start)) 79 (!vma || addr + len <= vma->vm_start))
80 return addr; 80 return addr;
81 } 81 }
82 if (len <= mm->cached_hole_size) {
83 mm->cached_hole_size = 0;
84 mm->free_area_cache = TASK_UNMAPPED_BASE;
85 }
82 if (flags & MAP_PRIVATE) 86 if (flags & MAP_PRIVATE)
83 addr = PAGE_ALIGN(mm->free_area_cache); 87 addr = PAGE_ALIGN(mm->free_area_cache);
84 else 88 else
@@ -95,6 +99,7 @@ full_search:
95 */ 99 */
96 if (start_addr != TASK_UNMAPPED_BASE) { 100 if (start_addr != TASK_UNMAPPED_BASE) {
97 start_addr = addr = TASK_UNMAPPED_BASE; 101 start_addr = addr = TASK_UNMAPPED_BASE;
102 mm->cached_hole_size = 0;
98 goto full_search; 103 goto full_search;
99 } 104 }
100 return -ENOMEM; 105 return -ENOMEM;
@@ -106,6 +111,9 @@ full_search:
106 mm->free_area_cache = addr + len; 111 mm->free_area_cache = addr + len;
107 return addr; 112 return addr;
108 } 113 }
114 if (addr + mm->cached_hole_size < vma->vm_start)
115 mm->cached_hole_size = vma->vm_start - addr;
116
109 addr = vma->vm_end; 117 addr = vma->vm_end;
110 if (!(flags & MAP_PRIVATE)) 118 if (!(flags & MAP_PRIVATE))
111 addr = COLOUR_ALIGN(addr); 119 addr = COLOUR_ALIGN(addr);
diff --git a/arch/sh/lib/delay.c b/arch/sh/lib/delay.c
index 50b36037d86b..351714694d6d 100644
--- a/arch/sh/lib/delay.c
+++ b/arch/sh/lib/delay.c
@@ -24,7 +24,7 @@ inline void __const_udelay(unsigned long xloops)
24 __asm__("dmulu.l %0, %2\n\t" 24 __asm__("dmulu.l %0, %2\n\t"
25 "sts mach, %0" 25 "sts mach, %0"
26 : "=r" (xloops) 26 : "=r" (xloops)
27 : "0" (xloops), "r" (cpu_data[_smp_processor_id()].loops_per_jiffy) 27 : "0" (xloops), "r" (cpu_data[raw_smp_processor_id()].loops_per_jiffy)
28 : "macl", "mach"); 28 : "macl", "mach");
29 __delay(xloops * HZ); 29 __delay(xloops * HZ);
30} 30}
diff --git a/arch/sh/mm/hugetlbpage.c b/arch/sh/mm/hugetlbpage.c
index 1f897bab2318..95bb1a6c6060 100644
--- a/arch/sh/mm/hugetlbpage.c
+++ b/arch/sh/mm/hugetlbpage.c
@@ -24,7 +24,7 @@
24#include <asm/tlbflush.h> 24#include <asm/tlbflush.h>
25#include <asm/cacheflush.h> 25#include <asm/cacheflush.h>
26 26
27static pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr) 27pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
28{ 28{
29 pgd_t *pgd; 29 pgd_t *pgd;
30 pmd_t *pmd; 30 pmd_t *pmd;
@@ -39,7 +39,7 @@ static pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
39 return pte; 39 return pte;
40} 40}
41 41
42static pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr) 42pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
43{ 43{
44 pgd_t *pgd; 44 pgd_t *pgd;
45 pmd_t *pmd; 45 pmd_t *pmd;
@@ -56,28 +56,34 @@ static pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
56 56
57#define mk_pte_huge(entry) do { pte_val(entry) |= _PAGE_SZHUGE; } while (0) 57#define mk_pte_huge(entry) do { pte_val(entry) |= _PAGE_SZHUGE; } while (0)
58 58
59static void set_huge_pte(struct mm_struct *mm, struct vm_area_struct *vma, 59void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
60 struct page *page, pte_t * page_table, int write_access) 60 pte_t *ptep, pte_t entry)
61{ 61{
62 unsigned long i; 62 int i;
63 pte_t entry;
64 63
65 add_mm_counter(mm, rss, HPAGE_SIZE / PAGE_SIZE); 64 for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
65 set_pte_at(mm, addr, ptep, entry);
66 ptep++;
67 addr += PAGE_SIZE;
68 pte_val(entry) += PAGE_SIZE;
69 }
70}
66 71
67 if (write_access) 72pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
68 entry = pte_mkwrite(pte_mkdirty(mk_pte(page, 73 pte_t *ptep)
69 vma->vm_page_prot))); 74{
70 else 75 pte_t entry;
71 entry = pte_wrprotect(mk_pte(page, vma->vm_page_prot)); 76 int i;
72 entry = pte_mkyoung(entry);
73 mk_pte_huge(entry);
74 77
75 for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) { 78 entry = *ptep;
76 set_pte(page_table, entry);
77 page_table++;
78 79
79 pte_val(entry) += PAGE_SIZE; 80 for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
81 pte_clear(mm, addr, ptep);
82 addr += PAGE_SIZE;
83 ptep++;
80 } 84 }
85
86 return entry;
81} 87}
82 88
83/* 89/*
@@ -92,79 +98,6 @@ int is_aligned_hugepage_range(unsigned long addr, unsigned long len)
92 return 0; 98 return 0;
93} 99}
94 100
95int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
96 struct vm_area_struct *vma)
97{
98 pte_t *src_pte, *dst_pte, entry;
99 struct page *ptepage;
100 unsigned long addr = vma->vm_start;
101 unsigned long end = vma->vm_end;
102 int i;
103
104 while (addr < end) {
105 dst_pte = huge_pte_alloc(dst, addr);
106 if (!dst_pte)
107 goto nomem;
108 src_pte = huge_pte_offset(src, addr);
109 BUG_ON(!src_pte || pte_none(*src_pte));
110 entry = *src_pte;
111 ptepage = pte_page(entry);
112 get_page(ptepage);
113 for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
114 set_pte(dst_pte, entry);
115 pte_val(entry) += PAGE_SIZE;
116 dst_pte++;
117 }
118 add_mm_counter(dst, rss, HPAGE_SIZE / PAGE_SIZE);
119 addr += HPAGE_SIZE;
120 }
121 return 0;
122
123nomem:
124 return -ENOMEM;
125}
126
127int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
128 struct page **pages, struct vm_area_struct **vmas,
129 unsigned long *position, int *length, int i)
130{
131 unsigned long vaddr = *position;
132 int remainder = *length;
133
134 WARN_ON(!is_vm_hugetlb_page(vma));
135
136 while (vaddr < vma->vm_end && remainder) {
137 if (pages) {
138 pte_t *pte;
139 struct page *page;
140
141 pte = huge_pte_offset(mm, vaddr);
142
143 /* hugetlb should be locked, and hence, prefaulted */
144 BUG_ON(!pte || pte_none(*pte));
145
146 page = pte_page(*pte);
147
148 WARN_ON(!PageCompound(page));
149
150 get_page(page);
151 pages[i] = page;
152 }
153
154 if (vmas)
155 vmas[i] = vma;
156
157 vaddr += PAGE_SIZE;
158 --remainder;
159 ++i;
160 }
161
162 *length = remainder;
163 *position = vaddr;
164
165 return i;
166}
167
168struct page *follow_huge_addr(struct mm_struct *mm, 101struct page *follow_huge_addr(struct mm_struct *mm,
169 unsigned long address, int write) 102 unsigned long address, int write)
170{ 103{
@@ -181,84 +114,3 @@ struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address,
181{ 114{
182 return NULL; 115 return NULL;
183} 116}
184
185void unmap_hugepage_range(struct vm_area_struct *vma,
186 unsigned long start, unsigned long end)
187{
188 struct mm_struct *mm = vma->vm_mm;
189 unsigned long address;
190 pte_t *pte;
191 struct page *page;
192 int i;
193
194 BUG_ON(start & (HPAGE_SIZE - 1));
195 BUG_ON(end & (HPAGE_SIZE - 1));
196
197 for (address = start; address < end; address += HPAGE_SIZE) {
198 pte = huge_pte_offset(mm, address);
199 BUG_ON(!pte);
200 if (pte_none(*pte))
201 continue;
202 page = pte_page(*pte);
203 put_page(page);
204 for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
205 pte_clear(mm, address+(i*PAGE_SIZE), pte);
206 pte++;
207 }
208 }
209 add_mm_counter(mm, rss, -((end - start) >> PAGE_SHIFT));
210 flush_tlb_range(vma, start, end);
211}
212
213int hugetlb_prefault(struct address_space *mapping, struct vm_area_struct *vma)
214{
215 struct mm_struct *mm = current->mm;
216 unsigned long addr;
217 int ret = 0;
218
219 BUG_ON(vma->vm_start & ~HPAGE_MASK);
220 BUG_ON(vma->vm_end & ~HPAGE_MASK);
221
222 spin_lock(&mm->page_table_lock);
223 for (addr = vma->vm_start; addr < vma->vm_end; addr += HPAGE_SIZE) {
224 unsigned long idx;
225 pte_t *pte = huge_pte_alloc(mm, addr);
226 struct page *page;
227
228 if (!pte) {
229 ret = -ENOMEM;
230 goto out;
231 }
232 if (!pte_none(*pte))
233 continue;
234
235 idx = ((addr - vma->vm_start) >> HPAGE_SHIFT)
236 + (vma->vm_pgoff >> (HPAGE_SHIFT - PAGE_SHIFT));
237 page = find_get_page(mapping, idx);
238 if (!page) {
239 /* charge the fs quota first */
240 if (hugetlb_get_quota(mapping)) {
241 ret = -ENOMEM;
242 goto out;
243 }
244 page = alloc_huge_page();
245 if (!page) {
246 hugetlb_put_quota(mapping);
247 ret = -ENOMEM;
248 goto out;
249 }
250 ret = add_to_page_cache(page, mapping, idx, GFP_ATOMIC);
251 if (! ret) {
252 unlock_page(page);
253 } else {
254 hugetlb_put_quota(mapping);
255 free_huge_page(page);
256 goto out;
257 }
258 }
259 set_huge_pte(mm, vma, page, pte, vma->vm_flags & VM_WRITE);
260 }
261out:
262 spin_unlock(&mm->page_table_lock);
263 return ret;
264}
diff --git a/arch/sh64/mm/hugetlbpage.c b/arch/sh64/mm/hugetlbpage.c
index bcad2aefa4ee..dcd9c8a8baf8 100644
--- a/arch/sh64/mm/hugetlbpage.c
+++ b/arch/sh64/mm/hugetlbpage.c
@@ -24,7 +24,7 @@
24#include <asm/tlbflush.h> 24#include <asm/tlbflush.h>
25#include <asm/cacheflush.h> 25#include <asm/cacheflush.h>
26 26
27static pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr) 27pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
28{ 28{
29 pgd_t *pgd; 29 pgd_t *pgd;
30 pmd_t *pmd; 30 pmd_t *pmd;
@@ -39,7 +39,7 @@ static pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
39 return pte; 39 return pte;
40} 40}
41 41
42static pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr) 42pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
43{ 43{
44 pgd_t *pgd; 44 pgd_t *pgd;
45 pmd_t *pmd; 45 pmd_t *pmd;
@@ -80,6 +80,20 @@ static void set_huge_pte(struct mm_struct *mm, struct vm_area_struct *vma,
80 } 80 }
81} 81}
82 82
83pte_t huge_ptep_get_and_clear(pte_t *ptep)
84{
85 pte_t entry;
86
87 entry = *ptep;
88
89 for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
90 pte_clear(pte);
91 pte++;
92 }
93
94 return entry;
95}
96
83/* 97/*
84 * This function checks for proper alignment of input addr and len parameters. 98 * This function checks for proper alignment of input addr and len parameters.
85 */ 99 */
diff --git a/arch/sparc/mm/init.c b/arch/sparc/mm/init.c
index a2dea69b2f07..ec2e05028a10 100644
--- a/arch/sparc/mm/init.c
+++ b/arch/sparc/mm/init.c
@@ -384,7 +384,6 @@ void map_high_region(unsigned long start_pfn, unsigned long end_pfn)
384 struct page *page = pfn_to_page(tmp); 384 struct page *page = pfn_to_page(tmp);
385 385
386 ClearPageReserved(page); 386 ClearPageReserved(page);
387 set_bit(PG_highmem, &page->flags);
388 set_page_count(page, 1); 387 set_page_count(page, 1);
389 __free_page(page); 388 __free_page(page);
390 totalhigh_pages++; 389 totalhigh_pages++;
diff --git a/arch/sparc64/kernel/sys_sparc.c b/arch/sparc64/kernel/sys_sparc.c
index 0077f02f4b37..5f8c822a2b4a 100644
--- a/arch/sparc64/kernel/sys_sparc.c
+++ b/arch/sparc64/kernel/sys_sparc.c
@@ -84,6 +84,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
84 return addr; 84 return addr;
85 } 85 }
86 86
87 if (len <= mm->cached_hole_size) {
88 mm->cached_hole_size = 0;
89 mm->free_area_cache = TASK_UNMAPPED_BASE;
90 }
87 start_addr = addr = mm->free_area_cache; 91 start_addr = addr = mm->free_area_cache;
88 92
89 task_size -= len; 93 task_size -= len;
@@ -103,6 +107,7 @@ full_search:
103 if (task_size < addr) { 107 if (task_size < addr) {
104 if (start_addr != TASK_UNMAPPED_BASE) { 108 if (start_addr != TASK_UNMAPPED_BASE) {
105 start_addr = addr = TASK_UNMAPPED_BASE; 109 start_addr = addr = TASK_UNMAPPED_BASE;
110 mm->cached_hole_size = 0;
106 goto full_search; 111 goto full_search;
107 } 112 }
108 return -ENOMEM; 113 return -ENOMEM;
@@ -114,6 +119,9 @@ full_search:
114 mm->free_area_cache = addr + len; 119 mm->free_area_cache = addr + len;
115 return addr; 120 return addr;
116 } 121 }
122 if (addr + mm->cached_hole_size < vma->vm_start)
123 mm->cached_hole_size = vma->vm_start - addr;
124
117 addr = vma->vm_end; 125 addr = vma->vm_end;
118 if (do_color_align) 126 if (do_color_align)
119 addr = COLOUR_ALIGN(addr, pgoff); 127 addr = COLOUR_ALIGN(addr, pgoff);
diff --git a/arch/sparc64/lib/delay.c b/arch/sparc64/lib/delay.c
index f6b4c784d53e..e8808727617a 100644
--- a/arch/sparc64/lib/delay.c
+++ b/arch/sparc64/lib/delay.c
@@ -31,7 +31,7 @@ void __const_udelay(unsigned long n)
31{ 31{
32 n *= 4; 32 n *= 4;
33 33
34 n *= (cpu_data(_smp_processor_id()).udelay_val * (HZ/4)); 34 n *= (cpu_data(raw_smp_processor_id()).udelay_val * (HZ/4));
35 n >>= 32; 35 n >>= 32;
36 36
37 __delay(n + 1); 37 __delay(n + 1);
diff --git a/arch/sparc64/mm/hugetlbpage.c b/arch/sparc64/mm/hugetlbpage.c
index 5a1f831b2de1..625cbb336a23 100644
--- a/arch/sparc64/mm/hugetlbpage.c
+++ b/arch/sparc64/mm/hugetlbpage.c
@@ -22,7 +22,7 @@
22#include <asm/cacheflush.h> 22#include <asm/cacheflush.h>
23#include <asm/mmu_context.h> 23#include <asm/mmu_context.h>
24 24
25static pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr) 25pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
26{ 26{
27 pgd_t *pgd; 27 pgd_t *pgd;
28 pud_t *pud; 28 pud_t *pud;
@@ -41,7 +41,7 @@ static pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
41 return pte; 41 return pte;
42} 42}
43 43
44static pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr) 44pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
45{ 45{
46 pgd_t *pgd; 46 pgd_t *pgd;
47 pud_t *pud; 47 pud_t *pud;
@@ -62,30 +62,34 @@ static pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
62 62
63#define mk_pte_huge(entry) do { pte_val(entry) |= _PAGE_SZHUGE; } while (0) 63#define mk_pte_huge(entry) do { pte_val(entry) |= _PAGE_SZHUGE; } while (0)
64 64
65static void set_huge_pte(struct mm_struct *mm, struct vm_area_struct *vma, 65void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
66 unsigned long addr, 66 pte_t *ptep, pte_t entry)
67 struct page *page, pte_t * page_table, int write_access)
68{ 67{
69 unsigned long i; 68 int i;
70 pte_t entry; 69
70 for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
71 set_pte_at(mm, addr, ptep, entry);
72 ptep++;
73 addr += PAGE_SIZE;
74 pte_val(entry) += PAGE_SIZE;
75 }
76}
71 77
72 add_mm_counter(mm, rss, HPAGE_SIZE / PAGE_SIZE); 78pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
79 pte_t *ptep)
80{
81 pte_t entry;
82 int i;
73 83
74 if (write_access) 84 entry = *ptep;
75 entry = pte_mkwrite(pte_mkdirty(mk_pte(page,
76 vma->vm_page_prot)));
77 else
78 entry = pte_wrprotect(mk_pte(page, vma->vm_page_prot));
79 entry = pte_mkyoung(entry);
80 mk_pte_huge(entry);
81 85
82 for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) { 86 for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
83 set_pte_at(mm, addr, page_table, entry); 87 pte_clear(mm, addr, ptep);
84 page_table++;
85 addr += PAGE_SIZE; 88 addr += PAGE_SIZE;
86 89 ptep++;
87 pte_val(entry) += PAGE_SIZE;
88 } 90 }
91
92 return entry;
89} 93}
90 94
91/* 95/*
@@ -100,79 +104,6 @@ int is_aligned_hugepage_range(unsigned long addr, unsigned long len)
100 return 0; 104 return 0;
101} 105}
102 106
103int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
104 struct vm_area_struct *vma)
105{
106 pte_t *src_pte, *dst_pte, entry;
107 struct page *ptepage;
108 unsigned long addr = vma->vm_start;
109 unsigned long end = vma->vm_end;
110 int i;
111
112 while (addr < end) {
113 dst_pte = huge_pte_alloc(dst, addr);
114 if (!dst_pte)
115 goto nomem;
116 src_pte = huge_pte_offset(src, addr);
117 BUG_ON(!src_pte || pte_none(*src_pte));
118 entry = *src_pte;
119 ptepage = pte_page(entry);
120 get_page(ptepage);
121 for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
122 set_pte_at(dst, addr, dst_pte, entry);
123 pte_val(entry) += PAGE_SIZE;
124 dst_pte++;
125 addr += PAGE_SIZE;
126 }
127 add_mm_counter(dst, rss, HPAGE_SIZE / PAGE_SIZE);
128 }
129 return 0;
130
131nomem:
132 return -ENOMEM;
133}
134
135int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
136 struct page **pages, struct vm_area_struct **vmas,
137 unsigned long *position, int *length, int i)
138{
139 unsigned long vaddr = *position;
140 int remainder = *length;
141
142 WARN_ON(!is_vm_hugetlb_page(vma));
143
144 while (vaddr < vma->vm_end && remainder) {
145 if (pages) {
146 pte_t *pte;
147 struct page *page;
148
149 pte = huge_pte_offset(mm, vaddr);
150
151 /* hugetlb should be locked, and hence, prefaulted */
152 BUG_ON(!pte || pte_none(*pte));
153
154 page = pte_page(*pte);
155
156 WARN_ON(!PageCompound(page));
157
158 get_page(page);
159 pages[i] = page;
160 }
161
162 if (vmas)
163 vmas[i] = vma;
164
165 vaddr += PAGE_SIZE;
166 --remainder;
167 ++i;
168 }
169
170 *length = remainder;
171 *position = vaddr;
172
173 return i;
174}
175
176struct page *follow_huge_addr(struct mm_struct *mm, 107struct page *follow_huge_addr(struct mm_struct *mm,
177 unsigned long address, int write) 108 unsigned long address, int write)
178{ 109{
@@ -190,34 +121,6 @@ struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address,
190 return NULL; 121 return NULL;
191} 122}
192 123
193void unmap_hugepage_range(struct vm_area_struct *vma,
194 unsigned long start, unsigned long end)
195{
196 struct mm_struct *mm = vma->vm_mm;
197 unsigned long address;
198 pte_t *pte;
199 struct page *page;
200 int i;
201
202 BUG_ON(start & (HPAGE_SIZE - 1));
203 BUG_ON(end & (HPAGE_SIZE - 1));
204
205 for (address = start; address < end; address += HPAGE_SIZE) {
206 pte = huge_pte_offset(mm, address);
207 BUG_ON(!pte);
208 if (pte_none(*pte))
209 continue;
210 page = pte_page(*pte);
211 put_page(page);
212 for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
213 pte_clear(mm, address+(i*PAGE_SIZE), pte);
214 pte++;
215 }
216 }
217 add_mm_counter(mm, rss, -((end - start) >> PAGE_SHIFT));
218 flush_tlb_range(vma, start, end);
219}
220
221static void context_reload(void *__data) 124static void context_reload(void *__data)
222{ 125{
223 struct mm_struct *mm = __data; 126 struct mm_struct *mm = __data;
@@ -226,12 +129,8 @@ static void context_reload(void *__data)
226 load_secondary_context(mm); 129 load_secondary_context(mm);
227} 130}
228 131
229int hugetlb_prefault(struct address_space *mapping, struct vm_area_struct *vma) 132void hugetlb_prefault_arch_hook(struct mm_struct *mm)
230{ 133{
231 struct mm_struct *mm = current->mm;
232 unsigned long addr;
233 int ret = 0;
234
235 /* On UltraSPARC-III+ and later, configure the second half of 134 /* On UltraSPARC-III+ and later, configure the second half of
236 * the Data-TLB for huge pages. 135 * the Data-TLB for huge pages.
237 */ 136 */
@@ -261,50 +160,4 @@ int hugetlb_prefault(struct address_space *mapping, struct vm_area_struct *vma)
261 } 160 }
262 spin_unlock(&ctx_alloc_lock); 161 spin_unlock(&ctx_alloc_lock);
263 } 162 }
264
265 BUG_ON(vma->vm_start & ~HPAGE_MASK);
266 BUG_ON(vma->vm_end & ~HPAGE_MASK);
267
268 spin_lock(&mm->page_table_lock);
269 for (addr = vma->vm_start; addr < vma->vm_end; addr += HPAGE_SIZE) {
270 unsigned long idx;
271 pte_t *pte = huge_pte_alloc(mm, addr);
272 struct page *page;
273
274 if (!pte) {
275 ret = -ENOMEM;
276 goto out;
277 }
278 if (!pte_none(*pte))
279 continue;
280
281 idx = ((addr - vma->vm_start) >> HPAGE_SHIFT)
282 + (vma->vm_pgoff >> (HPAGE_SHIFT - PAGE_SHIFT));
283 page = find_get_page(mapping, idx);
284 if (!page) {
285 /* charge the fs quota first */
286 if (hugetlb_get_quota(mapping)) {
287 ret = -ENOMEM;
288 goto out;
289 }
290 page = alloc_huge_page();
291 if (!page) {
292 hugetlb_put_quota(mapping);
293 ret = -ENOMEM;
294 goto out;
295 }
296 ret = add_to_page_cache(page, mapping, idx, GFP_ATOMIC);
297 if (! ret) {
298 unlock_page(page);
299 } else {
300 hugetlb_put_quota(mapping);
301 free_huge_page(page);
302 goto out;
303 }
304 }
305 set_huge_pte(mm, vma, addr, page, pte, vma->vm_flags & VM_WRITE);
306 }
307out:
308 spin_unlock(&mm->page_table_lock);
309 return ret;
310} 163}
diff --git a/arch/sparc64/solaris/socket.c b/arch/sparc64/solaris/socket.c
index ec8e074c4eac..06740582717e 100644
--- a/arch/sparc64/solaris/socket.c
+++ b/arch/sparc64/solaris/socket.c
@@ -317,8 +317,10 @@ asmlinkage int solaris_sendmsg(int fd, struct sol_nmsghdr __user *user_msg, unsi
317 unsigned long *kcmsg; 317 unsigned long *kcmsg;
318 compat_size_t cmlen; 318 compat_size_t cmlen;
319 319
320 if(kern_msg.msg_controllen > sizeof(ctl) && 320 if (kern_msg.msg_controllen <= sizeof(compat_size_t))
321 kern_msg.msg_controllen <= 256) { 321 return -EINVAL;
322
323 if(kern_msg.msg_controllen > sizeof(ctl)) {
322 err = -ENOBUFS; 324 err = -ENOBUFS;
323 ctl_buf = kmalloc(kern_msg.msg_controllen, GFP_KERNEL); 325 ctl_buf = kmalloc(kern_msg.msg_controllen, GFP_KERNEL);
324 if(!ctl_buf) 326 if(!ctl_buf)
diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index c5292181a664..b8e952c88fd1 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -35,6 +35,11 @@ config GENERIC_CALIBRATE_DELAY
35 bool 35 bool
36 default y 36 default y
37 37
38# Used in kernel/irq/manage.c and include/linux/irq.h
39config IRQ_RELEASE_METHOD
40 bool
41 default y
42
38menu "UML-specific options" 43menu "UML-specific options"
39 44
40config MODE_TT 45config MODE_TT
diff --git a/arch/um/Makefile b/arch/um/Makefile
index f2a0c40a9204..3f073902351f 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -122,7 +122,7 @@ endif
122CPPFLAGS_vmlinux.lds = $(shell echo -U$(SUBARCH) \ 122CPPFLAGS_vmlinux.lds = $(shell echo -U$(SUBARCH) \
123 -DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \ 123 -DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \
124 -DELF_FORMAT=\"$(ELF_FORMAT)\" $(CPP_MODE-y) \ 124 -DELF_FORMAT=\"$(ELF_FORMAT)\" $(CPP_MODE-y) \
125 -DKERNEL_STACK_SIZE=$(STACK_SIZE)) 125 -DKERNEL_STACK_SIZE=$(STACK_SIZE) -DSUBARCH=$(SUBARCH))
126 126
127#The wrappers will select whether using "malloc" or the kernel allocator. 127#The wrappers will select whether using "malloc" or the kernel allocator.
128LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc 128LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index 025d3be8aca4..0f59736db329 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -406,14 +406,12 @@ void line_disable(struct tty_struct *tty, int current_irq)
406 if(line->driver->read_irq == current_irq) 406 if(line->driver->read_irq == current_irq)
407 free_irq_later(line->driver->read_irq, tty); 407 free_irq_later(line->driver->read_irq, tty);
408 else { 408 else {
409 free_irq_by_irq_and_dev(line->driver->read_irq, tty);
410 free_irq(line->driver->read_irq, tty); 409 free_irq(line->driver->read_irq, tty);
411 } 410 }
412 411
413 if(line->driver->write_irq == current_irq) 412 if(line->driver->write_irq == current_irq)
414 free_irq_later(line->driver->write_irq, tty); 413 free_irq_later(line->driver->write_irq, tty);
415 else { 414 else {
416 free_irq_by_irq_and_dev(line->driver->write_irq, tty);
417 free_irq(line->driver->write_irq, tty); 415 free_irq(line->driver->write_irq, tty);
418 } 416 }
419 417
@@ -758,7 +756,6 @@ static void unregister_winch(struct tty_struct *tty)
758 if(winch->pid != -1) 756 if(winch->pid != -1)
759 os_kill_process(winch->pid, 1); 757 os_kill_process(winch->pid, 1);
760 758
761 free_irq_by_irq_and_dev(WINCH_IRQ, winch);
762 free_irq(WINCH_IRQ, winch); 759 free_irq(WINCH_IRQ, winch);
763 list_del(&winch->list); 760 list_del(&winch->list);
764 kfree(winch); 761 kfree(winch);
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index 4eeaf88c1e97..5388a7428691 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -146,7 +146,6 @@ static int uml_net_close(struct net_device *dev)
146 netif_stop_queue(dev); 146 netif_stop_queue(dev);
147 spin_lock(&lp->lock); 147 spin_lock(&lp->lock);
148 148
149 free_irq_by_irq_and_dev(dev->irq, dev);
150 free_irq(dev->irq, dev); 149 free_irq(dev->irq, dev);
151 if(lp->close != NULL) 150 if(lp->close != NULL)
152 (*lp->close)(lp->fd, &lp->user); 151 (*lp->close)(lp->fd, &lp->user);
diff --git a/arch/um/drivers/port_kern.c b/arch/um/drivers/port_kern.c
index b5ee07472f79..c41efd207fcc 100644
--- a/arch/um/drivers/port_kern.c
+++ b/arch/um/drivers/port_kern.c
@@ -257,7 +257,6 @@ int port_wait(void *data)
257 * connection. Then we loop here throwing out failed 257 * connection. Then we loop here throwing out failed
258 * connections until a good one is found. 258 * connections until a good one is found.
259 */ 259 */
260 free_irq_by_irq_and_dev(TELNETD_IRQ, conn);
261 free_irq(TELNETD_IRQ, conn); 260 free_irq(TELNETD_IRQ, conn);
262 261
263 if(conn->fd >= 0) break; 262 if(conn->fd >= 0) break;
diff --git a/arch/um/drivers/xterm_kern.c b/arch/um/drivers/xterm_kern.c
index a4fdf3584ad2..d269a80f4b0c 100644
--- a/arch/um/drivers/xterm_kern.c
+++ b/arch/um/drivers/xterm_kern.c
@@ -69,7 +69,6 @@ int xterm_fd(int socket, int *pid_out)
69 * isn't set) this will hang... */ 69 * isn't set) this will hang... */
70 wait_for_completion(&data->ready); 70 wait_for_completion(&data->ready);
71 71
72 free_irq_by_irq_and_dev(XTERM_IRQ, data);
73 free_irq(XTERM_IRQ, data); 72 free_irq(XTERM_IRQ, data);
74 73
75 ret = data->new_fd; 74 ret = data->new_fd;
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
index d44fb5282547..9f18061ef4c9 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -124,14 +124,16 @@ void irq_unlock(unsigned long flags)
124 spin_unlock_irqrestore(&irq_spinlock, flags); 124 spin_unlock_irqrestore(&irq_spinlock, flags);
125} 125}
126 126
127/* presently hw_interrupt_type must define (startup || enable) && 127/* hw_interrupt_type must define (startup || enable) &&
128 * disable && end */ 128 * (shutdown || disable) && end */
129static void dummy(unsigned int irq) 129static void dummy(unsigned int irq)
130{ 130{
131} 131}
132 132
133static struct hw_interrupt_type SIGIO_irq_type = { 133/* This is used for everything else than the timer. */
134static struct hw_interrupt_type normal_irq_type = {
134 .typename = "SIGIO", 135 .typename = "SIGIO",
136 .release = free_irq_by_irq_and_dev,
135 .disable = dummy, 137 .disable = dummy,
136 .enable = dummy, 138 .enable = dummy,
137 .ack = dummy, 139 .ack = dummy,
@@ -140,6 +142,7 @@ static struct hw_interrupt_type SIGIO_irq_type = {
140 142
141static struct hw_interrupt_type SIGVTALRM_irq_type = { 143static struct hw_interrupt_type SIGVTALRM_irq_type = {
142 .typename = "SIGVTALRM", 144 .typename = "SIGVTALRM",
145 .release = free_irq_by_irq_and_dev,
143 .shutdown = dummy, /* never called */ 146 .shutdown = dummy, /* never called */
144 .disable = dummy, 147 .disable = dummy,
145 .enable = dummy, 148 .enable = dummy,
@@ -160,7 +163,7 @@ void __init init_IRQ(void)
160 irq_desc[i].status = IRQ_DISABLED; 163 irq_desc[i].status = IRQ_DISABLED;
161 irq_desc[i].action = NULL; 164 irq_desc[i].action = NULL;
162 irq_desc[i].depth = 1; 165 irq_desc[i].depth = 1;
163 irq_desc[i].handler = &SIGIO_irq_type; 166 irq_desc[i].handler = &normal_irq_type;
164 enable_irq(i); 167 enable_irq(i);
165 } 168 }
166} 169}
diff --git a/arch/um/kernel/irq_user.c b/arch/um/kernel/irq_user.c
index b3074cbaa479..c3ccaf24f3e0 100644
--- a/arch/um/kernel/irq_user.c
+++ b/arch/um/kernel/irq_user.c
@@ -85,8 +85,6 @@ void sigio_handler(int sig, union uml_pt_regs *regs)
85 next = irq_fd->next; 85 next = irq_fd->next;
86 if(irq_fd->freed){ 86 if(irq_fd->freed){
87 free_irq(irq_fd->irq, irq_fd->id); 87 free_irq(irq_fd->irq, irq_fd->id);
88 free_irq_by_irq_and_dev(irq_fd->irq,
89 irq_fd->id);
90 } 88 }
91 } 89 }
92 } 90 }
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index c22825f13e40..5597bd39e6b5 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -53,7 +53,6 @@ static void setup_highmem(unsigned long highmem_start,
53 for(i = 0; i < highmem_len >> PAGE_SHIFT; i++){ 53 for(i = 0; i < highmem_len >> PAGE_SHIFT; i++){
54 page = &mem_map[highmem_pfn + i]; 54 page = &mem_map[highmem_pfn + i];
55 ClearPageReserved(page); 55 ClearPageReserved(page);
56 set_bit(PG_highmem, &page->flags);
57 set_page_count(page, 1); 56 set_page_count(page, 1);
58 __free_page(page); 57 __free_page(page);
59 } 58 }
diff --git a/arch/um/kernel/tt/Makefile b/arch/um/kernel/tt/Makefile
index c3faea21a996..3fd2554e60b6 100644
--- a/arch/um/kernel/tt/Makefile
+++ b/arch/um/kernel/tt/Makefile
@@ -3,10 +3,6 @@
3# Licensed under the GPL 3# Licensed under the GPL
4# 4#
5 5
6extra-y := unmap_fin.o
7targets := unmap.o
8clean-files := unmap_tmp.o
9
10obj-y = exec_kern.o exec_user.o gdb.o ksyms.o mem.o mem_user.o process_kern.o \ 6obj-y = exec_kern.o exec_user.o gdb.o ksyms.o mem.o mem_user.o process_kern.o \
11 syscall_kern.o syscall_user.o time.o tlb.o tracer.o trap_user.o \ 7 syscall_kern.o syscall_user.o time.o tlb.o tracer.o trap_user.o \
12 uaccess.o uaccess_user.o 8 uaccess.o uaccess_user.o
@@ -16,14 +12,3 @@ obj-$(CONFIG_PT_PROXY) += gdb_kern.o ptproxy/
16USER_OBJS := gdb.o time.o tracer.o 12USER_OBJS := gdb.o time.o tracer.o
17 13
18include arch/um/scripts/Makefile.rules 14include arch/um/scripts/Makefile.rules
19
20UNMAP_CFLAGS := $(patsubst -pg -DPROFILING,,$(USER_CFLAGS))
21UNMAP_CFLAGS := $(patsubst -fprofile-arcs -ftest-coverage,,$(UNMAP_CFLAGS))
22
23#XXX: partially copied from arch/um/scripts/Makefile.rules
24$(obj)/unmap.o: c_flags = -Wp,-MD,$(depfile) $(UNMAP_CFLAGS)
25
26$(obj)/unmap_fin.o : $(obj)/unmap.o
27 $(LD) -r -o $(obj)/unmap_tmp.o $< $(shell $(CC) -print-file-name=libc.a)
28 $(OBJCOPY) $(obj)/unmap_tmp.o $@ -G switcheroo
29
diff --git a/arch/um/kernel/tt/unmap.c b/arch/um/kernel/tt/unmap.c
deleted file mode 100644
index 3f7aecdbe532..000000000000
--- a/arch/um/kernel/tt/unmap.c
+++ /dev/null
@@ -1,31 +0,0 @@
1/*
2 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#include <sys/mman.h>
7
8int switcheroo(int fd, int prot, void *from, void *to, int size)
9{
10 if(munmap(to, size) < 0){
11 return(-1);
12 }
13 if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) != to){
14 return(-1);
15 }
16 if(munmap(from, size) < 0){
17 return(-1);
18 }
19 return(0);
20}
21
22/*
23 * Overrides for Emacs so that we follow Linus's tabbing style.
24 * Emacs will notice this stuff at the end of the file and automatically
25 * adjust the settings for this buffer only. This must remain at the end
26 * of the file.
27 * ---------------------------------------------------------------------------
28 * Local variables:
29 * c-file-style: "linux"
30 * End:
31 */
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S
index dd5355500bdc..61dfd4fef752 100644
--- a/arch/um/kernel/uml.lds.S
+++ b/arch/um/kernel/uml.lds.S
@@ -14,19 +14,10 @@ SECTIONS
14 /* Used in arch/um/kernel/mem.c. Any memory between START and __binary_start 14 /* Used in arch/um/kernel/mem.c. Any memory between START and __binary_start
15 * is remapped.*/ 15 * is remapped.*/
16 __binary_start = .; 16 __binary_start = .;
17#ifdef MODE_TT
18 .thread_private : {
19 __start_thread_private = .;
20 errno = .;
21 . += 4;
22 arch/um/kernel/tt/unmap_fin.o (.data)
23 __end_thread_private = .;
24 }
25 . = ALIGN(4096);
26 .remap : { arch/um/kernel/tt/unmap_fin.o (.text) }
27 17
28 /* We want it only if we are in MODE_TT. In both cases, however, when MODE_TT 18#ifdef MODE_TT
29 * is off the resulting binary segfaults.*/ 19 .remap_data : { arch/um/sys-SUBARCH/unmap_fin.o (.data .bss) }
20 .remap : { arch/um/sys-SUBARCH/unmap_fin.o (.text) }
30 21
31 . = ALIGN(4096); /* Init code and data */ 22 . = ALIGN(4096); /* Init code and data */
32#endif 23#endif
diff --git a/arch/um/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules
index 98346c711493..7459d09c233e 100644
--- a/arch/um/scripts/Makefile.rules
+++ b/arch/um/scripts/Makefile.rules
@@ -10,6 +10,12 @@ USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
10$(USER_OBJS) : c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) \ 10$(USER_OBJS) : c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) \
11 $(CFLAGS_$(notdir $@)) 11 $(CFLAGS_$(notdir $@))
12 12
13# The stubs and unmap.o can't try to call mcount or update basic block data
14define unprofile
15 $(patsubst -pg,,$(patsubst -fprofile-arcs -ftest-coverage,,$(1)))
16endef
17
18
13quiet_cmd_make_link = SYMLINK $@ 19quiet_cmd_make_link = SYMLINK $@
14cmd_make_link = ln -sf $(srctree)/arch/$(SUBARCH)/$($(notdir $@)-dir)/$(notdir $@) $@ 20cmd_make_link = ln -sf $(srctree)/arch/$(SUBARCH)/$($(notdir $@)-dir)/$(notdir $@) $@
15 21
diff --git a/arch/um/scripts/Makefile.unmap b/arch/um/scripts/Makefile.unmap
new file mode 100644
index 000000000000..37a8f9765295
--- /dev/null
+++ b/arch/um/scripts/Makefile.unmap
@@ -0,0 +1,22 @@
1clean-files += unmap_tmp.o unmap_fin.o unmap.o
2
3ifdef CONFIG_MODE_TT
4
5#Always build unmap_fin.o
6extra-y += unmap_fin.o
7#Do dependency tracking for unmap.o (it will be always built, but won't get the tracking unless we use this).
8targets += unmap.o
9
10#XXX: partially copied from arch/um/scripts/Makefile.rules
11$(obj)/unmap.o: _c_flags = $(call unprofile,$(CFLAGS))
12
13quiet_cmd_wrapld = LD $@
14define cmd_wrapld
15 $(LD) -r -o $(obj)/unmap_tmp.o $< $(shell $(CC) -print-file-name=libc.a); \
16 $(OBJCOPY) $(obj)/unmap_tmp.o $@ -G switcheroo
17endef
18
19$(obj)/unmap_fin.o : $(obj)/unmap.o FORCE
20 $(call if_changed,wrapld)
21
22endif
diff --git a/arch/um/sys-i386/Makefile b/arch/um/sys-i386/Makefile
index 4351e5605506..095bcdb0b9cc 100644
--- a/arch/um/sys-i386/Makefile
+++ b/arch/um/sys-i386/Makefile
@@ -17,3 +17,5 @@ highmem.c-dir = mm
17module.c-dir = kernel 17module.c-dir = kernel
18 18
19subdir- := util 19subdir- := util
20
21include arch/um/scripts/Makefile.unmap
diff --git a/arch/um/sys-i386/unmap.c b/arch/um/sys-i386/unmap.c
new file mode 100644
index 000000000000..136875263d27
--- /dev/null
+++ b/arch/um/sys-i386/unmap.c
@@ -0,0 +1,25 @@
1/*
2 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#include <linux/mman.h>
7#include <asm/unistd.h>
8
9static int errno;
10
11static inline _syscall2(int,munmap,void *,start,size_t,len)
12static inline _syscall6(void *,mmap2,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
13int switcheroo(int fd, int prot, void *from, void *to, int size)
14{
15 if(munmap(to, size) < 0){
16 return(-1);
17 }
18 if(mmap2(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) != to){
19 return(-1);
20 }
21 if(munmap(from, size) < 0){
22 return(-1);
23 }
24 return(0);
25}
diff --git a/arch/um/sys-x86_64/Makefile b/arch/um/sys-x86_64/Makefile
index 608466ad6b22..2bc6f6849010 100644
--- a/arch/um/sys-x86_64/Makefile
+++ b/arch/um/sys-x86_64/Makefile
@@ -29,3 +29,5 @@ thunk.S-dir = lib
29module.c-dir = kernel 29module.c-dir = kernel
30 30
31subdir- := util 31subdir- := util
32
33include arch/um/scripts/Makefile.unmap
diff --git a/arch/um/sys-x86_64/unmap.c b/arch/um/sys-x86_64/unmap.c
new file mode 100644
index 000000000000..bc7094cce47e
--- /dev/null
+++ b/arch/um/sys-x86_64/unmap.c
@@ -0,0 +1,25 @@
1/*
2 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#include <linux/mman.h>
7#include <asm/unistd.h>
8
9static int errno;
10
11static inline _syscall2(int,munmap,void *,start,size_t,len)
12static inline _syscall6(void *,mmap,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
13int switcheroo(int fd, int prot, void *from, void *to, int size)
14{
15 if(munmap(to, size) < 0){
16 return(-1);
17 }
18 if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) != to){
19 return(-1);
20 }
21 if(munmap(from, size) < 0){
22 return(-1);
23 }
24 return(0);
25}
diff --git a/arch/x86_64/ia32/ia32_aout.c b/arch/x86_64/ia32/ia32_aout.c
index 1965efc974dc..c12edf5d97f0 100644
--- a/arch/x86_64/ia32/ia32_aout.c
+++ b/arch/x86_64/ia32/ia32_aout.c
@@ -312,6 +312,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
312 current->mm->brk = ex.a_bss + 312 current->mm->brk = ex.a_bss +
313 (current->mm->start_brk = N_BSSADDR(ex)); 313 (current->mm->start_brk = N_BSSADDR(ex));
314 current->mm->free_area_cache = TASK_UNMAPPED_BASE; 314 current->mm->free_area_cache = TASK_UNMAPPED_BASE;
315 current->mm->cached_hole_size = 0;
315 316
316 set_mm_counter(current->mm, rss, 0); 317 set_mm_counter(current->mm, rss, 0);
317 current->mm->mmap = NULL; 318 current->mm->mmap = NULL;
diff --git a/arch/x86_64/ia32/ia32_binfmt.c b/arch/x86_64/ia32/ia32_binfmt.c
index 99b522052d16..c8131f342cfc 100644
--- a/arch/x86_64/ia32/ia32_binfmt.c
+++ b/arch/x86_64/ia32/ia32_binfmt.c
@@ -46,7 +46,7 @@ struct elf_phdr;
46 46
47#define IA32_EMULATOR 1 47#define IA32_EMULATOR 1
48 48
49#define ELF_ET_DYN_BASE (TASK_UNMAPPED_32 + 0x1000000) 49#define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
50 50
51#undef ELF_ARCH 51#undef ELF_ARCH
52#define ELF_ARCH EM_386 52#define ELF_ARCH EM_386
@@ -307,9 +307,6 @@ MODULE_AUTHOR("Eric Youngdale, Andi Kleen");
307 307
308#define elf_addr_t __u32 308#define elf_addr_t __u32
309 309
310#undef TASK_SIZE
311#define TASK_SIZE 0xffffffff
312
313static void elf32_init(struct pt_regs *); 310static void elf32_init(struct pt_regs *);
314 311
315#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 312#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
index 761b6d35e338..dce8bab4306c 100644
--- a/arch/x86_64/kernel/process.c
+++ b/arch/x86_64/kernel/process.c
@@ -656,7 +656,7 @@ long do_arch_prctl(struct task_struct *task, int code, unsigned long addr)
656 656
657 switch (code) { 657 switch (code) {
658 case ARCH_SET_GS: 658 case ARCH_SET_GS:
659 if (addr >= TASK_SIZE) 659 if (addr >= TASK_SIZE_OF(task))
660 return -EPERM; 660 return -EPERM;
661 cpu = get_cpu(); 661 cpu = get_cpu();
662 /* handle small bases via the GDT because that's faster to 662 /* handle small bases via the GDT because that's faster to
@@ -682,7 +682,7 @@ long do_arch_prctl(struct task_struct *task, int code, unsigned long addr)
682 case ARCH_SET_FS: 682 case ARCH_SET_FS:
683 /* Not strictly needed for fs, but do it for symmetry 683 /* Not strictly needed for fs, but do it for symmetry
684 with gs */ 684 with gs */
685 if (addr >= TASK_SIZE) 685 if (addr >= TASK_SIZE_OF(task))
686 return -EPERM; 686 return -EPERM;
687 cpu = get_cpu(); 687 cpu = get_cpu();
688 /* handle small bases via the GDT because that's faster to 688 /* handle small bases via the GDT because that's faster to
diff --git a/arch/x86_64/kernel/ptrace.c b/arch/x86_64/kernel/ptrace.c
index 525f6a128a27..bbf64b59a21e 100644
--- a/arch/x86_64/kernel/ptrace.c
+++ b/arch/x86_64/kernel/ptrace.c
@@ -257,12 +257,12 @@ static int putreg(struct task_struct *child,
257 value &= 0xffff; 257 value &= 0xffff;
258 return 0; 258 return 0;
259 case offsetof(struct user_regs_struct,fs_base): 259 case offsetof(struct user_regs_struct,fs_base):
260 if (value >= TASK_SIZE) 260 if (value >= TASK_SIZE_OF(child))
261 return -EIO; 261 return -EIO;
262 child->thread.fs = value; 262 child->thread.fs = value;
263 return 0; 263 return 0;
264 case offsetof(struct user_regs_struct,gs_base): 264 case offsetof(struct user_regs_struct,gs_base):
265 if (value >= TASK_SIZE) 265 if (value >= TASK_SIZE_OF(child))
266 return -EIO; 266 return -EIO;
267 child->thread.gs = value; 267 child->thread.gs = value;
268 return 0; 268 return 0;
@@ -279,7 +279,7 @@ static int putreg(struct task_struct *child,
279 break; 279 break;
280 case offsetof(struct user_regs_struct, rip): 280 case offsetof(struct user_regs_struct, rip):
281 /* Check if the new RIP address is canonical */ 281 /* Check if the new RIP address is canonical */
282 if (value >= TASK_SIZE) 282 if (value >= TASK_SIZE_OF(child))
283 return -EIO; 283 return -EIO;
284 break; 284 break;
285 } 285 }
@@ -419,6 +419,8 @@ asmlinkage long sys_ptrace(long request, long pid, unsigned long addr, long data
419 break; 419 break;
420 420
421 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ 421 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
422 {
423 int dsize = test_tsk_thread_flag(child, TIF_IA32) ? 3 : 7;
422 ret = -EIO; 424 ret = -EIO;
423 if ((addr & 7) || 425 if ((addr & 7) ||
424 addr > sizeof(struct user) - 7) 426 addr > sizeof(struct user) - 7)
@@ -430,22 +432,22 @@ asmlinkage long sys_ptrace(long request, long pid, unsigned long addr, long data
430 break; 432 break;
431 /* Disallows to set a breakpoint into the vsyscall */ 433 /* Disallows to set a breakpoint into the vsyscall */
432 case offsetof(struct user, u_debugreg[0]): 434 case offsetof(struct user, u_debugreg[0]):
433 if (data >= TASK_SIZE-7) break; 435 if (data >= TASK_SIZE_OF(child) - dsize) break;
434 child->thread.debugreg0 = data; 436 child->thread.debugreg0 = data;
435 ret = 0; 437 ret = 0;
436 break; 438 break;
437 case offsetof(struct user, u_debugreg[1]): 439 case offsetof(struct user, u_debugreg[1]):
438 if (data >= TASK_SIZE-7) break; 440 if (data >= TASK_SIZE_OF(child) - dsize) break;
439 child->thread.debugreg1 = data; 441 child->thread.debugreg1 = data;
440 ret = 0; 442 ret = 0;
441 break; 443 break;
442 case offsetof(struct user, u_debugreg[2]): 444 case offsetof(struct user, u_debugreg[2]):
443 if (data >= TASK_SIZE-7) break; 445 if (data >= TASK_SIZE_OF(child) - dsize) break;
444 child->thread.debugreg2 = data; 446 child->thread.debugreg2 = data;
445 ret = 0; 447 ret = 0;
446 break; 448 break;
447 case offsetof(struct user, u_debugreg[3]): 449 case offsetof(struct user, u_debugreg[3]):
448 if (data >= TASK_SIZE-7) break; 450 if (data >= TASK_SIZE_OF(child) - dsize) break;
449 child->thread.debugreg3 = data; 451 child->thread.debugreg3 = data;
450 ret = 0; 452 ret = 0;
451 break; 453 break;
@@ -469,6 +471,7 @@ asmlinkage long sys_ptrace(long request, long pid, unsigned long addr, long data
469 break; 471 break;
470 } 472 }
471 break; 473 break;
474 }
472 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ 475 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
473 case PTRACE_CONT: /* restart after signal. */ 476 case PTRACE_CONT: /* restart after signal. */
474 477
diff --git a/arch/x86_64/kernel/sys_x86_64.c b/arch/x86_64/kernel/sys_x86_64.c
index dbebd5ccba6b..cc7821c68851 100644
--- a/arch/x86_64/kernel/sys_x86_64.c
+++ b/arch/x86_64/kernel/sys_x86_64.c
@@ -68,13 +68,7 @@ out:
68static void find_start_end(unsigned long flags, unsigned long *begin, 68static void find_start_end(unsigned long flags, unsigned long *begin,
69 unsigned long *end) 69 unsigned long *end)
70{ 70{
71#ifdef CONFIG_IA32_EMULATION 71 if (!test_thread_flag(TIF_IA32) && (flags & MAP_32BIT)) {
72 if (test_thread_flag(TIF_IA32)) {
73 *begin = TASK_UNMAPPED_32;
74 *end = IA32_PAGE_OFFSET;
75 } else
76#endif
77 if (flags & MAP_32BIT) {
78 /* This is usually used needed to map code in small 72 /* This is usually used needed to map code in small
79 model, so it needs to be in the first 31bit. Limit 73 model, so it needs to be in the first 31bit. Limit
80 it to that. This means we need to move the 74 it to that. This means we need to move the
@@ -84,10 +78,10 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
84 of playground for now. -AK */ 78 of playground for now. -AK */
85 *begin = 0x40000000; 79 *begin = 0x40000000;
86 *end = 0x80000000; 80 *end = 0x80000000;
87 } else { 81 } else {
88 *begin = TASK_UNMAPPED_64; 82 *begin = TASK_UNMAPPED_BASE;
89 *end = TASK_SIZE; 83 *end = TASK_SIZE;
90 } 84 }
91} 85}
92 86
93unsigned long 87unsigned long
@@ -111,6 +105,11 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
111 (!vma || addr + len <= vma->vm_start)) 105 (!vma || addr + len <= vma->vm_start))
112 return addr; 106 return addr;
113 } 107 }
108 if (((flags & MAP_32BIT) || test_thread_flag(TIF_IA32))
109 && len <= mm->cached_hole_size) {
110 mm->cached_hole_size = 0;
111 mm->free_area_cache = begin;
112 }
114 addr = mm->free_area_cache; 113 addr = mm->free_area_cache;
115 if (addr < begin) 114 if (addr < begin)
116 addr = begin; 115 addr = begin;
@@ -126,6 +125,7 @@ full_search:
126 */ 125 */
127 if (start_addr != begin) { 126 if (start_addr != begin) {
128 start_addr = addr = begin; 127 start_addr = addr = begin;
128 mm->cached_hole_size = 0;
129 goto full_search; 129 goto full_search;
130 } 130 }
131 return -ENOMEM; 131 return -ENOMEM;
@@ -137,6 +137,9 @@ full_search:
137 mm->free_area_cache = addr + len; 137 mm->free_area_cache = addr + len;
138 return addr; 138 return addr;
139 } 139 }
140 if (addr + mm->cached_hole_size < vma->vm_start)
141 mm->cached_hole_size = vma->vm_start - addr;
142
140 addr = vma->vm_end; 143 addr = vma->vm_end;
141 } 144 }
142} 145}
diff --git a/arch/x86_64/lib/delay.c b/arch/x86_64/lib/delay.c
index 6e2d66472eb1..aed61a668a1b 100644
--- a/arch/x86_64/lib/delay.c
+++ b/arch/x86_64/lib/delay.c
@@ -34,7 +34,7 @@ void __delay(unsigned long loops)
34 34
35inline void __const_udelay(unsigned long xloops) 35inline void __const_udelay(unsigned long xloops)
36{ 36{
37 __delay(((xloops * cpu_data[_smp_processor_id()].loops_per_jiffy) >> 32) * HZ); 37 __delay(((xloops * cpu_data[raw_smp_processor_id()].loops_per_jiffy) >> 32) * HZ);
38} 38}
39 39
40void __udelay(unsigned long usecs) 40void __udelay(unsigned long usecs)
diff --git a/arch/x86_64/mm/fault.c b/arch/x86_64/mm/fault.c
index 5d6b2114cc9a..57d3ab15a5c7 100644
--- a/arch/x86_64/mm/fault.c
+++ b/arch/x86_64/mm/fault.c
@@ -350,7 +350,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code)
350 * (error_code & 4) == 0, and that the fault was not a 350 * (error_code & 4) == 0, and that the fault was not a
351 * protection error (error_code & 1) == 0. 351 * protection error (error_code & 1) == 0.
352 */ 352 */
353 if (unlikely(address >= TASK_SIZE)) { 353 if (unlikely(address >= TASK_SIZE64)) {
354 if (!(error_code & 5) && 354 if (!(error_code & 5) &&
355 ((address >= VMALLOC_START && address < VMALLOC_END) || 355 ((address >= VMALLOC_START && address < VMALLOC_END) ||
356 (address >= MODULES_VADDR && address < MODULES_END))) { 356 (address >= MODULES_VADDR && address < MODULES_END))) {
diff --git a/drivers/Kconfig b/drivers/Kconfig
index ed41d9036bfc..aed4a9b97c14 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -58,4 +58,6 @@ source "drivers/mmc/Kconfig"
58 58
59source "drivers/infiniband/Kconfig" 59source "drivers/infiniband/Kconfig"
60 60
61source "drivers/sn/Kconfig"
62
61endmenu 63endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index 15681de688f4..3167be54fedd 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -61,6 +61,6 @@ obj-$(CONFIG_EISA) += eisa/
61obj-$(CONFIG_CPU_FREQ) += cpufreq/ 61obj-$(CONFIG_CPU_FREQ) += cpufreq/
62obj-$(CONFIG_MMC) += mmc/ 62obj-$(CONFIG_MMC) += mmc/
63obj-$(CONFIG_INFINIBAND) += infiniband/ 63obj-$(CONFIG_INFINIBAND) += infiniband/
64obj-$(CONFIG_BLK_DEV_SGIIOC4) += sn/ 64obj-$(CONFIG_SGI_IOC4) += sn/
65obj-y += firmware/ 65obj-y += firmware/
66obj-$(CONFIG_CRYPTO) += crypto/ 66obj-$(CONFIG_CRYPTO) += crypto/
diff --git a/drivers/acorn/char/pcf8583.c b/drivers/acorn/char/pcf8583.c
index ad7ae7ab8920..141b4c237a50 100644
--- a/drivers/acorn/char/pcf8583.c
+++ b/drivers/acorn/char/pcf8583.c
@@ -26,11 +26,8 @@ static unsigned short normal_addr[] = { 0x50, I2C_CLIENT_END };
26 26
27static struct i2c_client_address_data addr_data = { 27static struct i2c_client_address_data addr_data = {
28 .normal_i2c = normal_addr, 28 .normal_i2c = normal_addr,
29 .normal_i2c_range = ignore,
30 .probe = ignore, 29 .probe = ignore,
31 .probe_range = ignore,
32 .ignore = ignore, 30 .ignore = ignore,
33 .ignore_range = ignore,
34 .force = ignore, 31 .force = ignore,
35}; 32};
36 33
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index ff64d333e95f..c9d671cf7857 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -171,7 +171,7 @@ static void acpi_processor_idle (void)
171 int sleep_ticks = 0; 171 int sleep_ticks = 0;
172 u32 t1, t2 = 0; 172 u32 t1, t2 = 0;
173 173
174 pr = processors[_smp_processor_id()]; 174 pr = processors[raw_smp_processor_id()];
175 if (!pr) 175 if (!pr)
176 return; 176 return;
177 177
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 5d4517ccc422..904b27caf697 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -87,7 +87,7 @@ static ssize_t node_read_numastat(struct sys_device * dev, char * buf)
87 for (i = 0; i < MAX_NR_ZONES; i++) { 87 for (i = 0; i < MAX_NR_ZONES; i++) {
88 struct zone *z = &pg->node_zones[i]; 88 struct zone *z = &pg->node_zones[i];
89 for (cpu = 0; cpu < NR_CPUS; cpu++) { 89 for (cpu = 0; cpu < NR_CPUS; cpu++) {
90 struct per_cpu_pageset *ps = &z->pageset[cpu]; 90 struct per_cpu_pageset *ps = zone_pcp(z,cpu);
91 numa_hit += ps->numa_hit; 91 numa_hit += ps->numa_hit;
92 numa_miss += ps->numa_miss; 92 numa_miss += ps->numa_miss;
93 numa_foreign += ps->numa_foreign; 93 numa_foreign += ps->numa_foreign;
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 5ed6515ae01f..7ccf871d3c9d 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -929,6 +929,10 @@ config SCx200_GPIO
929 929
930 If compiled as a module, it will be called scx200_gpio. 930 If compiled as a module, it will be called scx200_gpio.
931 931
932config GPIO_VR41XX
933 tristate "NEC VR4100 series General-purpose I/O Unit support"
934 depends on CPU_VR41XX
935
932config RAW_DRIVER 936config RAW_DRIVER
933 tristate "RAW driver (/dev/raw/rawN) (OBSOLETE)" 937 tristate "RAW driver (/dev/raw/rawN) (OBSOLETE)"
934 help 938 help
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index e3f5c32aac55..1aff819f3832 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -80,6 +80,7 @@ obj-$(CONFIG_PPDEV) += ppdev.o
80obj-$(CONFIG_NWBUTTON) += nwbutton.o 80obj-$(CONFIG_NWBUTTON) += nwbutton.o
81obj-$(CONFIG_NWFLASH) += nwflash.o 81obj-$(CONFIG_NWFLASH) += nwflash.o
82obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o 82obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o
83obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o
83obj-$(CONFIG_TANBAC_TB0219) += tb0219.o 84obj-$(CONFIG_TANBAC_TB0219) += tb0219.o
84 85
85obj-$(CONFIG_WATCHDOG) += watchdog/ 86obj-$(CONFIG_WATCHDOG) += watchdog/
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index d7fb452af7f9..0c81652eaba6 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -641,7 +641,7 @@ int ipmi_create_user(unsigned int if_num,
641 return -ENOMEM; 641 return -ENOMEM;
642 642
643 down_read(&interfaces_sem); 643 down_read(&interfaces_sem);
644 if ((if_num > MAX_IPMI_INTERFACES) || ipmi_interfaces[if_num] == NULL) 644 if ((if_num >= MAX_IPMI_INTERFACES) || ipmi_interfaces[if_num] == NULL)
645 { 645 {
646 rv = -EINVAL; 646 rv = -EINVAL;
647 goto out_unlock; 647 goto out_unlock;
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 257b8ee605e5..e3085b22a365 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -484,7 +484,7 @@ static ssize_t write_kmem(struct file * file, const char __user * buf,
484 return virtr + wrote; 484 return virtr + wrote;
485} 485}
486 486
487#if defined(CONFIG_ISA) || !defined(__mc68000__) 487#if (defined(CONFIG_ISA) || !defined(__mc68000__)) && (!defined(CONFIG_PPC_ISERIES) || defined(CONFIG_PCI))
488static ssize_t read_port(struct file * file, char __user * buf, 488static ssize_t read_port(struct file * file, char __user * buf,
489 size_t count, loff_t *ppos) 489 size_t count, loff_t *ppos)
490{ 490{
@@ -744,7 +744,7 @@ static struct file_operations null_fops = {
744 .write = write_null, 744 .write = write_null,
745}; 745};
746 746
747#if defined(CONFIG_ISA) || !defined(__mc68000__) 747#if (defined(CONFIG_ISA) || !defined(__mc68000__)) && (!defined(CONFIG_PPC_ISERIES) || defined(CONFIG_PCI))
748static struct file_operations port_fops = { 748static struct file_operations port_fops = {
749 .llseek = memory_lseek, 749 .llseek = memory_lseek,
750 .read = read_port, 750 .read = read_port,
@@ -804,7 +804,7 @@ static int memory_open(struct inode * inode, struct file * filp)
804 case 3: 804 case 3:
805 filp->f_op = &null_fops; 805 filp->f_op = &null_fops;
806 break; 806 break;
807#if defined(CONFIG_ISA) || !defined(__mc68000__) 807#if (defined(CONFIG_ISA) || !defined(__mc68000__)) && (!defined(CONFIG_PPC_ISERIES) || defined(CONFIG_PCI))
808 case 4: 808 case 4:
809 filp->f_op = &port_fops; 809 filp->f_op = &port_fops;
810 break; 810 break;
@@ -846,7 +846,7 @@ static const struct {
846 {1, "mem", S_IRUSR | S_IWUSR | S_IRGRP, &mem_fops}, 846 {1, "mem", S_IRUSR | S_IWUSR | S_IRGRP, &mem_fops},
847 {2, "kmem", S_IRUSR | S_IWUSR | S_IRGRP, &kmem_fops}, 847 {2, "kmem", S_IRUSR | S_IWUSR | S_IRGRP, &kmem_fops},
848 {3, "null", S_IRUGO | S_IWUGO, &null_fops}, 848 {3, "null", S_IRUGO | S_IWUGO, &null_fops},
849#if defined(CONFIG_ISA) || !defined(__mc68000__) 849#if (defined(CONFIG_ISA) || !defined(__mc68000__)) && (!defined(CONFIG_PPC_ISERIES) || defined(CONFIG_PCI))
850 {4, "port", S_IRUSR | S_IWUSR | S_IRGRP, &port_fops}, 850 {4, "port", S_IRUSR | S_IWUSR | S_IRGRP, &port_fops},
851#endif 851#endif
852 {5, "zero", S_IRUGO | S_IWUGO, &zero_fops}, 852 {5, "zero", S_IRUGO | S_IWUGO, &zero_fops},
diff --git a/drivers/char/vr41xx_giu.c b/drivers/char/vr41xx_giu.c
new file mode 100644
index 000000000000..683278bc5241
--- /dev/null
+++ b/drivers/char/vr41xx_giu.c
@@ -0,0 +1,743 @@
1/*
2 * Driver for NEC VR4100 series General-purpose I/O Unit.
3 *
4 * Copyright (C) 2002 MontaVista Software Inc.
5 * Author: Yoichi Yuasa <yyuasa@mvista.com or source@mvista.com>
6 * Copyright (C) 2003-2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
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#include <linux/device.h>
23#include <linux/errno.h>
24#include <linux/fs.h>
25#include <linux/init.h>
26#include <linux/irq.h>
27#include <linux/interrupt.h>
28#include <linux/kernel.h>
29#include <linux/module.h>
30#include <linux/spinlock.h>
31#include <linux/types.h>
32
33#include <asm/cpu.h>
34#include <asm/io.h>
35#include <asm/vr41xx/giu.h>
36#include <asm/vr41xx/vr41xx.h>
37
38MODULE_AUTHOR("Yoichi Yuasa <yuasa@hh.iij4u.or.jp>");
39MODULE_DESCRIPTION("NEC VR4100 series General-purpose I/O Unit driver");
40MODULE_LICENSE("GPL");
41
42static int major; /* default is dynamic major device number */
43module_param(major, int, 0);
44MODULE_PARM_DESC(major, "Major device number");
45
46#define GIU_TYPE1_START 0x0b000100UL
47#define GIU_TYPE1_SIZE 0x20UL
48
49#define GIU_TYPE2_START 0x0f000140UL
50#define GIU_TYPE2_SIZE 0x20UL
51
52#define GIU_TYPE3_START 0x0f000140UL
53#define GIU_TYPE3_SIZE 0x28UL
54
55#define GIU_PULLUPDOWN_START 0x0b0002e0UL
56#define GIU_PULLUPDOWN_SIZE 0x04UL
57
58#define GIUIOSELL 0x00
59#define GIUIOSELH 0x02
60#define GIUPIODL 0x04
61#define GIUPIODH 0x06
62#define GIUINTSTATL 0x08
63#define GIUINTSTATH 0x0a
64#define GIUINTENL 0x0c
65#define GIUINTENH 0x0e
66#define GIUINTTYPL 0x10
67#define GIUINTTYPH 0x12
68#define GIUINTALSELL 0x14
69#define GIUINTALSELH 0x16
70#define GIUINTHTSELL 0x18
71#define GIUINTHTSELH 0x1a
72#define GIUPODATL 0x1c
73#define GIUPODATEN 0x1c
74#define GIUPODATH 0x1e
75 #define PIOEN0 0x0100
76 #define PIOEN1 0x0200
77#define GIUPODAT 0x1e
78#define GIUFEDGEINHL 0x20
79#define GIUFEDGEINHH 0x22
80#define GIUREDGEINHL 0x24
81#define GIUREDGEINHH 0x26
82
83#define GIUUSEUPDN 0x1e0
84#define GIUTERMUPDN 0x1e2
85
86#define GPIO_HAS_PULLUPDOWN_IO 0x0001
87#define GPIO_HAS_OUTPUT_ENABLE 0x0002
88#define GPIO_HAS_INTERRUPT_EDGE_SELECT 0x0100
89
90static spinlock_t giu_lock;
91static struct resource *giu_resource1;
92static struct resource *giu_resource2;
93static unsigned long giu_flags;
94static unsigned int giu_nr_pins;
95
96static void __iomem *giu_base;
97
98#define giu_read(offset) readw(giu_base + (offset))
99#define giu_write(offset, value) writew((value), giu_base + (offset))
100
101#define GPIO_PIN_OF_IRQ(irq) ((irq) - GIU_IRQ_BASE)
102#define GIUINT_HIGH_OFFSET 16
103#define GIUINT_HIGH_MAX 32
104
105static inline uint16_t giu_set(uint16_t offset, uint16_t set)
106{
107 uint16_t data;
108
109 data = giu_read(offset);
110 data |= set;
111 giu_write(offset, data);
112
113 return data;
114}
115
116static inline uint16_t giu_clear(uint16_t offset, uint16_t clear)
117{
118 uint16_t data;
119
120 data = giu_read(offset);
121 data &= ~clear;
122 giu_write(offset, data);
123
124 return data;
125}
126
127static unsigned int startup_giuint_low_irq(unsigned int irq)
128{
129 unsigned int pin;
130
131 pin = GPIO_PIN_OF_IRQ(irq);
132 giu_write(GIUINTSTATL, 1 << pin);
133 giu_set(GIUINTENL, 1 << pin);
134
135 return 0;
136}
137
138static void shutdown_giuint_low_irq(unsigned int irq)
139{
140 giu_clear(GIUINTENL, 1 << GPIO_PIN_OF_IRQ(irq));
141}
142
143static void enable_giuint_low_irq(unsigned int irq)
144{
145 giu_set(GIUINTENL, 1 << GPIO_PIN_OF_IRQ(irq));
146}
147
148#define disable_giuint_low_irq shutdown_giuint_low_irq
149
150static void ack_giuint_low_irq(unsigned int irq)
151{
152 unsigned int pin;
153
154 pin = GPIO_PIN_OF_IRQ(irq);
155 giu_clear(GIUINTENL, 1 << pin);
156 giu_write(GIUINTSTATL, 1 << pin);
157}
158
159static void end_giuint_low_irq(unsigned int irq)
160{
161 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
162 giu_set(GIUINTENL, 1 << GPIO_PIN_OF_IRQ(irq));
163}
164
165static struct hw_interrupt_type giuint_low_irq_type = {
166 .typename = "GIUINTL",
167 .startup = startup_giuint_low_irq,
168 .shutdown = shutdown_giuint_low_irq,
169 .enable = enable_giuint_low_irq,
170 .disable = disable_giuint_low_irq,
171 .ack = ack_giuint_low_irq,
172 .end = end_giuint_low_irq,
173};
174
175static unsigned int startup_giuint_high_irq(unsigned int irq)
176{
177 unsigned int pin;
178
179 pin = GPIO_PIN_OF_IRQ(irq) - GIUINT_HIGH_OFFSET;
180 giu_write(GIUINTSTATH, 1 << pin);
181 giu_set(GIUINTENH, 1 << pin);
182
183 return 0;
184}
185
186static void shutdown_giuint_high_irq(unsigned int irq)
187{
188 giu_clear(GIUINTENH, 1 << (GPIO_PIN_OF_IRQ(irq) - GIUINT_HIGH_OFFSET));
189}
190
191static void enable_giuint_high_irq(unsigned int irq)
192{
193 giu_set(GIUINTENH, 1 << (GPIO_PIN_OF_IRQ(irq) - GIUINT_HIGH_OFFSET));
194}
195
196#define disable_giuint_high_irq shutdown_giuint_high_irq
197
198static void ack_giuint_high_irq(unsigned int irq)
199{
200 unsigned int pin;
201
202 pin = GPIO_PIN_OF_IRQ(irq) - GIUINT_HIGH_OFFSET;
203 giu_clear(GIUINTENH, 1 << pin);
204 giu_write(GIUINTSTATH, 1 << pin);
205}
206
207static void end_giuint_high_irq(unsigned int irq)
208{
209 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
210 giu_set(GIUINTENH, 1 << (GPIO_PIN_OF_IRQ(irq) - GIUINT_HIGH_OFFSET));
211}
212
213static struct hw_interrupt_type giuint_high_irq_type = {
214 .typename = "GIUINTH",
215 .startup = startup_giuint_high_irq,
216 .shutdown = shutdown_giuint_high_irq,
217 .enable = enable_giuint_high_irq,
218 .disable = disable_giuint_high_irq,
219 .ack = ack_giuint_high_irq,
220 .end = end_giuint_high_irq,
221};
222
223static int giu_get_irq(unsigned int irq, struct pt_regs *regs)
224{
225 uint16_t pendl, pendh, maskl, maskh;
226 int i;
227
228 pendl = giu_read(GIUINTSTATL);
229 pendh = giu_read(GIUINTSTATH);
230 maskl = giu_read(GIUINTENL);
231 maskh = giu_read(GIUINTENH);
232
233 maskl &= pendl;
234 maskh &= pendh;
235
236 if (maskl) {
237 for (i = 0; i < 16; i++) {
238 if (maskl & (1 << i))
239 return GIU_IRQ(i);
240 }
241 } else if (maskh) {
242 for (i = 0; i < 16; i++) {
243 if (maskh & (1 << i))
244 return GIU_IRQ(i + GIUINT_HIGH_OFFSET);
245 }
246 }
247
248 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
249 maskl, pendl, maskh, pendh);
250
251 atomic_inc(&irq_err_count);
252
253 return -EINVAL;
254}
255
256void vr41xx_set_irq_trigger(unsigned int pin, irq_trigger_t trigger, irq_signal_t signal)
257{
258 uint16_t mask;
259
260 if (pin < GIUINT_HIGH_OFFSET) {
261 mask = 1 << pin;
262 if (trigger != IRQ_TRIGGER_LEVEL) {
263 giu_set(GIUINTTYPL, mask);
264 if (signal == IRQ_SIGNAL_HOLD)
265 giu_set(GIUINTHTSELL, mask);
266 else
267 giu_clear(GIUINTHTSELL, mask);
268 if (current_cpu_data.cputype == CPU_VR4133) {
269 switch (trigger) {
270 case IRQ_TRIGGER_EDGE_FALLING:
271 giu_set(GIUFEDGEINHL, mask);
272 giu_clear(GIUREDGEINHL, mask);
273 break;
274 case IRQ_TRIGGER_EDGE_RISING:
275 giu_clear(GIUFEDGEINHL, mask);
276 giu_set(GIUREDGEINHL, mask);
277 break;
278 default:
279 giu_set(GIUFEDGEINHL, mask);
280 giu_set(GIUREDGEINHL, mask);
281 break;
282 }
283 }
284 } else {
285 giu_clear(GIUINTTYPL, mask);
286 giu_clear(GIUINTHTSELL, mask);
287 }
288 giu_write(GIUINTSTATL, mask);
289 } else if (pin < GIUINT_HIGH_MAX) {
290 mask = 1 << (pin - GIUINT_HIGH_OFFSET);
291 if (trigger != IRQ_TRIGGER_LEVEL) {
292 giu_set(GIUINTTYPH, mask);
293 if (signal == IRQ_SIGNAL_HOLD)
294 giu_set(GIUINTHTSELH, mask);
295 else
296 giu_clear(GIUINTHTSELH, mask);
297 if (current_cpu_data.cputype == CPU_VR4133) {
298 switch (trigger) {
299 case IRQ_TRIGGER_EDGE_FALLING:
300 giu_set(GIUFEDGEINHH, mask);
301 giu_clear(GIUREDGEINHH, mask);
302 break;
303 case IRQ_TRIGGER_EDGE_RISING:
304 giu_clear(GIUFEDGEINHH, mask);
305 giu_set(GIUREDGEINHH, mask);
306 break;
307 default:
308 giu_set(GIUFEDGEINHH, mask);
309 giu_set(GIUREDGEINHH, mask);
310 break;
311 }
312 }
313 } else {
314 giu_clear(GIUINTTYPH, mask);
315 giu_clear(GIUINTHTSELH, mask);
316 }
317 giu_write(GIUINTSTATH, mask);
318 }
319}
320
321EXPORT_SYMBOL_GPL(vr41xx_set_irq_trigger);
322
323void vr41xx_set_irq_level(unsigned int pin, irq_level_t level)
324{
325 uint16_t mask;
326
327 if (pin < GIUINT_HIGH_OFFSET) {
328 mask = 1 << pin;
329 if (level == IRQ_LEVEL_HIGH)
330 giu_set(GIUINTALSELL, mask);
331 else
332 giu_clear(GIUINTALSELL, mask);
333 giu_write(GIUINTSTATL, mask);
334 } else if (pin < GIUINT_HIGH_MAX) {
335 mask = 1 << (pin - GIUINT_HIGH_OFFSET);
336 if (level == IRQ_LEVEL_HIGH)
337 giu_set(GIUINTALSELH, mask);
338 else
339 giu_clear(GIUINTALSELH, mask);
340 giu_write(GIUINTSTATH, mask);
341 }
342}
343
344EXPORT_SYMBOL_GPL(vr41xx_set_irq_level);
345
346gpio_data_t vr41xx_gpio_get_pin(unsigned int pin)
347{
348 uint16_t reg, mask;
349
350 if (pin >= giu_nr_pins)
351 return GPIO_DATA_INVAL;
352
353 if (pin < 16) {
354 reg = giu_read(GIUPIODL);
355 mask = (uint16_t)1 << pin;
356 } else if (pin < 32) {
357 reg = giu_read(GIUPIODH);
358 mask = (uint16_t)1 << (pin - 16);
359 } else if (pin < 48) {
360 reg = giu_read(GIUPODATL);
361 mask = (uint16_t)1 << (pin - 32);
362 } else {
363 reg = giu_read(GIUPODATH);
364 mask = (uint16_t)1 << (pin - 48);
365 }
366
367 if (reg & mask)
368 return GPIO_DATA_HIGH;
369
370 return GPIO_DATA_LOW;
371}
372
373EXPORT_SYMBOL_GPL(vr41xx_gpio_get_pin);
374
375int vr41xx_gpio_set_pin(unsigned int pin, gpio_data_t data)
376{
377 uint16_t offset, mask, reg;
378 unsigned long flags;
379
380 if (pin >= giu_nr_pins)
381 return -EINVAL;
382
383 if (pin < 16) {
384 offset = GIUPIODL;
385 mask = (uint16_t)1 << pin;
386 } else if (pin < 32) {
387 offset = GIUPIODH;
388 mask = (uint16_t)1 << (pin - 16);
389 } else if (pin < 48) {
390 offset = GIUPODATL;
391 mask = (uint16_t)1 << (pin - 32);
392 } else {
393 offset = GIUPODATH;
394 mask = (uint16_t)1 << (pin - 48);
395 }
396
397 spin_lock_irqsave(&giu_lock, flags);
398
399 reg = giu_read(offset);
400 if (data == GPIO_DATA_HIGH)
401 reg |= mask;
402 else
403 reg &= ~mask;
404 giu_write(offset, reg);
405
406 spin_unlock_irqrestore(&giu_lock, flags);
407
408 return 0;
409}
410
411EXPORT_SYMBOL_GPL(vr41xx_gpio_set_pin);
412
413int vr41xx_gpio_set_direction(unsigned int pin, gpio_direction_t dir)
414{
415 uint16_t offset, mask, reg;
416 unsigned long flags;
417
418 if (pin >= giu_nr_pins)
419 return -EINVAL;
420
421 if (pin < 16) {
422 offset = GIUIOSELL;
423 mask = (uint16_t)1 << pin;
424 } else if (pin < 32) {
425 offset = GIUIOSELH;
426 mask = (uint16_t)1 << (pin - 16);
427 } else {
428 if (giu_flags & GPIO_HAS_OUTPUT_ENABLE) {
429 offset = GIUPODATEN;
430 mask = (uint16_t)1 << (pin - 32);
431 } else {
432 switch (pin) {
433 case 48:
434 offset = GIUPODATH;
435 mask = PIOEN0;
436 break;
437 case 49:
438 offset = GIUPODATH;
439 mask = PIOEN1;
440 break;
441 default:
442 return -EINVAL;
443 }
444 }
445 }
446
447 spin_lock_irqsave(&giu_lock, flags);
448
449 reg = giu_read(offset);
450 if (dir == GPIO_OUTPUT)
451 reg |= mask;
452 else
453 reg &= ~mask;
454 giu_write(offset, reg);
455
456 spin_unlock_irqrestore(&giu_lock, flags);
457
458 return 0;
459}
460
461EXPORT_SYMBOL_GPL(vr41xx_gpio_set_direction);
462
463int vr41xx_gpio_pullupdown(unsigned int pin, gpio_pull_t pull)
464{
465 uint16_t reg, mask;
466 unsigned long flags;
467
468 if ((giu_flags & GPIO_HAS_PULLUPDOWN_IO) != GPIO_HAS_PULLUPDOWN_IO)
469 return -EPERM;
470
471 if (pin >= 15)
472 return -EINVAL;
473
474 mask = (uint16_t)1 << pin;
475
476 spin_lock_irqsave(&giu_lock, flags);
477
478 if (pull == GPIO_PULL_UP || pull == GPIO_PULL_DOWN) {
479 reg = giu_read(GIUTERMUPDN);
480 if (pull == GPIO_PULL_UP)
481 reg |= mask;
482 else
483 reg &= ~mask;
484 giu_write(GIUTERMUPDN, reg);
485
486 reg = giu_read(GIUUSEUPDN);
487 reg |= mask;
488 giu_write(GIUUSEUPDN, reg);
489 } else {
490 reg = giu_read(GIUUSEUPDN);
491 reg &= ~mask;
492 giu_write(GIUUSEUPDN, reg);
493 }
494
495 spin_unlock_irqrestore(&giu_lock, flags);
496
497 return 0;
498}
499
500EXPORT_SYMBOL_GPL(vr41xx_gpio_pullupdown);
501
502static ssize_t gpio_read(struct file *file, char __user *buf, size_t len,
503 loff_t *ppos)
504{
505 unsigned int pin;
506 char value = '0';
507
508 pin = iminor(file->f_dentry->d_inode);
509 if (pin >= giu_nr_pins)
510 return -EBADF;
511
512 if (vr41xx_gpio_get_pin(pin) == GPIO_DATA_HIGH)
513 value = '1';
514
515 if (len <= 0)
516 return -EFAULT;
517
518 if (put_user(value, buf))
519 return -EFAULT;
520
521 return 1;
522}
523
524static ssize_t gpio_write(struct file *file, const char __user *data,
525 size_t len, loff_t *ppos)
526{
527 unsigned int pin;
528 size_t i;
529 char c;
530 int retval = 0;
531
532 pin = iminor(file->f_dentry->d_inode);
533 if (pin >= giu_nr_pins)
534 return -EBADF;
535
536 for (i = 0; i < len; i++) {
537 if (get_user(c, data + i))
538 return -EFAULT;
539
540 switch (c) {
541 case '0':
542 retval = vr41xx_gpio_set_pin(pin, GPIO_DATA_LOW);
543 break;
544 case '1':
545 retval = vr41xx_gpio_set_pin(pin, GPIO_DATA_HIGH);
546 break;
547 case 'D':
548 printk(KERN_INFO "GPIO%d: pull down\n", pin);
549 retval = vr41xx_gpio_pullupdown(pin, GPIO_PULL_DOWN);
550 break;
551 case 'd':
552 printk(KERN_INFO "GPIO%d: pull up/down disable\n", pin);
553 retval = vr41xx_gpio_pullupdown(pin, GPIO_PULL_DISABLE);
554 break;
555 case 'I':
556 printk(KERN_INFO "GPIO%d: input\n", pin);
557 retval = vr41xx_gpio_set_direction(pin, GPIO_INPUT);
558 break;
559 case 'O':
560 printk(KERN_INFO "GPIO%d: output\n", pin);
561 retval = vr41xx_gpio_set_direction(pin, GPIO_OUTPUT);
562 break;
563 case 'o':
564 printk(KERN_INFO "GPIO%d: output disable\n", pin);
565 retval = vr41xx_gpio_set_direction(pin, GPIO_OUTPUT_DISABLE);
566 break;
567 case 'P':
568 printk(KERN_INFO "GPIO%d: pull up\n", pin);
569 retval = vr41xx_gpio_pullupdown(pin, GPIO_PULL_UP);
570 break;
571 case 'p':
572 printk(KERN_INFO "GPIO%d: pull up/down disable\n", pin);
573 retval = vr41xx_gpio_pullupdown(pin, GPIO_PULL_DISABLE);
574 break;
575 default:
576 break;
577 }
578
579 if (retval < 0)
580 break;
581 }
582
583 return i;
584}
585
586static int gpio_open(struct inode *inode, struct file *file)
587{
588 unsigned int pin;
589
590 pin = iminor(inode);
591 if (pin >= giu_nr_pins)
592 return -EBADF;
593
594 return nonseekable_open(inode, file);
595}
596
597static int gpio_release(struct inode *inode, struct file *file)
598{
599 unsigned int pin;
600
601 pin = iminor(inode);
602 if (pin >= giu_nr_pins)
603 return -EBADF;
604
605 return 0;
606}
607
608static struct file_operations gpio_fops = {
609 .owner = THIS_MODULE,
610 .read = gpio_read,
611 .write = gpio_write,
612 .open = gpio_open,
613 .release = gpio_release,
614};
615
616static int giu_probe(struct device *dev)
617{
618 unsigned long start, size, flags = 0;
619 unsigned int nr_pins = 0;
620 struct resource *res1, *res2 = NULL;
621 void *base;
622 int retval, i;
623
624 switch (current_cpu_data.cputype) {
625 case CPU_VR4111:
626 case CPU_VR4121:
627 start = GIU_TYPE1_START;
628 size = GIU_TYPE1_SIZE;
629 flags = GPIO_HAS_PULLUPDOWN_IO;
630 nr_pins = 50;
631 break;
632 case CPU_VR4122:
633 case CPU_VR4131:
634 start = GIU_TYPE2_START;
635 size = GIU_TYPE2_SIZE;
636 nr_pins = 36;
637 break;
638 case CPU_VR4133:
639 start = GIU_TYPE3_START;
640 size = GIU_TYPE3_SIZE;
641 flags = GPIO_HAS_INTERRUPT_EDGE_SELECT;
642 nr_pins = 48;
643 break;
644 default:
645 return -ENODEV;
646 }
647
648 res1 = request_mem_region(start, size, "GIU");
649 if (res1 == NULL)
650 return -EBUSY;
651
652 base = ioremap(start, size);
653 if (base == NULL) {
654 release_resource(res1);
655 return -ENOMEM;
656 }
657
658 if (flags & GPIO_HAS_PULLUPDOWN_IO) {
659 res2 = request_mem_region(GIU_PULLUPDOWN_START, GIU_PULLUPDOWN_SIZE, "GIU");
660 if (res2 == NULL) {
661 iounmap(base);
662 release_resource(res1);
663 return -EBUSY;
664 }
665 }
666
667 retval = register_chrdev(major, "GIU", &gpio_fops);
668 if (retval < 0) {
669 iounmap(base);
670 release_resource(res1);
671 release_resource(res2);
672 return retval;
673 }
674
675 if (major == 0) {
676 major = retval;
677 printk(KERN_INFO "GIU: major number %d\n", major);
678 }
679
680 spin_lock_init(&giu_lock);
681 giu_base = base;
682 giu_resource1 = res1;
683 giu_resource2 = res2;
684 giu_flags = flags;
685 giu_nr_pins = nr_pins;
686
687 giu_write(GIUINTENL, 0);
688 giu_write(GIUINTENH, 0);
689
690 for (i = GIU_IRQ_BASE; i <= GIU_IRQ_LAST; i++) {
691 if (i < GIU_IRQ(GIUINT_HIGH_OFFSET))
692 irq_desc[i].handler = &giuint_low_irq_type;
693 else
694 irq_desc[i].handler = &giuint_high_irq_type;
695 }
696
697 return cascade_irq(GIUINT_IRQ, giu_get_irq);
698}
699
700static int giu_remove(struct device *dev)
701{
702 iounmap(giu_base);
703
704 release_resource(giu_resource1);
705 if (giu_flags & GPIO_HAS_PULLUPDOWN_IO)
706 release_resource(giu_resource2);
707
708 return 0;
709}
710
711static struct platform_device *giu_platform_device;
712
713static struct device_driver giu_device_driver = {
714 .name = "GIU",
715 .bus = &platform_bus_type,
716 .probe = giu_probe,
717 .remove = giu_remove,
718};
719
720static int __devinit vr41xx_giu_init(void)
721{
722 int retval;
723
724 giu_platform_device = platform_device_register_simple("GIU", -1, NULL, 0);
725 if (IS_ERR(giu_platform_device))
726 return PTR_ERR(giu_platform_device);
727
728 retval = driver_register(&giu_device_driver);
729 if (retval < 0)
730 platform_device_unregister(giu_platform_device);
731
732 return retval;
733}
734
735static void __devexit vr41xx_giu_exit(void)
736{
737 driver_unregister(&giu_device_driver);
738
739 platform_device_unregister(giu_platform_device);
740}
741
742module_init(vr41xx_giu_init);
743module_exit(vr41xx_giu_exit);
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c
index c3d912cbbbc3..cc3a952401f2 100644
--- a/drivers/i2c/algos/i2c-algo-pca.c
+++ b/drivers/i2c/algos/i2c-algo-pca.c
@@ -49,7 +49,7 @@ static int i2c_debug=0;
49/* 49/*
50 * Generate a start condition on the i2c bus. 50 * Generate a start condition on the i2c bus.
51 * 51 *
52 * returns after the start condition has occured 52 * returns after the start condition has occurred
53 */ 53 */
54static void pca_start(struct i2c_algo_pca_data *adap) 54static void pca_start(struct i2c_algo_pca_data *adap)
55{ 55{
@@ -62,9 +62,9 @@ static void pca_start(struct i2c_algo_pca_data *adap)
62} 62}
63 63
64/* 64/*
65 * Generate a repeated start condition on the i2c bus 65 * Generate a repeated start condition on the i2c bus
66 * 66 *
67 * return after the repeated start condition has occured 67 * return after the repeated start condition has occurred
68 */ 68 */
69static void pca_repeated_start(struct i2c_algo_pca_data *adap) 69static void pca_repeated_start(struct i2c_algo_pca_data *adap)
70{ 70{
@@ -82,7 +82,7 @@ static void pca_repeated_start(struct i2c_algo_pca_data *adap)
82 * returns after the stop condition has been generated 82 * returns after the stop condition has been generated
83 * 83 *
84 * STOPs do not generate an interrupt or set the SI flag, since the 84 * STOPs do not generate an interrupt or set the SI flag, since the
85 * part returns the the idle state (0xf8). Hence we don't need to 85 * part returns the idle state (0xf8). Hence we don't need to
86 * pca_wait here. 86 * pca_wait here.
87 */ 87 */
88static void pca_stop(struct i2c_algo_pca_data *adap) 88static void pca_stop(struct i2c_algo_pca_data *adap)
diff --git a/drivers/i2c/algos/i2c-algo-sibyte.c b/drivers/i2c/algos/i2c-algo-sibyte.c
index 35789bb7126a..f2785499237b 100644
--- a/drivers/i2c/algos/i2c-algo-sibyte.c
+++ b/drivers/i2c/algos/i2c-algo-sibyte.c
@@ -24,7 +24,6 @@
24 24
25/* Ported for SiByte SOCs by Broadcom Corporation. */ 25/* Ported for SiByte SOCs by Broadcom Corporation. */
26 26
27#include <linux/config.h>
28#include <linux/kernel.h> 27#include <linux/kernel.h>
29#include <linux/module.h> 28#include <linux/module.h>
30#include <linux/init.h> 29#include <linux/init.h>
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index a0018de3bef4..916ba5e40a96 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -7,7 +7,7 @@ menu "I2C Hardware Bus support"
7 7
8config I2C_ALI1535 8config I2C_ALI1535
9 tristate "ALI 1535" 9 tristate "ALI 1535"
10 depends on I2C && PCI && EXPERIMENTAL 10 depends on I2C && PCI
11 help 11 help
12 If you say yes to this option, support will be included for the SMB 12 If you say yes to this option, support will be included for the SMB
13 Host controller on Acer Labs Inc. (ALI) M1535 South Bridges. The SMB 13 Host controller on Acer Labs Inc. (ALI) M1535 South Bridges. The SMB
@@ -31,7 +31,7 @@ config I2C_ALI1563
31 31
32config I2C_ALI15X3 32config I2C_ALI15X3
33 tristate "ALI 15x3" 33 tristate "ALI 15x3"
34 depends on I2C && PCI && EXPERIMENTAL 34 depends on I2C && PCI
35 help 35 help
36 If you say yes to this option, support will be included for the 36 If you say yes to this option, support will be included for the
37 Acer Labs Inc. (ALI) M1514 and M1543 motherboard I2C interfaces. 37 Acer Labs Inc. (ALI) M1514 and M1543 motherboard I2C interfaces.
@@ -41,7 +41,7 @@ config I2C_ALI15X3
41 41
42config I2C_AMD756 42config I2C_AMD756
43 tristate "AMD 756/766/768/8111 and nVidia nForce" 43 tristate "AMD 756/766/768/8111 and nVidia nForce"
44 depends on I2C && PCI && EXPERIMENTAL 44 depends on I2C && PCI
45 help 45 help
46 If you say yes to this option, support will be included for the AMD 46 If you say yes to this option, support will be included for the AMD
47 756/766/768 mainboard I2C interfaces. The driver also includes 47 756/766/768 mainboard I2C interfaces. The driver also includes
@@ -66,7 +66,7 @@ config I2C_AMD756_S4882
66 66
67config I2C_AMD8111 67config I2C_AMD8111
68 tristate "AMD 8111" 68 tristate "AMD 8111"
69 depends on I2C && PCI && EXPERIMENTAL 69 depends on I2C && PCI
70 help 70 help
71 If you say yes to this option, support will be included for the 71 If you say yes to this option, support will be included for the
72 second (SMBus 2.0) AMD 8111 mainboard I2C interface. 72 second (SMBus 2.0) AMD 8111 mainboard I2C interface.
@@ -109,7 +109,7 @@ config I2C_HYDRA
109 109
110config I2C_I801 110config I2C_I801
111 tristate "Intel 82801 (ICH)" 111 tristate "Intel 82801 (ICH)"
112 depends on I2C && PCI && EXPERIMENTAL 112 depends on I2C && PCI
113 help 113 help
114 If you say yes to this option, support will be included for the Intel 114 If you say yes to this option, support will be included for the Intel
115 801 family of mainboard I2C interfaces. Specifically, the following 115 801 family of mainboard I2C interfaces. Specifically, the following
@@ -130,7 +130,7 @@ config I2C_I801
130 130
131config I2C_I810 131config I2C_I810
132 tristate "Intel 810/815" 132 tristate "Intel 810/815"
133 depends on I2C && PCI && EXPERIMENTAL 133 depends on I2C && PCI
134 select I2C_ALGOBIT 134 select I2C_ALGOBIT
135 help 135 help
136 If you say yes to this option, support will be included for the Intel 136 If you say yes to this option, support will be included for the Intel
@@ -183,7 +183,7 @@ config I2C_IOP3XX
183 183
184config I2C_ISA 184config I2C_ISA
185 tristate "ISA Bus support" 185 tristate "ISA Bus support"
186 depends on I2C && EXPERIMENTAL 186 depends on I2C
187 help 187 help
188 If you say yes to this option, support will be included for i2c 188 If you say yes to this option, support will be included for i2c
189 interfaces that are on the ISA bus. 189 interfaces that are on the ISA bus.
@@ -248,12 +248,11 @@ config I2C_MPC
248 will be called i2c-mpc. 248 will be called i2c-mpc.
249 249
250config I2C_NFORCE2 250config I2C_NFORCE2
251 tristate "Nvidia Nforce2" 251 tristate "Nvidia nForce2, nForce3 and nForce4"
252 depends on I2C && PCI && EXPERIMENTAL 252 depends on I2C && PCI
253 help 253 help
254 If you say yes to this option, support will be included for the Nvidia 254 If you say yes to this option, support will be included for the Nvidia
255 Nforce2 family of mainboard I2C interfaces. 255 nForce2, nForce3 and nForce4 families of mainboard I2C interfaces.
256 This driver also supports the nForce3 Pro 150 MCP.
257 256
258 This driver can also be built as a module. If so, the module 257 This driver can also be built as a module. If so, the module
259 will be called i2c-nforce2. 258 will be called i2c-nforce2.
@@ -305,7 +304,7 @@ config I2C_PARPORT_LIGHT
305 304
306config I2C_PROSAVAGE 305config I2C_PROSAVAGE
307 tristate "S3/VIA (Pro)Savage" 306 tristate "S3/VIA (Pro)Savage"
308 depends on I2C && PCI && EXPERIMENTAL 307 depends on I2C && PCI
309 select I2C_ALGOBIT 308 select I2C_ALGOBIT
310 help 309 help
311 If you say yes to this option, support will be included for the 310 If you say yes to this option, support will be included for the
@@ -388,7 +387,7 @@ config SCx200_ACB
388 387
389config I2C_SIS5595 388config I2C_SIS5595
390 tristate "SiS 5595" 389 tristate "SiS 5595"
391 depends on I2C && PCI && EXPERIMENTAL 390 depends on I2C && PCI
392 help 391 help
393 If you say yes to this option, support will be included for the 392 If you say yes to this option, support will be included for the
394 SiS5595 SMBus (a subset of I2C) interface. 393 SiS5595 SMBus (a subset of I2C) interface.
@@ -398,7 +397,7 @@ config I2C_SIS5595
398 397
399config I2C_SIS630 398config I2C_SIS630
400 tristate "SiS 630/730" 399 tristate "SiS 630/730"
401 depends on I2C && PCI && EXPERIMENTAL 400 depends on I2C && PCI
402 help 401 help
403 If you say yes to this option, support will be included for the 402 If you say yes to this option, support will be included for the
404 SiS630 and SiS730 SMBus (a subset of I2C) interface. 403 SiS630 and SiS730 SMBus (a subset of I2C) interface.
@@ -408,7 +407,7 @@ config I2C_SIS630
408 407
409config I2C_SIS96X 408config I2C_SIS96X
410 tristate "SiS 96x" 409 tristate "SiS 96x"
411 depends on I2C && PCI && EXPERIMENTAL 410 depends on I2C && PCI
412 help 411 help
413 If you say yes to this option, support will be included for the SiS 412 If you say yes to this option, support will be included for the SiS
414 96x SMBus (a subset of I2C) interfaces. Specifically, the following 413 96x SMBus (a subset of I2C) interfaces. Specifically, the following
@@ -419,6 +418,7 @@ config I2C_SIS96X
419 648/961 418 648/961
420 650/961 419 650/961
421 735 420 735
421 745
422 422
423 This driver can also be built as a module. If so, the module 423 This driver can also be built as a module. If so, the module
424 will be called i2c-sis96x. 424 will be called i2c-sis96x.
@@ -449,7 +449,7 @@ config I2C_VIA
449 449
450config I2C_VIAPRO 450config I2C_VIAPRO
451 tristate "VIA 82C596/82C686/823x" 451 tristate "VIA 82C596/82C686/823x"
452 depends on I2C && PCI && EXPERIMENTAL 452 depends on I2C && PCI
453 help 453 help
454 If you say yes to this option, support will be included for the VIA 454 If you say yes to this option, support will be included for the VIA
455 82C596/82C686/823x I2C interfaces. Specifically, the following 455 82C596/82C686/823x I2C interfaces. Specifically, the following
@@ -467,7 +467,7 @@ config I2C_VIAPRO
467 467
468config I2C_VOODOO3 468config I2C_VOODOO3
469 tristate "Voodoo 3" 469 tristate "Voodoo 3"
470 depends on I2C && PCI && EXPERIMENTAL 470 depends on I2C && PCI
471 select I2C_ALGOBIT 471 select I2C_ALGOBIT
472 help 472 help
473 If you say yes to this option, support will be included for the 473 If you say yes to this option, support will be included for the
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
index b00cd4098221..f634a0780cf0 100644
--- a/drivers/i2c/busses/i2c-ali1535.c
+++ b/drivers/i2c/busses/i2c-ali1535.c
@@ -53,7 +53,6 @@
53 53
54/* Note: we assume there can only be one ALI1535, with one SMBus interface */ 54/* Note: we assume there can only be one ALI1535, with one SMBus interface */
55 55
56#include <linux/config.h>
57#include <linux/module.h> 56#include <linux/module.h>
58#include <linux/pci.h> 57#include <linux/pci.h>
59#include <linux/kernel.h> 58#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
index 5bd6a4a77c1e..0f781a1a3323 100644
--- a/drivers/i2c/busses/i2c-ali15x3.c
+++ b/drivers/i2c/busses/i2c-ali15x3.c
@@ -60,7 +60,6 @@
60 60
61/* Note: we assume there can only be one ALI15X3, with one SMBus interface */ 61/* Note: we assume there can only be one ALI15X3, with one SMBus interface */
62 62
63#include <linux/config.h>
64#include <linux/module.h> 63#include <linux/module.h>
65#include <linux/pci.h> 64#include <linux/pci.h>
66#include <linux/kernel.h> 65#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
index eca5ed3738b8..6347ebc6fb53 100644
--- a/drivers/i2c/busses/i2c-amd756.c
+++ b/drivers/i2c/busses/i2c-amd756.c
@@ -37,7 +37,6 @@
37 Note: we assume there can only be one device, with one SMBus interface. 37 Note: we assume there can only be one device, with one SMBus interface.
38*/ 38*/
39 39
40#include <linux/config.h>
41#include <linux/module.h> 40#include <linux/module.h>
42#include <linux/pci.h> 41#include <linux/pci.h>
43#include <linux/kernel.h> 42#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c
index af22b401a38b..d6644481d2a0 100644
--- a/drivers/i2c/busses/i2c-amd8111.c
+++ b/drivers/i2c/busses/i2c-amd8111.c
@@ -8,7 +8,6 @@
8 * the Free Software Foundation version 2. 8 * the Free Software Foundation version 2.
9 */ 9 */
10 10
11#include <linux/config.h>
12#include <linux/module.h> 11#include <linux/module.h>
13#include <linux/pci.h> 12#include <linux/pci.h>
14#include <linux/kernel.h> 13#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-au1550.c b/drivers/i2c/busses/i2c-au1550.c
index 75831a20b0bd..a7ff112e49bf 100644
--- a/drivers/i2c/busses/i2c-au1550.c
+++ b/drivers/i2c/busses/i2c-au1550.c
@@ -27,7 +27,6 @@
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 */ 28 */
29 29
30#include <linux/config.h>
31#include <linux/delay.h> 30#include <linux/delay.h>
32#include <linux/kernel.h> 31#include <linux/kernel.h>
33#include <linux/module.h> 32#include <linux/module.h>
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c
index 0a7720000a0c..6930b660e508 100644
--- a/drivers/i2c/busses/i2c-elektor.c
+++ b/drivers/i2c/busses/i2c-elektor.c
@@ -25,7 +25,6 @@
25/* Partialy rewriten by Oleg I. Vdovikin for mmapped support of 25/* Partialy rewriten by Oleg I. Vdovikin for mmapped support of
26 for Alpha Processor Inc. UP-2000(+) boards */ 26 for Alpha Processor Inc. UP-2000(+) boards */
27 27
28#include <linux/config.h>
29#include <linux/kernel.h> 28#include <linux/kernel.h>
30#include <linux/ioport.h> 29#include <linux/ioport.h>
31#include <linux/module.h> 30#include <linux/module.h>
diff --git a/drivers/i2c/busses/i2c-frodo.c b/drivers/i2c/busses/i2c-frodo.c
index e093829a0bf7..b6f52f5a4138 100644
--- a/drivers/i2c/busses/i2c-frodo.c
+++ b/drivers/i2c/busses/i2c-frodo.c
@@ -12,7 +12,6 @@
12 * version 2 as published by the Free Software Foundation. 12 * version 2 as published by the Free Software Foundation.
13 */ 13 */
14 14
15#include <linux/config.h>
16#include <linux/module.h> 15#include <linux/module.h>
17#include <linux/kernel.h> 16#include <linux/kernel.h>
18#include <linux/init.h> 17#include <linux/init.h>
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 59c238c42e8c..45e6efb1dcd1 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -41,7 +41,6 @@
41 41
42/* Note: we assume there can only be one I801, with one SMBus interface */ 42/* Note: we assume there can only be one I801, with one SMBus interface */
43 43
44#include <linux/config.h>
45#include <linux/module.h> 44#include <linux/module.h>
46#include <linux/pci.h> 45#include <linux/pci.h>
47#include <linux/kernel.h> 46#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-i810.c b/drivers/i2c/busses/i2c-i810.c
index ef358bd9c3da..0ff7016e0629 100644
--- a/drivers/i2c/busses/i2c-i810.c
+++ b/drivers/i2c/busses/i2c-i810.c
@@ -34,7 +34,6 @@
34 i815 1132 34 i815 1132
35*/ 35*/
36 36
37#include <linux/config.h>
38#include <linux/kernel.h> 37#include <linux/kernel.h>
39#include <linux/module.h> 38#include <linux/module.h>
40#include <linux/init.h> 39#include <linux/init.h>
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index bb885215c08d..93ca36dc777e 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -695,7 +695,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){
695 695
696 dev->irq = iic_force_poll ? -1 : ocp->def->irq; 696 dev->irq = iic_force_poll ? -1 : ocp->def->irq;
697 if (dev->irq >= 0){ 697 if (dev->irq >= 0){
698 /* Disable interrupts until we finish intialization, 698 /* Disable interrupts until we finish initialization,
699 assumes level-sensitive IRQ setup... 699 assumes level-sensitive IRQ setup...
700 */ 700 */
701 iic_interrupt_mode(dev, 0); 701 iic_interrupt_mode(dev, 0);
diff --git a/drivers/i2c/busses/i2c-ibm_iic.h b/drivers/i2c/busses/i2c-ibm_iic.h
index d819a955d890..2b3219d00e92 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.h
+++ b/drivers/i2c/busses/i2c-ibm_iic.h
@@ -22,7 +22,6 @@
22#ifndef __I2C_IBM_IIC_H_ 22#ifndef __I2C_IBM_IIC_H_
23#define __I2C_IBM_IIC_H_ 23#define __I2C_IBM_IIC_H_
24 24
25#include <linux/config.h>
26#include <linux/i2c.h> 25#include <linux/i2c.h>
27 26
28struct iic_regs { 27struct iic_regs {
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c
index c961ba4cfb32..6b682e903f09 100644
--- a/drivers/i2c/busses/i2c-iop3xx.c
+++ b/drivers/i2c/busses/i2c-iop3xx.c
@@ -85,7 +85,7 @@ iop3xx_i2c_enable(struct i2c_algo_iop3xx_data *iop3xx_adap)
85 u32 cr = IOP3XX_ICR_GCD | IOP3XX_ICR_SCLEN | IOP3XX_ICR_UE; 85 u32 cr = IOP3XX_ICR_GCD | IOP3XX_ICR_SCLEN | IOP3XX_ICR_UE;
86 86
87 /* 87 /*
88 * Everytime unit enable is asserted, GPOD needs to be cleared 88 * Every time unit enable is asserted, GPOD needs to be cleared
89 * on IOP321 to avoid data corruption on the bus. 89 * on IOP321 to avoid data corruption on the bus.
90 */ 90 */
91#ifdef CONFIG_ARCH_IOP321 91#ifdef CONFIG_ARCH_IOP321
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c
index 0f54a2a0afa5..00e7f7157b75 100644
--- a/drivers/i2c/busses/i2c-isa.c
+++ b/drivers/i2c/busses/i2c-isa.c
@@ -24,7 +24,6 @@
24 the SMBus and the ISA bus very much easier. See lm78.c for an example 24 the SMBus and the ISA bus very much easier. See lm78.c for an example
25 of this. */ 25 of this. */
26 26
27#include <linux/config.h>
28#include <linux/init.h> 27#include <linux/init.h>
29#include <linux/module.h> 28#include <linux/module.h>
30#include <linux/kernel.h> 29#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-ite.c b/drivers/i2c/busses/i2c-ite.c
index 702e3def1b81..5f5d2944808b 100644
--- a/drivers/i2c/busses/i2c-ite.c
+++ b/drivers/i2c/busses/i2c-ite.c
@@ -33,7 +33,6 @@
33/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even 33/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
34 Frodo Looijaard <frodol@dds.nl> */ 34 Frodo Looijaard <frodol@dds.nl> */
35 35
36#include <linux/config.h>
37#include <linux/kernel.h> 36#include <linux/kernel.h>
38#include <linux/ioport.h> 37#include <linux/ioport.h>
39#include <linux/module.h> 38#include <linux/module.h>
diff --git a/drivers/i2c/busses/i2c-ixp2000.c b/drivers/i2c/busses/i2c-ixp2000.c
index 21cd54d02302..ec943cad2314 100644
--- a/drivers/i2c/busses/i2c-ixp2000.c
+++ b/drivers/i2c/busses/i2c-ixp2000.c
@@ -26,11 +26,6 @@
26 * 'enabled' to drive the GPIOs. 26 * 'enabled' to drive the GPIOs.
27 */ 27 */
28 28
29#include <linux/config.h>
30#ifdef CONFIG_I2C_DEBUG_BUS
31#define DEBUG 1
32#endif
33
34#include <linux/kernel.h> 29#include <linux/kernel.h>
35#include <linux/init.h> 30#include <linux/init.h>
36#include <linux/device.h> 31#include <linux/device.h>
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c
index 8c55eafc3a09..f6f5ca31fdba 100644
--- a/drivers/i2c/busses/i2c-ixp4xx.c
+++ b/drivers/i2c/busses/i2c-ixp4xx.c
@@ -26,11 +26,6 @@
26 * that is passed as the platform_data to this driver. 26 * that is passed as the platform_data to this driver.
27 */ 27 */
28 28
29#include <linux/config.h>
30#ifdef CONFIG_I2C_DEBUG_BUS
31#define DEBUG 1
32#endif
33
34#include <linux/kernel.h> 29#include <linux/kernel.h>
35#include <linux/init.h> 30#include <linux/init.h>
36#include <linux/device.h> 31#include <linux/device.h>
diff --git a/drivers/i2c/busses/i2c-keywest.c b/drivers/i2c/busses/i2c-keywest.c
index 867d443e7133..363e545fc01f 100644
--- a/drivers/i2c/busses/i2c-keywest.c
+++ b/drivers/i2c/busses/i2c-keywest.c
@@ -46,7 +46,6 @@
46 sound driver to be happy 46 sound driver to be happy
47*/ 47*/
48 48
49#include <linux/config.h>
50#include <linux/module.h> 49#include <linux/module.h>
51#include <linux/kernel.h> 50#include <linux/kernel.h>
52#include <linux/ioport.h> 51#include <linux/ioport.h>
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 6f33496d31c3..d41ca31dbcb2 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -325,7 +325,7 @@ static int __devinit mpc_i2c_probe(struct ocp_device *ocp)
325 if (i2c->irq != OCP_IRQ_NA) 325 if (i2c->irq != OCP_IRQ_NA)
326 { 326 {
327 if ((result = request_irq(ocp->def->irq, mpc_i2c_isr, 327 if ((result = request_irq(ocp->def->irq, mpc_i2c_isr,
328 0, "i2c-mpc", i2c)) < 0) { 328 SA_SHIRQ, "i2c-mpc", i2c)) < 0) {
329 printk(KERN_ERR 329 printk(KERN_ERR
330 "i2c-mpc - failed to attach interrupt\n"); 330 "i2c-mpc - failed to attach interrupt\n");
331 goto fail_irq; 331 goto fail_irq;
@@ -333,6 +333,9 @@ static int __devinit mpc_i2c_probe(struct ocp_device *ocp)
333 } else 333 } else
334 i2c->irq = 0; 334 i2c->irq = 0;
335 335
336 mpc_i2c_setclock(i2c);
337 ocp_set_drvdata(ocp, i2c);
338
336 i2c->adap = mpc_ops; 339 i2c->adap = mpc_ops;
337 i2c_set_adapdata(&i2c->adap, i2c); 340 i2c_set_adapdata(&i2c->adap, i2c);
338 341
@@ -341,8 +344,6 @@ static int __devinit mpc_i2c_probe(struct ocp_device *ocp)
341 goto fail_add; 344 goto fail_add;
342 } 345 }
343 346
344 mpc_i2c_setclock(i2c);
345 ocp_set_drvdata(ocp, i2c);
346 return result; 347 return result;
347 348
348 fail_add: 349 fail_add:
@@ -358,8 +359,8 @@ static int __devinit mpc_i2c_probe(struct ocp_device *ocp)
358static void __devexit mpc_i2c_remove(struct ocp_device *ocp) 359static void __devexit mpc_i2c_remove(struct ocp_device *ocp)
359{ 360{
360 struct mpc_i2c *i2c = ocp_get_drvdata(ocp); 361 struct mpc_i2c *i2c = ocp_get_drvdata(ocp);
361 ocp_set_drvdata(ocp, NULL);
362 i2c_del_adapter(&i2c->adap); 362 i2c_del_adapter(&i2c->adap);
363 ocp_set_drvdata(ocp, NULL);
363 364
364 if (ocp->def->irq != OCP_IRQ_NA) 365 if (ocp->def->irq != OCP_IRQ_NA)
365 free_irq(i2c->irq, i2c); 366 free_irq(i2c->irq, i2c);
@@ -424,12 +425,15 @@ static int fsl_i2c_probe(struct device *device)
424 425
425 if (i2c->irq != 0) 426 if (i2c->irq != 0)
426 if ((result = request_irq(i2c->irq, mpc_i2c_isr, 427 if ((result = request_irq(i2c->irq, mpc_i2c_isr,
427 0, "fsl-i2c", i2c)) < 0) { 428 SA_SHIRQ, "i2c-mpc", i2c)) < 0) {
428 printk(KERN_ERR 429 printk(KERN_ERR
429 "i2c-mpc - failed to attach interrupt\n"); 430 "i2c-mpc - failed to attach interrupt\n");
430 goto fail_irq; 431 goto fail_irq;
431 } 432 }
432 433
434 mpc_i2c_setclock(i2c);
435 dev_set_drvdata(device, i2c);
436
433 i2c->adap = mpc_ops; 437 i2c->adap = mpc_ops;
434 i2c_set_adapdata(&i2c->adap, i2c); 438 i2c_set_adapdata(&i2c->adap, i2c);
435 i2c->adap.dev.parent = &pdev->dev; 439 i2c->adap.dev.parent = &pdev->dev;
@@ -438,8 +442,6 @@ static int fsl_i2c_probe(struct device *device)
438 goto fail_add; 442 goto fail_add;
439 } 443 }
440 444
441 mpc_i2c_setclock(i2c);
442 dev_set_drvdata(device, i2c);
443 return result; 445 return result;
444 446
445 fail_add: 447 fail_add:
@@ -456,8 +458,8 @@ static int fsl_i2c_remove(struct device *device)
456{ 458{
457 struct mpc_i2c *i2c = dev_get_drvdata(device); 459 struct mpc_i2c *i2c = dev_get_drvdata(device);
458 460
459 dev_set_drvdata(device, NULL);
460 i2c_del_adapter(&i2c->adap); 461 i2c_del_adapter(&i2c->adap);
462 dev_set_drvdata(device, NULL);
461 463
462 if (i2c->irq != 0) 464 if (i2c->irq != 0)
463 free_irq(i2c->irq, i2c); 465 free_irq(i2c->irq, i2c);
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index 6d13127c8c4e..74eb89aa9350 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -37,7 +37,6 @@
37 37
38/* Note: we assume there can only be one nForce2, with two SMBus interfaces */ 38/* Note: we assume there can only be one nForce2, with two SMBus interfaces */
39 39
40#include <linux/config.h>
41#include <linux/module.h> 40#include <linux/module.h>
42#include <linux/pci.h> 41#include <linux/pci.h>
43#include <linux/kernel.h> 42#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-parport-light.c b/drivers/i2c/busses/i2c-parport-light.c
index cb5e722301d8..3e5eba9fcacb 100644
--- a/drivers/i2c/busses/i2c-parport-light.c
+++ b/drivers/i2c/busses/i2c-parport-light.c
@@ -24,7 +24,6 @@
24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * ------------------------------------------------------------------------ */ 25 * ------------------------------------------------------------------------ */
26 26
27#include <linux/config.h>
28#include <linux/kernel.h> 27#include <linux/kernel.h>
29#include <linux/module.h> 28#include <linux/module.h>
30#include <linux/init.h> 29#include <linux/init.h>
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c
index e9560bab51c4..71a2502fe069 100644
--- a/drivers/i2c/busses/i2c-parport.c
+++ b/drivers/i2c/busses/i2c-parport.c
@@ -24,7 +24,6 @@
24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * ------------------------------------------------------------------------ */ 25 * ------------------------------------------------------------------------ */
26 26
27#include <linux/config.h>
28#include <linux/kernel.h> 27#include <linux/kernel.h>
29#include <linux/module.h> 28#include <linux/module.h>
30#include <linux/init.h> 29#include <linux/init.h>
@@ -131,7 +130,7 @@ static int parport_getsda(void *data)
131/* Encapsulate the functions above in the correct structure. 130/* Encapsulate the functions above in the correct structure.
132 Note that this is only a template, from which the real structures are 131 Note that this is only a template, from which the real structures are
133 copied. The attaching code will set getscl to NULL for adapters that 132 copied. The attaching code will set getscl to NULL for adapters that
134 cannot read SCL back, and will also make the the data field point to 133 cannot read SCL back, and will also make the data field point to
135 the parallel port structure. */ 134 the parallel port structure. */
136static struct i2c_algo_bit_data parport_algo_data = { 135static struct i2c_algo_bit_data parport_algo_data = {
137 .setsda = parport_setsda, 136 .setsda = parport_setsda,
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c
index 9c611134db9c..d9b4ddbad7e0 100644
--- a/drivers/i2c/busses/i2c-pca-isa.c
+++ b/drivers/i2c/busses/i2c-pca-isa.c
@@ -17,7 +17,6 @@
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */ 18 */
19 19
20#include <linux/config.h>
21#include <linux/kernel.h> 20#include <linux/kernel.h>
22#include <linux/ioport.h> 21#include <linux/ioport.h>
23#include <linux/module.h> 22#include <linux/module.h>
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 646381b6b3bf..1f80ba9da6f1 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -28,7 +28,6 @@
28 Note: we assume there can only be one device, with one SMBus interface. 28 Note: we assume there can only be one device, with one SMBus interface.
29*/ 29*/
30 30
31#include <linux/config.h>
32#include <linux/module.h> 31#include <linux/module.h>
33#include <linux/moduleparam.h> 32#include <linux/moduleparam.h>
34#include <linux/pci.h> 33#include <linux/pci.h>
diff --git a/drivers/i2c/busses/i2c-prosavage.c b/drivers/i2c/busses/i2c-prosavage.c
index 13d66289933b..83fd16d61ce5 100644
--- a/drivers/i2c/busses/i2c-prosavage.c
+++ b/drivers/i2c/busses/i2c-prosavage.c
@@ -54,7 +54,6 @@
54 * (Additional documentation needed :( 54 * (Additional documentation needed :(
55 */ 55 */
56 56
57#include <linux/config.h>
58#include <linux/module.h> 57#include <linux/module.h>
59#include <linux/init.h> 58#include <linux/init.h>
60#include <linux/pci.h> 59#include <linux/pci.h>
diff --git a/drivers/i2c/busses/i2c-rpx.c b/drivers/i2c/busses/i2c-rpx.c
index 9497b1b6852f..0ebec3c1a54e 100644
--- a/drivers/i2c/busses/i2c-rpx.c
+++ b/drivers/i2c/busses/i2c-rpx.c
@@ -11,7 +11,6 @@
11 * changed to eliminate RPXLite references. 11 * changed to eliminate RPXLite references.
12 */ 12 */
13 13
14#include <linux/config.h>
15#include <linux/kernel.h> 14#include <linux/kernel.h>
16#include <linux/module.h> 15#include <linux/module.h>
17#include <linux/init.h> 16#include <linux/init.h>
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index fcfa51c1436b..a3b38257cc3d 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -20,6 +20,7 @@
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21*/ 21*/
22 22
23#include <linux/config.h>
23#include <linux/kernel.h> 24#include <linux/kernel.h>
24#include <linux/module.h> 25#include <linux/module.h>
25 26
@@ -533,7 +534,7 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int
533/* s3c24xx_i2c_xfer 534/* s3c24xx_i2c_xfer
534 * 535 *
535 * first port of call from the i2c bus code when an message needs 536 * first port of call from the i2c bus code when an message needs
536 * transfering across the i2c bus. 537 * transferring across the i2c bus.
537*/ 538*/
538 539
539static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, 540static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
diff --git a/drivers/i2c/busses/i2c-savage4.c b/drivers/i2c/busses/i2c-savage4.c
index 092d0323c6c6..0c8518298e4d 100644
--- a/drivers/i2c/busses/i2c-savage4.c
+++ b/drivers/i2c/busses/i2c-savage4.c
@@ -29,7 +29,6 @@
29 it easier to add later. 29 it easier to add later.
30*/ 30*/
31 31
32#include <linux/config.h>
33#include <linux/kernel.h> 32#include <linux/kernel.h>
34#include <linux/module.h> 33#include <linux/module.h>
35#include <linux/init.h> 34#include <linux/init.h>
diff --git a/drivers/i2c/busses/i2c-sibyte.c b/drivers/i2c/busses/i2c-sibyte.c
index e5dd90bdb04a..1c99536b673b 100644
--- a/drivers/i2c/busses/i2c-sibyte.c
+++ b/drivers/i2c/busses/i2c-sibyte.c
@@ -17,7 +17,6 @@
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */ 18 */
19 19
20#include <linux/config.h>
21#include <linux/module.h> 20#include <linux/module.h>
22#include <linux/i2c-algo-sibyte.h> 21#include <linux/i2c-algo-sibyte.h>
23#include <asm/sibyte/sb1250_regs.h> 22#include <asm/sibyte/sb1250_regs.h>
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
index 425733b019b6..2b5911cfb7b5 100644
--- a/drivers/i2c/busses/i2c-sis5595.c
+++ b/drivers/i2c/busses/i2c-sis5595.c
@@ -55,7 +55,6 @@
55 * Add adapter resets 55 * Add adapter resets
56 */ 56 */
57 57
58#include <linux/config.h>
59#include <linux/kernel.h> 58#include <linux/kernel.h>
60#include <linux/module.h> 59#include <linux/module.h>
61#include <linux/delay.h> 60#include <linux/delay.h>
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c
index 58df63df1540..f58455e7689e 100644
--- a/drivers/i2c/busses/i2c-sis630.c
+++ b/drivers/i2c/busses/i2c-sis630.c
@@ -48,7 +48,6 @@
48 Note: we assume there can only be one device, with one SMBus interface. 48 Note: we assume there can only be one device, with one SMBus interface.
49*/ 49*/
50 50
51#include <linux/config.h>
52#include <linux/kernel.h> 51#include <linux/kernel.h>
53#include <linux/module.h> 52#include <linux/module.h>
54#include <linux/delay.h> 53#include <linux/delay.h>
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c
index 3cac6d43bce5..6484792e23a1 100644
--- a/drivers/i2c/busses/i2c-sis96x.c
+++ b/drivers/i2c/busses/i2c-sis96x.c
@@ -32,7 +32,6 @@
32 We assume there can only be one SiS96x with one SMBus interface. 32 We assume there can only be one SiS96x with one SMBus interface.
33*/ 33*/
34 34
35#include <linux/config.h>
36#include <linux/module.h> 35#include <linux/module.h>
37#include <linux/pci.h> 36#include <linux/pci.h>
38#include <linux/kernel.h> 37#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-stub.c b/drivers/i2c/busses/i2c-stub.c
index 19c805ead4d8..00d94e886955 100644
--- a/drivers/i2c/busses/i2c-stub.c
+++ b/drivers/i2c/busses/i2c-stub.c
@@ -21,7 +21,6 @@
21 21
22#define DEBUG 1 22#define DEBUG 1
23 23
24#include <linux/config.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <linux/module.h> 25#include <linux/module.h>
27#include <linux/kernel.h> 26#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c
index 2cbc4cd22366..040b8abeabba 100644
--- a/drivers/i2c/busses/i2c-via.c
+++ b/drivers/i2c/busses/i2c-via.c
@@ -21,7 +21,6 @@
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22*/ 22*/
23 23
24#include <linux/config.h>
25#include <linux/kernel.h> 24#include <linux/kernel.h>
26#include <linux/module.h> 25#include <linux/module.h>
27#include <linux/pci.h> 26#include <linux/pci.h>
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
index 0bb60a636e16..6b5008005c6f 100644
--- a/drivers/i2c/busses/i2c-viapro.c
+++ b/drivers/i2c/busses/i2c-viapro.c
@@ -33,7 +33,6 @@
33 Note: we assume there can only be one device, with one SMBus interface. 33 Note: we assume there can only be one device, with one SMBus interface.
34*/ 34*/
35 35
36#include <linux/config.h>
37#include <linux/module.h> 36#include <linux/module.h>
38#include <linux/delay.h> 37#include <linux/delay.h>
39#include <linux/pci.h> 38#include <linux/pci.h>
diff --git a/drivers/i2c/busses/i2c-voodoo3.c b/drivers/i2c/busses/i2c-voodoo3.c
index 3edf0e34155e..b675773b0cc1 100644
--- a/drivers/i2c/busses/i2c-voodoo3.c
+++ b/drivers/i2c/busses/i2c-voodoo3.c
@@ -27,7 +27,6 @@
27/* This interfaces to the I2C bus of the Voodoo3 to gain access to 27/* This interfaces to the I2C bus of the Voodoo3 to gain access to
28 the BT869 and possibly other I2C devices. */ 28 the BT869 and possibly other I2C devices. */
29 29
30#include <linux/config.h>
31#include <linux/kernel.h> 30#include <linux/kernel.h>
32#include <linux/module.h> 31#include <linux/module.h>
33#include <linux/init.h> 32#include <linux/init.h>
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index 1c4159a93623..a18bdd9aa7ba 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -24,7 +24,6 @@
24 24
25*/ 25*/
26 26
27#include <linux/config.h>
28#include <linux/module.h> 27#include <linux/module.h>
29#include <linux/errno.h> 28#include <linux/errno.h>
30#include <linux/kernel.h> 29#include <linux/kernel.h>
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index 74d23cfce2a3..a0982da09803 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -1,5 +1,5 @@
1# 1#
2# I2C Sensor device configuration 2# I2C Sensor and "other" chip configuration
3# 3#
4 4
5menu "Hardware Sensors Chip support" 5menu "Hardware Sensors Chip support"
@@ -11,7 +11,7 @@ config I2C_SENSOR
11 11
12config SENSORS_ADM1021 12config SENSORS_ADM1021
13 tristate "Analog Devices ADM1021 and compatibles" 13 tristate "Analog Devices ADM1021 and compatibles"
14 depends on I2C && EXPERIMENTAL 14 depends on I2C
15 select I2C_SENSOR 15 select I2C_SENSOR
16 help 16 help
17 If you say yes here you get support for Analog Devices ADM1021 17 If you say yes here you get support for Analog Devices ADM1021
@@ -29,6 +29,7 @@ config SENSORS_ADM1025
29 help 29 help
30 If you say yes here you get support for Analog Devices ADM1025 30 If you say yes here you get support for Analog Devices ADM1025
31 and Philips NE1619 sensor chips. 31 and Philips NE1619 sensor chips.
32
32 This driver can also be built as a module. If so, the module 33 This driver can also be built as a module. If so, the module
33 will be called adm1025. 34 will be called adm1025.
34 35
@@ -38,6 +39,8 @@ config SENSORS_ADM1026
38 select I2C_SENSOR 39 select I2C_SENSOR
39 help 40 help
40 If you say yes here you get support for Analog Devices ADM1026 41 If you say yes here you get support for Analog Devices ADM1026
42 sensor chip.
43
41 This driver can also be built as a module. If so, the module 44 This driver can also be built as a module. If so, the module
42 will be called adm1026. 45 will be called adm1026.
43 46
@@ -48,9 +51,21 @@ config SENSORS_ADM1031
48 help 51 help
49 If you say yes here you get support for Analog Devices ADM1031 52 If you say yes here you get support for Analog Devices ADM1031
50 and ADM1030 sensor chips. 53 and ADM1030 sensor chips.
54
51 This driver can also be built as a module. If so, the module 55 This driver can also be built as a module. If so, the module
52 will be called adm1031. 56 will be called adm1031.
53 57
58config SENSORS_ADM9240
59 tristate "Analog Devices ADM9240 and compatibles"
60 depends on I2C && EXPERIMENTAL
61 select I2C_SENSOR
62 help
63 If you say yes here you get support for Analog Devices ADM9240,
64 Dallas DS1780, National Semiconductor LM81 sensor chips.
65
66 This driver can also be built as a module. If so, the module
67 will be called adm9240.
68
54config SENSORS_ASB100 69config SENSORS_ASB100
55 tristate "Asus ASB100 Bach" 70 tristate "Asus ASB100 Bach"
56 depends on I2C && EXPERIMENTAL 71 depends on I2C && EXPERIMENTAL
@@ -62,6 +77,19 @@ config SENSORS_ASB100
62 This driver can also be built as a module. If so, the module 77 This driver can also be built as a module. If so, the module
63 will be called asb100. 78 will be called asb100.
64 79
80config SENSORS_ATXP1
81 tristate "Attansic ATXP1 VID controller"
82 depends on I2C && EXPERIMENTAL
83 help
84 If you say yes here you get support for the Attansic ATXP1 VID
85 controller.
86
87 If your board have such a chip, you are able to control your CPU
88 core and other voltages.
89
90 This driver can also be built as a module. If so, the module
91 will be called atxp1.
92
65config SENSORS_DS1621 93config SENSORS_DS1621
66 tristate "Dallas Semiconductor DS1621 and DS1625" 94 tristate "Dallas Semiconductor DS1621 and DS1625"
67 depends on I2C && EXPERIMENTAL 95 depends on I2C && EXPERIMENTAL
@@ -97,7 +125,7 @@ config SENSORS_FSCPOS
97 125
98config SENSORS_GL518SM 126config SENSORS_GL518SM
99 tristate "Genesys Logic GL518SM" 127 tristate "Genesys Logic GL518SM"
100 depends on I2C && EXPERIMENTAL 128 depends on I2C
101 select I2C_SENSOR 129 select I2C_SENSOR
102 help 130 help
103 If you say yes here you get support for Genesys Logic GL518SM 131 If you say yes here you get support for Genesys Logic GL518SM
@@ -119,7 +147,7 @@ config SENSORS_GL520SM
119 147
120config SENSORS_IT87 148config SENSORS_IT87
121 tristate "ITE IT87xx and compatibles" 149 tristate "ITE IT87xx and compatibles"
122 depends on I2C && EXPERIMENTAL 150 depends on I2C
123 select I2C_SENSOR 151 select I2C_SENSOR
124 help 152 help
125 If you say yes here you get support for ITE IT87xx sensor chips 153 If you say yes here you get support for ITE IT87xx sensor chips
@@ -143,7 +171,7 @@ config SENSORS_LM63
143 171
144config SENSORS_LM75 172config SENSORS_LM75
145 tristate "National Semiconductor LM75 and compatibles" 173 tristate "National Semiconductor LM75 and compatibles"
146 depends on I2C && EXPERIMENTAL 174 depends on I2C
147 select I2C_SENSOR 175 select I2C_SENSOR
148 help 176 help
149 If you say yes here you get support for National Semiconductor LM75 177 If you say yes here you get support for National Semiconductor LM75
@@ -174,8 +202,7 @@ config SENSORS_LM78
174 select I2C_SENSOR 202 select I2C_SENSOR
175 help 203 help
176 If you say yes here you get support for National Semiconductor LM78, 204 If you say yes here you get support for National Semiconductor LM78,
177 LM78-J and LM79. This can also be built as a module which can be 205 LM78-J and LM79.
178 inserted and removed while the kernel is running.
179 206
180 This driver can also be built as a module. If so, the module 207 This driver can also be built as a module. If so, the module
181 will be called lm78. 208 will be called lm78.
@@ -208,7 +235,7 @@ config SENSORS_LM85
208 select I2C_SENSOR 235 select I2C_SENSOR
209 help 236 help
210 If you say yes here you get support for National Semiconductor LM85 237 If you say yes here you get support for National Semiconductor LM85
211 sensor chips and clones: ADT7463 and ADM1027. 238 sensor chips and clones: ADT7463, EMC6D100, EMC6D102 and ADM1027.
212 239
213 This driver can also be built as a module. If so, the module 240 This driver can also be built as a module. If so, the module
214 will be called lm85. 241 will be called lm85.
@@ -307,14 +334,14 @@ config SENSORS_SMSC47M1
307 help 334 help
308 If you say yes here you get support for the integrated fan 335 If you say yes here you get support for the integrated fan
309 monitoring and control capabilities of the SMSC LPC47B27x, 336 monitoring and control capabilities of the SMSC LPC47B27x,
310 LPC47M10x, LPC47M13x and LPC47M14x chips. 337 LPC47M10x, LPC47M13x, LPC47M14x, LPC47M15x and LPC47M192 chips.
311 338
312 This driver can also be built as a module. If so, the module 339 This driver can also be built as a module. If so, the module
313 will be called smsc47m1. 340 will be called smsc47m1.
314 341
315config SENSORS_VIA686A 342config SENSORS_VIA686A
316 tristate "VIA686A" 343 tristate "VIA686A"
317 depends on I2C && PCI && EXPERIMENTAL 344 depends on I2C && PCI
318 select I2C_SENSOR 345 select I2C_SENSOR
319 select I2C_ISA 346 select I2C_ISA
320 help 347 help
@@ -326,7 +353,7 @@ config SENSORS_VIA686A
326 353
327config SENSORS_W83781D 354config SENSORS_W83781D
328 tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" 355 tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F"
329 depends on I2C && EXPERIMENTAL 356 depends on I2C
330 select I2C_SENSOR 357 select I2C_SENSOR
331 help 358 help
332 If you say yes here you get support for the Winbond W8378x series 359 If you say yes here you get support for the Winbond W8378x series
@@ -360,22 +387,47 @@ config SENSORS_W83627HF
360 This driver can also be built as a module. If so, the module 387 This driver can also be built as a module. If so, the module
361 will be called w83627hf. 388 will be called w83627hf.
362 389
390config SENSORS_W83627EHF
391 tristate "Winbond W83627EHF"
392 depends on I2C && EXPERIMENTAL
393 select I2C_SENSOR
394 select I2C_ISA
395 help
396 If you say yes here you get preliminary support for the hardware
397 monitoring functionality of the Winbond W83627EHF Super-I/O chip.
398 Only fan and temperature inputs are supported at the moment, while
399 the chip does much more than that.
400
401 This driver can also be built as a module. If so, the module
402 will be called w83627ehf.
403
363endmenu 404endmenu
364 405
365menu "Other I2C Chip support" 406menu "Other I2C Chip support"
366 depends on I2C 407 depends on I2C
367 408
368config SENSORS_DS1337 409config SENSORS_DS1337
369 tristate "Dallas Semiconductor DS1337 Real Time Clock" 410 tristate "Dallas Semiconductor DS1337 and DS1339 Real Time Clock"
370 depends on I2C && EXPERIMENTAL 411 depends on I2C && EXPERIMENTAL
371 select I2C_SENSOR 412 select I2C_SENSOR
372 help 413 help
373 If you say yes here you get support for Dallas Semiconductor 414 If you say yes here you get support for Dallas Semiconductor
374 DS1337 real-time clock chips. 415 DS1337 and DS1339 real-time clock chips.
375 416
376 This driver can also be built as a module. If so, the module 417 This driver can also be built as a module. If so, the module
377 will be called ds1337. 418 will be called ds1337.
378 419
420config SENSORS_DS1374
421 tristate "Maxim/Dallas Semiconductor DS1374 Real Time Clock"
422 depends on I2C && EXPERIMENTAL
423 select I2C_SENSOR
424 help
425 If you say yes here you get support for Dallas Semiconductor
426 DS1374 real-time clock chips.
427
428 This driver can also be built as a module. If so, the module
429 will be called ds1374.
430
379config SENSORS_EEPROM 431config SENSORS_EEPROM
380 tristate "EEPROM reader" 432 tristate "EEPROM reader"
381 depends on I2C && EXPERIMENTAL 433 depends on I2C && EXPERIMENTAL
@@ -399,6 +451,16 @@ config SENSORS_PCF8574
399 This driver can also be built as a module. If so, the module 451 This driver can also be built as a module. If so, the module
400 will be called pcf8574. 452 will be called pcf8574.
401 453
454config SENSORS_PCA9539
455 tristate "Philips PCA9539 16-bit I/O port"
456 depends on I2C && EXPERIMENTAL
457 help
458 If you say yes here you get support for the Philips PCA9539
459 16-bit I/O port.
460
461 This driver can also be built as a module. If so, the module
462 will be called pca9539.
463
402config SENSORS_PCF8591 464config SENSORS_PCF8591
403 tristate "Philips PCF8591" 465 tristate "Philips PCF8591"
404 depends on I2C && EXPERIMENTAL 466 depends on I2C && EXPERIMENTAL
@@ -431,6 +493,23 @@ config ISP1301_OMAP
431 This driver can also be built as a module. If so, the module 493 This driver can also be built as a module. If so, the module
432 will be called isp1301_omap. 494 will be called isp1301_omap.
433 495
496# NOTE: This isn't really OMAP-specific, except for the current
497# interface location in <include/asm-arm/arch-omap/tps65010.h>
498# and having mostly OMAP-specific board support
499config TPS65010
500 tristate "TPS6501x Power Management chips"
501 depends on I2C && ARCH_OMAP
502 default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK
503 help
504 If you say yes here you get support for the TPS6501x series of
505 Power Management chips. These include voltage regulators,
506 lithium ion/polymer battery charging, and other features that
507 are often used in portable devices like cell phones and cameras.
508
509 This driver can also be built as a module. If so, the module
510 will be called tps65010.
511
512
434config SENSORS_M41T00 513config SENSORS_M41T00
435 tristate "ST M41T00 RTC chip" 514 tristate "ST M41T00 RTC chip"
436 depends on I2C && PPC32 515 depends on I2C && PPC32
@@ -440,4 +519,16 @@ config SENSORS_M41T00
440 This driver can also be built as a module. If so, the module 519 This driver can also be built as a module. If so, the module
441 will be called m41t00. 520 will be called m41t00.
442 521
522config SENSORS_MAX6875
523 tristate "MAXIM MAX6875 Power supply supervisor"
524 depends on I2C && EXPERIMENTAL
525 help
526 If you say yes here you get support for the MAX6875
527 EEPROM-Programmable, Hex/Quad, Power-Suppy Sequencers/Supervisors.
528
529 This provides a interface to program the EEPROM and reset the chip.
530
531 This driver can also be built as a module. If so, the module
532 will be called max6875.
533
443endmenu 534endmenu
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
index 65599161a172..b5e6d2f84f97 100644
--- a/drivers/i2c/chips/Makefile
+++ b/drivers/i2c/chips/Makefile
@@ -1,5 +1,5 @@
1# 1#
2# Makefile for the kernel hardware sensors chip drivers. 2# Makefile for sensor and "other" I2C chip drivers.
3# 3#
4 4
5# asb100, then w83781d go first, as they can override other drivers' addresses. 5# asb100, then w83781d go first, as they can override other drivers' addresses.
@@ -11,7 +11,10 @@ obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o
11obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o 11obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o
12obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o 12obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o
13obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o 13obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o
14obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o
15obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o
14obj-$(CONFIG_SENSORS_DS1337) += ds1337.o 16obj-$(CONFIG_SENSORS_DS1337) += ds1337.o
17obj-$(CONFIG_SENSORS_DS1374) += ds1374.o
15obj-$(CONFIG_SENSORS_DS1621) += ds1621.o 18obj-$(CONFIG_SENSORS_DS1621) += ds1621.o
16obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o 19obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o
17obj-$(CONFIG_SENSORS_FSCHER) += fscher.o 20obj-$(CONFIG_SENSORS_FSCHER) += fscher.o
@@ -30,8 +33,10 @@ obj-$(CONFIG_SENSORS_LM87) += lm87.o
30obj-$(CONFIG_SENSORS_LM90) += lm90.o 33obj-$(CONFIG_SENSORS_LM90) += lm90.o
31obj-$(CONFIG_SENSORS_LM92) += lm92.o 34obj-$(CONFIG_SENSORS_LM92) += lm92.o
32obj-$(CONFIG_SENSORS_MAX1619) += max1619.o 35obj-$(CONFIG_SENSORS_MAX1619) += max1619.o
36obj-$(CONFIG_SENSORS_MAX6875) += max6875.o
33obj-$(CONFIG_SENSORS_M41T00) += m41t00.o 37obj-$(CONFIG_SENSORS_M41T00) += m41t00.o
34obj-$(CONFIG_SENSORS_PC87360) += pc87360.o 38obj-$(CONFIG_SENSORS_PC87360) += pc87360.o
39obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o
35obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o 40obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o
36obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o 41obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
37obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o 42obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o
@@ -39,8 +44,11 @@ obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o
39obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o 44obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o
40obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o 45obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
41obj-$(CONFIG_SENSORS_VIA686A) += via686a.o 46obj-$(CONFIG_SENSORS_VIA686A) += via686a.o
47obj-$(CONFIG_SENSORS_W83627EHF) += w83627ehf.o
42obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o 48obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o
49
43obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o 50obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o
51obj-$(CONFIG_TPS65010) += tps65010.o
44 52
45ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) 53ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)
46EXTRA_CFLAGS += -DDEBUG 54EXTRA_CFLAGS += -DDEBUG
diff --git a/drivers/i2c/chips/adm1021.c b/drivers/i2c/chips/adm1021.c
index 9058c3956710..d2c774c32f45 100644
--- a/drivers/i2c/chips/adm1021.c
+++ b/drivers/i2c/chips/adm1021.c
@@ -19,7 +19,6 @@
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/ 20*/
21 21
22#include <linux/config.h>
23#include <linux/module.h> 22#include <linux/module.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/slab.h> 24#include <linux/slab.h>
@@ -103,8 +102,6 @@ struct adm1021_data {
103 u8 remote_temp_hyst; 102 u8 remote_temp_hyst;
104 u8 remote_temp_input; 103 u8 remote_temp_input;
105 u8 alarms; 104 u8 alarms;
106 /* special values for ADM1021 only */
107 u8 die_code;
108 /* Special values for ADM1023 only */ 105 /* Special values for ADM1023 only */
109 u8 remote_temp_prec; 106 u8 remote_temp_prec;
110 u8 remote_temp_os_prec; 107 u8 remote_temp_os_prec;
@@ -156,7 +153,6 @@ static ssize_t show_##value(struct device *dev, struct device_attribute *attr, c
156 return sprintf(buf, "%d\n", data->value); \ 153 return sprintf(buf, "%d\n", data->value); \
157} 154}
158show2(alarms); 155show2(alarms);
159show2(die_code);
160 156
161#define set(value, reg) \ 157#define set(value, reg) \
162static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ 158static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
@@ -183,7 +179,6 @@ static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_remote_temp_max, set_remot
183static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_remote_temp_hyst, set_remote_temp_hyst); 179static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_remote_temp_hyst, set_remote_temp_hyst);
184static DEVICE_ATTR(temp2_input, S_IRUGO, show_remote_temp_input, NULL); 180static DEVICE_ATTR(temp2_input, S_IRUGO, show_remote_temp_input, NULL);
185static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 181static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
186static DEVICE_ATTR(die_code, S_IRUGO, show_die_code, NULL);
187 182
188 183
189static int adm1021_attach_adapter(struct i2c_adapter *adapter) 184static int adm1021_attach_adapter(struct i2c_adapter *adapter)
@@ -307,8 +302,6 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
307 device_create_file(&new_client->dev, &dev_attr_temp2_min); 302 device_create_file(&new_client->dev, &dev_attr_temp2_min);
308 device_create_file(&new_client->dev, &dev_attr_temp2_input); 303 device_create_file(&new_client->dev, &dev_attr_temp2_input);
309 device_create_file(&new_client->dev, &dev_attr_alarms); 304 device_create_file(&new_client->dev, &dev_attr_alarms);
310 if (data->type == adm1021)
311 device_create_file(&new_client->dev, &dev_attr_die_code);
312 305
313 return 0; 306 return 0;
314 307
@@ -371,8 +364,6 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
371 data->remote_temp_max = adm1021_read_value(client, ADM1021_REG_REMOTE_TOS_R); 364 data->remote_temp_max = adm1021_read_value(client, ADM1021_REG_REMOTE_TOS_R);
372 data->remote_temp_hyst = adm1021_read_value(client, ADM1021_REG_REMOTE_THYST_R); 365 data->remote_temp_hyst = adm1021_read_value(client, ADM1021_REG_REMOTE_THYST_R);
373 data->alarms = adm1021_read_value(client, ADM1021_REG_STATUS) & 0x7c; 366 data->alarms = adm1021_read_value(client, ADM1021_REG_STATUS) & 0x7c;
374 if (data->type == adm1021)
375 data->die_code = adm1021_read_value(client, ADM1021_REG_DIE_CODE);
376 if (data->type == adm1023) { 367 if (data->type == adm1023) {
377 data->remote_temp_prec = adm1021_read_value(client, ADM1021_REG_REM_TEMP_PREC); 368 data->remote_temp_prec = adm1021_read_value(client, ADM1021_REG_REM_TEMP_PREC);
378 data->remote_temp_os_prec = adm1021_read_value(client, ADM1021_REG_REM_TOS_PREC); 369 data->remote_temp_os_prec = adm1021_read_value(client, ADM1021_REG_REM_TOS_PREC);
diff --git a/drivers/i2c/chips/adm1025.c b/drivers/i2c/chips/adm1025.c
index 111f0c86c933..e452d0daf906 100644
--- a/drivers/i2c/chips/adm1025.c
+++ b/drivers/i2c/chips/adm1025.c
@@ -45,7 +45,6 @@
45 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 45 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
46 */ 46 */
47 47
48#include <linux/config.h>
49#include <linux/module.h> 48#include <linux/module.h>
50#include <linux/init.h> 49#include <linux/init.h>
51#include <linux/slab.h> 50#include <linux/slab.h>
@@ -287,7 +286,9 @@ static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char
287 struct adm1025_data *data = adm1025_update_device(dev); 286 struct adm1025_data *data = adm1025_update_device(dev);
288 return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm)); 287 return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm));
289} 288}
289/* in1_ref is deprecated in favour of cpu0_vid, remove after 2005-11-11 */
290static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL); 290static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL);
291static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
291 292
292static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf) 293static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf)
293{ 294{
@@ -437,7 +438,9 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind)
437 device_create_file(&new_client->dev, &dev_attr_temp1_max); 438 device_create_file(&new_client->dev, &dev_attr_temp1_max);
438 device_create_file(&new_client->dev, &dev_attr_temp2_max); 439 device_create_file(&new_client->dev, &dev_attr_temp2_max);
439 device_create_file(&new_client->dev, &dev_attr_alarms); 440 device_create_file(&new_client->dev, &dev_attr_alarms);
441 /* in1_ref is deprecated, remove after 2005-11-11 */
440 device_create_file(&new_client->dev, &dev_attr_in1_ref); 442 device_create_file(&new_client->dev, &dev_attr_in1_ref);
443 device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
441 device_create_file(&new_client->dev, &dev_attr_vrm); 444 device_create_file(&new_client->dev, &dev_attr_vrm);
442 445
443 /* Pin 11 is either in4 (+12V) or VID4 */ 446 /* Pin 11 is either in4 (+12V) or VID4 */
diff --git a/drivers/i2c/chips/adm1026.c b/drivers/i2c/chips/adm1026.c
index b15fafe8f111..3c85fe150cd7 100644
--- a/drivers/i2c/chips/adm1026.c
+++ b/drivers/i2c/chips/adm1026.c
@@ -23,15 +23,14 @@
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24*/ 24*/
25 25
26#include <linux/config.h>
27#include <linux/module.h> 26#include <linux/module.h>
28#include <linux/init.h> 27#include <linux/init.h>
29#include <linux/slab.h> 28#include <linux/slab.h>
30#include <linux/jiffies.h> 29#include <linux/jiffies.h>
31#include <linux/i2c.h> 30#include <linux/i2c.h>
32#include <linux/i2c-sensor.h> 31#include <linux/i2c-sensor.h>
33#include <linux/i2c-sysfs.h>
34#include <linux/i2c-vid.h> 32#include <linux/i2c-vid.h>
33#include <linux/hwmon-sysfs.h>
35 34
36/* Addresses to scan */ 35/* Addresses to scan */
37static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; 36static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
@@ -1225,8 +1224,9 @@ static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, c
1225 struct adm1026_data *data = adm1026_update_device(dev); 1224 struct adm1026_data *data = adm1026_update_device(dev);
1226 return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm)); 1225 return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm));
1227} 1226}
1228 1227/* vid deprecated in favour of cpu0_vid, remove after 2005-11-11 */
1229static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL); 1228static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL);
1229static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL);
1230 1230
1231static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) 1231static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf)
1232{ 1232{
@@ -1666,7 +1666,9 @@ int adm1026_detect(struct i2c_adapter *adapter, int address,
1666 device_create_file(&new_client->dev, &dev_attr_temp1_crit_enable); 1666 device_create_file(&new_client->dev, &dev_attr_temp1_crit_enable);
1667 device_create_file(&new_client->dev, &dev_attr_temp2_crit_enable); 1667 device_create_file(&new_client->dev, &dev_attr_temp2_crit_enable);
1668 device_create_file(&new_client->dev, &dev_attr_temp3_crit_enable); 1668 device_create_file(&new_client->dev, &dev_attr_temp3_crit_enable);
1669 /* vid deprecated in favour of cpu0_vid, remove after 2005-11-11 */
1669 device_create_file(&new_client->dev, &dev_attr_vid); 1670 device_create_file(&new_client->dev, &dev_attr_vid);
1671 device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
1670 device_create_file(&new_client->dev, &dev_attr_vrm); 1672 device_create_file(&new_client->dev, &dev_attr_vrm);
1671 device_create_file(&new_client->dev, &dev_attr_alarms); 1673 device_create_file(&new_client->dev, &dev_attr_alarms);
1672 device_create_file(&new_client->dev, &dev_attr_alarm_mask); 1674 device_create_file(&new_client->dev, &dev_attr_alarm_mask);
diff --git a/drivers/i2c/chips/adm1031.c b/drivers/i2c/chips/adm1031.c
index 2163dba467c4..9168e983ca1d 100644
--- a/drivers/i2c/chips/adm1031.c
+++ b/drivers/i2c/chips/adm1031.c
@@ -440,7 +440,7 @@ pwm_reg(2);
440 440
441/* 441/*
442 * That function checks the cases where the fan reading is not 442 * That function checks the cases where the fan reading is not
443 * relevent. It is used to provide 0 as fan reading when the fan is 443 * relevant. It is used to provide 0 as fan reading when the fan is
444 * not supposed to run 444 * not supposed to run
445 */ 445 */
446static int trust_fan_readings(struct adm1031_data *data, int chan) 446static int trust_fan_readings(struct adm1031_data *data, int chan)
diff --git a/drivers/i2c/chips/adm9240.c b/drivers/i2c/chips/adm9240.c
new file mode 100644
index 000000000000..5c68e9c311aa
--- /dev/null
+++ b/drivers/i2c/chips/adm9240.c
@@ -0,0 +1,791 @@
1/*
2 * adm9240.c Part of lm_sensors, Linux kernel modules for hardware
3 * monitoring
4 *
5 * Copyright (C) 1999 Frodo Looijaard <frodol@dds.nl>
6 * Philip Edelbrock <phil@netroedge.com>
7 * Copyright (C) 2003 Michiel Rook <michiel@grendelproject.nl>
8 * Copyright (C) 2005 Grant Coady <gcoady@gmail.com> with valuable
9 * guidance from Jean Delvare
10 *
11 * Driver supports Analog Devices ADM9240
12 * Dallas Semiconductor DS1780
13 * National Semiconductor LM81
14 *
15 * ADM9240 is the reference, DS1780 and LM81 are register compatibles
16 *
17 * Voltage Six inputs are scaled by chip, VID also reported
18 * Temperature Chip temperature to 0.5'C, maximum and max_hysteris
19 * Fans 2 fans, low speed alarm, automatic fan clock divider
20 * Alarms 16-bit map of active alarms
21 * Analog Out 0..1250 mV output
22 *
23 * Chassis Intrusion: clear CI latch with 'echo 1 > chassis_clear'
24 *
25 * Test hardware: Intel SE440BX-2 desktop motherboard --Grant
26 *
27 * LM81 extended temp reading not implemented
28 *
29 * This program is free software; you can redistribute it and/or modify
30 * it under the terms of the GNU General Public License as published by
31 * the Free Software Foundation; either version 2 of the License, or
32 * (at your option) any later version.
33 *
34 * This program is distributed in the hope that it will be useful,
35 * but WITHOUT ANY WARRANTY; without even the implied warranty of
36 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37 * GNU General Public License for more details.
38 *
39 * You should have received a copy of the GNU General Public License
40 * along with this program; if not, write to the Free Software
41 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
42 */
43
44#include <linux/init.h>
45#include <linux/module.h>
46#include <linux/slab.h>
47#include <linux/i2c.h>
48#include <linux/i2c-sensor.h>
49#include <linux/i2c-vid.h>
50
51/* Addresses to scan */
52static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
53 I2C_CLIENT_END };
54
55static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
56
57/* Insmod parameters */
58SENSORS_INSMOD_3(adm9240, ds1780, lm81);
59
60/* ADM9240 registers */
61#define ADM9240_REG_MAN_ID 0x3e
62#define ADM9240_REG_DIE_REV 0x3f
63#define ADM9240_REG_CONFIG 0x40
64
65#define ADM9240_REG_IN(nr) (0x20 + (nr)) /* 0..5 */
66#define ADM9240_REG_IN_MAX(nr) (0x2b + (nr) * 2)
67#define ADM9240_REG_IN_MIN(nr) (0x2c + (nr) * 2)
68#define ADM9240_REG_FAN(nr) (0x28 + (nr)) /* 0..1 */
69#define ADM9240_REG_FAN_MIN(nr) (0x3b + (nr))
70#define ADM9240_REG_INT(nr) (0x41 + (nr))
71#define ADM9240_REG_INT_MASK(nr) (0x43 + (nr))
72#define ADM9240_REG_TEMP 0x27
73#define ADM9240_REG_TEMP_HIGH 0x39
74#define ADM9240_REG_TEMP_HYST 0x3a
75#define ADM9240_REG_ANALOG_OUT 0x19
76#define ADM9240_REG_CHASSIS_CLEAR 0x46
77#define ADM9240_REG_VID_FAN_DIV 0x47
78#define ADM9240_REG_I2C_ADDR 0x48
79#define ADM9240_REG_VID4 0x49
80#define ADM9240_REG_TEMP_CONF 0x4b
81
82/* generalised scaling with integer rounding */
83static inline int SCALE(long val, int mul, int div)
84{
85 if (val < 0)
86 return (val * mul - div / 2) / div;
87 else
88 return (val * mul + div / 2) / div;
89}
90
91/* adm9240 internally scales voltage measurements */
92static const u16 nom_mv[] = { 2500, 2700, 3300, 5000, 12000, 2700 };
93
94static inline unsigned int IN_FROM_REG(u8 reg, int n)
95{
96 return SCALE(reg, nom_mv[n], 192);
97}
98
99static inline u8 IN_TO_REG(unsigned long val, int n)
100{
101 return SENSORS_LIMIT(SCALE(val, 192, nom_mv[n]), 0, 255);
102}
103
104/* temperature range: -40..125, 127 disables temperature alarm */
105static inline s8 TEMP_TO_REG(long val)
106{
107 return SENSORS_LIMIT(SCALE(val, 1, 1000), -40, 127);
108}
109
110/* two fans, each with low fan speed limit */
111static inline unsigned int FAN_FROM_REG(u8 reg, u8 div)
112{
113 if (!reg) /* error */
114 return -1;
115
116 if (reg == 255)
117 return 0;
118
119 return SCALE(1350000, 1, reg * div);
120}
121
122/* analog out 0..1250mV */
123static inline u8 AOUT_TO_REG(unsigned long val)
124{
125 return SENSORS_LIMIT(SCALE(val, 255, 1250), 0, 255);
126}
127
128static inline unsigned int AOUT_FROM_REG(u8 reg)
129{
130 return SCALE(reg, 1250, 255);
131}
132
133static int adm9240_attach_adapter(struct i2c_adapter *adapter);
134static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind);
135static void adm9240_init_client(struct i2c_client *client);
136static int adm9240_detach_client(struct i2c_client *client);
137static struct adm9240_data *adm9240_update_device(struct device *dev);
138
139/* driver data */
140static struct i2c_driver adm9240_driver = {
141 .owner = THIS_MODULE,
142 .name = "adm9240",
143 .id = I2C_DRIVERID_ADM9240,
144 .flags = I2C_DF_NOTIFY,
145 .attach_adapter = adm9240_attach_adapter,
146 .detach_client = adm9240_detach_client,
147};
148
149/* per client data */
150struct adm9240_data {
151 enum chips type;
152 struct i2c_client client;
153 struct semaphore update_lock;
154 char valid;
155 unsigned long last_updated_measure;
156 unsigned long last_updated_config;
157
158 u8 in[6]; /* ro in0_input */
159 u8 in_max[6]; /* rw in0_max */
160 u8 in_min[6]; /* rw in0_min */
161 u8 fan[2]; /* ro fan1_input */
162 u8 fan_min[2]; /* rw fan1_min */
163 u8 fan_div[2]; /* rw fan1_div, read-only accessor */
164 s16 temp; /* ro temp1_input, 9-bit sign-extended */
165 s8 temp_high; /* rw temp1_max */
166 s8 temp_hyst; /* rw temp1_max_hyst */
167 u16 alarms; /* ro alarms */
168 u8 aout; /* rw aout_output */
169 u8 vid; /* ro vid */
170 u8 vrm; /* -- vrm set on startup, no accessor */
171};
172
173/* i2c byte read/write interface */
174static int adm9240_read_value(struct i2c_client *client, u8 reg)
175{
176 return i2c_smbus_read_byte_data(client, reg);
177}
178
179static int adm9240_write_value(struct i2c_client *client, u8 reg, u8 value)
180{
181 return i2c_smbus_write_byte_data(client, reg, value);
182}
183
184/*** sysfs accessors ***/
185
186/* temperature */
187#define show_temp(value, scale) \
188static ssize_t show_##value(struct device *dev, \
189 struct device_attribute *attr, \
190 char *buf) \
191{ \
192 struct adm9240_data *data = adm9240_update_device(dev); \
193 return sprintf(buf, "%d\n", data->value * scale); \
194}
195show_temp(temp_high, 1000);
196show_temp(temp_hyst, 1000);
197show_temp(temp, 500); /* 0.5'C per bit */
198
199#define set_temp(value, reg) \
200static ssize_t set_##value(struct device *dev, \
201 struct device_attribute *attr, \
202 const char *buf, size_t count) \
203{ \
204 struct i2c_client *client = to_i2c_client(dev); \
205 struct adm9240_data *data = adm9240_update_device(dev); \
206 long temp = simple_strtoul(buf, NULL, 10); \
207 \
208 down(&data->update_lock); \
209 data->value = TEMP_TO_REG(temp); \
210 adm9240_write_value(client, reg, data->value); \
211 up(&data->update_lock); \
212 return count; \
213}
214
215set_temp(temp_high, ADM9240_REG_TEMP_HIGH);
216set_temp(temp_hyst, ADM9240_REG_TEMP_HYST);
217
218static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO,
219 show_temp_high, set_temp_high);
220static DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO,
221 show_temp_hyst, set_temp_hyst);
222static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL);
223
224/* voltage */
225static ssize_t show_in(struct device *dev, char *buf, int nr)
226{
227 struct adm9240_data *data = adm9240_update_device(dev);
228 return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr], nr));
229}
230
231static ssize_t show_in_min(struct device *dev, char *buf, int nr)
232{
233 struct adm9240_data *data = adm9240_update_device(dev);
234 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr], nr));
235}
236
237static ssize_t show_in_max(struct device *dev, char *buf, int nr)
238{
239 struct adm9240_data *data = adm9240_update_device(dev);
240 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr], nr));
241}
242
243static ssize_t set_in_min(struct device *dev, const char *buf,
244 size_t count, int nr)
245{
246 struct i2c_client *client = to_i2c_client(dev);
247 struct adm9240_data *data = i2c_get_clientdata(client);
248 unsigned long val = simple_strtoul(buf, NULL, 10);
249
250 down(&data->update_lock);
251 data->in_min[nr] = IN_TO_REG(val, nr);
252 adm9240_write_value(client, ADM9240_REG_IN_MIN(nr), data->in_min[nr]);
253 up(&data->update_lock);
254 return count;
255}
256
257static ssize_t set_in_max(struct device *dev, const char *buf,
258 size_t count, int nr)
259{
260 struct i2c_client *client = to_i2c_client(dev);
261 struct adm9240_data *data = i2c_get_clientdata(client);
262 unsigned long val = simple_strtoul(buf, NULL, 10);
263
264 down(&data->update_lock);
265 data->in_max[nr] = IN_TO_REG(val, nr);
266 adm9240_write_value(client, ADM9240_REG_IN_MAX(nr), data->in_max[nr]);
267 up(&data->update_lock);
268 return count;
269}
270
271#define show_in_offset(offset) \
272static ssize_t show_in##offset(struct device *dev, \
273 struct device_attribute *attr, \
274 char *buf) \
275{ \
276 return show_in(dev, buf, offset); \
277} \
278static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); \
279static ssize_t show_in##offset##_min(struct device *dev, \
280 struct device_attribute *attr, \
281 char *buf) \
282{ \
283 return show_in_min(dev, buf, offset); \
284} \
285static ssize_t show_in##offset##_max(struct device *dev, \
286 struct device_attribute *attr, \
287 char *buf) \
288{ \
289 return show_in_max(dev, buf, offset); \
290} \
291static ssize_t \
292set_in##offset##_min(struct device *dev, \
293 struct device_attribute *attr, const char *buf, \
294 size_t count) \
295{ \
296 return set_in_min(dev, buf, count, offset); \
297} \
298static ssize_t \
299set_in##offset##_max(struct device *dev, \
300 struct device_attribute *attr, const char *buf, \
301 size_t count) \
302{ \
303 return set_in_max(dev, buf, count, offset); \
304} \
305static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
306 show_in##offset##_min, set_in##offset##_min); \
307static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
308 show_in##offset##_max, set_in##offset##_max);
309
310show_in_offset(0);
311show_in_offset(1);
312show_in_offset(2);
313show_in_offset(3);
314show_in_offset(4);
315show_in_offset(5);
316
317/* fans */
318static ssize_t show_fan(struct device *dev, char *buf, int nr)
319{
320 struct adm9240_data *data = adm9240_update_device(dev);
321 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr],
322 1 << data->fan_div[nr]));
323}
324
325static ssize_t show_fan_min(struct device *dev, char *buf, int nr)
326{
327 struct adm9240_data *data = adm9240_update_device(dev);
328 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr],
329 1 << data->fan_div[nr]));
330}
331
332static ssize_t show_fan_div(struct device *dev, char *buf, int nr)
333{
334 struct adm9240_data *data = adm9240_update_device(dev);
335 return sprintf(buf, "%d\n", 1 << data->fan_div[nr]);
336}
337
338/* write new fan div, callers must hold data->update_lock */
339static void adm9240_write_fan_div(struct i2c_client *client, int nr,
340 u8 fan_div)
341{
342 u8 reg, old, shift = (nr + 2) * 2;
343
344 reg = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV);
345 old = (reg >> shift) & 3;
346 reg &= ~(3 << shift);
347 reg |= (fan_div << shift);
348 adm9240_write_value(client, ADM9240_REG_VID_FAN_DIV, reg);
349 dev_dbg(&client->dev, "fan%d clock divider changed from %u "
350 "to %u\n", nr + 1, 1 << old, 1 << fan_div);
351}
352
353/*
354 * set fan speed low limit:
355 *
356 * - value is zero: disable fan speed low limit alarm
357 *
358 * - value is below fan speed measurement range: enable fan speed low
359 * limit alarm to be asserted while fan speed too slow to measure
360 *
361 * - otherwise: select fan clock divider to suit fan speed low limit,
362 * measurement code may adjust registers to ensure fan speed reading
363 */
364static ssize_t set_fan_min(struct device *dev, const char *buf,
365 size_t count, int nr)
366{
367 struct i2c_client *client = to_i2c_client(dev);
368 struct adm9240_data *data = i2c_get_clientdata(client);
369 unsigned long val = simple_strtoul(buf, NULL, 10);
370 u8 new_div;
371
372 down(&data->update_lock);
373
374 if (!val) {
375 data->fan_min[nr] = 255;
376 new_div = data->fan_div[nr];
377
378 dev_dbg(&client->dev, "fan%u low limit set disabled\n",
379 nr + 1);
380
381 } else if (val < 1350000 / (8 * 254)) {
382 new_div = 3;
383 data->fan_min[nr] = 254;
384
385 dev_dbg(&client->dev, "fan%u low limit set minimum %u\n",
386 nr + 1, FAN_FROM_REG(254, 1 << new_div));
387
388 } else {
389 unsigned int new_min = 1350000 / val;
390
391 new_div = 0;
392 while (new_min > 192 && new_div < 3) {
393 new_div++;
394 new_min /= 2;
395 }
396 if (!new_min) /* keep > 0 */
397 new_min++;
398
399 data->fan_min[nr] = new_min;
400
401 dev_dbg(&client->dev, "fan%u low limit set fan speed %u\n",
402 nr + 1, FAN_FROM_REG(new_min, 1 << new_div));
403 }
404
405 if (new_div != data->fan_div[nr]) {
406 data->fan_div[nr] = new_div;
407 adm9240_write_fan_div(client, nr, new_div);
408 }
409 adm9240_write_value(client, ADM9240_REG_FAN_MIN(nr),
410 data->fan_min[nr]);
411
412 up(&data->update_lock);
413 return count;
414}
415
416#define show_fan_offset(offset) \
417static ssize_t show_fan_##offset (struct device *dev, \
418 struct device_attribute *attr, \
419 char *buf) \
420{ \
421return show_fan(dev, buf, offset - 1); \
422} \
423static ssize_t show_fan_##offset##_div (struct device *dev, \
424 struct device_attribute *attr, \
425 char *buf) \
426{ \
427return show_fan_div(dev, buf, offset - 1); \
428} \
429static ssize_t show_fan_##offset##_min (struct device *dev, \
430 struct device_attribute *attr, \
431 char *buf) \
432{ \
433return show_fan_min(dev, buf, offset - 1); \
434} \
435static ssize_t set_fan_##offset##_min (struct device *dev, \
436 struct device_attribute *attr, \
437 const char *buf, size_t count) \
438{ \
439return set_fan_min(dev, buf, count, offset - 1); \
440} \
441static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
442 show_fan_##offset, NULL); \
443static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \
444 show_fan_##offset##_div, NULL); \
445static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
446 show_fan_##offset##_min, set_fan_##offset##_min);
447
448show_fan_offset(1);
449show_fan_offset(2);
450
451/* alarms */
452static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
453{
454 struct adm9240_data *data = adm9240_update_device(dev);
455 return sprintf(buf, "%u\n", data->alarms);
456}
457static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
458
459/* vid */
460static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
461{
462 struct adm9240_data *data = adm9240_update_device(dev);
463 return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm));
464}
465static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
466
467/* analog output */
468static ssize_t show_aout(struct device *dev, struct device_attribute *attr, char *buf)
469{
470 struct adm9240_data *data = adm9240_update_device(dev);
471 return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout));
472}
473
474static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
475{
476 struct i2c_client *client = to_i2c_client(dev);
477 struct adm9240_data *data = i2c_get_clientdata(client);
478 unsigned long val = simple_strtol(buf, NULL, 10);
479
480 down(&data->update_lock);
481 data->aout = AOUT_TO_REG(val);
482 adm9240_write_value(client, ADM9240_REG_ANALOG_OUT, data->aout);
483 up(&data->update_lock);
484 return count;
485}
486static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout);
487
488/* chassis_clear */
489static ssize_t chassis_clear(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
490{
491 struct i2c_client *client = to_i2c_client(dev);
492 unsigned long val = simple_strtol(buf, NULL, 10);
493
494 if (val == 1) {
495 adm9240_write_value(client, ADM9240_REG_CHASSIS_CLEAR, 0x80);
496 dev_dbg(&client->dev, "chassis intrusion latch cleared\n");
497 }
498 return count;
499}
500static DEVICE_ATTR(chassis_clear, S_IWUSR, NULL, chassis_clear);
501
502
503/*** sensor chip detect and driver install ***/
504
505static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
506{
507 struct i2c_client *new_client;
508 struct adm9240_data *data;
509 int err = 0;
510 const char *name = "";
511 u8 man_id, die_rev;
512
513 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
514 goto exit;
515
516 if (!(data = kmalloc(sizeof(struct adm9240_data), GFP_KERNEL))) {
517 err = -ENOMEM;
518 goto exit;
519 }
520 memset(data, 0, sizeof(struct adm9240_data));
521
522 new_client = &data->client;
523 i2c_set_clientdata(new_client, data);
524 new_client->addr = address;
525 new_client->adapter = adapter;
526 new_client->driver = &adm9240_driver;
527 new_client->flags = 0;
528
529 if (kind == 0) {
530 kind = adm9240;
531 }
532
533 if (kind < 0) {
534
535 /* verify chip: reg address should match i2c address */
536 if (adm9240_read_value(new_client, ADM9240_REG_I2C_ADDR)
537 != address) {
538 dev_err(&adapter->dev, "detect fail: address match, "
539 "0x%02x\n", address);
540 goto exit_free;
541 }
542
543 /* check known chip manufacturer */
544 man_id = adm9240_read_value(new_client, ADM9240_REG_MAN_ID);
545
546 if (man_id == 0x23) {
547 kind = adm9240;
548 } else if (man_id == 0xda) {
549 kind = ds1780;
550 } else if (man_id == 0x01) {
551 kind = lm81;
552 } else {
553 dev_err(&adapter->dev, "detect fail: unknown manuf, "
554 "0x%02x\n", man_id);
555 goto exit_free;
556 }
557
558 /* successful detect, print chip info */
559 die_rev = adm9240_read_value(new_client, ADM9240_REG_DIE_REV);
560 dev_info(&adapter->dev, "found %s revision %u\n",
561 man_id == 0x23 ? "ADM9240" :
562 man_id == 0xda ? "DS1780" : "LM81", die_rev);
563 }
564
565 /* either forced or detected chip kind */
566 if (kind == adm9240) {
567 name = "adm9240";
568 } else if (kind == ds1780) {
569 name = "ds1780";
570 } else if (kind == lm81) {
571 name = "lm81";
572 }
573
574 /* fill in the remaining client fields and attach */
575 strlcpy(new_client->name, name, I2C_NAME_SIZE);
576 data->type = kind;
577 init_MUTEX(&data->update_lock);
578
579 if ((err = i2c_attach_client(new_client)))
580 goto exit_free;
581
582 adm9240_init_client(new_client);
583
584 /* populate sysfs filesystem */
585 device_create_file(&new_client->dev, &dev_attr_in0_input);
586 device_create_file(&new_client->dev, &dev_attr_in0_min);
587 device_create_file(&new_client->dev, &dev_attr_in0_max);
588 device_create_file(&new_client->dev, &dev_attr_in1_input);
589 device_create_file(&new_client->dev, &dev_attr_in1_min);
590 device_create_file(&new_client->dev, &dev_attr_in1_max);
591 device_create_file(&new_client->dev, &dev_attr_in2_input);
592 device_create_file(&new_client->dev, &dev_attr_in2_min);
593 device_create_file(&new_client->dev, &dev_attr_in2_max);
594 device_create_file(&new_client->dev, &dev_attr_in3_input);
595 device_create_file(&new_client->dev, &dev_attr_in3_min);
596 device_create_file(&new_client->dev, &dev_attr_in3_max);
597 device_create_file(&new_client->dev, &dev_attr_in4_input);
598 device_create_file(&new_client->dev, &dev_attr_in4_min);
599 device_create_file(&new_client->dev, &dev_attr_in4_max);
600 device_create_file(&new_client->dev, &dev_attr_in5_input);
601 device_create_file(&new_client->dev, &dev_attr_in5_min);
602 device_create_file(&new_client->dev, &dev_attr_in5_max);
603 device_create_file(&new_client->dev, &dev_attr_temp1_max);
604 device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
605 device_create_file(&new_client->dev, &dev_attr_temp1_input);
606 device_create_file(&new_client->dev, &dev_attr_fan1_input);
607 device_create_file(&new_client->dev, &dev_attr_fan1_div);
608 device_create_file(&new_client->dev, &dev_attr_fan1_min);
609 device_create_file(&new_client->dev, &dev_attr_fan2_input);
610 device_create_file(&new_client->dev, &dev_attr_fan2_div);
611 device_create_file(&new_client->dev, &dev_attr_fan2_min);
612 device_create_file(&new_client->dev, &dev_attr_alarms);
613 device_create_file(&new_client->dev, &dev_attr_aout_output);
614 device_create_file(&new_client->dev, &dev_attr_chassis_clear);
615 device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
616
617 return 0;
618exit_free:
619 kfree(new_client);
620exit:
621 return err;
622}
623
624static int adm9240_attach_adapter(struct i2c_adapter *adapter)
625{
626 if (!(adapter->class & I2C_CLASS_HWMON))
627 return 0;
628 return i2c_detect(adapter, &addr_data, adm9240_detect);
629}
630
631static int adm9240_detach_client(struct i2c_client *client)
632{
633 int err;
634
635 if ((err = i2c_detach_client(client))) {
636 dev_err(&client->dev, "Client deregistration failed, "
637 "client not detached.\n");
638 return err;
639 }
640
641 kfree(i2c_get_clientdata(client));
642 return 0;
643}
644
645static void adm9240_init_client(struct i2c_client *client)
646{
647 struct adm9240_data *data = i2c_get_clientdata(client);
648 u8 conf = adm9240_read_value(client, ADM9240_REG_CONFIG);
649 u8 mode = adm9240_read_value(client, ADM9240_REG_TEMP_CONF) & 3;
650
651 data->vrm = i2c_which_vrm(); /* need this to report vid as mV */
652
653 dev_info(&client->dev, "Using VRM: %d.%d\n", data->vrm / 10,
654 data->vrm % 10);
655
656 if (conf & 1) { /* measurement cycle running: report state */
657
658 dev_info(&client->dev, "status: config 0x%02x mode %u\n",
659 conf, mode);
660
661 } else { /* cold start: open limits before starting chip */
662 int i;
663
664 for (i = 0; i < 6; i++)
665 {
666 adm9240_write_value(client,
667 ADM9240_REG_IN_MIN(i), 0);
668 adm9240_write_value(client,
669 ADM9240_REG_IN_MAX(i), 255);
670 }
671 adm9240_write_value(client, ADM9240_REG_FAN_MIN(0), 255);
672 adm9240_write_value(client, ADM9240_REG_FAN_MIN(1), 255);
673 adm9240_write_value(client, ADM9240_REG_TEMP_HIGH, 127);
674 adm9240_write_value(client, ADM9240_REG_TEMP_HYST, 127);
675
676 /* start measurement cycle */
677 adm9240_write_value(client, ADM9240_REG_CONFIG, 1);
678
679 dev_info(&client->dev, "cold start: config was 0x%02x "
680 "mode %u\n", conf, mode);
681 }
682}
683
684static struct adm9240_data *adm9240_update_device(struct device *dev)
685{
686 struct i2c_client *client = to_i2c_client(dev);
687 struct adm9240_data *data = i2c_get_clientdata(client);
688 int i;
689
690 down(&data->update_lock);
691
692 /* minimum measurement cycle: 1.75 seconds */
693 if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4))
694 || !data->valid) {
695
696 for (i = 0; i < 6; i++) /* read voltages */
697 {
698 data->in[i] = adm9240_read_value(client,
699 ADM9240_REG_IN(i));
700 }
701 data->alarms = adm9240_read_value(client,
702 ADM9240_REG_INT(0)) |
703 adm9240_read_value(client,
704 ADM9240_REG_INT(1)) << 8;
705
706 /* read temperature: assume temperature changes less than
707 * 0.5'C per two measurement cycles thus ignore possible
708 * but unlikely aliasing error on lsb reading. --Grant */
709 data->temp = ((adm9240_read_value(client,
710 ADM9240_REG_TEMP) << 8) |
711 adm9240_read_value(client,
712 ADM9240_REG_TEMP_CONF)) / 128;
713
714 for (i = 0; i < 2; i++) /* read fans */
715 {
716 data->fan[i] = adm9240_read_value(client,
717 ADM9240_REG_FAN(i));
718
719 /* adjust fan clock divider on overflow */
720 if (data->valid && data->fan[i] == 255 &&
721 data->fan_div[i] < 3) {
722
723 adm9240_write_fan_div(client, i,
724 ++data->fan_div[i]);
725
726 /* adjust fan_min if active, but not to 0 */
727 if (data->fan_min[i] < 255 &&
728 data->fan_min[i] >= 2)
729 data->fan_min[i] /= 2;
730 }
731 }
732 data->last_updated_measure = jiffies;
733 }
734
735 /* minimum config reading cycle: 300 seconds */
736 if (time_after(jiffies, data->last_updated_config + (HZ * 300))
737 || !data->valid) {
738
739 for (i = 0; i < 6; i++)
740 {
741 data->in_min[i] = adm9240_read_value(client,
742 ADM9240_REG_IN_MIN(i));
743 data->in_max[i] = adm9240_read_value(client,
744 ADM9240_REG_IN_MAX(i));
745 }
746 for (i = 0; i < 2; i++)
747 {
748 data->fan_min[i] = adm9240_read_value(client,
749 ADM9240_REG_FAN_MIN(i));
750 }
751 data->temp_high = adm9240_read_value(client,
752 ADM9240_REG_TEMP_HIGH);
753 data->temp_hyst = adm9240_read_value(client,
754 ADM9240_REG_TEMP_HYST);
755
756 /* read fan divs and 5-bit VID */
757 i = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV);
758 data->fan_div[0] = (i >> 4) & 3;
759 data->fan_div[1] = (i >> 6) & 3;
760 data->vid = i & 0x0f;
761 data->vid |= (adm9240_read_value(client,
762 ADM9240_REG_VID4) & 1) << 4;
763 /* read analog out */
764 data->aout = adm9240_read_value(client,
765 ADM9240_REG_ANALOG_OUT);
766
767 data->last_updated_config = jiffies;
768 data->valid = 1;
769 }
770 up(&data->update_lock);
771 return data;
772}
773
774static int __init sensors_adm9240_init(void)
775{
776 return i2c_add_driver(&adm9240_driver);
777}
778
779static void __exit sensors_adm9240_exit(void)
780{
781 i2c_del_driver(&adm9240_driver);
782}
783
784MODULE_AUTHOR("Michiel Rook <michiel@grendelproject.nl>, "
785 "Grant Coady <gcoady@gmail.com> and others");
786MODULE_DESCRIPTION("ADM9240/DS1780/LM81 driver");
787MODULE_LICENSE("GPL");
788
789module_init(sensors_adm9240_init);
790module_exit(sensors_adm9240_exit);
791
diff --git a/drivers/i2c/chips/asb100.c b/drivers/i2c/chips/asb100.c
index 4a47b4493e34..70d996d6fe0a 100644
--- a/drivers/i2c/chips/asb100.c
+++ b/drivers/i2c/chips/asb100.c
@@ -42,6 +42,7 @@
42#include <linux/i2c-sensor.h> 42#include <linux/i2c-sensor.h>
43#include <linux/i2c-vid.h> 43#include <linux/i2c-vid.h>
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/jiffies.h>
45#include "lm75.h" 46#include "lm75.h"
46 47
47/* 48/*
@@ -168,8 +169,6 @@ static int ASB100_PWM_FROM_REG(u8 reg)
168 return reg * 16; 169 return reg * 16;
169} 170}
170 171
171#define ALARMS_FROM_REG(val) (val)
172
173#define DIV_FROM_REG(val) (1 << (val)) 172#define DIV_FROM_REG(val) (1 << (val))
174 173
175/* FAN DIV: 1, 2, 4, or 8 (defaults to 2) 174/* FAN DIV: 1, 2, 4, or 8 (defaults to 2)
@@ -556,7 +555,7 @@ device_create_file(&client->dev, &dev_attr_vrm);
556static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 555static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
557{ 556{
558 struct asb100_data *data = asb100_update_device(dev); 557 struct asb100_data *data = asb100_update_device(dev);
559 return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->alarms)); 558 return sprintf(buf, "%u\n", data->alarms);
560} 559}
561 560
562static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 561static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
diff --git a/drivers/i2c/chips/atxp1.c b/drivers/i2c/chips/atxp1.c
new file mode 100644
index 000000000000..5c6597aa2c7f
--- /dev/null
+++ b/drivers/i2c/chips/atxp1.c
@@ -0,0 +1,361 @@
1/*
2 atxp1.c - kernel module for setting CPU VID and general purpose
3 I/Os using the Attansic ATXP1 chip.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19*/
20
21#include <linux/kernel.h>
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/i2c.h>
25#include <linux/i2c-sensor.h>
26#include <linux/i2c-vid.h>
27
28MODULE_LICENSE("GPL");
29MODULE_DESCRIPTION("System voltages control via Attansic ATXP1");
30MODULE_VERSION("0.6.2");
31MODULE_AUTHOR("Sebastian Witt <se.witt@gmx.net>");
32
33#define ATXP1_VID 0x00
34#define ATXP1_CVID 0x01
35#define ATXP1_GPIO1 0x06
36#define ATXP1_GPIO2 0x0a
37#define ATXP1_VIDENA 0x20
38#define ATXP1_VIDMASK 0x1f
39#define ATXP1_GPIO1MASK 0x0f
40
41static unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END };
42static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
43
44SENSORS_INSMOD_1(atxp1);
45
46static int atxp1_attach_adapter(struct i2c_adapter * adapter);
47static int atxp1_detach_client(struct i2c_client * client);
48static struct atxp1_data * atxp1_update_device(struct device *dev);
49static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind);
50
51static struct i2c_driver atxp1_driver = {
52 .owner = THIS_MODULE,
53 .name = "atxp1",
54 .flags = I2C_DF_NOTIFY,
55 .attach_adapter = atxp1_attach_adapter,
56 .detach_client = atxp1_detach_client,
57};
58
59struct atxp1_data {
60 struct i2c_client client;
61 struct semaphore update_lock;
62 unsigned long last_updated;
63 u8 valid;
64 struct {
65 u8 vid; /* VID output register */
66 u8 cpu_vid; /* VID input from CPU */
67 u8 gpio1; /* General purpose I/O register 1 */
68 u8 gpio2; /* General purpose I/O register 2 */
69 } reg;
70 u8 vrm; /* Detected CPU VRM */
71};
72
73static struct atxp1_data * atxp1_update_device(struct device *dev)
74{
75 struct i2c_client *client;
76 struct atxp1_data *data;
77
78 client = to_i2c_client(dev);
79 data = i2c_get_clientdata(client);
80
81 down(&data->update_lock);
82
83 if ((jiffies - data->last_updated > HZ) ||
84 (jiffies < data->last_updated) ||
85 !data->valid) {
86
87 /* Update local register data */
88 data->reg.vid = i2c_smbus_read_byte_data(client, ATXP1_VID);
89 data->reg.cpu_vid = i2c_smbus_read_byte_data(client, ATXP1_CVID);
90 data->reg.gpio1 = i2c_smbus_read_byte_data(client, ATXP1_GPIO1);
91 data->reg.gpio2 = i2c_smbus_read_byte_data(client, ATXP1_GPIO2);
92
93 data->valid = 1;
94 }
95
96 up(&data->update_lock);
97
98 return(data);
99}
100
101/* sys file functions for cpu0_vid */
102static ssize_t atxp1_showvcore(struct device *dev, struct device_attribute *attr, char *buf)
103{
104 int size;
105 struct atxp1_data *data;
106
107 data = atxp1_update_device(dev);
108
109 size = sprintf(buf, "%d\n", vid_from_reg(data->reg.vid & ATXP1_VIDMASK, data->vrm));
110
111 return size;
112}
113
114static ssize_t atxp1_storevcore(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
115{
116 struct atxp1_data *data;
117 struct i2c_client *client;
118 char vid;
119 char cvid;
120 unsigned int vcore;
121
122 client = to_i2c_client(dev);
123 data = atxp1_update_device(dev);
124
125 vcore = simple_strtoul(buf, NULL, 10);
126 vcore /= 25;
127 vcore *= 25;
128
129 /* Calculate VID */
130 vid = vid_to_reg(vcore, data->vrm);
131
132 if (vid < 0) {
133 dev_err(dev, "VID calculation failed.\n");
134 return -1;
135 }
136
137 /* If output enabled, use control register value. Otherwise original CPU VID */
138 if (data->reg.vid & ATXP1_VIDENA)
139 cvid = data->reg.vid & ATXP1_VIDMASK;
140 else
141 cvid = data->reg.cpu_vid;
142
143 /* Nothing changed, aborting */
144 if (vid == cvid)
145 return count;
146
147 dev_info(dev, "Setting VCore to %d mV (0x%02x)\n", vcore, vid);
148
149 /* Write every 25 mV step to increase stability */
150 if (cvid > vid) {
151 for (; cvid >= vid; cvid--) {
152 i2c_smbus_write_byte_data(client, ATXP1_VID, cvid | ATXP1_VIDENA);
153 }
154 }
155 else {
156 for (; cvid <= vid; cvid++) {
157 i2c_smbus_write_byte_data(client, ATXP1_VID, cvid | ATXP1_VIDENA);
158 }
159 }
160
161 data->valid = 0;
162
163 return count;
164}
165
166/* CPU core reference voltage
167 unit: millivolt
168*/
169static DEVICE_ATTR(cpu0_vid, S_IRUGO | S_IWUSR, atxp1_showvcore, atxp1_storevcore);
170
171/* sys file functions for GPIO1 */
172static ssize_t atxp1_showgpio1(struct device *dev, struct device_attribute *attr, char *buf)
173{
174 int size;
175 struct atxp1_data *data;
176
177 data = atxp1_update_device(dev);
178
179 size = sprintf(buf, "0x%02x\n", data->reg.gpio1 & ATXP1_GPIO1MASK);
180
181 return size;
182}
183
184static ssize_t atxp1_storegpio1(struct device *dev, struct device_attribute *attr, const char*buf, size_t count)
185{
186 struct atxp1_data *data;
187 struct i2c_client *client;
188 unsigned int value;
189
190 client = to_i2c_client(dev);
191 data = atxp1_update_device(dev);
192
193 value = simple_strtoul(buf, NULL, 16);
194
195 value &= ATXP1_GPIO1MASK;
196
197 if (value != (data->reg.gpio1 & ATXP1_GPIO1MASK)) {
198 dev_info(dev, "Writing 0x%x to GPIO1.\n", value);
199
200 i2c_smbus_write_byte_data(client, ATXP1_GPIO1, value);
201
202 data->valid = 0;
203 }
204
205 return count;
206}
207
208/* GPIO1 data register
209 unit: Four bit as hex (e.g. 0x0f)
210*/
211static DEVICE_ATTR(gpio1, S_IRUGO | S_IWUSR, atxp1_showgpio1, atxp1_storegpio1);
212
213/* sys file functions for GPIO2 */
214static ssize_t atxp1_showgpio2(struct device *dev, struct device_attribute *attr, char *buf)
215{
216 int size;
217 struct atxp1_data *data;
218
219 data = atxp1_update_device(dev);
220
221 size = sprintf(buf, "0x%02x\n", data->reg.gpio2);
222
223 return size;
224}
225
226static ssize_t atxp1_storegpio2(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
227{
228 struct atxp1_data *data;
229 struct i2c_client *client;
230 unsigned int value;
231
232 client = to_i2c_client(dev);
233 data = atxp1_update_device(dev);
234
235 value = simple_strtoul(buf, NULL, 16) & 0xff;
236
237 if (value != data->reg.gpio2) {
238 dev_info(dev, "Writing 0x%x to GPIO1.\n", value);
239
240 i2c_smbus_write_byte_data(client, ATXP1_GPIO2, value);
241
242 data->valid = 0;
243 }
244
245 return count;
246}
247
248/* GPIO2 data register
249 unit: Eight bit as hex (e.g. 0xff)
250*/
251static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2);
252
253
254static int atxp1_attach_adapter(struct i2c_adapter *adapter)
255{
256 return i2c_detect(adapter, &addr_data, &atxp1_detect);
257};
258
259static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)
260{
261 struct i2c_client * new_client;
262 struct atxp1_data * data;
263 int err = 0;
264 u8 temp;
265
266 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
267 goto exit;
268
269 if (!(data = kmalloc(sizeof(struct atxp1_data), GFP_KERNEL))) {
270 err = -ENOMEM;
271 goto exit;
272 }
273
274 memset(data, 0, sizeof(struct atxp1_data));
275 new_client = &data->client;
276 i2c_set_clientdata(new_client, data);
277
278 new_client->addr = address;
279 new_client->adapter = adapter;
280 new_client->driver = &atxp1_driver;
281 new_client->flags = 0;
282
283 /* Detect ATXP1, checking if vendor ID registers are all zero */
284 if (!((i2c_smbus_read_byte_data(new_client, 0x3e) == 0) &&
285 (i2c_smbus_read_byte_data(new_client, 0x3f) == 0) &&
286 (i2c_smbus_read_byte_data(new_client, 0xfe) == 0) &&
287 (i2c_smbus_read_byte_data(new_client, 0xff) == 0) )) {
288
289 /* No vendor ID, now checking if registers 0x10,0x11 (non-existent)
290 * showing the same as register 0x00 */
291 temp = i2c_smbus_read_byte_data(new_client, 0x00);
292
293 if (!((i2c_smbus_read_byte_data(new_client, 0x10) == temp) &&
294 (i2c_smbus_read_byte_data(new_client, 0x11) == temp) ))
295 goto exit_free;
296 }
297
298 /* Get VRM */
299 data->vrm = i2c_which_vrm();
300
301 if ((data->vrm != 90) && (data->vrm != 91)) {
302 dev_err(&new_client->dev, "Not supporting VRM %d.%d\n",
303 data->vrm / 10, data->vrm % 10);
304 goto exit_free;
305 }
306
307 strncpy(new_client->name, "atxp1", I2C_NAME_SIZE);
308
309 data->valid = 0;
310
311 init_MUTEX(&data->update_lock);
312
313 err = i2c_attach_client(new_client);
314
315 if (err)
316 {
317 dev_err(&new_client->dev, "Attach client error.\n");
318 goto exit_free;
319 }
320
321 device_create_file(&new_client->dev, &dev_attr_gpio1);
322 device_create_file(&new_client->dev, &dev_attr_gpio2);
323 device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
324
325 dev_info(&new_client->dev, "Using VRM: %d.%d\n",
326 data->vrm / 10, data->vrm % 10);
327
328 return 0;
329
330exit_free:
331 kfree(data);
332exit:
333 return err;
334};
335
336static int atxp1_detach_client(struct i2c_client * client)
337{
338 int err;
339
340 err = i2c_detach_client(client);
341
342 if (err)
343 dev_err(&client->dev, "Failed to detach client.\n");
344 else
345 kfree(i2c_get_clientdata(client));
346
347 return err;
348};
349
350static int __init atxp1_init(void)
351{
352 return i2c_add_driver(&atxp1_driver);
353};
354
355static void __exit atxp1_exit(void)
356{
357 i2c_del_driver(&atxp1_driver);
358};
359
360module_init(atxp1_init);
361module_exit(atxp1_exit);
diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c
index 07f16c3fb084..74ece8ac1c23 100644
--- a/drivers/i2c/chips/ds1337.c
+++ b/drivers/i2c/chips/ds1337.c
@@ -3,17 +3,16 @@
3 * 3 *
4 * Copyright (C) 2005 James Chapman <jchapman@katalix.com> 4 * Copyright (C) 2005 James Chapman <jchapman@katalix.com>
5 * 5 *
6 * based on linux/drivers/acron/char/pcf8583.c 6 * based on linux/drivers/acorn/char/pcf8583.c
7 * Copyright (C) 2000 Russell King 7 * Copyright (C) 2000 Russell King
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
12 * 12 *
13 * Driver for Dallas Semiconductor DS1337 real time clock chip 13 * Driver for Dallas Semiconductor DS1337 and DS1339 real time clock chip
14 */ 14 */
15 15
16#include <linux/config.h>
17#include <linux/module.h> 16#include <linux/module.h>
18#include <linux/init.h> 17#include <linux/init.h>
19#include <linux/slab.h> 18#include <linux/slab.h>
@@ -69,13 +68,11 @@ static struct i2c_driver ds1337_driver = {
69struct ds1337_data { 68struct ds1337_data {
70 struct i2c_client client; 69 struct i2c_client client;
71 struct list_head list; 70 struct list_head list;
72 int id;
73}; 71};
74 72
75/* 73/*
76 * Internal variables 74 * Internal variables
77 */ 75 */
78static int ds1337_id;
79static LIST_HEAD(ds1337_clients); 76static LIST_HEAD(ds1337_clients);
80 77
81static inline int ds1337_read(struct i2c_client *client, u8 reg, u8 *value) 78static inline int ds1337_read(struct i2c_client *client, u8 reg, u8 *value)
@@ -95,7 +92,6 @@ static inline int ds1337_read(struct i2c_client *client, u8 reg, u8 *value)
95 */ 92 */
96static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt) 93static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt)
97{ 94{
98 struct ds1337_data *data = i2c_get_clientdata(client);
99 int result; 95 int result;
100 u8 buf[7]; 96 u8 buf[7];
101 u8 val; 97 u8 val;
@@ -103,9 +99,7 @@ static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt)
103 u8 offs = 0; 99 u8 offs = 0;
104 100
105 if (!dt) { 101 if (!dt) {
106 dev_dbg(&client->adapter->dev, "%s: EINVAL: dt=NULL\n", 102 dev_dbg(&client->dev, "%s: EINVAL: dt=NULL\n", __FUNCTION__);
107 __FUNCTION__);
108
109 return -EINVAL; 103 return -EINVAL;
110 } 104 }
111 105
@@ -119,98 +113,86 @@ static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt)
119 msg[1].len = sizeof(buf); 113 msg[1].len = sizeof(buf);
120 msg[1].buf = &buf[0]; 114 msg[1].buf = &buf[0];
121 115
122 result = client->adapter->algo->master_xfer(client->adapter, 116 result = i2c_transfer(client->adapter, msg, 2);
123 &msg[0], 2);
124 117
125 dev_dbg(&client->adapter->dev, 118 dev_dbg(&client->dev, "%s: [%d] %02x %02x %02x %02x %02x %02x %02x\n",
126 "%s: [%d] %02x %02x %02x %02x %02x %02x %02x\n",
127 __FUNCTION__, result, buf[0], buf[1], buf[2], buf[3], 119 __FUNCTION__, result, buf[0], buf[1], buf[2], buf[3],
128 buf[4], buf[5], buf[6]); 120 buf[4], buf[5], buf[6]);
129 121
130 if (result >= 0) { 122 if (result == 2) {
131 dt->tm_sec = BCD_TO_BIN(buf[0]); 123 dt->tm_sec = BCD2BIN(buf[0]);
132 dt->tm_min = BCD_TO_BIN(buf[1]); 124 dt->tm_min = BCD2BIN(buf[1]);
133 val = buf[2] & 0x3f; 125 val = buf[2] & 0x3f;
134 dt->tm_hour = BCD_TO_BIN(val); 126 dt->tm_hour = BCD2BIN(val);
135 dt->tm_wday = BCD_TO_BIN(buf[3]) - 1; 127 dt->tm_wday = BCD2BIN(buf[3]) - 1;
136 dt->tm_mday = BCD_TO_BIN(buf[4]); 128 dt->tm_mday = BCD2BIN(buf[4]);
137 val = buf[5] & 0x7f; 129 val = buf[5] & 0x7f;
138 dt->tm_mon = BCD_TO_BIN(val); 130 dt->tm_mon = BCD2BIN(val) - 1;
139 dt->tm_year = 1900 + BCD_TO_BIN(buf[6]); 131 dt->tm_year = BCD2BIN(buf[6]);
140 if (buf[5] & 0x80) 132 if (buf[5] & 0x80)
141 dt->tm_year += 100; 133 dt->tm_year += 100;
142 134
143 dev_dbg(&client->adapter->dev, "%s: secs=%d, mins=%d, " 135 dev_dbg(&client->dev, "%s: secs=%d, mins=%d, "
144 "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", 136 "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n",
145 __FUNCTION__, dt->tm_sec, dt->tm_min, 137 __FUNCTION__, dt->tm_sec, dt->tm_min,
146 dt->tm_hour, dt->tm_mday, 138 dt->tm_hour, dt->tm_mday,
147 dt->tm_mon, dt->tm_year, dt->tm_wday); 139 dt->tm_mon, dt->tm_year, dt->tm_wday);
148 } else { 140
149 dev_err(&client->adapter->dev, "ds1337[%d]: error reading " 141 return 0;
150 "data! %d\n", data->id, result);
151 result = -EIO;
152 } 142 }
153 143
154 return result; 144 dev_err(&client->dev, "error reading data! %d\n", result);
145 return -EIO;
155} 146}
156 147
157static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt) 148static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt)
158{ 149{
159 struct ds1337_data *data = i2c_get_clientdata(client);
160 int result; 150 int result;
161 u8 buf[8]; 151 u8 buf[8];
162 u8 val; 152 u8 val;
163 struct i2c_msg msg[1]; 153 struct i2c_msg msg[1];
164 154
165 if (!dt) { 155 if (!dt) {
166 dev_dbg(&client->adapter->dev, "%s: EINVAL: dt=NULL\n", 156 dev_dbg(&client->dev, "%s: EINVAL: dt=NULL\n", __FUNCTION__);
167 __FUNCTION__);
168
169 return -EINVAL; 157 return -EINVAL;
170 } 158 }
171 159
172 dev_dbg(&client->adapter->dev, "%s: secs=%d, mins=%d, hours=%d, " 160 dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, "
173 "mday=%d, mon=%d, year=%d, wday=%d\n", __FUNCTION__, 161 "mday=%d, mon=%d, year=%d, wday=%d\n", __FUNCTION__,
174 dt->tm_sec, dt->tm_min, dt->tm_hour, 162 dt->tm_sec, dt->tm_min, dt->tm_hour,
175 dt->tm_mday, dt->tm_mon, dt->tm_year, dt->tm_wday); 163 dt->tm_mday, dt->tm_mon, dt->tm_year, dt->tm_wday);
176 164
177 buf[0] = 0; /* reg offset */ 165 buf[0] = 0; /* reg offset */
178 buf[1] = BIN_TO_BCD(dt->tm_sec); 166 buf[1] = BIN2BCD(dt->tm_sec);
179 buf[2] = BIN_TO_BCD(dt->tm_min); 167 buf[2] = BIN2BCD(dt->tm_min);
180 buf[3] = BIN_TO_BCD(dt->tm_hour) | (1 << 6); 168 buf[3] = BIN2BCD(dt->tm_hour) | (1 << 6);
181 buf[4] = BIN_TO_BCD(dt->tm_wday) + 1; 169 buf[4] = BIN2BCD(dt->tm_wday) + 1;
182 buf[5] = BIN_TO_BCD(dt->tm_mday); 170 buf[5] = BIN2BCD(dt->tm_mday);
183 buf[6] = BIN_TO_BCD(dt->tm_mon); 171 buf[6] = BIN2BCD(dt->tm_mon) + 1;
184 if (dt->tm_year >= 2000) { 172 val = dt->tm_year;
185 val = dt->tm_year - 2000; 173 if (val >= 100) {
174 val -= 100;
186 buf[6] |= (1 << 7); 175 buf[6] |= (1 << 7);
187 } else {
188 val = dt->tm_year - 1900;
189 } 176 }
190 buf[7] = BIN_TO_BCD(val); 177 buf[7] = BIN2BCD(val);
191 178
192 msg[0].addr = client->addr; 179 msg[0].addr = client->addr;
193 msg[0].flags = 0; 180 msg[0].flags = 0;
194 msg[0].len = sizeof(buf); 181 msg[0].len = sizeof(buf);
195 msg[0].buf = &buf[0]; 182 msg[0].buf = &buf[0];
196 183
197 result = client->adapter->algo->master_xfer(client->adapter, 184 result = i2c_transfer(client->adapter, msg, 1);
198 &msg[0], 1); 185 if (result == 1)
199 if (result < 0) { 186 return 0;
200 dev_err(&client->adapter->dev, "ds1337[%d]: error "
201 "writing data! %d\n", data->id, result);
202 result = -EIO;
203 } else {
204 result = 0;
205 }
206 187
207 return result; 188 dev_err(&client->dev, "error writing data! %d\n", result);
189 return -EIO;
208} 190}
209 191
210static int ds1337_command(struct i2c_client *client, unsigned int cmd, 192static int ds1337_command(struct i2c_client *client, unsigned int cmd,
211 void *arg) 193 void *arg)
212{ 194{
213 dev_dbg(&client->adapter->dev, "%s: cmd=%d\n", __FUNCTION__, cmd); 195 dev_dbg(&client->dev, "%s: cmd=%d\n", __FUNCTION__, cmd);
214 196
215 switch (cmd) { 197 switch (cmd) {
216 case DS1337_GET_DATE: 198 case DS1337_GET_DATE:
@@ -228,7 +210,7 @@ static int ds1337_command(struct i2c_client *client, unsigned int cmd,
228 * Public API for access to specific device. Useful for low-level 210 * Public API for access to specific device. Useful for low-level
229 * RTC access from kernel code. 211 * RTC access from kernel code.
230 */ 212 */
231int ds1337_do_command(int id, int cmd, void *arg) 213int ds1337_do_command(int bus, int cmd, void *arg)
232{ 214{
233 struct list_head *walk; 215 struct list_head *walk;
234 struct list_head *tmp; 216 struct list_head *tmp;
@@ -236,7 +218,7 @@ int ds1337_do_command(int id, int cmd, void *arg)
236 218
237 list_for_each_safe(walk, tmp, &ds1337_clients) { 219 list_for_each_safe(walk, tmp, &ds1337_clients) {
238 data = list_entry(walk, struct ds1337_data, list); 220 data = list_entry(walk, struct ds1337_data, list);
239 if (data->id == id) 221 if (data->client.adapter->nr == bus)
240 return ds1337_command(&data->client, cmd, arg); 222 return ds1337_command(&data->client, cmd, arg);
241 } 223 }
242 224
@@ -346,7 +328,6 @@ static int ds1337_detect(struct i2c_adapter *adapter, int address, int kind)
346 ds1337_init_client(new_client); 328 ds1337_init_client(new_client);
347 329
348 /* Add client to local list */ 330 /* Add client to local list */
349 data->id = ds1337_id++;
350 list_add(&data->list, &ds1337_clients); 331 list_add(&data->list, &ds1337_clients);
351 332
352 return 0; 333 return 0;
@@ -398,5 +379,7 @@ MODULE_AUTHOR("James Chapman <jchapman@katalix.com>");
398MODULE_DESCRIPTION("DS1337 RTC driver"); 379MODULE_DESCRIPTION("DS1337 RTC driver");
399MODULE_LICENSE("GPL"); 380MODULE_LICENSE("GPL");
400 381
382EXPORT_SYMBOL_GPL(ds1337_do_command);
383
401module_init(ds1337_init); 384module_init(ds1337_init);
402module_exit(ds1337_exit); 385module_exit(ds1337_exit);
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c
new file mode 100644
index 000000000000..a445736d8838
--- /dev/null
+++ b/drivers/i2c/chips/ds1374.c
@@ -0,0 +1,260 @@
1/*
2 * drivers/i2c/chips/ds1374.c
3 *
4 * I2C client/driver for the Maxim/Dallas DS1374 Real-Time Clock
5 *
6 * Author: Randy Vinson <rvinson@mvista.com>
7 *
8 * Based on the m41t00.c by Mark Greer <mgreer@mvista.com>
9 *
10 * 2005 (c) MontaVista Software, Inc. This file is licensed under
11 * the terms of the GNU General Public License version 2. This program
12 * is licensed "as is" without any warranty of any kind, whether express
13 * or implied.
14 */
15/*
16 * This i2c client/driver wedges between the drivers/char/genrtc.c RTC
17 * interface and the SMBus interface of the i2c subsystem.
18 * It would be more efficient to use i2c msgs/i2c_transfer directly but, as
19 * recommened in .../Documentation/i2c/writing-clients section
20 * "Sending and receiving", using SMBus level communication is preferred.
21 */
22
23#include <linux/kernel.h>
24#include <linux/module.h>
25#include <linux/interrupt.h>
26#include <linux/i2c.h>
27#include <linux/rtc.h>
28#include <linux/bcd.h>
29
30#define DS1374_REG_TOD0 0x00
31#define DS1374_REG_TOD1 0x01
32#define DS1374_REG_TOD2 0x02
33#define DS1374_REG_TOD3 0x03
34#define DS1374_REG_WDALM0 0x04
35#define DS1374_REG_WDALM1 0x05
36#define DS1374_REG_WDALM2 0x06
37#define DS1374_REG_CR 0x07
38#define DS1374_REG_SR 0x08
39#define DS1374_REG_SR_OSF 0x80
40#define DS1374_REG_TCR 0x09
41
42#define DS1374_DRV_NAME "ds1374"
43
44static DECLARE_MUTEX(ds1374_mutex);
45
46static struct i2c_driver ds1374_driver;
47static struct i2c_client *save_client;
48
49static unsigned short ignore[] = { I2C_CLIENT_END };
50static unsigned short normal_addr[] = { 0x68, I2C_CLIENT_END };
51
52static struct i2c_client_address_data addr_data = {
53 .normal_i2c = normal_addr,
54 .probe = ignore,
55 .ignore = ignore,
56 .force = ignore,
57};
58
59static ulong ds1374_read_rtc(void)
60{
61 ulong time = 0;
62 int reg = DS1374_REG_WDALM0;
63
64 while (reg--) {
65 s32 tmp;
66 if ((tmp = i2c_smbus_read_byte_data(save_client, reg)) < 0) {
67 dev_warn(&save_client->dev,
68 "can't read from rtc chip\n");
69 return 0;
70 }
71 time = (time << 8) | (tmp & 0xff);
72 }
73 return time;
74}
75
76static void ds1374_write_rtc(ulong time)
77{
78 int reg;
79
80 for (reg = DS1374_REG_TOD0; reg < DS1374_REG_WDALM0; reg++) {
81 if (i2c_smbus_write_byte_data(save_client, reg, time & 0xff)
82 < 0) {
83 dev_warn(&save_client->dev,
84 "can't write to rtc chip\n");
85 break;
86 }
87 time = time >> 8;
88 }
89}
90
91static void ds1374_check_rtc_status(void)
92{
93 s32 tmp;
94
95 tmp = i2c_smbus_read_byte_data(save_client, DS1374_REG_SR);
96 if (tmp < 0) {
97 dev_warn(&save_client->dev,
98 "can't read status from rtc chip\n");
99 return;
100 }
101 if (tmp & DS1374_REG_SR_OSF) {
102 dev_warn(&save_client->dev,
103 "oscillator discontinuity flagged, time unreliable\n");
104 tmp &= ~DS1374_REG_SR_OSF;
105 tmp = i2c_smbus_write_byte_data(save_client, DS1374_REG_SR,
106 tmp & 0xff);
107 if (tmp < 0)
108 dev_warn(&save_client->dev,
109 "can't clear discontinuity notification\n");
110 }
111}
112
113ulong ds1374_get_rtc_time(void)
114{
115 ulong t1, t2;
116 int limit = 10; /* arbitrary retry limit */
117
118 down(&ds1374_mutex);
119
120 /*
121 * Since the reads are being performed one byte at a time using
122 * the SMBus vs a 4-byte i2c transfer, there is a chance that a
123 * carry will occur during the read. To detect this, 2 reads are
124 * performed and compared.
125 */
126 do {
127 t1 = ds1374_read_rtc();
128 t2 = ds1374_read_rtc();
129 } while (t1 != t2 && limit--);
130
131 up(&ds1374_mutex);
132
133 if (t1 != t2) {
134 dev_warn(&save_client->dev,
135 "can't get consistent time from rtc chip\n");
136 t1 = 0;
137 }
138
139 return t1;
140}
141
142static void ds1374_set_tlet(ulong arg)
143{
144 ulong t1, t2;
145 int limit = 10; /* arbitrary retry limit */
146
147 t1 = *(ulong *) arg;
148
149 down(&ds1374_mutex);
150
151 /*
152 * Since the writes are being performed one byte at a time using
153 * the SMBus vs a 4-byte i2c transfer, there is a chance that a
154 * carry will occur during the write. To detect this, the write
155 * value is read back and compared.
156 */
157 do {
158 ds1374_write_rtc(t1);
159 t2 = ds1374_read_rtc();
160 } while (t1 != t2 && limit--);
161
162 up(&ds1374_mutex);
163
164 if (t1 != t2)
165 dev_warn(&save_client->dev,
166 "can't confirm time set from rtc chip\n");
167}
168
169ulong new_time;
170
171DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, (ulong) & new_time);
172
173int ds1374_set_rtc_time(ulong nowtime)
174{
175 new_time = nowtime;
176
177 if (in_interrupt())
178 tasklet_schedule(&ds1374_tasklet);
179 else
180 ds1374_set_tlet((ulong) & new_time);
181
182 return 0;
183}
184
185/*
186 *****************************************************************************
187 *
188 * Driver Interface
189 *
190 *****************************************************************************
191 */
192static int ds1374_probe(struct i2c_adapter *adap, int addr, int kind)
193{
194 struct i2c_client *client;
195 int rc;
196
197 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
198 if (!client)
199 return -ENOMEM;
200
201 memset(client, 0, sizeof(struct i2c_client));
202 strncpy(client->name, DS1374_DRV_NAME, I2C_NAME_SIZE);
203 client->flags = I2C_DF_NOTIFY;
204 client->addr = addr;
205 client->adapter = adap;
206 client->driver = &ds1374_driver;
207
208 if ((rc = i2c_attach_client(client)) != 0) {
209 kfree(client);
210 return rc;
211 }
212
213 save_client = client;
214
215 ds1374_check_rtc_status();
216
217 return 0;
218}
219
220static int ds1374_attach(struct i2c_adapter *adap)
221{
222 return i2c_probe(adap, &addr_data, ds1374_probe);
223}
224
225static int ds1374_detach(struct i2c_client *client)
226{
227 int rc;
228
229 if ((rc = i2c_detach_client(client)) == 0) {
230 kfree(i2c_get_clientdata(client));
231 tasklet_kill(&ds1374_tasklet);
232 }
233 return rc;
234}
235
236static struct i2c_driver ds1374_driver = {
237 .owner = THIS_MODULE,
238 .name = DS1374_DRV_NAME,
239 .id = I2C_DRIVERID_DS1374,
240 .flags = I2C_DF_NOTIFY,
241 .attach_adapter = ds1374_attach,
242 .detach_client = ds1374_detach,
243};
244
245static int __init ds1374_init(void)
246{
247 return i2c_add_driver(&ds1374_driver);
248}
249
250static void __exit ds1374_exit(void)
251{
252 i2c_del_driver(&ds1374_driver);
253}
254
255module_init(ds1374_init);
256module_exit(ds1374_exit);
257
258MODULE_AUTHOR("Randy Vinson <rvinson@mvista.com>");
259MODULE_DESCRIPTION("Maxim/Dallas DS1374 RTC I2C Client Driver");
260MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/chips/ds1621.c b/drivers/i2c/chips/ds1621.c
index 4ae15bd5dcfb..5360d58804f6 100644
--- a/drivers/i2c/chips/ds1621.c
+++ b/drivers/i2c/chips/ds1621.c
@@ -121,7 +121,7 @@ static int ds1621_write_value(struct i2c_client *client, u8 reg, u16 value)
121static void ds1621_init_client(struct i2c_client *client) 121static void ds1621_init_client(struct i2c_client *client)
122{ 122{
123 int reg = ds1621_read_value(client, DS1621_REG_CONF); 123 int reg = ds1621_read_value(client, DS1621_REG_CONF);
124 /* switch to continous conversion mode */ 124 /* switch to continuous conversion mode */
125 reg &= ~ DS1621_REG_CONFIG_1SHOT; 125 reg &= ~ DS1621_REG_CONFIG_1SHOT;
126 126
127 /* setup output polarity */ 127 /* setup output polarity */
@@ -303,7 +303,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev)
303 data->temp_max = ds1621_read_value(client, 303 data->temp_max = ds1621_read_value(client,
304 DS1621_REG_TEMP_MAX); 304 DS1621_REG_TEMP_MAX);
305 305
306 /* reset alarms if neccessary */ 306 /* reset alarms if necessary */
307 new_conf = data->conf; 307 new_conf = data->conf;
308 if (data->temp < data->temp_min) 308 if (data->temp < data->temp_min)
309 new_conf &= ~DS1621_ALARM_TEMP_LOW; 309 new_conf &= ~DS1621_ALARM_TEMP_LOW;
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
index cbdfa2db6f7c..addf0adc24d4 100644
--- a/drivers/i2c/chips/eeprom.c
+++ b/drivers/i2c/chips/eeprom.c
@@ -26,7 +26,6 @@
26 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27*/ 27*/
28 28
29#include <linux/config.h>
30#include <linux/kernel.h> 29#include <linux/kernel.h>
31#include <linux/init.h> 30#include <linux/init.h>
32#include <linux/module.h> 31#include <linux/module.h>
diff --git a/drivers/i2c/chips/fscher.c b/drivers/i2c/chips/fscher.c
index c3f37dbec11a..da411741c2c5 100644
--- a/drivers/i2c/chips/fscher.c
+++ b/drivers/i2c/chips/fscher.c
@@ -26,7 +26,6 @@
26 * and Philip Edelbrock <phil@netroedge.com> 26 * and Philip Edelbrock <phil@netroedge.com>
27 */ 27 */
28 28
29#include <linux/config.h>
30#include <linux/module.h> 29#include <linux/module.h>
31#include <linux/init.h> 30#include <linux/init.h>
32#include <linux/slab.h> 31#include <linux/slab.h>
diff --git a/drivers/i2c/chips/gl518sm.c b/drivers/i2c/chips/gl518sm.c
index 4316a1562251..6bedf729dcf5 100644
--- a/drivers/i2c/chips/gl518sm.c
+++ b/drivers/i2c/chips/gl518sm.c
@@ -36,7 +36,6 @@
36 * 2004-01-31 Code review and approval. (Jean Delvare) 36 * 2004-01-31 Code review and approval. (Jean Delvare)
37 */ 37 */
38 38
39#include <linux/config.h>
40#include <linux/module.h> 39#include <linux/module.h>
41#include <linux/init.h> 40#include <linux/init.h>
42#include <linux/slab.h> 41#include <linux/slab.h>
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c
index 7f29a8aff165..354a26295672 100644
--- a/drivers/i2c/chips/isp1301_omap.c
+++ b/drivers/i2c/chips/isp1301_omap.c
@@ -145,7 +145,6 @@ static inline void notresponding(struct isp1301 *isp)
145static unsigned short normal_i2c[] = { 145static unsigned short normal_i2c[] = {
146 ISP_BASE, ISP_BASE + 1, 146 ISP_BASE, ISP_BASE + 1,
147 I2C_CLIENT_END }; 147 I2C_CLIENT_END };
148static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
149 148
150I2C_CLIENT_INSMOD; 149I2C_CLIENT_INSMOD;
151 150
diff --git a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c
index 007bdf9e7e2a..db20c9e47393 100644
--- a/drivers/i2c/chips/it87.c
+++ b/drivers/i2c/chips/it87.c
@@ -31,7 +31,6 @@
31 type at module load time. 31 type at module load time.
32*/ 32*/
33 33
34#include <linux/config.h>
35#include <linux/module.h> 34#include <linux/module.h>
36#include <linux/init.h> 35#include <linux/init.h>
37#include <linux/slab.h> 36#include <linux/slab.h>
@@ -39,6 +38,7 @@
39#include <linux/i2c.h> 38#include <linux/i2c.h>
40#include <linux/i2c-sensor.h> 39#include <linux/i2c-sensor.h>
41#include <linux/i2c-vid.h> 40#include <linux/i2c-vid.h>
41#include <linux/hwmon-sysfs.h>
42#include <asm/io.h> 42#include <asm/io.h>
43 43
44 44
@@ -173,8 +173,6 @@ static inline u8 FAN_TO_REG(long rpm, int div)
173 ((val)+500)/1000),-128,127)) 173 ((val)+500)/1000),-128,127))
174#define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*1000) 174#define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*1000)
175 175
176#define ALARMS_FROM_REG(val) (val)
177
178#define PWM_TO_REG(val) ((val) >> 1) 176#define PWM_TO_REG(val) ((val) >> 1)
179#define PWM_FROM_REG(val) (((val)&0x7f) << 1) 177#define PWM_FROM_REG(val) (((val)&0x7f) << 1)
180 178
@@ -241,27 +239,42 @@ static struct i2c_driver it87_driver = {
241 .detach_client = it87_detach_client, 239 .detach_client = it87_detach_client,
242}; 240};
243 241
244static ssize_t show_in(struct device *dev, char *buf, int nr) 242static ssize_t show_in(struct device *dev, struct device_attribute *attr,
243 char *buf)
245{ 244{
245 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
246 int nr = sensor_attr->index;
247
246 struct it87_data *data = it87_update_device(dev); 248 struct it87_data *data = it87_update_device(dev);
247 return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr])); 249 return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr]));
248} 250}
249 251
250static ssize_t show_in_min(struct device *dev, char *buf, int nr) 252static ssize_t show_in_min(struct device *dev, struct device_attribute *attr,
253 char *buf)
251{ 254{
255 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
256 int nr = sensor_attr->index;
257
252 struct it87_data *data = it87_update_device(dev); 258 struct it87_data *data = it87_update_device(dev);
253 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr])); 259 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr]));
254} 260}
255 261
256static ssize_t show_in_max(struct device *dev, char *buf, int nr) 262static ssize_t show_in_max(struct device *dev, struct device_attribute *attr,
263 char *buf)
257{ 264{
265 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
266 int nr = sensor_attr->index;
267
258 struct it87_data *data = it87_update_device(dev); 268 struct it87_data *data = it87_update_device(dev);
259 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr])); 269 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr]));
260} 270}
261 271
262static ssize_t set_in_min(struct device *dev, const char *buf, 272static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
263 size_t count, int nr) 273 const char *buf, size_t count)
264{ 274{
275 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
276 int nr = sensor_attr->index;
277
265 struct i2c_client *client = to_i2c_client(dev); 278 struct i2c_client *client = to_i2c_client(dev);
266 struct it87_data *data = i2c_get_clientdata(client); 279 struct it87_data *data = i2c_get_clientdata(client);
267 unsigned long val = simple_strtoul(buf, NULL, 10); 280 unsigned long val = simple_strtoul(buf, NULL, 10);
@@ -273,9 +286,12 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
273 up(&data->update_lock); 286 up(&data->update_lock);
274 return count; 287 return count;
275} 288}
276static ssize_t set_in_max(struct device *dev, const char *buf, 289static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
277 size_t count, int nr) 290 const char *buf, size_t count)
278{ 291{
292 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
293 int nr = sensor_attr->index;
294
279 struct i2c_client *client = to_i2c_client(dev); 295 struct i2c_client *client = to_i2c_client(dev);
280 struct it87_data *data = i2c_get_clientdata(client); 296 struct it87_data *data = i2c_get_clientdata(client);
281 unsigned long val = simple_strtoul(buf, NULL, 10); 297 unsigned long val = simple_strtoul(buf, NULL, 10);
@@ -289,38 +305,14 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
289} 305}
290 306
291#define show_in_offset(offset) \ 307#define show_in_offset(offset) \
292static ssize_t \ 308static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \
293 show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 309 show_in, NULL, offset);
294{ \
295 return show_in(dev, buf, offset); \
296} \
297static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL);
298 310
299#define limit_in_offset(offset) \ 311#define limit_in_offset(offset) \
300static ssize_t \ 312static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
301 show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ 313 show_in_min, set_in_min, offset); \
302{ \ 314static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
303 return show_in_min(dev, buf, offset); \ 315 show_in_max, set_in_max, offset);
304} \
305static ssize_t \
306 show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \
307{ \
308 return show_in_max(dev, buf, offset); \
309} \
310static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \
311 const char *buf, size_t count) \
312{ \
313 return set_in_min(dev, buf, count, offset); \
314} \
315static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \
316 const char *buf, size_t count) \
317{ \
318 return set_in_max(dev, buf, count, offset); \
319} \
320static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
321 show_in##offset##_min, set_in##offset##_min); \
322static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
323 show_in##offset##_max, set_in##offset##_max);
324 316
325show_in_offset(0); 317show_in_offset(0);
326limit_in_offset(0); 318limit_in_offset(0);
@@ -341,24 +333,39 @@ limit_in_offset(7);
341show_in_offset(8); 333show_in_offset(8);
342 334
343/* 3 temperatures */ 335/* 3 temperatures */
344static ssize_t show_temp(struct device *dev, char *buf, int nr) 336static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
337 char *buf)
345{ 338{
339 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
340 int nr = sensor_attr->index;
341
346 struct it87_data *data = it87_update_device(dev); 342 struct it87_data *data = it87_update_device(dev);
347 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])); 343 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr]));
348} 344}
349static ssize_t show_temp_max(struct device *dev, char *buf, int nr) 345static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr,
346 char *buf)
350{ 347{
348 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
349 int nr = sensor_attr->index;
350
351 struct it87_data *data = it87_update_device(dev); 351 struct it87_data *data = it87_update_device(dev);
352 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[nr])); 352 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[nr]));
353} 353}
354static ssize_t show_temp_min(struct device *dev, char *buf, int nr) 354static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr,
355 char *buf)
355{ 356{
357 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
358 int nr = sensor_attr->index;
359
356 struct it87_data *data = it87_update_device(dev); 360 struct it87_data *data = it87_update_device(dev);
357 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[nr])); 361 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[nr]));
358} 362}
359static ssize_t set_temp_max(struct device *dev, const char *buf, 363static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
360 size_t count, int nr) 364 const char *buf, size_t count)
361{ 365{
366 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
367 int nr = sensor_attr->index;
368
362 struct i2c_client *client = to_i2c_client(dev); 369 struct i2c_client *client = to_i2c_client(dev);
363 struct it87_data *data = i2c_get_clientdata(client); 370 struct it87_data *data = i2c_get_clientdata(client);
364 int val = simple_strtol(buf, NULL, 10); 371 int val = simple_strtol(buf, NULL, 10);
@@ -369,9 +376,12 @@ static ssize_t set_temp_max(struct device *dev, const char *buf,
369 up(&data->update_lock); 376 up(&data->update_lock);
370 return count; 377 return count;
371} 378}
372static ssize_t set_temp_min(struct device *dev, const char *buf, 379static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
373 size_t count, int nr) 380 const char *buf, size_t count)
374{ 381{
382 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
383 int nr = sensor_attr->index;
384
375 struct i2c_client *client = to_i2c_client(dev); 385 struct i2c_client *client = to_i2c_client(dev);
376 struct it87_data *data = i2c_get_clientdata(client); 386 struct it87_data *data = i2c_get_clientdata(client);
377 int val = simple_strtol(buf, NULL, 10); 387 int val = simple_strtol(buf, NULL, 10);
@@ -383,42 +393,23 @@ static ssize_t set_temp_min(struct device *dev, const char *buf,
383 return count; 393 return count;
384} 394}
385#define show_temp_offset(offset) \ 395#define show_temp_offset(offset) \
386static ssize_t show_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 396static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
387{ \ 397 show_temp, NULL, offset - 1); \
388 return show_temp(dev, buf, offset - 1); \ 398static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
389} \ 399 show_temp_max, set_temp_max, offset - 1); \
390static ssize_t \ 400static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
391show_temp_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ 401 show_temp_min, set_temp_min, offset - 1);
392{ \
393 return show_temp_max(dev, buf, offset - 1); \
394} \
395static ssize_t \
396show_temp_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \
397{ \
398 return show_temp_min(dev, buf, offset - 1); \
399} \
400static ssize_t set_temp_##offset##_max (struct device *dev, struct device_attribute *attr, \
401 const char *buf, size_t count) \
402{ \
403 return set_temp_max(dev, buf, count, offset - 1); \
404} \
405static ssize_t set_temp_##offset##_min (struct device *dev, struct device_attribute *attr, \
406 const char *buf, size_t count) \
407{ \
408 return set_temp_min(dev, buf, count, offset - 1); \
409} \
410static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL); \
411static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
412 show_temp_##offset##_max, set_temp_##offset##_max); \
413static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
414 show_temp_##offset##_min, set_temp_##offset##_min);
415 402
416show_temp_offset(1); 403show_temp_offset(1);
417show_temp_offset(2); 404show_temp_offset(2);
418show_temp_offset(3); 405show_temp_offset(3);
419 406
420static ssize_t show_sensor(struct device *dev, char *buf, int nr) 407static ssize_t show_sensor(struct device *dev, struct device_attribute *attr,
408 char *buf)
421{ 409{
410 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
411 int nr = sensor_attr->index;
412
422 struct it87_data *data = it87_update_device(dev); 413 struct it87_data *data = it87_update_device(dev);
423 u8 reg = data->sensor; /* In case the value is updated while we use it */ 414 u8 reg = data->sensor; /* In case the value is updated while we use it */
424 415
@@ -428,9 +419,12 @@ static ssize_t show_sensor(struct device *dev, char *buf, int nr)
428 return sprintf(buf, "2\n"); /* thermistor */ 419 return sprintf(buf, "2\n"); /* thermistor */
429 return sprintf(buf, "0\n"); /* disabled */ 420 return sprintf(buf, "0\n"); /* disabled */
430} 421}
431static ssize_t set_sensor(struct device *dev, const char *buf, 422static ssize_t set_sensor(struct device *dev, struct device_attribute *attr,
432 size_t count, int nr) 423 const char *buf, size_t count)
433{ 424{
425 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
426 int nr = sensor_attr->index;
427
434 struct i2c_client *client = to_i2c_client(dev); 428 struct i2c_client *client = to_i2c_client(dev);
435 struct it87_data *data = i2c_get_clientdata(client); 429 struct it87_data *data = i2c_get_clientdata(client);
436 int val = simple_strtol(buf, NULL, 10); 430 int val = simple_strtol(buf, NULL, 10);
@@ -453,53 +447,67 @@ static ssize_t set_sensor(struct device *dev, const char *buf,
453 return count; 447 return count;
454} 448}
455#define show_sensor_offset(offset) \ 449#define show_sensor_offset(offset) \
456static ssize_t show_sensor_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 450static SENSOR_DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \
457{ \ 451 show_sensor, set_sensor, offset - 1);
458 return show_sensor(dev, buf, offset - 1); \
459} \
460static ssize_t set_sensor_##offset (struct device *dev, struct device_attribute *attr, \
461 const char *buf, size_t count) \
462{ \
463 return set_sensor(dev, buf, count, offset - 1); \
464} \
465static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \
466 show_sensor_##offset, set_sensor_##offset);
467 452
468show_sensor_offset(1); 453show_sensor_offset(1);
469show_sensor_offset(2); 454show_sensor_offset(2);
470show_sensor_offset(3); 455show_sensor_offset(3);
471 456
472/* 3 Fans */ 457/* 3 Fans */
473static ssize_t show_fan(struct device *dev, char *buf, int nr) 458static ssize_t show_fan(struct device *dev, struct device_attribute *attr,
459 char *buf)
474{ 460{
461 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
462 int nr = sensor_attr->index;
463
475 struct it87_data *data = it87_update_device(dev); 464 struct it87_data *data = it87_update_device(dev);
476 return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], 465 return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr],
477 DIV_FROM_REG(data->fan_div[nr]))); 466 DIV_FROM_REG(data->fan_div[nr])));
478} 467}
479static ssize_t show_fan_min(struct device *dev, char *buf, int nr) 468static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr,
469 char *buf)
480{ 470{
471 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
472 int nr = sensor_attr->index;
473
481 struct it87_data *data = it87_update_device(dev); 474 struct it87_data *data = it87_update_device(dev);
482 return sprintf(buf,"%d\n", 475 return sprintf(buf,"%d\n",
483 FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr]))); 476 FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])));
484} 477}
485static ssize_t show_fan_div(struct device *dev, char *buf, int nr) 478static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr,
479 char *buf)
486{ 480{
481 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
482 int nr = sensor_attr->index;
483
487 struct it87_data *data = it87_update_device(dev); 484 struct it87_data *data = it87_update_device(dev);
488 return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr])); 485 return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr]));
489} 486}
490static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr) 487static ssize_t show_pwm_enable(struct device *dev, struct device_attribute *attr,
488 char *buf)
491{ 489{
490 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
491 int nr = sensor_attr->index;
492
492 struct it87_data *data = it87_update_device(dev); 493 struct it87_data *data = it87_update_device(dev);
493 return sprintf(buf,"%d\n", (data->fan_main_ctrl & (1 << nr)) ? 1 : 0); 494 return sprintf(buf,"%d\n", (data->fan_main_ctrl & (1 << nr)) ? 1 : 0);
494} 495}
495static ssize_t show_pwm(struct device *dev, char *buf, int nr) 496static ssize_t show_pwm(struct device *dev, struct device_attribute *attr,
497 char *buf)
496{ 498{
499 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
500 int nr = sensor_attr->index;
501
497 struct it87_data *data = it87_update_device(dev); 502 struct it87_data *data = it87_update_device(dev);
498 return sprintf(buf,"%d\n", data->manual_pwm_ctl[nr]); 503 return sprintf(buf,"%d\n", data->manual_pwm_ctl[nr]);
499} 504}
500static ssize_t set_fan_min(struct device *dev, const char *buf, 505static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
501 size_t count, int nr) 506 const char *buf, size_t count)
502{ 507{
508 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
509 int nr = sensor_attr->index;
510
503 struct i2c_client *client = to_i2c_client(dev); 511 struct i2c_client *client = to_i2c_client(dev);
504 struct it87_data *data = i2c_get_clientdata(client); 512 struct it87_data *data = i2c_get_clientdata(client);
505 int val = simple_strtol(buf, NULL, 10); 513 int val = simple_strtol(buf, NULL, 10);
@@ -510,9 +518,12 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
510 up(&data->update_lock); 518 up(&data->update_lock);
511 return count; 519 return count;
512} 520}
513static ssize_t set_fan_div(struct device *dev, const char *buf, 521static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
514 size_t count, int nr) 522 const char *buf, size_t count)
515{ 523{
524 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
525 int nr = sensor_attr->index;
526
516 struct i2c_client *client = to_i2c_client(dev); 527 struct i2c_client *client = to_i2c_client(dev);
517 struct it87_data *data = i2c_get_clientdata(client); 528 struct it87_data *data = i2c_get_clientdata(client);
518 int val = simple_strtol(buf, NULL, 10); 529 int val = simple_strtol(buf, NULL, 10);
@@ -550,9 +561,12 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
550 up(&data->update_lock); 561 up(&data->update_lock);
551 return count; 562 return count;
552} 563}
553static ssize_t set_pwm_enable(struct device *dev, const char *buf, 564static ssize_t set_pwm_enable(struct device *dev,
554 size_t count, int nr) 565 struct device_attribute *attr, const char *buf, size_t count)
555{ 566{
567 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
568 int nr = sensor_attr->index;
569
556 struct i2c_client *client = to_i2c_client(dev); 570 struct i2c_client *client = to_i2c_client(dev);
557 struct it87_data *data = i2c_get_clientdata(client); 571 struct it87_data *data = i2c_get_clientdata(client);
558 int val = simple_strtol(buf, NULL, 10); 572 int val = simple_strtol(buf, NULL, 10);
@@ -581,9 +595,12 @@ static ssize_t set_pwm_enable(struct device *dev, const char *buf,
581 up(&data->update_lock); 595 up(&data->update_lock);
582 return count; 596 return count;
583} 597}
584static ssize_t set_pwm(struct device *dev, const char *buf, 598static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
585 size_t count, int nr) 599 const char *buf, size_t count)
586{ 600{
601 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
602 int nr = sensor_attr->index;
603
587 struct i2c_client *client = to_i2c_client(dev); 604 struct i2c_client *client = to_i2c_client(dev);
588 struct it87_data *data = i2c_get_clientdata(client); 605 struct it87_data *data = i2c_get_clientdata(client);
589 int val = simple_strtol(buf, NULL, 10); 606 int val = simple_strtol(buf, NULL, 10);
@@ -599,64 +616,23 @@ static ssize_t set_pwm(struct device *dev, const char *buf,
599 return count; 616 return count;
600} 617}
601 618
602#define show_fan_offset(offset) \ 619#define show_fan_offset(offset) \
603static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 620static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
604{ \ 621 show_fan, NULL, offset - 1); \
605 return show_fan(dev, buf, offset - 1); \ 622static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
606} \ 623 show_fan_min, set_fan_min, offset - 1); \
607static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ 624static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
608{ \ 625 show_fan_div, set_fan_div, offset - 1);
609 return show_fan_min(dev, buf, offset - 1); \
610} \
611static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \
612{ \
613 return show_fan_div(dev, buf, offset - 1); \
614} \
615static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \
616 const char *buf, size_t count) \
617{ \
618 return set_fan_min(dev, buf, count, offset - 1); \
619} \
620static ssize_t set_fan_##offset##_div (struct device *dev, struct device_attribute *attr, \
621 const char *buf, size_t count) \
622{ \
623 return set_fan_div(dev, buf, count, offset - 1); \
624} \
625static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL); \
626static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
627 show_fan_##offset##_min, set_fan_##offset##_min); \
628static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
629 show_fan_##offset##_div, set_fan_##offset##_div);
630 626
631show_fan_offset(1); 627show_fan_offset(1);
632show_fan_offset(2); 628show_fan_offset(2);
633show_fan_offset(3); 629show_fan_offset(3);
634 630
635#define show_pwm_offset(offset) \ 631#define show_pwm_offset(offset) \
636static ssize_t show_pwm##offset##_enable (struct device *dev, struct device_attribute *attr, \ 632static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \
637 char *buf) \ 633 show_pwm_enable, set_pwm_enable, offset - 1); \
638{ \ 634static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
639 return show_pwm_enable(dev, buf, offset - 1); \ 635 show_pwm, set_pwm, offset - 1);
640} \
641static ssize_t show_pwm##offset (struct device *dev, struct device_attribute *attr, char *buf) \
642{ \
643 return show_pwm(dev, buf, offset - 1); \
644} \
645static ssize_t set_pwm##offset##_enable (struct device *dev, struct device_attribute *attr, \
646 const char *buf, size_t count) \
647{ \
648 return set_pwm_enable(dev, buf, count, offset - 1); \
649} \
650static ssize_t set_pwm##offset (struct device *dev, struct device_attribute *attr, \
651 const char *buf, size_t count) \
652{ \
653 return set_pwm(dev, buf, count, offset - 1); \
654} \
655static DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \
656 show_pwm##offset##_enable, \
657 set_pwm##offset##_enable); \
658static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
659 show_pwm##offset , set_pwm##offset );
660 636
661show_pwm_offset(1); 637show_pwm_offset(1);
662show_pwm_offset(2); 638show_pwm_offset(2);
@@ -666,7 +642,7 @@ show_pwm_offset(3);
666static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 642static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)
667{ 643{
668 struct it87_data *data = it87_update_device(dev); 644 struct it87_data *data = it87_update_device(dev);
669 return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms)); 645 return sprintf(buf, "%u\n", data->alarms);
670} 646}
671static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 647static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
672 648
@@ -864,60 +840,60 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
864 it87_init_client(new_client, data); 840 it87_init_client(new_client, data);
865 841
866 /* Register sysfs hooks */ 842 /* Register sysfs hooks */
867 device_create_file(&new_client->dev, &dev_attr_in0_input); 843 device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr);
868 device_create_file(&new_client->dev, &dev_attr_in1_input); 844 device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr);
869 device_create_file(&new_client->dev, &dev_attr_in2_input); 845 device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr);
870 device_create_file(&new_client->dev, &dev_attr_in3_input); 846 device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr);
871 device_create_file(&new_client->dev, &dev_attr_in4_input); 847 device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr);
872 device_create_file(&new_client->dev, &dev_attr_in5_input); 848 device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr);
873 device_create_file(&new_client->dev, &dev_attr_in6_input); 849 device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr);
874 device_create_file(&new_client->dev, &dev_attr_in7_input); 850 device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr);
875 device_create_file(&new_client->dev, &dev_attr_in8_input); 851 device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr);
876 device_create_file(&new_client->dev, &dev_attr_in0_min); 852 device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr);
877 device_create_file(&new_client->dev, &dev_attr_in1_min); 853 device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr);
878 device_create_file(&new_client->dev, &dev_attr_in2_min); 854 device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr);
879 device_create_file(&new_client->dev, &dev_attr_in3_min); 855 device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr);
880 device_create_file(&new_client->dev, &dev_attr_in4_min); 856 device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr);
881 device_create_file(&new_client->dev, &dev_attr_in5_min); 857 device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr);
882 device_create_file(&new_client->dev, &dev_attr_in6_min); 858 device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr);
883 device_create_file(&new_client->dev, &dev_attr_in7_min); 859 device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr);
884 device_create_file(&new_client->dev, &dev_attr_in0_max); 860 device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr);
885 device_create_file(&new_client->dev, &dev_attr_in1_max); 861 device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr);
886 device_create_file(&new_client->dev, &dev_attr_in2_max); 862 device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr);
887 device_create_file(&new_client->dev, &dev_attr_in3_max); 863 device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr);
888 device_create_file(&new_client->dev, &dev_attr_in4_max); 864 device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr);
889 device_create_file(&new_client->dev, &dev_attr_in5_max); 865 device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr);
890 device_create_file(&new_client->dev, &dev_attr_in6_max); 866 device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr);
891 device_create_file(&new_client->dev, &dev_attr_in7_max); 867 device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr);
892 device_create_file(&new_client->dev, &dev_attr_temp1_input); 868 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr);
893 device_create_file(&new_client->dev, &dev_attr_temp2_input); 869 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr);
894 device_create_file(&new_client->dev, &dev_attr_temp3_input); 870 device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr);
895 device_create_file(&new_client->dev, &dev_attr_temp1_max); 871 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr);
896 device_create_file(&new_client->dev, &dev_attr_temp2_max); 872 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr);
897 device_create_file(&new_client->dev, &dev_attr_temp3_max); 873 device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr);
898 device_create_file(&new_client->dev, &dev_attr_temp1_min); 874 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr);
899 device_create_file(&new_client->dev, &dev_attr_temp2_min); 875 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr);
900 device_create_file(&new_client->dev, &dev_attr_temp3_min); 876 device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr);
901 device_create_file(&new_client->dev, &dev_attr_temp1_type); 877 device_create_file(&new_client->dev, &sensor_dev_attr_temp1_type.dev_attr);
902 device_create_file(&new_client->dev, &dev_attr_temp2_type); 878 device_create_file(&new_client->dev, &sensor_dev_attr_temp2_type.dev_attr);
903 device_create_file(&new_client->dev, &dev_attr_temp3_type); 879 device_create_file(&new_client->dev, &sensor_dev_attr_temp3_type.dev_attr);
904 device_create_file(&new_client->dev, &dev_attr_fan1_input); 880 device_create_file(&new_client->dev, &sensor_dev_attr_fan1_input.dev_attr);
905 device_create_file(&new_client->dev, &dev_attr_fan2_input); 881 device_create_file(&new_client->dev, &sensor_dev_attr_fan2_input.dev_attr);
906 device_create_file(&new_client->dev, &dev_attr_fan3_input); 882 device_create_file(&new_client->dev, &sensor_dev_attr_fan3_input.dev_attr);
907 device_create_file(&new_client->dev, &dev_attr_fan1_min); 883 device_create_file(&new_client->dev, &sensor_dev_attr_fan1_min.dev_attr);
908 device_create_file(&new_client->dev, &dev_attr_fan2_min); 884 device_create_file(&new_client->dev, &sensor_dev_attr_fan2_min.dev_attr);
909 device_create_file(&new_client->dev, &dev_attr_fan3_min); 885 device_create_file(&new_client->dev, &sensor_dev_attr_fan3_min.dev_attr);
910 device_create_file(&new_client->dev, &dev_attr_fan1_div); 886 device_create_file(&new_client->dev, &sensor_dev_attr_fan1_div.dev_attr);
911 device_create_file(&new_client->dev, &dev_attr_fan2_div); 887 device_create_file(&new_client->dev, &sensor_dev_attr_fan2_div.dev_attr);
912 device_create_file(&new_client->dev, &dev_attr_fan3_div); 888 device_create_file(&new_client->dev, &sensor_dev_attr_fan3_div.dev_attr);
913 device_create_file(&new_client->dev, &dev_attr_alarms); 889 device_create_file(&new_client->dev, &dev_attr_alarms);
914 if (enable_pwm_interface) { 890 if (enable_pwm_interface) {
915 device_create_file(&new_client->dev, &dev_attr_pwm1_enable); 891 device_create_file(&new_client->dev, &sensor_dev_attr_pwm1_enable.dev_attr);
916 device_create_file(&new_client->dev, &dev_attr_pwm2_enable); 892 device_create_file(&new_client->dev, &sensor_dev_attr_pwm2_enable.dev_attr);
917 device_create_file(&new_client->dev, &dev_attr_pwm3_enable); 893 device_create_file(&new_client->dev, &sensor_dev_attr_pwm3_enable.dev_attr);
918 device_create_file(&new_client->dev, &dev_attr_pwm1); 894 device_create_file(&new_client->dev, &sensor_dev_attr_pwm1.dev_attr);
919 device_create_file(&new_client->dev, &dev_attr_pwm2); 895 device_create_file(&new_client->dev, &sensor_dev_attr_pwm2.dev_attr);
920 device_create_file(&new_client->dev, &dev_attr_pwm3); 896 device_create_file(&new_client->dev, &sensor_dev_attr_pwm3.dev_attr);
921 } 897 }
922 898
923 if (data->type == it8712) { 899 if (data->type == it8712) {
@@ -954,7 +930,7 @@ static int it87_detach_client(struct i2c_client *client)
954 return 0; 930 return 0;
955} 931}
956 932
957/* The SMBus locks itself, but ISA access must be locked explicitely! 933/* The SMBus locks itself, but ISA access must be locked explicitly!
958 We don't want to lock the whole ISA bus, so we lock each client 934 We don't want to lock the whole ISA bus, so we lock each client
959 separately. 935 separately.
960 We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, 936 We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks,
@@ -974,7 +950,7 @@ static int it87_read_value(struct i2c_client *client, u8 reg)
974 return i2c_smbus_read_byte_data(client, reg); 950 return i2c_smbus_read_byte_data(client, reg);
975} 951}
976 952
977/* The SMBus locks itself, but ISA access muse be locked explicitely! 953/* The SMBus locks itself, but ISA access muse be locked explicitly!
978 We don't want to lock the whole ISA bus, so we lock each client 954 We don't want to lock the whole ISA bus, so we lock each client
979 separately. 955 separately.
980 We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, 956 We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks,
diff --git a/drivers/i2c/chips/lm63.c b/drivers/i2c/chips/lm63.c
index bc68e031392b..7c6f9ea5a254 100644
--- a/drivers/i2c/chips/lm63.c
+++ b/drivers/i2c/chips/lm63.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * lm63.c - driver for the National Semiconductor LM63 temperature sensor 2 * lm63.c - driver for the National Semiconductor LM63 temperature sensor
3 * with integrated fan control 3 * with integrated fan control
4 * Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> 4 * Copyright (C) 2004-2005 Jean Delvare <khali@linux-fr.org>
5 * Based on the lm90 driver. 5 * Based on the lm90 driver.
6 * 6 *
7 * The LM63 is a sensor chip made by National Semiconductor. It measures 7 * The LM63 is a sensor chip made by National Semiconductor. It measures
@@ -37,13 +37,13 @@
37 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 37 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
38 */ 38 */
39 39
40#include <linux/config.h>
41#include <linux/module.h> 40#include <linux/module.h>
42#include <linux/init.h> 41#include <linux/init.h>
43#include <linux/slab.h> 42#include <linux/slab.h>
44#include <linux/jiffies.h> 43#include <linux/jiffies.h>
45#include <linux/i2c.h> 44#include <linux/i2c.h>
46#include <linux/i2c-sensor.h> 45#include <linux/i2c-sensor.h>
46#include <linux/hwmon-sysfs.h>
47 47
48/* 48/*
49 * Addresses to scan 49 * Addresses to scan
@@ -99,9 +99,9 @@ SENSORS_INSMOD_1(lm63);
99 * Conversions and various macros 99 * Conversions and various macros
100 * For tachometer counts, the LM63 uses 16-bit values. 100 * For tachometer counts, the LM63 uses 16-bit values.
101 * For local temperature and high limit, remote critical limit and hysteresis 101 * For local temperature and high limit, remote critical limit and hysteresis
102 * value, it uses signed 8-bit values with LSB = 1 degree Celcius. 102 * value, it uses signed 8-bit values with LSB = 1 degree Celsius.
103 * For remote temperature, low and high limits, it uses signed 11-bit values 103 * For remote temperature, low and high limits, it uses signed 11-bit values
104 * with LSB = 0.125 degree Celcius, left-justified in 16-bit registers. 104 * with LSB = 0.125 degree Celsius, left-justified in 16-bit registers.
105 */ 105 */
106 106
107#define FAN_FROM_REG(reg) ((reg) == 0xFFFC || (reg) == 0 ? 0 : \ 107#define FAN_FROM_REG(reg) ((reg) == 0xFFFC || (reg) == 0 ? 0 : \
@@ -158,16 +158,16 @@ struct lm63_data {
158 158
159 /* registers values */ 159 /* registers values */
160 u8 config, config_fan; 160 u8 config, config_fan;
161 u16 fan1_input; 161 u16 fan[2]; /* 0: input
162 u16 fan1_low; 162 1: low limit */
163 u8 pwm1_freq; 163 u8 pwm1_freq;
164 u8 pwm1_value; 164 u8 pwm1_value;
165 s8 temp1_input; 165 s8 temp8[3]; /* 0: local input
166 s8 temp1_high; 166 1: local high limit
167 s16 temp2_input; 167 2: remote critical limit */
168 s16 temp2_high; 168 s16 temp11[3]; /* 0: remote input
169 s16 temp2_low; 169 1: remote low limit
170 s8 temp2_crit; 170 2: remote high limit */
171 u8 temp2_crit_hyst; 171 u8 temp2_crit_hyst;
172 u8 alarms; 172 u8 alarms;
173}; 173};
@@ -176,33 +176,33 @@ struct lm63_data {
176 * Sysfs callback functions and files 176 * Sysfs callback functions and files
177 */ 177 */
178 178
179#define show_fan(value) \ 179static ssize_t show_fan(struct device *dev, struct device_attribute *devattr,
180static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ 180 char *buf)
181{ \ 181{
182 struct lm63_data *data = lm63_update_device(dev); \ 182 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
183 return sprintf(buf, "%d\n", FAN_FROM_REG(data->value)); \ 183 struct lm63_data *data = lm63_update_device(dev);
184 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index]));
184} 185}
185show_fan(fan1_input);
186show_fan(fan1_low);
187 186
188static ssize_t set_fan1_low(struct device *dev, struct device_attribute *attr, const char *buf, 187static ssize_t set_fan(struct device *dev, struct device_attribute *dummy,
189 size_t count) 188 const char *buf, size_t count)
190{ 189{
191 struct i2c_client *client = to_i2c_client(dev); 190 struct i2c_client *client = to_i2c_client(dev);
192 struct lm63_data *data = i2c_get_clientdata(client); 191 struct lm63_data *data = i2c_get_clientdata(client);
193 unsigned long val = simple_strtoul(buf, NULL, 10); 192 unsigned long val = simple_strtoul(buf, NULL, 10);
194 193
195 down(&data->update_lock); 194 down(&data->update_lock);
196 data->fan1_low = FAN_TO_REG(val); 195 data->fan[1] = FAN_TO_REG(val);
197 i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB, 196 i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB,
198 data->fan1_low & 0xFF); 197 data->fan[1] & 0xFF);
199 i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB, 198 i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB,
200 data->fan1_low >> 8); 199 data->fan[1] >> 8);
201 up(&data->update_lock); 200 up(&data->update_lock);
202 return count; 201 return count;
203} 202}
204 203
205static ssize_t show_pwm1(struct device *dev, struct device_attribute *attr, char *buf) 204static ssize_t show_pwm1(struct device *dev, struct device_attribute *dummy,
205 char *buf)
206{ 206{
207 struct lm63_data *data = lm63_update_device(dev); 207 struct lm63_data *data = lm63_update_device(dev);
208 return sprintf(buf, "%d\n", data->pwm1_value >= 2 * data->pwm1_freq ? 208 return sprintf(buf, "%d\n", data->pwm1_value >= 2 * data->pwm1_freq ?
@@ -210,7 +210,8 @@ static ssize_t show_pwm1(struct device *dev, struct device_attribute *attr, char
210 (2 * data->pwm1_freq)); 210 (2 * data->pwm1_freq));
211} 211}
212 212
213static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 213static ssize_t set_pwm1(struct device *dev, struct device_attribute *dummy,
214 const char *buf, size_t count)
214{ 215{
215 struct i2c_client *client = to_i2c_client(dev); 216 struct i2c_client *client = to_i2c_client(dev);
216 struct lm63_data *data = i2c_get_clientdata(client); 217 struct lm63_data *data = i2c_get_clientdata(client);
@@ -229,77 +230,83 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const
229 return count; 230 return count;
230} 231}
231 232
232static ssize_t show_pwm1_enable(struct device *dev, struct device_attribute *attr, char *buf) 233static ssize_t show_pwm1_enable(struct device *dev, struct device_attribute *dummy,
234 char *buf)
233{ 235{
234 struct lm63_data *data = lm63_update_device(dev); 236 struct lm63_data *data = lm63_update_device(dev);
235 return sprintf(buf, "%d\n", data->config_fan & 0x20 ? 1 : 2); 237 return sprintf(buf, "%d\n", data->config_fan & 0x20 ? 1 : 2);
236} 238}
237 239
238#define show_temp8(value) \ 240static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr,
239static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ 241 char *buf)
240{ \ 242{
241 struct lm63_data *data = lm63_update_device(dev); \ 243 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
242 return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->value)); \ 244 struct lm63_data *data = lm63_update_device(dev);
245 return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[attr->index]));
243} 246}
244#define show_temp11(value) \ 247
245static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ 248static ssize_t set_temp8(struct device *dev, struct device_attribute *dummy,
246{ \ 249 const char *buf, size_t count)
247 struct lm63_data *data = lm63_update_device(dev); \ 250{
248 return sprintf(buf, "%d\n", TEMP11_FROM_REG(data->value)); \ 251 struct i2c_client *client = to_i2c_client(dev);
252 struct lm63_data *data = i2c_get_clientdata(client);
253 long val = simple_strtol(buf, NULL, 10);
254
255 down(&data->update_lock);
256 data->temp8[1] = TEMP8_TO_REG(val);
257 i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]);
258 up(&data->update_lock);
259 return count;
249} 260}
250show_temp8(temp1_input); 261
251show_temp8(temp1_high); 262static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr,
252show_temp11(temp2_input); 263 char *buf)
253show_temp11(temp2_high); 264{
254show_temp11(temp2_low); 265 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
255show_temp8(temp2_crit); 266 struct lm63_data *data = lm63_update_device(dev);
256 267 return sprintf(buf, "%d\n", TEMP11_FROM_REG(data->temp11[attr->index]));
257#define set_temp8(value, reg) \
258static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \
259 size_t count) \
260{ \
261 struct i2c_client *client = to_i2c_client(dev); \
262 struct lm63_data *data = i2c_get_clientdata(client); \
263 long val = simple_strtol(buf, NULL, 10); \
264 \
265 down(&data->update_lock); \
266 data->value = TEMP8_TO_REG(val); \
267 i2c_smbus_write_byte_data(client, reg, data->value); \
268 up(&data->update_lock); \
269 return count; \
270} 268}
271#define set_temp11(value, reg_msb, reg_lsb) \ 269
272static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ 270static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
273 size_t count) \ 271 const char *buf, size_t count)
274{ \ 272{
275 struct i2c_client *client = to_i2c_client(dev); \ 273 static const u8 reg[4] = {
276 struct lm63_data *data = i2c_get_clientdata(client); \ 274 LM63_REG_REMOTE_LOW_MSB,
277 long val = simple_strtol(buf, NULL, 10); \ 275 LM63_REG_REMOTE_LOW_LSB,
278 \ 276 LM63_REG_REMOTE_HIGH_MSB,
279 down(&data->update_lock); \ 277 LM63_REG_REMOTE_HIGH_LSB,
280 data->value = TEMP11_TO_REG(val); \ 278 };
281 i2c_smbus_write_byte_data(client, reg_msb, data->value >> 8); \ 279
282 i2c_smbus_write_byte_data(client, reg_lsb, data->value & 0xff); \ 280 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
283 up(&data->update_lock); \ 281 struct i2c_client *client = to_i2c_client(dev);
284 return count; \ 282 struct lm63_data *data = i2c_get_clientdata(client);
283 long val = simple_strtol(buf, NULL, 10);
284 int nr = attr->index;
285
286 down(&data->update_lock);
287 data->temp11[nr] = TEMP11_TO_REG(val);
288 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2],
289 data->temp11[nr] >> 8);
290 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1],
291 data->temp11[nr] & 0xff);
292 up(&data->update_lock);
293 return count;
285} 294}
286set_temp8(temp1_high, LM63_REG_LOCAL_HIGH);
287set_temp11(temp2_high, LM63_REG_REMOTE_HIGH_MSB, LM63_REG_REMOTE_HIGH_LSB);
288set_temp11(temp2_low, LM63_REG_REMOTE_LOW_MSB, LM63_REG_REMOTE_LOW_LSB);
289 295
290/* Hysteresis register holds a relative value, while we want to present 296/* Hysteresis register holds a relative value, while we want to present
291 an absolute to user-space */ 297 an absolute to user-space */
292static ssize_t show_temp2_crit_hyst(struct device *dev, struct device_attribute *attr, char *buf) 298static ssize_t show_temp2_crit_hyst(struct device *dev, struct device_attribute *dummy,
299 char *buf)
293{ 300{
294 struct lm63_data *data = lm63_update_device(dev); 301 struct lm63_data *data = lm63_update_device(dev);
295 return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp2_crit) 302 return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[2])
296 - TEMP8_FROM_REG(data->temp2_crit_hyst)); 303 - TEMP8_FROM_REG(data->temp2_crit_hyst));
297} 304}
298 305
299/* And now the other way around, user-space provides an absolute 306/* And now the other way around, user-space provides an absolute
300 hysteresis value and we have to store a relative one */ 307 hysteresis value and we have to store a relative one */
301static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *attr, const char *buf, 308static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *dummy,
302 size_t count) 309 const char *buf, size_t count)
303{ 310{
304 struct i2c_client *client = to_i2c_client(dev); 311 struct i2c_client *client = to_i2c_client(dev);
305 struct lm63_data *data = i2c_get_clientdata(client); 312 struct lm63_data *data = i2c_get_clientdata(client);
@@ -307,36 +314,37 @@ static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *
307 long hyst; 314 long hyst;
308 315
309 down(&data->update_lock); 316 down(&data->update_lock);
310 hyst = TEMP8_FROM_REG(data->temp2_crit) - val; 317 hyst = TEMP8_FROM_REG(data->temp8[2]) - val;
311 i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, 318 i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST,
312 HYST_TO_REG(hyst)); 319 HYST_TO_REG(hyst));
313 up(&data->update_lock); 320 up(&data->update_lock);
314 return count; 321 return count;
315} 322}
316 323
317static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 324static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy,
325 char *buf)
318{ 326{
319 struct lm63_data *data = lm63_update_device(dev); 327 struct lm63_data *data = lm63_update_device(dev);
320 return sprintf(buf, "%u\n", data->alarms); 328 return sprintf(buf, "%u\n", data->alarms);
321} 329}
322 330
323static DEVICE_ATTR(fan1_input, S_IRUGO, show_fan1_input, NULL); 331static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0);
324static DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan1_low, 332static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan,
325 set_fan1_low); 333 set_fan, 1);
326 334
327static DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm1, set_pwm1); 335static DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm1, set_pwm1);
328static DEVICE_ATTR(pwm1_enable, S_IRUGO, show_pwm1_enable, NULL); 336static DEVICE_ATTR(pwm1_enable, S_IRUGO, show_pwm1_enable, NULL);
329 337
330static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1_input, NULL); 338static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp8, NULL, 0);
331static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp1_high, 339static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp8,
332 set_temp1_high); 340 set_temp8, 1);
333 341
334static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp2_input, NULL); 342static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp11, NULL, 0);
335static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp2_low, 343static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp11,
336 set_temp2_low); 344 set_temp11, 1);
337static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp2_high, 345static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp11,
338 set_temp2_high); 346 set_temp11, 2);
339static DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp2_crit, NULL); 347static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp8, NULL, 2);
340static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp2_crit_hyst, 348static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp2_crit_hyst,
341 set_temp2_crit_hyst); 349 set_temp2_crit_hyst);
342 350
@@ -430,17 +438,25 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
430 438
431 /* Register sysfs hooks */ 439 /* Register sysfs hooks */
432 if (data->config & 0x04) { /* tachometer enabled */ 440 if (data->config & 0x04) { /* tachometer enabled */
433 device_create_file(&new_client->dev, &dev_attr_fan1_input); 441 device_create_file(&new_client->dev,
434 device_create_file(&new_client->dev, &dev_attr_fan1_min); 442 &sensor_dev_attr_fan1_input.dev_attr);
443 device_create_file(&new_client->dev,
444 &sensor_dev_attr_fan1_min.dev_attr);
435 } 445 }
436 device_create_file(&new_client->dev, &dev_attr_pwm1); 446 device_create_file(&new_client->dev, &dev_attr_pwm1);
437 device_create_file(&new_client->dev, &dev_attr_pwm1_enable); 447 device_create_file(&new_client->dev, &dev_attr_pwm1_enable);
438 device_create_file(&new_client->dev, &dev_attr_temp1_input); 448 device_create_file(&new_client->dev,
439 device_create_file(&new_client->dev, &dev_attr_temp2_input); 449 &sensor_dev_attr_temp1_input.dev_attr);
440 device_create_file(&new_client->dev, &dev_attr_temp2_min); 450 device_create_file(&new_client->dev,
441 device_create_file(&new_client->dev, &dev_attr_temp1_max); 451 &sensor_dev_attr_temp2_input.dev_attr);
442 device_create_file(&new_client->dev, &dev_attr_temp2_max); 452 device_create_file(&new_client->dev,
443 device_create_file(&new_client->dev, &dev_attr_temp2_crit); 453 &sensor_dev_attr_temp2_min.dev_attr);
454 device_create_file(&new_client->dev,
455 &sensor_dev_attr_temp1_max.dev_attr);
456 device_create_file(&new_client->dev,
457 &sensor_dev_attr_temp2_max.dev_attr);
458 device_create_file(&new_client->dev,
459 &sensor_dev_attr_temp2_crit.dev_attr);
444 device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst); 460 device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst);
445 device_create_file(&new_client->dev, &dev_attr_alarms); 461 device_create_file(&new_client->dev, &dev_attr_alarms);
446 462
@@ -511,14 +527,14 @@ static struct lm63_data *lm63_update_device(struct device *dev)
511 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { 527 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
512 if (data->config & 0x04) { /* tachometer enabled */ 528 if (data->config & 0x04) { /* tachometer enabled */
513 /* order matters for fan1_input */ 529 /* order matters for fan1_input */
514 data->fan1_input = i2c_smbus_read_byte_data(client, 530 data->fan[0] = i2c_smbus_read_byte_data(client,
515 LM63_REG_TACH_COUNT_LSB) & 0xFC; 531 LM63_REG_TACH_COUNT_LSB) & 0xFC;
516 data->fan1_input |= i2c_smbus_read_byte_data(client, 532 data->fan[0] |= i2c_smbus_read_byte_data(client,
517 LM63_REG_TACH_COUNT_MSB) << 8; 533 LM63_REG_TACH_COUNT_MSB) << 8;
518 data->fan1_low = (i2c_smbus_read_byte_data(client, 534 data->fan[1] = (i2c_smbus_read_byte_data(client,
519 LM63_REG_TACH_LIMIT_LSB) & 0xFC) 535 LM63_REG_TACH_LIMIT_LSB) & 0xFC)
520 | (i2c_smbus_read_byte_data(client, 536 | (i2c_smbus_read_byte_data(client,
521 LM63_REG_TACH_LIMIT_MSB) << 8); 537 LM63_REG_TACH_LIMIT_MSB) << 8);
522 } 538 }
523 539
524 data->pwm1_freq = i2c_smbus_read_byte_data(client, 540 data->pwm1_freq = i2c_smbus_read_byte_data(client,
@@ -528,26 +544,26 @@ static struct lm63_data *lm63_update_device(struct device *dev)
528 data->pwm1_value = i2c_smbus_read_byte_data(client, 544 data->pwm1_value = i2c_smbus_read_byte_data(client,
529 LM63_REG_PWM_VALUE); 545 LM63_REG_PWM_VALUE);
530 546
531 data->temp1_input = i2c_smbus_read_byte_data(client, 547 data->temp8[0] = i2c_smbus_read_byte_data(client,
532 LM63_REG_LOCAL_TEMP); 548 LM63_REG_LOCAL_TEMP);
533 data->temp1_high = i2c_smbus_read_byte_data(client, 549 data->temp8[1] = i2c_smbus_read_byte_data(client,
534 LM63_REG_LOCAL_HIGH); 550 LM63_REG_LOCAL_HIGH);
535 551
536 /* order matters for temp2_input */ 552 /* order matters for temp2_input */
537 data->temp2_input = i2c_smbus_read_byte_data(client, 553 data->temp11[0] = i2c_smbus_read_byte_data(client,
538 LM63_REG_REMOTE_TEMP_MSB) << 8; 554 LM63_REG_REMOTE_TEMP_MSB) << 8;
539 data->temp2_input |= i2c_smbus_read_byte_data(client, 555 data->temp11[0] |= i2c_smbus_read_byte_data(client,
540 LM63_REG_REMOTE_TEMP_LSB); 556 LM63_REG_REMOTE_TEMP_LSB);
541 data->temp2_high = (i2c_smbus_read_byte_data(client, 557 data->temp11[1] = (i2c_smbus_read_byte_data(client,
542 LM63_REG_REMOTE_HIGH_MSB) << 8)
543 | i2c_smbus_read_byte_data(client,
544 LM63_REG_REMOTE_HIGH_LSB);
545 data->temp2_low = (i2c_smbus_read_byte_data(client,
546 LM63_REG_REMOTE_LOW_MSB) << 8) 558 LM63_REG_REMOTE_LOW_MSB) << 8)
547 | i2c_smbus_read_byte_data(client, 559 | i2c_smbus_read_byte_data(client,
548 LM63_REG_REMOTE_LOW_LSB); 560 LM63_REG_REMOTE_LOW_LSB);
549 data->temp2_crit = i2c_smbus_read_byte_data(client, 561 data->temp11[2] = (i2c_smbus_read_byte_data(client,
550 LM63_REG_REMOTE_TCRIT); 562 LM63_REG_REMOTE_HIGH_MSB) << 8)
563 | i2c_smbus_read_byte_data(client,
564 LM63_REG_REMOTE_HIGH_LSB);
565 data->temp8[2] = i2c_smbus_read_byte_data(client,
566 LM63_REG_REMOTE_TCRIT);
551 data->temp2_crit_hyst = i2c_smbus_read_byte_data(client, 567 data->temp2_crit_hyst = i2c_smbus_read_byte_data(client,
552 LM63_REG_REMOTE_TCRIT_HYST); 568 LM63_REG_REMOTE_TCRIT_HYST);
553 569
diff --git a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c
index 57c51ac37c04..5be164ed278e 100644
--- a/drivers/i2c/chips/lm75.c
+++ b/drivers/i2c/chips/lm75.c
@@ -18,7 +18,6 @@
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/ 19*/
20 20
21#include <linux/config.h>
22#include <linux/module.h> 21#include <linux/module.h>
23#include <linux/init.h> 22#include <linux/init.h>
24#include <linux/slab.h> 23#include <linux/slab.h>
diff --git a/drivers/i2c/chips/lm77.c b/drivers/i2c/chips/lm77.c
index 9d15cd5189f6..b98f44952997 100644
--- a/drivers/i2c/chips/lm77.c
+++ b/drivers/i2c/chips/lm77.c
@@ -25,7 +25,6 @@
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26*/ 26*/
27 27
28#include <linux/config.h>
29#include <linux/module.h> 28#include <linux/module.h>
30#include <linux/init.h> 29#include <linux/init.h>
31#include <linux/slab.h> 30#include <linux/slab.h>
diff --git a/drivers/i2c/chips/lm78.c b/drivers/i2c/chips/lm78.c
index 21b195ff3871..29241469dcba 100644
--- a/drivers/i2c/chips/lm78.c
+++ b/drivers/i2c/chips/lm78.c
@@ -18,7 +18,6 @@
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/ 19*/
20 20
21#include <linux/config.h>
22#include <linux/module.h> 21#include <linux/module.h>
23#include <linux/init.h> 22#include <linux/init.h>
24#include <linux/slab.h> 23#include <linux/slab.h>
@@ -671,7 +670,7 @@ static int lm78_detach_client(struct i2c_client *client)
671 return 0; 670 return 0;
672} 671}
673 672
674/* The SMBus locks itself, but ISA access must be locked explicitely! 673/* The SMBus locks itself, but ISA access must be locked explicitly!
675 We don't want to lock the whole ISA bus, so we lock each client 674 We don't want to lock the whole ISA bus, so we lock each client
676 separately. 675 separately.
677 We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks, 676 We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks,
@@ -690,7 +689,7 @@ static int lm78_read_value(struct i2c_client *client, u8 reg)
690 return i2c_smbus_read_byte_data(client, reg); 689 return i2c_smbus_read_byte_data(client, reg);
691} 690}
692 691
693/* The SMBus locks itself, but ISA access muse be locked explicitely! 692/* The SMBus locks itself, but ISA access muse be locked explicitly!
694 We don't want to lock the whole ISA bus, so we lock each client 693 We don't want to lock the whole ISA bus, so we lock each client
695 separately. 694 separately.
696 We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks, 695 We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks,
diff --git a/drivers/i2c/chips/lm80.c b/drivers/i2c/chips/lm80.c
index 404057b70e90..8100595feb44 100644
--- a/drivers/i2c/chips/lm80.c
+++ b/drivers/i2c/chips/lm80.c
@@ -21,7 +21,6 @@
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 22 */
23 23
24#include <linux/config.h>
25#include <linux/module.h> 24#include <linux/module.h>
26#include <linux/init.h> 25#include <linux/init.h>
27#include <linux/slab.h> 26#include <linux/slab.h>
diff --git a/drivers/i2c/chips/lm83.c b/drivers/i2c/chips/lm83.c
index 4d6d7d21e14b..a49008b444c8 100644
--- a/drivers/i2c/chips/lm83.c
+++ b/drivers/i2c/chips/lm83.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * lm83.c - Part of lm_sensors, Linux kernel modules for hardware 2 * lm83.c - Part of lm_sensors, Linux kernel modules for hardware
3 * monitoring 3 * monitoring
4 * Copyright (C) 2003 Jean Delvare <khali@linux-fr.org> 4 * Copyright (C) 2003-2005 Jean Delvare <khali@linux-fr.org>
5 * 5 *
6 * Heavily inspired from the lm78, lm75 and adm1021 drivers. The LM83 is 6 * Heavily inspired from the lm78, lm75 and adm1021 drivers. The LM83 is
7 * a sensor chip made by National Semiconductor. It reports up to four 7 * a sensor chip made by National Semiconductor. It reports up to four
@@ -27,13 +27,13 @@
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 */ 28 */
29 29
30#include <linux/config.h>
31#include <linux/module.h> 30#include <linux/module.h>
32#include <linux/init.h> 31#include <linux/init.h>
33#include <linux/slab.h> 32#include <linux/slab.h>
34#include <linux/jiffies.h> 33#include <linux/jiffies.h>
35#include <linux/i2c.h> 34#include <linux/i2c.h>
36#include <linux/i2c-sensor.h> 35#include <linux/i2c-sensor.h>
36#include <linux/hwmon-sysfs.h>
37 37
38/* 38/*
39 * Addresses to scan 39 * Addresses to scan
@@ -81,7 +81,7 @@ SENSORS_INSMOD_1(lm83);
81 81
82/* 82/*
83 * Conversions and various macros 83 * Conversions and various macros
84 * The LM83 uses signed 8-bit values with LSB = 1 degree Celcius. 84 * The LM83 uses signed 8-bit values with LSB = 1 degree Celsius.
85 */ 85 */
86 86
87#define TEMP_FROM_REG(val) ((val) * 1000) 87#define TEMP_FROM_REG(val) ((val) * 1000)
@@ -94,21 +94,20 @@ static const u8 LM83_REG_R_TEMP[] = {
94 LM83_REG_R_LOCAL_TEMP, 94 LM83_REG_R_LOCAL_TEMP,
95 LM83_REG_R_REMOTE1_TEMP, 95 LM83_REG_R_REMOTE1_TEMP,
96 LM83_REG_R_REMOTE2_TEMP, 96 LM83_REG_R_REMOTE2_TEMP,
97 LM83_REG_R_REMOTE3_TEMP 97 LM83_REG_R_REMOTE3_TEMP,
98};
99
100static const u8 LM83_REG_R_HIGH[] = {
101 LM83_REG_R_LOCAL_HIGH, 98 LM83_REG_R_LOCAL_HIGH,
102 LM83_REG_R_REMOTE1_HIGH, 99 LM83_REG_R_REMOTE1_HIGH,
103 LM83_REG_R_REMOTE2_HIGH, 100 LM83_REG_R_REMOTE2_HIGH,
104 LM83_REG_R_REMOTE3_HIGH 101 LM83_REG_R_REMOTE3_HIGH,
102 LM83_REG_R_TCRIT,
105}; 103};
106 104
107static const u8 LM83_REG_W_HIGH[] = { 105static const u8 LM83_REG_W_HIGH[] = {
108 LM83_REG_W_LOCAL_HIGH, 106 LM83_REG_W_LOCAL_HIGH,
109 LM83_REG_W_REMOTE1_HIGH, 107 LM83_REG_W_REMOTE1_HIGH,
110 LM83_REG_W_REMOTE2_HIGH, 108 LM83_REG_W_REMOTE2_HIGH,
111 LM83_REG_W_REMOTE3_HIGH 109 LM83_REG_W_REMOTE3_HIGH,
110 LM83_REG_W_TCRIT,
112}; 111};
113 112
114/* 113/*
@@ -144,9 +143,9 @@ struct lm83_data {
144 unsigned long last_updated; /* in jiffies */ 143 unsigned long last_updated; /* in jiffies */
145 144
146 /* registers values */ 145 /* registers values */
147 s8 temp_input[4]; 146 s8 temp[9]; /* 0..3: input 1-4,
148 s8 temp_high[4]; 147 4..7: high limit 1-4,
149 s8 temp_crit; 148 8 : critical limit */
150 u16 alarms; /* bitvector, combined */ 149 u16 alarms; /* bitvector, combined */
151}; 150};
152 151
@@ -154,65 +153,55 @@ struct lm83_data {
154 * Sysfs stuff 153 * Sysfs stuff
155 */ 154 */
156 155
157#define show_temp(suffix, value) \ 156static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
158static ssize_t show_temp_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \ 157 char *buf)
159{ \ 158{
160 struct lm83_data *data = lm83_update_device(dev); \ 159 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
161 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \ 160 struct lm83_data *data = lm83_update_device(dev);
161 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index]));
162} 162}
163show_temp(input1, temp_input[0]); 163
164show_temp(input2, temp_input[1]); 164static ssize_t set_temp(struct device *dev, struct device_attribute *devattr,
165show_temp(input3, temp_input[2]); 165 const char *buf, size_t count)
166show_temp(input4, temp_input[3]); 166{
167show_temp(high1, temp_high[0]); 167 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
168show_temp(high2, temp_high[1]); 168 struct i2c_client *client = to_i2c_client(dev);
169show_temp(high3, temp_high[2]); 169 struct lm83_data *data = i2c_get_clientdata(client);
170show_temp(high4, temp_high[3]); 170 long val = simple_strtol(buf, NULL, 10);
171show_temp(crit, temp_crit); 171 int nr = attr->index;
172 172
173#define set_temp(suffix, value, reg) \ 173 down(&data->update_lock);
174static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \ 174 data->temp[nr] = TEMP_TO_REG(val);
175 size_t count) \ 175 i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4],
176{ \ 176 data->temp[nr]);
177 struct i2c_client *client = to_i2c_client(dev); \ 177 up(&data->update_lock);
178 struct lm83_data *data = i2c_get_clientdata(client); \ 178 return count;
179 long val = simple_strtol(buf, NULL, 10); \
180 \
181 down(&data->update_lock); \
182 data->value = TEMP_TO_REG(val); \
183 i2c_smbus_write_byte_data(client, reg, data->value); \
184 up(&data->update_lock); \
185 return count; \
186} 179}
187set_temp(high1, temp_high[0], LM83_REG_W_LOCAL_HIGH);
188set_temp(high2, temp_high[1], LM83_REG_W_REMOTE1_HIGH);
189set_temp(high3, temp_high[2], LM83_REG_W_REMOTE2_HIGH);
190set_temp(high4, temp_high[3], LM83_REG_W_REMOTE3_HIGH);
191set_temp(crit, temp_crit, LM83_REG_W_TCRIT);
192 180
193static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 181static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy,
182 char *buf)
194{ 183{
195 struct lm83_data *data = lm83_update_device(dev); 184 struct lm83_data *data = lm83_update_device(dev);
196 return sprintf(buf, "%d\n", data->alarms); 185 return sprintf(buf, "%d\n", data->alarms);
197} 186}
198 187
199static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL); 188static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
200static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input2, NULL); 189static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1);
201static DEVICE_ATTR(temp3_input, S_IRUGO, show_temp_input3, NULL); 190static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2);
202static DEVICE_ATTR(temp4_input, S_IRUGO, show_temp_input4, NULL); 191static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3);
203static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_high1, 192static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp,
204 set_temp_high1); 193 set_temp, 4);
205static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_high2, 194static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp,
206 set_temp_high2); 195 set_temp, 5);
207static DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp_high3, 196static SENSOR_DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp,
208 set_temp_high3); 197 set_temp, 6);
209static DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_temp_high4, 198static SENSOR_DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_temp,
210 set_temp_high4); 199 set_temp, 7);
211static DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp_crit, NULL); 200static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp, NULL, 8);
212static DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp_crit, NULL); 201static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp, NULL, 8);
213static DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp_crit, 202static SENSOR_DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp,
214 set_temp_crit); 203 set_temp, 8);
215static DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp_crit, NULL); 204static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp, NULL, 8);
216static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 205static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
217 206
218/* 207/*
@@ -323,18 +312,30 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
323 */ 312 */
324 313
325 /* Register sysfs hooks */ 314 /* Register sysfs hooks */
326 device_create_file(&new_client->dev, &dev_attr_temp1_input); 315 device_create_file(&new_client->dev,
327 device_create_file(&new_client->dev, &dev_attr_temp2_input); 316 &sensor_dev_attr_temp1_input.dev_attr);
328 device_create_file(&new_client->dev, &dev_attr_temp3_input); 317 device_create_file(&new_client->dev,
329 device_create_file(&new_client->dev, &dev_attr_temp4_input); 318 &sensor_dev_attr_temp2_input.dev_attr);
330 device_create_file(&new_client->dev, &dev_attr_temp1_max); 319 device_create_file(&new_client->dev,
331 device_create_file(&new_client->dev, &dev_attr_temp2_max); 320 &sensor_dev_attr_temp3_input.dev_attr);
332 device_create_file(&new_client->dev, &dev_attr_temp3_max); 321 device_create_file(&new_client->dev,
333 device_create_file(&new_client->dev, &dev_attr_temp4_max); 322 &sensor_dev_attr_temp4_input.dev_attr);
334 device_create_file(&new_client->dev, &dev_attr_temp1_crit); 323 device_create_file(&new_client->dev,
335 device_create_file(&new_client->dev, &dev_attr_temp2_crit); 324 &sensor_dev_attr_temp1_max.dev_attr);
336 device_create_file(&new_client->dev, &dev_attr_temp3_crit); 325 device_create_file(&new_client->dev,
337 device_create_file(&new_client->dev, &dev_attr_temp4_crit); 326 &sensor_dev_attr_temp2_max.dev_attr);
327 device_create_file(&new_client->dev,
328 &sensor_dev_attr_temp3_max.dev_attr);
329 device_create_file(&new_client->dev,
330 &sensor_dev_attr_temp4_max.dev_attr);
331 device_create_file(&new_client->dev,
332 &sensor_dev_attr_temp1_crit.dev_attr);
333 device_create_file(&new_client->dev,
334 &sensor_dev_attr_temp2_crit.dev_attr);
335 device_create_file(&new_client->dev,
336 &sensor_dev_attr_temp3_crit.dev_attr);
337 device_create_file(&new_client->dev,
338 &sensor_dev_attr_temp4_crit.dev_attr);
338 device_create_file(&new_client->dev, &dev_attr_alarms); 339 device_create_file(&new_client->dev, &dev_attr_alarms);
339 340
340 return 0; 341 return 0;
@@ -370,16 +371,11 @@ static struct lm83_data *lm83_update_device(struct device *dev)
370 int nr; 371 int nr;
371 372
372 dev_dbg(&client->dev, "Updating lm83 data.\n"); 373 dev_dbg(&client->dev, "Updating lm83 data.\n");
373 for (nr = 0; nr < 4 ; nr++) { 374 for (nr = 0; nr < 9; nr++) {
374 data->temp_input[nr] = 375 data->temp[nr] =
375 i2c_smbus_read_byte_data(client, 376 i2c_smbus_read_byte_data(client,
376 LM83_REG_R_TEMP[nr]); 377 LM83_REG_R_TEMP[nr]);
377 data->temp_high[nr] =
378 i2c_smbus_read_byte_data(client,
379 LM83_REG_R_HIGH[nr]);
380 } 378 }
381 data->temp_crit =
382 i2c_smbus_read_byte_data(client, LM83_REG_R_TCRIT);
383 data->alarms = 379 data->alarms =
384 i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS1) 380 i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS1)
385 + (i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS2) 381 + (i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS2)
diff --git a/drivers/i2c/chips/lm85.c b/drivers/i2c/chips/lm85.c
index b1976775b4ba..b4d7fd418264 100644
--- a/drivers/i2c/chips/lm85.c
+++ b/drivers/i2c/chips/lm85.c
@@ -23,7 +23,6 @@
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24*/ 24*/
25 25
26#include <linux/config.h>
27#include <linux/module.h> 26#include <linux/module.h>
28#include <linux/init.h> 27#include <linux/init.h>
29#include <linux/slab.h> 28#include <linux/slab.h>
@@ -285,8 +284,6 @@ static int ZONE_TO_REG( int zone )
285/* i2c-vid.h defines vid_from_reg() */ 284/* i2c-vid.h defines vid_from_reg() */
286#define VID_FROM_REG(val,vrm) (vid_from_reg((val),(vrm))) 285#define VID_FROM_REG(val,vrm) (vid_from_reg((val),(vrm)))
287 286
288#define ALARMS_FROM_REG(val) (val)
289
290/* Unlike some other drivers we DO NOT set initial limits. Use 287/* Unlike some other drivers we DO NOT set initial limits. Use
291 * the config file to set limits. Some users have reported 288 * the config file to set limits. Some users have reported
292 * motherboards shutting down when we set limits in a previous 289 * motherboards shutting down when we set limits in a previous
@@ -481,7 +478,7 @@ static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
481static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) 478static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)
482{ 479{
483 struct lm85_data *data = lm85_update_device(dev); 480 struct lm85_data *data = lm85_update_device(dev);
484 return sprintf(buf, "%ld\n", (long) ALARMS_FROM_REG(data->alarms)); 481 return sprintf(buf, "%u\n", data->alarms);
485} 482}
486 483
487static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); 484static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
diff --git a/drivers/i2c/chips/lm87.c b/drivers/i2c/chips/lm87.c
index 4372b61a0882..1921ed1af182 100644
--- a/drivers/i2c/chips/lm87.c
+++ b/drivers/i2c/chips/lm87.c
@@ -52,7 +52,6 @@
52 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 52 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
53 */ 53 */
54 54
55#include <linux/config.h>
56#include <linux/module.h> 55#include <linux/module.h>
57#include <linux/init.h> 56#include <linux/init.h>
58#include <linux/slab.h> 57#include <linux/slab.h>
diff --git a/drivers/i2c/chips/lm90.c b/drivers/i2c/chips/lm90.c
index 9b127a07f56b..a67dcadf7cb0 100644
--- a/drivers/i2c/chips/lm90.c
+++ b/drivers/i2c/chips/lm90.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * lm90.c - Part of lm_sensors, Linux kernel modules for hardware 2 * lm90.c - Part of lm_sensors, Linux kernel modules for hardware
3 * monitoring 3 * monitoring
4 * Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org> 4 * Copyright (C) 2003-2005 Jean Delvare <khali@linux-fr.org>
5 * 5 *
6 * Based on the lm83 driver. The LM90 is a sensor chip made by National 6 * Based on the lm83 driver. The LM90 is a sensor chip made by National
7 * Semiconductor. It reports up to two temperatures (its own plus up to 7 * Semiconductor. It reports up to two temperatures (its own plus up to
@@ -19,7 +19,7 @@
19 * Complete datasheets can be obtained from National's website at: 19 * Complete datasheets can be obtained from National's website at:
20 * http://www.national.com/pf/LM/LM89.html 20 * http://www.national.com/pf/LM/LM89.html
21 * http://www.national.com/pf/LM/LM99.html 21 * http://www.national.com/pf/LM/LM99.html
22 * Note that there is no way to differenciate between both chips. 22 * Note that there is no way to differentiate between both chips.
23 * 23 *
24 * This driver also supports the LM86, another sensor chip made by 24 * This driver also supports the LM86, another sensor chip made by
25 * National Semiconductor. It is exactly similar to the LM90 except it 25 * National Semiconductor. It is exactly similar to the LM90 except it
@@ -39,7 +39,7 @@
39 * chips made by Maxim. These chips are similar to the LM86. Complete 39 * chips made by Maxim. These chips are similar to the LM86. Complete
40 * datasheet can be obtained at Maxim's website at: 40 * datasheet can be obtained at Maxim's website at:
41 * http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 41 * http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578
42 * Note that there is no easy way to differenciate between the three 42 * Note that there is no easy way to differentiate between the three
43 * variants. The extra address and features of the MAX6659 are not 43 * variants. The extra address and features of the MAX6659 are not
44 * supported by this driver. 44 * supported by this driver.
45 * 45 *
@@ -70,13 +70,13 @@
70 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 70 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
71 */ 71 */
72 72
73#include <linux/config.h>
74#include <linux/module.h> 73#include <linux/module.h>
75#include <linux/init.h> 74#include <linux/init.h>
76#include <linux/slab.h> 75#include <linux/slab.h>
77#include <linux/jiffies.h> 76#include <linux/jiffies.h>
78#include <linux/i2c.h> 77#include <linux/i2c.h>
79#include <linux/i2c-sensor.h> 78#include <linux/i2c-sensor.h>
79#include <linux/hwmon-sysfs.h>
80 80
81/* 81/*
82 * Addresses to scan 82 * Addresses to scan
@@ -139,9 +139,9 @@ SENSORS_INSMOD_6(lm90, adm1032, lm99, lm86, max6657, adt7461);
139/* 139/*
140 * Conversions and various macros 140 * Conversions and various macros
141 * For local temperatures and limits, critical limits and the hysteresis 141 * For local temperatures and limits, critical limits and the hysteresis
142 * value, the LM90 uses signed 8-bit values with LSB = 1 degree Celcius. 142 * value, the LM90 uses signed 8-bit values with LSB = 1 degree Celsius.
143 * For remote temperatures and limits, it uses signed 11-bit values with 143 * For remote temperatures and limits, it uses signed 11-bit values with
144 * LSB = 0.125 degree Celcius, left-justified in 16-bit registers. 144 * LSB = 0.125 degree Celsius, left-justified in 16-bit registers.
145 */ 145 */
146 146
147#define TEMP1_FROM_REG(val) ((val) * 1000) 147#define TEMP1_FROM_REG(val) ((val) * 1000)
@@ -206,9 +206,14 @@ struct lm90_data {
206 int kind; 206 int kind;
207 207
208 /* registers values */ 208 /* registers values */
209 s8 temp_input1, temp_low1, temp_high1; /* local */ 209 s8 temp8[5]; /* 0: local input
210 s16 temp_input2, temp_low2, temp_high2; /* remote, combined */ 210 1: local low limit
211 s8 temp_crit1, temp_crit2; 211 2: local high limit
212 3: local critical limit
213 4: remote critical limit */
214 s16 temp11[3]; /* 0: remote input
215 1: remote low limit
216 2: remote high limit */
212 u8 temp_hyst; 217 u8 temp_hyst;
213 u8 alarms; /* bitvector */ 218 u8 alarms; /* bitvector */
214}; 219};
@@ -217,75 +222,88 @@ struct lm90_data {
217 * Sysfs stuff 222 * Sysfs stuff
218 */ 223 */
219 224
220#define show_temp(value, converter) \ 225static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr,
221static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ 226 char *buf)
222{ \ 227{
223 struct lm90_data *data = lm90_update_device(dev); \ 228 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
224 return sprintf(buf, "%d\n", converter(data->value)); \ 229 struct lm90_data *data = lm90_update_device(dev);
230 return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp8[attr->index]));
231}
232
233static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr,
234 const char *buf, size_t count)
235{
236 static const u8 reg[4] = {
237 LM90_REG_W_LOCAL_LOW,
238 LM90_REG_W_LOCAL_HIGH,
239 LM90_REG_W_LOCAL_CRIT,
240 LM90_REG_W_REMOTE_CRIT,
241 };
242
243 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
244 struct i2c_client *client = to_i2c_client(dev);
245 struct lm90_data *data = i2c_get_clientdata(client);
246 long val = simple_strtol(buf, NULL, 10);
247 int nr = attr->index;
248
249 down(&data->update_lock);
250 if (data->kind == adt7461)
251 data->temp8[nr] = TEMP1_TO_REG_ADT7461(val);
252 else
253 data->temp8[nr] = TEMP1_TO_REG(val);
254 i2c_smbus_write_byte_data(client, reg[nr - 1], data->temp8[nr]);
255 up(&data->update_lock);
256 return count;
225} 257}
226show_temp(temp_input1, TEMP1_FROM_REG); 258
227show_temp(temp_input2, TEMP2_FROM_REG); 259static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr,
228show_temp(temp_low1, TEMP1_FROM_REG); 260 char *buf)
229show_temp(temp_low2, TEMP2_FROM_REG); 261{
230show_temp(temp_high1, TEMP1_FROM_REG); 262 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
231show_temp(temp_high2, TEMP2_FROM_REG); 263 struct lm90_data *data = lm90_update_device(dev);
232show_temp(temp_crit1, TEMP1_FROM_REG); 264 return sprintf(buf, "%d\n", TEMP2_FROM_REG(data->temp11[attr->index]));
233show_temp(temp_crit2, TEMP1_FROM_REG);
234
235#define set_temp1(value, reg) \
236static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \
237 size_t count) \
238{ \
239 struct i2c_client *client = to_i2c_client(dev); \
240 struct lm90_data *data = i2c_get_clientdata(client); \
241 long val = simple_strtol(buf, NULL, 10); \
242 \
243 down(&data->update_lock); \
244 if (data->kind == adt7461) \
245 data->value = TEMP1_TO_REG_ADT7461(val); \
246 else \
247 data->value = TEMP1_TO_REG(val); \
248 i2c_smbus_write_byte_data(client, reg, data->value); \
249 up(&data->update_lock); \
250 return count; \
251} 265}
252#define set_temp2(value, regh, regl) \ 266
253static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ 267static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
254 size_t count) \ 268 const char *buf, size_t count)
255{ \ 269{
256 struct i2c_client *client = to_i2c_client(dev); \ 270 static const u8 reg[4] = {
257 struct lm90_data *data = i2c_get_clientdata(client); \ 271 LM90_REG_W_REMOTE_LOWH,
258 long val = simple_strtol(buf, NULL, 10); \ 272 LM90_REG_W_REMOTE_LOWL,
259 \ 273 LM90_REG_W_REMOTE_HIGHH,
260 down(&data->update_lock); \ 274 LM90_REG_W_REMOTE_HIGHL,
261 if (data->kind == adt7461) \ 275 };
262 data->value = TEMP2_TO_REG_ADT7461(val); \ 276
263 else \ 277 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
264 data->value = TEMP2_TO_REG(val); \ 278 struct i2c_client *client = to_i2c_client(dev);
265 i2c_smbus_write_byte_data(client, regh, data->value >> 8); \ 279 struct lm90_data *data = i2c_get_clientdata(client);
266 i2c_smbus_write_byte_data(client, regl, data->value & 0xff); \ 280 long val = simple_strtol(buf, NULL, 10);
267 up(&data->update_lock); \ 281 int nr = attr->index;
268 return count; \ 282
283 down(&data->update_lock);
284 if (data->kind == adt7461)
285 data->temp11[nr] = TEMP2_TO_REG_ADT7461(val);
286 else
287 data->temp11[nr] = TEMP2_TO_REG(val);
288 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2],
289 data->temp11[nr] >> 8);
290 i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1],
291 data->temp11[nr] & 0xff);
292 up(&data->update_lock);
293 return count;
269} 294}
270set_temp1(temp_low1, LM90_REG_W_LOCAL_LOW); 295
271set_temp2(temp_low2, LM90_REG_W_REMOTE_LOWH, LM90_REG_W_REMOTE_LOWL); 296static ssize_t show_temphyst(struct device *dev, struct device_attribute *devattr,
272set_temp1(temp_high1, LM90_REG_W_LOCAL_HIGH); 297 char *buf)
273set_temp2(temp_high2, LM90_REG_W_REMOTE_HIGHH, LM90_REG_W_REMOTE_HIGHL); 298{
274set_temp1(temp_crit1, LM90_REG_W_LOCAL_CRIT); 299 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
275set_temp1(temp_crit2, LM90_REG_W_REMOTE_CRIT); 300 struct lm90_data *data = lm90_update_device(dev);
276 301 return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp8[attr->index])
277#define show_temp_hyst(value, basereg) \ 302 - TEMP1_FROM_REG(data->temp_hyst));
278static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \
279{ \
280 struct lm90_data *data = lm90_update_device(dev); \
281 return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->basereg) \
282 - TEMP1_FROM_REG(data->temp_hyst)); \
283} 303}
284show_temp_hyst(temp_hyst1, temp_crit1);
285show_temp_hyst(temp_hyst2, temp_crit2);
286 304
287static ssize_t set_temp_hyst1(struct device *dev, struct device_attribute *attr, const char *buf, 305static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy,
288 size_t count) 306 const char *buf, size_t count)
289{ 307{
290 struct i2c_client *client = to_i2c_client(dev); 308 struct i2c_client *client = to_i2c_client(dev);
291 struct lm90_data *data = i2c_get_clientdata(client); 309 struct lm90_data *data = i2c_get_clientdata(client);
@@ -293,36 +311,37 @@ static ssize_t set_temp_hyst1(struct device *dev, struct device_attribute *attr,
293 long hyst; 311 long hyst;
294 312
295 down(&data->update_lock); 313 down(&data->update_lock);
296 hyst = TEMP1_FROM_REG(data->temp_crit1) - val; 314 hyst = TEMP1_FROM_REG(data->temp8[3]) - val;
297 i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, 315 i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST,
298 HYST_TO_REG(hyst)); 316 HYST_TO_REG(hyst));
299 up(&data->update_lock); 317 up(&data->update_lock);
300 return count; 318 return count;
301} 319}
302 320
303static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 321static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy,
322 char *buf)
304{ 323{
305 struct lm90_data *data = lm90_update_device(dev); 324 struct lm90_data *data = lm90_update_device(dev);
306 return sprintf(buf, "%d\n", data->alarms); 325 return sprintf(buf, "%d\n", data->alarms);
307} 326}
308 327
309static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL); 328static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp8, NULL, 0);
310static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input2, NULL); 329static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp11, NULL, 0);
311static DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp_low1, 330static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp8,
312 set_temp_low1); 331 set_temp8, 1);
313static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_low2, 332static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp11,
314 set_temp_low2); 333 set_temp11, 1);
315static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_high1, 334static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp8,
316 set_temp_high1); 335 set_temp8, 2);
317static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_high2, 336static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp11,
318 set_temp_high2); 337 set_temp11, 2);
319static DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp_crit1, 338static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp8,
320 set_temp_crit1); 339 set_temp8, 3);
321static DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp_crit2, 340static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp8,
322 set_temp_crit2); 341 set_temp8, 4);
323static DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temp_hyst1, 342static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temphyst,
324 set_temp_hyst1); 343 set_temphyst, 3);
325static DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temp_hyst2, NULL); 344static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4);
326static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 345static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
327 346
328/* 347/*
@@ -481,16 +500,26 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
481 lm90_init_client(new_client); 500 lm90_init_client(new_client);
482 501
483 /* Register sysfs hooks */ 502 /* Register sysfs hooks */
484 device_create_file(&new_client->dev, &dev_attr_temp1_input); 503 device_create_file(&new_client->dev,
485 device_create_file(&new_client->dev, &dev_attr_temp2_input); 504 &sensor_dev_attr_temp1_input.dev_attr);
486 device_create_file(&new_client->dev, &dev_attr_temp1_min); 505 device_create_file(&new_client->dev,
487 device_create_file(&new_client->dev, &dev_attr_temp2_min); 506 &sensor_dev_attr_temp2_input.dev_attr);
488 device_create_file(&new_client->dev, &dev_attr_temp1_max); 507 device_create_file(&new_client->dev,
489 device_create_file(&new_client->dev, &dev_attr_temp2_max); 508 &sensor_dev_attr_temp1_min.dev_attr);
490 device_create_file(&new_client->dev, &dev_attr_temp1_crit); 509 device_create_file(&new_client->dev,
491 device_create_file(&new_client->dev, &dev_attr_temp2_crit); 510 &sensor_dev_attr_temp2_min.dev_attr);
492 device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst); 511 device_create_file(&new_client->dev,
493 device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst); 512 &sensor_dev_attr_temp1_max.dev_attr);
513 device_create_file(&new_client->dev,
514 &sensor_dev_attr_temp2_max.dev_attr);
515 device_create_file(&new_client->dev,
516 &sensor_dev_attr_temp1_crit.dev_attr);
517 device_create_file(&new_client->dev,
518 &sensor_dev_attr_temp2_crit.dev_attr);
519 device_create_file(&new_client->dev,
520 &sensor_dev_attr_temp1_crit_hyst.dev_attr);
521 device_create_file(&new_client->dev,
522 &sensor_dev_attr_temp2_crit_hyst.dev_attr);
494 device_create_file(&new_client->dev, &dev_attr_alarms); 523 device_create_file(&new_client->dev, &dev_attr_alarms);
495 524
496 return 0; 525 return 0;
@@ -541,16 +570,16 @@ static struct lm90_data *lm90_update_device(struct device *dev)
541 u8 oldh, newh; 570 u8 oldh, newh;
542 571
543 dev_dbg(&client->dev, "Updating lm90 data.\n"); 572 dev_dbg(&client->dev, "Updating lm90 data.\n");
544 data->temp_input1 = i2c_smbus_read_byte_data(client, 573 data->temp8[0] = i2c_smbus_read_byte_data(client,
545 LM90_REG_R_LOCAL_TEMP); 574 LM90_REG_R_LOCAL_TEMP);
546 data->temp_high1 = i2c_smbus_read_byte_data(client, 575 data->temp8[1] = i2c_smbus_read_byte_data(client,
547 LM90_REG_R_LOCAL_HIGH); 576 LM90_REG_R_LOCAL_LOW);
548 data->temp_low1 = i2c_smbus_read_byte_data(client, 577 data->temp8[2] = i2c_smbus_read_byte_data(client,
549 LM90_REG_R_LOCAL_LOW); 578 LM90_REG_R_LOCAL_HIGH);
550 data->temp_crit1 = i2c_smbus_read_byte_data(client, 579 data->temp8[3] = i2c_smbus_read_byte_data(client,
551 LM90_REG_R_LOCAL_CRIT); 580 LM90_REG_R_LOCAL_CRIT);
552 data->temp_crit2 = i2c_smbus_read_byte_data(client, 581 data->temp8[4] = i2c_smbus_read_byte_data(client,
553 LM90_REG_R_REMOTE_CRIT); 582 LM90_REG_R_REMOTE_CRIT);
554 data->temp_hyst = i2c_smbus_read_byte_data(client, 583 data->temp_hyst = i2c_smbus_read_byte_data(client,
555 LM90_REG_R_TCRIT_HYST); 584 LM90_REG_R_TCRIT_HYST);
556 585
@@ -570,13 +599,13 @@ static struct lm90_data *lm90_update_device(struct device *dev)
570 */ 599 */
571 oldh = i2c_smbus_read_byte_data(client, 600 oldh = i2c_smbus_read_byte_data(client,
572 LM90_REG_R_REMOTE_TEMPH); 601 LM90_REG_R_REMOTE_TEMPH);
573 data->temp_input2 = i2c_smbus_read_byte_data(client, 602 data->temp11[0] = i2c_smbus_read_byte_data(client,
574 LM90_REG_R_REMOTE_TEMPL); 603 LM90_REG_R_REMOTE_TEMPL);
575 newh = i2c_smbus_read_byte_data(client, 604 newh = i2c_smbus_read_byte_data(client,
576 LM90_REG_R_REMOTE_TEMPH); 605 LM90_REG_R_REMOTE_TEMPH);
577 if (newh != oldh) { 606 if (newh != oldh) {
578 data->temp_input2 = i2c_smbus_read_byte_data(client, 607 data->temp11[0] = i2c_smbus_read_byte_data(client,
579 LM90_REG_R_REMOTE_TEMPL); 608 LM90_REG_R_REMOTE_TEMPL);
580#ifdef DEBUG 609#ifdef DEBUG
581 oldh = i2c_smbus_read_byte_data(client, 610 oldh = i2c_smbus_read_byte_data(client,
582 LM90_REG_R_REMOTE_TEMPH); 611 LM90_REG_R_REMOTE_TEMPH);
@@ -586,16 +615,16 @@ static struct lm90_data *lm90_update_device(struct device *dev)
586 "wrong.\n"); 615 "wrong.\n");
587#endif 616#endif
588 } 617 }
589 data->temp_input2 |= (newh << 8); 618 data->temp11[0] |= (newh << 8);
590 619
591 data->temp_high2 = (i2c_smbus_read_byte_data(client, 620 data->temp11[1] = (i2c_smbus_read_byte_data(client,
621 LM90_REG_R_REMOTE_LOWH) << 8) +
622 i2c_smbus_read_byte_data(client,
623 LM90_REG_R_REMOTE_LOWL);
624 data->temp11[2] = (i2c_smbus_read_byte_data(client,
592 LM90_REG_R_REMOTE_HIGHH) << 8) + 625 LM90_REG_R_REMOTE_HIGHH) << 8) +
593 i2c_smbus_read_byte_data(client, 626 i2c_smbus_read_byte_data(client,
594 LM90_REG_R_REMOTE_HIGHL); 627 LM90_REG_R_REMOTE_HIGHL);
595 data->temp_low2 = (i2c_smbus_read_byte_data(client,
596 LM90_REG_R_REMOTE_LOWH) << 8) +
597 i2c_smbus_read_byte_data(client,
598 LM90_REG_R_REMOTE_LOWL);
599 data->alarms = i2c_smbus_read_byte_data(client, 628 data->alarms = i2c_smbus_read_byte_data(client,
600 LM90_REG_R_STATUS); 629 LM90_REG_R_STATUS);
601 630
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c
index e771566dffa8..5e463c47bfbc 100644
--- a/drivers/i2c/chips/m41t00.c
+++ b/drivers/i2c/chips/m41t00.c
@@ -40,11 +40,8 @@ static unsigned short normal_addr[] = { 0x68, I2C_CLIENT_END };
40 40
41static struct i2c_client_address_data addr_data = { 41static struct i2c_client_address_data addr_data = {
42 .normal_i2c = normal_addr, 42 .normal_i2c = normal_addr,
43 .normal_i2c_range = ignore,
44 .probe = ignore, 43 .probe = ignore,
45 .probe_range = ignore,
46 .ignore = ignore, 44 .ignore = ignore,
47 .ignore_range = ignore,
48 .force = ignore, 45 .force = ignore,
49}; 46};
50 47
diff --git a/drivers/i2c/chips/max1619.c b/drivers/i2c/chips/max1619.c
index 30a196155fd9..bf553dcd97d6 100644
--- a/drivers/i2c/chips/max1619.c
+++ b/drivers/i2c/chips/max1619.c
@@ -26,7 +26,6 @@
26 */ 26 */
27 27
28 28
29#include <linux/config.h>
30#include <linux/module.h> 29#include <linux/module.h>
31#include <linux/init.h> 30#include <linux/init.h>
32#include <linux/slab.h> 31#include <linux/slab.h>
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c
new file mode 100644
index 000000000000..fe6b150ec4c2
--- /dev/null
+++ b/drivers/i2c/chips/max6875.c
@@ -0,0 +1,473 @@
1/*
2 max6875.c - driver for MAX6874/MAX6875
3
4 Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com>
5
6 Based on i2c/chips/eeprom.c
7
8 The MAX6875 has two EEPROM sections: config and user.
9 At reset, the config EEPROM is read into the registers.
10
11 This driver make 3 binary files available in sysfs:
12 reg_config - direct access to the registers
13 eeprom_config - acesses configuration eeprom space
14 eeprom_user - free for application use
15
16 In our application, we put device serial & model numbers in user eeprom.
17
18 Notes:
19 1) The datasheet says that register 0x44 / EEPROM 0x8044 should NOT
20 be overwritten, so the driver explicitly prevents that.
21 2) It's a good idea to keep the config (0x45) locked in config EEPROM.
22 You can temporarily enable config writes by changing register 0x45.
23
24 This program is free software; you can redistribute it and/or modify
25 it under the terms of the GNU General Public License as published by
26 the Free Software Foundation; version 2 of the License.
27*/
28
29#include <linux/config.h>
30#include <linux/kernel.h>
31#include <linux/init.h>
32#include <linux/module.h>
33#include <linux/slab.h>
34#include <linux/sched.h>
35#include <linux/delay.h>
36#include <linux/i2c.h>
37#include <linux/i2c-sensor.h>
38
39/* Addresses to scan */
40static unsigned short normal_i2c[] = {0x50, 0x52, I2C_CLIENT_END};
41static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END};
42
43/* Insmod parameters */
44SENSORS_INSMOD_1(max6875);
45
46/* this param will prevent 'accidental' writes to the eeprom */
47static int allow_write = 0;
48module_param(allow_write, int, 0);
49MODULE_PARM_DESC(allow_write,
50 "Enable write access:\n"
51 "*0: Read only\n"
52 " 1: Read/Write access");
53
54/* The MAX6875 can only read/write 16 bytes at a time */
55#define SLICE_SIZE 16
56#define SLICE_BITS 4
57
58/* CONFIG EEPROM is at addresses 0x8000 - 0x8045, registers are at 0 - 0x45 */
59#define CONFIG_EEPROM_BASE 0x8000
60#define CONFIG_EEPROM_SIZE 0x0046
61#define CONFIG_EEPROM_SLICES 5
62
63/* USER EEPROM is at addresses 0x8100 - 0x82FF */
64#define USER_EEPROM_BASE 0x8100
65#define USER_EEPROM_SIZE 0x0200
66#define USER_EEPROM_SLICES 32
67
68/* MAX6875 commands */
69#define MAX6875_CMD_BLOCK_WRITE 0x83
70#define MAX6875_CMD_BLOCK_READ 0x84
71#define MAX6875_CMD_REBOOT 0x88
72
73enum max6875_area_type {
74 max6875_register_config=0,
75 max6875_eeprom_config,
76 max6875_eeprom_user,
77 max6857_max
78};
79
80struct eeprom_block {
81 enum max6875_area_type type;
82 u8 slices;
83 u32 size;
84 u32 valid;
85 u32 base;
86 unsigned long *updated;
87 u8 *data;
88};
89
90/* Each client has this additional data */
91struct max6875_data {
92 struct i2c_client client;
93 struct semaphore update_lock;
94 struct eeprom_block blocks[max6857_max];
95 /* the above structs point into the arrays below */
96 u8 data[USER_EEPROM_SIZE + (CONFIG_EEPROM_SIZE*2)];
97 unsigned long last_updated[USER_EEPROM_SLICES + (CONFIG_EEPROM_SLICES*2)];
98};
99
100static int max6875_attach_adapter(struct i2c_adapter *adapter);
101static int max6875_detect(struct i2c_adapter *adapter, int address, int kind);
102static int max6875_detach_client(struct i2c_client *client);
103
104/* This is the driver that will be inserted */
105static struct i2c_driver max6875_driver = {
106 .owner = THIS_MODULE,
107 .name = "max6875",
108 .flags = I2C_DF_NOTIFY,
109 .attach_adapter = max6875_attach_adapter,
110 .detach_client = max6875_detach_client,
111};
112
113static int max6875_update_slice(struct i2c_client *client,
114 struct eeprom_block *blk,
115 int slice)
116{
117 struct max6875_data *data = i2c_get_clientdata(client);
118 int i, j, addr, count;
119 u8 rdbuf[SLICE_SIZE];
120 int retval = 0;
121
122 if (slice >= blk->slices)
123 return -1;
124
125 down(&data->update_lock);
126
127 if (!(blk->valid & (1 << slice)) ||
128 (jiffies - blk->updated[slice] > 300 * HZ) ||
129 (jiffies < blk->updated[slice])) {
130 dev_dbg(&client->dev, "Starting eeprom update, slice %u, base %u\n",
131 slice, blk->base);
132
133 addr = blk->base + (slice << SLICE_BITS);
134 count = blk->size - (slice << SLICE_BITS);
135 if (count > SLICE_SIZE) {
136 count = SLICE_SIZE;
137 }
138
139 /* Preset the read address */
140 if (addr < 0x100) {
141 /* select the register */
142 if (i2c_smbus_write_byte(client, addr & 0xFF)) {
143 dev_dbg(&client->dev, "max6875 register select has failed!\n");
144 retval = -1;
145 goto exit;
146 }
147 } else {
148 /* select the eeprom */
149 if (i2c_smbus_write_byte_data(client, addr >> 8, addr & 0xFF)) {
150 dev_dbg(&client->dev, "max6875 address set has failed!\n");
151 retval = -1;
152 goto exit;
153 }
154 }
155
156 if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
157 if (i2c_smbus_read_i2c_block_data(client, MAX6875_CMD_BLOCK_READ,
158 rdbuf) != SLICE_SIZE)
159 {
160 retval = -1;
161 goto exit;
162 }
163
164 memcpy(&blk->data[slice << SLICE_BITS], rdbuf, count);
165 } else {
166 for (i = 0; i < count; i++) {
167 j = i2c_smbus_read_byte(client);
168 if (j < 0)
169 {
170 retval = -1;
171 goto exit;
172 }
173 blk->data[(slice << SLICE_BITS) + i] = (u8) j;
174 }
175 }
176 blk->updated[slice] = jiffies;
177 blk->valid |= (1 << slice);
178 }
179 exit:
180 up(&data->update_lock);
181 return retval;
182}
183
184static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, size_t count,
185 enum max6875_area_type area_type)
186{
187 struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj));
188 struct max6875_data *data = i2c_get_clientdata(client);
189 struct eeprom_block *blk;
190 int slice;
191
192 blk = &data->blocks[area_type];
193
194 if (off > blk->size)
195 return 0;
196 if (off + count > blk->size)
197 count = blk->size - off;
198
199 /* Only refresh slices which contain requested bytes */
200 for (slice = (off >> SLICE_BITS); slice <= ((off + count - 1) >> SLICE_BITS); slice++)
201 max6875_update_slice(client, blk, slice);
202
203 memcpy(buf, &blk->data[off], count);
204
205 return count;
206}
207
208static ssize_t max6875_user_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
209{
210 return max6875_read(kobj, buf, off, count, max6875_eeprom_user);
211}
212
213static ssize_t max6875_config_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
214{
215 return max6875_read(kobj, buf, off, count, max6875_eeprom_config);
216}
217
218static ssize_t max6875_cfgreg_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
219{
220 return max6875_read(kobj, buf, off, count, max6875_register_config);
221}
222
223
224static ssize_t max6875_write(struct kobject *kobj, char *buf, loff_t off, size_t count,
225 enum max6875_area_type area_type)
226{
227 struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj));
228 struct max6875_data *data = i2c_get_clientdata(client);
229 struct eeprom_block *blk;
230 int slice, addr, retval;
231 ssize_t sent = 0;
232
233 blk = &data->blocks[area_type];
234
235 if (off > blk->size)
236 return 0;
237 if ((off + count) > blk->size)
238 count = blk->size - off;
239
240 if (down_interruptible(&data->update_lock))
241 return -EAGAIN;
242
243 /* writing to a register is done with i2c_smbus_write_byte_data() */
244 if (blk->type == max6875_register_config) {
245 for (sent = 0; sent < count; sent++) {
246 addr = off + sent;
247 if (addr == 0x44)
248 continue;
249
250 retval = i2c_smbus_write_byte_data(client, addr, buf[sent]);
251 }
252 } else {
253 int cmd, val;
254
255 /* We are writing to EEPROM */
256 for (sent = 0; sent < count; sent++) {
257 addr = blk->base + off + sent;
258 cmd = addr >> 8;
259 val = (addr & 0xff) | (buf[sent] << 8); // reversed
260
261 if (addr == 0x8044)
262 continue;
263
264 retval = i2c_smbus_write_word_data(client, cmd, val);
265
266 if (retval) {
267 goto error_exit;
268 }
269
270 /* A write takes up to 11 ms */
271 msleep(11);
272 }
273 }
274
275 /* Invalidate the scratch buffer */
276 for (slice = (off >> SLICE_BITS); slice <= ((off + count - 1) >> SLICE_BITS); slice++)
277 blk->valid &= ~(1 << slice);
278
279 error_exit:
280 up(&data->update_lock);
281
282 return sent;
283}
284
285static ssize_t max6875_user_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
286{
287 return max6875_write(kobj, buf, off, count, max6875_eeprom_user);
288}
289
290static ssize_t max6875_config_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
291{
292 return max6875_write(kobj, buf, off, count, max6875_eeprom_config);
293}
294
295static ssize_t max6875_cfgreg_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
296{
297 return max6875_write(kobj, buf, off, count, max6875_register_config);
298}
299
300static struct bin_attribute user_eeprom_attr = {
301 .attr = {
302 .name = "eeprom_user",
303 .mode = S_IRUGO | S_IWUSR | S_IWGRP,
304 .owner = THIS_MODULE,
305 },
306 .size = USER_EEPROM_SIZE,
307 .read = max6875_user_read,
308 .write = max6875_user_write,
309};
310
311static struct bin_attribute config_eeprom_attr = {
312 .attr = {
313 .name = "eeprom_config",
314 .mode = S_IRUGO | S_IWUSR,
315 .owner = THIS_MODULE,
316 },
317 .size = CONFIG_EEPROM_SIZE,
318 .read = max6875_config_read,
319 .write = max6875_config_write,
320};
321
322static struct bin_attribute config_register_attr = {
323 .attr = {
324 .name = "reg_config",
325 .mode = S_IRUGO | S_IWUSR,
326 .owner = THIS_MODULE,
327 },
328 .size = CONFIG_EEPROM_SIZE,
329 .read = max6875_cfgreg_read,
330 .write = max6875_cfgreg_write,
331};
332
333static int max6875_attach_adapter(struct i2c_adapter *adapter)
334{
335 return i2c_detect(adapter, &addr_data, max6875_detect);
336}
337
338/* This function is called by i2c_detect */
339static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
340{
341 struct i2c_client *new_client;
342 struct max6875_data *data;
343 int err = 0;
344
345 /* There are three ways we can read the EEPROM data:
346 (1) I2C block reads (faster, but unsupported by most adapters)
347 (2) Consecutive byte reads (100% overhead)
348 (3) Regular byte data reads (200% overhead)
349 The third method is not implemented by this driver because all
350 known adapters support at least the second. */
351 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA |
352 I2C_FUNC_SMBUS_BYTE |
353 I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
354 goto exit;
355
356 /* OK. For now, we presume we have a valid client. We now create the
357 client structure, even though we cannot fill it completely yet.
358 But it allows us to access eeprom_{read,write}_value. */
359 if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL))) {
360 err = -ENOMEM;
361 goto exit;
362 }
363 memset(data, 0, sizeof(struct max6875_data));
364
365 new_client = &data->client;
366 i2c_set_clientdata(new_client, data);
367 new_client->addr = address;
368 new_client->adapter = adapter;
369 new_client->driver = &max6875_driver;
370 new_client->flags = 0;
371
372 /* Setup the user section */
373 data->blocks[max6875_eeprom_user].type = max6875_eeprom_user;
374 data->blocks[max6875_eeprom_user].slices = USER_EEPROM_SLICES;
375 data->blocks[max6875_eeprom_user].size = USER_EEPROM_SIZE;
376 data->blocks[max6875_eeprom_user].base = USER_EEPROM_BASE;
377 data->blocks[max6875_eeprom_user].data = data->data;
378 data->blocks[max6875_eeprom_user].updated = data->last_updated;
379
380 /* Setup the config section */
381 data->blocks[max6875_eeprom_config].type = max6875_eeprom_config;
382 data->blocks[max6875_eeprom_config].slices = CONFIG_EEPROM_SLICES;
383 data->blocks[max6875_eeprom_config].size = CONFIG_EEPROM_SIZE;
384 data->blocks[max6875_eeprom_config].base = CONFIG_EEPROM_BASE;
385 data->blocks[max6875_eeprom_config].data = &data->data[USER_EEPROM_SIZE];
386 data->blocks[max6875_eeprom_config].updated = &data->last_updated[USER_EEPROM_SLICES];
387
388 /* Setup the register section */
389 data->blocks[max6875_register_config].type = max6875_register_config;
390 data->blocks[max6875_register_config].slices = CONFIG_EEPROM_SLICES;
391 data->blocks[max6875_register_config].size = CONFIG_EEPROM_SIZE;
392 data->blocks[max6875_register_config].base = 0;
393 data->blocks[max6875_register_config].data = &data->data[USER_EEPROM_SIZE+CONFIG_EEPROM_SIZE];
394 data->blocks[max6875_register_config].updated = &data->last_updated[USER_EEPROM_SLICES+CONFIG_EEPROM_SLICES];
395
396 /* Init the data */
397 memset(data->data, 0xff, sizeof(data->data));
398
399 /* Fill in the remaining client fields */
400 strlcpy(new_client->name, "max6875", I2C_NAME_SIZE);
401 init_MUTEX(&data->update_lock);
402
403 /* Verify that the chip is really what we think it is */
404 if ((max6875_update_slice(new_client, &data->blocks[max6875_eeprom_config], 4) < 0) ||
405 (max6875_update_slice(new_client, &data->blocks[max6875_register_config], 4) < 0))
406 goto exit_kfree;
407
408 /* 0x41,0x42 must be zero and 0x40 must match in eeprom and registers */
409 if ((data->blocks[max6875_eeprom_config].data[0x41] != 0) ||
410 (data->blocks[max6875_eeprom_config].data[0x42] != 0) ||
411 (data->blocks[max6875_register_config].data[0x41] != 0) ||
412 (data->blocks[max6875_register_config].data[0x42] != 0) ||
413 (data->blocks[max6875_eeprom_config].data[0x40] !=
414 data->blocks[max6875_register_config].data[0x40]))
415 goto exit_kfree;
416
417 /* Tell the I2C layer a new client has arrived */
418 if ((err = i2c_attach_client(new_client)))
419 goto exit_kfree;
420
421 /* create the sysfs eeprom files with the correct permissions */
422 if (allow_write == 0) {
423 user_eeprom_attr.attr.mode &= ~S_IWUGO;
424 user_eeprom_attr.write = NULL;
425 config_eeprom_attr.attr.mode &= ~S_IWUGO;
426 config_eeprom_attr.write = NULL;
427 config_register_attr.attr.mode &= ~S_IWUGO;
428 config_register_attr.write = NULL;
429 }
430 sysfs_create_bin_file(&new_client->dev.kobj, &user_eeprom_attr);
431 sysfs_create_bin_file(&new_client->dev.kobj, &config_eeprom_attr);
432 sysfs_create_bin_file(&new_client->dev.kobj, &config_register_attr);
433
434 return 0;
435
436exit_kfree:
437 kfree(data);
438exit:
439 return err;
440}
441
442static int max6875_detach_client(struct i2c_client *client)
443{
444 int err;
445
446 err = i2c_detach_client(client);
447 if (err) {
448 dev_err(&client->dev, "Client deregistration failed, client not detached.\n");
449 return err;
450 }
451
452 kfree(i2c_get_clientdata(client));
453
454 return 0;
455}
456
457static int __init max6875_init(void)
458{
459 return i2c_add_driver(&max6875_driver);
460}
461
462static void __exit max6875_exit(void)
463{
464 i2c_del_driver(&max6875_driver);
465}
466
467
468MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>");
469MODULE_DESCRIPTION("MAX6875 driver");
470MODULE_LICENSE("GPL");
471
472module_init(max6875_init);
473module_exit(max6875_exit);
diff --git a/drivers/i2c/chips/pc87360.c b/drivers/i2c/chips/pc87360.c
index 65637b2cd170..876c68f3af31 100644
--- a/drivers/i2c/chips/pc87360.c
+++ b/drivers/i2c/chips/pc87360.c
@@ -33,7 +33,6 @@
33 * the standard Super-I/O addresses is used (0x2E/0x2F or 0x4E/0x4F). 33 * the standard Super-I/O addresses is used (0x2E/0x2F or 0x4E/0x4F).
34 */ 34 */
35 35
36#include <linux/config.h>
37#include <linux/module.h> 36#include <linux/module.h>
38#include <linux/init.h> 37#include <linux/init.h>
39#include <linux/slab.h> 38#include <linux/slab.h>
diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c
new file mode 100644
index 000000000000..9f3ad45daae2
--- /dev/null
+++ b/drivers/i2c/chips/pca9539.c
@@ -0,0 +1,192 @@
1/*
2 pca9539.c - 16-bit I/O port with interrupt and reset
3
4 Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; version 2 of the License.
9*/
10
11#include <linux/module.h>
12#include <linux/init.h>
13#include <linux/slab.h>
14#include <linux/i2c.h>
15#include <linux/hwmon-sysfs.h>
16#include <linux/i2c-sensor.h>
17
18/* Addresses to scan */
19static unsigned short normal_i2c[] = {0x74, 0x75, 0x76, 0x77, I2C_CLIENT_END};
20static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END};
21
22/* Insmod parameters */
23SENSORS_INSMOD_1(pca9539);
24
25enum pca9539_cmd
26{
27 PCA9539_INPUT_0 = 0,
28 PCA9539_INPUT_1 = 1,
29 PCA9539_OUTPUT_0 = 2,
30 PCA9539_OUTPUT_1 = 3,
31 PCA9539_INVERT_0 = 4,
32 PCA9539_INVERT_1 = 5,
33 PCA9539_DIRECTION_0 = 6,
34 PCA9539_DIRECTION_1 = 7,
35};
36
37static int pca9539_attach_adapter(struct i2c_adapter *adapter);
38static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind);
39static int pca9539_detach_client(struct i2c_client *client);
40
41/* This is the driver that will be inserted */
42static struct i2c_driver pca9539_driver = {
43 .owner = THIS_MODULE,
44 .name = "pca9539",
45 .flags = I2C_DF_NOTIFY,
46 .attach_adapter = pca9539_attach_adapter,
47 .detach_client = pca9539_detach_client,
48};
49
50struct pca9539_data {
51 struct i2c_client client;
52};
53
54/* following are the sysfs callback functions */
55static ssize_t pca9539_show(struct device *dev, struct device_attribute *attr,
56 char *buf)
57{
58 struct sensor_device_attribute *psa = to_sensor_dev_attr(attr);
59 struct i2c_client *client = to_i2c_client(dev);
60 return sprintf(buf, "%d\n", i2c_smbus_read_byte_data(client,
61 psa->index));
62}
63
64static ssize_t pca9539_store(struct device *dev, struct device_attribute *attr,
65 const char *buf, size_t count)
66{
67 struct sensor_device_attribute *psa = to_sensor_dev_attr(attr);
68 struct i2c_client *client = to_i2c_client(dev);
69 unsigned long val = simple_strtoul(buf, NULL, 0);
70 if (val > 0xff)
71 return -EINVAL;
72 i2c_smbus_write_byte_data(client, psa->index, val);
73 return count;
74}
75
76/* Define the device attributes */
77
78#define PCA9539_ENTRY_RO(name, cmd_idx) \
79 static SENSOR_DEVICE_ATTR(name, S_IRUGO, pca9539_show, NULL, cmd_idx)
80
81#define PCA9539_ENTRY_RW(name, cmd_idx) \
82 static SENSOR_DEVICE_ATTR(name, S_IRUGO | S_IWUSR, pca9539_show, \
83 pca9539_store, cmd_idx)
84
85PCA9539_ENTRY_RO(input0, PCA9539_INPUT_0);
86PCA9539_ENTRY_RO(input1, PCA9539_INPUT_1);
87PCA9539_ENTRY_RW(output0, PCA9539_OUTPUT_0);
88PCA9539_ENTRY_RW(output1, PCA9539_OUTPUT_1);
89PCA9539_ENTRY_RW(invert0, PCA9539_INVERT_0);
90PCA9539_ENTRY_RW(invert1, PCA9539_INVERT_1);
91PCA9539_ENTRY_RW(direction0, PCA9539_DIRECTION_0);
92PCA9539_ENTRY_RW(direction1, PCA9539_DIRECTION_1);
93
94static struct attribute *pca9539_attributes[] = {
95 &sensor_dev_attr_input0.dev_attr.attr,
96 &sensor_dev_attr_input1.dev_attr.attr,
97 &sensor_dev_attr_output0.dev_attr.attr,
98 &sensor_dev_attr_output1.dev_attr.attr,
99 &sensor_dev_attr_invert0.dev_attr.attr,
100 &sensor_dev_attr_invert1.dev_attr.attr,
101 &sensor_dev_attr_direction0.dev_attr.attr,
102 &sensor_dev_attr_direction1.dev_attr.attr,
103 NULL
104};
105
106static struct attribute_group pca9539_defattr_group = {
107 .attrs = pca9539_attributes,
108};
109
110static int pca9539_attach_adapter(struct i2c_adapter *adapter)
111{
112 return i2c_detect(adapter, &addr_data, pca9539_detect);
113}
114
115/* This function is called by i2c_detect */
116static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind)
117{
118 struct i2c_client *new_client;
119 struct pca9539_data *data;
120 int err = 0;
121
122 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
123 goto exit;
124
125 /* OK. For now, we presume we have a valid client. We now create the
126 client structure, even though we cannot fill it completely yet. */
127 if (!(data = kmalloc(sizeof(struct pca9539_data), GFP_KERNEL))) {
128 err = -ENOMEM;
129 goto exit;
130 }
131 memset(data, 0, sizeof(struct pca9539_data));
132
133 new_client = &data->client;
134 i2c_set_clientdata(new_client, data);
135 new_client->addr = address;
136 new_client->adapter = adapter;
137 new_client->driver = &pca9539_driver;
138 new_client->flags = 0;
139
140 /* Detection: the pca9539 only has 8 registers (0-7).
141 A read of 7 should succeed, but a read of 8 should fail. */
142 if ((i2c_smbus_read_byte_data(new_client, 7) < 0) ||
143 (i2c_smbus_read_byte_data(new_client, 8) >= 0))
144 goto exit_kfree;
145
146 strlcpy(new_client->name, "pca9539", I2C_NAME_SIZE);
147
148 /* Tell the I2C layer a new client has arrived */
149 if ((err = i2c_attach_client(new_client)))
150 goto exit_kfree;
151
152 /* Register sysfs hooks (don't care about failure) */
153 sysfs_create_group(&new_client->dev.kobj, &pca9539_defattr_group);
154
155 return 0;
156
157exit_kfree:
158 kfree(data);
159exit:
160 return err;
161}
162
163static int pca9539_detach_client(struct i2c_client *client)
164{
165 int err;
166
167 if ((err = i2c_detach_client(client))) {
168 dev_err(&client->dev, "Client deregistration failed.\n");
169 return err;
170 }
171
172 kfree(i2c_get_clientdata(client));
173 return 0;
174}
175
176static int __init pca9539_init(void)
177{
178 return i2c_add_driver(&pca9539_driver);
179}
180
181static void __exit pca9539_exit(void)
182{
183 i2c_del_driver(&pca9539_driver);
184}
185
186MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>");
187MODULE_DESCRIPTION("PCA9539 driver");
188MODULE_LICENSE("GPL");
189
190module_init(pca9539_init);
191module_exit(pca9539_exit);
192
diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c
index 4956e9effd75..cfcf64654080 100644
--- a/drivers/i2c/chips/pcf8574.c
+++ b/drivers/i2c/chips/pcf8574.c
@@ -57,7 +57,7 @@ SENSORS_INSMOD_2(pcf8574, pcf8574a);
57struct pcf8574_data { 57struct pcf8574_data {
58 struct i2c_client client; 58 struct i2c_client client;
59 59
60 u8 read, write; /* Register values */ 60 u8 write; /* Remember last written value */
61}; 61};
62 62
63static int pcf8574_attach_adapter(struct i2c_adapter *adapter); 63static int pcf8574_attach_adapter(struct i2c_adapter *adapter);
@@ -79,9 +79,7 @@ static struct i2c_driver pcf8574_driver = {
79static ssize_t show_read(struct device *dev, struct device_attribute *attr, char *buf) 79static ssize_t show_read(struct device *dev, struct device_attribute *attr, char *buf)
80{ 80{
81 struct i2c_client *client = to_i2c_client(dev); 81 struct i2c_client *client = to_i2c_client(dev);
82 struct pcf8574_data *data = i2c_get_clientdata(client); 82 return sprintf(buf, "%u\n", i2c_smbus_read_byte(client));
83 data->read = i2c_smbus_read_byte(client);
84 return sprintf(buf, "%u\n", data->read);
85} 83}
86 84
87static DEVICE_ATTR(read, S_IRUGO, show_read, NULL); 85static DEVICE_ATTR(read, S_IRUGO, show_read, NULL);
diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c
index 5a9deddb626b..588fc2261a91 100644
--- a/drivers/i2c/chips/rtc8564.c
+++ b/drivers/i2c/chips/rtc8564.c
@@ -19,7 +19,6 @@
19#include <linux/string.h> 19#include <linux/string.h>
20#include <linux/rtc.h> /* get the user-level API */ 20#include <linux/rtc.h> /* get the user-level API */
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/init.h>
23 22
24#include "rtc8564.h" 23#include "rtc8564.h"
25 24
@@ -66,11 +65,8 @@ static unsigned short normal_addr[] = { 0x51, I2C_CLIENT_END };
66 65
67static struct i2c_client_address_data addr_data = { 66static struct i2c_client_address_data addr_data = {
68 .normal_i2c = normal_addr, 67 .normal_i2c = normal_addr,
69 .normal_i2c_range = ignore,
70 .probe = ignore, 68 .probe = ignore,
71 .probe_range = ignore,
72 .ignore = ignore, 69 .ignore = ignore,
73 .ignore_range = ignore,
74 .force = ignore, 70 .force = ignore,
75}; 71};
76 72
diff --git a/drivers/i2c/chips/sis5595.c b/drivers/i2c/chips/sis5595.c
index c6650727a27d..6bbfc8fb4f13 100644
--- a/drivers/i2c/chips/sis5595.c
+++ b/drivers/i2c/chips/sis5595.c
@@ -57,6 +57,7 @@
57#include <linux/i2c.h> 57#include <linux/i2c.h>
58#include <linux/i2c-sensor.h> 58#include <linux/i2c-sensor.h>
59#include <linux/init.h> 59#include <linux/init.h>
60#include <linux/jiffies.h>
60#include <asm/io.h> 61#include <asm/io.h>
61 62
62 63
diff --git a/drivers/i2c/chips/smsc47m1.c b/drivers/i2c/chips/smsc47m1.c
index 13d6d4a8bc7d..897117a7213f 100644
--- a/drivers/i2c/chips/smsc47m1.c
+++ b/drivers/i2c/chips/smsc47m1.c
@@ -372,14 +372,16 @@ static int smsc47m1_find(int *address)
372 * SMSC LPC47M10x/LPC47M13x (device id 0x59), LPC47M14x (device id 372 * SMSC LPC47M10x/LPC47M13x (device id 0x59), LPC47M14x (device id
373 * 0x5F) and LPC47B27x (device id 0x51) have fan control. 373 * 0x5F) and LPC47B27x (device id 0x51) have fan control.
374 * The LPC47M15x and LPC47M192 chips "with hardware monitoring block" 374 * The LPC47M15x and LPC47M192 chips "with hardware monitoring block"
375 * can do much more besides (device id 0x60, unsupported). 375 * can do much more besides (device id 0x60).
376 */ 376 */
377 if (val == 0x51) 377 if (val == 0x51)
378 printk(KERN_INFO "smsc47m1: Found SMSC47B27x\n"); 378 printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n");
379 else if (val == 0x59) 379 else if (val == 0x59)
380 printk(KERN_INFO "smsc47m1: Found SMSC47M10x/SMSC47M13x\n"); 380 printk(KERN_INFO "smsc47m1: Found SMSC LPC47M10x/LPC47M13x\n");
381 else if (val == 0x5F) 381 else if (val == 0x5F)
382 printk(KERN_INFO "smsc47m1: Found SMSC47M14x\n"); 382 printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n");
383 else if (val == 0x60)
384 printk(KERN_INFO "smsc47m1: Found SMSC LPC47M15x/LPC47M192\n");
383 else { 385 else {
384 superio_exit(); 386 superio_exit();
385 return -ENODEV; 387 return -ENODEV;
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c
new file mode 100644
index 000000000000..c0ac01b60039
--- /dev/null
+++ b/drivers/i2c/chips/tps65010.c
@@ -0,0 +1,1072 @@
1/*
2 * tps65010 - driver for tps6501x power management chips
3 *
4 * Copyright (C) 2004 Texas Instruments
5 * Copyright (C) 2004-2005 David Brownell
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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21#undef DEBUG
22
23#include <linux/config.h>
24#include <linux/kernel.h>
25#include <linux/module.h>
26#include <linux/init.h>
27#include <linux/slab.h>
28#include <linux/interrupt.h>
29#include <linux/device.h>
30#include <linux/i2c.h>
31#include <linux/delay.h>
32#include <linux/workqueue.h>
33#include <linux/suspend.h>
34#include <linux/debugfs.h>
35#include <linux/seq_file.h>
36
37#include <asm/irq.h>
38#include <asm/mach-types.h>
39
40#include <asm/arch/gpio.h>
41#include <asm/arch/mux.h>
42#include <asm/arch/tps65010.h>
43
44/*-------------------------------------------------------------------------*/
45
46#define DRIVER_VERSION "2 May 2005"
47#define DRIVER_NAME (tps65010_driver.name)
48
49MODULE_DESCRIPTION("TPS6501x Power Management Driver");
50MODULE_LICENSE("GPL");
51
52/* only two addresses possible */
53#define TPS_BASE 0x48
54static unsigned short normal_i2c[] = {
55 TPS_BASE,
56 I2C_CLIENT_END };
57static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
58
59I2C_CLIENT_INSMOD;
60
61static struct i2c_driver tps65010_driver;
62
63/*-------------------------------------------------------------------------*/
64
65/* This driver handles a family of multipurpose chips, which incorporate
66 * voltage regulators, lithium ion/polymer battery charging, GPIOs, LEDs,
67 * and other features often needed in portable devices like cell phones
68 * or digital cameras.
69 *
70 * The tps65011 and tps65013 have different voltage settings compared
71 * to tps65010 and tps65012. The tps65013 has a NO_CHG status/irq.
72 * All except tps65010 have "wait" mode, possibly defaulted so that
73 * battery-insert != device-on.
74 *
75 * We could distinguish between some models by checking VDCDC1.UVLO or
76 * other registers, unless they've been changed already after powerup
77 * as part of board setup by a bootloader.
78 */
79enum tps_model {
80 TPS_UNKNOWN = 0,
81 TPS65010,
82 TPS65011,
83 TPS65012,
84 TPS65013,
85};
86
87struct tps65010 {
88 struct i2c_client client;
89 struct semaphore lock;
90 int irq;
91 struct work_struct work;
92 struct dentry *file;
93 unsigned charging:1;
94 unsigned por:1;
95 unsigned model:8;
96 u16 vbus;
97 unsigned long flags;
98#define FLAG_VBUS_CHANGED 0
99#define FLAG_IRQ_ENABLE 1
100
101 /* copies of last register state */
102 u8 chgstatus, regstatus, chgconf;
103 u8 nmask1, nmask2;
104
105 /* plus four GPIOs, probably used to switch power */
106};
107
108#define POWER_POLL_DELAY msecs_to_jiffies(800)
109
110/*-------------------------------------------------------------------------*/
111
112#if defined(DEBUG) || defined(CONFIG_DEBUG_FS)
113
114static void dbg_chgstat(char *buf, size_t len, u8 chgstatus)
115{
116 snprintf(buf, len, "%02x%s%s%s%s%s%s%s%s\n",
117 chgstatus,
118 (chgstatus & TPS_CHG_USB) ? " USB" : "",
119 (chgstatus & TPS_CHG_AC) ? " AC" : "",
120 (chgstatus & TPS_CHG_THERM) ? " therm" : "",
121 (chgstatus & TPS_CHG_TERM) ? " done" :
122 ((chgstatus & (TPS_CHG_USB|TPS_CHG_AC))
123 ? " (charging)" : ""),
124 (chgstatus & TPS_CHG_TAPER_TMO) ? " taper_tmo" : "",
125 (chgstatus & TPS_CHG_CHG_TMO) ? " charge_tmo" : "",
126 (chgstatus & TPS_CHG_PRECHG_TMO) ? " prechg_tmo" : "",
127 (chgstatus & TPS_CHG_TEMP_ERR) ? " temp_err" : "");
128}
129
130static void dbg_regstat(char *buf, size_t len, u8 regstatus)
131{
132 snprintf(buf, len, "%02x %s%s%s%s%s%s%s%s\n",
133 regstatus,
134 (regstatus & TPS_REG_ONOFF) ? "off" : "(on)",
135 (regstatus & TPS_REG_COVER) ? " uncover" : "",
136 (regstatus & TPS_REG_UVLO) ? " UVLO" : "",
137 (regstatus & TPS_REG_NO_CHG) ? " NO_CHG" : "",
138 (regstatus & TPS_REG_PG_LD02) ? " ld01_bad" : "",
139 (regstatus & TPS_REG_PG_LD01) ? " ld01_bad" : "",
140 (regstatus & TPS_REG_PG_MAIN) ? " main_bad" : "",
141 (regstatus & TPS_REG_PG_CORE) ? " core_bad" : "");
142}
143
144static void dbg_chgconf(int por, char *buf, size_t len, u8 chgconfig)
145{
146 char *hibit;
147
148 if (por)
149 hibit = (chgconfig & TPS_CHARGE_POR)
150 ? "POR=69ms" : "POR=1sec";
151 else
152 hibit = (chgconfig & TPS65013_AUA) ? "AUA" : "";
153
154 snprintf(buf, len, "%02x %s%s%s AC=%d%% USB=%dmA %sCharge\n",
155 chgconfig, hibit,
156 (chgconfig & TPS_CHARGE_RESET) ? " reset" : "",
157 (chgconfig & TPS_CHARGE_FAST) ? " fast" : "",
158 ({int p; switch ((chgconfig >> 3) & 3) {
159 case 3: p = 100; break;
160 case 2: p = 75; break;
161 case 1: p = 50; break;
162 default: p = 25; break;
163 }; p; }),
164 (chgconfig & TPS_VBUS_CHARGING)
165 ? ((chgconfig & TPS_VBUS_500MA) ? 500 : 100)
166 : 0,
167 (chgconfig & TPS_CHARGE_ENABLE) ? "" : "No");
168}
169
170#endif
171
172#ifdef DEBUG
173
174static void show_chgstatus(const char *label, u8 chgstatus)
175{
176 char buf [100];
177
178 dbg_chgstat(buf, sizeof buf, chgstatus);
179 pr_debug("%s: %s %s", DRIVER_NAME, label, buf);
180}
181
182static void show_regstatus(const char *label, u8 regstatus)
183{
184 char buf [100];
185
186 dbg_regstat(buf, sizeof buf, regstatus);
187 pr_debug("%s: %s %s", DRIVER_NAME, label, buf);
188}
189
190static void show_chgconfig(int por, const char *label, u8 chgconfig)
191{
192 char buf [100];
193
194 dbg_chgconf(por, buf, sizeof buf, chgconfig);
195 pr_debug("%s: %s %s", DRIVER_NAME, label, buf);
196}
197
198#else
199
200static inline void show_chgstatus(const char *label, u8 chgstatus) { }
201static inline void show_regstatus(const char *label, u8 chgstatus) { }
202static inline void show_chgconfig(int por, const char *label, u8 chgconfig) { }
203
204#endif
205
206#ifdef CONFIG_DEBUG_FS
207
208static int dbg_show(struct seq_file *s, void *_)
209{
210 struct tps65010 *tps = s->private;
211 u8 value, v2;
212 unsigned i;
213 char buf[100];
214 const char *chip;
215
216 switch (tps->model) {
217 case TPS65010: chip = "tps65010"; break;
218 case TPS65011: chip = "tps65011"; break;
219 case TPS65012: chip = "tps65012"; break;
220 case TPS65013: chip = "tps65013"; break;
221 default: chip = NULL; break;
222 }
223 seq_printf(s, "driver %s\nversion %s\nchip %s\n\n",
224 DRIVER_NAME, DRIVER_VERSION, chip);
225
226 down(&tps->lock);
227
228 /* FIXME how can we tell whether a battery is present?
229 * likely involves a charge gauging chip (like BQ26501).
230 */
231
232 seq_printf(s, "%scharging\n\n", tps->charging ? "" : "(not) ");
233
234
235 /* registers for monitoring battery charging and status; note
236 * that reading chgstat and regstat may ack IRQs...
237 */
238 value = i2c_smbus_read_byte_data(&tps->client, TPS_CHGCONFIG);
239 dbg_chgconf(tps->por, buf, sizeof buf, value);
240 seq_printf(s, "chgconfig %s", buf);
241
242 value = i2c_smbus_read_byte_data(&tps->client, TPS_CHGSTATUS);
243 dbg_chgstat(buf, sizeof buf, value);
244 seq_printf(s, "chgstat %s", buf);
245 value = i2c_smbus_read_byte_data(&tps->client, TPS_MASK1);
246 dbg_chgstat(buf, sizeof buf, value);
247 seq_printf(s, "mask1 %s", buf);
248 /* ignore ackint1 */
249
250 value = i2c_smbus_read_byte_data(&tps->client, TPS_REGSTATUS);
251 dbg_regstat(buf, sizeof buf, value);
252 seq_printf(s, "regstat %s", buf);
253 value = i2c_smbus_read_byte_data(&tps->client, TPS_MASK2);
254 dbg_regstat(buf, sizeof buf, value);
255 seq_printf(s, "mask2 %s\n", buf);
256 /* ignore ackint2 */
257
258 (void) schedule_delayed_work(&tps->work, POWER_POLL_DELAY);
259
260
261 /* VMAIN voltage, enable lowpower, etc */
262 value = i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC1);
263 seq_printf(s, "vdcdc1 %02x\n", value);
264
265 /* VCORE voltage, vibrator on/off */
266 value = i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC2);
267 seq_printf(s, "vdcdc2 %02x\n", value);
268
269 /* both LD0s, and their lowpower behavior */
270 value = i2c_smbus_read_byte_data(&tps->client, TPS_VREGS1);
271 seq_printf(s, "vregs1 %02x\n\n", value);
272
273
274 /* LEDs and GPIOs */
275 value = i2c_smbus_read_byte_data(&tps->client, TPS_LED1_ON);
276 v2 = i2c_smbus_read_byte_data(&tps->client, TPS_LED1_PER);
277 seq_printf(s, "led1 %s, on=%02x, per=%02x, %d/%d msec\n",
278 (value & 0x80)
279 ? ((v2 & 0x80) ? "on" : "off")
280 : ((v2 & 0x80) ? "blink" : "(nPG)"),
281 value, v2,
282 (value & 0x7f) * 10, (v2 & 0x7f) * 100);
283
284 value = i2c_smbus_read_byte_data(&tps->client, TPS_LED2_ON);
285 v2 = i2c_smbus_read_byte_data(&tps->client, TPS_LED2_PER);
286 seq_printf(s, "led2 %s, on=%02x, per=%02x, %d/%d msec\n",
287 (value & 0x80)
288 ? ((v2 & 0x80) ? "on" : "off")
289 : ((v2 & 0x80) ? "blink" : "off"),
290 value, v2,
291 (value & 0x7f) * 10, (v2 & 0x7f) * 100);
292
293 value = i2c_smbus_read_byte_data(&tps->client, TPS_DEFGPIO);
294 v2 = i2c_smbus_read_byte_data(&tps->client, TPS_MASK3);
295 seq_printf(s, "defgpio %02x mask3 %02x\n", value, v2);
296
297 for (i = 0; i < 4; i++) {
298 if (value & (1 << (4 +i)))
299 seq_printf(s, " gpio%d-out %s\n", i + 1,
300 (value & (1 << i)) ? "low" : "hi ");
301 else
302 seq_printf(s, " gpio%d-in %s %s %s\n", i + 1,
303 (value & (1 << i)) ? "hi " : "low",
304 (v2 & (1 << i)) ? "no-irq" : "irq",
305 (v2 & (1 << (4 + i))) ? "rising" : "falling");
306 }
307
308 up(&tps->lock);
309 return 0;
310}
311
312static int dbg_tps_open(struct inode *inode, struct file *file)
313{
314 return single_open(file, dbg_show, inode->u.generic_ip);
315}
316
317static struct file_operations debug_fops = {
318 .open = dbg_tps_open,
319 .read = seq_read,
320 .llseek = seq_lseek,
321 .release = single_release,
322};
323
324#define DEBUG_FOPS &debug_fops
325
326#else
327#define DEBUG_FOPS NULL
328#endif
329
330/*-------------------------------------------------------------------------*/
331
332/* handle IRQS in a task context, so we can use I2C calls */
333static void tps65010_interrupt(struct tps65010 *tps)
334{
335 u8 tmp = 0, mask, poll;
336
337 /* IRQs won't trigger irqs for certain events, but we can get
338 * others by polling (normally, with external power applied).
339 */
340 poll = 0;
341
342 /* regstatus irqs */
343 if (tps->nmask2) {
344 tmp = i2c_smbus_read_byte_data(&tps->client, TPS_REGSTATUS);
345 mask = tmp ^ tps->regstatus;
346 tps->regstatus = tmp;
347 mask &= tps->nmask2;
348 } else
349 mask = 0;
350 if (mask) {
351 tps->regstatus = tmp;
352 /* may need to shut something down ... */
353
354 /* "off" usually means deep sleep */
355 if (tmp & TPS_REG_ONOFF) {
356 pr_info("%s: power off button\n", DRIVER_NAME);
357#if 0
358 /* REVISIT: this might need its own workqueue
359 * plus tweaks including deadlock avoidance ...
360 */
361 software_suspend();
362#endif
363 poll = 1;
364 }
365 }
366
367 /* chgstatus irqs */
368 if (tps->nmask1) {
369 tmp = i2c_smbus_read_byte_data(&tps->client, TPS_CHGSTATUS);
370 mask = tmp ^ tps->chgstatus;
371 tps->chgstatus = tmp;
372 mask &= tps->nmask1;
373 } else
374 mask = 0;
375 if (mask) {
376 unsigned charging = 0;
377
378 show_chgstatus("chg/irq", tmp);
379 if (tmp & (TPS_CHG_USB|TPS_CHG_AC))
380 show_chgconfig(tps->por, "conf", tps->chgconf);
381
382 /* Unless it was turned off or disabled, we charge any
383 * battery whenever there's power available for it
384 * and the charger hasn't been disabled.
385 */
386 if (!(tps->chgstatus & ~(TPS_CHG_USB|TPS_CHG_AC))
387 && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC))
388 && (tps->chgconf & TPS_CHARGE_ENABLE)
389 ) {
390 if (tps->chgstatus & TPS_CHG_USB) {
391 /* VBUS options are readonly until reconnect */
392 if (mask & TPS_CHG_USB)
393 set_bit(FLAG_VBUS_CHANGED, &tps->flags);
394 charging = 1;
395 } else if (tps->chgstatus & TPS_CHG_AC)
396 charging = 1;
397 }
398 if (charging != tps->charging) {
399 tps->charging = charging;
400 pr_info("%s: battery %scharging\n",
401 DRIVER_NAME, charging ? "" :
402 ((tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC))
403 ? "NOT " : "dis"));
404 }
405 }
406
407 /* always poll to detect (a) power removal, without tps65013
408 * NO_CHG IRQ; or (b) restart of charging after stop.
409 */
410 if ((tps->model != TPS65013 || !tps->charging)
411 && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC)))
412 poll = 1;
413 if (poll)
414 (void) schedule_delayed_work(&tps->work, POWER_POLL_DELAY);
415
416 /* also potentially gpio-in rise or fall */
417}
418
419/* handle IRQs and polling using keventd for now */
420static void tps65010_work(void *_tps)
421{
422 struct tps65010 *tps = _tps;
423
424 down(&tps->lock);
425
426 tps65010_interrupt(tps);
427
428 if (test_and_clear_bit(FLAG_VBUS_CHANGED, &tps->flags)) {
429 int status;
430 u8 chgconfig, tmp;
431
432 chgconfig = i2c_smbus_read_byte_data(&tps->client,
433 TPS_CHGCONFIG);
434 chgconfig &= ~(TPS_VBUS_500MA | TPS_VBUS_CHARGING);
435 if (tps->vbus == 500)
436 chgconfig |= TPS_VBUS_500MA | TPS_VBUS_CHARGING;
437 else if (tps->vbus >= 100)
438 chgconfig |= TPS_VBUS_CHARGING;
439
440 status = i2c_smbus_write_byte_data(&tps->client,
441 TPS_CHGCONFIG, chgconfig);
442
443 /* vbus update fails unless VBUS is connected! */
444 tmp = i2c_smbus_read_byte_data(&tps->client, TPS_CHGCONFIG);
445 tps->chgconf = tmp;
446 show_chgconfig(tps->por, "update vbus", tmp);
447 }
448
449 if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags))
450 enable_irq(tps->irq);
451
452 up(&tps->lock);
453}
454
455static irqreturn_t tps65010_irq(int irq, void *_tps, struct pt_regs *regs)
456{
457 struct tps65010 *tps = _tps;
458
459 disable_irq_nosync(irq);
460 set_bit(FLAG_IRQ_ENABLE, &tps->flags);
461 (void) schedule_work(&tps->work);
462 return IRQ_HANDLED;
463}
464
465/*-------------------------------------------------------------------------*/
466
467static struct tps65010 *the_tps;
468
469static int __exit tps65010_detach_client(struct i2c_client *client)
470{
471 struct tps65010 *tps;
472
473 tps = container_of(client, struct tps65010, client);
474#ifdef CONFIG_ARM
475 if (machine_is_omap_h2())
476 omap_free_gpio(58);
477 if (machine_is_omap_osk())
478 omap_free_gpio(OMAP_MPUIO(1));
479#endif
480 free_irq(tps->irq, tps);
481 debugfs_remove(tps->file);
482 if (i2c_detach_client(client) == 0)
483 kfree(tps);
484 the_tps = 0;
485 return 0;
486}
487
488static int tps65010_noscan(struct i2c_adapter *bus)
489{
490 /* pure paranoia, in case someone adds another i2c bus
491 * after our init section's gone...
492 */
493 return -ENODEV;
494}
495
496/* no error returns, they'd just make bus scanning stop */
497static int __init
498tps65010_probe(struct i2c_adapter *bus, int address, int kind)
499{
500 struct tps65010 *tps;
501 int status;
502
503 if (the_tps) {
504 dev_dbg(&bus->dev, "only one %s for now\n", DRIVER_NAME);
505 return 0;
506 }
507
508 tps = kmalloc(sizeof *tps, GFP_KERNEL);
509 if (!tps)
510 return 0;
511
512 memset(tps, 0, sizeof *tps);
513 init_MUTEX(&tps->lock);
514 INIT_WORK(&tps->work, tps65010_work, tps);
515 tps->irq = -1;
516 tps->client.addr = address;
517 i2c_set_clientdata(&tps->client, tps);
518 tps->client.adapter = bus;
519 tps->client.driver = &tps65010_driver;
520 strlcpy(tps->client.name, DRIVER_NAME, I2C_NAME_SIZE);
521
522 status = i2c_attach_client(&tps->client);
523 if (status < 0) {
524 dev_dbg(&bus->dev, "can't attach %s to device %d, err %d\n",
525 DRIVER_NAME, address, status);
526fail1:
527 kfree(tps);
528 return 0;
529 }
530
531#ifdef CONFIG_ARM
532 if (machine_is_omap_h2()) {
533 tps->model = TPS65010;
534 omap_cfg_reg(W4_GPIO58);
535 tps->irq = OMAP_GPIO_IRQ(58);
536 omap_request_gpio(58);
537 omap_set_gpio_direction(58, 1);
538 omap_set_gpio_edge_ctrl(58, OMAP_GPIO_FALLING_EDGE);
539 }
540 if (machine_is_omap_osk()) {
541 tps->model = TPS65010;
542 // omap_cfg_reg(U19_1610_MPUIO1);
543 tps->irq = OMAP_GPIO_IRQ(OMAP_MPUIO(1));
544 omap_request_gpio(OMAP_MPUIO(1));
545 omap_set_gpio_direction(OMAP_MPUIO(1), 1);
546 omap_set_gpio_edge_ctrl(OMAP_MPUIO(1), OMAP_GPIO_FALLING_EDGE);
547 }
548 if (machine_is_omap_h3()) {
549 tps->model = TPS65013;
550
551 // FIXME set up this board's IRQ ...
552 }
553#else
554#define set_irq_type(num,trigger) do{}while(0)
555#endif
556
557 if (tps->irq > 0) {
558 set_irq_type(tps->irq, IRQT_LOW);
559 status = request_irq(tps->irq, tps65010_irq,
560 SA_SAMPLE_RANDOM, DRIVER_NAME, tps);
561 if (status < 0) {
562 dev_dbg(&tps->client.dev, "can't get IRQ %d, err %d\n",
563 tps->irq, status);
564 i2c_detach_client(&tps->client);
565 goto fail1;
566 }
567#ifdef CONFIG_ARM
568 /* annoying race here, ideally we'd have an option
569 * to claim the irq now and enable it later.
570 */
571 disable_irq(tps->irq);
572 set_bit(FLAG_IRQ_ENABLE, &tps->flags);
573#endif
574 } else
575 printk(KERN_WARNING "%s: IRQ not configured!\n",
576 DRIVER_NAME);
577
578
579 switch (tps->model) {
580 case TPS65010:
581 case TPS65012:
582 tps->por = 1;
583 break;
584 case TPS_UNKNOWN:
585 printk(KERN_WARNING "%s: unknown TPS chip\n", DRIVER_NAME);
586 break;
587 /* else CHGCONFIG.POR is replaced by AUA, enabling a WAIT mode */
588 }
589 tps->chgconf = i2c_smbus_read_byte_data(&tps->client, TPS_CHGCONFIG);
590 show_chgconfig(tps->por, "conf/init", tps->chgconf);
591
592 show_chgstatus("chg/init",
593 i2c_smbus_read_byte_data(&tps->client, TPS_CHGSTATUS));
594 show_regstatus("reg/init",
595 i2c_smbus_read_byte_data(&tps->client, TPS_REGSTATUS));
596
597 pr_debug("%s: vdcdc1 0x%02x, vdcdc2 %02x, vregs1 %02x\n", DRIVER_NAME,
598 i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC1),
599 i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC2),
600 i2c_smbus_read_byte_data(&tps->client, TPS_VREGS1));
601 pr_debug("%s: defgpio 0x%02x, mask3 0x%02x\n", DRIVER_NAME,
602 i2c_smbus_read_byte_data(&tps->client, TPS_DEFGPIO),
603 i2c_smbus_read_byte_data(&tps->client, TPS_MASK3));
604
605 tps65010_driver.attach_adapter = tps65010_noscan;
606 the_tps = tps;
607
608#if defined(CONFIG_USB_GADGET) && !defined(CONFIG_USB_OTG)
609 /* USB hosts can't draw VBUS. OTG devices could, later
610 * when OTG infrastructure enables it. USB peripherals
611 * could be relying on VBUS while booting, though.
612 */
613 tps->vbus = 100;
614#endif
615
616 /* unmask the "interesting" irqs, then poll once to
617 * kickstart monitoring, initialize shadowed status
618 * registers, and maybe disable VBUS draw.
619 */
620 tps->nmask1 = ~0;
621 (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK1, ~tps->nmask1);
622
623 tps->nmask2 = TPS_REG_ONOFF;
624 if (tps->model == TPS65013)
625 tps->nmask2 |= TPS_REG_NO_CHG;
626 (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK2, ~tps->nmask2);
627
628 (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK3, 0x0f
629 | i2c_smbus_read_byte_data(&tps->client, TPS_MASK3));
630
631 tps65010_work(tps);
632
633 tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL,
634 tps, DEBUG_FOPS);
635 return 0;
636}
637
638static int __init tps65010_scan_bus(struct i2c_adapter *bus)
639{
640 if (!i2c_check_functionality(bus, I2C_FUNC_SMBUS_BYTE_DATA))
641 return -EINVAL;
642 return i2c_probe(bus, &addr_data, tps65010_probe);
643}
644
645static struct i2c_driver tps65010_driver = {
646 .owner = THIS_MODULE,
647 .name = "tps65010",
648 .id = 888, /* FIXME assign "official" value */
649 .flags = I2C_DF_NOTIFY,
650 .attach_adapter = tps65010_scan_bus,
651 .detach_client = __exit_p(tps65010_detach_client),
652};
653
654/*-------------------------------------------------------------------------*/
655
656/* Draw from VBUS:
657 * 0 mA -- DON'T DRAW (might supply power instead)
658 * 100 mA -- usb unit load (slowest charge rate)
659 * 500 mA -- usb high power (fast battery charge)
660 */
661int tps65010_set_vbus_draw(unsigned mA)
662{
663 unsigned long flags;
664
665 if (!the_tps)
666 return -ENODEV;
667
668 /* assumes non-SMP */
669 local_irq_save(flags);
670 if (mA >= 500)
671 mA = 500;
672 else if (mA >= 100)
673 mA = 100;
674 else
675 mA = 0;
676 the_tps->vbus = mA;
677 if ((the_tps->chgstatus & TPS_CHG_USB)
678 && test_and_set_bit(
679 FLAG_VBUS_CHANGED, &the_tps->flags)) {
680 /* gadget drivers call this in_irq() */
681 (void) schedule_work(&the_tps->work);
682 }
683 local_irq_restore(flags);
684
685 return 0;
686}
687EXPORT_SYMBOL(tps65010_set_vbus_draw);
688
689/*-------------------------------------------------------------------------*/
690/* tps65010_set_gpio_out_value parameter:
691 * gpio: GPIO1, GPIO2, GPIO3 or GPIO4
692 * value: LOW or HIGH
693 */
694int tps65010_set_gpio_out_value(unsigned gpio, unsigned value)
695{
696 int status;
697 unsigned defgpio;
698
699 if (!the_tps)
700 return -ENODEV;
701 if ((gpio < GPIO1) || (gpio > GPIO4))
702 return -EINVAL;
703
704 down(&the_tps->lock);
705
706 defgpio = i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO);
707
708 /* Configure GPIO for output */
709 defgpio |= 1 << (gpio + 3);
710
711 /* Writing 1 forces a logic 0 on that GPIO and vice versa */
712 switch (value) {
713 case LOW:
714 defgpio |= 1 << (gpio - 1); /* set GPIO low by writing 1 */
715 break;
716 /* case HIGH: */
717 default:
718 defgpio &= ~(1 << (gpio - 1)); /* set GPIO high by writing 0 */
719 break;
720 }
721
722 status = i2c_smbus_write_byte_data(&the_tps->client,
723 TPS_DEFGPIO, defgpio);
724
725 pr_debug("%s: gpio%dout = %s, defgpio 0x%02x\n", DRIVER_NAME,
726 gpio, value ? "high" : "low",
727 i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO));
728
729 up(&the_tps->lock);
730 return status;
731}
732EXPORT_SYMBOL(tps65010_set_gpio_out_value);
733
734/*-------------------------------------------------------------------------*/
735/* tps65010_set_led parameter:
736 * led: LED1 or LED2
737 * mode: ON, OFF or BLINK
738 */
739int tps65010_set_led(unsigned led, unsigned mode)
740{
741 int status;
742 unsigned led_on, led_per, offs;
743
744 if (!the_tps)
745 return -ENODEV;
746
747 if(led == LED1)
748 offs = 0;
749 else {
750 offs = 2;
751 led = LED2;
752 }
753
754 down(&the_tps->lock);
755
756 dev_dbg (&the_tps->client.dev, "led%i_on 0x%02x\n", led,
757 i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs));
758
759 dev_dbg (&the_tps->client.dev, "led%i_per 0x%02x\n", led,
760 i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_PER + offs));
761
762 switch (mode) {
763 case OFF:
764 led_on = 1 << 7;
765 led_per = 0 << 7;
766 break;
767 case ON:
768 led_on = 1 << 7;
769 led_per = 1 << 7;
770 break;
771 case BLINK:
772 led_on = 0x30 | (0 << 7);
773 led_per = 0x08 | (1 << 7);
774 break;
775 default:
776 printk(KERN_ERR "%s: Wrong mode parameter for tps65010_set_led()\n",
777 DRIVER_NAME);
778 up(&the_tps->lock);
779 return -EINVAL;
780 }
781
782 status = i2c_smbus_write_byte_data(&the_tps->client,
783 TPS_LED1_ON + offs, led_on);
784
785 if (status != 0) {
786 printk(KERN_ERR "%s: Failed to write led%i_on register\n",
787 DRIVER_NAME, led);
788 up(&the_tps->lock);
789 return status;
790 }
791
792 dev_dbg (&the_tps->client.dev, "led%i_on 0x%02x\n", led,
793 i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs));
794
795 status = i2c_smbus_write_byte_data(&the_tps->client,
796 TPS_LED1_PER + offs, led_per);
797
798 if (status != 0) {
799 printk(KERN_ERR "%s: Failed to write led%i_per register\n",
800 DRIVER_NAME, led);
801 up(&the_tps->lock);
802 return status;
803 }
804
805 dev_dbg (&the_tps->client.dev, "led%i_per 0x%02x\n", led,
806 i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_PER + offs));
807
808 up(&the_tps->lock);
809
810 return status;
811}
812EXPORT_SYMBOL(tps65010_set_led);
813
814/*-------------------------------------------------------------------------*/
815/* tps65010_set_vib parameter:
816 * value: ON or OFF
817 */
818int tps65010_set_vib(unsigned value)
819{
820 int status;
821 unsigned vdcdc2;
822
823 if (!the_tps)
824 return -ENODEV;
825
826 down(&the_tps->lock);
827
828 vdcdc2 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC2);
829 vdcdc2 &= ~(1 << 1);
830 if (value)
831 vdcdc2 |= (1 << 1);
832 status = i2c_smbus_write_byte_data(&the_tps->client,
833 TPS_VDCDC2, vdcdc2);
834
835 pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off");
836
837 up(&the_tps->lock);
838 return status;
839}
840EXPORT_SYMBOL(tps65010_set_vib);
841
842/*-------------------------------------------------------------------------*/
843/* tps65010_set_low_pwr parameter:
844 * mode: ON or OFF
845 */
846int tps65010_set_low_pwr(unsigned mode)
847{
848 int status;
849 unsigned vdcdc1;
850
851 if (!the_tps)
852 return -ENODEV;
853
854 down(&the_tps->lock);
855
856 pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME,
857 mode ? "enable" : "disable",
858 i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1));
859
860 vdcdc1 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1);
861
862 switch (mode) {
863 case OFF:
864 vdcdc1 &= ~TPS_ENABLE_LP; /* disable ENABLE_LP bit */
865 break;
866 /* case ON: */
867 default:
868 vdcdc1 |= TPS_ENABLE_LP; /* enable ENABLE_LP bit */
869 break;
870 }
871
872 status = i2c_smbus_write_byte_data(&the_tps->client,
873 TPS_VDCDC1, vdcdc1);
874
875 if (status != 0)
876 printk(KERN_ERR "%s: Failed to write vdcdc1 register\n",
877 DRIVER_NAME);
878 else
879 pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME,
880 i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1));
881
882 up(&the_tps->lock);
883
884 return status;
885}
886EXPORT_SYMBOL(tps65010_set_low_pwr);
887
888/*-------------------------------------------------------------------------*/
889/* tps65010_config_vregs1 parameter:
890 * value to be written to VREGS1 register
891 * Note: The complete register is written, set all bits you need
892 */
893int tps65010_config_vregs1(unsigned value)
894{
895 int status;
896
897 if (!the_tps)
898 return -ENODEV;
899
900 down(&the_tps->lock);
901
902 pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,
903 i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1));
904
905 status = i2c_smbus_write_byte_data(&the_tps->client,
906 TPS_VREGS1, value);
907
908 if (status != 0)
909 printk(KERN_ERR "%s: Failed to write vregs1 register\n",
910 DRIVER_NAME);
911 else
912 pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,
913 i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1));
914
915 up(&the_tps->lock);
916
917 return status;
918}
919EXPORT_SYMBOL(tps65010_config_vregs1);
920
921/*-------------------------------------------------------------------------*/
922/* tps65013_set_low_pwr parameter:
923 * mode: ON or OFF
924 */
925
926/* FIXME: Assumes AC or USB power is present. Setting AUA bit is not
927 required if power supply is through a battery */
928
929int tps65013_set_low_pwr(unsigned mode)
930{
931 int status;
932 unsigned vdcdc1, chgconfig;
933
934 if (!the_tps || the_tps->por)
935 return -ENODEV;
936
937 down(&the_tps->lock);
938
939 pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n",
940 DRIVER_NAME,
941 mode ? "enable" : "disable",
942 i2c_smbus_read_byte_data(&the_tps->client, TPS_CHGCONFIG),
943 i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1));
944
945 chgconfig = i2c_smbus_read_byte_data(&the_tps->client, TPS_CHGCONFIG);
946 vdcdc1 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1);
947
948 switch (mode) {
949 case OFF:
950 chgconfig &= ~TPS65013_AUA; /* disable AUA bit */
951 vdcdc1 &= ~TPS_ENABLE_LP; /* disable ENABLE_LP bit */
952 break;
953 /* case ON: */
954 default:
955 chgconfig |= TPS65013_AUA; /* enable AUA bit */
956 vdcdc1 |= TPS_ENABLE_LP; /* enable ENABLE_LP bit */
957 break;
958 }
959
960 status = i2c_smbus_write_byte_data(&the_tps->client,
961 TPS_CHGCONFIG, chgconfig);
962 if (status != 0) {
963 printk(KERN_ERR "%s: Failed to write chconfig register\n",
964 DRIVER_NAME);
965 up(&the_tps->lock);
966 return status;
967 }
968
969 chgconfig = i2c_smbus_read_byte_data(&the_tps->client, TPS_CHGCONFIG);
970 the_tps->chgconf = chgconfig;
971 show_chgconfig(0, "chgconf", chgconfig);
972
973 status = i2c_smbus_write_byte_data(&the_tps->client,
974 TPS_VDCDC1, vdcdc1);
975
976 if (status != 0)
977 printk(KERN_ERR "%s: Failed to write vdcdc1 register\n",
978 DRIVER_NAME);
979 else
980 pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME,
981 i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1));
982
983 up(&the_tps->lock);
984
985 return status;
986}
987EXPORT_SYMBOL(tps65013_set_low_pwr);
988
989/*-------------------------------------------------------------------------*/
990
991static int __init tps_init(void)
992{
993 u32 tries = 3;
994 int status = -ENODEV;
995
996 printk(KERN_INFO "%s: version %s\n", DRIVER_NAME, DRIVER_VERSION);
997
998 /* some boards have startup glitches */
999 while (tries--) {
1000 status = i2c_add_driver(&tps65010_driver);
1001 if (the_tps)
1002 break;
1003 i2c_del_driver(&tps65010_driver);
1004 if (!tries) {
1005 printk(KERN_ERR "%s: no chip?\n", DRIVER_NAME);
1006 return -ENODEV;
1007 }
1008 pr_debug("%s: re-probe ...\n", DRIVER_NAME);
1009 msleep(10);
1010 }
1011
1012#if defined(CONFIG_ARM)
1013 if (machine_is_omap_osk()) {
1014
1015 // FIXME: More should be placed in the initialization code
1016 // of the submodules (DSP, ethernet, power management,
1017 // board-osk.c). Careful: I2C is initialized "late".
1018
1019 /* Let LED1 (D9) blink */
1020 tps65010_set_led(LED1, BLINK);
1021
1022 /* Disable LED 2 (D2) */
1023 tps65010_set_led(LED2, OFF);
1024
1025 /* Set GPIO 1 HIGH to disable VBUS power supply;
1026 * OHCI driver powers it up/down as needed.
1027 */
1028 tps65010_set_gpio_out_value(GPIO1, HIGH);
1029
1030 /* Set GPIO 2 low to turn on LED D3 */
1031 tps65010_set_gpio_out_value(GPIO2, HIGH);
1032
1033 /* Set GPIO 3 low to take ethernet out of reset */
1034 tps65010_set_gpio_out_value(GPIO3, LOW);
1035
1036 /* gpio4 for VDD_DSP */
1037
1038 /* Enable LOW_PWR */
1039 tps65010_set_low_pwr(ON);
1040
1041 /* Switch VLDO2 to 3.0V for AIC23 */
1042 tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V | TPS_LDO1_ENABLE);
1043
1044 } else if (machine_is_omap_h2()) {
1045 /* gpio3 for SD, gpio4 for VDD_DSP */
1046
1047 /* Enable LOW_PWR */
1048 tps65010_set_low_pwr(ON);
1049 } else if (machine_is_omap_h3()) {
1050 /* gpio4 for SD, gpio3 for VDD_DSP */
1051#ifdef CONFIG_PM
1052 /* Enable LOW_PWR */
1053 tps65013_set_low_pwr(ON);
1054#endif
1055 }
1056#endif
1057
1058 return status;
1059}
1060/* NOTE: this MUST be initialized before the other parts of the system
1061 * that rely on it ... but after the i2c bus on which this relies.
1062 * That is, much earlier than on PC-type systems, which don't often use
1063 * I2C as a core system bus.
1064 */
1065subsys_initcall(tps_init);
1066
1067static void __exit tps_exit(void)
1068{
1069 i2c_del_driver(&tps65010_driver);
1070}
1071module_exit(tps_exit);
1072
diff --git a/drivers/i2c/chips/via686a.c b/drivers/i2c/chips/via686a.c
index fefc24a9251a..137d9b7cacd4 100644
--- a/drivers/i2c/chips/via686a.c
+++ b/drivers/i2c/chips/via686a.c
@@ -1,12 +1,12 @@
1/* 1/*
2 via686a.c - Part of lm_sensors, Linux kernel modules 2 via686a.c - Part of lm_sensors, Linux kernel modules
3 for hardware monitoring 3 for hardware monitoring
4 4
5 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, 5 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>,
6 Kyösti Mälkki <kmalkki@cc.hut.fi>, 6 Kyösti Mälkki <kmalkki@cc.hut.fi>,
7 Mark Studebaker <mdsxyz123@yahoo.com>, 7 Mark Studebaker <mdsxyz123@yahoo.com>,
8 and Bob Dougherty <bobd@stanford.edu> 8 and Bob Dougherty <bobd@stanford.edu>
9 (Some conversion-factor data were contributed by Jonathan Teh Soon Yew 9 (Some conversion-factor data were contributed by Jonathan Teh Soon Yew
10 <j.teh@iname.com> and Alex van Kaam <darkside@chello.nl>.) 10 <j.teh@iname.com> and Alex van Kaam <darkside@chello.nl>.)
11 11
12 This program is free software; you can redistribute it and/or modify 12 This program is free software; you can redistribute it and/or modify
@@ -30,11 +30,9 @@
30 Warning - only supports a single device. 30 Warning - only supports a single device.
31*/ 31*/
32 32
33#include <linux/config.h>
34#include <linux/module.h> 33#include <linux/module.h>
35#include <linux/slab.h> 34#include <linux/slab.h>
36#include <linux/pci.h> 35#include <linux/pci.h>
37#include <linux/delay.h>
38#include <linux/jiffies.h> 36#include <linux/jiffies.h>
39#include <linux/i2c.h> 37#include <linux/i2c.h>
40#include <linux/i2c-sensor.h> 38#include <linux/i2c-sensor.h>
@@ -66,49 +64,46 @@ SENSORS_INSMOD_1(via686a);
66/* Many VIA686A constants specified below */ 64/* Many VIA686A constants specified below */
67 65
68/* Length of ISA address segment */ 66/* Length of ISA address segment */
69#define VIA686A_EXTENT 0x80 67#define VIA686A_EXTENT 0x80
70#define VIA686A_BASE_REG 0x70 68#define VIA686A_BASE_REG 0x70
71#define VIA686A_ENABLE_REG 0x74 69#define VIA686A_ENABLE_REG 0x74
72 70
73/* The VIA686A registers */ 71/* The VIA686A registers */
74/* ins numbered 0-4 */ 72/* ins numbered 0-4 */
75#define VIA686A_REG_IN_MAX(nr) (0x2b + ((nr) * 2)) 73#define VIA686A_REG_IN_MAX(nr) (0x2b + ((nr) * 2))
76#define VIA686A_REG_IN_MIN(nr) (0x2c + ((nr) * 2)) 74#define VIA686A_REG_IN_MIN(nr) (0x2c + ((nr) * 2))
77#define VIA686A_REG_IN(nr) (0x22 + (nr)) 75#define VIA686A_REG_IN(nr) (0x22 + (nr))
78 76
79/* fans numbered 1-2 */ 77/* fans numbered 1-2 */
80#define VIA686A_REG_FAN_MIN(nr) (0x3a + (nr)) 78#define VIA686A_REG_FAN_MIN(nr) (0x3a + (nr))
81#define VIA686A_REG_FAN(nr) (0x28 + (nr)) 79#define VIA686A_REG_FAN(nr) (0x28 + (nr))
82
83/* the following values are as speced by VIA: */
84static const u8 regtemp[] = { 0x20, 0x21, 0x1f };
85static const u8 regover[] = { 0x39, 0x3d, 0x1d };
86static const u8 reghyst[] = { 0x3a, 0x3e, 0x1e };
87 80
88/* temps numbered 1-3 */ 81/* temps numbered 1-3 */
89#define VIA686A_REG_TEMP(nr) (regtemp[nr]) 82static const u8 VIA686A_REG_TEMP[] = { 0x20, 0x21, 0x1f };
90#define VIA686A_REG_TEMP_OVER(nr) (regover[nr]) 83static const u8 VIA686A_REG_TEMP_OVER[] = { 0x39, 0x3d, 0x1d };
91#define VIA686A_REG_TEMP_HYST(nr) (reghyst[nr]) 84static const u8 VIA686A_REG_TEMP_HYST[] = { 0x3a, 0x3e, 0x1e };
92#define VIA686A_REG_TEMP_LOW1 0x4b // bits 7-6 85/* bits 7-6 */
93#define VIA686A_REG_TEMP_LOW23 0x49 // 2 = bits 5-4, 3 = bits 7-6 86#define VIA686A_REG_TEMP_LOW1 0x4b
94 87/* 2 = bits 5-4, 3 = bits 7-6 */
95#define VIA686A_REG_ALARM1 0x41 88#define VIA686A_REG_TEMP_LOW23 0x49
96#define VIA686A_REG_ALARM2 0x42 89
97#define VIA686A_REG_FANDIV 0x47 90#define VIA686A_REG_ALARM1 0x41
98#define VIA686A_REG_CONFIG 0x40 91#define VIA686A_REG_ALARM2 0x42
99/* The following register sets temp interrupt mode (bits 1-0 for temp1, 92#define VIA686A_REG_FANDIV 0x47
93#define VIA686A_REG_CONFIG 0x40
94/* The following register sets temp interrupt mode (bits 1-0 for temp1,
100 3-2 for temp2, 5-4 for temp3). Modes are: 95 3-2 for temp2, 5-4 for temp3). Modes are:
101 00 interrupt stays as long as value is out-of-range 96 00 interrupt stays as long as value is out-of-range
102 01 interrupt is cleared once register is read (default) 97 01 interrupt is cleared once register is read (default)
103 10 comparator mode- like 00, but ignores hysteresis 98 10 comparator mode- like 00, but ignores hysteresis
104 11 same as 00 */ 99 11 same as 00 */
105#define VIA686A_REG_TEMP_MODE 0x4b 100#define VIA686A_REG_TEMP_MODE 0x4b
106/* We'll just assume that you want to set all 3 simultaneously: */ 101/* We'll just assume that you want to set all 3 simultaneously: */
107#define VIA686A_TEMP_MODE_MASK 0x3F 102#define VIA686A_TEMP_MODE_MASK 0x3F
108#define VIA686A_TEMP_MODE_CONTINUOUS (0x00) 103#define VIA686A_TEMP_MODE_CONTINUOUS 0x00
109 104
110/* Conversions. Limit checking is only done on the TO_REG 105/* Conversions. Limit checking is only done on the TO_REG
111 variants. 106 variants.
112 107
113********* VOLTAGE CONVERSIONS (Bob Dougherty) ******** 108********* VOLTAGE CONVERSIONS (Bob Dougherty) ********
114 From HWMon.cpp (Copyright 1998-2000 Jonathan Teh Soon Yew): 109 From HWMon.cpp (Copyright 1998-2000 Jonathan Teh Soon Yew):
@@ -121,7 +116,7 @@ static const u8 reghyst[] = { 0x3a, 0x3e, 0x1e };
121 That is: 116 That is:
122 volts = (25*regVal+133)*factor 117 volts = (25*regVal+133)*factor
123 regVal = (volts/factor-133)/25 118 regVal = (volts/factor-133)/25
124 (These conversions were contributed by Jonathan Teh Soon Yew 119 (These conversions were contributed by Jonathan Teh Soon Yew
125 <j.teh@iname.com>) */ 120 <j.teh@iname.com>) */
126static inline u8 IN_TO_REG(long val, int inNum) 121static inline u8 IN_TO_REG(long val, int inNum)
127{ 122{
@@ -182,55 +177,55 @@ static inline u8 FAN_TO_REG(long rpm, int div)
182 else 177 else
183 return double(temp)*0.924-127.33; 178 return double(temp)*0.924-127.33;
184 179
185 A fifth-order polynomial fits the unofficial data (provided by Alex van 180 A fifth-order polynomial fits the unofficial data (provided by Alex van
186 Kaam <darkside@chello.nl>) a bit better. It also give more reasonable 181 Kaam <darkside@chello.nl>) a bit better. It also give more reasonable
187 numbers on my machine (ie. they agree with what my BIOS tells me). 182 numbers on my machine (ie. they agree with what my BIOS tells me).
188 Here's the fifth-order fit to the 8-bit data: 183 Here's the fifth-order fit to the 8-bit data:
189 temp = 1.625093e-10*val^5 - 1.001632e-07*val^4 + 2.457653e-05*val^3 - 184 temp = 1.625093e-10*val^5 - 1.001632e-07*val^4 + 2.457653e-05*val^3 -
190 2.967619e-03*val^2 + 2.175144e-01*val - 7.090067e+0. 185 2.967619e-03*val^2 + 2.175144e-01*val - 7.090067e+0.
191 186
192 (2000-10-25- RFD: thanks to Uwe Andersen <uandersen@mayah.com> for 187 (2000-10-25- RFD: thanks to Uwe Andersen <uandersen@mayah.com> for
193 finding my typos in this formula!) 188 finding my typos in this formula!)
194 189
195 Alas, none of the elegant function-fit solutions will work because we 190 Alas, none of the elegant function-fit solutions will work because we
196 aren't allowed to use floating point in the kernel and doing it with 191 aren't allowed to use floating point in the kernel and doing it with
197 integers doesn't rpovide enough precision. So we'll do boring old 192 integers doesn't provide enough precision. So we'll do boring old
198 look-up table stuff. The unofficial data (see below) have effectively 193 look-up table stuff. The unofficial data (see below) have effectively
199 7-bit resolution (they are rounded to the nearest degree). I'm assuming 194 7-bit resolution (they are rounded to the nearest degree). I'm assuming
200 that the transfer function of the device is monotonic and smooth, so a 195 that the transfer function of the device is monotonic and smooth, so a
201 smooth function fit to the data will allow us to get better precision. 196 smooth function fit to the data will allow us to get better precision.
202 I used the 5th-order poly fit described above and solved for 197 I used the 5th-order poly fit described above and solved for
203 VIA register values 0-255. I *10 before rounding, so we get tenth-degree 198 VIA register values 0-255. I *10 before rounding, so we get tenth-degree
204 precision. (I could have done all 1024 values for our 10-bit readings, 199 precision. (I could have done all 1024 values for our 10-bit readings,
205 but the function is very linear in the useful range (0-80 deg C), so 200 but the function is very linear in the useful range (0-80 deg C), so
206 we'll just use linear interpolation for 10-bit readings.) So, tempLUT 201 we'll just use linear interpolation for 10-bit readings.) So, tempLUT
207 is the temp at via register values 0-255: */ 202 is the temp at via register values 0-255: */
208static const long tempLUT[] = 203static const long tempLUT[] =
209 { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, 204{ -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519,
210 -503, -487, -471, -456, -442, -428, -414, -400, -387, -375, 205 -503, -487, -471, -456, -442, -428, -414, -400, -387, -375,
211 -362, -350, -339, -327, -316, -305, -295, -285, -275, -265, 206 -362, -350, -339, -327, -316, -305, -295, -285, -275, -265,
212 -255, -246, -237, -229, -220, -212, -204, -196, -188, -180, 207 -255, -246, -237, -229, -220, -212, -204, -196, -188, -180,
213 -173, -166, -159, -152, -145, -139, -132, -126, -120, -114, 208 -173, -166, -159, -152, -145, -139, -132, -126, -120, -114,
214 -108, -102, -96, -91, -85, -80, -74, -69, -64, -59, -54, -49, 209 -108, -102, -96, -91, -85, -80, -74, -69, -64, -59, -54, -49,
215 -44, -39, -34, -29, -25, -20, -15, -11, -6, -2, 3, 7, 12, 16, 210 -44, -39, -34, -29, -25, -20, -15, -11, -6, -2, 3, 7, 12, 16,
216 20, 25, 29, 33, 37, 42, 46, 50, 54, 59, 63, 67, 71, 75, 79, 84, 211 20, 25, 29, 33, 37, 42, 46, 50, 54, 59, 63, 67, 71, 75, 79, 84,
217 88, 92, 96, 100, 104, 109, 113, 117, 121, 125, 130, 134, 138, 212 88, 92, 96, 100, 104, 109, 113, 117, 121, 125, 130, 134, 138,
218 142, 146, 151, 155, 159, 163, 168, 172, 176, 181, 185, 189, 213 142, 146, 151, 155, 159, 163, 168, 172, 176, 181, 185, 189,
219 193, 198, 202, 206, 211, 215, 219, 224, 228, 232, 237, 241, 214 193, 198, 202, 206, 211, 215, 219, 224, 228, 232, 237, 241,
220 245, 250, 254, 259, 263, 267, 272, 276, 281, 285, 290, 294, 215 245, 250, 254, 259, 263, 267, 272, 276, 281, 285, 290, 294,
221 299, 303, 307, 312, 316, 321, 325, 330, 334, 339, 344, 348, 216 299, 303, 307, 312, 316, 321, 325, 330, 334, 339, 344, 348,
222 353, 357, 362, 366, 371, 376, 380, 385, 390, 395, 399, 404, 217 353, 357, 362, 366, 371, 376, 380, 385, 390, 395, 399, 404,
223 409, 414, 419, 423, 428, 433, 438, 443, 449, 454, 459, 464, 218 409, 414, 419, 423, 428, 433, 438, 443, 449, 454, 459, 464,
224 469, 475, 480, 486, 491, 497, 502, 508, 514, 520, 526, 532, 219 469, 475, 480, 486, 491, 497, 502, 508, 514, 520, 526, 532,
225 538, 544, 551, 557, 564, 571, 578, 584, 592, 599, 606, 614, 220 538, 544, 551, 557, 564, 571, 578, 584, 592, 599, 606, 614,
226 621, 629, 637, 645, 654, 662, 671, 680, 689, 698, 708, 718, 221 621, 629, 637, 645, 654, 662, 671, 680, 689, 698, 708, 718,
227 728, 738, 749, 759, 770, 782, 793, 805, 818, 830, 843, 856, 222 728, 738, 749, 759, 770, 782, 793, 805, 818, 830, 843, 856,
228 870, 883, 898, 912, 927, 943, 958, 975, 991, 1008, 1026, 1044, 223 870, 883, 898, 912, 927, 943, 958, 975, 991, 1008, 1026, 1044,
229 1062, 1081, 1101, 1121, 1141, 1162, 1184, 1206, 1229, 1252, 224 1062, 1081, 1101, 1121, 1141, 1162, 1184, 1206, 1229, 1252,
230 1276, 1301, 1326, 1352, 1378, 1406, 1434, 1462 225 1276, 1301, 1326, 1352, 1378, 1406, 1434, 1462
231}; 226};
232 227
233/* the original LUT values from Alex van Kaam <darkside@chello.nl> 228/* the original LUT values from Alex van Kaam <darkside@chello.nl>
234 (for via register values 12-240): 229 (for via register values 12-240):
235{-50,-49,-47,-45,-43,-41,-39,-38,-37,-35,-34,-33,-32,-31, 230{-50,-49,-47,-45,-43,-41,-39,-38,-37,-35,-34,-33,-32,-31,
236-30,-29,-28,-27,-26,-25,-24,-24,-23,-22,-21,-20,-20,-19,-18,-17,-17,-16,-15, 231-30,-29,-28,-27,-26,-25,-24,-24,-23,-22,-21,-20,-20,-19,-18,-17,-17,-16,-15,
@@ -245,26 +240,26 @@ static const long tempLUT[] =
245 240
246 241
247 Here's the reverse LUT. I got it by doing a 6-th order poly fit (needed 242 Here's the reverse LUT. I got it by doing a 6-th order poly fit (needed
248 an extra term for a good fit to these inverse data!) and then 243 an extra term for a good fit to these inverse data!) and then
249 solving for each temp value from -50 to 110 (the useable range for 244 solving for each temp value from -50 to 110 (the useable range for
250 this chip). Here's the fit: 245 this chip). Here's the fit:
251 viaRegVal = -1.160370e-10*val^6 +3.193693e-08*val^5 - 1.464447e-06*val^4 246 viaRegVal = -1.160370e-10*val^6 +3.193693e-08*val^5 - 1.464447e-06*val^4
252 - 2.525453e-04*val^3 + 1.424593e-02*val^2 + 2.148941e+00*val +7.275808e+01) 247 - 2.525453e-04*val^3 + 1.424593e-02*val^2 + 2.148941e+00*val +7.275808e+01)
253 Note that n=161: */ 248 Note that n=161: */
254static const u8 viaLUT[] = 249static const u8 viaLUT[] =
255 { 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20, 21, 22, 23, 250{ 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20, 21, 22, 23,
256 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 39, 40, 251 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 39, 40,
257 41, 43, 45, 46, 48, 49, 51, 53, 55, 57, 59, 60, 62, 64, 66, 252 41, 43, 45, 46, 48, 49, 51, 53, 55, 57, 59, 60, 62, 64, 66,
258 69, 71, 73, 75, 77, 79, 82, 84, 86, 88, 91, 93, 95, 98, 100, 253 69, 71, 73, 75, 77, 79, 82, 84, 86, 88, 91, 93, 95, 98, 100,
259 103, 105, 107, 110, 112, 115, 117, 119, 122, 124, 126, 129, 254 103, 105, 107, 110, 112, 115, 117, 119, 122, 124, 126, 129,
260 131, 134, 136, 138, 140, 143, 145, 147, 150, 152, 154, 156, 255 131, 134, 136, 138, 140, 143, 145, 147, 150, 152, 154, 156,
261 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 256 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180,
262 182, 183, 185, 187, 188, 190, 192, 193, 195, 196, 198, 199, 257 182, 183, 185, 187, 188, 190, 192, 193, 195, 196, 198, 199,
263 200, 202, 203, 205, 206, 207, 208, 209, 210, 211, 212, 213, 258 200, 202, 203, 205, 206, 207, 208, 209, 210, 211, 212, 213,
264 214, 215, 216, 217, 218, 219, 220, 221, 222, 222, 223, 224, 259 214, 215, 216, 217, 218, 219, 220, 221, 222, 222, 223, 224,
265 225, 226, 226, 227, 228, 228, 229, 230, 230, 231, 232, 232, 260 225, 226, 226, 227, 228, 228, 229, 230, 230, 231, 232, 232,
266 233, 233, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239, 261 233, 233, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239,
267 239, 240 262 239, 240
268}; 263};
269 264
270/* Converting temps to (8-bit) hyst and over registers 265/* Converting temps to (8-bit) hyst and over registers
@@ -272,7 +267,7 @@ static const u8 viaLUT[] =
272 The +50 is because the temps start at -50 */ 267 The +50 is because the temps start at -50 */
273static inline u8 TEMP_TO_REG(long val) 268static inline u8 TEMP_TO_REG(long val)
274{ 269{
275 return viaLUT[val <= -50000 ? 0 : val >= 110000 ? 160 : 270 return viaLUT[val <= -50000 ? 0 : val >= 110000 ? 160 :
276 (val < 0 ? val - 500 : val + 500) / 1000 + 50]; 271 (val < 0 ? val - 500 : val + 500) / 1000 + 50];
277} 272}
278 273
@@ -291,11 +286,9 @@ static inline long TEMP_FROM_REG10(u16 val)
291 286
292 /* do some linear interpolation */ 287 /* do some linear interpolation */
293 return (tempLUT[eightBits] * (4 - twoBits) + 288 return (tempLUT[eightBits] * (4 - twoBits) +
294 tempLUT[eightBits + 1] * twoBits) * 25; 289 tempLUT[eightBits + 1] * twoBits) * 25;
295} 290}
296 291
297#define ALARMS_FROM_REG(val) (val)
298
299#define DIV_FROM_REG(val) (1 << (val)) 292#define DIV_FROM_REG(val) (1 << (val))
300#define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1) 293#define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1)
301 294
@@ -358,28 +351,28 @@ static ssize_t show_in_max(struct device *dev, char *buf, int nr) {
358 return sprintf(buf, "%ld\n", IN_FROM_REG(data->in_max[nr], nr)); 351 return sprintf(buf, "%ld\n", IN_FROM_REG(data->in_max[nr], nr));
359} 352}
360 353
361static ssize_t set_in_min(struct device *dev, const char *buf, 354static ssize_t set_in_min(struct device *dev, const char *buf,
362 size_t count, int nr) { 355 size_t count, int nr) {
363 struct i2c_client *client = to_i2c_client(dev); 356 struct i2c_client *client = to_i2c_client(dev);
364 struct via686a_data *data = i2c_get_clientdata(client); 357 struct via686a_data *data = i2c_get_clientdata(client);
365 unsigned long val = simple_strtoul(buf, NULL, 10); 358 unsigned long val = simple_strtoul(buf, NULL, 10);
366 359
367 down(&data->update_lock); 360 down(&data->update_lock);
368 data->in_min[nr] = IN_TO_REG(val,nr); 361 data->in_min[nr] = IN_TO_REG(val, nr);
369 via686a_write_value(client, VIA686A_REG_IN_MIN(nr), 362 via686a_write_value(client, VIA686A_REG_IN_MIN(nr),
370 data->in_min[nr]); 363 data->in_min[nr]);
371 up(&data->update_lock); 364 up(&data->update_lock);
372 return count; 365 return count;
373} 366}
374static ssize_t set_in_max(struct device *dev, const char *buf, 367static ssize_t set_in_max(struct device *dev, const char *buf,
375 size_t count, int nr) { 368 size_t count, int nr) {
376 struct i2c_client *client = to_i2c_client(dev); 369 struct i2c_client *client = to_i2c_client(dev);
377 struct via686a_data *data = i2c_get_clientdata(client); 370 struct via686a_data *data = i2c_get_clientdata(client);
378 unsigned long val = simple_strtoul(buf, NULL, 10); 371 unsigned long val = simple_strtoul(buf, NULL, 10);
379 372
380 down(&data->update_lock); 373 down(&data->update_lock);
381 data->in_max[nr] = IN_TO_REG(val,nr); 374 data->in_max[nr] = IN_TO_REG(val, nr);
382 via686a_write_value(client, VIA686A_REG_IN_MAX(nr), 375 via686a_write_value(client, VIA686A_REG_IN_MAX(nr),
383 data->in_max[nr]); 376 data->in_max[nr]);
384 up(&data->update_lock); 377 up(&data->update_lock);
385 return count; 378 return count;
@@ -435,7 +428,7 @@ static ssize_t show_temp_hyst(struct device *dev, char *buf, int nr) {
435 struct via686a_data *data = via686a_update_device(dev); 428 struct via686a_data *data = via686a_update_device(dev);
436 return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp_hyst[nr])); 429 return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp_hyst[nr]));
437} 430}
438static ssize_t set_temp_over(struct device *dev, const char *buf, 431static ssize_t set_temp_over(struct device *dev, const char *buf,
439 size_t count, int nr) { 432 size_t count, int nr) {
440 struct i2c_client *client = to_i2c_client(dev); 433 struct i2c_client *client = to_i2c_client(dev);
441 struct via686a_data *data = i2c_get_clientdata(client); 434 struct via686a_data *data = i2c_get_clientdata(client);
@@ -443,11 +436,12 @@ static ssize_t set_temp_over(struct device *dev, const char *buf,
443 436
444 down(&data->update_lock); 437 down(&data->update_lock);
445 data->temp_over[nr] = TEMP_TO_REG(val); 438 data->temp_over[nr] = TEMP_TO_REG(val);
446 via686a_write_value(client, VIA686A_REG_TEMP_OVER(nr), data->temp_over[nr]); 439 via686a_write_value(client, VIA686A_REG_TEMP_OVER[nr],
440 data->temp_over[nr]);
447 up(&data->update_lock); 441 up(&data->update_lock);
448 return count; 442 return count;
449} 443}
450static ssize_t set_temp_hyst(struct device *dev, const char *buf, 444static ssize_t set_temp_hyst(struct device *dev, const char *buf,
451 size_t count, int nr) { 445 size_t count, int nr) {
452 struct i2c_client *client = to_i2c_client(dev); 446 struct i2c_client *client = to_i2c_client(dev);
453 struct via686a_data *data = i2c_get_clientdata(client); 447 struct via686a_data *data = i2c_get_clientdata(client);
@@ -455,7 +449,8 @@ static ssize_t set_temp_hyst(struct device *dev, const char *buf,
455 449
456 down(&data->update_lock); 450 down(&data->update_lock);
457 data->temp_hyst[nr] = TEMP_TO_REG(val); 451 data->temp_hyst[nr] = TEMP_TO_REG(val);
458 via686a_write_value(client, VIA686A_REG_TEMP_HYST(nr), data->temp_hyst[nr]); 452 via686a_write_value(client, VIA686A_REG_TEMP_HYST[nr],
453 data->temp_hyst[nr]);
459 up(&data->update_lock); 454 up(&data->update_lock);
460 return count; 455 return count;
461} 456}
@@ -488,7 +483,7 @@ static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL);\
488static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ 483static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
489 show_temp_##offset##_over, set_temp_##offset##_over); \ 484 show_temp_##offset##_over, set_temp_##offset##_over); \
490static DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \ 485static DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \
491 show_temp_##offset##_hyst, set_temp_##offset##_hyst); 486 show_temp_##offset##_hyst, set_temp_##offset##_hyst);
492 487
493show_temp_offset(1); 488show_temp_offset(1);
494show_temp_offset(2); 489show_temp_offset(2);
@@ -497,19 +492,19 @@ show_temp_offset(3);
497/* 2 Fans */ 492/* 2 Fans */
498static ssize_t show_fan(struct device *dev, char *buf, int nr) { 493static ssize_t show_fan(struct device *dev, char *buf, int nr) {
499 struct via686a_data *data = via686a_update_device(dev); 494 struct via686a_data *data = via686a_update_device(dev);
500 return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], 495 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr],
501 DIV_FROM_REG(data->fan_div[nr])) ); 496 DIV_FROM_REG(data->fan_div[nr])) );
502} 497}
503static ssize_t show_fan_min(struct device *dev, char *buf, int nr) { 498static ssize_t show_fan_min(struct device *dev, char *buf, int nr) {
504 struct via686a_data *data = via686a_update_device(dev); 499 struct via686a_data *data = via686a_update_device(dev);
505 return sprintf(buf,"%d\n", 500 return sprintf(buf, "%d\n",
506 FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])) ); 501 FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])) );
507} 502}
508static ssize_t show_fan_div(struct device *dev, char *buf, int nr) { 503static ssize_t show_fan_div(struct device *dev, char *buf, int nr) {
509 struct via686a_data *data = via686a_update_device(dev); 504 struct via686a_data *data = via686a_update_device(dev);
510 return sprintf(buf,"%d\n", DIV_FROM_REG(data->fan_div[nr]) ); 505 return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr]) );
511} 506}
512static ssize_t set_fan_min(struct device *dev, const char *buf, 507static ssize_t set_fan_min(struct device *dev, const char *buf,
513 size_t count, int nr) { 508 size_t count, int nr) {
514 struct i2c_client *client = to_i2c_client(dev); 509 struct i2c_client *client = to_i2c_client(dev);
515 struct via686a_data *data = i2c_get_clientdata(client); 510 struct via686a_data *data = i2c_get_clientdata(client);
@@ -521,7 +516,7 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
521 up(&data->update_lock); 516 up(&data->update_lock);
522 return count; 517 return count;
523} 518}
524static ssize_t set_fan_div(struct device *dev, const char *buf, 519static ssize_t set_fan_div(struct device *dev, const char *buf,
525 size_t count, int nr) { 520 size_t count, int nr) {
526 struct i2c_client *client = to_i2c_client(dev); 521 struct i2c_client *client = to_i2c_client(dev);
527 struct via686a_data *data = i2c_get_clientdata(client); 522 struct via686a_data *data = i2c_get_clientdata(client);
@@ -572,7 +567,7 @@ show_fan_offset(2);
572/* Alarms */ 567/* Alarms */
573static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) { 568static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) {
574 struct via686a_data *data = via686a_update_device(dev); 569 struct via686a_data *data = via686a_update_device(dev);
575 return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms)); 570 return sprintf(buf, "%u\n", data->alarms);
576} 571}
577static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 572static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
578 573
@@ -612,11 +607,12 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
612 } 607 }
613 608
614 /* 8231 requires multiple of 256, we enforce that on 686 as well */ 609 /* 8231 requires multiple of 256, we enforce that on 686 as well */
615 if(force_addr) 610 if (force_addr)
616 address = force_addr & 0xFF00; 611 address = force_addr & 0xFF00;
617 612
618 if(force_addr) { 613 if (force_addr) {
619 dev_warn(&adapter->dev,"forcing ISA address 0x%04X\n", address); 614 dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n",
615 address);
620 if (PCIBIOS_SUCCESSFUL != 616 if (PCIBIOS_SUCCESSFUL !=
621 pci_write_config_word(s_bridge, VIA686A_BASE_REG, address)) 617 pci_write_config_word(s_bridge, VIA686A_BASE_REG, address))
622 return -ENODEV; 618 return -ENODEV;
@@ -625,17 +621,17 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
625 pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val)) 621 pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val))
626 return -ENODEV; 622 return -ENODEV;
627 if (!(val & 0x0001)) { 623 if (!(val & 0x0001)) {
628 dev_warn(&adapter->dev,"enabling sensors\n"); 624 dev_warn(&adapter->dev, "enabling sensors\n");
629 if (PCIBIOS_SUCCESSFUL != 625 if (PCIBIOS_SUCCESSFUL !=
630 pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, 626 pci_write_config_word(s_bridge, VIA686A_ENABLE_REG,
631 val | 0x0001)) 627 val | 0x0001))
632 return -ENODEV; 628 return -ENODEV;
633 } 629 }
634 630
635 /* Reserve the ISA region */ 631 /* Reserve the ISA region */
636 if (!request_region(address, VIA686A_EXTENT, via686a_driver.name)) { 632 if (!request_region(address, VIA686A_EXTENT, via686a_driver.name)) {
637 dev_err(&adapter->dev,"region 0x%x already in use!\n", 633 dev_err(&adapter->dev, "region 0x%x already in use!\n",
638 address); 634 address);
639 return -ENODEV; 635 return -ENODEV;
640 } 636 }
641 637
@@ -660,7 +656,7 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
660 /* Tell the I2C layer a new client has arrived */ 656 /* Tell the I2C layer a new client has arrived */
661 if ((err = i2c_attach_client(new_client))) 657 if ((err = i2c_attach_client(new_client)))
662 goto ERROR3; 658 goto ERROR3;
663 659
664 /* Initialize the VIA686A chip */ 660 /* Initialize the VIA686A chip */
665 via686a_init_client(new_client); 661 via686a_init_client(new_client);
666 662
@@ -699,9 +695,9 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
699 695
700 return 0; 696 return 0;
701 697
702 ERROR3: 698ERROR3:
703 kfree(data); 699 kfree(data);
704 ERROR0: 700ERROR0:
705 release_region(address, VIA686A_EXTENT); 701 release_region(address, VIA686A_EXTENT);
706 return err; 702 return err;
707} 703}
@@ -732,7 +728,7 @@ static void via686a_init_client(struct i2c_client *client)
732 via686a_write_value(client, VIA686A_REG_CONFIG, (reg|0x01)&0x7F); 728 via686a_write_value(client, VIA686A_REG_CONFIG, (reg|0x01)&0x7F);
733 729
734 /* Configure temp interrupt mode for continuous-interrupt operation */ 730 /* Configure temp interrupt mode for continuous-interrupt operation */
735 via686a_write_value(client, VIA686A_REG_TEMP_MODE, 731 via686a_write_value(client, VIA686A_REG_TEMP_MODE,
736 via686a_read_value(client, VIA686A_REG_TEMP_MODE) & 732 via686a_read_value(client, VIA686A_REG_TEMP_MODE) &
737 !(VIA686A_TEMP_MODE_MASK | VIA686A_TEMP_MODE_CONTINUOUS)); 733 !(VIA686A_TEMP_MODE_MASK | VIA686A_TEMP_MODE_CONTINUOUS));
738} 734}
@@ -764,15 +760,15 @@ static struct via686a_data *via686a_update_device(struct device *dev)
764 } 760 }
765 for (i = 0; i <= 2; i++) { 761 for (i = 0; i <= 2; i++) {
766 data->temp[i] = via686a_read_value(client, 762 data->temp[i] = via686a_read_value(client,
767 VIA686A_REG_TEMP(i)) << 2; 763 VIA686A_REG_TEMP[i]) << 2;
768 data->temp_over[i] = 764 data->temp_over[i] =
769 via686a_read_value(client, 765 via686a_read_value(client,
770 VIA686A_REG_TEMP_OVER(i)); 766 VIA686A_REG_TEMP_OVER[i]);
771 data->temp_hyst[i] = 767 data->temp_hyst[i] =
772 via686a_read_value(client, 768 via686a_read_value(client,
773 VIA686A_REG_TEMP_HYST(i)); 769 VIA686A_REG_TEMP_HYST[i]);
774 } 770 }
775 /* add in lower 2 bits 771 /* add in lower 2 bits
776 temp1 uses bits 7-6 of VIA686A_REG_TEMP_LOW1 772 temp1 uses bits 7-6 of VIA686A_REG_TEMP_LOW1
777 temp2 uses bits 5-4 of VIA686A_REG_TEMP_LOW23 773 temp2 uses bits 5-4 of VIA686A_REG_TEMP_LOW23
778 temp3 uses bits 7-6 of VIA686A_REG_TEMP_LOW23 774 temp3 uses bits 7-6 of VIA686A_REG_TEMP_LOW23
@@ -804,35 +800,36 @@ static struct via686a_data *via686a_update_device(struct device *dev)
804} 800}
805 801
806static struct pci_device_id via686a_pci_ids[] = { 802static struct pci_device_id via686a_pci_ids[] = {
807 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4) }, 803 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4) },
808 { 0, } 804 { 0, }
809}; 805};
810 806
811MODULE_DEVICE_TABLE(pci, via686a_pci_ids); 807MODULE_DEVICE_TABLE(pci, via686a_pci_ids);
812 808
813static int __devinit via686a_pci_probe(struct pci_dev *dev, 809static int __devinit via686a_pci_probe(struct pci_dev *dev,
814 const struct pci_device_id *id) 810 const struct pci_device_id *id)
815{ 811{
816 u16 val; 812 u16 val;
817 int addr = 0; 813 int addr = 0;
818 814
819 if (PCIBIOS_SUCCESSFUL != 815 if (PCIBIOS_SUCCESSFUL !=
820 pci_read_config_word(dev, VIA686A_BASE_REG, &val)) 816 pci_read_config_word(dev, VIA686A_BASE_REG, &val))
821 return -ENODEV; 817 return -ENODEV;
822 818
823 addr = val & ~(VIA686A_EXTENT - 1); 819 addr = val & ~(VIA686A_EXTENT - 1);
824 if (addr == 0 && force_addr == 0) { 820 if (addr == 0 && force_addr == 0) {
825 dev_err(&dev->dev,"base address not set - upgrade BIOS or use force_addr=0xaddr\n"); 821 dev_err(&dev->dev, "base address not set - upgrade BIOS "
826 return -ENODEV; 822 "or use force_addr=0xaddr\n");
827 } 823 return -ENODEV;
828 if (force_addr) 824 }
829 addr = force_addr; /* so detect will get called */ 825 if (force_addr)
830 826 addr = force_addr; /* so detect will get called */
831 if (!addr) { 827
832 dev_err(&dev->dev,"No Via 686A sensors found.\n"); 828 if (!addr) {
833 return -ENODEV; 829 dev_err(&dev->dev, "No Via 686A sensors found.\n");
834 } 830 return -ENODEV;
835 normal_isa[0] = addr; 831 }
832 normal_isa[0] = addr;
836 833
837 s_bridge = pci_dev_get(dev); 834 s_bridge = pci_dev_get(dev);
838 if (i2c_add_driver(&via686a_driver)) { 835 if (i2c_add_driver(&via686a_driver)) {
@@ -848,14 +845,14 @@ static int __devinit via686a_pci_probe(struct pci_dev *dev,
848} 845}
849 846
850static struct pci_driver via686a_pci_driver = { 847static struct pci_driver via686a_pci_driver = {
851 .name = "via686a", 848 .name = "via686a",
852 .id_table = via686a_pci_ids, 849 .id_table = via686a_pci_ids,
853 .probe = via686a_pci_probe, 850 .probe = via686a_pci_probe,
854}; 851};
855 852
856static int __init sm_via686a_init(void) 853static int __init sm_via686a_init(void)
857{ 854{
858 return pci_register_driver(&via686a_pci_driver); 855 return pci_register_driver(&via686a_pci_driver);
859} 856}
860 857
861static void __exit sm_via686a_exit(void) 858static void __exit sm_via686a_exit(void)
@@ -869,8 +866,8 @@ static void __exit sm_via686a_exit(void)
869} 866}
870 867
871MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>, " 868MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>, "
872 "Mark Studebaker <mdsxyz123@yahoo.com> " 869 "Mark Studebaker <mdsxyz123@yahoo.com> "
873 "and Bob Dougherty <bobd@stanford.edu>"); 870 "and Bob Dougherty <bobd@stanford.edu>");
874MODULE_DESCRIPTION("VIA 686A Sensor device"); 871MODULE_DESCRIPTION("VIA 686A Sensor device");
875MODULE_LICENSE("GPL"); 872MODULE_LICENSE("GPL");
876 873
diff --git a/drivers/i2c/chips/w83627ehf.c b/drivers/i2c/chips/w83627ehf.c
new file mode 100644
index 000000000000..8a40b6976e1a
--- /dev/null
+++ b/drivers/i2c/chips/w83627ehf.c
@@ -0,0 +1,846 @@
1/*
2 w83627ehf - Driver for the hardware monitoring functionality of
3 the Winbond W83627EHF Super-I/O chip
4 Copyright (C) 2005 Jean Delvare <khali@linux-fr.org>
5
6 Shamelessly ripped from the w83627hf driver
7 Copyright (C) 2003 Mark Studebaker
8
9 Thanks to Leon Moonen, Steve Cliffe and Grant Coady for their help
10 in testing and debugging this driver.
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
26
27 Supports the following chips:
28
29 Chip #vin #fan #pwm #temp chip_id man_id
30 w83627ehf - 5 - 3 0x88 0x5ca3
31
32 This is a preliminary version of the driver, only supporting the
33 fan and temperature inputs. The chip does much more than that.
34*/
35
36#include <linux/module.h>
37#include <linux/init.h>
38#include <linux/slab.h>
39#include <linux/i2c.h>
40#include <linux/i2c-sensor.h>
41#include <asm/io.h>
42#include "lm75.h"
43
44/* Addresses to scan
45 The actual ISA address is read from Super-I/O configuration space */
46static unsigned short normal_i2c[] = { I2C_CLIENT_END };
47static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END };
48
49/* Insmod parameters */
50SENSORS_INSMOD_1(w83627ehf);
51
52/*
53 * Super-I/O constants and functions
54 */
55
56static int REG; /* The register to read/write */
57static int VAL; /* The value to read/write */
58
59#define W83627EHF_LD_HWM 0x0b
60
61#define SIO_REG_LDSEL 0x07 /* Logical device select */
62#define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */
63#define SIO_REG_ENABLE 0x30 /* Logical device enable */
64#define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */
65
66#define SIO_W83627EHF_ID 0x8840
67#define SIO_ID_MASK 0xFFC0
68
69static inline void
70superio_outb(int reg, int val)
71{
72 outb(reg, REG);
73 outb(val, VAL);
74}
75
76static inline int
77superio_inb(int reg)
78{
79 outb(reg, REG);
80 return inb(VAL);
81}
82
83static inline void
84superio_select(int ld)
85{
86 outb(SIO_REG_LDSEL, REG);
87 outb(ld, VAL);
88}
89
90static inline void
91superio_enter(void)
92{
93 outb(0x87, REG);
94 outb(0x87, REG);
95}
96
97static inline void
98superio_exit(void)
99{
100 outb(0x02, REG);
101 outb(0x02, VAL);
102}
103
104/*
105 * ISA constants
106 */
107
108#define REGION_LENGTH 8
109#define ADDR_REG_OFFSET 5
110#define DATA_REG_OFFSET 6
111
112#define W83627EHF_REG_BANK 0x4E
113#define W83627EHF_REG_CONFIG 0x40
114#define W83627EHF_REG_CHIP_ID 0x49
115#define W83627EHF_REG_MAN_ID 0x4F
116
117static const u16 W83627EHF_REG_FAN[] = { 0x28, 0x29, 0x2a, 0x3f, 0x553 };
118static const u16 W83627EHF_REG_FAN_MIN[] = { 0x3b, 0x3c, 0x3d, 0x3e, 0x55c };
119
120#define W83627EHF_REG_TEMP1 0x27
121#define W83627EHF_REG_TEMP1_HYST 0x3a
122#define W83627EHF_REG_TEMP1_OVER 0x39
123static const u16 W83627EHF_REG_TEMP[] = { 0x150, 0x250 };
124static const u16 W83627EHF_REG_TEMP_HYST[] = { 0x153, 0x253 };
125static const u16 W83627EHF_REG_TEMP_OVER[] = { 0x155, 0x255 };
126static const u16 W83627EHF_REG_TEMP_CONFIG[] = { 0x152, 0x252 };
127
128/* Fan clock dividers are spread over the following five registers */
129#define W83627EHF_REG_FANDIV1 0x47
130#define W83627EHF_REG_FANDIV2 0x4B
131#define W83627EHF_REG_VBAT 0x5D
132#define W83627EHF_REG_DIODE 0x59
133#define W83627EHF_REG_SMI_OVT 0x4C
134
135/*
136 * Conversions
137 */
138
139static inline unsigned int
140fan_from_reg(u8 reg, unsigned int div)
141{
142 if (reg == 0 || reg == 255)
143 return 0;
144 return 1350000U / (reg * div);
145}
146
147static inline unsigned int
148div_from_reg(u8 reg)
149{
150 return 1 << reg;
151}
152
153static inline int
154temp1_from_reg(s8 reg)
155{
156 return reg * 1000;
157}
158
159static inline s8
160temp1_to_reg(int temp)
161{
162 if (temp <= -128000)
163 return -128;
164 if (temp >= 127000)
165 return 127;
166 if (temp < 0)
167 return (temp - 500) / 1000;
168 return (temp + 500) / 1000;
169}
170
171/*
172 * Data structures and manipulation thereof
173 */
174
175struct w83627ehf_data {
176 struct i2c_client client;
177 struct semaphore lock;
178
179 struct semaphore update_lock;
180 char valid; /* !=0 if following fields are valid */
181 unsigned long last_updated; /* In jiffies */
182
183 /* Register values */
184 u8 fan[5];
185 u8 fan_min[5];
186 u8 fan_div[5];
187 u8 has_fan; /* some fan inputs can be disabled */
188 s8 temp1;
189 s8 temp1_max;
190 s8 temp1_max_hyst;
191 s16 temp[2];
192 s16 temp_max[2];
193 s16 temp_max_hyst[2];
194};
195
196static inline int is_word_sized(u16 reg)
197{
198 return (((reg & 0xff00) == 0x100
199 || (reg & 0xff00) == 0x200)
200 && ((reg & 0x00ff) == 0x50
201 || (reg & 0x00ff) == 0x53
202 || (reg & 0x00ff) == 0x55));
203}
204
205/* We assume that the default bank is 0, thus the following two functions do
206 nothing for registers which live in bank 0. For others, they respectively
207 set the bank register to the correct value (before the register is
208 accessed), and back to 0 (afterwards). */
209static inline void w83627ehf_set_bank(struct i2c_client *client, u16 reg)
210{
211 if (reg & 0xff00) {
212 outb_p(W83627EHF_REG_BANK, client->addr + ADDR_REG_OFFSET);
213 outb_p(reg >> 8, client->addr + DATA_REG_OFFSET);
214 }
215}
216
217static inline void w83627ehf_reset_bank(struct i2c_client *client, u16 reg)
218{
219 if (reg & 0xff00) {
220 outb_p(W83627EHF_REG_BANK, client->addr + ADDR_REG_OFFSET);
221 outb_p(0, client->addr + DATA_REG_OFFSET);
222 }
223}
224
225static u16 w83627ehf_read_value(struct i2c_client *client, u16 reg)
226{
227 struct w83627ehf_data *data = i2c_get_clientdata(client);
228 int res, word_sized = is_word_sized(reg);
229
230 down(&data->lock);
231
232 w83627ehf_set_bank(client, reg);
233 outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET);
234 res = inb_p(client->addr + DATA_REG_OFFSET);
235 if (word_sized) {
236 outb_p((reg & 0xff) + 1,
237 client->addr + ADDR_REG_OFFSET);
238 res = (res << 8) + inb_p(client->addr + DATA_REG_OFFSET);
239 }
240 w83627ehf_reset_bank(client, reg);
241
242 up(&data->lock);
243
244 return res;
245}
246
247static int w83627ehf_write_value(struct i2c_client *client, u16 reg, u16 value)
248{
249 struct w83627ehf_data *data = i2c_get_clientdata(client);
250 int word_sized = is_word_sized(reg);
251
252 down(&data->lock);
253
254 w83627ehf_set_bank(client, reg);
255 outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET);
256 if (word_sized) {
257 outb_p(value >> 8, client->addr + DATA_REG_OFFSET);
258 outb_p((reg & 0xff) + 1,
259 client->addr + ADDR_REG_OFFSET);
260 }
261 outb_p(value & 0xff, client->addr + DATA_REG_OFFSET);
262 w83627ehf_reset_bank(client, reg);
263
264 up(&data->lock);
265 return 0;
266}
267
268/* This function assumes that the caller holds data->update_lock */
269static void w83627ehf_write_fan_div(struct i2c_client *client, int nr)
270{
271 struct w83627ehf_data *data = i2c_get_clientdata(client);
272 u8 reg;
273
274 switch (nr) {
275 case 0:
276 reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0xcf)
277 | ((data->fan_div[0] & 0x03) << 4);
278 w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg);
279 reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xdf)
280 | ((data->fan_div[0] & 0x04) << 3);
281 w83627ehf_write_value(client, W83627EHF_REG_VBAT, reg);
282 break;
283 case 1:
284 reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0x3f)
285 | ((data->fan_div[1] & 0x03) << 6);
286 w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg);
287 reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xbf)
288 | ((data->fan_div[1] & 0x04) << 4);
289 w83627ehf_write_value(client, W83627EHF_REG_VBAT, reg);
290 break;
291 case 2:
292 reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV2) & 0x3f)
293 | ((data->fan_div[2] & 0x03) << 6);
294 w83627ehf_write_value(client, W83627EHF_REG_FANDIV2, reg);
295 reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0x7f)
296 | ((data->fan_div[2] & 0x04) << 5);
297 w83627ehf_write_value(client, W83627EHF_REG_VBAT, reg);
298 break;
299 case 3:
300 reg = (w83627ehf_read_value(client, W83627EHF_REG_DIODE) & 0xfc)
301 | (data->fan_div[3] & 0x03);
302 w83627ehf_write_value(client, W83627EHF_REG_DIODE, reg);
303 reg = (w83627ehf_read_value(client, W83627EHF_REG_SMI_OVT) & 0x7f)
304 | ((data->fan_div[3] & 0x04) << 5);
305 w83627ehf_write_value(client, W83627EHF_REG_SMI_OVT, reg);
306 break;
307 case 4:
308 reg = (w83627ehf_read_value(client, W83627EHF_REG_DIODE) & 0x73)
309 | ((data->fan_div[4] & 0x03) << 3)
310 | ((data->fan_div[4] & 0x04) << 5);
311 w83627ehf_write_value(client, W83627EHF_REG_DIODE, reg);
312 break;
313 }
314}
315
316static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
317{
318 struct i2c_client *client = to_i2c_client(dev);
319 struct w83627ehf_data *data = i2c_get_clientdata(client);
320 int i;
321
322 down(&data->update_lock);
323
324 if (time_after(jiffies, data->last_updated + HZ)
325 || !data->valid) {
326 /* Fan clock dividers */
327 i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV1);
328 data->fan_div[0] = (i >> 4) & 0x03;
329 data->fan_div[1] = (i >> 6) & 0x03;
330 i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV2);
331 data->fan_div[2] = (i >> 6) & 0x03;
332 i = w83627ehf_read_value(client, W83627EHF_REG_VBAT);
333 data->fan_div[0] |= (i >> 3) & 0x04;
334 data->fan_div[1] |= (i >> 4) & 0x04;
335 data->fan_div[2] |= (i >> 5) & 0x04;
336 if (data->has_fan & ((1 << 3) | (1 << 4))) {
337 i = w83627ehf_read_value(client, W83627EHF_REG_DIODE);
338 data->fan_div[3] = i & 0x03;
339 data->fan_div[4] = ((i >> 2) & 0x03)
340 | ((i >> 5) & 0x04);
341 }
342 if (data->has_fan & (1 << 3)) {
343 i = w83627ehf_read_value(client, W83627EHF_REG_SMI_OVT);
344 data->fan_div[3] |= (i >> 5) & 0x04;
345 }
346
347 /* Measured fan speeds and limits */
348 for (i = 0; i < 5; i++) {
349 if (!(data->has_fan & (1 << i)))
350 continue;
351
352 data->fan[i] = w83627ehf_read_value(client,
353 W83627EHF_REG_FAN[i]);
354 data->fan_min[i] = w83627ehf_read_value(client,
355 W83627EHF_REG_FAN_MIN[i]);
356
357 /* If we failed to measure the fan speed and clock
358 divider can be increased, let's try that for next
359 time */
360 if (data->fan[i] == 0xff
361 && data->fan_div[i] < 0x07) {
362 dev_dbg(&client->dev, "Increasing fan %d "
363 "clock divider from %u to %u\n",
364 i, div_from_reg(data->fan_div[i]),
365 div_from_reg(data->fan_div[i] + 1));
366 data->fan_div[i]++;
367 w83627ehf_write_fan_div(client, i);
368 /* Preserve min limit if possible */
369 if (data->fan_min[i] >= 2
370 && data->fan_min[i] != 255)
371 w83627ehf_write_value(client,
372 W83627EHF_REG_FAN_MIN[i],
373 (data->fan_min[i] /= 2));
374 }
375 }
376
377 /* Measured temperatures and limits */
378 data->temp1 = w83627ehf_read_value(client,
379 W83627EHF_REG_TEMP1);
380 data->temp1_max = w83627ehf_read_value(client,
381 W83627EHF_REG_TEMP1_OVER);
382 data->temp1_max_hyst = w83627ehf_read_value(client,
383 W83627EHF_REG_TEMP1_HYST);
384 for (i = 0; i < 2; i++) {
385 data->temp[i] = w83627ehf_read_value(client,
386 W83627EHF_REG_TEMP[i]);
387 data->temp_max[i] = w83627ehf_read_value(client,
388 W83627EHF_REG_TEMP_OVER[i]);
389 data->temp_max_hyst[i] = w83627ehf_read_value(client,
390 W83627EHF_REG_TEMP_HYST[i]);
391 }
392
393 data->last_updated = jiffies;
394 data->valid = 1;
395 }
396
397 up(&data->update_lock);
398 return data;
399}
400
401/*
402 * Sysfs callback functions
403 */
404
405#define show_fan_reg(reg) \
406static ssize_t \
407show_##reg(struct device *dev, char *buf, int nr) \
408{ \
409 struct w83627ehf_data *data = w83627ehf_update_device(dev); \
410 return sprintf(buf, "%d\n", \
411 fan_from_reg(data->reg[nr], \
412 div_from_reg(data->fan_div[nr]))); \
413}
414show_fan_reg(fan);
415show_fan_reg(fan_min);
416
417static ssize_t
418show_fan_div(struct device *dev, char *buf, int nr)
419{
420 struct w83627ehf_data *data = w83627ehf_update_device(dev);
421 return sprintf(buf, "%u\n",
422 div_from_reg(data->fan_div[nr]));
423}
424
425static ssize_t
426store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
427{
428 struct i2c_client *client = to_i2c_client(dev);
429 struct w83627ehf_data *data = i2c_get_clientdata(client);
430 unsigned int val = simple_strtoul(buf, NULL, 10);
431 unsigned int reg;
432 u8 new_div;
433
434 down(&data->update_lock);
435 if (!val) {
436 /* No min limit, alarm disabled */
437 data->fan_min[nr] = 255;
438 new_div = data->fan_div[nr]; /* No change */
439 dev_info(dev, "fan%u low limit and alarm disabled\n", nr + 1);
440 } else if ((reg = 1350000U / val) >= 128 * 255) {
441 /* Speed below this value cannot possibly be represented,
442 even with the highest divider (128) */
443 data->fan_min[nr] = 254;
444 new_div = 7; /* 128 == (1 << 7) */
445 dev_warn(dev, "fan%u low limit %u below minimum %u, set to "
446 "minimum\n", nr + 1, val, fan_from_reg(254, 128));
447 } else if (!reg) {
448 /* Speed above this value cannot possibly be represented,
449 even with the lowest divider (1) */
450 data->fan_min[nr] = 1;
451 new_div = 0; /* 1 == (1 << 0) */
452 dev_warn(dev, "fan%u low limit %u above maximum %u, set to "
453 "maximum\n", nr + 1, val, fan_from_reg(1, 1));
454 } else {
455 /* Automatically pick the best divider, i.e. the one such
456 that the min limit will correspond to a register value
457 in the 96..192 range */
458 new_div = 0;
459 while (reg > 192 && new_div < 7) {
460 reg >>= 1;
461 new_div++;
462 }
463 data->fan_min[nr] = reg;
464 }
465
466 /* Write both the fan clock divider (if it changed) and the new
467 fan min (unconditionally) */
468 if (new_div != data->fan_div[nr]) {
469 if (new_div > data->fan_div[nr])
470 data->fan[nr] >>= (data->fan_div[nr] - new_div);
471 else
472 data->fan[nr] <<= (new_div - data->fan_div[nr]);
473
474 dev_dbg(dev, "fan%u clock divider changed from %u to %u\n",
475 nr + 1, div_from_reg(data->fan_div[nr]),
476 div_from_reg(new_div));
477 data->fan_div[nr] = new_div;
478 w83627ehf_write_fan_div(client, nr);
479 }
480 w83627ehf_write_value(client, W83627EHF_REG_FAN_MIN[nr],
481 data->fan_min[nr]);
482 up(&data->update_lock);
483
484 return count;
485}
486
487#define sysfs_fan_offset(offset) \
488static ssize_t \
489show_reg_fan_##offset(struct device *dev, struct device_attribute *attr, \
490 char *buf) \
491{ \
492 return show_fan(dev, buf, offset-1); \
493} \
494static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
495 show_reg_fan_##offset, NULL);
496
497#define sysfs_fan_min_offset(offset) \
498static ssize_t \
499show_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \
500 char *buf) \
501{ \
502 return show_fan_min(dev, buf, offset-1); \
503} \
504static ssize_t \
505store_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \
506 const char *buf, size_t count) \
507{ \
508 return store_fan_min(dev, buf, count, offset-1); \
509} \
510static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
511 show_reg_fan##offset##_min, \
512 store_reg_fan##offset##_min);
513
514#define sysfs_fan_div_offset(offset) \
515static ssize_t \
516show_reg_fan##offset##_div(struct device *dev, struct device_attribute *attr, \
517 char *buf) \
518{ \
519 return show_fan_div(dev, buf, offset - 1); \
520} \
521static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \
522 show_reg_fan##offset##_div, NULL);
523
524sysfs_fan_offset(1);
525sysfs_fan_min_offset(1);
526sysfs_fan_div_offset(1);
527sysfs_fan_offset(2);
528sysfs_fan_min_offset(2);
529sysfs_fan_div_offset(2);
530sysfs_fan_offset(3);
531sysfs_fan_min_offset(3);
532sysfs_fan_div_offset(3);
533sysfs_fan_offset(4);
534sysfs_fan_min_offset(4);
535sysfs_fan_div_offset(4);
536sysfs_fan_offset(5);
537sysfs_fan_min_offset(5);
538sysfs_fan_div_offset(5);
539
540#define show_temp1_reg(reg) \
541static ssize_t \
542show_##reg(struct device *dev, struct device_attribute *attr, \
543 char *buf) \
544{ \
545 struct w83627ehf_data *data = w83627ehf_update_device(dev); \
546 return sprintf(buf, "%d\n", temp1_from_reg(data->reg)); \
547}
548show_temp1_reg(temp1);
549show_temp1_reg(temp1_max);
550show_temp1_reg(temp1_max_hyst);
551
552#define store_temp1_reg(REG, reg) \
553static ssize_t \
554store_temp1_##reg(struct device *dev, struct device_attribute *attr, \
555 const char *buf, size_t count) \
556{ \
557 struct i2c_client *client = to_i2c_client(dev); \
558 struct w83627ehf_data *data = i2c_get_clientdata(client); \
559 u32 val = simple_strtoul(buf, NULL, 10); \
560 \
561 down(&data->update_lock); \
562 data->temp1_##reg = temp1_to_reg(val); \
563 w83627ehf_write_value(client, W83627EHF_REG_TEMP1_##REG, \
564 data->temp1_##reg); \
565 up(&data->update_lock); \
566 return count; \
567}
568store_temp1_reg(OVER, max);
569store_temp1_reg(HYST, max_hyst);
570
571static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL);
572static DEVICE_ATTR(temp1_max, S_IRUGO| S_IWUSR,
573 show_temp1_max, store_temp1_max);
574static DEVICE_ATTR(temp1_max_hyst, S_IRUGO| S_IWUSR,
575 show_temp1_max_hyst, store_temp1_max_hyst);
576
577#define show_temp_reg(reg) \
578static ssize_t \
579show_##reg (struct device *dev, char *buf, int nr) \
580{ \
581 struct w83627ehf_data *data = w83627ehf_update_device(dev); \
582 return sprintf(buf, "%d\n", \
583 LM75_TEMP_FROM_REG(data->reg[nr])); \
584}
585show_temp_reg(temp);
586show_temp_reg(temp_max);
587show_temp_reg(temp_max_hyst);
588
589#define store_temp_reg(REG, reg) \
590static ssize_t \
591store_##reg (struct device *dev, const char *buf, size_t count, int nr) \
592{ \
593 struct i2c_client *client = to_i2c_client(dev); \
594 struct w83627ehf_data *data = i2c_get_clientdata(client); \
595 u32 val = simple_strtoul(buf, NULL, 10); \
596 \
597 down(&data->update_lock); \
598 data->reg[nr] = LM75_TEMP_TO_REG(val); \
599 w83627ehf_write_value(client, W83627EHF_REG_TEMP_##REG[nr], \
600 data->reg[nr]); \
601 up(&data->update_lock); \
602 return count; \
603}
604store_temp_reg(OVER, temp_max);
605store_temp_reg(HYST, temp_max_hyst);
606
607#define sysfs_temp_offset(offset) \
608static ssize_t \
609show_reg_temp##offset (struct device *dev, struct device_attribute *attr, \
610 char *buf) \
611{ \
612 return show_temp(dev, buf, offset - 2); \
613} \
614static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
615 show_reg_temp##offset, NULL);
616
617#define sysfs_temp_reg_offset(reg, offset) \
618static ssize_t \
619show_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \
620 char *buf) \
621{ \
622 return show_temp_##reg(dev, buf, offset - 2); \
623} \
624static ssize_t \
625store_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \
626 const char *buf, size_t count) \
627{ \
628 return store_temp_##reg(dev, buf, count, offset - 2); \
629} \
630static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \
631 show_reg_temp##offset##_##reg, \
632 store_reg_temp##offset##_##reg);
633
634sysfs_temp_offset(2);
635sysfs_temp_reg_offset(max, 2);
636sysfs_temp_reg_offset(max_hyst, 2);
637sysfs_temp_offset(3);
638sysfs_temp_reg_offset(max, 3);
639sysfs_temp_reg_offset(max_hyst, 3);
640
641/*
642 * Driver and client management
643 */
644
645static struct i2c_driver w83627ehf_driver;
646
647static void w83627ehf_init_client(struct i2c_client *client)
648{
649 int i;
650 u8 tmp;
651
652 /* Start monitoring is needed */
653 tmp = w83627ehf_read_value(client, W83627EHF_REG_CONFIG);
654 if (!(tmp & 0x01))
655 w83627ehf_write_value(client, W83627EHF_REG_CONFIG,
656 tmp | 0x01);
657
658 /* Enable temp2 and temp3 if needed */
659 for (i = 0; i < 2; i++) {
660 tmp = w83627ehf_read_value(client,
661 W83627EHF_REG_TEMP_CONFIG[i]);
662 if (tmp & 0x01)
663 w83627ehf_write_value(client,
664 W83627EHF_REG_TEMP_CONFIG[i],
665 tmp & 0xfe);
666 }
667}
668
669static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind)
670{
671 struct i2c_client *client;
672 struct w83627ehf_data *data;
673 int i, err = 0;
674
675 if (!i2c_is_isa_adapter(adapter))
676 return 0;
677
678 if (!request_region(address, REGION_LENGTH, w83627ehf_driver.name)) {
679 err = -EBUSY;
680 goto exit;
681 }
682
683 if (!(data = kmalloc(sizeof(struct w83627ehf_data), GFP_KERNEL))) {
684 err = -ENOMEM;
685 goto exit_release;
686 }
687 memset(data, 0, sizeof(struct w83627ehf_data));
688
689 client = &data->client;
690 i2c_set_clientdata(client, data);
691 client->addr = address;
692 init_MUTEX(&data->lock);
693 client->adapter = adapter;
694 client->driver = &w83627ehf_driver;
695 client->flags = 0;
696
697 strlcpy(client->name, "w83627ehf", I2C_NAME_SIZE);
698 data->valid = 0;
699 init_MUTEX(&data->update_lock);
700
701 /* Tell the i2c layer a new client has arrived */
702 if ((err = i2c_attach_client(client)))
703 goto exit_free;
704
705 /* Initialize the chip */
706 w83627ehf_init_client(client);
707
708 /* A few vars need to be filled upon startup */
709 for (i = 0; i < 5; i++)
710 data->fan_min[i] = w83627ehf_read_value(client,
711 W83627EHF_REG_FAN_MIN[i]);
712
713 /* It looks like fan4 and fan5 pins can be alternatively used
714 as fan on/off switches */
715 data->has_fan = 0x07; /* fan1, fan2 and fan3 */
716 i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV1);
717 if (i & (1 << 2))
718 data->has_fan |= (1 << 3);
719 if (i & (1 << 0))
720 data->has_fan |= (1 << 4);
721
722 /* Register sysfs hooks */
723 device_create_file(&client->dev, &dev_attr_fan1_input);
724 device_create_file(&client->dev, &dev_attr_fan1_min);
725 device_create_file(&client->dev, &dev_attr_fan1_div);
726 device_create_file(&client->dev, &dev_attr_fan2_input);
727 device_create_file(&client->dev, &dev_attr_fan2_min);
728 device_create_file(&client->dev, &dev_attr_fan2_div);
729 device_create_file(&client->dev, &dev_attr_fan3_input);
730 device_create_file(&client->dev, &dev_attr_fan3_min);
731 device_create_file(&client->dev, &dev_attr_fan3_div);
732
733 if (data->has_fan & (1 << 3)) {
734 device_create_file(&client->dev, &dev_attr_fan4_input);
735 device_create_file(&client->dev, &dev_attr_fan4_min);
736 device_create_file(&client->dev, &dev_attr_fan4_div);
737 }
738 if (data->has_fan & (1 << 4)) {
739 device_create_file(&client->dev, &dev_attr_fan5_input);
740 device_create_file(&client->dev, &dev_attr_fan5_min);
741 device_create_file(&client->dev, &dev_attr_fan5_div);
742 }
743
744 device_create_file(&client->dev, &dev_attr_temp1_input);
745 device_create_file(&client->dev, &dev_attr_temp1_max);
746 device_create_file(&client->dev, &dev_attr_temp1_max_hyst);
747 device_create_file(&client->dev, &dev_attr_temp2_input);
748 device_create_file(&client->dev, &dev_attr_temp2_max);
749 device_create_file(&client->dev, &dev_attr_temp2_max_hyst);
750 device_create_file(&client->dev, &dev_attr_temp3_input);
751 device_create_file(&client->dev, &dev_attr_temp3_max);
752 device_create_file(&client->dev, &dev_attr_temp3_max_hyst);
753
754 return 0;
755
756exit_free:
757 kfree(data);
758exit_release:
759 release_region(address, REGION_LENGTH);
760exit:
761 return err;
762}
763
764static int w83627ehf_attach_adapter(struct i2c_adapter *adapter)
765{
766 if (!(adapter->class & I2C_CLASS_HWMON))
767 return 0;
768 return i2c_detect(adapter, &addr_data, w83627ehf_detect);
769}
770
771static int w83627ehf_detach_client(struct i2c_client *client)
772{
773 int err;
774
775 if ((err = i2c_detach_client(client))) {
776 dev_err(&client->dev, "Client deregistration failed, "
777 "client not detached.\n");
778 return err;
779 }
780 release_region(client->addr, REGION_LENGTH);
781 kfree(i2c_get_clientdata(client));
782
783 return 0;
784}
785
786static struct i2c_driver w83627ehf_driver = {
787 .owner = THIS_MODULE,
788 .name = "w83627ehf",
789 .flags = I2C_DF_NOTIFY,
790 .attach_adapter = w83627ehf_attach_adapter,
791 .detach_client = w83627ehf_detach_client,
792};
793
794static int __init w83627ehf_find(int sioaddr, int *address)
795{
796 u16 val;
797
798 REG = sioaddr;
799 VAL = sioaddr + 1;
800 superio_enter();
801
802 val = (superio_inb(SIO_REG_DEVID) << 8)
803 | superio_inb(SIO_REG_DEVID + 1);
804 if ((val & SIO_ID_MASK) != SIO_W83627EHF_ID) {
805 superio_exit();
806 return -ENODEV;
807 }
808
809 superio_select(W83627EHF_LD_HWM);
810 val = (superio_inb(SIO_REG_ADDR) << 8)
811 | superio_inb(SIO_REG_ADDR + 1);
812 *address = val & ~(REGION_LENGTH - 1);
813 if (*address == 0) {
814 superio_exit();
815 return -ENODEV;
816 }
817
818 /* Activate logical device if needed */
819 val = superio_inb(SIO_REG_ENABLE);
820 if (!(val & 0x01))
821 superio_outb(SIO_REG_ENABLE, val | 0x01);
822
823 superio_exit();
824 return 0;
825}
826
827static int __init sensors_w83627ehf_init(void)
828{
829 if (w83627ehf_find(0x2e, &normal_isa[0])
830 && w83627ehf_find(0x4e, &normal_isa[0]))
831 return -ENODEV;
832
833 return i2c_add_driver(&w83627ehf_driver);
834}
835
836static void __exit sensors_w83627ehf_exit(void)
837{
838 i2c_del_driver(&w83627ehf_driver);
839}
840
841MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
842MODULE_DESCRIPTION("W83627EHF driver");
843MODULE_LICENSE("GPL");
844
845module_init(sensors_w83627ehf_init);
846module_exit(sensors_w83627ehf_exit);
diff --git a/drivers/i2c/chips/w83627hf.c b/drivers/i2c/chips/w83627hf.c
index 4f1bff572c1c..bd87a42e068a 100644
--- a/drivers/i2c/chips/w83627hf.c
+++ b/drivers/i2c/chips/w83627hf.c
@@ -264,7 +264,7 @@ static inline u8 DIV_TO_REG(long val)
264{ 264{
265 int i; 265 int i;
266 val = SENSORS_LIMIT(val, 1, 128) >> 1; 266 val = SENSORS_LIMIT(val, 1, 128) >> 1;
267 for (i = 0; i < 6; i++) { 267 for (i = 0; i < 7; i++) {
268 if (val == 0) 268 if (val == 0)
269 break; 269 break;
270 val >>= 1; 270 val >>= 1;
diff --git a/drivers/i2c/chips/w83781d.c b/drivers/i2c/chips/w83781d.c
index c3926d2d8ac6..0bb131ce09eb 100644
--- a/drivers/i2c/chips/w83781d.c
+++ b/drivers/i2c/chips/w83781d.c
@@ -28,14 +28,11 @@
28 as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no 28 as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no
29 w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes 29 w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes
30 w83627hf 9 3 2 3 0x21 0x5ca3 yes yes(LPC) 30 w83627hf 9 3 2 3 0x21 0x5ca3 yes yes(LPC)
31 w83627thf 9 3 2 3 0x90 0x5ca3 no yes(LPC)
32 w83782d 9 3 2-4 3 0x30 0x5ca3 yes yes 31 w83782d 9 3 2-4 3 0x30 0x5ca3 yes yes
33 w83783s 5-6 3 2 1-2 0x40 0x5ca3 yes no 32 w83783s 5-6 3 2 1-2 0x40 0x5ca3 yes no
34 w83697hf 8 2 2 2 0x60 0x5ca3 no yes(LPC)
35 33
36*/ 34*/
37 35
38#include <linux/config.h>
39#include <linux/module.h> 36#include <linux/module.h>
40#include <linux/init.h> 37#include <linux/init.h>
41#include <linux/slab.h> 38#include <linux/slab.h>
@@ -53,7 +50,7 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
53static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; 50static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END };
54 51
55/* Insmod parameters */ 52/* Insmod parameters */
56SENSORS_INSMOD_6(w83781d, w83782d, w83783s, w83627hf, as99127f, w83697hf); 53SENSORS_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f);
57I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " 54I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: "
58 "{bus, clientaddr, subclientaddr1, subclientaddr2}"); 55 "{bus, clientaddr, subclientaddr1, subclientaddr2}");
59 56
@@ -173,7 +170,6 @@ FAN_TO_REG(long rpm, int div)
173 : (val)) / 1000, 0, 0xff)) 170 : (val)) / 1000, 0, 0xff))
174#define TEMP_FROM_REG(val) (((val) & 0x80 ? (val)-0x100 : (val)) * 1000) 171#define TEMP_FROM_REG(val) (((val) & 0x80 ? (val)-0x100 : (val)) * 1000)
175 172
176#define ALARMS_FROM_REG(val) (val)
177#define PWM_FROM_REG(val) (val) 173#define PWM_FROM_REG(val) (val)
178#define PWM_TO_REG(val) (SENSORS_LIMIT((val),0,255)) 174#define PWM_TO_REG(val) (SENSORS_LIMIT((val),0,255))
179#define BEEP_MASK_FROM_REG(val,type) ((type) == as99127f ? \ 175#define BEEP_MASK_FROM_REG(val,type) ((type) == as99127f ? \
@@ -193,7 +189,7 @@ DIV_TO_REG(long val, enum chips type)
193 val = SENSORS_LIMIT(val, 1, 189 val = SENSORS_LIMIT(val, 1,
194 ((type == w83781d 190 ((type == w83781d
195 || type == as99127f) ? 8 : 128)) >> 1; 191 || type == as99127f) ? 8 : 128)) >> 1;
196 for (i = 0; i < 6; i++) { 192 for (i = 0; i < 7; i++) {
197 if (val == 0) 193 if (val == 0)
198 break; 194 break;
199 val >>= 1; 195 val >>= 1;
@@ -524,7 +520,7 @@ static ssize_t
524show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) 520show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)
525{ 521{
526 struct w83781d_data *data = w83781d_update_device(dev); 522 struct w83781d_data *data = w83781d_update_device(dev);
527 return sprintf(buf, "%ld\n", (long) ALARMS_FROM_REG(data->alarms)); 523 return sprintf(buf, "%u\n", data->alarms);
528} 524}
529 525
530static 526static
@@ -1000,13 +996,6 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1000 err = -EINVAL; 996 err = -EINVAL;
1001 goto ERROR0; 997 goto ERROR0;
1002 } 998 }
1003 if (!is_isa && kind == w83697hf) {
1004 dev_err(&adapter->dev,
1005 "Cannot force ISA-only chip for I2C address 0x%02x.\n",
1006 address);
1007 err = -EINVAL;
1008 goto ERROR0;
1009 }
1010 999
1011 if (is_isa) 1000 if (is_isa)
1012 if (!request_region(address, W83781D_EXTENT, 1001 if (!request_region(address, W83781D_EXTENT,
@@ -1139,12 +1128,10 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1139 else if (val1 == 0x40 && vendid == winbond && !is_isa 1128 else if (val1 == 0x40 && vendid == winbond && !is_isa
1140 && address == 0x2d) 1129 && address == 0x2d)
1141 kind = w83783s; 1130 kind = w83783s;
1142 else if ((val1 == 0x21 || val1 == 0x90) && vendid == winbond) 1131 else if (val1 == 0x21 && vendid == winbond)
1143 kind = w83627hf; 1132 kind = w83627hf;
1144 else if (val1 == 0x31 && !is_isa && address >= 0x28) 1133 else if (val1 == 0x31 && !is_isa && address >= 0x28)
1145 kind = as99127f; 1134 kind = as99127f;
1146 else if (val1 == 0x60 && vendid == winbond && is_isa)
1147 kind = w83697hf;
1148 else { 1135 else {
1149 if (kind == 0) 1136 if (kind == 0)
1150 dev_warn(&new_client->dev, "Ignoring 'force' " 1137 dev_warn(&new_client->dev, "Ignoring 'force' "
@@ -1163,14 +1150,9 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1163 } else if (kind == w83783s) { 1150 } else if (kind == w83783s) {
1164 client_name = "w83783s"; 1151 client_name = "w83783s";
1165 } else if (kind == w83627hf) { 1152 } else if (kind == w83627hf) {
1166 if (val1 == 0x90) 1153 client_name = "w83627hf";
1167 client_name = "w83627thf";
1168 else
1169 client_name = "w83627hf";
1170 } else if (kind == as99127f) { 1154 } else if (kind == as99127f) {
1171 client_name = "as99127f"; 1155 client_name = "as99127f";
1172 } else if (kind == w83697hf) {
1173 client_name = "w83697hf";
1174 } 1156 }
1175 1157
1176 /* Fill in the remaining client fields and put into the global list */ 1158 /* Fill in the remaining client fields and put into the global list */
@@ -1208,7 +1190,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1208 1190
1209 /* Register sysfs hooks */ 1191 /* Register sysfs hooks */
1210 device_create_file_in(new_client, 0); 1192 device_create_file_in(new_client, 0);
1211 if (kind != w83783s && kind != w83697hf) 1193 if (kind != w83783s)
1212 device_create_file_in(new_client, 1); 1194 device_create_file_in(new_client, 1);
1213 device_create_file_in(new_client, 2); 1195 device_create_file_in(new_client, 2);
1214 device_create_file_in(new_client, 3); 1196 device_create_file_in(new_client, 3);
@@ -1222,24 +1204,19 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1222 1204
1223 device_create_file_fan(new_client, 1); 1205 device_create_file_fan(new_client, 1);
1224 device_create_file_fan(new_client, 2); 1206 device_create_file_fan(new_client, 2);
1225 if (kind != w83697hf) 1207 device_create_file_fan(new_client, 3);
1226 device_create_file_fan(new_client, 3);
1227 1208
1228 device_create_file_temp(new_client, 1); 1209 device_create_file_temp(new_client, 1);
1229 device_create_file_temp(new_client, 2); 1210 device_create_file_temp(new_client, 2);
1230 if (kind != w83783s && kind != w83697hf) 1211 if (kind != w83783s)
1231 device_create_file_temp(new_client, 3); 1212 device_create_file_temp(new_client, 3);
1232 1213
1233 if (kind != w83697hf) 1214 device_create_file_vid(new_client);
1234 device_create_file_vid(new_client); 1215 device_create_file_vrm(new_client);
1235
1236 if (kind != w83697hf)
1237 device_create_file_vrm(new_client);
1238 1216
1239 device_create_file_fan_div(new_client, 1); 1217 device_create_file_fan_div(new_client, 1);
1240 device_create_file_fan_div(new_client, 2); 1218 device_create_file_fan_div(new_client, 2);
1241 if (kind != w83697hf) 1219 device_create_file_fan_div(new_client, 3);
1242 device_create_file_fan_div(new_client, 3);
1243 1220
1244 device_create_file_alarms(new_client); 1221 device_create_file_alarms(new_client);
1245 1222
@@ -1258,7 +1235,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1258 if (kind != as99127f && kind != w83781d) { 1235 if (kind != as99127f && kind != w83781d) {
1259 device_create_file_sensor(new_client, 1); 1236 device_create_file_sensor(new_client, 1);
1260 device_create_file_sensor(new_client, 2); 1237 device_create_file_sensor(new_client, 2);
1261 if (kind != w83783s && kind != w83697hf) 1238 if (kind != w83783s)
1262 device_create_file_sensor(new_client, 3); 1239 device_create_file_sensor(new_client, 3);
1263 } 1240 }
1264 1241
@@ -1481,7 +1458,7 @@ w83781d_init_client(struct i2c_client *client)
1481 else 1458 else
1482 data->sens[i - 1] = 2; 1459 data->sens[i - 1] = 2;
1483 } 1460 }
1484 if ((type == w83783s || type == w83697hf) && (i == 2)) 1461 if (type == w83783s && i == 2)
1485 break; 1462 break;
1486 } 1463 }
1487 } 1464 }
@@ -1497,7 +1474,7 @@ w83781d_init_client(struct i2c_client *client)
1497 } 1474 }
1498 1475
1499 /* Enable temp3 */ 1476 /* Enable temp3 */
1500 if (type != w83783s && type != w83697hf) { 1477 if (type != w83783s) {
1501 tmp = w83781d_read_value(client, 1478 tmp = w83781d_read_value(client,
1502 W83781D_REG_TEMP3_CONFIG); 1479 W83781D_REG_TEMP3_CONFIG);
1503 if (tmp & 0x01) { 1480 if (tmp & 0x01) {
@@ -1538,8 +1515,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev)
1538 dev_dbg(dev, "Starting device update\n"); 1515 dev_dbg(dev, "Starting device update\n");
1539 1516
1540 for (i = 0; i <= 8; i++) { 1517 for (i = 0; i <= 8; i++) {
1541 if ((data->type == w83783s || data->type == w83697hf) 1518 if (data->type == w83783s && i == 1)
1542 && (i == 1))
1543 continue; /* 783S has no in1 */ 1519 continue; /* 783S has no in1 */
1544 data->in[i] = 1520 data->in[i] =
1545 w83781d_read_value(client, W83781D_REG_IN(i)); 1521 w83781d_read_value(client, W83781D_REG_IN(i));
@@ -1547,7 +1523,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev)
1547 w83781d_read_value(client, W83781D_REG_IN_MIN(i)); 1523 w83781d_read_value(client, W83781D_REG_IN_MIN(i));
1548 data->in_max[i] = 1524 data->in_max[i] =
1549 w83781d_read_value(client, W83781D_REG_IN_MAX(i)); 1525 w83781d_read_value(client, W83781D_REG_IN_MAX(i));
1550 if ((data->type != w83782d) && (data->type != w83697hf) 1526 if ((data->type != w83782d)
1551 && (data->type != w83627hf) && (i == 6)) 1527 && (data->type != w83627hf) && (i == 6))
1552 break; 1528 break;
1553 } 1529 }
@@ -1583,7 +1559,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev)
1583 w83781d_read_value(client, W83781D_REG_TEMP_OVER(2)); 1559 w83781d_read_value(client, W83781D_REG_TEMP_OVER(2));
1584 data->temp_max_hyst_add[0] = 1560 data->temp_max_hyst_add[0] =
1585 w83781d_read_value(client, W83781D_REG_TEMP_HYST(2)); 1561 w83781d_read_value(client, W83781D_REG_TEMP_HYST(2));
1586 if (data->type != w83783s && data->type != w83697hf) { 1562 if (data->type != w83783s) {
1587 data->temp_add[1] = 1563 data->temp_add[1] =
1588 w83781d_read_value(client, W83781D_REG_TEMP(3)); 1564 w83781d_read_value(client, W83781D_REG_TEMP(3));
1589 data->temp_max_add[1] = 1565 data->temp_max_add[1] =
@@ -1594,26 +1570,18 @@ static struct w83781d_data *w83781d_update_device(struct device *dev)
1594 W83781D_REG_TEMP_HYST(3)); 1570 W83781D_REG_TEMP_HYST(3));
1595 } 1571 }
1596 i = w83781d_read_value(client, W83781D_REG_VID_FANDIV); 1572 i = w83781d_read_value(client, W83781D_REG_VID_FANDIV);
1597 if (data->type != w83697hf) { 1573 data->vid = i & 0x0f;
1598 data->vid = i & 0x0f; 1574 data->vid |= (w83781d_read_value(client,
1599 data->vid |= 1575 W83781D_REG_CHIPID) & 0x01) << 4;
1600 (w83781d_read_value(client, W83781D_REG_CHIPID) &
1601 0x01)
1602 << 4;
1603 }
1604 data->fan_div[0] = (i >> 4) & 0x03; 1576 data->fan_div[0] = (i >> 4) & 0x03;
1605 data->fan_div[1] = (i >> 6) & 0x03; 1577 data->fan_div[1] = (i >> 6) & 0x03;
1606 if (data->type != w83697hf) { 1578 data->fan_div[2] = (w83781d_read_value(client,
1607 data->fan_div[2] = (w83781d_read_value(client, 1579 W83781D_REG_PIN) >> 6) & 0x03;
1608 W83781D_REG_PIN)
1609 >> 6) & 0x03;
1610 }
1611 if ((data->type != w83781d) && (data->type != as99127f)) { 1580 if ((data->type != w83781d) && (data->type != as99127f)) {
1612 i = w83781d_read_value(client, W83781D_REG_VBAT); 1581 i = w83781d_read_value(client, W83781D_REG_VBAT);
1613 data->fan_div[0] |= (i >> 3) & 0x04; 1582 data->fan_div[0] |= (i >> 3) & 0x04;
1614 data->fan_div[1] |= (i >> 4) & 0x04; 1583 data->fan_div[1] |= (i >> 4) & 0x04;
1615 if (data->type != w83697hf) 1584 data->fan_div[2] |= (i >> 5) & 0x04;
1616 data->fan_div[2] |= (i >> 5) & 0x04;
1617 } 1585 }
1618 data->alarms = 1586 data->alarms =
1619 w83781d_read_value(client, 1587 w83781d_read_value(client,
diff --git a/drivers/i2c/chips/w83l785ts.c b/drivers/i2c/chips/w83l785ts.c
index 74d4b58e4237..4469d52aba4c 100644
--- a/drivers/i2c/chips/w83l785ts.c
+++ b/drivers/i2c/chips/w83l785ts.c
@@ -30,7 +30,6 @@
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 */ 31 */
32 32
33#include <linux/config.h>
34#include <linux/module.h> 33#include <linux/module.h>
35#include <linux/delay.h> 34#include <linux/delay.h>
36#include <linux/init.h> 35#include <linux/init.h>
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index a22e53badacb..51ce268998cd 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -21,7 +21,6 @@
21 All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl> 21 All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl>
22 SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> */ 22 SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> */
23 23
24#include <linux/config.h>
25#include <linux/module.h> 24#include <linux/module.h>
26#include <linux/kernel.h> 25#include <linux/kernel.h>
27#include <linux/errno.h> 26#include <linux/errno.h>
@@ -239,7 +238,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
239 } 238 }
240 239
241 /* detach any active clients. This must be done first, because 240 /* detach any active clients. This must be done first, because
242 * it can fail; in which case we give upp. */ 241 * it can fail; in which case we give up. */
243 list_for_each_safe(item, _n, &adap->clients) { 242 list_for_each_safe(item, _n, &adap->clients) {
244 client = list_entry(item, struct i2c_client, list); 243 client = list_entry(item, struct i2c_client, list);
245 244
@@ -612,27 +611,16 @@ int i2c_master_send(struct i2c_client *client,const char *buf ,int count)
612 struct i2c_adapter *adap=client->adapter; 611 struct i2c_adapter *adap=client->adapter;
613 struct i2c_msg msg; 612 struct i2c_msg msg;
614 613
615 if (client->adapter->algo->master_xfer) { 614 msg.addr = client->addr;
616 msg.addr = client->addr; 615 msg.flags = client->flags & I2C_M_TEN;
617 msg.flags = client->flags & I2C_M_TEN; 616 msg.len = count;
618 msg.len = count; 617 msg.buf = (char *)buf;
619 msg.buf = (char *)buf;
620 618
621 dev_dbg(&client->adapter->dev, "master_send: writing %d bytes.\n", 619 ret = i2c_transfer(adap, &msg, 1);
622 count);
623
624 down(&adap->bus_lock);
625 ret = adap->algo->master_xfer(adap,&msg,1);
626 up(&adap->bus_lock);
627 620
628 /* if everything went ok (i.e. 1 msg transmitted), return #bytes 621 /* If everything went ok (i.e. 1 msg transmitted), return #bytes
629 * transmitted, else error code. 622 transmitted, else error code. */
630 */ 623 return (ret == 1) ? count : ret;
631 return (ret == 1 )? count : ret;
632 } else {
633 dev_err(&client->adapter->dev, "I2C level transfers not supported\n");
634 return -ENOSYS;
635 }
636} 624}
637 625
638int i2c_master_recv(struct i2c_client *client, char *buf ,int count) 626int i2c_master_recv(struct i2c_client *client, char *buf ,int count)
@@ -640,31 +628,18 @@ int i2c_master_recv(struct i2c_client *client, char *buf ,int count)
640 struct i2c_adapter *adap=client->adapter; 628 struct i2c_adapter *adap=client->adapter;
641 struct i2c_msg msg; 629 struct i2c_msg msg;
642 int ret; 630 int ret;
643 if (client->adapter->algo->master_xfer) { 631
644 msg.addr = client->addr; 632 msg.addr = client->addr;
645 msg.flags = client->flags & I2C_M_TEN; 633 msg.flags = client->flags & I2C_M_TEN;
646 msg.flags |= I2C_M_RD; 634 msg.flags |= I2C_M_RD;
647 msg.len = count; 635 msg.len = count;
648 msg.buf = buf; 636 msg.buf = buf;
649 637
650 dev_dbg(&client->adapter->dev, "master_recv: reading %d bytes.\n", 638 ret = i2c_transfer(adap, &msg, 1);
651 count); 639
652 640 /* If everything went ok (i.e. 1 msg transmitted), return #bytes
653 down(&adap->bus_lock); 641 transmitted, else error code. */
654 ret = adap->algo->master_xfer(adap,&msg,1); 642 return (ret == 1) ? count : ret;
655 up(&adap->bus_lock);
656
657 dev_dbg(&client->adapter->dev, "master_recv: return:%d (count:%d, addr:0x%02x)\n",
658 ret, count, client->addr);
659
660 /* if everything went ok (i.e. 1 msg transmitted), return #bytes
661 * transmitted, else error code.
662 */
663 return (ret == 1 )? count : ret;
664 } else {
665 dev_err(&client->adapter->dev, "I2C level transfers not supported\n");
666 return -ENOSYS;
667 }
668} 643}
669 644
670 645
@@ -742,18 +717,6 @@ int i2c_probe(struct i2c_adapter *adapter,
742 found = 1; 717 found = 1;
743 } 718 }
744 } 719 }
745 for (i = 0;
746 !found && (address_data->ignore_range[i] != I2C_CLIENT_END);
747 i += 3) {
748 if (((adap_id == address_data->ignore_range[i]) ||
749 ((address_data->ignore_range[i]==ANY_I2C_BUS))) &&
750 (addr >= address_data->ignore_range[i+1]) &&
751 (addr <= address_data->ignore_range[i+2])) {
752 dev_dbg(&adapter->dev, "found ignore_range parameter for adapter %d, "
753 "addr %04x\n", adap_id,addr);
754 found = 1;
755 }
756 }
757 if (found) 720 if (found)
758 continue; 721 continue;
759 722
@@ -770,17 +733,6 @@ int i2c_probe(struct i2c_adapter *adapter,
770 } 733 }
771 734
772 for (i = 0; 735 for (i = 0;
773 !found && (address_data->normal_i2c_range[i] != I2C_CLIENT_END);
774 i += 2) {
775 if ((addr >= address_data->normal_i2c_range[i]) &&
776 (addr <= address_data->normal_i2c_range[i+1])) {
777 found = 1;
778 dev_dbg(&adapter->dev, "found normal i2c_range entry for adapter %d, "
779 "addr %04x\n", adap_id,addr);
780 }
781 }
782
783 for (i = 0;
784 !found && (address_data->probe[i] != I2C_CLIENT_END); 736 !found && (address_data->probe[i] != I2C_CLIENT_END);
785 i += 2) { 737 i += 2) {
786 if (((adap_id == address_data->probe[i]) || 738 if (((adap_id == address_data->probe[i]) ||
@@ -791,18 +743,6 @@ int i2c_probe(struct i2c_adapter *adapter,
791 "addr %04x\n", adap_id,addr); 743 "addr %04x\n", adap_id,addr);
792 } 744 }
793 } 745 }
794 for (i = 0;
795 !found && (address_data->probe_range[i] != I2C_CLIENT_END);
796 i += 3) {
797 if (((adap_id == address_data->probe_range[i]) ||
798 (address_data->probe_range[i] == ANY_I2C_BUS)) &&
799 (addr >= address_data->probe_range[i+1]) &&
800 (addr <= address_data->probe_range[i+2])) {
801 found = 1;
802 dev_dbg(&adapter->dev, "found probe_range parameter for adapter %d, "
803 "addr %04x\n", adap_id,addr);
804 }
805 }
806 if (!found) 746 if (!found)
807 continue; 747 continue;
808 748
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 86c4d0149e82..bc5d557e5dd9 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -29,7 +29,6 @@
29/* The devfs code is contributed by Philipp Matthias Hahn 29/* The devfs code is contributed by Philipp Matthias Hahn
30 <pmhahn@titan.lahn.de> */ 30 <pmhahn@titan.lahn.de> */
31 31
32#include <linux/config.h>
33#include <linux/kernel.h> 32#include <linux/kernel.h>
34#include <linux/module.h> 33#include <linux/module.h>
35#include <linux/fs.h> 34#include <linux/fs.h>
@@ -214,7 +213,7 @@ static int i2cdev_ioctl(struct inode *inode, struct file *file,
214 sizeof(rdwr_arg))) 213 sizeof(rdwr_arg)))
215 return -EFAULT; 214 return -EFAULT;
216 215
217 /* Put an arbritrary limit on the number of messages that can 216 /* Put an arbitrary limit on the number of messages that can
218 * be sent at once */ 217 * be sent at once */
219 if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) 218 if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)
220 return -EINVAL; 219 return -EINVAL;
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 3ac0a535b4aa..0273f124a4f7 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -672,8 +672,8 @@ config BLK_DEV_SVWKS
672 chipsets. 672 chipsets.
673 673
674config BLK_DEV_SGIIOC4 674config BLK_DEV_SGIIOC4
675 tristate "Silicon Graphics IOC4 chipset support" 675 tristate "Silicon Graphics IOC4 chipset ATA/ATAPI support"
676 depends on IA64_SGI_SN2 || IA64_GENERIC 676 depends on (IA64_SGI_SN2 || IA64_GENERIC) && SGI_IOC4
677 help 677 help
678 This driver adds PIO & MultiMode DMA-2 support for the SGI IOC4 678 This driver adds PIO & MultiMode DMA-2 support for the SGI IOC4
679 chipset, which has one channel and can support two devices. 679 chipset, which has one channel and can support two devices.
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index 4651a22bf12e..af526b671c4e 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -34,7 +34,7 @@
34#include <linux/mm.h> 34#include <linux/mm.h>
35#include <linux/ioport.h> 35#include <linux/ioport.h>
36#include <linux/blkdev.h> 36#include <linux/blkdev.h>
37#include <linux/ioc4_common.h> 37#include <linux/ioc4.h>
38#include <asm/io.h> 38#include <asm/io.h>
39 39
40#include <linux/ide.h> 40#include <linux/ide.h>
@@ -715,14 +715,34 @@ static ide_pci_device_t sgiioc4_chipsets[] __devinitdata = {
715}; 715};
716 716
717int 717int
718ioc4_ide_attach_one(struct pci_dev *dev, const struct pci_device_id *id) 718ioc4_ide_attach_one(struct ioc4_driver_data *idd)
719{ 719{
720 return pci_init_sgiioc4(dev, &sgiioc4_chipsets[id->driver_data]); 720 return pci_init_sgiioc4(idd->idd_pdev,
721 &sgiioc4_chipsets[idd->idd_pci_id->driver_data]);
721} 722}
722 723
724static struct ioc4_submodule ioc4_ide_submodule = {
725 .is_name = "IOC4_ide",
726 .is_owner = THIS_MODULE,
727 .is_probe = ioc4_ide_attach_one,
728/* .is_remove = ioc4_ide_remove_one, */
729};
730
731static int __devinit
732ioc4_ide_init(void)
733{
734 return ioc4_register_submodule(&ioc4_ide_submodule);
735}
736
737static void __devexit
738ioc4_ide_exit(void)
739{
740 ioc4_unregister_submodule(&ioc4_ide_submodule);
741}
742
743module_init(ioc4_ide_init);
744module_exit(ioc4_ide_exit);
723 745
724MODULE_AUTHOR("Aniket Malatpure - Silicon Graphics Inc. (SGI)"); 746MODULE_AUTHOR("Aniket Malatpure - Silicon Graphics Inc. (SGI)");
725MODULE_DESCRIPTION("IDE PCI driver module for SGI IOC4 Base-IO Card"); 747MODULE_DESCRIPTION("IDE PCI driver module for SGI IOC4 Base-IO Card");
726MODULE_LICENSE("GPL"); 748MODULE_LICENSE("GPL");
727
728EXPORT_SYMBOL(ioc4_ide_attach_one);
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index 9b8ff396e6f8..e152d0fa0cdd 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -134,7 +134,7 @@ static int gameport_measure_speed(struct gameport *gameport)
134 } 134 }
135 135
136 gameport_close(gameport); 136 gameport_close(gameport);
137 return (cpu_data[_smp_processor_id()].loops_per_jiffy * (unsigned long)HZ / (1000 / 50)) / (tx < 1 ? 1 : tx); 137 return (cpu_data[raw_smp_processor_id()].loops_per_jiffy * (unsigned long)HZ / (1000 / 50)) / (tx < 1 ? 1 : tx);
138 138
139#else 139#else
140 140
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
index 0bdb47f08c2a..61400f04015e 100644
--- a/drivers/macintosh/therm_windtunnel.c
+++ b/drivers/macintosh/therm_windtunnel.c
@@ -51,8 +51,10 @@
51static int do_probe( struct i2c_adapter *adapter, int addr, int kind); 51static int do_probe( struct i2c_adapter *adapter, int addr, int kind);
52 52
53/* scan 0x48-0x4f (DS1775) and 0x2c-2x2f (ADM1030) */ 53/* scan 0x48-0x4f (DS1775) and 0x2c-2x2f (ADM1030) */
54static unsigned short normal_i2c[] = { 0x49, 0x2c, I2C_CLIENT_END }; 54static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b,
55static unsigned short normal_i2c_range[] = { 0x48, 0x4f, 0x2c, 0x2f, I2C_CLIENT_END }; 55 0x4c, 0x4d, 0x4e, 0x4f,
56 0x2c, 0x2d, 0x2e, 0x2f,
57 I2C_CLIENT_END };
56 58
57I2C_CLIENT_INSMOD; 59I2C_CLIENT_INSMOD;
58 60
diff --git a/drivers/md/Makefile b/drivers/md/Makefile
index 90de9c146a5f..d3efedf6a6ad 100644
--- a/drivers/md/Makefile
+++ b/drivers/md/Makefile
@@ -7,6 +7,7 @@ dm-mod-objs := dm.o dm-table.o dm-target.o dm-linear.o dm-stripe.o \
7dm-multipath-objs := dm-hw-handler.o dm-path-selector.o dm-mpath.o 7dm-multipath-objs := dm-hw-handler.o dm-path-selector.o dm-mpath.o
8dm-snapshot-objs := dm-snap.o dm-exception-store.o 8dm-snapshot-objs := dm-snap.o dm-exception-store.o
9dm-mirror-objs := dm-log.o dm-raid1.o 9dm-mirror-objs := dm-log.o dm-raid1.o
10md-mod-objs := md.o bitmap.o
10raid6-objs := raid6main.o raid6algos.o raid6recov.o raid6tables.o \ 11raid6-objs := raid6main.o raid6algos.o raid6recov.o raid6tables.o \
11 raid6int1.o raid6int2.o raid6int4.o \ 12 raid6int1.o raid6int2.o raid6int4.o \
12 raid6int8.o raid6int16.o raid6int32.o \ 13 raid6int8.o raid6int16.o raid6int32.o \
@@ -28,7 +29,7 @@ obj-$(CONFIG_MD_RAID5) += raid5.o xor.o
28obj-$(CONFIG_MD_RAID6) += raid6.o xor.o 29obj-$(CONFIG_MD_RAID6) += raid6.o xor.o
29obj-$(CONFIG_MD_MULTIPATH) += multipath.o 30obj-$(CONFIG_MD_MULTIPATH) += multipath.o
30obj-$(CONFIG_MD_FAULTY) += faulty.o 31obj-$(CONFIG_MD_FAULTY) += faulty.o
31obj-$(CONFIG_BLK_DEV_MD) += md.o 32obj-$(CONFIG_BLK_DEV_MD) += md-mod.o
32obj-$(CONFIG_BLK_DEV_DM) += dm-mod.o 33obj-$(CONFIG_BLK_DEV_DM) += dm-mod.o
33obj-$(CONFIG_DM_CRYPT) += dm-crypt.o 34obj-$(CONFIG_DM_CRYPT) += dm-crypt.o
34obj-$(CONFIG_DM_MULTIPATH) += dm-multipath.o dm-round-robin.o 35obj-$(CONFIG_DM_MULTIPATH) += dm-multipath.o dm-round-robin.o
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
new file mode 100644
index 000000000000..95980ad6b27b
--- /dev/null
+++ b/drivers/md/bitmap.c
@@ -0,0 +1,1586 @@
1/*
2 * bitmap.c two-level bitmap (C) Peter T. Breuer (ptb@ot.uc3m.es) 2003
3 *
4 * bitmap_create - sets up the bitmap structure
5 * bitmap_destroy - destroys the bitmap structure
6 *
7 * additions, Copyright (C) 2003-2004, Paul Clements, SteelEye Technology, Inc.:
8 * - added disk storage for bitmap
9 * - changes to allow various bitmap chunk sizes
10 * - added bitmap daemon (to asynchronously clear bitmap bits from disk)
11 */
12
13/*
14 * Still to do:
15 *
16 * flush after percent set rather than just time based. (maybe both).
17 * wait if count gets too high, wake when it drops to half.
18 * allow bitmap to be mirrored with superblock (before or after...)
19 * allow hot-add to re-instate a current device.
20 * allow hot-add of bitmap after quiessing device
21 */
22
23#include <linux/module.h>
24#include <linux/version.h>
25#include <linux/errno.h>
26#include <linux/slab.h>
27#include <linux/init.h>
28#include <linux/config.h>
29#include <linux/timer.h>
30#include <linux/sched.h>
31#include <linux/list.h>
32#include <linux/file.h>
33#include <linux/mount.h>
34#include <linux/buffer_head.h>
35#include <linux/raid/md.h>
36#include <linux/raid/bitmap.h>
37
38/* debug macros */
39
40#define DEBUG 0
41
42#if DEBUG
43/* these are for debugging purposes only! */
44
45/* define one and only one of these */
46#define INJECT_FAULTS_1 0 /* cause bitmap_alloc_page to fail always */
47#define INJECT_FAULTS_2 0 /* cause bitmap file to be kicked when first bit set*/
48#define INJECT_FAULTS_3 0 /* treat bitmap file as kicked at init time */
49#define INJECT_FAULTS_4 0 /* undef */
50#define INJECT_FAULTS_5 0 /* undef */
51#define INJECT_FAULTS_6 0
52
53/* if these are defined, the driver will fail! debug only */
54#define INJECT_FATAL_FAULT_1 0 /* fail kmalloc, causing bitmap_create to fail */
55#define INJECT_FATAL_FAULT_2 0 /* undef */
56#define INJECT_FATAL_FAULT_3 0 /* undef */
57#endif
58
59//#define DPRINTK PRINTK /* set this NULL to avoid verbose debug output */
60#define DPRINTK(x...) do { } while(0)
61
62#ifndef PRINTK
63# if DEBUG > 0
64# define PRINTK(x...) printk(KERN_DEBUG x)
65# else
66# define PRINTK(x...)
67# endif
68#endif
69
70static inline char * bmname(struct bitmap *bitmap)
71{
72 return bitmap->mddev ? mdname(bitmap->mddev) : "mdX";
73}
74
75
76/*
77 * test if the bitmap is active
78 */
79int bitmap_active(struct bitmap *bitmap)
80{
81 unsigned long flags;
82 int res = 0;
83
84 if (!bitmap)
85 return res;
86 spin_lock_irqsave(&bitmap->lock, flags);
87 res = bitmap->flags & BITMAP_ACTIVE;
88 spin_unlock_irqrestore(&bitmap->lock, flags);
89 return res;
90}
91
92#define WRITE_POOL_SIZE 256
93/* mempool for queueing pending writes on the bitmap file */
94static void *write_pool_alloc(unsigned int gfp_flags, void *data)
95{
96 return kmalloc(sizeof(struct page_list), gfp_flags);
97}
98
99static void write_pool_free(void *ptr, void *data)
100{
101 kfree(ptr);
102}
103
104/*
105 * just a placeholder - calls kmalloc for bitmap pages
106 */
107static unsigned char *bitmap_alloc_page(struct bitmap *bitmap)
108{
109 unsigned char *page;
110
111#if INJECT_FAULTS_1
112 page = NULL;
113#else
114 page = kmalloc(PAGE_SIZE, GFP_NOIO);
115#endif
116 if (!page)
117 printk("%s: bitmap_alloc_page FAILED\n", bmname(bitmap));
118 else
119 PRINTK("%s: bitmap_alloc_page: allocated page at %p\n",
120 bmname(bitmap), page);
121 return page;
122}
123
124/*
125 * for now just a placeholder -- just calls kfree for bitmap pages
126 */
127static void bitmap_free_page(struct bitmap *bitmap, unsigned char *page)
128{
129 PRINTK("%s: bitmap_free_page: free page %p\n", bmname(bitmap), page);
130 kfree(page);
131}
132
133/*
134 * check a page and, if necessary, allocate it (or hijack it if the alloc fails)
135 *
136 * 1) check to see if this page is allocated, if it's not then try to alloc
137 * 2) if the alloc fails, set the page's hijacked flag so we'll use the
138 * page pointer directly as a counter
139 *
140 * if we find our page, we increment the page's refcount so that it stays
141 * allocated while we're using it
142 */
143static int bitmap_checkpage(struct bitmap *bitmap, unsigned long page, int create)
144{
145 unsigned char *mappage;
146
147 if (page >= bitmap->pages) {
148 printk(KERN_ALERT
149 "%s: invalid bitmap page request: %lu (> %lu)\n",
150 bmname(bitmap), page, bitmap->pages-1);
151 return -EINVAL;
152 }
153
154
155 if (bitmap->bp[page].hijacked) /* it's hijacked, don't try to alloc */
156 return 0;
157
158 if (bitmap->bp[page].map) /* page is already allocated, just return */
159 return 0;
160
161 if (!create)
162 return -ENOENT;
163
164 spin_unlock_irq(&bitmap->lock);
165
166 /* this page has not been allocated yet */
167
168 if ((mappage = bitmap_alloc_page(bitmap)) == NULL) {
169 PRINTK("%s: bitmap map page allocation failed, hijacking\n",
170 bmname(bitmap));
171 /* failed - set the hijacked flag so that we can use the
172 * pointer as a counter */
173 spin_lock_irq(&bitmap->lock);
174 if (!bitmap->bp[page].map)
175 bitmap->bp[page].hijacked = 1;
176 goto out;
177 }
178
179 /* got a page */
180
181 spin_lock_irq(&bitmap->lock);
182
183 /* recheck the page */
184
185 if (bitmap->bp[page].map || bitmap->bp[page].hijacked) {
186 /* somebody beat us to getting the page */
187 bitmap_free_page(bitmap, mappage);
188 return 0;
189 }
190
191 /* no page was in place and we have one, so install it */
192
193 memset(mappage, 0, PAGE_SIZE);
194 bitmap->bp[page].map = mappage;
195 bitmap->missing_pages--;
196out:
197 return 0;
198}
199
200
201/* if page is completely empty, put it back on the free list, or dealloc it */
202/* if page was hijacked, unmark the flag so it might get alloced next time */
203/* Note: lock should be held when calling this */
204static inline void bitmap_checkfree(struct bitmap *bitmap, unsigned long page)
205{
206 char *ptr;
207
208 if (bitmap->bp[page].count) /* page is still busy */
209 return;
210
211 /* page is no longer in use, it can be released */
212
213 if (bitmap->bp[page].hijacked) { /* page was hijacked, undo this now */
214 bitmap->bp[page].hijacked = 0;
215 bitmap->bp[page].map = NULL;
216 return;
217 }
218
219 /* normal case, free the page */
220
221#if 0
222/* actually ... let's not. We will probably need the page again exactly when
223 * memory is tight and we are flusing to disk
224 */
225 return;
226#else
227 ptr = bitmap->bp[page].map;
228 bitmap->bp[page].map = NULL;
229 bitmap->missing_pages++;
230 bitmap_free_page(bitmap, ptr);
231 return;
232#endif
233}
234
235
236/*
237 * bitmap file handling - read and write the bitmap file and its superblock
238 */
239
240/* copy the pathname of a file to a buffer */
241char *file_path(struct file *file, char *buf, int count)
242{
243 struct dentry *d;
244 struct vfsmount *v;
245
246 if (!buf)
247 return NULL;
248
249 d = file->f_dentry;
250 v = file->f_vfsmnt;
251
252 buf = d_path(d, v, buf, count);
253
254 return IS_ERR(buf) ? NULL : buf;
255}
256
257/*
258 * basic page I/O operations
259 */
260
261/* IO operations when bitmap is stored near all superblocks */
262static struct page *read_sb_page(mddev_t *mddev, long offset, unsigned long index)
263{
264 /* choose a good rdev and read the page from there */
265
266 mdk_rdev_t *rdev;
267 struct list_head *tmp;
268 struct page *page = alloc_page(GFP_KERNEL);
269 sector_t target;
270
271 if (!page)
272 return ERR_PTR(-ENOMEM);
273 do {
274 ITERATE_RDEV(mddev, rdev, tmp)
275 if (rdev->in_sync && !rdev->faulty)
276 goto found;
277 return ERR_PTR(-EIO);
278
279 found:
280 target = (rdev->sb_offset << 1) + offset + index * (PAGE_SIZE/512);
281
282 } while (!sync_page_io(rdev->bdev, target, PAGE_SIZE, page, READ));
283
284 page->index = index;
285 return page;
286}
287
288static int write_sb_page(mddev_t *mddev, long offset, struct page *page, int wait)
289{
290 mdk_rdev_t *rdev;
291 struct list_head *tmp;
292
293 ITERATE_RDEV(mddev, rdev, tmp)
294 if (rdev->in_sync && !rdev->faulty)
295 md_super_write(mddev, rdev,
296 (rdev->sb_offset<<1) + offset
297 + page->index * (PAGE_SIZE/512),
298 PAGE_SIZE,
299 page);
300
301 if (wait)
302 wait_event(mddev->sb_wait, atomic_read(&mddev->pending_writes)==0);
303 return 0;
304}
305
306/*
307 * write out a page to a file
308 */
309static int write_page(struct bitmap *bitmap, struct page *page, int wait)
310{
311 int ret = -ENOMEM;
312
313 if (bitmap->file == NULL)
314 return write_sb_page(bitmap->mddev, bitmap->offset, page, wait);
315
316 if (wait)
317 lock_page(page);
318 else {
319 if (TestSetPageLocked(page))
320 return -EAGAIN; /* already locked */
321 if (PageWriteback(page)) {
322 unlock_page(page);
323 return -EAGAIN;
324 }
325 }
326
327 ret = page->mapping->a_ops->prepare_write(NULL, page, 0, PAGE_SIZE);
328 if (!ret)
329 ret = page->mapping->a_ops->commit_write(NULL, page, 0,
330 PAGE_SIZE);
331 if (ret) {
332 unlock_page(page);
333 return ret;
334 }
335
336 set_page_dirty(page); /* force it to be written out */
337
338 if (!wait) {
339 /* add to list to be waited for by daemon */
340 struct page_list *item = mempool_alloc(bitmap->write_pool, GFP_NOIO);
341 item->page = page;
342 page_cache_get(page);
343 spin_lock(&bitmap->write_lock);
344 list_add(&item->list, &bitmap->complete_pages);
345 spin_unlock(&bitmap->write_lock);
346 md_wakeup_thread(bitmap->writeback_daemon);
347 }
348 return write_one_page(page, wait);
349}
350
351/* read a page from a file, pinning it into cache, and return bytes_read */
352static struct page *read_page(struct file *file, unsigned long index,
353 unsigned long *bytes_read)
354{
355 struct inode *inode = file->f_mapping->host;
356 struct page *page = NULL;
357 loff_t isize = i_size_read(inode);
358 unsigned long end_index = isize >> PAGE_CACHE_SHIFT;
359
360 PRINTK("read bitmap file (%dB @ %Lu)\n", (int)PAGE_CACHE_SIZE,
361 (unsigned long long)index << PAGE_CACHE_SHIFT);
362
363 page = read_cache_page(inode->i_mapping, index,
364 (filler_t *)inode->i_mapping->a_ops->readpage, file);
365 if (IS_ERR(page))
366 goto out;
367 wait_on_page_locked(page);
368 if (!PageUptodate(page) || PageError(page)) {
369 page_cache_release(page);
370 page = ERR_PTR(-EIO);
371 goto out;
372 }
373
374 if (index > end_index) /* we have read beyond EOF */
375 *bytes_read = 0;
376 else if (index == end_index) /* possible short read */
377 *bytes_read = isize & ~PAGE_CACHE_MASK;
378 else
379 *bytes_read = PAGE_CACHE_SIZE; /* got a full page */
380out:
381 if (IS_ERR(page))
382 printk(KERN_ALERT "md: bitmap read error: (%dB @ %Lu): %ld\n",
383 (int)PAGE_CACHE_SIZE,
384 (unsigned long long)index << PAGE_CACHE_SHIFT,
385 PTR_ERR(page));
386 return page;
387}
388
389/*
390 * bitmap file superblock operations
391 */
392
393/* update the event counter and sync the superblock to disk */
394int bitmap_update_sb(struct bitmap *bitmap)
395{
396 bitmap_super_t *sb;
397 unsigned long flags;
398
399 if (!bitmap || !bitmap->mddev) /* no bitmap for this array */
400 return 0;
401 spin_lock_irqsave(&bitmap->lock, flags);
402 if (!bitmap->sb_page) { /* no superblock */
403 spin_unlock_irqrestore(&bitmap->lock, flags);
404 return 0;
405 }
406 spin_unlock_irqrestore(&bitmap->lock, flags);
407 sb = (bitmap_super_t *)kmap(bitmap->sb_page);
408 sb->events = cpu_to_le64(bitmap->mddev->events);
409 if (!bitmap->mddev->degraded)
410 sb->events_cleared = cpu_to_le64(bitmap->mddev->events);
411 kunmap(bitmap->sb_page);
412 return write_page(bitmap, bitmap->sb_page, 1);
413}
414
415/* print out the bitmap file superblock */
416void bitmap_print_sb(struct bitmap *bitmap)
417{
418 bitmap_super_t *sb;
419
420 if (!bitmap || !bitmap->sb_page)
421 return;
422 sb = (bitmap_super_t *)kmap(bitmap->sb_page);
423 printk(KERN_DEBUG "%s: bitmap file superblock:\n", bmname(bitmap));
424 printk(KERN_DEBUG " magic: %08x\n", le32_to_cpu(sb->magic));
425 printk(KERN_DEBUG " version: %d\n", le32_to_cpu(sb->version));
426 printk(KERN_DEBUG " uuid: %08x.%08x.%08x.%08x\n",
427 *(__u32 *)(sb->uuid+0),
428 *(__u32 *)(sb->uuid+4),
429 *(__u32 *)(sb->uuid+8),
430 *(__u32 *)(sb->uuid+12));
431 printk(KERN_DEBUG " events: %llu\n",
432 (unsigned long long) le64_to_cpu(sb->events));
433 printk(KERN_DEBUG "events cleared: %llu\n",
434 (unsigned long long) le64_to_cpu(sb->events_cleared));
435 printk(KERN_DEBUG " state: %08x\n", le32_to_cpu(sb->state));
436 printk(KERN_DEBUG " chunksize: %d B\n", le32_to_cpu(sb->chunksize));
437 printk(KERN_DEBUG " daemon sleep: %ds\n", le32_to_cpu(sb->daemon_sleep));
438 printk(KERN_DEBUG " sync size: %llu KB\n",
439 (unsigned long long)le64_to_cpu(sb->sync_size)/2);
440 kunmap(bitmap->sb_page);
441}
442
443/* read the superblock from the bitmap file and initialize some bitmap fields */
444static int bitmap_read_sb(struct bitmap *bitmap)
445{
446 char *reason = NULL;
447 bitmap_super_t *sb;
448 unsigned long chunksize, daemon_sleep;
449 unsigned long bytes_read;
450 unsigned long long events;
451 int err = -EINVAL;
452
453 /* page 0 is the superblock, read it... */
454 if (bitmap->file)
455 bitmap->sb_page = read_page(bitmap->file, 0, &bytes_read);
456 else {
457 bitmap->sb_page = read_sb_page(bitmap->mddev, bitmap->offset, 0);
458 bytes_read = PAGE_SIZE;
459 }
460 if (IS_ERR(bitmap->sb_page)) {
461 err = PTR_ERR(bitmap->sb_page);
462 bitmap->sb_page = NULL;
463 return err;
464 }
465
466 sb = (bitmap_super_t *)kmap(bitmap->sb_page);
467
468 if (bytes_read < sizeof(*sb)) { /* short read */
469 printk(KERN_INFO "%s: bitmap file superblock truncated\n",
470 bmname(bitmap));
471 err = -ENOSPC;
472 goto out;
473 }
474
475 chunksize = le32_to_cpu(sb->chunksize);
476 daemon_sleep = le32_to_cpu(sb->daemon_sleep);
477
478 /* verify that the bitmap-specific fields are valid */
479 if (sb->magic != cpu_to_le32(BITMAP_MAGIC))
480 reason = "bad magic";
481 else if (sb->version != cpu_to_le32(BITMAP_MAJOR))
482 reason = "unrecognized superblock version";
483 else if (chunksize < 512 || chunksize > (1024 * 1024 * 4))
484 reason = "bitmap chunksize out of range (512B - 4MB)";
485 else if ((1 << ffz(~chunksize)) != chunksize)
486 reason = "bitmap chunksize not a power of 2";
487 else if (daemon_sleep < 1 || daemon_sleep > 15)
488 reason = "daemon sleep period out of range";
489 if (reason) {
490 printk(KERN_INFO "%s: invalid bitmap file superblock: %s\n",
491 bmname(bitmap), reason);
492 goto out;
493 }
494
495 /* keep the array size field of the bitmap superblock up to date */
496 sb->sync_size = cpu_to_le64(bitmap->mddev->resync_max_sectors);
497
498 if (!bitmap->mddev->persistent)
499 goto success;
500
501 /*
502 * if we have a persistent array superblock, compare the
503 * bitmap's UUID and event counter to the mddev's
504 */
505 if (memcmp(sb->uuid, bitmap->mddev->uuid, 16)) {
506 printk(KERN_INFO "%s: bitmap superblock UUID mismatch\n",
507 bmname(bitmap));
508 goto out;
509 }
510 events = le64_to_cpu(sb->events);
511 if (events < bitmap->mddev->events) {
512 printk(KERN_INFO "%s: bitmap file is out of date (%llu < %llu) "
513 "-- forcing full recovery\n", bmname(bitmap), events,
514 (unsigned long long) bitmap->mddev->events);
515 sb->state |= BITMAP_STALE;
516 }
517success:
518 /* assign fields using values from superblock */
519 bitmap->chunksize = chunksize;
520 bitmap->daemon_sleep = daemon_sleep;
521 bitmap->flags |= sb->state;
522 bitmap->events_cleared = le64_to_cpu(sb->events_cleared);
523 err = 0;
524out:
525 kunmap(bitmap->sb_page);
526 if (err)
527 bitmap_print_sb(bitmap);
528 return err;
529}
530
531enum bitmap_mask_op {
532 MASK_SET,
533 MASK_UNSET
534};
535
536/* record the state of the bitmap in the superblock */
537static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits,
538 enum bitmap_mask_op op)
539{
540 bitmap_super_t *sb;
541 unsigned long flags;
542
543 spin_lock_irqsave(&bitmap->lock, flags);
544 if (!bitmap || !bitmap->sb_page) { /* can't set the state */
545 spin_unlock_irqrestore(&bitmap->lock, flags);
546 return;
547 }
548 page_cache_get(bitmap->sb_page);
549 spin_unlock_irqrestore(&bitmap->lock, flags);
550 sb = (bitmap_super_t *)kmap(bitmap->sb_page);
551 switch (op) {
552 case MASK_SET: sb->state |= bits;
553 break;
554 case MASK_UNSET: sb->state &= ~bits;
555 break;
556 default: BUG();
557 }
558 kunmap(bitmap->sb_page);
559 page_cache_release(bitmap->sb_page);
560}
561
562/*
563 * general bitmap file operations
564 */
565
566/* calculate the index of the page that contains this bit */
567static inline unsigned long file_page_index(unsigned long chunk)
568{
569 return CHUNK_BIT_OFFSET(chunk) >> PAGE_BIT_SHIFT;
570}
571
572/* calculate the (bit) offset of this bit within a page */
573static inline unsigned long file_page_offset(unsigned long chunk)
574{
575 return CHUNK_BIT_OFFSET(chunk) & (PAGE_BITS - 1);
576}
577
578/*
579 * return a pointer to the page in the filemap that contains the given bit
580 *
581 * this lookup is complicated by the fact that the bitmap sb might be exactly
582 * 1 page (e.g., x86) or less than 1 page -- so the bitmap might start on page
583 * 0 or page 1
584 */
585static inline struct page *filemap_get_page(struct bitmap *bitmap,
586 unsigned long chunk)
587{
588 return bitmap->filemap[file_page_index(chunk) - file_page_index(0)];
589}
590
591
592static void bitmap_file_unmap(struct bitmap *bitmap)
593{
594 struct page **map, *sb_page;
595 unsigned long *attr;
596 int pages;
597 unsigned long flags;
598
599 spin_lock_irqsave(&bitmap->lock, flags);
600 map = bitmap->filemap;
601 bitmap->filemap = NULL;
602 attr = bitmap->filemap_attr;
603 bitmap->filemap_attr = NULL;
604 pages = bitmap->file_pages;
605 bitmap->file_pages = 0;
606 sb_page = bitmap->sb_page;
607 bitmap->sb_page = NULL;
608 spin_unlock_irqrestore(&bitmap->lock, flags);
609
610 while (pages--)
611 if (map[pages]->index != 0) /* 0 is sb_page, release it below */
612 page_cache_release(map[pages]);
613 kfree(map);
614 kfree(attr);
615
616 if (sb_page)
617 page_cache_release(sb_page);
618}
619
620static void bitmap_stop_daemons(struct bitmap *bitmap);
621
622/* dequeue the next item in a page list -- don't call from irq context */
623static struct page_list *dequeue_page(struct bitmap *bitmap)
624{
625 struct page_list *item = NULL;
626 struct list_head *head = &bitmap->complete_pages;
627
628 spin_lock(&bitmap->write_lock);
629 if (list_empty(head))
630 goto out;
631 item = list_entry(head->prev, struct page_list, list);
632 list_del(head->prev);
633out:
634 spin_unlock(&bitmap->write_lock);
635 return item;
636}
637
638static void drain_write_queues(struct bitmap *bitmap)
639{
640 struct page_list *item;
641
642 while ((item = dequeue_page(bitmap))) {
643 /* don't bother to wait */
644 page_cache_release(item->page);
645 mempool_free(item, bitmap->write_pool);
646 }
647
648 wake_up(&bitmap->write_wait);
649}
650
651static void bitmap_file_put(struct bitmap *bitmap)
652{
653 struct file *file;
654 struct inode *inode;
655 unsigned long flags;
656
657 spin_lock_irqsave(&bitmap->lock, flags);
658 file = bitmap->file;
659 bitmap->file = NULL;
660 spin_unlock_irqrestore(&bitmap->lock, flags);
661
662 bitmap_stop_daemons(bitmap);
663
664 drain_write_queues(bitmap);
665
666 bitmap_file_unmap(bitmap);
667
668 if (file) {
669 inode = file->f_mapping->host;
670 spin_lock(&inode->i_lock);
671 atomic_set(&inode->i_writecount, 1); /* allow writes again */
672 spin_unlock(&inode->i_lock);
673 fput(file);
674 }
675}
676
677
678/*
679 * bitmap_file_kick - if an error occurs while manipulating the bitmap file
680 * then it is no longer reliable, so we stop using it and we mark the file
681 * as failed in the superblock
682 */
683static void bitmap_file_kick(struct bitmap *bitmap)
684{
685 char *path, *ptr = NULL;
686
687 bitmap_mask_state(bitmap, BITMAP_STALE, MASK_SET);
688 bitmap_update_sb(bitmap);
689
690 if (bitmap->file) {
691 path = kmalloc(PAGE_SIZE, GFP_KERNEL);
692 if (path)
693 ptr = file_path(bitmap->file, path, PAGE_SIZE);
694
695 printk(KERN_ALERT "%s: kicking failed bitmap file %s from array!\n",
696 bmname(bitmap), ptr ? ptr : "");
697
698 kfree(path);
699 }
700
701 bitmap_file_put(bitmap);
702
703 return;
704}
705
706enum bitmap_page_attr {
707 BITMAP_PAGE_DIRTY = 1, // there are set bits that need to be synced
708 BITMAP_PAGE_CLEAN = 2, // there are bits that might need to be cleared
709 BITMAP_PAGE_NEEDWRITE=4, // there are cleared bits that need to be synced
710};
711
712static inline void set_page_attr(struct bitmap *bitmap, struct page *page,
713 enum bitmap_page_attr attr)
714{
715 bitmap->filemap_attr[page->index] |= attr;
716}
717
718static inline void clear_page_attr(struct bitmap *bitmap, struct page *page,
719 enum bitmap_page_attr attr)
720{
721 bitmap->filemap_attr[page->index] &= ~attr;
722}
723
724static inline unsigned long get_page_attr(struct bitmap *bitmap, struct page *page)
725{
726 return bitmap->filemap_attr[page->index];
727}
728
729/*
730 * bitmap_file_set_bit -- called before performing a write to the md device
731 * to set (and eventually sync) a particular bit in the bitmap file
732 *
733 * we set the bit immediately, then we record the page number so that
734 * when an unplug occurs, we can flush the dirty pages out to disk
735 */
736static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block)
737{
738 unsigned long bit;
739 struct page *page;
740 void *kaddr;
741 unsigned long chunk = block >> CHUNK_BLOCK_SHIFT(bitmap);
742
743 if (!bitmap->filemap) {
744 return;
745 }
746
747 page = filemap_get_page(bitmap, chunk);
748 bit = file_page_offset(chunk);
749
750
751 /* make sure the page stays cached until it gets written out */
752 if (! (get_page_attr(bitmap, page) & BITMAP_PAGE_DIRTY))
753 page_cache_get(page);
754
755 /* set the bit */
756 kaddr = kmap_atomic(page, KM_USER0);
757 set_bit(bit, kaddr);
758 kunmap_atomic(kaddr, KM_USER0);
759 PRINTK("set file bit %lu page %lu\n", bit, page->index);
760
761 /* record page number so it gets flushed to disk when unplug occurs */
762 set_page_attr(bitmap, page, BITMAP_PAGE_DIRTY);
763
764}
765
766/* this gets called when the md device is ready to unplug its underlying
767 * (slave) device queues -- before we let any writes go down, we need to
768 * sync the dirty pages of the bitmap file to disk */
769int bitmap_unplug(struct bitmap *bitmap)
770{
771 unsigned long i, attr, flags;
772 struct page *page;
773 int wait = 0;
774 int err;
775
776 if (!bitmap)
777 return 0;
778
779 /* look at each page to see if there are any set bits that need to be
780 * flushed out to disk */
781 for (i = 0; i < bitmap->file_pages; i++) {
782 spin_lock_irqsave(&bitmap->lock, flags);
783 if (!bitmap->filemap) {
784 spin_unlock_irqrestore(&bitmap->lock, flags);
785 return 0;
786 }
787 page = bitmap->filemap[i];
788 attr = get_page_attr(bitmap, page);
789 clear_page_attr(bitmap, page, BITMAP_PAGE_DIRTY);
790 clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE);
791 if ((attr & BITMAP_PAGE_DIRTY))
792 wait = 1;
793 spin_unlock_irqrestore(&bitmap->lock, flags);
794
795 if (attr & (BITMAP_PAGE_DIRTY | BITMAP_PAGE_NEEDWRITE)) {
796 err = write_page(bitmap, page, 0);
797 if (err == -EAGAIN) {
798 if (attr & BITMAP_PAGE_DIRTY)
799 err = write_page(bitmap, page, 1);
800 else
801 err = 0;
802 }
803 if (err)
804 return 1;
805 }
806 }
807 if (wait) { /* if any writes were performed, we need to wait on them */
808 if (bitmap->file) {
809 spin_lock_irq(&bitmap->write_lock);
810 wait_event_lock_irq(bitmap->write_wait,
811 list_empty(&bitmap->complete_pages), bitmap->write_lock,
812 wake_up_process(bitmap->writeback_daemon->tsk));
813 spin_unlock_irq(&bitmap->write_lock);
814 } else
815 wait_event(bitmap->mddev->sb_wait,
816 atomic_read(&bitmap->mddev->pending_writes)==0);
817 }
818 return 0;
819}
820
821static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset,
822 unsigned long sectors, int in_sync);
823/* * bitmap_init_from_disk -- called at bitmap_create time to initialize
824 * the in-memory bitmap from the on-disk bitmap -- also, sets up the
825 * memory mapping of the bitmap file
826 * Special cases:
827 * if there's no bitmap file, or if the bitmap file had been
828 * previously kicked from the array, we mark all the bits as
829 * 1's in order to cause a full resync.
830 */
831static int bitmap_init_from_disk(struct bitmap *bitmap, int in_sync)
832{
833 unsigned long i, chunks, index, oldindex, bit;
834 struct page *page = NULL, *oldpage = NULL;
835 unsigned long num_pages, bit_cnt = 0;
836 struct file *file;
837 unsigned long bytes, offset, dummy;
838 int outofdate;
839 int ret = -ENOSPC;
840
841 chunks = bitmap->chunks;
842 file = bitmap->file;
843
844 BUG_ON(!file && !bitmap->offset);
845
846#if INJECT_FAULTS_3
847 outofdate = 1;
848#else
849 outofdate = bitmap->flags & BITMAP_STALE;
850#endif
851 if (outofdate)
852 printk(KERN_INFO "%s: bitmap file is out of date, doing full "
853 "recovery\n", bmname(bitmap));
854
855 bytes = (chunks + 7) / 8;
856
857 num_pages = (bytes + sizeof(bitmap_super_t) + PAGE_SIZE - 1) / PAGE_SIZE;
858
859 if (file && i_size_read(file->f_mapping->host) < bytes + sizeof(bitmap_super_t)) {
860 printk(KERN_INFO "%s: bitmap file too short %lu < %lu\n",
861 bmname(bitmap),
862 (unsigned long) i_size_read(file->f_mapping->host),
863 bytes + sizeof(bitmap_super_t));
864 goto out;
865 }
866
867 ret = -ENOMEM;
868
869 bitmap->filemap = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL);
870 if (!bitmap->filemap)
871 goto out;
872
873 bitmap->filemap_attr = kmalloc(sizeof(long) * num_pages, GFP_KERNEL);
874 if (!bitmap->filemap_attr)
875 goto out;
876
877 memset(bitmap->filemap_attr, 0, sizeof(long) * num_pages);
878
879 oldindex = ~0L;
880
881 for (i = 0; i < chunks; i++) {
882 index = file_page_index(i);
883 bit = file_page_offset(i);
884 if (index != oldindex) { /* this is a new page, read it in */
885 /* unmap the old page, we're done with it */
886 if (oldpage != NULL)
887 kunmap(oldpage);
888 if (index == 0) {
889 /*
890 * if we're here then the superblock page
891 * contains some bits (PAGE_SIZE != sizeof sb)
892 * we've already read it in, so just use it
893 */
894 page = bitmap->sb_page;
895 offset = sizeof(bitmap_super_t);
896 } else if (file) {
897 page = read_page(file, index, &dummy);
898 offset = 0;
899 } else {
900 page = read_sb_page(bitmap->mddev, bitmap->offset, index);
901 offset = 0;
902 }
903 if (IS_ERR(page)) { /* read error */
904 ret = PTR_ERR(page);
905 goto out;
906 }
907
908 oldindex = index;
909 oldpage = page;
910 kmap(page);
911
912 if (outofdate) {
913 /*
914 * if bitmap is out of date, dirty the
915 * whole page and write it out
916 */
917 memset(page_address(page) + offset, 0xff,
918 PAGE_SIZE - offset);
919 ret = write_page(bitmap, page, 1);
920 if (ret) {
921 kunmap(page);
922 /* release, page not in filemap yet */
923 page_cache_release(page);
924 goto out;
925 }
926 }
927
928 bitmap->filemap[bitmap->file_pages++] = page;
929 }
930 if (test_bit(bit, page_address(page))) {
931 /* if the disk bit is set, set the memory bit */
932 bitmap_set_memory_bits(bitmap,
933 i << CHUNK_BLOCK_SHIFT(bitmap), 1, in_sync);
934 bit_cnt++;
935 }
936 }
937
938 /* everything went OK */
939 ret = 0;
940 bitmap_mask_state(bitmap, BITMAP_STALE, MASK_UNSET);
941
942 if (page) /* unmap the last page */
943 kunmap(page);
944
945 if (bit_cnt) { /* Kick recovery if any bits were set */
946 set_bit(MD_RECOVERY_NEEDED, &bitmap->mddev->recovery);
947 md_wakeup_thread(bitmap->mddev->thread);
948 }
949
950out:
951 printk(KERN_INFO "%s: bitmap initialized from disk: "
952 "read %lu/%lu pages, set %lu bits, status: %d\n",
953 bmname(bitmap), bitmap->file_pages, num_pages, bit_cnt, ret);
954
955 return ret;
956}
957
958void bitmap_write_all(struct bitmap *bitmap)
959{
960 /* We don't actually write all bitmap blocks here,
961 * just flag them as needing to be written
962 */
963
964 unsigned long chunks = bitmap->chunks;
965 unsigned long bytes = (chunks+7)/8 + sizeof(bitmap_super_t);
966 unsigned long num_pages = (bytes + PAGE_SIZE-1) / PAGE_SIZE;
967 while (num_pages--)
968 bitmap->filemap_attr[num_pages] |= BITMAP_PAGE_NEEDWRITE;
969}
970
971
972static void bitmap_count_page(struct bitmap *bitmap, sector_t offset, int inc)
973{
974 sector_t chunk = offset >> CHUNK_BLOCK_SHIFT(bitmap);
975 unsigned long page = chunk >> PAGE_COUNTER_SHIFT;
976 bitmap->bp[page].count += inc;
977/*
978 if (page == 0) printk("count page 0, offset %llu: %d gives %d\n",
979 (unsigned long long)offset, inc, bitmap->bp[page].count);
980*/
981 bitmap_checkfree(bitmap, page);
982}
983static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap,
984 sector_t offset, int *blocks,
985 int create);
986
987/*
988 * bitmap daemon -- periodically wakes up to clean bits and flush pages
989 * out to disk
990 */
991
992int bitmap_daemon_work(struct bitmap *bitmap)
993{
994 unsigned long j;
995 unsigned long flags;
996 struct page *page = NULL, *lastpage = NULL;
997 int err = 0;
998 int blocks;
999 int attr;
1000
1001 if (bitmap == NULL)
1002 return 0;
1003 if (time_before(jiffies, bitmap->daemon_lastrun + bitmap->daemon_sleep*HZ))
1004 return 0;
1005 bitmap->daemon_lastrun = jiffies;
1006
1007 for (j = 0; j < bitmap->chunks; j++) {
1008 bitmap_counter_t *bmc;
1009 spin_lock_irqsave(&bitmap->lock, flags);
1010 if (!bitmap->filemap) {
1011 /* error or shutdown */
1012 spin_unlock_irqrestore(&bitmap->lock, flags);
1013 break;
1014 }
1015
1016 page = filemap_get_page(bitmap, j);
1017
1018 if (page != lastpage) {
1019 /* skip this page unless it's marked as needing cleaning */
1020 if (!((attr=get_page_attr(bitmap, page)) & BITMAP_PAGE_CLEAN)) {
1021 if (attr & BITMAP_PAGE_NEEDWRITE) {
1022 page_cache_get(page);
1023 clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE);
1024 }
1025 spin_unlock_irqrestore(&bitmap->lock, flags);
1026 if (attr & BITMAP_PAGE_NEEDWRITE) {
1027 switch (write_page(bitmap, page, 0)) {
1028 case -EAGAIN:
1029 set_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE);
1030 break;
1031 case 0:
1032 break;
1033 default:
1034 bitmap_file_kick(bitmap);
1035 }
1036 page_cache_release(page);
1037 }
1038 continue;
1039 }
1040
1041 /* grab the new page, sync and release the old */
1042 page_cache_get(page);
1043 if (lastpage != NULL) {
1044 if (get_page_attr(bitmap, lastpage) & BITMAP_PAGE_NEEDWRITE) {
1045 clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
1046 spin_unlock_irqrestore(&bitmap->lock, flags);
1047 err = write_page(bitmap, lastpage, 0);
1048 if (err == -EAGAIN) {
1049 err = 0;
1050 set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
1051 }
1052 } else {
1053 set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
1054 spin_unlock_irqrestore(&bitmap->lock, flags);
1055 }
1056 kunmap(lastpage);
1057 page_cache_release(lastpage);
1058 if (err)
1059 bitmap_file_kick(bitmap);
1060 } else
1061 spin_unlock_irqrestore(&bitmap->lock, flags);
1062 lastpage = page;
1063 kmap(page);
1064/*
1065 printk("bitmap clean at page %lu\n", j);
1066*/
1067 spin_lock_irqsave(&bitmap->lock, flags);
1068 clear_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
1069 }
1070 bmc = bitmap_get_counter(bitmap, j << CHUNK_BLOCK_SHIFT(bitmap),
1071 &blocks, 0);
1072 if (bmc) {
1073/*
1074 if (j < 100) printk("bitmap: j=%lu, *bmc = 0x%x\n", j, *bmc);
1075*/
1076 if (*bmc == 2) {
1077 *bmc=1; /* maybe clear the bit next time */
1078 set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
1079 } else if (*bmc == 1) {
1080 /* we can clear the bit */
1081 *bmc = 0;
1082 bitmap_count_page(bitmap, j << CHUNK_BLOCK_SHIFT(bitmap),
1083 -1);
1084
1085 /* clear the bit */
1086 clear_bit(file_page_offset(j), page_address(page));
1087 }
1088 }
1089 spin_unlock_irqrestore(&bitmap->lock, flags);
1090 }
1091
1092 /* now sync the final page */
1093 if (lastpage != NULL) {
1094 kunmap(lastpage);
1095 spin_lock_irqsave(&bitmap->lock, flags);
1096 if (get_page_attr(bitmap, lastpage) &BITMAP_PAGE_NEEDWRITE) {
1097 clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
1098 spin_unlock_irqrestore(&bitmap->lock, flags);
1099 err = write_page(bitmap, lastpage, 0);
1100 if (err == -EAGAIN) {
1101 set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
1102 err = 0;
1103 }
1104 } else {
1105 set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
1106 spin_unlock_irqrestore(&bitmap->lock, flags);
1107 }
1108
1109 page_cache_release(lastpage);
1110 }
1111
1112 return err;
1113}
1114
1115static void daemon_exit(struct bitmap *bitmap, mdk_thread_t **daemon)
1116{
1117 mdk_thread_t *dmn;
1118 unsigned long flags;
1119
1120 /* if no one is waiting on us, we'll free the md thread struct
1121 * and exit, otherwise we let the waiter clean things up */
1122 spin_lock_irqsave(&bitmap->lock, flags);
1123 if ((dmn = *daemon)) { /* no one is waiting, cleanup and exit */
1124 *daemon = NULL;
1125 spin_unlock_irqrestore(&bitmap->lock, flags);
1126 kfree(dmn);
1127 complete_and_exit(NULL, 0); /* do_exit not exported */
1128 }
1129 spin_unlock_irqrestore(&bitmap->lock, flags);
1130}
1131
1132static void bitmap_writeback_daemon(mddev_t *mddev)
1133{
1134 struct bitmap *bitmap = mddev->bitmap;
1135 struct page *page;
1136 struct page_list *item;
1137 int err = 0;
1138
1139 if (signal_pending(current)) {
1140 printk(KERN_INFO
1141 "%s: bitmap writeback daemon got signal, exiting...\n",
1142 bmname(bitmap));
1143 err = -EINTR;
1144 goto out;
1145 }
1146
1147 PRINTK("%s: bitmap writeback daemon woke up...\n", bmname(bitmap));
1148 /* wait on bitmap page writebacks */
1149 while ((item = dequeue_page(bitmap))) {
1150 page = item->page;
1151 mempool_free(item, bitmap->write_pool);
1152 PRINTK("wait on page writeback: %p\n", page);
1153 wait_on_page_writeback(page);
1154 PRINTK("finished page writeback: %p\n", page);
1155
1156 err = PageError(page);
1157 page_cache_release(page);
1158 if (err) {
1159 printk(KERN_WARNING "%s: bitmap file writeback "
1160 "failed (page %lu): %d\n",
1161 bmname(bitmap), page->index, err);
1162 bitmap_file_kick(bitmap);
1163 goto out;
1164 }
1165 }
1166 out:
1167 wake_up(&bitmap->write_wait);
1168 if (err) {
1169 printk(KERN_INFO "%s: bitmap writeback daemon exiting (%d)\n",
1170 bmname(bitmap), err);
1171 daemon_exit(bitmap, &bitmap->writeback_daemon);
1172 }
1173}
1174
1175static int bitmap_start_daemon(struct bitmap *bitmap, mdk_thread_t **ptr,
1176 void (*func)(mddev_t *), char *name)
1177{
1178 mdk_thread_t *daemon;
1179 unsigned long flags;
1180 char namebuf[32];
1181
1182 spin_lock_irqsave(&bitmap->lock, flags);
1183 *ptr = NULL;
1184
1185 if (!bitmap->file) /* no need for daemon if there's no backing file */
1186 goto out_unlock;
1187
1188 spin_unlock_irqrestore(&bitmap->lock, flags);
1189
1190#if INJECT_FATAL_FAULT_2
1191 daemon = NULL;
1192#else
1193 sprintf(namebuf, "%%s_%s", name);
1194 daemon = md_register_thread(func, bitmap->mddev, namebuf);
1195#endif
1196 if (!daemon) {
1197 printk(KERN_ERR "%s: failed to start bitmap daemon\n",
1198 bmname(bitmap));
1199 return -ECHILD;
1200 }
1201
1202 spin_lock_irqsave(&bitmap->lock, flags);
1203 *ptr = daemon;
1204
1205 md_wakeup_thread(daemon); /* start it running */
1206
1207 PRINTK("%s: %s daemon (pid %d) started...\n",
1208 bmname(bitmap), name, daemon->tsk->pid);
1209out_unlock:
1210 spin_unlock_irqrestore(&bitmap->lock, flags);
1211 return 0;
1212}
1213
1214static int bitmap_start_daemons(struct bitmap *bitmap)
1215{
1216 int err = bitmap_start_daemon(bitmap, &bitmap->writeback_daemon,
1217 bitmap_writeback_daemon, "bitmap_wb");
1218 return err;
1219}
1220
1221static void bitmap_stop_daemon(struct bitmap *bitmap, mdk_thread_t **ptr)
1222{
1223 mdk_thread_t *daemon;
1224 unsigned long flags;
1225
1226 spin_lock_irqsave(&bitmap->lock, flags);
1227 daemon = *ptr;
1228 *ptr = NULL;
1229 spin_unlock_irqrestore(&bitmap->lock, flags);
1230 if (daemon)
1231 md_unregister_thread(daemon); /* destroy the thread */
1232}
1233
1234static void bitmap_stop_daemons(struct bitmap *bitmap)
1235{
1236 /* the daemons can't stop themselves... they'll just exit instead... */
1237 if (bitmap->writeback_daemon &&
1238 current->pid != bitmap->writeback_daemon->tsk->pid)
1239 bitmap_stop_daemon(bitmap, &bitmap->writeback_daemon);
1240}
1241
1242static bitmap_counter_t *bitmap_get_counter(struct bitmap *bitmap,
1243 sector_t offset, int *blocks,
1244 int create)
1245{
1246 /* If 'create', we might release the lock and reclaim it.
1247 * The lock must have been taken with interrupts enabled.
1248 * If !create, we don't release the lock.
1249 */
1250 sector_t chunk = offset >> CHUNK_BLOCK_SHIFT(bitmap);
1251 unsigned long page = chunk >> PAGE_COUNTER_SHIFT;
1252 unsigned long pageoff = (chunk & PAGE_COUNTER_MASK) << COUNTER_BYTE_SHIFT;
1253 sector_t csize;
1254
1255 if (bitmap_checkpage(bitmap, page, create) < 0) {
1256 csize = ((sector_t)1) << (CHUNK_BLOCK_SHIFT(bitmap));
1257 *blocks = csize - (offset & (csize- 1));
1258 return NULL;
1259 }
1260 /* now locked ... */
1261
1262 if (bitmap->bp[page].hijacked) { /* hijacked pointer */
1263 /* should we use the first or second counter field
1264 * of the hijacked pointer? */
1265 int hi = (pageoff > PAGE_COUNTER_MASK);
1266 csize = ((sector_t)1) << (CHUNK_BLOCK_SHIFT(bitmap) +
1267 PAGE_COUNTER_SHIFT - 1);
1268 *blocks = csize - (offset & (csize- 1));
1269 return &((bitmap_counter_t *)
1270 &bitmap->bp[page].map)[hi];
1271 } else { /* page is allocated */
1272 csize = ((sector_t)1) << (CHUNK_BLOCK_SHIFT(bitmap));
1273 *blocks = csize - (offset & (csize- 1));
1274 return (bitmap_counter_t *)
1275 &(bitmap->bp[page].map[pageoff]);
1276 }
1277}
1278
1279int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors)
1280{
1281 if (!bitmap) return 0;
1282 while (sectors) {
1283 int blocks;
1284 bitmap_counter_t *bmc;
1285
1286 spin_lock_irq(&bitmap->lock);
1287 bmc = bitmap_get_counter(bitmap, offset, &blocks, 1);
1288 if (!bmc) {
1289 spin_unlock_irq(&bitmap->lock);
1290 return 0;
1291 }
1292
1293 switch(*bmc) {
1294 case 0:
1295 bitmap_file_set_bit(bitmap, offset);
1296 bitmap_count_page(bitmap,offset, 1);
1297 blk_plug_device(bitmap->mddev->queue);
1298 /* fall through */
1299 case 1:
1300 *bmc = 2;
1301 }
1302 if ((*bmc & COUNTER_MAX) == COUNTER_MAX) BUG();
1303 (*bmc)++;
1304
1305 spin_unlock_irq(&bitmap->lock);
1306
1307 offset += blocks;
1308 if (sectors > blocks)
1309 sectors -= blocks;
1310 else sectors = 0;
1311 }
1312 return 0;
1313}
1314
1315void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors,
1316 int success)
1317{
1318 if (!bitmap) return;
1319 while (sectors) {
1320 int blocks;
1321 unsigned long flags;
1322 bitmap_counter_t *bmc;
1323
1324 spin_lock_irqsave(&bitmap->lock, flags);
1325 bmc = bitmap_get_counter(bitmap, offset, &blocks, 0);
1326 if (!bmc) {
1327 spin_unlock_irqrestore(&bitmap->lock, flags);
1328 return;
1329 }
1330
1331 if (!success && ! (*bmc & NEEDED_MASK))
1332 *bmc |= NEEDED_MASK;
1333
1334 (*bmc)--;
1335 if (*bmc <= 2) {
1336 set_page_attr(bitmap,
1337 filemap_get_page(bitmap, offset >> CHUNK_BLOCK_SHIFT(bitmap)),
1338 BITMAP_PAGE_CLEAN);
1339 }
1340 spin_unlock_irqrestore(&bitmap->lock, flags);
1341 offset += blocks;
1342 if (sectors > blocks)
1343 sectors -= blocks;
1344 else sectors = 0;
1345 }
1346}
1347
1348int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks)
1349{
1350 bitmap_counter_t *bmc;
1351 int rv;
1352 if (bitmap == NULL) {/* FIXME or bitmap set as 'failed' */
1353 *blocks = 1024;
1354 return 1; /* always resync if no bitmap */
1355 }
1356 spin_lock_irq(&bitmap->lock);
1357 bmc = bitmap_get_counter(bitmap, offset, blocks, 0);
1358 rv = 0;
1359 if (bmc) {
1360 /* locked */
1361 if (RESYNC(*bmc))
1362 rv = 1;
1363 else if (NEEDED(*bmc)) {
1364 rv = 1;
1365 *bmc |= RESYNC_MASK;
1366 *bmc &= ~NEEDED_MASK;
1367 }
1368 }
1369 spin_unlock_irq(&bitmap->lock);
1370 return rv;
1371}
1372
1373void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted)
1374{
1375 bitmap_counter_t *bmc;
1376 unsigned long flags;
1377/*
1378 if (offset == 0) printk("bitmap_end_sync 0 (%d)\n", aborted);
1379*/ if (bitmap == NULL) {
1380 *blocks = 1024;
1381 return;
1382 }
1383 spin_lock_irqsave(&bitmap->lock, flags);
1384 bmc = bitmap_get_counter(bitmap, offset, blocks, 0);
1385 if (bmc == NULL)
1386 goto unlock;
1387 /* locked */
1388/*
1389 if (offset == 0) printk("bitmap_end sync found 0x%x, blocks %d\n", *bmc, *blocks);
1390*/
1391 if (RESYNC(*bmc)) {
1392 *bmc &= ~RESYNC_MASK;
1393
1394 if (!NEEDED(*bmc) && aborted)
1395 *bmc |= NEEDED_MASK;
1396 else {
1397 if (*bmc <= 2) {
1398 set_page_attr(bitmap,
1399 filemap_get_page(bitmap, offset >> CHUNK_BLOCK_SHIFT(bitmap)),
1400 BITMAP_PAGE_CLEAN);
1401 }
1402 }
1403 }
1404 unlock:
1405 spin_unlock_irqrestore(&bitmap->lock, flags);
1406}
1407
1408void bitmap_close_sync(struct bitmap *bitmap)
1409{
1410 /* Sync has finished, and any bitmap chunks that weren't synced
1411 * properly have been aborted. It remains to us to clear the
1412 * RESYNC bit wherever it is still on
1413 */
1414 sector_t sector = 0;
1415 int blocks;
1416 if (!bitmap) return;
1417 while (sector < bitmap->mddev->resync_max_sectors) {
1418 bitmap_end_sync(bitmap, sector, &blocks, 0);
1419/*
1420 if (sector < 500) printk("bitmap_close_sync: sec %llu blks %d\n",
1421 (unsigned long long)sector, blocks);
1422*/ sector += blocks;
1423 }
1424}
1425
1426static void bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset,
1427 unsigned long sectors, int in_sync)
1428{
1429 /* For each chunk covered by any of these sectors, set the
1430 * counter to 1 and set resync_needed unless in_sync. They should all
1431 * be 0 at this point
1432 */
1433 while (sectors) {
1434 int secs;
1435 bitmap_counter_t *bmc;
1436 spin_lock_irq(&bitmap->lock);
1437 bmc = bitmap_get_counter(bitmap, offset, &secs, 1);
1438 if (!bmc) {
1439 spin_unlock_irq(&bitmap->lock);
1440 return;
1441 }
1442 if (! *bmc) {
1443 struct page *page;
1444 *bmc = 1 | (in_sync? 0 : NEEDED_MASK);
1445 bitmap_count_page(bitmap, offset, 1);
1446 page = filemap_get_page(bitmap, offset >> CHUNK_BLOCK_SHIFT(bitmap));
1447 set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
1448 }
1449 spin_unlock_irq(&bitmap->lock);
1450 if (sectors > secs)
1451 sectors -= secs;
1452 else
1453 sectors = 0;
1454 }
1455}
1456
1457/*
1458 * free memory that was allocated
1459 */
1460void bitmap_destroy(mddev_t *mddev)
1461{
1462 unsigned long k, pages;
1463 struct bitmap_page *bp;
1464 struct bitmap *bitmap = mddev->bitmap;
1465
1466 if (!bitmap) /* there was no bitmap */
1467 return;
1468
1469 mddev->bitmap = NULL; /* disconnect from the md device */
1470
1471 /* release the bitmap file and kill the daemon */
1472 bitmap_file_put(bitmap);
1473
1474 bp = bitmap->bp;
1475 pages = bitmap->pages;
1476
1477 /* free all allocated memory */
1478
1479 mempool_destroy(bitmap->write_pool);
1480
1481 if (bp) /* deallocate the page memory */
1482 for (k = 0; k < pages; k++)
1483 if (bp[k].map && !bp[k].hijacked)
1484 kfree(bp[k].map);
1485 kfree(bp);
1486 kfree(bitmap);
1487}
1488
1489/*
1490 * initialize the bitmap structure
1491 * if this returns an error, bitmap_destroy must be called to do clean up
1492 */
1493int bitmap_create(mddev_t *mddev)
1494{
1495 struct bitmap *bitmap;
1496 unsigned long blocks = mddev->resync_max_sectors;
1497 unsigned long chunks;
1498 unsigned long pages;
1499 struct file *file = mddev->bitmap_file;
1500 int err;
1501
1502 BUG_ON(sizeof(bitmap_super_t) != 256);
1503
1504 if (!file && !mddev->bitmap_offset) /* bitmap disabled, nothing to do */
1505 return 0;
1506
1507 BUG_ON(file && mddev->bitmap_offset);
1508
1509 bitmap = kmalloc(sizeof(*bitmap), GFP_KERNEL);
1510 if (!bitmap)
1511 return -ENOMEM;
1512
1513 memset(bitmap, 0, sizeof(*bitmap));
1514
1515 spin_lock_init(&bitmap->lock);
1516 bitmap->mddev = mddev;
1517 mddev->bitmap = bitmap;
1518
1519 spin_lock_init(&bitmap->write_lock);
1520 INIT_LIST_HEAD(&bitmap->complete_pages);
1521 init_waitqueue_head(&bitmap->write_wait);
1522 bitmap->write_pool = mempool_create(WRITE_POOL_SIZE, write_pool_alloc,
1523 write_pool_free, NULL);
1524 if (!bitmap->write_pool)
1525 return -ENOMEM;
1526
1527 bitmap->file = file;
1528 bitmap->offset = mddev->bitmap_offset;
1529 if (file) get_file(file);
1530 /* read superblock from bitmap file (this sets bitmap->chunksize) */
1531 err = bitmap_read_sb(bitmap);
1532 if (err)
1533 return err;
1534
1535 bitmap->chunkshift = find_first_bit(&bitmap->chunksize,
1536 sizeof(bitmap->chunksize));
1537
1538 /* now that chunksize and chunkshift are set, we can use these macros */
1539 chunks = (blocks + CHUNK_BLOCK_RATIO(bitmap) - 1) /
1540 CHUNK_BLOCK_RATIO(bitmap);
1541 pages = (chunks + PAGE_COUNTER_RATIO - 1) / PAGE_COUNTER_RATIO;
1542
1543 BUG_ON(!pages);
1544
1545 bitmap->chunks = chunks;
1546 bitmap->pages = pages;
1547 bitmap->missing_pages = pages;
1548 bitmap->counter_bits = COUNTER_BITS;
1549
1550 bitmap->syncchunk = ~0UL;
1551
1552#if INJECT_FATAL_FAULT_1
1553 bitmap->bp = NULL;
1554#else
1555 bitmap->bp = kmalloc(pages * sizeof(*bitmap->bp), GFP_KERNEL);
1556#endif
1557 if (!bitmap->bp)
1558 return -ENOMEM;
1559 memset(bitmap->bp, 0, pages * sizeof(*bitmap->bp));
1560
1561 bitmap->flags |= BITMAP_ACTIVE;
1562
1563 /* now that we have some pages available, initialize the in-memory
1564 * bitmap from the on-disk bitmap */
1565 err = bitmap_init_from_disk(bitmap, mddev->recovery_cp == MaxSector);
1566 if (err)
1567 return err;
1568
1569 printk(KERN_INFO "created bitmap (%lu pages) for device %s\n",
1570 pages, bmname(bitmap));
1571
1572 /* kick off the bitmap daemons */
1573 err = bitmap_start_daemons(bitmap);
1574 if (err)
1575 return err;
1576 return bitmap_update_sb(bitmap);
1577}
1578
1579/* the bitmap API -- for raid personalities */
1580EXPORT_SYMBOL(bitmap_startwrite);
1581EXPORT_SYMBOL(bitmap_endwrite);
1582EXPORT_SYMBOL(bitmap_start_sync);
1583EXPORT_SYMBOL(bitmap_end_sync);
1584EXPORT_SYMBOL(bitmap_unplug);
1585EXPORT_SYMBOL(bitmap_close_sync);
1586EXPORT_SYMBOL(bitmap_daemon_work);
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 0dd6c2b5391b..d0a4bab220e5 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -704,8 +704,7 @@ static void crypt_dtr(struct dm_target *ti)
704 mempool_destroy(cc->page_pool); 704 mempool_destroy(cc->page_pool);
705 mempool_destroy(cc->io_pool); 705 mempool_destroy(cc->io_pool);
706 706
707 if (cc->iv_mode) 707 kfree(cc->iv_mode);
708 kfree(cc->iv_mode);
709 if (cc->iv_gen_ops && cc->iv_gen_ops->dtr) 708 if (cc->iv_gen_ops && cc->iv_gen_ops->dtr)
710 cc->iv_gen_ops->dtr(cc); 709 cc->iv_gen_ops->dtr(cc);
711 crypto_free_tfm(cc->tfm); 710 crypto_free_tfm(cc->tfm);
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index b1941b887f46..8d740013d74d 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -217,8 +217,7 @@ static int linear_run (mddev_t *mddev)
217 return 0; 217 return 0;
218 218
219out: 219out:
220 if (conf) 220 kfree(conf);
221 kfree(conf);
222 return 1; 221 return 1;
223} 222}
224 223
diff --git a/drivers/md/md.c b/drivers/md/md.c
index d899204d3743..0c6b5b6baff6 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -19,6 +19,9 @@
19 19
20 Neil Brown <neilb@cse.unsw.edu.au>. 20 Neil Brown <neilb@cse.unsw.edu.au>.
21 21
22 - persistent bitmap code
23 Copyright (C) 2003-2004, Paul Clements, SteelEye Technology, Inc.
24
22 This program is free software; you can redistribute it and/or modify 25 This program is free software; you can redistribute it and/or modify
23 it under the terms of the GNU General Public License as published by 26 it under the terms of the GNU General Public License as published by
24 the Free Software Foundation; either version 2, or (at your option) 27 the Free Software Foundation; either version 2, or (at your option)
@@ -33,6 +36,7 @@
33#include <linux/config.h> 36#include <linux/config.h>
34#include <linux/linkage.h> 37#include <linux/linkage.h>
35#include <linux/raid/md.h> 38#include <linux/raid/md.h>
39#include <linux/raid/bitmap.h>
36#include <linux/sysctl.h> 40#include <linux/sysctl.h>
37#include <linux/devfs_fs_kernel.h> 41#include <linux/devfs_fs_kernel.h>
38#include <linux/buffer_head.h> /* for invalidate_bdev */ 42#include <linux/buffer_head.h> /* for invalidate_bdev */
@@ -40,6 +44,8 @@
40 44
41#include <linux/init.h> 45#include <linux/init.h>
42 46
47#include <linux/file.h>
48
43#ifdef CONFIG_KMOD 49#ifdef CONFIG_KMOD
44#include <linux/kmod.h> 50#include <linux/kmod.h>
45#endif 51#endif
@@ -189,8 +195,7 @@ static mddev_t * mddev_find(dev_t unit)
189 if (mddev->unit == unit) { 195 if (mddev->unit == unit) {
190 mddev_get(mddev); 196 mddev_get(mddev);
191 spin_unlock(&all_mddevs_lock); 197 spin_unlock(&all_mddevs_lock);
192 if (new) 198 kfree(new);
193 kfree(new);
194 return mddev; 199 return mddev;
195 } 200 }
196 201
@@ -218,6 +223,8 @@ static mddev_t * mddev_find(dev_t unit)
218 INIT_LIST_HEAD(&new->all_mddevs); 223 INIT_LIST_HEAD(&new->all_mddevs);
219 init_timer(&new->safemode_timer); 224 init_timer(&new->safemode_timer);
220 atomic_set(&new->active, 1); 225 atomic_set(&new->active, 1);
226 spin_lock_init(&new->write_lock);
227 init_waitqueue_head(&new->sb_wait);
221 228
222 new->queue = blk_alloc_queue(GFP_KERNEL); 229 new->queue = blk_alloc_queue(GFP_KERNEL);
223 if (!new->queue) { 230 if (!new->queue) {
@@ -320,6 +327,40 @@ static void free_disk_sb(mdk_rdev_t * rdev)
320} 327}
321 328
322 329
330static int super_written(struct bio *bio, unsigned int bytes_done, int error)
331{
332 mdk_rdev_t *rdev = bio->bi_private;
333 if (bio->bi_size)
334 return 1;
335
336 if (error || !test_bit(BIO_UPTODATE, &bio->bi_flags))
337 md_error(rdev->mddev, rdev);
338
339 if (atomic_dec_and_test(&rdev->mddev->pending_writes))
340 wake_up(&rdev->mddev->sb_wait);
341 return 0;
342}
343
344void md_super_write(mddev_t *mddev, mdk_rdev_t *rdev,
345 sector_t sector, int size, struct page *page)
346{
347 /* write first size bytes of page to sector of rdev
348 * Increment mddev->pending_writes before returning
349 * and decrement it on completion, waking up sb_wait
350 * if zero is reached.
351 * If an error occurred, call md_error
352 */
353 struct bio *bio = bio_alloc(GFP_NOIO, 1);
354
355 bio->bi_bdev = rdev->bdev;
356 bio->bi_sector = sector;
357 bio_add_page(bio, page, size, 0);
358 bio->bi_private = rdev;
359 bio->bi_end_io = super_written;
360 atomic_inc(&mddev->pending_writes);
361 submit_bio((1<<BIO_RW)|(1<<BIO_RW_SYNC), bio);
362}
363
323static int bi_complete(struct bio *bio, unsigned int bytes_done, int error) 364static int bi_complete(struct bio *bio, unsigned int bytes_done, int error)
324{ 365{
325 if (bio->bi_size) 366 if (bio->bi_size)
@@ -329,7 +370,7 @@ static int bi_complete(struct bio *bio, unsigned int bytes_done, int error)
329 return 0; 370 return 0;
330} 371}
331 372
332static int sync_page_io(struct block_device *bdev, sector_t sector, int size, 373int sync_page_io(struct block_device *bdev, sector_t sector, int size,
333 struct page *page, int rw) 374 struct page *page, int rw)
334{ 375{
335 struct bio *bio = bio_alloc(GFP_NOIO, 1); 376 struct bio *bio = bio_alloc(GFP_NOIO, 1);
@@ -416,11 +457,8 @@ static int sb_equal(mdp_super_t *sb1, mdp_super_t *sb2)
416 ret = 1; 457 ret = 1;
417 458
418abort: 459abort:
419 if (tmp1) 460 kfree(tmp1);
420 kfree(tmp1); 461 kfree(tmp2);
421 if (tmp2)
422 kfree(tmp2);
423
424 return ret; 462 return ret;
425} 463}
426 464
@@ -569,6 +607,8 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev)
569 mdp_disk_t *desc; 607 mdp_disk_t *desc;
570 mdp_super_t *sb = (mdp_super_t *)page_address(rdev->sb_page); 608 mdp_super_t *sb = (mdp_super_t *)page_address(rdev->sb_page);
571 609
610 rdev->raid_disk = -1;
611 rdev->in_sync = 0;
572 if (mddev->raid_disks == 0) { 612 if (mddev->raid_disks == 0) {
573 mddev->major_version = 0; 613 mddev->major_version = 0;
574 mddev->minor_version = sb->minor_version; 614 mddev->minor_version = sb->minor_version;
@@ -599,16 +639,35 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev)
599 memcpy(mddev->uuid+12,&sb->set_uuid3, 4); 639 memcpy(mddev->uuid+12,&sb->set_uuid3, 4);
600 640
601 mddev->max_disks = MD_SB_DISKS; 641 mddev->max_disks = MD_SB_DISKS;
602 } else { 642
603 __u64 ev1; 643 if (sb->state & (1<<MD_SB_BITMAP_PRESENT) &&
604 ev1 = md_event(sb); 644 mddev->bitmap_file == NULL) {
645 if (mddev->level != 1) {
646 /* FIXME use a better test */
647 printk(KERN_WARNING "md: bitmaps only support for raid1\n");
648 return -EINVAL;
649 }
650 mddev->bitmap_offset = (MD_SB_BYTES >> 9);
651 }
652
653 } else if (mddev->pers == NULL) {
654 /* Insist on good event counter while assembling */
655 __u64 ev1 = md_event(sb);
605 ++ev1; 656 ++ev1;
606 if (ev1 < mddev->events) 657 if (ev1 < mddev->events)
607 return -EINVAL; 658 return -EINVAL;
608 } 659 } else if (mddev->bitmap) {
660 /* if adding to array with a bitmap, then we can accept an
661 * older device ... but not too old.
662 */
663 __u64 ev1 = md_event(sb);
664 if (ev1 < mddev->bitmap->events_cleared)
665 return 0;
666 } else /* just a hot-add of a new device, leave raid_disk at -1 */
667 return 0;
668
609 if (mddev->level != LEVEL_MULTIPATH) { 669 if (mddev->level != LEVEL_MULTIPATH) {
610 rdev->raid_disk = -1; 670 rdev->faulty = 0;
611 rdev->in_sync = rdev->faulty = 0;
612 desc = sb->disks + rdev->desc_nr; 671 desc = sb->disks + rdev->desc_nr;
613 672
614 if (desc->state & (1<<MD_DISK_FAULTY)) 673 if (desc->state & (1<<MD_DISK_FAULTY))
@@ -618,7 +677,8 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev)
618 rdev->in_sync = 1; 677 rdev->in_sync = 1;
619 rdev->raid_disk = desc->raid_disk; 678 rdev->raid_disk = desc->raid_disk;
620 } 679 }
621 } 680 } else /* MULTIPATH are always insync */
681 rdev->in_sync = 1;
622 return 0; 682 return 0;
623} 683}
624 684
@@ -683,6 +743,9 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
683 sb->layout = mddev->layout; 743 sb->layout = mddev->layout;
684 sb->chunk_size = mddev->chunk_size; 744 sb->chunk_size = mddev->chunk_size;
685 745
746 if (mddev->bitmap && mddev->bitmap_file == NULL)
747 sb->state |= (1<<MD_SB_BITMAP_PRESENT);
748
686 sb->disks[0].state = (1<<MD_DISK_REMOVED); 749 sb->disks[0].state = (1<<MD_DISK_REMOVED);
687 ITERATE_RDEV(mddev,rdev2,tmp) { 750 ITERATE_RDEV(mddev,rdev2,tmp) {
688 mdp_disk_t *d; 751 mdp_disk_t *d;
@@ -780,7 +843,7 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
780 case 0: 843 case 0:
781 sb_offset = rdev->bdev->bd_inode->i_size >> 9; 844 sb_offset = rdev->bdev->bd_inode->i_size >> 9;
782 sb_offset -= 8*2; 845 sb_offset -= 8*2;
783 sb_offset &= ~(4*2-1); 846 sb_offset &= ~(sector_t)(4*2-1);
784 /* convert from sectors to K */ 847 /* convert from sectors to K */
785 sb_offset /= 2; 848 sb_offset /= 2;
786 break; 849 break;
@@ -860,6 +923,8 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
860{ 923{
861 struct mdp_superblock_1 *sb = (struct mdp_superblock_1*)page_address(rdev->sb_page); 924 struct mdp_superblock_1 *sb = (struct mdp_superblock_1*)page_address(rdev->sb_page);
862 925
926 rdev->raid_disk = -1;
927 rdev->in_sync = 0;
863 if (mddev->raid_disks == 0) { 928 if (mddev->raid_disks == 0) {
864 mddev->major_version = 1; 929 mddev->major_version = 1;
865 mddev->patch_version = 0; 930 mddev->patch_version = 0;
@@ -877,13 +942,30 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
877 memcpy(mddev->uuid, sb->set_uuid, 16); 942 memcpy(mddev->uuid, sb->set_uuid, 16);
878 943
879 mddev->max_disks = (4096-256)/2; 944 mddev->max_disks = (4096-256)/2;
880 } else { 945
881 __u64 ev1; 946 if ((le32_to_cpu(sb->feature_map) & 1) &&
882 ev1 = le64_to_cpu(sb->events); 947 mddev->bitmap_file == NULL ) {
948 if (mddev->level != 1) {
949 printk(KERN_WARNING "md: bitmaps only supported for raid1\n");
950 return -EINVAL;
951 }
952 mddev->bitmap_offset = (__s32)le32_to_cpu(sb->bitmap_offset);
953 }
954 } else if (mddev->pers == NULL) {
955 /* Insist of good event counter while assembling */
956 __u64 ev1 = le64_to_cpu(sb->events);
883 ++ev1; 957 ++ev1;
884 if (ev1 < mddev->events) 958 if (ev1 < mddev->events)
885 return -EINVAL; 959 return -EINVAL;
886 } 960 } else if (mddev->bitmap) {
961 /* If adding to array with a bitmap, then we can accept an
962 * older device, but not too old.
963 */
964 __u64 ev1 = le64_to_cpu(sb->events);
965 if (ev1 < mddev->bitmap->events_cleared)
966 return 0;
967 } else /* just a hot-add of a new device, leave raid_disk at -1 */
968 return 0;
887 969
888 if (mddev->level != LEVEL_MULTIPATH) { 970 if (mddev->level != LEVEL_MULTIPATH) {
889 int role; 971 int role;
@@ -891,14 +973,10 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
891 role = le16_to_cpu(sb->dev_roles[rdev->desc_nr]); 973 role = le16_to_cpu(sb->dev_roles[rdev->desc_nr]);
892 switch(role) { 974 switch(role) {
893 case 0xffff: /* spare */ 975 case 0xffff: /* spare */
894 rdev->in_sync = 0;
895 rdev->faulty = 0; 976 rdev->faulty = 0;
896 rdev->raid_disk = -1;
897 break; 977 break;
898 case 0xfffe: /* faulty */ 978 case 0xfffe: /* faulty */
899 rdev->in_sync = 0;
900 rdev->faulty = 1; 979 rdev->faulty = 1;
901 rdev->raid_disk = -1;
902 break; 980 break;
903 default: 981 default:
904 rdev->in_sync = 1; 982 rdev->in_sync = 1;
@@ -906,7 +984,9 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
906 rdev->raid_disk = role; 984 rdev->raid_disk = role;
907 break; 985 break;
908 } 986 }
909 } 987 } else /* MULTIPATH are always insync */
988 rdev->in_sync = 1;
989
910 return 0; 990 return 0;
911} 991}
912 992
@@ -933,6 +1013,11 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
933 else 1013 else
934 sb->resync_offset = cpu_to_le64(0); 1014 sb->resync_offset = cpu_to_le64(0);
935 1015
1016 if (mddev->bitmap && mddev->bitmap_file == NULL) {
1017 sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_offset);
1018 sb->feature_map = cpu_to_le32(1);
1019 }
1020
936 max_dev = 0; 1021 max_dev = 0;
937 ITERATE_RDEV(mddev,rdev2,tmp) 1022 ITERATE_RDEV(mddev,rdev2,tmp)
938 if (rdev2->desc_nr+1 > max_dev) 1023 if (rdev2->desc_nr+1 > max_dev)
@@ -1196,8 +1281,11 @@ void md_print_devices(void)
1196 printk("md: * <COMPLETE RAID STATE PRINTOUT> *\n"); 1281 printk("md: * <COMPLETE RAID STATE PRINTOUT> *\n");
1197 printk("md: **********************************\n"); 1282 printk("md: **********************************\n");
1198 ITERATE_MDDEV(mddev,tmp) { 1283 ITERATE_MDDEV(mddev,tmp) {
1199 printk("%s: ", mdname(mddev));
1200 1284
1285 if (mddev->bitmap)
1286 bitmap_print_sb(mddev->bitmap);
1287 else
1288 printk("%s: ", mdname(mddev));
1201 ITERATE_RDEV(mddev,rdev,tmp2) 1289 ITERATE_RDEV(mddev,rdev,tmp2)
1202 printk("<%s>", bdevname(rdev->bdev,b)); 1290 printk("<%s>", bdevname(rdev->bdev,b));
1203 printk("\n"); 1291 printk("\n");
@@ -1210,30 +1298,6 @@ void md_print_devices(void)
1210} 1298}
1211 1299
1212 1300
1213static int write_disk_sb(mdk_rdev_t * rdev)
1214{
1215 char b[BDEVNAME_SIZE];
1216 if (!rdev->sb_loaded) {
1217 MD_BUG();
1218 return 1;
1219 }
1220 if (rdev->faulty) {
1221 MD_BUG();
1222 return 1;
1223 }
1224
1225 dprintk(KERN_INFO "(write) %s's sb offset: %llu\n",
1226 bdevname(rdev->bdev,b),
1227 (unsigned long long)rdev->sb_offset);
1228
1229 if (sync_page_io(rdev->bdev, rdev->sb_offset<<1, MD_SB_BYTES, rdev->sb_page, WRITE))
1230 return 0;
1231
1232 printk("md: write_disk_sb failed for device %s\n",
1233 bdevname(rdev->bdev,b));
1234 return 1;
1235}
1236
1237static void sync_sbs(mddev_t * mddev) 1301static void sync_sbs(mddev_t * mddev)
1238{ 1302{
1239 mdk_rdev_t *rdev; 1303 mdk_rdev_t *rdev;
@@ -1248,12 +1312,14 @@ static void sync_sbs(mddev_t * mddev)
1248 1312
1249static void md_update_sb(mddev_t * mddev) 1313static void md_update_sb(mddev_t * mddev)
1250{ 1314{
1251 int err, count = 100; 1315 int err;
1252 struct list_head *tmp; 1316 struct list_head *tmp;
1253 mdk_rdev_t *rdev; 1317 mdk_rdev_t *rdev;
1318 int sync_req;
1254 1319
1255 mddev->sb_dirty = 0;
1256repeat: 1320repeat:
1321 spin_lock(&mddev->write_lock);
1322 sync_req = mddev->in_sync;
1257 mddev->utime = get_seconds(); 1323 mddev->utime = get_seconds();
1258 mddev->events ++; 1324 mddev->events ++;
1259 1325
@@ -1266,20 +1332,26 @@ repeat:
1266 MD_BUG(); 1332 MD_BUG();
1267 mddev->events --; 1333 mddev->events --;
1268 } 1334 }
1335 mddev->sb_dirty = 2;
1269 sync_sbs(mddev); 1336 sync_sbs(mddev);
1270 1337
1271 /* 1338 /*
1272 * do not write anything to disk if using 1339 * do not write anything to disk if using
1273 * nonpersistent superblocks 1340 * nonpersistent superblocks
1274 */ 1341 */
1275 if (!mddev->persistent) 1342 if (!mddev->persistent) {
1343 mddev->sb_dirty = 0;
1344 spin_unlock(&mddev->write_lock);
1345 wake_up(&mddev->sb_wait);
1276 return; 1346 return;
1347 }
1348 spin_unlock(&mddev->write_lock);
1277 1349
1278 dprintk(KERN_INFO 1350 dprintk(KERN_INFO
1279 "md: updating %s RAID superblock on device (in sync %d)\n", 1351 "md: updating %s RAID superblock on device (in sync %d)\n",
1280 mdname(mddev),mddev->in_sync); 1352 mdname(mddev),mddev->in_sync);
1281 1353
1282 err = 0; 1354 err = bitmap_update_sb(mddev->bitmap);
1283 ITERATE_RDEV(mddev,rdev,tmp) { 1355 ITERATE_RDEV(mddev,rdev,tmp) {
1284 char b[BDEVNAME_SIZE]; 1356 char b[BDEVNAME_SIZE];
1285 dprintk(KERN_INFO "md: "); 1357 dprintk(KERN_INFO "md: ");
@@ -1288,22 +1360,32 @@ repeat:
1288 1360
1289 dprintk("%s ", bdevname(rdev->bdev,b)); 1361 dprintk("%s ", bdevname(rdev->bdev,b));
1290 if (!rdev->faulty) { 1362 if (!rdev->faulty) {
1291 err += write_disk_sb(rdev); 1363 md_super_write(mddev,rdev,
1364 rdev->sb_offset<<1, MD_SB_BYTES,
1365 rdev->sb_page);
1366 dprintk(KERN_INFO "(write) %s's sb offset: %llu\n",
1367 bdevname(rdev->bdev,b),
1368 (unsigned long long)rdev->sb_offset);
1369
1292 } else 1370 } else
1293 dprintk(")\n"); 1371 dprintk(")\n");
1294 if (!err && mddev->level == LEVEL_MULTIPATH) 1372 if (mddev->level == LEVEL_MULTIPATH)
1295 /* only need to write one superblock... */ 1373 /* only need to write one superblock... */
1296 break; 1374 break;
1297 } 1375 }
1298 if (err) { 1376 wait_event(mddev->sb_wait, atomic_read(&mddev->pending_writes)==0);
1299 if (--count) { 1377 /* if there was a failure, sb_dirty was set to 1, and we re-write super */
1300 printk(KERN_ERR "md: errors occurred during superblock" 1378
1301 " update, repeating\n"); 1379 spin_lock(&mddev->write_lock);
1302 goto repeat; 1380 if (mddev->in_sync != sync_req|| mddev->sb_dirty == 1) {
1303 } 1381 /* have to write it out again */
1304 printk(KERN_ERR \ 1382 spin_unlock(&mddev->write_lock);
1305 "md: excessive errors occurred during superblock update, exiting\n"); 1383 goto repeat;
1306 } 1384 }
1385 mddev->sb_dirty = 0;
1386 spin_unlock(&mddev->write_lock);
1387 wake_up(&mddev->sb_wait);
1388
1307} 1389}
1308 1390
1309/* 1391/*
@@ -1607,12 +1689,19 @@ static int do_md_run(mddev_t * mddev)
1607 1689
1608 mddev->resync_max_sectors = mddev->size << 1; /* may be over-ridden by personality */ 1690 mddev->resync_max_sectors = mddev->size << 1; /* may be over-ridden by personality */
1609 1691
1610 err = mddev->pers->run(mddev); 1692 /* before we start the array running, initialise the bitmap */
1693 err = bitmap_create(mddev);
1694 if (err)
1695 printk(KERN_ERR "%s: failed to create bitmap (%d)\n",
1696 mdname(mddev), err);
1697 else
1698 err = mddev->pers->run(mddev);
1611 if (err) { 1699 if (err) {
1612 printk(KERN_ERR "md: pers->run() failed ...\n"); 1700 printk(KERN_ERR "md: pers->run() failed ...\n");
1613 module_put(mddev->pers->owner); 1701 module_put(mddev->pers->owner);
1614 mddev->pers = NULL; 1702 mddev->pers = NULL;
1615 return -EINVAL; 1703 bitmap_destroy(mddev);
1704 return err;
1616 } 1705 }
1617 atomic_set(&mddev->writes_pending,0); 1706 atomic_set(&mddev->writes_pending,0);
1618 mddev->safemode = 0; 1707 mddev->safemode = 0;
@@ -1725,6 +1814,14 @@ static int do_md_stop(mddev_t * mddev, int ro)
1725 if (ro) 1814 if (ro)
1726 set_disk_ro(disk, 1); 1815 set_disk_ro(disk, 1);
1727 } 1816 }
1817
1818 bitmap_destroy(mddev);
1819 if (mddev->bitmap_file) {
1820 atomic_set(&mddev->bitmap_file->f_dentry->d_inode->i_writecount, 1);
1821 fput(mddev->bitmap_file);
1822 mddev->bitmap_file = NULL;
1823 }
1824
1728 /* 1825 /*
1729 * Free resources if final stop 1826 * Free resources if final stop
1730 */ 1827 */
@@ -1983,6 +2080,42 @@ static int get_array_info(mddev_t * mddev, void __user * arg)
1983 return 0; 2080 return 0;
1984} 2081}
1985 2082
2083static int get_bitmap_file(mddev_t * mddev, void * arg)
2084{
2085 mdu_bitmap_file_t *file = NULL; /* too big for stack allocation */
2086 char *ptr, *buf = NULL;
2087 int err = -ENOMEM;
2088
2089 file = kmalloc(sizeof(*file), GFP_KERNEL);
2090 if (!file)
2091 goto out;
2092
2093 /* bitmap disabled, zero the first byte and copy out */
2094 if (!mddev->bitmap || !mddev->bitmap->file) {
2095 file->pathname[0] = '\0';
2096 goto copy_out;
2097 }
2098
2099 buf = kmalloc(sizeof(file->pathname), GFP_KERNEL);
2100 if (!buf)
2101 goto out;
2102
2103 ptr = file_path(mddev->bitmap->file, buf, sizeof(file->pathname));
2104 if (!ptr)
2105 goto out;
2106
2107 strcpy(file->pathname, ptr);
2108
2109copy_out:
2110 err = 0;
2111 if (copy_to_user(arg, file, sizeof(*file)))
2112 err = -EFAULT;
2113out:
2114 kfree(buf);
2115 kfree(file);
2116 return err;
2117}
2118
1986static int get_disk_info(mddev_t * mddev, void __user * arg) 2119static int get_disk_info(mddev_t * mddev, void __user * arg)
1987{ 2120{
1988 mdu_disk_info_t info; 2121 mdu_disk_info_t info;
@@ -2078,11 +2211,25 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
2078 PTR_ERR(rdev)); 2211 PTR_ERR(rdev));
2079 return PTR_ERR(rdev); 2212 return PTR_ERR(rdev);
2080 } 2213 }
2214 /* set save_raid_disk if appropriate */
2215 if (!mddev->persistent) {
2216 if (info->state & (1<<MD_DISK_SYNC) &&
2217 info->raid_disk < mddev->raid_disks)
2218 rdev->raid_disk = info->raid_disk;
2219 else
2220 rdev->raid_disk = -1;
2221 } else
2222 super_types[mddev->major_version].
2223 validate_super(mddev, rdev);
2224 rdev->saved_raid_disk = rdev->raid_disk;
2225
2081 rdev->in_sync = 0; /* just to be sure */ 2226 rdev->in_sync = 0; /* just to be sure */
2082 rdev->raid_disk = -1; 2227 rdev->raid_disk = -1;
2083 err = bind_rdev_to_array(rdev, mddev); 2228 err = bind_rdev_to_array(rdev, mddev);
2084 if (err) 2229 if (err)
2085 export_rdev(rdev); 2230 export_rdev(rdev);
2231
2232 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
2086 if (mddev->thread) 2233 if (mddev->thread)
2087 md_wakeup_thread(mddev->thread); 2234 md_wakeup_thread(mddev->thread);
2088 return err; 2235 return err;
@@ -2256,6 +2403,49 @@ abort_export:
2256 return err; 2403 return err;
2257} 2404}
2258 2405
2406/* similar to deny_write_access, but accounts for our holding a reference
2407 * to the file ourselves */
2408static int deny_bitmap_write_access(struct file * file)
2409{
2410 struct inode *inode = file->f_mapping->host;
2411
2412 spin_lock(&inode->i_lock);
2413 if (atomic_read(&inode->i_writecount) > 1) {
2414 spin_unlock(&inode->i_lock);
2415 return -ETXTBSY;
2416 }
2417 atomic_set(&inode->i_writecount, -1);
2418 spin_unlock(&inode->i_lock);
2419
2420 return 0;
2421}
2422
2423static int set_bitmap_file(mddev_t *mddev, int fd)
2424{
2425 int err;
2426
2427 if (mddev->pers)
2428 return -EBUSY;
2429
2430 mddev->bitmap_file = fget(fd);
2431
2432 if (mddev->bitmap_file == NULL) {
2433 printk(KERN_ERR "%s: error: failed to get bitmap file\n",
2434 mdname(mddev));
2435 return -EBADF;
2436 }
2437
2438 err = deny_bitmap_write_access(mddev->bitmap_file);
2439 if (err) {
2440 printk(KERN_ERR "%s: error: bitmap file is already in use\n",
2441 mdname(mddev));
2442 fput(mddev->bitmap_file);
2443 mddev->bitmap_file = NULL;
2444 } else
2445 mddev->bitmap_offset = 0; /* file overrides offset */
2446 return err;
2447}
2448
2259/* 2449/*
2260 * set_array_info is used two different ways 2450 * set_array_info is used two different ways
2261 * The original usage is when creating a new array. 2451 * The original usage is when creating a new array.
@@ -2567,8 +2757,10 @@ static int md_ioctl(struct inode *inode, struct file *file,
2567 /* 2757 /*
2568 * Commands querying/configuring an existing array: 2758 * Commands querying/configuring an existing array:
2569 */ 2759 */
2570 /* if we are initialised yet, only ADD_NEW_DISK or STOP_ARRAY is allowed */ 2760 /* if we are not initialised yet, only ADD_NEW_DISK, STOP_ARRAY,
2571 if (!mddev->raid_disks && cmd != ADD_NEW_DISK && cmd != STOP_ARRAY && cmd != RUN_ARRAY) { 2761 * RUN_ARRAY, and SET_BITMAP_FILE are allowed */
2762 if (!mddev->raid_disks && cmd != ADD_NEW_DISK && cmd != STOP_ARRAY
2763 && cmd != RUN_ARRAY && cmd != SET_BITMAP_FILE) {
2572 err = -ENODEV; 2764 err = -ENODEV;
2573 goto abort_unlock; 2765 goto abort_unlock;
2574 } 2766 }
@@ -2582,6 +2774,10 @@ static int md_ioctl(struct inode *inode, struct file *file,
2582 err = get_array_info(mddev, argp); 2774 err = get_array_info(mddev, argp);
2583 goto done_unlock; 2775 goto done_unlock;
2584 2776
2777 case GET_BITMAP_FILE:
2778 err = get_bitmap_file(mddev, (void *)arg);
2779 goto done_unlock;
2780
2585 case GET_DISK_INFO: 2781 case GET_DISK_INFO:
2586 err = get_disk_info(mddev, argp); 2782 err = get_disk_info(mddev, argp);
2587 goto done_unlock; 2783 goto done_unlock;
@@ -2662,6 +2858,10 @@ static int md_ioctl(struct inode *inode, struct file *file,
2662 err = do_md_run (mddev); 2858 err = do_md_run (mddev);
2663 goto done_unlock; 2859 goto done_unlock;
2664 2860
2861 case SET_BITMAP_FILE:
2862 err = set_bitmap_file(mddev, (int)arg);
2863 goto done_unlock;
2864
2665 default: 2865 default:
2666 if (_IOC_TYPE(cmd) == MD_MAJOR) 2866 if (_IOC_TYPE(cmd) == MD_MAJOR)
2667 printk(KERN_WARNING "md: %s(pid %d) used" 2867 printk(KERN_WARNING "md: %s(pid %d) used"
@@ -2773,8 +2973,9 @@ static int md_thread(void * arg)
2773 while (thread->run) { 2973 while (thread->run) {
2774 void (*run)(mddev_t *); 2974 void (*run)(mddev_t *);
2775 2975
2776 wait_event_interruptible(thread->wqueue, 2976 wait_event_interruptible_timeout(thread->wqueue,
2777 test_bit(THREAD_WAKEUP, &thread->flags)); 2977 test_bit(THREAD_WAKEUP, &thread->flags),
2978 thread->timeout);
2778 if (current->flags & PF_FREEZE) 2979 if (current->flags & PF_FREEZE)
2779 refrigerator(PF_FREEZE); 2980 refrigerator(PF_FREEZE);
2780 2981
@@ -2820,6 +3021,7 @@ mdk_thread_t *md_register_thread(void (*run) (mddev_t *), mddev_t *mddev,
2820 thread->run = run; 3021 thread->run = run;
2821 thread->mddev = mddev; 3022 thread->mddev = mddev;
2822 thread->name = name; 3023 thread->name = name;
3024 thread->timeout = MAX_SCHEDULE_TIMEOUT;
2823 ret = kernel_thread(md_thread, thread, 0); 3025 ret = kernel_thread(md_thread, thread, 0);
2824 if (ret < 0) { 3026 if (ret < 0) {
2825 kfree(thread); 3027 kfree(thread);
@@ -2858,13 +3060,13 @@ void md_error(mddev_t *mddev, mdk_rdev_t *rdev)
2858 3060
2859 if (!rdev || rdev->faulty) 3061 if (!rdev || rdev->faulty)
2860 return; 3062 return;
2861 3063/*
2862 dprintk("md_error dev:%s, rdev:(%d:%d), (caller: %p,%p,%p,%p).\n", 3064 dprintk("md_error dev:%s, rdev:(%d:%d), (caller: %p,%p,%p,%p).\n",
2863 mdname(mddev), 3065 mdname(mddev),
2864 MAJOR(rdev->bdev->bd_dev), MINOR(rdev->bdev->bd_dev), 3066 MAJOR(rdev->bdev->bd_dev), MINOR(rdev->bdev->bd_dev),
2865 __builtin_return_address(0),__builtin_return_address(1), 3067 __builtin_return_address(0),__builtin_return_address(1),
2866 __builtin_return_address(2),__builtin_return_address(3)); 3068 __builtin_return_address(2),__builtin_return_address(3));
2867 3069*/
2868 if (!mddev->pers->error_handler) 3070 if (!mddev->pers->error_handler)
2869 return; 3071 return;
2870 mddev->pers->error_handler(mddev,rdev); 3072 mddev->pers->error_handler(mddev,rdev);
@@ -3018,6 +3220,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
3018 struct list_head *tmp2; 3220 struct list_head *tmp2;
3019 mdk_rdev_t *rdev; 3221 mdk_rdev_t *rdev;
3020 int i; 3222 int i;
3223 struct bitmap *bitmap;
3021 3224
3022 if (v == (void*)1) { 3225 if (v == (void*)1) {
3023 seq_printf(seq, "Personalities : "); 3226 seq_printf(seq, "Personalities : ");
@@ -3070,10 +3273,35 @@ static int md_seq_show(struct seq_file *seq, void *v)
3070 if (mddev->pers) { 3273 if (mddev->pers) {
3071 mddev->pers->status (seq, mddev); 3274 mddev->pers->status (seq, mddev);
3072 seq_printf(seq, "\n "); 3275 seq_printf(seq, "\n ");
3073 if (mddev->curr_resync > 2) 3276 if (mddev->curr_resync > 2) {
3074 status_resync (seq, mddev); 3277 status_resync (seq, mddev);
3075 else if (mddev->curr_resync == 1 || mddev->curr_resync == 2) 3278 seq_printf(seq, "\n ");
3076 seq_printf(seq, " resync=DELAYED"); 3279 } else if (mddev->curr_resync == 1 || mddev->curr_resync == 2)
3280 seq_printf(seq, " resync=DELAYED\n ");
3281 } else
3282 seq_printf(seq, "\n ");
3283
3284 if ((bitmap = mddev->bitmap)) {
3285 unsigned long chunk_kb;
3286 unsigned long flags;
3287 spin_lock_irqsave(&bitmap->lock, flags);
3288 chunk_kb = bitmap->chunksize >> 10;
3289 seq_printf(seq, "bitmap: %lu/%lu pages [%luKB], "
3290 "%lu%s chunk",
3291 bitmap->pages - bitmap->missing_pages,
3292 bitmap->pages,
3293 (bitmap->pages - bitmap->missing_pages)
3294 << (PAGE_SHIFT - 10),
3295 chunk_kb ? chunk_kb : bitmap->chunksize,
3296 chunk_kb ? "KB" : "B");
3297 if (bitmap->file) {
3298 seq_printf(seq, ", file: ");
3299 seq_path(seq, bitmap->file->f_vfsmnt,
3300 bitmap->file->f_dentry," \t\n");
3301 }
3302
3303 seq_printf(seq, "\n");
3304 spin_unlock_irqrestore(&bitmap->lock, flags);
3077 } 3305 }
3078 3306
3079 seq_printf(seq, "\n"); 3307 seq_printf(seq, "\n");
@@ -3176,19 +3404,28 @@ void md_done_sync(mddev_t *mddev, int blocks, int ok)
3176} 3404}
3177 3405
3178 3406
3179void md_write_start(mddev_t *mddev) 3407/* md_write_start(mddev, bi)
3408 * If we need to update some array metadata (e.g. 'active' flag
3409 * in superblock) before writing, schedule a superblock update
3410 * and wait for it to complete.
3411 */
3412void md_write_start(mddev_t *mddev, struct bio *bi)
3180{ 3413{
3181 if (!atomic_read(&mddev->writes_pending)) { 3414 DEFINE_WAIT(w);
3182 mddev_lock_uninterruptible(mddev); 3415 if (bio_data_dir(bi) != WRITE)
3416 return;
3417
3418 atomic_inc(&mddev->writes_pending);
3419 if (mddev->in_sync) {
3420 spin_lock(&mddev->write_lock);
3183 if (mddev->in_sync) { 3421 if (mddev->in_sync) {
3184 mddev->in_sync = 0; 3422 mddev->in_sync = 0;
3185 del_timer(&mddev->safemode_timer); 3423 mddev->sb_dirty = 1;
3186 md_update_sb(mddev); 3424 md_wakeup_thread(mddev->thread);
3187 } 3425 }
3188 atomic_inc(&mddev->writes_pending); 3426 spin_unlock(&mddev->write_lock);
3189 mddev_unlock(mddev); 3427 }
3190 } else 3428 wait_event(mddev->sb_wait, mddev->sb_dirty==0);
3191 atomic_inc(&mddev->writes_pending);
3192} 3429}
3193 3430
3194void md_write_end(mddev_t *mddev) 3431void md_write_end(mddev_t *mddev)
@@ -3201,37 +3438,6 @@ void md_write_end(mddev_t *mddev)
3201 } 3438 }
3202} 3439}
3203 3440
3204static inline void md_enter_safemode(mddev_t *mddev)
3205{
3206 if (!mddev->safemode) return;
3207 if (mddev->safemode == 2 &&
3208 (atomic_read(&mddev->writes_pending) || mddev->in_sync ||
3209 mddev->recovery_cp != MaxSector))
3210 return; /* avoid the lock */
3211 mddev_lock_uninterruptible(mddev);
3212 if (mddev->safemode && !atomic_read(&mddev->writes_pending) &&
3213 !mddev->in_sync && mddev->recovery_cp == MaxSector) {
3214 mddev->in_sync = 1;
3215 md_update_sb(mddev);
3216 }
3217 mddev_unlock(mddev);
3218
3219 if (mddev->safemode == 1)
3220 mddev->safemode = 0;
3221}
3222
3223void md_handle_safemode(mddev_t *mddev)
3224{
3225 if (signal_pending(current)) {
3226 printk(KERN_INFO "md: %s in immediate safe mode\n",
3227 mdname(mddev));
3228 mddev->safemode = 2;
3229 flush_signals(current);
3230 }
3231 md_enter_safemode(mddev);
3232}
3233
3234
3235static DECLARE_WAIT_QUEUE_HEAD(resync_wait); 3441static DECLARE_WAIT_QUEUE_HEAD(resync_wait);
3236 3442
3237#define SYNC_MARKS 10 3443#define SYNC_MARKS 10
@@ -3241,12 +3447,13 @@ static void md_do_sync(mddev_t *mddev)
3241 mddev_t *mddev2; 3447 mddev_t *mddev2;
3242 unsigned int currspeed = 0, 3448 unsigned int currspeed = 0,
3243 window; 3449 window;
3244 sector_t max_sectors,j; 3450 sector_t max_sectors,j, io_sectors;
3245 unsigned long mark[SYNC_MARKS]; 3451 unsigned long mark[SYNC_MARKS];
3246 sector_t mark_cnt[SYNC_MARKS]; 3452 sector_t mark_cnt[SYNC_MARKS];
3247 int last_mark,m; 3453 int last_mark,m;
3248 struct list_head *tmp; 3454 struct list_head *tmp;
3249 sector_t last_check; 3455 sector_t last_check;
3456 int skipped = 0;
3250 3457
3251 /* just incase thread restarts... */ 3458 /* just incase thread restarts... */
3252 if (test_bit(MD_RECOVERY_DONE, &mddev->recovery)) 3459 if (test_bit(MD_RECOVERY_DONE, &mddev->recovery))
@@ -3312,7 +3519,7 @@ static void md_do_sync(mddev_t *mddev)
3312 3519
3313 if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) 3520 if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery))
3314 /* resync follows the size requested by the personality, 3521 /* resync follows the size requested by the personality,
3315 * which default to physical size, but can be virtual size 3522 * which defaults to physical size, but can be virtual size
3316 */ 3523 */
3317 max_sectors = mddev->resync_max_sectors; 3524 max_sectors = mddev->resync_max_sectors;
3318 else 3525 else
@@ -3327,13 +3534,15 @@ static void md_do_sync(mddev_t *mddev)
3327 sysctl_speed_limit_max); 3534 sysctl_speed_limit_max);
3328 3535
3329 is_mddev_idle(mddev); /* this also initializes IO event counters */ 3536 is_mddev_idle(mddev); /* this also initializes IO event counters */
3330 if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) 3537 /* we don't use the checkpoint if there's a bitmap */
3538 if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery) && !mddev->bitmap)
3331 j = mddev->recovery_cp; 3539 j = mddev->recovery_cp;
3332 else 3540 else
3333 j = 0; 3541 j = 0;
3542 io_sectors = 0;
3334 for (m = 0; m < SYNC_MARKS; m++) { 3543 for (m = 0; m < SYNC_MARKS; m++) {
3335 mark[m] = jiffies; 3544 mark[m] = jiffies;
3336 mark_cnt[m] = j; 3545 mark_cnt[m] = io_sectors;
3337 } 3546 }
3338 last_mark = 0; 3547 last_mark = 0;
3339 mddev->resync_mark = mark[last_mark]; 3548 mddev->resync_mark = mark[last_mark];
@@ -3358,21 +3567,29 @@ static void md_do_sync(mddev_t *mddev)
3358 } 3567 }
3359 3568
3360 while (j < max_sectors) { 3569 while (j < max_sectors) {
3361 int sectors; 3570 sector_t sectors;
3362 3571
3363 sectors = mddev->pers->sync_request(mddev, j, currspeed < sysctl_speed_limit_min); 3572 skipped = 0;
3364 if (sectors < 0) { 3573 sectors = mddev->pers->sync_request(mddev, j, &skipped,
3574 currspeed < sysctl_speed_limit_min);
3575 if (sectors == 0) {
3365 set_bit(MD_RECOVERY_ERR, &mddev->recovery); 3576 set_bit(MD_RECOVERY_ERR, &mddev->recovery);
3366 goto out; 3577 goto out;
3367 } 3578 }
3368 atomic_add(sectors, &mddev->recovery_active); 3579
3580 if (!skipped) { /* actual IO requested */
3581 io_sectors += sectors;
3582 atomic_add(sectors, &mddev->recovery_active);
3583 }
3584
3369 j += sectors; 3585 j += sectors;
3370 if (j>1) mddev->curr_resync = j; 3586 if (j>1) mddev->curr_resync = j;
3371 3587
3372 if (last_check + window > j || j == max_sectors) 3588
3589 if (last_check + window > io_sectors || j == max_sectors)
3373 continue; 3590 continue;
3374 3591
3375 last_check = j; 3592 last_check = io_sectors;
3376 3593
3377 if (test_bit(MD_RECOVERY_INTR, &mddev->recovery) || 3594 if (test_bit(MD_RECOVERY_INTR, &mddev->recovery) ||
3378 test_bit(MD_RECOVERY_ERR, &mddev->recovery)) 3595 test_bit(MD_RECOVERY_ERR, &mddev->recovery))
@@ -3386,7 +3603,7 @@ static void md_do_sync(mddev_t *mddev)
3386 mddev->resync_mark = mark[next]; 3603 mddev->resync_mark = mark[next];
3387 mddev->resync_mark_cnt = mark_cnt[next]; 3604 mddev->resync_mark_cnt = mark_cnt[next];
3388 mark[next] = jiffies; 3605 mark[next] = jiffies;
3389 mark_cnt[next] = j - atomic_read(&mddev->recovery_active); 3606 mark_cnt[next] = io_sectors - atomic_read(&mddev->recovery_active);
3390 last_mark = next; 3607 last_mark = next;
3391 } 3608 }
3392 3609
@@ -3413,7 +3630,8 @@ static void md_do_sync(mddev_t *mddev)
3413 mddev->queue->unplug_fn(mddev->queue); 3630 mddev->queue->unplug_fn(mddev->queue);
3414 cond_resched(); 3631 cond_resched();
3415 3632
3416 currspeed = ((unsigned long)(j-mddev->resync_mark_cnt))/2/((jiffies-mddev->resync_mark)/HZ +1) +1; 3633 currspeed = ((unsigned long)(io_sectors-mddev->resync_mark_cnt))/2
3634 /((jiffies-mddev->resync_mark)/HZ +1) +1;
3417 3635
3418 if (currspeed > sysctl_speed_limit_min) { 3636 if (currspeed > sysctl_speed_limit_min) {
3419 if ((currspeed > sysctl_speed_limit_max) || 3637 if ((currspeed > sysctl_speed_limit_max) ||
@@ -3433,7 +3651,7 @@ static void md_do_sync(mddev_t *mddev)
3433 wait_event(mddev->recovery_wait, !atomic_read(&mddev->recovery_active)); 3651 wait_event(mddev->recovery_wait, !atomic_read(&mddev->recovery_active));
3434 3652
3435 /* tell personality that we are finished */ 3653 /* tell personality that we are finished */
3436 mddev->pers->sync_request(mddev, max_sectors, 1); 3654 mddev->pers->sync_request(mddev, max_sectors, &skipped, 1);
3437 3655
3438 if (!test_bit(MD_RECOVERY_ERR, &mddev->recovery) && 3656 if (!test_bit(MD_RECOVERY_ERR, &mddev->recovery) &&
3439 mddev->curr_resync > 2 && 3657 mddev->curr_resync > 2 &&
@@ -3447,7 +3665,6 @@ static void md_do_sync(mddev_t *mddev)
3447 mddev->recovery_cp = MaxSector; 3665 mddev->recovery_cp = MaxSector;
3448 } 3666 }
3449 3667
3450 md_enter_safemode(mddev);
3451 skip: 3668 skip:
3452 mddev->curr_resync = 0; 3669 mddev->curr_resync = 0;
3453 wake_up(&resync_wait); 3670 wake_up(&resync_wait);
@@ -3484,20 +3701,48 @@ void md_check_recovery(mddev_t *mddev)
3484 struct list_head *rtmp; 3701 struct list_head *rtmp;
3485 3702
3486 3703
3487 dprintk(KERN_INFO "md: recovery thread got woken up ...\n"); 3704 if (mddev->bitmap)
3705 bitmap_daemon_work(mddev->bitmap);
3488 3706
3489 if (mddev->ro) 3707 if (mddev->ro)
3490 return; 3708 return;
3709
3710 if (signal_pending(current)) {
3711 if (mddev->pers->sync_request) {
3712 printk(KERN_INFO "md: %s in immediate safe mode\n",
3713 mdname(mddev));
3714 mddev->safemode = 2;
3715 }
3716 flush_signals(current);
3717 }
3718
3491 if ( ! ( 3719 if ( ! (
3492 mddev->sb_dirty || 3720 mddev->sb_dirty ||
3493 test_bit(MD_RECOVERY_NEEDED, &mddev->recovery) || 3721 test_bit(MD_RECOVERY_NEEDED, &mddev->recovery) ||
3494 test_bit(MD_RECOVERY_DONE, &mddev->recovery) 3722 test_bit(MD_RECOVERY_DONE, &mddev->recovery) ||
3723 (mddev->safemode == 1) ||
3724 (mddev->safemode == 2 && ! atomic_read(&mddev->writes_pending)
3725 && !mddev->in_sync && mddev->recovery_cp == MaxSector)
3495 )) 3726 ))
3496 return; 3727 return;
3728
3497 if (mddev_trylock(mddev)==0) { 3729 if (mddev_trylock(mddev)==0) {
3498 int spares =0; 3730 int spares =0;
3731
3732 spin_lock(&mddev->write_lock);
3733 if (mddev->safemode && !atomic_read(&mddev->writes_pending) &&
3734 !mddev->in_sync && mddev->recovery_cp == MaxSector) {
3735 mddev->in_sync = 1;
3736 mddev->sb_dirty = 1;
3737 }
3738 if (mddev->safemode == 1)
3739 mddev->safemode = 0;
3740 spin_unlock(&mddev->write_lock);
3741
3499 if (mddev->sb_dirty) 3742 if (mddev->sb_dirty)
3500 md_update_sb(mddev); 3743 md_update_sb(mddev);
3744
3745
3501 if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) && 3746 if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) &&
3502 !test_bit(MD_RECOVERY_DONE, &mddev->recovery)) { 3747 !test_bit(MD_RECOVERY_DONE, &mddev->recovery)) {
3503 /* resync/recovery still happening */ 3748 /* resync/recovery still happening */
@@ -3515,6 +3760,14 @@ void md_check_recovery(mddev_t *mddev)
3515 mddev->pers->spare_active(mddev); 3760 mddev->pers->spare_active(mddev);
3516 } 3761 }
3517 md_update_sb(mddev); 3762 md_update_sb(mddev);
3763
3764 /* if array is no-longer degraded, then any saved_raid_disk
3765 * information must be scrapped
3766 */
3767 if (!mddev->degraded)
3768 ITERATE_RDEV(mddev,rdev,rtmp)
3769 rdev->saved_raid_disk = -1;
3770
3518 mddev->recovery = 0; 3771 mddev->recovery = 0;
3519 /* flag recovery needed just to double check */ 3772 /* flag recovery needed just to double check */
3520 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 3773 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
@@ -3557,6 +3810,13 @@ void md_check_recovery(mddev_t *mddev)
3557 set_bit(MD_RECOVERY_RUNNING, &mddev->recovery); 3810 set_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
3558 if (!spares) 3811 if (!spares)
3559 set_bit(MD_RECOVERY_SYNC, &mddev->recovery); 3812 set_bit(MD_RECOVERY_SYNC, &mddev->recovery);
3813 if (spares && mddev->bitmap && ! mddev->bitmap->file) {
3814 /* We are adding a device or devices to an array
3815 * which has the bitmap stored on all devices.
3816 * So make sure all bitmap pages get written
3817 */
3818 bitmap_write_all(mddev->bitmap);
3819 }
3560 mddev->sync_thread = md_register_thread(md_do_sync, 3820 mddev->sync_thread = md_register_thread(md_do_sync,
3561 mddev, 3821 mddev,
3562 "%s_resync"); 3822 "%s_resync");
@@ -3624,6 +3884,8 @@ static int __init md_init(void)
3624 " MD_SB_DISKS=%d\n", 3884 " MD_SB_DISKS=%d\n",
3625 MD_MAJOR_VERSION, MD_MINOR_VERSION, 3885 MD_MAJOR_VERSION, MD_MINOR_VERSION,
3626 MD_PATCHLEVEL_VERSION, MAX_MD_DEVS, MD_SB_DISKS); 3886 MD_PATCHLEVEL_VERSION, MAX_MD_DEVS, MD_SB_DISKS);
3887 printk(KERN_INFO "md: bitmap version %d.%d\n", BITMAP_MAJOR,
3888 BITMAP_MINOR);
3627 3889
3628 if (register_blkdev(MAJOR_NR, "md")) 3890 if (register_blkdev(MAJOR_NR, "md"))
3629 return -1; 3891 return -1;
@@ -3739,7 +4001,6 @@ EXPORT_SYMBOL(md_error);
3739EXPORT_SYMBOL(md_done_sync); 4001EXPORT_SYMBOL(md_done_sync);
3740EXPORT_SYMBOL(md_write_start); 4002EXPORT_SYMBOL(md_write_start);
3741EXPORT_SYMBOL(md_write_end); 4003EXPORT_SYMBOL(md_write_end);
3742EXPORT_SYMBOL(md_handle_safemode);
3743EXPORT_SYMBOL(md_register_thread); 4004EXPORT_SYMBOL(md_register_thread);
3744EXPORT_SYMBOL(md_unregister_thread); 4005EXPORT_SYMBOL(md_unregister_thread);
3745EXPORT_SYMBOL(md_wakeup_thread); 4006EXPORT_SYMBOL(md_wakeup_thread);
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 2ae2d709cb15..2d2ca7fa0265 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -533,8 +533,7 @@ static int multipath_run (mddev_t *mddev)
533out_free_conf: 533out_free_conf:
534 if (conf->pool) 534 if (conf->pool)
535 mempool_destroy(conf->pool); 535 mempool_destroy(conf->pool);
536 if (conf->multipaths) 536 kfree(conf->multipaths);
537 kfree(conf->multipaths);
538 kfree(conf); 537 kfree(conf);
539 mddev->private = NULL; 538 mddev->private = NULL;
540out: 539out:
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index e7d934eca06f..e11dd14d0b43 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -371,10 +371,8 @@ static int raid0_run (mddev_t *mddev)
371 return 0; 371 return 0;
372 372
373out_free_conf: 373out_free_conf:
374 if (conf->strip_zone) 374 kfree(conf->strip_zone);
375 kfree(conf->strip_zone); 375 kfree(conf->devlist);
376 if (conf->devlist)
377 kfree (conf->devlist);
378 kfree(conf); 376 kfree(conf);
379 mddev->private = NULL; 377 mddev->private = NULL;
380out: 378out:
@@ -386,11 +384,11 @@ static int raid0_stop (mddev_t *mddev)
386 raid0_conf_t *conf = mddev_to_conf(mddev); 384 raid0_conf_t *conf = mddev_to_conf(mddev);
387 385
388 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ 386 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
389 kfree (conf->hash_table); 387 kfree(conf->hash_table);
390 conf->hash_table = NULL; 388 conf->hash_table = NULL;
391 kfree (conf->strip_zone); 389 kfree(conf->strip_zone);
392 conf->strip_zone = NULL; 390 conf->strip_zone = NULL;
393 kfree (conf); 391 kfree(conf);
394 mddev->private = NULL; 392 mddev->private = NULL;
395 393
396 return 0; 394 return 0;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 1db5de52d376..ff1dbec864af 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -12,6 +12,15 @@
12 * Fixes to reconstruction by Jakob Østergaard" <jakob@ostenfeld.dk> 12 * Fixes to reconstruction by Jakob Østergaard" <jakob@ostenfeld.dk>
13 * Various fixes by Neil Brown <neilb@cse.unsw.edu.au> 13 * Various fixes by Neil Brown <neilb@cse.unsw.edu.au>
14 * 14 *
15 * Changes by Peter T. Breuer <ptb@it.uc3m.es> 31/1/2003 to support
16 * bitmapped intelligence in resync:
17 *
18 * - bitmap marked during normal i/o
19 * - bitmap used to skip nondirty blocks during sync
20 *
21 * Additions to bitmap code, (C) 2003-2004 Paul Clements, SteelEye Technology:
22 * - persistent bitmap code
23 *
15 * This program is free software; you can redistribute it and/or modify 24 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by 25 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2, or (at your option) 26 * the Free Software Foundation; either version 2, or (at your option)
@@ -22,7 +31,16 @@
22 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 31 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */ 32 */
24 33
34#include "dm-bio-list.h"
25#include <linux/raid/raid1.h> 35#include <linux/raid/raid1.h>
36#include <linux/raid/bitmap.h>
37
38#define DEBUG 0
39#if DEBUG
40#define PRINTK(x...) printk(x)
41#else
42#define PRINTK(x...)
43#endif
26 44
27/* 45/*
28 * Number of guaranteed r1bios in case of extreme VM load: 46 * Number of guaranteed r1bios in case of extreme VM load:
@@ -287,9 +305,11 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
287 /* 305 /*
288 * this branch is our 'one mirror IO has finished' event handler: 306 * this branch is our 'one mirror IO has finished' event handler:
289 */ 307 */
290 if (!uptodate) 308 if (!uptodate) {
291 md_error(r1_bio->mddev, conf->mirrors[mirror].rdev); 309 md_error(r1_bio->mddev, conf->mirrors[mirror].rdev);
292 else 310 /* an I/O failed, we can't clear the bitmap */
311 set_bit(R1BIO_Degraded, &r1_bio->state);
312 } else
293 /* 313 /*
294 * Set R1BIO_Uptodate in our master bio, so that 314 * Set R1BIO_Uptodate in our master bio, so that
295 * we will return a good error code for to the higher 315 * we will return a good error code for to the higher
@@ -309,6 +329,10 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
309 * already. 329 * already.
310 */ 330 */
311 if (atomic_dec_and_test(&r1_bio->remaining)) { 331 if (atomic_dec_and_test(&r1_bio->remaining)) {
332 /* clear the bitmap if all writes complete successfully */
333 bitmap_endwrite(r1_bio->mddev->bitmap, r1_bio->sector,
334 r1_bio->sectors,
335 !test_bit(R1BIO_Degraded, &r1_bio->state));
312 md_write_end(r1_bio->mddev); 336 md_write_end(r1_bio->mddev);
313 raid_end_bio_io(r1_bio); 337 raid_end_bio_io(r1_bio);
314 } 338 }
@@ -458,7 +482,10 @@ static void unplug_slaves(mddev_t *mddev)
458 482
459static void raid1_unplug(request_queue_t *q) 483static void raid1_unplug(request_queue_t *q)
460{ 484{
461 unplug_slaves(q->queuedata); 485 mddev_t *mddev = q->queuedata;
486
487 unplug_slaves(mddev);
488 md_wakeup_thread(mddev->thread);
462} 489}
463 490
464static int raid1_issue_flush(request_queue_t *q, struct gendisk *disk, 491static int raid1_issue_flush(request_queue_t *q, struct gendisk *disk,
@@ -501,16 +528,16 @@ static void device_barrier(conf_t *conf, sector_t sect)
501{ 528{
502 spin_lock_irq(&conf->resync_lock); 529 spin_lock_irq(&conf->resync_lock);
503 wait_event_lock_irq(conf->wait_idle, !waitqueue_active(&conf->wait_resume), 530 wait_event_lock_irq(conf->wait_idle, !waitqueue_active(&conf->wait_resume),
504 conf->resync_lock, unplug_slaves(conf->mddev)); 531 conf->resync_lock, raid1_unplug(conf->mddev->queue));
505 532
506 if (!conf->barrier++) { 533 if (!conf->barrier++) {
507 wait_event_lock_irq(conf->wait_idle, !conf->nr_pending, 534 wait_event_lock_irq(conf->wait_idle, !conf->nr_pending,
508 conf->resync_lock, unplug_slaves(conf->mddev)); 535 conf->resync_lock, raid1_unplug(conf->mddev->queue));
509 if (conf->nr_pending) 536 if (conf->nr_pending)
510 BUG(); 537 BUG();
511 } 538 }
512 wait_event_lock_irq(conf->wait_resume, conf->barrier < RESYNC_DEPTH, 539 wait_event_lock_irq(conf->wait_resume, conf->barrier < RESYNC_DEPTH,
513 conf->resync_lock, unplug_slaves(conf->mddev)); 540 conf->resync_lock, raid1_unplug(conf->mddev->queue));
514 conf->next_resync = sect; 541 conf->next_resync = sect;
515 spin_unlock_irq(&conf->resync_lock); 542 spin_unlock_irq(&conf->resync_lock);
516} 543}
@@ -522,14 +549,20 @@ static int make_request(request_queue_t *q, struct bio * bio)
522 mirror_info_t *mirror; 549 mirror_info_t *mirror;
523 r1bio_t *r1_bio; 550 r1bio_t *r1_bio;
524 struct bio *read_bio; 551 struct bio *read_bio;
525 int i, disks; 552 int i, targets = 0, disks;
526 mdk_rdev_t *rdev; 553 mdk_rdev_t *rdev;
554 struct bitmap *bitmap = mddev->bitmap;
555 unsigned long flags;
556 struct bio_list bl;
557
527 558
528 /* 559 /*
529 * Register the new request and wait if the reconstruction 560 * Register the new request and wait if the reconstruction
530 * thread has put up a bar for new requests. 561 * thread has put up a bar for new requests.
531 * Continue immediately if no resync is active currently. 562 * Continue immediately if no resync is active currently.
532 */ 563 */
564 md_write_start(mddev, bio); /* wait on superblock update early */
565
533 spin_lock_irq(&conf->resync_lock); 566 spin_lock_irq(&conf->resync_lock);
534 wait_event_lock_irq(conf->wait_resume, !conf->barrier, conf->resync_lock, ); 567 wait_event_lock_irq(conf->wait_resume, !conf->barrier, conf->resync_lock, );
535 conf->nr_pending++; 568 conf->nr_pending++;
@@ -552,7 +585,7 @@ static int make_request(request_queue_t *q, struct bio * bio)
552 585
553 r1_bio->master_bio = bio; 586 r1_bio->master_bio = bio;
554 r1_bio->sectors = bio->bi_size >> 9; 587 r1_bio->sectors = bio->bi_size >> 9;
555 588 r1_bio->state = 0;
556 r1_bio->mddev = mddev; 589 r1_bio->mddev = mddev;
557 r1_bio->sector = bio->bi_sector; 590 r1_bio->sector = bio->bi_sector;
558 591
@@ -595,6 +628,13 @@ static int make_request(request_queue_t *q, struct bio * bio)
595 * bios[x] to bio 628 * bios[x] to bio
596 */ 629 */
597 disks = conf->raid_disks; 630 disks = conf->raid_disks;
631#if 0
632 { static int first=1;
633 if (first) printk("First Write sector %llu disks %d\n",
634 (unsigned long long)r1_bio->sector, disks);
635 first = 0;
636 }
637#endif
598 rcu_read_lock(); 638 rcu_read_lock();
599 for (i = 0; i < disks; i++) { 639 for (i = 0; i < disks; i++) {
600 if ((rdev=conf->mirrors[i].rdev) != NULL && 640 if ((rdev=conf->mirrors[i].rdev) != NULL &&
@@ -605,13 +645,21 @@ static int make_request(request_queue_t *q, struct bio * bio)
605 r1_bio->bios[i] = NULL; 645 r1_bio->bios[i] = NULL;
606 } else 646 } else
607 r1_bio->bios[i] = bio; 647 r1_bio->bios[i] = bio;
648 targets++;
608 } else 649 } else
609 r1_bio->bios[i] = NULL; 650 r1_bio->bios[i] = NULL;
610 } 651 }
611 rcu_read_unlock(); 652 rcu_read_unlock();
612 653
613 atomic_set(&r1_bio->remaining, 1); 654 if (targets < conf->raid_disks) {
614 md_write_start(mddev); 655 /* array is degraded, we will not clear the bitmap
656 * on I/O completion (see raid1_end_write_request) */
657 set_bit(R1BIO_Degraded, &r1_bio->state);
658 }
659
660 atomic_set(&r1_bio->remaining, 0);
661
662 bio_list_init(&bl);
615 for (i = 0; i < disks; i++) { 663 for (i = 0; i < disks; i++) {
616 struct bio *mbio; 664 struct bio *mbio;
617 if (!r1_bio->bios[i]) 665 if (!r1_bio->bios[i])
@@ -627,14 +675,23 @@ static int make_request(request_queue_t *q, struct bio * bio)
627 mbio->bi_private = r1_bio; 675 mbio->bi_private = r1_bio;
628 676
629 atomic_inc(&r1_bio->remaining); 677 atomic_inc(&r1_bio->remaining);
630 generic_make_request(mbio);
631 }
632 678
633 if (atomic_dec_and_test(&r1_bio->remaining)) { 679 bio_list_add(&bl, mbio);
634 md_write_end(mddev);
635 raid_end_bio_io(r1_bio);
636 } 680 }
637 681
682 bitmap_startwrite(bitmap, bio->bi_sector, r1_bio->sectors);
683 spin_lock_irqsave(&conf->device_lock, flags);
684 bio_list_merge(&conf->pending_bio_list, &bl);
685 bio_list_init(&bl);
686
687 blk_plug_device(mddev->queue);
688 spin_unlock_irqrestore(&conf->device_lock, flags);
689
690#if 0
691 while ((bio = bio_list_pop(&bl)) != NULL)
692 generic_make_request(bio);
693#endif
694
638 return 0; 695 return 0;
639} 696}
640 697
@@ -714,7 +771,7 @@ static void close_sync(conf_t *conf)
714{ 771{
715 spin_lock_irq(&conf->resync_lock); 772 spin_lock_irq(&conf->resync_lock);
716 wait_event_lock_irq(conf->wait_resume, !conf->barrier, 773 wait_event_lock_irq(conf->wait_resume, !conf->barrier,
717 conf->resync_lock, unplug_slaves(conf->mddev)); 774 conf->resync_lock, raid1_unplug(conf->mddev->queue));
718 spin_unlock_irq(&conf->resync_lock); 775 spin_unlock_irq(&conf->resync_lock);
719 776
720 if (conf->barrier) BUG(); 777 if (conf->barrier) BUG();
@@ -754,9 +811,12 @@ static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
754{ 811{
755 conf_t *conf = mddev->private; 812 conf_t *conf = mddev->private;
756 int found = 0; 813 int found = 0;
757 int mirror; 814 int mirror = 0;
758 mirror_info_t *p; 815 mirror_info_t *p;
759 816
817 if (rdev->saved_raid_disk >= 0 &&
818 conf->mirrors[rdev->saved_raid_disk].rdev == NULL)
819 mirror = rdev->saved_raid_disk;
760 for (mirror=0; mirror < mddev->raid_disks; mirror++) 820 for (mirror=0; mirror < mddev->raid_disks; mirror++)
761 if ( !(p=conf->mirrors+mirror)->rdev) { 821 if ( !(p=conf->mirrors+mirror)->rdev) {
762 822
@@ -773,6 +833,8 @@ static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
773 p->head_position = 0; 833 p->head_position = 0;
774 rdev->raid_disk = mirror; 834 rdev->raid_disk = mirror;
775 found = 1; 835 found = 1;
836 if (rdev->saved_raid_disk != mirror)
837 conf->fullsync = 1;
776 p->rdev = rdev; 838 p->rdev = rdev;
777 break; 839 break;
778 } 840 }
@@ -828,10 +890,11 @@ static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error)
828 * or re-read if the read failed. 890 * or re-read if the read failed.
829 * We don't do much here, just schedule handling by raid1d 891 * We don't do much here, just schedule handling by raid1d
830 */ 892 */
831 if (!uptodate) 893 if (!uptodate) {
832 md_error(r1_bio->mddev, 894 md_error(r1_bio->mddev,
833 conf->mirrors[r1_bio->read_disk].rdev); 895 conf->mirrors[r1_bio->read_disk].rdev);
834 else 896 set_bit(R1BIO_Degraded, &r1_bio->state);
897 } else
835 set_bit(R1BIO_Uptodate, &r1_bio->state); 898 set_bit(R1BIO_Uptodate, &r1_bio->state);
836 rdev_dec_pending(conf->mirrors[r1_bio->read_disk].rdev, conf->mddev); 899 rdev_dec_pending(conf->mirrors[r1_bio->read_disk].rdev, conf->mddev);
837 reschedule_retry(r1_bio); 900 reschedule_retry(r1_bio);
@@ -855,8 +918,10 @@ static int end_sync_write(struct bio *bio, unsigned int bytes_done, int error)
855 mirror = i; 918 mirror = i;
856 break; 919 break;
857 } 920 }
858 if (!uptodate) 921 if (!uptodate) {
859 md_error(mddev, conf->mirrors[mirror].rdev); 922 md_error(mddev, conf->mirrors[mirror].rdev);
923 set_bit(R1BIO_Degraded, &r1_bio->state);
924 }
860 update_head_pos(mirror, r1_bio); 925 update_head_pos(mirror, r1_bio);
861 926
862 if (atomic_dec_and_test(&r1_bio->remaining)) { 927 if (atomic_dec_and_test(&r1_bio->remaining)) {
@@ -876,6 +941,9 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio)
876 941
877 bio = r1_bio->bios[r1_bio->read_disk]; 942 bio = r1_bio->bios[r1_bio->read_disk];
878 943
944/*
945 if (r1_bio->sector == 0) printk("First sync write startss\n");
946*/
879 /* 947 /*
880 * schedule writes 948 * schedule writes
881 */ 949 */
@@ -903,10 +971,12 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio)
903 atomic_inc(&conf->mirrors[i].rdev->nr_pending); 971 atomic_inc(&conf->mirrors[i].rdev->nr_pending);
904 atomic_inc(&r1_bio->remaining); 972 atomic_inc(&r1_bio->remaining);
905 md_sync_acct(conf->mirrors[i].rdev->bdev, wbio->bi_size >> 9); 973 md_sync_acct(conf->mirrors[i].rdev->bdev, wbio->bi_size >> 9);
974
906 generic_make_request(wbio); 975 generic_make_request(wbio);
907 } 976 }
908 977
909 if (atomic_dec_and_test(&r1_bio->remaining)) { 978 if (atomic_dec_and_test(&r1_bio->remaining)) {
979 /* if we're here, all write(s) have completed, so clean up */
910 md_done_sync(mddev, r1_bio->sectors, 1); 980 md_done_sync(mddev, r1_bio->sectors, 1);
911 put_buf(r1_bio); 981 put_buf(r1_bio);
912 } 982 }
@@ -931,11 +1001,30 @@ static void raid1d(mddev_t *mddev)
931 mdk_rdev_t *rdev; 1001 mdk_rdev_t *rdev;
932 1002
933 md_check_recovery(mddev); 1003 md_check_recovery(mddev);
934 md_handle_safemode(mddev);
935 1004
936 for (;;) { 1005 for (;;) {
937 char b[BDEVNAME_SIZE]; 1006 char b[BDEVNAME_SIZE];
938 spin_lock_irqsave(&conf->device_lock, flags); 1007 spin_lock_irqsave(&conf->device_lock, flags);
1008
1009 if (conf->pending_bio_list.head) {
1010 bio = bio_list_get(&conf->pending_bio_list);
1011 blk_remove_plug(mddev->queue);
1012 spin_unlock_irqrestore(&conf->device_lock, flags);
1013 /* flush any pending bitmap writes to disk before proceeding w/ I/O */
1014 if (bitmap_unplug(mddev->bitmap) != 0)
1015 printk("%s: bitmap file write failed!\n", mdname(mddev));
1016
1017 while (bio) { /* submit pending writes */
1018 struct bio *next = bio->bi_next;
1019 bio->bi_next = NULL;
1020 generic_make_request(bio);
1021 bio = next;
1022 }
1023 unplug = 1;
1024
1025 continue;
1026 }
1027
939 if (list_empty(head)) 1028 if (list_empty(head))
940 break; 1029 break;
941 r1_bio = list_entry(head->prev, r1bio_t, retry_list); 1030 r1_bio = list_entry(head->prev, r1bio_t, retry_list);
@@ -1009,7 +1098,7 @@ static int init_resync(conf_t *conf)
1009 * that can be installed to exclude normal IO requests. 1098 * that can be installed to exclude normal IO requests.
1010 */ 1099 */
1011 1100
1012static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster) 1101static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, int go_faster)
1013{ 1102{
1014 conf_t *conf = mddev_to_conf(mddev); 1103 conf_t *conf = mddev_to_conf(mddev);
1015 mirror_info_t *mirror; 1104 mirror_info_t *mirror;
@@ -1019,17 +1108,43 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster)
1019 int disk; 1108 int disk;
1020 int i; 1109 int i;
1021 int write_targets = 0; 1110 int write_targets = 0;
1111 int sync_blocks;
1022 1112
1023 if (!conf->r1buf_pool) 1113 if (!conf->r1buf_pool)
1114 {
1115/*
1116 printk("sync start - bitmap %p\n", mddev->bitmap);
1117*/
1024 if (init_resync(conf)) 1118 if (init_resync(conf))
1025 return -ENOMEM; 1119 return 0;
1120 }
1026 1121
1027 max_sector = mddev->size << 1; 1122 max_sector = mddev->size << 1;
1028 if (sector_nr >= max_sector) { 1123 if (sector_nr >= max_sector) {
1124 /* If we aborted, we need to abort the
1125 * sync on the 'current' bitmap chunk (there will
1126 * only be one in raid1 resync.
1127 * We can find the current addess in mddev->curr_resync
1128 */
1129 if (!conf->fullsync) {
1130 if (mddev->curr_resync < max_sector)
1131 bitmap_end_sync(mddev->bitmap,
1132 mddev->curr_resync,
1133 &sync_blocks, 1);
1134 bitmap_close_sync(mddev->bitmap);
1135 }
1136 if (mddev->curr_resync >= max_sector)
1137 conf->fullsync = 0;
1029 close_sync(conf); 1138 close_sync(conf);
1030 return 0; 1139 return 0;
1031 } 1140 }
1032 1141
1142 if (!conf->fullsync &&
1143 !bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks)) {
1144 /* We can skip this block, and probably several more */
1145 *skipped = 1;
1146 return sync_blocks;
1147 }
1033 /* 1148 /*
1034 * If there is non-resync activity waiting for us then 1149 * If there is non-resync activity waiting for us then
1035 * put in a delay to throttle resync. 1150 * put in a delay to throttle resync.
@@ -1068,6 +1183,7 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster)
1068 1183
1069 r1_bio->mddev = mddev; 1184 r1_bio->mddev = mddev;
1070 r1_bio->sector = sector_nr; 1185 r1_bio->sector = sector_nr;
1186 r1_bio->state = 0;
1071 set_bit(R1BIO_IsSync, &r1_bio->state); 1187 set_bit(R1BIO_IsSync, &r1_bio->state);
1072 r1_bio->read_disk = disk; 1188 r1_bio->read_disk = disk;
1073 1189
@@ -1102,18 +1218,24 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster)
1102 bio->bi_bdev = conf->mirrors[i].rdev->bdev; 1218 bio->bi_bdev = conf->mirrors[i].rdev->bdev;
1103 bio->bi_private = r1_bio; 1219 bio->bi_private = r1_bio;
1104 } 1220 }
1221
1222 if (write_targets + 1 < conf->raid_disks)
1223 /* array degraded, can't clear bitmap */
1224 set_bit(R1BIO_Degraded, &r1_bio->state);
1225
1105 if (write_targets == 0) { 1226 if (write_targets == 0) {
1106 /* There is nowhere to write, so all non-sync 1227 /* There is nowhere to write, so all non-sync
1107 * drives must be failed - so we are finished 1228 * drives must be failed - so we are finished
1108 */ 1229 */
1109 int rv = max_sector - sector_nr; 1230 sector_t rv = max_sector - sector_nr;
1110 md_done_sync(mddev, rv, 1); 1231 *skipped = 1;
1111 put_buf(r1_bio); 1232 put_buf(r1_bio);
1112 rdev_dec_pending(conf->mirrors[disk].rdev, mddev); 1233 rdev_dec_pending(conf->mirrors[disk].rdev, mddev);
1113 return rv; 1234 return rv;
1114 } 1235 }
1115 1236
1116 nr_sectors = 0; 1237 nr_sectors = 0;
1238 sync_blocks = 0;
1117 do { 1239 do {
1118 struct page *page; 1240 struct page *page;
1119 int len = PAGE_SIZE; 1241 int len = PAGE_SIZE;
@@ -1121,6 +1243,17 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster)
1121 len = (max_sector - sector_nr) << 9; 1243 len = (max_sector - sector_nr) << 9;
1122 if (len == 0) 1244 if (len == 0)
1123 break; 1245 break;
1246 if (!conf->fullsync) {
1247 if (sync_blocks == 0) {
1248 if (!bitmap_start_sync(mddev->bitmap,
1249 sector_nr, &sync_blocks))
1250 break;
1251 if (sync_blocks < (PAGE_SIZE>>9))
1252 BUG();
1253 if (len > (sync_blocks<<9)) len = sync_blocks<<9;
1254 }
1255 }
1256
1124 for (i=0 ; i < conf->raid_disks; i++) { 1257 for (i=0 ; i < conf->raid_disks; i++) {
1125 bio = r1_bio->bios[i]; 1258 bio = r1_bio->bios[i];
1126 if (bio->bi_end_io) { 1259 if (bio->bi_end_io) {
@@ -1143,6 +1276,7 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster)
1143 } 1276 }
1144 nr_sectors += len>>9; 1277 nr_sectors += len>>9;
1145 sector_nr += len>>9; 1278 sector_nr += len>>9;
1279 sync_blocks -= (len>>9);
1146 } while (r1_bio->bios[disk]->bi_vcnt < RESYNC_PAGES); 1280 } while (r1_bio->bios[disk]->bi_vcnt < RESYNC_PAGES);
1147 bio_full: 1281 bio_full:
1148 bio = r1_bio->bios[disk]; 1282 bio = r1_bio->bios[disk];
@@ -1231,6 +1365,9 @@ static int run(mddev_t *mddev)
1231 init_waitqueue_head(&conf->wait_idle); 1365 init_waitqueue_head(&conf->wait_idle);
1232 init_waitqueue_head(&conf->wait_resume); 1366 init_waitqueue_head(&conf->wait_resume);
1233 1367
1368 bio_list_init(&conf->pending_bio_list);
1369 bio_list_init(&conf->flushing_bio_list);
1370
1234 if (!conf->working_disks) { 1371 if (!conf->working_disks) {
1235 printk(KERN_ERR "raid1: no operational mirrors for %s\n", 1372 printk(KERN_ERR "raid1: no operational mirrors for %s\n",
1236 mdname(mddev)); 1373 mdname(mddev));
@@ -1259,16 +1396,15 @@ static int run(mddev_t *mddev)
1259 conf->last_used = j; 1396 conf->last_used = j;
1260 1397
1261 1398
1262 1399 mddev->thread = md_register_thread(raid1d, mddev, "%s_raid1");
1263 { 1400 if (!mddev->thread) {
1264 mddev->thread = md_register_thread(raid1d, mddev, "%s_raid1"); 1401 printk(KERN_ERR
1265 if (!mddev->thread) { 1402 "raid1: couldn't allocate thread for %s\n",
1266 printk(KERN_ERR 1403 mdname(mddev));
1267 "raid1: couldn't allocate thread for %s\n", 1404 goto out_free_conf;
1268 mdname(mddev));
1269 goto out_free_conf;
1270 }
1271 } 1405 }
1406 if (mddev->bitmap) mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
1407
1272 printk(KERN_INFO 1408 printk(KERN_INFO
1273 "raid1: raid set %s active with %d out of %d mirrors\n", 1409 "raid1: raid set %s active with %d out of %d mirrors\n",
1274 mdname(mddev), mddev->raid_disks - mddev->degraded, 1410 mdname(mddev), mddev->raid_disks - mddev->degraded,
@@ -1291,10 +1427,8 @@ out_free_conf:
1291 if (conf) { 1427 if (conf) {
1292 if (conf->r1bio_pool) 1428 if (conf->r1bio_pool)
1293 mempool_destroy(conf->r1bio_pool); 1429 mempool_destroy(conf->r1bio_pool);
1294 if (conf->mirrors) 1430 kfree(conf->mirrors);
1295 kfree(conf->mirrors); 1431 kfree(conf->poolinfo);
1296 if (conf->poolinfo)
1297 kfree(conf->poolinfo);
1298 kfree(conf); 1432 kfree(conf);
1299 mddev->private = NULL; 1433 mddev->private = NULL;
1300 } 1434 }
@@ -1311,10 +1445,8 @@ static int stop(mddev_t *mddev)
1311 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ 1445 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
1312 if (conf->r1bio_pool) 1446 if (conf->r1bio_pool)
1313 mempool_destroy(conf->r1bio_pool); 1447 mempool_destroy(conf->r1bio_pool);
1314 if (conf->mirrors) 1448 kfree(conf->mirrors);
1315 kfree(conf->mirrors); 1449 kfree(conf->poolinfo);
1316 if (conf->poolinfo)
1317 kfree(conf->poolinfo);
1318 kfree(conf); 1450 kfree(conf);
1319 mddev->private = NULL; 1451 mddev->private = NULL;
1320 return 0; 1452 return 0;
@@ -1349,17 +1481,26 @@ static int raid1_reshape(mddev_t *mddev, int raid_disks)
1349 * We allocate a new r1bio_pool if we can. 1481 * We allocate a new r1bio_pool if we can.
1350 * Then raise a device barrier and wait until all IO stops. 1482 * Then raise a device barrier and wait until all IO stops.
1351 * Then resize conf->mirrors and swap in the new r1bio pool. 1483 * Then resize conf->mirrors and swap in the new r1bio pool.
1484 *
1485 * At the same time, we "pack" the devices so that all the missing
1486 * devices have the higher raid_disk numbers.
1352 */ 1487 */
1353 mempool_t *newpool, *oldpool; 1488 mempool_t *newpool, *oldpool;
1354 struct pool_info *newpoolinfo; 1489 struct pool_info *newpoolinfo;
1355 mirror_info_t *newmirrors; 1490 mirror_info_t *newmirrors;
1356 conf_t *conf = mddev_to_conf(mddev); 1491 conf_t *conf = mddev_to_conf(mddev);
1492 int cnt;
1357 1493
1358 int d; 1494 int d, d2;
1359 1495
1360 for (d= raid_disks; d < conf->raid_disks; d++) 1496 if (raid_disks < conf->raid_disks) {
1361 if (conf->mirrors[d].rdev) 1497 cnt=0;
1498 for (d= 0; d < conf->raid_disks; d++)
1499 if (conf->mirrors[d].rdev)
1500 cnt++;
1501 if (cnt > raid_disks)
1362 return -EBUSY; 1502 return -EBUSY;
1503 }
1363 1504
1364 newpoolinfo = kmalloc(sizeof(*newpoolinfo), GFP_KERNEL); 1505 newpoolinfo = kmalloc(sizeof(*newpoolinfo), GFP_KERNEL);
1365 if (!newpoolinfo) 1506 if (!newpoolinfo)
@@ -1384,14 +1525,18 @@ static int raid1_reshape(mddev_t *mddev, int raid_disks)
1384 spin_lock_irq(&conf->resync_lock); 1525 spin_lock_irq(&conf->resync_lock);
1385 conf->barrier++; 1526 conf->barrier++;
1386 wait_event_lock_irq(conf->wait_idle, !conf->nr_pending, 1527 wait_event_lock_irq(conf->wait_idle, !conf->nr_pending,
1387 conf->resync_lock, unplug_slaves(mddev)); 1528 conf->resync_lock, raid1_unplug(mddev->queue));
1388 spin_unlock_irq(&conf->resync_lock); 1529 spin_unlock_irq(&conf->resync_lock);
1389 1530
1390 /* ok, everything is stopped */ 1531 /* ok, everything is stopped */
1391 oldpool = conf->r1bio_pool; 1532 oldpool = conf->r1bio_pool;
1392 conf->r1bio_pool = newpool; 1533 conf->r1bio_pool = newpool;
1393 for (d=0; d < raid_disks && d < conf->raid_disks; d++) 1534
1394 newmirrors[d] = conf->mirrors[d]; 1535 for (d=d2=0; d < conf->raid_disks; d++)
1536 if (conf->mirrors[d].rdev) {
1537 conf->mirrors[d].rdev->raid_disk = d2;
1538 newmirrors[d2++].rdev = conf->mirrors[d].rdev;
1539 }
1395 kfree(conf->mirrors); 1540 kfree(conf->mirrors);
1396 conf->mirrors = newmirrors; 1541 conf->mirrors = newmirrors;
1397 kfree(conf->poolinfo); 1542 kfree(conf->poolinfo);
@@ -1400,6 +1545,7 @@ static int raid1_reshape(mddev_t *mddev, int raid_disks)
1400 mddev->degraded += (raid_disks - conf->raid_disks); 1545 mddev->degraded += (raid_disks - conf->raid_disks);
1401 conf->raid_disks = mddev->raid_disks = raid_disks; 1546 conf->raid_disks = mddev->raid_disks = raid_disks;
1402 1547
1548 conf->last_used = 0; /* just make sure it is in-range */
1403 spin_lock_irq(&conf->resync_lock); 1549 spin_lock_irq(&conf->resync_lock);
1404 conf->barrier--; 1550 conf->barrier--;
1405 spin_unlock_irq(&conf->resync_lock); 1551 spin_unlock_irq(&conf->resync_lock);
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 3c37be6423d7..62ebb1bc72be 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -700,6 +700,8 @@ static int make_request(request_queue_t *q, struct bio * bio)
700 return 0; 700 return 0;
701 } 701 }
702 702
703 md_write_start(mddev, bio);
704
703 /* 705 /*
704 * Register the new request and wait if the reconstruction 706 * Register the new request and wait if the reconstruction
705 * thread has put up a bar for new requests. 707 * thread has put up a bar for new requests.
@@ -774,7 +776,7 @@ static int make_request(request_queue_t *q, struct bio * bio)
774 rcu_read_unlock(); 776 rcu_read_unlock();
775 777
776 atomic_set(&r10_bio->remaining, 1); 778 atomic_set(&r10_bio->remaining, 1);
777 md_write_start(mddev); 779
778 for (i = 0; i < conf->copies; i++) { 780 for (i = 0; i < conf->copies; i++) {
779 struct bio *mbio; 781 struct bio *mbio;
780 int d = r10_bio->devs[i].devnum; 782 int d = r10_bio->devs[i].devnum;
@@ -1216,7 +1218,6 @@ static void raid10d(mddev_t *mddev)
1216 mdk_rdev_t *rdev; 1218 mdk_rdev_t *rdev;
1217 1219
1218 md_check_recovery(mddev); 1220 md_check_recovery(mddev);
1219 md_handle_safemode(mddev);
1220 1221
1221 for (;;) { 1222 for (;;) {
1222 char b[BDEVNAME_SIZE]; 1223 char b[BDEVNAME_SIZE];
@@ -1319,7 +1320,7 @@ static int init_resync(conf_t *conf)
1319 * 1320 *
1320 */ 1321 */
1321 1322
1322static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster) 1323static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, int go_faster)
1323{ 1324{
1324 conf_t *conf = mddev_to_conf(mddev); 1325 conf_t *conf = mddev_to_conf(mddev);
1325 r10bio_t *r10_bio; 1326 r10bio_t *r10_bio;
@@ -1333,7 +1334,7 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster)
1333 1334
1334 if (!conf->r10buf_pool) 1335 if (!conf->r10buf_pool)
1335 if (init_resync(conf)) 1336 if (init_resync(conf))
1336 return -ENOMEM; 1337 return 0;
1337 1338
1338 skipped: 1339 skipped:
1339 max_sector = mddev->size << 1; 1340 max_sector = mddev->size << 1;
@@ -1341,15 +1342,15 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster)
1341 max_sector = mddev->resync_max_sectors; 1342 max_sector = mddev->resync_max_sectors;
1342 if (sector_nr >= max_sector) { 1343 if (sector_nr >= max_sector) {
1343 close_sync(conf); 1344 close_sync(conf);
1345 *skipped = 1;
1344 return sectors_skipped; 1346 return sectors_skipped;
1345 } 1347 }
1346 if (chunks_skipped >= conf->raid_disks) { 1348 if (chunks_skipped >= conf->raid_disks) {
1347 /* if there has been nothing to do on any drive, 1349 /* if there has been nothing to do on any drive,
1348 * then there is nothing to do at all.. 1350 * then there is nothing to do at all..
1349 */ 1351 */
1350 sector_t sec = max_sector - sector_nr; 1352 *skipped = 1;
1351 md_done_sync(mddev, sec, 1); 1353 return (max_sector - sector_nr) + sectors_skipped;
1352 return sec + sectors_skipped;
1353 } 1354 }
1354 1355
1355 /* make sure whole request will fit in a chunk - if chunks 1356 /* make sure whole request will fit in a chunk - if chunks
@@ -1563,17 +1564,22 @@ static int sync_request(mddev_t *mddev, sector_t sector_nr, int go_faster)
1563 } 1564 }
1564 } 1565 }
1565 1566
1567 if (sectors_skipped)
1568 /* pretend they weren't skipped, it makes
1569 * no important difference in this case
1570 */
1571 md_done_sync(mddev, sectors_skipped, 1);
1572
1566 return sectors_skipped + nr_sectors; 1573 return sectors_skipped + nr_sectors;
1567 giveup: 1574 giveup:
1568 /* There is nowhere to write, so all non-sync 1575 /* There is nowhere to write, so all non-sync
1569 * drives must be failed, so try the next chunk... 1576 * drives must be failed, so try the next chunk...
1570 */ 1577 */
1571 { 1578 {
1572 int sec = max_sector - sector_nr; 1579 sector_t sec = max_sector - sector_nr;
1573 sectors_skipped += sec; 1580 sectors_skipped += sec;
1574 chunks_skipped ++; 1581 chunks_skipped ++;
1575 sector_nr = max_sector; 1582 sector_nr = max_sector;
1576 md_done_sync(mddev, sec, 1);
1577 goto skipped; 1583 goto skipped;
1578 } 1584 }
1579} 1585}
@@ -1731,8 +1737,7 @@ static int run(mddev_t *mddev)
1731out_free_conf: 1737out_free_conf:
1732 if (conf->r10bio_pool) 1738 if (conf->r10bio_pool)
1733 mempool_destroy(conf->r10bio_pool); 1739 mempool_destroy(conf->r10bio_pool);
1734 if (conf->mirrors) 1740 kfree(conf->mirrors);
1735 kfree(conf->mirrors);
1736 kfree(conf); 1741 kfree(conf);
1737 mddev->private = NULL; 1742 mddev->private = NULL;
1738out: 1743out:
@@ -1748,8 +1753,7 @@ static int stop(mddev_t *mddev)
1748 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ 1753 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
1749 if (conf->r10bio_pool) 1754 if (conf->r10bio_pool)
1750 mempool_destroy(conf->r10bio_pool); 1755 mempool_destroy(conf->r10bio_pool);
1751 if (conf->mirrors) 1756 kfree(conf->mirrors);
1752 kfree(conf->mirrors);
1753 kfree(conf); 1757 kfree(conf);
1754 mddev->private = NULL; 1758 mddev->private = NULL;
1755 return 0; 1759 return 0;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 3cb11ac232fa..93a9726cc2d6 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1411,6 +1411,8 @@ static int make_request (request_queue_t *q, struct bio * bi)
1411 sector_t logical_sector, last_sector; 1411 sector_t logical_sector, last_sector;
1412 struct stripe_head *sh; 1412 struct stripe_head *sh;
1413 1413
1414 md_write_start(mddev, bi);
1415
1414 if (bio_data_dir(bi)==WRITE) { 1416 if (bio_data_dir(bi)==WRITE) {
1415 disk_stat_inc(mddev->gendisk, writes); 1417 disk_stat_inc(mddev->gendisk, writes);
1416 disk_stat_add(mddev->gendisk, write_sectors, bio_sectors(bi)); 1418 disk_stat_add(mddev->gendisk, write_sectors, bio_sectors(bi));
@@ -1423,8 +1425,7 @@ static int make_request (request_queue_t *q, struct bio * bi)
1423 last_sector = bi->bi_sector + (bi->bi_size>>9); 1425 last_sector = bi->bi_sector + (bi->bi_size>>9);
1424 bi->bi_next = NULL; 1426 bi->bi_next = NULL;
1425 bi->bi_phys_segments = 1; /* over-loaded to count active stripes */ 1427 bi->bi_phys_segments = 1; /* over-loaded to count active stripes */
1426 if ( bio_data_dir(bi) == WRITE ) 1428
1427 md_write_start(mddev);
1428 for (;logical_sector < last_sector; logical_sector += STRIPE_SECTORS) { 1429 for (;logical_sector < last_sector; logical_sector += STRIPE_SECTORS) {
1429 DEFINE_WAIT(w); 1430 DEFINE_WAIT(w);
1430 1431
@@ -1475,7 +1476,7 @@ static int make_request (request_queue_t *q, struct bio * bi)
1475} 1476}
1476 1477
1477/* FIXME go_faster isn't used */ 1478/* FIXME go_faster isn't used */
1478static int sync_request (mddev_t *mddev, sector_t sector_nr, int go_faster) 1479static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, int go_faster)
1479{ 1480{
1480 raid5_conf_t *conf = (raid5_conf_t *) mddev->private; 1481 raid5_conf_t *conf = (raid5_conf_t *) mddev->private;
1481 struct stripe_head *sh; 1482 struct stripe_head *sh;
@@ -1498,8 +1499,8 @@ static int sync_request (mddev_t *mddev, sector_t sector_nr, int go_faster)
1498 * nothing we can do. 1499 * nothing we can do.
1499 */ 1500 */
1500 if (mddev->degraded >= 1 && test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) { 1501 if (mddev->degraded >= 1 && test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) {
1501 int rv = (mddev->size << 1) - sector_nr; 1502 sector_t rv = (mddev->size << 1) - sector_nr;
1502 md_done_sync(mddev, rv, 1); 1503 *skipped = 1;
1503 return rv; 1504 return rv;
1504 } 1505 }
1505 1506
@@ -1546,7 +1547,6 @@ static void raid5d (mddev_t *mddev)
1546 PRINTK("+++ raid5d active\n"); 1547 PRINTK("+++ raid5d active\n");
1547 1548
1548 md_check_recovery(mddev); 1549 md_check_recovery(mddev);
1549 md_handle_safemode(mddev);
1550 1550
1551 handled = 0; 1551 handled = 0;
1552 spin_lock_irq(&conf->device_lock); 1552 spin_lock_irq(&conf->device_lock);
diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c
index 908edd78a792..f62ea1a73d0d 100644
--- a/drivers/md/raid6main.c
+++ b/drivers/md/raid6main.c
@@ -1570,6 +1570,8 @@ static int make_request (request_queue_t *q, struct bio * bi)
1570 sector_t logical_sector, last_sector; 1570 sector_t logical_sector, last_sector;
1571 struct stripe_head *sh; 1571 struct stripe_head *sh;
1572 1572
1573 md_write_start(mddev, bi);
1574
1573 if (bio_data_dir(bi)==WRITE) { 1575 if (bio_data_dir(bi)==WRITE) {
1574 disk_stat_inc(mddev->gendisk, writes); 1576 disk_stat_inc(mddev->gendisk, writes);
1575 disk_stat_add(mddev->gendisk, write_sectors, bio_sectors(bi)); 1577 disk_stat_add(mddev->gendisk, write_sectors, bio_sectors(bi));
@@ -1583,8 +1585,7 @@ static int make_request (request_queue_t *q, struct bio * bi)
1583 1585
1584 bi->bi_next = NULL; 1586 bi->bi_next = NULL;
1585 bi->bi_phys_segments = 1; /* over-loaded to count active stripes */ 1587 bi->bi_phys_segments = 1; /* over-loaded to count active stripes */
1586 if ( bio_data_dir(bi) == WRITE ) 1588
1587 md_write_start(mddev);
1588 for (;logical_sector < last_sector; logical_sector += STRIPE_SECTORS) { 1589 for (;logical_sector < last_sector; logical_sector += STRIPE_SECTORS) {
1589 DEFINE_WAIT(w); 1590 DEFINE_WAIT(w);
1590 1591
@@ -1634,7 +1635,7 @@ static int make_request (request_queue_t *q, struct bio * bi)
1634} 1635}
1635 1636
1636/* FIXME go_faster isn't used */ 1637/* FIXME go_faster isn't used */
1637static int sync_request (mddev_t *mddev, sector_t sector_nr, int go_faster) 1638static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, int go_faster)
1638{ 1639{
1639 raid6_conf_t *conf = (raid6_conf_t *) mddev->private; 1640 raid6_conf_t *conf = (raid6_conf_t *) mddev->private;
1640 struct stripe_head *sh; 1641 struct stripe_head *sh;
@@ -1657,8 +1658,8 @@ static int sync_request (mddev_t *mddev, sector_t sector_nr, int go_faster)
1657 * nothing we can do. 1658 * nothing we can do.
1658 */ 1659 */
1659 if (mddev->degraded >= 2 && test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) { 1660 if (mddev->degraded >= 2 && test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) {
1660 int rv = (mddev->size << 1) - sector_nr; 1661 sector_t rv = (mddev->size << 1) - sector_nr;
1661 md_done_sync(mddev, rv, 1); 1662 *skipped = 1;
1662 return rv; 1663 return rv;
1663 } 1664 }
1664 1665
@@ -1705,7 +1706,6 @@ static void raid6d (mddev_t *mddev)
1705 PRINTK("+++ raid6d active\n"); 1706 PRINTK("+++ raid6d active\n");
1706 1707
1707 md_check_recovery(mddev); 1708 md_check_recovery(mddev);
1708 md_handle_safemode(mddev);
1709 1709
1710 handled = 0; 1710 handled = 0;
1711 spin_lock_irq(&conf->device_lock); 1711 spin_lock_irq(&conf->device_lock);
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
index 80254caa444c..48989eda2400 100644
--- a/drivers/media/video/adv7170.c
+++ b/drivers/media/video/adv7170.c
@@ -384,22 +384,14 @@ static unsigned short normal_i2c[] =
384 I2C_ADV7171 >> 1, (I2C_ADV7171 >> 1) + 1, 384 I2C_ADV7171 >> 1, (I2C_ADV7171 >> 1) + 1,
385 I2C_CLIENT_END 385 I2C_CLIENT_END
386}; 386};
387static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
388 387
389static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 388static unsigned short ignore = I2C_CLIENT_END;
390static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
391static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
392static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
393static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
394 389
395static struct i2c_client_address_data addr_data = { 390static struct i2c_client_address_data addr_data = {
396 .normal_i2c = normal_i2c, 391 .normal_i2c = normal_i2c,
397 .normal_i2c_range = normal_i2c_range, 392 .probe = &ignore,
398 .probe = probe, 393 .ignore = &ignore,
399 .probe_range = probe_range, 394 .force = &ignore,
400 .ignore = ignore,
401 .ignore_range = ignore_range,
402 .force = force
403}; 395};
404 396
405static struct i2c_driver i2c_driver_adv7170; 397static struct i2c_driver i2c_driver_adv7170;
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
index 95d0974b0ab5..f898b6586374 100644
--- a/drivers/media/video/adv7175.c
+++ b/drivers/media/video/adv7175.c
@@ -434,22 +434,14 @@ static unsigned short normal_i2c[] =
434 I2C_ADV7176 >> 1, (I2C_ADV7176 >> 1) + 1, 434 I2C_ADV7176 >> 1, (I2C_ADV7176 >> 1) + 1,
435 I2C_CLIENT_END 435 I2C_CLIENT_END
436}; 436};
437static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
438 437
439static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 438static unsigned short ignore = I2C_CLIENT_END;
440static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
441static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
442static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
443static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
444 439
445static struct i2c_client_address_data addr_data = { 440static struct i2c_client_address_data addr_data = {
446 .normal_i2c = normal_i2c, 441 .normal_i2c = normal_i2c,
447 .normal_i2c_range = normal_i2c_range, 442 .probe = &ignore,
448 .probe = probe, 443 .ignore = &ignore,
449 .probe_range = probe_range, 444 .force = &ignore,
450 .ignore = ignore,
451 .ignore_range = ignore_range,
452 .force = force
453}; 445};
454 446
455static struct i2c_driver i2c_driver_adv7175; 447static struct i2c_driver i2c_driver_adv7175;
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
index cf0db2554a80..8733588f6db3 100644
--- a/drivers/media/video/bt819.c
+++ b/drivers/media/video/bt819.c
@@ -500,22 +500,14 @@ static unsigned short normal_i2c[] = {
500 I2C_BT819 >> 1, 500 I2C_BT819 >> 1,
501 I2C_CLIENT_END, 501 I2C_CLIENT_END,
502}; 502};
503static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
504 503
505static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 504static unsigned short ignore = I2C_CLIENT_END;
506static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
507static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
508static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
509static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
510 505
511static struct i2c_client_address_data addr_data = { 506static struct i2c_client_address_data addr_data = {
512 .normal_i2c = normal_i2c, 507 .normal_i2c = normal_i2c,
513 .normal_i2c_range = normal_i2c_range, 508 .probe = &ignore,
514 .probe = probe, 509 .ignore = &ignore,
515 .probe_range = probe_range, 510 .force = &ignore,
516 .ignore = ignore,
517 .ignore_range = ignore_range,
518 .force = force
519}; 511};
520 512
521static struct i2c_driver i2c_driver_bt819; 513static struct i2c_driver i2c_driver_bt819;
diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c
index efe605a113a1..07f72f64c5f7 100644
--- a/drivers/media/video/bt832.c
+++ b/drivers/media/video/bt832.c
@@ -39,8 +39,8 @@
39MODULE_LICENSE("GPL"); 39MODULE_LICENSE("GPL");
40 40
41/* Addresses to scan */ 41/* Addresses to scan */
42static unsigned short normal_i2c[] = {I2C_CLIENT_END}; 42static unsigned short normal_i2c[] = { I2C_BT832_ALT1>>1, I2C_BT832_ALT2>>1,
43static unsigned short normal_i2c_range[] = {I2C_BT832_ALT1>>1,I2C_BT832_ALT2>>1,I2C_CLIENT_END}; 43 I2C_CLIENT_END };
44I2C_CLIENT_INSMOD; 44I2C_CLIENT_INSMOD;
45 45
46/* ---------------------------------------------------------------------- */ 46/* ---------------------------------------------------------------------- */
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
index 72c7eb0f8c24..a5d529ccf3ad 100644
--- a/drivers/media/video/bt856.c
+++ b/drivers/media/video/bt856.c
@@ -288,22 +288,14 @@ bt856_command (struct i2c_client *client,
288 * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 288 * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1'
289 */ 289 */
290static unsigned short normal_i2c[] = { I2C_BT856 >> 1, I2C_CLIENT_END }; 290static unsigned short normal_i2c[] = { I2C_BT856 >> 1, I2C_CLIENT_END };
291static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
292 291
293static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 292static unsigned short ignore = I2C_CLIENT_END;
294static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
295static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
296static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
297static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
298 293
299static struct i2c_client_address_data addr_data = { 294static struct i2c_client_address_data addr_data = {
300 .normal_i2c = normal_i2c, 295 .normal_i2c = normal_i2c,
301 .normal_i2c_range = normal_i2c_range, 296 .probe = &ignore,
302 .probe = probe, 297 .ignore = &ignore,
303 .probe_range = probe_range, 298 .force = &ignore,
304 .ignore = ignore,
305 .ignore_range = ignore_range,
306 .force = force
307}; 299};
308 300
309static struct i2c_driver i2c_driver_bt856; 301static struct i2c_driver i2c_driver_bt856;
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c
index 7fbb8581a87d..09464d624a6b 100644
--- a/drivers/media/video/msp3400.c
+++ b/drivers/media/video/msp3400.c
@@ -147,7 +147,6 @@ static unsigned short normal_i2c[] = {
147 I2C_MSP3400C_ALT >> 1, 147 I2C_MSP3400C_ALT >> 1,
148 I2C_CLIENT_END 148 I2C_CLIENT_END
149}; 149};
150static unsigned short normal_i2c_range[] = {I2C_CLIENT_END,I2C_CLIENT_END};
151I2C_CLIENT_INSMOD; 150I2C_CLIENT_INSMOD;
152 151
153/* ----------------------------------------------------------------------- */ 152/* ----------------------------------------------------------------------- */
diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c
index ba69f09cbdd1..b8054da31ffd 100644
--- a/drivers/media/video/saa5246a.c
+++ b/drivers/media/video/saa5246a.c
@@ -64,7 +64,6 @@ static struct video_device saa_template; /* Declared near bottom */
64 64
65/* Addresses to scan */ 65/* Addresses to scan */
66static unsigned short normal_i2c[] = { I2C_ADDRESS, I2C_CLIENT_END }; 66static unsigned short normal_i2c[] = { I2C_ADDRESS, I2C_CLIENT_END };
67static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
68I2C_CLIENT_INSMOD; 67I2C_CLIENT_INSMOD;
69 68
70static struct i2c_client client_template; 69static struct i2c_client client_template;
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index d74caa139f0a..7ffa2e9a9bf3 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -132,7 +132,6 @@ static struct video_device saa_template; /* Declared near bottom */
132 132
133/* Addresses to scan */ 133/* Addresses to scan */
134static unsigned short normal_i2c[] = {34>>1,I2C_CLIENT_END}; 134static unsigned short normal_i2c[] = {34>>1,I2C_CLIENT_END};
135static unsigned short normal_i2c_range[] = {I2C_CLIENT_END};
136I2C_CLIENT_INSMOD; 135I2C_CLIENT_INSMOD;
137 136
138static struct i2c_client client_template; 137static struct i2c_client client_template;
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c
index 64273b438530..22d055d8a695 100644
--- a/drivers/media/video/saa7110.c
+++ b/drivers/media/video/saa7110.c
@@ -463,22 +463,14 @@ static unsigned short normal_i2c[] = {
463 (I2C_SAA7110 >> 1) + 1, 463 (I2C_SAA7110 >> 1) + 1,
464 I2C_CLIENT_END 464 I2C_CLIENT_END
465}; 465};
466static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
467 466
468static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 467static unsigned short ignore = I2C_CLIENT_END;
469static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
470static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
471static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
472static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
473 468
474static struct i2c_client_address_data addr_data = { 469static struct i2c_client_address_data addr_data = {
475 .normal_i2c = normal_i2c, 470 .normal_i2c = normal_i2c,
476 .normal_i2c_range = normal_i2c_range, 471 .probe = &ignore,
477 .probe = probe, 472 .ignore = &ignore,
478 .probe_range = probe_range, 473 .force = &ignore,
479 .ignore = ignore,
480 .ignore_range = ignore_range,
481 .force = force
482}; 474};
483 475
484static struct i2c_driver i2c_driver_saa7110; 476static struct i2c_driver i2c_driver_saa7110;
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
index 0a873112ae23..fcd897382fcf 100644
--- a/drivers/media/video/saa7111.c
+++ b/drivers/media/video/saa7111.c
@@ -482,22 +482,14 @@ saa7111_command (struct i2c_client *client,
482 * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 482 * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1'
483 */ 483 */
484static unsigned short normal_i2c[] = { I2C_SAA7111 >> 1, I2C_CLIENT_END }; 484static unsigned short normal_i2c[] = { I2C_SAA7111 >> 1, I2C_CLIENT_END };
485static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
486 485
487static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 486static unsigned short ignore = I2C_CLIENT_END;
488static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
489static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
490static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
491static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
492 487
493static struct i2c_client_address_data addr_data = { 488static struct i2c_client_address_data addr_data = {
494 .normal_i2c = normal_i2c, 489 .normal_i2c = normal_i2c,
495 .normal_i2c_range = normal_i2c_range, 490 .probe = &ignore,
496 .probe = probe, 491 .ignore = &ignore,
497 .probe_range = probe_range, 492 .force = &ignore,
498 .ignore = ignore,
499 .ignore_range = ignore_range,
500 .force = force
501}; 493};
502 494
503static struct i2c_driver i2c_driver_saa7111; 495static struct i2c_driver i2c_driver_saa7111;
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c
index e73023695e58..2ba997f5ef1d 100644
--- a/drivers/media/video/saa7114.c
+++ b/drivers/media/video/saa7114.c
@@ -820,22 +820,14 @@ saa7114_command (struct i2c_client *client,
820 */ 820 */
821static unsigned short normal_i2c[] = 821static unsigned short normal_i2c[] =
822 { I2C_SAA7114 >> 1, I2C_SAA7114A >> 1, I2C_CLIENT_END }; 822 { I2C_SAA7114 >> 1, I2C_SAA7114A >> 1, I2C_CLIENT_END };
823static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
824 823
825static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 824static unsigned short ignore = I2C_CLIENT_END;
826static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
827static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
828static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
829static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
830 825
831static struct i2c_client_address_data addr_data = { 826static struct i2c_client_address_data addr_data = {
832 .normal_i2c = normal_i2c, 827 .normal_i2c = normal_i2c,
833 .normal_i2c_range = normal_i2c_range, 828 .probe = &ignore,
834 .probe = probe, 829 .ignore = &ignore,
835 .probe_range = probe_range, 830 .force = &ignore,
836 .ignore = ignore,
837 .ignore_range = ignore_range,
838 .force = force
839}; 831};
840 832
841static struct i2c_driver i2c_driver_saa7114; 833static struct i2c_driver i2c_driver_saa7114;
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c
index 1db022682980..42c2b565c9fe 100644
--- a/drivers/media/video/saa7134/saa6752hs.c
+++ b/drivers/media/video/saa7134/saa6752hs.c
@@ -22,7 +22,6 @@
22 22
23/* Addresses to scan */ 23/* Addresses to scan */
24static unsigned short normal_i2c[] = {0x20, I2C_CLIENT_END}; 24static unsigned short normal_i2c[] = {0x20, I2C_CLIENT_END};
25static unsigned short normal_i2c_range[] = {I2C_CLIENT_END};
26I2C_CLIENT_INSMOD; 25I2C_CLIENT_INSMOD;
27 26
28MODULE_DESCRIPTION("device driver for saa6752hs MPEG2 encoder"); 27MODULE_DESCRIPTION("device driver for saa6752hs MPEG2 encoder");
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
index 5f0b224c3cb6..108e7a4a0273 100644
--- a/drivers/media/video/saa7185.c
+++ b/drivers/media/video/saa7185.c
@@ -380,22 +380,14 @@ saa7185_command (struct i2c_client *client,
380 * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 380 * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1'
381 */ 381 */
382static unsigned short normal_i2c[] = { I2C_SAA7185 >> 1, I2C_CLIENT_END }; 382static unsigned short normal_i2c[] = { I2C_SAA7185 >> 1, I2C_CLIENT_END };
383static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
384 383
385static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 384static unsigned short ignore = I2C_CLIENT_END;
386static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
387static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
388static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
389static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
390 385
391static struct i2c_client_address_data addr_data = { 386static struct i2c_client_address_data addr_data = {
392 .normal_i2c = normal_i2c, 387 .normal_i2c = normal_i2c,
393 .normal_i2c_range = normal_i2c_range, 388 .probe = &ignore,
394 .probe = probe, 389 .ignore = &ignore,
395 .probe_range = probe_range, 390 .force = &ignore,
396 .ignore = ignore,
397 .ignore_range = ignore_range,
398 .force = force
399}; 391};
400 392
401static struct i2c_driver i2c_driver_saa7185; 393static struct i2c_driver i2c_driver_saa7185;
diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c
index 376a4a439e9b..07ba6d3ed08c 100644
--- a/drivers/media/video/tda7432.c
+++ b/drivers/media/video/tda7432.c
@@ -74,7 +74,6 @@ static unsigned short normal_i2c[] = {
74 I2C_TDA7432 >> 1, 74 I2C_TDA7432 >> 1,
75 I2C_CLIENT_END, 75 I2C_CLIENT_END,
76}; 76};
77static unsigned short normal_i2c_range[] = { I2C_CLIENT_END, I2C_CLIENT_END };
78I2C_CLIENT_INSMOD; 77I2C_CLIENT_INSMOD;
79 78
80/* Structure of address and subaddresses for the tda7432 */ 79/* Structure of address and subaddresses for the tda7432 */
diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c
index b5177c6f54f6..c29bdfc3244e 100644
--- a/drivers/media/video/tda9840.c
+++ b/drivers/media/video/tda9840.c
@@ -43,7 +43,6 @@ MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
43 43
44/* addresses to scan, found only at 0x42 (7-Bit) */ 44/* addresses to scan, found only at 0x42 (7-Bit) */
45static unsigned short normal_i2c[] = { I2C_TDA9840, I2C_CLIENT_END }; 45static unsigned short normal_i2c[] = { I2C_TDA9840, I2C_CLIENT_END };
46static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
47 46
48/* magic definition of all other variables and things */ 47/* magic definition of all other variables and things */
49I2C_CLIENT_INSMOD; 48I2C_CLIENT_INSMOD;
diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c
index 4f1114c033a1..97b113e070f3 100644
--- a/drivers/media/video/tda9875.c
+++ b/drivers/media/video/tda9875.c
@@ -44,7 +44,6 @@ static unsigned short normal_i2c[] = {
44 I2C_TDA9875 >> 1, 44 I2C_TDA9875 >> 1,
45 I2C_CLIENT_END 45 I2C_CLIENT_END
46}; 46};
47static unsigned short normal_i2c_range[] = {I2C_CLIENT_END};
48I2C_CLIENT_INSMOD; 47I2C_CLIENT_INSMOD;
49 48
50/* This is a superset of the TDA9875 */ 49/* This is a superset of the TDA9875 */
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index debef1910c37..7e6e6dd966a2 100644
--- a/drivers/media/video/tda9887.c
+++ b/drivers/media/video/tda9887.c
@@ -33,7 +33,6 @@ static unsigned short normal_i2c[] = {
33 0x96 >>1, 33 0x96 >>1,
34 I2C_CLIENT_END, 34 I2C_CLIENT_END,
35}; 35};
36static unsigned short normal_i2c_range[] = {I2C_CLIENT_END,I2C_CLIENT_END};
37I2C_CLIENT_INSMOD; 36I2C_CLIENT_INSMOD;
38 37
39/* insmod options */ 38/* insmod options */
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c
index 3ec39550bf46..b44db8a7b94d 100644
--- a/drivers/media/video/tea6415c.c
+++ b/drivers/media/video/tea6415c.c
@@ -43,7 +43,6 @@ MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
43 43
44/* addresses to scan, found only at 0x03 and/or 0x43 (7-bit) */ 44/* addresses to scan, found only at 0x03 and/or 0x43 (7-bit) */
45static unsigned short normal_i2c[] = { I2C_TEA6415C_1, I2C_TEA6415C_2, I2C_CLIENT_END }; 45static unsigned short normal_i2c[] = { I2C_TEA6415C_1, I2C_TEA6415C_2, I2C_CLIENT_END };
46static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
47 46
48/* magic definition of all other variables and things */ 47/* magic definition of all other variables and things */
49I2C_CLIENT_INSMOD; 48I2C_CLIENT_INSMOD;
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c
index bd10710fd909..48d4db7d507b 100644
--- a/drivers/media/video/tea6420.c
+++ b/drivers/media/video/tea6420.c
@@ -40,7 +40,6 @@ MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
40 40
41/* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */ 41/* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */
42static unsigned short normal_i2c[] = { I2C_TEA6420_1, I2C_TEA6420_2, I2C_CLIENT_END }; 42static unsigned short normal_i2c[] = { I2C_TEA6420_1, I2C_TEA6420_2, I2C_CLIENT_END };
43static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
44 43
45/* magic definition of all other variables and things */ 44/* magic definition of all other variables and things */
46I2C_CLIENT_INSMOD; 45I2C_CLIENT_INSMOD;
diff --git a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c
index 6b20aa902a8f..51748c6578d1 100644
--- a/drivers/media/video/tuner-3036.c
+++ b/drivers/media/video/tuner-3036.c
@@ -34,19 +34,14 @@ static int this_adap;
34static struct i2c_client client_template; 34static struct i2c_client client_template;
35 35
36/* Addresses to scan */ 36/* Addresses to scan */
37static unsigned short normal_i2c[] = {I2C_CLIENT_END}; 37static unsigned short normal_i2c[] = { 0x60, 0x61, I2C_CLIENT_END };
38static unsigned short normal_i2c_range[] = {0x60, 0x61, I2C_CLIENT_END}; 38static unsigned short ignore = I2C_CLIENT_END;
39static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
40static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
41static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
42static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
43static unsigned short force[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
44 39
45static struct i2c_client_address_data addr_data = { 40static struct i2c_client_address_data addr_data = {
46 normal_i2c, normal_i2c_range, 41 .normal_i2c = normal_i2c,
47 probe, probe_range, 42 .probe = &ignore,
48 ignore, ignore_range, 43 .ignore = &ignore,
49 force 44 .force = &ignore,
50}; 45};
51 46
52/* ---------------------------------------------------------------------- */ 47/* ---------------------------------------------------------------------- */
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 6212388edb75..81882ddab859 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -28,10 +28,8 @@
28/* standard i2c insmod options */ 28/* standard i2c insmod options */
29static unsigned short normal_i2c[] = { 29static unsigned short normal_i2c[] = {
30 0x4b, /* tda8290 */ 30 0x4b, /* tda8290 */
31 I2C_CLIENT_END 31 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
32}; 32 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
33static unsigned short normal_i2c_range[] = {
34 0x60, 0x6f,
35 I2C_CLIENT_END 33 I2C_CLIENT_END
36}; 34};
37I2C_CLIENT_INSMOD; 35I2C_CLIENT_INSMOD;
@@ -225,9 +223,8 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
225static int tuner_probe(struct i2c_adapter *adap) 223static int tuner_probe(struct i2c_adapter *adap)
226{ 224{
227 if (0 != addr) { 225 if (0 != addr) {
228 normal_i2c[0] = addr; 226 normal_i2c[0] = addr;
229 normal_i2c_range[0] = addr; 227 normal_i2c[1] = I2C_CLIENT_END;
230 normal_i2c_range[1] = addr;
231 } 228 }
232 this_adap = 0; 229 this_adap = 0;
233 230
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 80dc34f18c2c..41b635e0d3c6 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -148,7 +148,6 @@ static unsigned short normal_i2c[] = {
148 I2C_TDA9874 >> 1, 148 I2C_TDA9874 >> 1,
149 I2C_PIC16C54 >> 1, 149 I2C_PIC16C54 >> 1,
150 I2C_CLIENT_END }; 150 I2C_CLIENT_END };
151static unsigned short normal_i2c_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
152I2C_CLIENT_INSMOD; 151I2C_CLIENT_INSMOD;
153 152
154static struct i2c_driver driver; 153static struct i2c_driver driver;
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index e1443a0937e3..3d216973798c 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -482,7 +482,6 @@ static unsigned short normal_i2c[] = {
482 0xa0 >> 1, 482 0xa0 >> 1,
483 I2C_CLIENT_END, 483 I2C_CLIENT_END,
484}; 484};
485static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
486I2C_CLIENT_INSMOD; 485I2C_CLIENT_INSMOD;
487 486
488struct i2c_driver i2c_driver_tveeprom; 487struct i2c_driver i2c_driver_tveeprom;
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c
index 0fd6c9a70917..5dbd9f6bf353 100644
--- a/drivers/media/video/vpx3220.c
+++ b/drivers/media/video/vpx3220.c
@@ -569,22 +569,14 @@ static unsigned short normal_i2c[] =
569 { I2C_VPX3220 >> 1, (I2C_VPX3220 >> 1) + 4, 569 { I2C_VPX3220 >> 1, (I2C_VPX3220 >> 1) + 4,
570 I2C_CLIENT_END 570 I2C_CLIENT_END
571}; 571};
572static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
573 572
574static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 573static unsigned short ignore = I2C_CLIENT_END;
575static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
576static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
577static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };
578static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };
579 574
580static struct i2c_client_address_data addr_data = { 575static struct i2c_client_address_data addr_data = {
581 .normal_i2c = normal_i2c, 576 .normal_i2c = normal_i2c,
582 .normal_i2c_range = normal_i2c_range, 577 .probe = &ignore,
583 .probe = probe, 578 .ignore = &ignore,
584 .probe_range = probe_range, 579 .force = &ignore,
585 .ignore = ignore,
586 .ignore_range = ignore_range,
587 .force = force
588}; 580};
589 581
590static struct i2c_driver vpx3220_i2c_driver; 582static struct i2c_driver vpx3220_i2c_driver;
diff --git a/drivers/misc/ibmasm/command.c b/drivers/misc/ibmasm/command.c
index 245b0058381d..07a085ccbd5b 100644
--- a/drivers/misc/ibmasm/command.c
+++ b/drivers/misc/ibmasm/command.c
@@ -23,6 +23,7 @@
23 */ 23 */
24 24
25#include "ibmasm.h" 25#include "ibmasm.h"
26#include "lowlevel.h"
26 27
27static void exec_next_command(struct service_processor *sp); 28static void exec_next_command(struct service_processor *sp);
28static void free_command(struct kobject *kobj); 29static void free_command(struct kobject *kobj);
@@ -31,8 +32,9 @@ static struct kobj_type ibmasm_cmd_kobj_type = {
31 .release = free_command, 32 .release = free_command,
32}; 33};
33 34
35static atomic_t command_count = ATOMIC_INIT(0);
34 36
35struct command *ibmasm_new_command(size_t buffer_size) 37struct command *ibmasm_new_command(struct service_processor *sp, size_t buffer_size)
36{ 38{
37 struct command *cmd; 39 struct command *cmd;
38 40
@@ -55,11 +57,15 @@ struct command *ibmasm_new_command(size_t buffer_size)
55 57
56 kobject_init(&cmd->kobj); 58 kobject_init(&cmd->kobj);
57 cmd->kobj.ktype = &ibmasm_cmd_kobj_type; 59 cmd->kobj.ktype = &ibmasm_cmd_kobj_type;
60 cmd->lock = &sp->lock;
58 61
59 cmd->status = IBMASM_CMD_PENDING; 62 cmd->status = IBMASM_CMD_PENDING;
60 init_waitqueue_head(&cmd->wait); 63 init_waitqueue_head(&cmd->wait);
61 INIT_LIST_HEAD(&cmd->queue_node); 64 INIT_LIST_HEAD(&cmd->queue_node);
62 65
66 atomic_inc(&command_count);
67 dbg("command count: %d\n", atomic_read(&command_count));
68
63 return cmd; 69 return cmd;
64} 70}
65 71
@@ -68,6 +74,8 @@ static void free_command(struct kobject *kobj)
68 struct command *cmd = to_command(kobj); 74 struct command *cmd = to_command(kobj);
69 75
70 list_del(&cmd->queue_node); 76 list_del(&cmd->queue_node);
77 atomic_dec(&command_count);
78 dbg("command count: %d\n", atomic_read(&command_count));
71 kfree(cmd->buffer); 79 kfree(cmd->buffer);
72 kfree(cmd); 80 kfree(cmd);
73} 81}
@@ -94,8 +102,14 @@ static struct command *dequeue_command(struct service_processor *sp)
94 102
95static inline void do_exec_command(struct service_processor *sp) 103static inline void do_exec_command(struct service_processor *sp)
96{ 104{
105 char tsbuf[32];
106
107 dbg("%s:%d at %s\n", __FUNCTION__, __LINE__, get_timestamp(tsbuf));
108
97 if (ibmasm_send_i2o_message(sp)) { 109 if (ibmasm_send_i2o_message(sp)) {
98 sp->current_command->status = IBMASM_CMD_FAILED; 110 sp->current_command->status = IBMASM_CMD_FAILED;
111 wake_up(&sp->current_command->wait);
112 command_put(sp->current_command);
99 exec_next_command(sp); 113 exec_next_command(sp);
100 } 114 }
101} 115}
@@ -111,14 +125,16 @@ static inline void do_exec_command(struct service_processor *sp)
111void ibmasm_exec_command(struct service_processor *sp, struct command *cmd) 125void ibmasm_exec_command(struct service_processor *sp, struct command *cmd)
112{ 126{
113 unsigned long flags; 127 unsigned long flags;
128 char tsbuf[32];
129
130 dbg("%s:%d at %s\n", __FUNCTION__, __LINE__, get_timestamp(tsbuf));
114 131
115 spin_lock_irqsave(&sp->lock, flags); 132 spin_lock_irqsave(&sp->lock, flags);
116 133
117 if (!sp->current_command) { 134 if (!sp->current_command) {
118 command_get(cmd);
119 sp->current_command = cmd; 135 sp->current_command = cmd;
136 command_get(sp->current_command);
120 spin_unlock_irqrestore(&sp->lock, flags); 137 spin_unlock_irqrestore(&sp->lock, flags);
121
122 do_exec_command(sp); 138 do_exec_command(sp);
123 } else { 139 } else {
124 enqueue_command(sp, cmd); 140 enqueue_command(sp, cmd);
@@ -129,9 +145,9 @@ void ibmasm_exec_command(struct service_processor *sp, struct command *cmd)
129static void exec_next_command(struct service_processor *sp) 145static void exec_next_command(struct service_processor *sp)
130{ 146{
131 unsigned long flags; 147 unsigned long flags;
148 char tsbuf[32];
132 149
133 wake_up(&sp->current_command->wait); 150 dbg("%s:%d at %s\n", __FUNCTION__, __LINE__, get_timestamp(tsbuf));
134 command_put(sp->current_command);
135 151
136 spin_lock_irqsave(&sp->lock, flags); 152 spin_lock_irqsave(&sp->lock, flags);
137 sp->current_command = dequeue_command(sp); 153 sp->current_command = dequeue_command(sp);
@@ -169,7 +185,9 @@ void ibmasm_receive_command_response(struct service_processor *sp, void *respons
169 if (!sp->current_command) 185 if (!sp->current_command)
170 return; 186 return;
171 187
172 memcpy(cmd->buffer, response, min(size, cmd->buffer_size)); 188 memcpy_fromio(cmd->buffer, response, min(size, cmd->buffer_size));
173 cmd->status = IBMASM_CMD_COMPLETE; 189 cmd->status = IBMASM_CMD_COMPLETE;
190 wake_up(&sp->current_command->wait);
191 command_put(sp->current_command);
174 exec_next_command(sp); 192 exec_next_command(sp);
175} 193}
diff --git a/drivers/misc/ibmasm/dot_command.c b/drivers/misc/ibmasm/dot_command.c
index 478a8d898fc1..13c52f866e2e 100644
--- a/drivers/misc/ibmasm/dot_command.c
+++ b/drivers/misc/ibmasm/dot_command.c
@@ -33,7 +33,13 @@ void ibmasm_receive_message(struct service_processor *sp, void *message, int mes
33 u32 size; 33 u32 size;
34 struct dot_command_header *header = (struct dot_command_header *)message; 34 struct dot_command_header *header = (struct dot_command_header *)message;
35 35
36 if (message_size == 0)
37 return;
38
36 size = get_dot_command_size(message); 39 size = get_dot_command_size(message);
40 if (size == 0)
41 return;
42
37 if (size > message_size) 43 if (size > message_size)
38 size = message_size; 44 size = message_size;
39 45
@@ -67,7 +73,7 @@ int ibmasm_send_driver_vpd(struct service_processor *sp)
67 u8 *vpd_data; 73 u8 *vpd_data;
68 int result = 0; 74 int result = 0;
69 75
70 command = ibmasm_new_command(INIT_BUFFER_SIZE); 76 command = ibmasm_new_command(sp, INIT_BUFFER_SIZE);
71 if (command == NULL) 77 if (command == NULL)
72 return -ENOMEM; 78 return -ENOMEM;
73 79
@@ -121,7 +127,7 @@ int ibmasm_send_os_state(struct service_processor *sp, int os_state)
121 struct os_state_command *os_state_cmd; 127 struct os_state_command *os_state_cmd;
122 int result = 0; 128 int result = 0;
123 129
124 cmd = ibmasm_new_command(sizeof(struct os_state_command)); 130 cmd = ibmasm_new_command(sp, sizeof(struct os_state_command));
125 if (cmd == NULL) 131 if (cmd == NULL)
126 return -ENOMEM; 132 return -ENOMEM;
127 133
diff --git a/drivers/misc/ibmasm/event.c b/drivers/misc/ibmasm/event.c
index e100f34f1587..fe1e819235a4 100644
--- a/drivers/misc/ibmasm/event.c
+++ b/drivers/misc/ibmasm/event.c
@@ -23,6 +23,7 @@
23 */ 23 */
24 24
25#include "ibmasm.h" 25#include "ibmasm.h"
26#include "lowlevel.h"
26 27
27/* 28/*
28 * ASM service processor event handling routines. 29 * ASM service processor event handling routines.
@@ -34,7 +35,6 @@
34 * circular buffer. 35 * circular buffer.
35 */ 36 */
36 37
37
38static void wake_up_event_readers(struct service_processor *sp) 38static void wake_up_event_readers(struct service_processor *sp)
39{ 39{
40 struct event_reader *reader; 40 struct event_reader *reader;
@@ -63,7 +63,7 @@ void ibmasm_receive_event(struct service_processor *sp, void *data, unsigned int
63 spin_lock_irqsave(&sp->lock, flags); 63 spin_lock_irqsave(&sp->lock, flags);
64 /* copy the event into the next slot in the circular buffer */ 64 /* copy the event into the next slot in the circular buffer */
65 event = &buffer->events[buffer->next_index]; 65 event = &buffer->events[buffer->next_index];
66 memcpy(event->data, data, data_size); 66 memcpy_fromio(event->data, data, data_size);
67 event->data_size = data_size; 67 event->data_size = data_size;
68 event->serial_number = buffer->next_serial_number; 68 event->serial_number = buffer->next_serial_number;
69 69
@@ -93,7 +93,10 @@ int ibmasm_get_next_event(struct service_processor *sp, struct event_reader *rea
93 unsigned int index; 93 unsigned int index;
94 unsigned long flags; 94 unsigned long flags;
95 95
96 if (wait_event_interruptible(reader->wait, event_available(buffer, reader))) 96 reader->cancelled = 0;
97
98 if (wait_event_interruptible(reader->wait,
99 event_available(buffer, reader) || reader->cancelled))
97 return -ERESTARTSYS; 100 return -ERESTARTSYS;
98 101
99 if (!event_available(buffer, reader)) 102 if (!event_available(buffer, reader))
@@ -116,6 +119,12 @@ int ibmasm_get_next_event(struct service_processor *sp, struct event_reader *rea
116 return event->data_size; 119 return event->data_size;
117} 120}
118 121
122void ibmasm_cancel_next_event(struct event_reader *reader)
123{
124 reader->cancelled = 1;
125 wake_up_interruptible(&reader->wait);
126}
127
119void ibmasm_event_reader_register(struct service_processor *sp, struct event_reader *reader) 128void ibmasm_event_reader_register(struct service_processor *sp, struct event_reader *reader)
120{ 129{
121 unsigned long flags; 130 unsigned long flags;
@@ -131,8 +140,6 @@ void ibmasm_event_reader_unregister(struct service_processor *sp, struct event_r
131{ 140{
132 unsigned long flags; 141 unsigned long flags;
133 142
134 wake_up_interruptible(&reader->wait);
135
136 spin_lock_irqsave(&sp->lock, flags); 143 spin_lock_irqsave(&sp->lock, flags);
137 list_del(&reader->node); 144 list_del(&reader->node);
138 spin_unlock_irqrestore(&sp->lock, flags); 145 spin_unlock_irqrestore(&sp->lock, flags);
@@ -164,6 +171,5 @@ int ibmasm_event_buffer_init(struct service_processor *sp)
164 171
165void ibmasm_event_buffer_exit(struct service_processor *sp) 172void ibmasm_event_buffer_exit(struct service_processor *sp)
166{ 173{
167 wake_up_event_readers(sp);
168 kfree(sp->event_buffer); 174 kfree(sp->event_buffer);
169} 175}
diff --git a/drivers/misc/ibmasm/heartbeat.c b/drivers/misc/ibmasm/heartbeat.c
index ce09309174d6..f295401fac21 100644
--- a/drivers/misc/ibmasm/heartbeat.c
+++ b/drivers/misc/ibmasm/heartbeat.c
@@ -25,6 +25,7 @@
25#include <linux/notifier.h> 25#include <linux/notifier.h>
26#include "ibmasm.h" 26#include "ibmasm.h"
27#include "dot_command.h" 27#include "dot_command.h"
28#include "lowlevel.h"
28 29
29static int suspend_heartbeats = 0; 30static int suspend_heartbeats = 0;
30 31
@@ -62,7 +63,7 @@ void ibmasm_unregister_panic_notifier(void)
62 63
63int ibmasm_heartbeat_init(struct service_processor *sp) 64int ibmasm_heartbeat_init(struct service_processor *sp)
64{ 65{
65 sp->heartbeat = ibmasm_new_command(HEARTBEAT_BUFFER_SIZE); 66 sp->heartbeat = ibmasm_new_command(sp, HEARTBEAT_BUFFER_SIZE);
66 if (sp->heartbeat == NULL) 67 if (sp->heartbeat == NULL)
67 return -ENOMEM; 68 return -ENOMEM;
68 69
@@ -71,6 +72,12 @@ int ibmasm_heartbeat_init(struct service_processor *sp)
71 72
72void ibmasm_heartbeat_exit(struct service_processor *sp) 73void ibmasm_heartbeat_exit(struct service_processor *sp)
73{ 74{
75 char tsbuf[32];
76
77 dbg("%s:%d at %s\n", __FUNCTION__, __LINE__, get_timestamp(tsbuf));
78 ibmasm_wait_for_response(sp->heartbeat, IBMASM_CMD_TIMEOUT_NORMAL);
79 dbg("%s:%d at %s\n", __FUNCTION__, __LINE__, get_timestamp(tsbuf));
80 suspend_heartbeats = 1;
74 command_put(sp->heartbeat); 81 command_put(sp->heartbeat);
75} 82}
76 83
@@ -78,14 +85,16 @@ void ibmasm_receive_heartbeat(struct service_processor *sp, void *message, size
78{ 85{
79 struct command *cmd = sp->heartbeat; 86 struct command *cmd = sp->heartbeat;
80 struct dot_command_header *header = (struct dot_command_header *)cmd->buffer; 87 struct dot_command_header *header = (struct dot_command_header *)cmd->buffer;
88 char tsbuf[32];
81 89
90 dbg("%s:%d at %s\n", __FUNCTION__, __LINE__, get_timestamp(tsbuf));
82 if (suspend_heartbeats) 91 if (suspend_heartbeats)
83 return; 92 return;
84 93
85 /* return the received dot command to sender */ 94 /* return the received dot command to sender */
86 cmd->status = IBMASM_CMD_PENDING; 95 cmd->status = IBMASM_CMD_PENDING;
87 size = min(size, cmd->buffer_size); 96 size = min(size, cmd->buffer_size);
88 memcpy(cmd->buffer, message, size); 97 memcpy_fromio(cmd->buffer, message, size);
89 header->type = sp_write; 98 header->type = sp_write;
90 ibmasm_exec_command(sp, cmd); 99 ibmasm_exec_command(sp, cmd);
91} 100}
diff --git a/drivers/misc/ibmasm/ibmasm.h b/drivers/misc/ibmasm/ibmasm.h
index 6fec7fd8cd1a..ecce4ffd3e23 100644
--- a/drivers/misc/ibmasm/ibmasm.h
+++ b/drivers/misc/ibmasm/ibmasm.h
@@ -34,16 +34,31 @@
34#include <linux/version.h> 34#include <linux/version.h>
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/device.h> 36#include <linux/device.h>
37#include <linux/input.h>
37 38
38/* Driver identification */ 39/* Driver identification */
39#define DRIVER_NAME "ibmasm" 40#define DRIVER_NAME "ibmasm"
40#define DRIVER_VERSION "0.4" 41#define DRIVER_VERSION "1.0"
41#define DRIVER_AUTHOR "Max Asbock" 42#define DRIVER_AUTHOR "Max Asbock <masbock@us.ibm.com>, Vernon Mauery <vernux@us.ibm.com>"
42#define DRIVER_DESC "IBM ASM Service Processor Driver" 43#define DRIVER_DESC "IBM ASM Service Processor Driver"
43 44
44#define err(msg) printk(KERN_ERR "%s: " msg "\n", DRIVER_NAME) 45#define err(msg) printk(KERN_ERR "%s: " msg "\n", DRIVER_NAME)
45#define info(msg) printk(KERN_INFO "%s: " msg "\n", DRIVER_NAME) 46#define info(msg) printk(KERN_INFO "%s: " msg "\n", DRIVER_NAME)
46 47
48extern int ibmasm_debug;
49#define dbg(STR, ARGS...) \
50 do { \
51 if (ibmasm_debug) \
52 printk(KERN_DEBUG STR , ##ARGS); \
53 } while (0)
54
55static inline char *get_timestamp(char *buf)
56{
57 struct timeval now;
58 do_gettimeofday(&now);
59 sprintf(buf, "%lu.%lu", now.tv_sec, now.tv_usec);
60 return buf;
61}
47 62
48#define IBMASM_CMD_PENDING 0 63#define IBMASM_CMD_PENDING 0
49#define IBMASM_CMD_COMPLETE 1 64#define IBMASM_CMD_COMPLETE 1
@@ -52,7 +67,7 @@
52#define IBMASM_CMD_TIMEOUT_NORMAL 45 67#define IBMASM_CMD_TIMEOUT_NORMAL 45
53#define IBMASM_CMD_TIMEOUT_EXTRA 240 68#define IBMASM_CMD_TIMEOUT_EXTRA 240
54 69
55#define IBMASM_CMD_MAX_BUFFER_SIZE 0x4000 70#define IBMASM_CMD_MAX_BUFFER_SIZE 0x8000
56 71
57#define REVERSE_HEARTBEAT_TIMEOUT 120 72#define REVERSE_HEARTBEAT_TIMEOUT 120
58 73
@@ -80,12 +95,17 @@ struct command {
80 size_t buffer_size; 95 size_t buffer_size;
81 int status; 96 int status;
82 struct kobject kobj; 97 struct kobject kobj;
98 spinlock_t *lock;
83}; 99};
84#define to_command(c) container_of(c, struct command, kobj) 100#define to_command(c) container_of(c, struct command, kobj)
85 101
86static inline void command_put(struct command *cmd) 102static inline void command_put(struct command *cmd)
87{ 103{
104 unsigned long flags;
105
106 spin_lock_irqsave(cmd->lock, flags);
88 kobject_put(&cmd->kobj); 107 kobject_put(&cmd->kobj);
108 spin_unlock_irqrestore(cmd->lock, flags);
89} 109}
90 110
91static inline void command_get(struct command *cmd) 111static inline void command_get(struct command *cmd)
@@ -108,6 +128,7 @@ struct event_buffer {
108}; 128};
109 129
110struct event_reader { 130struct event_reader {
131 int cancelled;
111 unsigned int next_serial_number; 132 unsigned int next_serial_number;
112 wait_queue_head_t wait; 133 wait_queue_head_t wait;
113 struct list_head node; 134 struct list_head node;
@@ -120,41 +141,11 @@ struct reverse_heartbeat {
120 unsigned int stopped; 141 unsigned int stopped;
121}; 142};
122 143
123 144struct ibmasm_remote {
124/* remote console events */ 145 struct input_dev keybd_dev;
125struct mouse_event { 146 struct input_dev mouse_dev;
126 long x;
127 long y;
128 unsigned char buttons;
129 unsigned char transitions;
130};
131
132struct keyboard_event {
133 unsigned long key_code;
134 unsigned char key_down;
135}; 147};
136 148
137struct remote_event {
138 unsigned long type;
139 union {
140 struct mouse_event mouse;
141 struct keyboard_event keyboard;
142 } data;
143};
144
145#define DRIVER_REMOTE_QUEUE_SIZE 240
146
147struct remote_queue {
148 struct remote_event *start;
149 struct remote_event *end;
150 struct remote_event *reader;
151 struct remote_event *writer;
152 unsigned int size;
153 int open;
154 wait_queue_head_t wait;
155};
156
157
158struct service_processor { 149struct service_processor {
159 struct list_head node; 150 struct list_head node;
160 spinlock_t lock; 151 spinlock_t lock;
@@ -167,13 +158,13 @@ struct service_processor {
167 char dirname[IBMASM_NAME_SIZE]; 158 char dirname[IBMASM_NAME_SIZE];
168 char devname[IBMASM_NAME_SIZE]; 159 char devname[IBMASM_NAME_SIZE];
169 unsigned int number; 160 unsigned int number;
170 struct remote_queue remote_queue; 161 struct ibmasm_remote *remote;
171 int serial_line; 162 int serial_line;
172 struct device *dev; 163 struct device *dev;
173}; 164};
174 165
175/* command processing */ 166/* command processing */
176extern struct command *ibmasm_new_command(size_t buffer_size); 167extern struct command *ibmasm_new_command(struct service_processor *sp, size_t buffer_size);
177extern void ibmasm_exec_command(struct service_processor *sp, struct command *cmd); 168extern void ibmasm_exec_command(struct service_processor *sp, struct command *cmd);
178extern void ibmasm_wait_for_response(struct command *cmd, int timeout); 169extern void ibmasm_wait_for_response(struct command *cmd, int timeout);
179extern void ibmasm_receive_command_response(struct service_processor *sp, void *response, size_t size); 170extern void ibmasm_receive_command_response(struct service_processor *sp, void *response, size_t size);
@@ -185,6 +176,7 @@ extern void ibmasm_receive_event(struct service_processor *sp, void *data, unsi
185extern void ibmasm_event_reader_register(struct service_processor *sp, struct event_reader *reader); 176extern void ibmasm_event_reader_register(struct service_processor *sp, struct event_reader *reader);
186extern void ibmasm_event_reader_unregister(struct service_processor *sp, struct event_reader *reader); 177extern void ibmasm_event_reader_unregister(struct service_processor *sp, struct event_reader *reader);
187extern int ibmasm_get_next_event(struct service_processor *sp, struct event_reader *reader); 178extern int ibmasm_get_next_event(struct service_processor *sp, struct event_reader *reader);
179extern void ibmasm_cancel_next_event(struct event_reader *reader);
188 180
189/* heartbeat - from SP to OS */ 181/* heartbeat - from SP to OS */
190extern void ibmasm_register_panic_notifier(void); 182extern void ibmasm_register_panic_notifier(void);
@@ -208,11 +200,9 @@ extern int ibmasm_send_i2o_message(struct service_processor *sp);
208extern irqreturn_t ibmasm_interrupt_handler(int irq, void * dev_id, struct pt_regs *regs); 200extern irqreturn_t ibmasm_interrupt_handler(int irq, void * dev_id, struct pt_regs *regs);
209 201
210/* remote console */ 202/* remote console */
211extern void ibmasm_handle_mouse_interrupt(struct service_processor *sp); 203extern void ibmasm_handle_mouse_interrupt(struct service_processor *sp, struct pt_regs *regs);
212extern int ibmasm_init_remote_queue(struct service_processor *sp); 204extern int ibmasm_init_remote_input_dev(struct service_processor *sp);
213extern void ibmasm_free_remote_queue(struct service_processor *sp); 205extern void ibmasm_free_remote_input_dev(struct service_processor *sp);
214extern void ibmasm_advance_reader(struct remote_queue *q, unsigned int n);
215extern size_t ibmasm_events_available(struct remote_queue *q);
216 206
217/* file system */ 207/* file system */
218extern int ibmasmfs_register(void); 208extern int ibmasmfs_register(void);
diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c
index 866e867e68f2..5c550fcac2c4 100644
--- a/drivers/misc/ibmasm/ibmasmfs.c
+++ b/drivers/misc/ibmasm/ibmasmfs.c
@@ -37,9 +37,7 @@
37 * | |-- event 37 * | |-- event
38 * | |-- reverse_heartbeat 38 * | |-- reverse_heartbeat
39 * | `-- remote_video 39 * | `-- remote_video
40 * | |-- connected
41 * | |-- depth 40 * | |-- depth
42 * | |-- events
43 * | |-- height 41 * | |-- height
44 * | `-- width 42 * | `-- width
45 * . 43 * .
@@ -50,9 +48,7 @@
50 * |-- event 48 * |-- event
51 * |-- reverse_heartbeat 49 * |-- reverse_heartbeat
52 * `-- remote_video 50 * `-- remote_video
53 * |-- connected
54 * |-- depth 51 * |-- depth
55 * |-- events
56 * |-- height 52 * |-- height
57 * `-- width 53 * `-- width
58 * 54 *
@@ -75,14 +71,6 @@
75 * remote_video/width: control remote display settings 71 * remote_video/width: control remote display settings
76 * write: set value 72 * write: set value
77 * read: read value 73 * read: read value
78 *
79 * remote_video/connected
80 * read: return "1" if web browser VNC java applet is connected,
81 * "0" otherwise
82 *
83 * remote_video/events
84 * read: sleep until a remote mouse or keyboard event occurs, then return
85 * then event.
86 */ 74 */
87 75
88#include <linux/fs.h> 76#include <linux/fs.h>
@@ -333,7 +321,7 @@ static ssize_t command_file_write(struct file *file, const char __user *ubuff, s
333 if (command_data->command) 321 if (command_data->command)
334 return -EAGAIN; 322 return -EAGAIN;
335 323
336 cmd = ibmasm_new_command(count); 324 cmd = ibmasm_new_command(command_data->sp, count);
337 if (!cmd) 325 if (!cmd)
338 return -ENOMEM; 326 return -ENOMEM;
339 327
@@ -374,6 +362,7 @@ static int event_file_open(struct inode *inode, struct file *file)
374 ibmasm_event_reader_register(sp, &event_data->reader); 362 ibmasm_event_reader_register(sp, &event_data->reader);
375 363
376 event_data->sp = sp; 364 event_data->sp = sp;
365 event_data->active = 0;
377 file->private_data = event_data; 366 file->private_data = event_data;
378 return 0; 367 return 0;
379} 368}
@@ -391,7 +380,9 @@ static ssize_t event_file_read(struct file *file, char __user *buf, size_t count
391{ 380{
392 struct ibmasmfs_event_data *event_data = file->private_data; 381 struct ibmasmfs_event_data *event_data = file->private_data;
393 struct event_reader *reader = &event_data->reader; 382 struct event_reader *reader = &event_data->reader;
383 struct service_processor *sp = event_data->sp;
394 int ret; 384 int ret;
385 unsigned long flags;
395 386
396 if (*offset < 0) 387 if (*offset < 0)
397 return -EINVAL; 388 return -EINVAL;
@@ -400,17 +391,32 @@ static ssize_t event_file_read(struct file *file, char __user *buf, size_t count
400 if (*offset != 0) 391 if (*offset != 0)
401 return 0; 392 return 0;
402 393
403 ret = ibmasm_get_next_event(event_data->sp, reader); 394 spin_lock_irqsave(&sp->lock, flags);
395 if (event_data->active) {
396 spin_unlock_irqrestore(&sp->lock, flags);
397 return -EBUSY;
398 }
399 event_data->active = 1;
400 spin_unlock_irqrestore(&sp->lock, flags);
401
402 ret = ibmasm_get_next_event(sp, reader);
404 if (ret <= 0) 403 if (ret <= 0)
405 return ret; 404 goto out;
406 405
407 if (count < reader->data_size) 406 if (count < reader->data_size) {
408 return -EINVAL; 407 ret = -EINVAL;
408 goto out;
409 }
409 410
410 if (copy_to_user(buf, reader->data, reader->data_size)) 411 if (copy_to_user(buf, reader->data, reader->data_size)) {
411 return -EFAULT; 412 ret = -EFAULT;
413 goto out;
414 }
415 ret = reader->data_size;
412 416
413 return reader->data_size; 417out:
418 event_data->active = 0;
419 return ret;
414} 420}
415 421
416static ssize_t event_file_write(struct file *file, const char __user *buf, size_t count, loff_t *offset) 422static ssize_t event_file_write(struct file *file, const char __user *buf, size_t count, loff_t *offset)
@@ -424,7 +430,7 @@ static ssize_t event_file_write(struct file *file, const char __user *buf, size_
424 if (*offset != 0) 430 if (*offset != 0)
425 return 0; 431 return 0;
426 432
427 wake_up_interruptible(&event_data->reader.wait); 433 ibmasm_cancel_next_event(&event_data->reader);
428 return 0; 434 return 0;
429} 435}
430 436
@@ -575,75 +581,6 @@ static ssize_t remote_settings_file_write(struct file *file, const char __user *
575 return count; 581 return count;
576} 582}
577 583
578static int remote_event_file_open(struct inode *inode, struct file *file)
579{
580 struct service_processor *sp;
581 unsigned long flags;
582 struct remote_queue *q;
583
584 file->private_data = inode->u.generic_ip;
585 sp = file->private_data;
586 q = &sp->remote_queue;
587
588 /* allow only one event reader */
589 spin_lock_irqsave(&sp->lock, flags);
590 if (q->open) {
591 spin_unlock_irqrestore(&sp->lock, flags);
592 return -EBUSY;
593 }
594 q->open = 1;
595 spin_unlock_irqrestore(&sp->lock, flags);
596
597 enable_mouse_interrupts(sp);
598
599 return 0;
600}
601
602static int remote_event_file_close(struct inode *inode, struct file *file)
603{
604 struct service_processor *sp = file->private_data;
605
606 disable_mouse_interrupts(sp);
607 wake_up_interruptible(&sp->remote_queue.wait);
608 sp->remote_queue.open = 0;
609
610 return 0;
611}
612
613static ssize_t remote_event_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
614{
615 struct service_processor *sp = file->private_data;
616 struct remote_queue *q = &sp->remote_queue;
617 size_t data_size;
618 struct remote_event *reader = q->reader;
619 size_t num_events;
620
621 if (*offset < 0)
622 return -EINVAL;
623 if (count == 0 || count > 1024)
624 return 0;
625 if (*offset != 0)
626 return 0;
627
628 if (wait_event_interruptible(q->wait, q->reader != q->writer))
629 return -ERESTARTSYS;
630
631 /* only get multiples of struct remote_event */
632 num_events = min((count/sizeof(struct remote_event)), ibmasm_events_available(q));
633 if (!num_events)
634 return 0;
635
636 data_size = num_events * sizeof(struct remote_event);
637
638 if (copy_to_user(buf, reader, data_size))
639 return -EFAULT;
640
641 ibmasm_advance_reader(q, num_events);
642
643 return data_size;
644}
645
646
647static struct file_operations command_fops = { 584static struct file_operations command_fops = {
648 .open = command_file_open, 585 .open = command_file_open,
649 .release = command_file_close, 586 .release = command_file_close,
@@ -672,12 +609,6 @@ static struct file_operations remote_settings_fops = {
672 .write = remote_settings_file_write, 609 .write = remote_settings_file_write,
673}; 610};
674 611
675static struct file_operations remote_event_fops = {
676 .open = remote_event_file_open,
677 .release = remote_event_file_close,
678 .read = remote_event_file_read,
679};
680
681 612
682static void ibmasmfs_create_files (struct super_block *sb, struct dentry *root) 613static void ibmasmfs_create_files (struct super_block *sb, struct dentry *root)
683{ 614{
@@ -703,7 +634,5 @@ static void ibmasmfs_create_files (struct super_block *sb, struct dentry *root)
703 ibmasmfs_create_file(sb, remote_dir, "width", &remote_settings_fops, (void *)display_width(sp), S_IRUSR|S_IWUSR); 634 ibmasmfs_create_file(sb, remote_dir, "width", &remote_settings_fops, (void *)display_width(sp), S_IRUSR|S_IWUSR);
704 ibmasmfs_create_file(sb, remote_dir, "height", &remote_settings_fops, (void *)display_height(sp), S_IRUSR|S_IWUSR); 635 ibmasmfs_create_file(sb, remote_dir, "height", &remote_settings_fops, (void *)display_height(sp), S_IRUSR|S_IWUSR);
705 ibmasmfs_create_file(sb, remote_dir, "depth", &remote_settings_fops, (void *)display_depth(sp), S_IRUSR|S_IWUSR); 636 ibmasmfs_create_file(sb, remote_dir, "depth", &remote_settings_fops, (void *)display_depth(sp), S_IRUSR|S_IWUSR);
706 ibmasmfs_create_file(sb, remote_dir, "connected", &remote_settings_fops, (void *)vnc_status(sp), S_IRUSR);
707 ibmasmfs_create_file(sb, remote_dir, "events", &remote_event_fops, (void *)sp, S_IRUSR);
708 } 637 }
709} 638}
diff --git a/drivers/misc/ibmasm/lowlevel.c b/drivers/misc/ibmasm/lowlevel.c
index 5156de2759d8..47949a2c7e94 100644
--- a/drivers/misc/ibmasm/lowlevel.c
+++ b/drivers/misc/ibmasm/lowlevel.c
@@ -46,8 +46,8 @@ int ibmasm_send_i2o_message(struct service_processor *sp)
46 46
47 message = get_i2o_message(sp->base_address, mfa); 47 message = get_i2o_message(sp->base_address, mfa);
48 48
49 memcpy(&message->header, &header, sizeof(struct i2o_header)); 49 memcpy_toio(&message->header, &header, sizeof(struct i2o_header));
50 memcpy(&message->data, command->buffer, command_size); 50 memcpy_toio(&message->data, command->buffer, command_size);
51 51
52 set_mfa_inbound(sp->base_address, mfa); 52 set_mfa_inbound(sp->base_address, mfa);
53 53
@@ -59,23 +59,27 @@ irqreturn_t ibmasm_interrupt_handler(int irq, void * dev_id, struct pt_regs *reg
59 u32 mfa; 59 u32 mfa;
60 struct service_processor *sp = (struct service_processor *)dev_id; 60 struct service_processor *sp = (struct service_processor *)dev_id;
61 void __iomem *base_address = sp->base_address; 61 void __iomem *base_address = sp->base_address;
62 char tsbuf[32];
62 63
63 if (!sp_interrupt_pending(base_address)) 64 if (!sp_interrupt_pending(base_address))
64 return IRQ_NONE; 65 return IRQ_NONE;
65 66
67 dbg("respond to interrupt at %s\n", get_timestamp(tsbuf));
68
66 if (mouse_interrupt_pending(sp)) { 69 if (mouse_interrupt_pending(sp)) {
67 ibmasm_handle_mouse_interrupt(sp); 70 ibmasm_handle_mouse_interrupt(sp, regs);
68 mfa = get_mfa_outbound(base_address);
69 clear_mouse_interrupt(sp); 71 clear_mouse_interrupt(sp);
70 set_mfa_outbound(base_address, mfa);
71 return IRQ_HANDLED;
72 } 72 }
73 73
74 mfa = get_mfa_outbound(base_address); 74 mfa = get_mfa_outbound(base_address);
75 if (valid_mfa(mfa)) { 75 if (valid_mfa(mfa)) {
76 struct i2o_message *msg = get_i2o_message(base_address, mfa); 76 struct i2o_message *msg = get_i2o_message(base_address, mfa);
77 ibmasm_receive_message(sp, &msg->data, incoming_data_size(msg)); 77 ibmasm_receive_message(sp, &msg->data, incoming_data_size(msg));
78 } 78 } else
79 dbg("didn't get a valid MFA\n");
80
79 set_mfa_outbound(base_address, mfa); 81 set_mfa_outbound(base_address, mfa);
82 dbg("finished interrupt at %s\n", get_timestamp(tsbuf));
83
80 return IRQ_HANDLED; 84 return IRQ_HANDLED;
81} 85}
diff --git a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c
index 777432ae764a..1fdf03fd2da7 100644
--- a/drivers/misc/ibmasm/module.c
+++ b/drivers/misc/ibmasm/module.c
@@ -56,17 +56,26 @@
56#include "lowlevel.h" 56#include "lowlevel.h"
57#include "remote.h" 57#include "remote.h"
58 58
59int ibmasm_debug = 0;
60module_param(ibmasm_debug, int , S_IRUGO | S_IWUSR);
61MODULE_PARM_DESC(ibmasm_debug, " Set debug mode on or off");
62
59 63
60static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 64static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
61{ 65{
62 int err, result = -ENOMEM; 66 int result;
63 struct service_processor *sp; 67 struct service_processor *sp;
64 68
65 if ((err = pci_enable_device(pdev))) { 69 if ((result = pci_enable_device(pdev))) {
66 printk(KERN_ERR "%s: can't enable PCI device at %s\n", 70 dev_err(&pdev->dev, "Failed to enable PCI device\n");
67 DRIVER_NAME, pci_name(pdev)); 71 return result;
68 return err;
69 } 72 }
73 if ((result = pci_request_regions(pdev, DRIVER_NAME))) {
74 dev_err(&pdev->dev, "Failed to allocate PCI resources\n");
75 goto error_resources;
76 }
77 /* vnc client won't work without bus-mastering */
78 pci_set_master(pdev);
70 79
71 sp = kmalloc(sizeof(struct service_processor), GFP_KERNEL); 80 sp = kmalloc(sizeof(struct service_processor), GFP_KERNEL);
72 if (sp == NULL) { 81 if (sp == NULL) {
@@ -76,6 +85,9 @@ static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_devi
76 } 85 }
77 memset(sp, 0, sizeof(struct service_processor)); 86 memset(sp, 0, sizeof(struct service_processor));
78 87
88 sp->lock = SPIN_LOCK_UNLOCKED;
89 INIT_LIST_HEAD(&sp->command_queue);
90
79 pci_set_drvdata(pdev, (void *)sp); 91 pci_set_drvdata(pdev, (void *)sp);
80 sp->dev = &pdev->dev; 92 sp->dev = &pdev->dev;
81 sp->number = pdev->bus->number; 93 sp->number = pdev->bus->number;
@@ -101,15 +113,6 @@ static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_devi
101 goto error_ioremap; 113 goto error_ioremap;
102 } 114 }
103 115
104 result = ibmasm_init_remote_queue(sp);
105 if (result) {
106 dev_err(sp->dev, "Failed to initialize remote queue\n");
107 goto error_remote_queue;
108 }
109
110 spin_lock_init(&sp->lock);
111 INIT_LIST_HEAD(&sp->command_queue);
112
113 result = request_irq(sp->irq, ibmasm_interrupt_handler, SA_SHIRQ, sp->devname, (void*)sp); 116 result = request_irq(sp->irq, ibmasm_interrupt_handler, SA_SHIRQ, sp->devname, (void*)sp);
114 if (result) { 117 if (result) {
115 dev_err(sp->dev, "Failed to register interrupt handler\n"); 118 dev_err(sp->dev, "Failed to register interrupt handler\n");
@@ -117,7 +120,12 @@ static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_devi
117 } 120 }
118 121
119 enable_sp_interrupts(sp->base_address); 122 enable_sp_interrupts(sp->base_address);
120 disable_mouse_interrupts(sp); 123
124 result = ibmasm_init_remote_input_dev(sp);
125 if (result) {
126 dev_err(sp->dev, "Failed to initialize remote queue\n");
127 goto error_send_message;
128 }
121 129
122 result = ibmasm_send_driver_vpd(sp); 130 result = ibmasm_send_driver_vpd(sp);
123 if (result) { 131 if (result) {
@@ -133,30 +141,25 @@ static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_devi
133 141
134 ibmasm_register_uart(sp); 142 ibmasm_register_uart(sp);
135 143
136 dev_printk(KERN_DEBUG, &pdev->dev, "WARNING: This software may not be supported or function\n");
137 dev_printk(KERN_DEBUG, &pdev->dev, "correctly on your IBM server. Please consult the IBM\n");
138 dev_printk(KERN_DEBUG, &pdev->dev, "ServerProven website\n");
139 dev_printk(KERN_DEBUG, &pdev->dev, "http://www.pc.ibm.com/ww/eserver/xseries/serverproven\n");
140 dev_printk(KERN_DEBUG, &pdev->dev, "for information on the specific driver level and support\n");
141 dev_printk(KERN_DEBUG, &pdev->dev, "statement for your IBM server.\n");
142
143 return 0; 144 return 0;
144 145
145error_send_message: 146error_send_message:
146 disable_sp_interrupts(sp->base_address); 147 disable_sp_interrupts(sp->base_address);
148 ibmasm_free_remote_input_dev(sp);
147 free_irq(sp->irq, (void *)sp); 149 free_irq(sp->irq, (void *)sp);
148error_request_irq: 150error_request_irq:
149 ibmasm_free_remote_queue(sp);
150error_remote_queue:
151 iounmap(sp->base_address); 151 iounmap(sp->base_address);
152error_ioremap: 152error_ioremap:
153 ibmasm_heartbeat_exit(sp); 153 ibmasm_heartbeat_exit(sp);
154error_heartbeat: 154error_heartbeat:
155 ibmasm_event_buffer_exit(sp); 155 ibmasm_event_buffer_exit(sp);
156error_eventbuffer: 156error_eventbuffer:
157 pci_set_drvdata(pdev, NULL);
157 kfree(sp); 158 kfree(sp);
158error_kmalloc: 159error_kmalloc:
159 pci_disable_device(pdev); 160 pci_release_regions(pdev);
161error_resources:
162 pci_disable_device(pdev);
160 163
161 return result; 164 return result;
162} 165}
@@ -165,16 +168,24 @@ static void __devexit ibmasm_remove_one(struct pci_dev *pdev)
165{ 168{
166 struct service_processor *sp = (struct service_processor *)pci_get_drvdata(pdev); 169 struct service_processor *sp = (struct service_processor *)pci_get_drvdata(pdev);
167 170
171 dbg("Unregistering UART\n");
168 ibmasm_unregister_uart(sp); 172 ibmasm_unregister_uart(sp);
169 ibmasm_send_os_state(sp, SYSTEM_STATE_OS_DOWN); 173 dbg("Sending OS down message\n");
174 if (ibmasm_send_os_state(sp, SYSTEM_STATE_OS_DOWN))
175 err("failed to get repsonse to 'Send OS State' command\n");
176 dbg("Disabling heartbeats\n");
177 ibmasm_heartbeat_exit(sp);
178 dbg("Disabling interrupts\n");
170 disable_sp_interrupts(sp->base_address); 179 disable_sp_interrupts(sp->base_address);
171 disable_mouse_interrupts(sp); 180 dbg("Freeing SP irq\n");
172 free_irq(sp->irq, (void *)sp); 181 free_irq(sp->irq, (void *)sp);
173 ibmasm_heartbeat_exit(sp); 182 dbg("Cleaning up\n");
174 ibmasm_free_remote_queue(sp); 183 ibmasm_free_remote_input_dev(sp);
175 iounmap(sp->base_address); 184 iounmap(sp->base_address);
176 ibmasm_event_buffer_exit(sp); 185 ibmasm_event_buffer_exit(sp);
186 pci_set_drvdata(pdev, NULL);
177 kfree(sp); 187 kfree(sp);
188 pci_release_regions(pdev);
178 pci_disable_device(pdev); 189 pci_disable_device(pdev);
179} 190}
180 191
diff --git a/drivers/misc/ibmasm/r_heartbeat.c b/drivers/misc/ibmasm/r_heartbeat.c
index 93d9c1b2ad6f..f8fdb2d5417e 100644
--- a/drivers/misc/ibmasm/r_heartbeat.c
+++ b/drivers/misc/ibmasm/r_heartbeat.c
@@ -63,7 +63,7 @@ int ibmasm_start_reverse_heartbeat(struct service_processor *sp, struct reverse_
63 int times_failed = 0; 63 int times_failed = 0;
64 int result = 1; 64 int result = 1;
65 65
66 cmd = ibmasm_new_command(sizeof rhb_dot_cmd); 66 cmd = ibmasm_new_command(sp, sizeof rhb_dot_cmd);
67 if (!cmd) 67 if (!cmd)
68 return -ENOMEM; 68 return -ENOMEM;
69 69
diff --git a/drivers/misc/ibmasm/remote.c b/drivers/misc/ibmasm/remote.c
index 520c3f10c271..d3c48d23ee51 100644
--- a/drivers/misc/ibmasm/remote.c
+++ b/drivers/misc/ibmasm/remote.c
@@ -1,4 +1,3 @@
1
2/* 1/*
3 * IBM ASM Service Processor Device Driver 2 * IBM ASM Service Processor Device Driver
4 * 3 *
@@ -18,135 +17,256 @@
18 * 17 *
19 * Copyright (C) IBM Corporation, 2004 18 * Copyright (C) IBM Corporation, 2004
20 * 19 *
21 * Author: Max Asböck <amax@us.ibm.com> 20 * Authors: Max Asböck <amax@us.ibm.com>
21 * Vernon Mauery <vernux@us.ibm.com>
22 * 22 *
23 */ 23 */
24 24
25/* Remote mouse and keyboard event handling functions */ 25/* Remote mouse and keyboard event handling functions */
26 26
27#include <linux/pci.h>
27#include "ibmasm.h" 28#include "ibmasm.h"
28#include "remote.h" 29#include "remote.h"
29 30
30int ibmasm_init_remote_queue(struct service_processor *sp) 31static int xmax = 1600;
31{ 32static int ymax = 1200;
32 struct remote_queue *q = &sp->remote_queue;
33
34 disable_mouse_interrupts(sp);
35 33
36 q->open = 0;
37 q->size = 0;
38 34
39 q->start = kmalloc(DRIVER_REMOTE_QUEUE_SIZE * sizeof(struct remote_event), GFP_KERNEL); 35static unsigned short xlate_high[XLATE_SIZE] = {
40 if (q->start == 0) 36 [KEY_SYM_ENTER & 0xff] = KEY_ENTER,
41 return -ENOMEM; 37 [KEY_SYM_KPSLASH & 0xff] = KEY_KPSLASH,
38 [KEY_SYM_KPSTAR & 0xff] = KEY_KPASTERISK,
39 [KEY_SYM_KPMINUS & 0xff] = KEY_KPMINUS,
40 [KEY_SYM_KPDOT & 0xff] = KEY_KPDOT,
41 [KEY_SYM_KPPLUS & 0xff] = KEY_KPPLUS,
42 [KEY_SYM_KP0 & 0xff] = KEY_KP0,
43 [KEY_SYM_KP1 & 0xff] = KEY_KP1,
44 [KEY_SYM_KP2 & 0xff] = KEY_KP2, [KEY_SYM_KPDOWN & 0xff] = KEY_KP2,
45 [KEY_SYM_KP3 & 0xff] = KEY_KP3,
46 [KEY_SYM_KP4 & 0xff] = KEY_KP4, [KEY_SYM_KPLEFT & 0xff] = KEY_KP4,
47 [KEY_SYM_KP5 & 0xff] = KEY_KP5,
48 [KEY_SYM_KP6 & 0xff] = KEY_KP6, [KEY_SYM_KPRIGHT & 0xff] = KEY_KP6,
49 [KEY_SYM_KP7 & 0xff] = KEY_KP7,
50 [KEY_SYM_KP8 & 0xff] = KEY_KP8, [KEY_SYM_KPUP & 0xff] = KEY_KP8,
51 [KEY_SYM_KP9 & 0xff] = KEY_KP9,
52 [KEY_SYM_BK_SPC & 0xff] = KEY_BACKSPACE,
53 [KEY_SYM_TAB & 0xff] = KEY_TAB,
54 [KEY_SYM_CTRL & 0xff] = KEY_LEFTCTRL,
55 [KEY_SYM_ALT & 0xff] = KEY_LEFTALT,
56 [KEY_SYM_INSERT & 0xff] = KEY_INSERT,
57 [KEY_SYM_DELETE & 0xff] = KEY_DELETE,
58 [KEY_SYM_SHIFT & 0xff] = KEY_LEFTSHIFT,
59 [KEY_SYM_UARROW & 0xff] = KEY_UP,
60 [KEY_SYM_DARROW & 0xff] = KEY_DOWN,
61 [KEY_SYM_LARROW & 0xff] = KEY_LEFT,
62 [KEY_SYM_RARROW & 0xff] = KEY_RIGHT,
63 [KEY_SYM_ESCAPE & 0xff] = KEY_ESC,
64 [KEY_SYM_PAGEUP & 0xff] = KEY_PAGEUP,
65 [KEY_SYM_PAGEDOWN & 0xff] = KEY_PAGEDOWN,
66 [KEY_SYM_HOME & 0xff] = KEY_HOME,
67 [KEY_SYM_END & 0xff] = KEY_END,
68 [KEY_SYM_F1 & 0xff] = KEY_F1,
69 [KEY_SYM_F2 & 0xff] = KEY_F2,
70 [KEY_SYM_F3 & 0xff] = KEY_F3,
71 [KEY_SYM_F4 & 0xff] = KEY_F4,
72 [KEY_SYM_F5 & 0xff] = KEY_F5,
73 [KEY_SYM_F6 & 0xff] = KEY_F6,
74 [KEY_SYM_F7 & 0xff] = KEY_F7,
75 [KEY_SYM_F8 & 0xff] = KEY_F8,
76 [KEY_SYM_F9 & 0xff] = KEY_F9,
77 [KEY_SYM_F10 & 0xff] = KEY_F10,
78 [KEY_SYM_F11 & 0xff] = KEY_F11,
79 [KEY_SYM_F12 & 0xff] = KEY_F12,
80 [KEY_SYM_CAP_LOCK & 0xff] = KEY_CAPSLOCK,
81 [KEY_SYM_NUM_LOCK & 0xff] = KEY_NUMLOCK,
82 [KEY_SYM_SCR_LOCK & 0xff] = KEY_SCROLLLOCK,
83};
84static unsigned short xlate[XLATE_SIZE] = {
85 [NO_KEYCODE] = KEY_RESERVED,
86 [KEY_SYM_SPACE] = KEY_SPACE,
87 [KEY_SYM_TILDE] = KEY_GRAVE, [KEY_SYM_BKTIC] = KEY_GRAVE,
88 [KEY_SYM_ONE] = KEY_1, [KEY_SYM_BANG] = KEY_1,
89 [KEY_SYM_TWO] = KEY_2, [KEY_SYM_AT] = KEY_2,
90 [KEY_SYM_THREE] = KEY_3, [KEY_SYM_POUND] = KEY_3,
91 [KEY_SYM_FOUR] = KEY_4, [KEY_SYM_DOLLAR] = KEY_4,
92 [KEY_SYM_FIVE] = KEY_5, [KEY_SYM_PERCENT] = KEY_5,
93 [KEY_SYM_SIX] = KEY_6, [KEY_SYM_CARAT] = KEY_6,
94 [KEY_SYM_SEVEN] = KEY_7, [KEY_SYM_AMPER] = KEY_7,
95 [KEY_SYM_EIGHT] = KEY_8, [KEY_SYM_STAR] = KEY_8,
96 [KEY_SYM_NINE] = KEY_9, [KEY_SYM_LPAREN] = KEY_9,
97 [KEY_SYM_ZERO] = KEY_0, [KEY_SYM_RPAREN] = KEY_0,
98 [KEY_SYM_MINUS] = KEY_MINUS, [KEY_SYM_USCORE] = KEY_MINUS,
99 [KEY_SYM_EQUAL] = KEY_EQUAL, [KEY_SYM_PLUS] = KEY_EQUAL,
100 [KEY_SYM_LBRKT] = KEY_LEFTBRACE, [KEY_SYM_LCURLY] = KEY_LEFTBRACE,
101 [KEY_SYM_RBRKT] = KEY_RIGHTBRACE, [KEY_SYM_RCURLY] = KEY_RIGHTBRACE,
102 [KEY_SYM_SLASH] = KEY_BACKSLASH, [KEY_SYM_PIPE] = KEY_BACKSLASH,
103 [KEY_SYM_TIC] = KEY_APOSTROPHE, [KEY_SYM_QUOTE] = KEY_APOSTROPHE,
104 [KEY_SYM_SEMIC] = KEY_SEMICOLON, [KEY_SYM_COLON] = KEY_SEMICOLON,
105 [KEY_SYM_COMMA] = KEY_COMMA, [KEY_SYM_LT] = KEY_COMMA,
106 [KEY_SYM_PERIOD] = KEY_DOT, [KEY_SYM_GT] = KEY_DOT,
107 [KEY_SYM_BSLASH] = KEY_SLASH, [KEY_SYM_QMARK] = KEY_SLASH,
108 [KEY_SYM_A] = KEY_A, [KEY_SYM_a] = KEY_A,
109 [KEY_SYM_B] = KEY_B, [KEY_SYM_b] = KEY_B,
110 [KEY_SYM_C] = KEY_C, [KEY_SYM_c] = KEY_C,
111 [KEY_SYM_D] = KEY_D, [KEY_SYM_d] = KEY_D,
112 [KEY_SYM_E] = KEY_E, [KEY_SYM_e] = KEY_E,
113 [KEY_SYM_F] = KEY_F, [KEY_SYM_f] = KEY_F,
114 [KEY_SYM_G] = KEY_G, [KEY_SYM_g] = KEY_G,
115 [KEY_SYM_H] = KEY_H, [KEY_SYM_h] = KEY_H,
116 [KEY_SYM_I] = KEY_I, [KEY_SYM_i] = KEY_I,
117 [KEY_SYM_J] = KEY_J, [KEY_SYM_j] = KEY_J,
118 [KEY_SYM_K] = KEY_K, [KEY_SYM_k] = KEY_K,
119 [KEY_SYM_L] = KEY_L, [KEY_SYM_l] = KEY_L,
120 [KEY_SYM_M] = KEY_M, [KEY_SYM_m] = KEY_M,
121 [KEY_SYM_N] = KEY_N, [KEY_SYM_n] = KEY_N,
122 [KEY_SYM_O] = KEY_O, [KEY_SYM_o] = KEY_O,
123 [KEY_SYM_P] = KEY_P, [KEY_SYM_p] = KEY_P,
124 [KEY_SYM_Q] = KEY_Q, [KEY_SYM_q] = KEY_Q,
125 [KEY_SYM_R] = KEY_R, [KEY_SYM_r] = KEY_R,
126 [KEY_SYM_S] = KEY_S, [KEY_SYM_s] = KEY_S,
127 [KEY_SYM_T] = KEY_T, [KEY_SYM_t] = KEY_T,
128 [KEY_SYM_U] = KEY_U, [KEY_SYM_u] = KEY_U,
129 [KEY_SYM_V] = KEY_V, [KEY_SYM_v] = KEY_V,
130 [KEY_SYM_W] = KEY_W, [KEY_SYM_w] = KEY_W,
131 [KEY_SYM_X] = KEY_X, [KEY_SYM_x] = KEY_X,
132 [KEY_SYM_Y] = KEY_Y, [KEY_SYM_y] = KEY_Y,
133 [KEY_SYM_Z] = KEY_Z, [KEY_SYM_z] = KEY_Z,
134};
42 135
43 q->end = q->start + DRIVER_REMOTE_QUEUE_SIZE; 136static char remote_mouse_name[] = "ibmasm RSA I remote mouse";
44 q->reader = q->start; 137static char remote_keybd_name[] = "ibmasm RSA I remote keyboard";
45 q->writer = q->start;
46 q->size = DRIVER_REMOTE_QUEUE_SIZE;
47 init_waitqueue_head(&q->wait);
48 138
49 return 0; 139static void print_input(struct remote_input *input)
50}
51
52void ibmasm_free_remote_queue(struct service_processor *sp)
53{ 140{
54 kfree(sp->remote_queue.start); 141 if (input->type == INPUT_TYPE_MOUSE) {
142 unsigned char buttons = input->mouse_buttons;
143 dbg("remote mouse movement: (x,y)=(%d,%d)%s%s%s%s\n",
144 input->data.mouse.x, input->data.mouse.y,
145 (buttons)?" -- buttons:":"",
146 (buttons & REMOTE_BUTTON_LEFT)?"left ":"",
147 (buttons & REMOTE_BUTTON_MIDDLE)?"middle ":"",
148 (buttons & REMOTE_BUTTON_RIGHT)?"right":""
149 );
150 } else {
151 dbg("remote keypress (code, flag, down):"
152 "%d (0x%x) [0x%x] [0x%x]\n",
153 input->data.keyboard.key_code,
154 input->data.keyboard.key_code,
155 input->data.keyboard.key_flag,
156 input->data.keyboard.key_down
157 );
158 }
55} 159}
56 160
57void ibmasm_advance_reader(struct remote_queue *q, unsigned int n) 161static void send_mouse_event(struct input_dev *dev, struct pt_regs *regs,
162 struct remote_input *input)
58{ 163{
59 q->reader += n; 164 unsigned char buttons = input->mouse_buttons;
60 if (q->reader >= q->end)
61 q->reader -= q->size;
62}
63 165
64size_t ibmasm_events_available(struct remote_queue *q) 166 input_regs(dev, regs);
65{ 167 input_report_abs(dev, ABS_X, input->data.mouse.x);
66 ssize_t diff = q->writer - q->reader; 168 input_report_abs(dev, ABS_Y, input->data.mouse.y);
67 169 input_report_key(dev, BTN_LEFT, buttons & REMOTE_BUTTON_LEFT);
68 return (diff >= 0) ? diff : q->end - q->reader; 170 input_report_key(dev, BTN_MIDDLE, buttons & REMOTE_BUTTON_MIDDLE);
171 input_report_key(dev, BTN_RIGHT, buttons & REMOTE_BUTTON_RIGHT);
172 input_sync(dev);
69} 173}
70
71 174
72static int space_free(struct remote_queue *q) 175static void send_keyboard_event(struct input_dev *dev, struct pt_regs *regs,
176 struct remote_input *input)
73{ 177{
74 if (q->reader == q->writer) 178 unsigned int key;
75 return q->size - 1; 179 unsigned short code = input->data.keyboard.key_code;
76 180
77 return ( (q->reader + q->size - q->writer) % q->size ) - 1; 181 if (code & 0xff00)
182 key = xlate_high[code & 0xff];
183 else
184 key = xlate[code];
185 input_regs(dev, regs);
186 input_report_key(dev, key, (input->data.keyboard.key_down) ? 1 : 0);
187 input_sync(dev);
78} 188}
79 189
80static void set_mouse_event(struct remote_input *input, struct mouse_event *mouse) 190void ibmasm_handle_mouse_interrupt(struct service_processor *sp,
191 struct pt_regs *regs)
81{ 192{
82 static char last_buttons = 0; 193 unsigned long reader;
194 unsigned long writer;
195 struct remote_input input;
83 196
84 mouse->x = input->data.mouse.x; 197 reader = get_queue_reader(sp);
85 mouse->y = input->data.mouse.y; 198 writer = get_queue_writer(sp);
86 199
87 if (input->mouse_buttons == REMOTE_MOUSE_DOUBLE_CLICK) { 200 while (reader != writer) {
88 mouse->buttons = REMOTE_MOUSE_DOUBLE_CLICK; 201 memcpy_fromio(&input, get_queue_entry(sp, reader),
89 last_buttons = 0; 202 sizeof(struct remote_input));
90 return;
91 }
92 mouse->transitions = last_buttons ^ input->mouse_buttons;
93 mouse->buttons = input->mouse_buttons;
94 203
95 last_buttons = input->mouse_buttons; 204 print_input(&input);
96} 205 if (input.type == INPUT_TYPE_MOUSE) {
206 send_mouse_event(&sp->remote->mouse_dev, regs, &input);
207 } else if (input.type == INPUT_TYPE_KEYBOARD) {
208 send_keyboard_event(&sp->remote->keybd_dev, regs, &input);
209 } else
210 break;
97 211
98static void set_keyboard_event(struct remote_input *input, struct keyboard_event *keyboard) 212 reader = advance_queue_reader(sp, reader);
99{ 213 writer = get_queue_writer(sp);
100 keyboard->key_code = input->data.keyboard.key_code; 214 }
101 keyboard->key_down = input->data.keyboard.key_down;
102} 215}
103 216
104static int add_to_driver_queue(struct remote_queue *q, struct remote_input *input) 217int ibmasm_init_remote_input_dev(struct service_processor *sp)
105{ 218{
106 struct remote_event *event = q->writer; 219 /* set up the mouse input device */
220 struct ibmasm_remote *remote;
221 struct pci_dev *pdev = to_pci_dev(sp->dev);
222 int i;
107 223
108 if (space_free(q) < 1) { 224 sp->remote = remote = kmalloc(sizeof(*remote), GFP_KERNEL);
109 return 1; 225 if (!remote)
110 } 226 return -ENOMEM;
111 227
112 switch(input->type) { 228 memset(remote, 0, sizeof(*remote));
113 case (INPUT_TYPE_MOUSE):
114 event->type = INPUT_TYPE_MOUSE;
115 set_mouse_event(input, &event->data.mouse);
116 break;
117 case (INPUT_TYPE_KEYBOARD):
118 event->type = INPUT_TYPE_KEYBOARD;
119 set_keyboard_event(input, &event->data.keyboard);
120 break;
121 default:
122 return 0;
123 }
124 event->type = input->type;
125 229
126 q->writer++; 230 remote->mouse_dev.private = remote;
127 if (q->writer == q->end) 231 init_input_dev(&remote->mouse_dev);
128 q->writer = q->start; 232 remote->mouse_dev.id.vendor = pdev->vendor;
233 remote->mouse_dev.id.product = pdev->device;
234 remote->mouse_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
235 remote->mouse_dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) |
236 BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
237 set_bit(BTN_TOUCH, remote->mouse_dev.keybit);
238 remote->mouse_dev.name = remote_mouse_name;
239 input_set_abs_params(&remote->mouse_dev, ABS_X, 0, xmax, 0, 0);
240 input_set_abs_params(&remote->mouse_dev, ABS_Y, 0, ymax, 0, 0);
129 241
130 return 0; 242 remote->keybd_dev.private = remote;
131} 243 init_input_dev(&remote->keybd_dev);
132 244 remote->keybd_dev.id.vendor = pdev->vendor;
245 remote->keybd_dev.id.product = pdev->device;
246 remote->keybd_dev.evbit[0] = BIT(EV_KEY);
247 remote->keybd_dev.name = remote_keybd_name;
133 248
134void ibmasm_handle_mouse_interrupt(struct service_processor *sp) 249 for (i=0; i<XLATE_SIZE; i++) {
135{ 250 if (xlate_high[i])
136 unsigned long reader; 251 set_bit(xlate_high[i], remote->keybd_dev.keybit);
137 unsigned long writer; 252 if (xlate[i])
138 struct remote_input input; 253 set_bit(xlate[i], remote->keybd_dev.keybit);
254 }
139 255
140 reader = get_queue_reader(sp); 256 input_register_device(&remote->mouse_dev);
141 writer = get_queue_writer(sp); 257 input_register_device(&remote->keybd_dev);
258 enable_mouse_interrupts(sp);
142 259
143 while (reader != writer) { 260 printk(KERN_INFO "ibmasm remote responding to events on RSA card %d\n", sp->number);
144 memcpy(&input, (void *)get_queue_entry(sp, reader), sizeof(struct remote_input));
145 261
146 if (add_to_driver_queue(&sp->remote_queue, &input)) 262 return 0;
147 break; 263}
148 264
149 reader = advance_queue_reader(sp, reader); 265void ibmasm_free_remote_input_dev(struct service_processor *sp)
150 } 266{
151 wake_up_interruptible(&sp->remote_queue.wait); 267 disable_mouse_interrupts(sp);
268 input_unregister_device(&sp->remote->keybd_dev);
269 input_unregister_device(&sp->remote->mouse_dev);
270 kfree(sp->remote);
152} 271}
272
diff --git a/drivers/misc/ibmasm/remote.h b/drivers/misc/ibmasm/remote.h
index a8eb19f02d3f..b7076a8442d2 100644
--- a/drivers/misc/ibmasm/remote.h
+++ b/drivers/misc/ibmasm/remote.h
@@ -51,11 +51,13 @@
51 51
52 52
53/* mouse button states received from SP */ 53/* mouse button states received from SP */
54#define REMOTE_MOUSE_DOUBLE_CLICK 0xF0 54#define REMOTE_DOUBLE_CLICK 0xF0
55#define REMOTE_MOUSE_BUTTON_LEFT 0x01 55#define REMOTE_BUTTON_LEFT 0x01
56#define REMOTE_MOUSE_BUTTON_MIDDLE 0x02 56#define REMOTE_BUTTON_MIDDLE 0x02
57#define REMOTE_MOUSE_BUTTON_RIGHT 0x04 57#define REMOTE_BUTTON_RIGHT 0x04
58 58
59/* size of keysym/keycode translation matricies */
60#define XLATE_SIZE 256
59 61
60struct mouse_input { 62struct mouse_input {
61 unsigned short y; 63 unsigned short y;
@@ -83,11 +85,13 @@ struct remote_input {
83 unsigned char pad3; 85 unsigned char pad3;
84}; 86};
85 87
86#define mouse_addr(sp) sp->base_address + CONDOR_MOUSE_DATA 88#define mouse_addr(sp) (sp->base_address + CONDOR_MOUSE_DATA)
87#define display_width(sp) mouse_addr(sp) + CONDOR_INPUT_DISPLAY_RESX 89#define display_width(sp) (mouse_addr(sp) + CONDOR_INPUT_DISPLAY_RESX)
88#define display_height(sp) mouse_addr(sp) + CONDOR_INPUT_DISPLAY_RESY 90#define display_height(sp) (mouse_addr(sp) + CONDOR_INPUT_DISPLAY_RESY)
89#define display_depth(sp) mouse_addr(sp) + CONDOR_INPUT_DISPLAY_BITS 91#define display_depth(sp) (mouse_addr(sp) + CONDOR_INPUT_DISPLAY_BITS)
90#define vnc_status(sp) mouse_addr(sp) + CONDOR_OUTPUT_VNC_STATUS 92#define desktop_info(sp) (mouse_addr(sp) + CONDOR_INPUT_DESKTOP_INFO)
93#define vnc_status(sp) (mouse_addr(sp) + CONDOR_OUTPUT_VNC_STATUS)
94#define isr_control(sp) (mouse_addr(sp) + CONDOR_MOUSE_ISR_CONTROL)
91 95
92#define mouse_interrupt_pending(sp) readl(mouse_addr(sp) + CONDOR_MOUSE_ISR_STATUS) 96#define mouse_interrupt_pending(sp) readl(mouse_addr(sp) + CONDOR_MOUSE_ISR_STATUS)
93#define clear_mouse_interrupt(sp) writel(0, mouse_addr(sp) + CONDOR_MOUSE_ISR_STATUS) 97#define clear_mouse_interrupt(sp) writel(0, mouse_addr(sp) + CONDOR_MOUSE_ISR_STATUS)
@@ -101,10 +105,10 @@ struct remote_input {
101#define get_queue_reader(sp) readl(mouse_addr(sp) + CONDOR_MOUSE_Q_READER) 105#define get_queue_reader(sp) readl(mouse_addr(sp) + CONDOR_MOUSE_Q_READER)
102#define set_queue_reader(sp, reader) writel(reader, mouse_addr(sp) + CONDOR_MOUSE_Q_READER) 106#define set_queue_reader(sp, reader) writel(reader, mouse_addr(sp) + CONDOR_MOUSE_Q_READER)
103 107
104#define queue_begin mouse_addr(sp) + CONDOR_MOUSE_Q_BEGIN 108#define queue_begin (mouse_addr(sp) + CONDOR_MOUSE_Q_BEGIN)
105 109
106#define get_queue_entry(sp, read_index) \ 110#define get_queue_entry(sp, read_index) \
107 queue_begin + read_index * sizeof(struct remote_input) 111 ((void*)(queue_begin + read_index * sizeof(struct remote_input)))
108 112
109static inline int advance_queue_reader(struct service_processor *sp, unsigned long reader) 113static inline int advance_queue_reader(struct service_processor *sp, unsigned long reader)
110{ 114{
@@ -116,4 +120,151 @@ static inline int advance_queue_reader(struct service_processor *sp, unsigned lo
116 return reader; 120 return reader;
117} 121}
118 122
123#define NO_KEYCODE 0
124#define KEY_SYM_BK_SPC 0xFF08
125#define KEY_SYM_TAB 0xFF09
126#define KEY_SYM_ENTER 0xFF0D
127#define KEY_SYM_SCR_LOCK 0xFF14
128#define KEY_SYM_ESCAPE 0xFF1B
129#define KEY_SYM_HOME 0xFF50
130#define KEY_SYM_LARROW 0xFF51
131#define KEY_SYM_UARROW 0xFF52
132#define KEY_SYM_RARROW 0xFF53
133#define KEY_SYM_DARROW 0xFF54
134#define KEY_SYM_PAGEUP 0xFF55
135#define KEY_SYM_PAGEDOWN 0xFF56
136#define KEY_SYM_END 0xFF57
137#define KEY_SYM_INSERT 0xFF63
138#define KEY_SYM_NUM_LOCK 0xFF7F
139#define KEY_SYM_KPSTAR 0xFFAA
140#define KEY_SYM_KPPLUS 0xFFAB
141#define KEY_SYM_KPMINUS 0xFFAD
142#define KEY_SYM_KPDOT 0xFFAE
143#define KEY_SYM_KPSLASH 0xFFAF
144#define KEY_SYM_KPRIGHT 0xFF96
145#define KEY_SYM_KPUP 0xFF97
146#define KEY_SYM_KPLEFT 0xFF98
147#define KEY_SYM_KPDOWN 0xFF99
148#define KEY_SYM_KP0 0xFFB0
149#define KEY_SYM_KP1 0xFFB1
150#define KEY_SYM_KP2 0xFFB2
151#define KEY_SYM_KP3 0xFFB3
152#define KEY_SYM_KP4 0xFFB4
153#define KEY_SYM_KP5 0xFFB5
154#define KEY_SYM_KP6 0xFFB6
155#define KEY_SYM_KP7 0xFFB7
156#define KEY_SYM_KP8 0xFFB8
157#define KEY_SYM_KP9 0xFFB9
158#define KEY_SYM_F1 0xFFBE // 1B 5B 5B 41
159#define KEY_SYM_F2 0xFFBF // 1B 5B 5B 42
160#define KEY_SYM_F3 0xFFC0 // 1B 5B 5B 43
161#define KEY_SYM_F4 0xFFC1 // 1B 5B 5B 44
162#define KEY_SYM_F5 0xFFC2 // 1B 5B 5B 45
163#define KEY_SYM_F6 0xFFC3 // 1B 5B 31 37 7E
164#define KEY_SYM_F7 0xFFC4 // 1B 5B 31 38 7E
165#define KEY_SYM_F8 0xFFC5 // 1B 5B 31 39 7E
166#define KEY_SYM_F9 0xFFC6 // 1B 5B 32 30 7E
167#define KEY_SYM_F10 0xFFC7 // 1B 5B 32 31 7E
168#define KEY_SYM_F11 0xFFC8 // 1B 5B 32 33 7E
169#define KEY_SYM_F12 0xFFC9 // 1B 5B 32 34 7E
170#define KEY_SYM_SHIFT 0xFFE1
171#define KEY_SYM_CTRL 0xFFE3
172#define KEY_SYM_ALT 0xFFE9
173#define KEY_SYM_CAP_LOCK 0xFFE5
174#define KEY_SYM_DELETE 0xFFFF
175#define KEY_SYM_TILDE 0x60
176#define KEY_SYM_BKTIC 0x7E
177#define KEY_SYM_ONE 0x31
178#define KEY_SYM_BANG 0x21
179#define KEY_SYM_TWO 0x32
180#define KEY_SYM_AT 0x40
181#define KEY_SYM_THREE 0x33
182#define KEY_SYM_POUND 0x23
183#define KEY_SYM_FOUR 0x34
184#define KEY_SYM_DOLLAR 0x24
185#define KEY_SYM_FIVE 0x35
186#define KEY_SYM_PERCENT 0x25
187#define KEY_SYM_SIX 0x36
188#define KEY_SYM_CARAT 0x5E
189#define KEY_SYM_SEVEN 0x37
190#define KEY_SYM_AMPER 0x26
191#define KEY_SYM_EIGHT 0x38
192#define KEY_SYM_STAR 0x2A
193#define KEY_SYM_NINE 0x39
194#define KEY_SYM_LPAREN 0x28
195#define KEY_SYM_ZERO 0x30
196#define KEY_SYM_RPAREN 0x29
197#define KEY_SYM_MINUS 0x2D
198#define KEY_SYM_USCORE 0x5F
199#define KEY_SYM_EQUAL 0x2B
200#define KEY_SYM_PLUS 0x3D
201#define KEY_SYM_LBRKT 0x5B
202#define KEY_SYM_LCURLY 0x7B
203#define KEY_SYM_RBRKT 0x5D
204#define KEY_SYM_RCURLY 0x7D
205#define KEY_SYM_SLASH 0x5C
206#define KEY_SYM_PIPE 0x7C
207#define KEY_SYM_TIC 0x27
208#define KEY_SYM_QUOTE 0x22
209#define KEY_SYM_SEMIC 0x3B
210#define KEY_SYM_COLON 0x3A
211#define KEY_SYM_COMMA 0x2C
212#define KEY_SYM_LT 0x3C
213#define KEY_SYM_PERIOD 0x2E
214#define KEY_SYM_GT 0x3E
215#define KEY_SYM_BSLASH 0x2F
216#define KEY_SYM_QMARK 0x3F
217#define KEY_SYM_A 0x41
218#define KEY_SYM_B 0x42
219#define KEY_SYM_C 0x43
220#define KEY_SYM_D 0x44
221#define KEY_SYM_E 0x45
222#define KEY_SYM_F 0x46
223#define KEY_SYM_G 0x47
224#define KEY_SYM_H 0x48
225#define KEY_SYM_I 0x49
226#define KEY_SYM_J 0x4A
227#define KEY_SYM_K 0x4B
228#define KEY_SYM_L 0x4C
229#define KEY_SYM_M 0x4D
230#define KEY_SYM_N 0x4E
231#define KEY_SYM_O 0x4F
232#define KEY_SYM_P 0x50
233#define KEY_SYM_Q 0x51
234#define KEY_SYM_R 0x52
235#define KEY_SYM_S 0x53
236#define KEY_SYM_T 0x54
237#define KEY_SYM_U 0x55
238#define KEY_SYM_V 0x56
239#define KEY_SYM_W 0x57
240#define KEY_SYM_X 0x58
241#define KEY_SYM_Y 0x59
242#define KEY_SYM_Z 0x5A
243#define KEY_SYM_a 0x61
244#define KEY_SYM_b 0x62
245#define KEY_SYM_c 0x63
246#define KEY_SYM_d 0x64
247#define KEY_SYM_e 0x65
248#define KEY_SYM_f 0x66
249#define KEY_SYM_g 0x67
250#define KEY_SYM_h 0x68
251#define KEY_SYM_i 0x69
252#define KEY_SYM_j 0x6A
253#define KEY_SYM_k 0x6B
254#define KEY_SYM_l 0x6C
255#define KEY_SYM_m 0x6D
256#define KEY_SYM_n 0x6E
257#define KEY_SYM_o 0x6F
258#define KEY_SYM_p 0x70
259#define KEY_SYM_q 0x71
260#define KEY_SYM_r 0x72
261#define KEY_SYM_s 0x73
262#define KEY_SYM_t 0x74
263#define KEY_SYM_u 0x75
264#define KEY_SYM_v 0x76
265#define KEY_SYM_w 0x77
266#define KEY_SYM_x 0x78
267#define KEY_SYM_y 0x79
268#define KEY_SYM_z 0x7A
269#define KEY_SYM_SPACE 0x20
119#endif /* _IBMASM_REMOTE_H_ */ 270#endif /* _IBMASM_REMOTE_H_ */
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index b5e076043431..80ec9aa575bb 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -2202,9 +2202,8 @@ boomerang_start_xmit(struct sk_buff *skb, struct net_device *dev)
2202 2202
2203 if (vortex_debug > 6) { 2203 if (vortex_debug > 6) {
2204 printk(KERN_DEBUG "boomerang_start_xmit()\n"); 2204 printk(KERN_DEBUG "boomerang_start_xmit()\n");
2205 if (vortex_debug > 3) 2205 printk(KERN_DEBUG "%s: Trying to send a packet, Tx index %d.\n",
2206 printk(KERN_DEBUG "%s: Trying to send a packet, Tx index %d.\n", 2206 dev->name, vp->cur_tx);
2207 dev->name, vp->cur_tx);
2208 } 2207 }
2209 2208
2210 if (vp->cur_tx - vp->dirty_tx >= TX_RING_SIZE) { 2209 if (vp->cur_tx - vp->dirty_tx >= TX_RING_SIZE) {
diff --git a/drivers/net/8390.c b/drivers/net/8390.c
index bab16bcc9ae5..6d76f3a99b17 100644
--- a/drivers/net/8390.c
+++ b/drivers/net/8390.c
@@ -225,9 +225,9 @@ void ei_tx_timeout(struct net_device *dev)
225 unsigned long icucr; 225 unsigned long icucr;
226 226
227 local_irq_save(flags); 227 local_irq_save(flags);
228 icucr = inl(ICUCR1); 228 icucr = inl(M32R_ICU_CR1_PORTL);
229 icucr |= M32R_ICUCR_ISMOD11; 229 icucr |= M32R_ICUCR_ISMOD11;
230 outl(icucr, ICUCR1); 230 outl(icucr, M32R_ICU_CR1_PORTL);
231 local_irq_restore(flags); 231 local_irq_restore(flags);
232#endif 232#endif
233 ei_local->stat.tx_errors++; 233 ei_local->stat.tx_errors++;
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
index 55720dc6ec43..745a14183634 100644
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -62,7 +62,7 @@ static int task_exit_notify(struct notifier_block * self, unsigned long val, voi
62 /* To avoid latency problems, we only process the current CPU, 62 /* To avoid latency problems, we only process the current CPU,
63 * hoping that most samples for the task are on this CPU 63 * hoping that most samples for the task are on this CPU
64 */ 64 */
65 sync_buffer(_smp_processor_id()); 65 sync_buffer(raw_smp_processor_id());
66 return 0; 66 return 0;
67} 67}
68 68
@@ -86,7 +86,7 @@ static int munmap_notify(struct notifier_block * self, unsigned long val, void *
86 /* To avoid latency problems, we only process the current CPU, 86 /* To avoid latency problems, we only process the current CPU,
87 * hoping that most samples for the task are on this CPU 87 * hoping that most samples for the task are on this CPU
88 */ 88 */
89 sync_buffer(_smp_processor_id()); 89 sync_buffer(raw_smp_processor_id());
90 return 0; 90 return 0;
91 } 91 }
92 92
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index 6375ebc85020..14e4124e1523 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -171,19 +171,21 @@ config PCMCIA_PROBE
171config M32R_PCC 171config M32R_PCC
172 bool "M32R PCMCIA I/F" 172 bool "M32R PCMCIA I/F"
173 depends on M32R && CHIP_M32700 && PCMCIA 173 depends on M32R && CHIP_M32700 && PCMCIA
174 select PCCARD_NONSTATIC
174 help 175 help
175 Say Y here to use the M32R PCMCIA controller. 176 Say Y here to use the M32R PCMCIA controller.
176 177
177config M32R_CFC 178config M32R_CFC
178 bool "M32R CF I/F Controller" 179 bool "M32R CF I/F Controller"
179 depends on M32R && (PLAT_USRV || PLAT_M32700UT || PLAT_MAPPI2 || PLAT_OPSPUT) 180 depends on M32R && (PLAT_USRV || PLAT_M32700UT || PLAT_MAPPI2 || PLAT_MAPPI3 || PLAT_OPSPUT)
181 select PCCARD_NONSTATIC
180 help 182 help
181 Say Y here to use the M32R CompactFlash controller. 183 Say Y here to use the M32R CompactFlash controller.
182 184
183config M32R_CFC_NUM 185config M32R_CFC_NUM
184 int "M32R CF I/F number" 186 int "M32R CF I/F number"
185 depends on M32R_CFC 187 depends on M32R_CFC
186 default "1" if PLAT_USRV || PLAT_M32700UT || PLAT_MAPPI2 || PLAT_OPSPUT 188 default "1" if PLAT_USRV || PLAT_M32700UT || PLAT_MAPPI2 || PLAT_MAPPI3 || PLAT_OPSPUT
187 help 189 help
188 Set the number of M32R CF slots. 190 Set the number of M32R CF slots.
189 191
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c
index 581bfa95429e..b1111c6bf062 100644
--- a/drivers/pcmcia/m32r_cfc.c
+++ b/drivers/pcmcia/m32r_cfc.c
@@ -24,9 +24,9 @@
24#include <linux/workqueue.h> 24#include <linux/workqueue.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/device.h> 26#include <linux/device.h>
27#include <linux/bitops.h>
27#include <asm/irq.h> 28#include <asm/irq.h>
28#include <asm/io.h> 29#include <asm/io.h>
29#include <asm/bitops.h>
30#include <asm/system.h> 30#include <asm/system.h>
31 31
32#include <pcmcia/version.h> 32#include <pcmcia/version.h>
@@ -444,7 +444,7 @@ static int _pcc_get_status(u_short sock, u_int *value)
444 debug(3, "m32r_cfc: _pcc_get_status: " 444 debug(3, "m32r_cfc: _pcc_get_status: "
445 "power off (CPCR=0x%08x)\n", status); 445 "power off (CPCR=0x%08x)\n", status);
446 } 446 }
447#elif defined(CONFIG_PLAT_MAPPI2) 447#elif defined(CONFIG_PLAT_MAPPI2) || defined(CONFIG_PLAT_MAPPI3)
448 if ( status ) { 448 if ( status ) {
449 status = pcc_get(sock, (unsigned int)PLD_CPCR); 449 status = pcc_get(sock, (unsigned int)PLD_CPCR);
450 if (status == 0) { /* power off */ 450 if (status == 0) { /* power off */
@@ -452,18 +452,23 @@ static int _pcc_get_status(u_short sock, u_int *value)
452 pcc_set(sock, (unsigned int)PLD_CFBUFCR,0); /* force buffer off for ZA-36 */ 452 pcc_set(sock, (unsigned int)PLD_CFBUFCR,0); /* force buffer off for ZA-36 */
453 udelay(50); 453 udelay(50);
454 } 454 }
455 status = pcc_get(sock, (unsigned int)PLD_CFBUFCR); 455 *value |= SS_POWERON;
456 if (status != 0) { /* buffer off */ 456
457 pcc_set(sock, (unsigned int)PLD_CFBUFCR,0); 457 pcc_set(sock, (unsigned int)PLD_CFBUFCR,0);
458 udelay(50); 458 udelay(50);
459 pcc_set(sock, (unsigned int)PLD_CFRSTCR, 0x0101); 459 pcc_set(sock, (unsigned int)PLD_CFRSTCR, 0x0101);
460 udelay(25); /* for IDE reset */ 460 udelay(25); /* for IDE reset */
461 pcc_set(sock, (unsigned int)PLD_CFRSTCR, 0x0100); 461 pcc_set(sock, (unsigned int)PLD_CFRSTCR, 0x0100);
462 mdelay(2); /* for IDE reset */ 462 mdelay(2); /* for IDE reset */
463 } else { 463
464 *value |= SS_POWERON; 464 *value |= SS_READY;
465 *value |= SS_READY; 465 *value |= SS_3VCARD;
466 } 466 } else {
467 /* disable CF power */
468 pcc_set(sock, (unsigned int)PLD_CPCR, 0);
469 udelay(100);
470 debug(3, "m32r_cfc: _pcc_get_status: "
471 "power off (CPCR=0x%08x)\n", status);
467 } 472 }
468#else 473#else
469#error no platform configuration 474#error no platform configuration
@@ -479,14 +484,13 @@ static int _pcc_get_socket(u_short sock, socket_state_t *state)
479{ 484{
480// pcc_socket_t *t = &socket[sock]; 485// pcc_socket_t *t = &socket[sock];
481 486
482#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_USRV) || defined(CONFIG_PLAT_OPSPUT)
483 state->flags = 0; 487 state->flags = 0;
484 state->csc_mask = SS_DETECT; 488 state->csc_mask = SS_DETECT;
485 state->csc_mask |= SS_READY; 489 state->csc_mask |= SS_READY;
486 state->io_irq = 0; 490 state->io_irq = 0;
487 state->Vcc = 33; /* 3.3V fixed */ 491 state->Vcc = 33; /* 3.3V fixed */
488 state->Vpp = 33; 492 state->Vpp = 33;
489#endif 493
490 debug(3, "m32r_cfc: GetSocket(%d) = flags %#3.3x, Vcc %d, Vpp %d, " 494 debug(3, "m32r_cfc: GetSocket(%d) = flags %#3.3x, Vcc %d, Vpp %d, "
491 "io_irq %d, csc_mask %#2.2x\n", sock, state->flags, 495 "io_irq %d, csc_mask %#2.2x\n", sock, state->flags,
492 state->Vcc, state->Vpp, state->io_irq, state->csc_mask); 496 state->Vcc, state->Vpp, state->io_irq, state->csc_mask);
@@ -497,32 +501,17 @@ static int _pcc_get_socket(u_short sock, socket_state_t *state)
497 501
498static int _pcc_set_socket(u_short sock, socket_state_t *state) 502static int _pcc_set_socket(u_short sock, socket_state_t *state)
499{ 503{
500#if defined(CONFIG_PLAT_MAPPI2)
501 u_long reg = 0;
502#endif
503 debug(3, "m32r_cfc: SetSocket(%d, flags %#3.3x, Vcc %d, Vpp %d, " 504 debug(3, "m32r_cfc: SetSocket(%d, flags %#3.3x, Vcc %d, Vpp %d, "
504 "io_irq %d, csc_mask %#2.2x)\n", sock, state->flags, 505 "io_irq %d, csc_mask %#2.2x)\n", sock, state->flags,
505 state->Vcc, state->Vpp, state->io_irq, state->csc_mask); 506 state->Vcc, state->Vpp, state->io_irq, state->csc_mask);
506 507
507#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_USRV) || defined(CONFIG_PLAT_OPSPUT) 508#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_USRV) || defined(CONFIG_PLAT_OPSPUT) || defined(CONFIG_PLAT_MAPPI2) || defined(CONFIG_PLAT_MAPPI3)
508 if (state->Vcc) { 509 if (state->Vcc) {
509 if ((state->Vcc != 50) && (state->Vcc != 33)) 510 if ((state->Vcc != 50) && (state->Vcc != 33))
510 return -EINVAL; 511 return -EINVAL;
511 /* accept 5V and 3.3V */ 512 /* accept 5V and 3.3V */
512 } 513 }
513#elif defined(CONFIG_PLAT_MAPPI2)
514 if (state->Vcc) {
515 /*
516 * 5V only
517 */
518 if (state->Vcc == 50) {
519 reg |= PCCSIGCR_VEN;
520 } else {
521 return -EINVAL;
522 }
523 }
524#endif 514#endif
525
526 if (state->flags & SS_RESET) { 515 if (state->flags & SS_RESET) {
527 debug(3, ":RESET\n"); 516 debug(3, ":RESET\n");
528 pcc_set(sock,(unsigned int)PLD_CFRSTCR,0x101); 517 pcc_set(sock,(unsigned int)PLD_CFRSTCR,0x101);
@@ -788,7 +777,7 @@ static int __init init_m32r_pcc(void)
788 return ret; 777 return ret;
789 } 778 }
790 779
791#if defined(CONFIG_PLAT_MAPPI2) 780#if defined(CONFIG_PLAT_MAPPI2) || defined(CONFIG_PLAT_MAPPI3)
792 pcc_set(0, (unsigned int)PLD_CFCR0, 0x0f0f); 781 pcc_set(0, (unsigned int)PLD_CFCR0, 0x0f0f);
793 pcc_set(0, (unsigned int)PLD_CFCR1, 0x0200); 782 pcc_set(0, (unsigned int)PLD_CFCR1, 0x0200);
794#endif 783#endif
@@ -825,7 +814,7 @@ static int __init init_m32r_pcc(void)
825 for (i = 0 ; i < pcc_sockets ; i++) { 814 for (i = 0 ; i < pcc_sockets ; i++) {
826 socket[i].socket.dev.dev = &pcc_device.dev; 815 socket[i].socket.dev.dev = &pcc_device.dev;
827 socket[i].socket.ops = &pcc_operations; 816 socket[i].socket.ops = &pcc_operations;
828 socket[i].socket.resource_ops = &pccard_static_ops; 817 socket[i].socket.resource_ops = &pccard_nonstatic_ops;
829 socket[i].socket.owner = THIS_MODULE; 818 socket[i].socket.owner = THIS_MODULE;
830 socket[i].number = i; 819 socket[i].number = i;
831 ret = pcmcia_register_socket(&socket[i].socket); 820 ret = pcmcia_register_socket(&socket[i].socket);
diff --git a/drivers/pcmcia/m32r_cfc.h b/drivers/pcmcia/m32r_cfc.h
index 17c1db7ae155..8146e3bee2e8 100644
--- a/drivers/pcmcia/m32r_cfc.h
+++ b/drivers/pcmcia/m32r_cfc.h
@@ -71,11 +71,15 @@
71 71
72#define CFC_IOPORT_BASE 0x1000 72#define CFC_IOPORT_BASE 0x1000
73 73
74#if !defined(CONFIG_PLAT_USRV) 74#if defined(CONFIG_PLAT_MAPPI3)
75#define CFC_ATTR_MAPBASE 0x14014000
76#define CFC_IO_MAPBASE_BYTE 0xb4012000
77#define CFC_IO_MAPBASE_WORD 0xb4002000
78#elif !defined(CONFIG_PLAT_USRV)
75#define CFC_ATTR_MAPBASE 0x0c014000 79#define CFC_ATTR_MAPBASE 0x0c014000
76#define CFC_IO_MAPBASE_BYTE 0xac012000 80#define CFC_IO_MAPBASE_BYTE 0xac012000
77#define CFC_IO_MAPBASE_WORD 0xac002000 81#define CFC_IO_MAPBASE_WORD 0xac002000
78#else /* CONFIG_PLAT_USRV */ 82#else
79#define CFC_ATTR_MAPBASE 0x04014000 83#define CFC_ATTR_MAPBASE 0x04014000
80#define CFC_IO_MAPBASE_BYTE 0xa4012000 84#define CFC_IO_MAPBASE_BYTE 0xa4012000
81#define CFC_IO_MAPBASE_WORD 0xa4002000 85#define CFC_IO_MAPBASE_WORD 0xa4002000
diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c
index 4a06c7d0e5e4..aac83ce6469c 100644
--- a/drivers/s390/cio/blacklist.c
+++ b/drivers/s390/cio/blacklist.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/s390/cio/blacklist.c 2 * drivers/s390/cio/blacklist.c
3 * S/390 common I/O routines -- blacklisting of specific devices 3 * S/390 common I/O routines -- blacklisting of specific devices
4 * $Revision: 1.33 $ 4 * $Revision: 1.34 $
5 * 5 *
6 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH, 6 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 7 * IBM Corporation
@@ -289,7 +289,7 @@ static int cio_ignore_read (char *page, char **start, off_t off,
289 len = 0; 289 len = 0;
290 for (devno = off; /* abuse the page variable 290 for (devno = off; /* abuse the page variable
291 * as counter, see fs/proc/generic.c */ 291 * as counter, see fs/proc/generic.c */
292 devno <= __MAX_SUBCHANNELS && len + entry_size < count; devno++) { 292 devno < __MAX_SUBCHANNELS && len + entry_size < count; devno++) {
293 if (!test_bit(devno, bl_dev)) 293 if (!test_bit(devno, bl_dev))
294 continue; 294 continue;
295 len += sprintf(page + len, "0.0.%04lx", devno); 295 len += sprintf(page + len, "0.0.%04lx", devno);
@@ -302,7 +302,7 @@ static int cio_ignore_read (char *page, char **start, off_t off,
302 len += sprintf(page + len, "\n"); 302 len += sprintf(page + len, "\n");
303 } 303 }
304 304
305 if (devno <= __MAX_SUBCHANNELS) 305 if (devno < __MAX_SUBCHANNELS)
306 *eof = 1; 306 *eof = 1;
307 *start = (char *) (devno - off); /* number of checked entries */ 307 *start = (char *) (devno - off); /* number of checked entries */
308 return len; 308 return len;
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 80b0c40c522b..ec81532eb845 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -1975,7 +1975,7 @@ __megaraid_reset(Scsi_Cmnd *cmd)
1975static int 1975static int
1976megaraid_reset(Scsi_Cmnd *cmd) 1976megaraid_reset(Scsi_Cmnd *cmd)
1977{ 1977{
1978 adapter = (adapter_t *)cmd->device->host->hostdata; 1978 adapter_t *adapter = (adapter_t *)cmd->device->host->hostdata;
1979 int rc; 1979 int rc;
1980 1980
1981 spin_lock_irq(&adapter->lock); 1981 spin_lock_irq(&adapter->lock);
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 6e44b46c9e9d..25fcef2c42de 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -753,7 +753,7 @@ config SERIAL_MPC52xx_CONSOLE_BAUD
753 753
754config SERIAL_ICOM 754config SERIAL_ICOM
755 tristate "IBM Multiport Serial Adapter" 755 tristate "IBM Multiport Serial Adapter"
756 depends on PPC_ISERIES || PPC_PSERIES 756 depends on PCI && (PPC_ISERIES || PPC_PSERIES)
757 select SERIAL_CORE 757 select SERIAL_CORE
758 help 758 help
759 This driver is for a family of multiport serial adapters 759 This driver is for a family of multiport serial adapters
@@ -843,4 +843,13 @@ config SERIAL_JSM
843 To compile this driver as a module, choose M here: the 843 To compile this driver as a module, choose M here: the
844 module will be called jsm. 844 module will be called jsm.
845 845
846config SERIAL_SGI_IOC4
847 tristate "SGI IOC4 controller serial support"
848 depends on (IA64_GENERIC || IA64_SGI_SN2) && SGI_IOC4
849 select SERIAL_CORE
850 help
851 If you have an SGI Altix with an IOC4 based Base IO card
852 and wish to use the serial ports on this card, say Y.
853 Otherwise, say N.
854
846endmenu 855endmenu
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 81b77d769b84..8f1cdde7dbed 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -51,4 +51,4 @@ obj-$(CONFIG_ETRAX_SERIAL) += crisv10.o
51obj-$(CONFIG_SERIAL_JSM) += jsm/ 51obj-$(CONFIG_SERIAL_JSM) += jsm/
52obj-$(CONFIG_SERIAL_TXX9) += serial_txx9.o 52obj-$(CONFIG_SERIAL_TXX9) += serial_txx9.o
53obj-$(CONFIG_SERIAL_VR41XX) += vr41xx_siu.o 53obj-$(CONFIG_SERIAL_VR41XX) += vr41xx_siu.o
54obj-$(CONFIG_BLK_DEV_SGIIOC4) += ioc4_serial.o 54obj-$(CONFIG_SERIAL_SGI_IOC4) += ioc4_serial.o
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/serial/cpm_uart/cpm_uart_cpm2.c
index b422c3abfba6..c4c8f4b44f53 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm2.c
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.c
@@ -134,12 +134,21 @@ void scc1_lineif(struct uart_cpm_port *pinfo)
134 134
135void scc2_lineif(struct uart_cpm_port *pinfo) 135void scc2_lineif(struct uart_cpm_port *pinfo)
136{ 136{
137 /*
138 * STx GP3 uses the SCC2 secondary option pin assignment
139 * which this driver doesn't account for in the static
140 * pin assignments. This kind of board specific info
141 * really has to get out of the driver so boards can
142 * be supported in a sane fashion.
143 */
144#ifndef CONFIG_STX_GP3
137 volatile iop_cpm2_t *io = &cpm2_immr->im_ioport; 145 volatile iop_cpm2_t *io = &cpm2_immr->im_ioport;
138 io->iop_pparb |= 0x008b0000; 146 io->iop_pparb |= 0x008b0000;
139 io->iop_pdirb |= 0x00880000; 147 io->iop_pdirb |= 0x00880000;
140 io->iop_psorb |= 0x00880000; 148 io->iop_psorb |= 0x00880000;
141 io->iop_pdirb &= ~0x00030000; 149 io->iop_pdirb &= ~0x00030000;
142 io->iop_psorb &= ~0x00030000; 150 io->iop_psorb &= ~0x00030000;
151#endif
143 cpm2_immr->im_cpmux.cmx_scr &= 0xff00ffff; 152 cpm2_immr->im_cpmux.cmx_scr &= 0xff00ffff;
144 cpm2_immr->im_cpmux.cmx_scr |= 0x00090000; 153 cpm2_immr->im_cpmux.cmx_scr |= 0x00090000;
145 pinfo->brg = 2; 154 pinfo->brg = 2;
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index ba4e13a22a50..793c3a7cbe47 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -20,7 +20,7 @@
20#include <linux/serial_reg.h> 20#include <linux/serial_reg.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/pci.h> 22#include <linux/pci.h>
23#include <linux/ioc4_common.h> 23#include <linux/ioc4.h>
24#include <linux/serial_core.h> 24#include <linux/serial_core.h>
25 25
26/* 26/*
@@ -130,12 +130,19 @@
130 IOC4_SIO_IR_S3_TX_EXPLICIT) 130 IOC4_SIO_IR_S3_TX_EXPLICIT)
131 131
132/* Bitmasks for IOC4_OTHER_IR, IOC4_OTHER_IEC, and IOC4_OTHER_IES */ 132/* Bitmasks for IOC4_OTHER_IR, IOC4_OTHER_IEC, and IOC4_OTHER_IES */
133#define IOC4_OTHER_IR_ATA_INT 0x00000001 /* ATAPI intr pass-thru */ 133#define IOC4_OTHER_IR_ATA_INT 0x00000001 /* ATAPI intr pass-thru */
134#define IOC4_OTHER_IR_ATA_MEMERR 0x00000002 /* ATAPI DMA PCI error */ 134#define IOC4_OTHER_IR_ATA_MEMERR 0x00000002 /* ATAPI DMA PCI error */
135#define IOC4_OTHER_IR_S0_MEMERR 0x00000004 /* Port 0 PCI error */ 135#define IOC4_OTHER_IR_S0_MEMERR 0x00000004 /* Port 0 PCI error */
136#define IOC4_OTHER_IR_S1_MEMERR 0x00000008 /* Port 1 PCI error */ 136#define IOC4_OTHER_IR_S1_MEMERR 0x00000008 /* Port 1 PCI error */
137#define IOC4_OTHER_IR_S2_MEMERR 0x00000010 /* Port 2 PCI error */ 137#define IOC4_OTHER_IR_S2_MEMERR 0x00000010 /* Port 2 PCI error */
138#define IOC4_OTHER_IR_S3_MEMERR 0x00000020 /* Port 3 PCI error */ 138#define IOC4_OTHER_IR_S3_MEMERR 0x00000020 /* Port 3 PCI error */
139#define IOC4_OTHER_IR_KBD_INT 0x00000040 /* Keyboard/mouse */
140#define IOC4_OTHER_IR_RESERVED 0x007fff80 /* Reserved */
141#define IOC4_OTHER_IR_RT_INT 0x00800000 /* INT_OUT section output */
142#define IOC4_OTHER_IR_GEN_INT 0xff000000 /* Generic pins */
143
144#define IOC4_OTHER_IR_SER_MEMERR (IOC4_OTHER_IR_S0_MEMERR | IOC4_OTHER_IR_S1_MEMERR | \
145 IOC4_OTHER_IR_S2_MEMERR | IOC4_OTHER_IR_S3_MEMERR)
139 146
140/* Bitmasks for IOC4_SIO_CR */ 147/* Bitmasks for IOC4_SIO_CR */
141#define IOC4_SIO_CR_CMD_PULSE_SHIFT 0 /* byte bus strobe shift */ 148#define IOC4_SIO_CR_CMD_PULSE_SHIFT 0 /* byte bus strobe shift */
@@ -274,70 +281,24 @@ struct ioc4_uartregs {
274#define i4u_dlm u2.dlm 281#define i4u_dlm u2.dlm
275#define i4u_fcr u3.fcr 282#define i4u_fcr u3.fcr
276 283
277/* PCI memory space register map addressed using pci_bar0 */ 284/* Serial port registers used for DMA serial I/O */
278struct ioc4_memregs { 285struct ioc4_serial {
279 struct ioc4_mem { 286 uint32_t sbbr01_l;
280 /* Miscellaneous IOC4 registers */ 287 uint32_t sbbr01_h;
281 uint32_t pci_err_addr_l; 288 uint32_t sbbr23_l;
282 uint32_t pci_err_addr_h; 289 uint32_t sbbr23_h;
283 uint32_t sio_ir; 290
284 uint32_t other_ir; 291 struct ioc4_serialregs port_0;
285 292 struct ioc4_serialregs port_1;
286 /* These registers are read-only for general kernel code. */ 293 struct ioc4_serialregs port_2;
287 uint32_t sio_ies_ro; 294 struct ioc4_serialregs port_3;
288 uint32_t other_ies_ro; 295 struct ioc4_uartregs uart_0;
289 uint32_t sio_iec_ro; 296 struct ioc4_uartregs uart_1;
290 uint32_t other_iec_ro; 297 struct ioc4_uartregs uart_2;
291 uint32_t sio_cr; 298 struct ioc4_uartregs uart_3;
292 uint32_t misc_fill1; 299} ioc4_serial;
293 uint32_t int_out;
294 uint32_t misc_fill2;
295 uint32_t gpcr_s;
296 uint32_t gpcr_c;
297 uint32_t gpdr;
298 uint32_t misc_fill3;
299 uint32_t gppr_0;
300 uint32_t gppr_1;
301 uint32_t gppr_2;
302 uint32_t gppr_3;
303 uint32_t gppr_4;
304 uint32_t gppr_5;
305 uint32_t gppr_6;
306 uint32_t gppr_7;
307 } ioc4_mem;
308
309 char misc_fill4[0x100 - 0x5C - 4];
310
311 /* ATA/ATAP registers */
312 uint32_t ata_notused[9];
313 char ata_fill1[0x140 - 0x120 - 4];
314 uint32_t ata_notused1[8];
315 char ata_fill2[0x200 - 0x15C - 4];
316
317 /* Keyboard and mouse registers */
318 uint32_t km_notused[5];;
319 char km_fill1[0x300 - 0x210 - 4];
320
321 /* Serial port registers used for DMA serial I/O */
322 struct ioc4_serial {
323 uint32_t sbbr01_l;
324 uint32_t sbbr01_h;
325 uint32_t sbbr23_l;
326 uint32_t sbbr23_h;
327
328 struct ioc4_serialregs port_0;
329 struct ioc4_serialregs port_1;
330 struct ioc4_serialregs port_2;
331 struct ioc4_serialregs port_3;
332 struct ioc4_uartregs uart_0;
333 struct ioc4_uartregs uart_1;
334 struct ioc4_uartregs uart_2;
335 struct ioc4_uartregs uart_3;
336 } ioc4_serial;
337};
338 300
339/* UART clock speed */ 301/* UART clock speed */
340#define IOC4_SER_XIN_CLK IOC4_SER_XIN_CLK_66
341#define IOC4_SER_XIN_CLK_66 66666667 302#define IOC4_SER_XIN_CLK_66 66666667
342#define IOC4_SER_XIN_CLK_33 33333333 303#define IOC4_SER_XIN_CLK_33 33333333
343 304
@@ -412,8 +373,8 @@ enum sio_proto {
412 | UART_LCR_WLEN7 | UART_LCR_WLEN8) 373 | UART_LCR_WLEN7 | UART_LCR_WLEN8)
413#define LCR_MASK_STOP_BITS (UART_LCR_STOP) 374#define LCR_MASK_STOP_BITS (UART_LCR_STOP)
414 375
415#define PENDING(_p) (readl(&(_p)->ip_mem->sio_ir) & _p->ip_ienb) 376#define PENDING(_p) (readl(&(_p)->ip_mem->sio_ir.raw) & _p->ip_ienb)
416#define READ_SIO_IR(_p) readl(&(_p)->ip_mem->sio_ir) 377#define READ_SIO_IR(_p) readl(&(_p)->ip_mem->sio_ir.raw)
417 378
418/* Default to 4k buffers */ 379/* Default to 4k buffers */
419#ifdef IOC4_1K_BUFFERS 380#ifdef IOC4_1K_BUFFERS
@@ -447,7 +408,7 @@ struct ioc4_control {
447 */ 408 */
448#define MAX_IOC4_INTR_ENTS (8 * sizeof(uint32_t)) 409#define MAX_IOC4_INTR_ENTS (8 * sizeof(uint32_t))
449struct ioc4_soft { 410struct ioc4_soft {
450 struct ioc4_mem __iomem *is_ioc4_mem_addr; 411 struct ioc4_misc_regs __iomem *is_ioc4_misc_addr;
451 struct ioc4_serial __iomem *is_ioc4_serial_addr; 412 struct ioc4_serial __iomem *is_ioc4_serial_addr;
452 413
453 /* Each interrupt type has an entry in the array */ 414 /* Each interrupt type has an entry in the array */
@@ -486,7 +447,7 @@ struct ioc4_port {
486 struct ioc4_soft *ip_ioc4_soft; 447 struct ioc4_soft *ip_ioc4_soft;
487 448
488 /* pci mem addresses */ 449 /* pci mem addresses */
489 struct ioc4_mem __iomem *ip_mem; 450 struct ioc4_misc_regs __iomem *ip_mem;
490 struct ioc4_serial __iomem *ip_serial; 451 struct ioc4_serial __iomem *ip_serial;
491 struct ioc4_serialregs __iomem *ip_serial_regs; 452 struct ioc4_serialregs __iomem *ip_serial_regs;
492 struct ioc4_uartregs __iomem *ip_uart_regs; 453 struct ioc4_uartregs __iomem *ip_uart_regs;
@@ -553,7 +514,7 @@ struct hooks {
553 uint32_t intr_dma_error; 514 uint32_t intr_dma_error;
554 uint32_t intr_clear; 515 uint32_t intr_clear;
555 uint32_t intr_all; 516 uint32_t intr_all;
556 char rs422_select_pin; 517 int rs422_select_pin;
557}; 518};
558 519
559static struct hooks hooks_array[IOC4_NUM_SERIAL_PORTS] = { 520static struct hooks hooks_array[IOC4_NUM_SERIAL_PORTS] = {
@@ -669,7 +630,7 @@ static void handle_intr(void *arg, uint32_t sio_ir);
669static inline void 630static inline void
670write_ireg(struct ioc4_soft *ioc4_soft, uint32_t val, int which, int type) 631write_ireg(struct ioc4_soft *ioc4_soft, uint32_t val, int which, int type)
671{ 632{
672 struct ioc4_mem __iomem *mem = ioc4_soft->is_ioc4_mem_addr; 633 struct ioc4_misc_regs __iomem *mem = ioc4_soft->is_ioc4_misc_addr;
673 unsigned long flags; 634 unsigned long flags;
674 635
675 spin_lock_irqsave(&ioc4_soft->is_ir_lock, flags); 636 spin_lock_irqsave(&ioc4_soft->is_ir_lock, flags);
@@ -678,11 +639,11 @@ write_ireg(struct ioc4_soft *ioc4_soft, uint32_t val, int which, int type)
678 case IOC4_SIO_INTR_TYPE: 639 case IOC4_SIO_INTR_TYPE:
679 switch (which) { 640 switch (which) {
680 case IOC4_W_IES: 641 case IOC4_W_IES:
681 writel(val, &mem->sio_ies_ro); 642 writel(val, &mem->sio_ies.raw);
682 break; 643 break;
683 644
684 case IOC4_W_IEC: 645 case IOC4_W_IEC:
685 writel(val, &mem->sio_iec_ro); 646 writel(val, &mem->sio_iec.raw);
686 break; 647 break;
687 } 648 }
688 break; 649 break;
@@ -690,11 +651,11 @@ write_ireg(struct ioc4_soft *ioc4_soft, uint32_t val, int which, int type)
690 case IOC4_OTHER_INTR_TYPE: 651 case IOC4_OTHER_INTR_TYPE:
691 switch (which) { 652 switch (which) {
692 case IOC4_W_IES: 653 case IOC4_W_IES:
693 writel(val, &mem->other_ies_ro); 654 writel(val, &mem->other_ies.raw);
694 break; 655 break;
695 656
696 case IOC4_W_IEC: 657 case IOC4_W_IEC:
697 writel(val, &mem->other_iec_ro); 658 writel(val, &mem->other_iec.raw);
698 break; 659 break;
699 } 660 }
700 break; 661 break;
@@ -747,7 +708,8 @@ static int set_baud(struct ioc4_port *port, int baud)
747 */ 708 */
748static struct ioc4_port *get_ioc4_port(struct uart_port *the_port) 709static struct ioc4_port *get_ioc4_port(struct uart_port *the_port)
749{ 710{
750 struct ioc4_control *control = dev_get_drvdata(the_port->dev); 711 struct ioc4_driver_data *idd = dev_get_drvdata(the_port->dev);
712 struct ioc4_control *control = idd->idd_serial_data;
751 int ii; 713 int ii;
752 714
753 if (control) { 715 if (control) {
@@ -782,7 +744,7 @@ static struct ioc4_port *get_ioc4_port(struct uart_port *the_port)
782static inline uint32_t 744static inline uint32_t
783pending_intrs(struct ioc4_soft *soft, int type) 745pending_intrs(struct ioc4_soft *soft, int type)
784{ 746{
785 struct ioc4_mem __iomem *mem = soft->is_ioc4_mem_addr; 747 struct ioc4_misc_regs __iomem *mem = soft->is_ioc4_misc_addr;
786 unsigned long flag; 748 unsigned long flag;
787 uint32_t intrs = 0; 749 uint32_t intrs = 0;
788 750
@@ -793,11 +755,11 @@ pending_intrs(struct ioc4_soft *soft, int type)
793 755
794 switch (type) { 756 switch (type) {
795 case IOC4_SIO_INTR_TYPE: 757 case IOC4_SIO_INTR_TYPE:
796 intrs = readl(&mem->sio_ir) & readl(&mem->sio_ies_ro); 758 intrs = readl(&mem->sio_ir.raw) & readl(&mem->sio_ies.raw);
797 break; 759 break;
798 760
799 case IOC4_OTHER_INTR_TYPE: 761 case IOC4_OTHER_INTR_TYPE:
800 intrs = readl(&mem->other_ir) & readl(&mem->other_ies_ro); 762 intrs = readl(&mem->other_ir.raw) & readl(&mem->other_ies.raw);
801 763
802 /* Don't process any ATA interrupte */ 764 /* Don't process any ATA interrupte */
803 intrs &= ~(IOC4_OTHER_IR_ATA_INT | IOC4_OTHER_IR_ATA_MEMERR); 765 intrs &= ~(IOC4_OTHER_IR_ATA_INT | IOC4_OTHER_IR_ATA_MEMERR);
@@ -826,7 +788,7 @@ static int inline port_init(struct ioc4_port *port)
826 788
827 /* Wait until any pending bus activity for this port has ceased */ 789 /* Wait until any pending bus activity for this port has ceased */
828 do 790 do
829 sio_cr = readl(&port->ip_mem->sio_cr); 791 sio_cr = readl(&port->ip_mem->sio_cr.raw);
830 while (!(sio_cr & IOC4_SIO_CR_SIO_DIAG_IDLE)); 792 while (!(sio_cr & IOC4_SIO_CR_SIO_DIAG_IDLE));
831 793
832 /* Finish reset sequence */ 794 /* Finish reset sequence */
@@ -899,7 +861,7 @@ static int inline port_init(struct ioc4_port *port)
899 write_ireg(port->ip_ioc4_soft, hooks->intr_clear, 861 write_ireg(port->ip_ioc4_soft, hooks->intr_clear,
900 IOC4_W_IEC, IOC4_SIO_INTR_TYPE); 862 IOC4_W_IEC, IOC4_SIO_INTR_TYPE);
901 port->ip_ienb &= ~hooks->intr_clear; 863 port->ip_ienb &= ~hooks->intr_clear;
902 writel(hooks->intr_clear, &port->ip_mem->sio_ir); 864 writel(hooks->intr_clear, &port->ip_mem->sio_ir.raw);
903 return 0; 865 return 0;
904} 866}
905 867
@@ -918,23 +880,23 @@ static void handle_dma_error_intr(void *arg, uint32_t other_ir)
918 spin_lock_irqsave(&port->ip_lock, flags); 880 spin_lock_irqsave(&port->ip_lock, flags);
919 881
920 /* ACK the interrupt */ 882 /* ACK the interrupt */
921 writel(hooks->intr_dma_error, &port->ip_mem->other_ir); 883 writel(hooks->intr_dma_error, &port->ip_mem->other_ir.raw);
922 884
923 if (readl(&port->ip_mem->pci_err_addr_l) & IOC4_PCI_ERR_ADDR_VLD) { 885 if (readl(&port->ip_mem->pci_err_addr_l.raw) & IOC4_PCI_ERR_ADDR_VLD) {
924 printk(KERN_ERR 886 printk(KERN_ERR
925 "PCI error address is 0x%lx, " 887 "PCI error address is 0x%lx, "
926 "master is serial port %c %s\n", 888 "master is serial port %c %s\n",
927 (((uint64_t)readl(&port->ip_mem->pci_err_addr_h) 889 (((uint64_t)readl(&port->ip_mem->pci_err_addr_h)
928 << 32) 890 << 32)
929 | readl(&port->ip_mem->pci_err_addr_l)) 891 | readl(&port->ip_mem->pci_err_addr_l.raw))
930 & IOC4_PCI_ERR_ADDR_ADDR_MSK, '1' + 892 & IOC4_PCI_ERR_ADDR_ADDR_MSK, '1' +
931 ((char)(readl(&port->ip_mem-> pci_err_addr_l) & 893 ((char)(readl(&port->ip_mem->pci_err_addr_l.raw) &
932 IOC4_PCI_ERR_ADDR_MST_NUM_MSK) >> 1), 894 IOC4_PCI_ERR_ADDR_MST_NUM_MSK) >> 1),
933 (readl(&port->ip_mem->pci_err_addr_l) 895 (readl(&port->ip_mem->pci_err_addr_l.raw)
934 & IOC4_PCI_ERR_ADDR_MST_TYP_MSK) 896 & IOC4_PCI_ERR_ADDR_MST_TYP_MSK)
935 ? "RX" : "TX"); 897 ? "RX" : "TX");
936 898
937 if (readl(&port->ip_mem->pci_err_addr_l) 899 if (readl(&port->ip_mem->pci_err_addr_l.raw)
938 & IOC4_PCI_ERR_ADDR_MUL_ERR) { 900 & IOC4_PCI_ERR_ADDR_MUL_ERR) {
939 printk(KERN_ERR 901 printk(KERN_ERR
940 "Multiple errors occurred\n"); 902 "Multiple errors occurred\n");
@@ -1018,26 +980,26 @@ static irqreturn_t ioc4_intr(int irq, void *arg, struct pt_regs *regs)
1018 "other_ies = 0x%x\n", 980 "other_ies = 0x%x\n",
1019 (intr_type == IOC4_SIO_INTR_TYPE) ? "sio" : 981 (intr_type == IOC4_SIO_INTR_TYPE) ? "sio" :
1020 "other", this_ir, 982 "other", this_ir,
1021 readl(&soft->is_ioc4_mem_addr->sio_ir), 983 readl(&soft->is_ioc4_misc_addr->sio_ir.raw),
1022 readl(&soft->is_ioc4_mem_addr->sio_ies_ro), 984 readl(&soft->is_ioc4_misc_addr->sio_ies.raw),
1023 readl(&soft->is_ioc4_mem_addr->other_ir), 985 readl(&soft->is_ioc4_misc_addr->other_ir.raw),
1024 readl(&soft->is_ioc4_mem_addr->other_ies_ro)); 986 readl(&soft->is_ioc4_misc_addr->other_ies.raw));
1025 } 987 }
1026 } 988 }
1027#ifdef DEBUG_INTERRUPTS 989#ifdef DEBUG_INTERRUPTS
1028 { 990 {
1029 struct ioc4_mem __iomem *mem = soft->is_ioc4_mem_addr; 991 struct ioc4_misc_regs __iomem *mem = soft->is_ioc4_misc_addr;
1030 spinlock_t *lp = &soft->is_ir_lock; 992 spinlock_t *lp = &soft->is_ir_lock;
1031 unsigned long flag; 993 unsigned long flag;
1032 994
1033 spin_lock_irqsave(&soft->is_ir_lock, flag); 995 spin_lock_irqsave(&soft->is_ir_lock, flag);
1034 printk ("%s : %d : mem 0x%p sio_ir 0x%x sio_ies_ro 0x%x " 996 printk ("%s : %d : mem 0x%p sio_ir 0x%x sio_ies 0x%x "
1035 "other_ir 0x%x other_ies_ro 0x%x mask 0x%x\n", 997 "other_ir 0x%x other_ies 0x%x mask 0x%x\n",
1036 __FUNCTION__, __LINE__, 998 __FUNCTION__, __LINE__,
1037 (void *)mem, readl(&mem->sio_ir), 999 (void *)mem, readl(&mem->sio_ir.raw),
1038 readl(&mem->sio_ies_ro), 1000 readl(&mem->sio_ies.raw),
1039 readl(&mem->other_ir), 1001 readl(&mem->other_ir.raw),
1040 readl(&mem->other_ies_ro), 1002 readl(&mem->other_ies.raw),
1041 IOC4_OTHER_IR_ATA_INT | IOC4_OTHER_IR_ATA_MEMERR); 1003 IOC4_OTHER_IR_ATA_INT | IOC4_OTHER_IR_ATA_MEMERR);
1042 spin_unlock_irqrestore(&soft->is_ir_lock, flag); 1004 spin_unlock_irqrestore(&soft->is_ir_lock, flag);
1043 } 1005 }
@@ -1049,21 +1011,20 @@ static irqreturn_t ioc4_intr(int irq, void *arg, struct pt_regs *regs)
1049 * ioc4_attach_local - Device initialization. 1011 * ioc4_attach_local - Device initialization.
1050 * Called at *_attach() time for each 1012 * Called at *_attach() time for each
1051 * IOC4 with serial ports in the system. 1013 * IOC4 with serial ports in the system.
1052 * @control: ioc4_control ptr 1014 * @idd: Master module data for this IOC4
1053 * @pdev: PCI handle for this device
1054 * @soft: soft struct for this device
1055 * @ioc4: ioc4 mem space
1056 */ 1015 */
1057static int inline ioc4_attach_local(struct pci_dev *pdev, 1016static int inline ioc4_attach_local(struct ioc4_driver_data *idd)
1058 struct ioc4_control *control,
1059 struct ioc4_soft *soft, void __iomem *ioc4_mem,
1060 void __iomem *ioc4_serial)
1061{ 1017{
1062 struct ioc4_port *port; 1018 struct ioc4_port *port;
1063 struct ioc4_port *ports[IOC4_NUM_SERIAL_PORTS]; 1019 struct ioc4_port *ports[IOC4_NUM_SERIAL_PORTS];
1064 int port_number; 1020 int port_number;
1065 uint16_t ioc4_revid_min = 62; 1021 uint16_t ioc4_revid_min = 62;
1066 uint16_t ioc4_revid; 1022 uint16_t ioc4_revid;
1023 struct pci_dev *pdev = idd->idd_pdev;
1024 struct ioc4_control* control = idd->idd_serial_data;
1025 struct ioc4_soft *soft = control->ic_soft;
1026 void __iomem *ioc4_misc = idd->idd_misc_regs;
1027 void __iomem *ioc4_serial = soft->is_ioc4_serial_addr;
1067 1028
1068 /* IOC4 firmware must be at least rev 62 */ 1029 /* IOC4 firmware must be at least rev 62 */
1069 pci_read_config_word(pdev, PCI_COMMAND_SPECIAL, &ioc4_revid); 1030 pci_read_config_word(pdev, PCI_COMMAND_SPECIAL, &ioc4_revid);
@@ -1076,7 +1037,7 @@ static int inline ioc4_attach_local(struct pci_dev *pdev,
1076 ioc4_revid, ioc4_revid_min); 1037 ioc4_revid, ioc4_revid_min);
1077 return -EPERM; 1038 return -EPERM;
1078 } 1039 }
1079 BUG_ON(ioc4_mem == NULL); 1040 BUG_ON(ioc4_misc == NULL);
1080 BUG_ON(ioc4_serial == NULL); 1041 BUG_ON(ioc4_serial == NULL);
1081 1042
1082 /* Create port structures for each port */ 1043 /* Create port structures for each port */
@@ -1100,10 +1061,18 @@ static int inline ioc4_attach_local(struct pci_dev *pdev,
1100 port->ip_ioc4_soft = soft; 1061 port->ip_ioc4_soft = soft;
1101 port->ip_pdev = pdev; 1062 port->ip_pdev = pdev;
1102 port->ip_ienb = 0; 1063 port->ip_ienb = 0;
1103 port->ip_pci_bus_speed = IOC4_SER_XIN_CLK; 1064 /* Use baud rate calculations based on detected PCI
1065 * bus speed. Simply test whether the PCI clock is
1066 * running closer to 66MHz or 33MHz.
1067 */
1068 if (idd->count_period/IOC4_EXTINT_COUNT_DIVISOR < 20) {
1069 port->ip_pci_bus_speed = IOC4_SER_XIN_CLK_66;
1070 } else {
1071 port->ip_pci_bus_speed = IOC4_SER_XIN_CLK_33;
1072 }
1104 port->ip_baud = 9600; 1073 port->ip_baud = 9600;
1105 port->ip_control = control; 1074 port->ip_control = control;
1106 port->ip_mem = ioc4_mem; 1075 port->ip_mem = ioc4_misc;
1107 port->ip_serial = ioc4_serial; 1076 port->ip_serial = ioc4_serial;
1108 1077
1109 /* point to the right hook */ 1078 /* point to the right hook */
@@ -1604,14 +1573,12 @@ static int ioc4_set_proto(struct ioc4_port *port, enum sio_proto proto)
1604 switch (proto) { 1573 switch (proto) {
1605 case PROTO_RS232: 1574 case PROTO_RS232:
1606 /* Clear the appropriate GIO pin */ 1575 /* Clear the appropriate GIO pin */
1607 writel(0, (&port->ip_mem->gppr_0 + 1576 writel(0, (&port->ip_mem->gppr[hooks->rs422_select_pin].raw));
1608 hooks->rs422_select_pin));
1609 break; 1577 break;
1610 1578
1611 case PROTO_RS422: 1579 case PROTO_RS422:
1612 /* Set the appropriate GIO pin */ 1580 /* Set the appropriate GIO pin */
1613 writel(1, (&port->ip_mem->gppr_0 + 1581 writel(1, (&port->ip_mem->gppr[hooks->rs422_select_pin].raw));
1614 hooks->rs422_select_pin));
1615 break; 1582 break;
1616 1583
1617 default: 1584 default:
@@ -1885,7 +1852,7 @@ static void handle_intr(void *arg, uint32_t sio_ir)
1885 if (sio_ir & hooks->intr_delta_dcd) { 1852 if (sio_ir & hooks->intr_delta_dcd) {
1886 /* ACK the interrupt */ 1853 /* ACK the interrupt */
1887 writel(hooks->intr_delta_dcd, 1854 writel(hooks->intr_delta_dcd,
1888 &port->ip_mem->sio_ir); 1855 &port->ip_mem->sio_ir.raw);
1889 1856
1890 shadow = readl(&port->ip_serial_regs->shadow); 1857 shadow = readl(&port->ip_serial_regs->shadow);
1891 1858
@@ -1907,7 +1874,7 @@ static void handle_intr(void *arg, uint32_t sio_ir)
1907 if (sio_ir & hooks->intr_delta_cts) { 1874 if (sio_ir & hooks->intr_delta_cts) {
1908 /* ACK the interrupt */ 1875 /* ACK the interrupt */
1909 writel(hooks->intr_delta_cts, 1876 writel(hooks->intr_delta_cts,
1910 &port->ip_mem->sio_ir); 1877 &port->ip_mem->sio_ir.raw);
1911 1878
1912 shadow = readl(&port->ip_serial_regs->shadow); 1879 shadow = readl(&port->ip_serial_regs->shadow);
1913 1880
@@ -1928,7 +1895,7 @@ static void handle_intr(void *arg, uint32_t sio_ir)
1928 if (sio_ir & hooks->intr_rx_timer) { 1895 if (sio_ir & hooks->intr_rx_timer) {
1929 /* ACK the interrupt */ 1896 /* ACK the interrupt */
1930 writel(hooks->intr_rx_timer, 1897 writel(hooks->intr_rx_timer,
1931 &port->ip_mem->sio_ir); 1898 &port->ip_mem->sio_ir.raw);
1932 1899
1933 if ((port->ip_notify & N_DATA_READY) 1900 if ((port->ip_notify & N_DATA_READY)
1934 && (port->ip_port)) { 1901 && (port->ip_port)) {
@@ -1974,7 +1941,7 @@ static void handle_intr(void *arg, uint32_t sio_ir)
1974 1941
1975 /* ACK the interrupt */ 1942 /* ACK the interrupt */
1976 writel(hooks->intr_tx_explicit, 1943 writel(hooks->intr_tx_explicit,
1977 &port->ip_mem->sio_ir); 1944 &port->ip_mem->sio_ir.raw);
1978 1945
1979 if (port->ip_notify & N_OUTPUT_LOWAT) 1946 if (port->ip_notify & N_OUTPUT_LOWAT)
1980 ioc4_cb_output_lowat(port); 1947 ioc4_cb_output_lowat(port);
@@ -2634,7 +2601,8 @@ ioc4_serial_core_attach(struct pci_dev *pdev)
2634{ 2601{
2635 struct ioc4_port *port; 2602 struct ioc4_port *port;
2636 struct uart_port *the_port; 2603 struct uart_port *the_port;
2637 struct ioc4_control *control = pci_get_drvdata(pdev); 2604 struct ioc4_driver_data *idd = pci_get_drvdata(pdev);
2605 struct ioc4_control *control = idd->idd_serial_data;
2638 int ii; 2606 int ii;
2639 2607
2640 DPRINT_CONFIG(("%s: attach pdev 0x%p - control 0x%p\n", 2608 DPRINT_CONFIG(("%s: attach pdev 0x%p - control 0x%p\n",
@@ -2680,55 +2648,29 @@ ioc4_serial_core_attach(struct pci_dev *pdev)
2680 2648
2681/** 2649/**
2682 * ioc4_serial_attach_one - register attach function 2650 * ioc4_serial_attach_one - register attach function
2683 * called per card found from ioc4_serial_detect as part 2651 * called per card found from IOC4 master module.
2684 * of module_init(). 2652 * @idd: Master module data for this IOC4
2685 * @pdev: handle for this card
2686 * @pci_id: pci id for this card
2687 */ 2653 */
2688int 2654int
2689ioc4_serial_attach_one(struct pci_dev *pdev, const struct pci_device_id *pci_id) 2655ioc4_serial_attach_one(struct ioc4_driver_data *idd)
2690{ 2656{
2691 struct ioc4_mem __iomem *mem; 2657 unsigned long tmp_addr1;
2692 unsigned long tmp_addr, tmp_addr1;
2693 struct ioc4_serial __iomem *serial; 2658 struct ioc4_serial __iomem *serial;
2694 struct ioc4_soft *soft; 2659 struct ioc4_soft *soft;
2695 struct ioc4_control *control; 2660 struct ioc4_control *control;
2696 int tmp, ret = 0; 2661 int ret = 0;
2697 2662
2698 2663
2699 DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __FUNCTION__, pdev, pci_id)); 2664 DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __FUNCTION__, idd->idd_pdev, idd->idd_pci_id));
2700
2701 /* Map in the ioc4 memory */
2702 tmp_addr = pci_resource_start(pdev, 0);
2703 if (!tmp_addr) {
2704 printk(KERN_WARNING
2705 "ioc4 (%p) : unable to get PIO mapping for "
2706 "MEM space\n", (void *)pdev);
2707 return -ENODEV;
2708 }
2709 if (!request_region(tmp_addr, sizeof(struct ioc4_mem), "sioc4_mem")) {
2710 printk(KERN_ALERT
2711 "ioc4 (%p): unable to get request region for "
2712 "MEM space\n", (void *)pdev);
2713 return -ENODEV;
2714 }
2715 mem = ioremap(tmp_addr, sizeof(struct ioc4_mem));
2716 if (!mem) {
2717 printk(KERN_WARNING
2718 "ioc4 (%p) : unable to remap ioc4 memory\n",
2719 (void *)pdev);
2720 ret = -ENODEV;
2721 goto out1;
2722 }
2723 2665
2724 /* request serial registers */ 2666 /* request serial registers */
2725 tmp_addr1 = pci_resource_start(pdev, 0) + IOC4_SERIAL_OFFSET; 2667 tmp_addr1 = idd->idd_bar0 + IOC4_SERIAL_OFFSET;
2726 2668
2727 if (!request_region(tmp_addr1, sizeof(struct ioc4_serial), 2669 if (!request_region(tmp_addr1, sizeof(struct ioc4_serial),
2728 "sioc4_uart")) { 2670 "sioc4_uart")) {
2729 printk(KERN_WARNING 2671 printk(KERN_WARNING
2730 "ioc4 (%p): unable to get request region for " 2672 "ioc4 (%p): unable to get request region for "
2731 "uart space\n", (void *)pdev); 2673 "uart space\n", (void *)idd->idd_pdev);
2732 ret = -ENODEV; 2674 ret = -ENODEV;
2733 goto out1; 2675 goto out1;
2734 } 2676 }
@@ -2736,12 +2678,12 @@ ioc4_serial_attach_one(struct pci_dev *pdev, const struct pci_device_id *pci_id)
2736 if (!serial) { 2678 if (!serial) {
2737 printk(KERN_WARNING 2679 printk(KERN_WARNING
2738 "ioc4 (%p) : unable to remap ioc4 serial register\n", 2680 "ioc4 (%p) : unable to remap ioc4 serial register\n",
2739 (void *)pdev); 2681 (void *)idd->idd_pdev);
2740 ret = -ENODEV; 2682 ret = -ENODEV;
2741 goto out2; 2683 goto out2;
2742 } 2684 }
2743 DPRINT_CONFIG(("%s : mem 0x%p, serial 0x%p\n", 2685 DPRINT_CONFIG(("%s : mem 0x%p, serial 0x%p\n",
2744 __FUNCTION__, (void *)mem, (void *)serial)); 2686 __FUNCTION__, (void *)idd->idd_misc_regs, (void *)serial));
2745 2687
2746 /* Get memory for the new card */ 2688 /* Get memory for the new card */
2747 control = kmalloc(sizeof(struct ioc4_control) * IOC4_NUM_SERIAL_PORTS, 2689 control = kmalloc(sizeof(struct ioc4_control) * IOC4_NUM_SERIAL_PORTS,
@@ -2754,59 +2696,56 @@ ioc4_serial_attach_one(struct pci_dev *pdev, const struct pci_device_id *pci_id)
2754 goto out2; 2696 goto out2;
2755 } 2697 }
2756 memset(control, 0, sizeof(struct ioc4_control)); 2698 memset(control, 0, sizeof(struct ioc4_control));
2757 pci_set_drvdata(pdev, control); 2699 idd->idd_serial_data = control;
2758 2700
2759 /* Allocate the soft structure */ 2701 /* Allocate the soft structure */
2760 soft = kmalloc(sizeof(struct ioc4_soft), GFP_KERNEL); 2702 soft = kmalloc(sizeof(struct ioc4_soft), GFP_KERNEL);
2761 if (!soft) { 2703 if (!soft) {
2762 printk(KERN_WARNING 2704 printk(KERN_WARNING
2763 "ioc4 (%p): unable to get memory for the soft struct\n", 2705 "ioc4 (%p): unable to get memory for the soft struct\n",
2764 (void *)pdev); 2706 (void *)idd->idd_pdev);
2765 ret = -ENOMEM; 2707 ret = -ENOMEM;
2766 goto out3; 2708 goto out3;
2767 } 2709 }
2768 memset(soft, 0, sizeof(struct ioc4_soft)); 2710 memset(soft, 0, sizeof(struct ioc4_soft));
2769 2711
2770 spin_lock_init(&soft->is_ir_lock); 2712 spin_lock_init(&soft->is_ir_lock);
2771 soft->is_ioc4_mem_addr = mem; 2713 soft->is_ioc4_misc_addr = idd->idd_misc_regs;
2772 soft->is_ioc4_serial_addr = serial; 2714 soft->is_ioc4_serial_addr = serial;
2773 2715
2774 /* Init the IOC4 */ 2716 /* Init the IOC4 */
2775 pci_read_config_dword(pdev, PCI_COMMAND, &tmp); 2717 writel(0xf << IOC4_SIO_CR_CMD_PULSE_SHIFT,
2776 pci_write_config_dword(pdev, PCI_COMMAND, 2718 &idd->idd_misc_regs->sio_cr.raw);
2777 tmp | PCI_COMMAND_PARITY | PCI_COMMAND_SERR);
2778
2779 writel(0xf << IOC4_SIO_CR_CMD_PULSE_SHIFT, &mem->sio_cr);
2780 2719
2781 /* Enable serial port mode select generic PIO pins as outputs */ 2720 /* Enable serial port mode select generic PIO pins as outputs */
2782 writel(IOC4_GPCR_UART0_MODESEL | IOC4_GPCR_UART1_MODESEL 2721 writel(IOC4_GPCR_UART0_MODESEL | IOC4_GPCR_UART1_MODESEL
2783 | IOC4_GPCR_UART2_MODESEL | IOC4_GPCR_UART3_MODESEL, 2722 | IOC4_GPCR_UART2_MODESEL | IOC4_GPCR_UART3_MODESEL,
2784 &mem->gpcr_s); 2723 &idd->idd_misc_regs->gpcr_s.raw);
2785 2724
2786 /* Clear and disable all interrupts */ 2725 /* Clear and disable all serial interrupts */
2787 write_ireg(soft, ~0, IOC4_W_IEC, IOC4_SIO_INTR_TYPE); 2726 write_ireg(soft, ~0, IOC4_W_IEC, IOC4_SIO_INTR_TYPE);
2788 writel(~0, &mem->sio_ir); 2727 writel(~0, &idd->idd_misc_regs->sio_ir.raw);
2789 write_ireg(soft, ~(IOC4_OTHER_IR_ATA_INT | IOC4_OTHER_IR_ATA_MEMERR), 2728 write_ireg(soft, IOC4_OTHER_IR_SER_MEMERR, IOC4_W_IEC,
2790 IOC4_W_IEC, IOC4_OTHER_INTR_TYPE); 2729 IOC4_OTHER_INTR_TYPE);
2791 writel(~(IOC4_OTHER_IR_ATA_MEMERR | IOC4_OTHER_IR_ATA_MEMERR), 2730 writel(IOC4_OTHER_IR_SER_MEMERR, &idd->idd_misc_regs->other_ir.raw);
2792 &mem->other_ir);
2793 control->ic_soft = soft; 2731 control->ic_soft = soft;
2794 if (!request_irq(pdev->irq, ioc4_intr, SA_SHIRQ, 2732
2733 /* Hook up interrupt handler */
2734 if (!request_irq(idd->idd_pdev->irq, ioc4_intr, SA_SHIRQ,
2795 "sgi-ioc4serial", (void *)soft)) { 2735 "sgi-ioc4serial", (void *)soft)) {
2796 control->ic_irq = pdev->irq; 2736 control->ic_irq = idd->idd_pdev->irq;
2797 } else { 2737 } else {
2798 printk(KERN_WARNING 2738 printk(KERN_WARNING
2799 "%s : request_irq fails for IRQ 0x%x\n ", 2739 "%s : request_irq fails for IRQ 0x%x\n ",
2800 __FUNCTION__, pdev->irq); 2740 __FUNCTION__, idd->idd_pdev->irq);
2801 } 2741 }
2802 if ((ret = ioc4_attach_local(pdev, control, soft, 2742 ret = ioc4_attach_local(idd);
2803 soft->is_ioc4_mem_addr, 2743 if (ret)
2804 soft->is_ioc4_serial_addr)))
2805 goto out4; 2744 goto out4;
2806 2745
2807 /* register port with the serial core */ 2746 /* register port with the serial core */
2808 2747
2809 if ((ret = ioc4_serial_core_attach(pdev))) 2748 if ((ret = ioc4_serial_core_attach(idd->idd_pdev)))
2810 goto out4; 2749 goto out4;
2811 2750
2812 return ret; 2751 return ret;
@@ -2819,7 +2758,6 @@ out3:
2819out2: 2758out2:
2820 release_region(tmp_addr1, sizeof(struct ioc4_serial)); 2759 release_region(tmp_addr1, sizeof(struct ioc4_serial));
2821out1: 2760out1:
2822 release_region(tmp_addr, sizeof(struct ioc4_mem));
2823 2761
2824 return ret; 2762 return ret;
2825} 2763}
@@ -2828,11 +2766,10 @@ out1:
2828/** 2766/**
2829 * ioc4_serial_remove_one - detach function 2767 * ioc4_serial_remove_one - detach function
2830 * 2768 *
2831 * @pdev: handle for this card 2769 * @idd: IOC4 master module data for this IOC4
2832 */ 2770 */
2833 2771
2834#if 0 2772int ioc4_serial_remove_one(struct ioc4_driver_data *idd)
2835void ioc4_serial_remove_one(struct pci_dev *pdev)
2836{ 2773{
2837 int ii; 2774 int ii;
2838 struct ioc4_control *control; 2775 struct ioc4_control *control;
@@ -2840,7 +2777,7 @@ void ioc4_serial_remove_one(struct pci_dev *pdev)
2840 struct ioc4_port *port; 2777 struct ioc4_port *port;
2841 struct ioc4_soft *soft; 2778 struct ioc4_soft *soft;
2842 2779
2843 control = pci_get_drvdata(pdev); 2780 control = idd->idd_serial_data;
2844 2781
2845 for (ii = 0; ii < IOC4_NUM_SERIAL_PORTS; ii++) { 2782 for (ii = 0; ii < IOC4_NUM_SERIAL_PORTS; ii++) {
2846 the_port = &control->ic_port[ii].icp_uart_port; 2783 the_port = &control->ic_port[ii].icp_uart_port;
@@ -2867,10 +2804,17 @@ void ioc4_serial_remove_one(struct pci_dev *pdev)
2867 kfree(soft); 2804 kfree(soft);
2868 } 2805 }
2869 kfree(control); 2806 kfree(control);
2870 pci_set_drvdata(pdev, NULL); 2807 idd->idd_serial_data = NULL;
2871 uart_unregister_driver(&ioc4_uart); 2808
2809 return 0;
2872} 2810}
2873#endif 2811
2812static struct ioc4_submodule ioc4_serial_submodule = {
2813 .is_name = "IOC4_serial",
2814 .is_owner = THIS_MODULE,
2815 .is_probe = ioc4_serial_attach_one,
2816 .is_remove = ioc4_serial_remove_one,
2817};
2874 2818
2875/** 2819/**
2876 * ioc4_serial_init - module init 2820 * ioc4_serial_init - module init
@@ -2886,12 +2830,20 @@ int ioc4_serial_init(void)
2886 __FUNCTION__); 2830 __FUNCTION__);
2887 return ret; 2831 return ret;
2888 } 2832 }
2889 return 0; 2833
2834 /* register with IOC4 main module */
2835 return ioc4_register_submodule(&ioc4_serial_submodule);
2836}
2837
2838static void __devexit ioc4_serial_exit(void)
2839{
2840 ioc4_unregister_submodule(&ioc4_serial_submodule);
2841 uart_unregister_driver(&ioc4_uart);
2890} 2842}
2891 2843
2844module_init(ioc4_serial_init);
2845module_exit(ioc4_serial_exit);
2846
2892MODULE_AUTHOR("Pat Gefre - Silicon Graphics Inc. (SGI) <pfg@sgi.com>"); 2847MODULE_AUTHOR("Pat Gefre - Silicon Graphics Inc. (SGI) <pfg@sgi.com>");
2893MODULE_DESCRIPTION("Serial PCI driver module for SGI IOC4 Base-IO Card"); 2848MODULE_DESCRIPTION("Serial PCI driver module for SGI IOC4 Base-IO Card");
2894MODULE_LICENSE("GPL"); 2849MODULE_LICENSE("GPL");
2895
2896EXPORT_SYMBOL(ioc4_serial_init);
2897EXPORT_SYMBOL(ioc4_serial_attach_one);
diff --git a/drivers/sn/Kconfig b/drivers/sn/Kconfig
new file mode 100644
index 000000000000..13b8d249da5c
--- /dev/null
+++ b/drivers/sn/Kconfig
@@ -0,0 +1,20 @@
1#
2# Miscellaneous SN-specific devices
3#
4
5menu "SN Devices"
6
7config SGI_IOC4
8 tristate "SGI IOC4 Base IO support"
9 depends on (IA64_GENERIC || IA64_SGI_SN2) && MMTIMER
10 default m
11 ---help---
12 This option enables basic support for the SGI IOC4-based Base IO
13 controller card. This option does not enable any specific
14 functions on such a card, but provides necessary infrastructure
15 for other drivers to utilize.
16
17 If you have an SGI Altix with an IOC4-based
18 I/O controller say Y. Otherwise say N.
19
20endmenu
diff --git a/drivers/sn/Makefile b/drivers/sn/Makefile
index 631e54958448..c2a284185372 100644
--- a/drivers/sn/Makefile
+++ b/drivers/sn/Makefile
@@ -3,4 +3,4 @@
3# 3#
4# 4#
5 5
6obj-$(CONFIG_BLK_DEV_SGIIOC4) += ioc4.o 6obj-$(CONFIG_SGI_IOC4) += ioc4.o
diff --git a/drivers/sn/ioc4.c b/drivers/sn/ioc4.c
index d9e4ee280e5f..ea75b3d0612b 100644
--- a/drivers/sn/ioc4.c
+++ b/drivers/sn/ioc4.c
@@ -6,60 +6,422 @@
6 * Copyright (C) 2005 Silicon Graphics, Inc. All Rights Reserved. 6 * Copyright (C) 2005 Silicon Graphics, Inc. All Rights Reserved.
7 */ 7 */
8 8
9/* 9/* This file contains the master driver module for use by SGI IOC4 subdrivers.
10 * This file contains a shim driver for the IOC4 IDE and serial drivers. 10 *
11 * It allocates any resources shared between multiple subdevices, and
12 * provides accessor functions (where needed) and the like for those
13 * resources. It also provides a mechanism for the subdevice modules
14 * to support loading and unloading.
15 *
16 * Non-shared resources (e.g. external interrupt A_INT_OUT register page
17 * alias, serial port and UART registers) are handled by the subdevice
18 * modules themselves.
19 *
20 * This is all necessary because IOC4 is not implemented as a multi-function
21 * PCI device, but an amalgamation of disparate registers for several
22 * types of device (ATA, serial, external interrupts). The normal
23 * resource management in the kernel doesn't have quite the right interfaces
24 * to handle this situation (e.g. multiple modules can't claim the same
25 * PCI ID), thus this IOC4 master module.
11 */ 26 */
12 27
13#include <linux/errno.h> 28#include <linux/errno.h>
14#include <linux/module.h> 29#include <linux/module.h>
15#include <linux/pci.h> 30#include <linux/pci.h>
16#include <linux/ioc4_common.h> 31#include <linux/ioc4.h>
17#include <linux/ide.h> 32#include <linux/mmtimer.h>
33#include <linux/rtc.h>
34#include <linux/rwsem.h>
35#include <asm/sn/addrs.h>
36#include <asm/sn/clksupport.h>
37#include <asm/sn/shub_mmr.h>
18 38
39/***************
40 * Definitions *
41 ***************/
19 42
20static int __devinit 43/* Tweakable values */
21ioc4_probe_one(struct pci_dev *pdev, const struct pci_device_id *pci_id) 44
45/* PCI bus speed detection/calibration */
46#define IOC4_CALIBRATE_COUNT 63 /* Calibration cycle period */
47#define IOC4_CALIBRATE_CYCLES 256 /* Average over this many cycles */
48#define IOC4_CALIBRATE_DISCARD 2 /* Discard first few cycles */
49#define IOC4_CALIBRATE_LOW_MHZ 25 /* Lower bound on bus speed sanity */
50#define IOC4_CALIBRATE_HIGH_MHZ 75 /* Upper bound on bus speed sanity */
51#define IOC4_CALIBRATE_DEFAULT_MHZ 66 /* Assumed if sanity check fails */
52
53/************************
54 * Submodule management *
55 ************************/
56
57static LIST_HEAD(ioc4_devices);
58static DECLARE_RWSEM(ioc4_devices_rwsem);
59
60static LIST_HEAD(ioc4_submodules);
61static DECLARE_RWSEM(ioc4_submodules_rwsem);
62
63/* Register an IOC4 submodule */
64int
65ioc4_register_submodule(struct ioc4_submodule *is)
66{
67 struct ioc4_driver_data *idd;
68
69 down_write(&ioc4_submodules_rwsem);
70 list_add(&is->is_list, &ioc4_submodules);
71 up_write(&ioc4_submodules_rwsem);
72
73 /* Initialize submodule for each IOC4 */
74 if (!is->is_probe)
75 return 0;
76
77 down_read(&ioc4_devices_rwsem);
78 list_for_each_entry(idd, &ioc4_devices, idd_list) {
79 if (is->is_probe(idd)) {
80 printk(KERN_WARNING
81 "%s: IOC4 submodule %s probe failed "
82 "for pci_dev %s",
83 __FUNCTION__, module_name(is->is_owner),
84 pci_name(idd->idd_pdev));
85 }
86 }
87 up_read(&ioc4_devices_rwsem);
88
89 return 0;
90}
91
92/* Unregister an IOC4 submodule */
93void
94ioc4_unregister_submodule(struct ioc4_submodule *is)
95{
96 struct ioc4_driver_data *idd;
97
98 down_write(&ioc4_submodules_rwsem);
99 list_del(&is->is_list);
100 up_write(&ioc4_submodules_rwsem);
101
102 /* Remove submodule for each IOC4 */
103 if (!is->is_remove)
104 return;
105
106 down_read(&ioc4_devices_rwsem);
107 list_for_each_entry(idd, &ioc4_devices, idd_list) {
108 if (is->is_remove(idd)) {
109 printk(KERN_WARNING
110 "%s: IOC4 submodule %s remove failed "
111 "for pci_dev %s.\n",
112 __FUNCTION__, module_name(is->is_owner),
113 pci_name(idd->idd_pdev));
114 }
115 }
116 up_read(&ioc4_devices_rwsem);
117}
118
119/*********************
120 * Device management *
121 *********************/
122
123#define IOC4_CALIBRATE_LOW_LIMIT \
124 (1000*IOC4_EXTINT_COUNT_DIVISOR/IOC4_CALIBRATE_LOW_MHZ)
125#define IOC4_CALIBRATE_HIGH_LIMIT \
126 (1000*IOC4_EXTINT_COUNT_DIVISOR/IOC4_CALIBRATE_HIGH_MHZ)
127#define IOC4_CALIBRATE_DEFAULT \
128 (1000*IOC4_EXTINT_COUNT_DIVISOR/IOC4_CALIBRATE_DEFAULT_MHZ)
129
130#define IOC4_CALIBRATE_END \
131 (IOC4_CALIBRATE_CYCLES + IOC4_CALIBRATE_DISCARD)
132
133#define IOC4_INT_OUT_MODE_TOGGLE 0x7 /* Toggle INT_OUT every COUNT+1 ticks */
134
135/* Determines external interrupt output clock period of the PCI bus an
136 * IOC4 is attached to. This value can be used to determine the PCI
137 * bus speed.
138 *
139 * IOC4 has a design feature that various internal timers are derived from
140 * the PCI bus clock. This causes IOC4 device drivers to need to take the
141 * bus speed into account when setting various register values (e.g. INT_OUT
142 * register COUNT field, UART divisors, etc). Since this information is
143 * needed by several subdrivers, it is determined by the main IOC4 driver,
144 * even though the following code utilizes external interrupt registers
145 * to perform the speed calculation.
146 */
147static void
148ioc4_clock_calibrate(struct ioc4_driver_data *idd)
149{
150 extern unsigned long sn_rtc_cycles_per_second;
151 union ioc4_int_out int_out;
152 union ioc4_gpcr gpcr;
153 unsigned int state, last_state = 1;
154 uint64_t start = 0, end, period;
155 unsigned int count = 0;
156
157 /* Enable output */
158 gpcr.raw = 0;
159 gpcr.fields.dir = IOC4_GPCR_DIR_0;
160 gpcr.fields.int_out_en = 1;
161 writel(gpcr.raw, &idd->idd_misc_regs->gpcr_s.raw);
162
163 /* Reset to power-on state */
164 writel(0, &idd->idd_misc_regs->int_out.raw);
165 mmiowb();
166
167 printk(KERN_INFO
168 "%s: Calibrating PCI bus speed "
169 "for pci_dev %s ... ", __FUNCTION__, pci_name(idd->idd_pdev));
170 /* Set up square wave */
171 int_out.raw = 0;
172 int_out.fields.count = IOC4_CALIBRATE_COUNT;
173 int_out.fields.mode = IOC4_INT_OUT_MODE_TOGGLE;
174 int_out.fields.diag = 0;
175 writel(int_out.raw, &idd->idd_misc_regs->int_out.raw);
176 mmiowb();
177
178 /* Check square wave period averaged over some number of cycles */
179 do {
180 int_out.raw = readl(&idd->idd_misc_regs->int_out.raw);
181 state = int_out.fields.int_out;
182 if (!last_state && state) {
183 count++;
184 if (count == IOC4_CALIBRATE_END) {
185 end = rtc_time();
186 break;
187 } else if (count == IOC4_CALIBRATE_DISCARD)
188 start = rtc_time();
189 }
190 last_state = state;
191 } while (1);
192
193 /* Calculation rearranged to preserve intermediate precision.
194 * Logically:
195 * 1. "end - start" gives us number of RTC cycles over all the
196 * square wave cycles measured.
197 * 2. Divide by number of square wave cycles to get number of
198 * RTC cycles per square wave cycle.
199 * 3. Divide by 2*(int_out.fields.count+1), which is the formula
200 * by which the IOC4 generates the square wave, to get the
201 * number of RTC cycles per IOC4 INT_OUT count.
202 * 4. Divide by sn_rtc_cycles_per_second to get seconds per
203 * count.
204 * 5. Multiply by 1E9 to get nanoseconds per count.
205 */
206 period = ((end - start) * 1000000000) /
207 (IOC4_CALIBRATE_CYCLES * 2 * (IOC4_CALIBRATE_COUNT + 1)
208 * sn_rtc_cycles_per_second);
209
210 /* Bounds check the result. */
211 if (period > IOC4_CALIBRATE_LOW_LIMIT ||
212 period < IOC4_CALIBRATE_HIGH_LIMIT) {
213 printk("failed. Assuming PCI clock ticks are %d ns.\n",
214 IOC4_CALIBRATE_DEFAULT / IOC4_EXTINT_COUNT_DIVISOR);
215 period = IOC4_CALIBRATE_DEFAULT;
216 } else {
217 printk("succeeded. PCI clock ticks are %ld ns.\n",
218 period / IOC4_EXTINT_COUNT_DIVISOR);
219 }
220
221 /* Remember results. We store the extint clock period rather
222 * than the PCI clock period so that greater precision is
223 * retained. Divide by IOC4_EXTINT_COUNT_DIVISOR to get
224 * PCI clock period.
225 */
226 idd->count_period = period;
227}
228
229/* Adds a new instance of an IOC4 card */
230static int
231ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
22{ 232{
233 struct ioc4_driver_data *idd;
234 struct ioc4_submodule *is;
235 uint32_t pcmd;
23 int ret; 236 int ret;
24 237
238 /* Enable IOC4 and take ownership of it */
25 if ((ret = pci_enable_device(pdev))) { 239 if ((ret = pci_enable_device(pdev))) {
26 printk(KERN_WARNING 240 printk(KERN_WARNING
27 "%s: Failed to enable device with " 241 "%s: Failed to enable IOC4 device for pci_dev %s.\n",
28 "pci_dev 0x%p... returning\n", 242 __FUNCTION__, pci_name(pdev));
29 __FUNCTION__, (void *)pdev); 243 goto out;
30 return ret;
31 } 244 }
32 pci_set_master(pdev); 245 pci_set_master(pdev);
33 246
34 /* attach each sub-device */ 247 /* Set up per-IOC4 data */
35 ret = ioc4_ide_attach_one(pdev, pci_id); 248 idd = kmalloc(sizeof(struct ioc4_driver_data), GFP_KERNEL);
36 if (ret) 249 if (!idd) {
37 return ret; 250 printk(KERN_WARNING
38 return ioc4_serial_attach_one(pdev, pci_id); 251 "%s: Failed to allocate IOC4 data for pci_dev %s.\n",
252 __FUNCTION__, pci_name(pdev));
253 ret = -ENODEV;
254 goto out_idd;
255 }
256 idd->idd_pdev = pdev;
257 idd->idd_pci_id = pci_id;
258
259 /* Map IOC4 misc registers. These are shared between subdevices
260 * so the main IOC4 module manages them.
261 */
262 idd->idd_bar0 = pci_resource_start(idd->idd_pdev, 0);
263 if (!idd->idd_bar0) {
264 printk(KERN_WARNING
265 "%s: Unable to find IOC4 misc resource "
266 "for pci_dev %s.\n",
267 __FUNCTION__, pci_name(idd->idd_pdev));
268 ret = -ENODEV;
269 goto out_pci;
270 }
271 if (!request_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs),
272 "ioc4_misc")) {
273 printk(KERN_WARNING
274 "%s: Unable to request IOC4 misc region "
275 "for pci_dev %s.\n",
276 __FUNCTION__, pci_name(idd->idd_pdev));
277 ret = -ENODEV;
278 goto out_pci;
279 }
280 idd->idd_misc_regs = ioremap(idd->idd_bar0,
281 sizeof(struct ioc4_misc_regs));
282 if (!idd->idd_misc_regs) {
283 printk(KERN_WARNING
284 "%s: Unable to remap IOC4 misc region "
285 "for pci_dev %s.\n",
286 __FUNCTION__, pci_name(idd->idd_pdev));
287 ret = -ENODEV;
288 goto out_misc_region;
289 }
290
291 /* Failsafe portion of per-IOC4 initialization */
292
293 /* Initialize IOC4 */
294 pci_read_config_dword(idd->idd_pdev, PCI_COMMAND, &pcmd);
295 pci_write_config_dword(idd->idd_pdev, PCI_COMMAND,
296 pcmd | PCI_COMMAND_PARITY | PCI_COMMAND_SERR);
297
298 /* Determine PCI clock */
299 ioc4_clock_calibrate(idd);
300
301 /* Disable/clear all interrupts. Need to do this here lest
302 * one submodule request the shared IOC4 IRQ, but interrupt
303 * is generated by a different subdevice.
304 */
305 /* Disable */
306 writel(~0, &idd->idd_misc_regs->other_iec.raw);
307 writel(~0, &idd->idd_misc_regs->sio_iec);
308 /* Clear (i.e. acknowledge) */
309 writel(~0, &idd->idd_misc_regs->other_ir.raw);
310 writel(~0, &idd->idd_misc_regs->sio_ir);
311
312 /* Track PCI-device specific data */
313 idd->idd_serial_data = NULL;
314 pci_set_drvdata(idd->idd_pdev, idd);
315 down_write(&ioc4_devices_rwsem);
316 list_add(&idd->idd_list, &ioc4_devices);
317 up_write(&ioc4_devices_rwsem);
318
319 /* Add this IOC4 to all submodules */
320 down_read(&ioc4_submodules_rwsem);
321 list_for_each_entry(is, &ioc4_submodules, is_list) {
322 if (is->is_probe && is->is_probe(idd)) {
323 printk(KERN_WARNING
324 "%s: IOC4 submodule 0x%s probe failed "
325 "for pci_dev %s.\n",
326 __FUNCTION__, module_name(is->is_owner),
327 pci_name(idd->idd_pdev));
328 }
329 }
330 up_read(&ioc4_submodules_rwsem);
331
332 return 0;
333
334out_misc_region:
335 release_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs));
336out_pci:
337 kfree(idd);
338out_idd:
339 pci_disable_device(pdev);
340out:
341 return ret;
39} 342}
40 343
41/* pci device struct */ 344/* Removes a particular instance of an IOC4 card. */
42static struct pci_device_id ioc4_s_id_table[] = { 345static void
346ioc4_remove(struct pci_dev *pdev)
347{
348 struct ioc4_submodule *is;
349 struct ioc4_driver_data *idd;
350
351 idd = pci_get_drvdata(pdev);
352
353 /* Remove this IOC4 from all submodules */
354 down_read(&ioc4_submodules_rwsem);
355 list_for_each_entry(is, &ioc4_submodules, is_list) {
356 if (is->is_remove && is->is_remove(idd)) {
357 printk(KERN_WARNING
358 "%s: IOC4 submodule 0x%s remove failed "
359 "for pci_dev %s.\n",
360 __FUNCTION__, module_name(is->is_owner),
361 pci_name(idd->idd_pdev));
362 }
363 }
364 up_read(&ioc4_submodules_rwsem);
365
366 /* Release resources */
367 iounmap(idd->idd_misc_regs);
368 if (!idd->idd_bar0) {
369 printk(KERN_WARNING
370 "%s: Unable to get IOC4 misc mapping for pci_dev %s. "
371 "Device removal may be incomplete.\n",
372 __FUNCTION__, pci_name(idd->idd_pdev));
373 }
374 release_region(idd->idd_bar0, sizeof(struct ioc4_misc_regs));
375
376 /* Disable IOC4 and relinquish */
377 pci_disable_device(pdev);
378
379 /* Remove and free driver data */
380 down_write(&ioc4_devices_rwsem);
381 list_del(&idd->idd_list);
382 up_write(&ioc4_devices_rwsem);
383 kfree(idd);
384}
385
386static struct pci_device_id ioc4_id_table[] = {
43 {PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC4, PCI_ANY_ID, 387 {PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC4, PCI_ANY_ID,
44 PCI_ANY_ID, 0x0b4000, 0xFFFFFF}, 388 PCI_ANY_ID, 0x0b4000, 0xFFFFFF},
45 {0} 389 {0}
46}; 390};
47MODULE_DEVICE_TABLE(pci, ioc4_s_id_table);
48 391
49static struct pci_driver __devinitdata ioc4_s_driver = { 392static struct pci_driver __devinitdata ioc4_driver = {
50 .name = "IOC4", 393 .name = "IOC4",
51 .id_table = ioc4_s_id_table, 394 .id_table = ioc4_id_table,
52 .probe = ioc4_probe_one, 395 .probe = ioc4_probe,
396 .remove = ioc4_remove,
53}; 397};
54 398
55static int __devinit ioc4_detect(void) 399MODULE_DEVICE_TABLE(pci, ioc4_id_table);
400
401/*********************
402 * Module management *
403 *********************/
404
405/* Module load */
406static int __devinit
407ioc4_init(void)
56{ 408{
57 ioc4_serial_init(); 409 return pci_register_driver(&ioc4_driver);
410}
58 411
59 return pci_register_driver(&ioc4_s_driver); 412/* Module unload */
413static void __devexit
414ioc4_exit(void)
415{
416 pci_unregister_driver(&ioc4_driver);
60} 417}
61module_init(ioc4_detect);
62 418
63MODULE_AUTHOR("Pat Gefre - Silicon Graphics Inc. (SGI) <pfg@sgi.com>"); 419module_init(ioc4_init);
64MODULE_DESCRIPTION("PCI driver module for SGI IOC4 Base-IO Card"); 420module_exit(ioc4_exit);
421
422MODULE_AUTHOR("Brent Casavant - Silicon Graphics, Inc. <bcasavan@sgi.com>");
423MODULE_DESCRIPTION("PCI driver master module for SGI IOC4 Base-IO Card");
65MODULE_LICENSE("GPL"); 424MODULE_LICENSE("GPL");
425
426EXPORT_SYMBOL(ioc4_register_submodule);
427EXPORT_SYMBOL(ioc4_unregister_submodule);
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 6be8fbec0a0e..04d3120f7236 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -322,6 +322,22 @@ config FB_FM2
322 This is the frame buffer device driver for the Amiga FrameMaster 322 This is the frame buffer device driver for the Amiga FrameMaster
323 card from BSC (exhibited 1992 but not shipped as a CBM product). 323 card from BSC (exhibited 1992 but not shipped as a CBM product).
324 324
325config FB_ARC
326 tristate "Arc Monochrome LCD board support"
327 depends on FB && X86
328 select FB_CFB_FILLRECT
329 select FB_CFB_COPYAREA
330 select FB_CFB_IMAGEBLIT
331 select FB_SOFT_CURSOR
332 help
333 This enables support for the Arc Monochrome LCD board. The board
334 is based on the KS-108 lcd controller and is typically a matrix
335 of 2*n chips. This driver was tested with a 128x64 panel. This
336 driver supports it for use with x86 SBCs through a 16 bit GPIO
337 interface (8 bit data, 8 bit control). If you anticpate using
338 this driver, say Y or M; otherwise say N. You must specify the
339 GPIO IO address to be used for setting control and data.
340
325config FB_ATARI 341config FB_ATARI
326 bool "Atari native chipset support" 342 bool "Atari native chipset support"
327 depends on (FB = y) && ATARI && BROKEN 343 depends on (FB = y) && ATARI && BROKEN
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index bd8dc0ffe723..b018df4e95c8 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_FB_MACMODES) += macmodes.o
21# Hardware specific drivers go first 21# Hardware specific drivers go first
22obj-$(CONFIG_FB_RETINAZ3) += retz3fb.o 22obj-$(CONFIG_FB_RETINAZ3) += retz3fb.o
23obj-$(CONFIG_FB_AMIGA) += amifb.o c2p.o 23obj-$(CONFIG_FB_AMIGA) += amifb.o c2p.o
24obj-$(CONFIG_FB_ARC) += arcfb.o
24obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o 25obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o
25obj-$(CONFIG_FB_CYBER) += cyberfb.o 26obj-$(CONFIG_FB_CYBER) += cyberfb.o
26obj-$(CONFIG_FB_CYBER2000) += cyber2000fb.o 27obj-$(CONFIG_FB_CYBER2000) += cyber2000fb.o
diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
new file mode 100644
index 000000000000..d28457e0c063
--- /dev/null
+++ b/drivers/video/arcfb.c
@@ -0,0 +1,684 @@
1/*
2 * linux/drivers/video/arcfb.c -- FB driver for Arc monochrome LCD board
3 *
4 * Copyright (C) 2005, Jaya Kumar <jayalk@intworks.biz>
5 * http://www.intworks.biz/arclcd
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file COPYING in the main directory of this archive for
9 * more details.
10 *
11 * Layout is based on skeletonfb.c by James Simmons and Geert Uytterhoeven.
12 *
13 * This driver was written to be used with the Arc LCD board. Arc uses a
14 * set of KS108 chips that control individual 64x64 LCD matrices. The board
15 * can be paneled in a variety of setups such as 2x1=128x64, 4x4=256x256 and
16 * so on. The interface between the board and the host is TTL based GPIO. The
17 * GPIO requirements are 8 writable data lines and 4+n lines for control. On a
18 * GPIO-less system, the board can be tested by connecting the respective sigs
19 * up to a parallel port connector. The driver requires the IO addresses for
20 * data and control GPIO at load time. It is unable to probe for the
21 * existence of the LCD so it must be told at load time whether it should
22 * be enabled or not.
23 *
24 * Todo:
25 * - testing with 4x4
26 * - testing with interrupt hw
27 *
28 * General notes:
29 * - User must set tuhold. It's in microseconds. According to the 108 spec,
30 * the hold time is supposed to be at least 1 microsecond.
31 * - User must set num_cols=x num_rows=y, eg: x=2 means 128
32 * - User must set arcfb_enable=1 to enable it
33 * - User must set dio_addr=0xIOADDR cio_addr=0xIOADDR
34 *
35 */
36
37#include <linux/module.h>
38#include <linux/kernel.h>
39#include <linux/errno.h>
40#include <linux/string.h>
41#include <linux/mm.h>
42#include <linux/tty.h>
43#include <linux/slab.h>
44#include <linux/vmalloc.h>
45#include <linux/delay.h>
46#include <linux/interrupt.h>
47#include <linux/fb.h>
48#include <linux/init.h>
49#include <linux/arcfb.h>
50
51#include <asm/uaccess.h>
52
53#define floor8(a) (a&(~0x07))
54#define floorXres(a,xres) (a&(~(xres - 1)))
55#define iceil8(a) (((int)((a+7)/8))*8)
56#define ceil64(a) (a|0x3F)
57#define ceilXres(a,xres) (a|(xres - 1))
58
59/* ks108 chipset specific defines and code */
60
61#define KS_SET_DPY_START_LINE 0xC0
62#define KS_SET_PAGE_NUM 0xB8
63#define KS_SET_X 0x40
64#define KS_CEHI 0x01
65#define KS_CELO 0x00
66#define KS_SEL_CMD 0x08
67#define KS_SEL_DATA 0x00
68#define KS_DPY_ON 0x3F
69#define KS_DPY_OFF 0x3E
70#define KS_INTACK 0x40
71#define KS_CLRINT 0x02
72
73struct arcfb_par {
74 unsigned long dio_addr;
75 unsigned long cio_addr;
76 unsigned long c2io_addr;
77 atomic_t ref_count;
78 unsigned char cslut[9];
79 struct fb_info *info;
80 unsigned int irq;
81 spinlock_t lock;
82};
83
84static struct fb_fix_screeninfo arcfb_fix __initdata = {
85 .id = "arcfb",
86 .type = FB_TYPE_PACKED_PIXELS,
87 .visual = FB_VISUAL_MONO01,
88 .xpanstep = 0,
89 .ypanstep = 1,
90 .ywrapstep = 0,
91 .accel = FB_ACCEL_NONE,
92};
93
94static struct fb_var_screeninfo arcfb_var __initdata = {
95 .xres = 128,
96 .yres = 64,
97 .xres_virtual = 128,
98 .yres_virtual = 64,
99 .bits_per_pixel = 1,
100 .nonstd = 1,
101};
102
103static unsigned long num_cols;
104static unsigned long num_rows;
105static unsigned long dio_addr;
106static unsigned long cio_addr;
107static unsigned long c2io_addr;
108static unsigned long splashval;
109static unsigned long tuhold;
110static unsigned int nosplash;
111static unsigned int arcfb_enable;
112static unsigned int irq;
113
114static DECLARE_WAIT_QUEUE_HEAD(arcfb_waitq);
115
116static void ks108_writeb_ctl(struct arcfb_par *par,
117 unsigned int chipindex, unsigned char value)
118{
119 unsigned char chipselval = par->cslut[chipindex];
120
121 outb(chipselval|KS_CEHI|KS_SEL_CMD, par->cio_addr);
122 outb(value, par->dio_addr);
123 udelay(tuhold);
124 outb(chipselval|KS_CELO|KS_SEL_CMD, par->cio_addr);
125}
126
127static void ks108_writeb_mainctl(struct arcfb_par *par, unsigned char value)
128{
129
130 outb(value, par->cio_addr);
131 udelay(tuhold);
132}
133
134static unsigned char ks108_readb_ctl2(struct arcfb_par *par)
135{
136 return inb(par->c2io_addr);
137}
138
139static void ks108_writeb_data(struct arcfb_par *par,
140 unsigned int chipindex, unsigned char value)
141{
142 unsigned char chipselval = par->cslut[chipindex];
143
144 outb(chipselval|KS_CEHI|KS_SEL_DATA, par->cio_addr);
145 outb(value, par->dio_addr);
146 udelay(tuhold);
147 outb(chipselval|KS_CELO|KS_SEL_DATA, par->cio_addr);
148}
149
150static void ks108_set_start_line(struct arcfb_par *par,
151 unsigned int chipindex, unsigned char y)
152{
153 ks108_writeb_ctl(par, chipindex, KS_SET_DPY_START_LINE|y);
154}
155
156static void ks108_set_yaddr(struct arcfb_par *par,
157 unsigned int chipindex, unsigned char y)
158{
159 ks108_writeb_ctl(par, chipindex, KS_SET_PAGE_NUM|y);
160}
161
162static void ks108_set_xaddr(struct arcfb_par *par,
163 unsigned int chipindex, unsigned char x)
164{
165 ks108_writeb_ctl(par, chipindex, KS_SET_X|x);
166}
167
168static void ks108_clear_lcd(struct arcfb_par *par, unsigned int chipindex)
169{
170 int i,j;
171
172 for (i = 0; i <= 8; i++) {
173 ks108_set_yaddr(par, chipindex, i);
174 ks108_set_xaddr(par, chipindex, 0);
175 for (j = 0; j < 64; j++) {
176 ks108_writeb_data(par, chipindex,
177 (unsigned char) splashval);
178 }
179 }
180}
181
182/* main arcfb functions */
183
184static int arcfb_open(struct fb_info *info, int user)
185{
186 struct arcfb_par *par = info->par;
187
188 atomic_inc(&par->ref_count);
189 return 0;
190}
191
192static int arcfb_release(struct fb_info *info, int user)
193{
194 struct arcfb_par *par = info->par;
195 int count = atomic_read(&par->ref_count);
196
197 if (!count)
198 return -EINVAL;
199 atomic_dec(&par->ref_count);
200 return 0;
201}
202
203static int arcfb_pan_display(struct fb_var_screeninfo *var,
204 struct fb_info *info)
205{
206 int i;
207 struct arcfb_par *par = info->par;
208
209 if ((var->vmode & FB_VMODE_YWRAP) && (var->yoffset < 64)
210 && (info->var.yres <= 64)) {
211 for (i = 0; i < num_cols; i++) {
212 ks108_set_start_line(par, i, var->yoffset);
213 }
214 info->var.yoffset = var->yoffset;
215 return 0;
216 }
217
218 return -EINVAL;
219}
220
221static irqreturn_t arcfb_interrupt(int vec, void *dev_instance,
222 struct pt_regs *regs)
223{
224 struct fb_info *info = dev_instance;
225 unsigned char ctl2status;
226 struct arcfb_par *par = info->par;
227
228 ctl2status = ks108_readb_ctl2(par);
229
230 if (!(ctl2status & KS_INTACK)) /* not arc generated interrupt */
231 return IRQ_NONE;
232
233 ks108_writeb_mainctl(par, KS_CLRINT);
234
235 spin_lock(&par->lock);
236 if (waitqueue_active(&arcfb_waitq)) {
237 wake_up(&arcfb_waitq);
238 }
239 spin_unlock(&par->lock);
240
241 return IRQ_HANDLED;
242}
243
244/*
245 * here we handle a specific page on the lcd. the complexity comes from
246 * the fact that the fb is laidout in 8xX vertical columns. we extract
247 * each write of 8 vertical pixels. then we shift out as we move along
248 * X. That's what rightshift does. bitmask selects the desired input bit.
249 */
250static void arcfb_lcd_update_page(struct arcfb_par *par, unsigned int upper,
251 unsigned int left, unsigned int right, unsigned int distance)
252{
253 unsigned char *src;
254 unsigned int xindex, yindex, chipindex, linesize;
255 int i, count;
256 unsigned char val;
257 unsigned char bitmask, rightshift;
258
259 xindex = left >> 6;
260 yindex = upper >> 6;
261 chipindex = (xindex + (yindex*num_cols));
262
263 ks108_set_yaddr(par, chipindex, upper/8);
264
265 linesize = par->info->var.xres/8;
266 src = par->info->screen_base + (left/8) + (upper * linesize);
267 ks108_set_xaddr(par, chipindex, left);
268
269 bitmask=1;
270 rightshift=0;
271 while (left <= right) {
272 val = 0;
273 for (i = 0; i < 8; i++) {
274 if ( i > rightshift) {
275 val |= (*(src + (i*linesize)) & bitmask)
276 << (i - rightshift);
277 } else {
278 val |= (*(src + (i*linesize)) & bitmask)
279 >> (rightshift - i);
280 }
281 }
282 ks108_writeb_data(par, chipindex, val);
283 left++;
284 count++;
285 if (bitmask == 0x80) {
286 bitmask = 1;
287 src++;
288 rightshift=0;
289 } else {
290 bitmask <<= 1;
291 rightshift++;
292 }
293 }
294}
295
296/*
297 * here we handle the entire vertical page of the update. we write across
298 * lcd chips. update_page uses the upper/left values to decide which
299 * chip to select for the right. upper is needed for setting the page
300 * desired for the write.
301 */
302static void arcfb_lcd_update_vert(struct arcfb_par *par, unsigned int top,
303 unsigned int bottom, unsigned int left, unsigned int right)
304{
305 unsigned int distance, upper, lower;
306
307 distance = (bottom - top) + 1;
308 upper = top;
309 lower = top + 7;
310
311 while (distance > 0) {
312 distance -= 8;
313 arcfb_lcd_update_page(par, upper, left, right, 8);
314 upper = lower + 1;
315 lower = upper + 7;
316 }
317}
318
319/*
320 * here we handle horizontal blocks for the update. update_vert will
321 * handle spaning multiple pages. we break out each horizontal
322 * block in to individual blocks no taller than 64 pixels.
323 */
324static void arcfb_lcd_update_horiz(struct arcfb_par *par, unsigned int left,
325 unsigned int right, unsigned int top, unsigned int h)
326{
327 unsigned int distance, upper, lower;
328
329 distance = h;
330 upper = floor8(top);
331 lower = min(upper + distance - 1, ceil64(upper));
332
333 while (distance > 0) {
334 distance -= ((lower - upper) + 1 );
335 arcfb_lcd_update_vert(par, upper, lower, left, right);
336 upper = lower + 1;
337 lower = min(upper + distance - 1, ceil64(upper));
338 }
339}
340
341/*
342 * here we start the process of spliting out the fb update into
343 * individual blocks of pixels. we end up spliting into 64x64 blocks
344 * and finally down to 64x8 pages.
345 */
346static void arcfb_lcd_update(struct arcfb_par *par, unsigned int dx,
347 unsigned int dy, unsigned int w, unsigned int h)
348{
349 unsigned int left, right, distance, y;
350
351 /* align the request first */
352 y = floor8(dy);
353 h += dy - y;
354 h = iceil8(h);
355
356 distance = w;
357 left = dx;
358 right = min(left + w - 1, ceil64(left));
359
360 while (distance > 0) {
361 arcfb_lcd_update_horiz(par, left, right, y, h);
362 distance -= ((right - left) + 1);
363 left = right + 1;
364 right = min(left + distance - 1, ceil64(left));
365 }
366}
367
368void arcfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
369{
370 struct arcfb_par *par = info->par;
371
372 cfb_fillrect(info, rect);
373
374 /* update the physical lcd */
375 arcfb_lcd_update(par, rect->dx, rect->dy, rect->width, rect->height);
376}
377
378void arcfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
379{
380 struct arcfb_par *par = info->par;
381
382 cfb_copyarea(info, area);
383
384 /* update the physical lcd */
385 arcfb_lcd_update(par, area->dx, area->dy, area->width, area->height);
386}
387
388void arcfb_imageblit(struct fb_info *info, const struct fb_image *image)
389{
390 struct arcfb_par *par = info->par;
391
392 cfb_imageblit(info, image);
393
394 /* update the physical lcd */
395 arcfb_lcd_update(par, image->dx, image->dy, image->width,
396 image->height);
397}
398
399static int arcfb_ioctl(struct inode *inode, struct file *file,
400 unsigned int cmd, unsigned long arg,
401 struct fb_info *info)
402{
403 void __user *argp = (void __user *)arg;
404 struct arcfb_par *par = info->par;
405 unsigned long flags;
406
407 switch (cmd) {
408 case FBIO_WAITEVENT:
409 {
410 DEFINE_WAIT(wait);
411 /* illegal to wait on arc if no irq will occur */
412 if (!par->irq)
413 return -EINVAL;
414
415 /* wait until the Arc has generated an interrupt
416 * which will wake us up */
417 spin_lock_irqsave(&par->lock, flags);
418 prepare_to_wait(&arcfb_waitq, &wait,
419 TASK_INTERRUPTIBLE);
420 spin_unlock_irqrestore(&par->lock, flags);
421 schedule();
422 finish_wait(&arcfb_waitq, &wait);
423 }
424 case FBIO_GETCONTROL2:
425 {
426 unsigned char ctl2;
427
428 ctl2 = ks108_readb_ctl2(info->par);
429 if (copy_to_user(argp, &ctl2, sizeof(ctl2)))
430 return -EFAULT;
431 return 0;
432 }
433 default:
434 return -EINVAL;
435 }
436}
437
438/*
439 * this is the access path from userspace. they can seek and write to
440 * the fb. it's inefficient for them to do anything less than 64*8
441 * writes since we update the lcd in each write() anyway.
442 */
443static ssize_t arcfb_write(struct file *file, const char *buf, size_t count,
444 loff_t *ppos)
445{
446 /* modded from epson 1355 */
447
448 struct inode *inode;
449 int fbidx;
450 struct fb_info *info;
451 unsigned long p;
452 int err=-EINVAL;
453 unsigned int fbmemlength,x,y,w,h, bitppos, startpos, endpos, bitcount;
454 struct arcfb_par *par;
455 unsigned int xres;
456
457 p = *ppos;
458 inode = file->f_dentry->d_inode;
459 fbidx = iminor(inode);
460 info = registered_fb[fbidx];
461 par = info->par;
462
463 if (!info || !info->screen_base)
464 return -ENODEV;
465
466 xres = info->var.xres;
467 fbmemlength = (xres * info->var.yres)/8;
468
469 if (p > fbmemlength)
470 return -ENOSPC;
471
472 err = 0;
473 if ((count + p) > fbmemlength) {
474 count = fbmemlength - p;
475 err = -ENOSPC;
476 }
477
478 if (count) {
479 char *base_addr;
480
481 base_addr = info->screen_base;
482 count -= copy_from_user(base_addr + p, buf, count);
483 *ppos += count;
484 err = -EFAULT;
485 }
486
487
488 bitppos = p*8;
489 startpos = floorXres(bitppos, xres);
490 endpos = ceilXres((bitppos + (count*8)), xres);
491 bitcount = endpos - startpos;
492
493 x = startpos % xres;
494 y = startpos / xres;
495 w = xres;
496 h = bitcount / xres;
497 arcfb_lcd_update(par, x, y, w, h);
498
499 if (count)
500 return count;
501 return err;
502}
503
504static void arcfb_platform_release(struct device *device)
505{
506}
507
508static struct fb_ops arcfb_ops = {
509 .owner = THIS_MODULE,
510 .fb_open = arcfb_open,
511 .fb_write = arcfb_write,
512 .fb_release = arcfb_release,
513 .fb_pan_display = arcfb_pan_display,
514 .fb_fillrect = arcfb_fillrect,
515 .fb_copyarea = arcfb_copyarea,
516 .fb_imageblit = arcfb_imageblit,
517 .fb_cursor = soft_cursor,
518 .fb_ioctl = arcfb_ioctl,
519};
520
521static int __init arcfb_probe(struct device *device)
522{
523 struct platform_device *dev = to_platform_device(device);
524 struct fb_info *info;
525 int retval = -ENOMEM;
526 int videomemorysize;
527 unsigned char *videomemory;
528 struct arcfb_par *par;
529 int i;
530
531 videomemorysize = (((64*64)*num_cols)*num_rows)/8;
532
533 /* We need a flat backing store for the Arc's
534 less-flat actual paged framebuffer */
535 if (!(videomemory = vmalloc(videomemorysize)))
536 return retval;
537
538 memset(videomemory, 0, videomemorysize);
539
540 info = framebuffer_alloc(sizeof(struct arcfb_par), &dev->dev);
541 if (!info)
542 goto err;
543
544 info->screen_base = (char __iomem *)videomemory;
545 info->fbops = &arcfb_ops;
546
547 info->var = arcfb_var;
548 info->fix = arcfb_fix;
549 par = info->par;
550 par->info = info;
551
552 if (!dio_addr || !cio_addr || !c2io_addr) {
553 printk(KERN_WARNING "no IO addresses supplied\n");
554 goto err1;
555 }
556 par->dio_addr = dio_addr;
557 par->cio_addr = cio_addr;
558 par->c2io_addr = c2io_addr;
559 par->cslut[0] = 0x00;
560 par->cslut[1] = 0x06;
561 info->flags = FBINFO_FLAG_DEFAULT;
562 spin_lock_init(&par->lock);
563 retval = register_framebuffer(info);
564 if (retval < 0)
565 goto err1;
566 dev_set_drvdata(&dev->dev, info);
567 if (irq) {
568 par->irq = irq;
569 if (request_irq(par->irq, &arcfb_interrupt, SA_SHIRQ,
570 "arcfb", info)) {
571 printk(KERN_INFO
572 "arcfb: Failed req IRQ %d\n", par->irq);
573 goto err1;
574 }
575 }
576 printk(KERN_INFO
577 "fb%d: Arc frame buffer device, using %dK of video memory\n",
578 info->node, videomemorysize >> 10);
579
580 /* this inits the lcd but doesn't clear dirty pixels */
581 for (i = 0; i < num_cols * num_rows; i++) {
582 ks108_writeb_ctl(par, i, KS_DPY_OFF);
583 ks108_set_start_line(par, i, 0);
584 ks108_set_yaddr(par, i, 0);
585 ks108_set_xaddr(par, i, 0);
586 ks108_writeb_ctl(par, i, KS_DPY_ON);
587 }
588
589 /* if we were told to splash the screen, we just clear it */
590 if (!nosplash) {
591 for (i = 0; i < num_cols * num_rows; i++) {
592 printk(KERN_INFO "fb%d: splashing lcd %d\n",
593 info->node, i);
594 ks108_set_start_line(par, i, 0);
595 ks108_clear_lcd(par, i);
596 }
597 }
598
599 return 0;
600err1:
601 framebuffer_release(info);
602err:
603 vfree(videomemory);
604 return retval;
605}
606
607static int arcfb_remove(struct device *device)
608{
609 struct fb_info *info = dev_get_drvdata(device);
610
611 if (info) {
612 unregister_framebuffer(info);
613 vfree(info->screen_base);
614 framebuffer_release(info);
615 }
616 return 0;
617}
618
619static struct device_driver arcfb_driver = {
620 .name = "arcfb",
621 .bus = &platform_bus_type,
622 .probe = arcfb_probe,
623 .remove = arcfb_remove,
624};
625
626static struct platform_device arcfb_device = {
627 .name = "arcfb",
628 .id = 0,
629 .dev = {
630 .release = arcfb_platform_release,
631 }
632};
633
634static int __init arcfb_init(void)
635{
636 int ret;
637
638 if (!arcfb_enable)
639 return -ENXIO;
640
641 ret = driver_register(&arcfb_driver);
642 if (!ret) {
643 ret = platform_device_register(&arcfb_device);
644 if (ret)
645 driver_unregister(&arcfb_driver);
646 }
647 return ret;
648
649}
650
651static void __exit arcfb_exit(void)
652{
653 platform_device_unregister(&arcfb_device);
654 driver_unregister(&arcfb_driver);
655}
656
657module_param(num_cols, ulong, 0);
658MODULE_PARM_DESC(num_cols, "Num horiz panels, eg: 2 = 128 bit wide");
659module_param(num_rows, ulong, 0);
660MODULE_PARM_DESC(num_rows, "Num vert panels, eg: 1 = 64 bit high");
661module_param(nosplash, uint, 0);
662MODULE_PARM_DESC(nosplash, "Disable doing the splash screen");
663module_param(arcfb_enable, uint, 0);
664MODULE_PARM_DESC(arcfb_enable, "Enable communication with Arc board");
665module_param(dio_addr, ulong, 0);
666MODULE_PARM_DESC(dio_addr, "IO address for data, eg: 0x480");
667module_param(cio_addr, ulong, 0);
668MODULE_PARM_DESC(cio_addr, "IO address for control, eg: 0x400");
669module_param(c2io_addr, ulong, 0);
670MODULE_PARM_DESC(c2io_addr, "IO address for secondary control, eg: 0x408");
671module_param(splashval, ulong, 0);
672MODULE_PARM_DESC(splashval, "Splash pattern: 0xFF is black, 0x00 is green");
673module_param(tuhold, ulong, 0);
674MODULE_PARM_DESC(tuhold, "Time to hold between strobing data to Arc board");
675module_param(irq, uint, 0);
676MODULE_PARM_DESC(irq, "IRQ for the Arc board");
677
678module_init(arcfb_init);
679module_exit(arcfb_exit);
680
681MODULE_DESCRIPTION("fbdev driver for Arc monochrome LCD board");
682MODULE_AUTHOR("Jaya Kumar");
683MODULE_LICENSE("GPL");
684
diff --git a/drivers/video/chipsfb.c b/drivers/video/chipsfb.c
index ab98f225fe3e..95e72550d43f 100644
--- a/drivers/video/chipsfb.c
+++ b/drivers/video/chipsfb.c
@@ -423,9 +423,6 @@ chipsfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent)
423 pmu_register_sleep_notifier(&chips_sleep_notifier); 423 pmu_register_sleep_notifier(&chips_sleep_notifier);
424#endif /* CONFIG_PMAC_PBOOK */ 424#endif /* CONFIG_PMAC_PBOOK */
425 425
426 /* Clear the entire framebuffer */
427 memset(p->screen_base, 0, 0x100000);
428
429 pci_set_drvdata(dp, p); 426 pci_set_drvdata(dp, p);
430 return 0; 427 return 0;
431} 428}
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
index ccf55811d24f..e4b91a4b936c 100644
--- a/drivers/video/console/Kconfig
+++ b/drivers/video/console/Kconfig
@@ -153,6 +153,15 @@ config FONT_6x11
153 Small console font with Macintosh-style high-half glyphs. Some Mac 153 Small console font with Macintosh-style high-half glyphs. Some Mac
154 framebuffer drivers don't support this one at all. 154 framebuffer drivers don't support this one at all.
155 155
156config FONT_7x14
157 bool "console 7x14 font (not supported by all drivers)" if FONTS
158 depends on FRAMEBUFFER_CONSOLE
159 default y if !SPARC32 && !SPARC64 && !FONTS
160 help
161 Console font with characters just a bit smaller than the default.
162 If the standard 8x16 font is a little too big for you, say Y.
163 Otherwise, say N.
164
156config FONT_PEARL_8x8 165config FONT_PEARL_8x8
157 bool "Pearl (old m68k) console 8x8 font" if FONTS 166 bool "Pearl (old m68k) console 8x8 font" if FONTS
158 depends on FRAMEBUFFER_CONSOLE 167 depends on FRAMEBUFFER_CONSOLE
@@ -187,5 +196,13 @@ config FONT_SUN12x22
187 big letters (like the letters used in the SPARC PROM). If the 196 big letters (like the letters used in the SPARC PROM). If the
188 standard font is unreadable for you, say Y, otherwise say N. 197 standard font is unreadable for you, say Y, otherwise say N.
189 198
199config FONT_10x18
200 bool "console 10x18 font (not supported by all drivers)"
201 depends on FONTS
202 help
203 This is a high resolution console font for machines with very
204 big letters. It fits between the sun 12x22 and the normal 8x16 font.
205 If other fonts are too big or too small for you, say Y, otherwise say N.
206
190endmenu 207endmenu
191 208
diff --git a/drivers/video/console/Makefile b/drivers/video/console/Makefile
index 33516447f9f2..b562f6bb9d31 100644
--- a/drivers/video/console/Makefile
+++ b/drivers/video/console/Makefile
@@ -10,6 +10,8 @@ font-objs-$(CONFIG_FONT_SUN12x22) += font_sun12x22.o
10font-objs-$(CONFIG_FONT_8x8) += font_8x8.o 10font-objs-$(CONFIG_FONT_8x8) += font_8x8.o
11font-objs-$(CONFIG_FONT_8x16) += font_8x16.o 11font-objs-$(CONFIG_FONT_8x16) += font_8x16.o
12font-objs-$(CONFIG_FONT_6x11) += font_6x11.o 12font-objs-$(CONFIG_FONT_6x11) += font_6x11.o
13font-objs-$(CONFIG_FONT_7x14) += font_7x14.o
14font-objs-$(CONFIG_FONT_10x18) += font_10x18.o
13font-objs-$(CONFIG_FONT_PEARL_8x8) += font_pearl_8x8.o 15font-objs-$(CONFIG_FONT_PEARL_8x8) += font_pearl_8x8.o
14font-objs-$(CONFIG_FONT_ACORN_8x8) += font_acorn_8x8.o 16font-objs-$(CONFIG_FONT_ACORN_8x8) += font_acorn_8x8.o
15font-objs-$(CONFIG_FONT_MINI_4x6) += font_mini_4x6.o 17font-objs-$(CONFIG_FONT_MINI_4x6) += font_mini_4x6.o
diff --git a/drivers/video/console/bitblit.c b/drivers/video/console/bitblit.c
index b28a4b0e395e..3c731577fed6 100644
--- a/drivers/video/console/bitblit.c
+++ b/drivers/video/console/bitblit.c
@@ -107,13 +107,6 @@ static void bit_putcs(struct vc_data *vc, struct fb_info *info,
107 const unsigned short *s, int count, int yy, int xx, 107 const unsigned short *s, int count, int yy, int xx,
108 int fg, int bg) 108 int fg, int bg)
109{ 109{
110 void (*move_unaligned)(struct fb_info *info, struct fb_pixmap *buf,
111 u8 *dst, u32 d_pitch, u8 *src, u32 idx,
112 u32 height, u32 shift_high, u32 shift_low,
113 u32 mod);
114 void (*move_aligned)(struct fb_info *info, struct fb_pixmap *buf,
115 u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch,
116 u32 height);
117 unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; 110 unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
118 unsigned int width = (vc->vc_font.width + 7) >> 3; 111 unsigned int width = (vc->vc_font.width + 7) >> 3;
119 unsigned int cellsize = vc->vc_font.height * width; 112 unsigned int cellsize = vc->vc_font.height * width;
@@ -141,13 +134,6 @@ static void bit_putcs(struct vc_data *vc, struct fb_info *info,
141 image.height = vc->vc_font.height; 134 image.height = vc->vc_font.height;
142 image.depth = 1; 135 image.depth = 1;
143 136
144 if (info->pixmap.outbuf && info->pixmap.inbuf) {
145 move_aligned = fb_iomove_buf_aligned;
146 move_unaligned = fb_iomove_buf_unaligned;
147 } else {
148 move_aligned = fb_sysmove_buf_aligned;
149 move_unaligned = fb_sysmove_buf_unaligned;
150 }
151 while (count) { 137 while (count) {
152 if (count > maxcnt) 138 if (count > maxcnt)
153 cnt = k = maxcnt; 139 cnt = k = maxcnt;
@@ -171,9 +157,9 @@ static void bit_putcs(struct vc_data *vc, struct fb_info *info,
171 src = buf; 157 src = buf;
172 } 158 }
173 159
174 move_unaligned(info, &info->pixmap, dst, pitch, 160 fb_pad_unaligned_buffer(dst, pitch, src, idx,
175 src, idx, image.height, 161 image.height, shift_high,
176 shift_high, shift_low, mod); 162 shift_low, mod);
177 shift_low += mod; 163 shift_low += mod;
178 dst += (shift_low >= 8) ? width : width - 1; 164 dst += (shift_low >= 8) ? width : width - 1;
179 shift_low &= 7; 165 shift_low &= 7;
@@ -189,8 +175,7 @@ static void bit_putcs(struct vc_data *vc, struct fb_info *info,
189 src = buf; 175 src = buf;
190 } 176 }
191 177
192 move_aligned(info, &info->pixmap, dst, pitch, 178 fb_pad_aligned_buffer(dst, pitch, src, idx, image.height);
193 src, idx, image.height);
194 dst += width; 179 dst += width;
195 } 180 }
196 } 181 }
diff --git a/drivers/video/console/font_10x18.c b/drivers/video/console/font_10x18.c
new file mode 100644
index 000000000000..ff0af96e4dfc
--- /dev/null
+++ b/drivers/video/console/font_10x18.c
@@ -0,0 +1,5146 @@
1/********************************
2 * adapted from font_sun12x22.c *
3 * by Jurriaan Kalkman 06-2005 *
4 ********************************/
5
6#include <linux/font.h>
7
8#define FONTDATAMAX 9216
9
10static unsigned char fontdata_10x18[FONTDATAMAX] = {
11
12 /* 0 0x00 '^@' */
13 0x00, 0x00, /* 0000000000 */
14 0x00, 0x00, /* 0000000000 */
15 0x00, 0x00, /* 0000000000 */
16 0x00, 0x00, /* 0000000000 */
17 0x00, 0x00, /* 0000000000 */
18 0x00, 0x00, /* 0000000000 */
19 0x00, 0x00, /* 0000000000 */
20 0x00, 0x00, /* 0000000000 */
21 0x00, 0x00, /* 0000000000 */
22 0x00, 0x00, /* 0000000000 */
23 0x00, 0x00, /* 0000000000 */
24 0x00, 0x00, /* 0000000000 */
25 0x00, 0x00, /* 0000000000 */
26 0x00, 0x00, /* 0000000000 */
27 0x00, 0x00, /* 0000000000 */
28 0x00, 0x00, /* 0000000000 */
29 0x00, 0x00, /* 0000000000 */
30 0x00, 0x00, /* 0000000000 */
31
32 /* 1 0x01 '^A' */
33 0x00, 0x00, /* 0000000000 */
34 0x00, 0x00, /* 0000000000 */
35 0x00, 0x00, /* 0000000000 */
36 0x00, 0x00, /* 0000000000 */
37 0x00, 0x00, /* 0000000000 */
38 0x3f, 0x80, /* 0011111110 */
39 0x40, 0x40, /* 0100000001 */
40 0x5b, 0x40, /* 0101101101 */
41 0x40, 0x40, /* 0100000001 */
42 0x44, 0x40, /* 0100010001 */
43 0x44, 0x40, /* 0100010001 */
44 0x51, 0x40, /* 0101000101 */
45 0x4e, 0x40, /* 0100111001 */
46 0x40, 0x40, /* 0100000001 */
47 0x3f, 0x80, /* 0011111110 */
48 0x00, 0x00, /* 0000000000 */
49 0x00, 0x00, /* 0000000000 */
50 0x00, 0x00, /* 0000000000 */
51
52 /* 2 0x02 '^B' */
53 0x00, 0x00, /* 0000000000 */
54 0x00, 0x00, /* 0000000000 */
55 0x00, 0x00, /* 0000000000 */
56 0x00, 0x00, /* 0000000000 */
57 0x00, 0x00, /* 0000000000 */
58 0x3f, 0x80, /* 0011111110 */
59 0x7f, 0xc0, /* 0111111111 */
60 0x64, 0xc0, /* 0110010011 */
61 0x7f, 0xc0, /* 0111111111 */
62 0x7b, 0xc0, /* 0111101111 */
63 0x7b, 0xc0, /* 0111101111 */
64 0x6e, 0xc0, /* 0110111011 */
65 0x71, 0xc0, /* 0111000111 */
66 0x7f, 0xc0, /* 0111111111 */
67 0x3f, 0x80, /* 0011111110 */
68 0x00, 0x00, /* 0000000000 */
69 0x00, 0x00, /* 0000000000 */
70 0x00, 0x00, /* 0000000000 */
71
72 /* 3 0x03 '^C' */
73 0x00, 0x00, /* 0000000000 */
74 0x00, 0x00, /* 0000000000 */
75 0x00, 0x00, /* 0000000000 */
76 0x00, 0x00, /* 0000000000 */
77 0x00, 0x00, /* 0000000000 */
78 0x11, 0x00, /* 0001000100 */
79 0x3b, 0x80, /* 0011101110 */
80 0x7f, 0xc0, /* 0111111111 */
81 0x3f, 0x80, /* 0011111110 */
82 0x3f, 0x80, /* 0011111110 */
83 0x1f, 0x00, /* 0001111100 */
84 0x1f, 0x00, /* 0001111100 */
85 0x0e, 0x00, /* 0000111000 */
86 0x0e, 0x00, /* 0000111000 */
87 0x04, 0x00, /* 0000010000 */
88 0x00, 0x00, /* 0000000000 */
89 0x00, 0x00, /* 0000000000 */
90 0x00, 0x00, /* 0000000000 */
91
92 /* 4 0x04 '^D' */
93 0x00, 0x00, /* 0000000000 */
94 0x00, 0x00, /* 0000000000 */
95 0x00, 0x00, /* 0000000000 */
96 0x00, 0x00, /* 0000000000 */
97 0x04, 0x00, /* 0000010000 */
98 0x0e, 0x00, /* 0000111000 */
99 0x0e, 0x00, /* 0000111000 */
100 0x1f, 0x00, /* 0001111100 */
101 0x1f, 0x00, /* 0001111100 */
102 0x3f, 0x80, /* 0011111110 */
103 0x1f, 0x00, /* 0001111100 */
104 0x1f, 0x00, /* 0001111100 */
105 0x0e, 0x00, /* 0000111000 */
106 0x0e, 0x00, /* 0000111000 */
107 0x04, 0x00, /* 0000010000 */
108 0x00, 0x00, /* 0000000000 */
109 0x00, 0x00, /* 0000000000 */
110 0x00, 0x00, /* 0000000000 */
111
112 /* 5 0x05 '^E' */
113 0x00, 0x00, /* 0000000000 */
114 0x00, 0x00, /* 0000000000 */
115 0x00, 0x00, /* 0000000000 */
116 0x00, 0x00, /* 0000000000 */
117 0x00, 0x00, /* 0000000000 */
118 0x00, 0x00, /* 0000000000 */
119 0x0c, 0x00, /* 0000110000 */
120 0x1e, 0x00, /* 0001111000 */
121 0x0c, 0x00, /* 0000110000 */
122 0x31, 0x80, /* 0011000110 */
123 0x7b, 0xc0, /* 0111101111 */
124 0x35, 0x80, /* 0011010110 */
125 0x04, 0x00, /* 0000010000 */
126 0x0e, 0x00, /* 0000111000 */
127 0x1f, 0x00, /* 0001111100 */
128 0x00, 0x00, /* 0000000000 */
129 0x00, 0x00, /* 0000000000 */
130 0x00, 0x00, /* 0000000000 */
131
132 /* 6 0x06 '^F' */
133 0x00, 0x00, /* 0000000000 */
134 0x00, 0x00, /* 0000000000 */
135 0x00, 0x00, /* 0000000000 */
136 0x00, 0x00, /* 0000000000 */
137 0x04, 0x00, /* 0000010000 */
138 0x0e, 0x00, /* 0000111000 */
139 0x1f, 0x00, /* 0001111100 */
140 0x1f, 0x00, /* 0001111100 */
141 0x3f, 0x80, /* 0011111110 */
142 0x7f, 0xc0, /* 0111111111 */
143 0x7f, 0xc0, /* 0111111111 */
144 0x35, 0x80, /* 0011010110 */
145 0x04, 0x00, /* 0000010000 */
146 0x0e, 0x00, /* 0000111000 */
147 0x1f, 0x00, /* 0001111100 */
148 0x00, 0x00, /* 0000000000 */
149 0x00, 0x00, /* 0000000000 */
150 0x00, 0x00, /* 0000000000 */
151
152 /* 7 0x07 '^G' */
153 0x00, 0x00, /* 0000000000 */
154 0x00, 0x00, /* 0000000000 */
155 0x00, 0x00, /* 0000000000 */
156 0x00, 0x00, /* 0000000000 */
157 0x00, 0x00, /* 0000000000 */
158 0x0c, 0x00, /* 0000110000 */
159 0x1e, 0x00, /* 0001111000 */
160 0x1e, 0x00, /* 0001111000 */
161 0x3f, 0x00, /* 0011111100 */
162 0x3f, 0x00, /* 0011111100 */
163 0x1e, 0x00, /* 0001111000 */
164 0x1e, 0x00, /* 0001111000 */
165 0x0c, 0x00, /* 0000110000 */
166 0x00, 0x00, /* 0000000000 */
167 0x00, 0x00, /* 0000000000 */
168 0x00, 0x00, /* 0000000000 */
169 0x00, 0x00, /* 0000000000 */
170 0x00, 0x00, /* 0000000000 */
171
172 /* 8 0x08 '^H' */
173 0xff, 0xc0, /* 1111111111 */
174 0xff, 0xc0, /* 1111111111 */
175 0xff, 0xc0, /* 1111111111 */
176 0xff, 0xc0, /* 1111111111 */
177 0xff, 0xc0, /* 1111111111 */
178 0xf3, 0xc0, /* 1111001111 */
179 0xe1, 0xc0, /* 1110000111 */
180 0xe1, 0xc0, /* 1110000111 */
181 0xc0, 0xc0, /* 1100000011 */
182 0xc0, 0xc0, /* 1100000011 */
183 0xe1, 0xc0, /* 1110000111 */
184 0xe1, 0xc0, /* 1110000111 */
185 0xf3, 0xc0, /* 1111001111 */
186 0xff, 0xc0, /* 1111111111 */
187 0xff, 0xc0, /* 1111111111 */
188 0xff, 0xc0, /* 1111111111 */
189 0xff, 0xc0, /* 1111111111 */
190 0xff, 0xc0, /* 1111111111 */
191
192 /* 9 0x09 '^I' */
193 0x00, 0x00, /* 0000000000 */
194 0x00, 0x00, /* 0000000000 */
195 0x00, 0x00, /* 0000000000 */
196 0x00, 0x00, /* 0000000000 */
197 0x00, 0x00, /* 0000000000 */
198 0x0c, 0x00, /* 0000110000 */
199 0x12, 0x00, /* 0001001000 */
200 0x12, 0x00, /* 0001001000 */
201 0x21, 0x00, /* 0010000100 */
202 0x21, 0x00, /* 0010000100 */
203 0x12, 0x00, /* 0001001000 */
204 0x12, 0x00, /* 0001001000 */
205 0x0c, 0x00, /* 0000110000 */
206 0x00, 0x00, /* 0000000000 */
207 0x00, 0x00, /* 0000000000 */
208 0x00, 0x00, /* 0000000000 */
209 0x00, 0x00, /* 0000000000 */
210 0x00, 0x00, /* 0000000000 */
211
212 /* 10 0x0a '^J' */
213 0xff, 0xc0, /* 1111111111 */
214 0xff, 0xc0, /* 1111111111 */
215 0xff, 0xc0, /* 1111111111 */
216 0xff, 0xc0, /* 1111111111 */
217 0xff, 0xc0, /* 1111111111 */
218 0xf3, 0xc0, /* 1111001111 */
219 0xed, 0xc0, /* 1110110111 */
220 0xed, 0xc0, /* 1110110111 */
221 0xde, 0xc0, /* 1101111011 */
222 0xde, 0xc0, /* 1101111011 */
223 0xed, 0xc0, /* 1110110111 */
224 0xed, 0xc0, /* 1110110111 */
225 0xf3, 0xc0, /* 1111001111 */
226 0xff, 0xc0, /* 1111111111 */
227 0xff, 0xc0, /* 1111111111 */
228 0xff, 0xc0, /* 1111111111 */
229 0xff, 0xc0, /* 1111111111 */
230 0xff, 0xc0, /* 1111111111 */
231
232 /* 11 0x0b '^K' */
233 0x00, 0x00, /* 0000000000 */
234 0x00, 0x00, /* 0000000000 */
235 0x0f, 0xc0, /* 0000111111 */
236 0x0f, 0xc0, /* 0000111111 */
237 0x03, 0xc0, /* 0000001111 */
238 0x06, 0xc0, /* 0000011011 */
239 0x0c, 0xc0, /* 0000110011 */
240 0x3c, 0x00, /* 0011110000 */
241 0x66, 0x00, /* 0110011000 */
242 0xc3, 0x00, /* 1100001100 */
243 0xc3, 0x00, /* 1100001100 */
244 0xc3, 0x00, /* 1100001100 */
245 0x66, 0x00, /* 0110011000 */
246 0x3c, 0x00, /* 0011110000 */
247 0x00, 0x00, /* 0000000000 */
248 0x00, 0x00, /* 0000000000 */
249 0x00, 0x00, /* 0000000000 */
250 0x00, 0x00, /* 0000000000 */
251
252 /* 12 0x0c '^L' */
253 0x00, 0x00, /* 0000000000 */
254 0x00, 0x00, /* 0000000000 */
255 0x00, 0x00, /* 0000000000 */
256 0x1e, 0x00, /* 0001111000 */
257 0x33, 0x00, /* 0011001100 */
258 0x61, 0x80, /* 0110000110 */
259 0x61, 0x80, /* 0110000110 */
260 0x61, 0x80, /* 0110000110 */
261 0x33, 0x00, /* 0011001100 */
262 0x1e, 0x00, /* 0001111000 */
263 0x0c, 0x00, /* 0000110000 */
264 0x0c, 0x00, /* 0000110000 */
265 0x3f, 0x00, /* 0011111100 */
266 0x0c, 0x00, /* 0000110000 */
267 0x0c, 0x00, /* 0000110000 */
268 0x00, 0x00, /* 0000000000 */
269 0x00, 0x00, /* 0000000000 */
270 0x00, 0x00, /* 0000000000 */
271
272 /* 13 0x0d '^M' */
273 0x00, 0x00, /* 0000000000 */
274 0x00, 0x00, /* 0000000000 */
275 0x00, 0x00, /* 0000000000 */
276 0x0f, 0x80, /* 0000111110 */
277 0x08, 0x80, /* 0000100010 */
278 0x0f, 0x80, /* 0000111110 */
279 0x08, 0x00, /* 0000100000 */
280 0x08, 0x00, /* 0000100000 */
281 0x08, 0x00, /* 0000100000 */
282 0x08, 0x00, /* 0000100000 */
283 0x08, 0x00, /* 0000100000 */
284 0x08, 0x00, /* 0000100000 */
285 0x38, 0x00, /* 0011100000 */
286 0x78, 0x00, /* 0111100000 */
287 0x30, 0x00, /* 0011000000 */
288 0x00, 0x00, /* 0000000000 */
289 0x00, 0x00, /* 0000000000 */
290 0x00, 0x00, /* 0000000000 */
291
292 /* 14 0x0e '^N' */
293 0x00, 0x00, /* 0000000000 */
294 0x00, 0x00, /* 0000000000 */
295 0x00, 0x00, /* 0000000000 */
296 0x1f, 0x80, /* 0001111110 */
297 0x10, 0x80, /* 0001000010 */
298 0x1f, 0x80, /* 0001111110 */
299 0x10, 0x80, /* 0001000010 */
300 0x10, 0x80, /* 0001000010 */
301 0x10, 0x80, /* 0001000010 */
302 0x10, 0x80, /* 0001000010 */
303 0x13, 0x80, /* 0001001110 */
304 0x17, 0x80, /* 0001011110 */
305 0x73, 0x00, /* 0111001100 */
306 0xf0, 0x00, /* 1111000000 */
307 0x60, 0x00, /* 0110000000 */
308 0x00, 0x00, /* 0000000000 */
309 0x00, 0x00, /* 0000000000 */
310 0x00, 0x00, /* 0000000000 */
311
312 /* 15 0x0f '^O' */
313 0x00, 0x00, /* 0000000000 */
314 0x00, 0x00, /* 0000000000 */
315 0x00, 0x00, /* 0000000000 */
316 0x04, 0x00, /* 0000010000 */
317 0x24, 0x80, /* 0010010010 */
318 0x15, 0x00, /* 0001010100 */
319 0x55, 0x40, /* 0101010101 */
320 0x3f, 0x80, /* 0011111110 */
321 0x0e, 0x00, /* 0000111000 */
322 0x00, 0x00, /* 0000000000 */
323 0x0e, 0x00, /* 0000111000 */
324 0x3f, 0x80, /* 0011111110 */
325 0x55, 0x40, /* 0101010101 */
326 0x15, 0x00, /* 0001010100 */
327 0x24, 0x80, /* 0010010010 */
328 0x00, 0x00, /* 0000000000 */
329 0x00, 0x00, /* 0000000000 */
330 0x00, 0x00, /* 0000000000 */
331
332 /* 16 0x10 '^P' */
333 0x00, 0x80, /* 0000000010 */
334 0x01, 0x80, /* 0000000110 */
335 0x03, 0x80, /* 0000001110 */
336 0x07, 0x80, /* 0000011110 */
337 0x0f, 0x80, /* 0000111110 */
338 0x1f, 0x80, /* 0001111110 */
339 0x3f, 0x80, /* 0011111110 */
340 0x7f, 0x80, /* 0111111110 */
341 0xff, 0x80, /* 1111111110 */
342 0x7f, 0x80, /* 0111111110 */
343 0x3f, 0x80, /* 0011111110 */
344 0x1f, 0x80, /* 0001111110 */
345 0x0f, 0x80, /* 0000111110 */
346 0x07, 0x80, /* 0000011110 */
347 0x03, 0x80, /* 0000001110 */
348 0x01, 0x80, /* 0000000110 */
349 0x00, 0x80, /* 0000000010 */
350 0x00, 0x00, /* 0000000000 */
351
352 /* 17 0x11 '^Q' */
353 0x40, 0x00, /* 0100000000 */
354 0x60, 0x00, /* 0110000000 */
355 0x70, 0x00, /* 0111000000 */
356 0x78, 0x00, /* 0111100000 */
357 0x7c, 0x00, /* 0111110000 */
358 0x7e, 0x00, /* 0111111000 */
359 0x7f, 0x00, /* 0111111100 */
360 0x7f, 0x80, /* 0111111110 */
361 0x7f, 0xc0, /* 0111111111 */
362 0x7f, 0x80, /* 0111111110 */
363 0x7f, 0x00, /* 0111111100 */
364 0x7e, 0x00, /* 0111111000 */
365 0x7c, 0x00, /* 0111110000 */
366 0x78, 0x00, /* 0111100000 */
367 0x70, 0x00, /* 0111000000 */
368 0x60, 0x00, /* 0110000000 */
369 0x40, 0x00, /* 0100000000 */
370 0x00, 0x00, /* 0000000000 */
371
372 /* 18 0x12 '^R' */
373 0x00, 0x00, /* 0000000000 */
374 0x00, 0x00, /* 0000000000 */
375 0x00, 0x00, /* 0000000000 */
376 0x00, 0x00, /* 0000000000 */
377 0x0c, 0x00, /* 0000110000 */
378 0x1e, 0x00, /* 0001111000 */
379 0x3f, 0x00, /* 0011111100 */
380 0x7f, 0x80, /* 0111111110 */
381 0x0c, 0x00, /* 0000110000 */
382 0x0c, 0x00, /* 0000110000 */
383 0x0c, 0x00, /* 0000110000 */
384 0x7f, 0x80, /* 0111111110 */
385 0x3f, 0x00, /* 0011111100 */
386 0x1e, 0x00, /* 0001111000 */
387 0x0c, 0x00, /* 0000110000 */
388 0x00, 0x00, /* 0000000000 */
389 0x00, 0x00, /* 0000000000 */
390 0x00, 0x00, /* 0000000000 */
391
392 /* 19 0x13 '^S' */
393 0x00, 0x00, /* 0000000000 */
394 0x33, 0x00, /* 0011001100 */
395 0x33, 0x00, /* 0011001100 */
396 0x33, 0x00, /* 0011001100 */
397 0x33, 0x00, /* 0011001100 */
398 0x33, 0x00, /* 0011001100 */
399 0x33, 0x00, /* 0011001100 */
400 0x33, 0x00, /* 0011001100 */
401 0x33, 0x00, /* 0011001100 */
402 0x33, 0x00, /* 0011001100 */
403 0x33, 0x00, /* 0011001100 */
404 0x00, 0x00, /* 0000000000 */
405 0x00, 0x00, /* 0000000000 */
406 0x33, 0x00, /* 0011001100 */
407 0x33, 0x00, /* 0011001100 */
408 0x00, 0x00, /* 0000000000 */
409 0x00, 0x00, /* 0000000000 */
410 0x00, 0x00, /* 0000000000 */
411
412 /* 20 0x14 '^T' */
413 0x00, 0x00, /* 0000000000 */
414 0x1f, 0xc0, /* 0001111111 */
415 0x39, 0x80, /* 0011100110 */
416 0x79, 0x80, /* 0111100110 */
417 0x79, 0x80, /* 0111100110 */
418 0x79, 0x80, /* 0111100110 */
419 0x39, 0x80, /* 0011100110 */
420 0x19, 0x80, /* 0001100110 */
421 0x19, 0x80, /* 0001100110 */
422 0x19, 0x80, /* 0001100110 */
423 0x19, 0x80, /* 0001100110 */
424 0x19, 0x80, /* 0001100110 */
425 0x19, 0x80, /* 0001100110 */
426 0x39, 0xc0, /* 0011100111 */
427 0x00, 0x00, /* 0000000000 */
428 0x00, 0x00, /* 0000000000 */
429 0x00, 0x00, /* 0000000000 */
430 0x00, 0x00, /* 0000000000 */
431
432 /* 21 0x15 '^U' */
433 0x00, 0x00, /* 0000000000 */
434 0x00, 0x00, /* 0000000000 */
435 0x3e, 0x00, /* 0011111000 */
436 0x63, 0x00, /* 0110001100 */
437 0x63, 0x00, /* 0110001100 */
438 0x60, 0x00, /* 0110000000 */
439 0x60, 0x00, /* 0110000000 */
440 0x3e, 0x00, /* 0011111000 */
441 0x63, 0x00, /* 0110001100 */
442 0x63, 0x00, /* 0110001100 */
443 0x3e, 0x00, /* 0011111000 */
444 0x03, 0x00, /* 0000001100 */
445 0x03, 0x00, /* 0000001100 */
446 0x63, 0x00, /* 0110001100 */
447 0x63, 0x00, /* 0110001100 */
448 0x3e, 0x00, /* 0011111000 */
449 0x00, 0x00, /* 0000000000 */
450 0x00, 0x00, /* 0000000000 */
451
452 /* 22 0x16 '^V' */
453 0x00, 0x00, /* 0000000000 */
454 0x00, 0x00, /* 0000000000 */
455 0x00, 0x00, /* 0000000000 */
456 0x00, 0x00, /* 0000000000 */
457 0x00, 0x00, /* 0000000000 */
458 0x00, 0x00, /* 0000000000 */
459 0x00, 0x00, /* 0000000000 */
460 0x00, 0x00, /* 0000000000 */
461 0x00, 0x00, /* 0000000000 */
462 0x00, 0x00, /* 0000000000 */
463 0x00, 0x00, /* 0000000000 */
464 0x00, 0x00, /* 0000000000 */
465 0x7f, 0x80, /* 0111111110 */
466 0x7f, 0x80, /* 0111111110 */
467 0x7f, 0x80, /* 0111111110 */
468 0x00, 0x00, /* 0000000000 */
469 0x00, 0x00, /* 0000000000 */
470 0x00, 0x00, /* 0000000000 */
471
472 /* 23 0x17 '^W' */
473 0x00, 0x00, /* 0000000000 */
474 0x00, 0x00, /* 0000000000 */
475 0x0c, 0x00, /* 0000110000 */
476 0x1e, 0x00, /* 0001111000 */
477 0x3f, 0x00, /* 0011111100 */
478 0x7f, 0x80, /* 0111111110 */
479 0x0c, 0x00, /* 0000110000 */
480 0x0c, 0x00, /* 0000110000 */
481 0x0c, 0x00, /* 0000110000 */
482 0x7f, 0x80, /* 0111111110 */
483 0x3f, 0x00, /* 0011111100 */
484 0x1e, 0x00, /* 0001111000 */
485 0x0c, 0x00, /* 0000110000 */
486 0x7f, 0x80, /* 0111111110 */
487 0x7f, 0x80, /* 0111111110 */
488 0x00, 0x00, /* 0000000000 */
489 0x00, 0x00, /* 0000000000 */
490 0x00, 0x00, /* 0000000000 */
491
492 /* 24 0x18 '^X' */
493 0x00, 0x00, /* 0000000000 */
494 0x00, 0x00, /* 0000000000 */
495 0x00, 0x00, /* 0000000000 */
496 0x0c, 0x00, /* 0000110000 */
497 0x1e, 0x00, /* 0001111000 */
498 0x3f, 0x00, /* 0011111100 */
499 0x7f, 0x80, /* 0111111110 */
500 0x0c, 0x00, /* 0000110000 */
501 0x0c, 0x00, /* 0000110000 */
502 0x0c, 0x00, /* 0000110000 */
503 0x0c, 0x00, /* 0000110000 */
504 0x0c, 0x00, /* 0000110000 */
505 0x0c, 0x00, /* 0000110000 */
506 0x0c, 0x00, /* 0000110000 */
507 0x0c, 0x00, /* 0000110000 */
508 0x00, 0x00, /* 0000000000 */
509 0x00, 0x00, /* 0000000000 */
510 0x00, 0x00, /* 0000000000 */
511
512 /* 25 0x19 '^Y' */
513 0x00, 0x00, /* 0000000000 */
514 0x00, 0x00, /* 0000000000 */
515 0x00, 0x00, /* 0000000000 */
516 0x0c, 0x00, /* 0000110000 */
517 0x0c, 0x00, /* 0000110000 */
518 0x0c, 0x00, /* 0000110000 */
519 0x0c, 0x00, /* 0000110000 */
520 0x0c, 0x00, /* 0000110000 */
521 0x0c, 0x00, /* 0000110000 */
522 0x0c, 0x00, /* 0000110000 */
523 0x0c, 0x00, /* 0000110000 */
524 0x7f, 0x80, /* 0111111110 */
525 0x3f, 0x00, /* 0011111100 */
526 0x1e, 0x00, /* 0001111000 */
527 0x0c, 0x00, /* 0000110000 */
528 0x00, 0x00, /* 0000000000 */
529 0x00, 0x00, /* 0000000000 */
530 0x00, 0x00, /* 0000000000 */
531
532 /* 26 0x1a '^Z' */
533 0x00, 0x00, /* 0000000000 */
534 0x00, 0x00, /* 0000000000 */
535 0x00, 0x00, /* 0000000000 */
536 0x00, 0x00, /* 0000000000 */
537 0x04, 0x00, /* 0000010000 */
538 0x06, 0x00, /* 0000011000 */
539 0x07, 0x00, /* 0000011100 */
540 0x7f, 0x80, /* 0111111110 */
541 0x7f, 0x80, /* 0111111110 */
542 0x07, 0x00, /* 0000011100 */
543 0x06, 0x00, /* 0000011000 */
544 0x04, 0x00, /* 0000010000 */
545 0x00, 0x00, /* 0000000000 */
546 0x00, 0x00, /* 0000000000 */
547 0x00, 0x00, /* 0000000000 */
548 0x00, 0x00, /* 0000000000 */
549 0x00, 0x00, /* 0000000000 */
550 0x00, 0x00, /* 0000000000 */
551
552 /* 27 0x1b '^[' */
553 0x00, 0x00, /* 0000000000 */
554 0x00, 0x00, /* 0000000000 */
555 0x00, 0x00, /* 0000000000 */
556 0x00, 0x00, /* 0000000000 */
557 0x00, 0x00, /* 0000000000 */
558 0x08, 0x00, /* 0000100000 */
559 0x18, 0x00, /* 0001100000 */
560 0x38, 0x00, /* 0011100000 */
561 0x7f, 0x80, /* 0111111110 */
562 0x7f, 0x80, /* 0111111110 */
563 0x38, 0x00, /* 0011100000 */
564 0x18, 0x00, /* 0001100000 */
565 0x08, 0x00, /* 0000100000 */
566 0x00, 0x00, /* 0000000000 */
567 0x00, 0x00, /* 0000000000 */
568 0x00, 0x00, /* 0000000000 */
569 0x00, 0x00, /* 0000000000 */
570 0x00, 0x00, /* 0000000000 */
571
572 /* 28 0x1c '^\' */
573 0x00, 0x00, /* 0000000000 */
574 0x00, 0x00, /* 0000000000 */
575 0x00, 0x00, /* 0000000000 */
576 0x00, 0x00, /* 0000000000 */
577 0x00, 0x00, /* 0000000000 */
578 0x60, 0x00, /* 0110000000 */
579 0x60, 0x00, /* 0110000000 */
580 0x60, 0x00, /* 0110000000 */
581 0x7f, 0x80, /* 0111111110 */
582 0x7f, 0x80, /* 0111111110 */
583 0x00, 0x00, /* 0000000000 */
584 0x00, 0x00, /* 0000000000 */
585 0x00, 0x00, /* 0000000000 */
586 0x00, 0x00, /* 0000000000 */
587 0x00, 0x00, /* 0000000000 */
588 0x00, 0x00, /* 0000000000 */
589 0x00, 0x00, /* 0000000000 */
590 0x00, 0x00, /* 0000000000 */
591
592 /* 29 0x1d '^]' */
593 0x00, 0x00, /* 0000000000 */
594 0x00, 0x00, /* 0000000000 */
595 0x00, 0x00, /* 0000000000 */
596 0x00, 0x00, /* 0000000000 */
597 0x00, 0x00, /* 0000000000 */
598 0x12, 0x00, /* 0001001000 */
599 0x33, 0x00, /* 0011001100 */
600 0x73, 0x80, /* 0111001110 */
601 0xff, 0xc0, /* 1111111111 */
602 0xff, 0xc0, /* 1111111111 */
603 0x73, 0x80, /* 0111001110 */
604 0x33, 0x00, /* 0011001100 */
605 0x12, 0x00, /* 0001001000 */
606 0x00, 0x00, /* 0000000000 */
607 0x00, 0x00, /* 0000000000 */
608 0x00, 0x00, /* 0000000000 */
609 0x00, 0x00, /* 0000000000 */
610 0x00, 0x00, /* 0000000000 */
611
612 /* 30 0x1e '^^' */
613 0x00, 0x00, /* 0000000000 */
614 0x00, 0x00, /* 0000000000 */
615 0x00, 0x00, /* 0000000000 */
616 0x00, 0x00, /* 0000000000 */
617 0x00, 0x00, /* 0000000000 */
618 0x04, 0x00, /* 0000010000 */
619 0x04, 0x00, /* 0000010000 */
620 0x0e, 0x00, /* 0000111000 */
621 0x0e, 0x00, /* 0000111000 */
622 0x1f, 0x00, /* 0001111100 */
623 0x1f, 0x00, /* 0001111100 */
624 0x3f, 0x80, /* 0011111110 */
625 0x3f, 0x80, /* 0011111110 */
626 0x7f, 0xc0, /* 0111111111 */
627 0x7f, 0xc0, /* 0111111111 */
628 0x00, 0x00, /* 0000000000 */
629 0x00, 0x00, /* 0000000000 */
630 0x00, 0x00, /* 0000000000 */
631
632 /* 31 0x1f '^_' */
633 0x00, 0x00, /* 0000000000 */
634 0x00, 0x00, /* 0000000000 */
635 0x00, 0x00, /* 0000000000 */
636 0x00, 0x00, /* 0000000000 */
637 0x00, 0x00, /* 0000000000 */
638 0x7f, 0xc0, /* 0111111111 */
639 0x7f, 0xc0, /* 0111111111 */
640 0x3f, 0x80, /* 0011111110 */
641 0x3f, 0x80, /* 0011111110 */
642 0x1f, 0x00, /* 0001111100 */
643 0x1f, 0x00, /* 0001111100 */
644 0x0e, 0x00, /* 0000111000 */
645 0x0e, 0x00, /* 0000111000 */
646 0x04, 0x00, /* 0000010000 */
647 0x04, 0x00, /* 0000010000 */
648 0x00, 0x00, /* 0000000000 */
649 0x00, 0x00, /* 0000000000 */
650 0x00, 0x00, /* 0000000000 */
651
652 /* 32 0x20 ' ' */
653 0x00, 0x00, /* 0000000000 */
654 0x00, 0x00, /* 0000000000 */
655 0x00, 0x00, /* 0000000000 */
656 0x00, 0x00, /* 0000000000 */
657 0x00, 0x00, /* 0000000000 */
658 0x00, 0x00, /* 0000000000 */
659 0x00, 0x00, /* 0000000000 */
660 0x00, 0x00, /* 0000000000 */
661 0x00, 0x00, /* 0000000000 */
662 0x00, 0x00, /* 0000000000 */
663 0x00, 0x00, /* 0000000000 */
664 0x00, 0x00, /* 0000000000 */
665 0x00, 0x00, /* 0000000000 */
666 0x00, 0x00, /* 0000000000 */
667 0x00, 0x00, /* 0000000000 */
668 0x00, 0x00, /* 0000000000 */
669 0x00, 0x00, /* 0000000000 */
670 0x00, 0x00, /* 0000000000 */
671
672 /* 33 0x21 '!' */
673 0x00, 0x00, /* 0000000000 */
674 0x0c, 0x00, /* 0000110000 */
675 0x0c, 0x00, /* 0000110000 */
676 0x0c, 0x00, /* 0000110000 */
677 0x0c, 0x00, /* 0000110000 */
678 0x0c, 0x00, /* 0000110000 */
679 0x0c, 0x00, /* 0000110000 */
680 0x0c, 0x00, /* 0000110000 */
681 0x0c, 0x00, /* 0000110000 */
682 0x0c, 0x00, /* 0000110000 */
683 0x0c, 0x00, /* 0000110000 */
684 0x00, 0x00, /* 0000000000 */
685 0x0c, 0x00, /* 0000110000 */
686 0x0c, 0x00, /* 0000110000 */
687 0x00, 0x00, /* 0000000000 */
688 0x00, 0x00, /* 0000000000 */
689 0x00, 0x00, /* 0000000000 */
690 0x00, 0x00, /* 0000000000 */
691
692 /* 34 0x22 '"' */
693 0x00, 0x00, /* 0000000000 */
694 0x63, 0x00, /* 0110001100 */
695 0xf7, 0x80, /* 1111011110 */
696 0xf7, 0x80, /* 1111011110 */
697 0x31, 0x80, /* 0011000110 */
698 0x31, 0x80, /* 0011000110 */
699 0x63, 0x00, /* 0110001100 */
700 0x42, 0x00, /* 0100001000 */
701 0x00, 0x00, /* 0000000000 */
702 0x00, 0x00, /* 0000000000 */
703 0x00, 0x00, /* 0000000000 */
704 0x00, 0x00, /* 0000000000 */
705 0x00, 0x00, /* 0000000000 */
706 0x00, 0x00, /* 0000000000 */
707 0x00, 0x00, /* 0000000000 */
708 0x00, 0x00, /* 0000000000 */
709 0x00, 0x00, /* 0000000000 */
710 0x00, 0x00, /* 0000000000 */
711
712 /* 35 0x23 '#' */
713 0x00, 0x00, /* 0000000000 */
714 0x33, 0x00, /* 0011001100 */
715 0x33, 0x00, /* 0011001100 */
716 0x7f, 0x80, /* 0111111110 */
717 0x7f, 0x80, /* 0111111110 */
718 0x33, 0x00, /* 0011001100 */
719 0x33, 0x00, /* 0011001100 */
720 0x33, 0x00, /* 0011001100 */
721 0x33, 0x00, /* 0011001100 */
722 0x7f, 0x80, /* 0111111110 */
723 0x7f, 0x80, /* 0111111110 */
724 0x33, 0x00, /* 0011001100 */
725 0x33, 0x00, /* 0011001100 */
726 0x00, 0x00, /* 0000000000 */
727 0x00, 0x00, /* 0000000000 */
728 0x00, 0x00, /* 0000000000 */
729 0x00, 0x00, /* 0000000000 */
730 0x00, 0x00, /* 0000000000 */
731
732 /* 36 0x24 '$' */
733 0x00, 0x00, /* 0000000000 */
734 0x0c, 0x00, /* 0000110000 */
735 0x3e, 0x00, /* 0011111000 */
736 0x3f, 0x00, /* 0011111100 */
737 0x6f, 0x80, /* 0110111110 */
738 0x6d, 0x80, /* 0110110110 */
739 0x6c, 0x80, /* 0110110010 */
740 0x3c, 0x00, /* 0011110000 */
741 0x0f, 0x00, /* 0000111100 */
742 0x0d, 0x80, /* 0000110110 */
743 0x4d, 0x80, /* 0100110110 */
744 0x6d, 0x80, /* 0110110110 */
745 0x7f, 0x00, /* 0111111100 */
746 0x3e, 0x00, /* 0011111000 */
747 0x0c, 0x00, /* 0000110000 */
748 0x00, 0x00, /* 0000000000 */
749 0x00, 0x00, /* 0000000000 */
750 0x00, 0x00, /* 0000000000 */
751
752 /* 37 0x25 '%' */
753 0x00, 0x00, /* 0000000000 */
754 0x31, 0x80, /* 0011000110 */
755 0x7b, 0x00, /* 0111101100 */
756 0x7b, 0x00, /* 0111101100 */
757 0x36, 0x00, /* 0011011000 */
758 0x06, 0x00, /* 0000011000 */
759 0x0c, 0x00, /* 0000110000 */
760 0x0c, 0x00, /* 0000110000 */
761 0x18, 0x00, /* 0001100000 */
762 0x1b, 0x00, /* 0001101100 */
763 0x37, 0x80, /* 0011011110 */
764 0x37, 0x80, /* 0011011110 */
765 0x63, 0x00, /* 0110001100 */
766 0x00, 0x00, /* 0000000000 */
767 0x00, 0x00, /* 0000000000 */
768 0x00, 0x00, /* 0000000000 */
769 0x00, 0x00, /* 0000000000 */
770 0x00, 0x00, /* 0000000000 */
771
772 /* 38 0x26 '&' */
773 0x00, 0x00, /* 0000000000 */
774 0x07, 0x00, /* 0000011100 */
775 0x0f, 0x80, /* 0000111110 */
776 0x19, 0x80, /* 0001100110 */
777 0x19, 0x80, /* 0001100110 */
778 0x0f, 0x80, /* 0000111110 */
779 0x1e, 0x00, /* 0001111000 */
780 0x3e, 0x00, /* 0011111000 */
781 0x76, 0x00, /* 0111011000 */
782 0x66, 0x40, /* 0110011001 */
783 0x63, 0xc0, /* 0110001111 */
784 0x63, 0x80, /* 0110001110 */
785 0x63, 0x00, /* 0110001100 */
786 0x3f, 0x80, /* 0011111110 */
787 0x1c, 0xc0, /* 0001110011 */
788 0x00, 0x00, /* 0000000000 */
789 0x00, 0x00, /* 0000000000 */
790 0x00, 0x00, /* 0000000000 */
791
792 /* 39 0x27 ''' */
793 0x00, 0x00, /* 0000000000 */
794 0x30, 0x00, /* 0011000000 */
795 0x78, 0x00, /* 0111100000 */
796 0x78, 0x00, /* 0111100000 */
797 0x18, 0x00, /* 0001100000 */
798 0x18, 0x00, /* 0001100000 */
799 0x30, 0x00, /* 0011000000 */
800 0x20, 0x00, /* 0010000000 */
801 0x00, 0x00, /* 0000000000 */
802 0x00, 0x00, /* 0000000000 */
803 0x00, 0x00, /* 0000000000 */
804 0x00, 0x00, /* 0000000000 */
805 0x00, 0x00, /* 0000000000 */
806 0x00, 0x00, /* 0000000000 */
807 0x00, 0x00, /* 0000000000 */
808 0x00, 0x00, /* 0000000000 */
809 0x00, 0x00, /* 0000000000 */
810 0x00, 0x00, /* 0000000000 */
811
812 /* 40 0x28 '(' */
813 0x00, 0x00, /* 0000000000 */
814 0x03, 0x00, /* 0000001100 */
815 0x06, 0x00, /* 0000011000 */
816 0x0c, 0x00, /* 0000110000 */
817 0x0c, 0x00, /* 0000110000 */
818 0x18, 0x00, /* 0001100000 */
819 0x18, 0x00, /* 0001100000 */
820 0x18, 0x00, /* 0001100000 */
821 0x18, 0x00, /* 0001100000 */
822 0x18, 0x00, /* 0001100000 */
823 0x18, 0x00, /* 0001100000 */
824 0x0c, 0x00, /* 0000110000 */
825 0x0c, 0x00, /* 0000110000 */
826 0x06, 0x00, /* 0000011000 */
827 0x03, 0x00, /* 0000001100 */
828 0x00, 0x00, /* 0000000000 */
829 0x00, 0x00, /* 0000000000 */
830 0x00, 0x00, /* 0000000000 */
831
832 /* 41 0x29 ')' */
833 0x00, 0x00, /* 0000000000 */
834 0x30, 0x00, /* 0011000000 */
835 0x18, 0x00, /* 0001100000 */
836 0x0c, 0x00, /* 0000110000 */
837 0x0c, 0x00, /* 0000110000 */
838 0x06, 0x00, /* 0000011000 */
839 0x06, 0x00, /* 0000011000 */
840 0x06, 0x00, /* 0000011000 */
841 0x06, 0x00, /* 0000011000 */
842 0x06, 0x00, /* 0000011000 */
843 0x06, 0x00, /* 0000011000 */
844 0x0c, 0x00, /* 0000110000 */
845 0x0c, 0x00, /* 0000110000 */
846 0x18, 0x00, /* 0001100000 */
847 0x30, 0x00, /* 0011000000 */
848 0x00, 0x00, /* 0000000000 */
849 0x00, 0x00, /* 0000000000 */
850 0x00, 0x00, /* 0000000000 */
851
852 /* 42 0x2a '*' */
853 0x00, 0x00, /* 0000000000 */
854 0x00, 0x00, /* 0000000000 */
855 0x00, 0x00, /* 0000000000 */
856 0x0c, 0x00, /* 0000110000 */
857 0x4c, 0x80, /* 0100110010 */
858 0x6d, 0x80, /* 0110110110 */
859 0x3f, 0x00, /* 0011111100 */
860 0x7f, 0x80, /* 0111111110 */
861 0x3f, 0x00, /* 0011111100 */
862 0x6d, 0x80, /* 0110110110 */
863 0x4c, 0x80, /* 0100110010 */
864 0x0c, 0x00, /* 0000110000 */
865 0x00, 0x00, /* 0000000000 */
866 0x00, 0x00, /* 0000000000 */
867 0x00, 0x00, /* 0000000000 */
868 0x00, 0x00, /* 0000000000 */
869 0x00, 0x00, /* 0000000000 */
870 0x00, 0x00, /* 0000000000 */
871
872 /* 43 0x2b '+' */
873 0x00, 0x00, /* 0000000000 */
874 0x00, 0x00, /* 0000000000 */
875 0x00, 0x00, /* 0000000000 */
876 0x0c, 0x00, /* 0000110000 */
877 0x0c, 0x00, /* 0000110000 */
878 0x0c, 0x00, /* 0000110000 */
879 0x0c, 0x00, /* 0000110000 */
880 0x7f, 0x80, /* 0111111110 */
881 0x7f, 0x80, /* 0111111110 */
882 0x0c, 0x00, /* 0000110000 */
883 0x0c, 0x00, /* 0000110000 */
884 0x0c, 0x00, /* 0000110000 */
885 0x0c, 0x00, /* 0000110000 */
886 0x00, 0x00, /* 0000000000 */
887 0x00, 0x00, /* 0000000000 */
888 0x00, 0x00, /* 0000000000 */
889 0x00, 0x00, /* 0000000000 */
890 0x00, 0x00, /* 0000000000 */
891
892 /* 44 0x2c ',' */
893 0x00, 0x00, /* 0000000000 */
894 0x00, 0x00, /* 0000000000 */
895 0x00, 0x00, /* 0000000000 */
896 0x00, 0x00, /* 0000000000 */
897 0x00, 0x00, /* 0000000000 */
898 0x00, 0x00, /* 0000000000 */
899 0x00, 0x00, /* 0000000000 */
900 0x00, 0x00, /* 0000000000 */
901 0x00, 0x00, /* 0000000000 */
902 0x00, 0x00, /* 0000000000 */
903 0x30, 0x00, /* 0011000000 */
904 0x78, 0x00, /* 0111100000 */
905 0x78, 0x00, /* 0111100000 */
906 0x18, 0x00, /* 0001100000 */
907 0x18, 0x00, /* 0001100000 */
908 0x30, 0x00, /* 0011000000 */
909 0x60, 0x00, /* 0110000000 */
910 0x40, 0x00, /* 0100000000 */
911
912 /* 45 0x2d '-' */
913 0x00, 0x00, /* 0000000000 */
914 0x00, 0x00, /* 0000000000 */
915 0x00, 0x00, /* 0000000000 */
916 0x00, 0x00, /* 0000000000 */
917 0x00, 0x00, /* 0000000000 */
918 0x00, 0x00, /* 0000000000 */
919 0x00, 0x00, /* 0000000000 */
920 0x00, 0x00, /* 0000000000 */
921 0x7f, 0x80, /* 0111111110 */
922 0x7f, 0x80, /* 0111111110 */
923 0x00, 0x00, /* 0000000000 */
924 0x00, 0x00, /* 0000000000 */
925 0x00, 0x00, /* 0000000000 */
926 0x00, 0x00, /* 0000000000 */
927 0x00, 0x00, /* 0000000000 */
928 0x00, 0x00, /* 0000000000 */
929 0x00, 0x00, /* 0000000000 */
930 0x00, 0x00, /* 0000000000 */
931
932 /* 46 0x2e '.' */
933 0x00, 0x00, /* 0000000000 */
934 0x00, 0x00, /* 0000000000 */
935 0x00, 0x00, /* 0000000000 */
936 0x00, 0x00, /* 0000000000 */
937 0x00, 0x00, /* 0000000000 */
938 0x00, 0x00, /* 0000000000 */
939 0x00, 0x00, /* 0000000000 */
940 0x00, 0x00, /* 0000000000 */
941 0x00, 0x00, /* 0000000000 */
942 0x00, 0x00, /* 0000000000 */
943 0x00, 0x00, /* 0000000000 */
944 0x18, 0x00, /* 0001100000 */
945 0x3c, 0x00, /* 0011110000 */
946 0x3c, 0x00, /* 0011110000 */
947 0x18, 0x00, /* 0001100000 */
948 0x00, 0x00, /* 0000000000 */
949 0x00, 0x00, /* 0000000000 */
950 0x00, 0x00, /* 0000000000 */
951
952 /* 47 0x2f '/' */
953 0x00, 0x00, /* 0000000000 */
954 0x01, 0x80, /* 0000000110 */
955 0x01, 0x80, /* 0000000110 */
956 0x03, 0x00, /* 0000001100 */
957 0x03, 0x00, /* 0000001100 */
958 0x06, 0x00, /* 0000011000 */
959 0x06, 0x00, /* 0000011000 */
960 0x0c, 0x00, /* 0000110000 */
961 0x0c, 0x00, /* 0000110000 */
962 0x18, 0x00, /* 0001100000 */
963 0x18, 0x00, /* 0001100000 */
964 0x30, 0x00, /* 0011000000 */
965 0x30, 0x00, /* 0011000000 */
966 0x60, 0x00, /* 0110000000 */
967 0x60, 0x00, /* 0110000000 */
968 0x00, 0x00, /* 0000000000 */
969 0x00, 0x00, /* 0000000000 */
970 0x00, 0x00, /* 0000000000 */
971
972 /* 48 0x30 '0' */
973 0x00, 0x00, /* 0000000000 */
974 0x0e, 0x00, /* 0000111000 */
975 0x1f, 0x00, /* 0001111100 */
976 0x23, 0x00, /* 0010001100 */
977 0x61, 0x80, /* 0110000110 */
978 0x63, 0x80, /* 0110001110 */
979 0x65, 0x80, /* 0110010110 */
980 0x65, 0x80, /* 0110010110 */
981 0x69, 0x80, /* 0110100110 */
982 0x69, 0x80, /* 0110100110 */
983 0x71, 0x80, /* 0111000110 */
984 0x61, 0x00, /* 0110000100 */
985 0x31, 0x00, /* 0011000100 */
986 0x3e, 0x00, /* 0011111000 */
987 0x1c, 0x00, /* 0001110000 */
988 0x00, 0x00, /* 0000000000 */
989 0x00, 0x00, /* 0000000000 */
990 0x00, 0x00, /* 0000000000 */
991
992 /* 49 0x31 '1' */
993 0x00, 0x00, /* 0000000000 */
994 0x04, 0x00, /* 0000010000 */
995 0x0c, 0x00, /* 0000110000 */
996 0x1c, 0x00, /* 0001110000 */
997 0x3c, 0x00, /* 0011110000 */
998 0x6c, 0x00, /* 0110110000 */
999 0x0c, 0x00, /* 0000110000 */
1000 0x0c, 0x00, /* 0000110000 */
1001 0x0c, 0x00, /* 0000110000 */
1002 0x0c, 0x00, /* 0000110000 */
1003 0x0c, 0x00, /* 0000110000 */
1004 0x0c, 0x00, /* 0000110000 */
1005 0x0c, 0x00, /* 0000110000 */
1006 0x0c, 0x00, /* 0000110000 */
1007 0x7f, 0x80, /* 0111111110 */
1008 0x00, 0x00, /* 0000000000 */
1009 0x00, 0x00, /* 0000000000 */
1010 0x00, 0x00, /* 0000000000 */
1011
1012 /* 50 0x32 '2' */
1013 0x00, 0x00, /* 0000000000 */
1014 0x1e, 0x00, /* 0001111000 */
1015 0x3f, 0x00, /* 0011111100 */
1016 0x63, 0x80, /* 0110001110 */
1017 0x41, 0x80, /* 0100000110 */
1018 0x01, 0x80, /* 0000000110 */
1019 0x01, 0x80, /* 0000000110 */
1020 0x03, 0x00, /* 0000001100 */
1021 0x06, 0x00, /* 0000011000 */
1022 0x06, 0x00, /* 0000011000 */
1023 0x0c, 0x00, /* 0000110000 */
1024 0x18, 0x00, /* 0001100000 */
1025 0x30, 0x80, /* 0011000010 */
1026 0x7f, 0x80, /* 0111111110 */
1027 0x7f, 0x80, /* 0111111110 */
1028 0x00, 0x00, /* 0000000000 */
1029 0x00, 0x00, /* 0000000000 */
1030 0x00, 0x00, /* 0000000000 */
1031
1032 /* 51 0x33 '3' */
1033 0x00, 0x00, /* 0000000000 */
1034 0x1c, 0x00, /* 0001110000 */
1035 0x3e, 0x00, /* 0011111000 */
1036 0x47, 0x00, /* 0100011100 */
1037 0x03, 0x00, /* 0000001100 */
1038 0x07, 0x00, /* 0000011100 */
1039 0x06, 0x00, /* 0000011000 */
1040 0x0e, 0x00, /* 0000111000 */
1041 0x07, 0x00, /* 0000011100 */
1042 0x03, 0x00, /* 0000001100 */
1043 0x01, 0x80, /* 0000000110 */
1044 0x41, 0x80, /* 0100000110 */
1045 0x61, 0x80, /* 0110000110 */
1046 0x3f, 0x00, /* 0011111100 */
1047 0x1e, 0x00, /* 0001111000 */
1048 0x00, 0x00, /* 0000000000 */
1049 0x00, 0x00, /* 0000000000 */
1050 0x00, 0x00, /* 0000000000 */
1051
1052 /* 52 0x34 '4' */
1053 0x00, 0x00, /* 0000000000 */
1054 0x06, 0x00, /* 0000011000 */
1055 0x0e, 0x00, /* 0000111000 */
1056 0x1e, 0x00, /* 0001111000 */
1057 0x36, 0x00, /* 0011011000 */
1058 0x36, 0x00, /* 0011011000 */
1059 0x66, 0x00, /* 0110011000 */
1060 0x66, 0x00, /* 0110011000 */
1061 0xc6, 0x00, /* 1100011000 */
1062 0xc6, 0x00, /* 1100011000 */
1063 0xff, 0x80, /* 1111111110 */
1064 0xff, 0x80, /* 1111111110 */
1065 0x06, 0x00, /* 0000011000 */
1066 0x06, 0x00, /* 0000011000 */
1067 0x06, 0x00, /* 0000011000 */
1068 0x00, 0x00, /* 0000000000 */
1069 0x00, 0x00, /* 0000000000 */
1070 0x00, 0x00, /* 0000000000 */
1071
1072 /* 53 0x35 '5' */
1073 0x00, 0x00, /* 0000000000 */
1074 0x1f, 0x00, /* 0001111100 */
1075 0x1f, 0x00, /* 0001111100 */
1076 0x30, 0x00, /* 0011000000 */
1077 0x30, 0x00, /* 0011000000 */
1078 0x60, 0x00, /* 0110000000 */
1079 0x7e, 0x00, /* 0111111000 */
1080 0x67, 0x00, /* 0110011100 */
1081 0x03, 0x80, /* 0000001110 */
1082 0x01, 0x80, /* 0000000110 */
1083 0x01, 0x80, /* 0000000110 */
1084 0x01, 0x80, /* 0000000110 */
1085 0x41, 0x80, /* 0100000110 */
1086 0x63, 0x00, /* 0110001100 */
1087 0x3e, 0x00, /* 0011111000 */
1088 0x00, 0x00, /* 0000000000 */
1089 0x00, 0x00, /* 0000000000 */
1090 0x00, 0x00, /* 0000000000 */
1091
1092 /* 54 0x36 '6' */
1093 0x00, 0x00, /* 0000000000 */
1094 0x06, 0x00, /* 0000011000 */
1095 0x0c, 0x00, /* 0000110000 */
1096 0x18, 0x00, /* 0001100000 */
1097 0x30, 0x00, /* 0011000000 */
1098 0x30, 0x00, /* 0011000000 */
1099 0x60, 0x00, /* 0110000000 */
1100 0x6e, 0x00, /* 0110111000 */
1101 0x7f, 0x00, /* 0111111100 */
1102 0x73, 0x80, /* 0111001110 */
1103 0x61, 0x80, /* 0110000110 */
1104 0x61, 0x80, /* 0110000110 */
1105 0x71, 0x00, /* 0111000100 */
1106 0x3e, 0x00, /* 0011111000 */
1107 0x1c, 0x00, /* 0001110000 */
1108 0x00, 0x00, /* 0000000000 */
1109 0x00, 0x00, /* 0000000000 */
1110 0x00, 0x00, /* 0000000000 */
1111
1112 /* 55 0x37 '7' */
1113 0x00, 0x00, /* 0000000000 */
1114 0x1f, 0x80, /* 0001111110 */
1115 0x3f, 0x80, /* 0011111110 */
1116 0x61, 0x80, /* 0110000110 */
1117 0x01, 0x80, /* 0000000110 */
1118 0x03, 0x00, /* 0000001100 */
1119 0x03, 0x00, /* 0000001100 */
1120 0x06, 0x00, /* 0000011000 */
1121 0x06, 0x00, /* 0000011000 */
1122 0x0c, 0x00, /* 0000110000 */
1123 0x0c, 0x00, /* 0000110000 */
1124 0x18, 0x00, /* 0001100000 */
1125 0x18, 0x00, /* 0001100000 */
1126 0x30, 0x00, /* 0011000000 */
1127 0x30, 0x00, /* 0011000000 */
1128 0x00, 0x00, /* 0000000000 */
1129 0x00, 0x00, /* 0000000000 */
1130 0x00, 0x00, /* 0000000000 */
1131
1132 /* 56 0x38 '8' */
1133 0x00, 0x00, /* 0000000000 */
1134 0x1e, 0x00, /* 0001111000 */
1135 0x23, 0x00, /* 0010001100 */
1136 0x61, 0x80, /* 0110000110 */
1137 0x61, 0x80, /* 0110000110 */
1138 0x31, 0x00, /* 0011000100 */
1139 0x1a, 0x00, /* 0001101000 */
1140 0x0c, 0x00, /* 0000110000 */
1141 0x16, 0x00, /* 0001011000 */
1142 0x23, 0x00, /* 0010001100 */
1143 0x61, 0x80, /* 0110000110 */
1144 0x61, 0x80, /* 0110000110 */
1145 0x61, 0x80, /* 0110000110 */
1146 0x31, 0x00, /* 0011000100 */
1147 0x1e, 0x00, /* 0001111000 */
1148 0x00, 0x00, /* 0000000000 */
1149 0x00, 0x00, /* 0000000000 */
1150 0x00, 0x00, /* 0000000000 */
1151
1152 /* 57 0x39 '9' */
1153 0x00, 0x00, /* 0000000000 */
1154 0x0e, 0x00, /* 0000111000 */
1155 0x17, 0x00, /* 0001011100 */
1156 0x23, 0x80, /* 0010001110 */
1157 0x61, 0x80, /* 0110000110 */
1158 0x61, 0x80, /* 0110000110 */
1159 0x61, 0x80, /* 0110000110 */
1160 0x73, 0x80, /* 0111001110 */
1161 0x3d, 0x80, /* 0011110110 */
1162 0x19, 0x80, /* 0001100110 */
1163 0x01, 0x80, /* 0000000110 */
1164 0x03, 0x00, /* 0000001100 */
1165 0x03, 0x00, /* 0000001100 */
1166 0x06, 0x00, /* 0000011000 */
1167 0x0c, 0x00, /* 0000110000 */
1168 0x18, 0x00, /* 0001100000 */
1169 0x00, 0x00, /* 0000000000 */
1170 0x00, 0x00, /* 0000000000 */
1171
1172 /* 58 0x3a ':' */
1173 0x00, 0x00, /* 0000000000 */
1174 0x00, 0x00, /* 0000000000 */
1175 0x00, 0x00, /* 0000000000 */
1176 0x00, 0x00, /* 0000000000 */
1177 0x18, 0x00, /* 0001100000 */
1178 0x3c, 0x00, /* 0011110000 */
1179 0x3c, 0x00, /* 0011110000 */
1180 0x18, 0x00, /* 0001100000 */
1181 0x00, 0x00, /* 0000000000 */
1182 0x00, 0x00, /* 0000000000 */
1183 0x18, 0x00, /* 0001100000 */
1184 0x3c, 0x00, /* 0011110000 */
1185 0x3c, 0x00, /* 0011110000 */
1186 0x18, 0x00, /* 0001100000 */
1187 0x00, 0x00, /* 0000000000 */
1188 0x00, 0x00, /* 0000000000 */
1189 0x00, 0x00, /* 0000000000 */
1190 0x00, 0x00, /* 0000000000 */
1191
1192 /* 59 0x3b ';' */
1193 0x00, 0x00, /* 0000000000 */
1194 0x00, 0x00, /* 0000000000 */
1195 0x00, 0x00, /* 0000000000 */
1196 0x00, 0x00, /* 0000000000 */
1197 0x00, 0x00, /* 0000000000 */
1198 0x00, 0x00, /* 0000000000 */
1199 0x18, 0x00, /* 0001100000 */
1200 0x3c, 0x00, /* 0011110000 */
1201 0x3c, 0x00, /* 0011110000 */
1202 0x18, 0x00, /* 0001100000 */
1203 0x00, 0x00, /* 0000000000 */
1204 0x18, 0x00, /* 0001100000 */
1205 0x3c, 0x00, /* 0011110000 */
1206 0x3c, 0x00, /* 0011110000 */
1207 0x0c, 0x00, /* 0000110000 */
1208 0x18, 0x00, /* 0001100000 */
1209 0x30, 0x00, /* 0011000000 */
1210 0x20, 0x00, /* 0010000000 */
1211
1212 /* 60 0x3c '<' */
1213 0x00, 0x00, /* 0000000000 */
1214 0x00, 0x00, /* 0000000000 */
1215 0x03, 0x00, /* 0000001100 */
1216 0x06, 0x00, /* 0000011000 */
1217 0x0c, 0x00, /* 0000110000 */
1218 0x18, 0x00, /* 0001100000 */
1219 0x30, 0x00, /* 0011000000 */
1220 0x60, 0x00, /* 0110000000 */
1221 0x60, 0x00, /* 0110000000 */
1222 0x30, 0x00, /* 0011000000 */
1223 0x18, 0x00, /* 0001100000 */
1224 0x0c, 0x00, /* 0000110000 */
1225 0x06, 0x00, /* 0000011000 */
1226 0x03, 0x00, /* 0000001100 */
1227 0x00, 0x00, /* 0000000000 */
1228 0x00, 0x00, /* 0000000000 */
1229 0x00, 0x00, /* 0000000000 */
1230 0x00, 0x00, /* 0000000000 */
1231
1232 /* 61 0x3d '=' */
1233 0x00, 0x00, /* 0000000000 */
1234 0x00, 0x00, /* 0000000000 */
1235 0x00, 0x00, /* 0000000000 */
1236 0x00, 0x00, /* 0000000000 */
1237 0x00, 0x00, /* 0000000000 */
1238 0x00, 0x00, /* 0000000000 */
1239 0x7f, 0x80, /* 0111111110 */
1240 0x7f, 0x80, /* 0111111110 */
1241 0x00, 0x00, /* 0000000000 */
1242 0x00, 0x00, /* 0000000000 */
1243 0x7f, 0x80, /* 0111111110 */
1244 0x7f, 0x80, /* 0111111110 */
1245 0x00, 0x00, /* 0000000000 */
1246 0x00, 0x00, /* 0000000000 */
1247 0x00, 0x00, /* 0000000000 */
1248 0x00, 0x00, /* 0000000000 */
1249 0x00, 0x00, /* 0000000000 */
1250 0x00, 0x00, /* 0000000000 */
1251
1252 /* 62 0x3e '>' */
1253 0x00, 0x00, /* 0000000000 */
1254 0x00, 0x00, /* 0000000000 */
1255 0x30, 0x00, /* 0011000000 */
1256 0x18, 0x00, /* 0001100000 */
1257 0x0c, 0x00, /* 0000110000 */
1258 0x06, 0x00, /* 0000011000 */
1259 0x03, 0x00, /* 0000001100 */
1260 0x01, 0x80, /* 0000000110 */
1261 0x01, 0x80, /* 0000000110 */
1262 0x03, 0x00, /* 0000001100 */
1263 0x06, 0x00, /* 0000011000 */
1264 0x0c, 0x00, /* 0000110000 */
1265 0x18, 0x00, /* 0001100000 */
1266 0x30, 0x00, /* 0011000000 */
1267 0x00, 0x00, /* 0000000000 */
1268 0x00, 0x00, /* 0000000000 */
1269 0x00, 0x00, /* 0000000000 */
1270 0x00, 0x00, /* 0000000000 */
1271
1272 /* 63 0x3f '?' */
1273 0x00, 0x00, /* 0000000000 */
1274 0x0e, 0x00, /* 0000111000 */
1275 0x1f, 0x00, /* 0001111100 */
1276 0x3b, 0x80, /* 0011101110 */
1277 0x21, 0x80, /* 0010000110 */
1278 0x01, 0x80, /* 0000000110 */
1279 0x03, 0x00, /* 0000001100 */
1280 0x06, 0x00, /* 0000011000 */
1281 0x06, 0x00, /* 0000011000 */
1282 0x0c, 0x00, /* 0000110000 */
1283 0x0c, 0x00, /* 0000110000 */
1284 0x00, 0x00, /* 0000000000 */
1285 0x00, 0x00, /* 0000000000 */
1286 0x0c, 0x00, /* 0000110000 */
1287 0x0c, 0x00, /* 0000110000 */
1288 0x00, 0x00, /* 0000000000 */
1289 0x00, 0x00, /* 0000000000 */
1290 0x00, 0x00, /* 0000000000 */
1291
1292 /* 64 0x40 '@' */
1293 0x00, 0x00, /* 0000000000 */
1294 0x00, 0x00, /* 0000000000 */
1295 0x0e, 0x00, /* 0000111000 */
1296 0x3f, 0x00, /* 0011111100 */
1297 0x31, 0x80, /* 0011000110 */
1298 0x65, 0x80, /* 0110010110 */
1299 0x6d, 0x80, /* 0110110110 */
1300 0x6d, 0x80, /* 0110110110 */
1301 0x6d, 0x80, /* 0110110110 */
1302 0x6d, 0x80, /* 0110110110 */
1303 0x6f, 0x80, /* 0110111110 */
1304 0x60, 0x00, /* 0110000000 */
1305 0x31, 0x80, /* 0011000110 */
1306 0x3f, 0x80, /* 0011111110 */
1307 0x0f, 0x00, /* 0000111100 */
1308 0x00, 0x00, /* 0000000000 */
1309 0x00, 0x00, /* 0000000000 */
1310 0x00, 0x00, /* 0000000000 */
1311
1312 /* 65 0x41 'A' */
1313 0x00, 0x00, /* 0000000000 */
1314 0x04, 0x00, /* 0000010000 */
1315 0x04, 0x00, /* 0000010000 */
1316 0x0e, 0x00, /* 0000111000 */
1317 0x0e, 0x00, /* 0000111000 */
1318 0x1b, 0x00, /* 0001101100 */
1319 0x1b, 0x00, /* 0001101100 */
1320 0x19, 0x80, /* 0001100110 */
1321 0x31, 0x80, /* 0011000110 */
1322 0x3f, 0x80, /* 0011111110 */
1323 0x31, 0x80, /* 0011000110 */
1324 0x61, 0x80, /* 0110000110 */
1325 0x60, 0xc0, /* 0110000011 */
1326 0x60, 0xc0, /* 0110000011 */
1327 0xf1, 0xc0, /* 1111000111 */
1328 0x00, 0x00, /* 0000000000 */
1329 0x00, 0x00, /* 0000000000 */
1330 0x00, 0x00, /* 0000000000 */
1331
1332 /* 66 0x42 'B' */
1333 0x00, 0x00, /* 0000000000 */
1334 0xfc, 0x00, /* 1111110000 */
1335 0x62, 0x00, /* 0110001000 */
1336 0x63, 0x00, /* 0110001100 */
1337 0x63, 0x00, /* 0110001100 */
1338 0x63, 0x00, /* 0110001100 */
1339 0x66, 0x00, /* 0110011000 */
1340 0x7e, 0x00, /* 0111111000 */
1341 0x63, 0x00, /* 0110001100 */
1342 0x61, 0x80, /* 0110000110 */
1343 0x61, 0x80, /* 0110000110 */
1344 0x61, 0x80, /* 0110000110 */
1345 0x61, 0x80, /* 0110000110 */
1346 0x63, 0x00, /* 0110001100 */
1347 0xfe, 0x00, /* 1111111000 */
1348 0x00, 0x00, /* 0000000000 */
1349 0x00, 0x00, /* 0000000000 */
1350 0x00, 0x00, /* 0000000000 */
1351
1352 /* 67 0x43 'C' */
1353 0x00, 0x00, /* 0000000000 */
1354 0x0f, 0x00, /* 0000111100 */
1355 0x11, 0x80, /* 0001000110 */
1356 0x20, 0x80, /* 0010000010 */
1357 0x20, 0x00, /* 0010000000 */
1358 0x60, 0x00, /* 0110000000 */
1359 0x60, 0x00, /* 0110000000 */
1360 0x60, 0x00, /* 0110000000 */
1361 0x60, 0x00, /* 0110000000 */
1362 0x60, 0x00, /* 0110000000 */
1363 0x60, 0x00, /* 0110000000 */
1364 0x20, 0x00, /* 0010000000 */
1365 0x30, 0x80, /* 0011000010 */
1366 0x19, 0x00, /* 0001100100 */
1367 0x0e, 0x00, /* 0000111000 */
1368 0x00, 0x00, /* 0000000000 */
1369 0x00, 0x00, /* 0000000000 */
1370 0x00, 0x00, /* 0000000000 */
1371
1372 /* 68 0x44 'D' */
1373 0x00, 0x00, /* 0000000000 */
1374 0xfc, 0x00, /* 1111110000 */
1375 0x67, 0x00, /* 0110011100 */
1376 0x63, 0x00, /* 0110001100 */
1377 0x61, 0x80, /* 0110000110 */
1378 0x61, 0x80, /* 0110000110 */
1379 0x61, 0x80, /* 0110000110 */
1380 0x61, 0x80, /* 0110000110 */
1381 0x61, 0x80, /* 0110000110 */
1382 0x61, 0x80, /* 0110000110 */
1383 0x61, 0x80, /* 0110000110 */
1384 0x61, 0x80, /* 0110000110 */
1385 0x61, 0x00, /* 0110000100 */
1386 0x66, 0x00, /* 0110011000 */
1387 0xf8, 0x00, /* 1111100000 */
1388 0x00, 0x00, /* 0000000000 */
1389 0x00, 0x00, /* 0000000000 */
1390 0x00, 0x00, /* 0000000000 */
1391
1392 /* 69 0x45 'E' */
1393 0x00, 0x00, /* 0000000000 */
1394 0x7f, 0x80, /* 0111111110 */
1395 0x30, 0x80, /* 0011000010 */
1396 0x30, 0x80, /* 0011000010 */
1397 0x30, 0x00, /* 0011000000 */
1398 0x30, 0x00, /* 0011000000 */
1399 0x31, 0x00, /* 0011000100 */
1400 0x3f, 0x00, /* 0011111100 */
1401 0x31, 0x00, /* 0011000100 */
1402 0x30, 0x00, /* 0011000000 */
1403 0x30, 0x00, /* 0011000000 */
1404 0x30, 0x00, /* 0011000000 */
1405 0x30, 0x80, /* 0011000010 */
1406 0x30, 0x80, /* 0011000010 */
1407 0x7f, 0x80, /* 0111111110 */
1408 0x00, 0x00, /* 0000000000 */
1409 0x00, 0x00, /* 0000000000 */
1410 0x00, 0x00, /* 0000000000 */
1411
1412 /* 70 0x46 'F' */
1413 0x00, 0x00, /* 0000000000 */
1414 0x7f, 0x80, /* 0111111110 */
1415 0x30, 0x80, /* 0011000010 */
1416 0x30, 0x80, /* 0011000010 */
1417 0x30, 0x00, /* 0011000000 */
1418 0x30, 0x00, /* 0011000000 */
1419 0x31, 0x00, /* 0011000100 */
1420 0x3f, 0x00, /* 0011111100 */
1421 0x31, 0x00, /* 0011000100 */
1422 0x30, 0x00, /* 0011000000 */
1423 0x30, 0x00, /* 0011000000 */
1424 0x30, 0x00, /* 0011000000 */
1425 0x30, 0x00, /* 0011000000 */
1426 0x30, 0x00, /* 0011000000 */
1427 0x78, 0x00, /* 0111100000 */
1428 0x00, 0x00, /* 0000000000 */
1429 0x00, 0x00, /* 0000000000 */
1430 0x00, 0x00, /* 0000000000 */
1431
1432 /* 71 0x47 'G' */
1433 0x00, 0x00, /* 0000000000 */
1434 0x0f, 0x00, /* 0000111100 */
1435 0x11, 0x80, /* 0001000110 */
1436 0x20, 0x80, /* 0010000010 */
1437 0x20, 0x00, /* 0010000000 */
1438 0x60, 0x00, /* 0110000000 */
1439 0x60, 0x00, /* 0110000000 */
1440 0x60, 0x00, /* 0110000000 */
1441 0x60, 0x00, /* 0110000000 */
1442 0x67, 0xc0, /* 0110011111 */
1443 0x61, 0x80, /* 0110000110 */
1444 0x21, 0x80, /* 0010000110 */
1445 0x31, 0x80, /* 0011000110 */
1446 0x19, 0x80, /* 0001100110 */
1447 0x0e, 0x00, /* 0000111000 */
1448 0x00, 0x00, /* 0000000000 */
1449 0x00, 0x00, /* 0000000000 */
1450 0x00, 0x00, /* 0000000000 */
1451
1452 /* 72 0x48 'H' */
1453 0x00, 0x00, /* 0000000000 */
1454 0xf3, 0xc0, /* 1111001111 */
1455 0x61, 0x80, /* 0110000110 */
1456 0x61, 0x80, /* 0110000110 */
1457 0x61, 0x80, /* 0110000110 */
1458 0x61, 0x80, /* 0110000110 */
1459 0x61, 0x80, /* 0110000110 */
1460 0x7f, 0x80, /* 0111111110 */
1461 0x61, 0x80, /* 0110000110 */
1462 0x61, 0x80, /* 0110000110 */
1463 0x61, 0x80, /* 0110000110 */
1464 0x61, 0x80, /* 0110000110 */
1465 0x61, 0x80, /* 0110000110 */
1466 0x61, 0x80, /* 0110000110 */
1467 0xf3, 0xc0, /* 1111001111 */
1468 0x00, 0x00, /* 0000000000 */
1469 0x00, 0x00, /* 0000000000 */
1470 0x00, 0x00, /* 0000000000 */
1471
1472 /* 73 0x49 'I' */
1473 0x00, 0x00, /* 0000000000 */
1474 0x3f, 0x00, /* 0011111100 */
1475 0x0c, 0x00, /* 0000110000 */
1476 0x0c, 0x00, /* 0000110000 */
1477 0x0c, 0x00, /* 0000110000 */
1478 0x0c, 0x00, /* 0000110000 */
1479 0x0c, 0x00, /* 0000110000 */
1480 0x0c, 0x00, /* 0000110000 */
1481 0x0c, 0x00, /* 0000110000 */
1482 0x0c, 0x00, /* 0000110000 */
1483 0x0c, 0x00, /* 0000110000 */
1484 0x0c, 0x00, /* 0000110000 */
1485 0x0c, 0x00, /* 0000110000 */
1486 0x0c, 0x00, /* 0000110000 */
1487 0x3f, 0x00, /* 0011111100 */
1488 0x00, 0x00, /* 0000000000 */
1489 0x00, 0x00, /* 0000000000 */
1490 0x00, 0x00, /* 0000000000 */
1491
1492 /* 74 0x4a 'J' */
1493 0x00, 0x00, /* 0000000000 */
1494 0x3f, 0x00, /* 0011111100 */
1495 0x0c, 0x00, /* 0000110000 */
1496 0x0c, 0x00, /* 0000110000 */
1497 0x0c, 0x00, /* 0000110000 */
1498 0x0c, 0x00, /* 0000110000 */
1499 0x0c, 0x00, /* 0000110000 */
1500 0x0c, 0x00, /* 0000110000 */
1501 0x0c, 0x00, /* 0000110000 */
1502 0x0c, 0x00, /* 0000110000 */
1503 0x0c, 0x00, /* 0000110000 */
1504 0x0c, 0x00, /* 0000110000 */
1505 0x0c, 0x00, /* 0000110000 */
1506 0x0c, 0x00, /* 0000110000 */
1507 0x08, 0x00, /* 0000100000 */
1508 0x70, 0x00, /* 0111000000 */
1509 0x60, 0x00, /* 0110000000 */
1510 0x00, 0x00, /* 0000000000 */
1511
1512 /* 75 0x4b 'K' */
1513 0x00, 0x00, /* 0000000000 */
1514 0xf1, 0x80, /* 1111000110 */
1515 0x63, 0x00, /* 0110001100 */
1516 0x66, 0x00, /* 0110011000 */
1517 0x6c, 0x00, /* 0110110000 */
1518 0x78, 0x00, /* 0111100000 */
1519 0x70, 0x00, /* 0111000000 */
1520 0x70, 0x00, /* 0111000000 */
1521 0x78, 0x00, /* 0111100000 */
1522 0x78, 0x00, /* 0111100000 */
1523 0x6c, 0x00, /* 0110110000 */
1524 0x66, 0x00, /* 0110011000 */
1525 0x63, 0x00, /* 0110001100 */
1526 0x61, 0x80, /* 0110000110 */
1527 0xf0, 0xc0, /* 1111000011 */
1528 0x00, 0x00, /* 0000000000 */
1529 0x00, 0x00, /* 0000000000 */
1530 0x00, 0x00, /* 0000000000 */
1531
1532 /* 76 0x4c 'L' */
1533 0x00, 0x00, /* 0000000000 */
1534 0x78, 0x00, /* 0111100000 */
1535 0x30, 0x00, /* 0011000000 */
1536 0x30, 0x00, /* 0011000000 */
1537 0x30, 0x00, /* 0011000000 */
1538 0x30, 0x00, /* 0011000000 */
1539 0x30, 0x00, /* 0011000000 */
1540 0x30, 0x00, /* 0011000000 */
1541 0x30, 0x00, /* 0011000000 */
1542 0x30, 0x00, /* 0011000000 */
1543 0x30, 0x00, /* 0011000000 */
1544 0x30, 0x00, /* 0011000000 */
1545 0x30, 0x80, /* 0011000010 */
1546 0x30, 0x80, /* 0011000010 */
1547 0x7f, 0x80, /* 0111111110 */
1548 0x00, 0x00, /* 0000000000 */
1549 0x00, 0x00, /* 0000000000 */
1550 0x00, 0x00, /* 0000000000 */
1551
1552 /* 77 0x4d 'M' */
1553 0x00, 0x00, /* 0000000000 */
1554 0xe0, 0xc0, /* 1110000011 */
1555 0x61, 0x80, /* 0110000110 */
1556 0x73, 0x80, /* 0111001110 */
1557 0x73, 0x80, /* 0111001110 */
1558 0x6d, 0x80, /* 0110110110 */
1559 0x6d, 0x80, /* 0110110110 */
1560 0x61, 0x80, /* 0110000110 */
1561 0x61, 0x80, /* 0110000110 */
1562 0x61, 0x80, /* 0110000110 */
1563 0x61, 0x80, /* 0110000110 */
1564 0x61, 0x80, /* 0110000110 */
1565 0x61, 0x80, /* 0110000110 */
1566 0x61, 0x80, /* 0110000110 */
1567 0xf3, 0xc0, /* 1111001111 */
1568 0x00, 0x00, /* 0000000000 */
1569 0x00, 0x00, /* 0000000000 */
1570 0x00, 0x00, /* 0000000000 */
1571
1572 /* 78 0x4e 'N' */
1573 0x00, 0x00, /* 0000000000 */
1574 0xf3, 0xc0, /* 1111001111 */
1575 0x61, 0x80, /* 0110000110 */
1576 0x61, 0x80, /* 0110000110 */
1577 0x71, 0x80, /* 0111000110 */
1578 0x79, 0x80, /* 0111100110 */
1579 0x79, 0x80, /* 0111100110 */
1580 0x6d, 0x80, /* 0110110110 */
1581 0x6d, 0x80, /* 0110110110 */
1582 0x67, 0x80, /* 0110011110 */
1583 0x67, 0x80, /* 0110011110 */
1584 0x63, 0x80, /* 0110001110 */
1585 0x61, 0x80, /* 0110000110 */
1586 0x61, 0x80, /* 0110000110 */
1587 0xf3, 0xc0, /* 1111001111 */
1588 0x00, 0x00, /* 0000000000 */
1589 0x00, 0x00, /* 0000000000 */
1590 0x00, 0x00, /* 0000000000 */
1591
1592 /* 79 0x4f 'O' */
1593 0x00, 0x00, /* 0000000000 */
1594 0x0c, 0x00, /* 0000110000 */
1595 0x17, 0x00, /* 0001011100 */
1596 0x23, 0x00, /* 0010001100 */
1597 0x21, 0x80, /* 0010000110 */
1598 0x61, 0x80, /* 0110000110 */
1599 0x61, 0x80, /* 0110000110 */
1600 0x61, 0x80, /* 0110000110 */
1601 0x61, 0x80, /* 0110000110 */
1602 0x61, 0x80, /* 0110000110 */
1603 0x61, 0x80, /* 0110000110 */
1604 0x21, 0x00, /* 0010000100 */
1605 0x31, 0x00, /* 0011000100 */
1606 0x1a, 0x00, /* 0001101000 */
1607 0x0c, 0x00, /* 0000110000 */
1608 0x00, 0x00, /* 0000000000 */
1609 0x00, 0x00, /* 0000000000 */
1610 0x00, 0x00, /* 0000000000 */
1611
1612 /* 80 0x50 'P' */
1613 0x00, 0x00, /* 0000000000 */
1614 0xfe, 0x00, /* 1111111000 */
1615 0x63, 0x00, /* 0110001100 */
1616 0x61, 0x80, /* 0110000110 */
1617 0x61, 0x80, /* 0110000110 */
1618 0x61, 0x80, /* 0110000110 */
1619 0x63, 0x00, /* 0110001100 */
1620 0x7e, 0x00, /* 0111111000 */
1621 0x60, 0x00, /* 0110000000 */
1622 0x60, 0x00, /* 0110000000 */
1623 0x60, 0x00, /* 0110000000 */
1624 0x60, 0x00, /* 0110000000 */
1625 0x60, 0x00, /* 0110000000 */
1626 0x60, 0x00, /* 0110000000 */
1627 0xf0, 0x00, /* 1111000000 */
1628 0x00, 0x00, /* 0000000000 */
1629 0x00, 0x00, /* 0000000000 */
1630 0x00, 0x00, /* 0000000000 */
1631
1632 /* 81 0x51 'Q' */
1633 0x00, 0x00, /* 0000000000 */
1634 0x0e, 0x00, /* 0000111000 */
1635 0x13, 0x00, /* 0001001100 */
1636 0x23, 0x00, /* 0010001100 */
1637 0x21, 0x80, /* 0010000110 */
1638 0x61, 0x80, /* 0110000110 */
1639 0x61, 0x80, /* 0110000110 */
1640 0x61, 0x80, /* 0110000110 */
1641 0x61, 0x80, /* 0110000110 */
1642 0x61, 0x80, /* 0110000110 */
1643 0x31, 0x80, /* 0011000110 */
1644 0x3b, 0x00, /* 0011101100 */
1645 0x1e, 0x00, /* 0001111000 */
1646 0x0c, 0x00, /* 0000110000 */
1647 0x1e, 0x00, /* 0001111000 */
1648 0x26, 0x00, /* 0010011000 */
1649 0x03, 0x80, /* 0000001110 */
1650 0x00, 0x00, /* 0000000000 */
1651
1652 /* 82 0x52 'R' */
1653 0x00, 0x00, /* 0000000000 */
1654 0xfe, 0x00, /* 1111111000 */
1655 0x63, 0x00, /* 0110001100 */
1656 0x61, 0x80, /* 0110000110 */
1657 0x61, 0x80, /* 0110000110 */
1658 0x61, 0x80, /* 0110000110 */
1659 0x61, 0x00, /* 0110000100 */
1660 0x7e, 0x00, /* 0111111000 */
1661 0x78, 0x00, /* 0111100000 */
1662 0x6c, 0x00, /* 0110110000 */
1663 0x6e, 0x00, /* 0110111000 */
1664 0x67, 0x00, /* 0110011100 */
1665 0x63, 0x80, /* 0110001110 */
1666 0x61, 0xc0, /* 0110000111 */
1667 0xf0, 0xc0, /* 1111000011 */
1668 0x00, 0x00, /* 0000000000 */
1669 0x00, 0x00, /* 0000000000 */
1670 0x00, 0x00, /* 0000000000 */
1671
1672 /* 83 0x53 'S' */
1673 0x00, 0x00, /* 0000000000 */
1674 0x1f, 0x00, /* 0001111100 */
1675 0x31, 0x80, /* 0011000110 */
1676 0x60, 0x80, /* 0110000010 */
1677 0x60, 0x00, /* 0110000000 */
1678 0x60, 0x00, /* 0110000000 */
1679 0x30, 0x00, /* 0011000000 */
1680 0x18, 0x00, /* 0001100000 */
1681 0x0c, 0x00, /* 0000110000 */
1682 0x06, 0x00, /* 0000011000 */
1683 0x03, 0x00, /* 0000001100 */
1684 0x01, 0x80, /* 0000000110 */
1685 0x41, 0x80, /* 0100000110 */
1686 0x63, 0x00, /* 0110001100 */
1687 0x3e, 0x00, /* 0011111000 */
1688 0x00, 0x00, /* 0000000000 */
1689 0x00, 0x00, /* 0000000000 */
1690 0x00, 0x00, /* 0000000000 */
1691
1692 /* 84 0x54 'T' */
1693 0x00, 0x00, /* 0000000000 */
1694 0x7f, 0x80, /* 0111111110 */
1695 0x4c, 0x80, /* 0100110010 */
1696 0x0c, 0x00, /* 0000110000 */
1697 0x0c, 0x00, /* 0000110000 */
1698 0x0c, 0x00, /* 0000110000 */
1699 0x0c, 0x00, /* 0000110000 */
1700 0x0c, 0x00, /* 0000110000 */
1701 0x0c, 0x00, /* 0000110000 */
1702 0x0c, 0x00, /* 0000110000 */
1703 0x0c, 0x00, /* 0000110000 */
1704 0x0c, 0x00, /* 0000110000 */
1705 0x0c, 0x00, /* 0000110000 */
1706 0x0c, 0x00, /* 0000110000 */
1707 0x3f, 0x00, /* 0011111100 */
1708 0x00, 0x00, /* 0000000000 */
1709 0x00, 0x00, /* 0000000000 */
1710 0x00, 0x00, /* 0000000000 */
1711
1712 /* 85 0x55 'U' */
1713 0x00, 0x00, /* 0000000000 */
1714 0xf3, 0xc0, /* 1111001111 */
1715 0x61, 0x80, /* 0110000110 */
1716 0x61, 0x80, /* 0110000110 */
1717 0x61, 0x80, /* 0110000110 */
1718 0x61, 0x80, /* 0110000110 */
1719 0x61, 0x80, /* 0110000110 */
1720 0x61, 0x80, /* 0110000110 */
1721 0x61, 0x80, /* 0110000110 */
1722 0x61, 0x80, /* 0110000110 */
1723 0x61, 0x80, /* 0110000110 */
1724 0x61, 0x80, /* 0110000110 */
1725 0x73, 0x00, /* 0111001100 */
1726 0x3f, 0x00, /* 0011111100 */
1727 0x1e, 0x00, /* 0001111000 */
1728 0x00, 0x00, /* 0000000000 */
1729 0x00, 0x00, /* 0000000000 */
1730 0x00, 0x00, /* 0000000000 */
1731
1732 /* 86 0x56 'V' */
1733 0x00, 0x00, /* 0000000000 */
1734 0xe1, 0xc0, /* 1110000111 */
1735 0xc0, 0xc0, /* 1100000011 */
1736 0x61, 0x80, /* 0110000110 */
1737 0x61, 0x80, /* 0110000110 */
1738 0x61, 0x80, /* 0110000110 */
1739 0x33, 0x00, /* 0011001100 */
1740 0x33, 0x00, /* 0011001100 */
1741 0x33, 0x00, /* 0011001100 */
1742 0x12, 0x00, /* 0001001000 */
1743 0x1e, 0x00, /* 0001111000 */
1744 0x1e, 0x00, /* 0001111000 */
1745 0x0c, 0x00, /* 0000110000 */
1746 0x0c, 0x00, /* 0000110000 */
1747 0x0c, 0x00, /* 0000110000 */
1748 0x00, 0x00, /* 0000000000 */
1749 0x00, 0x00, /* 0000000000 */
1750 0x00, 0x00, /* 0000000000 */
1751
1752 /* 87 0x57 'W' */
1753 0x00, 0x00, /* 0000000000 */
1754 0xe1, 0xc0, /* 1110000111 */
1755 0xc0, 0xc0, /* 1100000011 */
1756 0xc0, 0xc0, /* 1100000011 */
1757 0xc0, 0xc0, /* 1100000011 */
1758 0xe0, 0xc0, /* 1110000011 */
1759 0x61, 0x80, /* 0110000110 */
1760 0x6d, 0x80, /* 0110110110 */
1761 0x6d, 0x80, /* 0110110110 */
1762 0x7f, 0x80, /* 0111111110 */
1763 0x77, 0x00, /* 0111011100 */
1764 0x33, 0x00, /* 0011001100 */
1765 0x33, 0x00, /* 0011001100 */
1766 0x33, 0x00, /* 0011001100 */
1767 0x33, 0x00, /* 0011001100 */
1768 0x00, 0x00, /* 0000000000 */
1769 0x00, 0x00, /* 0000000000 */
1770 0x00, 0x00, /* 0000000000 */
1771
1772 /* 88 0x58 'X' */
1773 0x00, 0x00, /* 0000000000 */
1774 0xf7, 0x80, /* 1111011110 */
1775 0x63, 0x00, /* 0110001100 */
1776 0x63, 0x00, /* 0110001100 */
1777 0x36, 0x00, /* 0011011000 */
1778 0x36, 0x00, /* 0011011000 */
1779 0x36, 0x00, /* 0011011000 */
1780 0x1c, 0x00, /* 0001110000 */
1781 0x1c, 0x00, /* 0001110000 */
1782 0x36, 0x00, /* 0011011000 */
1783 0x36, 0x00, /* 0011011000 */
1784 0x36, 0x00, /* 0011011000 */
1785 0x63, 0x00, /* 0110001100 */
1786 0x63, 0x00, /* 0110001100 */
1787 0xf7, 0x80, /* 1111011110 */
1788 0x00, 0x00, /* 0000000000 */
1789 0x00, 0x00, /* 0000000000 */
1790 0x00, 0x00, /* 0000000000 */
1791
1792 /* 89 0x59 'Y' */
1793 0x00, 0x00, /* 0000000000 */
1794 0xf3, 0xc0, /* 1111001111 */
1795 0x61, 0x80, /* 0110000110 */
1796 0x61, 0x80, /* 0110000110 */
1797 0x33, 0x00, /* 0011001100 */
1798 0x33, 0x00, /* 0011001100 */
1799 0x1e, 0x00, /* 0001111000 */
1800 0x0c, 0x00, /* 0000110000 */
1801 0x0c, 0x00, /* 0000110000 */
1802 0x0c, 0x00, /* 0000110000 */
1803 0x0c, 0x00, /* 0000110000 */
1804 0x0c, 0x00, /* 0000110000 */
1805 0x0c, 0x00, /* 0000110000 */
1806 0x0c, 0x00, /* 0000110000 */
1807 0x1e, 0x00, /* 0001111000 */
1808 0x00, 0x00, /* 0000000000 */
1809 0x00, 0x00, /* 0000000000 */
1810 0x00, 0x00, /* 0000000000 */
1811
1812 /* 90 0x5a 'Z' */
1813 0x00, 0x00, /* 0000000000 */
1814 0x3f, 0x80, /* 0011111110 */
1815 0x21, 0x80, /* 0010000110 */
1816 0x01, 0x80, /* 0000000110 */
1817 0x03, 0x00, /* 0000001100 */
1818 0x03, 0x00, /* 0000001100 */
1819 0x06, 0x00, /* 0000011000 */
1820 0x06, 0x00, /* 0000011000 */
1821 0x0c, 0x00, /* 0000110000 */
1822 0x0c, 0x00, /* 0000110000 */
1823 0x18, 0x00, /* 0001100000 */
1824 0x18, 0x00, /* 0001100000 */
1825 0x30, 0x00, /* 0011000000 */
1826 0x30, 0x80, /* 0011000010 */
1827 0x3f, 0x80, /* 0011111110 */
1828 0x00, 0x00, /* 0000000000 */
1829 0x00, 0x00, /* 0000000000 */
1830 0x00, 0x00, /* 0000000000 */
1831
1832 /* 91 0x5b '[' */
1833 0x00, 0x00, /* 0000000000 */
1834 0x1f, 0x00, /* 0001111100 */
1835 0x1f, 0x00, /* 0001111100 */
1836 0x18, 0x00, /* 0001100000 */
1837 0x18, 0x00, /* 0001100000 */
1838 0x18, 0x00, /* 0001100000 */
1839 0x18, 0x00, /* 0001100000 */
1840 0x18, 0x00, /* 0001100000 */
1841 0x18, 0x00, /* 0001100000 */
1842 0x18, 0x00, /* 0001100000 */
1843 0x18, 0x00, /* 0001100000 */
1844 0x18, 0x00, /* 0001100000 */
1845 0x18, 0x00, /* 0001100000 */
1846 0x18, 0x00, /* 0001100000 */
1847 0x1f, 0x00, /* 0001111100 */
1848 0x1f, 0x00, /* 0001111100 */
1849 0x00, 0x00, /* 0000000000 */
1850 0x00, 0x00, /* 0000000000 */
1851
1852 /* 92 0x5c '\' */
1853 0x00, 0x00, /* 0000000000 */
1854 0xc0, 0x00, /* 1100000000 */
1855 0x60, 0x00, /* 0110000000 */
1856 0x60, 0x00, /* 0110000000 */
1857 0x30, 0x00, /* 0011000000 */
1858 0x30, 0x00, /* 0011000000 */
1859 0x18, 0x00, /* 0001100000 */
1860 0x18, 0x00, /* 0001100000 */
1861 0x0c, 0x00, /* 0000110000 */
1862 0x0c, 0x00, /* 0000110000 */
1863 0x06, 0x00, /* 0000011000 */
1864 0x06, 0x00, /* 0000011000 */
1865 0x03, 0x00, /* 0000001100 */
1866 0x03, 0x00, /* 0000001100 */
1867 0x01, 0x80, /* 0000000110 */
1868 0x01, 0x80, /* 0000000110 */
1869 0x00, 0xc0, /* 0000000011 */
1870 0x00, 0x00, /* 0000000000 */
1871
1872 /* 93 0x5d ']' */
1873 0x00, 0x00, /* 0000000000 */
1874 0x3e, 0x00, /* 0011111000 */
1875 0x3e, 0x00, /* 0011111000 */
1876 0x06, 0x00, /* 0000011000 */
1877 0x06, 0x00, /* 0000011000 */
1878 0x06, 0x00, /* 0000011000 */
1879 0x06, 0x00, /* 0000011000 */
1880 0x06, 0x00, /* 0000011000 */
1881 0x06, 0x00, /* 0000011000 */
1882 0x06, 0x00, /* 0000011000 */
1883 0x06, 0x00, /* 0000011000 */
1884 0x06, 0x00, /* 0000011000 */
1885 0x06, 0x00, /* 0000011000 */
1886 0x06, 0x00, /* 0000011000 */
1887 0x3e, 0x00, /* 0011111000 */
1888 0x3e, 0x00, /* 0011111000 */
1889 0x00, 0x00, /* 0000000000 */
1890 0x00, 0x00, /* 0000000000 */
1891
1892 /* 94 0x5e '^' */
1893 0x00, 0x00, /* 0000000000 */
1894 0x0c, 0x00, /* 0000110000 */
1895 0x1e, 0x00, /* 0001111000 */
1896 0x33, 0x00, /* 0011001100 */
1897 0x61, 0x80, /* 0110000110 */
1898 0x00, 0x00, /* 0000000000 */
1899 0x00, 0x00, /* 0000000000 */
1900 0x00, 0x00, /* 0000000000 */
1901 0x00, 0x00, /* 0000000000 */
1902 0x00, 0x00, /* 0000000000 */
1903 0x00, 0x00, /* 0000000000 */
1904 0x00, 0x00, /* 0000000000 */
1905 0x00, 0x00, /* 0000000000 */
1906 0x00, 0x00, /* 0000000000 */
1907 0x00, 0x00, /* 0000000000 */
1908 0x00, 0x00, /* 0000000000 */
1909 0x00, 0x00, /* 0000000000 */
1910 0x00, 0x00, /* 0000000000 */
1911
1912 /* 95 0x5f '_' */
1913 0x00, 0x00, /* 0000000000 */
1914 0x00, 0x00, /* 0000000000 */
1915 0x00, 0x00, /* 0000000000 */
1916 0x00, 0x00, /* 0000000000 */
1917 0x00, 0x00, /* 0000000000 */
1918 0x00, 0x00, /* 0000000000 */
1919 0x00, 0x00, /* 0000000000 */
1920 0x00, 0x00, /* 0000000000 */
1921 0x00, 0x00, /* 0000000000 */
1922 0x00, 0x00, /* 0000000000 */
1923 0x00, 0x00, /* 0000000000 */
1924 0x00, 0x00, /* 0000000000 */
1925 0x00, 0x00, /* 0000000000 */
1926 0x00, 0x00, /* 0000000000 */
1927 0x00, 0x00, /* 0000000000 */
1928 0xff, 0xc0, /* 1111111111 */
1929 0xff, 0xc0, /* 1111111111 */
1930 0x00, 0x00, /* 0000000000 */
1931
1932 /* 96 0x60 '`' */
1933 0x04, 0x00, /* 0000010000 */
1934 0x0c, 0x00, /* 0000110000 */
1935 0x18, 0x00, /* 0001100000 */
1936 0x18, 0x00, /* 0001100000 */
1937 0x1e, 0x00, /* 0001111000 */
1938 0x1e, 0x00, /* 0001111000 */
1939 0x0c, 0x00, /* 0000110000 */
1940 0x00, 0x00, /* 0000000000 */
1941 0x00, 0x00, /* 0000000000 */
1942 0x00, 0x00, /* 0000000000 */
1943 0x00, 0x00, /* 0000000000 */
1944 0x00, 0x00, /* 0000000000 */
1945 0x00, 0x00, /* 0000000000 */
1946 0x00, 0x00, /* 0000000000 */
1947 0x00, 0x00, /* 0000000000 */
1948 0x00, 0x00, /* 0000000000 */
1949 0x00, 0x00, /* 0000000000 */
1950 0x00, 0x00, /* 0000000000 */
1951
1952 /* 97 0x61 'a' */
1953 0x00, 0x00, /* 0000000000 */
1954 0x00, 0x00, /* 0000000000 */
1955 0x00, 0x00, /* 0000000000 */
1956 0x00, 0x00, /* 0000000000 */
1957 0x00, 0x00, /* 0000000000 */
1958 0x1f, 0x00, /* 0001111100 */
1959 0x31, 0x80, /* 0011000110 */
1960 0x21, 0x80, /* 0010000110 */
1961 0x07, 0x80, /* 0000011110 */
1962 0x39, 0x80, /* 0011100110 */
1963 0x61, 0x80, /* 0110000110 */
1964 0x61, 0x80, /* 0110000110 */
1965 0x61, 0x80, /* 0110000110 */
1966 0x73, 0x80, /* 0111001110 */
1967 0x3d, 0xc0, /* 0011110111 */
1968 0x00, 0x00, /* 0000000000 */
1969 0x00, 0x00, /* 0000000000 */
1970 0x00, 0x00, /* 0000000000 */
1971
1972 /* 98 0x62 'b' */
1973 0x20, 0x00, /* 0010000000 */
1974 0x60, 0x00, /* 0110000000 */
1975 0xe0, 0x00, /* 1110000000 */
1976 0x60, 0x00, /* 0110000000 */
1977 0x60, 0x00, /* 0110000000 */
1978 0x66, 0x00, /* 0110011000 */
1979 0x6f, 0x00, /* 0110111100 */
1980 0x73, 0x80, /* 0111001110 */
1981 0x61, 0x80, /* 0110000110 */
1982 0x61, 0x80, /* 0110000110 */
1983 0x61, 0x80, /* 0110000110 */
1984 0x61, 0x80, /* 0110000110 */
1985 0x71, 0x80, /* 0111000110 */
1986 0x7b, 0x00, /* 0111101100 */
1987 0x4e, 0x00, /* 0100111000 */
1988 0x00, 0x00, /* 0000000000 */
1989 0x00, 0x00, /* 0000000000 */
1990 0x00, 0x00, /* 0000000000 */
1991
1992 /* 99 0x63 'c' */
1993 0x00, 0x00, /* 0000000000 */
1994 0x00, 0x00, /* 0000000000 */
1995 0x00, 0x00, /* 0000000000 */
1996 0x00, 0x00, /* 0000000000 */
1997 0x00, 0x00, /* 0000000000 */
1998 0x1e, 0x00, /* 0001111000 */
1999 0x37, 0x00, /* 0011011100 */
2000 0x23, 0x00, /* 0010001100 */
2001 0x60, 0x00, /* 0110000000 */
2002 0x60, 0x00, /* 0110000000 */
2003 0x60, 0x00, /* 0110000000 */
2004 0x60, 0x00, /* 0110000000 */
2005 0x71, 0x00, /* 0111000100 */
2006 0x33, 0x00, /* 0011001100 */
2007 0x1e, 0x00, /* 0001111000 */
2008 0x00, 0x00, /* 0000000000 */
2009 0x00, 0x00, /* 0000000000 */
2010 0x00, 0x00, /* 0000000000 */
2011
2012 /* 100 0x64 'd' */
2013 0x01, 0x80, /* 0000000110 */
2014 0x03, 0x80, /* 0000001110 */
2015 0x01, 0x80, /* 0000000110 */
2016 0x01, 0x80, /* 0000000110 */
2017 0x01, 0x80, /* 0000000110 */
2018 0x0d, 0x80, /* 0000110110 */
2019 0x37, 0x80, /* 0011011110 */
2020 0x23, 0x80, /* 0010001110 */
2021 0x61, 0x80, /* 0110000110 */
2022 0x61, 0x80, /* 0110000110 */
2023 0x61, 0x80, /* 0110000110 */
2024 0x61, 0x80, /* 0110000110 */
2025 0x73, 0x80, /* 0111001110 */
2026 0x35, 0x80, /* 0011010110 */
2027 0x19, 0xc0, /* 0001100111 */
2028 0x00, 0x00, /* 0000000000 */
2029 0x00, 0x00, /* 0000000000 */
2030 0x00, 0x00, /* 0000000000 */
2031
2032 /* 101 0x65 'e' */
2033 0x00, 0x00, /* 0000000000 */
2034 0x00, 0x00, /* 0000000000 */
2035 0x00, 0x00, /* 0000000000 */
2036 0x00, 0x00, /* 0000000000 */
2037 0x00, 0x00, /* 0000000000 */
2038 0x0c, 0x00, /* 0000110000 */
2039 0x33, 0x00, /* 0011001100 */
2040 0x61, 0x80, /* 0110000110 */
2041 0x61, 0x80, /* 0110000110 */
2042 0x7f, 0x80, /* 0111111110 */
2043 0x60, 0x00, /* 0110000000 */
2044 0x60, 0x00, /* 0110000000 */
2045 0x30, 0x00, /* 0011000000 */
2046 0x19, 0x80, /* 0001100110 */
2047 0x0e, 0x00, /* 0000111000 */
2048 0x00, 0x00, /* 0000000000 */
2049 0x00, 0x00, /* 0000000000 */
2050 0x00, 0x00, /* 0000000000 */
2051
2052 /* 102 0x66 'f' */
2053 0x07, 0x00, /* 0000011100 */
2054 0x09, 0x80, /* 0000100110 */
2055 0x09, 0x80, /* 0000100110 */
2056 0x18, 0x00, /* 0001100000 */
2057 0x18, 0x00, /* 0001100000 */
2058 0x18, 0x00, /* 0001100000 */
2059 0x18, 0x00, /* 0001100000 */
2060 0x7f, 0x00, /* 0111111100 */
2061 0x18, 0x00, /* 0001100000 */
2062 0x18, 0x00, /* 0001100000 */
2063 0x18, 0x00, /* 0001100000 */
2064 0x18, 0x00, /* 0001100000 */
2065 0x18, 0x00, /* 0001100000 */
2066 0x18, 0x00, /* 0001100000 */
2067 0x3c, 0x00, /* 0011110000 */
2068 0x00, 0x00, /* 0000000000 */
2069 0x00, 0x00, /* 0000000000 */
2070 0x00, 0x00, /* 0000000000 */
2071
2072 /* 103 0x67 'g' */
2073 0x00, 0x00, /* 0000000000 */
2074 0x00, 0x00, /* 0000000000 */
2075 0x00, 0x00, /* 0000000000 */
2076 0x00, 0x00, /* 0000000000 */
2077 0x00, 0x00, /* 0000000000 */
2078 0x1c, 0x80, /* 0001110010 */
2079 0x37, 0x80, /* 0011011110 */
2080 0x63, 0x00, /* 0110001100 */
2081 0x63, 0x00, /* 0110001100 */
2082 0x36, 0x00, /* 0011011000 */
2083 0x3c, 0x00, /* 0011110000 */
2084 0x60, 0x00, /* 0110000000 */
2085 0x7f, 0x00, /* 0111111100 */
2086 0x3f, 0x80, /* 0011111110 */
2087 0x21, 0x80, /* 0010000110 */
2088 0x40, 0x80, /* 0100000010 */
2089 0x7f, 0x00, /* 0111111100 */
2090 0x3e, 0x00, /* 0011111000 */
2091
2092 /* 104 0x68 'h' */
2093 0x10, 0x00, /* 0001000000 */
2094 0x30, 0x00, /* 0011000000 */
2095 0x70, 0x00, /* 0111000000 */
2096 0x30, 0x00, /* 0011000000 */
2097 0x30, 0x00, /* 0011000000 */
2098 0x37, 0x00, /* 0011011100 */
2099 0x3b, 0x80, /* 0011101110 */
2100 0x31, 0x80, /* 0011000110 */
2101 0x31, 0x80, /* 0011000110 */
2102 0x31, 0x80, /* 0011000110 */
2103 0x31, 0x80, /* 0011000110 */
2104 0x31, 0x80, /* 0011000110 */
2105 0x31, 0x80, /* 0011000110 */
2106 0x31, 0x80, /* 0011000110 */
2107 0x7b, 0xc0, /* 0111101111 */
2108 0x00, 0x00, /* 0000000000 */
2109 0x00, 0x00, /* 0000000000 */
2110 0x00, 0x00, /* 0000000000 */
2111
2112 /* 105 0x69 'i' */
2113 0x00, 0x00, /* 0000000000 */
2114 0x0c, 0x00, /* 0000110000 */
2115 0x0c, 0x00, /* 0000110000 */
2116 0x00, 0x00, /* 0000000000 */
2117 0x00, 0x00, /* 0000000000 */
2118 0x3c, 0x00, /* 0011110000 */
2119 0x0c, 0x00, /* 0000110000 */
2120 0x0c, 0x00, /* 0000110000 */
2121 0x0c, 0x00, /* 0000110000 */
2122 0x0c, 0x00, /* 0000110000 */
2123 0x0c, 0x00, /* 0000110000 */
2124 0x0c, 0x00, /* 0000110000 */
2125 0x0c, 0x00, /* 0000110000 */
2126 0x0c, 0x00, /* 0000110000 */
2127 0x3f, 0x00, /* 0011111100 */
2128 0x00, 0x00, /* 0000000000 */
2129 0x00, 0x00, /* 0000000000 */
2130 0x00, 0x00, /* 0000000000 */
2131
2132 /* 106 0x6a 'j' */
2133 0x00, 0x00, /* 0000000000 */
2134 0x01, 0x80, /* 0000000110 */
2135 0x01, 0x80, /* 0000000110 */
2136 0x00, 0x00, /* 0000000000 */
2137 0x00, 0x00, /* 0000000000 */
2138 0x07, 0x80, /* 0000011110 */
2139 0x01, 0x80, /* 0000000110 */
2140 0x01, 0x80, /* 0000000110 */
2141 0x01, 0x80, /* 0000000110 */
2142 0x01, 0x80, /* 0000000110 */
2143 0x01, 0x80, /* 0000000110 */
2144 0x01, 0x80, /* 0000000110 */
2145 0x01, 0x80, /* 0000000110 */
2146 0x41, 0x80, /* 0100000110 */
2147 0x61, 0x80, /* 0110000110 */
2148 0x71, 0x80, /* 0111000110 */
2149 0x3f, 0x00, /* 0011111100 */
2150 0x1c, 0x00, /* 0001110000 */
2151
2152 /* 107 0x6b 'k' */
2153 0x60, 0x00, /* 0110000000 */
2154 0xe0, 0x00, /* 1110000000 */
2155 0x60, 0x00, /* 0110000000 */
2156 0x60, 0x00, /* 0110000000 */
2157 0x60, 0x00, /* 0110000000 */
2158 0x63, 0x80, /* 0110001110 */
2159 0x66, 0x00, /* 0110011000 */
2160 0x6c, 0x00, /* 0110110000 */
2161 0x78, 0x00, /* 0111100000 */
2162 0x70, 0x00, /* 0111000000 */
2163 0x78, 0x00, /* 0111100000 */
2164 0x6c, 0x00, /* 0110110000 */
2165 0x6e, 0x00, /* 0110111000 */
2166 0x67, 0x00, /* 0110011100 */
2167 0xf3, 0x80, /* 1111001110 */
2168 0x00, 0x00, /* 0000000000 */
2169 0x00, 0x00, /* 0000000000 */
2170 0x00, 0x00, /* 0000000000 */
2171
2172 /* 108 0x6c 'l' */
2173 0x3c, 0x00, /* 0011110000 */
2174 0x0c, 0x00, /* 0000110000 */
2175 0x0c, 0x00, /* 0000110000 */
2176 0x0c, 0x00, /* 0000110000 */
2177 0x0c, 0x00, /* 0000110000 */
2178 0x0c, 0x00, /* 0000110000 */
2179 0x0c, 0x00, /* 0000110000 */
2180 0x0c, 0x00, /* 0000110000 */
2181 0x0c, 0x00, /* 0000110000 */
2182 0x0c, 0x00, /* 0000110000 */
2183 0x0c, 0x00, /* 0000110000 */
2184 0x0c, 0x00, /* 0000110000 */
2185 0x0c, 0x00, /* 0000110000 */
2186 0x0c, 0x00, /* 0000110000 */
2187 0x3f, 0x00, /* 0011111100 */
2188 0x00, 0x00, /* 0000000000 */
2189 0x00, 0x00, /* 0000000000 */
2190 0x00, 0x00, /* 0000000000 */
2191
2192 /* 109 0x6d 'm' */
2193 0x00, 0x00, /* 0000000000 */
2194 0x00, 0x00, /* 0000000000 */
2195 0x00, 0x00, /* 0000000000 */
2196 0x00, 0x00, /* 0000000000 */
2197 0x00, 0x00, /* 0000000000 */
2198 0xdb, 0x80, /* 1101101110 */
2199 0x6d, 0x80, /* 0110110110 */
2200 0x6d, 0x80, /* 0110110110 */
2201 0x6d, 0x80, /* 0110110110 */
2202 0x6d, 0x80, /* 0110110110 */
2203 0x6d, 0x80, /* 0110110110 */
2204 0x6d, 0x80, /* 0110110110 */
2205 0x6d, 0x80, /* 0110110110 */
2206 0x6d, 0x80, /* 0110110110 */
2207 0xed, 0xc0, /* 1110110111 */
2208 0x00, 0x00, /* 0000000000 */
2209 0x00, 0x00, /* 0000000000 */
2210 0x00, 0x00, /* 0000000000 */
2211
2212 /* 110 0x6e 'n' */
2213 0x00, 0x00, /* 0000000000 */
2214 0x00, 0x00, /* 0000000000 */
2215 0x00, 0x00, /* 0000000000 */
2216 0x00, 0x00, /* 0000000000 */
2217 0x00, 0x00, /* 0000000000 */
2218 0x6f, 0x00, /* 0110111100 */
2219 0x7b, 0x80, /* 0111101110 */
2220 0x31, 0x80, /* 0011000110 */
2221 0x31, 0x80, /* 0011000110 */
2222 0x31, 0x80, /* 0011000110 */
2223 0x31, 0x80, /* 0011000110 */
2224 0x31, 0x80, /* 0011000110 */
2225 0x31, 0x80, /* 0011000110 */
2226 0x31, 0x80, /* 0011000110 */
2227 0x7b, 0xc0, /* 0111101111 */
2228 0x00, 0x00, /* 0000000000 */
2229 0x00, 0x00, /* 0000000000 */
2230 0x00, 0x00, /* 0000000000 */
2231
2232 /* 111 0x6f 'o' */
2233 0x00, 0x00, /* 0000000000 */
2234 0x00, 0x00, /* 0000000000 */
2235 0x00, 0x00, /* 0000000000 */
2236 0x00, 0x00, /* 0000000000 */
2237 0x00, 0x00, /* 0000000000 */
2238 0x3c, 0x00, /* 0011110000 */
2239 0x66, 0x00, /* 0110011000 */
2240 0xc3, 0x00, /* 1100001100 */
2241 0xc1, 0x80, /* 1100000110 */
2242 0xc1, 0x80, /* 1100000110 */
2243 0xc1, 0x80, /* 1100000110 */
2244 0xc1, 0x80, /* 1100000110 */
2245 0xe1, 0x80, /* 1110000110 */
2246 0x73, 0x00, /* 0111001100 */
2247 0x3c, 0x00, /* 0011110000 */
2248 0x00, 0x00, /* 0000000000 */
2249 0x00, 0x00, /* 0000000000 */
2250 0x00, 0x00, /* 0000000000 */
2251
2252 /* 112 0x70 'p' */
2253 0x00, 0x00, /* 0000000000 */
2254 0x00, 0x00, /* 0000000000 */
2255 0x00, 0x00, /* 0000000000 */
2256 0x00, 0x00, /* 0000000000 */
2257 0x00, 0x00, /* 0000000000 */
2258 0xde, 0x00, /* 1101111000 */
2259 0x76, 0x00, /* 0111011000 */
2260 0x63, 0x00, /* 0110001100 */
2261 0x61, 0x80, /* 0110000110 */
2262 0x61, 0x80, /* 0110000110 */
2263 0x61, 0x80, /* 0110000110 */
2264 0x61, 0x80, /* 0110000110 */
2265 0x71, 0x80, /* 0111000110 */
2266 0x7b, 0x00, /* 0111101100 */
2267 0x7e, 0x00, /* 0111111000 */
2268 0x60, 0x00, /* 0110000000 */
2269 0x60, 0x00, /* 0110000000 */
2270 0xf0, 0x00, /* 1111000000 */
2271
2272 /* 113 0x71 'q' */
2273 0x00, 0x00, /* 0000000000 */
2274 0x00, 0x00, /* 0000000000 */
2275 0x00, 0x00, /* 0000000000 */
2276 0x00, 0x00, /* 0000000000 */
2277 0x00, 0x00, /* 0000000000 */
2278 0x0e, 0xc0, /* 0000111011 */
2279 0x1b, 0x80, /* 0001101110 */
2280 0x33, 0x80, /* 0011001110 */
2281 0x61, 0x80, /* 0110000110 */
2282 0x61, 0x80, /* 0110000110 */
2283 0x61, 0x80, /* 0110000110 */
2284 0x61, 0x80, /* 0110000110 */
2285 0x71, 0x80, /* 0111000110 */
2286 0x3b, 0x80, /* 0011101110 */
2287 0x1f, 0x80, /* 0001111110 */
2288 0x01, 0x80, /* 0000000110 */
2289 0x01, 0x80, /* 0000000110 */
2290 0x03, 0xc0, /* 0000001111 */
2291
2292 /* 114 0x72 'r' */
2293 0x00, 0x00, /* 0000000000 */
2294 0x00, 0x00, /* 0000000000 */
2295 0x00, 0x00, /* 0000000000 */
2296 0x00, 0x00, /* 0000000000 */
2297 0x00, 0x00, /* 0000000000 */
2298 0x73, 0x00, /* 0111001100 */
2299 0x35, 0x80, /* 0011010110 */
2300 0x39, 0x80, /* 0011100110 */
2301 0x30, 0x00, /* 0011000000 */
2302 0x30, 0x00, /* 0011000000 */
2303 0x30, 0x00, /* 0011000000 */
2304 0x30, 0x00, /* 0011000000 */
2305 0x30, 0x00, /* 0011000000 */
2306 0x30, 0x00, /* 0011000000 */
2307 0x78, 0x00, /* 0111100000 */
2308 0x00, 0x00, /* 0000000000 */
2309 0x00, 0x00, /* 0000000000 */
2310 0x00, 0x00, /* 0000000000 */
2311
2312 /* 115 0x73 's' */
2313 0x00, 0x00, /* 0000000000 */
2314 0x00, 0x00, /* 0000000000 */
2315 0x00, 0x00, /* 0000000000 */
2316 0x00, 0x00, /* 0000000000 */
2317 0x00, 0x00, /* 0000000000 */
2318 0x3f, 0x00, /* 0011111100 */
2319 0x63, 0x00, /* 0110001100 */
2320 0x61, 0x00, /* 0110000100 */
2321 0x70, 0x00, /* 0111000000 */
2322 0x38, 0x00, /* 0011100000 */
2323 0x0e, 0x00, /* 0000111000 */
2324 0x07, 0x00, /* 0000011100 */
2325 0x43, 0x00, /* 0100001100 */
2326 0x63, 0x00, /* 0110001100 */
2327 0x7e, 0x00, /* 0111111000 */
2328 0x00, 0x00, /* 0000000000 */
2329 0x00, 0x00, /* 0000000000 */
2330 0x00, 0x00, /* 0000000000 */
2331
2332 /* 116 0x74 't' */
2333 0x00, 0x00, /* 0000000000 */
2334 0x00, 0x00, /* 0000000000 */
2335 0x08, 0x00, /* 0000100000 */
2336 0x08, 0x00, /* 0000100000 */
2337 0x18, 0x00, /* 0001100000 */
2338 0x7f, 0x80, /* 0111111110 */
2339 0x18, 0x00, /* 0001100000 */
2340 0x18, 0x00, /* 0001100000 */
2341 0x18, 0x00, /* 0001100000 */
2342 0x18, 0x00, /* 0001100000 */
2343 0x18, 0x00, /* 0001100000 */
2344 0x18, 0x00, /* 0001100000 */
2345 0x18, 0x00, /* 0001100000 */
2346 0x1c, 0x80, /* 0001110010 */
2347 0x0f, 0x00, /* 0000111100 */
2348 0x00, 0x00, /* 0000000000 */
2349 0x00, 0x00, /* 0000000000 */
2350 0x00, 0x00, /* 0000000000 */
2351
2352 /* 117 0x75 'u' */
2353 0x00, 0x00, /* 0000000000 */
2354 0x00, 0x00, /* 0000000000 */
2355 0x00, 0x00, /* 0000000000 */
2356 0x00, 0x00, /* 0000000000 */
2357 0x00, 0x00, /* 0000000000 */
2358 0xf7, 0x80, /* 1111011110 */
2359 0x63, 0x00, /* 0110001100 */
2360 0x63, 0x00, /* 0110001100 */
2361 0x63, 0x00, /* 0110001100 */
2362 0x63, 0x00, /* 0110001100 */
2363 0x63, 0x00, /* 0110001100 */
2364 0x63, 0x00, /* 0110001100 */
2365 0x63, 0x00, /* 0110001100 */
2366 0x77, 0x00, /* 0111011100 */
2367 0x3d, 0x80, /* 0011110110 */
2368 0x00, 0x00, /* 0000000000 */
2369 0x00, 0x00, /* 0000000000 */
2370 0x00, 0x00, /* 0000000000 */
2371
2372 /* 118 0x76 'v' */
2373 0x00, 0x00, /* 0000000000 */
2374 0x00, 0x00, /* 0000000000 */
2375 0x00, 0x00, /* 0000000000 */
2376 0x00, 0x00, /* 0000000000 */
2377 0x00, 0x00, /* 0000000000 */
2378 0xf1, 0xc0, /* 1111000111 */
2379 0x60, 0xc0, /* 0110000011 */
2380 0x31, 0x80, /* 0011000110 */
2381 0x31, 0x80, /* 0011000110 */
2382 0x19, 0x80, /* 0001100110 */
2383 0x1b, 0x00, /* 0001101100 */
2384 0x0f, 0x00, /* 0000111100 */
2385 0x0f, 0x00, /* 0000111100 */
2386 0x06, 0x00, /* 0000011000 */
2387 0x06, 0x00, /* 0000011000 */
2388 0x00, 0x00, /* 0000000000 */
2389 0x00, 0x00, /* 0000000000 */
2390 0x00, 0x00, /* 0000000000 */
2391
2392 /* 119 0x77 'w' */
2393 0x00, 0x00, /* 0000000000 */
2394 0x00, 0x00, /* 0000000000 */
2395 0x00, 0x00, /* 0000000000 */
2396 0x00, 0x00, /* 0000000000 */
2397 0x00, 0x00, /* 0000000000 */
2398 0xe3, 0xc0, /* 1110001111 */
2399 0xc1, 0x80, /* 1100000110 */
2400 0xc1, 0x80, /* 1100000110 */
2401 0xc1, 0x80, /* 1100000110 */
2402 0xc1, 0x80, /* 1100000110 */
2403 0x6b, 0x00, /* 0110101100 */
2404 0x6b, 0x00, /* 0110101100 */
2405 0x7e, 0x00, /* 0111111000 */
2406 0x36, 0x00, /* 0011011000 */
2407 0x36, 0x00, /* 0011011000 */
2408 0x00, 0x00, /* 0000000000 */
2409 0x00, 0x00, /* 0000000000 */
2410 0x00, 0x00, /* 0000000000 */
2411
2412 /* 120 0x78 'x' */
2413 0x00, 0x00, /* 0000000000 */
2414 0x00, 0x00, /* 0000000000 */
2415 0x00, 0x00, /* 0000000000 */
2416 0x00, 0x00, /* 0000000000 */
2417 0x00, 0x00, /* 0000000000 */
2418 0xf7, 0x80, /* 1111011110 */
2419 0x63, 0x00, /* 0110001100 */
2420 0x36, 0x00, /* 0011011000 */
2421 0x36, 0x00, /* 0011011000 */
2422 0x1c, 0x00, /* 0001110000 */
2423 0x1c, 0x00, /* 0001110000 */
2424 0x36, 0x00, /* 0011011000 */
2425 0x66, 0x00, /* 0110011000 */
2426 0x63, 0x00, /* 0110001100 */
2427 0xf7, 0x80, /* 1111011110 */
2428 0x00, 0x00, /* 0000000000 */
2429 0x00, 0x00, /* 0000000000 */
2430 0x00, 0x00, /* 0000000000 */
2431
2432 /* 121 0x79 'y' */
2433 0x00, 0x00, /* 0000000000 */
2434 0x00, 0x00, /* 0000000000 */
2435 0x00, 0x00, /* 0000000000 */
2436 0x00, 0x00, /* 0000000000 */
2437 0x00, 0x00, /* 0000000000 */
2438 0xf3, 0xc0, /* 1111001111 */
2439 0x61, 0x80, /* 0110000110 */
2440 0x33, 0x00, /* 0011001100 */
2441 0x1b, 0x00, /* 0001101100 */
2442 0x1e, 0x00, /* 0001111000 */
2443 0x0e, 0x00, /* 0000111000 */
2444 0x0c, 0x00, /* 0000110000 */
2445 0x0c, 0x00, /* 0000110000 */
2446 0x0c, 0x00, /* 0000110000 */
2447 0x0c, 0x00, /* 0000110000 */
2448 0x18, 0x00, /* 0001100000 */
2449 0x78, 0x00, /* 0111100000 */
2450 0x70, 0x00, /* 0111000000 */
2451
2452 /* 122 0x7a 'z' */
2453 0x00, 0x00, /* 0000000000 */
2454 0x00, 0x00, /* 0000000000 */
2455 0x00, 0x00, /* 0000000000 */
2456 0x00, 0x00, /* 0000000000 */
2457 0x00, 0x00, /* 0000000000 */
2458 0x7f, 0x80, /* 0111111110 */
2459 0x61, 0x80, /* 0110000110 */
2460 0x43, 0x00, /* 0100001100 */
2461 0x06, 0x00, /* 0000011000 */
2462 0x0c, 0x00, /* 0000110000 */
2463 0x18, 0x00, /* 0001100000 */
2464 0x30, 0x00, /* 0011000000 */
2465 0x60, 0x80, /* 0110000010 */
2466 0x61, 0x80, /* 0110000110 */
2467 0x7f, 0x80, /* 0111111110 */
2468 0x00, 0x00, /* 0000000000 */
2469 0x00, 0x00, /* 0000000000 */
2470 0x00, 0x00, /* 0000000000 */
2471
2472 /* 123 0x7b '{' */
2473 0x07, 0x00, /* 0000011100 */
2474 0x0c, 0x00, /* 0000110000 */
2475 0x0c, 0x00, /* 0000110000 */
2476 0x0c, 0x00, /* 0000110000 */
2477 0x0c, 0x00, /* 0000110000 */
2478 0x0c, 0x00, /* 0000110000 */
2479 0x18, 0x00, /* 0001100000 */
2480 0x70, 0x00, /* 0111000000 */
2481 0x18, 0x00, /* 0001100000 */
2482 0x0c, 0x00, /* 0000110000 */
2483 0x0c, 0x00, /* 0000110000 */
2484 0x0c, 0x00, /* 0000110000 */
2485 0x0c, 0x00, /* 0000110000 */
2486 0x0c, 0x00, /* 0000110000 */
2487 0x07, 0x00, /* 0000011100 */
2488 0x00, 0x00, /* 0000000000 */
2489 0x00, 0x00, /* 0000000000 */
2490 0x00, 0x00, /* 0000000000 */
2491
2492 /* 124 0x7c '|' */
2493 0x0c, 0x00, /* 0000110000 */
2494 0x0c, 0x00, /* 0000110000 */
2495 0x0c, 0x00, /* 0000110000 */
2496 0x0c, 0x00, /* 0000110000 */
2497 0x0c, 0x00, /* 0000110000 */
2498 0x0c, 0x00, /* 0000110000 */
2499 0x0c, 0x00, /* 0000110000 */
2500 0x0c, 0x00, /* 0000110000 */
2501 0x0c, 0x00, /* 0000110000 */
2502 0x0c, 0x00, /* 0000110000 */
2503 0x0c, 0x00, /* 0000110000 */
2504 0x0c, 0x00, /* 0000110000 */
2505 0x0c, 0x00, /* 0000110000 */
2506 0x0c, 0x00, /* 0000110000 */
2507 0x0c, 0x00, /* 0000110000 */
2508 0x0c, 0x00, /* 0000110000 */
2509 0x0c, 0x00, /* 0000110000 */
2510 0x00, 0x00, /* 0000000000 */
2511
2512 /* 125 0x7d '}' */
2513 0x38, 0x00, /* 0011100000 */
2514 0x0c, 0x00, /* 0000110000 */
2515 0x0c, 0x00, /* 0000110000 */
2516 0x0c, 0x00, /* 0000110000 */
2517 0x0c, 0x00, /* 0000110000 */
2518 0x0c, 0x00, /* 0000110000 */
2519 0x06, 0x00, /* 0000011000 */
2520 0x03, 0x80, /* 0000001110 */
2521 0x06, 0x00, /* 0000011000 */
2522 0x0c, 0x00, /* 0000110000 */
2523 0x0c, 0x00, /* 0000110000 */
2524 0x0c, 0x00, /* 0000110000 */
2525 0x0c, 0x00, /* 0000110000 */
2526 0x0c, 0x00, /* 0000110000 */
2527 0x38, 0x00, /* 0011100000 */
2528 0x00, 0x00, /* 0000000000 */
2529 0x00, 0x00, /* 0000000000 */
2530 0x00, 0x00, /* 0000000000 */
2531
2532 /* 126 0x7e '~' */
2533 0x00, 0x00, /* 0000000000 */
2534 0x18, 0x80, /* 0001100010 */
2535 0x3d, 0x80, /* 0011110110 */
2536 0x6f, 0x00, /* 0110111100 */
2537 0x46, 0x00, /* 0100011000 */
2538 0x00, 0x00, /* 0000000000 */
2539 0x00, 0x00, /* 0000000000 */
2540 0x00, 0x00, /* 0000000000 */
2541 0x00, 0x00, /* 0000000000 */
2542 0x00, 0x00, /* 0000000000 */
2543 0x00, 0x00, /* 0000000000 */
2544 0x00, 0x00, /* 0000000000 */
2545 0x00, 0x00, /* 0000000000 */
2546 0x00, 0x00, /* 0000000000 */
2547 0x00, 0x00, /* 0000000000 */
2548 0x00, 0x00, /* 0000000000 */
2549 0x00, 0x00, /* 0000000000 */
2550 0x00, 0x00, /* 0000000000 */
2551
2552 /* 127 0x7f '.' */
2553 0x00, 0x00, /* 0000000000 */
2554 0x00, 0x00, /* 0000000000 */
2555 0x00, 0x00, /* 0000000000 */
2556 0x00, 0x00, /* 0000000000 */
2557 0x00, 0x00, /* 0000000000 */
2558 0x00, 0x00, /* 0000000000 */
2559 0x00, 0x00, /* 0000000000 */
2560 0x00, 0x00, /* 0000000000 */
2561 0x0c, 0x00, /* 0000110000 */
2562 0x12, 0x00, /* 0001001000 */
2563 0x21, 0x00, /* 0010000100 */
2564 0x40, 0x80, /* 0100000010 */
2565 0x40, 0x80, /* 0100000010 */
2566 0x40, 0x80, /* 0100000010 */
2567 0x7f, 0x80, /* 0111111110 */
2568 0x00, 0x00, /* 0000000000 */
2569 0x00, 0x00, /* 0000000000 */
2570 0x00, 0x00, /* 0000000000 */
2571
2572 /* 128 0x80 '.' */
2573 0x00, 0x00, /* 0000000000 */
2574 0x1f, 0x00, /* 0001111100 */
2575 0x21, 0x80, /* 0010000110 */
2576 0x40, 0x80, /* 0100000010 */
2577 0x40, 0x00, /* 0100000000 */
2578 0x40, 0x00, /* 0100000000 */
2579 0x40, 0x00, /* 0100000000 */
2580 0x40, 0x00, /* 0100000000 */
2581 0x40, 0x00, /* 0100000000 */
2582 0x40, 0x00, /* 0100000000 */
2583 0x60, 0x80, /* 0110000010 */
2584 0x31, 0x00, /* 0011000100 */
2585 0x1e, 0x00, /* 0001111000 */
2586 0x08, 0x00, /* 0000100000 */
2587 0x04, 0x00, /* 0000010000 */
2588 0x02, 0x00, /* 0000001000 */
2589 0x02, 0x00, /* 0000001000 */
2590 0x1c, 0x00, /* 0001110000 */
2591
2592 /* 129 0x81 '.' */
2593 0x00, 0x00, /* 0000000000 */
2594 0x1b, 0x00, /* 0001101100 */
2595 0x1b, 0x00, /* 0001101100 */
2596 0x00, 0x00, /* 0000000000 */
2597 0x00, 0x00, /* 0000000000 */
2598 0x7b, 0x80, /* 0111101110 */
2599 0x31, 0x00, /* 0011000100 */
2600 0x31, 0x00, /* 0011000100 */
2601 0x31, 0x00, /* 0011000100 */
2602 0x31, 0x00, /* 0011000100 */
2603 0x31, 0x00, /* 0011000100 */
2604 0x31, 0x00, /* 0011000100 */
2605 0x31, 0x00, /* 0011000100 */
2606 0x3b, 0x00, /* 0011101100 */
2607 0x1c, 0x80, /* 0001110010 */
2608 0x00, 0x00, /* 0000000000 */
2609 0x00, 0x00, /* 0000000000 */
2610 0x00, 0x00, /* 0000000000 */
2611
2612 /* 130 0x82 '.' */
2613 0x00, 0x00, /* 0000000000 */
2614 0x01, 0x00, /* 0000000100 */
2615 0x02, 0x00, /* 0000001000 */
2616 0x04, 0x00, /* 0000010000 */
2617 0x00, 0x00, /* 0000000000 */
2618 0x0c, 0x00, /* 0000110000 */
2619 0x33, 0x00, /* 0011001100 */
2620 0x61, 0x80, /* 0110000110 */
2621 0x61, 0x80, /* 0110000110 */
2622 0x7f, 0x80, /* 0111111110 */
2623 0x60, 0x00, /* 0110000000 */
2624 0x60, 0x00, /* 0110000000 */
2625 0x30, 0x00, /* 0011000000 */
2626 0x19, 0x80, /* 0001100110 */
2627 0x0e, 0x00, /* 0000111000 */
2628 0x00, 0x00, /* 0000000000 */
2629 0x00, 0x00, /* 0000000000 */
2630 0x00, 0x00, /* 0000000000 */
2631
2632 /* 131 0x83 '.' */
2633 0x04, 0x00, /* 0000010000 */
2634 0x0e, 0x00, /* 0000111000 */
2635 0x1b, 0x00, /* 0001101100 */
2636 0x31, 0x80, /* 0011000110 */
2637 0x00, 0x00, /* 0000000000 */
2638 0x1f, 0x00, /* 0001111100 */
2639 0x31, 0x80, /* 0011000110 */
2640 0x21, 0x80, /* 0010000110 */
2641 0x07, 0x80, /* 0000011110 */
2642 0x39, 0x80, /* 0011100110 */
2643 0x61, 0x80, /* 0110000110 */
2644 0x61, 0x80, /* 0110000110 */
2645 0x61, 0x80, /* 0110000110 */
2646 0x73, 0x80, /* 0111001110 */
2647 0x3d, 0xc0, /* 0011110111 */
2648 0x00, 0x00, /* 0000000000 */
2649 0x00, 0x00, /* 0000000000 */
2650 0x00, 0x00, /* 0000000000 */
2651
2652 /* 132 0x84 '.' */
2653 0x00, 0x00, /* 0000000000 */
2654 0x1b, 0x00, /* 0001101100 */
2655 0x1b, 0x00, /* 0001101100 */
2656 0x00, 0x00, /* 0000000000 */
2657 0x00, 0x00, /* 0000000000 */
2658 0x1f, 0x00, /* 0001111100 */
2659 0x31, 0x80, /* 0011000110 */
2660 0x21, 0x80, /* 0010000110 */
2661 0x07, 0x80, /* 0000011110 */
2662 0x39, 0x80, /* 0011100110 */
2663 0x61, 0x80, /* 0110000110 */
2664 0x61, 0x80, /* 0110000110 */
2665 0x61, 0x80, /* 0110000110 */
2666 0x73, 0x80, /* 0111001110 */
2667 0x3d, 0xc0, /* 0011110111 */
2668 0x00, 0x00, /* 0000000000 */
2669 0x00, 0x00, /* 0000000000 */
2670 0x00, 0x00, /* 0000000000 */
2671
2672 /* 133 0x85 '.' */
2673 0x00, 0x00, /* 0000000000 */
2674 0x18, 0x00, /* 0001100000 */
2675 0x0c, 0x00, /* 0000110000 */
2676 0x06, 0x00, /* 0000011000 */
2677 0x00, 0x00, /* 0000000000 */
2678 0x1f, 0x00, /* 0001111100 */
2679 0x31, 0x80, /* 0011000110 */
2680 0x21, 0x80, /* 0010000110 */
2681 0x07, 0x80, /* 0000011110 */
2682 0x39, 0x80, /* 0011100110 */
2683 0x61, 0x80, /* 0110000110 */
2684 0x61, 0x80, /* 0110000110 */
2685 0x61, 0x80, /* 0110000110 */
2686 0x73, 0x80, /* 0111001110 */
2687 0x3d, 0xc0, /* 0011110111 */
2688 0x00, 0x00, /* 0000000000 */
2689 0x00, 0x00, /* 0000000000 */
2690 0x00, 0x00, /* 0000000000 */
2691
2692 /* 134 0x86 '.' */
2693 0x00, 0x00, /* 0000000000 */
2694 0x0e, 0x00, /* 0000111000 */
2695 0x1b, 0x00, /* 0001101100 */
2696 0x0e, 0x00, /* 0000111000 */
2697 0x00, 0x00, /* 0000000000 */
2698 0x1f, 0x00, /* 0001111100 */
2699 0x31, 0x80, /* 0011000110 */
2700 0x21, 0x80, /* 0010000110 */
2701 0x07, 0x80, /* 0000011110 */
2702 0x39, 0x80, /* 0011100110 */
2703 0x61, 0x80, /* 0110000110 */
2704 0x61, 0x80, /* 0110000110 */
2705 0x61, 0x80, /* 0110000110 */
2706 0x73, 0x80, /* 0111001110 */
2707 0x3d, 0xc0, /* 0011110111 */
2708 0x00, 0x00, /* 0000000000 */
2709 0x00, 0x00, /* 0000000000 */
2710 0x00, 0x00, /* 0000000000 */
2711
2712 /* 135 0x87 '.' */
2713 0x00, 0x00, /* 0000000000 */
2714 0x00, 0x00, /* 0000000000 */
2715 0x00, 0x00, /* 0000000000 */
2716 0x00, 0x00, /* 0000000000 */
2717 0x00, 0x00, /* 0000000000 */
2718 0x1f, 0x00, /* 0001111100 */
2719 0x31, 0x80, /* 0011000110 */
2720 0x20, 0x80, /* 0010000010 */
2721 0x60, 0x00, /* 0110000000 */
2722 0x60, 0x00, /* 0110000000 */
2723 0x60, 0x00, /* 0110000000 */
2724 0x70, 0x80, /* 0111000010 */
2725 0x30, 0x80, /* 0011000010 */
2726 0x1f, 0x00, /* 0001111100 */
2727 0x04, 0x00, /* 0000010000 */
2728 0x02, 0x00, /* 0000001000 */
2729 0x01, 0x00, /* 0000000100 */
2730 0x0e, 0x00, /* 0000111000 */
2731
2732 /* 136 0x88 '.' */
2733 0x04, 0x00, /* 0000010000 */
2734 0x0e, 0x00, /* 0000111000 */
2735 0x1b, 0x00, /* 0001101100 */
2736 0x31, 0x80, /* 0011000110 */
2737 0x00, 0x00, /* 0000000000 */
2738 0x0c, 0x00, /* 0000110000 */
2739 0x33, 0x00, /* 0011001100 */
2740 0x61, 0x80, /* 0110000110 */
2741 0x61, 0x80, /* 0110000110 */
2742 0x7f, 0x80, /* 0111111110 */
2743 0x60, 0x00, /* 0110000000 */
2744 0x60, 0x00, /* 0110000000 */
2745 0x30, 0x00, /* 0011000000 */
2746 0x19, 0x80, /* 0001100110 */
2747 0x0e, 0x00, /* 0000111000 */
2748 0x00, 0x00, /* 0000000000 */
2749 0x00, 0x00, /* 0000000000 */
2750 0x00, 0x00, /* 0000000000 */
2751
2752 /* 137 0x89 '.' */
2753 0x00, 0x00, /* 0000000000 */
2754 0x36, 0x00, /* 0011011000 */
2755 0x36, 0x00, /* 0011011000 */
2756 0x00, 0x00, /* 0000000000 */
2757 0x00, 0x00, /* 0000000000 */
2758 0x0c, 0x00, /* 0000110000 */
2759 0x33, 0x00, /* 0011001100 */
2760 0x61, 0x80, /* 0110000110 */
2761 0x61, 0x80, /* 0110000110 */
2762 0x7f, 0x80, /* 0111111110 */
2763 0x60, 0x00, /* 0110000000 */
2764 0x60, 0x00, /* 0110000000 */
2765 0x30, 0x00, /* 0011000000 */
2766 0x19, 0x80, /* 0001100110 */
2767 0x0e, 0x00, /* 0000111000 */
2768 0x00, 0x00, /* 0000000000 */
2769 0x00, 0x00, /* 0000000000 */
2770 0x00, 0x00, /* 0000000000 */
2771
2772 /* 138 0x8a '.' */
2773 0x00, 0x00, /* 0000000000 */
2774 0x30, 0x00, /* 0011000000 */
2775 0x18, 0x00, /* 0001100000 */
2776 0x0c, 0x00, /* 0000110000 */
2777 0x00, 0x00, /* 0000000000 */
2778 0x0c, 0x00, /* 0000110000 */
2779 0x33, 0x00, /* 0011001100 */
2780 0x61, 0x80, /* 0110000110 */
2781 0x61, 0x80, /* 0110000110 */
2782 0x7f, 0x80, /* 0111111110 */
2783 0x60, 0x00, /* 0110000000 */
2784 0x60, 0x00, /* 0110000000 */
2785 0x30, 0x00, /* 0011000000 */
2786 0x19, 0x80, /* 0001100110 */
2787 0x0e, 0x00, /* 0000111000 */
2788 0x00, 0x00, /* 0000000000 */
2789 0x00, 0x00, /* 0000000000 */
2790 0x00, 0x00, /* 0000000000 */
2791
2792 /* 139 0x8b '.' */
2793 0x00, 0x00, /* 0000000000 */
2794 0x36, 0x00, /* 0011011000 */
2795 0x36, 0x00, /* 0011011000 */
2796 0x00, 0x00, /* 0000000000 */
2797 0x00, 0x00, /* 0000000000 */
2798 0x3c, 0x00, /* 0011110000 */
2799 0x0c, 0x00, /* 0000110000 */
2800 0x0c, 0x00, /* 0000110000 */
2801 0x0c, 0x00, /* 0000110000 */
2802 0x0c, 0x00, /* 0000110000 */
2803 0x0c, 0x00, /* 0000110000 */
2804 0x0c, 0x00, /* 0000110000 */
2805 0x0c, 0x00, /* 0000110000 */
2806 0x0c, 0x00, /* 0000110000 */
2807 0x3f, 0x00, /* 0011111100 */
2808 0x00, 0x00, /* 0000000000 */
2809 0x00, 0x00, /* 0000000000 */
2810 0x00, 0x00, /* 0000000000 */
2811
2812 /* 140 0x8c '.' */
2813 0x08, 0x00, /* 0000100000 */
2814 0x1c, 0x00, /* 0001110000 */
2815 0x36, 0x00, /* 0011011000 */
2816 0x63, 0x00, /* 0110001100 */
2817 0x00, 0x00, /* 0000000000 */
2818 0x3c, 0x00, /* 0011110000 */
2819 0x0c, 0x00, /* 0000110000 */
2820 0x0c, 0x00, /* 0000110000 */
2821 0x0c, 0x00, /* 0000110000 */
2822 0x0c, 0x00, /* 0000110000 */
2823 0x0c, 0x00, /* 0000110000 */
2824 0x0c, 0x00, /* 0000110000 */
2825 0x0c, 0x00, /* 0000110000 */
2826 0x0c, 0x00, /* 0000110000 */
2827 0x3f, 0x00, /* 0011111100 */
2828 0x00, 0x00, /* 0000000000 */
2829 0x00, 0x00, /* 0000000000 */
2830 0x00, 0x00, /* 0000000000 */
2831
2832 /* 141 0x8d '.' */
2833 0x00, 0x00, /* 0000000000 */
2834 0x30, 0x00, /* 0011000000 */
2835 0x18, 0x00, /* 0001100000 */
2836 0x0c, 0x00, /* 0000110000 */
2837 0x00, 0x00, /* 0000000000 */
2838 0x3c, 0x00, /* 0011110000 */
2839 0x0c, 0x00, /* 0000110000 */
2840 0x0c, 0x00, /* 0000110000 */
2841 0x0c, 0x00, /* 0000110000 */
2842 0x0c, 0x00, /* 0000110000 */
2843 0x0c, 0x00, /* 0000110000 */
2844 0x0c, 0x00, /* 0000110000 */
2845 0x0c, 0x00, /* 0000110000 */
2846 0x0c, 0x00, /* 0000110000 */
2847 0x3f, 0x00, /* 0011111100 */
2848 0x00, 0x00, /* 0000000000 */
2849 0x00, 0x00, /* 0000000000 */
2850 0x00, 0x00, /* 0000000000 */
2851
2852 /* 142 0x8e '.' */
2853 0x31, 0x80, /* 0011000110 */
2854 0x31, 0x80, /* 0011000110 */
2855 0x04, 0x00, /* 0000010000 */
2856 0x04, 0x00, /* 0000010000 */
2857 0x0e, 0x00, /* 0000111000 */
2858 0x0e, 0x00, /* 0000111000 */
2859 0x0e, 0x00, /* 0000111000 */
2860 0x19, 0x00, /* 0001100100 */
2861 0x19, 0x00, /* 0001100100 */
2862 0x3f, 0x00, /* 0011111100 */
2863 0x31, 0x00, /* 0011000100 */
2864 0x31, 0x00, /* 0011000100 */
2865 0x60, 0x80, /* 0110000010 */
2866 0x60, 0x80, /* 0110000010 */
2867 0xf3, 0xc0, /* 1111001111 */
2868 0x00, 0x00, /* 0000000000 */
2869 0x00, 0x00, /* 0000000000 */
2870 0x00, 0x00, /* 0000000000 */
2871
2872 /* 143 0x8f '.' */
2873 0x04, 0x00, /* 0000010000 */
2874 0x0a, 0x00, /* 0000101000 */
2875 0x0a, 0x00, /* 0000101000 */
2876 0x04, 0x00, /* 0000010000 */
2877 0x0e, 0x00, /* 0000111000 */
2878 0x0e, 0x00, /* 0000111000 */
2879 0x0e, 0x00, /* 0000111000 */
2880 0x19, 0x00, /* 0001100100 */
2881 0x19, 0x00, /* 0001100100 */
2882 0x3f, 0x00, /* 0011111100 */
2883 0x31, 0x00, /* 0011000100 */
2884 0x31, 0x00, /* 0011000100 */
2885 0x60, 0x80, /* 0110000010 */
2886 0x60, 0x80, /* 0110000010 */
2887 0xf3, 0xc0, /* 1111001111 */
2888 0x00, 0x00, /* 0000000000 */
2889 0x00, 0x00, /* 0000000000 */
2890 0x00, 0x00, /* 0000000000 */
2891
2892 /* 144 0x90 '.' */
2893 0x03, 0x00, /* 0000001100 */
2894 0x06, 0x00, /* 0000011000 */
2895 0x0c, 0x00, /* 0000110000 */
2896 0x7f, 0x80, /* 0111111110 */
2897 0x30, 0x80, /* 0011000010 */
2898 0x30, 0x80, /* 0011000010 */
2899 0x30, 0x00, /* 0011000000 */
2900 0x31, 0x00, /* 0011000100 */
2901 0x3f, 0x00, /* 0011111100 */
2902 0x31, 0x00, /* 0011000100 */
2903 0x30, 0x00, /* 0011000000 */
2904 0x30, 0x00, /* 0011000000 */
2905 0x30, 0x80, /* 0011000010 */
2906 0x30, 0x80, /* 0011000010 */
2907 0x7f, 0x80, /* 0111111110 */
2908 0x00, 0x00, /* 0000000000 */
2909 0x00, 0x00, /* 0000000000 */
2910 0x00, 0x00, /* 0000000000 */
2911
2912 /* 145 0x91 '.' */
2913 0x00, 0x00, /* 0000000000 */
2914 0x00, 0x00, /* 0000000000 */
2915 0x00, 0x00, /* 0000000000 */
2916 0x00, 0x00, /* 0000000000 */
2917 0x00, 0x00, /* 0000000000 */
2918 0x3b, 0x80, /* 0011101110 */
2919 0x6c, 0xc0, /* 0110110011 */
2920 0x4c, 0xc0, /* 0100110011 */
2921 0x0c, 0xc0, /* 0000110011 */
2922 0x3f, 0xc0, /* 0011111111 */
2923 0x6c, 0x00, /* 0110110000 */
2924 0xcc, 0x00, /* 1100110000 */
2925 0xcc, 0x00, /* 1100110000 */
2926 0xee, 0xc0, /* 1110111011 */
2927 0x7b, 0x80, /* 0111101110 */
2928 0x00, 0x00, /* 0000000000 */
2929 0x00, 0x00, /* 0000000000 */
2930 0x00, 0x00, /* 0000000000 */
2931
2932 /* 146 0x92 '.' */
2933 0x00, 0x00, /* 0000000000 */
2934 0x07, 0xc0, /* 0000011111 */
2935 0x0e, 0x40, /* 0000111001 */
2936 0x0e, 0x40, /* 0000111001 */
2937 0x0e, 0x00, /* 0000111000 */
2938 0x16, 0x00, /* 0001011000 */
2939 0x16, 0x80, /* 0001011010 */
2940 0x17, 0x80, /* 0001011110 */
2941 0x16, 0x80, /* 0001011010 */
2942 0x3e, 0x00, /* 0011111000 */
2943 0x26, 0x00, /* 0010011000 */
2944 0x26, 0x00, /* 0010011000 */
2945 0x46, 0x40, /* 0100011001 */
2946 0x46, 0x40, /* 0100011001 */
2947 0xef, 0xc0, /* 1110111111 */
2948 0x00, 0x00, /* 0000000000 */
2949 0x00, 0x00, /* 0000000000 */
2950 0x00, 0x00, /* 0000000000 */
2951
2952 /* 147 0x93 '.' */
2953 0x00, 0x00, /* 0000000000 */
2954 0x08, 0x00, /* 0000100000 */
2955 0x1c, 0x00, /* 0001110000 */
2956 0x36, 0x00, /* 0011011000 */
2957 0x00, 0x00, /* 0000000000 */
2958 0x3c, 0x00, /* 0011110000 */
2959 0x66, 0x00, /* 0110011000 */
2960 0xc3, 0x00, /* 1100001100 */
2961 0xc1, 0x80, /* 1100000110 */
2962 0xc1, 0x80, /* 1100000110 */
2963 0xc1, 0x80, /* 1100000110 */
2964 0xc1, 0x80, /* 1100000110 */
2965 0xe1, 0x80, /* 1110000110 */
2966 0x73, 0x00, /* 0111001100 */
2967 0x3c, 0x00, /* 0011110000 */
2968 0x00, 0x00, /* 0000000000 */
2969 0x00, 0x00, /* 0000000000 */
2970 0x00, 0x00, /* 0000000000 */
2971
2972 /* 148 0x94 '.' */
2973 0x00, 0x00, /* 0000000000 */
2974 0x00, 0x00, /* 0000000000 */
2975 0x33, 0x00, /* 0011001100 */
2976 0x33, 0x00, /* 0011001100 */
2977 0x00, 0x00, /* 0000000000 */
2978 0x3c, 0x00, /* 0011110000 */
2979 0x66, 0x00, /* 0110011000 */
2980 0xc3, 0x00, /* 1100001100 */
2981 0xc1, 0x80, /* 1100000110 */
2982 0xc1, 0x80, /* 1100000110 */
2983 0xc1, 0x80, /* 1100000110 */
2984 0xc1, 0x80, /* 1100000110 */
2985 0xe1, 0x80, /* 1110000110 */
2986 0x73, 0x00, /* 0111001100 */
2987 0x3c, 0x00, /* 0011110000 */
2988 0x00, 0x00, /* 0000000000 */
2989 0x00, 0x00, /* 0000000000 */
2990 0x00, 0x00, /* 0000000000 */
2991
2992 /* 149 0x95 '.' */
2993 0x00, 0x00, /* 0000000000 */
2994 0x18, 0x00, /* 0001100000 */
2995 0x0c, 0x00, /* 0000110000 */
2996 0x06, 0x00, /* 0000011000 */
2997 0x00, 0x00, /* 0000000000 */
2998 0x3c, 0x00, /* 0011110000 */
2999 0x66, 0x00, /* 0110011000 */
3000 0xc3, 0x00, /* 1100001100 */
3001 0xc1, 0x80, /* 1100000110 */
3002 0xc1, 0x80, /* 1100000110 */
3003 0xc1, 0x80, /* 1100000110 */
3004 0xc1, 0x80, /* 1100000110 */
3005 0xe1, 0x80, /* 1110000110 */
3006 0x73, 0x00, /* 0111001100 */
3007 0x3c, 0x00, /* 0011110000 */
3008 0x00, 0x00, /* 0000000000 */
3009 0x00, 0x00, /* 0000000000 */
3010 0x00, 0x00, /* 0000000000 */
3011
3012 /* 150 0x96 '.' */
3013 0x08, 0x00, /* 0000100000 */
3014 0x1c, 0x00, /* 0001110000 */
3015 0x36, 0x00, /* 0011011000 */
3016 0x63, 0x00, /* 0110001100 */
3017 0x00, 0x00, /* 0000000000 */
3018 0xf7, 0x80, /* 1111011110 */
3019 0x63, 0x00, /* 0110001100 */
3020 0x63, 0x00, /* 0110001100 */
3021 0x63, 0x00, /* 0110001100 */
3022 0x63, 0x00, /* 0110001100 */
3023 0x63, 0x00, /* 0110001100 */
3024 0x63, 0x00, /* 0110001100 */
3025 0x63, 0x00, /* 0110001100 */
3026 0x77, 0x00, /* 0111011100 */
3027 0x3d, 0x80, /* 0011110110 */
3028 0x00, 0x00, /* 0000000000 */
3029 0x00, 0x00, /* 0000000000 */
3030 0x00, 0x00, /* 0000000000 */
3031
3032 /* 151 0x97 '.' */
3033 0x00, 0x00, /* 0000000000 */
3034 0x60, 0x00, /* 0110000000 */
3035 0x30, 0x00, /* 0011000000 */
3036 0x18, 0x00, /* 0001100000 */
3037 0x00, 0x00, /* 0000000000 */
3038 0xf7, 0x80, /* 1111011110 */
3039 0x63, 0x00, /* 0110001100 */
3040 0x63, 0x00, /* 0110001100 */
3041 0x63, 0x00, /* 0110001100 */
3042 0x63, 0x00, /* 0110001100 */
3043 0x63, 0x00, /* 0110001100 */
3044 0x63, 0x00, /* 0110001100 */
3045 0x63, 0x00, /* 0110001100 */
3046 0x77, 0x00, /* 0111011100 */
3047 0x3d, 0x80, /* 0011110110 */
3048 0x00, 0x00, /* 0000000000 */
3049 0x00, 0x00, /* 0000000000 */
3050 0x00, 0x00, /* 0000000000 */
3051
3052 /* 152 0x98 '.' */
3053 0x00, 0x00, /* 0000000000 */
3054 0x33, 0x00, /* 0011001100 */
3055 0x33, 0x00, /* 0011001100 */
3056 0x00, 0x00, /* 0000000000 */
3057 0x00, 0x00, /* 0000000000 */
3058 0xf3, 0xc0, /* 1111001111 */
3059 0x61, 0x80, /* 0110000110 */
3060 0x33, 0x00, /* 0011001100 */
3061 0x1b, 0x00, /* 0001101100 */
3062 0x1e, 0x00, /* 0001111000 */
3063 0x0e, 0x00, /* 0000111000 */
3064 0x0c, 0x00, /* 0000110000 */
3065 0x0c, 0x00, /* 0000110000 */
3066 0x0c, 0x00, /* 0000110000 */
3067 0x0c, 0x00, /* 0000110000 */
3068 0x18, 0x00, /* 0001100000 */
3069 0x78, 0x00, /* 0111100000 */
3070 0x70, 0x00, /* 0111000000 */
3071
3072 /* 153 0x99 '.' */
3073 0x61, 0x80, /* 0110000110 */
3074 0x61, 0x80, /* 0110000110 */
3075 0x0c, 0x00, /* 0000110000 */
3076 0x17, 0x00, /* 0001011100 */
3077 0x23, 0x00, /* 0010001100 */
3078 0x21, 0x80, /* 0010000110 */
3079 0x61, 0x80, /* 0110000110 */
3080 0x61, 0x80, /* 0110000110 */
3081 0x61, 0x80, /* 0110000110 */
3082 0x61, 0x80, /* 0110000110 */
3083 0x61, 0x80, /* 0110000110 */
3084 0x21, 0x00, /* 0010000100 */
3085 0x31, 0x00, /* 0011000100 */
3086 0x1a, 0x00, /* 0001101000 */
3087 0x0c, 0x00, /* 0000110000 */
3088 0x00, 0x00, /* 0000000000 */
3089 0x00, 0x00, /* 0000000000 */
3090 0x00, 0x00, /* 0000000000 */
3091
3092 /* 154 0x9a '.' */
3093 0x33, 0x00, /* 0011001100 */
3094 0x33, 0x00, /* 0011001100 */
3095 0x00, 0x00, /* 0000000000 */
3096 0xf1, 0xc0, /* 1111000111 */
3097 0x60, 0x80, /* 0110000010 */
3098 0x60, 0x80, /* 0110000010 */
3099 0x60, 0x80, /* 0110000010 */
3100 0x60, 0x80, /* 0110000010 */
3101 0x60, 0x80, /* 0110000010 */
3102 0x60, 0x80, /* 0110000010 */
3103 0x60, 0x80, /* 0110000010 */
3104 0x60, 0x80, /* 0110000010 */
3105 0x71, 0x00, /* 0111000100 */
3106 0x3f, 0x00, /* 0011111100 */
3107 0x1e, 0x00, /* 0001111000 */
3108 0x00, 0x00, /* 0000000000 */
3109 0x00, 0x00, /* 0000000000 */
3110 0x00, 0x00, /* 0000000000 */
3111
3112 /* 155 0x9b '.' */
3113 0x00, 0x00, /* 0000000000 */
3114 0x00, 0x00, /* 0000000000 */
3115 0x00, 0x00, /* 0000000000 */
3116 0x06, 0x00, /* 0000011000 */
3117 0x06, 0x00, /* 0000011000 */
3118 0x1f, 0x80, /* 0001111110 */
3119 0x36, 0x80, /* 0011011010 */
3120 0x26, 0x00, /* 0010011000 */
3121 0x66, 0x00, /* 0110011000 */
3122 0x66, 0x00, /* 0110011000 */
3123 0x66, 0x00, /* 0110011000 */
3124 0x66, 0x00, /* 0110011000 */
3125 0x76, 0x00, /* 0111011000 */
3126 0x36, 0x80, /* 0011011010 */
3127 0x1f, 0x80, /* 0001111110 */
3128 0x06, 0x00, /* 0000011000 */
3129 0x06, 0x00, /* 0000011000 */
3130 0x00, 0x00, /* 0000000000 */
3131
3132 /* 156 0x9c '.' */
3133 0x00, 0x00, /* 0000000000 */
3134 0x1e, 0x00, /* 0001111000 */
3135 0x3b, 0x00, /* 0011101100 */
3136 0x33, 0x00, /* 0011001100 */
3137 0x30, 0x00, /* 0011000000 */
3138 0x30, 0x00, /* 0011000000 */
3139 0x30, 0x00, /* 0011000000 */
3140 0x7e, 0x00, /* 0111111000 */
3141 0x7e, 0x00, /* 0111111000 */
3142 0x30, 0x00, /* 0011000000 */
3143 0x30, 0x00, /* 0011000000 */
3144 0x30, 0x00, /* 0011000000 */
3145 0x30, 0x00, /* 0011000000 */
3146 0x7c, 0x80, /* 0111110010 */
3147 0x7f, 0x80, /* 0111111110 */
3148 0x43, 0x00, /* 0100001100 */
3149 0x00, 0x00, /* 0000000000 */
3150 0x00, 0x00, /* 0000000000 */
3151
3152 /* 157 0x9d '.' */
3153 0x00, 0x00, /* 0000000000 */
3154 0x40, 0x80, /* 0100000010 */
3155 0x40, 0x80, /* 0100000010 */
3156 0x21, 0x00, /* 0010000100 */
3157 0x33, 0x00, /* 0011001100 */
3158 0x33, 0x00, /* 0011001100 */
3159 0x1e, 0x00, /* 0001111000 */
3160 0x0c, 0x00, /* 0000110000 */
3161 0x3f, 0x00, /* 0011111100 */
3162 0x0c, 0x00, /* 0000110000 */
3163 0x3f, 0x00, /* 0011111100 */
3164 0x0c, 0x00, /* 0000110000 */
3165 0x0c, 0x00, /* 0000110000 */
3166 0x0c, 0x00, /* 0000110000 */
3167 0x0c, 0x00, /* 0000110000 */
3168 0x00, 0x00, /* 0000000000 */
3169 0x00, 0x00, /* 0000000000 */
3170 0x00, 0x00, /* 0000000000 */
3171
3172 /* 158 0x9e '.' */
3173 0x00, 0x00, /* 0000000000 */
3174 0xbf, 0x00, /* 1011111100 */
3175 0x40, 0x80, /* 0100000010 */
3176 0x40, 0x80, /* 0100000010 */
3177 0x7f, 0x00, /* 0111111100 */
3178 0x40, 0x00, /* 0100000000 */
3179 0x48, 0x00, /* 0100100000 */
3180 0x48, 0x00, /* 0100100000 */
3181 0x5e, 0x00, /* 0101111000 */
3182 0x48, 0x00, /* 0100100000 */
3183 0x48, 0x00, /* 0100100000 */
3184 0x48, 0x00, /* 0100100000 */
3185 0x48, 0x80, /* 0100100010 */
3186 0x47, 0x00, /* 0100011100 */
3187 0xe0, 0x00, /* 1110000000 */
3188 0x00, 0x00, /* 0000000000 */
3189 0x00, 0x00, /* 0000000000 */
3190 0x00, 0x00, /* 0000000000 */
3191
3192 /* 159 0x9f '.' */
3193 0x00, 0x00, /* 0000000000 */
3194 0x03, 0x00, /* 0000001100 */
3195 0x04, 0x80, /* 0000010010 */
3196 0x08, 0x00, /* 0000100000 */
3197 0x08, 0x00, /* 0000100000 */
3198 0x08, 0x00, /* 0000100000 */
3199 0x08, 0x00, /* 0000100000 */
3200 0x09, 0x00, /* 0000100100 */
3201 0x3e, 0x00, /* 0011111000 */
3202 0x48, 0x00, /* 0100100000 */
3203 0x08, 0x00, /* 0000100000 */
3204 0x08, 0x00, /* 0000100000 */
3205 0x08, 0x00, /* 0000100000 */
3206 0x08, 0x00, /* 0000100000 */
3207 0x08, 0x00, /* 0000100000 */
3208 0x90, 0x00, /* 1001000000 */
3209 0x60, 0x00, /* 0110000000 */
3210 0x00, 0x00, /* 0000000000 */
3211
3212 /* 160 0xa0 '.' */
3213 0x00, 0x00, /* 0000000000 */
3214 0x03, 0x00, /* 0000001100 */
3215 0x06, 0x00, /* 0000011000 */
3216 0x0c, 0x00, /* 0000110000 */
3217 0x00, 0x00, /* 0000000000 */
3218 0x1f, 0x00, /* 0001111100 */
3219 0x31, 0x80, /* 0011000110 */
3220 0x21, 0x80, /* 0010000110 */
3221 0x07, 0x80, /* 0000011110 */
3222 0x39, 0x80, /* 0011100110 */
3223 0x61, 0x80, /* 0110000110 */
3224 0x61, 0x80, /* 0110000110 */
3225 0x61, 0x80, /* 0110000110 */
3226 0x73, 0x80, /* 0111001110 */
3227 0x3d, 0xc0, /* 0011110111 */
3228 0x00, 0x00, /* 0000000000 */
3229 0x00, 0x00, /* 0000000000 */
3230 0x00, 0x00, /* 0000000000 */
3231
3232 /* 161 0xa1 '.' */
3233 0x00, 0x00, /* 0000000000 */
3234 0x03, 0x00, /* 0000001100 */
3235 0x06, 0x00, /* 0000011000 */
3236 0x0c, 0x00, /* 0000110000 */
3237 0x00, 0x00, /* 0000000000 */
3238 0x3c, 0x00, /* 0011110000 */
3239 0x0c, 0x00, /* 0000110000 */
3240 0x0c, 0x00, /* 0000110000 */
3241 0x0c, 0x00, /* 0000110000 */
3242 0x0c, 0x00, /* 0000110000 */
3243 0x0c, 0x00, /* 0000110000 */
3244 0x0c, 0x00, /* 0000110000 */
3245 0x0c, 0x00, /* 0000110000 */
3246 0x0c, 0x00, /* 0000110000 */
3247 0x3f, 0x00, /* 0011111100 */
3248 0x00, 0x00, /* 0000000000 */
3249 0x00, 0x00, /* 0000000000 */
3250 0x00, 0x00, /* 0000000000 */
3251
3252 /* 162 0xa2 '.' */
3253 0x00, 0x00, /* 0000000000 */
3254 0x06, 0x00, /* 0000011000 */
3255 0x0c, 0x00, /* 0000110000 */
3256 0x18, 0x00, /* 0001100000 */
3257 0x00, 0x00, /* 0000000000 */
3258 0x3c, 0x00, /* 0011110000 */
3259 0x66, 0x00, /* 0110011000 */
3260 0xc3, 0x00, /* 1100001100 */
3261 0xc1, 0x80, /* 1100000110 */
3262 0xc1, 0x80, /* 1100000110 */
3263 0xc1, 0x80, /* 1100000110 */
3264 0xc1, 0x80, /* 1100000110 */
3265 0xe1, 0x80, /* 1110000110 */
3266 0x73, 0x00, /* 0111001100 */
3267 0x3c, 0x00, /* 0011110000 */
3268 0x00, 0x00, /* 0000000000 */
3269 0x00, 0x00, /* 0000000000 */
3270 0x00, 0x00, /* 0000000000 */
3271
3272 /* 163 0xa3 '.' */
3273 0x00, 0x00, /* 0000000000 */
3274 0x06, 0x00, /* 0000011000 */
3275 0x0c, 0x00, /* 0000110000 */
3276 0x18, 0x00, /* 0001100000 */
3277 0x00, 0x00, /* 0000000000 */
3278 0xf7, 0x80, /* 1111011110 */
3279 0x63, 0x00, /* 0110001100 */
3280 0x63, 0x00, /* 0110001100 */
3281 0x63, 0x00, /* 0110001100 */
3282 0x63, 0x00, /* 0110001100 */
3283 0x63, 0x00, /* 0110001100 */
3284 0x63, 0x00, /* 0110001100 */
3285 0x63, 0x00, /* 0110001100 */
3286 0x77, 0x00, /* 0111011100 */
3287 0x3d, 0x80, /* 0011110110 */
3288 0x00, 0x00, /* 0000000000 */
3289 0x00, 0x00, /* 0000000000 */
3290 0x00, 0x00, /* 0000000000 */
3291
3292 /* 164 0xa4 '.' */
3293 0x00, 0x00, /* 0000000000 */
3294 0x38, 0x80, /* 0011100010 */
3295 0x7f, 0x80, /* 0111111110 */
3296 0x47, 0x00, /* 0100011100 */
3297 0x00, 0x00, /* 0000000000 */
3298 0x6f, 0x00, /* 0110111100 */
3299 0x7b, 0x80, /* 0111101110 */
3300 0x31, 0x80, /* 0011000110 */
3301 0x31, 0x80, /* 0011000110 */
3302 0x31, 0x80, /* 0011000110 */
3303 0x31, 0x80, /* 0011000110 */
3304 0x31, 0x80, /* 0011000110 */
3305 0x31, 0x80, /* 0011000110 */
3306 0x31, 0x80, /* 0011000110 */
3307 0x7b, 0xc0, /* 0111101111 */
3308 0x00, 0x00, /* 0000000000 */
3309 0x00, 0x00, /* 0000000000 */
3310 0x00, 0x00, /* 0000000000 */
3311
3312 /* 165 0xa5 '.' */
3313 0x00, 0x00, /* 0000000000 */
3314 0x38, 0x80, /* 0011100010 */
3315 0x7f, 0x80, /* 0111111110 */
3316 0x47, 0x00, /* 0100011100 */
3317 0x00, 0x00, /* 0000000000 */
3318 0xe3, 0xc0, /* 1110001111 */
3319 0x71, 0x80, /* 0111000110 */
3320 0x79, 0x80, /* 0111100110 */
3321 0x79, 0x80, /* 0111100110 */
3322 0x6d, 0x80, /* 0110110110 */
3323 0x6d, 0x80, /* 0110110110 */
3324 0x67, 0x80, /* 0110011110 */
3325 0x63, 0x80, /* 0110001110 */
3326 0x61, 0x80, /* 0110000110 */
3327 0xf0, 0xc0, /* 1111000011 */
3328 0x00, 0x00, /* 0000000000 */
3329 0x00, 0x00, /* 0000000000 */
3330 0x00, 0x00, /* 0000000000 */
3331
3332 /* 166 0xa6 '.' */
3333 0x00, 0x00, /* 0000000000 */
3334 0x3e, 0x00, /* 0011111000 */
3335 0x63, 0x00, /* 0110001100 */
3336 0x03, 0x00, /* 0000001100 */
3337 0x0f, 0x00, /* 0000111100 */
3338 0x33, 0x00, /* 0011001100 */
3339 0x63, 0x00, /* 0110001100 */
3340 0x63, 0x00, /* 0110001100 */
3341 0x67, 0x00, /* 0110011100 */
3342 0x3b, 0x80, /* 0011101110 */
3343 0x00, 0x00, /* 0000000000 */
3344 0x7f, 0x80, /* 0111111110 */
3345 0x00, 0x00, /* 0000000000 */
3346 0x00, 0x00, /* 0000000000 */
3347 0x00, 0x00, /* 0000000000 */
3348 0x00, 0x00, /* 0000000000 */
3349 0x00, 0x00, /* 0000000000 */
3350 0x00, 0x00, /* 0000000000 */
3351
3352 /* 167 0xa7 '.' */
3353 0x00, 0x00, /* 0000000000 */
3354 0x0e, 0x00, /* 0000111000 */
3355 0x33, 0x00, /* 0011001100 */
3356 0x21, 0x80, /* 0010000110 */
3357 0x61, 0x80, /* 0110000110 */
3358 0x61, 0x80, /* 0110000110 */
3359 0x61, 0x80, /* 0110000110 */
3360 0x61, 0x00, /* 0110000100 */
3361 0x33, 0x00, /* 0011001100 */
3362 0x1c, 0x00, /* 0001110000 */
3363 0x00, 0x00, /* 0000000000 */
3364 0x7f, 0x80, /* 0111111110 */
3365 0x00, 0x00, /* 0000000000 */
3366 0x00, 0x00, /* 0000000000 */
3367 0x00, 0x00, /* 0000000000 */
3368 0x00, 0x00, /* 0000000000 */
3369 0x00, 0x00, /* 0000000000 */
3370 0x00, 0x00, /* 0000000000 */
3371
3372 /* 168 0xa8 '.' */
3373 0x00, 0x00, /* 0000000000 */
3374 0x06, 0x00, /* 0000011000 */
3375 0x06, 0x00, /* 0000011000 */
3376 0x00, 0x00, /* 0000000000 */
3377 0x06, 0x00, /* 0000011000 */
3378 0x06, 0x00, /* 0000011000 */
3379 0x0c, 0x00, /* 0000110000 */
3380 0x18, 0x00, /* 0001100000 */
3381 0x30, 0x00, /* 0011000000 */
3382 0x60, 0x00, /* 0110000000 */
3383 0x60, 0x00, /* 0110000000 */
3384 0x60, 0x80, /* 0110000010 */
3385 0x73, 0x80, /* 0111001110 */
3386 0x3f, 0x00, /* 0011111100 */
3387 0x1e, 0x00, /* 0001111000 */
3388 0x00, 0x00, /* 0000000000 */
3389 0x00, 0x00, /* 0000000000 */
3390 0x00, 0x00, /* 0000000000 */
3391
3392 /* 169 0xa9 '.' */
3393 0x00, 0x00, /* 0000000000 */
3394 0x00, 0x00, /* 0000000000 */
3395 0x00, 0x00, /* 0000000000 */
3396 0x00, 0x00, /* 0000000000 */
3397 0x00, 0x00, /* 0000000000 */
3398 0x00, 0x00, /* 0000000000 */
3399 0x00, 0x00, /* 0000000000 */
3400 0x00, 0x00, /* 0000000000 */
3401 0x7f, 0x80, /* 0111111110 */
3402 0x7f, 0x80, /* 0111111110 */
3403 0x60, 0x00, /* 0110000000 */
3404 0x60, 0x00, /* 0110000000 */
3405 0x60, 0x00, /* 0110000000 */
3406 0x00, 0x00, /* 0000000000 */
3407 0x00, 0x00, /* 0000000000 */
3408 0x00, 0x00, /* 0000000000 */
3409 0x00, 0x00, /* 0000000000 */
3410 0x00, 0x00, /* 0000000000 */
3411
3412 /* 170 0xaa '.' */
3413 0x00, 0x00, /* 0000000000 */
3414 0x00, 0x00, /* 0000000000 */
3415 0x00, 0x00, /* 0000000000 */
3416 0x00, 0x00, /* 0000000000 */
3417 0x00, 0x00, /* 0000000000 */
3418 0x00, 0x00, /* 0000000000 */
3419 0x00, 0x00, /* 0000000000 */
3420 0x00, 0x00, /* 0000000000 */
3421 0x7f, 0x80, /* 0111111110 */
3422 0x7f, 0x80, /* 0111111110 */
3423 0x01, 0x80, /* 0000000110 */
3424 0x01, 0x80, /* 0000000110 */
3425 0x01, 0x80, /* 0000000110 */
3426 0x00, 0x00, /* 0000000000 */
3427 0x00, 0x00, /* 0000000000 */
3428 0x00, 0x00, /* 0000000000 */
3429 0x00, 0x00, /* 0000000000 */
3430 0x00, 0x00, /* 0000000000 */
3431
3432 /* 171 0xab '.' */
3433 0x00, 0x00, /* 0000000000 */
3434 0x20, 0x00, /* 0010000000 */
3435 0x60, 0x00, /* 0110000000 */
3436 0x20, 0x00, /* 0010000000 */
3437 0x20, 0x80, /* 0010000010 */
3438 0x21, 0x00, /* 0010000100 */
3439 0x22, 0x00, /* 0010001000 */
3440 0x74, 0x00, /* 0111010000 */
3441 0x08, 0x00, /* 0000100000 */
3442 0x17, 0x00, /* 0001011100 */
3443 0x28, 0x80, /* 0010100010 */
3444 0x43, 0x00, /* 0100001100 */
3445 0x04, 0x00, /* 0000010000 */
3446 0x08, 0x00, /* 0000100000 */
3447 0x0f, 0x80, /* 0000111110 */
3448 0x00, 0x00, /* 0000000000 */
3449 0x00, 0x00, /* 0000000000 */
3450 0x00, 0x00, /* 0000000000 */
3451
3452 /* 172 0xac '.' */
3453 0x00, 0x00, /* 0000000000 */
3454 0x20, 0x00, /* 0010000000 */
3455 0x60, 0x00, /* 0110000000 */
3456 0x20, 0x00, /* 0010000000 */
3457 0x20, 0x80, /* 0010000010 */
3458 0x21, 0x00, /* 0010000100 */
3459 0x22, 0x00, /* 0010001000 */
3460 0x74, 0x00, /* 0111010000 */
3461 0x09, 0x00, /* 0000100100 */
3462 0x13, 0x00, /* 0001001100 */
3463 0x25, 0x00, /* 0010010100 */
3464 0x49, 0x00, /* 0100100100 */
3465 0x1f, 0x80, /* 0001111110 */
3466 0x01, 0x00, /* 0000000100 */
3467 0x01, 0x00, /* 0000000100 */
3468 0x00, 0x00, /* 0000000000 */
3469 0x00, 0x00, /* 0000000000 */
3470 0x00, 0x00, /* 0000000000 */
3471
3472 /* 173 0xad '.' */
3473 0x00, 0x00, /* 0000000000 */
3474 0x0c, 0x00, /* 0000110000 */
3475 0x0c, 0x00, /* 0000110000 */
3476 0x00, 0x00, /* 0000000000 */
3477 0x0c, 0x00, /* 0000110000 */
3478 0x0c, 0x00, /* 0000110000 */
3479 0x0c, 0x00, /* 0000110000 */
3480 0x0c, 0x00, /* 0000110000 */
3481 0x0c, 0x00, /* 0000110000 */
3482 0x0c, 0x00, /* 0000110000 */
3483 0x0c, 0x00, /* 0000110000 */
3484 0x0c, 0x00, /* 0000110000 */
3485 0x0c, 0x00, /* 0000110000 */
3486 0x0c, 0x00, /* 0000110000 */
3487 0x0c, 0x00, /* 0000110000 */
3488 0x00, 0x00, /* 0000000000 */
3489 0x00, 0x00, /* 0000000000 */
3490 0x00, 0x00, /* 0000000000 */
3491
3492 /* 174 0xae '.' */
3493 0x00, 0x00, /* 0000000000 */
3494 0x00, 0x00, /* 0000000000 */
3495 0x00, 0x00, /* 0000000000 */
3496 0x00, 0x00, /* 0000000000 */
3497 0x00, 0x00, /* 0000000000 */
3498 0x0d, 0x80, /* 0000110110 */
3499 0x1b, 0x00, /* 0001101100 */
3500 0x36, 0x00, /* 0011011000 */
3501 0x6c, 0x00, /* 0110110000 */
3502 0xd8, 0x00, /* 1101100000 */
3503 0x6c, 0x00, /* 0110110000 */
3504 0x36, 0x00, /* 0011011000 */
3505 0x1b, 0x00, /* 0001101100 */
3506 0x0d, 0x80, /* 0000110110 */
3507 0x00, 0x00, /* 0000000000 */
3508 0x00, 0x00, /* 0000000000 */
3509 0x00, 0x00, /* 0000000000 */
3510 0x00, 0x00, /* 0000000000 */
3511
3512 /* 175 0xaf '.' */
3513 0x00, 0x00, /* 0000000000 */
3514 0x00, 0x00, /* 0000000000 */
3515 0x00, 0x00, /* 0000000000 */
3516 0x00, 0x00, /* 0000000000 */
3517 0x00, 0x00, /* 0000000000 */
3518 0x6c, 0x00, /* 0110110000 */
3519 0x36, 0x00, /* 0011011000 */
3520 0x1b, 0x00, /* 0001101100 */
3521 0x0d, 0x80, /* 0000110110 */
3522 0x06, 0xc0, /* 0000011011 */
3523 0x0d, 0x80, /* 0000110110 */
3524 0x1b, 0x00, /* 0001101100 */
3525 0x36, 0x00, /* 0011011000 */
3526 0x6c, 0x00, /* 0110110000 */
3527 0x00, 0x00, /* 0000000000 */
3528 0x00, 0x00, /* 0000000000 */
3529 0x00, 0x00, /* 0000000000 */
3530 0x00, 0x00, /* 0000000000 */
3531
3532 /* 176 0xb0 '.' */
3533 0xc3, 0x00, /* 1100001100 */
3534 0x41, 0x00, /* 0100000100 */
3535 0x18, 0x40, /* 0001100001 */
3536 0x10, 0x40, /* 0001000001 */
3537 0xc3, 0x00, /* 1100001100 */
3538 0x41, 0x00, /* 0100000100 */
3539 0x18, 0x40, /* 0001100001 */
3540 0x10, 0x40, /* 0001000001 */
3541 0xc3, 0x00, /* 1100001100 */
3542 0x41, 0x00, /* 0100000100 */
3543 0x18, 0x40, /* 0001100001 */
3544 0x10, 0x40, /* 0001000001 */
3545 0xc3, 0x00, /* 1100001100 */
3546 0x41, 0x00, /* 0100000100 */
3547 0x18, 0x40, /* 0001100001 */
3548 0x10, 0x40, /* 0001000001 */
3549 0xc3, 0x00, /* 1100001100 */
3550 0x41, 0x00, /* 0100000100 */
3551
3552 /* 177 0xb1 '.' */
3553 0x11, 0x00, /* 0001000100 */
3554 0xbb, 0x80, /* 1011101110 */
3555 0x11, 0x00, /* 0001000100 */
3556 0x44, 0x40, /* 0100010001 */
3557 0xee, 0xc0, /* 1110111011 */
3558 0x44, 0x40, /* 0100010001 */
3559 0x11, 0x00, /* 0001000100 */
3560 0xbb, 0x80, /* 1011101110 */
3561 0x11, 0x00, /* 0001000100 */
3562 0x44, 0x40, /* 0100010001 */
3563 0xee, 0xc0, /* 1110111011 */
3564 0x44, 0x40, /* 0100010001 */
3565 0x11, 0x00, /* 0001000100 */
3566 0xbb, 0x80, /* 1011101110 */
3567 0x11, 0x00, /* 0001000100 */
3568 0x44, 0x40, /* 0100010001 */
3569 0xee, 0xc0, /* 1110111011 */
3570 0x44, 0x40, /* 0100010001 */
3571
3572 /* 178 0xb2 '.' */
3573 0x3c, 0xc0, /* 0011110011 */
3574 0xbe, 0xc0, /* 1011111011 */
3575 0xe7, 0x80, /* 1110011110 */
3576 0xef, 0x80, /* 1110111110 */
3577 0x3c, 0xc0, /* 0011110011 */
3578 0xbe, 0xc0, /* 1011111011 */
3579 0xe7, 0x80, /* 1110011110 */
3580 0xef, 0x80, /* 1110111110 */
3581 0x3c, 0xc0, /* 0011110011 */
3582 0xbe, 0xc0, /* 1011111011 */
3583 0xe7, 0x80, /* 1110011110 */
3584 0xef, 0x80, /* 1110111110 */
3585 0x3c, 0xc0, /* 0011110011 */
3586 0xbe, 0xc0, /* 1011111011 */
3587 0xe7, 0x80, /* 1110011110 */
3588 0xef, 0x80, /* 1110111110 */
3589 0x3c, 0xc0, /* 0011110011 */
3590 0xbe, 0xc0, /* 1011111011 */
3591
3592 /* 179 0xb3 '.' */
3593 0x0c, 0x00, /* 0000110000 */
3594 0x0c, 0x00, /* 0000110000 */
3595 0x0c, 0x00, /* 0000110000 */
3596 0x0c, 0x00, /* 0000110000 */
3597 0x0c, 0x00, /* 0000110000 */
3598 0x0c, 0x00, /* 0000110000 */
3599 0x0c, 0x00, /* 0000110000 */
3600 0x0c, 0x00, /* 0000110000 */
3601 0x0c, 0x00, /* 0000110000 */
3602 0x0c, 0x00, /* 0000110000 */
3603 0x0c, 0x00, /* 0000110000 */
3604 0x0c, 0x00, /* 0000110000 */
3605 0x0c, 0x00, /* 0000110000 */
3606 0x0c, 0x00, /* 0000110000 */
3607 0x0c, 0x00, /* 0000110000 */
3608 0x0c, 0x00, /* 0000110000 */
3609 0x0c, 0x00, /* 0000110000 */
3610 0x0c, 0x00, /* 0000110000 */
3611
3612 /* 180 0xb4 '.' */
3613 0x0c, 0x00, /* 0000110000 */
3614 0x0c, 0x00, /* 0000110000 */
3615 0x0c, 0x00, /* 0000110000 */
3616 0x0c, 0x00, /* 0000110000 */
3617 0x0c, 0x00, /* 0000110000 */
3618 0x0c, 0x00, /* 0000110000 */
3619 0x0c, 0x00, /* 0000110000 */
3620 0x0c, 0x00, /* 0000110000 */
3621 0xfc, 0x00, /* 1111110000 */
3622 0xfc, 0x00, /* 1111110000 */
3623 0x0c, 0x00, /* 0000110000 */
3624 0x0c, 0x00, /* 0000110000 */
3625 0x0c, 0x00, /* 0000110000 */
3626 0x0c, 0x00, /* 0000110000 */
3627 0x0c, 0x00, /* 0000110000 */
3628 0x0c, 0x00, /* 0000110000 */
3629 0x0c, 0x00, /* 0000110000 */
3630 0x0c, 0x00, /* 0000110000 */
3631
3632 /* 181 0xb5 '.' */
3633 0x0c, 0x00, /* 0000110000 */
3634 0x0c, 0x00, /* 0000110000 */
3635 0x0c, 0x00, /* 0000110000 */
3636 0x0c, 0x00, /* 0000110000 */
3637 0x0c, 0x00, /* 0000110000 */
3638 0xfc, 0x00, /* 1111110000 */
3639 0xfc, 0x00, /* 1111110000 */
3640 0x0c, 0x00, /* 0000110000 */
3641 0xfc, 0x00, /* 1111110000 */
3642 0xfc, 0x00, /* 1111110000 */
3643 0x0c, 0x00, /* 0000110000 */
3644 0x0c, 0x00, /* 0000110000 */
3645 0x0c, 0x00, /* 0000110000 */
3646 0x0c, 0x00, /* 0000110000 */
3647 0x0c, 0x00, /* 0000110000 */
3648 0x0c, 0x00, /* 0000110000 */
3649 0x0c, 0x00, /* 0000110000 */
3650 0x0c, 0x00, /* 0000110000 */
3651
3652 /* 182 0xb6 '.' */
3653 0x1b, 0x00, /* 0001101100 */
3654 0x1b, 0x00, /* 0001101100 */
3655 0x1b, 0x00, /* 0001101100 */
3656 0x1b, 0x00, /* 0001101100 */
3657 0x1b, 0x00, /* 0001101100 */
3658 0x1b, 0x00, /* 0001101100 */
3659 0x1b, 0x00, /* 0001101100 */
3660 0x1b, 0x00, /* 0001101100 */
3661 0xfb, 0x00, /* 1111101100 */
3662 0xfb, 0x00, /* 1111101100 */
3663 0x1b, 0x00, /* 0001101100 */
3664 0x1b, 0x00, /* 0001101100 */
3665 0x1b, 0x00, /* 0001101100 */
3666 0x1b, 0x00, /* 0001101100 */
3667 0x1b, 0x00, /* 0001101100 */
3668 0x1b, 0x00, /* 0001101100 */
3669 0x1b, 0x00, /* 0001101100 */
3670 0x1b, 0x00, /* 0001101100 */
3671
3672 /* 183 0xb7 '.' */
3673 0x00, 0x00, /* 0000000000 */
3674 0x00, 0x00, /* 0000000000 */
3675 0x00, 0x00, /* 0000000000 */
3676 0x00, 0x00, /* 0000000000 */
3677 0x00, 0x00, /* 0000000000 */
3678 0x00, 0x00, /* 0000000000 */
3679 0x00, 0x00, /* 0000000000 */
3680 0x00, 0x00, /* 0000000000 */
3681 0xff, 0x00, /* 1111111100 */
3682 0xff, 0x00, /* 1111111100 */
3683 0x1b, 0x00, /* 0001101100 */
3684 0x1b, 0x00, /* 0001101100 */
3685 0x1b, 0x00, /* 0001101100 */
3686 0x1b, 0x00, /* 0001101100 */
3687 0x1b, 0x00, /* 0001101100 */
3688 0x1b, 0x00, /* 0001101100 */
3689 0x1b, 0x00, /* 0001101100 */
3690 0x1b, 0x00, /* 0001101100 */
3691
3692 /* 184 0xb8 '.' */
3693 0x00, 0x00, /* 0000000000 */
3694 0x00, 0x00, /* 0000000000 */
3695 0x00, 0x00, /* 0000000000 */
3696 0x00, 0x00, /* 0000000000 */
3697 0x00, 0x00, /* 0000000000 */
3698 0xfc, 0x00, /* 1111110000 */
3699 0xfc, 0x00, /* 1111110000 */
3700 0x0c, 0x00, /* 0000110000 */
3701 0xfc, 0x00, /* 1111110000 */
3702 0xfc, 0x00, /* 1111110000 */
3703 0x0c, 0x00, /* 0000110000 */
3704 0x0c, 0x00, /* 0000110000 */
3705 0x0c, 0x00, /* 0000110000 */
3706 0x0c, 0x00, /* 0000110000 */
3707 0x0c, 0x00, /* 0000110000 */
3708 0x0c, 0x00, /* 0000110000 */
3709 0x0c, 0x00, /* 0000110000 */
3710 0x0c, 0x00, /* 0000110000 */
3711
3712 /* 185 0xb9 '.' */
3713 0x1b, 0x00, /* 0001101100 */
3714 0x1b, 0x00, /* 0001101100 */
3715 0x1b, 0x00, /* 0001101100 */
3716 0x1b, 0x00, /* 0001101100 */
3717 0x1b, 0x00, /* 0001101100 */
3718 0xfb, 0x00, /* 1111101100 */
3719 0xfb, 0x00, /* 1111101100 */
3720 0x03, 0x00, /* 0000001100 */
3721 0xfb, 0x00, /* 1111101100 */
3722 0xfb, 0x00, /* 1111101100 */
3723 0x1b, 0x00, /* 0001101100 */
3724 0x1b, 0x00, /* 0001101100 */
3725 0x1b, 0x00, /* 0001101100 */
3726 0x1b, 0x00, /* 0001101100 */
3727 0x1b, 0x00, /* 0001101100 */
3728 0x1b, 0x00, /* 0001101100 */
3729 0x1b, 0x00, /* 0001101100 */
3730 0x1b, 0x00, /* 0001101100 */
3731
3732 /* 186 0xba '.' */
3733 0x1b, 0x00, /* 0001101100 */
3734 0x1b, 0x00, /* 0001101100 */
3735 0x1b, 0x00, /* 0001101100 */
3736 0x1b, 0x00, /* 0001101100 */
3737 0x1b, 0x00, /* 0001101100 */
3738 0x1b, 0x00, /* 0001101100 */
3739 0x1b, 0x00, /* 0001101100 */
3740 0x1b, 0x00, /* 0001101100 */
3741 0x1b, 0x00, /* 0001101100 */
3742 0x1b, 0x00, /* 0001101100 */
3743 0x1b, 0x00, /* 0001101100 */
3744 0x1b, 0x00, /* 0001101100 */
3745 0x1b, 0x00, /* 0001101100 */
3746 0x1b, 0x00, /* 0001101100 */
3747 0x1b, 0x00, /* 0001101100 */
3748 0x1b, 0x00, /* 0001101100 */
3749 0x1b, 0x00, /* 0001101100 */
3750 0x1b, 0x00, /* 0001101100 */
3751
3752 /* 187 0xbb '.' */
3753 0x00, 0x00, /* 0000000000 */
3754 0x00, 0x00, /* 0000000000 */
3755 0x00, 0x00, /* 0000000000 */
3756 0x00, 0x00, /* 0000000000 */
3757 0x00, 0x00, /* 0000000000 */
3758 0xff, 0x00, /* 1111111100 */
3759 0xff, 0x00, /* 1111111100 */
3760 0x03, 0x00, /* 0000001100 */
3761 0xfb, 0x00, /* 1111101100 */
3762 0xfb, 0x00, /* 1111101100 */
3763 0x1b, 0x00, /* 0001101100 */
3764 0x1b, 0x00, /* 0001101100 */
3765 0x1b, 0x00, /* 0001101100 */
3766 0x1b, 0x00, /* 0001101100 */
3767 0x1b, 0x00, /* 0001101100 */
3768 0x1b, 0x00, /* 0001101100 */
3769 0x1b, 0x00, /* 0001101100 */
3770 0x1b, 0x00, /* 0001101100 */
3771
3772 /* 188 0xbc '.' */
3773 0x1b, 0x00, /* 0001101100 */
3774 0x1b, 0x00, /* 0001101100 */
3775 0x1b, 0x00, /* 0001101100 */
3776 0x1b, 0x00, /* 0001101100 */
3777 0x1b, 0x00, /* 0001101100 */
3778 0xfb, 0x00, /* 1111101100 */
3779 0xfb, 0x00, /* 1111101100 */
3780 0x03, 0x00, /* 0000001100 */
3781 0xff, 0x00, /* 1111111100 */
3782 0xff, 0x00, /* 1111111100 */
3783 0x00, 0x00, /* 0000000000 */
3784 0x00, 0x00, /* 0000000000 */
3785 0x00, 0x00, /* 0000000000 */
3786 0x00, 0x00, /* 0000000000 */
3787 0x00, 0x00, /* 0000000000 */
3788 0x00, 0x00, /* 0000000000 */
3789 0x00, 0x00, /* 0000000000 */
3790 0x00, 0x00, /* 0000000000 */
3791
3792 /* 189 0xbd '.' */
3793 0x1b, 0x00, /* 0001101100 */
3794 0x1b, 0x00, /* 0001101100 */
3795 0x1b, 0x00, /* 0001101100 */
3796 0x1b, 0x00, /* 0001101100 */
3797 0x1b, 0x00, /* 0001101100 */
3798 0x1b, 0x00, /* 0001101100 */
3799 0x1b, 0x00, /* 0001101100 */
3800 0x1b, 0x00, /* 0001101100 */
3801 0xff, 0x00, /* 1111111100 */
3802 0xff, 0x00, /* 1111111100 */
3803 0x00, 0x00, /* 0000000000 */
3804 0x00, 0x00, /* 0000000000 */
3805 0x00, 0x00, /* 0000000000 */
3806 0x00, 0x00, /* 0000000000 */
3807 0x00, 0x00, /* 0000000000 */
3808 0x00, 0x00, /* 0000000000 */
3809 0x00, 0x00, /* 0000000000 */
3810 0x00, 0x00, /* 0000000000 */
3811
3812 /* 190 0xbe '.' */
3813 0x0c, 0x00, /* 0000110000 */
3814 0x0c, 0x00, /* 0000110000 */
3815 0x0c, 0x00, /* 0000110000 */
3816 0x0c, 0x00, /* 0000110000 */
3817 0x0c, 0x00, /* 0000110000 */
3818 0xfc, 0x00, /* 1111110000 */
3819 0xfc, 0x00, /* 1111110000 */
3820 0x0c, 0x00, /* 0000110000 */
3821 0xfc, 0x00, /* 1111110000 */
3822 0xfc, 0x00, /* 1111110000 */
3823 0x00, 0x00, /* 0000000000 */
3824 0x00, 0x00, /* 0000000000 */
3825 0x00, 0x00, /* 0000000000 */
3826 0x00, 0x00, /* 0000000000 */
3827 0x00, 0x00, /* 0000000000 */
3828 0x00, 0x00, /* 0000000000 */
3829 0x00, 0x00, /* 0000000000 */
3830 0x00, 0x00, /* 0000000000 */
3831
3832 /* 191 0xbf '.' */
3833 0x00, 0x00, /* 0000000000 */
3834 0x00, 0x00, /* 0000000000 */
3835 0x00, 0x00, /* 0000000000 */
3836 0x00, 0x00, /* 0000000000 */
3837 0x00, 0x00, /* 0000000000 */
3838 0x00, 0x00, /* 0000000000 */
3839 0x00, 0x00, /* 0000000000 */
3840 0x00, 0x00, /* 0000000000 */
3841 0xfc, 0x00, /* 1111110000 */
3842 0xfc, 0x00, /* 1111110000 */
3843 0x0c, 0x00, /* 0000110000 */
3844 0x0c, 0x00, /* 0000110000 */
3845 0x0c, 0x00, /* 0000110000 */
3846 0x0c, 0x00, /* 0000110000 */
3847 0x0c, 0x00, /* 0000110000 */
3848 0x0c, 0x00, /* 0000110000 */
3849 0x0c, 0x00, /* 0000110000 */
3850 0x0c, 0x00, /* 0000110000 */
3851
3852 /* 192 0xc0 '.' */
3853 0x0c, 0x00, /* 0000110000 */
3854 0x0c, 0x00, /* 0000110000 */
3855 0x0c, 0x00, /* 0000110000 */
3856 0x0c, 0x00, /* 0000110000 */
3857 0x0c, 0x00, /* 0000110000 */
3858 0x0c, 0x00, /* 0000110000 */
3859 0x0c, 0x00, /* 0000110000 */
3860 0x0c, 0x00, /* 0000110000 */
3861 0x0f, 0xc0, /* 0000111111 */
3862 0x0f, 0xc0, /* 0000111111 */
3863 0x00, 0x00, /* 0000000000 */
3864 0x00, 0x00, /* 0000000000 */
3865 0x00, 0x00, /* 0000000000 */
3866 0x00, 0x00, /* 0000000000 */
3867 0x00, 0x00, /* 0000000000 */
3868 0x00, 0x00, /* 0000000000 */
3869 0x00, 0x00, /* 0000000000 */
3870 0x00, 0x00, /* 0000000000 */
3871
3872 /* 193 0xc1 '.' */
3873 0x0c, 0x00, /* 0000110000 */
3874 0x0c, 0x00, /* 0000110000 */
3875 0x0c, 0x00, /* 0000110000 */
3876 0x0c, 0x00, /* 0000110000 */
3877 0x0c, 0x00, /* 0000110000 */
3878 0x0c, 0x00, /* 0000110000 */
3879 0x0c, 0x00, /* 0000110000 */
3880 0x0c, 0x00, /* 0000110000 */
3881 0xff, 0xc0, /* 1111111111 */
3882 0xff, 0xc0, /* 1111111111 */
3883 0x00, 0x00, /* 0000000000 */
3884 0x00, 0x00, /* 0000000000 */
3885 0x00, 0x00, /* 0000000000 */
3886 0x00, 0x00, /* 0000000000 */
3887 0x00, 0x00, /* 0000000000 */
3888 0x00, 0x00, /* 0000000000 */
3889 0x00, 0x00, /* 0000000000 */
3890 0x00, 0x00, /* 0000000000 */
3891
3892 /* 194 0xc2 '.' */
3893 0x00, 0x00, /* 0000000000 */
3894 0x00, 0x00, /* 0000000000 */
3895 0x00, 0x00, /* 0000000000 */
3896 0x00, 0x00, /* 0000000000 */
3897 0x00, 0x00, /* 0000000000 */
3898 0x00, 0x00, /* 0000000000 */
3899 0x00, 0x00, /* 0000000000 */
3900 0x00, 0x00, /* 0000000000 */
3901 0xff, 0xc0, /* 1111111111 */
3902 0xff, 0xc0, /* 1111111111 */
3903 0x0c, 0x00, /* 0000110000 */
3904 0x0c, 0x00, /* 0000110000 */
3905 0x0c, 0x00, /* 0000110000 */
3906 0x0c, 0x00, /* 0000110000 */
3907 0x0c, 0x00, /* 0000110000 */
3908 0x0c, 0x00, /* 0000110000 */
3909 0x0c, 0x00, /* 0000110000 */
3910 0x0c, 0x00, /* 0000110000 */
3911
3912 /* 195 0xc3 '.' */
3913 0x0c, 0x00, /* 0000110000 */
3914 0x0c, 0x00, /* 0000110000 */
3915 0x0c, 0x00, /* 0000110000 */
3916 0x0c, 0x00, /* 0000110000 */
3917 0x0c, 0x00, /* 0000110000 */
3918 0x0c, 0x00, /* 0000110000 */
3919 0x0c, 0x00, /* 0000110000 */
3920 0x0c, 0x00, /* 0000110000 */
3921 0x0f, 0xc0, /* 0000111111 */
3922 0x0f, 0xc0, /* 0000111111 */
3923 0x0c, 0x00, /* 0000110000 */
3924 0x0c, 0x00, /* 0000110000 */
3925 0x0c, 0x00, /* 0000110000 */
3926 0x0c, 0x00, /* 0000110000 */
3927 0x0c, 0x00, /* 0000110000 */
3928 0x0c, 0x00, /* 0000110000 */
3929 0x0c, 0x00, /* 0000110000 */
3930 0x0c, 0x00, /* 0000110000 */
3931
3932 /* 196 0xc4 '.' */
3933 0x00, 0x00, /* 0000000000 */
3934 0x00, 0x00, /* 0000000000 */
3935 0x00, 0x00, /* 0000000000 */
3936 0x00, 0x00, /* 0000000000 */
3937 0x00, 0x00, /* 0000000000 */
3938 0x00, 0x00, /* 0000000000 */
3939 0x00, 0x00, /* 0000000000 */
3940 0x00, 0x00, /* 0000000000 */
3941 0xff, 0xc0, /* 1111111111 */
3942 0xff, 0xc0, /* 1111111111 */
3943 0x00, 0x00, /* 0000000000 */
3944 0x00, 0x00, /* 0000000000 */
3945 0x00, 0x00, /* 0000000000 */
3946 0x00, 0x00, /* 0000000000 */
3947 0x00, 0x00, /* 0000000000 */
3948 0x00, 0x00, /* 0000000000 */
3949 0x00, 0x00, /* 0000000000 */
3950 0x00, 0x00, /* 0000000000 */
3951
3952 /* 197 0xc5 '.' */
3953 0x0c, 0x00, /* 0000110000 */
3954 0x0c, 0x00, /* 0000110000 */
3955 0x0c, 0x00, /* 0000110000 */
3956 0x0c, 0x00, /* 0000110000 */
3957 0x0c, 0x00, /* 0000110000 */
3958 0x0c, 0x00, /* 0000110000 */
3959 0x0c, 0x00, /* 0000110000 */
3960 0x0c, 0x00, /* 0000110000 */
3961 0xff, 0xc0, /* 1111111111 */
3962 0xff, 0xc0, /* 1111111111 */
3963 0x0c, 0x00, /* 0000110000 */
3964 0x0c, 0x00, /* 0000110000 */
3965 0x0c, 0x00, /* 0000110000 */
3966 0x0c, 0x00, /* 0000110000 */
3967 0x0c, 0x00, /* 0000110000 */
3968 0x0c, 0x00, /* 0000110000 */
3969 0x0c, 0x00, /* 0000110000 */
3970 0x0c, 0x00, /* 0000110000 */
3971
3972 /* 198 0xc6 '.' */
3973 0x0c, 0x00, /* 0000110000 */
3974 0x0c, 0x00, /* 0000110000 */
3975 0x0c, 0x00, /* 0000110000 */
3976 0x0c, 0x00, /* 0000110000 */
3977 0x0c, 0x00, /* 0000110000 */
3978 0x0f, 0xc0, /* 0000111111 */
3979 0x0f, 0xc0, /* 0000111111 */
3980 0x0c, 0x00, /* 0000110000 */
3981 0x0f, 0xc0, /* 0000111111 */
3982 0x0f, 0xc0, /* 0000111111 */
3983 0x0c, 0x00, /* 0000110000 */
3984 0x0c, 0x00, /* 0000110000 */
3985 0x0c, 0x00, /* 0000110000 */
3986 0x0c, 0x00, /* 0000110000 */
3987 0x0c, 0x00, /* 0000110000 */
3988 0x0c, 0x00, /* 0000110000 */
3989 0x0c, 0x00, /* 0000110000 */
3990 0x0c, 0x00, /* 0000110000 */
3991
3992 /* 199 0xc7 '.' */
3993 0x1b, 0x00, /* 0001101100 */
3994 0x1b, 0x00, /* 0001101100 */
3995 0x1b, 0x00, /* 0001101100 */
3996 0x1b, 0x00, /* 0001101100 */
3997 0x1b, 0x00, /* 0001101100 */
3998 0x1b, 0x00, /* 0001101100 */
3999 0x1b, 0x00, /* 0001101100 */
4000 0x1b, 0x00, /* 0001101100 */
4001 0x1b, 0xc0, /* 0001101111 */
4002 0x1b, 0xc0, /* 0001101111 */
4003 0x1b, 0x00, /* 0001101100 */
4004 0x1b, 0x00, /* 0001101100 */
4005 0x1b, 0x00, /* 0001101100 */
4006 0x1b, 0x00, /* 0001101100 */
4007 0x1b, 0x00, /* 0001101100 */
4008 0x1b, 0x00, /* 0001101100 */
4009 0x1b, 0x00, /* 0001101100 */
4010 0x1b, 0x00, /* 0001101100 */
4011
4012 /* 200 0xc8 '.' */
4013 0x1b, 0x00, /* 0001101100 */
4014 0x1b, 0x00, /* 0001101100 */
4015 0x1b, 0x00, /* 0001101100 */
4016 0x1b, 0x00, /* 0001101100 */
4017 0x1b, 0x00, /* 0001101100 */
4018 0x1b, 0xc0, /* 0001101111 */
4019 0x1b, 0xc0, /* 0001101111 */
4020 0x18, 0x00, /* 0001100000 */
4021 0x1f, 0xc0, /* 0001111111 */
4022 0x1f, 0xc0, /* 0001111111 */
4023 0x00, 0x00, /* 0000000000 */
4024 0x00, 0x00, /* 0000000000 */
4025 0x00, 0x00, /* 0000000000 */
4026 0x00, 0x00, /* 0000000000 */
4027 0x00, 0x00, /* 0000000000 */
4028 0x00, 0x00, /* 0000000000 */
4029 0x00, 0x00, /* 0000000000 */
4030 0x00, 0x00, /* 0000000000 */
4031
4032 /* 201 0xc9 '.' */
4033 0x00, 0x00, /* 0000000000 */
4034 0x00, 0x00, /* 0000000000 */
4035 0x00, 0x00, /* 0000000000 */
4036 0x00, 0x00, /* 0000000000 */
4037 0x00, 0x00, /* 0000000000 */
4038 0x1f, 0xc0, /* 0001111111 */
4039 0x1f, 0xc0, /* 0001111111 */
4040 0x18, 0x00, /* 0001100000 */
4041 0x1b, 0xc0, /* 0001101111 */
4042 0x1b, 0xc0, /* 0001101111 */
4043 0x1b, 0x00, /* 0001101100 */
4044 0x1b, 0x00, /* 0001101100 */
4045 0x1b, 0x00, /* 0001101100 */
4046 0x1b, 0x00, /* 0001101100 */
4047 0x1b, 0x00, /* 0001101100 */
4048 0x1b, 0x00, /* 0001101100 */
4049 0x1b, 0x00, /* 0001101100 */
4050 0x1b, 0x00, /* 0001101100 */
4051
4052 /* 202 0xca '.' */
4053 0x1b, 0x00, /* 0001101100 */
4054 0x1b, 0x00, /* 0001101100 */
4055 0x1b, 0x00, /* 0001101100 */
4056 0x1b, 0x00, /* 0001101100 */
4057 0x1b, 0x00, /* 0001101100 */
4058 0xfb, 0xc0, /* 1111101111 */
4059 0xfb, 0xc0, /* 1111101111 */
4060 0x00, 0x00, /* 0000000000 */
4061 0xff, 0xc0, /* 1111111111 */
4062 0xff, 0xc0, /* 1111111111 */
4063 0x00, 0x00, /* 0000000000 */
4064 0x00, 0x00, /* 0000000000 */
4065 0x00, 0x00, /* 0000000000 */
4066 0x00, 0x00, /* 0000000000 */
4067 0x00, 0x00, /* 0000000000 */
4068 0x00, 0x00, /* 0000000000 */
4069 0x00, 0x00, /* 0000000000 */
4070 0x00, 0x00, /* 0000000000 */
4071
4072 /* 203 0xcb '.' */
4073 0x00, 0x00, /* 0000000000 */
4074 0x00, 0x00, /* 0000000000 */
4075 0x00, 0x00, /* 0000000000 */
4076 0x00, 0x00, /* 0000000000 */
4077 0x00, 0x00, /* 0000000000 */
4078 0xff, 0xc0, /* 1111111111 */
4079 0xff, 0xc0, /* 1111111111 */
4080 0x00, 0x00, /* 0000000000 */
4081 0xfb, 0xc0, /* 1111101111 */
4082 0xfb, 0xc0, /* 1111101111 */
4083 0x1b, 0x00, /* 0001101100 */
4084 0x1b, 0x00, /* 0001101100 */
4085 0x1b, 0x00, /* 0001101100 */
4086 0x1b, 0x00, /* 0001101100 */
4087 0x1b, 0x00, /* 0001101100 */
4088 0x1b, 0x00, /* 0001101100 */
4089 0x1b, 0x00, /* 0001101100 */
4090 0x1b, 0x00, /* 0001101100 */
4091
4092 /* 204 0xcc '.' */
4093 0x1b, 0x00, /* 0001101100 */
4094 0x1b, 0x00, /* 0001101100 */
4095 0x1b, 0x00, /* 0001101100 */
4096 0x1b, 0x00, /* 0001101100 */
4097 0x1b, 0x00, /* 0001101100 */
4098 0x1b, 0xc0, /* 0001101111 */
4099 0x1b, 0xc0, /* 0001101111 */
4100 0x18, 0x00, /* 0001100000 */
4101 0x1b, 0xc0, /* 0001101111 */
4102 0x1b, 0xc0, /* 0001101111 */
4103 0x1b, 0x00, /* 0001101100 */
4104 0x1b, 0x00, /* 0001101100 */
4105 0x1b, 0x00, /* 0001101100 */
4106 0x1b, 0x00, /* 0001101100 */
4107 0x1b, 0x00, /* 0001101100 */
4108 0x1b, 0x00, /* 0001101100 */
4109 0x1b, 0x00, /* 0001101100 */
4110 0x1b, 0x00, /* 0001101100 */
4111
4112 /* 205 0xcd '.' */
4113 0x00, 0x00, /* 0000000000 */
4114 0x00, 0x00, /* 0000000000 */
4115 0x00, 0x00, /* 0000000000 */
4116 0x00, 0x00, /* 0000000000 */
4117 0x00, 0x00, /* 0000000000 */
4118 0xff, 0xc0, /* 1111111111 */
4119 0xff, 0xc0, /* 1111111111 */
4120 0x00, 0x00, /* 0000000000 */
4121 0xff, 0xc0, /* 1111111111 */
4122 0xff, 0xc0, /* 1111111111 */
4123 0x00, 0x00, /* 0000000000 */
4124 0x00, 0x00, /* 0000000000 */
4125 0x00, 0x00, /* 0000000000 */
4126 0x00, 0x00, /* 0000000000 */
4127 0x00, 0x00, /* 0000000000 */
4128 0x00, 0x00, /* 0000000000 */
4129 0x00, 0x00, /* 0000000000 */
4130 0x00, 0x00, /* 0000000000 */
4131
4132 /* 206 0xce '.' */
4133 0x1b, 0x00, /* 0001101100 */
4134 0x1b, 0x00, /* 0001101100 */
4135 0x1b, 0x00, /* 0001101100 */
4136 0x1b, 0x00, /* 0001101100 */
4137 0x1b, 0x00, /* 0001101100 */
4138 0xfb, 0xc0, /* 1111101111 */
4139 0xfb, 0xc0, /* 1111101111 */
4140 0x00, 0x00, /* 0000000000 */
4141 0xfb, 0xc0, /* 1111101111 */
4142 0xfb, 0xc0, /* 1111101111 */
4143 0x1b, 0x00, /* 0001101100 */
4144 0x1b, 0x00, /* 0001101100 */
4145 0x1b, 0x00, /* 0001101100 */
4146 0x1b, 0x00, /* 0001101100 */
4147 0x1b, 0x00, /* 0001101100 */
4148 0x1b, 0x00, /* 0001101100 */
4149 0x1b, 0x00, /* 0001101100 */
4150 0x1b, 0x00, /* 0001101100 */
4151
4152 /* 207 0xcf '.' */
4153 0x0c, 0x00, /* 0000110000 */
4154 0x0c, 0x00, /* 0000110000 */
4155 0x0c, 0x00, /* 0000110000 */
4156 0x0c, 0x00, /* 0000110000 */
4157 0x0c, 0x00, /* 0000110000 */
4158 0xff, 0xc0, /* 1111111111 */
4159 0xff, 0xc0, /* 1111111111 */
4160 0x00, 0x00, /* 0000000000 */
4161 0xff, 0xc0, /* 1111111111 */
4162 0xff, 0xc0, /* 1111111111 */
4163 0x00, 0x00, /* 0000000000 */
4164 0x00, 0x00, /* 0000000000 */
4165 0x00, 0x00, /* 0000000000 */
4166 0x00, 0x00, /* 0000000000 */
4167 0x00, 0x00, /* 0000000000 */
4168 0x00, 0x00, /* 0000000000 */
4169 0x00, 0x00, /* 0000000000 */
4170 0x00, 0x00, /* 0000000000 */
4171
4172 /* 208 0xd0 '.' */
4173 0x1b, 0x00, /* 0001101100 */
4174 0x1b, 0x00, /* 0001101100 */
4175 0x1b, 0x00, /* 0001101100 */
4176 0x1b, 0x00, /* 0001101100 */
4177 0x1b, 0x00, /* 0001101100 */
4178 0x1b, 0x00, /* 0001101100 */
4179 0x1b, 0x00, /* 0001101100 */
4180 0x1b, 0x00, /* 0001101100 */
4181 0xff, 0xc0, /* 1111111111 */
4182 0xff, 0xc0, /* 1111111111 */
4183 0x00, 0x00, /* 0000000000 */
4184 0x00, 0x00, /* 0000000000 */
4185 0x00, 0x00, /* 0000000000 */
4186 0x00, 0x00, /* 0000000000 */
4187 0x00, 0x00, /* 0000000000 */
4188 0x00, 0x00, /* 0000000000 */
4189 0x00, 0x00, /* 0000000000 */
4190 0x00, 0x00, /* 0000000000 */
4191
4192 /* 209 0xd1 '.' */
4193 0x00, 0x00, /* 0000000000 */
4194 0x00, 0x00, /* 0000000000 */
4195 0x00, 0x00, /* 0000000000 */
4196 0x00, 0x00, /* 0000000000 */
4197 0x00, 0x00, /* 0000000000 */
4198 0xff, 0xc0, /* 1111111111 */
4199 0xff, 0xc0, /* 1111111111 */
4200 0x00, 0x00, /* 0000000000 */
4201 0xff, 0xc0, /* 1111111111 */
4202 0xff, 0xc0, /* 1111111111 */
4203 0x0c, 0x00, /* 0000110000 */
4204 0x0c, 0x00, /* 0000110000 */
4205 0x0c, 0x00, /* 0000110000 */
4206 0x0c, 0x00, /* 0000110000 */
4207 0x0c, 0x00, /* 0000110000 */
4208 0x0c, 0x00, /* 0000110000 */
4209 0x0c, 0x00, /* 0000110000 */
4210 0x0c, 0x00, /* 0000110000 */
4211
4212 /* 210 0xd2 '.' */
4213 0x00, 0x00, /* 0000000000 */
4214 0x00, 0x00, /* 0000000000 */
4215 0x00, 0x00, /* 0000000000 */
4216 0x00, 0x00, /* 0000000000 */
4217 0x00, 0x00, /* 0000000000 */
4218 0x00, 0x00, /* 0000000000 */
4219 0x00, 0x00, /* 0000000000 */
4220 0x00, 0x00, /* 0000000000 */
4221 0xff, 0xc0, /* 1111111111 */
4222 0xff, 0xc0, /* 1111111111 */
4223 0x1b, 0x00, /* 0001101100 */
4224 0x1b, 0x00, /* 0001101100 */
4225 0x1b, 0x00, /* 0001101100 */
4226 0x1b, 0x00, /* 0001101100 */
4227 0x1b, 0x00, /* 0001101100 */
4228 0x1b, 0x00, /* 0001101100 */
4229 0x1b, 0x00, /* 0001101100 */
4230 0x1b, 0x00, /* 0001101100 */
4231
4232 /* 211 0xd3 '.' */
4233 0x1b, 0x00, /* 0001101100 */
4234 0x1b, 0x00, /* 0001101100 */
4235 0x1b, 0x00, /* 0001101100 */
4236 0x1b, 0x00, /* 0001101100 */
4237 0x1b, 0x00, /* 0001101100 */
4238 0x1b, 0x00, /* 0001101100 */
4239 0x1b, 0x00, /* 0001101100 */
4240 0x1b, 0x00, /* 0001101100 */
4241 0x1f, 0xc0, /* 0001111111 */
4242 0x1f, 0xc0, /* 0001111111 */
4243 0x00, 0x00, /* 0000000000 */
4244 0x00, 0x00, /* 0000000000 */
4245 0x00, 0x00, /* 0000000000 */
4246 0x00, 0x00, /* 0000000000 */
4247 0x00, 0x00, /* 0000000000 */
4248 0x00, 0x00, /* 0000000000 */
4249 0x00, 0x00, /* 0000000000 */
4250 0x00, 0x00, /* 0000000000 */
4251
4252 /* 212 0xd4 '.' */
4253 0x0c, 0x00, /* 0000110000 */
4254 0x0c, 0x00, /* 0000110000 */
4255 0x0c, 0x00, /* 0000110000 */
4256 0x0c, 0x00, /* 0000110000 */
4257 0x0c, 0x00, /* 0000110000 */
4258 0x0f, 0xc0, /* 0000111111 */
4259 0x0f, 0xc0, /* 0000111111 */
4260 0x0c, 0x00, /* 0000110000 */
4261 0x0f, 0xc0, /* 0000111111 */
4262 0x0f, 0xc0, /* 0000111111 */
4263 0x00, 0x00, /* 0000000000 */
4264 0x00, 0x00, /* 0000000000 */
4265 0x00, 0x00, /* 0000000000 */
4266 0x00, 0x00, /* 0000000000 */
4267 0x00, 0x00, /* 0000000000 */
4268 0x00, 0x00, /* 0000000000 */
4269 0x00, 0x00, /* 0000000000 */
4270 0x00, 0x00, /* 0000000000 */
4271
4272 /* 213 0xd5 '.' */
4273 0x00, 0x00, /* 0000000000 */
4274 0x00, 0x00, /* 0000000000 */
4275 0x00, 0x00, /* 0000000000 */
4276 0x00, 0x00, /* 0000000000 */
4277 0x00, 0x00, /* 0000000000 */
4278 0x0f, 0xc0, /* 0000111111 */
4279 0x0f, 0xc0, /* 0000111111 */
4280 0x0c, 0x00, /* 0000110000 */
4281 0x0f, 0xc0, /* 0000111111 */
4282 0x0f, 0xc0, /* 0000111111 */
4283 0x0c, 0x00, /* 0000110000 */
4284 0x0c, 0x00, /* 0000110000 */
4285 0x0c, 0x00, /* 0000110000 */
4286 0x0c, 0x00, /* 0000110000 */
4287 0x0c, 0x00, /* 0000110000 */
4288 0x0c, 0x00, /* 0000110000 */
4289 0x0c, 0x00, /* 0000110000 */
4290 0x0c, 0x00, /* 0000110000 */
4291
4292 /* 214 0xd6 '.' */
4293 0x00, 0x00, /* 0000000000 */
4294 0x00, 0x00, /* 0000000000 */
4295 0x00, 0x00, /* 0000000000 */
4296 0x00, 0x00, /* 0000000000 */
4297 0x00, 0x00, /* 0000000000 */
4298 0x00, 0x00, /* 0000000000 */
4299 0x00, 0x00, /* 0000000000 */
4300 0x00, 0x00, /* 0000000000 */
4301 0x1f, 0xc0, /* 0001111111 */
4302 0x1f, 0xc0, /* 0001111111 */
4303 0x1b, 0x00, /* 0001101100 */
4304 0x1b, 0x00, /* 0001101100 */
4305 0x1b, 0x00, /* 0001101100 */
4306 0x1b, 0x00, /* 0001101100 */
4307 0x1b, 0x00, /* 0001101100 */
4308 0x1b, 0x00, /* 0001101100 */
4309 0x1b, 0x00, /* 0001101100 */
4310 0x1b, 0x00, /* 0001101100 */
4311
4312 /* 215 0xd7 '.' */
4313 0x1b, 0x00, /* 0001101100 */
4314 0x1b, 0x00, /* 0001101100 */
4315 0x1b, 0x00, /* 0001101100 */
4316 0x1b, 0x00, /* 0001101100 */
4317 0x1b, 0x00, /* 0001101100 */
4318 0x1b, 0x00, /* 0001101100 */
4319 0x1b, 0x00, /* 0001101100 */
4320 0x1b, 0x00, /* 0001101100 */
4321 0xff, 0xc0, /* 1111111111 */
4322 0xff, 0xc0, /* 1111111111 */
4323 0x1b, 0x00, /* 0001101100 */
4324 0x1b, 0x00, /* 0001101100 */
4325 0x1b, 0x00, /* 0001101100 */
4326 0x1b, 0x00, /* 0001101100 */
4327 0x1b, 0x00, /* 0001101100 */
4328 0x1b, 0x00, /* 0001101100 */
4329 0x1b, 0x00, /* 0001101100 */
4330 0x1b, 0x00, /* 0001101100 */
4331
4332 /* 216 0xd8 '.' */
4333 0x0c, 0x00, /* 0000110000 */
4334 0x0c, 0x00, /* 0000110000 */
4335 0x0c, 0x00, /* 0000110000 */
4336 0x0c, 0x00, /* 0000110000 */
4337 0x0c, 0x00, /* 0000110000 */
4338 0xff, 0xc0, /* 1111111111 */
4339 0xff, 0xc0, /* 1111111111 */
4340 0x0c, 0x00, /* 0000110000 */
4341 0xff, 0xc0, /* 1111111111 */
4342 0xff, 0xc0, /* 1111111111 */
4343 0x0c, 0x00, /* 0000110000 */
4344 0x0c, 0x00, /* 0000110000 */
4345 0x0c, 0x00, /* 0000110000 */
4346 0x0c, 0x00, /* 0000110000 */
4347 0x0c, 0x00, /* 0000110000 */
4348 0x0c, 0x00, /* 0000110000 */
4349 0x0c, 0x00, /* 0000110000 */
4350 0x0c, 0x00, /* 0000110000 */
4351
4352 /* 217 0xd9 '.' */
4353 0x0c, 0x00, /* 0000110000 */
4354 0x0c, 0x00, /* 0000110000 */
4355 0x0c, 0x00, /* 0000110000 */
4356 0x0c, 0x00, /* 0000110000 */
4357 0x0c, 0x00, /* 0000110000 */
4358 0x0c, 0x00, /* 0000110000 */
4359 0x0c, 0x00, /* 0000110000 */
4360 0x0c, 0x00, /* 0000110000 */
4361 0xfc, 0x00, /* 1111110000 */
4362 0xfc, 0x00, /* 1111110000 */
4363 0x00, 0x00, /* 0000000000 */
4364 0x00, 0x00, /* 0000000000 */
4365 0x00, 0x00, /* 0000000000 */
4366 0x00, 0x00, /* 0000000000 */
4367 0x00, 0x00, /* 0000000000 */
4368 0x00, 0x00, /* 0000000000 */
4369 0x00, 0x00, /* 0000000000 */
4370 0x00, 0x00, /* 0000000000 */
4371
4372 /* 218 0xda '.' */
4373 0x00, 0x00, /* 0000000000 */
4374 0x00, 0x00, /* 0000000000 */
4375 0x00, 0x00, /* 0000000000 */
4376 0x00, 0x00, /* 0000000000 */
4377 0x00, 0x00, /* 0000000000 */
4378 0x00, 0x00, /* 0000000000 */
4379 0x00, 0x00, /* 0000000000 */
4380 0x00, 0x00, /* 0000000000 */
4381 0x0f, 0xc0, /* 0000111111 */
4382 0x0f, 0xc0, /* 0000111111 */
4383 0x0c, 0x00, /* 0000110000 */
4384 0x0c, 0x00, /* 0000110000 */
4385 0x0c, 0x00, /* 0000110000 */
4386 0x0c, 0x00, /* 0000110000 */
4387 0x0c, 0x00, /* 0000110000 */
4388 0x0c, 0x00, /* 0000110000 */
4389 0x0c, 0x00, /* 0000110000 */
4390 0x0c, 0x00, /* 0000110000 */
4391
4392 /* 219 0xdb '.' */
4393 0xff, 0xc0, /* 1111111111 */
4394 0xff, 0xc0, /* 1111111111 */
4395 0xff, 0xc0, /* 1111111111 */
4396 0xff, 0xc0, /* 1111111111 */
4397 0xff, 0xc0, /* 1111111111 */
4398 0xff, 0xc0, /* 1111111111 */
4399 0xff, 0xc0, /* 1111111111 */
4400 0xff, 0xc0, /* 1111111111 */
4401 0xff, 0xc0, /* 1111111111 */
4402 0xff, 0xc0, /* 1111111111 */
4403 0xff, 0xc0, /* 1111111111 */
4404 0xff, 0xc0, /* 1111111111 */
4405 0xff, 0xc0, /* 1111111111 */
4406 0xff, 0xc0, /* 1111111111 */
4407 0xff, 0xc0, /* 1111111111 */
4408 0xff, 0xc0, /* 1111111111 */
4409 0xff, 0xc0, /* 1111111111 */
4410 0xff, 0xc0, /* 1111111111 */
4411
4412 /* 220 0xdc '.' */
4413 0x00, 0x00, /* 0000000000 */
4414 0x00, 0x00, /* 0000000000 */
4415 0x00, 0x00, /* 0000000000 */
4416 0x00, 0x00, /* 0000000000 */
4417 0x00, 0x00, /* 0000000000 */
4418 0x00, 0x00, /* 0000000000 */
4419 0x00, 0x00, /* 0000000000 */
4420 0x00, 0x00, /* 0000000000 */
4421 0xff, 0xc0, /* 1111111111 */
4422 0xff, 0xc0, /* 1111111111 */
4423 0xff, 0xc0, /* 1111111111 */
4424 0xff, 0xc0, /* 1111111111 */
4425 0xff, 0xc0, /* 1111111111 */
4426 0xff, 0xc0, /* 1111111111 */
4427 0xff, 0xc0, /* 1111111111 */
4428 0xff, 0xc0, /* 1111111111 */
4429 0xff, 0xc0, /* 1111111111 */
4430 0xff, 0xc0, /* 1111111111 */
4431
4432 /* 221 0xdd '.' */
4433 0xf8, 0x00, /* 1111100000 */
4434 0xf8, 0x00, /* 1111100000 */
4435 0xf8, 0x00, /* 1111100000 */
4436 0xf8, 0x00, /* 1111100000 */
4437 0xf8, 0x00, /* 1111100000 */
4438 0xf8, 0x00, /* 1111100000 */
4439 0xf8, 0x00, /* 1111100000 */
4440 0xf8, 0x00, /* 1111100000 */
4441 0xf8, 0x00, /* 1111100000 */
4442 0xf8, 0x00, /* 1111100000 */
4443 0xf8, 0x00, /* 1111100000 */
4444 0xf8, 0x00, /* 1111100000 */
4445 0xf8, 0x00, /* 1111100000 */
4446 0xf8, 0x00, /* 1111100000 */
4447 0xf8, 0x00, /* 1111100000 */
4448 0xf8, 0x00, /* 1111100000 */
4449 0xf8, 0x00, /* 1111100000 */
4450 0xf8, 0x00, /* 1111100000 */
4451
4452 /* 222 0xde '.' */
4453 0x07, 0xc0, /* 0000011111 */
4454 0x07, 0xc0, /* 0000011111 */
4455 0x07, 0xc0, /* 0000011111 */
4456 0x07, 0xc0, /* 0000011111 */
4457 0x07, 0xc0, /* 0000011111 */
4458 0x07, 0xc0, /* 0000011111 */
4459 0x07, 0xc0, /* 0000011111 */
4460 0x07, 0xc0, /* 0000011111 */
4461 0x07, 0xc0, /* 0000011111 */
4462 0x07, 0xc0, /* 0000011111 */
4463 0x07, 0xc0, /* 0000011111 */
4464 0x07, 0xc0, /* 0000011111 */
4465 0x07, 0xc0, /* 0000011111 */
4466 0x07, 0xc0, /* 0000011111 */
4467 0x07, 0xc0, /* 0000011111 */
4468 0x07, 0xc0, /* 0000011111 */
4469 0x07, 0xc0, /* 0000011111 */
4470 0x07, 0xc0, /* 0000011111 */
4471
4472 /* 223 0xdf '.' */
4473 0xff, 0xc0, /* 1111111111 */
4474 0xff, 0xc0, /* 1111111111 */
4475 0xff, 0xc0, /* 1111111111 */
4476 0xff, 0xc0, /* 1111111111 */
4477 0xff, 0xc0, /* 1111111111 */
4478 0xff, 0xc0, /* 1111111111 */
4479 0xff, 0xc0, /* 1111111111 */
4480 0xff, 0xc0, /* 1111111111 */
4481 0x00, 0x00, /* 0000000000 */
4482 0x00, 0x00, /* 0000000000 */
4483 0x00, 0x00, /* 0000000000 */
4484 0x00, 0x00, /* 0000000000 */
4485 0x00, 0x00, /* 0000000000 */
4486 0x00, 0x00, /* 0000000000 */
4487 0x00, 0x00, /* 0000000000 */
4488 0x00, 0x00, /* 0000000000 */
4489 0x00, 0x00, /* 0000000000 */
4490 0x00, 0x00, /* 0000000000 */
4491
4492 /* 224 0xe0 '.' */
4493 0x00, 0x00, /* 0000000000 */
4494 0x00, 0x00, /* 0000000000 */
4495 0x00, 0x00, /* 0000000000 */
4496 0x00, 0x00, /* 0000000000 */
4497 0x00, 0x00, /* 0000000000 */
4498 0x1c, 0x80, /* 0001110010 */
4499 0x35, 0x80, /* 0011010110 */
4500 0x63, 0x00, /* 0110001100 */
4501 0x63, 0x00, /* 0110001100 */
4502 0x63, 0x00, /* 0110001100 */
4503 0x63, 0x00, /* 0110001100 */
4504 0x63, 0x00, /* 0110001100 */
4505 0x63, 0x00, /* 0110001100 */
4506 0x37, 0x80, /* 0011011110 */
4507 0x1c, 0x80, /* 0001110010 */
4508 0x00, 0x00, /* 0000000000 */
4509 0x00, 0x00, /* 0000000000 */
4510 0x00, 0x00, /* 0000000000 */
4511
4512 /* 225 0xe1 '.' */
4513 0x00, 0x00, /* 0000000000 */
4514 0x1e, 0x00, /* 0001111000 */
4515 0x33, 0x00, /* 0011001100 */
4516 0x61, 0x80, /* 0110000110 */
4517 0x61, 0x80, /* 0110000110 */
4518 0x61, 0x80, /* 0110000110 */
4519 0x63, 0x00, /* 0110001100 */
4520 0x6f, 0x00, /* 0110111100 */
4521 0x63, 0x00, /* 0110001100 */
4522 0x61, 0x80, /* 0110000110 */
4523 0x61, 0x80, /* 0110000110 */
4524 0x61, 0x80, /* 0110000110 */
4525 0x61, 0x80, /* 0110000110 */
4526 0x63, 0x00, /* 0110001100 */
4527 0x6e, 0x00, /* 0110111000 */
4528 0x00, 0x00, /* 0000000000 */
4529 0x00, 0x00, /* 0000000000 */
4530 0x00, 0x00, /* 0000000000 */
4531
4532 /* 226 0xe2 '.' */
4533 0x00, 0x00, /* 0000000000 */
4534 0x7f, 0x80, /* 0111111110 */
4535 0x61, 0x80, /* 0110000110 */
4536 0x61, 0x80, /* 0110000110 */
4537 0x60, 0x00, /* 0110000000 */
4538 0x60, 0x00, /* 0110000000 */
4539 0x60, 0x00, /* 0110000000 */
4540 0x60, 0x00, /* 0110000000 */
4541 0x60, 0x00, /* 0110000000 */
4542 0x60, 0x00, /* 0110000000 */
4543 0x60, 0x00, /* 0110000000 */
4544 0x60, 0x00, /* 0110000000 */
4545 0x60, 0x00, /* 0110000000 */
4546 0x60, 0x00, /* 0110000000 */
4547 0x60, 0x00, /* 0110000000 */
4548 0x00, 0x00, /* 0000000000 */
4549 0x00, 0x00, /* 0000000000 */
4550 0x00, 0x00, /* 0000000000 */
4551
4552 /* 227 0xe3 '.' */
4553 0x00, 0x00, /* 0000000000 */
4554 0x00, 0x00, /* 0000000000 */
4555 0x00, 0x00, /* 0000000000 */
4556 0x00, 0x00, /* 0000000000 */
4557 0x00, 0x00, /* 0000000000 */
4558 0x00, 0x00, /* 0000000000 */
4559 0x7f, 0x80, /* 0111111110 */
4560 0x33, 0x00, /* 0011001100 */
4561 0x33, 0x00, /* 0011001100 */
4562 0x33, 0x00, /* 0011001100 */
4563 0x33, 0x00, /* 0011001100 */
4564 0x33, 0x00, /* 0011001100 */
4565 0x33, 0x00, /* 0011001100 */
4566 0x33, 0x00, /* 0011001100 */
4567 0x33, 0x00, /* 0011001100 */
4568 0x00, 0x00, /* 0000000000 */
4569 0x00, 0x00, /* 0000000000 */
4570 0x00, 0x00, /* 0000000000 */
4571
4572 /* 228 0xe4 '.' */
4573 0x00, 0x00, /* 0000000000 */
4574 0x00, 0x00, /* 0000000000 */
4575 0xff, 0x80, /* 1111111110 */
4576 0x60, 0x00, /* 0110000000 */
4577 0x30, 0x00, /* 0011000000 */
4578 0x30, 0x00, /* 0011000000 */
4579 0x18, 0x00, /* 0001100000 */
4580 0x18, 0x00, /* 0001100000 */
4581 0x0c, 0x00, /* 0000110000 */
4582 0x0c, 0x00, /* 0000110000 */
4583 0x18, 0x00, /* 0001100000 */
4584 0x30, 0x00, /* 0011000000 */
4585 0x30, 0x80, /* 0011000010 */
4586 0x61, 0x80, /* 0110000110 */
4587 0xff, 0x80, /* 1111111110 */
4588 0x00, 0x00, /* 0000000000 */
4589 0x00, 0x00, /* 0000000000 */
4590 0x00, 0x00, /* 0000000000 */
4591
4592 /* 229 0xe5 '.' */
4593 0x00, 0x00, /* 0000000000 */
4594 0x00, 0x00, /* 0000000000 */
4595 0x00, 0x00, /* 0000000000 */
4596 0x00, 0x00, /* 0000000000 */
4597 0x00, 0x00, /* 0000000000 */
4598 0x00, 0x00, /* 0000000000 */
4599 0x00, 0x00, /* 0000000000 */
4600 0x1f, 0xc0, /* 0001111111 */
4601 0x36, 0x00, /* 0011011000 */
4602 0x63, 0x00, /* 0110001100 */
4603 0x61, 0x80, /* 0110000110 */
4604 0x61, 0x80, /* 0110000110 */
4605 0x61, 0x80, /* 0110000110 */
4606 0x33, 0x00, /* 0011001100 */
4607 0x3e, 0x00, /* 0011111000 */
4608 0x00, 0x00, /* 0000000000 */
4609 0x00, 0x00, /* 0000000000 */
4610 0x00, 0x00, /* 0000000000 */
4611
4612 /* 230 0xe6 '.' */
4613 0x00, 0x00, /* 0000000000 */
4614 0x00, 0x00, /* 0000000000 */
4615 0x00, 0x00, /* 0000000000 */
4616 0x61, 0x80, /* 0110000110 */
4617 0x61, 0x80, /* 0110000110 */
4618 0x61, 0x80, /* 0110000110 */
4619 0x61, 0x80, /* 0110000110 */
4620 0x61, 0x80, /* 0110000110 */
4621 0x61, 0x80, /* 0110000110 */
4622 0x61, 0x80, /* 0110000110 */
4623 0x61, 0x80, /* 0110000110 */
4624 0x73, 0x80, /* 0111001110 */
4625 0x6d, 0x80, /* 0110110110 */
4626 0x60, 0x00, /* 0110000000 */
4627 0x60, 0x00, /* 0110000000 */
4628 0x60, 0x00, /* 0110000000 */
4629 0x60, 0x00, /* 0110000000 */
4630 0xc0, 0x00, /* 1100000000 */
4631
4632 /* 231 0xe7 '.' */
4633 0x00, 0x00, /* 0000000000 */
4634 0x00, 0x00, /* 0000000000 */
4635 0x00, 0x00, /* 0000000000 */
4636 0x01, 0x80, /* 0000000110 */
4637 0x36, 0x40, /* 0011011001 */
4638 0x5e, 0x00, /* 0101111000 */
4639 0x8c, 0x00, /* 1000110000 */
4640 0x0c, 0x00, /* 0000110000 */
4641 0x0c, 0x00, /* 0000110000 */
4642 0x0c, 0x00, /* 0000110000 */
4643 0x0c, 0x00, /* 0000110000 */
4644 0x0c, 0x00, /* 0000110000 */
4645 0x0c, 0x00, /* 0000110000 */
4646 0x0c, 0x00, /* 0000110000 */
4647 0x0c, 0x00, /* 0000110000 */
4648 0x00, 0x00, /* 0000000000 */
4649 0x00, 0x00, /* 0000000000 */
4650 0x00, 0x00, /* 0000000000 */
4651
4652 /* 232 0xe8 '.' */
4653 0x00, 0x00, /* 0000000000 */
4654 0x00, 0x00, /* 0000000000 */
4655 0x7f, 0x80, /* 0111111110 */
4656 0x0c, 0x00, /* 0000110000 */
4657 0x0c, 0x00, /* 0000110000 */
4658 0x1e, 0x00, /* 0001111000 */
4659 0x33, 0x00, /* 0011001100 */
4660 0x61, 0x80, /* 0110000110 */
4661 0x61, 0x80, /* 0110000110 */
4662 0x61, 0x80, /* 0110000110 */
4663 0x33, 0x00, /* 0011001100 */
4664 0x1e, 0x00, /* 0001111000 */
4665 0x0c, 0x00, /* 0000110000 */
4666 0x0c, 0x00, /* 0000110000 */
4667 0x7f, 0x80, /* 0111111110 */
4668 0x00, 0x00, /* 0000000000 */
4669 0x00, 0x00, /* 0000000000 */
4670 0x00, 0x00, /* 0000000000 */
4671
4672 /* 233 0xe9 '.' */
4673 0x00, 0x00, /* 0000000000 */
4674 0x00, 0x00, /* 0000000000 */
4675 0x00, 0x00, /* 0000000000 */
4676 0x0e, 0x00, /* 0000111000 */
4677 0x1f, 0x00, /* 0001111100 */
4678 0x31, 0x80, /* 0011000110 */
4679 0x31, 0x80, /* 0011000110 */
4680 0x60, 0xc0, /* 0110000011 */
4681 0x7f, 0xc0, /* 0111111111 */
4682 0x7f, 0xc0, /* 0111111111 */
4683 0x60, 0xc0, /* 0110000011 */
4684 0x31, 0x80, /* 0011000110 */
4685 0x31, 0x80, /* 0011000110 */
4686 0x1f, 0x00, /* 0001111100 */
4687 0x0e, 0x00, /* 0000111000 */
4688 0x00, 0x00, /* 0000000000 */
4689 0x00, 0x00, /* 0000000000 */
4690 0x00, 0x00, /* 0000000000 */
4691
4692 /* 234 0xea '.' */
4693 0x00, 0x00, /* 0000000000 */
4694 0x00, 0x00, /* 0000000000 */
4695 0x00, 0x00, /* 0000000000 */
4696 0x00, 0x00, /* 0000000000 */
4697 0x1e, 0x00, /* 0001111000 */
4698 0x33, 0x00, /* 0011001100 */
4699 0x61, 0x80, /* 0110000110 */
4700 0xc0, 0xc0, /* 1100000011 */
4701 0xc0, 0xc0, /* 1100000011 */
4702 0xc0, 0xc0, /* 1100000011 */
4703 0x61, 0x80, /* 0110000110 */
4704 0x33, 0x00, /* 0011001100 */
4705 0x33, 0x00, /* 0011001100 */
4706 0x33, 0x00, /* 0011001100 */
4707 0x33, 0x00, /* 0011001100 */
4708 0xf3, 0xc0, /* 1111001111 */
4709 0x00, 0x00, /* 0000000000 */
4710 0x00, 0x00, /* 0000000000 */
4711
4712 /* 235 0xeb '.' */
4713 0x00, 0x00, /* 0000000000 */
4714 0x07, 0x00, /* 0000011100 */
4715 0x1f, 0x80, /* 0001111110 */
4716 0x30, 0xc0, /* 0011000011 */
4717 0x30, 0x00, /* 0011000000 */
4718 0x18, 0x00, /* 0001100000 */
4719 0x0c, 0x00, /* 0000110000 */
4720 0x0c, 0x00, /* 0000110000 */
4721 0x3e, 0x00, /* 0011111000 */
4722 0x66, 0x00, /* 0110011000 */
4723 0xc3, 0x00, /* 1100001100 */
4724 0xc3, 0x00, /* 1100001100 */
4725 0xc3, 0x00, /* 1100001100 */
4726 0x66, 0x00, /* 0110011000 */
4727 0x3c, 0x00, /* 0011110000 */
4728 0x18, 0x00, /* 0001100000 */
4729 0x00, 0x00, /* 0000000000 */
4730 0x00, 0x00, /* 0000000000 */
4731
4732 /* 236 0xec '.' */
4733 0x00, 0x00, /* 0000000000 */
4734 0x00, 0x00, /* 0000000000 */
4735 0x00, 0x00, /* 0000000000 */
4736 0x00, 0x00, /* 0000000000 */
4737 0x00, 0x00, /* 0000000000 */
4738 0x33, 0x00, /* 0011001100 */
4739 0x6d, 0x80, /* 0110110110 */
4740 0xcc, 0xc0, /* 1100110011 */
4741 0xcc, 0xc0, /* 1100110011 */
4742 0xcc, 0xc0, /* 1100110011 */
4743 0xcc, 0xc0, /* 1100110011 */
4744 0x6d, 0x80, /* 0110110110 */
4745 0x33, 0x00, /* 0011001100 */
4746 0x00, 0x00, /* 0000000000 */
4747 0x00, 0x00, /* 0000000000 */
4748 0x00, 0x00, /* 0000000000 */
4749 0x00, 0x00, /* 0000000000 */
4750 0x00, 0x00, /* 0000000000 */
4751
4752 /* 237 0xed '.' */
4753 0x00, 0x00, /* 0000000000 */
4754 0x01, 0x80, /* 0000000110 */
4755 0x01, 0x80, /* 0000000110 */
4756 0x03, 0x00, /* 0000001100 */
4757 0x03, 0x00, /* 0000001100 */
4758 0x37, 0x00, /* 0011011100 */
4759 0x6d, 0x80, /* 0110110110 */
4760 0xcc, 0xc0, /* 1100110011 */
4761 0xcc, 0xc0, /* 1100110011 */
4762 0xcc, 0xc0, /* 1100110011 */
4763 0xcc, 0xc0, /* 1100110011 */
4764 0x6d, 0x80, /* 0110110110 */
4765 0x3b, 0x00, /* 0011101100 */
4766 0x30, 0x00, /* 0011000000 */
4767 0x30, 0x00, /* 0011000000 */
4768 0x60, 0x00, /* 0110000000 */
4769 0x60, 0x00, /* 0110000000 */
4770 0x00, 0x00, /* 0000000000 */
4771
4772 /* 238 0xee '.' */
4773 0x00, 0x00, /* 0000000000 */
4774 0x03, 0x80, /* 0000001110 */
4775 0x0e, 0x00, /* 0000111000 */
4776 0x18, 0x00, /* 0001100000 */
4777 0x18, 0x00, /* 0001100000 */
4778 0x30, 0x00, /* 0011000000 */
4779 0x30, 0x00, /* 0011000000 */
4780 0x3f, 0x80, /* 0011111110 */
4781 0x3f, 0x80, /* 0011111110 */
4782 0x30, 0x00, /* 0011000000 */
4783 0x30, 0x00, /* 0011000000 */
4784 0x18, 0x00, /* 0001100000 */
4785 0x18, 0x00, /* 0001100000 */
4786 0x0e, 0x00, /* 0000111000 */
4787 0x03, 0x80, /* 0000001110 */
4788 0x00, 0x00, /* 0000000000 */
4789 0x00, 0x00, /* 0000000000 */
4790 0x00, 0x00, /* 0000000000 */
4791
4792 /* 239 0xef '.' */
4793 0x00, 0x00, /* 0000000000 */
4794 0x00, 0x00, /* 0000000000 */
4795 0x00, 0x00, /* 0000000000 */
4796 0x00, 0x00, /* 0000000000 */
4797 0x1e, 0x00, /* 0001111000 */
4798 0x33, 0x00, /* 0011001100 */
4799 0x61, 0x80, /* 0110000110 */
4800 0x61, 0x80, /* 0110000110 */
4801 0x61, 0x80, /* 0110000110 */
4802 0x61, 0x80, /* 0110000110 */
4803 0x61, 0x80, /* 0110000110 */
4804 0x61, 0x80, /* 0110000110 */
4805 0x61, 0x80, /* 0110000110 */
4806 0x61, 0x80, /* 0110000110 */
4807 0x61, 0x80, /* 0110000110 */
4808 0x00, 0x00, /* 0000000000 */
4809 0x00, 0x00, /* 0000000000 */
4810 0x00, 0x00, /* 0000000000 */
4811
4812 /* 240 0xf0 '.' */
4813 0x00, 0x00, /* 0000000000 */
4814 0x00, 0x00, /* 0000000000 */
4815 0x00, 0x00, /* 0000000000 */
4816 0x00, 0x00, /* 0000000000 */
4817 0x00, 0x00, /* 0000000000 */
4818 0x7f, 0x80, /* 0111111110 */
4819 0x7f, 0x80, /* 0111111110 */
4820 0x00, 0x00, /* 0000000000 */
4821 0x00, 0x00, /* 0000000000 */
4822 0x7f, 0x80, /* 0111111110 */
4823 0x7f, 0x80, /* 0111111110 */
4824 0x00, 0x00, /* 0000000000 */
4825 0x00, 0x00, /* 0000000000 */
4826 0x7f, 0x80, /* 0111111110 */
4827 0x7f, 0x80, /* 0111111110 */
4828 0x00, 0x00, /* 0000000000 */
4829 0x00, 0x00, /* 0000000000 */
4830 0x00, 0x00, /* 0000000000 */
4831
4832 /* 241 0xf1 '.' */
4833 0x00, 0x00, /* 0000000000 */
4834 0x00, 0x00, /* 0000000000 */
4835 0x0c, 0x00, /* 0000110000 */
4836 0x0c, 0x00, /* 0000110000 */
4837 0x0c, 0x00, /* 0000110000 */
4838 0x0c, 0x00, /* 0000110000 */
4839 0x7f, 0x80, /* 0111111110 */
4840 0x7f, 0x80, /* 0111111110 */
4841 0x0c, 0x00, /* 0000110000 */
4842 0x0c, 0x00, /* 0000110000 */
4843 0x0c, 0x00, /* 0000110000 */
4844 0x0c, 0x00, /* 0000110000 */
4845 0x00, 0x00, /* 0000000000 */
4846 0x7f, 0x80, /* 0111111110 */
4847 0x7f, 0x80, /* 0111111110 */
4848 0x00, 0x00, /* 0000000000 */
4849 0x00, 0x00, /* 0000000000 */
4850 0x00, 0x00, /* 0000000000 */
4851
4852 /* 242 0xf2 '.' */
4853 0x00, 0x00, /* 0000000000 */
4854 0x00, 0x00, /* 0000000000 */
4855 0x00, 0x00, /* 0000000000 */
4856 0x00, 0x00, /* 0000000000 */
4857 0x00, 0x00, /* 0000000000 */
4858 0xe0, 0x00, /* 1110000000 */
4859 0x38, 0x00, /* 0011100000 */
4860 0x0e, 0x00, /* 0000111000 */
4861 0x03, 0x80, /* 0000001110 */
4862 0x0e, 0x00, /* 0000111000 */
4863 0x38, 0x00, /* 0011100000 */
4864 0xe0, 0x00, /* 1110000000 */
4865 0x00, 0x00, /* 0000000000 */
4866 0xff, 0x00, /* 1111111100 */
4867 0xff, 0x00, /* 1111111100 */
4868 0x00, 0x00, /* 0000000000 */
4869 0x00, 0x00, /* 0000000000 */
4870 0x00, 0x00, /* 0000000000 */
4871
4872 /* 243 0xf3 '.' */
4873 0x00, 0x00, /* 0000000000 */
4874 0x00, 0x00, /* 0000000000 */
4875 0x00, 0x00, /* 0000000000 */
4876 0x00, 0x00, /* 0000000000 */
4877 0x00, 0x00, /* 0000000000 */
4878 0x03, 0x80, /* 0000001110 */
4879 0x0e, 0x00, /* 0000111000 */
4880 0x38, 0x00, /* 0011100000 */
4881 0xe0, 0x00, /* 1110000000 */
4882 0x38, 0x00, /* 0011100000 */
4883 0x0e, 0x00, /* 0000111000 */
4884 0x03, 0x80, /* 0000001110 */
4885 0x00, 0x00, /* 0000000000 */
4886 0xff, 0x80, /* 1111111110 */
4887 0xff, 0x80, /* 1111111110 */
4888 0x00, 0x00, /* 0000000000 */
4889 0x00, 0x00, /* 0000000000 */
4890 0x00, 0x00, /* 0000000000 */
4891
4892 /* 244 0xf4 '.' */
4893 0x00, 0x00, /* 0000000000 */
4894 0x00, 0x00, /* 0000000000 */
4895 0x1e, 0x00, /* 0001111000 */
4896 0x33, 0x00, /* 0011001100 */
4897 0x33, 0x00, /* 0011001100 */
4898 0x30, 0x00, /* 0011000000 */
4899 0x30, 0x00, /* 0011000000 */
4900 0x30, 0x00, /* 0011000000 */
4901 0x30, 0x00, /* 0011000000 */
4902 0x30, 0x00, /* 0011000000 */
4903 0x30, 0x00, /* 0011000000 */
4904 0x30, 0x00, /* 0011000000 */
4905 0x30, 0x00, /* 0011000000 */
4906 0x30, 0x00, /* 0011000000 */
4907 0x30, 0x00, /* 0011000000 */
4908 0x30, 0x00, /* 0011000000 */
4909 0x30, 0x00, /* 0011000000 */
4910 0x00, 0x00, /* 0000000000 */
4911
4912 /* 245 0xf5 '.' */
4913 0x00, 0x00, /* 0000000000 */
4914 0x00, 0x00, /* 0000000000 */
4915 0x1e, 0x00, /* 0001111000 */
4916 0x33, 0x00, /* 0011001100 */
4917 0x33, 0x00, /* 0011001100 */
4918 0x03, 0x00, /* 0000001100 */
4919 0x03, 0x00, /* 0000001100 */
4920 0x03, 0x00, /* 0000001100 */
4921 0x03, 0x00, /* 0000001100 */
4922 0x03, 0x00, /* 0000001100 */
4923 0x03, 0x00, /* 0000001100 */
4924 0x03, 0x00, /* 0000001100 */
4925 0x03, 0x00, /* 0000001100 */
4926 0x03, 0x00, /* 0000001100 */
4927 0x03, 0x00, /* 0000001100 */
4928 0x03, 0x00, /* 0000001100 */
4929 0x03, 0x00, /* 0000001100 */
4930 0x00, 0x00, /* 0000000000 */
4931
4932 /* 246 0xf6 '.' */
4933 0x00, 0x00, /* 0000000000 */
4934 0x00, 0x00, /* 0000000000 */
4935 0x00, 0x00, /* 0000000000 */
4936 0x00, 0x00, /* 0000000000 */
4937 0x00, 0x00, /* 0000000000 */
4938 0x0c, 0x00, /* 0000110000 */
4939 0x0c, 0x00, /* 0000110000 */
4940 0x00, 0x00, /* 0000000000 */
4941 0x00, 0x00, /* 0000000000 */
4942 0x7f, 0x80, /* 0111111110 */
4943 0x7f, 0x80, /* 0111111110 */
4944 0x00, 0x00, /* 0000000000 */
4945 0x00, 0x00, /* 0000000000 */
4946 0x0c, 0x00, /* 0000110000 */
4947 0x0c, 0x00, /* 0000110000 */
4948 0x00, 0x00, /* 0000000000 */
4949 0x00, 0x00, /* 0000000000 */
4950 0x00, 0x00, /* 0000000000 */
4951
4952 /* 247 0xf7 '.' */
4953 0x00, 0x00, /* 0000000000 */
4954 0x00, 0x00, /* 0000000000 */
4955 0x00, 0x00, /* 0000000000 */
4956 0x00, 0x00, /* 0000000000 */
4957 0x00, 0x00, /* 0000000000 */
4958 0x00, 0x00, /* 0000000000 */
4959 0x38, 0x00, /* 0011100000 */
4960 0x6c, 0x00, /* 0110110000 */
4961 0x06, 0xc0, /* 0000011011 */
4962 0x03, 0x80, /* 0000001110 */
4963 0x38, 0x00, /* 0011100000 */
4964 0x6c, 0x00, /* 0110110000 */
4965 0x06, 0xc0, /* 0000011011 */
4966 0x03, 0x80, /* 0000001110 */
4967 0x00, 0x00, /* 0000000000 */
4968 0x00, 0x00, /* 0000000000 */
4969 0x00, 0x00, /* 0000000000 */
4970 0x00, 0x00, /* 0000000000 */
4971
4972 /* 248 0xf8 '.' */
4973 0x00, 0x00, /* 0000000000 */
4974 0x1e, 0x00, /* 0001111000 */
4975 0x33, 0x00, /* 0011001100 */
4976 0x33, 0x00, /* 0011001100 */
4977 0x1e, 0x00, /* 0001111000 */
4978 0x00, 0x00, /* 0000000000 */
4979 0x00, 0x00, /* 0000000000 */
4980 0x00, 0x00, /* 0000000000 */
4981 0x00, 0x00, /* 0000000000 */
4982 0x00, 0x00, /* 0000000000 */
4983 0x00, 0x00, /* 0000000000 */
4984 0x00, 0x00, /* 0000000000 */
4985 0x00, 0x00, /* 0000000000 */
4986 0x00, 0x00, /* 0000000000 */
4987 0x00, 0x00, /* 0000000000 */
4988 0x00, 0x00, /* 0000000000 */
4989 0x00, 0x00, /* 0000000000 */
4990 0x00, 0x00, /* 0000000000 */
4991
4992 /* 249 0xf9 '.' */
4993 0x00, 0x00, /* 0000000000 */
4994 0x00, 0x00, /* 0000000000 */
4995 0x00, 0x00, /* 0000000000 */
4996 0x00, 0x00, /* 0000000000 */
4997 0x00, 0x00, /* 0000000000 */
4998 0x00, 0x00, /* 0000000000 */
4999 0x00, 0x00, /* 0000000000 */
5000 0x00, 0x00, /* 0000000000 */
5001 0x0c, 0x00, /* 0000110000 */
5002 0x1e, 0x00, /* 0001111000 */
5003 0x1e, 0x00, /* 0001111000 */
5004 0x0c, 0x00, /* 0000110000 */
5005 0x00, 0x00, /* 0000000000 */
5006 0x00, 0x00, /* 0000000000 */
5007 0x00, 0x00, /* 0000000000 */
5008 0x00, 0x00, /* 0000000000 */
5009 0x00, 0x00, /* 0000000000 */
5010 0x00, 0x00, /* 0000000000 */
5011
5012 /* 250 0xfa '.' */
5013 0x00, 0x00, /* 0000000000 */
5014 0x00, 0x00, /* 0000000000 */
5015 0x00, 0x00, /* 0000000000 */
5016 0x00, 0x00, /* 0000000000 */
5017 0x00, 0x00, /* 0000000000 */
5018 0x00, 0x00, /* 0000000000 */
5019 0x00, 0x00, /* 0000000000 */
5020 0x00, 0x00, /* 0000000000 */
5021 0x00, 0x00, /* 0000000000 */
5022 0x0c, 0x00, /* 0000110000 */
5023 0x0c, 0x00, /* 0000110000 */
5024 0x00, 0x00, /* 0000000000 */
5025 0x00, 0x00, /* 0000000000 */
5026 0x00, 0x00, /* 0000000000 */
5027 0x00, 0x00, /* 0000000000 */
5028 0x00, 0x00, /* 0000000000 */
5029 0x00, 0x00, /* 0000000000 */
5030 0x00, 0x00, /* 0000000000 */
5031
5032 /* 251 0xfb '.' */
5033 0x00, 0x00, /* 0000000000 */
5034 0x00, 0x00, /* 0000000000 */
5035 0x0f, 0xc0, /* 0000111111 */
5036 0x0f, 0xc0, /* 0000111111 */
5037 0x0c, 0x00, /* 0000110000 */
5038 0x0c, 0x00, /* 0000110000 */
5039 0x0c, 0x00, /* 0000110000 */
5040 0x0c, 0x00, /* 0000110000 */
5041 0x0c, 0x00, /* 0000110000 */
5042 0x0c, 0x00, /* 0000110000 */
5043 0xcc, 0x00, /* 1100110000 */
5044 0x6c, 0x00, /* 0110110000 */
5045 0x3c, 0x00, /* 0011110000 */
5046 0x1c, 0x00, /* 0001110000 */
5047 0x0c, 0x00, /* 0000110000 */
5048 0x00, 0x00, /* 0000000000 */
5049 0x00, 0x00, /* 0000000000 */
5050 0x00, 0x00, /* 0000000000 */
5051
5052 /* 252 0xfc '.' */
5053 0x00, 0x00, /* 0000000000 */
5054 0x27, 0x00, /* 0010011100 */
5055 0x7b, 0x00, /* 0111101100 */
5056 0x31, 0x00, /* 0011000100 */
5057 0x31, 0x00, /* 0011000100 */
5058 0x31, 0x00, /* 0011000100 */
5059 0x7b, 0x80, /* 0111101110 */
5060 0x00, 0x00, /* 0000000000 */
5061 0x00, 0x00, /* 0000000000 */
5062 0x00, 0x00, /* 0000000000 */
5063 0x00, 0x00, /* 0000000000 */
5064 0x00, 0x00, /* 0000000000 */
5065 0x00, 0x00, /* 0000000000 */
5066 0x00, 0x00, /* 0000000000 */
5067 0x00, 0x00, /* 0000000000 */
5068 0x00, 0x00, /* 0000000000 */
5069 0x00, 0x00, /* 0000000000 */
5070 0x00, 0x00, /* 0000000000 */
5071
5072 /* 253 0xfd '.' */
5073 0x00, 0x00, /* 0000000000 */
5074 0x1e, 0x00, /* 0001111000 */
5075 0x3f, 0x00, /* 0011111100 */
5076 0x63, 0x00, /* 0110001100 */
5077 0x43, 0x00, /* 0100001100 */
5078 0x06, 0x00, /* 0000011000 */
5079 0x0c, 0x00, /* 0000110000 */
5080 0x18, 0x00, /* 0001100000 */
5081 0x30, 0x80, /* 0011000010 */
5082 0x7f, 0x80, /* 0111111110 */
5083 0x7f, 0x80, /* 0111111110 */
5084 0x00, 0x00, /* 0000000000 */
5085 0x00, 0x00, /* 0000000000 */
5086 0x00, 0x00, /* 0000000000 */
5087 0x00, 0x00, /* 0000000000 */
5088 0x00, 0x00, /* 0000000000 */
5089 0x00, 0x00, /* 0000000000 */
5090 0x00, 0x00, /* 0000000000 */
5091
5092 /* 254 0xfe '.' */
5093 0x00, 0x00, /* 0000000000 */
5094 0x00, 0x00, /* 0000000000 */
5095 0x00, 0x00, /* 0000000000 */
5096 0x3f, 0x00, /* 0011111100 */
5097 0x3f, 0x00, /* 0011111100 */
5098 0x3f, 0x00, /* 0011111100 */
5099 0x3f, 0x00, /* 0011111100 */
5100 0x3f, 0x00, /* 0011111100 */
5101 0x3f, 0x00, /* 0011111100 */
5102 0x3f, 0x00, /* 0011111100 */
5103 0x3f, 0x00, /* 0011111100 */
5104 0x3f, 0x00, /* 0011111100 */
5105 0x3f, 0x00, /* 0011111100 */
5106 0x3f, 0x00, /* 0011111100 */
5107 0x3f, 0x00, /* 0011111100 */
5108 0x00, 0x00, /* 0000000000 */
5109 0x00, 0x00, /* 0000000000 */
5110 0x00, 0x00, /* 0000000000 */
5111
5112 /* 255 0xff '.' */
5113 0x00, 0x00, /* 0000000000 */
5114 0x00, 0x00, /* 0000000000 */
5115 0x00, 0x00, /* 0000000000 */
5116 0x00, 0x00, /* 0000000000 */
5117 0x00, 0x00, /* 0000000000 */
5118 0x00, 0x00, /* 0000000000 */
5119 0x00, 0x00, /* 0000000000 */
5120 0x00, 0x00, /* 0000000000 */
5121 0x00, 0x00, /* 0000000000 */
5122 0x00, 0x00, /* 0000000000 */
5123 0x00, 0x00, /* 0000000000 */
5124 0x00, 0x00, /* 0000000000 */
5125 0x00, 0x00, /* 0000000000 */
5126 0x00, 0x00, /* 0000000000 */
5127 0x00, 0x00, /* 0000000000 */
5128 0x00, 0x00, /* 0000000000 */
5129 0x00, 0x00, /* 0000000000 */
5130 0x00, 0x00, /* 0000000000 */
5131
5132};
5133
5134
5135struct font_desc font_10x18 = {
5136 FONT10x18_IDX,
5137 "10x18",
5138 10,
5139 18,
5140 fontdata_10x18,
5141#ifdef __sparc__
5142 5
5143#else
5144 -1
5145#endif
5146};
diff --git a/drivers/video/console/font_7x14.c b/drivers/video/console/font_7x14.c
new file mode 100644
index 000000000000..1fa7fcf2ff72
--- /dev/null
+++ b/drivers/video/console/font_7x14.c
@@ -0,0 +1,4118 @@
1/**************************************/
2/* this file adapted from font_8x16.c */
3/* by Jurriaan Kalkman 05-2005 */
4/**************************************/
5
6#include <linux/font.h>
7
8#define FONTDATAMAX 3584
9
10static unsigned char fontdata_7x14[FONTDATAMAX] = {
11
12 /* 0 0x00 '^@' */
13 0x00, /* 0000000 */
14 0x00, /* 0000000 */
15 0x00, /* 0000000 */
16 0x00, /* 0000000 */
17 0x00, /* 0000000 */
18 0x00, /* 0000000 */
19 0x00, /* 0000000 */
20 0x00, /* 0000000 */
21 0x00, /* 0000000 */
22 0x00, /* 0000000 */
23 0x00, /* 0000000 */
24 0x00, /* 0000000 */
25 0x00, /* 0000000 */
26 0x00, /* 0000000 */
27
28 /* 1 0x01 '^A' */
29 0x00, /* 0000000 */
30 0x7c, /* 0111110 */
31 0x82, /* 1000001 */
32 0xaa, /* 1010101 */
33 0x82, /* 1000001 */
34 0x82, /* 1000001 */
35 0xba, /* 1011101 */
36 0x92, /* 1001001 */
37 0x82, /* 1000001 */
38 0x7c, /* 0111110 */
39 0x00, /* 0000000 */
40 0x00, /* 0000000 */
41 0x00, /* 0000000 */
42 0x00, /* 0000000 */
43
44 /* 2 0x02 '^B' */
45 0x00, /* 0000000 */
46 0x7c, /* 0111110 */
47 0xfe, /* 1111111 */
48 0xd6, /* 1101011 */
49 0xfe, /* 1111111 */
50 0xfe, /* 1111111 */
51 0xc6, /* 1100011 */
52 0xee, /* 1110111 */
53 0xfe, /* 1111111 */
54 0xfe, /* 1111111 */
55 0x7c, /* 0111110 */
56 0x00, /* 0000000 */
57 0x00, /* 0000000 */
58 0x00, /* 0000000 */
59
60 /* 3 0x03 '^C' */
61 0x00, /* 0000000 */
62 0x00, /* 0000000 */
63 0x00, /* 0000000 */
64 0x00, /* 0000000 */
65 0x6c, /* 0110110 */
66 0x7c, /* 0111110 */
67 0xfe, /* 1111111 */
68 0x7c, /* 0111110 */
69 0x38, /* 0011100 */
70 0x18, /* 0001100 */
71 0x10, /* 0001000 */
72 0x00, /* 0000000 */
73 0x00, /* 0000000 */
74 0x00, /* 0000000 */
75
76 /* 4 0x04 '^D' */
77 0x00, /* 0000000 */
78 0x00, /* 0000000 */
79 0x00, /* 0000000 */
80 0x10, /* 0001000 */
81 0x38, /* 0011100 */
82 0x7c, /* 0111110 */
83 0xfe, /* 1111111 */
84 0x7c, /* 0111110 */
85 0x38, /* 0011100 */
86 0x10, /* 0001000 */
87 0x00, /* 0000000 */
88 0x00, /* 0000000 */
89 0x00, /* 0000000 */
90 0x00, /* 0000000 */
91
92 /* 5 0x05 '^E' */
93 0x00, /* 0000000 */
94 0x00, /* 0000000 */
95 0x38, /* 0011100 */
96 0x38, /* 0011100 */
97 0x38, /* 0011100 */
98 0xee, /* 1110111 */
99 0xee, /* 1110111 */
100 0xee, /* 1110111 */
101 0x10, /* 0001000 */
102 0x10, /* 0001000 */
103 0x38, /* 0011100 */
104 0x00, /* 0000000 */
105 0x00, /* 0000000 */
106 0x00, /* 0000000 */
107
108 /* 6 0x06 '^F' */
109 0x00, /* 0000000 */
110 0x00, /* 0000000 */
111 0x10, /* 0001000 */
112 0x38, /* 0011100 */
113 0x7c, /* 0111110 */
114 0xfe, /* 1111111 */
115 0xfe, /* 1111111 */
116 0x7c, /* 0111110 */
117 0x10, /* 0001000 */
118 0x10, /* 0001000 */
119 0x38, /* 0011100 */
120 0x00, /* 0000000 */
121 0x00, /* 0000000 */
122 0x00, /* 0000000 */
123
124 /* 7 0x07 '^G' */
125 0x00, /* 0000000 */
126 0x00, /* 0000000 */
127 0x00, /* 0000000 */
128 0x00, /* 0000000 */
129 0x00, /* 0000000 */
130 0x18, /* 0001100 */
131 0x3c, /* 0011110 */
132 0x3c, /* 0011110 */
133 0x18, /* 0001100 */
134 0x00, /* 0000000 */
135 0x00, /* 0000000 */
136 0x00, /* 0000000 */
137 0x00, /* 0000000 */
138 0x00, /* 0000000 */
139
140 /* 8 0x08 '^H' */
141 0xfe, /* 1111111 */
142 0xfe, /* 1111111 */
143 0xfe, /* 1111111 */
144 0xfe, /* 1111111 */
145 0xfe, /* 1111111 */
146 0xe6, /* 1110011 */
147 0xc2, /* 1100001 */
148 0xc2, /* 1100001 */
149 0xe6, /* 1110011 */
150 0xfe, /* 1111111 */
151 0xfe, /* 1111111 */
152 0xfe, /* 1111111 */
153 0xfe, /* 1111111 */
154 0xfe, /* 1111111 */
155
156 /* 9 0x09 '^I' */
157 0x00, /* 0000000 */
158 0x00, /* 0000000 */
159 0x00, /* 0000000 */
160 0x00, /* 0000000 */
161 0x00, /* 0000000 */
162 0x38, /* 0011100 */
163 0x6c, /* 0110110 */
164 0x44, /* 0100010 */
165 0x6c, /* 0110110 */
166 0x38, /* 0011100 */
167 0x00, /* 0000000 */
168 0x00, /* 0000000 */
169 0x00, /* 0000000 */
170 0x00, /* 0000000 */
171
172 /* 10 0x0a '^J' */
173 0xfe, /* 1111111 */
174 0xfe, /* 1111111 */
175 0xfe, /* 1111111 */
176 0xfe, /* 1111111 */
177 0xfe, /* 1111111 */
178 0xc6, /* 1100011 */
179 0x92, /* 1001001 */
180 0xba, /* 1011101 */
181 0x92, /* 1001001 */
182 0xc6, /* 1100011 */
183 0xfe, /* 1111111 */
184 0xfe, /* 1111111 */
185 0xfe, /* 1111111 */
186 0xfe, /* 1111111 */
187
188 /* 11 0x0b '^K' */
189 0x00, /* 0000000 */
190 0x1e, /* 0001111 */
191 0x0e, /* 0000111 */
192 0x1a, /* 0001101 */
193 0x1a, /* 0001101 */
194 0x78, /* 0111100 */
195 0xcc, /* 1100110 */
196 0xcc, /* 1100110 */
197 0xcc, /* 1100110 */
198 0xcc, /* 1100110 */
199 0x78, /* 0111100 */
200 0x00, /* 0000000 */
201 0x00, /* 0000000 */
202 0x00, /* 0000000 */
203
204 /* 12 0x0c '^L' */
205 0x00, /* 0000000 */
206 0x3c, /* 0011110 */
207 0x66, /* 0110011 */
208 0x66, /* 0110011 */
209 0x66, /* 0110011 */
210 0x66, /* 0110011 */
211 0x3c, /* 0011110 */
212 0x18, /* 0001100 */
213 0x7e, /* 0111111 */
214 0x18, /* 0001100 */
215 0x18, /* 0001100 */
216 0x00, /* 0000000 */
217 0x00, /* 0000000 */
218 0x00, /* 0000000 */
219
220 /* 13 0x0d '^M' */
221 0x00, /* 0000000 */
222 0x3e, /* 0011111 */
223 0x36, /* 0011011 */
224 0x3e, /* 0011111 */
225 0x30, /* 0011000 */
226 0x30, /* 0011000 */
227 0x30, /* 0011000 */
228 0x30, /* 0011000 */
229 0x70, /* 0111000 */
230 0xf0, /* 1111000 */
231 0xe0, /* 1110000 */
232 0x00, /* 0000000 */
233 0x00, /* 0000000 */
234 0x00, /* 0000000 */
235
236 /* 14 0x0e '^N' */
237 0x00, /* 0000000 */
238 0x7e, /* 0111111 */
239 0x66, /* 0110011 */
240 0x7e, /* 0111111 */
241 0x66, /* 0110011 */
242 0x66, /* 0110011 */
243 0x66, /* 0110011 */
244 0x66, /* 0110011 */
245 0x6e, /* 0110111 */
246 0xee, /* 1110111 */
247 0xec, /* 1110110 */
248 0xc0, /* 1100000 */
249 0x00, /* 0000000 */
250 0x00, /* 0000000 */
251
252 /* 15 0x0f '^O' */
253 0x00, /* 0000000 */
254 0x00, /* 0000000 */
255 0x10, /* 0001000 */
256 0x10, /* 0001000 */
257 0xd6, /* 1101011 */
258 0x38, /* 0011100 */
259 0xee, /* 1110111 */
260 0x38, /* 0011100 */
261 0xd6, /* 1101011 */
262 0x10, /* 0001000 */
263 0x10, /* 0001000 */
264 0x00, /* 0000000 */
265 0x00, /* 0000000 */
266 0x00, /* 0000000 */
267
268 /* 16 0x10 '^P' */
269 0x00, /* 0000000 */
270 0x80, /* 1000000 */
271 0xc0, /* 1100000 */
272 0xe0, /* 1110000 */
273 0xf0, /* 1111000 */
274 0xfc, /* 1111110 */
275 0xf0, /* 1111000 */
276 0xe0, /* 1110000 */
277 0xc0, /* 1100000 */
278 0x80, /* 1000000 */
279 0x00, /* 0000000 */
280 0x00, /* 0000000 */
281 0x00, /* 0000000 */
282 0x00, /* 0000000 */
283
284 /* 17 0x11 '^Q' */
285 0x00, /* 0000000 */
286 0x04, /* 0000010 */
287 0x0c, /* 0000110 */
288 0x1c, /* 0001110 */
289 0x3c, /* 0011110 */
290 0xfc, /* 1111110 */
291 0x3c, /* 0011110 */
292 0x1c, /* 0001110 */
293 0x0c, /* 0000110 */
294 0x04, /* 0000010 */
295 0x00, /* 0000000 */
296 0x00, /* 0000000 */
297 0x00, /* 0000000 */
298 0x00, /* 0000000 */
299
300 /* 18 0x12 '^R' */
301 0x00, /* 0000000 */
302 0x18, /* 0001100 */
303 0x3c, /* 0011110 */
304 0x7e, /* 0111111 */
305 0x18, /* 0001100 */
306 0x18, /* 0001100 */
307 0x18, /* 0001100 */
308 0x7e, /* 0111111 */
309 0x3c, /* 0011110 */
310 0x18, /* 0001100 */
311 0x00, /* 0000000 */
312 0x00, /* 0000000 */
313 0x00, /* 0000000 */
314 0x00, /* 0000000 */
315
316 /* 19 0x13 '^S' */
317 0x00, /* 0000000 */
318 0x6c, /* 0110110 */
319 0x6c, /* 0110110 */
320 0x6c, /* 0110110 */
321 0x6c, /* 0110110 */
322 0x6c, /* 0110110 */
323 0x6c, /* 0110110 */
324 0x6c, /* 0110110 */
325 0x00, /* 0000000 */
326 0x6c, /* 0110110 */
327 0x6c, /* 0110110 */
328 0x00, /* 0000000 */
329 0x00, /* 0000000 */
330 0x00, /* 0000000 */
331
332 /* 20 0x14 '^T' */
333 0x00, /* 0000000 */
334 0x7e, /* 0111111 */
335 0xd4, /* 1101010 */
336 0xd4, /* 1101010 */
337 0xd4, /* 1101010 */
338 0x74, /* 0111010 */
339 0x14, /* 0001010 */
340 0x14, /* 0001010 */
341 0x14, /* 0001010 */
342 0x14, /* 0001010 */
343 0x16, /* 0001011 */
344 0x00, /* 0000000 */
345 0x00, /* 0000000 */
346 0x00, /* 0000000 */
347
348 /* 21 0x15 '^U' */
349 0x78, /* 0111100 */
350 0xcc, /* 1100110 */
351 0x60, /* 0110000 */
352 0x38, /* 0011100 */
353 0x6c, /* 0110110 */
354 0xc6, /* 1100011 */
355 0xc6, /* 1100011 */
356 0x6c, /* 0110110 */
357 0x38, /* 0011100 */
358 0x18, /* 0001100 */
359 0xcc, /* 1100110 */
360 0x78, /* 0111100 */
361 0x00, /* 0000000 */
362 0x00, /* 0000000 */
363
364 /* 22 0x16 '^V' */
365 0x00, /* 0000000 */
366 0x00, /* 0000000 */
367 0x00, /* 0000000 */
368 0x00, /* 0000000 */
369 0x00, /* 0000000 */
370 0x00, /* 0000000 */
371 0x00, /* 0000000 */
372 0xfc, /* 1111110 */
373 0xfc, /* 1111110 */
374 0xfc, /* 1111110 */
375 0xfc, /* 1111110 */
376 0x00, /* 0000000 */
377 0x00, /* 0000000 */
378 0x00, /* 0000000 */
379
380 /* 23 0x17 '^W' */
381 0x00, /* 0000000 */
382 0x18, /* 0001100 */
383 0x3c, /* 0011110 */
384 0x7e, /* 0111111 */
385 0x18, /* 0001100 */
386 0x18, /* 0001100 */
387 0x18, /* 0001100 */
388 0x7e, /* 0111111 */
389 0x3c, /* 0011110 */
390 0x18, /* 0001100 */
391 0x7e, /* 0111111 */
392 0x00, /* 0000000 */
393 0x00, /* 0000000 */
394 0x00, /* 0000000 */
395
396 /* 24 0x18 '^X' */
397 0x00, /* 0000000 */
398 0x18, /* 0001100 */
399 0x3c, /* 0011110 */
400 0x7e, /* 0111111 */
401 0x18, /* 0001100 */
402 0x18, /* 0001100 */
403 0x18, /* 0001100 */
404 0x18, /* 0001100 */
405 0x18, /* 0001100 */
406 0x18, /* 0001100 */
407 0x18, /* 0001100 */
408 0x00, /* 0000000 */
409 0x00, /* 0000000 */
410 0x00, /* 0000000 */
411
412 /* 25 0x19 '^Y' */
413 0x00, /* 0000000 */
414 0x18, /* 0001100 */
415 0x18, /* 0001100 */
416 0x18, /* 0001100 */
417 0x18, /* 0001100 */
418 0x18, /* 0001100 */
419 0x18, /* 0001100 */
420 0x18, /* 0001100 */
421 0x7e, /* 0111111 */
422 0x3c, /* 0011110 */
423 0x18, /* 0001100 */
424 0x00, /* 0000000 */
425 0x00, /* 0000000 */
426 0x00, /* 0000000 */
427
428 /* 26 0x1a '^Z' */
429 0x00, /* 0000000 */
430 0x00, /* 0000000 */
431 0x00, /* 0000000 */
432 0x00, /* 0000000 */
433 0x30, /* 0011000 */
434 0x18, /* 0001100 */
435 0xfc, /* 1111110 */
436 0x18, /* 0001100 */
437 0x30, /* 0011000 */
438 0x00, /* 0000000 */
439 0x00, /* 0000000 */
440 0x00, /* 0000000 */
441 0x00, /* 0000000 */
442 0x00, /* 0000000 */
443
444 /* 27 0x1b '^[' */
445 0x00, /* 0000000 */
446 0x00, /* 0000000 */
447 0x00, /* 0000000 */
448 0x00, /* 0000000 */
449 0x30, /* 0011000 */
450 0x60, /* 0110000 */
451 0xfc, /* 1111110 */
452 0x60, /* 0110000 */
453 0x30, /* 0011000 */
454 0x00, /* 0000000 */
455 0x00, /* 0000000 */
456 0x00, /* 0000000 */
457 0x00, /* 0000000 */
458 0x00, /* 0000000 */
459
460 /* 28 0x1c '^\' */
461 0x00, /* 0000000 */
462 0x00, /* 0000000 */
463 0x00, /* 0000000 */
464 0x00, /* 0000000 */
465 0x00, /* 0000000 */
466 0xc0, /* 1100000 */
467 0xc0, /* 1100000 */
468 0xc0, /* 1100000 */
469 0xfc, /* 1111110 */
470 0x00, /* 0000000 */
471 0x00, /* 0000000 */
472 0x00, /* 0000000 */
473 0x00, /* 0000000 */
474 0x00, /* 0000000 */
475
476 /* 29 0x1d '^]' */
477 0x00, /* 0000000 */
478 0x00, /* 0000000 */
479 0x00, /* 0000000 */
480 0x00, /* 0000000 */
481 0x28, /* 0010100 */
482 0x6c, /* 0110110 */
483 0xfe, /* 1111111 */
484 0x6c, /* 0110110 */
485 0x28, /* 0010100 */
486 0x00, /* 0000000 */
487 0x00, /* 0000000 */
488 0x00, /* 0000000 */
489 0x00, /* 0000000 */
490 0x00, /* 0000000 */
491
492 /* 30 0x1e '^^' */
493 0x00, /* 0000000 */
494 0x00, /* 0000000 */
495 0x00, /* 0000000 */
496 0x00, /* 0000000 */
497 0x30, /* 0011000 */
498 0x30, /* 0011000 */
499 0x78, /* 0111100 */
500 0x78, /* 0111100 */
501 0xfc, /* 1111110 */
502 0xfc, /* 1111110 */
503 0x00, /* 0000000 */
504 0x00, /* 0000000 */
505 0x00, /* 0000000 */
506 0x00, /* 0000000 */
507
508 /* 31 0x1f '^_' */
509 0x00, /* 0000000 */
510 0x00, /* 0000000 */
511 0x00, /* 0000000 */
512 0x00, /* 0000000 */
513 0xfc, /* 1111110 */
514 0xfc, /* 1111110 */
515 0x78, /* 0111100 */
516 0x78, /* 0111100 */
517 0x30, /* 0011000 */
518 0x30, /* 0011000 */
519 0x00, /* 0000000 */
520 0x00, /* 0000000 */
521 0x00, /* 0000000 */
522 0x00, /* 0000000 */
523
524 /* 32 0x20 ' ' */
525 0x00, /* 0000000 */
526 0x00, /* 0000000 */
527 0x00, /* 0000000 */
528 0x00, /* 0000000 */
529 0x00, /* 0000000 */
530 0x00, /* 0000000 */
531 0x00, /* 0000000 */
532 0x00, /* 0000000 */
533 0x00, /* 0000000 */
534 0x00, /* 0000000 */
535 0x00, /* 0000000 */
536 0x00, /* 0000000 */
537 0x00, /* 0000000 */
538 0x00, /* 0000000 */
539
540 /* 33 0x21 '!' */
541 0x00, /* 0000000 */
542 0x18, /* 0001100 */
543 0x3c, /* 0011110 */
544 0x3c, /* 0011110 */
545 0x3c, /* 0011110 */
546 0x18, /* 0001100 */
547 0x18, /* 0001100 */
548 0x18, /* 0001100 */
549 0x00, /* 0000000 */
550 0x18, /* 0001100 */
551 0x18, /* 0001100 */
552 0x00, /* 0000000 */
553 0x00, /* 0000000 */
554 0x00, /* 0000000 */
555
556 /* 34 0x22 '"' */
557 0x00, /* 0000000 */
558 0x6c, /* 0110110 */
559 0x6c, /* 0110110 */
560 0x6c, /* 0110110 */
561 0x28, /* 0010100 */
562 0x00, /* 0000000 */
563 0x00, /* 0000000 */
564 0x00, /* 0000000 */
565 0x00, /* 0000000 */
566 0x00, /* 0000000 */
567 0x00, /* 0000000 */
568 0x00, /* 0000000 */
569 0x00, /* 0000000 */
570 0x00, /* 0000000 */
571
572 /* 35 0x23 '#' */
573 0x00, /* 0000000 */
574 0x6c, /* 0110110 */
575 0x6c, /* 0110110 */
576 0xfe, /* 1111111 */
577 0xfe, /* 1111111 */
578 0x6c, /* 0110110 */
579 0x6c, /* 0110110 */
580 0xfe, /* 1111111 */
581 0xfe, /* 1111111 */
582 0x6c, /* 0110110 */
583 0x6c, /* 0110110 */
584 0x00, /* 0000000 */
585 0x00, /* 0000000 */
586 0x00, /* 0000000 */
587
588 /* 36 0x24 '$' */
589 0x30, /* 0011000 */
590 0x30, /* 0011000 */
591 0x78, /* 0111100 */
592 0xcc, /* 1100110 */
593 0xc4, /* 1100010 */
594 0xc0, /* 1100000 */
595 0x78, /* 0111100 */
596 0x0c, /* 0000110 */
597 0x8c, /* 1000110 */
598 0xcc, /* 1100110 */
599 0x78, /* 0111100 */
600 0x30, /* 0011000 */
601 0x30, /* 0011000 */
602 0x00, /* 0000000 */
603
604 /* 37 0x25 '%' */
605 0x00, /* 0000000 */
606 0x00, /* 0000000 */
607 0x00, /* 0000000 */
608 0xc0, /* 1100000 */
609 0xc4, /* 1100010 */
610 0x0c, /* 0000110 */
611 0x18, /* 0001100 */
612 0x30, /* 0011000 */
613 0x60, /* 0110000 */
614 0xcc, /* 1100110 */
615 0x8c, /* 1000110 */
616 0x00, /* 0000000 */
617 0x00, /* 0000000 */
618 0x00, /* 0000000 */
619
620 /* 38 0x26 '&' */
621 0x00, /* 0000000 */
622 0x38, /* 0011100 */
623 0x6c, /* 0110110 */
624 0x6c, /* 0110110 */
625 0x38, /* 0011100 */
626 0x78, /* 0111100 */
627 0xde, /* 1101111 */
628 0xcc, /* 1100110 */
629 0xcc, /* 1100110 */
630 0xdc, /* 1101110 */
631 0x76, /* 0111011 */
632 0x00, /* 0000000 */
633 0x00, /* 0000000 */
634 0x00, /* 0000000 */
635
636 /* 39 0x27 ''' */
637 0x00, /* 0000000 */
638 0x30, /* 0011000 */
639 0x30, /* 0011000 */
640 0x30, /* 0011000 */
641 0x60, /* 0110000 */
642 0x00, /* 0000000 */
643 0x00, /* 0000000 */
644 0x00, /* 0000000 */
645 0x00, /* 0000000 */
646 0x00, /* 0000000 */
647 0x00, /* 0000000 */
648 0x00, /* 0000000 */
649 0x00, /* 0000000 */
650 0x00, /* 0000000 */
651
652 /* 40 0x28 '(' */
653 0x00, /* 0000000 */
654 0x0c, /* 0000110 */
655 0x18, /* 0001100 */
656 0x30, /* 0011000 */
657 0x30, /* 0011000 */
658 0x30, /* 0011000 */
659 0x30, /* 0011000 */
660 0x30, /* 0011000 */
661 0x30, /* 0011000 */
662 0x18, /* 0001100 */
663 0x0c, /* 0000110 */
664 0x00, /* 0000000 */
665 0x00, /* 0000000 */
666 0x00, /* 0000000 */
667
668 /* 41 0x29 ')' */
669 0x00, /* 0000000 */
670 0x30, /* 0011000 */
671 0x18, /* 0001100 */
672 0x0c, /* 0000110 */
673 0x0c, /* 0000110 */
674 0x0c, /* 0000110 */
675 0x0c, /* 0000110 */
676 0x0c, /* 0000110 */
677 0x0c, /* 0000110 */
678 0x18, /* 0001100 */
679 0x30, /* 0011000 */
680 0x00, /* 0000000 */
681 0x00, /* 0000000 */
682 0x00, /* 0000000 */
683
684 /* 42 0x2a '*' */
685 0x00, /* 0000000 */
686 0x00, /* 0000000 */
687 0x00, /* 0000000 */
688 0x00, /* 0000000 */
689 0x6c, /* 0110110 */
690 0x38, /* 0011100 */
691 0xfe, /* 1111111 */
692 0x38, /* 0011100 */
693 0x6c, /* 0110110 */
694 0x00, /* 0000000 */
695 0x00, /* 0000000 */
696 0x00, /* 0000000 */
697 0x00, /* 0000000 */
698 0x00, /* 0000000 */
699
700 /* 43 0x2b '+' */
701 0x00, /* 0000000 */
702 0x00, /* 0000000 */
703 0x00, /* 0000000 */
704 0x00, /* 0000000 */
705 0x10, /* 0001000 */
706 0x10, /* 0001000 */
707 0x7c, /* 0111110 */
708 0x10, /* 0001000 */
709 0x10, /* 0001000 */
710 0x00, /* 0000000 */
711 0x00, /* 0000000 */
712 0x00, /* 0000000 */
713 0x00, /* 0000000 */
714 0x00, /* 0000000 */
715
716 /* 44 0x2c ',' */
717 0x00, /* 0000000 */
718 0x00, /* 0000000 */
719 0x00, /* 0000000 */
720 0x00, /* 0000000 */
721 0x00, /* 0000000 */
722 0x00, /* 0000000 */
723 0x00, /* 0000000 */
724 0x00, /* 0000000 */
725 0x18, /* 0001100 */
726 0x18, /* 0001100 */
727 0x18, /* 0001100 */
728 0x30, /* 0011000 */
729 0x00, /* 0000000 */
730 0x00, /* 0000000 */
731
732 /* 45 0x2d '-' */
733 0x00, /* 0000000 */
734 0x00, /* 0000000 */
735 0x00, /* 0000000 */
736 0x00, /* 0000000 */
737 0x00, /* 0000000 */
738 0x00, /* 0000000 */
739 0xfc, /* 1111110 */
740 0x00, /* 0000000 */
741 0x00, /* 0000000 */
742 0x00, /* 0000000 */
743 0x00, /* 0000000 */
744 0x00, /* 0000000 */
745 0x00, /* 0000000 */
746 0x00, /* 0000000 */
747
748 /* 46 0x2e '.' */
749 0x00, /* 0000000 */
750 0x00, /* 0000000 */
751 0x00, /* 0000000 */
752 0x00, /* 0000000 */
753 0x00, /* 0000000 */
754 0x00, /* 0000000 */
755 0x00, /* 0000000 */
756 0x00, /* 0000000 */
757 0x00, /* 0000000 */
758 0x18, /* 0001100 */
759 0x18, /* 0001100 */
760 0x00, /* 0000000 */
761 0x00, /* 0000000 */
762 0x00, /* 0000000 */
763
764 /* 47 0x2f '/' */
765 0x00, /* 0000000 */
766 0x00, /* 0000000 */
767 0x00, /* 0000000 */
768 0x00, /* 0000000 */
769 0x04, /* 0000010 */
770 0x0c, /* 0000110 */
771 0x18, /* 0001100 */
772 0x30, /* 0011000 */
773 0x60, /* 0110000 */
774 0xc0, /* 1100000 */
775 0x80, /* 1000000 */
776 0x00, /* 0000000 */
777 0x00, /* 0000000 */
778 0x00, /* 0000000 */
779
780 /* 48 0x30 '0' */
781 0x00, /* 0000000 */
782 0x30, /* 0011000 */
783 0x78, /* 0111100 */
784 0xcc, /* 1100110 */
785 0xcc, /* 1100110 */
786 0xdc, /* 1101110 */
787 0xec, /* 1110110 */
788 0xcc, /* 1100110 */
789 0xcc, /* 1100110 */
790 0x78, /* 0111100 */
791 0x30, /* 0011000 */
792 0x00, /* 0000000 */
793 0x00, /* 0000000 */
794 0x00, /* 0000000 */
795
796 /* 49 0x31 '1' */
797 0x00, /* 0000000 */
798 0x18, /* 0001100 */
799 0x38, /* 0011100 */
800 0x78, /* 0111100 */
801 0x18, /* 0001100 */
802 0x18, /* 0001100 */
803 0x18, /* 0001100 */
804 0x18, /* 0001100 */
805 0x18, /* 0001100 */
806 0x18, /* 0001100 */
807 0x7c, /* 0111110 */
808 0x00, /* 0000000 */
809 0x00, /* 0000000 */
810 0x00, /* 0000000 */
811
812 /* 50 0x32 '2' */
813 0x00, /* 0000000 */
814 0x78, /* 0111100 */
815 0xcc, /* 1100110 */
816 0x0c, /* 0000110 */
817 0x18, /* 0001100 */
818 0x18, /* 0001100 */
819 0x30, /* 0011000 */
820 0x60, /* 0110000 */
821 0xc0, /* 1100000 */
822 0xcc, /* 1100110 */
823 0xfc, /* 1111110 */
824 0x00, /* 0000000 */
825 0x00, /* 0000000 */
826 0x00, /* 0000000 */
827
828 /* 51 0x33 '3' */
829 0x00, /* 0000000 */
830 0x78, /* 0111100 */
831 0xcc, /* 1100110 */
832 0x0c, /* 0000110 */
833 0x0c, /* 0000110 */
834 0x38, /* 0011100 */
835 0x0c, /* 0000110 */
836 0x0c, /* 0000110 */
837 0x0c, /* 0000110 */
838 0xcc, /* 1100110 */
839 0x78, /* 0111100 */
840 0x00, /* 0000000 */
841 0x00, /* 0000000 */
842 0x00, /* 0000000 */
843
844 /* 52 0x34 '4' */
845 0x00, /* 0000000 */
846 0x0c, /* 0000110 */
847 0x1c, /* 0001110 */
848 0x3c, /* 0011110 */
849 0x6c, /* 0110110 */
850 0xcc, /* 1100110 */
851 0xfe, /* 1111111 */
852 0x0c, /* 0000110 */
853 0x0c, /* 0000110 */
854 0x0c, /* 0000110 */
855 0x0c, /* 0000110 */
856 0x00, /* 0000000 */
857 0x00, /* 0000000 */
858 0x00, /* 0000000 */
859
860 /* 53 0x35 '5' */
861 0x00, /* 0000000 */
862 0xfc, /* 1111110 */
863 0xc0, /* 1100000 */
864 0xc0, /* 1100000 */
865 0xc0, /* 1100000 */
866 0xf8, /* 1111100 */
867 0x0c, /* 0000110 */
868 0x0c, /* 0000110 */
869 0x0c, /* 0000110 */
870 0xcc, /* 1100110 */
871 0x78, /* 0111100 */
872 0x00, /* 0000000 */
873 0x00, /* 0000000 */
874 0x00, /* 0000000 */
875
876 /* 54 0x36 '6' */
877 0x00, /* 0000000 */
878 0x30, /* 0011000 */
879 0x60, /* 0110000 */
880 0xc0, /* 1100000 */
881 0xc0, /* 1100000 */
882 0xf8, /* 1111100 */
883 0xcc, /* 1100110 */
884 0xcc, /* 1100110 */
885 0xcc, /* 1100110 */
886 0xcc, /* 1100110 */
887 0x78, /* 0111100 */
888 0x00, /* 0000000 */
889 0x00, /* 0000000 */
890 0x00, /* 0000000 */
891
892 /* 55 0x37 '7' */
893 0x00, /* 0000000 */
894 0xfc, /* 1111110 */
895 0xcc, /* 1100110 */
896 0x0c, /* 0000110 */
897 0x0c, /* 0000110 */
898 0x18, /* 0001100 */
899 0x18, /* 0001100 */
900 0x30, /* 0011000 */
901 0x30, /* 0011000 */
902 0x30, /* 0011000 */
903 0x30, /* 0011000 */
904 0x00, /* 0000000 */
905 0x00, /* 0000000 */
906 0x00, /* 0000000 */
907
908 /* 56 0x38 '8' */
909 0x00, /* 0000000 */
910 0x78, /* 0111100 */
911 0xcc, /* 1100110 */
912 0xcc, /* 1100110 */
913 0xcc, /* 1100110 */
914 0x78, /* 0111100 */
915 0xcc, /* 1100110 */
916 0xcc, /* 1100110 */
917 0xcc, /* 1100110 */
918 0xcc, /* 1100110 */
919 0x78, /* 0111100 */
920 0x00, /* 0000000 */
921 0x00, /* 0000000 */
922 0x00, /* 0000000 */
923
924 /* 57 0x39 '9' */
925 0x00, /* 0000000 */
926 0x78, /* 0111100 */
927 0xcc, /* 1100110 */
928 0xcc, /* 1100110 */
929 0xcc, /* 1100110 */
930 0x7c, /* 0111110 */
931 0x0c, /* 0000110 */
932 0x0c, /* 0000110 */
933 0x0c, /* 0000110 */
934 0x18, /* 0001100 */
935 0x70, /* 0111000 */
936 0x00, /* 0000000 */
937 0x00, /* 0000000 */
938 0x00, /* 0000000 */
939
940 /* 58 0x3a ':' */
941 0x00, /* 0000000 */
942 0x00, /* 0000000 */
943 0x00, /* 0000000 */
944 0x18, /* 0001100 */
945 0x18, /* 0001100 */
946 0x00, /* 0000000 */
947 0x00, /* 0000000 */
948 0x00, /* 0000000 */
949 0x18, /* 0001100 */
950 0x18, /* 0001100 */
951 0x00, /* 0000000 */
952 0x00, /* 0000000 */
953 0x00, /* 0000000 */
954 0x00, /* 0000000 */
955
956 /* 59 0x3b ';' */
957 0x00, /* 0000000 */
958 0x00, /* 0000000 */
959 0x00, /* 0000000 */
960 0x18, /* 0001100 */
961 0x18, /* 0001100 */
962 0x00, /* 0000000 */
963 0x00, /* 0000000 */
964 0x00, /* 0000000 */
965 0x18, /* 0001100 */
966 0x18, /* 0001100 */
967 0x30, /* 0011000 */
968 0x00, /* 0000000 */
969 0x00, /* 0000000 */
970 0x00, /* 0000000 */
971
972 /* 60 0x3c '<' */
973 0x00, /* 0000000 */
974 0x00, /* 0000000 */
975 0x04, /* 0000010 */
976 0x0c, /* 0000110 */
977 0x18, /* 0001100 */
978 0x30, /* 0011000 */
979 0x60, /* 0110000 */
980 0x30, /* 0011000 */
981 0x18, /* 0001100 */
982 0x0c, /* 0000110 */
983 0x04, /* 0000010 */
984 0x00, /* 0000000 */
985 0x00, /* 0000000 */
986 0x00, /* 0000000 */
987
988 /* 61 0x3d '=' */
989 0x00, /* 0000000 */
990 0x00, /* 0000000 */
991 0x00, /* 0000000 */
992 0x00, /* 0000000 */
993 0x7c, /* 0111110 */
994 0x00, /* 0000000 */
995 0x00, /* 0000000 */
996 0x7c, /* 0111110 */
997 0x00, /* 0000000 */
998 0x00, /* 0000000 */
999 0x00, /* 0000000 */
1000 0x00, /* 0000000 */
1001 0x00, /* 0000000 */
1002 0x00, /* 0000000 */
1003
1004 /* 62 0x3e '>' */
1005 0x00, /* 0000000 */
1006 0x00, /* 0000000 */
1007 0x40, /* 0100000 */
1008 0x60, /* 0110000 */
1009 0x30, /* 0011000 */
1010 0x18, /* 0001100 */
1011 0x0c, /* 0000110 */
1012 0x18, /* 0001100 */
1013 0x30, /* 0011000 */
1014 0x60, /* 0110000 */
1015 0x40, /* 0100000 */
1016 0x00, /* 0000000 */
1017 0x00, /* 0000000 */
1018 0x00, /* 0000000 */
1019
1020 /* 63 0x3f '?' */
1021 0x00, /* 0000000 */
1022 0x78, /* 0111100 */
1023 0xcc, /* 1100110 */
1024 0xcc, /* 1100110 */
1025 0x18, /* 0001100 */
1026 0x30, /* 0011000 */
1027 0x30, /* 0011000 */
1028 0x30, /* 0011000 */
1029 0x00, /* 0000000 */
1030 0x30, /* 0011000 */
1031 0x30, /* 0011000 */
1032 0x00, /* 0000000 */
1033 0x00, /* 0000000 */
1034 0x00, /* 0000000 */
1035
1036 /* 64 0x40 '@' */
1037 0x00, /* 0000000 */
1038 0x00, /* 0000000 */
1039 0x00, /* 0000000 */
1040 0x78, /* 0111100 */
1041 0xcc, /* 1100110 */
1042 0xcc, /* 1100110 */
1043 0xdc, /* 1101110 */
1044 0xdc, /* 1101110 */
1045 0xd8, /* 1101100 */
1046 0xc0, /* 1100000 */
1047 0x78, /* 0111100 */
1048 0x00, /* 0000000 */
1049 0x00, /* 0000000 */
1050 0x00, /* 0000000 */
1051
1052 /* 65 0x41 'A' */
1053 0x00, /* 0000000 */
1054 0x30, /* 0011000 */
1055 0x78, /* 0111100 */
1056 0xcc, /* 1100110 */
1057 0xcc, /* 1100110 */
1058 0xcc, /* 1100110 */
1059 0xfc, /* 1111110 */
1060 0xcc, /* 1100110 */
1061 0xcc, /* 1100110 */
1062 0xcc, /* 1100110 */
1063 0xcc, /* 1100110 */
1064 0x00, /* 0000000 */
1065 0x00, /* 0000000 */
1066 0x00, /* 0000000 */
1067
1068 /* 66 0x42 'B' */
1069 0x00, /* 0000000 */
1070 0xf8, /* 1111100 */
1071 0x6c, /* 0110110 */
1072 0x6c, /* 0110110 */
1073 0x6c, /* 0110110 */
1074 0x78, /* 0111100 */
1075 0x6c, /* 0110110 */
1076 0x6c, /* 0110110 */
1077 0x6c, /* 0110110 */
1078 0x6c, /* 0110110 */
1079 0xf8, /* 1111100 */
1080 0x00, /* 0000000 */
1081 0x00, /* 0000000 */
1082 0x00, /* 0000000 */
1083
1084 /* 67 0x43 'C' */
1085 0x00, /* 0000000 */
1086 0x38, /* 0011100 */
1087 0x6c, /* 0110110 */
1088 0xc4, /* 1100010 */
1089 0xc0, /* 1100000 */
1090 0xc0, /* 1100000 */
1091 0xc0, /* 1100000 */
1092 0xc0, /* 1100000 */
1093 0xc4, /* 1100010 */
1094 0x6c, /* 0110110 */
1095 0x38, /* 0011100 */
1096 0x00, /* 0000000 */
1097 0x00, /* 0000000 */
1098 0x00, /* 0000000 */
1099
1100 /* 68 0x44 'D' */
1101 0x00, /* 0000000 */
1102 0xf0, /* 1111000 */
1103 0xd8, /* 1101100 */
1104 0xcc, /* 1100110 */
1105 0xcc, /* 1100110 */
1106 0xcc, /* 1100110 */
1107 0xcc, /* 1100110 */
1108 0xcc, /* 1100110 */
1109 0xcc, /* 1100110 */
1110 0xd8, /* 1101100 */
1111 0xf0, /* 1111000 */
1112 0x00, /* 0000000 */
1113 0x00, /* 0000000 */
1114 0x00, /* 0000000 */
1115
1116 /* 69 0x45 'E' */
1117 0x00, /* 0000000 */
1118 0x7c, /* 0111110 */
1119 0x6c, /* 0110110 */
1120 0x64, /* 0110010 */
1121 0x68, /* 0110100 */
1122 0x78, /* 0111100 */
1123 0x68, /* 0110100 */
1124 0x60, /* 0110000 */
1125 0x64, /* 0110010 */
1126 0x6c, /* 0110110 */
1127 0x7c, /* 0111110 */
1128 0x00, /* 0000000 */
1129 0x00, /* 0000000 */
1130 0x00, /* 0000000 */
1131
1132 /* 70 0x46 'F' */
1133 0x00, /* 0000000 */
1134 0x7c, /* 0111110 */
1135 0x64, /* 0110010 */
1136 0x60, /* 0110000 */
1137 0x68, /* 0110100 */
1138 0x78, /* 0111100 */
1139 0x68, /* 0110100 */
1140 0x60, /* 0110000 */
1141 0x60, /* 0110000 */
1142 0x60, /* 0110000 */
1143 0x70, /* 0111000 */
1144 0x00, /* 0000000 */
1145 0x00, /* 0000000 */
1146 0x00, /* 0000000 */
1147
1148 /* 71 0x47 'G' */
1149 0x00, /* 0000000 */
1150 0x38, /* 0011100 */
1151 0x6c, /* 0110110 */
1152 0xc4, /* 1100010 */
1153 0xc0, /* 1100000 */
1154 0xc0, /* 1100000 */
1155 0xdc, /* 1101110 */
1156 0xcc, /* 1100110 */
1157 0xcc, /* 1100110 */
1158 0x6c, /* 0110110 */
1159 0x34, /* 0011010 */
1160 0x00, /* 0000000 */
1161 0x00, /* 0000000 */
1162 0x00, /* 0000000 */
1163
1164 /* 72 0x48 'H' */
1165 0x00, /* 0000000 */
1166 0xcc, /* 1100110 */
1167 0xcc, /* 1100110 */
1168 0xcc, /* 1100110 */
1169 0xcc, /* 1100110 */
1170 0xfc, /* 1111110 */
1171 0xcc, /* 1100110 */
1172 0xcc, /* 1100110 */
1173 0xcc, /* 1100110 */
1174 0xcc, /* 1100110 */
1175 0xcc, /* 1100110 */
1176 0x00, /* 0000000 */
1177 0x00, /* 0000000 */
1178 0x00, /* 0000000 */
1179
1180 /* 73 0x49 'I' */
1181 0x00, /* 0000000 */
1182 0x3c, /* 0011110 */
1183 0x18, /* 0001100 */
1184 0x18, /* 0001100 */
1185 0x18, /* 0001100 */
1186 0x18, /* 0001100 */
1187 0x18, /* 0001100 */
1188 0x18, /* 0001100 */
1189 0x18, /* 0001100 */
1190 0x18, /* 0001100 */
1191 0x3c, /* 0011110 */
1192 0x00, /* 0000000 */
1193 0x00, /* 0000000 */
1194 0x00, /* 0000000 */
1195
1196 /* 74 0x4a 'J' */
1197 0x00, /* 0000000 */
1198 0x1c, /* 0001110 */
1199 0x0c, /* 0000110 */
1200 0x0c, /* 0000110 */
1201 0x0c, /* 0000110 */
1202 0x0c, /* 0000110 */
1203 0x0c, /* 0000110 */
1204 0xcc, /* 1100110 */
1205 0xcc, /* 1100110 */
1206 0xcc, /* 1100110 */
1207 0x78, /* 0111100 */
1208 0x00, /* 0000000 */
1209 0x00, /* 0000000 */
1210 0x00, /* 0000000 */
1211
1212 /* 75 0x4b 'K' */
1213 0x00, /* 0000000 */
1214 0xcc, /* 1100110 */
1215 0xcc, /* 1100110 */
1216 0xcc, /* 1100110 */
1217 0xd8, /* 1101100 */
1218 0xf0, /* 1111000 */
1219 0xf0, /* 1111000 */
1220 0xd8, /* 1101100 */
1221 0xcc, /* 1100110 */
1222 0xcc, /* 1100110 */
1223 0xcc, /* 1100110 */
1224 0x00, /* 0000000 */
1225 0x00, /* 0000000 */
1226 0x00, /* 0000000 */
1227
1228 /* 76 0x4c 'L' */
1229 0x00, /* 0000000 */
1230 0xc0, /* 1100000 */
1231 0xc0, /* 1100000 */
1232 0xc0, /* 1100000 */
1233 0xc0, /* 1100000 */
1234 0xc0, /* 1100000 */
1235 0xc0, /* 1100000 */
1236 0xc0, /* 1100000 */
1237 0xc4, /* 1100010 */
1238 0xcc, /* 1100110 */
1239 0xfc, /* 1111110 */
1240 0x00, /* 0000000 */
1241 0x00, /* 0000000 */
1242 0x00, /* 0000000 */
1243
1244 /* 77 0x4d 'M' */
1245 0x00, /* 0000000 */
1246 0xc6, /* 1100011 */
1247 0xee, /* 1110111 */
1248 0xfe, /* 1111111 */
1249 0xfe, /* 1111111 */
1250 0xd6, /* 1101011 */
1251 0xc6, /* 1100011 */
1252 0xc6, /* 1100011 */
1253 0xc6, /* 1100011 */
1254 0xc6, /* 1100011 */
1255 0xc6, /* 1100011 */
1256 0x00, /* 0000000 */
1257 0x00, /* 0000000 */
1258 0x00, /* 0000000 */
1259
1260 /* 78 0x4e 'N' */
1261 0x00, /* 0000000 */
1262 0xcc, /* 1100110 */
1263 0xec, /* 1110110 */
1264 0xec, /* 1110110 */
1265 0xfc, /* 1111110 */
1266 0xdc, /* 1101110 */
1267 0xdc, /* 1101110 */
1268 0xcc, /* 1100110 */
1269 0xcc, /* 1100110 */
1270 0xcc, /* 1100110 */
1271 0xcc, /* 1100110 */
1272 0x00, /* 0000000 */
1273 0x00, /* 0000000 */
1274 0x00, /* 0000000 */
1275
1276 /* 79 0x4f 'O' */
1277 0x00, /* 0000000 */
1278 0x78, /* 0111100 */
1279 0xcc, /* 1100110 */
1280 0xcc, /* 1100110 */
1281 0xcc, /* 1100110 */
1282 0xcc, /* 1100110 */
1283 0xcc, /* 1100110 */
1284 0xcc, /* 1100110 */
1285 0xcc, /* 1100110 */
1286 0xcc, /* 1100110 */
1287 0x78, /* 0111100 */
1288 0x00, /* 0000000 */
1289 0x00, /* 0000000 */
1290 0x00, /* 0000000 */
1291
1292 /* 80 0x50 'P' */
1293 0x00, /* 0000000 */
1294 0xf8, /* 1111100 */
1295 0xcc, /* 1100110 */
1296 0xcc, /* 1100110 */
1297 0xcc, /* 1100110 */
1298 0xf8, /* 1111100 */
1299 0xc0, /* 1100000 */
1300 0xc0, /* 1100000 */
1301 0xc0, /* 1100000 */
1302 0xc0, /* 1100000 */
1303 0xc0, /* 1100000 */
1304 0x00, /* 0000000 */
1305 0x00, /* 0000000 */
1306 0x00, /* 0000000 */
1307
1308 /* 81 0x51 'Q' */
1309 0x00, /* 0000000 */
1310 0x78, /* 0111100 */
1311 0xcc, /* 1100110 */
1312 0xcc, /* 1100110 */
1313 0xcc, /* 1100110 */
1314 0xcc, /* 1100110 */
1315 0xcc, /* 1100110 */
1316 0xcc, /* 1100110 */
1317 0xcc, /* 1100110 */
1318 0xdc, /* 1101110 */
1319 0x78, /* 0111100 */
1320 0x18, /* 0001100 */
1321 0x1c, /* 0001110 */
1322 0x00, /* 0000000 */
1323
1324 /* 82 0x52 'R' */
1325 0x00, /* 0000000 */
1326 0xf8, /* 1111100 */
1327 0xcc, /* 1100110 */
1328 0xcc, /* 1100110 */
1329 0xcc, /* 1100110 */
1330 0xf8, /* 1111100 */
1331 0xd8, /* 1101100 */
1332 0xcc, /* 1100110 */
1333 0xcc, /* 1100110 */
1334 0xcc, /* 1100110 */
1335 0xcc, /* 1100110 */
1336 0x00, /* 0000000 */
1337 0x00, /* 0000000 */
1338 0x00, /* 0000000 */
1339
1340 /* 83 0x53 'S' */
1341 0x00, /* 0000000 */
1342 0x7c, /* 0111110 */
1343 0xc4, /* 1100010 */
1344 0xc0, /* 1100000 */
1345 0xc0, /* 1100000 */
1346 0x60, /* 0110000 */
1347 0x38, /* 0011100 */
1348 0x0c, /* 0000110 */
1349 0x0c, /* 0000110 */
1350 0x8c, /* 1000110 */
1351 0xf8, /* 1111100 */
1352 0x00, /* 0000000 */
1353 0x00, /* 0000000 */
1354 0x00, /* 0000000 */
1355
1356 /* 84 0x54 'T' */
1357 0x00, /* 0000000 */
1358 0xfc, /* 1111110 */
1359 0xfc, /* 1111110 */
1360 0xb4, /* 1011010 */
1361 0x30, /* 0011000 */
1362 0x30, /* 0011000 */
1363 0x30, /* 0011000 */
1364 0x30, /* 0011000 */
1365 0x30, /* 0011000 */
1366 0x30, /* 0011000 */
1367 0x78, /* 0111100 */
1368 0x00, /* 0000000 */
1369 0x00, /* 0000000 */
1370 0x00, /* 0000000 */
1371
1372 /* 85 0x55 'U' */
1373 0x00, /* 0000000 */
1374 0xcc, /* 1100110 */
1375 0xcc, /* 1100110 */
1376 0xcc, /* 1100110 */
1377 0xcc, /* 1100110 */
1378 0xcc, /* 1100110 */
1379 0xcc, /* 1100110 */
1380 0xcc, /* 1100110 */
1381 0xcc, /* 1100110 */
1382 0xcc, /* 1100110 */
1383 0x78, /* 0111100 */
1384 0x00, /* 0000000 */
1385 0x00, /* 0000000 */
1386 0x00, /* 0000000 */
1387
1388 /* 86 0x56 'V' */
1389 0x00, /* 0000000 */
1390 0xcc, /* 1100110 */
1391 0xcc, /* 1100110 */
1392 0xcc, /* 1100110 */
1393 0xcc, /* 1100110 */
1394 0xcc, /* 1100110 */
1395 0xcc, /* 1100110 */
1396 0xcc, /* 1100110 */
1397 0x78, /* 0111100 */
1398 0x78, /* 0111100 */
1399 0x30, /* 0011000 */
1400 0x00, /* 0000000 */
1401 0x00, /* 0000000 */
1402 0x00, /* 0000000 */
1403
1404 /* 87 0x57 'W' */
1405 0x00, /* 0000000 */
1406 0xcc, /* 1100110 */
1407 0xcc, /* 1100110 */
1408 0xcc, /* 1100110 */
1409 0xcc, /* 1100110 */
1410 0xcc, /* 1100110 */
1411 0xcc, /* 1100110 */
1412 0xcc, /* 1100110 */
1413 0xfc, /* 1111110 */
1414 0xfc, /* 1111110 */
1415 0x48, /* 0100100 */
1416 0x00, /* 0000000 */
1417 0x00, /* 0000000 */
1418 0x00, /* 0000000 */
1419
1420 /* 88 0x58 'X' */
1421 0x00, /* 0000000 */
1422 0xcc, /* 1100110 */
1423 0xcc, /* 1100110 */
1424 0x78, /* 0111100 */
1425 0x78, /* 0111100 */
1426 0x30, /* 0011000 */
1427 0x30, /* 0011000 */
1428 0x78, /* 0111100 */
1429 0x78, /* 0111100 */
1430 0xcc, /* 1100110 */
1431 0xcc, /* 1100110 */
1432 0x00, /* 0000000 */
1433 0x00, /* 0000000 */
1434 0x00, /* 0000000 */
1435
1436 /* 89 0x59 'Y' */
1437 0x00, /* 0000000 */
1438 0xcc, /* 1100110 */
1439 0xcc, /* 1100110 */
1440 0xcc, /* 1100110 */
1441 0xcc, /* 1100110 */
1442 0x78, /* 0111100 */
1443 0x30, /* 0011000 */
1444 0x30, /* 0011000 */
1445 0x30, /* 0011000 */
1446 0x30, /* 0011000 */
1447 0x30, /* 0011000 */
1448 0x00, /* 0000000 */
1449 0x00, /* 0000000 */
1450 0x00, /* 0000000 */
1451
1452 /* 90 0x5a 'Z' */
1453 0x00, /* 0000000 */
1454 0xfc, /* 1111110 */
1455 0xcc, /* 1100110 */
1456 0x8c, /* 1000110 */
1457 0x18, /* 0001100 */
1458 0x18, /* 0001100 */
1459 0x30, /* 0011000 */
1460 0x60, /* 0110000 */
1461 0xc4, /* 1100010 */
1462 0xcc, /* 1100110 */
1463 0xfc, /* 1111110 */
1464 0x00, /* 0000000 */
1465 0x00, /* 0000000 */
1466 0x00, /* 0000000 */
1467
1468 /* 91 0x5b '[' */
1469 0x00, /* 0000000 */
1470 0x78, /* 0111100 */
1471 0x60, /* 0110000 */
1472 0x60, /* 0110000 */
1473 0x60, /* 0110000 */
1474 0x60, /* 0110000 */
1475 0x60, /* 0110000 */
1476 0x60, /* 0110000 */
1477 0x60, /* 0110000 */
1478 0x60, /* 0110000 */
1479 0x78, /* 0111100 */
1480 0x00, /* 0000000 */
1481 0x00, /* 0000000 */
1482 0x00, /* 0000000 */
1483
1484 /* 92 0x5c '\' */
1485 0x00, /* 0000000 */
1486 0x00, /* 0000000 */
1487 0x00, /* 0000000 */
1488 0x80, /* 1000000 */
1489 0xc0, /* 1100000 */
1490 0xe0, /* 1110000 */
1491 0x70, /* 0111000 */
1492 0x38, /* 0011100 */
1493 0x1c, /* 0001110 */
1494 0x0c, /* 0000110 */
1495 0x04, /* 0000010 */
1496 0x00, /* 0000000 */
1497 0x00, /* 0000000 */
1498 0x00, /* 0000000 */
1499
1500 /* 93 0x5d ']' */
1501 0x00, /* 0000000 */
1502 0x78, /* 0111100 */
1503 0x18, /* 0001100 */
1504 0x18, /* 0001100 */
1505 0x18, /* 0001100 */
1506 0x18, /* 0001100 */
1507 0x18, /* 0001100 */
1508 0x18, /* 0001100 */
1509 0x18, /* 0001100 */
1510 0x18, /* 0001100 */
1511 0x78, /* 0111100 */
1512 0x00, /* 0000000 */
1513 0x00, /* 0000000 */
1514 0x00, /* 0000000 */
1515
1516 /* 94 0x5e '^' */
1517 0x10, /* 0001000 */
1518 0x38, /* 0011100 */
1519 0x6c, /* 0110110 */
1520 0xc6, /* 1100011 */
1521 0x00, /* 0000000 */
1522 0x00, /* 0000000 */
1523 0x00, /* 0000000 */
1524 0x00, /* 0000000 */
1525 0x00, /* 0000000 */
1526 0x00, /* 0000000 */
1527 0x00, /* 0000000 */
1528 0x00, /* 0000000 */
1529 0x00, /* 0000000 */
1530 0x00, /* 0000000 */
1531
1532 /* 95 0x5f '_' */
1533 0x00, /* 0000000 */
1534 0x00, /* 0000000 */
1535 0x00, /* 0000000 */
1536 0x00, /* 0000000 */
1537 0x00, /* 0000000 */
1538 0x00, /* 0000000 */
1539 0x00, /* 0000000 */
1540 0x00, /* 0000000 */
1541 0x00, /* 0000000 */
1542 0x00, /* 0000000 */
1543 0x00, /* 0000000 */
1544 0x00, /* 0000000 */
1545 0xfe, /* 1111111 */
1546 0x00, /* 0000000 */
1547
1548 /* 96 0x60 '`' */
1549 0x00, /* 0000000 */
1550 0x60, /* 0110000 */
1551 0x30, /* 0011000 */
1552 0x18, /* 0001100 */
1553 0x00, /* 0000000 */
1554 0x00, /* 0000000 */
1555 0x00, /* 0000000 */
1556 0x00, /* 0000000 */
1557 0x00, /* 0000000 */
1558 0x00, /* 0000000 */
1559 0x00, /* 0000000 */
1560 0x00, /* 0000000 */
1561 0x00, /* 0000000 */
1562 0x00, /* 0000000 */
1563
1564 /* 97 0x61 'a' */
1565 0x00, /* 0000000 */
1566 0x00, /* 0000000 */
1567 0x00, /* 0000000 */
1568 0x00, /* 0000000 */
1569 0x78, /* 0111100 */
1570 0x0c, /* 0000110 */
1571 0x7c, /* 0111110 */
1572 0xcc, /* 1100110 */
1573 0xcc, /* 1100110 */
1574 0xcc, /* 1100110 */
1575 0x76, /* 0111011 */
1576 0x00, /* 0000000 */
1577 0x00, /* 0000000 */
1578 0x00, /* 0000000 */
1579
1580 /* 98 0x62 'b' */
1581 0x00, /* 0000000 */
1582 0xc0, /* 1100000 */
1583 0xc0, /* 1100000 */
1584 0xc0, /* 1100000 */
1585 0xf0, /* 1111000 */
1586 0xd8, /* 1101100 */
1587 0xcc, /* 1100110 */
1588 0xcc, /* 1100110 */
1589 0xcc, /* 1100110 */
1590 0xcc, /* 1100110 */
1591 0xf8, /* 1111100 */
1592 0x00, /* 0000000 */
1593 0x00, /* 0000000 */
1594 0x00, /* 0000000 */
1595
1596 /* 99 0x63 'c' */
1597 0x00, /* 0000000 */
1598 0x00, /* 0000000 */
1599 0x00, /* 0000000 */
1600 0x00, /* 0000000 */
1601 0x78, /* 0111100 */
1602 0xcc, /* 1100110 */
1603 0xc0, /* 1100000 */
1604 0xc0, /* 1100000 */
1605 0xc0, /* 1100000 */
1606 0xcc, /* 1100110 */
1607 0x78, /* 0111100 */
1608 0x00, /* 0000000 */
1609 0x00, /* 0000000 */
1610 0x00, /* 0000000 */
1611
1612 /* 100 0x64 'd' */
1613 0x00, /* 0000000 */
1614 0x1c, /* 0001110 */
1615 0x0c, /* 0000110 */
1616 0x0c, /* 0000110 */
1617 0x3c, /* 0011110 */
1618 0x6c, /* 0110110 */
1619 0xcc, /* 1100110 */
1620 0xcc, /* 1100110 */
1621 0xcc, /* 1100110 */
1622 0xcc, /* 1100110 */
1623 0x76, /* 0111011 */
1624 0x00, /* 0000000 */
1625 0x00, /* 0000000 */
1626 0x00, /* 0000000 */
1627
1628 /* 101 0x65 'e' */
1629 0x00, /* 0000000 */
1630 0x00, /* 0000000 */
1631 0x00, /* 0000000 */
1632 0x00, /* 0000000 */
1633 0x78, /* 0111100 */
1634 0xcc, /* 1100110 */
1635 0xfc, /* 1111110 */
1636 0xc0, /* 1100000 */
1637 0xc0, /* 1100000 */
1638 0xcc, /* 1100110 */
1639 0x78, /* 0111100 */
1640 0x00, /* 0000000 */
1641 0x00, /* 0000000 */
1642 0x00, /* 0000000 */
1643
1644 /* 102 0x66 'f' */
1645 0x00, /* 0000000 */
1646 0x38, /* 0011100 */
1647 0x6c, /* 0110110 */
1648 0x64, /* 0110010 */
1649 0x60, /* 0110000 */
1650 0xf0, /* 1111000 */
1651 0x60, /* 0110000 */
1652 0x60, /* 0110000 */
1653 0x60, /* 0110000 */
1654 0x60, /* 0110000 */
1655 0xf0, /* 1111000 */
1656 0x00, /* 0000000 */
1657 0x00, /* 0000000 */
1658 0x00, /* 0000000 */
1659
1660 /* 103 0x67 'g' */
1661 0x00, /* 0000000 */
1662 0x00, /* 0000000 */
1663 0x00, /* 0000000 */
1664 0x00, /* 0000000 */
1665 0x76, /* 0111011 */
1666 0xcc, /* 1100110 */
1667 0xcc, /* 1100110 */
1668 0xcc, /* 1100110 */
1669 0xcc, /* 1100110 */
1670 0xcc, /* 1100110 */
1671 0x7c, /* 0111110 */
1672 0x0c, /* 0000110 */
1673 0xcc, /* 1100110 */
1674 0x78, /* 0111100 */
1675
1676 /* 104 0x68 'h' */
1677 0x00, /* 0000000 */
1678 0xc0, /* 1100000 */
1679 0xc0, /* 1100000 */
1680 0xc0, /* 1100000 */
1681 0xd8, /* 1101100 */
1682 0xec, /* 1110110 */
1683 0xcc, /* 1100110 */
1684 0xcc, /* 1100110 */
1685 0xcc, /* 1100110 */
1686 0xcc, /* 1100110 */
1687 0xcc, /* 1100110 */
1688 0x00, /* 0000000 */
1689 0x00, /* 0000000 */
1690 0x00, /* 0000000 */
1691
1692 /* 105 0x69 'i' */
1693 0x00, /* 0000000 */
1694 0x30, /* 0011000 */
1695 0x30, /* 0011000 */
1696 0x00, /* 0000000 */
1697 0x70, /* 0111000 */
1698 0x30, /* 0011000 */
1699 0x30, /* 0011000 */
1700 0x30, /* 0011000 */
1701 0x30, /* 0011000 */
1702 0x30, /* 0011000 */
1703 0x78, /* 0111100 */
1704 0x00, /* 0000000 */
1705 0x00, /* 0000000 */
1706 0x00, /* 0000000 */
1707
1708 /* 106 0x6a 'j' */
1709 0x00, /* 0000000 */
1710 0x0c, /* 0000110 */
1711 0x0c, /* 0000110 */
1712 0x00, /* 0000000 */
1713 0x1c, /* 0001110 */
1714 0x0c, /* 0000110 */
1715 0x0c, /* 0000110 */
1716 0x0c, /* 0000110 */
1717 0x0c, /* 0000110 */
1718 0x0c, /* 0000110 */
1719 0x0c, /* 0000110 */
1720 0xcc, /* 1100110 */
1721 0xcc, /* 1100110 */
1722 0x78, /* 0111100 */
1723
1724 /* 107 0x6b 'k' */
1725 0x00, /* 0000000 */
1726 0xc0, /* 1100000 */
1727 0xc0, /* 1100000 */
1728 0xc0, /* 1100000 */
1729 0xcc, /* 1100110 */
1730 0xd8, /* 1101100 */
1731 0xf0, /* 1111000 */
1732 0xf0, /* 1111000 */
1733 0xd8, /* 1101100 */
1734 0xcc, /* 1100110 */
1735 0xcc, /* 1100110 */
1736 0x00, /* 0000000 */
1737 0x00, /* 0000000 */
1738 0x00, /* 0000000 */
1739
1740 /* 108 0x6c 'l' */
1741 0x00, /* 0000000 */
1742 0x70, /* 0111000 */
1743 0x30, /* 0011000 */
1744 0x30, /* 0011000 */
1745 0x30, /* 0011000 */
1746 0x30, /* 0011000 */
1747 0x30, /* 0011000 */
1748 0x30, /* 0011000 */
1749 0x30, /* 0011000 */
1750 0x30, /* 0011000 */
1751 0x78, /* 0111100 */
1752 0x00, /* 0000000 */
1753 0x00, /* 0000000 */
1754 0x00, /* 0000000 */
1755
1756 /* 109 0x6d 'm' */
1757 0x00, /* 0000000 */
1758 0x00, /* 0000000 */
1759 0x00, /* 0000000 */
1760 0x00, /* 0000000 */
1761 0xec, /* 1110110 */
1762 0xfe, /* 1111111 */
1763 0xd6, /* 1101011 */
1764 0xd6, /* 1101011 */
1765 0xd6, /* 1101011 */
1766 0xd6, /* 1101011 */
1767 0xd6, /* 1101011 */
1768 0x00, /* 0000000 */
1769 0x00, /* 0000000 */
1770 0x00, /* 0000000 */
1771
1772 /* 110 0x6e 'n' */
1773 0x00, /* 0000000 */
1774 0x00, /* 0000000 */
1775 0x00, /* 0000000 */
1776 0x00, /* 0000000 */
1777 0xb8, /* 1011100 */
1778 0xcc, /* 1100110 */
1779 0xcc, /* 1100110 */
1780 0xcc, /* 1100110 */
1781 0xcc, /* 1100110 */
1782 0xcc, /* 1100110 */
1783 0xcc, /* 1100110 */
1784 0x00, /* 0000000 */
1785 0x00, /* 0000000 */
1786 0x00, /* 0000000 */
1787
1788 /* 111 0x6f 'o' */
1789 0x00, /* 0000000 */
1790 0x00, /* 0000000 */
1791 0x00, /* 0000000 */
1792 0x00, /* 0000000 */
1793 0x78, /* 0111100 */
1794 0xcc, /* 1100110 */
1795 0xcc, /* 1100110 */
1796 0xcc, /* 1100110 */
1797 0xcc, /* 1100110 */
1798 0xcc, /* 1100110 */
1799 0x78, /* 0111100 */
1800 0x00, /* 0000000 */
1801 0x00, /* 0000000 */
1802 0x00, /* 0000000 */
1803
1804 /* 112 0x70 'p' */
1805 0x00, /* 0000000 */
1806 0x00, /* 0000000 */
1807 0x00, /* 0000000 */
1808 0x00, /* 0000000 */
1809 0xb8, /* 1011100 */
1810 0xcc, /* 1100110 */
1811 0xcc, /* 1100110 */
1812 0xcc, /* 1100110 */
1813 0xcc, /* 1100110 */
1814 0xcc, /* 1100110 */
1815 0xf8, /* 1111100 */
1816 0xc0, /* 1100000 */
1817 0xc0, /* 1100000 */
1818 0xc0, /* 1100000 */
1819
1820 /* 113 0x71 'q' */
1821 0x00, /* 0000000 */
1822 0x00, /* 0000000 */
1823 0x00, /* 0000000 */
1824 0x00, /* 0000000 */
1825 0x74, /* 0111010 */
1826 0xcc, /* 1100110 */
1827 0xcc, /* 1100110 */
1828 0xcc, /* 1100110 */
1829 0xcc, /* 1100110 */
1830 0xcc, /* 1100110 */
1831 0x7c, /* 0111110 */
1832 0x0c, /* 0000110 */
1833 0x0c, /* 0000110 */
1834 0x0c, /* 0000110 */
1835
1836 /* 114 0x72 'r' */
1837 0x00, /* 0000000 */
1838 0x00, /* 0000000 */
1839 0x00, /* 0000000 */
1840 0x00, /* 0000000 */
1841 0xb8, /* 1011100 */
1842 0xec, /* 1110110 */
1843 0xcc, /* 1100110 */
1844 0xc0, /* 1100000 */
1845 0xc0, /* 1100000 */
1846 0xc0, /* 1100000 */
1847 0xc0, /* 1100000 */
1848 0x00, /* 0000000 */
1849 0x00, /* 0000000 */
1850 0x00, /* 0000000 */
1851
1852 /* 115 0x73 's' */
1853 0x00, /* 0000000 */
1854 0x00, /* 0000000 */
1855 0x00, /* 0000000 */
1856 0x00, /* 0000000 */
1857 0x78, /* 0111100 */
1858 0xcc, /* 1100110 */
1859 0x60, /* 0110000 */
1860 0x30, /* 0011000 */
1861 0x18, /* 0001100 */
1862 0xcc, /* 1100110 */
1863 0x78, /* 0111100 */
1864 0x00, /* 0000000 */
1865 0x00, /* 0000000 */
1866 0x00, /* 0000000 */
1867
1868 /* 116 0x74 't' */
1869 0x00, /* 0000000 */
1870 0x10, /* 0001000 */
1871 0x30, /* 0011000 */
1872 0x30, /* 0011000 */
1873 0xfc, /* 1111110 */
1874 0x30, /* 0011000 */
1875 0x30, /* 0011000 */
1876 0x30, /* 0011000 */
1877 0x30, /* 0011000 */
1878 0x36, /* 0011011 */
1879 0x1c, /* 0001110 */
1880 0x00, /* 0000000 */
1881 0x00, /* 0000000 */
1882 0x00, /* 0000000 */
1883
1884 /* 117 0x75 'u' */
1885 0x00, /* 0000000 */
1886 0x00, /* 0000000 */
1887 0x00, /* 0000000 */
1888 0x00, /* 0000000 */
1889 0xcc, /* 1100110 */
1890 0xcc, /* 1100110 */
1891 0xcc, /* 1100110 */
1892 0xcc, /* 1100110 */
1893 0xcc, /* 1100110 */
1894 0xcc, /* 1100110 */
1895 0x76, /* 0111011 */
1896 0x00, /* 0000000 */
1897 0x00, /* 0000000 */
1898 0x00, /* 0000000 */
1899
1900 /* 118 0x76 'v' */
1901 0x00, /* 0000000 */
1902 0x00, /* 0000000 */
1903 0x00, /* 0000000 */
1904 0x00, /* 0000000 */
1905 0xcc, /* 1100110 */
1906 0xcc, /* 1100110 */
1907 0xcc, /* 1100110 */
1908 0xcc, /* 1100110 */
1909 0xcc, /* 1100110 */
1910 0x78, /* 0111100 */
1911 0x30, /* 0011000 */
1912 0x00, /* 0000000 */
1913 0x00, /* 0000000 */
1914 0x00, /* 0000000 */
1915
1916 /* 119 0x77 'w' */
1917 0x00, /* 0000000 */
1918 0x00, /* 0000000 */
1919 0x00, /* 0000000 */
1920 0x00, /* 0000000 */
1921 0xc6, /* 1100011 */
1922 0xc6, /* 1100011 */
1923 0xd6, /* 1101011 */
1924 0xd6, /* 1101011 */
1925 0xd6, /* 1101011 */
1926 0xfe, /* 1111111 */
1927 0x6c, /* 0110110 */
1928 0x00, /* 0000000 */
1929 0x00, /* 0000000 */
1930 0x00, /* 0000000 */
1931
1932 /* 120 0x78 'x' */
1933 0x00, /* 0000000 */
1934 0x00, /* 0000000 */
1935 0x00, /* 0000000 */
1936 0x00, /* 0000000 */
1937 0xcc, /* 1100110 */
1938 0xcc, /* 1100110 */
1939 0x78, /* 0111100 */
1940 0x30, /* 0011000 */
1941 0x78, /* 0111100 */
1942 0xcc, /* 1100110 */
1943 0xcc, /* 1100110 */
1944 0x00, /* 0000000 */
1945 0x00, /* 0000000 */
1946 0x00, /* 0000000 */
1947
1948 /* 121 0x79 'y' */
1949 0x00, /* 0000000 */
1950 0x00, /* 0000000 */
1951 0x00, /* 0000000 */
1952 0x00, /* 0000000 */
1953 0xcc, /* 1100110 */
1954 0xcc, /* 1100110 */
1955 0xcc, /* 1100110 */
1956 0xcc, /* 1100110 */
1957 0xcc, /* 1100110 */
1958 0xcc, /* 1100110 */
1959 0x7c, /* 0111110 */
1960 0x0c, /* 0000110 */
1961 0x18, /* 0001100 */
1962 0xf0, /* 1111000 */
1963
1964 /* 122 0x7a 'z' */
1965 0x00, /* 0000000 */
1966 0x00, /* 0000000 */
1967 0x00, /* 0000000 */
1968 0x00, /* 0000000 */
1969 0xfc, /* 1111110 */
1970 0xcc, /* 1100110 */
1971 0x18, /* 0001100 */
1972 0x30, /* 0011000 */
1973 0x60, /* 0110000 */
1974 0xcc, /* 1100110 */
1975 0xfc, /* 1111110 */
1976 0x00, /* 0000000 */
1977 0x00, /* 0000000 */
1978 0x00, /* 0000000 */
1979
1980 /* 123 0x7b '{' */
1981 0x00, /* 0000000 */
1982 0x1c, /* 0001110 */
1983 0x30, /* 0011000 */
1984 0x30, /* 0011000 */
1985 0x30, /* 0011000 */
1986 0xe0, /* 1110000 */
1987 0x30, /* 0011000 */
1988 0x30, /* 0011000 */
1989 0x30, /* 0011000 */
1990 0x30, /* 0011000 */
1991 0x1c, /* 0001110 */
1992 0x00, /* 0000000 */
1993 0x00, /* 0000000 */
1994 0x00, /* 0000000 */
1995
1996 /* 124 0x7c '|' */
1997 0x00, /* 0000000 */
1998 0x30, /* 0011000 */
1999 0x30, /* 0011000 */
2000 0x30, /* 0011000 */
2001 0x30, /* 0011000 */
2002 0x30, /* 0011000 */
2003 0x30, /* 0011000 */
2004 0x30, /* 0011000 */
2005 0x30, /* 0011000 */
2006 0x30, /* 0011000 */
2007 0x30, /* 0011000 */
2008 0x00, /* 0000000 */
2009 0x00, /* 0000000 */
2010 0x00, /* 0000000 */
2011
2012 /* 125 0x7d '}' */
2013 0x00, /* 0000000 */
2014 0x70, /* 0111000 */
2015 0x18, /* 0001100 */
2016 0x18, /* 0001100 */
2017 0x18, /* 0001100 */
2018 0x0e, /* 0000111 */
2019 0x18, /* 0001100 */
2020 0x18, /* 0001100 */
2021 0x18, /* 0001100 */
2022 0x18, /* 0001100 */
2023 0x70, /* 0111000 */
2024 0x00, /* 0000000 */
2025 0x00, /* 0000000 */
2026 0x00, /* 0000000 */
2027
2028 /* 126 0x7e '~' */
2029 0x00, /* 0000000 */
2030 0xec, /* 1110110 */
2031 0xb8, /* 1011100 */
2032 0x00, /* 0000000 */
2033 0x00, /* 0000000 */
2034 0x00, /* 0000000 */
2035 0x00, /* 0000000 */
2036 0x00, /* 0000000 */
2037 0x00, /* 0000000 */
2038 0x00, /* 0000000 */
2039 0x00, /* 0000000 */
2040 0x00, /* 0000000 */
2041 0x00, /* 0000000 */
2042 0x00, /* 0000000 */
2043
2044 /* 127 0x7f '' */
2045 0x00, /* 0000000 */
2046 0x00, /* 0000000 */
2047 0x00, /* 0000000 */
2048 0x10, /* 0001000 */
2049 0x38, /* 0011100 */
2050 0x6c, /* 0110110 */
2051 0xc6, /* 1100011 */
2052 0xc6, /* 1100011 */
2053 0xc6, /* 1100011 */
2054 0xfe, /* 1111111 */
2055 0x00, /* 0000000 */
2056 0x00, /* 0000000 */
2057 0x00, /* 0000000 */
2058 0x00, /* 0000000 */
2059
2060 /* 128 0x80 '€' */
2061 0x00, /* 0000000 */
2062 0x38, /* 0011100 */
2063 0x6c, /* 0110110 */
2064 0xc4, /* 1100010 */
2065 0xc0, /* 1100000 */
2066 0xc0, /* 1100000 */
2067 0xc0, /* 1100000 */
2068 0xc0, /* 1100000 */
2069 0xc4, /* 1100010 */
2070 0x6c, /* 0110110 */
2071 0x38, /* 0011100 */
2072 0x18, /* 0001100 */
2073 0x70, /* 0111000 */
2074 0x00, /* 0000000 */
2075
2076 /* 129 0x81 '' */
2077 0x00, /* 0000000 */
2078 0xcc, /* 1100110 */
2079 0x00, /* 0000000 */
2080 0x00, /* 0000000 */
2081 0xcc, /* 1100110 */
2082 0xcc, /* 1100110 */
2083 0xcc, /* 1100110 */
2084 0xcc, /* 1100110 */
2085 0xcc, /* 1100110 */
2086 0xcc, /* 1100110 */
2087 0x76, /* 0111011 */
2088 0x00, /* 0000000 */
2089 0x00, /* 0000000 */
2090 0x00, /* 0000000 */
2091
2092 /* 130 0x82 '‚' */
2093 0x0c, /* 0000110 */
2094 0x18, /* 0001100 */
2095 0x30, /* 0011000 */
2096 0x00, /* 0000000 */
2097 0x78, /* 0111100 */
2098 0xcc, /* 1100110 */
2099 0xfc, /* 1111110 */
2100 0xc0, /* 1100000 */
2101 0xc0, /* 1100000 */
2102 0xcc, /* 1100110 */
2103 0x78, /* 0111100 */
2104 0x00, /* 0000000 */
2105 0x00, /* 0000000 */
2106 0x00, /* 0000000 */
2107
2108 /* 131 0x83 'ƒ' */
2109 0x10, /* 0001000 */
2110 0x38, /* 0011100 */
2111 0x6c, /* 0110110 */
2112 0x00, /* 0000000 */
2113 0x78, /* 0111100 */
2114 0x0c, /* 0000110 */
2115 0x7c, /* 0111110 */
2116 0xcc, /* 1100110 */
2117 0xcc, /* 1100110 */
2118 0xcc, /* 1100110 */
2119 0x76, /* 0111011 */
2120 0x00, /* 0000000 */
2121 0x00, /* 0000000 */
2122 0x00, /* 0000000 */
2123
2124 /* 132 0x84 '„' */
2125 0x00, /* 0000000 */
2126 0xcc, /* 1100110 */
2127 0x00, /* 0000000 */
2128 0x00, /* 0000000 */
2129 0x78, /* 0111100 */
2130 0x0c, /* 0000110 */
2131 0x7c, /* 0111110 */
2132 0xcc, /* 1100110 */
2133 0xcc, /* 1100110 */
2134 0xcc, /* 1100110 */
2135 0x76, /* 0111011 */
2136 0x00, /* 0000000 */
2137 0x00, /* 0000000 */
2138 0x00, /* 0000000 */
2139
2140 /* 133 0x85 '…' */
2141 0x60, /* 0110000 */
2142 0x30, /* 0011000 */
2143 0x18, /* 0001100 */
2144 0x00, /* 0000000 */
2145 0x78, /* 0111100 */
2146 0x0c, /* 0000110 */
2147 0x7c, /* 0111110 */
2148 0xcc, /* 1100110 */
2149 0xcc, /* 1100110 */
2150 0xcc, /* 1100110 */
2151 0x76, /* 0111011 */
2152 0x00, /* 0000000 */
2153 0x00, /* 0000000 */
2154 0x00, /* 0000000 */
2155
2156 /* 134 0x86 '†' */
2157 0x38, /* 0011100 */
2158 0x6c, /* 0110110 */
2159 0x38, /* 0011100 */
2160 0x00, /* 0000000 */
2161 0x78, /* 0111100 */
2162 0x0c, /* 0000110 */
2163 0x7c, /* 0111110 */
2164 0xcc, /* 1100110 */
2165 0xcc, /* 1100110 */
2166 0xcc, /* 1100110 */
2167 0x76, /* 0111011 */
2168 0x00, /* 0000000 */
2169 0x00, /* 0000000 */
2170 0x00, /* 0000000 */
2171
2172 /* 135 0x87 '‡' */
2173 0x00, /* 0000000 */
2174 0x00, /* 0000000 */
2175 0x00, /* 0000000 */
2176 0x00, /* 0000000 */
2177 0x78, /* 0111100 */
2178 0xcc, /* 1100110 */
2179 0xc0, /* 1100000 */
2180 0xc0, /* 1100000 */
2181 0xc0, /* 1100000 */
2182 0xcc, /* 1100110 */
2183 0x78, /* 0111100 */
2184 0x30, /* 0011000 */
2185 0x30, /* 0011000 */
2186 0xe0, /* 1110000 */
2187
2188 /* 136 0x88 'ˆ' */
2189 0x10, /* 0001000 */
2190 0x38, /* 0011100 */
2191 0x6c, /* 0110110 */
2192 0x00, /* 0000000 */
2193 0x78, /* 0111100 */
2194 0xcc, /* 1100110 */
2195 0xfc, /* 1111110 */
2196 0xc0, /* 1100000 */
2197 0xc0, /* 1100000 */
2198 0xcc, /* 1100110 */
2199 0x78, /* 0111100 */
2200 0x00, /* 0000000 */
2201 0x00, /* 0000000 */
2202 0x00, /* 0000000 */
2203
2204 /* 137 0x89 '‰' */
2205 0x00, /* 0000000 */
2206 0xcc, /* 1100110 */
2207 0x00, /* 0000000 */
2208 0x00, /* 0000000 */
2209 0x78, /* 0111100 */
2210 0xcc, /* 1100110 */
2211 0xfc, /* 1111110 */
2212 0xc0, /* 1100000 */
2213 0xc0, /* 1100000 */
2214 0xcc, /* 1100110 */
2215 0x78, /* 0111100 */
2216 0x00, /* 0000000 */
2217 0x00, /* 0000000 */
2218 0x00, /* 0000000 */
2219
2220 /* 138 0x8a 'Š' */
2221 0xc0, /* 1100000 */
2222 0x60, /* 0110000 */
2223 0x30, /* 0011000 */
2224 0x00, /* 0000000 */
2225 0x78, /* 0111100 */
2226 0xcc, /* 1100110 */
2227 0xfc, /* 1111110 */
2228 0xc0, /* 1100000 */
2229 0xc0, /* 1100000 */
2230 0xcc, /* 1100110 */
2231 0x78, /* 0111100 */
2232 0x00, /* 0000000 */
2233 0x00, /* 0000000 */
2234 0x00, /* 0000000 */
2235
2236 /* 139 0x8b '‹' */
2237 0x00, /* 0000000 */
2238 0x6c, /* 0110110 */
2239 0x00, /* 0000000 */
2240 0x00, /* 0000000 */
2241 0x38, /* 0011100 */
2242 0x18, /* 0001100 */
2243 0x18, /* 0001100 */
2244 0x18, /* 0001100 */
2245 0x18, /* 0001100 */
2246 0x18, /* 0001100 */
2247 0x3c, /* 0011110 */
2248 0x00, /* 0000000 */
2249 0x00, /* 0000000 */
2250 0x00, /* 0000000 */
2251
2252 /* 140 0x8c 'Œ' */
2253 0x30, /* 0011000 */
2254 0x78, /* 0111100 */
2255 0xcc, /* 1100110 */
2256 0x00, /* 0000000 */
2257 0x70, /* 0111000 */
2258 0x30, /* 0011000 */
2259 0x30, /* 0011000 */
2260 0x30, /* 0011000 */
2261 0x30, /* 0011000 */
2262 0x30, /* 0011000 */
2263 0x78, /* 0111100 */
2264 0x00, /* 0000000 */
2265 0x00, /* 0000000 */
2266 0x00, /* 0000000 */
2267
2268 /* 141 0x8d '' */
2269 0xc0, /* 1100000 */
2270 0x60, /* 0110000 */
2271 0x30, /* 0011000 */
2272 0x00, /* 0000000 */
2273 0x70, /* 0111000 */
2274 0x30, /* 0011000 */
2275 0x30, /* 0011000 */
2276 0x30, /* 0011000 */
2277 0x30, /* 0011000 */
2278 0x30, /* 0011000 */
2279 0x78, /* 0111100 */
2280 0x00, /* 0000000 */
2281 0x00, /* 0000000 */
2282 0x00, /* 0000000 */
2283
2284 /* 142 0x8e 'Ž' */
2285 0x00, /* 0000000 */
2286 0xcc, /* 1100110 */
2287 0x00, /* 0000000 */
2288 0x30, /* 0011000 */
2289 0x78, /* 0111100 */
2290 0xcc, /* 1100110 */
2291 0xcc, /* 1100110 */
2292 0xfc, /* 1111110 */
2293 0xcc, /* 1100110 */
2294 0xcc, /* 1100110 */
2295 0xcc, /* 1100110 */
2296 0x00, /* 0000000 */
2297 0x00, /* 0000000 */
2298 0x00, /* 0000000 */
2299
2300 /* 143 0x8f '' */
2301 0x30, /* 0011000 */
2302 0x48, /* 0100100 */
2303 0x48, /* 0100100 */
2304 0x30, /* 0011000 */
2305 0x78, /* 0111100 */
2306 0xcc, /* 1100110 */
2307 0xfc, /* 1111110 */
2308 0xcc, /* 1100110 */
2309 0xcc, /* 1100110 */
2310 0xcc, /* 1100110 */
2311 0xcc, /* 1100110 */
2312 0x00, /* 0000000 */
2313 0x00, /* 0000000 */
2314 0x00, /* 0000000 */
2315
2316 /* 144 0x90 '' */
2317 0x18, /* 0001100 */
2318 0x30, /* 0011000 */
2319 0xfc, /* 1111110 */
2320 0xcc, /* 1100110 */
2321 0xc4, /* 1100010 */
2322 0xd0, /* 1101000 */
2323 0xf0, /* 1111000 */
2324 0xd0, /* 1101000 */
2325 0xc4, /* 1100010 */
2326 0xcc, /* 1100110 */
2327 0xfc, /* 1111110 */
2328 0x00, /* 0000000 */
2329 0x00, /* 0000000 */
2330 0x00, /* 0000000 */
2331
2332 /* 145 0x91 '‘' */
2333 0x00, /* 0000000 */
2334 0x00, /* 0000000 */
2335 0x00, /* 0000000 */
2336 0x00, /* 0000000 */
2337 0xec, /* 1110110 */
2338 0x36, /* 0011011 */
2339 0x36, /* 0011011 */
2340 0x7e, /* 0111111 */
2341 0xd8, /* 1101100 */
2342 0xd8, /* 1101100 */
2343 0x6e, /* 0110111 */
2344 0x00, /* 0000000 */
2345 0x00, /* 0000000 */
2346 0x00, /* 0000000 */
2347
2348 /* 146 0x92 '’' */
2349 0x00, /* 0000000 */
2350 0x3e, /* 0011111 */
2351 0x6c, /* 0110110 */
2352 0xcc, /* 1100110 */
2353 0xcc, /* 1100110 */
2354 0xfe, /* 1111111 */
2355 0xcc, /* 1100110 */
2356 0xcc, /* 1100110 */
2357 0xcc, /* 1100110 */
2358 0xcc, /* 1100110 */
2359 0xce, /* 1100111 */
2360 0x00, /* 0000000 */
2361 0x00, /* 0000000 */
2362 0x00, /* 0000000 */
2363
2364 /* 147 0x93 '“' */
2365 0x10, /* 0001000 */
2366 0x38, /* 0011100 */
2367 0x6c, /* 0110110 */
2368 0x00, /* 0000000 */
2369 0x78, /* 0111100 */
2370 0xcc, /* 1100110 */
2371 0xcc, /* 1100110 */
2372 0xcc, /* 1100110 */
2373 0xcc, /* 1100110 */
2374 0xcc, /* 1100110 */
2375 0x78, /* 0111100 */
2376 0x00, /* 0000000 */
2377 0x00, /* 0000000 */
2378 0x00, /* 0000000 */
2379
2380 /* 148 0x94 '”' */
2381 0x00, /* 0000000 */
2382 0xcc, /* 1100110 */
2383 0x00, /* 0000000 */
2384 0x00, /* 0000000 */
2385 0x78, /* 0111100 */
2386 0xcc, /* 1100110 */
2387 0xcc, /* 1100110 */
2388 0xcc, /* 1100110 */
2389 0xcc, /* 1100110 */
2390 0xcc, /* 1100110 */
2391 0x78, /* 0111100 */
2392 0x00, /* 0000000 */
2393 0x00, /* 0000000 */
2394 0x00, /* 0000000 */
2395
2396 /* 149 0x95 '•' */
2397 0xc0, /* 1100000 */
2398 0x60, /* 0110000 */
2399 0x30, /* 0011000 */
2400 0x00, /* 0000000 */
2401 0x78, /* 0111100 */
2402 0xcc, /* 1100110 */
2403 0xcc, /* 1100110 */
2404 0xcc, /* 1100110 */
2405 0xcc, /* 1100110 */
2406 0xcc, /* 1100110 */
2407 0x78, /* 0111100 */
2408 0x00, /* 0000000 */
2409 0x00, /* 0000000 */
2410 0x00, /* 0000000 */
2411
2412 /* 150 0x96 '–' */
2413 0x30, /* 0011000 */
2414 0x78, /* 0111100 */
2415 0xcc, /* 1100110 */
2416 0x00, /* 0000000 */
2417 0xcc, /* 1100110 */
2418 0xcc, /* 1100110 */
2419 0xcc, /* 1100110 */
2420 0xcc, /* 1100110 */
2421 0xcc, /* 1100110 */
2422 0xcc, /* 1100110 */
2423 0x76, /* 0111011 */
2424 0x00, /* 0000000 */
2425 0x00, /* 0000000 */
2426 0x00, /* 0000000 */
2427
2428 /* 151 0x97 '—' */
2429 0x60, /* 0110000 */
2430 0x30, /* 0011000 */
2431 0x18, /* 0001100 */
2432 0x00, /* 0000000 */
2433 0xcc, /* 1100110 */
2434 0xcc, /* 1100110 */
2435 0xcc, /* 1100110 */
2436 0xcc, /* 1100110 */
2437 0xcc, /* 1100110 */
2438 0xcc, /* 1100110 */
2439 0x76, /* 0111011 */
2440 0x00, /* 0000000 */
2441 0x00, /* 0000000 */
2442 0x00, /* 0000000 */
2443
2444 /* 152 0x98 '˜' */
2445 0x00, /* 0000000 */
2446 0xcc, /* 1100110 */
2447 0x00, /* 0000000 */
2448 0x00, /* 0000000 */
2449 0xcc, /* 1100110 */
2450 0xcc, /* 1100110 */
2451 0xcc, /* 1100110 */
2452 0xcc, /* 1100110 */
2453 0xcc, /* 1100110 */
2454 0xcc, /* 1100110 */
2455 0x7c, /* 0111110 */
2456 0x0c, /* 0000110 */
2457 0x18, /* 0001100 */
2458 0x70, /* 0111000 */
2459
2460 /* 153 0x99 '™' */
2461 0xcc, /* 1100110 */
2462 0x00, /* 0000000 */
2463 0x78, /* 0111100 */
2464 0xcc, /* 1100110 */
2465 0xcc, /* 1100110 */
2466 0xcc, /* 1100110 */
2467 0xcc, /* 1100110 */
2468 0xcc, /* 1100110 */
2469 0xcc, /* 1100110 */
2470 0xcc, /* 1100110 */
2471 0x78, /* 0111100 */
2472 0x00, /* 0000000 */
2473 0x00, /* 0000000 */
2474 0x00, /* 0000000 */
2475
2476 /* 154 0x9a 'š' */
2477 0xcc, /* 1100110 */
2478 0x00, /* 0000000 */
2479 0xcc, /* 1100110 */
2480 0xcc, /* 1100110 */
2481 0xcc, /* 1100110 */
2482 0xcc, /* 1100110 */
2483 0xcc, /* 1100110 */
2484 0xcc, /* 1100110 */
2485 0xcc, /* 1100110 */
2486 0xcc, /* 1100110 */
2487 0x78, /* 0111100 */
2488 0x00, /* 0000000 */
2489 0x00, /* 0000000 */
2490 0x00, /* 0000000 */
2491
2492 /* 155 0x9b '›' */
2493 0x30, /* 0011000 */
2494 0x30, /* 0011000 */
2495 0x7c, /* 0111110 */
2496 0xcc, /* 1100110 */
2497 0xc0, /* 1100000 */
2498 0xc0, /* 1100000 */
2499 0xc0, /* 1100000 */
2500 0xcc, /* 1100110 */
2501 0x7c, /* 0111110 */
2502 0x30, /* 0011000 */
2503 0x30, /* 0011000 */
2504 0x00, /* 0000000 */
2505 0x00, /* 0000000 */
2506 0x00, /* 0000000 */
2507
2508 /* 156 0x9c 'œ' */
2509 0x38, /* 0011100 */
2510 0x6c, /* 0110110 */
2511 0x64, /* 0110010 */
2512 0x60, /* 0110000 */
2513 0xf0, /* 1111000 */
2514 0x60, /* 0110000 */
2515 0x60, /* 0110000 */
2516 0x60, /* 0110000 */
2517 0x60, /* 0110000 */
2518 0xe6, /* 1110011 */
2519 0xfc, /* 1111110 */
2520 0x00, /* 0000000 */
2521 0x00, /* 0000000 */
2522 0x00, /* 0000000 */
2523
2524 /* 157 0x9d '' */
2525 0x00, /* 0000000 */
2526 0xcc, /* 1100110 */
2527 0xcc, /* 1100110 */
2528 0x78, /* 0111100 */
2529 0x30, /* 0011000 */
2530 0xfc, /* 1111110 */
2531 0x30, /* 0011000 */
2532 0xfc, /* 1111110 */
2533 0x30, /* 0011000 */
2534 0x30, /* 0011000 */
2535 0x30, /* 0011000 */
2536 0x00, /* 0000000 */
2537 0x00, /* 0000000 */
2538 0x00, /* 0000000 */
2539
2540 /* 158 0x9e 'ž' */
2541 0xf8, /* 1111100 */
2542 0xcc, /* 1100110 */
2543 0xcc, /* 1100110 */
2544 0xf8, /* 1111100 */
2545 0xc4, /* 1100010 */
2546 0xcc, /* 1100110 */
2547 0xde, /* 1101111 */
2548 0xcc, /* 1100110 */
2549 0xcc, /* 1100110 */
2550 0xcc, /* 1100110 */
2551 0xc6, /* 1100011 */
2552 0x00, /* 0000000 */
2553 0x00, /* 0000000 */
2554 0x00, /* 0000000 */
2555
2556 /* 159 0x9f 'Ÿ' */
2557 0x1c, /* 0001110 */
2558 0x36, /* 0011011 */
2559 0x30, /* 0011000 */
2560 0x30, /* 0011000 */
2561 0x30, /* 0011000 */
2562 0xfc, /* 1111110 */
2563 0x30, /* 0011000 */
2564 0x30, /* 0011000 */
2565 0x30, /* 0011000 */
2566 0xb0, /* 1011000 */
2567 0xe0, /* 1110000 */
2568 0x00, /* 0000000 */
2569 0x00, /* 0000000 */
2570 0x00, /* 0000000 */
2571
2572 /* 160 0xa0 ' ' */
2573 0x18, /* 0001100 */
2574 0x30, /* 0011000 */
2575 0x60, /* 0110000 */
2576 0x00, /* 0000000 */
2577 0x78, /* 0111100 */
2578 0x0c, /* 0000110 */
2579 0x7c, /* 0111110 */
2580 0xcc, /* 1100110 */
2581 0xcc, /* 1100110 */
2582 0xcc, /* 1100110 */
2583 0x76, /* 0111011 */
2584 0x00, /* 0000000 */
2585 0x00, /* 0000000 */
2586 0x00, /* 0000000 */
2587
2588 /* 161 0xa1 '¡' */
2589 0x18, /* 0001100 */
2590 0x30, /* 0011000 */
2591 0x60, /* 0110000 */
2592 0x00, /* 0000000 */
2593 0x70, /* 0111000 */
2594 0x30, /* 0011000 */
2595 0x30, /* 0011000 */
2596 0x30, /* 0011000 */
2597 0x30, /* 0011000 */
2598 0x30, /* 0011000 */
2599 0x78, /* 0111100 */
2600 0x00, /* 0000000 */
2601 0x00, /* 0000000 */
2602 0x00, /* 0000000 */
2603
2604 /* 162 0xa2 '¢' */
2605 0x18, /* 0001100 */
2606 0x30, /* 0011000 */
2607 0x60, /* 0110000 */
2608 0x00, /* 0000000 */
2609 0x78, /* 0111100 */
2610 0xcc, /* 1100110 */
2611 0xcc, /* 1100110 */
2612 0xcc, /* 1100110 */
2613 0xcc, /* 1100110 */
2614 0xcc, /* 1100110 */
2615 0x78, /* 0111100 */
2616 0x00, /* 0000000 */
2617 0x00, /* 0000000 */
2618 0x00, /* 0000000 */
2619
2620 /* 163 0xa3 '£' */
2621 0x18, /* 0001100 */
2622 0x30, /* 0011000 */
2623 0x60, /* 0110000 */
2624 0x00, /* 0000000 */
2625 0xcc, /* 1100110 */
2626 0xcc, /* 1100110 */
2627 0xcc, /* 1100110 */
2628 0xcc, /* 1100110 */
2629 0xcc, /* 1100110 */
2630 0xcc, /* 1100110 */
2631 0x76, /* 0111011 */
2632 0x00, /* 0000000 */
2633 0x00, /* 0000000 */
2634 0x00, /* 0000000 */
2635
2636 /* 164 0xa4 '¤' */
2637 0x00, /* 0000000 */
2638 0x76, /* 0111011 */
2639 0xdc, /* 1101110 */
2640 0x00, /* 0000000 */
2641 0xb8, /* 1011100 */
2642 0xcc, /* 1100110 */
2643 0xcc, /* 1100110 */
2644 0xcc, /* 1100110 */
2645 0xcc, /* 1100110 */
2646 0xcc, /* 1100110 */
2647 0xcc, /* 1100110 */
2648 0x00, /* 0000000 */
2649 0x00, /* 0000000 */
2650 0x00, /* 0000000 */
2651
2652 /* 165 0xa5 '¥' */
2653 0x76, /* 0111011 */
2654 0xdc, /* 1101110 */
2655 0x00, /* 0000000 */
2656 0xcc, /* 1100110 */
2657 0xec, /* 1110110 */
2658 0xec, /* 1110110 */
2659 0xfc, /* 1111110 */
2660 0xdc, /* 1101110 */
2661 0xcc, /* 1100110 */
2662 0xcc, /* 1100110 */
2663 0xcc, /* 1100110 */
2664 0x00, /* 0000000 */
2665 0x00, /* 0000000 */
2666 0x00, /* 0000000 */
2667
2668 /* 166 0xa6 '¦' */
2669 0x00, /* 0000000 */
2670 0x78, /* 0111100 */
2671 0xd8, /* 1101100 */
2672 0xd8, /* 1101100 */
2673 0x7c, /* 0111110 */
2674 0x00, /* 0000000 */
2675 0xfc, /* 1111110 */
2676 0x00, /* 0000000 */
2677 0x00, /* 0000000 */
2678 0x00, /* 0000000 */
2679 0x00, /* 0000000 */
2680 0x00, /* 0000000 */
2681 0x00, /* 0000000 */
2682 0x00, /* 0000000 */
2683
2684 /* 167 0xa7 '§' */
2685 0x00, /* 0000000 */
2686 0x70, /* 0111000 */
2687 0xd8, /* 1101100 */
2688 0xd8, /* 1101100 */
2689 0x70, /* 0111000 */
2690 0x00, /* 0000000 */
2691 0xf8, /* 1111100 */
2692 0x00, /* 0000000 */
2693 0x00, /* 0000000 */
2694 0x00, /* 0000000 */
2695 0x00, /* 0000000 */
2696 0x00, /* 0000000 */
2697 0x00, /* 0000000 */
2698 0x00, /* 0000000 */
2699
2700 /* 168 0xa8 '¨' */
2701 0x00, /* 0000000 */
2702 0x30, /* 0011000 */
2703 0x30, /* 0011000 */
2704 0x00, /* 0000000 */
2705 0x30, /* 0011000 */
2706 0x30, /* 0011000 */
2707 0x60, /* 0110000 */
2708 0xc0, /* 1100000 */
2709 0xcc, /* 1100110 */
2710 0xcc, /* 1100110 */
2711 0x78, /* 0111100 */
2712 0x00, /* 0000000 */
2713 0x00, /* 0000000 */
2714 0x00, /* 0000000 */
2715
2716 /* 169 0xa9 '©' */
2717 0x00, /* 0000000 */
2718 0x00, /* 0000000 */
2719 0x00, /* 0000000 */
2720 0x00, /* 0000000 */
2721 0x00, /* 0000000 */
2722 0xfc, /* 1111110 */
2723 0xc0, /* 1100000 */
2724 0xc0, /* 1100000 */
2725 0xc0, /* 1100000 */
2726 0xc0, /* 1100000 */
2727 0x00, /* 0000000 */
2728 0x00, /* 0000000 */
2729 0x00, /* 0000000 */
2730 0x00, /* 0000000 */
2731
2732 /* 170 0xaa 'ª' */
2733 0x00, /* 0000000 */
2734 0x00, /* 0000000 */
2735 0x00, /* 0000000 */
2736 0x00, /* 0000000 */
2737 0x00, /* 0000000 */
2738 0xfc, /* 1111110 */
2739 0x0c, /* 0000110 */
2740 0x0c, /* 0000110 */
2741 0x0c, /* 0000110 */
2742 0x0c, /* 0000110 */
2743 0x00, /* 0000000 */
2744 0x00, /* 0000000 */
2745 0x00, /* 0000000 */
2746 0x00, /* 0000000 */
2747
2748 /* 171 0xab '«' */
2749 0x60, /* 0110000 */
2750 0xe0, /* 1110000 */
2751 0x62, /* 0110001 */
2752 0x66, /* 0110011 */
2753 0x6c, /* 0110110 */
2754 0x18, /* 0001100 */
2755 0x30, /* 0011000 */
2756 0x60, /* 0110000 */
2757 0xc0, /* 1100000 */
2758 0xb8, /* 1011100 */
2759 0x4c, /* 0100110 */
2760 0x18, /* 0001100 */
2761 0x30, /* 0011000 */
2762 0x7c, /* 0111110 */
2763
2764 /* 172 0xac '¬' */
2765 0x60, /* 0110000 */
2766 0xe0, /* 1110000 */
2767 0x62, /* 0110001 */
2768 0x66, /* 0110011 */
2769 0x6c, /* 0110110 */
2770 0x18, /* 0001100 */
2771 0x30, /* 0011000 */
2772 0x6c, /* 0110110 */
2773 0xdc, /* 1101110 */
2774 0xb4, /* 1011010 */
2775 0x7e, /* 0111111 */
2776 0x0c, /* 0000110 */
2777 0x0c, /* 0000110 */
2778 0x00, /* 0000000 */
2779
2780 /* 173 0xad '­' */
2781 0x00, /* 0000000 */
2782 0x30, /* 0011000 */
2783 0x30, /* 0011000 */
2784 0x00, /* 0000000 */
2785 0x30, /* 0011000 */
2786 0x30, /* 0011000 */
2787 0x30, /* 0011000 */
2788 0x78, /* 0111100 */
2789 0x78, /* 0111100 */
2790 0x78, /* 0111100 */
2791 0x30, /* 0011000 */
2792 0x00, /* 0000000 */
2793 0x00, /* 0000000 */
2794 0x00, /* 0000000 */
2795
2796 /* 174 0xae '®' */
2797 0x00, /* 0000000 */
2798 0x00, /* 0000000 */
2799 0x00, /* 0000000 */
2800 0x00, /* 0000000 */
2801 0x36, /* 0011011 */
2802 0x6c, /* 0110110 */
2803 0xd8, /* 1101100 */
2804 0x6c, /* 0110110 */
2805 0x36, /* 0011011 */
2806 0x00, /* 0000000 */
2807 0x00, /* 0000000 */
2808 0x00, /* 0000000 */
2809 0x00, /* 0000000 */
2810 0x00, /* 0000000 */
2811
2812 /* 175 0xaf '¯' */
2813 0x00, /* 0000000 */
2814 0x00, /* 0000000 */
2815 0x00, /* 0000000 */
2816 0x00, /* 0000000 */
2817 0xd8, /* 1101100 */
2818 0x6c, /* 0110110 */
2819 0x36, /* 0011011 */
2820 0x6c, /* 0110110 */
2821 0xd8, /* 1101100 */
2822 0x00, /* 0000000 */
2823 0x00, /* 0000000 */
2824 0x00, /* 0000000 */
2825 0x00, /* 0000000 */
2826 0x00, /* 0000000 */
2827
2828 /* 176 0xb0 '°' */
2829 0x88, /* 1000100 */
2830 0x22, /* 0010001 */
2831 0x88, /* 1000100 */
2832 0x22, /* 0010001 */
2833 0x88, /* 1000100 */
2834 0x22, /* 0010001 */
2835 0x88, /* 1000100 */
2836 0x22, /* 0010001 */
2837 0x88, /* 1000100 */
2838 0x22, /* 0010001 */
2839 0x88, /* 1000100 */
2840 0x22, /* 0010001 */
2841 0x88, /* 1000100 */
2842 0x22, /* 0010001 */
2843
2844 /* 177 0xb1 '±' */
2845 0x54, /* 0101010 */
2846 0xaa, /* 1010101 */
2847 0x54, /* 0101010 */
2848 0xaa, /* 1010101 */
2849 0x54, /* 0101010 */
2850 0xaa, /* 1010101 */
2851 0x54, /* 0101010 */
2852 0xaa, /* 1010101 */
2853 0x54, /* 0101010 */
2854 0xaa, /* 1010101 */
2855 0x54, /* 0101010 */
2856 0xaa, /* 1010101 */
2857 0x54, /* 0101010 */
2858 0xaa, /* 1010101 */
2859
2860 /* 178 0xb2 '²' */
2861 0xee, /* 1110111 */
2862 0xba, /* 1011101 */
2863 0xee, /* 1110111 */
2864 0xba, /* 1011101 */
2865 0xee, /* 1110111 */
2866 0xba, /* 1011101 */
2867 0xee, /* 1110111 */
2868 0xba, /* 1011101 */
2869 0xee, /* 1110111 */
2870 0xba, /* 1011101 */
2871 0xee, /* 1110111 */
2872 0xba, /* 1011101 */
2873 0xee, /* 1110111 */
2874 0xba, /* 1011101 */
2875
2876 /* 179 0xb3 '³' */
2877 0x30, /* 0011000 */
2878 0x30, /* 0011000 */
2879 0x30, /* 0011000 */
2880 0x30, /* 0011000 */
2881 0x30, /* 0011000 */
2882 0x30, /* 0011000 */
2883 0x30, /* 0011000 */
2884 0x30, /* 0011000 */
2885 0x30, /* 0011000 */
2886 0x30, /* 0011000 */
2887 0x30, /* 0011000 */
2888 0x30, /* 0011000 */
2889 0x30, /* 0011000 */
2890 0x30, /* 0011000 */
2891
2892 /* 180 0xb4 '´' */
2893 0x30, /* 0011000 */
2894 0x30, /* 0011000 */
2895 0x30, /* 0011000 */
2896 0x30, /* 0011000 */
2897 0x30, /* 0011000 */
2898 0x30, /* 0011000 */
2899 0xf0, /* 1111000 */
2900 0x30, /* 0011000 */
2901 0x30, /* 0011000 */
2902 0x30, /* 0011000 */
2903 0x30, /* 0011000 */
2904 0x30, /* 0011000 */
2905 0x30, /* 0011000 */
2906 0x30, /* 0011000 */
2907
2908 /* 181 0xb5 'µ' */
2909 0x30, /* 0011000 */
2910 0x30, /* 0011000 */
2911 0x30, /* 0011000 */
2912 0x30, /* 0011000 */
2913 0xf0, /* 1111000 */
2914 0x30, /* 0011000 */
2915 0xf0, /* 1111000 */
2916 0x30, /* 0011000 */
2917 0x30, /* 0011000 */
2918 0x30, /* 0011000 */
2919 0x30, /* 0011000 */
2920 0x30, /* 0011000 */
2921 0x30, /* 0011000 */
2922 0x30, /* 0011000 */
2923
2924 /* 182 0xb6 '¶' */
2925 0x6c, /* 0110110 */
2926 0x6c, /* 0110110 */
2927 0x6c, /* 0110110 */
2928 0x6c, /* 0110110 */
2929 0x6c, /* 0110110 */
2930 0x6c, /* 0110110 */
2931 0xec, /* 1110110 */
2932 0x6c, /* 0110110 */
2933 0x6c, /* 0110110 */
2934 0x6c, /* 0110110 */
2935 0x6c, /* 0110110 */
2936 0x6c, /* 0110110 */
2937 0x6c, /* 0110110 */
2938 0x6c, /* 0110110 */
2939
2940 /* 183 0xb7 '·' */
2941 0x00, /* 0000000 */
2942 0x00, /* 0000000 */
2943 0x00, /* 0000000 */
2944 0x00, /* 0000000 */
2945 0x00, /* 0000000 */
2946 0x00, /* 0000000 */
2947 0xfc, /* 1111110 */
2948 0x6c, /* 0110110 */
2949 0x6c, /* 0110110 */
2950 0x6c, /* 0110110 */
2951 0x6c, /* 0110110 */
2952 0x6c, /* 0110110 */
2953 0x6c, /* 0110110 */
2954 0x6c, /* 0110110 */
2955
2956 /* 184 0xb8 '¸' */
2957 0x00, /* 0000000 */
2958 0x00, /* 0000000 */
2959 0x00, /* 0000000 */
2960 0x00, /* 0000000 */
2961 0xf0, /* 1111000 */
2962 0x30, /* 0011000 */
2963 0xf0, /* 1111000 */
2964 0x30, /* 0011000 */
2965 0x30, /* 0011000 */
2966 0x30, /* 0011000 */
2967 0x30, /* 0011000 */
2968 0x30, /* 0011000 */
2969 0x30, /* 0011000 */
2970 0x30, /* 0011000 */
2971
2972 /* 185 0xb9 '¹' */
2973 0x6c, /* 0110110 */
2974 0x6c, /* 0110110 */
2975 0x6c, /* 0110110 */
2976 0x6c, /* 0110110 */
2977 0xec, /* 1110110 */
2978 0x0c, /* 0000110 */
2979 0xec, /* 1110110 */
2980 0x6c, /* 0110110 */
2981 0x6c, /* 0110110 */
2982 0x6c, /* 0110110 */
2983 0x6c, /* 0110110 */
2984 0x6c, /* 0110110 */
2985 0x6c, /* 0110110 */
2986 0x6c, /* 0110110 */
2987
2988 /* 186 0xba 'º' */
2989 0x6c, /* 0110110 */
2990 0x6c, /* 0110110 */
2991 0x6c, /* 0110110 */
2992 0x6c, /* 0110110 */
2993 0x6c, /* 0110110 */
2994 0x6c, /* 0110110 */
2995 0x6c, /* 0110110 */
2996 0x6c, /* 0110110 */
2997 0x6c, /* 0110110 */
2998 0x6c, /* 0110110 */
2999 0x6c, /* 0110110 */
3000 0x6c, /* 0110110 */
3001 0x6c, /* 0110110 */
3002 0x6c, /* 0110110 */
3003
3004 /* 187 0xbb '»' */
3005 0x00, /* 0000000 */
3006 0x00, /* 0000000 */
3007 0x00, /* 0000000 */
3008 0x00, /* 0000000 */
3009 0xfc, /* 1111110 */
3010 0x0c, /* 0000110 */
3011 0xec, /* 1110110 */
3012 0x6c, /* 0110110 */
3013 0x6c, /* 0110110 */
3014 0x6c, /* 0110110 */
3015 0x6c, /* 0110110 */
3016 0x6c, /* 0110110 */
3017 0x6c, /* 0110110 */
3018 0x6c, /* 0110110 */
3019
3020 /* 188 0xbc '¼' */
3021 0x6c, /* 0110110 */
3022 0x6c, /* 0110110 */
3023 0x6c, /* 0110110 */
3024 0x6c, /* 0110110 */
3025 0xec, /* 1110110 */
3026 0x0c, /* 0000110 */
3027 0xfc, /* 1111110 */
3028 0x00, /* 0000000 */
3029 0x00, /* 0000000 */
3030 0x00, /* 0000000 */
3031 0x00, /* 0000000 */
3032 0x00, /* 0000000 */
3033 0x00, /* 0000000 */
3034 0x00, /* 0000000 */
3035
3036 /* 189 0xbd '½' */
3037 0x6c, /* 0110110 */
3038 0x6c, /* 0110110 */
3039 0x6c, /* 0110110 */
3040 0x6c, /* 0110110 */
3041 0x6c, /* 0110110 */
3042 0x6c, /* 0110110 */
3043 0xfc, /* 1111110 */
3044 0x00, /* 0000000 */
3045 0x00, /* 0000000 */
3046 0x00, /* 0000000 */
3047 0x00, /* 0000000 */
3048 0x00, /* 0000000 */
3049 0x00, /* 0000000 */
3050 0x00, /* 0000000 */
3051
3052 /* 190 0xbe '¾' */
3053 0x30, /* 0011000 */
3054 0x30, /* 0011000 */
3055 0x30, /* 0011000 */
3056 0x30, /* 0011000 */
3057 0xf0, /* 1111000 */
3058 0x30, /* 0011000 */
3059 0xf0, /* 1111000 */
3060 0x00, /* 0000000 */
3061 0x00, /* 0000000 */
3062 0x00, /* 0000000 */
3063 0x00, /* 0000000 */
3064 0x00, /* 0000000 */
3065 0x00, /* 0000000 */
3066 0x00, /* 0000000 */
3067
3068 /* 191 0xbf '¿' */
3069 0x00, /* 0000000 */
3070 0x00, /* 0000000 */
3071 0x00, /* 0000000 */
3072 0x00, /* 0000000 */
3073 0x00, /* 0000000 */
3074 0x00, /* 0000000 */
3075 0xf0, /* 1111000 */
3076 0x30, /* 0011000 */
3077 0x30, /* 0011000 */
3078 0x30, /* 0011000 */
3079 0x30, /* 0011000 */
3080 0x30, /* 0011000 */
3081 0x30, /* 0011000 */
3082 0x30, /* 0011000 */
3083
3084 /* 192 0xc0 'À' */
3085 0x30, /* 0011000 */
3086 0x30, /* 0011000 */
3087 0x30, /* 0011000 */
3088 0x30, /* 0011000 */
3089 0x30, /* 0011000 */
3090 0x30, /* 0011000 */
3091 0x3e, /* 0011111 */
3092 0x00, /* 0000000 */
3093 0x00, /* 0000000 */
3094 0x00, /* 0000000 */
3095 0x00, /* 0000000 */
3096 0x00, /* 0000000 */
3097 0x00, /* 0000000 */
3098 0x00, /* 0000000 */
3099
3100 /* 193 0xc1 'Á' */
3101 0x30, /* 0011000 */
3102 0x30, /* 0011000 */
3103 0x30, /* 0011000 */
3104 0x30, /* 0011000 */
3105 0x30, /* 0011000 */
3106 0x30, /* 0011000 */
3107 0xfe, /* 1111111 */
3108 0x00, /* 0000000 */
3109 0x00, /* 0000000 */
3110 0x00, /* 0000000 */
3111 0x00, /* 0000000 */
3112 0x00, /* 0000000 */
3113 0x00, /* 0000000 */
3114 0x00, /* 0000000 */
3115
3116 /* 194 0xc2 'Â' */
3117 0x00, /* 0000000 */
3118 0x00, /* 0000000 */
3119 0x00, /* 0000000 */
3120 0x00, /* 0000000 */
3121 0x00, /* 0000000 */
3122 0x00, /* 0000000 */
3123 0xfe, /* 1111111 */
3124 0x30, /* 0011000 */
3125 0x30, /* 0011000 */
3126 0x30, /* 0011000 */
3127 0x30, /* 0011000 */
3128 0x30, /* 0011000 */
3129 0x30, /* 0011000 */
3130 0x30, /* 0011000 */
3131
3132 /* 195 0xc3 'Ã' */
3133 0x30, /* 0011000 */
3134 0x30, /* 0011000 */
3135 0x30, /* 0011000 */
3136 0x30, /* 0011000 */
3137 0x30, /* 0011000 */
3138 0x30, /* 0011000 */
3139 0x3e, /* 0011111 */
3140 0x30, /* 0011000 */
3141 0x30, /* 0011000 */
3142 0x30, /* 0011000 */
3143 0x30, /* 0011000 */
3144 0x30, /* 0011000 */
3145 0x30, /* 0011000 */
3146 0x30, /* 0011000 */
3147
3148 /* 196 0xc4 'Ä' */
3149 0x00, /* 0000000 */
3150 0x00, /* 0000000 */
3151 0x00, /* 0000000 */
3152 0x00, /* 0000000 */
3153 0x00, /* 0000000 */
3154 0x00, /* 0000000 */
3155 0xfe, /* 1111111 */
3156 0x00, /* 0000000 */
3157 0x00, /* 0000000 */
3158 0x00, /* 0000000 */
3159 0x00, /* 0000000 */
3160 0x00, /* 0000000 */
3161 0x00, /* 0000000 */
3162 0x00, /* 0000000 */
3163
3164 /* 197 0xc5 'Å' */
3165 0x30, /* 0011000 */
3166 0x30, /* 0011000 */
3167 0x30, /* 0011000 */
3168 0x30, /* 0011000 */
3169 0x30, /* 0011000 */
3170 0x30, /* 0011000 */
3171 0xfe, /* 1111111 */
3172 0x30, /* 0011000 */
3173 0x30, /* 0011000 */
3174 0x30, /* 0011000 */
3175 0x30, /* 0011000 */
3176 0x30, /* 0011000 */
3177 0x30, /* 0011000 */
3178 0x30, /* 0011000 */
3179
3180 /* 198 0xc6 'Æ' */
3181 0x30, /* 0011000 */
3182 0x30, /* 0011000 */
3183 0x30, /* 0011000 */
3184 0x30, /* 0011000 */
3185 0x3e, /* 0011111 */
3186 0x30, /* 0011000 */
3187 0x3e, /* 0011111 */
3188 0x30, /* 0011000 */
3189 0x30, /* 0011000 */
3190 0x30, /* 0011000 */
3191 0x30, /* 0011000 */
3192 0x30, /* 0011000 */
3193 0x30, /* 0011000 */
3194 0x30, /* 0011000 */
3195
3196 /* 199 0xc7 'Ç' */
3197 0x6c, /* 0110110 */
3198 0x6c, /* 0110110 */
3199 0x6c, /* 0110110 */
3200 0x6c, /* 0110110 */
3201 0x6c, /* 0110110 */
3202 0x6c, /* 0110110 */
3203 0x6e, /* 0110111 */
3204 0x6c, /* 0110110 */
3205 0x6c, /* 0110110 */
3206 0x6c, /* 0110110 */
3207 0x6c, /* 0110110 */
3208 0x6c, /* 0110110 */
3209 0x6c, /* 0110110 */
3210 0x6c, /* 0110110 */
3211
3212 /* 200 0xc8 'È' */
3213 0x6c, /* 0110110 */
3214 0x6c, /* 0110110 */
3215 0x6c, /* 0110110 */
3216 0x6c, /* 0110110 */
3217 0x6e, /* 0110111 */
3218 0x60, /* 0110000 */
3219 0x7e, /* 0111111 */
3220 0x00, /* 0000000 */
3221 0x00, /* 0000000 */
3222 0x00, /* 0000000 */
3223 0x00, /* 0000000 */
3224 0x00, /* 0000000 */
3225 0x00, /* 0000000 */
3226 0x00, /* 0000000 */
3227
3228 /* 201 0xc9 'É' */
3229 0x00, /* 0000000 */
3230 0x00, /* 0000000 */
3231 0x00, /* 0000000 */
3232 0x00, /* 0000000 */
3233 0x7e, /* 0111111 */
3234 0x60, /* 0110000 */
3235 0x6e, /* 0110111 */
3236 0x6c, /* 0110110 */
3237 0x6c, /* 0110110 */
3238 0x6c, /* 0110110 */
3239 0x6c, /* 0110110 */
3240 0x6c, /* 0110110 */
3241 0x6c, /* 0110110 */
3242 0x6c, /* 0110110 */
3243
3244 /* 202 0xca 'Ê' */
3245 0x6c, /* 0110110 */
3246 0x6c, /* 0110110 */
3247 0x6c, /* 0110110 */
3248 0x6c, /* 0110110 */
3249 0xee, /* 1110111 */
3250 0x00, /* 0000000 */
3251 0xfe, /* 1111111 */
3252 0x00, /* 0000000 */
3253 0x00, /* 0000000 */
3254 0x00, /* 0000000 */
3255 0x00, /* 0000000 */
3256 0x00, /* 0000000 */
3257 0x00, /* 0000000 */
3258 0x00, /* 0000000 */
3259
3260 /* 203 0xcb 'Ë' */
3261 0x00, /* 0000000 */
3262 0x00, /* 0000000 */
3263 0x00, /* 0000000 */
3264 0x00, /* 0000000 */
3265 0xfe, /* 1111111 */
3266 0x00, /* 0000000 */
3267 0xee, /* 1110111 */
3268 0x6c, /* 0110110 */
3269 0x6c, /* 0110110 */
3270 0x6c, /* 0110110 */
3271 0x6c, /* 0110110 */
3272 0x6c, /* 0110110 */
3273 0x6c, /* 0110110 */
3274 0x6c, /* 0110110 */
3275
3276 /* 204 0xcc 'Ì' */
3277 0x6c, /* 0110110 */
3278 0x6c, /* 0110110 */
3279 0x6c, /* 0110110 */
3280 0x6c, /* 0110110 */
3281 0x6e, /* 0110111 */
3282 0x60, /* 0110000 */
3283 0x6e, /* 0110111 */
3284 0x6c, /* 0110110 */
3285 0x6c, /* 0110110 */
3286 0x6c, /* 0110110 */
3287 0x6c, /* 0110110 */
3288 0x6c, /* 0110110 */
3289 0x6c, /* 0110110 */
3290 0x6c, /* 0110110 */
3291
3292 /* 205 0xcd 'Í' */
3293 0x00, /* 0000000 */
3294 0x00, /* 0000000 */
3295 0x00, /* 0000000 */
3296 0x00, /* 0000000 */
3297 0xfe, /* 1111111 */
3298 0x00, /* 0000000 */
3299 0xfe, /* 1111111 */
3300 0x00, /* 0000000 */
3301 0x00, /* 0000000 */
3302 0x00, /* 0000000 */
3303 0x00, /* 0000000 */
3304 0x00, /* 0000000 */
3305 0x00, /* 0000000 */
3306 0x00, /* 0000000 */
3307
3308 /* 206 0xce 'Î' */
3309 0x6c, /* 0110110 */
3310 0x6c, /* 0110110 */
3311 0x6c, /* 0110110 */
3312 0x6c, /* 0110110 */
3313 0xee, /* 1110111 */
3314 0x00, /* 0000000 */
3315 0xee, /* 1110111 */
3316 0x6c, /* 0110110 */
3317 0x6c, /* 0110110 */
3318 0x6c, /* 0110110 */
3319 0x6c, /* 0110110 */
3320 0x6c, /* 0110110 */
3321 0x6c, /* 0110110 */
3322 0x6c, /* 0110110 */
3323
3324 /* 207 0xcf 'Ï' */
3325 0x30, /* 0011000 */
3326 0x30, /* 0011000 */
3327 0x30, /* 0011000 */
3328 0x30, /* 0011000 */
3329 0xfe, /* 1111111 */
3330 0x00, /* 0000000 */
3331 0xfe, /* 1111111 */
3332 0x00, /* 0000000 */
3333 0x00, /* 0000000 */
3334 0x00, /* 0000000 */
3335 0x00, /* 0000000 */
3336 0x00, /* 0000000 */
3337 0x00, /* 0000000 */
3338 0x00, /* 0000000 */
3339
3340 /* 208 0xd0 'Ð' */
3341 0x6c, /* 0110110 */
3342 0x6c, /* 0110110 */
3343 0x6c, /* 0110110 */
3344 0x6c, /* 0110110 */
3345 0x6c, /* 0110110 */
3346 0x6c, /* 0110110 */
3347 0xfe, /* 1111111 */
3348 0x00, /* 0000000 */
3349 0x00, /* 0000000 */
3350 0x00, /* 0000000 */
3351 0x00, /* 0000000 */
3352 0x00, /* 0000000 */
3353 0x00, /* 0000000 */
3354 0x00, /* 0000000 */
3355
3356 /* 209 0xd1 'Ñ' */
3357 0x00, /* 0000000 */
3358 0x00, /* 0000000 */
3359 0x00, /* 0000000 */
3360 0x00, /* 0000000 */
3361 0xfe, /* 1111111 */
3362 0x00, /* 0000000 */
3363 0xfe, /* 1111111 */
3364 0x30, /* 0011000 */
3365 0x30, /* 0011000 */
3366 0x30, /* 0011000 */
3367 0x30, /* 0011000 */
3368 0x30, /* 0011000 */
3369 0x30, /* 0011000 */
3370 0x30, /* 0011000 */
3371
3372 /* 210 0xd2 'Ò' */
3373 0x00, /* 0000000 */
3374 0x00, /* 0000000 */
3375 0x00, /* 0000000 */
3376 0x00, /* 0000000 */
3377 0x00, /* 0000000 */
3378 0x00, /* 0000000 */
3379 0xfe, /* 1111111 */
3380 0x6c, /* 0110110 */
3381 0x6c, /* 0110110 */
3382 0x6c, /* 0110110 */
3383 0x6c, /* 0110110 */
3384 0x6c, /* 0110110 */
3385 0x6c, /* 0110110 */
3386 0x6c, /* 0110110 */
3387
3388 /* 211 0xd3 'Ó' */
3389 0x6c, /* 0110110 */
3390 0x6c, /* 0110110 */
3391 0x6c, /* 0110110 */
3392 0x6c, /* 0110110 */
3393 0x6c, /* 0110110 */
3394 0x6c, /* 0110110 */
3395 0x7e, /* 0111111 */
3396 0x00, /* 0000000 */
3397 0x00, /* 0000000 */
3398 0x00, /* 0000000 */
3399 0x00, /* 0000000 */
3400 0x00, /* 0000000 */
3401 0x00, /* 0000000 */
3402 0x00, /* 0000000 */
3403
3404 /* 212 0xd4 'Ô' */
3405 0x30, /* 0011000 */
3406 0x30, /* 0011000 */
3407 0x30, /* 0011000 */
3408 0x30, /* 0011000 */
3409 0x3e, /* 0011111 */
3410 0x30, /* 0011000 */
3411 0x3e, /* 0011111 */
3412 0x00, /* 0000000 */
3413 0x00, /* 0000000 */
3414 0x00, /* 0000000 */
3415 0x00, /* 0000000 */
3416 0x00, /* 0000000 */
3417 0x00, /* 0000000 */
3418 0x00, /* 0000000 */
3419
3420 /* 213 0xd5 'Õ' */
3421 0x00, /* 0000000 */
3422 0x00, /* 0000000 */
3423 0x00, /* 0000000 */
3424 0x00, /* 0000000 */
3425 0x3e, /* 0011111 */
3426 0x30, /* 0011000 */
3427 0x3e, /* 0011111 */
3428 0x30, /* 0011000 */
3429 0x30, /* 0011000 */
3430 0x30, /* 0011000 */
3431 0x30, /* 0011000 */
3432 0x30, /* 0011000 */
3433 0x30, /* 0011000 */
3434 0x30, /* 0011000 */
3435
3436 /* 214 0xd6 'Ö' */
3437 0x00, /* 0000000 */
3438 0x00, /* 0000000 */
3439 0x00, /* 0000000 */
3440 0x00, /* 0000000 */
3441 0x00, /* 0000000 */
3442 0x00, /* 0000000 */
3443 0x7e, /* 0111111 */
3444 0x6c, /* 0110110 */
3445 0x6c, /* 0110110 */
3446 0x6c, /* 0110110 */
3447 0x6c, /* 0110110 */
3448 0x6c, /* 0110110 */
3449 0x6c, /* 0110110 */
3450 0x6c, /* 0110110 */
3451
3452 /* 215 0xd7 '×' */
3453 0x6c, /* 0110110 */
3454 0x6c, /* 0110110 */
3455 0x6c, /* 0110110 */
3456 0x6c, /* 0110110 */
3457 0x6c, /* 0110110 */
3458 0x6c, /* 0110110 */
3459 0xfe, /* 1111111 */
3460 0x6c, /* 0110110 */
3461 0x6c, /* 0110110 */
3462 0x6c, /* 0110110 */
3463 0x6c, /* 0110110 */
3464 0x6c, /* 0110110 */
3465 0x6c, /* 0110110 */
3466 0x6c, /* 0110110 */
3467
3468 /* 216 0xd8 'Ø' */
3469 0x30, /* 0011000 */
3470 0x30, /* 0011000 */
3471 0x30, /* 0011000 */
3472 0x30, /* 0011000 */
3473 0xfe, /* 1111111 */
3474 0x30, /* 0011000 */
3475 0xfe, /* 1111111 */
3476 0x30, /* 0011000 */
3477 0x30, /* 0011000 */
3478 0x30, /* 0011000 */
3479 0x30, /* 0011000 */
3480 0x30, /* 0011000 */
3481 0x30, /* 0011000 */
3482 0x30, /* 0011000 */
3483
3484 /* 217 0xd9 'Ù' */
3485 0x30, /* 0011000 */
3486 0x30, /* 0011000 */
3487 0x30, /* 0011000 */
3488 0x30, /* 0011000 */
3489 0x30, /* 0011000 */
3490 0x30, /* 0011000 */
3491 0xf0, /* 1111000 */
3492 0x00, /* 0000000 */
3493 0x00, /* 0000000 */
3494 0x00, /* 0000000 */
3495 0x00, /* 0000000 */
3496 0x00, /* 0000000 */
3497 0x00, /* 0000000 */
3498 0x00, /* 0000000 */
3499
3500 /* 218 0xda 'Ú' */
3501 0x00, /* 0000000 */
3502 0x00, /* 0000000 */
3503 0x00, /* 0000000 */
3504 0x00, /* 0000000 */
3505 0x00, /* 0000000 */
3506 0x00, /* 0000000 */
3507 0x3e, /* 0011111 */
3508 0x30, /* 0011000 */
3509 0x30, /* 0011000 */
3510 0x30, /* 0011000 */
3511 0x30, /* 0011000 */
3512 0x30, /* 0011000 */
3513 0x30, /* 0011000 */
3514 0x30, /* 0011000 */
3515
3516 /* 219 0xdb 'Û' */
3517 0xfe, /* 1111111 */
3518 0xfe, /* 1111111 */
3519 0xfe, /* 1111111 */
3520 0xfe, /* 1111111 */
3521 0xfe, /* 1111111 */
3522 0xfe, /* 1111111 */
3523 0xfe, /* 1111111 */
3524 0xfe, /* 1111111 */
3525 0xfe, /* 1111111 */
3526 0xfe, /* 1111111 */
3527 0xfe, /* 1111111 */
3528 0xfe, /* 1111111 */
3529 0xfe, /* 1111111 */
3530 0xfe, /* 1111111 */
3531
3532 /* 220 0xdc 'Ü' */
3533 0x00, /* 0000000 */
3534 0x00, /* 0000000 */
3535 0x00, /* 0000000 */
3536 0x00, /* 0000000 */
3537 0x00, /* 0000000 */
3538 0x00, /* 0000000 */
3539 0xfe, /* 1111111 */
3540 0xfe, /* 1111111 */
3541 0xfe, /* 1111111 */
3542 0xfe, /* 1111111 */
3543 0xfe, /* 1111111 */
3544 0xfe, /* 1111111 */
3545 0xfe, /* 1111111 */
3546 0xfe, /* 1111111 */
3547
3548 /* 221 0xdd 'Ý' */
3549 0xe0, /* 1110000 */
3550 0xe0, /* 1110000 */
3551 0xe0, /* 1110000 */
3552 0xe0, /* 1110000 */
3553 0xe0, /* 1110000 */
3554 0xe0, /* 1110000 */
3555 0xe0, /* 1110000 */
3556 0xe0, /* 1110000 */
3557 0xe0, /* 1110000 */
3558 0xe0, /* 1110000 */
3559 0xe0, /* 1110000 */
3560 0xe0, /* 1110000 */
3561 0xe0, /* 1110000 */
3562 0xe0, /* 1110000 */
3563
3564 /* 222 0xde 'Þ' */
3565 0x1e, /* 0001111 */
3566 0x1e, /* 0001111 */
3567 0x1e, /* 0001111 */
3568 0x1e, /* 0001111 */
3569 0x1e, /* 0001111 */
3570 0x1e, /* 0001111 */
3571 0x1e, /* 0001111 */
3572 0x1e, /* 0001111 */
3573 0x1e, /* 0001111 */
3574 0x1e, /* 0001111 */
3575 0x1e, /* 0001111 */
3576 0x1e, /* 0001111 */
3577 0x1e, /* 0001111 */
3578 0x1e, /* 0001111 */
3579
3580 /* 223 0xdf 'ß' */
3581 0xfe, /* 1111111 */
3582 0xfe, /* 1111111 */
3583 0xfe, /* 1111111 */
3584 0xfe, /* 1111111 */
3585 0xfe, /* 1111111 */
3586 0xfe, /* 1111111 */
3587 0x00, /* 0000000 */
3588 0x00, /* 0000000 */
3589 0x00, /* 0000000 */
3590 0x00, /* 0000000 */
3591 0x00, /* 0000000 */
3592 0x00, /* 0000000 */
3593 0x00, /* 0000000 */
3594 0x00, /* 0000000 */
3595
3596 /* 224 0xe0 'à' */
3597 0x00, /* 0000000 */
3598 0x00, /* 0000000 */
3599 0x00, /* 0000000 */
3600 0x00, /* 0000000 */
3601 0x76, /* 0111011 */
3602 0xdc, /* 1101110 */
3603 0xd8, /* 1101100 */
3604 0xd8, /* 1101100 */
3605 0xd8, /* 1101100 */
3606 0xdc, /* 1101110 */
3607 0x76, /* 0111011 */
3608 0x00, /* 0000000 */
3609 0x00, /* 0000000 */
3610 0x00, /* 0000000 */
3611
3612 /* 225 0xe1 'á' */
3613 0x00, /* 0000000 */
3614 0x78, /* 0111100 */
3615 0xcc, /* 1100110 */
3616 0xcc, /* 1100110 */
3617 0xcc, /* 1100110 */
3618 0xd8, /* 1101100 */
3619 0xcc, /* 1100110 */
3620 0xc6, /* 1100011 */
3621 0xc6, /* 1100011 */
3622 0xc6, /* 1100011 */
3623 0xcc, /* 1100110 */
3624 0x00, /* 0000000 */
3625 0x00, /* 0000000 */
3626 0x00, /* 0000000 */
3627
3628 /* 226 0xe2 'â' */
3629 0x00, /* 0000000 */
3630 0xfc, /* 1111110 */
3631 0xcc, /* 1100110 */
3632 0xcc, /* 1100110 */
3633 0xc0, /* 1100000 */
3634 0xc0, /* 1100000 */
3635 0xc0, /* 1100000 */
3636 0xc0, /* 1100000 */
3637 0xc0, /* 1100000 */
3638 0xc0, /* 1100000 */
3639 0xc0, /* 1100000 */
3640 0x00, /* 0000000 */
3641 0x00, /* 0000000 */
3642 0x00, /* 0000000 */
3643
3644 /* 227 0xe3 'ã' */
3645 0x00, /* 0000000 */
3646 0x00, /* 0000000 */
3647 0xfe, /* 1111111 */
3648 0xfe, /* 1111111 */
3649 0x6c, /* 0110110 */
3650 0x6c, /* 0110110 */
3651 0x6c, /* 0110110 */
3652 0x6c, /* 0110110 */
3653 0x6c, /* 0110110 */
3654 0x6c, /* 0110110 */
3655 0x6c, /* 0110110 */
3656 0x00, /* 0000000 */
3657 0x00, /* 0000000 */
3658 0x00, /* 0000000 */
3659
3660 /* 228 0xe4 'ä' */
3661 0x00, /* 0000000 */
3662 0xfc, /* 1111110 */
3663 0xcc, /* 1100110 */
3664 0x60, /* 0110000 */
3665 0x30, /* 0011000 */
3666 0x18, /* 0001100 */
3667 0x18, /* 0001100 */
3668 0x30, /* 0011000 */
3669 0x60, /* 0110000 */
3670 0xcc, /* 1100110 */
3671 0xfc, /* 1111110 */
3672 0x00, /* 0000000 */
3673 0x00, /* 0000000 */
3674 0x00, /* 0000000 */
3675
3676 /* 229 0xe5 'å' */
3677 0x00, /* 0000000 */
3678 0x00, /* 0000000 */
3679 0x00, /* 0000000 */
3680 0x00, /* 0000000 */
3681 0x7e, /* 0111111 */
3682 0xd8, /* 1101100 */
3683 0xd8, /* 1101100 */
3684 0xd8, /* 1101100 */
3685 0xd8, /* 1101100 */
3686 0xd8, /* 1101100 */
3687 0x70, /* 0111000 */
3688 0x00, /* 0000000 */
3689 0x00, /* 0000000 */
3690 0x00, /* 0000000 */
3691
3692 /* 230 0xe6 'æ' */
3693 0x00, /* 0000000 */
3694 0x00, /* 0000000 */
3695 0x00, /* 0000000 */
3696 0x00, /* 0000000 */
3697 0xcc, /* 1100110 */
3698 0xcc, /* 1100110 */
3699 0xcc, /* 1100110 */
3700 0xcc, /* 1100110 */
3701 0xcc, /* 1100110 */
3702 0xcc, /* 1100110 */
3703 0xf8, /* 1111100 */
3704 0xc0, /* 1100000 */
3705 0xc0, /* 1100000 */
3706 0x80, /* 1000000 */
3707
3708 /* 231 0xe7 'ç' */
3709 0x00, /* 0000000 */
3710 0x00, /* 0000000 */
3711 0x00, /* 0000000 */
3712 0x76, /* 0111011 */
3713 0xdc, /* 1101110 */
3714 0x18, /* 0001100 */
3715 0x18, /* 0001100 */
3716 0x18, /* 0001100 */
3717 0x18, /* 0001100 */
3718 0x18, /* 0001100 */
3719 0x18, /* 0001100 */
3720 0x00, /* 0000000 */
3721 0x00, /* 0000000 */
3722 0x00, /* 0000000 */
3723
3724 /* 232 0xe8 'è' */
3725 0x00, /* 0000000 */
3726 0xfc, /* 1111110 */
3727 0x30, /* 0011000 */
3728 0x78, /* 0111100 */
3729 0xcc, /* 1100110 */
3730 0xcc, /* 1100110 */
3731 0xcc, /* 1100110 */
3732 0xcc, /* 1100110 */
3733 0x78, /* 0111100 */
3734 0x30, /* 0011000 */
3735 0xfc, /* 1111110 */
3736 0x00, /* 0000000 */
3737 0x00, /* 0000000 */
3738 0x00, /* 0000000 */
3739
3740 /* 233 0xe9 'é' */
3741 0x00, /* 0000000 */
3742 0x38, /* 0011100 */
3743 0x6c, /* 0110110 */
3744 0xcc, /* 1100110 */
3745 0xcc, /* 1100110 */
3746 0xfc, /* 1111110 */
3747 0xcc, /* 1100110 */
3748 0xcc, /* 1100110 */
3749 0xcc, /* 1100110 */
3750 0x6c, /* 0110110 */
3751 0x38, /* 0011100 */
3752 0x00, /* 0000000 */
3753 0x00, /* 0000000 */
3754 0x00, /* 0000000 */
3755
3756 /* 234 0xea 'ê' */
3757 0x00, /* 0000000 */
3758 0x38, /* 0011100 */
3759 0x6c, /* 0110110 */
3760 0xc6, /* 1100011 */
3761 0xc6, /* 1100011 */
3762 0xc6, /* 1100011 */
3763 0x6c, /* 0110110 */
3764 0x6c, /* 0110110 */
3765 0x6c, /* 0110110 */
3766 0x6c, /* 0110110 */
3767 0xee, /* 1110111 */
3768 0x00, /* 0000000 */
3769 0x00, /* 0000000 */
3770 0x00, /* 0000000 */
3771
3772 /* 235 0xeb 'ë' */
3773 0x00, /* 0000000 */
3774 0x3c, /* 0011110 */
3775 0x60, /* 0110000 */
3776 0x30, /* 0011000 */
3777 0x18, /* 0001100 */
3778 0x7c, /* 0111110 */
3779 0xcc, /* 1100110 */
3780 0xcc, /* 1100110 */
3781 0xcc, /* 1100110 */
3782 0xcc, /* 1100110 */
3783 0x78, /* 0111100 */
3784 0x00, /* 0000000 */
3785 0x00, /* 0000000 */
3786 0x00, /* 0000000 */
3787
3788 /* 236 0xec 'ì' */
3789 0x00, /* 0000000 */
3790 0x00, /* 0000000 */
3791 0x00, /* 0000000 */
3792 0x00, /* 0000000 */
3793 0x7c, /* 0111110 */
3794 0xd6, /* 1101011 */
3795 0xd6, /* 1101011 */
3796 0xd6, /* 1101011 */
3797 0x7c, /* 0111110 */
3798 0x00, /* 0000000 */
3799 0x00, /* 0000000 */
3800 0x00, /* 0000000 */
3801 0x00, /* 0000000 */
3802 0x00, /* 0000000 */
3803
3804 /* 237 0xed 'í' */
3805 0x00, /* 0000000 */
3806 0x00, /* 0000000 */
3807 0x06, /* 0000011 */
3808 0x0c, /* 0000110 */
3809 0x7c, /* 0111110 */
3810 0xd6, /* 1101011 */
3811 0xd6, /* 1101011 */
3812 0xe6, /* 1110011 */
3813 0x7c, /* 0111110 */
3814 0x60, /* 0110000 */
3815 0xc0, /* 1100000 */
3816 0x00, /* 0000000 */
3817 0x00, /* 0000000 */
3818 0x00, /* 0000000 */
3819
3820 /* 238 0xee 'î' */
3821 0x00, /* 0000000 */
3822 0x1c, /* 0001110 */
3823 0x30, /* 0011000 */
3824 0x60, /* 0110000 */
3825 0x60, /* 0110000 */
3826 0x7c, /* 0111110 */
3827 0x60, /* 0110000 */
3828 0x60, /* 0110000 */
3829 0x60, /* 0110000 */
3830 0x30, /* 0011000 */
3831 0x1c, /* 0001110 */
3832 0x00, /* 0000000 */
3833 0x00, /* 0000000 */
3834 0x00, /* 0000000 */
3835
3836 /* 239 0xef 'ï' */
3837 0x00, /* 0000000 */
3838 0x00, /* 0000000 */
3839 0x78, /* 0111100 */
3840 0xcc, /* 1100110 */
3841 0xcc, /* 1100110 */
3842 0xcc, /* 1100110 */
3843 0xcc, /* 1100110 */
3844 0xcc, /* 1100110 */
3845 0xcc, /* 1100110 */
3846 0xcc, /* 1100110 */
3847 0xcc, /* 1100110 */
3848 0x00, /* 0000000 */
3849 0x00, /* 0000000 */
3850 0x00, /* 0000000 */
3851
3852 /* 240 0xf0 'ð' */
3853 0x00, /* 0000000 */
3854 0x00, /* 0000000 */
3855 0x00, /* 0000000 */
3856 0xfc, /* 1111110 */
3857 0x00, /* 0000000 */
3858 0x00, /* 0000000 */
3859 0xfc, /* 1111110 */
3860 0x00, /* 0000000 */
3861 0x00, /* 0000000 */
3862 0xfc, /* 1111110 */
3863 0x00, /* 0000000 */
3864 0x00, /* 0000000 */
3865 0x00, /* 0000000 */
3866 0x00, /* 0000000 */
3867
3868 /* 241 0xf1 'ñ' */
3869 0x00, /* 0000000 */
3870 0x00, /* 0000000 */
3871 0x00, /* 0000000 */
3872 0x30, /* 0011000 */
3873 0x30, /* 0011000 */
3874 0xfc, /* 1111110 */
3875 0x30, /* 0011000 */
3876 0x30, /* 0011000 */
3877 0x00, /* 0000000 */
3878 0x00, /* 0000000 */
3879 0xfc, /* 1111110 */
3880 0x00, /* 0000000 */
3881 0x00, /* 0000000 */
3882 0x00, /* 0000000 */
3883
3884 /* 242 0xf2 'ò' */
3885 0x00, /* 0000000 */
3886 0x00, /* 0000000 */
3887 0x60, /* 0110000 */
3888 0x30, /* 0011000 */
3889 0x18, /* 0001100 */
3890 0x0c, /* 0000110 */
3891 0x18, /* 0001100 */
3892 0x30, /* 0011000 */
3893 0x60, /* 0110000 */
3894 0x00, /* 0000000 */
3895 0xfc, /* 1111110 */
3896 0x00, /* 0000000 */
3897 0x00, /* 0000000 */
3898 0x00, /* 0000000 */
3899
3900 /* 243 0xf3 'ó' */
3901 0x00, /* 0000000 */
3902 0x00, /* 0000000 */
3903 0x18, /* 0001100 */
3904 0x30, /* 0011000 */
3905 0x60, /* 0110000 */
3906 0xc0, /* 1100000 */
3907 0x60, /* 0110000 */
3908 0x30, /* 0011000 */
3909 0x18, /* 0001100 */
3910 0x00, /* 0000000 */
3911 0xfc, /* 1111110 */
3912 0x00, /* 0000000 */
3913 0x00, /* 0000000 */
3914 0x00, /* 0000000 */
3915
3916 /* 244 0xf4 'ô' */
3917 0x00, /* 0000000 */
3918 0x1c, /* 0001110 */
3919 0x36, /* 0011011 */
3920 0x36, /* 0011011 */
3921 0x30, /* 0011000 */
3922 0x30, /* 0011000 */
3923 0x30, /* 0011000 */
3924 0x30, /* 0011000 */
3925 0x30, /* 0011000 */
3926 0x30, /* 0011000 */
3927 0x30, /* 0011000 */
3928 0x30, /* 0011000 */
3929 0x30, /* 0011000 */
3930 0x30, /* 0011000 */
3931
3932 /* 245 0xf5 'õ' */
3933 0x18, /* 0001100 */
3934 0x18, /* 0001100 */
3935 0x18, /* 0001100 */
3936 0x18, /* 0001100 */
3937 0x18, /* 0001100 */
3938 0x18, /* 0001100 */
3939 0x18, /* 0001100 */
3940 0x18, /* 0001100 */
3941 0xd8, /* 1101100 */
3942 0xd8, /* 1101100 */
3943 0xd8, /* 1101100 */
3944 0x70, /* 0111000 */
3945 0x00, /* 0000000 */
3946 0x00, /* 0000000 */
3947
3948 /* 246 0xf6 'ö' */
3949 0x00, /* 0000000 */
3950 0x00, /* 0000000 */
3951 0x00, /* 0000000 */
3952 0x00, /* 0000000 */
3953 0x30, /* 0011000 */
3954 0x00, /* 0000000 */
3955 0xfc, /* 1111110 */
3956 0x00, /* 0000000 */
3957 0x30, /* 0011000 */
3958 0x00, /* 0000000 */
3959 0x00, /* 0000000 */
3960 0x00, /* 0000000 */
3961 0x00, /* 0000000 */
3962 0x00, /* 0000000 */
3963
3964 /* 247 0xf7 '÷' */
3965 0x00, /* 0000000 */
3966 0x00, /* 0000000 */
3967 0x00, /* 0000000 */
3968 0x00, /* 0000000 */
3969 0x76, /* 0111011 */
3970 0xdc, /* 1101110 */
3971 0x00, /* 0000000 */
3972 0x76, /* 0111011 */
3973 0xdc, /* 1101110 */
3974 0x00, /* 0000000 */
3975 0x00, /* 0000000 */
3976 0x00, /* 0000000 */
3977 0x00, /* 0000000 */
3978 0x00, /* 0000000 */
3979
3980 /* 248 0xf8 'ø' */
3981 0x38, /* 0011100 */
3982 0x6c, /* 0110110 */
3983 0x6c, /* 0110110 */
3984 0x38, /* 0011100 */
3985 0x00, /* 0000000 */
3986 0x00, /* 0000000 */
3987 0x00, /* 0000000 */
3988 0x00, /* 0000000 */
3989 0x00, /* 0000000 */
3990 0x00, /* 0000000 */
3991 0x00, /* 0000000 */
3992 0x00, /* 0000000 */
3993 0x00, /* 0000000 */
3994 0x00, /* 0000000 */
3995
3996 /* 249 0xf9 'ù' */
3997 0x00, /* 0000000 */
3998 0x00, /* 0000000 */
3999 0x00, /* 0000000 */
4000 0x00, /* 0000000 */
4001 0x00, /* 0000000 */
4002 0x00, /* 0000000 */
4003 0x30, /* 0011000 */
4004 0x30, /* 0011000 */
4005 0x00, /* 0000000 */
4006 0x00, /* 0000000 */
4007 0x00, /* 0000000 */
4008 0x00, /* 0000000 */
4009 0x00, /* 0000000 */
4010 0x00, /* 0000000 */
4011
4012 /* 250 0xfa 'ú' */
4013 0x00, /* 0000000 */
4014 0x00, /* 0000000 */
4015 0x00, /* 0000000 */
4016 0x00, /* 0000000 */
4017 0x00, /* 0000000 */
4018 0x00, /* 0000000 */
4019 0x30, /* 0011000 */
4020 0x00, /* 0000000 */
4021 0x00, /* 0000000 */
4022 0x00, /* 0000000 */
4023 0x00, /* 0000000 */
4024 0x00, /* 0000000 */
4025 0x00, /* 0000000 */
4026 0x00, /* 0000000 */
4027
4028 /* 251 0xfb 'û' */
4029 0x1e, /* 0001111 */
4030 0x18, /* 0001100 */
4031 0x18, /* 0001100 */
4032 0x18, /* 0001100 */
4033 0x18, /* 0001100 */
4034 0x18, /* 0001100 */
4035 0xd8, /* 1101100 */
4036 0xd8, /* 1101100 */
4037 0xd8, /* 1101100 */
4038 0x78, /* 0111100 */
4039 0x38, /* 0011100 */
4040 0x00, /* 0000000 */
4041 0x00, /* 0000000 */
4042 0x00, /* 0000000 */
4043
4044 /* 252 0xfc 'ü' */
4045 0xd8, /* 1101100 */
4046 0x6c, /* 0110110 */
4047 0x6c, /* 0110110 */
4048 0x6c, /* 0110110 */
4049 0x6c, /* 0110110 */
4050 0x6c, /* 0110110 */
4051 0x00, /* 0000000 */
4052 0x00, /* 0000000 */
4053 0x00, /* 0000000 */
4054 0x00, /* 0000000 */
4055 0x00, /* 0000000 */
4056 0x00, /* 0000000 */
4057 0x00, /* 0000000 */
4058 0x00, /* 0000000 */
4059
4060 /* 253 0xfd 'ý' */
4061 0x78, /* 0111100 */
4062 0xcc, /* 1100110 */
4063 0x18, /* 0001100 */
4064 0x30, /* 0011000 */
4065 0x64, /* 0110010 */
4066 0xfc, /* 1111110 */
4067 0x00, /* 0000000 */
4068 0x00, /* 0000000 */
4069 0x00, /* 0000000 */
4070 0x00, /* 0000000 */
4071 0x00, /* 0000000 */
4072 0x00, /* 0000000 */
4073 0x00, /* 0000000 */
4074 0x00, /* 0000000 */
4075
4076 /* 254 0xfe 'þ' */
4077 0x00, /* 0000000 */
4078 0x00, /* 0000000 */
4079 0x00, /* 0000000 */
4080 0x7c, /* 0111110 */
4081 0x7c, /* 0111110 */
4082 0x7c, /* 0111110 */
4083 0x7c, /* 0111110 */
4084 0x7c, /* 0111110 */
4085 0x7c, /* 0111110 */
4086 0x7c, /* 0111110 */
4087 0x00, /* 0000000 */
4088 0x00, /* 0000000 */
4089 0x00, /* 0000000 */
4090 0x00, /* 0000000 */
4091
4092 /* 255 0xff 'ÿ' */
4093 0x00, /* 0000000 */
4094 0x00, /* 0000000 */
4095 0x00, /* 0000000 */
4096 0x00, /* 0000000 */
4097 0x00, /* 0000000 */
4098 0x00, /* 0000000 */
4099 0x00, /* 0000000 */
4100 0x00, /* 0000000 */
4101 0x00, /* 0000000 */
4102 0x00, /* 0000000 */
4103 0x00, /* 0000000 */
4104 0x00, /* 0000000 */
4105 0x00, /* 0000000 */
4106 0x00, /* 0000000 */
4107
4108};
4109
4110
4111struct font_desc font_7x14 = {
4112 FONT7x14_IDX,
4113 "7x14",
4114 7,
4115 14,
4116 fontdata_7x14,
4117 0
4118};
diff --git a/drivers/video/console/font_sun12x22.c b/drivers/video/console/font_sun12x22.c
index 05215d0c3e09..c7bd967ea100 100644
--- a/drivers/video/console/font_sun12x22.c
+++ b/drivers/video/console/font_sun12x22.c
@@ -29,24 +29,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
29 0x00, 0x00, /* 000000000000 */ 29 0x00, 0x00, /* 000000000000 */
30 30
31 /* 1 0x01 '^A' */ 31 /* 1 0x01 '^A' */
32 /* FIXME */
33 0x00, 0x00, /* 000000000000 */ 32 0x00, 0x00, /* 000000000000 */
34 0x00, 0x00, /* 000000000000 */ 33 0x00, 0x00, /* 000000000000 */
35 0x00, 0x00, /* 000000000000 */ 34 0x00, 0x00, /* 000000000000 */
36 0x00, 0x00, /* 000000000000 */ 35 0x00, 0x00, /* 000000000000 */
36 0x1f, 0xc0, /* 000111111100 */
37 0x30, 0x60, /* 001100000110 */
38 0x65, 0x30, /* 011001010011 */
39 0x6d, 0xb0, /* 011011011011 */
40 0x60, 0x30, /* 011000000011 */
41 0x62, 0x30, /* 011000100011 */
42 0x62, 0x30, /* 011000100011 */
43 0x60, 0x30, /* 011000000011 */
44 0x6f, 0xb0, /* 011011111011 */
45 0x67, 0x30, /* 011001110011 */
46 0x30, 0x60, /* 001100000110 */
47 0x1f, 0xc0, /* 000111111100 */
37 0x00, 0x00, /* 000000000000 */ 48 0x00, 0x00, /* 000000000000 */
38 0x3f, 0xc0, /* 001111111100 */
39 0x3f, 0xc0, /* 001111111100 */
40 0x3f, 0xc0, /* 001111111100 */
41 0x3f, 0xc0, /* 001111111100 */
42 0x3f, 0xc0, /* 001111111100 */
43 0x3f, 0xc0, /* 001111111100 */
44 0x3f, 0xc0, /* 001111111100 */
45 0x3f, 0xc0, /* 001111111100 */
46 0x3f, 0xc0, /* 001111111100 */
47 0x3f, 0xc0, /* 001111111100 */
48 0x3f, 0xc0, /* 001111111100 */
49 0x3f, 0xc0, /* 001111111100 */
50 0x00, 0x00, /* 000000000000 */ 49 0x00, 0x00, /* 000000000000 */
51 0x00, 0x00, /* 000000000000 */ 50 0x00, 0x00, /* 000000000000 */
52 0x00, 0x00, /* 000000000000 */ 51 0x00, 0x00, /* 000000000000 */
@@ -54,24 +53,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
54 0x00, 0x00, /* 000000000000 */ 53 0x00, 0x00, /* 000000000000 */
55 54
56 /* 2 0x02 '^B' */ 55 /* 2 0x02 '^B' */
57 /* FIXME */
58 0x00, 0x00, /* 000000000000 */ 56 0x00, 0x00, /* 000000000000 */
59 0x00, 0x00, /* 000000000000 */ 57 0x00, 0x00, /* 000000000000 */
60 0x00, 0x00, /* 000000000000 */ 58 0x00, 0x00, /* 000000000000 */
61 0x00, 0x00, /* 000000000000 */ 59 0x00, 0x00, /* 000000000000 */
60 0x1f, 0xc0, /* 000111111100 */
61 0x3f, 0xe0, /* 001111111110 */
62 0x7a, 0xf0, /* 011110101111 */
63 0x72, 0x70, /* 011100100111 */
64 0x7f, 0xf0, /* 011111111111 */
65 0x7d, 0xf0, /* 011111011111 */
66 0x7d, 0xf0, /* 011111011111 */
67 0x7f, 0xf0, /* 011111111111 */
68 0x70, 0x70, /* 011100000111 */
69 0x78, 0xf0, /* 011110001111 */
70 0x3f, 0xe0, /* 001111111110 */
71 0x1f, 0xc0, /* 000111111100 */
62 0x00, 0x00, /* 000000000000 */ 72 0x00, 0x00, /* 000000000000 */
63 0x3f, 0xc0, /* 001111111100 */
64 0x3f, 0xc0, /* 001111111100 */
65 0x3f, 0xc0, /* 001111111100 */
66 0x3f, 0xc0, /* 001111111100 */
67 0x3f, 0xc0, /* 001111111100 */
68 0x3f, 0xc0, /* 001111111100 */
69 0x3f, 0xc0, /* 001111111100 */
70 0x3f, 0xc0, /* 001111111100 */
71 0x3f, 0xc0, /* 001111111100 */
72 0x3f, 0xc0, /* 001111111100 */
73 0x3f, 0xc0, /* 001111111100 */
74 0x3f, 0xc0, /* 001111111100 */
75 0x00, 0x00, /* 000000000000 */ 73 0x00, 0x00, /* 000000000000 */
76 0x00, 0x00, /* 000000000000 */ 74 0x00, 0x00, /* 000000000000 */
77 0x00, 0x00, /* 000000000000 */ 75 0x00, 0x00, /* 000000000000 */
@@ -79,24 +77,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
79 0x00, 0x00, /* 000000000000 */ 77 0x00, 0x00, /* 000000000000 */
80 78
81 /* 3 0x03 '^C' */ 79 /* 3 0x03 '^C' */
82 /* FIXME */
83 0x00, 0x00, /* 000000000000 */ 80 0x00, 0x00, /* 000000000000 */
84 0x00, 0x00, /* 000000000000 */ 81 0x00, 0x00, /* 000000000000 */
85 0x00, 0x00, /* 000000000000 */ 82 0x00, 0x00, /* 000000000000 */
86 0x00, 0x00, /* 000000000000 */ 83 0x00, 0x00, /* 000000000000 */
87 0x00, 0x00, /* 000000000000 */ 84 0x00, 0x00, /* 000000000000 */
85 0x00, 0x00, /* 000000000000 */
86 0x19, 0x80, /* 000110011000 */
88 0x3f, 0xc0, /* 001111111100 */ 87 0x3f, 0xc0, /* 001111111100 */
88 0x7f, 0xe0, /* 011111111110 */
89 0x3f, 0xc0, /* 001111111100 */ 89 0x3f, 0xc0, /* 001111111100 */
90 0x3f, 0xc0, /* 001111111100 */ 90 0x3f, 0xc0, /* 001111111100 */
91 0x3f, 0xc0, /* 001111111100 */ 91 0x1f, 0x80, /* 000111111000 */
92 0x3f, 0xc0, /* 001111111100 */ 92 0x1f, 0x80, /* 000111111000 */
93 0x3f, 0xc0, /* 001111111100 */ 93 0x0f, 0x00, /* 000011110000 */
94 0x3f, 0xc0, /* 001111111100 */ 94 0x0f, 0x00, /* 000011110000 */
95 0x3f, 0xc0, /* 001111111100 */ 95 0x06, 0x00, /* 000001100000 */
96 0x3f, 0xc0, /* 001111111100 */ 96 0x00, 0x00, /* 000000000000 */
97 0x3f, 0xc0, /* 001111111100 */
98 0x3f, 0xc0, /* 001111111100 */
99 0x3f, 0xc0, /* 001111111100 */
100 0x00, 0x00, /* 000000000000 */ 97 0x00, 0x00, /* 000000000000 */
101 0x00, 0x00, /* 000000000000 */ 98 0x00, 0x00, /* 000000000000 */
102 0x00, 0x00, /* 000000000000 */ 99 0x00, 0x00, /* 000000000000 */
@@ -104,49 +101,47 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
104 0x00, 0x00, /* 000000000000 */ 101 0x00, 0x00, /* 000000000000 */
105 102
106 /* 4 0x04 '^D' */ 103 /* 4 0x04 '^D' */
107 /* FIXME */
108 0x00, 0x00, /* 000000000000 */ 104 0x00, 0x00, /* 000000000000 */
109 0x00, 0x00, /* 000000000000 */ 105 0x00, 0x00, /* 000000000000 */
110 0x00, 0x00, /* 000000000000 */ 106 0x00, 0x00, /* 000000000000 */
107 0x02, 0x00, /* 000000100000 */
108 0x07, 0x00, /* 000001110000 */
109 0x0f, 0x80, /* 000011111000 */
110 0x0f, 0x80, /* 000011111000 */
111 0x1f, 0xc0, /* 000111111100 */
112 0x1f, 0xc0, /* 000111111100 */
113 0x3f, 0xe0, /* 001111111110 */
114 0x1f, 0xc0, /* 000111111100 */
115 0x1f, 0xc0, /* 000111111100 */
116 0x0f, 0x80, /* 000011111000 */
117 0x0f, 0x80, /* 000011111000 */
118 0x07, 0x00, /* 000001110000 */
119 0x02, 0x00, /* 000000100000 */
111 0x00, 0x00, /* 000000000000 */ 120 0x00, 0x00, /* 000000000000 */
112 0x00, 0x00, /* 000000000000 */ 121 0x00, 0x00, /* 000000000000 */
113 0x3f, 0xc0, /* 001111111100 */
114 0x3f, 0xc0, /* 001111111100 */
115 0x3f, 0xc0, /* 001111111100 */
116 0x3f, 0xc0, /* 001111111100 */
117 0x3f, 0xc0, /* 001111111100 */
118 0x3f, 0xc0, /* 001111111100 */
119 0x3f, 0xc0, /* 001111111100 */
120 0x3f, 0xc0, /* 001111111100 */
121 0x3f, 0xc0, /* 001111111100 */
122 0x3f, 0xc0, /* 001111111100 */
123 0x3f, 0xc0, /* 001111111100 */
124 0x3f, 0xc0, /* 001111111100 */
125 0x00, 0x00, /* 000000000000 */
126 0x00, 0x00, /* 000000000000 */ 122 0x00, 0x00, /* 000000000000 */
127 0x00, 0x00, /* 000000000000 */ 123 0x00, 0x00, /* 000000000000 */
128 0x00, 0x00, /* 000000000000 */ 124 0x00, 0x00, /* 000000000000 */
129 0x00, 0x00, /* 000000000000 */ 125 0x00, 0x00, /* 000000000000 */
130 126
131 /* 5 0x05 '^E' */ 127 /* 5 0x05 '^E' */
132 /* FIXME */
133 0x00, 0x00, /* 000000000000 */ 128 0x00, 0x00, /* 000000000000 */
134 0x00, 0x00, /* 000000000000 */ 129 0x00, 0x00, /* 000000000000 */
135 0x00, 0x00, /* 000000000000 */ 130 0x00, 0x00, /* 000000000000 */
136 0x00, 0x00, /* 000000000000 */ 131 0x00, 0x00, /* 000000000000 */
132 0x02, 0x00, /* 000000100000 */
133 0x07, 0x00, /* 000001110000 */
134 0x07, 0x00, /* 000001110000 */
135 0x02, 0x00, /* 000000100000 */
136 0x18, 0xc0, /* 000110001100 */
137 0x3d, 0xe0, /* 001111011110 */
138 0x3d, 0xe0, /* 001111011110 */
139 0x1a, 0xc0, /* 000110101100 */
140 0x02, 0x00, /* 000000100000 */
141 0x07, 0x00, /* 000001110000 */
142 0x0f, 0x80, /* 000011111000 */
143 0x1f, 0xc0, /* 000111111100 */
137 0x00, 0x00, /* 000000000000 */ 144 0x00, 0x00, /* 000000000000 */
138 0x3f, 0xc0, /* 001111111100 */
139 0x3f, 0xc0, /* 001111111100 */
140 0x3f, 0xc0, /* 001111111100 */
141 0x3f, 0xc0, /* 001111111100 */
142 0x3f, 0xc0, /* 001111111100 */
143 0x3f, 0xc0, /* 001111111100 */
144 0x3f, 0xc0, /* 001111111100 */
145 0x3f, 0xc0, /* 001111111100 */
146 0x3f, 0xc0, /* 001111111100 */
147 0x3f, 0xc0, /* 001111111100 */
148 0x3f, 0xc0, /* 001111111100 */
149 0x3f, 0xc0, /* 001111111100 */
150 0x00, 0x00, /* 000000000000 */ 145 0x00, 0x00, /* 000000000000 */
151 0x00, 0x00, /* 000000000000 */ 146 0x00, 0x00, /* 000000000000 */
152 0x00, 0x00, /* 000000000000 */ 147 0x00, 0x00, /* 000000000000 */
@@ -154,23 +149,22 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
154 0x00, 0x00, /* 000000000000 */ 149 0x00, 0x00, /* 000000000000 */
155 150
156 /* 6 0x06 '^F' */ 151 /* 6 0x06 '^F' */
157 /* FIXME */
158 0x00, 0x00, /* 000000000000 */
159 0x00, 0x00, /* 000000000000 */ 152 0x00, 0x00, /* 000000000000 */
160 0x00, 0x00, /* 000000000000 */ 153 0x00, 0x00, /* 000000000000 */
161 0x00, 0x00, /* 000000000000 */ 154 0x00, 0x00, /* 000000000000 */
162 0x00, 0x00, /* 000000000000 */ 155 0x00, 0x00, /* 000000000000 */
156 0x06, 0x00, /* 000001100000 */
157 0x0f, 0x00, /* 000011110000 */
158 0x1f, 0x80, /* 000111111000 */
159 0x1f, 0x80, /* 000111111000 */
163 0x3f, 0xc0, /* 001111111100 */ 160 0x3f, 0xc0, /* 001111111100 */
164 0x3f, 0xc0, /* 001111111100 */ 161 0x7f, 0xe0, /* 011111111110 */
165 0x3f, 0xc0, /* 001111111100 */ 162 0x7f, 0xe0, /* 011111111110 */
166 0x3f, 0xc0, /* 001111111100 */ 163 0x36, 0xc0, /* 001101101100 */
167 0x3f, 0xc0, /* 001111111100 */ 164 0x06, 0x00, /* 000001100000 */
168 0x3f, 0xc0, /* 001111111100 */ 165 0x06, 0x00, /* 000001100000 */
169 0x3f, 0xc0, /* 001111111100 */ 166 0x0f, 0x00, /* 000011110000 */
170 0x3f, 0xc0, /* 001111111100 */ 167 0x1f, 0x80, /* 000111111000 */
171 0x3f, 0xc0, /* 001111111100 */
172 0x3f, 0xc0, /* 001111111100 */
173 0x3f, 0xc0, /* 001111111100 */
174 0x3f, 0xc0, /* 001111111100 */ 168 0x3f, 0xc0, /* 001111111100 */
175 0x00, 0x00, /* 000000000000 */ 169 0x00, 0x00, /* 000000000000 */
176 0x00, 0x00, /* 000000000000 */ 170 0x00, 0x00, /* 000000000000 */
@@ -179,24 +173,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
179 0x00, 0x00, /* 000000000000 */ 173 0x00, 0x00, /* 000000000000 */
180 174
181 /* 7 0x07 '^G' */ 175 /* 7 0x07 '^G' */
182 /* FIXME */
183 0x00, 0x00, /* 000000000000 */
184 0x00, 0x00, /* 000000000000 */ 176 0x00, 0x00, /* 000000000000 */
185 0x00, 0x00, /* 000000000000 */ 177 0x00, 0x00, /* 000000000000 */
186 0x00, 0x00, /* 000000000000 */ 178 0x00, 0x00, /* 000000000000 */
187 0x00, 0x00, /* 000000000000 */ 179 0x00, 0x00, /* 000000000000 */
180 0x06, 0x00, /* 000001100000 */
181 0x0f, 0x00, /* 000011110000 */
182 0x0f, 0x00, /* 000011110000 */
183 0x1f, 0x80, /* 000111111000 */
184 0x1f, 0x80, /* 000111111000 */
188 0x3f, 0xc0, /* 001111111100 */ 185 0x3f, 0xc0, /* 001111111100 */
189 0x3f, 0xc0, /* 001111111100 */ 186 0x3f, 0xc0, /* 001111111100 */
190 0x3f, 0xc0, /* 001111111100 */ 187 0x1f, 0x80, /* 000111111000 */
191 0x3f, 0xc0, /* 001111111100 */ 188 0x1f, 0x80, /* 000111111000 */
192 0x3f, 0xc0, /* 001111111100 */ 189 0x0f, 0x00, /* 000011110000 */
193 0x3f, 0xc0, /* 001111111100 */ 190 0x0f, 0x00, /* 000011110000 */
194 0x3f, 0xc0, /* 001111111100 */ 191 0x06, 0x00, /* 000001100000 */
195 0x3f, 0xc0, /* 001111111100 */ 192 0x00, 0x00, /* 000000000000 */
196 0x3f, 0xc0, /* 001111111100 */
197 0x3f, 0xc0, /* 001111111100 */
198 0x3f, 0xc0, /* 001111111100 */
199 0x3f, 0xc0, /* 001111111100 */
200 0x00, 0x00, /* 000000000000 */ 193 0x00, 0x00, /* 000000000000 */
201 0x00, 0x00, /* 000000000000 */ 194 0x00, 0x00, /* 000000000000 */
202 0x00, 0x00, /* 000000000000 */ 195 0x00, 0x00, /* 000000000000 */
@@ -204,49 +197,47 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
204 0x00, 0x00, /* 000000000000 */ 197 0x00, 0x00, /* 000000000000 */
205 198
206 /* 8 0x08 '^H' */ 199 /* 8 0x08 '^H' */
207 /* FIXME */ 200 0xff, 0xf0, /* 111111111111 */
208 0x00, 0x00, /* 000000000000 */ 201 0xff, 0xf0, /* 111111111111 */
209 0x00, 0x00, /* 000000000000 */ 202 0xff, 0xf0, /* 111111111111 */
210 0x00, 0x00, /* 000000000000 */ 203 0xff, 0xf0, /* 111111111111 */
211 0x00, 0x00, /* 000000000000 */ 204 0xf9, 0xf0, /* 111110011111 */
212 0x00, 0x00, /* 000000000000 */ 205 0xf0, 0xf0, /* 111100001111 */
213 0x3f, 0xc0, /* 001111111100 */ 206 0xf0, 0xf0, /* 111100001111 */
214 0x3f, 0xc0, /* 001111111100 */ 207 0xe0, 0x70, /* 111000000111 */
215 0x3f, 0xc0, /* 001111111100 */ 208 0xe0, 0x70, /* 111000000111 */
216 0x3f, 0xc0, /* 001111111100 */ 209 0xc0, 0x30, /* 110000000011 */
217 0x3f, 0xc0, /* 001111111100 */ 210 0xc0, 0x30, /* 110000000011 */
218 0x3f, 0xc0, /* 001111111100 */ 211 0xe0, 0x70, /* 111000000111 */
219 0x3f, 0xc0, /* 001111111100 */ 212 0xe0, 0x70, /* 111000000111 */
220 0x3f, 0xc0, /* 001111111100 */ 213 0xf0, 0xf0, /* 111100001111 */
221 0x3f, 0xc0, /* 001111111100 */ 214 0xf0, 0xf0, /* 111100001111 */
222 0x3f, 0xc0, /* 001111111100 */ 215 0xf9, 0xf0, /* 111110011111 */
223 0x3f, 0xc0, /* 001111111100 */ 216 0xff, 0xf0, /* 111111111111 */
224 0x3f, 0xc0, /* 001111111100 */ 217 0xff, 0xf0, /* 111111111111 */
225 0x00, 0x00, /* 000000000000 */ 218 0xff, 0xf0, /* 111111111111 */
226 0x00, 0x00, /* 000000000000 */ 219 0xff, 0xf0, /* 111111111111 */
227 0x00, 0x00, /* 000000000000 */ 220 0xff, 0xf0, /* 111111111111 */
228 0x00, 0x00, /* 000000000000 */ 221 0xff, 0xf0, /* 111111111111 */
229 0x00, 0x00, /* 000000000000 */
230 222
231 /* 9 0x09 '^I' */ 223 /* 9 0x09 '^I' */
232 /* FIXME */
233 0x00, 0x00, /* 000000000000 */ 224 0x00, 0x00, /* 000000000000 */
234 0x00, 0x00, /* 000000000000 */ 225 0x00, 0x00, /* 000000000000 */
235 0x00, 0x00, /* 000000000000 */ 226 0x00, 0x00, /* 000000000000 */
236 0x00, 0x00, /* 000000000000 */ 227 0x00, 0x00, /* 000000000000 */
228 0x06, 0x00, /* 000001100000 */
229 0x0f, 0x00, /* 000011110000 */
230 0x0f, 0x00, /* 000011110000 */
231 0x19, 0x80, /* 000110011000 */
232 0x19, 0x80, /* 000110011000 */
233 0x30, 0xc0, /* 001100001100 */
234 0x30, 0xc0, /* 001100001100 */
235 0x19, 0x80, /* 000110011000 */
236 0x19, 0x80, /* 000110011000 */
237 0x0f, 0x00, /* 000011110000 */
238 0x0f, 0x00, /* 000011110000 */
239 0x06, 0x00, /* 000001100000 */
237 0x00, 0x00, /* 000000000000 */ 240 0x00, 0x00, /* 000000000000 */
238 0x3f, 0xc0, /* 001111111100 */
239 0x3f, 0xc0, /* 001111111100 */
240 0x3f, 0xc0, /* 001111111100 */
241 0x3f, 0xc0, /* 001111111100 */
242 0x3f, 0xc0, /* 001111111100 */
243 0x3f, 0xc0, /* 001111111100 */
244 0x3f, 0xc0, /* 001111111100 */
245 0x3f, 0xc0, /* 001111111100 */
246 0x3f, 0xc0, /* 001111111100 */
247 0x3f, 0xc0, /* 001111111100 */
248 0x3f, 0xc0, /* 001111111100 */
249 0x3f, 0xc0, /* 001111111100 */
250 0x00, 0x00, /* 000000000000 */ 241 0x00, 0x00, /* 000000000000 */
251 0x00, 0x00, /* 000000000000 */ 242 0x00, 0x00, /* 000000000000 */
252 0x00, 0x00, /* 000000000000 */ 243 0x00, 0x00, /* 000000000000 */
@@ -254,49 +245,47 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
254 0x00, 0x00, /* 000000000000 */ 245 0x00, 0x00, /* 000000000000 */
255 246
256 /* 10 0x0a '^J' */ 247 /* 10 0x0a '^J' */
257 /* FIXME */ 248 0xff, 0xf0, /* 111111111111 */
258 0x00, 0x00, /* 000000000000 */ 249 0xff, 0xf0, /* 111111111111 */
259 0x00, 0x00, /* 000000000000 */ 250 0xff, 0xf0, /* 111111111111 */
260 0x00, 0x00, /* 000000000000 */ 251 0xff, 0xf0, /* 111111111111 */
261 0x00, 0x00, /* 000000000000 */ 252 0xf9, 0xf0, /* 111110011111 */
262 0x00, 0x00, /* 000000000000 */ 253 0xf0, 0xf0, /* 111100001111 */
263 0x3f, 0xc0, /* 001111111100 */ 254 0xf0, 0xf0, /* 111100001111 */
264 0x3f, 0xc0, /* 001111111100 */ 255 0xe6, 0x70, /* 111001100111 */
265 0x3f, 0xc0, /* 001111111100 */ 256 0xe6, 0x70, /* 111001100111 */
266 0x3f, 0xc0, /* 001111111100 */ 257 0xcf, 0x30, /* 110011110011 */
267 0x3f, 0xc0, /* 001111111100 */ 258 0xcf, 0x30, /* 110011110011 */
268 0x3f, 0xc0, /* 001111111100 */ 259 0xe6, 0x70, /* 111001100111 */
269 0x3f, 0xc0, /* 001111111100 */ 260 0xe6, 0x70, /* 111001100111 */
270 0x3f, 0xc0, /* 001111111100 */ 261 0xf0, 0xf0, /* 111100001111 */
271 0x3f, 0xc0, /* 001111111100 */ 262 0xf0, 0xf0, /* 111100001111 */
272 0x3f, 0xc0, /* 001111111100 */ 263 0xf9, 0xf0, /* 111110011111 */
273 0x3f, 0xc0, /* 001111111100 */ 264 0xff, 0xf0, /* 111111111111 */
274 0x3f, 0xc0, /* 001111111100 */ 265 0xff, 0xf0, /* 111111111111 */
275 0x00, 0x00, /* 000000000000 */ 266 0xff, 0xf0, /* 111111111111 */
276 0x00, 0x00, /* 000000000000 */ 267 0xff, 0xf0, /* 111111111111 */
277 0x00, 0x00, /* 000000000000 */ 268 0xff, 0xf0, /* 111111111111 */
278 0x00, 0x00, /* 000000000000 */ 269 0xff, 0xf0, /* 111111111111 */
279 0x00, 0x00, /* 000000000000 */
280 270
281 /* 11 0x0b '^K' */ 271 /* 11 0x0b '^K' */
282 /* FIXME */
283 0x00, 0x00, /* 000000000000 */
284 0x00, 0x00, /* 000000000000 */
285 0x00, 0x00, /* 000000000000 */ 272 0x00, 0x00, /* 000000000000 */
286 0x00, 0x00, /* 000000000000 */ 273 0x00, 0x00, /* 000000000000 */
274 0x0f, 0xe0, /* 000011111110 */
275 0x0f, 0xe0, /* 000011111110 */
276 0x01, 0xe0, /* 000000011110 */
277 0x03, 0x60, /* 000000110110 */
278 0x06, 0x60, /* 000001100110 */
279 0x1e, 0x00, /* 000111100000 */
280 0x33, 0x00, /* 001100110000 */
281 0x33, 0x00, /* 001100110000 */
282 0x61, 0x80, /* 011000011000 */
283 0x61, 0x80, /* 011000011000 */
284 0x33, 0x00, /* 001100110000 */
285 0x33, 0x00, /* 001100110000 */
286 0x1e, 0x00, /* 000111100000 */
287 0x0c, 0x00, /* 000011000000 */
287 0x00, 0x00, /* 000000000000 */ 288 0x00, 0x00, /* 000000000000 */
288 0x3f, 0xc0, /* 001111111100 */
289 0x3f, 0xc0, /* 001111111100 */
290 0x3f, 0xc0, /* 001111111100 */
291 0x3f, 0xc0, /* 001111111100 */
292 0x3f, 0xc0, /* 001111111100 */
293 0x3f, 0xc0, /* 001111111100 */
294 0x3f, 0xc0, /* 001111111100 */
295 0x3f, 0xc0, /* 001111111100 */
296 0x3f, 0xc0, /* 001111111100 */
297 0x3f, 0xc0, /* 001111111100 */
298 0x3f, 0xc0, /* 001111111100 */
299 0x3f, 0xc0, /* 001111111100 */
300 0x00, 0x00, /* 000000000000 */ 289 0x00, 0x00, /* 000000000000 */
301 0x00, 0x00, /* 000000000000 */ 290 0x00, 0x00, /* 000000000000 */
302 0x00, 0x00, /* 000000000000 */ 291 0x00, 0x00, /* 000000000000 */
@@ -304,24 +293,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
304 0x00, 0x00, /* 000000000000 */ 293 0x00, 0x00, /* 000000000000 */
305 294
306 /* 12 0x0c '^L' */ 295 /* 12 0x0c '^L' */
307 /* FIXME */
308 0x00, 0x00, /* 000000000000 */
309 0x00, 0x00, /* 000000000000 */
310 0x00, 0x00, /* 000000000000 */
311 0x00, 0x00, /* 000000000000 */ 296 0x00, 0x00, /* 000000000000 */
312 0x00, 0x00, /* 000000000000 */ 297 0x00, 0x00, /* 000000000000 */
298 0x06, 0x00, /* 000001100000 */
299 0x0f, 0x00, /* 000011110000 */
300 0x19, 0x80, /* 000110011000 */
301 0x30, 0xc0, /* 001100001100 */
302 0x30, 0xc0, /* 001100001100 */
303 0x19, 0x80, /* 000110011000 */
304 0x0f, 0x00, /* 000011110000 */
305 0x06, 0x00, /* 000001100000 */
306 0x06, 0x00, /* 000001100000 */
307 0x06, 0x00, /* 000001100000 */
313 0x3f, 0xc0, /* 001111111100 */ 308 0x3f, 0xc0, /* 001111111100 */
314 0x3f, 0xc0, /* 001111111100 */ 309 0x3f, 0xc0, /* 001111111100 */
315 0x3f, 0xc0, /* 001111111100 */ 310 0x06, 0x00, /* 000001100000 */
316 0x3f, 0xc0, /* 001111111100 */ 311 0x06, 0x00, /* 000001100000 */
317 0x3f, 0xc0, /* 001111111100 */ 312 0x00, 0x00, /* 000000000000 */
318 0x3f, 0xc0, /* 001111111100 */
319 0x3f, 0xc0, /* 001111111100 */
320 0x3f, 0xc0, /* 001111111100 */
321 0x3f, 0xc0, /* 001111111100 */
322 0x3f, 0xc0, /* 001111111100 */
323 0x3f, 0xc0, /* 001111111100 */
324 0x3f, 0xc0, /* 001111111100 */
325 0x00, 0x00, /* 000000000000 */ 313 0x00, 0x00, /* 000000000000 */
326 0x00, 0x00, /* 000000000000 */ 314 0x00, 0x00, /* 000000000000 */
327 0x00, 0x00, /* 000000000000 */ 315 0x00, 0x00, /* 000000000000 */
@@ -329,149 +317,143 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
329 0x00, 0x00, /* 000000000000 */ 317 0x00, 0x00, /* 000000000000 */
330 318
331 /* 13 0x0d '^M' */ 319 /* 13 0x0d '^M' */
332 /* FIXME */
333 0x00, 0x00, /* 000000000000 */
334 0x00, 0x00, /* 000000000000 */
335 0x00, 0x00, /* 000000000000 */
336 0x00, 0x00, /* 000000000000 */
337 0x00, 0x00, /* 000000000000 */
338 0x3f, 0xc0, /* 001111111100 */
339 0x3f, 0xc0, /* 001111111100 */
340 0x3f, 0xc0, /* 001111111100 */
341 0x3f, 0xc0, /* 001111111100 */
342 0x3f, 0xc0, /* 001111111100 */
343 0x3f, 0xc0, /* 001111111100 */
344 0x3f, 0xc0, /* 001111111100 */
345 0x3f, 0xc0, /* 001111111100 */
346 0x3f, 0xc0, /* 001111111100 */
347 0x3f, 0xc0, /* 001111111100 */
348 0x3f, 0xc0, /* 001111111100 */
349 0x3f, 0xc0, /* 001111111100 */
350 0x00, 0x00, /* 000000000000 */ 320 0x00, 0x00, /* 000000000000 */
351 0x00, 0x00, /* 000000000000 */ 321 0x00, 0x00, /* 000000000000 */
322 0x0f, 0xe0, /* 000011111110 */
323 0x0c, 0x60, /* 000011000110 */
324 0x0c, 0x60, /* 000011000110 */
325 0x0f, 0xe0, /* 000011111110 */
326 0x0c, 0x00, /* 000011000000 */
327 0x0c, 0x00, /* 000011000000 */
328 0x0c, 0x00, /* 000011000000 */
329 0x0c, 0x00, /* 000011000000 */
330 0x0c, 0x00, /* 000011000000 */
331 0x0c, 0x00, /* 000011000000 */
332 0x0c, 0x00, /* 000011000000 */
333 0x0c, 0x00, /* 000011000000 */
334 0x0c, 0x00, /* 000011000000 */
335 0x3c, 0x00, /* 001111000000 */
336 0x7c, 0x00, /* 011111000000 */
337 0x78, 0x00, /* 011110000000 */
338 0x30, 0x00, /* 001100000000 */
352 0x00, 0x00, /* 000000000000 */ 339 0x00, 0x00, /* 000000000000 */
353 0x00, 0x00, /* 000000000000 */ 340 0x00, 0x00, /* 000000000000 */
354 0x00, 0x00, /* 000000000000 */ 341 0x00, 0x00, /* 000000000000 */
355 342
356 /* 14 0x0e '^N' */ 343 /* 14 0x0e '^N' */
357 /* FIXME */
358 0x00, 0x00, /* 000000000000 */
359 0x00, 0x00, /* 000000000000 */
360 0x00, 0x00, /* 000000000000 */
361 0x00, 0x00, /* 000000000000 */
362 0x00, 0x00, /* 000000000000 */
363 0x3f, 0xc0, /* 001111111100 */
364 0x3f, 0xc0, /* 001111111100 */
365 0x3f, 0xc0, /* 001111111100 */
366 0x3f, 0xc0, /* 001111111100 */
367 0x3f, 0xc0, /* 001111111100 */
368 0x3f, 0xc0, /* 001111111100 */
369 0x3f, 0xc0, /* 001111111100 */
370 0x3f, 0xc0, /* 001111111100 */
371 0x3f, 0xc0, /* 001111111100 */
372 0x3f, 0xc0, /* 001111111100 */
373 0x3f, 0xc0, /* 001111111100 */
374 0x3f, 0xc0, /* 001111111100 */
375 0x00, 0x00, /* 000000000000 */ 344 0x00, 0x00, /* 000000000000 */
376 0x00, 0x00, /* 000000000000 */ 345 0x00, 0x00, /* 000000000000 */
346 0x1f, 0xe0, /* 000111111110 */
347 0x18, 0x60, /* 000110000110 */
348 0x18, 0x60, /* 000110000110 */
349 0x1f, 0xe0, /* 000111111110 */
350 0x18, 0x60, /* 000110000110 */
351 0x18, 0x60, /* 000110000110 */
352 0x18, 0x60, /* 000110000110 */
353 0x18, 0x60, /* 000110000110 */
354 0x18, 0x60, /* 000110000110 */
355 0x18, 0x60, /* 000110000110 */
356 0x19, 0xe0, /* 000110011110 */
357 0x1b, 0xe0, /* 000110111110 */
358 0x1b, 0xc0, /* 000110111100 */
359 0x79, 0x80, /* 011110011000 */
360 0xf8, 0x00, /* 111110000000 */
361 0xf0, 0x00, /* 111100000000 */
362 0x60, 0x00, /* 011000000000 */
377 0x00, 0x00, /* 000000000000 */ 363 0x00, 0x00, /* 000000000000 */
378 0x00, 0x00, /* 000000000000 */ 364 0x00, 0x00, /* 000000000000 */
379 0x00, 0x00, /* 000000000000 */ 365 0x00, 0x00, /* 000000000000 */
380 366
381 /* 15 0x0f '^O' */ 367 /* 15 0x0f '^O' */
382 /* FIXME */
383 0x00, 0x00, /* 000000000000 */
384 0x00, 0x00, /* 000000000000 */ 368 0x00, 0x00, /* 000000000000 */
385 0x00, 0x00, /* 000000000000 */ 369 0x00, 0x00, /* 000000000000 */
386 0x00, 0x00, /* 000000000000 */ 370 0x00, 0x00, /* 000000000000 */
387 0x00, 0x00, /* 000000000000 */ 371 0x00, 0x00, /* 000000000000 */
388 0x3f, 0xc0, /* 001111111100 */
389 0x3f, 0xc0, /* 001111111100 */
390 0x3f, 0xc0, /* 001111111100 */
391 0x3f, 0xc0, /* 001111111100 */
392 0x3f, 0xc0, /* 001111111100 */
393 0x3f, 0xc0, /* 001111111100 */
394 0x3f, 0xc0, /* 001111111100 */
395 0x3f, 0xc0, /* 001111111100 */
396 0x3f, 0xc0, /* 001111111100 */
397 0x3f, 0xc0, /* 001111111100 */
398 0x3f, 0xc0, /* 001111111100 */
399 0x3f, 0xc0, /* 001111111100 */
400 0x00, 0x00, /* 000000000000 */
401 0x00, 0x00, /* 000000000000 */
402 0x00, 0x00, /* 000000000000 */ 372 0x00, 0x00, /* 000000000000 */
403 0x00, 0x00, /* 000000000000 */ 373 0x00, 0x00, /* 000000000000 */
404 0x00, 0x00, /* 000000000000 */ 374 0x00, 0x00, /* 000000000000 */
405 375 0x18, 0xc0, /* 000110001100 */
406 /* 16 0x10 '^P' */ 376 0x0d, 0x80, /* 000011011000 */
407 /* FIXME */ 377 0x6d, 0xb0, /* 011011011011 */
378 0x3d, 0xe0, /* 001111011110 */
408 0x00, 0x00, /* 000000000000 */ 379 0x00, 0x00, /* 000000000000 */
380 0x3d, 0xe0, /* 001111011110 */
381 0x6d, 0xb0, /* 011011011011 */
382 0x0d, 0x80, /* 000011011000 */
383 0x18, 0xc0, /* 000110001100 */
409 0x00, 0x00, /* 000000000000 */ 384 0x00, 0x00, /* 000000000000 */
410 0x00, 0x00, /* 000000000000 */ 385 0x00, 0x00, /* 000000000000 */
411 0x00, 0x00, /* 000000000000 */ 386 0x00, 0x00, /* 000000000000 */
412 0x00, 0x00, /* 000000000000 */ 387 0x00, 0x00, /* 000000000000 */
413 0x3f, 0xc0, /* 001111111100 */
414 0x3f, 0xc0, /* 001111111100 */
415 0x3f, 0xc0, /* 001111111100 */
416 0x3f, 0xc0, /* 001111111100 */
417 0x3f, 0xc0, /* 001111111100 */
418 0x3f, 0xc0, /* 001111111100 */
419 0x3f, 0xc0, /* 001111111100 */
420 0x3f, 0xc0, /* 001111111100 */
421 0x3f, 0xc0, /* 001111111100 */
422 0x3f, 0xc0, /* 001111111100 */
423 0x3f, 0xc0, /* 001111111100 */
424 0x3f, 0xc0, /* 001111111100 */
425 0x00, 0x00, /* 000000000000 */ 388 0x00, 0x00, /* 000000000000 */
426 0x00, 0x00, /* 000000000000 */ 389 0x00, 0x00, /* 000000000000 */
390
391 /* 16 0x10 '^P' */
427 0x00, 0x00, /* 000000000000 */ 392 0x00, 0x00, /* 000000000000 */
393 0x00, 0x20, /* 000000000010 */
394 0x00, 0x60, /* 000000000110 */
395 0x00, 0xe0, /* 000000001110 */
396 0x01, 0xe0, /* 000000011110 */
397 0x03, 0xe0, /* 000000111110 */
398 0x07, 0xe0, /* 000001111110 */
399 0x0f, 0xe0, /* 000011111110 */
400 0x1f, 0xe0, /* 000111111110 */
401 0x3f, 0xe0, /* 001111111110 */
402 0x7f, 0xe0, /* 011111111110 */
403 0x3f, 0xe0, /* 001111111110 */
404 0x1f, 0xe0, /* 000111111110 */
405 0x0f, 0xe0, /* 000011111110 */
406 0x07, 0xe0, /* 000001111110 */
407 0x03, 0xe0, /* 000000111110 */
408 0x01, 0xe0, /* 000000011110 */
409 0x00, 0xe0, /* 000000001110 */
410 0x00, 0x60, /* 000000000110 */
411 0x00, 0x20, /* 000000000010 */
428 0x00, 0x00, /* 000000000000 */ 412 0x00, 0x00, /* 000000000000 */
429 0x00, 0x00, /* 000000000000 */ 413 0x00, 0x00, /* 000000000000 */
430 414
431 /* 17 0x11 '^Q' */ 415 /* 17 0x11 '^Q' */
432 /* FIXME */
433 0x00, 0x00, /* 000000000000 */
434 0x00, 0x00, /* 000000000000 */
435 0x00, 0x00, /* 000000000000 */
436 0x00, 0x00, /* 000000000000 */
437 0x00, 0x00, /* 000000000000 */
438 0x3f, 0xc0, /* 001111111100 */
439 0x3f, 0xc0, /* 001111111100 */
440 0x3f, 0xc0, /* 001111111100 */
441 0x3f, 0xc0, /* 001111111100 */
442 0x3f, 0xc0, /* 001111111100 */
443 0x3f, 0xc0, /* 001111111100 */
444 0x3f, 0xc0, /* 001111111100 */
445 0x3f, 0xc0, /* 001111111100 */
446 0x3f, 0xc0, /* 001111111100 */
447 0x3f, 0xc0, /* 001111111100 */
448 0x3f, 0xc0, /* 001111111100 */
449 0x3f, 0xc0, /* 001111111100 */
450 0x00, 0x00, /* 000000000000 */
451 0x00, 0x00, /* 000000000000 */
452 0x00, 0x00, /* 000000000000 */ 416 0x00, 0x00, /* 000000000000 */
417 0x40, 0x00, /* 010000000000 */
418 0x60, 0x00, /* 011000000000 */
419 0x70, 0x00, /* 011100000000 */
420 0x78, 0x00, /* 011110000000 */
421 0x7c, 0x00, /* 011111000000 */
422 0x7e, 0x00, /* 011111100000 */
423 0x7f, 0x00, /* 011111110000 */
424 0x7f, 0x80, /* 011111111000 */
425 0x7f, 0xc0, /* 011111111100 */
426 0x7f, 0xe0, /* 011111111110 */
427 0x7f, 0xc0, /* 011111111100 */
428 0x7f, 0x80, /* 011111111000 */
429 0x7f, 0x00, /* 011111110000 */
430 0x7e, 0x00, /* 011111100000 */
431 0x7c, 0x00, /* 011111000000 */
432 0x78, 0x00, /* 011110000000 */
433 0x70, 0x00, /* 011100000000 */
434 0x60, 0x00, /* 011000000000 */
435 0x40, 0x00, /* 010000000000 */
453 0x00, 0x00, /* 000000000000 */ 436 0x00, 0x00, /* 000000000000 */
454 0x00, 0x00, /* 000000000000 */ 437 0x00, 0x00, /* 000000000000 */
455 438
456 /* 18 0x12 '^R' */ 439 /* 18 0x12 '^R' */
457 /* FIXME */
458 0x00, 0x00, /* 000000000000 */ 440 0x00, 0x00, /* 000000000000 */
459 0x00, 0x00, /* 000000000000 */ 441 0x00, 0x00, /* 000000000000 */
460 0x00, 0x00, /* 000000000000 */ 442 0x00, 0x00, /* 000000000000 */
461 0x00, 0x00, /* 000000000000 */ 443 0x00, 0x00, /* 000000000000 */
444 0x04, 0x00, /* 000001000000 */
445 0x0e, 0x00, /* 000011100000 */
446 0x1f, 0x00, /* 000111110000 */
447 0x3f, 0x80, /* 001111111000 */
448 0x7f, 0xc0, /* 011111111100 */
449 0x0e, 0x00, /* 000011100000 */
450 0x0e, 0x00, /* 000011100000 */
451 0x7f, 0xc0, /* 011111111100 */
452 0x3f, 0x80, /* 001111111000 */
453 0x1f, 0x00, /* 000111110000 */
454 0x0e, 0x00, /* 000011100000 */
455 0x04, 0x00, /* 000001000000 */
462 0x00, 0x00, /* 000000000000 */ 456 0x00, 0x00, /* 000000000000 */
463 0x3f, 0xc0, /* 001111111100 */
464 0x3f, 0xc0, /* 001111111100 */
465 0x3f, 0xc0, /* 001111111100 */
466 0x3f, 0xc0, /* 001111111100 */
467 0x3f, 0xc0, /* 001111111100 */
468 0x3f, 0xc0, /* 001111111100 */
469 0x3f, 0xc0, /* 001111111100 */
470 0x3f, 0xc0, /* 001111111100 */
471 0x3f, 0xc0, /* 001111111100 */
472 0x3f, 0xc0, /* 001111111100 */
473 0x3f, 0xc0, /* 001111111100 */
474 0x3f, 0xc0, /* 001111111100 */
475 0x00, 0x00, /* 000000000000 */ 457 0x00, 0x00, /* 000000000000 */
476 0x00, 0x00, /* 000000000000 */ 458 0x00, 0x00, /* 000000000000 */
477 0x00, 0x00, /* 000000000000 */ 459 0x00, 0x00, /* 000000000000 */
@@ -551,99 +533,95 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
551 0x00, 0x00, /* 000000000000 */ 533 0x00, 0x00, /* 000000000000 */
552 534
553 /* 22 0x16 '^V' */ 535 /* 22 0x16 '^V' */
554 /* FIXME */
555 0x00, 0x00, /* 000000000000 */ 536 0x00, 0x00, /* 000000000000 */
556 0x00, 0x00, /* 000000000000 */ 537 0x00, 0x00, /* 000000000000 */
557 0x00, 0x00, /* 000000000000 */ 538 0x00, 0x00, /* 000000000000 */
558 0x00, 0x00, /* 000000000000 */ 539 0x00, 0x00, /* 000000000000 */
559 0x00, 0x00, /* 000000000000 */ 540 0x00, 0x00, /* 000000000000 */
560 0x3f, 0xc0, /* 001111111100 */
561 0x3f, 0xc0, /* 001111111100 */
562 0x3f, 0xc0, /* 001111111100 */
563 0x3f, 0xc0, /* 001111111100 */
564 0x3f, 0xc0, /* 001111111100 */
565 0x3f, 0xc0, /* 001111111100 */
566 0x3f, 0xc0, /* 001111111100 */
567 0x3f, 0xc0, /* 001111111100 */
568 0x3f, 0xc0, /* 001111111100 */
569 0x3f, 0xc0, /* 001111111100 */
570 0x3f, 0xc0, /* 001111111100 */
571 0x3f, 0xc0, /* 001111111100 */
572 0x00, 0x00, /* 000000000000 */
573 0x00, 0x00, /* 000000000000 */ 541 0x00, 0x00, /* 000000000000 */
574 0x00, 0x00, /* 000000000000 */ 542 0x00, 0x00, /* 000000000000 */
575 0x00, 0x00, /* 000000000000 */ 543 0x00, 0x00, /* 000000000000 */
576 0x00, 0x00, /* 000000000000 */ 544 0x00, 0x00, /* 000000000000 */
577
578 /* 23 0x17 '^W' */
579 /* FIXME */
580 0x00, 0x00, /* 000000000000 */ 545 0x00, 0x00, /* 000000000000 */
581 0x00, 0x00, /* 000000000000 */ 546 0x00, 0x00, /* 000000000000 */
582 0x00, 0x00, /* 000000000000 */ 547 0x00, 0x00, /* 000000000000 */
583 0x00, 0x00, /* 000000000000 */ 548 0x00, 0x00, /* 000000000000 */
549 0x7f, 0xe0, /* 011111111110 */
550 0x7f, 0xe0, /* 011111111110 */
551 0x7f, 0xe0, /* 011111111110 */
584 0x00, 0x00, /* 000000000000 */ 552 0x00, 0x00, /* 000000000000 */
585 0x3f, 0xc0, /* 001111111100 */
586 0x3f, 0xc0, /* 001111111100 */
587 0x3f, 0xc0, /* 001111111100 */
588 0x3f, 0xc0, /* 001111111100 */
589 0x3f, 0xc0, /* 001111111100 */
590 0x3f, 0xc0, /* 001111111100 */
591 0x3f, 0xc0, /* 001111111100 */
592 0x3f, 0xc0, /* 001111111100 */
593 0x3f, 0xc0, /* 001111111100 */
594 0x3f, 0xc0, /* 001111111100 */
595 0x3f, 0xc0, /* 001111111100 */
596 0x3f, 0xc0, /* 001111111100 */
597 0x00, 0x00, /* 000000000000 */ 553 0x00, 0x00, /* 000000000000 */
598 0x00, 0x00, /* 000000000000 */ 554 0x00, 0x00, /* 000000000000 */
599 0x00, 0x00, /* 000000000000 */ 555 0x00, 0x00, /* 000000000000 */
600 0x00, 0x00, /* 000000000000 */ 556 0x00, 0x00, /* 000000000000 */
601 0x00, 0x00, /* 000000000000 */ 557 0x00, 0x00, /* 000000000000 */
602 558
603 /* 24 0x18 '^X' */ 559 /* 23 0x17 '^W' */
604 /* FIXME */
605 0x00, 0x00, /* 000000000000 */ 560 0x00, 0x00, /* 000000000000 */
606 0x00, 0x00, /* 000000000000 */ 561 0x00, 0x00, /* 000000000000 */
562 0x04, 0x00, /* 000001000000 */
563 0x0e, 0x00, /* 000011100000 */
564 0x1f, 0x00, /* 000111110000 */
565 0x3f, 0x80, /* 001111111000 */
566 0x7f, 0xc0, /* 011111111100 */
567 0x0e, 0x00, /* 000011100000 */
568 0x0e, 0x00, /* 000011100000 */
569 0x7f, 0xc0, /* 011111111100 */
570 0x3f, 0x80, /* 001111111000 */
571 0x1f, 0x00, /* 000111110000 */
572 0x0e, 0x00, /* 000011100000 */
573 0x04, 0x00, /* 000001000000 */
607 0x00, 0x00, /* 000000000000 */ 574 0x00, 0x00, /* 000000000000 */
575 0x7f, 0xe0, /* 011111111110 */
576 0x7f, 0xe0, /* 011111111110 */
608 0x00, 0x00, /* 000000000000 */ 577 0x00, 0x00, /* 000000000000 */
609 0x00, 0x00, /* 000000000000 */ 578 0x00, 0x00, /* 000000000000 */
610 0x3f, 0xc0, /* 001111111100 */
611 0x3f, 0xc0, /* 001111111100 */
612 0x3f, 0xc0, /* 001111111100 */
613 0x3f, 0xc0, /* 001111111100 */
614 0x3f, 0xc0, /* 001111111100 */
615 0x3f, 0xc0, /* 001111111100 */
616 0x3f, 0xc0, /* 001111111100 */
617 0x3f, 0xc0, /* 001111111100 */
618 0x3f, 0xc0, /* 001111111100 */
619 0x3f, 0xc0, /* 001111111100 */
620 0x3f, 0xc0, /* 001111111100 */
621 0x3f, 0xc0, /* 001111111100 */
622 0x00, 0x00, /* 000000000000 */ 579 0x00, 0x00, /* 000000000000 */
623 0x00, 0x00, /* 000000000000 */ 580 0x00, 0x00, /* 000000000000 */
624 0x00, 0x00, /* 000000000000 */ 581 0x00, 0x00, /* 000000000000 */
582
583 /* 24 0x18 '^X' */
625 0x00, 0x00, /* 000000000000 */ 584 0x00, 0x00, /* 000000000000 */
626 0x00, 0x00, /* 000000000000 */ 585 0x00, 0x00, /* 000000000000 */
627 586 0x04, 0x00, /* 000001000000 */
628 /* 25 0x19 '^Y' */ 587 0x0e, 0x00, /* 000011100000 */
629 /* FIXME */ 588 0x1f, 0x00, /* 000111110000 */
589 0x3f, 0x80, /* 001111111000 */
590 0x7f, 0xc0, /* 011111111100 */
591 0x0e, 0x00, /* 000011100000 */
592 0x0e, 0x00, /* 000011100000 */
593 0x0e, 0x00, /* 000011100000 */
594 0x0e, 0x00, /* 000011100000 */
595 0x0e, 0x00, /* 000011100000 */
596 0x0e, 0x00, /* 000011100000 */
597 0x0e, 0x00, /* 000011100000 */
598 0x0e, 0x00, /* 000011100000 */
599 0x0e, 0x00, /* 000011100000 */
630 0x00, 0x00, /* 000000000000 */ 600 0x00, 0x00, /* 000000000000 */
631 0x00, 0x00, /* 000000000000 */ 601 0x00, 0x00, /* 000000000000 */
632 0x00, 0x00, /* 000000000000 */ 602 0x00, 0x00, /* 000000000000 */
633 0x00, 0x00, /* 000000000000 */ 603 0x00, 0x00, /* 000000000000 */
634 0x00, 0x00, /* 000000000000 */ 604 0x00, 0x00, /* 000000000000 */
635 0x3f, 0xc0, /* 001111111100 */ 605 0x00, 0x00, /* 000000000000 */
636 0x3f, 0xc0, /* 001111111100 */ 606
637 0x3f, 0xc0, /* 001111111100 */ 607 /* 25 0x19 '^Y' */
638 0x3f, 0xc0, /* 001111111100 */ 608 0x00, 0x00, /* 000000000000 */
639 0x3f, 0xc0, /* 001111111100 */ 609 0x00, 0x00, /* 000000000000 */
640 0x3f, 0xc0, /* 001111111100 */ 610 0x0e, 0x00, /* 000011100000 */
641 0x3f, 0xc0, /* 001111111100 */ 611 0x0e, 0x00, /* 000011100000 */
642 0x3f, 0xc0, /* 001111111100 */ 612 0x0e, 0x00, /* 000011100000 */
643 0x3f, 0xc0, /* 001111111100 */ 613 0x0e, 0x00, /* 000011100000 */
644 0x3f, 0xc0, /* 001111111100 */ 614 0x0e, 0x00, /* 000011100000 */
645 0x3f, 0xc0, /* 001111111100 */ 615 0x0e, 0x00, /* 000011100000 */
646 0x3f, 0xc0, /* 001111111100 */ 616 0x0e, 0x00, /* 000011100000 */
617 0x0e, 0x00, /* 000011100000 */
618 0x0e, 0x00, /* 000011100000 */
619 0x0e, 0x00, /* 000011100000 */
620 0x7f, 0xc0, /* 011111111100 */
621 0x3f, 0x80, /* 001111111000 */
622 0x1f, 0x00, /* 000111110000 */
623 0x0e, 0x00, /* 000011100000 */
624 0x04, 0x00, /* 000001000000 */
647 0x00, 0x00, /* 000000000000 */ 625 0x00, 0x00, /* 000000000000 */
648 0x00, 0x00, /* 000000000000 */ 626 0x00, 0x00, /* 000000000000 */
649 0x00, 0x00, /* 000000000000 */ 627 0x00, 0x00, /* 000000000000 */
@@ -651,24 +629,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
651 0x00, 0x00, /* 000000000000 */ 629 0x00, 0x00, /* 000000000000 */
652 630
653 /* 26 0x1a '^Z' */ 631 /* 26 0x1a '^Z' */
654 /* FIXME */
655 0x00, 0x00, /* 000000000000 */ 632 0x00, 0x00, /* 000000000000 */
656 0x00, 0x00, /* 000000000000 */ 633 0x00, 0x00, /* 000000000000 */
657 0x00, 0x00, /* 000000000000 */ 634 0x00, 0x00, /* 000000000000 */
658 0x00, 0x00, /* 000000000000 */ 635 0x00, 0x00, /* 000000000000 */
659 0x00, 0x00, /* 000000000000 */ 636 0x00, 0x00, /* 000000000000 */
660 0x3f, 0xc0, /* 001111111100 */ 637 0x00, 0x00, /* 000000000000 */
661 0x3f, 0xc0, /* 001111111100 */ 638 0x08, 0x00, /* 000010000000 */
662 0x3f, 0xc0, /* 001111111100 */ 639 0x18, 0x00, /* 000110000000 */
663 0x3f, 0xc0, /* 001111111100 */ 640 0x38, 0x00, /* 001110000000 */
664 0x3f, 0xc0, /* 001111111100 */ 641 0x7f, 0xe0, /* 011111111110 */
665 0x3f, 0xc0, /* 001111111100 */ 642 0xff, 0xe0, /* 111111111110 */
666 0x3f, 0xc0, /* 001111111100 */ 643 0x7f, 0xe0, /* 011111111110 */
667 0x3f, 0xc0, /* 001111111100 */ 644 0x38, 0x00, /* 001110000000 */
668 0x3f, 0xc0, /* 001111111100 */ 645 0x18, 0x00, /* 000110000000 */
669 0x3f, 0xc0, /* 001111111100 */ 646 0x08, 0x00, /* 000010000000 */
670 0x3f, 0xc0, /* 001111111100 */ 647 0x00, 0x00, /* 000000000000 */
671 0x3f, 0xc0, /* 001111111100 */ 648 0x00, 0x00, /* 000000000000 */
672 0x00, 0x00, /* 000000000000 */ 649 0x00, 0x00, /* 000000000000 */
673 0x00, 0x00, /* 000000000000 */ 650 0x00, 0x00, /* 000000000000 */
674 0x00, 0x00, /* 000000000000 */ 651 0x00, 0x00, /* 000000000000 */
@@ -676,24 +653,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
676 0x00, 0x00, /* 000000000000 */ 653 0x00, 0x00, /* 000000000000 */
677 654
678 /* 27 0x1b '^[' */ 655 /* 27 0x1b '^[' */
679 /* FIXME */
680 0x00, 0x00, /* 000000000000 */ 656 0x00, 0x00, /* 000000000000 */
681 0x00, 0x00, /* 000000000000 */ 657 0x00, 0x00, /* 000000000000 */
682 0x00, 0x00, /* 000000000000 */ 658 0x00, 0x00, /* 000000000000 */
683 0x00, 0x00, /* 000000000000 */ 659 0x00, 0x00, /* 000000000000 */
684 0x00, 0x00, /* 000000000000 */ 660 0x00, 0x00, /* 000000000000 */
685 0x3f, 0xc0, /* 001111111100 */ 661 0x00, 0x00, /* 000000000000 */
686 0x3f, 0xc0, /* 001111111100 */ 662 0x01, 0x00, /* 000000010000 */
687 0x3f, 0xc0, /* 001111111100 */ 663 0x01, 0x80, /* 000000011000 */
688 0x3f, 0xc0, /* 001111111100 */ 664 0x01, 0xc0, /* 000000011100 */
689 0x3f, 0xc0, /* 001111111100 */ 665 0x7f, 0xe0, /* 011111111110 */
690 0x3f, 0xc0, /* 001111111100 */ 666 0x7f, 0xf0, /* 011111111111 */
691 0x3f, 0xc0, /* 001111111100 */ 667 0x7f, 0xe0, /* 011111111110 */
692 0x3f, 0xc0, /* 001111111100 */ 668 0x01, 0xc0, /* 000000011100 */
693 0x3f, 0xc0, /* 001111111100 */ 669 0x01, 0x80, /* 000000011000 */
694 0x3f, 0xc0, /* 001111111100 */ 670 0x01, 0x00, /* 000000010000 */
695 0x3f, 0xc0, /* 001111111100 */ 671 0x00, 0x00, /* 000000000000 */
696 0x3f, 0xc0, /* 001111111100 */ 672 0x00, 0x00, /* 000000000000 */
697 0x00, 0x00, /* 000000000000 */ 673 0x00, 0x00, /* 000000000000 */
698 0x00, 0x00, /* 000000000000 */ 674 0x00, 0x00, /* 000000000000 */
699 0x00, 0x00, /* 000000000000 */ 675 0x00, 0x00, /* 000000000000 */
@@ -701,24 +677,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
701 0x00, 0x00, /* 000000000000 */ 677 0x00, 0x00, /* 000000000000 */
702 678
703 /* 28 0x1c '^\' */ 679 /* 28 0x1c '^\' */
704 /* FIXME */
705 0x00, 0x00, /* 000000000000 */ 680 0x00, 0x00, /* 000000000000 */
706 0x00, 0x00, /* 000000000000 */ 681 0x00, 0x00, /* 000000000000 */
707 0x00, 0x00, /* 000000000000 */ 682 0x00, 0x00, /* 000000000000 */
708 0x00, 0x00, /* 000000000000 */ 683 0x00, 0x00, /* 000000000000 */
709 0x00, 0x00, /* 000000000000 */ 684 0x00, 0x00, /* 000000000000 */
710 0x3f, 0xc0, /* 001111111100 */ 685 0x00, 0x00, /* 000000000000 */
711 0x3f, 0xc0, /* 001111111100 */ 686 0x00, 0x00, /* 000000000000 */
712 0x3f, 0xc0, /* 001111111100 */ 687 0x00, 0x00, /* 000000000000 */
713 0x3f, 0xc0, /* 001111111100 */ 688 0x00, 0x00, /* 000000000000 */
714 0x3f, 0xc0, /* 001111111100 */ 689 0x00, 0x00, /* 000000000000 */
715 0x3f, 0xc0, /* 001111111100 */ 690 0x00, 0x00, /* 000000000000 */
716 0x3f, 0xc0, /* 001111111100 */ 691 0x00, 0x00, /* 000000000000 */
717 0x3f, 0xc0, /* 001111111100 */ 692 0x00, 0x00, /* 000000000000 */
718 0x3f, 0xc0, /* 001111111100 */ 693 0x30, 0x00, /* 001100000000 */
719 0x3f, 0xc0, /* 001111111100 */ 694 0x30, 0x00, /* 001100000000 */
720 0x3f, 0xc0, /* 001111111100 */ 695 0x3f, 0xe0, /* 001111111110 */
721 0x3f, 0xc0, /* 001111111100 */ 696 0x3f, 0xe0, /* 001111111110 */
722 0x00, 0x00, /* 000000000000 */ 697 0x00, 0x00, /* 000000000000 */
723 0x00, 0x00, /* 000000000000 */ 698 0x00, 0x00, /* 000000000000 */
724 0x00, 0x00, /* 000000000000 */ 699 0x00, 0x00, /* 000000000000 */
@@ -726,24 +701,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
726 0x00, 0x00, /* 000000000000 */ 701 0x00, 0x00, /* 000000000000 */
727 702
728 /* 29 0x1d '^]' */ 703 /* 29 0x1d '^]' */
729 /* FIXME */
730 0x00, 0x00, /* 000000000000 */ 704 0x00, 0x00, /* 000000000000 */
731 0x00, 0x00, /* 000000000000 */ 705 0x00, 0x00, /* 000000000000 */
732 0x00, 0x00, /* 000000000000 */ 706 0x00, 0x00, /* 000000000000 */
733 0x00, 0x00, /* 000000000000 */ 707 0x00, 0x00, /* 000000000000 */
734 0x00, 0x00, /* 000000000000 */ 708 0x00, 0x00, /* 000000000000 */
735 0x3f, 0xc0, /* 001111111100 */ 709 0x00, 0x00, /* 000000000000 */
736 0x3f, 0xc0, /* 001111111100 */ 710 0x09, 0x00, /* 000010010000 */
737 0x3f, 0xc0, /* 001111111100 */ 711 0x19, 0x80, /* 000110011000 */
738 0x3f, 0xc0, /* 001111111100 */ 712 0x39, 0xc0, /* 001110011100 */
739 0x3f, 0xc0, /* 001111111100 */ 713 0x7f, 0xe0, /* 011111111110 */
740 0x3f, 0xc0, /* 001111111100 */ 714 0xff, 0xf0, /* 111111111111 */
741 0x3f, 0xc0, /* 001111111100 */ 715 0x7f, 0xe0, /* 011111111110 */
742 0x3f, 0xc0, /* 001111111100 */ 716 0x39, 0xc0, /* 001110011100 */
743 0x3f, 0xc0, /* 001111111100 */ 717 0x19, 0x80, /* 000110011000 */
744 0x3f, 0xc0, /* 001111111100 */ 718 0x09, 0x00, /* 000010010000 */
745 0x3f, 0xc0, /* 001111111100 */ 719 0x00, 0x00, /* 000000000000 */
746 0x3f, 0xc0, /* 001111111100 */ 720 0x00, 0x00, /* 000000000000 */
747 0x00, 0x00, /* 000000000000 */ 721 0x00, 0x00, /* 000000000000 */
748 0x00, 0x00, /* 000000000000 */ 722 0x00, 0x00, /* 000000000000 */
749 0x00, 0x00, /* 000000000000 */ 723 0x00, 0x00, /* 000000000000 */
@@ -751,24 +725,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
751 0x00, 0x00, /* 000000000000 */ 725 0x00, 0x00, /* 000000000000 */
752 726
753 /* 30 0x1e '^^' */ 727 /* 30 0x1e '^^' */
754 /* FIXME */
755 0x00, 0x00, /* 000000000000 */ 728 0x00, 0x00, /* 000000000000 */
756 0x00, 0x00, /* 000000000000 */ 729 0x00, 0x00, /* 000000000000 */
757 0x00, 0x00, /* 000000000000 */ 730 0x00, 0x00, /* 000000000000 */
758 0x00, 0x00, /* 000000000000 */ 731 0x00, 0x00, /* 000000000000 */
759 0x00, 0x00, /* 000000000000 */ 732 0x00, 0x00, /* 000000000000 */
760 0x3f, 0xc0, /* 001111111100 */ 733 0x00, 0x00, /* 000000000000 */
761 0x3f, 0xc0, /* 001111111100 */ 734 0x04, 0x00, /* 000001000000 */
762 0x3f, 0xc0, /* 001111111100 */ 735 0x04, 0x00, /* 000001000000 */
763 0x3f, 0xc0, /* 001111111100 */ 736 0x0e, 0x00, /* 000011100000 */
764 0x3f, 0xc0, /* 001111111100 */ 737 0x0e, 0x00, /* 000011100000 */
765 0x3f, 0xc0, /* 001111111100 */ 738 0x1f, 0x00, /* 000111110000 */
766 0x3f, 0xc0, /* 001111111100 */ 739 0x1f, 0x00, /* 000111110000 */
767 0x3f, 0xc0, /* 001111111100 */ 740 0x3f, 0x80, /* 001111111000 */
768 0x3f, 0xc0, /* 001111111100 */ 741 0x3f, 0x80, /* 001111111000 */
769 0x3f, 0xc0, /* 001111111100 */ 742 0x7f, 0xc0, /* 011111111100 */
770 0x3f, 0xc0, /* 001111111100 */ 743 0x7f, 0xc0, /* 011111111100 */
771 0x3f, 0xc0, /* 001111111100 */ 744 0x00, 0x00, /* 000000000000 */
772 0x00, 0x00, /* 000000000000 */ 745 0x00, 0x00, /* 000000000000 */
773 0x00, 0x00, /* 000000000000 */ 746 0x00, 0x00, /* 000000000000 */
774 0x00, 0x00, /* 000000000000 */ 747 0x00, 0x00, /* 000000000000 */
@@ -776,24 +749,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
776 0x00, 0x00, /* 000000000000 */ 749 0x00, 0x00, /* 000000000000 */
777 750
778 /* 31 0x1f '^_' */ 751 /* 31 0x1f '^_' */
779 /* FIXME */
780 0x00, 0x00, /* 000000000000 */ 752 0x00, 0x00, /* 000000000000 */
781 0x00, 0x00, /* 000000000000 */ 753 0x00, 0x00, /* 000000000000 */
782 0x00, 0x00, /* 000000000000 */ 754 0x00, 0x00, /* 000000000000 */
783 0x00, 0x00, /* 000000000000 */ 755 0x00, 0x00, /* 000000000000 */
784 0x00, 0x00, /* 000000000000 */ 756 0x00, 0x00, /* 000000000000 */
785 0x3f, 0xc0, /* 001111111100 */ 757 0x00, 0x00, /* 000000000000 */
786 0x3f, 0xc0, /* 001111111100 */ 758 0x7f, 0xc0, /* 011111111100 */
787 0x3f, 0xc0, /* 001111111100 */ 759 0x7f, 0xc0, /* 011111111100 */
788 0x3f, 0xc0, /* 001111111100 */ 760 0x3f, 0x80, /* 001111111000 */
789 0x3f, 0xc0, /* 001111111100 */ 761 0x3f, 0x80, /* 001111111000 */
790 0x3f, 0xc0, /* 001111111100 */ 762 0x1f, 0x00, /* 000111110000 */
791 0x3f, 0xc0, /* 001111111100 */ 763 0x1f, 0x00, /* 000111110000 */
792 0x3f, 0xc0, /* 001111111100 */ 764 0x0e, 0x00, /* 000011100000 */
793 0x3f, 0xc0, /* 001111111100 */ 765 0x0e, 0x00, /* 000011100000 */
794 0x3f, 0xc0, /* 001111111100 */ 766 0x04, 0x00, /* 000001000000 */
795 0x3f, 0xc0, /* 001111111100 */ 767 0x04, 0x00, /* 000001000000 */
796 0x3f, 0xc0, /* 001111111100 */ 768 0x00, 0x00, /* 000000000000 */
797 0x00, 0x00, /* 000000000000 */ 769 0x00, 0x00, /* 000000000000 */
798 0x00, 0x00, /* 000000000000 */ 770 0x00, 0x00, /* 000000000000 */
799 0x00, 0x00, /* 000000000000 */ 771 0x00, 0x00, /* 000000000000 */
@@ -3081,29 +3053,28 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
3081 0x00, 0x00, /* 000000000000 */ 3053 0x00, 0x00, /* 000000000000 */
3082 3054
3083 /* 127 0x7f '.' */ 3055 /* 127 0x7f '.' */
3084 /* FIXME */
3085 0x00, 0x00, /* 000000000000 */ 3056 0x00, 0x00, /* 000000000000 */
3086 0x00, 0x00, /* 000000000000 */ 3057 0x00, 0x00, /* 000000000000 */
3087 0x00, 0x00, /* 000000000000 */ 3058 0x00, 0x00, /* 000000000000 */
3088 0x00, 0x00, /* 000000000000 */ 3059 0x00, 0x00, /* 000000000000 */
3089 0x00, 0x00, /* 000000000000 */ 3060 0x00, 0x00, /* 000000000000 */
3090 0x3f, 0xc0, /* 001111111100 */
3091 0x3f, 0xc0, /* 001111111100 */
3092 0x3f, 0xc0, /* 001111111100 */
3093 0x3f, 0xc0, /* 001111111100 */
3094 0x3f, 0xc0, /* 001111111100 */
3095 0x3f, 0xc0, /* 001111111100 */
3096 0x3f, 0xc0, /* 001111111100 */
3097 0x3f, 0xc0, /* 001111111100 */
3098 0x3f, 0xc0, /* 001111111100 */
3099 0x3f, 0xc0, /* 001111111100 */
3100 0x3f, 0xc0, /* 001111111100 */
3101 0x3f, 0xc0, /* 001111111100 */
3102 0x00, 0x00, /* 000000000000 */ 3061 0x00, 0x00, /* 000000000000 */
3103 0x00, 0x00, /* 000000000000 */ 3062 0x00, 0x00, /* 000000000000 */
3104 0x00, 0x00, /* 000000000000 */ 3063 0x00, 0x00, /* 000000000000 */
3105 0x00, 0x00, /* 000000000000 */ 3064 0x00, 0x00, /* 000000000000 */
3106 0x00, 0x00, /* 000000000000 */ 3065 0x00, 0x00, /* 000000000000 */
3066 0x00, 0x00, /* 000000000000 */
3067 0x00, 0x00, /* 000000000000 */
3068 0x00, 0x00, /* 000000000000 */
3069 0x00, 0x00, /* 000000000000 */
3070 0x00, 0x00, /* 000000000000 */
3071 0x00, 0x00, /* 000000000000 */
3072 0x00, 0x00, /* 000000000000 */
3073 0x00, 0x00, /* 000000000000 */
3074 0x00, 0x00, /* 000000000000 */
3075 0xff, 0xf0, /* 111111111111 */
3076 0xff, 0xf0, /* 111111111111 */
3077 0x00, 0x00, /* 000000000000 */
3107 3078
3108 /* 128 0x80 '.' */ 3079 /* 128 0x80 '.' */
3109 0x00, 0x00, /* 000000000000 */ 3080 0x00, 0x00, /* 000000000000 */
@@ -3826,24 +3797,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
3826 0x00, 0x00, /* 000000000000 */ 3797 0x00, 0x00, /* 000000000000 */
3827 3798
3828 /* 158 0x9e '.' */ 3799 /* 158 0x9e '.' */
3829 /* FIXME */
3830 0x00, 0x00, /* 000000000000 */
3831 0x00, 0x00, /* 000000000000 */
3832 0x00, 0x00, /* 000000000000 */
3833 0x00, 0x00, /* 000000000000 */ 3800 0x00, 0x00, /* 000000000000 */
3801 0x7f, 0x80, /* 011111111000 */
3802 0x30, 0xc0, /* 001100001100 */
3803 0x30, 0x60, /* 001100000110 */
3804 0x30, 0x60, /* 001100000110 */
3805 0x30, 0x60, /* 001100000110 */
3806 0x30, 0xc0, /* 001100001100 */
3807 0x37, 0x80, /* 001101111000 */
3808 0x30, 0x00, /* 001100000000 */
3809 0x33, 0x00, /* 001100110000 */
3810 0x37, 0x80, /* 001101111000 */
3811 0x33, 0x00, /* 001100110000 */
3812 0x33, 0x00, /* 001100110000 */
3813 0x33, 0x30, /* 001100110011 */
3814 0x31, 0xe0, /* 001100011110 */
3815 0x78, 0xc0, /* 011110001100 */
3834 0x00, 0x00, /* 000000000000 */ 3816 0x00, 0x00, /* 000000000000 */
3835 0x3f, 0xc0, /* 001111111100 */
3836 0x3f, 0xc0, /* 001111111100 */
3837 0x3f, 0xc0, /* 001111111100 */
3838 0x3f, 0xc0, /* 001111111100 */
3839 0x3f, 0xc0, /* 001111111100 */
3840 0x3f, 0xc0, /* 001111111100 */
3841 0x3f, 0xc0, /* 001111111100 */
3842 0x3f, 0xc0, /* 001111111100 */
3843 0x3f, 0xc0, /* 001111111100 */
3844 0x3f, 0xc0, /* 001111111100 */
3845 0x3f, 0xc0, /* 001111111100 */
3846 0x3f, 0xc0, /* 001111111100 */
3847 0x00, 0x00, /* 000000000000 */ 3817 0x00, 0x00, /* 000000000000 */
3848 0x00, 0x00, /* 000000000000 */ 3818 0x00, 0x00, /* 000000000000 */
3849 0x00, 0x00, /* 000000000000 */ 3819 0x00, 0x00, /* 000000000000 */
@@ -3851,28 +3821,27 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
3851 0x00, 0x00, /* 000000000000 */ 3821 0x00, 0x00, /* 000000000000 */
3852 3822
3853 /* 159 0x9f '.' */ 3823 /* 159 0x9f '.' */
3854 /* FIXME */
3855 0x00, 0x00, /* 000000000000 */
3856 0x00, 0x00, /* 000000000000 */
3857 0x00, 0x00, /* 000000000000 */
3858 0x00, 0x00, /* 000000000000 */
3859 0x00, 0x00, /* 000000000000 */
3860 0x3f, 0xc0, /* 001111111100 */
3861 0x3f, 0xc0, /* 001111111100 */
3862 0x3f, 0xc0, /* 001111111100 */
3863 0x3f, 0xc0, /* 001111111100 */
3864 0x3f, 0xc0, /* 001111111100 */
3865 0x3f, 0xc0, /* 001111111100 */
3866 0x3f, 0xc0, /* 001111111100 */
3867 0x3f, 0xc0, /* 001111111100 */
3868 0x3f, 0xc0, /* 001111111100 */
3869 0x3f, 0xc0, /* 001111111100 */
3870 0x3f, 0xc0, /* 001111111100 */
3871 0x3f, 0xc0, /* 001111111100 */
3872 0x00, 0x00, /* 000000000000 */
3873 0x00, 0x00, /* 000000000000 */
3874 0x00, 0x00, /* 000000000000 */
3875 0x00, 0x00, /* 000000000000 */ 3824 0x00, 0x00, /* 000000000000 */
3825 0x00, 0xc0, /* 000000001100 */
3826 0x01, 0xe0, /* 000000011110 */
3827 0x03, 0x30, /* 000000110011 */
3828 0x06, 0x00, /* 000001100000 */
3829 0x06, 0x00, /* 000001100000 */
3830 0x06, 0x00, /* 000001100000 */
3831 0x06, 0x00, /* 000001100000 */
3832 0x06, 0x00, /* 000001100000 */
3833 0x06, 0x00, /* 000001100000 */
3834 0x3f, 0xe0, /* 001111111110 */
3835 0x7f, 0xc0, /* 011111111100 */
3836 0x06, 0x00, /* 000001100000 */
3837 0x06, 0x00, /* 000001100000 */
3838 0x06, 0x00, /* 000001100000 */
3839 0x06, 0x00, /* 000001100000 */
3840 0x06, 0x00, /* 000001100000 */
3841 0x06, 0x00, /* 000001100000 */
3842 0xcc, 0x00, /* 110011000000 */
3843 0x78, 0x00, /* 011110000000 */
3844 0x30, 0x00, /* 001100000000 */
3876 0x00, 0x00, /* 000000000000 */ 3845 0x00, 0x00, /* 000000000000 */
3877 3846
3878 /* 160 0xa0 '.' */ 3847 /* 160 0xa0 '.' */
@@ -4092,24 +4061,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
4092 0x00, 0x00, /* 000000000000 */ 4061 0x00, 0x00, /* 000000000000 */
4093 4062
4094 /* 169 0xa9 '.' */ 4063 /* 169 0xa9 '.' */
4095 /* FIXME */
4096 0x00, 0x00, /* 000000000000 */
4097 0x00, 0x00, /* 000000000000 */ 4064 0x00, 0x00, /* 000000000000 */
4098 0x00, 0x00, /* 000000000000 */ 4065 0x00, 0x00, /* 000000000000 */
4099 0x00, 0x00, /* 000000000000 */ 4066 0x00, 0x00, /* 000000000000 */
4100 0x00, 0x00, /* 000000000000 */ 4067 0x00, 0x00, /* 000000000000 */
4101 0x3f, 0xc0, /* 001111111100 */ 4068 0x3f, 0xc0, /* 001111111100 */
4102 0x3f, 0xc0, /* 001111111100 */ 4069 0x3f, 0xc0, /* 001111111100 */
4103 0x3f, 0xc0, /* 001111111100 */ 4070 0x30, 0x00, /* 001100000000 */
4104 0x3f, 0xc0, /* 001111111100 */ 4071 0x30, 0x00, /* 001100000000 */
4105 0x3f, 0xc0, /* 001111111100 */ 4072 0x30, 0x00, /* 001100000000 */
4106 0x3f, 0xc0, /* 001111111100 */ 4073 0x00, 0x00, /* 000000000000 */
4107 0x3f, 0xc0, /* 001111111100 */ 4074 0x00, 0x00, /* 000000000000 */
4108 0x3f, 0xc0, /* 001111111100 */ 4075 0x00, 0x00, /* 000000000000 */
4109 0x3f, 0xc0, /* 001111111100 */ 4076 0x00, 0x00, /* 000000000000 */
4110 0x3f, 0xc0, /* 001111111100 */ 4077 0x00, 0x00, /* 000000000000 */
4111 0x3f, 0xc0, /* 001111111100 */ 4078 0x00, 0x00, /* 000000000000 */
4112 0x3f, 0xc0, /* 001111111100 */ 4079 0x00, 0x00, /* 000000000000 */
4080 0x00, 0x00, /* 000000000000 */
4113 0x00, 0x00, /* 000000000000 */ 4081 0x00, 0x00, /* 000000000000 */
4114 0x00, 0x00, /* 000000000000 */ 4082 0x00, 0x00, /* 000000000000 */
4115 0x00, 0x00, /* 000000000000 */ 4083 0x00, 0x00, /* 000000000000 */
@@ -5413,24 +5381,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
5413 0x00, 0x00, /* 000000000000 */ 5381 0x00, 0x00, /* 000000000000 */
5414 5382
5415 /* 224 0xe0 '.' */ 5383 /* 224 0xe0 '.' */
5416 /* FIXME */
5417 0x00, 0x00, /* 000000000000 */ 5384 0x00, 0x00, /* 000000000000 */
5418 0x00, 0x00, /* 000000000000 */ 5385 0x00, 0x00, /* 000000000000 */
5419 0x00, 0x00, /* 000000000000 */ 5386 0x00, 0x00, /* 000000000000 */
5420 0x00, 0x00, /* 000000000000 */ 5387 0x00, 0x00, /* 000000000000 */
5421 0x00, 0x00, /* 000000000000 */ 5388 0x00, 0x00, /* 000000000000 */
5422 0x3f, 0xc0, /* 001111111100 */ 5389 0x00, 0x00, /* 000000000000 */
5423 0x3f, 0xc0, /* 001111111100 */ 5390 0x0f, 0x60, /* 000011110110 */
5424 0x3f, 0xc0, /* 001111111100 */ 5391 0x13, 0xe0, /* 000100111110 */
5425 0x3f, 0xc0, /* 001111111100 */ 5392 0x21, 0xc0, /* 001000011100 */
5426 0x3f, 0xc0, /* 001111111100 */ 5393 0x60, 0xc0, /* 011000001100 */
5427 0x3f, 0xc0, /* 001111111100 */ 5394 0x60, 0xc0, /* 011000001100 */
5428 0x3f, 0xc0, /* 001111111100 */ 5395 0x60, 0xc0, /* 011000001100 */
5429 0x3f, 0xc0, /* 001111111100 */ 5396 0x60, 0xc0, /* 011000001100 */
5430 0x3f, 0xc0, /* 001111111100 */ 5397 0x70, 0x80, /* 011100001000 */
5431 0x3f, 0xc0, /* 001111111100 */ 5398 0x39, 0xc0, /* 001110011100 */
5432 0x3f, 0xc0, /* 001111111100 */ 5399 0x1f, 0x60, /* 000111110110 */
5433 0x3f, 0xc0, /* 001111111100 */ 5400 0x00, 0x00, /* 000000000000 */
5434 0x00, 0x00, /* 000000000000 */ 5401 0x00, 0x00, /* 000000000000 */
5435 0x00, 0x00, /* 000000000000 */ 5402 0x00, 0x00, /* 000000000000 */
5436 0x00, 0x00, /* 000000000000 */ 5403 0x00, 0x00, /* 000000000000 */
@@ -5462,24 +5429,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
5462 0x00, 0x00, /* 000000000000 */ 5429 0x00, 0x00, /* 000000000000 */
5463 5430
5464 /* 226 0xe2 '.' */ 5431 /* 226 0xe2 '.' */
5465 /* FIXME */
5466 0x00, 0x00, /* 000000000000 */
5467 0x00, 0x00, /* 000000000000 */
5468 0x00, 0x00, /* 000000000000 */ 5432 0x00, 0x00, /* 000000000000 */
5469 0x00, 0x00, /* 000000000000 */ 5433 0x00, 0x00, /* 000000000000 */
5434 0x3f, 0xe0, /* 001111111110 */
5435 0x3f, 0xe0, /* 001111111110 */
5436 0x30, 0x60, /* 001100000110 */
5437 0x30, 0x60, /* 001100000110 */
5438 0x30, 0x00, /* 001100000000 */
5439 0x30, 0x00, /* 001100000000 */
5440 0x30, 0x00, /* 001100000000 */
5441 0x30, 0x00, /* 001100000000 */
5442 0x30, 0x00, /* 001100000000 */
5443 0x30, 0x00, /* 001100000000 */
5444 0x30, 0x00, /* 001100000000 */
5445 0x30, 0x00, /* 001100000000 */
5446 0x30, 0x00, /* 001100000000 */
5447 0x30, 0x00, /* 001100000000 */
5470 0x00, 0x00, /* 000000000000 */ 5448 0x00, 0x00, /* 000000000000 */
5471 0x3f, 0xc0, /* 001111111100 */
5472 0x3f, 0xc0, /* 001111111100 */
5473 0x3f, 0xc0, /* 001111111100 */
5474 0x3f, 0xc0, /* 001111111100 */
5475 0x3f, 0xc0, /* 001111111100 */
5476 0x3f, 0xc0, /* 001111111100 */
5477 0x3f, 0xc0, /* 001111111100 */
5478 0x3f, 0xc0, /* 001111111100 */
5479 0x3f, 0xc0, /* 001111111100 */
5480 0x3f, 0xc0, /* 001111111100 */
5481 0x3f, 0xc0, /* 001111111100 */
5482 0x3f, 0xc0, /* 001111111100 */
5483 0x00, 0x00, /* 000000000000 */ 5449 0x00, 0x00, /* 000000000000 */
5484 0x00, 0x00, /* 000000000000 */ 5450 0x00, 0x00, /* 000000000000 */
5485 0x00, 0x00, /* 000000000000 */ 5451 0x00, 0x00, /* 000000000000 */
@@ -5487,49 +5453,47 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
5487 0x00, 0x00, /* 000000000000 */ 5453 0x00, 0x00, /* 000000000000 */
5488 5454
5489 /* 227 0xe3 '.' */ 5455 /* 227 0xe3 '.' */
5490 /* FIXME */
5491 0x00, 0x00, /* 000000000000 */ 5456 0x00, 0x00, /* 000000000000 */
5492 0x00, 0x00, /* 000000000000 */ 5457 0x00, 0x00, /* 000000000000 */
5493 0x00, 0x00, /* 000000000000 */ 5458 0x00, 0x00, /* 000000000000 */
5494 0x00, 0x00, /* 000000000000 */ 5459 0x00, 0x00, /* 000000000000 */
5495 0x00, 0x00, /* 000000000000 */ 5460 0x00, 0x00, /* 000000000000 */
5496 0x3f, 0xc0, /* 001111111100 */
5497 0x3f, 0xc0, /* 001111111100 */
5498 0x3f, 0xc0, /* 001111111100 */
5499 0x3f, 0xc0, /* 001111111100 */
5500 0x3f, 0xc0, /* 001111111100 */
5501 0x3f, 0xc0, /* 001111111100 */
5502 0x3f, 0xc0, /* 001111111100 */
5503 0x3f, 0xc0, /* 001111111100 */
5504 0x3f, 0xc0, /* 001111111100 */
5505 0x3f, 0xc0, /* 001111111100 */
5506 0x3f, 0xc0, /* 001111111100 */
5507 0x3f, 0xc0, /* 001111111100 */
5508 0x00, 0x00, /* 000000000000 */
5509 0x00, 0x00, /* 000000000000 */ 5461 0x00, 0x00, /* 000000000000 */
5462 0x7f, 0xe0, /* 011111111110 */
5463 0x7f, 0xe0, /* 011111111110 */
5464 0x19, 0x80, /* 000110011000 */
5465 0x19, 0x80, /* 000110011000 */
5466 0x19, 0x80, /* 000110011000 */
5467 0x19, 0x80, /* 000110011000 */
5468 0x19, 0x80, /* 000110011000 */
5469 0x19, 0x80, /* 000110011000 */
5470 0x19, 0x80, /* 000110011000 */
5471 0x19, 0x80, /* 000110011000 */
5510 0x00, 0x00, /* 000000000000 */ 5472 0x00, 0x00, /* 000000000000 */
5511 0x00, 0x00, /* 000000000000 */ 5473 0x00, 0x00, /* 000000000000 */
5512 0x00, 0x00, /* 000000000000 */ 5474 0x00, 0x00, /* 000000000000 */
5513
5514 /* 228 0xe4 '.' */
5515 /* FIXME */
5516 0x00, 0x00, /* 000000000000 */ 5475 0x00, 0x00, /* 000000000000 */
5517 0x00, 0x00, /* 000000000000 */ 5476 0x00, 0x00, /* 000000000000 */
5518 0x00, 0x00, /* 000000000000 */ 5477 0x00, 0x00, /* 000000000000 */
5478
5479 /* 228 0xe4 '.' */
5519 0x00, 0x00, /* 000000000000 */ 5480 0x00, 0x00, /* 000000000000 */
5481 0x7f, 0xe0, /* 011111111110 */
5482 0x7f, 0xe0, /* 011111111110 */
5483 0x60, 0x60, /* 011000000110 */
5484 0x30, 0x60, /* 001100000110 */
5485 0x30, 0x00, /* 001100000000 */
5486 0x18, 0x00, /* 000110000000 */
5487 0x18, 0x00, /* 000110000000 */
5488 0x0c, 0x00, /* 000011000000 */
5489 0x18, 0x00, /* 000110000000 */
5490 0x18, 0x00, /* 000110000000 */
5491 0x30, 0x00, /* 001100000000 */
5492 0x30, 0x60, /* 001100000110 */
5493 0x60, 0x60, /* 011000000110 */
5494 0x7f, 0xe0, /* 011111111110 */
5495 0x7f, 0xe0, /* 011111111110 */
5520 0x00, 0x00, /* 000000000000 */ 5496 0x00, 0x00, /* 000000000000 */
5521 0x3f, 0xc0, /* 001111111100 */
5522 0x3f, 0xc0, /* 001111111100 */
5523 0x3f, 0xc0, /* 001111111100 */
5524 0x3f, 0xc0, /* 001111111100 */
5525 0x3f, 0xc0, /* 001111111100 */
5526 0x3f, 0xc0, /* 001111111100 */
5527 0x3f, 0xc0, /* 001111111100 */
5528 0x3f, 0xc0, /* 001111111100 */
5529 0x3f, 0xc0, /* 001111111100 */
5530 0x3f, 0xc0, /* 001111111100 */
5531 0x3f, 0xc0, /* 001111111100 */
5532 0x3f, 0xc0, /* 001111111100 */
5533 0x00, 0x00, /* 000000000000 */ 5497 0x00, 0x00, /* 000000000000 */
5534 0x00, 0x00, /* 000000000000 */ 5498 0x00, 0x00, /* 000000000000 */
5535 0x00, 0x00, /* 000000000000 */ 5499 0x00, 0x00, /* 000000000000 */
@@ -5537,24 +5501,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
5537 0x00, 0x00, /* 000000000000 */ 5501 0x00, 0x00, /* 000000000000 */
5538 5502
5539 /* 229 0xe5 '.' */ 5503 /* 229 0xe5 '.' */
5540 /* FIXME */
5541 0x00, 0x00, /* 000000000000 */ 5504 0x00, 0x00, /* 000000000000 */
5542 0x00, 0x00, /* 000000000000 */ 5505 0x00, 0x00, /* 000000000000 */
5543 0x00, 0x00, /* 000000000000 */ 5506 0x00, 0x00, /* 000000000000 */
5544 0x00, 0x00, /* 000000000000 */ 5507 0x00, 0x00, /* 000000000000 */
5545 0x00, 0x00, /* 000000000000 */ 5508 0x00, 0x00, /* 000000000000 */
5546 0x3f, 0xc0, /* 001111111100 */ 5509 0x07, 0xe0, /* 000001111110 */
5547 0x3f, 0xc0, /* 001111111100 */ 5510 0x0f, 0xe0, /* 000011111110 */
5548 0x3f, 0xc0, /* 001111111100 */ 5511 0x13, 0x80, /* 000100111000 */
5549 0x3f, 0xc0, /* 001111111100 */ 5512 0x21, 0xc0, /* 001000011100 */
5550 0x3f, 0xc0, /* 001111111100 */ 5513 0x60, 0xc0, /* 011000001100 */
5551 0x3f, 0xc0, /* 001111111100 */ 5514 0x60, 0xc0, /* 011000001100 */
5552 0x3f, 0xc0, /* 001111111100 */ 5515 0x60, 0xc0, /* 011000001100 */
5553 0x3f, 0xc0, /* 001111111100 */ 5516 0x60, 0xc0, /* 011000001100 */
5554 0x3f, 0xc0, /* 001111111100 */ 5517 0x70, 0x80, /* 011100001000 */
5555 0x3f, 0xc0, /* 001111111100 */ 5518 0x39, 0x00, /* 001110010000 */
5556 0x3f, 0xc0, /* 001111111100 */ 5519 0x1e, 0x00, /* 000111100000 */
5557 0x3f, 0xc0, /* 001111111100 */ 5520 0x00, 0x00, /* 000000000000 */
5558 0x00, 0x00, /* 000000000000 */ 5521 0x00, 0x00, /* 000000000000 */
5559 0x00, 0x00, /* 000000000000 */ 5522 0x00, 0x00, /* 000000000000 */
5560 0x00, 0x00, /* 000000000000 */ 5523 0x00, 0x00, /* 000000000000 */
@@ -5586,24 +5549,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
5586 0x00, 0x00, /* 000000000000 */ 5549 0x00, 0x00, /* 000000000000 */
5587 5550
5588 /* 231 0xe7 '.' */ 5551 /* 231 0xe7 '.' */
5589 /* FIXME */
5590 0x00, 0x00, /* 000000000000 */
5591 0x00, 0x00, /* 000000000000 */
5592 0x00, 0x00, /* 000000000000 */
5593 0x00, 0x00, /* 000000000000 */ 5552 0x00, 0x00, /* 000000000000 */
5594 0x00, 0x00, /* 000000000000 */ 5553 0x19, 0x80, /* 000110011000 */
5595 0x3f, 0xc0, /* 001111111100 */
5596 0x3f, 0xc0, /* 001111111100 */
5597 0x3f, 0xc0, /* 001111111100 */
5598 0x3f, 0xc0, /* 001111111100 */
5599 0x3f, 0xc0, /* 001111111100 */
5600 0x3f, 0xc0, /* 001111111100 */
5601 0x3f, 0xc0, /* 001111111100 */
5602 0x3f, 0xc0, /* 001111111100 */
5603 0x3f, 0xc0, /* 001111111100 */
5604 0x3f, 0xc0, /* 001111111100 */
5605 0x3f, 0xc0, /* 001111111100 */
5606 0x3f, 0xc0, /* 001111111100 */ 5554 0x3f, 0xc0, /* 001111111100 */
5555 0x66, 0x60, /* 011001100110 */
5556 0x66, 0x60, /* 011001100110 */
5557 0x06, 0x00, /* 000001100000 */
5558 0x06, 0x00, /* 000001100000 */
5559 0x06, 0x00, /* 000001100000 */
5560 0x06, 0x00, /* 000001100000 */
5561 0x06, 0x00, /* 000001100000 */
5562 0x06, 0x00, /* 000001100000 */
5563 0x06, 0x00, /* 000001100000 */
5564 0x06, 0x00, /* 000001100000 */
5565 0x06, 0x00, /* 000001100000 */
5566 0x06, 0x00, /* 000001100000 */
5567 0x06, 0x00, /* 000001100000 */
5568 0x00, 0x00, /* 000000000000 */
5607 0x00, 0x00, /* 000000000000 */ 5569 0x00, 0x00, /* 000000000000 */
5608 0x00, 0x00, /* 000000000000 */ 5570 0x00, 0x00, /* 000000000000 */
5609 0x00, 0x00, /* 000000000000 */ 5571 0x00, 0x00, /* 000000000000 */
@@ -5611,24 +5573,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
5611 0x00, 0x00, /* 000000000000 */ 5573 0x00, 0x00, /* 000000000000 */
5612 5574
5613 /* 232 0xe8 '.' */ 5575 /* 232 0xe8 '.' */
5614 /* FIXME */
5615 0x00, 0x00, /* 000000000000 */
5616 0x00, 0x00, /* 000000000000 */
5617 0x00, 0x00, /* 000000000000 */ 5576 0x00, 0x00, /* 000000000000 */
5618 0x00, 0x00, /* 000000000000 */ 5577 0x00, 0x00, /* 000000000000 */
5578 0x7f, 0xe0, /* 011111111110 */
5579 0x7f, 0xe0, /* 011111111110 */
5580 0x06, 0x00, /* 000001100000 */
5581 0x06, 0x00, /* 000001100000 */
5582 0x0f, 0x00, /* 000011110000 */
5583 0x19, 0x80, /* 000110011000 */
5584 0x30, 0xc0, /* 001100001100 */
5585 0x30, 0xc0, /* 001100001100 */
5586 0x19, 0x80, /* 000110011000 */
5587 0x0f, 0x00, /* 000011110000 */
5588 0x06, 0x00, /* 000001100000 */
5589 0x06, 0x00, /* 000001100000 */
5590 0x7f, 0xe0, /* 011111111110 */
5591 0x7f, 0xe0, /* 011111111110 */
5619 0x00, 0x00, /* 000000000000 */ 5592 0x00, 0x00, /* 000000000000 */
5620 0x3f, 0xc0, /* 001111111100 */
5621 0x3f, 0xc0, /* 001111111100 */
5622 0x3f, 0xc0, /* 001111111100 */
5623 0x3f, 0xc0, /* 001111111100 */
5624 0x3f, 0xc0, /* 001111111100 */
5625 0x3f, 0xc0, /* 001111111100 */
5626 0x3f, 0xc0, /* 001111111100 */
5627 0x3f, 0xc0, /* 001111111100 */
5628 0x3f, 0xc0, /* 001111111100 */
5629 0x3f, 0xc0, /* 001111111100 */
5630 0x3f, 0xc0, /* 001111111100 */
5631 0x3f, 0xc0, /* 001111111100 */
5632 0x00, 0x00, /* 000000000000 */ 5593 0x00, 0x00, /* 000000000000 */
5633 0x00, 0x00, /* 000000000000 */ 5594 0x00, 0x00, /* 000000000000 */
5634 0x00, 0x00, /* 000000000000 */ 5595 0x00, 0x00, /* 000000000000 */
@@ -5636,24 +5597,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
5636 0x00, 0x00, /* 000000000000 */ 5597 0x00, 0x00, /* 000000000000 */
5637 5598
5638 /* 233 0xe9 '.' */ 5599 /* 233 0xe9 '.' */
5639 /* FIXME */
5640 0x00, 0x00, /* 000000000000 */ 5600 0x00, 0x00, /* 000000000000 */
5641 0x00, 0x00, /* 000000000000 */ 5601 0x00, 0x00, /* 000000000000 */
5642 0x00, 0x00, /* 000000000000 */ 5602 0x00, 0x00, /* 000000000000 */
5643 0x00, 0x00, /* 000000000000 */ 5603 0x00, 0x00, /* 000000000000 */
5604 0x0f, 0x00, /* 000011110000 */
5605 0x1f, 0x80, /* 000111111000 */
5606 0x30, 0xc0, /* 001100001100 */
5607 0x60, 0x60, /* 011000000110 */
5608 0x60, 0x60, /* 011000000110 */
5609 0x7f, 0xe0, /* 011111111110 */
5610 0x7f, 0xe0, /* 011111111110 */
5611 0x60, 0x60, /* 011000000110 */
5612 0x60, 0x60, /* 011000000110 */
5613 0x30, 0xc0, /* 001100001100 */
5614 0x1f, 0x80, /* 000111111000 */
5615 0x0f, 0x00, /* 000011110000 */
5644 0x00, 0x00, /* 000000000000 */ 5616 0x00, 0x00, /* 000000000000 */
5645 0x3f, 0xc0, /* 001111111100 */
5646 0x3f, 0xc0, /* 001111111100 */
5647 0x3f, 0xc0, /* 001111111100 */
5648 0x3f, 0xc0, /* 001111111100 */
5649 0x3f, 0xc0, /* 001111111100 */
5650 0x3f, 0xc0, /* 001111111100 */
5651 0x3f, 0xc0, /* 001111111100 */
5652 0x3f, 0xc0, /* 001111111100 */
5653 0x3f, 0xc0, /* 001111111100 */
5654 0x3f, 0xc0, /* 001111111100 */
5655 0x3f, 0xc0, /* 001111111100 */
5656 0x3f, 0xc0, /* 001111111100 */
5657 0x00, 0x00, /* 000000000000 */ 5617 0x00, 0x00, /* 000000000000 */
5658 0x00, 0x00, /* 000000000000 */ 5618 0x00, 0x00, /* 000000000000 */
5659 0x00, 0x00, /* 000000000000 */ 5619 0x00, 0x00, /* 000000000000 */
@@ -5661,24 +5621,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
5661 0x00, 0x00, /* 000000000000 */ 5621 0x00, 0x00, /* 000000000000 */
5662 5622
5663 /* 234 0xea '.' */ 5623 /* 234 0xea '.' */
5664 /* FIXME */
5665 0x00, 0x00, /* 000000000000 */ 5624 0x00, 0x00, /* 000000000000 */
5666 0x00, 0x00, /* 000000000000 */ 5625 0x00, 0x00, /* 000000000000 */
5667 0x00, 0x00, /* 000000000000 */ 5626 0x00, 0x00, /* 000000000000 */
5668 0x00, 0x00, /* 000000000000 */ 5627 0x00, 0x00, /* 000000000000 */
5628 0x1f, 0x00, /* 000111110000 */
5629 0x31, 0x80, /* 001100011000 */
5630 0x30, 0xc0, /* 001100001100 */
5631 0x30, 0xc0, /* 001100001100 */
5632 0x60, 0x60, /* 011000000110 */
5633 0x60, 0x60, /* 011000000110 */
5634 0x30, 0xc0, /* 001100001100 */
5635 0x30, 0xc0, /* 001100001100 */
5636 0x19, 0x80, /* 000110011000 */
5637 0x19, 0x80, /* 000110011000 */
5638 0xd9, 0xb0, /* 110110011011 */
5639 0x79, 0xe0, /* 011110011110 */
5669 0x00, 0x00, /* 000000000000 */ 5640 0x00, 0x00, /* 000000000000 */
5670 0x3f, 0xc0, /* 001111111100 */
5671 0x3f, 0xc0, /* 001111111100 */
5672 0x3f, 0xc0, /* 001111111100 */
5673 0x3f, 0xc0, /* 001111111100 */
5674 0x3f, 0xc0, /* 001111111100 */
5675 0x3f, 0xc0, /* 001111111100 */
5676 0x3f, 0xc0, /* 001111111100 */
5677 0x3f, 0xc0, /* 001111111100 */
5678 0x3f, 0xc0, /* 001111111100 */
5679 0x3f, 0xc0, /* 001111111100 */
5680 0x3f, 0xc0, /* 001111111100 */
5681 0x3f, 0xc0, /* 001111111100 */
5682 0x00, 0x00, /* 000000000000 */ 5641 0x00, 0x00, /* 000000000000 */
5683 0x00, 0x00, /* 000000000000 */ 5642 0x00, 0x00, /* 000000000000 */
5684 0x00, 0x00, /* 000000000000 */ 5643 0x00, 0x00, /* 000000000000 */
@@ -5686,24 +5645,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
5686 0x00, 0x00, /* 000000000000 */ 5645 0x00, 0x00, /* 000000000000 */
5687 5646
5688 /* 235 0xeb '.' */ 5647 /* 235 0xeb '.' */
5689 /* FIXME */
5690 0x00, 0x00, /* 000000000000 */
5691 0x00, 0x00, /* 000000000000 */
5692 0x00, 0x00, /* 000000000000 */
5693 0x00, 0x00, /* 000000000000 */ 5648 0x00, 0x00, /* 000000000000 */
5649 0x07, 0x80, /* 000001111000 */
5650 0x0c, 0xc0, /* 000011001100 */
5651 0x18, 0x60, /* 000110000110 */
5652 0x18, 0x00, /* 000110000000 */
5653 0x0c, 0x00, /* 000011000000 */
5654 0x06, 0x00, /* 000001100000 */
5655 0x03, 0x00, /* 000000110000 */
5656 0x0f, 0x80, /* 000011111000 */
5657 0x11, 0xc0, /* 000100011100 */
5658 0x20, 0xe0, /* 001000001110 */
5659 0x60, 0x60, /* 011000000110 */
5660 0x60, 0x60, /* 011000000110 */
5661 0x70, 0x40, /* 011100000100 */
5662 0x38, 0x80, /* 001110001000 */
5663 0x1f, 0x00, /* 000111110000 */
5694 0x00, 0x00, /* 000000000000 */ 5664 0x00, 0x00, /* 000000000000 */
5695 0x3f, 0xc0, /* 001111111100 */
5696 0x3f, 0xc0, /* 001111111100 */
5697 0x3f, 0xc0, /* 001111111100 */
5698 0x3f, 0xc0, /* 001111111100 */
5699 0x3f, 0xc0, /* 001111111100 */
5700 0x3f, 0xc0, /* 001111111100 */
5701 0x3f, 0xc0, /* 001111111100 */
5702 0x3f, 0xc0, /* 001111111100 */
5703 0x3f, 0xc0, /* 001111111100 */
5704 0x3f, 0xc0, /* 001111111100 */
5705 0x3f, 0xc0, /* 001111111100 */
5706 0x3f, 0xc0, /* 001111111100 */
5707 0x00, 0x00, /* 000000000000 */ 5665 0x00, 0x00, /* 000000000000 */
5708 0x00, 0x00, /* 000000000000 */ 5666 0x00, 0x00, /* 000000000000 */
5709 0x00, 0x00, /* 000000000000 */ 5667 0x00, 0x00, /* 000000000000 */
@@ -5711,99 +5669,95 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
5711 0x00, 0x00, /* 000000000000 */ 5669 0x00, 0x00, /* 000000000000 */
5712 5670
5713 /* 236 0xec '.' */ 5671 /* 236 0xec '.' */
5714 /* FIXME */
5715 0x00, 0x00, /* 000000000000 */ 5672 0x00, 0x00, /* 000000000000 */
5716 0x00, 0x00, /* 000000000000 */ 5673 0x00, 0x00, /* 000000000000 */
5717 0x00, 0x00, /* 000000000000 */ 5674 0x00, 0x00, /* 000000000000 */
5718 0x00, 0x00, /* 000000000000 */ 5675 0x00, 0x00, /* 000000000000 */
5719 0x00, 0x00, /* 000000000000 */ 5676 0x00, 0x00, /* 000000000000 */
5720 0x3f, 0xc0, /* 001111111100 */
5721 0x3f, 0xc0, /* 001111111100 */
5722 0x3f, 0xc0, /* 001111111100 */
5723 0x3f, 0xc0, /* 001111111100 */
5724 0x3f, 0xc0, /* 001111111100 */
5725 0x3f, 0xc0, /* 001111111100 */
5726 0x3f, 0xc0, /* 001111111100 */
5727 0x3f, 0xc0, /* 001111111100 */
5728 0x3f, 0xc0, /* 001111111100 */
5729 0x3f, 0xc0, /* 001111111100 */
5730 0x3f, 0xc0, /* 001111111100 */
5731 0x3f, 0xc0, /* 001111111100 */
5732 0x00, 0x00, /* 000000000000 */ 5677 0x00, 0x00, /* 000000000000 */
5733 0x00, 0x00, /* 000000000000 */ 5678 0x00, 0x00, /* 000000000000 */
5734 0x00, 0x00, /* 000000000000 */ 5679 0x00, 0x00, /* 000000000000 */
5680 0x39, 0xc0, /* 001110011100 */
5681 0x6f, 0x60, /* 011011110110 */
5682 0x66, 0x60, /* 011001100110 */
5683 0xc6, 0x30, /* 110001100011 */
5684 0xc6, 0x30, /* 110001100011 */
5685 0x66, 0x60, /* 011001100110 */
5686 0x6f, 0x60, /* 011011110110 */
5687 0x39, 0xc0, /* 001110011100 */
5735 0x00, 0x00, /* 000000000000 */ 5688 0x00, 0x00, /* 000000000000 */
5736 0x00, 0x00, /* 000000000000 */ 5689 0x00, 0x00, /* 000000000000 */
5737
5738 /* 237 0xed '.' */
5739 /* FIXME */
5740 0x00, 0x00, /* 000000000000 */ 5690 0x00, 0x00, /* 000000000000 */
5741 0x00, 0x00, /* 000000000000 */ 5691 0x00, 0x00, /* 000000000000 */
5742 0x00, 0x00, /* 000000000000 */ 5692 0x00, 0x00, /* 000000000000 */
5743 0x00, 0x00, /* 000000000000 */ 5693 0x00, 0x00, /* 000000000000 */
5694
5695 /* 237 0xed '.' */
5744 0x00, 0x00, /* 000000000000 */ 5696 0x00, 0x00, /* 000000000000 */
5745 0x3f, 0xc0, /* 001111111100 */
5746 0x3f, 0xc0, /* 001111111100 */
5747 0x3f, 0xc0, /* 001111111100 */
5748 0x3f, 0xc0, /* 001111111100 */
5749 0x3f, 0xc0, /* 001111111100 */
5750 0x3f, 0xc0, /* 001111111100 */
5751 0x3f, 0xc0, /* 001111111100 */
5752 0x3f, 0xc0, /* 001111111100 */
5753 0x3f, 0xc0, /* 001111111100 */
5754 0x3f, 0xc0, /* 001111111100 */
5755 0x3f, 0xc0, /* 001111111100 */
5756 0x3f, 0xc0, /* 001111111100 */
5757 0x00, 0x00, /* 000000000000 */ 5697 0x00, 0x00, /* 000000000000 */
5758 0x00, 0x00, /* 000000000000 */ 5698 0x00, 0x00, /* 000000000000 */
5759 0x00, 0x00, /* 000000000000 */ 5699 0x00, 0x00, /* 000000000000 */
5700 0x00, 0xc0, /* 000000001100 */
5701 0x00, 0xc0, /* 000000001100 */
5702 0x01, 0x80, /* 000000011000 */
5703 0x01, 0x80, /* 000000011000 */
5704 0x3b, 0xc0, /* 001110111100 */
5705 0x6f, 0x60, /* 011011110110 */
5706 0x66, 0x60, /* 011001100110 */
5707 0xc6, 0x30, /* 110001100011 */
5708 0xc6, 0x30, /* 110001100011 */
5709 0x66, 0x60, /* 011001100110 */
5710 0x6f, 0x60, /* 011011110110 */
5711 0x3d, 0xc0, /* 001111011100 */
5712 0x18, 0x00, /* 000110000000 */
5713 0x18, 0x00, /* 000110000000 */
5714 0x30, 0x00, /* 001100000000 */
5715 0x30, 0x00, /* 001100000000 */
5760 0x00, 0x00, /* 000000000000 */ 5716 0x00, 0x00, /* 000000000000 */
5761 0x00, 0x00, /* 000000000000 */ 5717 0x00, 0x00, /* 000000000000 */
5762 5718
5763 /* 238 0xee '.' */ 5719 /* 238 0xee '.' */
5764 /* FIXME */
5765 0x00, 0x00, /* 000000000000 */ 5720 0x00, 0x00, /* 000000000000 */
5721 0x01, 0xc0, /* 000000011100 */
5722 0x03, 0x00, /* 000000110000 */
5723 0x06, 0x00, /* 000001100000 */
5724 0x06, 0x00, /* 000001100000 */
5725 0x0c, 0x00, /* 000011000000 */
5726 0x0c, 0x00, /* 000011000000 */
5727 0x18, 0x00, /* 000110000000 */
5728 0x1f, 0xc0, /* 000111111100 */
5729 0x18, 0x00, /* 000110000000 */
5730 0x0c, 0x00, /* 000011000000 */
5731 0x0c, 0x00, /* 000011000000 */
5732 0x06, 0x00, /* 000001100000 */
5733 0x06, 0x00, /* 000001100000 */
5734 0x03, 0x00, /* 000000110000 */
5735 0x01, 0xc0, /* 000000011100 */
5766 0x00, 0x00, /* 000000000000 */ 5736 0x00, 0x00, /* 000000000000 */
5767 0x00, 0x00, /* 000000000000 */ 5737 0x00, 0x00, /* 000000000000 */
5768 0x00, 0x00, /* 000000000000 */ 5738 0x00, 0x00, /* 000000000000 */
5769 0x00, 0x00, /* 000000000000 */ 5739 0x00, 0x00, /* 000000000000 */
5770 0x3f, 0xc0, /* 001111111100 */
5771 0x3f, 0xc0, /* 001111111100 */
5772 0x3f, 0xc0, /* 001111111100 */
5773 0x3f, 0xc0, /* 001111111100 */
5774 0x3f, 0xc0, /* 001111111100 */
5775 0x3f, 0xc0, /* 001111111100 */
5776 0x3f, 0xc0, /* 001111111100 */
5777 0x3f, 0xc0, /* 001111111100 */
5778 0x3f, 0xc0, /* 001111111100 */
5779 0x3f, 0xc0, /* 001111111100 */
5780 0x3f, 0xc0, /* 001111111100 */
5781 0x3f, 0xc0, /* 001111111100 */
5782 0x00, 0x00, /* 000000000000 */
5783 0x00, 0x00, /* 000000000000 */
5784 0x00, 0x00, /* 000000000000 */
5785 0x00, 0x00, /* 000000000000 */ 5740 0x00, 0x00, /* 000000000000 */
5786 0x00, 0x00, /* 000000000000 */ 5741 0x00, 0x00, /* 000000000000 */
5787 5742
5788 /* 239 0xef '.' */ 5743 /* 239 0xef '.' */
5789 /* FIXME */
5790 0x00, 0x00, /* 000000000000 */ 5744 0x00, 0x00, /* 000000000000 */
5791 0x00, 0x00, /* 000000000000 */ 5745 0x00, 0x00, /* 000000000000 */
5792 0x00, 0x00, /* 000000000000 */ 5746 0x00, 0x00, /* 000000000000 */
5793 0x00, 0x00, /* 000000000000 */ 5747 0x00, 0x00, /* 000000000000 */
5794 0x00, 0x00, /* 000000000000 */ 5748 0x00, 0x00, /* 000000000000 */
5795 0x3f, 0xc0, /* 001111111100 */ 5749 0x0f, 0x00, /* 000011110000 */
5796 0x3f, 0xc0, /* 001111111100 */ 5750 0x1f, 0x80, /* 000111111000 */
5797 0x3f, 0xc0, /* 001111111100 */ 5751 0x39, 0xc0, /* 001110011100 */
5798 0x3f, 0xc0, /* 001111111100 */ 5752 0x30, 0xc0, /* 001100001100 */
5799 0x3f, 0xc0, /* 001111111100 */ 5753 0x30, 0xc0, /* 001100001100 */
5800 0x3f, 0xc0, /* 001111111100 */ 5754 0x30, 0xc0, /* 001100001100 */
5801 0x3f, 0xc0, /* 001111111100 */ 5755 0x30, 0xc0, /* 001100001100 */
5802 0x3f, 0xc0, /* 001111111100 */ 5756 0x30, 0xc0, /* 001100001100 */
5803 0x3f, 0xc0, /* 001111111100 */ 5757 0x30, 0xc0, /* 001100001100 */
5804 0x3f, 0xc0, /* 001111111100 */ 5758 0x30, 0xc0, /* 001100001100 */
5805 0x3f, 0xc0, /* 001111111100 */ 5759 0x30, 0xc0, /* 001100001100 */
5806 0x3f, 0xc0, /* 001111111100 */ 5760 0x30, 0xc0, /* 001100001100 */
5807 0x00, 0x00, /* 000000000000 */ 5761 0x00, 0x00, /* 000000000000 */
5808 0x00, 0x00, /* 000000000000 */ 5762 0x00, 0x00, /* 000000000000 */
5809 0x00, 0x00, /* 000000000000 */ 5763 0x00, 0x00, /* 000000000000 */
@@ -5811,24 +5765,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
5811 0x00, 0x00, /* 000000000000 */ 5765 0x00, 0x00, /* 000000000000 */
5812 5766
5813 /* 240 0xf0 '.' */ 5767 /* 240 0xf0 '.' */
5814 /* FIXME */
5815 0x00, 0x00, /* 000000000000 */ 5768 0x00, 0x00, /* 000000000000 */
5816 0x00, 0x00, /* 000000000000 */ 5769 0x00, 0x00, /* 000000000000 */
5817 0x00, 0x00, /* 000000000000 */ 5770 0x00, 0x00, /* 000000000000 */
5818 0x00, 0x00, /* 000000000000 */ 5771 0x00, 0x00, /* 000000000000 */
5819 0x00, 0x00, /* 000000000000 */ 5772 0x00, 0x00, /* 000000000000 */
5820 0x3f, 0xc0, /* 001111111100 */ 5773 0x7f, 0xe0, /* 011111111110 */
5821 0x3f, 0xc0, /* 001111111100 */ 5774 0x7f, 0xe0, /* 011111111110 */
5822 0x3f, 0xc0, /* 001111111100 */ 5775 0x00, 0x00, /* 000000000000 */
5823 0x3f, 0xc0, /* 001111111100 */ 5776 0x00, 0x00, /* 000000000000 */
5824 0x3f, 0xc0, /* 001111111100 */ 5777 0x00, 0x00, /* 000000000000 */
5825 0x3f, 0xc0, /* 001111111100 */ 5778 0x7f, 0xe0, /* 011111111110 */
5826 0x3f, 0xc0, /* 001111111100 */ 5779 0x7f, 0xe0, /* 011111111110 */
5827 0x3f, 0xc0, /* 001111111100 */ 5780 0x00, 0x00, /* 000000000000 */
5828 0x3f, 0xc0, /* 001111111100 */ 5781 0x00, 0x00, /* 000000000000 */
5829 0x3f, 0xc0, /* 001111111100 */ 5782 0x00, 0x00, /* 000000000000 */
5830 0x3f, 0xc0, /* 001111111100 */ 5783 0x7f, 0xe0, /* 011111111110 */
5831 0x3f, 0xc0, /* 001111111100 */ 5784 0x7f, 0xe0, /* 011111111110 */
5832 0x00, 0x00, /* 000000000000 */ 5785 0x00, 0x00, /* 000000000000 */
5833 0x00, 0x00, /* 000000000000 */ 5786 0x00, 0x00, /* 000000000000 */
5834 0x00, 0x00, /* 000000000000 */ 5787 0x00, 0x00, /* 000000000000 */
@@ -5860,24 +5813,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
5860 0x00, 0x00, /* 000000000000 */ 5813 0x00, 0x00, /* 000000000000 */
5861 5814
5862 /* 242 0xf2 '.' */ 5815 /* 242 0xf2 '.' */
5863 /* FIXME */
5864 0x00, 0x00, /* 000000000000 */ 5816 0x00, 0x00, /* 000000000000 */
5865 0x00, 0x00, /* 000000000000 */ 5817 0x00, 0x00, /* 000000000000 */
5866 0x00, 0x00, /* 000000000000 */ 5818 0x00, 0x00, /* 000000000000 */
5867 0x00, 0x00, /* 000000000000 */ 5819 0x00, 0x00, /* 000000000000 */
5820 0x60, 0x00, /* 011000000000 */
5821 0x38, 0x00, /* 001110000000 */
5822 0x0e, 0x00, /* 000011100000 */
5823 0x03, 0x80, /* 000000111000 */
5824 0x00, 0xe0, /* 000000001110 */
5825 0x00, 0xe0, /* 000000001110 */
5826 0x03, 0x80, /* 000000111000 */
5827 0x0e, 0x00, /* 000011100000 */
5828 0x38, 0x00, /* 001110000000 */
5829 0x60, 0x00, /* 011000000000 */
5868 0x00, 0x00, /* 000000000000 */ 5830 0x00, 0x00, /* 000000000000 */
5869 0x3f, 0xc0, /* 001111111100 */ 5831 0x7f, 0xe0, /* 011111111110 */
5870 0x3f, 0xc0, /* 001111111100 */ 5832 0x7f, 0xe0, /* 011111111110 */
5871 0x3f, 0xc0, /* 001111111100 */
5872 0x3f, 0xc0, /* 001111111100 */
5873 0x3f, 0xc0, /* 001111111100 */
5874 0x3f, 0xc0, /* 001111111100 */
5875 0x3f, 0xc0, /* 001111111100 */
5876 0x3f, 0xc0, /* 001111111100 */
5877 0x3f, 0xc0, /* 001111111100 */
5878 0x3f, 0xc0, /* 001111111100 */
5879 0x3f, 0xc0, /* 001111111100 */
5880 0x3f, 0xc0, /* 001111111100 */
5881 0x00, 0x00, /* 000000000000 */ 5833 0x00, 0x00, /* 000000000000 */
5882 0x00, 0x00, /* 000000000000 */ 5834 0x00, 0x00, /* 000000000000 */
5883 0x00, 0x00, /* 000000000000 */ 5835 0x00, 0x00, /* 000000000000 */
@@ -5885,24 +5837,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
5885 0x00, 0x00, /* 000000000000 */ 5837 0x00, 0x00, /* 000000000000 */
5886 5838
5887 /* 243 0xf3 '.' */ 5839 /* 243 0xf3 '.' */
5888 /* FIXME */
5889 0x00, 0x00, /* 000000000000 */ 5840 0x00, 0x00, /* 000000000000 */
5890 0x00, 0x00, /* 000000000000 */ 5841 0x00, 0x00, /* 000000000000 */
5891 0x00, 0x00, /* 000000000000 */ 5842 0x00, 0x00, /* 000000000000 */
5843 0x00, 0x60, /* 000000000110 */
5844 0x01, 0xc0, /* 000000011100 */
5845 0x07, 0x00, /* 000001110000 */
5846 0x1c, 0x00, /* 000111000000 */
5847 0x70, 0x00, /* 011100000000 */
5848 0x70, 0x00, /* 011100000000 */
5849 0x1c, 0x00, /* 000111000000 */
5850 0x07, 0x00, /* 000001110000 */
5851 0x01, 0xc0, /* 000000011100 */
5852 0x00, 0x60, /* 000000000110 */
5892 0x00, 0x00, /* 000000000000 */ 5853 0x00, 0x00, /* 000000000000 */
5854 0x7f, 0xe0, /* 011111111110 */
5855 0x7f, 0xe0, /* 011111111110 */
5893 0x00, 0x00, /* 000000000000 */ 5856 0x00, 0x00, /* 000000000000 */
5894 0x3f, 0xc0, /* 001111111100 */
5895 0x3f, 0xc0, /* 001111111100 */
5896 0x3f, 0xc0, /* 001111111100 */
5897 0x3f, 0xc0, /* 001111111100 */
5898 0x3f, 0xc0, /* 001111111100 */
5899 0x3f, 0xc0, /* 001111111100 */
5900 0x3f, 0xc0, /* 001111111100 */
5901 0x3f, 0xc0, /* 001111111100 */
5902 0x3f, 0xc0, /* 001111111100 */
5903 0x3f, 0xc0, /* 001111111100 */
5904 0x3f, 0xc0, /* 001111111100 */
5905 0x3f, 0xc0, /* 001111111100 */
5906 0x00, 0x00, /* 000000000000 */ 5857 0x00, 0x00, /* 000000000000 */
5907 0x00, 0x00, /* 000000000000 */ 5858 0x00, 0x00, /* 000000000000 */
5908 0x00, 0x00, /* 000000000000 */ 5859 0x00, 0x00, /* 000000000000 */
@@ -5910,54 +5861,52 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
5910 0x00, 0x00, /* 000000000000 */ 5861 0x00, 0x00, /* 000000000000 */
5911 5862
5912 /* 244 0xf4 '.' */ 5863 /* 244 0xf4 '.' */
5913 /* FIXME */
5914 0x00, 0x00, /* 000000000000 */
5915 0x00, 0x00, /* 000000000000 */
5916 0x00, 0x00, /* 000000000000 */
5917 0x00, 0x00, /* 000000000000 */
5918 0x00, 0x00, /* 000000000000 */
5919 0x3f, 0xc0, /* 001111111100 */
5920 0x3f, 0xc0, /* 001111111100 */
5921 0x3f, 0xc0, /* 001111111100 */
5922 0x3f, 0xc0, /* 001111111100 */
5923 0x3f, 0xc0, /* 001111111100 */
5924 0x3f, 0xc0, /* 001111111100 */
5925 0x3f, 0xc0, /* 001111111100 */
5926 0x3f, 0xc0, /* 001111111100 */
5927 0x3f, 0xc0, /* 001111111100 */
5928 0x3f, 0xc0, /* 001111111100 */
5929 0x3f, 0xc0, /* 001111111100 */
5930 0x3f, 0xc0, /* 001111111100 */
5931 0x00, 0x00, /* 000000000000 */
5932 0x00, 0x00, /* 000000000000 */
5933 0x00, 0x00, /* 000000000000 */
5934 0x00, 0x00, /* 000000000000 */
5935 0x00, 0x00, /* 000000000000 */ 5864 0x00, 0x00, /* 000000000000 */
5865 0x03, 0x80, /* 000000111000 */
5866 0x07, 0xc0, /* 000001111100 */
5867 0x0c, 0x60, /* 000011000110 */
5868 0x0c, 0x60, /* 000011000110 */
5869 0x0c, 0x00, /* 000011000000 */
5870 0x0c, 0x00, /* 000011000000 */
5871 0x0c, 0x00, /* 000011000000 */
5872 0x0c, 0x00, /* 000011000000 */
5873 0x0c, 0x00, /* 000011000000 */
5874 0x0c, 0x00, /* 000011000000 */
5875 0x0c, 0x00, /* 000011000000 */
5876 0x0c, 0x00, /* 000011000000 */
5877 0x0c, 0x00, /* 000011000000 */
5878 0x0c, 0x00, /* 000011000000 */
5879 0x0c, 0x00, /* 000011000000 */
5880 0x0c, 0x00, /* 000011000000 */
5881 0x0c, 0x00, /* 000011000000 */
5882 0x0c, 0x00, /* 000011000000 */
5883 0x0c, 0x00, /* 000011000000 */
5884 0x0c, 0x00, /* 000011000000 */
5885 0x0c, 0x00, /* 000011000000 */
5936 5886
5937 /* 245 0xf5 '.' */ 5887 /* 245 0xf5 '.' */
5938 /* FIXME */
5939 0x00, 0x00, /* 000000000000 */
5940 0x00, 0x00, /* 000000000000 */
5941 0x00, 0x00, /* 000000000000 */
5942 0x00, 0x00, /* 000000000000 */
5943 0x00, 0x00, /* 000000000000 */
5944 0x3f, 0xc0, /* 001111111100 */
5945 0x3f, 0xc0, /* 001111111100 */
5946 0x3f, 0xc0, /* 001111111100 */
5947 0x3f, 0xc0, /* 001111111100 */
5948 0x3f, 0xc0, /* 001111111100 */
5949 0x3f, 0xc0, /* 001111111100 */
5950 0x3f, 0xc0, /* 001111111100 */
5951 0x3f, 0xc0, /* 001111111100 */
5952 0x3f, 0xc0, /* 001111111100 */
5953 0x3f, 0xc0, /* 001111111100 */
5954 0x3f, 0xc0, /* 001111111100 */
5955 0x3f, 0xc0, /* 001111111100 */
5956 0x00, 0x00, /* 000000000000 */
5957 0x00, 0x00, /* 000000000000 */
5958 0x00, 0x00, /* 000000000000 */
5959 0x00, 0x00, /* 000000000000 */
5960 0x00, 0x00, /* 000000000000 */ 5888 0x00, 0x00, /* 000000000000 */
5889 0x1c, 0x00, /* 000111000000 */
5890 0x3e, 0x00, /* 001111100000 */
5891 0x63, 0x00, /* 011000110000 */
5892 0x63, 0x00, /* 011000110000 */
5893 0x03, 0x00, /* 000000110000 */
5894 0x03, 0x00, /* 000000110000 */
5895 0x03, 0x00, /* 000000110000 */
5896 0x03, 0x00, /* 000000110000 */
5897 0x03, 0x00, /* 000000110000 */
5898 0x03, 0x00, /* 000000110000 */
5899 0x03, 0x00, /* 000000110000 */
5900 0x03, 0x00, /* 000000110000 */
5901 0x03, 0x00, /* 000000110000 */
5902 0x03, 0x00, /* 000000110000 */
5903 0x03, 0x00, /* 000000110000 */
5904 0x03, 0x00, /* 000000110000 */
5905 0x03, 0x00, /* 000000110000 */
5906 0x03, 0x00, /* 000000110000 */
5907 0x03, 0x00, /* 000000110000 */
5908 0x03, 0x00, /* 000000110000 */
5909 0x03, 0x00, /* 000000110000 */
5961 5910
5962 /* 246 0xf6 '.' */ 5911 /* 246 0xf6 '.' */
5963 0x00, 0x00, /* 000000000000 */ 5912 0x00, 0x00, /* 000000000000 */
@@ -5984,24 +5933,23 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
5984 0x00, 0x00, /* 000000000000 */ 5933 0x00, 0x00, /* 000000000000 */
5985 5934
5986 /* 247 0xf7 '.' */ 5935 /* 247 0xf7 '.' */
5987 /* FIXME */
5988 0x00, 0x00, /* 000000000000 */ 5936 0x00, 0x00, /* 000000000000 */
5989 0x00, 0x00, /* 000000000000 */ 5937 0x00, 0x00, /* 000000000000 */
5990 0x00, 0x00, /* 000000000000 */ 5938 0x00, 0x00, /* 000000000000 */
5991 0x00, 0x00, /* 000000000000 */ 5939 0x00, 0x00, /* 000000000000 */
5992 0x00, 0x00, /* 000000000000 */ 5940 0x00, 0x00, /* 000000000000 */
5993 0x3f, 0xc0, /* 001111111100 */ 5941 0x00, 0x00, /* 000000000000 */
5994 0x3f, 0xc0, /* 001111111100 */ 5942 0x00, 0x00, /* 000000000000 */
5995 0x3f, 0xc0, /* 001111111100 */ 5943 0x38, 0x00, /* 001110000000 */
5996 0x3f, 0xc0, /* 001111111100 */ 5944 0x6c, 0x00, /* 011011000000 */
5997 0x3f, 0xc0, /* 001111111100 */ 5945 0x06, 0x30, /* 000001100011 */
5998 0x3f, 0xc0, /* 001111111100 */ 5946 0x03, 0x60, /* 000000110110 */
5999 0x3f, 0xc0, /* 001111111100 */ 5947 0x39, 0xc0, /* 001110011100 */
6000 0x3f, 0xc0, /* 001111111100 */ 5948 0x6c, 0x00, /* 011011000000 */
6001 0x3f, 0xc0, /* 001111111100 */ 5949 0x06, 0x30, /* 000001100011 */
6002 0x3f, 0xc0, /* 001111111100 */ 5950 0x03, 0x60, /* 000000110110 */
6003 0x3f, 0xc0, /* 001111111100 */ 5951 0x01, 0xc0, /* 000000011100 */
6004 0x3f, 0xc0, /* 001111111100 */ 5952 0x00, 0x00, /* 000000000000 */
6005 0x00, 0x00, /* 000000000000 */ 5953 0x00, 0x00, /* 000000000000 */
6006 0x00, 0x00, /* 000000000000 */ 5954 0x00, 0x00, /* 000000000000 */
6007 0x00, 0x00, /* 000000000000 */ 5955 0x00, 0x00, /* 000000000000 */
@@ -6033,44 +5981,31 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
6033 0x00, 0x00, /* 000000000000 */ 5981 0x00, 0x00, /* 000000000000 */
6034 5982
6035 /* 249 0xf9 '.' */ 5983 /* 249 0xf9 '.' */
6036 /* FIXME */
6037 0x00, 0x00, /* 000000000000 */ 5984 0x00, 0x00, /* 000000000000 */
6038 0x00, 0x00, /* 000000000000 */ 5985 0x00, 0x00, /* 000000000000 */
6039 0x00, 0x00, /* 000000000000 */ 5986 0x00, 0x00, /* 000000000000 */
6040 0x00, 0x00, /* 000000000000 */ 5987 0x00, 0x00, /* 000000000000 */
6041 0x00, 0x00, /* 000000000000 */ 5988 0x00, 0x00, /* 000000000000 */
6042 0x3f, 0xc0, /* 001111111100 */
6043 0x3f, 0xc0, /* 001111111100 */
6044 0x3f, 0xc0, /* 001111111100 */
6045 0x3f, 0xc0, /* 001111111100 */
6046 0x3f, 0xc0, /* 001111111100 */
6047 0x3f, 0xc0, /* 001111111100 */
6048 0x3f, 0xc0, /* 001111111100 */
6049 0x3f, 0xc0, /* 001111111100 */
6050 0x3f, 0xc0, /* 001111111100 */
6051 0x3f, 0xc0, /* 001111111100 */
6052 0x3f, 0xc0, /* 001111111100 */
6053 0x3f, 0xc0, /* 001111111100 */
6054 0x00, 0x00, /* 000000000000 */ 5989 0x00, 0x00, /* 000000000000 */
6055 0x00, 0x00, /* 000000000000 */ 5990 0x00, 0x00, /* 000000000000 */
6056 0x00, 0x00, /* 000000000000 */ 5991 0x00, 0x00, /* 000000000000 */
6057 0x00, 0x00, /* 000000000000 */ 5992 0x00, 0x00, /* 000000000000 */
6058 0x00, 0x00, /* 000000000000 */ 5993 0x00, 0x00, /* 000000000000 */
6059
6060 /* 250 0xfa '.' */
6061 0x00, 0x00, /* 000000000000 */
6062 0x00, 0x00, /* 000000000000 */ 5994 0x00, 0x00, /* 000000000000 */
5995 0x1c, 0x00, /* 000111000000 */
5996 0x3e, 0x00, /* 001111100000 */
5997 0x3e, 0x00, /* 001111100000 */
5998 0x3e, 0x00, /* 001111100000 */
5999 0x1c, 0x00, /* 000111000000 */
6063 0x00, 0x00, /* 000000000000 */ 6000 0x00, 0x00, /* 000000000000 */
6064 0x00, 0x00, /* 000000000000 */ 6001 0x00, 0x00, /* 000000000000 */
6065 0x00, 0x00, /* 000000000000 */ 6002 0x00, 0x00, /* 000000000000 */
6066 0x00, 0x00, /* 000000000000 */ 6003 0x00, 0x00, /* 000000000000 */
6067 0x00, 0x00, /* 000000000000 */ 6004 0x00, 0x00, /* 000000000000 */
6068 0x00, 0x00, /* 000000000000 */ 6005 0x00, 0x00, /* 000000000000 */
6006
6007 /* 250 0xfa '.' */
6069 0x00, 0x00, /* 000000000000 */ 6008 0x00, 0x00, /* 000000000000 */
6070 0x06, 0x00, /* 000001100000 */
6071 0x0f, 0x00, /* 000011110000 */
6072 0x0f, 0x00, /* 000011110000 */
6073 0x06, 0x00, /* 000001100000 */
6074 0x00, 0x00, /* 000000000000 */ 6009 0x00, 0x00, /* 000000000000 */
6075 0x00, 0x00, /* 000000000000 */ 6010 0x00, 0x00, /* 000000000000 */
6076 0x00, 0x00, /* 000000000000 */ 6011 0x00, 0x00, /* 000000000000 */
@@ -6080,51 +6015,61 @@ static unsigned char fontdata_sun12x22[FONTDATAMAX] = {
6080 0x00, 0x00, /* 000000000000 */ 6015 0x00, 0x00, /* 000000000000 */
6081 0x00, 0x00, /* 000000000000 */ 6016 0x00, 0x00, /* 000000000000 */
6082 0x00, 0x00, /* 000000000000 */ 6017 0x00, 0x00, /* 000000000000 */
6083
6084 /* 251 0xfb '.' */
6085 /* FIXME */
6086 0x00, 0x00, /* 000000000000 */ 6018 0x00, 0x00, /* 000000000000 */
6087 0x00, 0x00, /* 000000000000 */ 6019 0x00, 0x00, /* 000000000000 */
6020 0x18, 0x00, /* 000110000000 */
6021 0x3c, 0x00, /* 001111000000 */
6022 0x3c, 0x00, /* 001111000000 */
6023 0x18, 0x00, /* 000110000000 */
6088 0x00, 0x00, /* 000000000000 */ 6024 0x00, 0x00, /* 000000000000 */
6089 0x00, 0x00, /* 000000000000 */ 6025 0x00, 0x00, /* 000000000000 */
6090 0x00, 0x00, /* 000000000000 */ 6026 0x00, 0x00, /* 000000000000 */
6091 0x3f, 0xc0, /* 001111111100 */
6092 0x3f, 0xc0, /* 001111111100 */
6093 0x3f, 0xc0, /* 001111111100 */
6094 0x3f, 0xc0, /* 001111111100 */
6095 0x3f, 0xc0, /* 001111111100 */
6096 0x3f, 0xc0, /* 001111111100 */
6097 0x3f, 0xc0, /* 001111111100 */
6098 0x3f, 0xc0, /* 001111111100 */
6099 0x3f, 0xc0, /* 001111111100 */
6100 0x3f, 0xc0, /* 001111111100 */
6101 0x3f, 0xc0, /* 001111111100 */
6102 0x3f, 0xc0, /* 001111111100 */
6103 0x00, 0x00, /* 000000000000 */ 6027 0x00, 0x00, /* 000000000000 */
6104 0x00, 0x00, /* 000000000000 */ 6028 0x00, 0x00, /* 000000000000 */
6105 0x00, 0x00, /* 000000000000 */ 6029 0x00, 0x00, /* 000000000000 */
6030
6031 /* 251 0xfb '.' */
6106 0x00, 0x00, /* 000000000000 */ 6032 0x00, 0x00, /* 000000000000 */
6033 0x07, 0xe0, /* 000001111110 */
6034 0x06, 0x00, /* 000001100000 */
6035 0x06, 0x00, /* 000001100000 */
6036 0x06, 0x00, /* 000001100000 */
6037 0x06, 0x00, /* 000001100000 */
6038 0x06, 0x00, /* 000001100000 */
6039 0x06, 0x00, /* 000001100000 */
6040 0x06, 0x00, /* 000001100000 */
6041 0x06, 0x00, /* 000001100000 */
6042 0x06, 0x00, /* 000001100000 */
6043 0x06, 0x00, /* 000001100000 */
6044 0x06, 0x00, /* 000001100000 */
6045 0x06, 0x00, /* 000001100000 */
6046 0xc6, 0x00, /* 110001100000 */
6047 0x66, 0x00, /* 011001100000 */
6048 0x36, 0x00, /* 001101100000 */
6049 0x1e, 0x00, /* 000111100000 */
6050 0x0e, 0x00, /* 000011100000 */
6051 0x06, 0x00, /* 000001100000 */
6052 0x02, 0x00, /* 000000100000 */
6107 0x00, 0x00, /* 000000000000 */ 6053 0x00, 0x00, /* 000000000000 */
6108 6054
6109 /* 252 0xfc '.' */ 6055 /* 252 0xfc '.' */
6110 /* FIXME */ 6056 0x00, 0x00, /* 000000000000 */
6057 0x00, 0x00, /* 000000000000 */
6058 0x13, 0x80, /* 000100111000 */
6059 0x3d, 0xc0, /* 001111011100 */
6060 0x18, 0xc0, /* 000110001100 */
6061 0x18, 0xc0, /* 000110001100 */
6062 0x18, 0xc0, /* 000110001100 */
6063 0x18, 0xc0, /* 000110001100 */
6064 0x3d, 0xe0, /* 001111011110 */
6065 0x00, 0x00, /* 000000000000 */
6066 0x00, 0x00, /* 000000000000 */
6067 0x00, 0x00, /* 000000000000 */
6111 0x00, 0x00, /* 000000000000 */ 6068 0x00, 0x00, /* 000000000000 */
6112 0x00, 0x00, /* 000000000000 */ 6069 0x00, 0x00, /* 000000000000 */
6113 0x00, 0x00, /* 000000000000 */ 6070 0x00, 0x00, /* 000000000000 */
6114 0x00, 0x00, /* 000000000000 */ 6071 0x00, 0x00, /* 000000000000 */
6115 0x00, 0x00, /* 000000000000 */ 6072 0x00, 0x00, /* 000000000000 */
6116 0x3f, 0xc0, /* 001111111100 */
6117 0x3f, 0xc0, /* 001111111100 */
6118 0x3f, 0xc0, /* 001111111100 */
6119 0x3f, 0xc0, /* 001111111100 */
6120 0x3f, 0xc0, /* 001111111100 */
6121 0x3f, 0xc0, /* 001111111100 */
6122 0x3f, 0xc0, /* 001111111100 */
6123 0x3f, 0xc0, /* 001111111100 */
6124 0x3f, 0xc0, /* 001111111100 */
6125 0x3f, 0xc0, /* 001111111100 */
6126 0x3f, 0xc0, /* 001111111100 */
6127 0x3f, 0xc0, /* 001111111100 */
6128 0x00, 0x00, /* 000000000000 */ 6073 0x00, 0x00, /* 000000000000 */
6129 0x00, 0x00, /* 000000000000 */ 6074 0x00, 0x00, /* 000000000000 */
6130 0x00, 0x00, /* 000000000000 */ 6075 0x00, 0x00, /* 000000000000 */
diff --git a/drivers/video/console/fonts.c b/drivers/video/console/fonts.c
index 465d678230ae..e79b29702649 100644
--- a/drivers/video/console/fonts.c
+++ b/drivers/video/console/fonts.c
@@ -36,6 +36,10 @@ static struct font_desc *fonts[] = {
36#undef NO_FONTS 36#undef NO_FONTS
37 &font_vga_6x11, 37 &font_vga_6x11,
38#endif 38#endif
39#ifdef CONFIG_FONT_7x14
40#undef NO_FONTS
41 &font_7x14,
42#endif
39#ifdef CONFIG_FONT_SUN8x16 43#ifdef CONFIG_FONT_SUN8x16
40#undef NO_FONTS 44#undef NO_FONTS
41 &font_sun_8x16, 45 &font_sun_8x16,
@@ -44,6 +48,10 @@ static struct font_desc *fonts[] = {
44#undef NO_FONTS 48#undef NO_FONTS
45 &font_sun_12x22, 49 &font_sun_12x22,
46#endif 50#endif
51#ifdef CONFIG_FONT_10x18
52#undef NO_FONTS
53 &font_10x18,
54#endif
47#ifdef CONFIG_FONT_ACORN_8x8 55#ifdef CONFIG_FONT_ACORN_8x8
48#undef NO_FONTS 56#undef NO_FONTS
49 &font_acorn_8x8, 57 &font_acorn_8x8,
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index bcf59b28a14f..d27fa91e5886 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -95,6 +95,7 @@ static unsigned long vgacon_uni_pagedir[2];
95/* Description of the hardware situation */ 95/* Description of the hardware situation */
96static unsigned long vga_vram_base; /* Base of video memory */ 96static unsigned long vga_vram_base; /* Base of video memory */
97static unsigned long vga_vram_end; /* End of video memory */ 97static unsigned long vga_vram_end; /* End of video memory */
98static int vga_vram_size; /* Size of video memory */
98static u16 vga_video_port_reg; /* Video register select port */ 99static u16 vga_video_port_reg; /* Video register select port */
99static u16 vga_video_port_val; /* Video register value port */ 100static u16 vga_video_port_val; /* Video register value port */
100static unsigned int vga_video_num_columns; /* Number of text columns */ 101static unsigned int vga_video_num_columns; /* Number of text columns */
@@ -288,6 +289,7 @@ static const char __init *vgacon_startup(void)
288 289
289 vga_vram_base = VGA_MAP_MEM(vga_vram_base); 290 vga_vram_base = VGA_MAP_MEM(vga_vram_base);
290 vga_vram_end = VGA_MAP_MEM(vga_vram_end); 291 vga_vram_end = VGA_MAP_MEM(vga_vram_end);
292 vga_vram_size = vga_vram_end - vga_vram_base;
291 293
292 /* 294 /*
293 * Find out if there is a graphics card present. 295 * Find out if there is a graphics card present.
@@ -504,9 +506,13 @@ static int vgacon_switch(struct vc_data *c)
504 */ 506 */
505 vga_video_num_columns = c->vc_cols; 507 vga_video_num_columns = c->vc_cols;
506 vga_video_num_lines = c->vc_rows; 508 vga_video_num_lines = c->vc_rows;
509
510 /* We can only copy out the size of the video buffer here,
511 * otherwise we get into VGA BIOS */
512
507 if (!vga_is_gfx) 513 if (!vga_is_gfx)
508 scr_memcpyw((u16 *) c->vc_origin, (u16 *) c->vc_screenbuf, 514 scr_memcpyw((u16 *) c->vc_origin, (u16 *) c->vc_screenbuf,
509 c->vc_screenbuf_size); 515 c->vc_screenbuf_size > vga_vram_size ? vga_vram_size : c->vc_screenbuf_size);
510 return 0; /* Redrawing not needed */ 516 return 0; /* Redrawing not needed */
511} 517}
512 518
@@ -961,7 +967,6 @@ static int vgacon_scrolldelta(struct vc_data *c, int lines)
961 if (!lines) /* Turn scrollback off */ 967 if (!lines) /* Turn scrollback off */
962 c->vc_visible_origin = c->vc_origin; 968 c->vc_visible_origin = c->vc_origin;
963 else { 969 else {
964 int vram_size = vga_vram_end - vga_vram_base;
965 int margin = c->vc_size_row * 4; 970 int margin = c->vc_size_row * 4;
966 int ul, we, p, st; 971 int ul, we, p, st;
967 972
@@ -971,7 +976,7 @@ static int vgacon_scrolldelta(struct vc_data *c, int lines)
971 we = vga_rolled_over + c->vc_size_row; 976 we = vga_rolled_over + c->vc_size_row;
972 } else { 977 } else {
973 ul = 0; 978 ul = 0;
974 we = vram_size; 979 we = vga_vram_size;
975 } 980 }
976 p = (c->vc_visible_origin - vga_vram_base - ul + we) % we + 981 p = (c->vc_visible_origin - vga_vram_base - ul + we) % we +
977 lines * c->vc_size_row; 982 lines * c->vc_size_row;
@@ -1012,9 +1017,13 @@ static void vgacon_save_screen(struct vc_data *c)
1012 c->vc_x = ORIG_X; 1017 c->vc_x = ORIG_X;
1013 c->vc_y = ORIG_Y; 1018 c->vc_y = ORIG_Y;
1014 } 1019 }
1020
1021 /* We can't copy in more then the size of the video buffer,
1022 * or we'll be copying in VGA BIOS */
1023
1015 if (!vga_is_gfx) 1024 if (!vga_is_gfx)
1016 scr_memcpyw((u16 *) c->vc_screenbuf, (u16 *) c->vc_origin, 1025 scr_memcpyw((u16 *) c->vc_screenbuf, (u16 *) c->vc_origin,
1017 c->vc_screenbuf_size); 1026 c->vc_screenbuf_size > vga_vram_size ? vga_vram_size : c->vc_screenbuf_size);
1018} 1027}
1019 1028
1020static int vgacon_scroll(struct vc_data *c, int t, int b, int dir, 1029static int vgacon_scroll(struct vc_data *c, int t, int b, int dir,
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 8cef020d1801..2222de6ad844 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -76,70 +76,22 @@ int fb_get_color_depth(struct fb_var_screeninfo *var)
76EXPORT_SYMBOL(fb_get_color_depth); 76EXPORT_SYMBOL(fb_get_color_depth);
77 77
78/* 78/*
79 * Drawing helpers. 79 * Data padding functions.
80 */ 80 */
81void fb_iomove_buf_aligned(struct fb_info *info, struct fb_pixmap *buf, 81void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u32 height)
82 u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch,
83 u32 height)
84{ 82{
85 int i; 83 int i;
86 84
87 for (i = height; i--; ) { 85 for (i = height; i--; ) {
88 buf->outbuf(info, dst, src, s_pitch); 86 memcpy(dst, src, s_pitch);
89 src += s_pitch; 87 src += s_pitch;
90 dst += d_pitch; 88 dst += d_pitch;
91 } 89 }
92} 90}
91EXPORT_SYMBOL(fb_pad_aligned_buffer);
93 92
94void fb_sysmove_buf_aligned(struct fb_info *info, struct fb_pixmap *buf, 93void fb_pad_unaligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 idx, u32 height,
95 u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, 94 u32 shift_high, u32 shift_low, u32 mod)
96 u32 height)
97{
98 int i, j;
99
100 for (i = height; i--; ) {
101 for (j = 0; j < s_pitch; j++)
102 dst[j] = src[j];
103 src += s_pitch;
104 dst += d_pitch;
105 }
106}
107
108void fb_iomove_buf_unaligned(struct fb_info *info, struct fb_pixmap *buf,
109 u8 *dst, u32 d_pitch, u8 *src, u32 idx,
110 u32 height, u32 shift_high, u32 shift_low,
111 u32 mod)
112{
113 u8 mask = (u8) (0xfff << shift_high), tmp;
114 int i, j;
115
116 for (i = height; i--; ) {
117 for (j = 0; j < idx; j++) {
118 tmp = buf->inbuf(info, dst+j);
119 tmp &= mask;
120 tmp |= *src >> shift_low;
121 buf->outbuf(info, dst+j, &tmp, 1);
122 tmp = *src << shift_high;
123 buf->outbuf(info, dst+j+1, &tmp, 1);
124 src++;
125 }
126 tmp = buf->inbuf(info, dst+idx);
127 tmp &= mask;
128 tmp |= *src >> shift_low;
129 buf->outbuf(info, dst+idx, &tmp, 1);
130 if (shift_high < mod) {
131 tmp = *src << shift_high;
132 buf->outbuf(info, dst+idx+1, &tmp, 1);
133 }
134 src++;
135 dst += d_pitch;
136 }
137}
138
139void fb_sysmove_buf_unaligned(struct fb_info *info, struct fb_pixmap *buf,
140 u8 *dst, u32 d_pitch, u8 *src, u32 idx,
141 u32 height, u32 shift_high, u32 shift_low,
142 u32 mod)
143{ 95{
144 u8 mask = (u8) (0xfff << shift_high), tmp; 96 u8 mask = (u8) (0xfff << shift_high), tmp;
145 int i, j; 97 int i, j;
@@ -166,6 +118,7 @@ void fb_sysmove_buf_unaligned(struct fb_info *info, struct fb_pixmap *buf,
166 dst += d_pitch; 118 dst += d_pitch;
167 } 119 }
168} 120}
121EXPORT_SYMBOL(fb_pad_unaligned_buffer);
169 122
170/* 123/*
171 * we need to lock this section since fb_cursor 124 * we need to lock this section since fb_cursor
@@ -1081,7 +1034,7 @@ register_framebuffer(struct fb_info *fb_info)
1081 fb_info->pixmap.size = FBPIXMAPSIZE; 1034 fb_info->pixmap.size = FBPIXMAPSIZE;
1082 fb_info->pixmap.buf_align = 1; 1035 fb_info->pixmap.buf_align = 1;
1083 fb_info->pixmap.scan_align = 1; 1036 fb_info->pixmap.scan_align = 1;
1084 fb_info->pixmap.access_align = 4; 1037 fb_info->pixmap.access_align = 32;
1085 fb_info->pixmap.flags = FB_PIXMAP_DEFAULT; 1038 fb_info->pixmap.flags = FB_PIXMAP_DEFAULT;
1086 } 1039 }
1087 } 1040 }
@@ -1357,10 +1310,6 @@ EXPORT_SYMBOL(fb_set_var);
1357EXPORT_SYMBOL(fb_blank); 1310EXPORT_SYMBOL(fb_blank);
1358EXPORT_SYMBOL(fb_pan_display); 1311EXPORT_SYMBOL(fb_pan_display);
1359EXPORT_SYMBOL(fb_get_buffer_offset); 1312EXPORT_SYMBOL(fb_get_buffer_offset);
1360EXPORT_SYMBOL(fb_iomove_buf_unaligned);
1361EXPORT_SYMBOL(fb_iomove_buf_aligned);
1362EXPORT_SYMBOL(fb_sysmove_buf_unaligned);
1363EXPORT_SYMBOL(fb_sysmove_buf_aligned);
1364EXPORT_SYMBOL(fb_set_suspend); 1313EXPORT_SYMBOL(fb_set_suspend);
1365EXPORT_SYMBOL(fb_register_client); 1314EXPORT_SYMBOL(fb_register_client);
1366EXPORT_SYMBOL(fb_unregister_client); 1315EXPORT_SYMBOL(fb_unregister_client);
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
index a9a618f2aa6a..7513fb9b19cf 100644
--- a/drivers/video/i810/i810_main.c
+++ b/drivers/video/i810/i810_main.c
@@ -1885,6 +1885,7 @@ static int __devinit i810fb_init_pci (struct pci_dev *dev,
1885 memset(info->pixmap.addr, 0, 8*1024); 1885 memset(info->pixmap.addr, 0, 8*1024);
1886 info->pixmap.size = 8*1024; 1886 info->pixmap.size = 8*1024;
1887 info->pixmap.buf_align = 8; 1887 info->pixmap.buf_align = 8;
1888 info->pixmap.access_align = 32;
1888 info->pixmap.flags = FB_PIXMAP_SYSTEM; 1889 info->pixmap.flags = FB_PIXMAP_SYSTEM;
1889 1890
1890 if ((err = i810_allocate_pci_resource(par, entry))) { 1891 if ((err = i810_allocate_pci_resource(par, entry))) {
diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c
index 25f9a9a65c24..298bc9cd99e7 100644
--- a/drivers/video/intelfb/intelfbdrv.c
+++ b/drivers/video/intelfb/intelfbdrv.c
@@ -214,7 +214,7 @@ static struct fb_ops intel_fb_ops = {
214 214
215/* PCI driver module table */ 215/* PCI driver module table */
216static struct pci_driver intelfb_driver = { 216static struct pci_driver intelfb_driver = {
217 .name = "Intel(R) " SUPPORTED_CHIPSETS " Framebuffer Driver", 217 .name = "intelfb",
218 .id_table = intelfb_pci_table, 218 .id_table = intelfb_pci_table,
219 .probe = intelfb_pci_register, 219 .probe = intelfb_pci_register,
220 .remove = __devexit_p(intelfb_pci_unregister) 220 .remove = __devexit_p(intelfb_pci_unregister)
@@ -238,12 +238,15 @@ static int noregister = 0;
238static int probeonly = 0; 238static int probeonly = 0;
239static int idonly = 0; 239static int idonly = 0;
240static int bailearly = 0; 240static int bailearly = 0;
241static int voffset = 48;
241static char *mode = NULL; 242static char *mode = NULL;
242 243
243module_param(accel, bool, S_IRUGO); 244module_param(accel, bool, S_IRUGO);
244MODULE_PARM_DESC(accel, "Enable console acceleration"); 245MODULE_PARM_DESC(accel, "Enable console acceleration");
245module_param(vram, int, S_IRUGO); 246module_param(vram, int, S_IRUGO);
246MODULE_PARM_DESC(vram, "System RAM to allocate to framebuffer in MiB"); 247MODULE_PARM_DESC(vram, "System RAM to allocate to framebuffer in MiB");
248module_param(voffset, int, S_IRUGO);
249MODULE_PARM_DESC(voffset, "Offset of framebuffer in MiB");
247module_param(hwcursor, bool, S_IRUGO); 250module_param(hwcursor, bool, S_IRUGO);
248MODULE_PARM_DESC(hwcursor, "Enable HW cursor"); 251MODULE_PARM_DESC(hwcursor, "Enable HW cursor");
249module_param(mtrr, bool, S_IRUGO); 252module_param(mtrr, bool, S_IRUGO);
@@ -503,6 +506,7 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
503 struct agp_bridge_data *bridge; 506 struct agp_bridge_data *bridge;
504 int aperture_bar = 0; 507 int aperture_bar = 0;
505 int mmio_bar = 1; 508 int mmio_bar = 1;
509 int offset;
506 510
507 DBG_MSG("intelfb_pci_register\n"); 511 DBG_MSG("intelfb_pci_register\n");
508 512
@@ -659,17 +663,21 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
659 return -ENODEV; 663 return -ENODEV;
660 } 664 }
661 665
666 if (MB(voffset) < stolen_size)
667 offset = (stolen_size >> 12);
668 else
669 offset = ROUND_UP_TO_PAGE(MB(voffset))/GTT_PAGE_SIZE;
670
662 /* set the mem offsets - set them after the already used pages */ 671 /* set the mem offsets - set them after the already used pages */
663 if (dinfo->accel) { 672 if (dinfo->accel) {
664 dinfo->ring.offset = (stolen_size >> 12) 673 dinfo->ring.offset = offset + gtt_info.current_memory;
665 + gtt_info.current_memory;
666 } 674 }
667 if (dinfo->hwcursor) { 675 if (dinfo->hwcursor) {
668 dinfo->cursor.offset = (stolen_size >> 12) + 676 dinfo->cursor.offset = offset +
669 + gtt_info.current_memory + (dinfo->ring.size >> 12); 677 + gtt_info.current_memory + (dinfo->ring.size >> 12);
670 } 678 }
671 if (dinfo->fbmem_gart) { 679 if (dinfo->fbmem_gart) {
672 dinfo->fb.offset = (stolen_size >> 12) + 680 dinfo->fb.offset = offset +
673 + gtt_info.current_memory + (dinfo->ring.size >> 12) 681 + gtt_info.current_memory + (dinfo->ring.size >> 12)
674 + (dinfo->cursor.size >> 12); 682 + (dinfo->cursor.size >> 12);
675 } 683 }
@@ -1083,6 +1091,7 @@ intelfb_set_fbinfo(struct intelfb_info *dinfo)
1083 1091
1084 info->pixmap.size = 64*1024; 1092 info->pixmap.size = 64*1024;
1085 info->pixmap.buf_align = 8; 1093 info->pixmap.buf_align = 8;
1094 info->pixmap.access_align = 32;
1086 info->pixmap.flags = FB_PIXMAP_SYSTEM; 1095 info->pixmap.flags = FB_PIXMAP_SYSTEM;
1087 1096
1088 if (intelfb_init_var(dinfo)) 1097 if (intelfb_init_var(dinfo))
@@ -1293,7 +1302,7 @@ intelfb_set_par(struct fb_info *info)
1293 1302
1294 intelfb_blank(FB_BLANK_POWERDOWN, info); 1303 intelfb_blank(FB_BLANK_POWERDOWN, info);
1295 1304
1296 if (dinfo->accel) 1305 if (ACCEL(dinfo, info))
1297 intelfbhw_2d_stop(dinfo); 1306 intelfbhw_2d_stop(dinfo);
1298 1307
1299 memcpy(hw, &dinfo->save_state, sizeof(*hw)); 1308 memcpy(hw, &dinfo->save_state, sizeof(*hw));
@@ -1309,7 +1318,7 @@ intelfb_set_par(struct fb_info *info)
1309 1318
1310 update_dinfo(dinfo, &info->var); 1319 update_dinfo(dinfo, &info->var);
1311 1320
1312 if (dinfo->accel) 1321 if (ACCEL(dinfo, info))
1313 intelfbhw_2d_start(dinfo); 1322 intelfbhw_2d_start(dinfo);
1314 1323
1315 intelfb_pan_display(&info->var, info); 1324 intelfb_pan_display(&info->var, info);
diff --git a/drivers/video/matrox/matroxfb_maven.c b/drivers/video/matrox/matroxfb_maven.c
index e529841cd83d..67f85344f0cc 100644
--- a/drivers/video/matrox/matroxfb_maven.c
+++ b/drivers/video/matrox/matroxfb_maven.c
@@ -1230,7 +1230,6 @@ static int maven_shutdown_client(struct i2c_client* clnt) {
1230} 1230}
1231 1231
1232static unsigned short normal_i2c[] = { MAVEN_I2CID, I2C_CLIENT_END }; 1232static unsigned short normal_i2c[] = { MAVEN_I2CID, I2C_CLIENT_END };
1233static unsigned short normal_i2c_range[] = { MAVEN_I2CID, MAVEN_I2CID, I2C_CLIENT_END };
1234I2C_CLIENT_INSMOD; 1233I2C_CLIENT_INSMOD;
1235 1234
1236static struct i2c_driver maven_driver; 1235static struct i2c_driver maven_driver;
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
index 47733f58153b..b2e6b2407869 100644
--- a/drivers/video/nvidia/nvidia.c
+++ b/drivers/video/nvidia/nvidia.c
@@ -516,9 +516,9 @@ static struct backlight_controller nvidia_backlight_controller = {
516static void nvidiafb_load_cursor_image(struct nvidia_par *par, u8 * data8, 516static void nvidiafb_load_cursor_image(struct nvidia_par *par, u8 * data8,
517 u16 bg, u16 fg, u32 w, u32 h) 517 u16 bg, u16 fg, u32 w, u32 h)
518{ 518{
519 u32 *data = (u32 *) data8;
519 int i, j, k = 0; 520 int i, j, k = 0;
520 u32 b, tmp; 521 u32 b, tmp;
521 u32 *data = (u32 *) data8;
522 522
523 w = (w + 1) & ~1; 523 w = (w + 1) & ~1;
524 524
@@ -890,11 +890,11 @@ static int nvidiafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
890{ 890{
891 struct nvidia_par *par = info->par; 891 struct nvidia_par *par = info->par;
892 u8 data[MAX_CURS * MAX_CURS / 8]; 892 u8 data[MAX_CURS * MAX_CURS / 8];
893 u16 fg, bg;
894 int i, set = cursor->set; 893 int i, set = cursor->set;
894 u16 fg, bg;
895 895
896 if (cursor->image.width > MAX_CURS || cursor->image.height > MAX_CURS) 896 if (cursor->image.width > MAX_CURS || cursor->image.height > MAX_CURS)
897 return soft_cursor(info, cursor); 897 return -ENXIO;
898 898
899 NVShowHideCursor(par, 0); 899 NVShowHideCursor(par, 0);
900 900
@@ -931,21 +931,18 @@ static int nvidiafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
931 if (src) { 931 if (src) {
932 switch (cursor->rop) { 932 switch (cursor->rop) {
933 case ROP_XOR: 933 case ROP_XOR:
934 for (i = 0; i < s_pitch * cursor->image.height; 934 for (i = 0; i < s_pitch * cursor->image.height; i++)
935 i++)
936 src[i] = dat[i] ^ msk[i]; 935 src[i] = dat[i] ^ msk[i];
937 break; 936 break;
938 case ROP_COPY: 937 case ROP_COPY:
939 default: 938 default:
940 for (i = 0; i < s_pitch * cursor->image.height; 939 for (i = 0; i < s_pitch * cursor->image.height; i++)
941 i++)
942 src[i] = dat[i] & msk[i]; 940 src[i] = dat[i] & msk[i];
943 break; 941 break;
944 } 942 }
945 943
946 fb_sysmove_buf_aligned(info, &info->pixmap, data, 944 fb_pad_aligned_buffer(data, d_pitch, src, s_pitch,
947 d_pitch, src, s_pitch, 945 cursor->image.height);
948 cursor->image.height);
949 946
950 bg = ((info->cmap.red[bg_idx] & 0xf8) << 7) | 947 bg = ((info->cmap.red[bg_idx] & 0xf8) << 7) |
951 ((info->cmap.green[bg_idx] & 0xf8) << 2) | 948 ((info->cmap.green[bg_idx] & 0xf8) << 2) |
@@ -1348,6 +1345,7 @@ static int __devinit nvidia_set_fbinfo(struct fb_info *info)
1348 1345
1349 info->pixmap.scan_align = 4; 1346 info->pixmap.scan_align = 4;
1350 info->pixmap.buf_align = 4; 1347 info->pixmap.buf_align = 4;
1348 info->pixmap.access_align = 32;
1351 info->pixmap.size = 8 * 1024; 1349 info->pixmap.size = 8 * 1024;
1352 info->pixmap.flags = FB_PIXMAP_SYSTEM; 1350 info->pixmap.flags = FB_PIXMAP_SYSTEM;
1353 1351
diff --git a/drivers/video/pm3fb.c b/drivers/video/pm3fb.c
index 8e024aad1b57..e0dad948467b 100644
--- a/drivers/video/pm3fb.c
+++ b/drivers/video/pm3fb.c
@@ -5,7 +5,7 @@
5 * Based on code written by: 5 * Based on code written by:
6 * Sven Luther, <luther@dpt-info.u-strasbg.fr> 6 * Sven Luther, <luther@dpt-info.u-strasbg.fr>
7 * Alan Hourihane, <alanh@fairlite.demon.co.uk> 7 * Alan Hourihane, <alanh@fairlite.demon.co.uk>
8 * Russel King, <rmk@arm.linux.org.uk> 8 * Russell King, <rmk@arm.linux.org.uk>
9 * Based on linux/drivers/video/skeletonfb.c: 9 * Based on linux/drivers/video/skeletonfb.c:
10 * Copyright (C) 1997 Geert Uytterhoeven 10 * Copyright (C) 1997 Geert Uytterhoeven
11 * Based on linux/driver/video/pm2fb.c: 11 * Based on linux/driver/video/pm2fb.c:
diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c
index b0c886de0404..6a9e183be41b 100644
--- a/drivers/video/riva/fbdev.c
+++ b/drivers/video/riva/fbdev.c
@@ -1582,12 +1582,11 @@ static int rivafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1582{ 1582{
1583 struct riva_par *par = (struct riva_par *) info->par; 1583 struct riva_par *par = (struct riva_par *) info->par;
1584 u8 data[MAX_CURS * MAX_CURS/8]; 1584 u8 data[MAX_CURS * MAX_CURS/8];
1585 u16 fg, bg;
1586 int i, set = cursor->set; 1585 int i, set = cursor->set;
1586 u16 fg, bg;
1587 1587
1588 if (cursor->image.width > MAX_CURS || 1588 if (cursor->image.width > MAX_CURS || cursor->image.height > MAX_CURS)
1589 cursor->image.height > MAX_CURS) 1589 return -ENXIO;
1590 return soft_cursor(info, cursor);
1591 1590
1592 par->riva.ShowHideCursor(&par->riva, 0); 1591 par->riva.ShowHideCursor(&par->riva, 0);
1593 1592
@@ -1625,21 +1624,18 @@ static int rivafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
1625 if (src) { 1624 if (src) {
1626 switch (cursor->rop) { 1625 switch (cursor->rop) {
1627 case ROP_XOR: 1626 case ROP_XOR:
1628 for (i = 0; i < s_pitch * cursor->image.height; 1627 for (i = 0; i < s_pitch * cursor->image.height; i++)
1629 i++)
1630 src[i] = dat[i] ^ msk[i]; 1628 src[i] = dat[i] ^ msk[i];
1631 break; 1629 break;
1632 case ROP_COPY: 1630 case ROP_COPY:
1633 default: 1631 default:
1634 for (i = 0; i < s_pitch * cursor->image.height; 1632 for (i = 0; i < s_pitch * cursor->image.height; i++)
1635 i++)
1636 src[i] = dat[i] & msk[i]; 1633 src[i] = dat[i] & msk[i];
1637 break; 1634 break;
1638 } 1635 }
1639 1636
1640 fb_sysmove_buf_aligned(info, &info->pixmap, data, 1637 fb_pad_aligned_buffer(data, d_pitch, src, s_pitch,
1641 d_pitch, src, s_pitch, 1638 cursor->image.height);
1642 cursor->image.height);
1643 1639
1644 bg = ((info->cmap.red[bg_idx] & 0xf8) << 7) | 1640 bg = ((info->cmap.red[bg_idx] & 0xf8) << 7) |
1645 ((info->cmap.green[bg_idx] & 0xf8) << 2) | 1641 ((info->cmap.green[bg_idx] & 0xf8) << 2) |
@@ -1727,6 +1723,7 @@ static int __devinit riva_set_fbinfo(struct fb_info *info)
1727 1723
1728 info->pixmap.size = 8 * 1024; 1724 info->pixmap.size = 8 * 1024;
1729 info->pixmap.buf_align = 4; 1725 info->pixmap.buf_align = 4;
1726 info->pixmap.access_align = 32;
1730 info->pixmap.flags = FB_PIXMAP_SYSTEM; 1727 info->pixmap.flags = FB_PIXMAP_SYSTEM;
1731 info->var.yres_virtual = -1; 1728 info->var.yres_virtual = -1;
1732 NVTRACE_LEAVE(); 1729 NVTRACE_LEAVE();
diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
index b637c389e4f4..789de13f461f 100644
--- a/drivers/video/s1d13xxxfb.c
+++ b/drivers/video/s1d13xxxfb.c
@@ -493,7 +493,7 @@ s1d13xxxfb_fetch_hw_state(struct fb_info *info)
493} 493}
494 494
495 495
496static int __devexit 496static int
497s1d13xxxfb_remove(struct device *dev) 497s1d13xxxfb_remove(struct device *dev)
498{ 498{
499 struct fb_info *info = dev_get_drvdata(dev); 499 struct fb_info *info = dev_get_drvdata(dev);
diff --git a/drivers/video/savage/savagefb_driver.c b/drivers/video/savage/savagefb_driver.c
index 03d74e8ee067..8fadcdae6f42 100644
--- a/drivers/video/savage/savagefb_driver.c
+++ b/drivers/video/savage/savagefb_driver.c
@@ -1897,7 +1897,7 @@ static int __devinit savage_init_fb_info (struct fb_info *info,
1897 info->pixmap.size = 8*1024; 1897 info->pixmap.size = 8*1024;
1898 info->pixmap.scan_align = 4; 1898 info->pixmap.scan_align = 4;
1899 info->pixmap.buf_align = 4; 1899 info->pixmap.buf_align = 4;
1900 info->pixmap.access_align = 4; 1900 info->pixmap.access_align = 32;
1901 1901
1902 fb_alloc_cmap (&info->cmap, NR_PALETTE, 0); 1902 fb_alloc_cmap (&info->cmap, NR_PALETTE, 0);
1903 info->flags |= FBINFO_HWACCEL_COPYAREA | 1903 info->flags |= FBINFO_HWACCEL_COPYAREA |
diff --git a/drivers/video/softcursor.c b/drivers/video/softcursor.c
index 13a4511539a1..229c4bc35079 100644
--- a/drivers/video/softcursor.c
+++ b/drivers/video/softcursor.c
@@ -58,17 +58,10 @@ int soft_cursor(struct fb_info *info, struct fb_cursor *cursor)
58 } else 58 } else
59 memcpy(src, image->data, dsize); 59 memcpy(src, image->data, dsize);
60 60
61 if (info->pixmap.outbuf) 61 fb_pad_aligned_buffer(dst, d_pitch, src, s_pitch, image->height);
62 fb_iomove_buf_aligned(info, &info->pixmap, dst, d_pitch, src,
63 s_pitch, image->height);
64 else
65 fb_sysmove_buf_aligned(info, &info->pixmap, dst, d_pitch, src,
66 s_pitch, image->height);
67
68 image->data = dst; 62 image->data = dst;
69 info->fbops->fb_imageblit(info, image); 63 info->fbops->fb_imageblit(info, image);
70 kfree(src); 64 kfree(src);
71
72 return 0; 65 return 0;
73} 66}
74 67
diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
index 3027841f9c24..f3069b01e248 100644
--- a/drivers/video/vesafb.c
+++ b/drivers/video/vesafb.c
@@ -271,7 +271,7 @@ static int __init vesafb_probe(struct device *device)
271 271
272 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) { 272 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
273 printk(KERN_WARNING 273 printk(KERN_WARNING
274 "vesafb: abort, cannot reserve video memory at 0x%lx\n", 274 "vesafb: cannot reserve video memory at 0x%lx\n",
275 vesafb_fix.smem_start); 275 vesafb_fix.smem_start);
276 /* We cannot make this fatal. Sometimes this comes from magic 276 /* We cannot make this fatal. Sometimes this comes from magic
277 spaces our resource handlers simply don't know about */ 277 spaces our resource handlers simply don't know about */
@@ -279,13 +279,13 @@ static int __init vesafb_probe(struct device *device)
279 279
280 info = framebuffer_alloc(sizeof(u32) * 256, &dev->dev); 280 info = framebuffer_alloc(sizeof(u32) * 256, &dev->dev);
281 if (!info) { 281 if (!info) {
282 release_mem_region(vesafb_fix.smem_start, vesafb_fix.smem_len); 282 release_mem_region(vesafb_fix.smem_start, size_total);
283 return -ENOMEM; 283 return -ENOMEM;
284 } 284 }
285 info->pseudo_palette = info->par; 285 info->pseudo_palette = info->par;
286 info->par = NULL; 286 info->par = NULL;
287 287
288 info->screen_base = ioremap(vesafb_fix.smem_start, vesafb_fix.smem_len); 288 info->screen_base = ioremap(vesafb_fix.smem_start, vesafb_fix.smem_len);
289 if (!info->screen_base) { 289 if (!info->screen_base) {
290 printk(KERN_ERR 290 printk(KERN_ERR
291 "vesafb: abort, cannot ioremap video memory 0x%x @ 0x%lx\n", 291 "vesafb: abort, cannot ioremap video memory 0x%x @ 0x%lx\n",
@@ -386,7 +386,7 @@ static int __init vesafb_probe(struct device *device)
386 request_region(0x3c0, 32, "vesafb"); 386 request_region(0x3c0, 32, "vesafb");
387 387
388 if (mtrr) { 388 if (mtrr) {
389 int temp_size = size_total; 389 unsigned int temp_size = size_total;
390 /* Find the largest power-of-two */ 390 /* Find the largest power-of-two */
391 while (temp_size & (temp_size - 1)) 391 while (temp_size & (temp_size - 1))
392 temp_size &= (temp_size - 1); 392 temp_size &= (temp_size - 1);
diff --git a/drivers/w1/Kconfig b/drivers/w1/Kconfig
index 2ab65c902fe5..4f120796273e 100644
--- a/drivers/w1/Kconfig
+++ b/drivers/w1/Kconfig
@@ -3,9 +3,9 @@ menu "Dallas's 1-wire bus"
3config W1 3config W1
4 tristate "Dallas's 1-wire support" 4 tristate "Dallas's 1-wire support"
5 ---help--- 5 ---help---
6 Dallas's 1-wire bus is usefull to connect slow 1-pin devices 6 Dallas's 1-wire bus is usefull to connect slow 1-pin devices
7 such as iButtons and thermal sensors. 7 such as iButtons and thermal sensors.
8 8
9 If you want W1 support, you should say Y here. 9 If you want W1 support, you should say Y here.
10 10
11 This W1 support can also be built as a module. If so, the module 11 This W1 support can also be built as a module. If so, the module
@@ -17,8 +17,8 @@ config W1_MATROX
17 help 17 help
18 Say Y here if you want to communicate with your 1-wire devices 18 Say Y here if you want to communicate with your 1-wire devices
19 using Matrox's G400 GPIO pins. 19 using Matrox's G400 GPIO pins.
20 20
21 This support is also available as a module. If so, the module 21 This support is also available as a module. If so, the module
22 will be called matrox_w1.ko. 22 will be called matrox_w1.ko.
23 23
24config W1_DS9490 24config W1_DS9490
@@ -27,17 +27,17 @@ config W1_DS9490
27 help 27 help
28 Say Y here if you want to have a driver for DS9490R UWB <-> W1 bridge. 28 Say Y here if you want to have a driver for DS9490R UWB <-> W1 bridge.
29 29
30 This support is also available as a module. If so, the module 30 This support is also available as a module. If so, the module
31 will be called ds9490r.ko. 31 will be called ds9490r.ko.
32 32
33config W1_DS9490_BRIDGE 33config W1_DS9490R_BRIDGE
34 tristate "DS9490R USB <-> W1 transport layer for 1-wire" 34 tristate "DS9490R USB <-> W1 transport layer for 1-wire"
35 depends on W1_DS9490 35 depends on W1_DS9490
36 help 36 help
37 Say Y here if you want to communicate with your 1-wire devices 37 Say Y here if you want to communicate with your 1-wire devices
38 using DS9490R USB bridge. 38 using DS9490R USB bridge.
39 39
40 This support is also available as a module. If so, the module 40 This support is also available as a module. If so, the module
41 will be called ds_w1_bridge.ko. 41 will be called ds_w1_bridge.ko.
42 42
43config W1_THERM 43config W1_THERM
@@ -51,7 +51,7 @@ config W1_SMEM
51 tristate "Simple 64bit memory family implementation" 51 tristate "Simple 64bit memory family implementation"
52 depends on W1 52 depends on W1
53 help 53 help
54 Say Y here if you want to connect 1-wire 54 Say Y here if you want to connect 1-wire
55 simple 64bit memory rom(ds2401/ds2411/ds1990*) to you wire. 55 simple 64bit memory rom(ds2401/ds2411/ds1990*) to you wire.
56 56
57endmenu 57endmenu
diff --git a/drivers/w1/ds_w1_bridge.c b/drivers/w1/ds_w1_bridge.c
index 0baaeb5fd630..7bddd8ac7d7f 100644
--- a/drivers/w1/ds_w1_bridge.c
+++ b/drivers/w1/ds_w1_bridge.c
@@ -83,11 +83,11 @@ static u8 ds9490r_read_byte(unsigned long data)
83 return byte; 83 return byte;
84} 84}
85 85
86static void ds9490r_write_block(unsigned long data, u8 *buf, int len) 86static void ds9490r_write_block(unsigned long data, const u8 *buf, int len)
87{ 87{
88 struct ds_device *dev = (struct ds_device *)data; 88 struct ds_device *dev = (struct ds_device *)data;
89 89
90 ds_write_block(dev, buf, len); 90 ds_write_block(dev, (u8 *)buf, len);
91} 91}
92 92
93static u8 ds9490r_read_block(unsigned long data, u8 *buf, int len) 93static u8 ds9490r_read_block(unsigned long data, u8 *buf, int len)
diff --git a/drivers/w1/matrox_w1.c b/drivers/w1/matrox_w1.c
index e565416458ea..0b03f8f93f63 100644
--- a/drivers/w1/matrox_w1.c
+++ b/drivers/w1/matrox_w1.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * matrox_w1.c 2 * matrox_w1.c
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -59,7 +59,7 @@ static struct pci_driver matrox_w1_pci_driver = {
59 .remove = __devexit_p(matrox_w1_remove), 59 .remove = __devexit_p(matrox_w1_remove),
60}; 60};
61 61
62/* 62/*
63 * Matrox G400 DDC registers. 63 * Matrox G400 DDC registers.
64 */ 64 */
65 65
@@ -177,8 +177,8 @@ static int __devinit matrox_w1_probe(struct pci_dev *pdev, const struct pci_devi
177 177
178 dev->bus_master = (struct w1_bus_master *)(dev + 1); 178 dev->bus_master = (struct w1_bus_master *)(dev + 1);
179 179
180 /* 180 /*
181 * True for G400, for some other we need resource 0, see drivers/video/matrox/matroxfb_base.c 181 * True for G400, for some other we need resource 0, see drivers/video/matrox/matroxfb_base.c
182 */ 182 */
183 183
184 dev->phys_addr = pci_resource_start(pdev, 1); 184 dev->phys_addr = pci_resource_start(pdev, 1);
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 24a192e3b8b4..b460927ec32a 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * w1.c 2 * w1.c
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -59,6 +59,19 @@ static pid_t control_thread;
59static int control_needs_exit; 59static int control_needs_exit;
60static DECLARE_COMPLETION(w1_control_complete); 60static DECLARE_COMPLETION(w1_control_complete);
61 61
62/* stuff for the default family */
63static ssize_t w1_famdefault_read_name(struct device *dev, struct device_attribute *attr, char *buf)
64{
65 struct w1_slave *sl = container_of(dev, struct w1_slave, dev);
66 return(sprintf(buf, "%s\n", sl->name));
67}
68static struct w1_family_ops w1_default_fops = {
69 .rname = &w1_famdefault_read_name,
70};
71static struct w1_family w1_default_family = {
72 .fops = &w1_default_fops,
73};
74
62static int w1_master_match(struct device *dev, struct device_driver *drv) 75static int w1_master_match(struct device *dev, struct device_driver *drv)
63{ 76{
64 return 1; 77 return 1;
@@ -99,6 +112,20 @@ static ssize_t w1_default_read_bin(struct kobject *kobj, char *buf, loff_t off,
99 return sprintf(buf, "No family registered.\n"); 112 return sprintf(buf, "No family registered.\n");
100} 113}
101 114
115static struct device_attribute w1_slave_attribute =
116 __ATTR(name, S_IRUGO, w1_default_read_name, NULL);
117
118static struct bin_attribute w1_slave_bin_attribute = {
119 .attr = {
120 .name = "w1_slave",
121 .mode = S_IRUGO,
122 .owner = THIS_MODULE,
123 },
124 .size = W1_SLAVE_DATA_SIZE,
125 .read = &w1_default_read_bin,
126};
127
128
102static struct bus_type w1_bus_type = { 129static struct bus_type w1_bus_type = {
103 .name = "w1", 130 .name = "w1",
104 .match = w1_master_match, 131 .match = w1_master_match,
@@ -119,34 +146,49 @@ struct device w1_device = {
119 .release = &w1_master_release 146 .release = &w1_master_release
120}; 147};
121 148
122static struct device_attribute w1_slave_attribute = {
123 .attr = {
124 .name = "name",
125 .mode = S_IRUGO,
126 .owner = THIS_MODULE
127 },
128 .show = &w1_default_read_name,
129};
130
131static struct device_attribute w1_slave_attribute_val = {
132 .attr = {
133 .name = "value",
134 .mode = S_IRUGO,
135 .owner = THIS_MODULE
136 },
137 .show = &w1_default_read_name,
138};
139
140static ssize_t w1_master_attribute_show_name(struct device *dev, struct device_attribute *attr, char *buf) 149static ssize_t w1_master_attribute_show_name(struct device *dev, struct device_attribute *attr, char *buf)
141{ 150{
142 struct w1_master *md = container_of (dev, struct w1_master, dev); 151 struct w1_master *md = container_of(dev, struct w1_master, dev);
143 ssize_t count; 152 ssize_t count;
144 153
145 if (down_interruptible (&md->mutex)) 154 if (down_interruptible (&md->mutex))
146 return -EBUSY; 155 return -EBUSY;
147 156
148 count = sprintf(buf, "%s\n", md->name); 157 count = sprintf(buf, "%s\n", md->name);
149 158
159 up(&md->mutex);
160
161 return count;
162}
163
164static ssize_t w1_master_attribute_store_search(struct device * dev,
165 struct device_attribute *attr,
166 const char * buf, size_t count)
167{
168 struct w1_master *md = container_of(dev, struct w1_master, dev);
169
170 if (down_interruptible (&md->mutex))
171 return -EBUSY;
172
173 md->search_count = simple_strtol(buf, NULL, 0);
174
175 up(&md->mutex);
176
177 return count;
178}
179
180static ssize_t w1_master_attribute_show_search(struct device *dev,
181 struct device_attribute *attr,
182 char *buf)
183{
184 struct w1_master *md = container_of(dev, struct w1_master, dev);
185 ssize_t count;
186
187 if (down_interruptible (&md->mutex))
188 return -EBUSY;
189
190 count = sprintf(buf, "%d\n", md->search_count);
191
150 up(&md->mutex); 192 up(&md->mutex);
151 193
152 return count; 194 return count;
@@ -156,12 +198,12 @@ static ssize_t w1_master_attribute_show_pointer(struct device *dev, struct devic
156{ 198{
157 struct w1_master *md = container_of(dev, struct w1_master, dev); 199 struct w1_master *md = container_of(dev, struct w1_master, dev);
158 ssize_t count; 200 ssize_t count;
159 201
160 if (down_interruptible(&md->mutex)) 202 if (down_interruptible(&md->mutex))
161 return -EBUSY; 203 return -EBUSY;
162 204
163 count = sprintf(buf, "0x%p\n", md->bus_master); 205 count = sprintf(buf, "0x%p\n", md->bus_master);
164 206
165 up(&md->mutex); 207 up(&md->mutex);
166 return count; 208 return count;
167} 209}
@@ -177,12 +219,12 @@ static ssize_t w1_master_attribute_show_max_slave_count(struct device *dev, stru
177{ 219{
178 struct w1_master *md = container_of(dev, struct w1_master, dev); 220 struct w1_master *md = container_of(dev, struct w1_master, dev);
179 ssize_t count; 221 ssize_t count;
180 222
181 if (down_interruptible(&md->mutex)) 223 if (down_interruptible(&md->mutex))
182 return -EBUSY; 224 return -EBUSY;
183 225
184 count = sprintf(buf, "%d\n", md->max_slave_count); 226 count = sprintf(buf, "%d\n", md->max_slave_count);
185 227
186 up(&md->mutex); 228 up(&md->mutex);
187 return count; 229 return count;
188} 230}
@@ -191,12 +233,12 @@ static ssize_t w1_master_attribute_show_attempts(struct device *dev, struct devi
191{ 233{
192 struct w1_master *md = container_of(dev, struct w1_master, dev); 234 struct w1_master *md = container_of(dev, struct w1_master, dev);
193 ssize_t count; 235 ssize_t count;
194 236
195 if (down_interruptible(&md->mutex)) 237 if (down_interruptible(&md->mutex))
196 return -EBUSY; 238 return -EBUSY;
197 239
198 count = sprintf(buf, "%lu\n", md->attempts); 240 count = sprintf(buf, "%lu\n", md->attempts);
199 241
200 up(&md->mutex); 242 up(&md->mutex);
201 return count; 243 return count;
202} 244}
@@ -205,18 +247,17 @@ static ssize_t w1_master_attribute_show_slave_count(struct device *dev, struct d
205{ 247{
206 struct w1_master *md = container_of(dev, struct w1_master, dev); 248 struct w1_master *md = container_of(dev, struct w1_master, dev);
207 ssize_t count; 249 ssize_t count;
208 250
209 if (down_interruptible(&md->mutex)) 251 if (down_interruptible(&md->mutex))
210 return -EBUSY; 252 return -EBUSY;
211 253
212 count = sprintf(buf, "%d\n", md->slave_count); 254 count = sprintf(buf, "%d\n", md->slave_count);
213 255
214 up(&md->mutex); 256 up(&md->mutex);
215 return count; 257 return count;
216} 258}
217 259
218static ssize_t w1_master_attribute_show_slaves(struct device *dev, struct device_attribute *attr, char *buf) 260static ssize_t w1_master_attribute_show_slaves(struct device *dev, struct device_attribute *attr, char *buf)
219
220{ 261{
221 struct w1_master *md = container_of(dev, struct w1_master, dev); 262 struct w1_master *md = container_of(dev, struct w1_master, dev);
222 int c = PAGE_SIZE; 263 int c = PAGE_SIZE;
@@ -233,7 +274,7 @@ static ssize_t w1_master_attribute_show_slaves(struct device *dev, struct device
233 list_for_each_safe(ent, n, &md->slist) { 274 list_for_each_safe(ent, n, &md->slist) {
234 sl = list_entry(ent, struct w1_slave, w1_slave_entry); 275 sl = list_entry(ent, struct w1_slave, w1_slave_entry);
235 276
236 c -= snprintf(buf + PAGE_SIZE - c, c, "%s\n", sl->name); 277 c -= snprintf(buf + PAGE_SIZE - c, c, "%s\n", sl->name);
237 } 278 }
238 } 279 }
239 280
@@ -242,73 +283,52 @@ static ssize_t w1_master_attribute_show_slaves(struct device *dev, struct device
242 return PAGE_SIZE - c; 283 return PAGE_SIZE - c;
243} 284}
244 285
245static struct device_attribute w1_master_attribute_slaves = { 286#define W1_MASTER_ATTR_RO(_name, _mode) \
246 .attr = { 287 struct device_attribute w1_master_attribute_##_name = \
247 .name = "w1_master_slaves", 288 __ATTR(w1_master_##_name, _mode, \
248 .mode = S_IRUGO, 289 w1_master_attribute_show_##_name, NULL)
249 .owner = THIS_MODULE, 290
250 }, 291#define W1_MASTER_ATTR_RW(_name, _mode) \
251 .show = &w1_master_attribute_show_slaves, 292 struct device_attribute w1_master_attribute_##_name = \
252}; 293 __ATTR(w1_master_##_name, _mode, \
253static struct device_attribute w1_master_attribute_slave_count = { 294 w1_master_attribute_show_##_name, \
254 .attr = { 295 w1_master_attribute_store_##_name)
255 .name = "w1_master_slave_count", 296
256 .mode = S_IRUGO, 297static W1_MASTER_ATTR_RO(name, S_IRUGO);
257 .owner = THIS_MODULE 298static W1_MASTER_ATTR_RO(slaves, S_IRUGO);
258 }, 299static W1_MASTER_ATTR_RO(slave_count, S_IRUGO);
259 .show = &w1_master_attribute_show_slave_count, 300static W1_MASTER_ATTR_RO(max_slave_count, S_IRUGO);
260}; 301static W1_MASTER_ATTR_RO(attempts, S_IRUGO);
261static struct device_attribute w1_master_attribute_attempts = { 302static W1_MASTER_ATTR_RO(timeout, S_IRUGO);
262 .attr = { 303static W1_MASTER_ATTR_RO(pointer, S_IRUGO);
263 .name = "w1_master_attempts", 304static W1_MASTER_ATTR_RW(search, S_IRUGO | S_IWUGO);
264 .mode = S_IRUGO, 305
265 .owner = THIS_MODULE 306static struct attribute *w1_master_default_attrs[] = {
266 }, 307 &w1_master_attribute_name.attr,
267 .show = &w1_master_attribute_show_attempts, 308 &w1_master_attribute_slaves.attr,
268}; 309 &w1_master_attribute_slave_count.attr,
269static struct device_attribute w1_master_attribute_max_slave_count = { 310 &w1_master_attribute_max_slave_count.attr,
270 .attr = { 311 &w1_master_attribute_attempts.attr,
271 .name = "w1_master_max_slave_count", 312 &w1_master_attribute_timeout.attr,
272 .mode = S_IRUGO, 313 &w1_master_attribute_pointer.attr,
273 .owner = THIS_MODULE 314 &w1_master_attribute_search.attr,
274 }, 315 NULL
275 .show = &w1_master_attribute_show_max_slave_count,
276};
277static struct device_attribute w1_master_attribute_timeout = {
278 .attr = {
279 .name = "w1_master_timeout",
280 .mode = S_IRUGO,
281 .owner = THIS_MODULE
282 },
283 .show = &w1_master_attribute_show_timeout,
284};
285static struct device_attribute w1_master_attribute_pointer = {
286 .attr = {
287 .name = "w1_master_pointer",
288 .mode = S_IRUGO,
289 .owner = THIS_MODULE
290 },
291 .show = &w1_master_attribute_show_pointer,
292};
293static struct device_attribute w1_master_attribute_name = {
294 .attr = {
295 .name = "w1_master_name",
296 .mode = S_IRUGO,
297 .owner = THIS_MODULE
298 },
299 .show = &w1_master_attribute_show_name,
300}; 316};
301 317
302static struct bin_attribute w1_slave_bin_attribute = { 318static struct attribute_group w1_master_defattr_group = {
303 .attr = { 319 .attrs = w1_master_default_attrs,
304 .name = "w1_slave",
305 .mode = S_IRUGO,
306 .owner = THIS_MODULE,
307 },
308 .size = W1_SLAVE_DATA_SIZE,
309 .read = &w1_default_read_bin,
310}; 320};
311 321
322int w1_create_master_attributes(struct w1_master *master)
323{
324 return sysfs_create_group(&master->dev.kobj, &w1_master_defattr_group);
325}
326
327void w1_destroy_master_attributes(struct w1_master *master)
328{
329 sysfs_remove_group(&master->dev.kobj, &w1_master_defattr_group);
330}
331
312static int __w1_attach_slave_device(struct w1_slave *sl) 332static int __w1_attach_slave_device(struct w1_slave *sl)
313{ 333{
314 int err; 334 int err;
@@ -319,13 +339,13 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
319 sl->dev.release = &w1_slave_release; 339 sl->dev.release = &w1_slave_release;
320 340
321 snprintf(&sl->dev.bus_id[0], sizeof(sl->dev.bus_id), 341 snprintf(&sl->dev.bus_id[0], sizeof(sl->dev.bus_id),
322 "%02x-%012llx", 342 "%02x-%012llx",
323 (unsigned int) sl->reg_num.family, 343 (unsigned int) sl->reg_num.family,
324 (unsigned long long) sl->reg_num.id); 344 (unsigned long long) sl->reg_num.id);
325 snprintf (&sl->name[0], sizeof(sl->name), 345 snprintf(&sl->name[0], sizeof(sl->name),
326 "%02x-%012llx", 346 "%02x-%012llx",
327 (unsigned int) sl->reg_num.family, 347 (unsigned int) sl->reg_num.family,
328 (unsigned long long) sl->reg_num.id); 348 (unsigned long long) sl->reg_num.id);
329 349
330 dev_dbg(&sl->dev, "%s: registering %s.\n", __func__, 350 dev_dbg(&sl->dev, "%s: registering %s.\n", __func__,
331 &sl->dev.bus_id[0]); 351 &sl->dev.bus_id[0]);
@@ -333,48 +353,36 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
333 err = device_register(&sl->dev); 353 err = device_register(&sl->dev);
334 if (err < 0) { 354 if (err < 0) {
335 dev_err(&sl->dev, 355 dev_err(&sl->dev,
336 "Device registration [%s] failed. err=%d\n", 356 "Device registration [%s] failed. err=%d\n",
337 sl->dev.bus_id, err); 357 sl->dev.bus_id, err);
338 return err; 358 return err;
339 } 359 }
340 360
341 memcpy(&sl->attr_bin, &w1_slave_bin_attribute, sizeof(sl->attr_bin)); 361 memcpy(&sl->attr_bin, &w1_slave_bin_attribute, sizeof(sl->attr_bin));
342 memcpy(&sl->attr_name, &w1_slave_attribute, sizeof(sl->attr_name)); 362 memcpy(&sl->attr_name, &w1_slave_attribute, sizeof(sl->attr_name));
343 memcpy(&sl->attr_val, &w1_slave_attribute_val, sizeof(sl->attr_val)); 363
344
345 sl->attr_bin.read = sl->family->fops->rbin; 364 sl->attr_bin.read = sl->family->fops->rbin;
346 sl->attr_name.show = sl->family->fops->rname; 365 sl->attr_name.show = sl->family->fops->rname;
347 sl->attr_val.show = sl->family->fops->rval;
348 sl->attr_val.attr.name = sl->family->fops->rvalname;
349 366
350 err = device_create_file(&sl->dev, &sl->attr_name); 367 err = device_create_file(&sl->dev, &sl->attr_name);
351 if (err < 0) { 368 if (err < 0) {
352 dev_err(&sl->dev, 369 dev_err(&sl->dev,
353 "sysfs file creation for [%s] failed. err=%d\n", 370 "sysfs file creation for [%s] failed. err=%d\n",
354 sl->dev.bus_id, err); 371 sl->dev.bus_id, err);
355 device_unregister(&sl->dev);
356 return err;
357 }
358
359 err = device_create_file(&sl->dev, &sl->attr_val);
360 if (err < 0) {
361 dev_err(&sl->dev,
362 "sysfs file creation for [%s] failed. err=%d\n",
363 sl->dev.bus_id, err);
364 device_remove_file(&sl->dev, &sl->attr_name);
365 device_unregister(&sl->dev); 372 device_unregister(&sl->dev);
366 return err; 373 return err;
367 } 374 }
368 375
369 err = sysfs_create_bin_file(&sl->dev.kobj, &sl->attr_bin); 376 if ( sl->attr_bin.read ) {
370 if (err < 0) { 377 err = sysfs_create_bin_file(&sl->dev.kobj, &sl->attr_bin);
371 dev_err(&sl->dev, 378 if (err < 0) {
372 "sysfs file creation for [%s] failed. err=%d\n", 379 dev_err(&sl->dev,
373 sl->dev.bus_id, err); 380 "sysfs file creation for [%s] failed. err=%d\n",
374 device_remove_file(&sl->dev, &sl->attr_name); 381 sl->dev.bus_id, err);
375 device_remove_file(&sl->dev, &sl->attr_val); 382 device_remove_file(&sl->dev, &sl->attr_name);
376 device_unregister(&sl->dev); 383 device_unregister(&sl->dev);
377 return err; 384 return err;
385 }
378 } 386 }
379 387
380 list_add_tail(&sl->w1_slave_entry, &sl->master->slist); 388 list_add_tail(&sl->w1_slave_entry, &sl->master->slist);
@@ -410,12 +418,10 @@ static int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
410 spin_lock(&w1_flock); 418 spin_lock(&w1_flock);
411 f = w1_family_registered(rn->family); 419 f = w1_family_registered(rn->family);
412 if (!f) { 420 if (!f) {
413 spin_unlock(&w1_flock); 421 f= &w1_default_family;
414 dev_info(&dev->dev, "Family %x for %02x.%012llx.%02x is not registered.\n", 422 dev_info(&dev->dev, "Family %x for %02x.%012llx.%02x is not registered.\n",
415 rn->family, rn->family, 423 rn->family, rn->family,
416 (unsigned long long)rn->id, rn->crc); 424 (unsigned long long)rn->id, rn->crc);
417 kfree(sl);
418 return -ENODEV;
419 } 425 }
420 __w1_family_get(f); 426 __w1_family_get(f);
421 spin_unlock(&w1_flock); 427 spin_unlock(&w1_flock);
@@ -445,7 +451,7 @@ static int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
445static void w1_slave_detach(struct w1_slave *sl) 451static void w1_slave_detach(struct w1_slave *sl)
446{ 452{
447 struct w1_netlink_msg msg; 453 struct w1_netlink_msg msg;
448 454
449 dev_info(&sl->dev, "%s: detaching %s.\n", __func__, sl->name); 455 dev_info(&sl->dev, "%s: detaching %s.\n", __func__, sl->name);
450 456
451 while (atomic_read(&sl->refcnt)) { 457 while (atomic_read(&sl->refcnt)) {
@@ -456,12 +462,15 @@ static void w1_slave_detach(struct w1_slave *sl)
456 flush_signals(current); 462 flush_signals(current);
457 } 463 }
458 464
459 sysfs_remove_bin_file (&sl->dev.kobj, &sl->attr_bin); 465 if ( sl->attr_bin.read ) {
466 sysfs_remove_bin_file (&sl->dev.kobj, &sl->attr_bin);
467 }
460 device_remove_file(&sl->dev, &sl->attr_name); 468 device_remove_file(&sl->dev, &sl->attr_name);
461 device_remove_file(&sl->dev, &sl->attr_val);
462 device_unregister(&sl->dev); 469 device_unregister(&sl->dev);
463 w1_family_put(sl->family); 470 w1_family_put(sl->family);
464 471
472 sl->master->slave_count--;
473
465 memcpy(&msg.id.id, &sl->reg_num, sizeof(msg.id.id)); 474 memcpy(&msg.id.id, &sl->reg_num, sizeof(msg.id.id));
466 msg.type = W1_SLAVE_REMOVE; 475 msg.type = W1_SLAVE_REMOVE;
467 w1_netlink_send(sl->master, &msg); 476 w1_netlink_send(sl->master, &msg);
@@ -471,8 +480,8 @@ static struct w1_master *w1_search_master(unsigned long data)
471{ 480{
472 struct w1_master *dev; 481 struct w1_master *dev;
473 int found = 0; 482 int found = 0;
474 483
475 spin_lock_irq(&w1_mlock); 484 spin_lock_bh(&w1_mlock);
476 list_for_each_entry(dev, &w1_masters, w1_master_entry) { 485 list_for_each_entry(dev, &w1_masters, w1_master_entry) {
477 if (dev->bus_master->data == data) { 486 if (dev->bus_master->data == data) {
478 found = 1; 487 found = 1;
@@ -480,12 +489,26 @@ static struct w1_master *w1_search_master(unsigned long data)
480 break; 489 break;
481 } 490 }
482 } 491 }
483 spin_unlock_irq(&w1_mlock); 492 spin_unlock_bh(&w1_mlock);
484 493
485 return (found)?dev:NULL; 494 return (found)?dev:NULL;
486} 495}
487 496
488void w1_slave_found(unsigned long data, u64 rn) 497void w1_reconnect_slaves(struct w1_family *f)
498{
499 struct w1_master *dev;
500
501 spin_lock_bh(&w1_mlock);
502 list_for_each_entry(dev, &w1_masters, w1_master_entry) {
503 dev_info(&dev->dev, "Reconnecting slaves in %s into new family %02x.\n",
504 dev->name, f->fid);
505 set_bit(W1_MASTER_NEED_RECONNECT, &dev->flags);
506 }
507 spin_unlock_bh(&w1_mlock);
508}
509
510
511static void w1_slave_found(unsigned long data, u64 rn)
489{ 512{
490 int slave_count; 513 int slave_count;
491 struct w1_slave *sl; 514 struct w1_slave *sl;
@@ -500,7 +523,7 @@ void w1_slave_found(unsigned long data, u64 rn)
500 data); 523 data);
501 return; 524 return;
502 } 525 }
503 526
504 tmp = (struct w1_reg_num *) &rn; 527 tmp = (struct w1_reg_num *) &rn;
505 528
506 slave_count = 0; 529 slave_count = 0;
@@ -513,8 +536,7 @@ void w1_slave_found(unsigned long data, u64 rn)
513 sl->reg_num.crc == tmp->crc) { 536 sl->reg_num.crc == tmp->crc) {
514 set_bit(W1_SLAVE_ACTIVE, (long *)&sl->flags); 537 set_bit(W1_SLAVE_ACTIVE, (long *)&sl->flags);
515 break; 538 break;
516 } 539 } else if (sl->reg_num.family == tmp->family) {
517 else if (sl->reg_num.family == tmp->family) {
518 family_found = 1; 540 family_found = 1;
519 break; 541 break;
520 } 542 }
@@ -528,30 +550,43 @@ void w1_slave_found(unsigned long data, u64 rn)
528 rn && ((le64_to_cpu(rn) >> 56) & 0xff) == w1_calc_crc8((u8 *)&rn, 7)) { 550 rn && ((le64_to_cpu(rn) >> 56) & 0xff) == w1_calc_crc8((u8 *)&rn, 7)) {
529 w1_attach_slave_device(dev, tmp); 551 w1_attach_slave_device(dev, tmp);
530 } 552 }
531 553
532 atomic_dec(&dev->refcnt); 554 atomic_dec(&dev->refcnt);
533} 555}
534 556
535void w1_search(struct w1_master *dev) 557/**
558 * Performs a ROM Search & registers any devices found.
559 * The 1-wire search is a simple binary tree search.
560 * For each bit of the address, we read two bits and write one bit.
561 * The bit written will put to sleep all devies that don't match that bit.
562 * When the two reads differ, the direction choice is obvious.
563 * When both bits are 0, we must choose a path to take.
564 * When we can scan all 64 bits without having to choose a path, we are done.
565 *
566 * See "Application note 187 1-wire search algorithm" at www.maxim-ic.com
567 *
568 * @dev The master device to search
569 * @cb Function to call when a device is found
570 */
571void w1_search(struct w1_master *dev, w1_slave_found_callback cb)
536{ 572{
537 u64 last, rn, tmp; 573 u64 last_rn, rn, tmp64;
538 int i, count = 0; 574 int i, slave_count = 0;
539 int last_family_desc, last_zero, last_device; 575 int last_zero, last_device;
540 int search_bit, id_bit, comp_bit, desc_bit; 576 int search_bit, desc_bit;
577 u8 triplet_ret = 0;
541 578
542 search_bit = id_bit = comp_bit = 0; 579 search_bit = 0;
543 rn = tmp = last = 0; 580 rn = last_rn = 0;
544 last_device = last_zero = last_family_desc = 0; 581 last_device = 0;
582 last_zero = -1;
545 583
546 desc_bit = 64; 584 desc_bit = 64;
547 585
548 while (!(id_bit && comp_bit) && !last_device 586 while ( !last_device && (slave_count++ < dev->max_slave_count) ) {
549 && count++ < dev->max_slave_count) { 587 last_rn = rn;
550 last = rn;
551 rn = 0; 588 rn = 0;
552 589
553 last_family_desc = 0;
554
555 /* 590 /*
556 * Reset bus and all 1-wire device state machines 591 * Reset bus and all 1-wire device state machines
557 * so they can respond to our requests. 592 * so they can respond to our requests.
@@ -563,94 +598,46 @@ void w1_search(struct w1_master *dev)
563 break; 598 break;
564 } 599 }
565 600
566#if 1 601 /* Start the search */
567 w1_write_8(dev, W1_SEARCH); 602 w1_write_8(dev, W1_SEARCH);
568 for (i = 0; i < 64; ++i) { 603 for (i = 0; i < 64; ++i) {
569 /* 604 /* Determine the direction/search bit */
570 * Read 2 bits from bus. 605 if (i == desc_bit)
571 * All who don't sleep must send ID bit and COMPLEMENT ID bit. 606 search_bit = 1; /* took the 0 path last time, so take the 1 path */
572 * They actually are ANDed between all senders. 607 else if (i > desc_bit)
573 */ 608 search_bit = 0; /* take the 0 path on the next branch */
574 id_bit = w1_touch_bit(dev, 1);
575 comp_bit = w1_touch_bit(dev, 1);
576
577 if (id_bit && comp_bit)
578 break;
579
580 if (id_bit == 0 && comp_bit == 0) {
581 if (i == desc_bit)
582 search_bit = 1;
583 else if (i > desc_bit)
584 search_bit = 0;
585 else
586 search_bit = ((last >> i) & 0x1);
587
588 if (search_bit == 0) {
589 last_zero = i;
590 if (last_zero < 9)
591 last_family_desc = last_zero;
592 }
593
594 }
595 else 609 else
596 search_bit = id_bit; 610 search_bit = ((last_rn >> i) & 0x1);
597 611
598 tmp = search_bit; 612 /** Read two bits and write one bit */
599 rn |= (tmp << i); 613 triplet_ret = w1_triplet(dev, search_bit);
600 614
601 /* 615 /* quit if no device responded */
602 * Write 1 bit to bus 616 if ( (triplet_ret & 0x03) == 0x03 )
603 * and make all who don't have "search_bit" in "i"'th position 617 break;
604 * in it's registration number sleep.
605 */
606 if (dev->bus_master->touch_bit)
607 w1_touch_bit(dev, search_bit);
608 else
609 w1_write_bit(dev, search_bit);
610 618
611 } 619 /* If both directions were valid, and we took the 0 path... */
612#endif 620 if (triplet_ret == 0)
621 last_zero = i;
613 622
614 if (desc_bit == last_zero) 623 /* extract the direction taken & update the device number */
615 last_device = 1; 624 tmp64 = (triplet_ret >> 2);
625 rn |= (tmp64 << i);
626 }
616 627
617 desc_bit = last_zero; 628 if ( (triplet_ret & 0x03) != 0x03 ) {
618 629 if ( (desc_bit == last_zero) || (last_zero < 0))
619 w1_slave_found(dev->bus_master->data, rn); 630 last_device = 1;
631 desc_bit = last_zero;
632 cb(dev->bus_master->data, rn);
633 }
620 } 634 }
621} 635}
622 636
623int w1_create_master_attributes(struct w1_master *dev) 637static int w1_control(void *data)
624{
625 if ( device_create_file(&dev->dev, &w1_master_attribute_slaves) < 0 ||
626 device_create_file(&dev->dev, &w1_master_attribute_slave_count) < 0 ||
627 device_create_file(&dev->dev, &w1_master_attribute_attempts) < 0 ||
628 device_create_file(&dev->dev, &w1_master_attribute_max_slave_count) < 0 ||
629 device_create_file(&dev->dev, &w1_master_attribute_timeout) < 0||
630 device_create_file(&dev->dev, &w1_master_attribute_pointer) < 0||
631 device_create_file(&dev->dev, &w1_master_attribute_name) < 0)
632 return -EINVAL;
633
634 return 0;
635}
636
637void w1_destroy_master_attributes(struct w1_master *dev)
638{ 638{
639 device_remove_file(&dev->dev, &w1_master_attribute_slaves); 639 struct w1_slave *sl, *sln;
640 device_remove_file(&dev->dev, &w1_master_attribute_slave_count); 640 struct w1_master *dev, *n;
641 device_remove_file(&dev->dev, &w1_master_attribute_attempts);
642 device_remove_file(&dev->dev, &w1_master_attribute_max_slave_count);
643 device_remove_file(&dev->dev, &w1_master_attribute_timeout);
644 device_remove_file(&dev->dev, &w1_master_attribute_pointer);
645 device_remove_file(&dev->dev, &w1_master_attribute_name);
646}
647
648
649int w1_control(void *data)
650{
651 struct w1_slave *sl;
652 struct w1_master *dev;
653 struct list_head *ent, *ment, *n, *mn;
654 int err, have_to_wait = 0; 641 int err, have_to_wait = 0;
655 642
656 daemonize("w1_control"); 643 daemonize("w1_control");
@@ -665,10 +652,8 @@ int w1_control(void *data)
665 if (signal_pending(current)) 652 if (signal_pending(current))
666 flush_signals(current); 653 flush_signals(current);
667 654
668 list_for_each_safe(ment, mn, &w1_masters) { 655 list_for_each_entry_safe(dev, n, &w1_masters, w1_master_entry) {
669 dev = list_entry(ment, struct w1_master, w1_master_entry); 656 if (!control_needs_exit && !dev->flags)
670
671 if (!control_needs_exit && !dev->need_exit)
672 continue; 657 continue;
673 /* 658 /*
674 * Little race: we can create thread but not set the flag. 659 * Little race: we can create thread but not set the flag.
@@ -679,12 +664,8 @@ int w1_control(void *data)
679 continue; 664 continue;
680 } 665 }
681 666
682 spin_lock(&w1_mlock);
683 list_del(&dev->w1_master_entry);
684 spin_unlock(&w1_mlock);
685
686 if (control_needs_exit) { 667 if (control_needs_exit) {
687 dev->need_exit = 1; 668 set_bit(W1_MASTER_NEED_EXIT, &dev->flags);
688 669
689 err = kill_proc(dev->kpid, SIGTERM, 1); 670 err = kill_proc(dev->kpid, SIGTERM, 1);
690 if (err) 671 if (err)
@@ -693,24 +674,42 @@ int w1_control(void *data)
693 dev->kpid); 674 dev->kpid);
694 } 675 }
695 676
696 wait_for_completion(&dev->dev_exited); 677 if (test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) {
697 678 wait_for_completion(&dev->dev_exited);
698 list_for_each_safe(ent, n, &dev->slist) { 679 spin_lock_bh(&w1_mlock);
699 sl = list_entry(ent, struct w1_slave, w1_slave_entry); 680 list_del(&dev->w1_master_entry);
681 spin_unlock_bh(&w1_mlock);
700 682
701 if (!sl) 683 list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) {
702 dev_warn(&dev->dev,
703 "%s: slave entry is NULL.\n",
704 __func__);
705 else {
706 list_del(&sl->w1_slave_entry); 684 list_del(&sl->w1_slave_entry);
707 685
708 w1_slave_detach(sl); 686 w1_slave_detach(sl);
709 kfree(sl); 687 kfree(sl);
710 } 688 }
689 w1_destroy_master_attributes(dev);
690 atomic_dec(&dev->refcnt);
691 continue;
692 }
693
694 if (test_bit(W1_MASTER_NEED_RECONNECT, &dev->flags)) {
695 dev_info(&dev->dev, "Reconnecting slaves in device %s.\n", dev->name);
696 down(&dev->mutex);
697 list_for_each_entry(sl, &dev->slist, w1_slave_entry) {
698 if (sl->family->fid == W1_FAMILY_DEFAULT) {
699 struct w1_reg_num rn;
700 list_del(&sl->w1_slave_entry);
701 w1_slave_detach(sl);
702
703 memcpy(&rn, &sl->reg_num, sizeof(rn));
704
705 kfree(sl);
706
707 w1_attach_slave_device(dev, &rn);
708 }
709 }
710 clear_bit(W1_MASTER_NEED_RECONNECT, &dev->flags);
711 up(&dev->mutex);
711 } 712 }
712 w1_destroy_master_attributes(dev);
713 atomic_dec(&dev->refcnt);
714 } 713 }
715 } 714 }
716 715
@@ -720,51 +719,50 @@ int w1_control(void *data)
720int w1_process(void *data) 719int w1_process(void *data)
721{ 720{
722 struct w1_master *dev = (struct w1_master *) data; 721 struct w1_master *dev = (struct w1_master *) data;
723 struct list_head *ent, *n; 722 struct w1_slave *sl, *sln;
724 struct w1_slave *sl;
725 723
726 daemonize("%s", dev->name); 724 daemonize("%s", dev->name);
727 allow_signal(SIGTERM); 725 allow_signal(SIGTERM);
728 726
729 while (!dev->need_exit) { 727 while (!test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) {
730 try_to_freeze(PF_FREEZE); 728 try_to_freeze(PF_FREEZE);
731 msleep_interruptible(w1_timeout * 1000); 729 msleep_interruptible(w1_timeout * 1000);
732 730
733 if (signal_pending(current)) 731 if (signal_pending(current))
734 flush_signals(current); 732 flush_signals(current);
735 733
736 if (dev->need_exit) 734 if (test_bit(W1_MASTER_NEED_EXIT, &dev->flags))
737 break; 735 break;
738 736
739 if (!dev->initialized) 737 if (!dev->initialized)
740 continue; 738 continue;
741 739
740 if (dev->search_count == 0)
741 continue;
742
742 if (down_interruptible(&dev->mutex)) 743 if (down_interruptible(&dev->mutex))
743 continue; 744 continue;
744 745
745 list_for_each_safe(ent, n, &dev->slist) { 746 list_for_each_entry(sl, &dev->slist, w1_slave_entry)
746 sl = list_entry(ent, struct w1_slave, w1_slave_entry); 747 clear_bit(W1_SLAVE_ACTIVE, (long *)&sl->flags);
747 748
748 if (sl)
749 clear_bit(W1_SLAVE_ACTIVE, (long *)&sl->flags);
750 }
751
752 w1_search_devices(dev, w1_slave_found); 749 w1_search_devices(dev, w1_slave_found);
753 750
754 list_for_each_safe(ent, n, &dev->slist) { 751 list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) {
755 sl = list_entry(ent, struct w1_slave, w1_slave_entry); 752 if (!test_bit(W1_SLAVE_ACTIVE, (unsigned long *)&sl->flags) && !--sl->ttl) {
756
757 if (sl && !test_bit(W1_SLAVE_ACTIVE, (unsigned long *)&sl->flags) && !--sl->ttl) {
758 list_del (&sl->w1_slave_entry); 753 list_del (&sl->w1_slave_entry);
759 754
760 w1_slave_detach (sl); 755 w1_slave_detach (sl);
761 kfree (sl); 756 kfree (sl);
762 757
763 dev->slave_count--; 758 dev->slave_count--;
764 } 759 } else if (test_bit(W1_SLAVE_ACTIVE, (unsigned long *)&sl->flags))
765 else if (test_bit(W1_SLAVE_ACTIVE, (unsigned long *)&sl->flags))
766 sl->ttl = dev->slave_ttl; 760 sl->ttl = dev->slave_ttl;
767 } 761 }
762
763 if (dev->search_count > 0)
764 dev->search_count--;
765
768 up(&dev->mutex); 766 up(&dev->mutex);
769 } 767 }
770 768
@@ -774,7 +772,7 @@ int w1_process(void *data)
774 return 0; 772 return 0;
775} 773}
776 774
777int w1_init(void) 775static int w1_init(void)
778{ 776{
779 int retval; 777 int retval;
780 778
@@ -814,18 +812,14 @@ err_out_exit_init:
814 return retval; 812 return retval;
815} 813}
816 814
817void w1_fini(void) 815static void w1_fini(void)
818{ 816{
819 struct w1_master *dev; 817 struct w1_master *dev;
820 struct list_head *ent, *n;
821 818
822 list_for_each_safe(ent, n, &w1_masters) { 819 list_for_each_entry(dev, &w1_masters, w1_master_entry)
823 dev = list_entry(ent, struct w1_master, w1_master_entry);
824 __w1_remove_master_device(dev); 820 __w1_remove_master_device(dev);
825 }
826 821
827 control_needs_exit = 1; 822 control_needs_exit = 1;
828
829 wait_for_completion(&w1_control_complete); 823 wait_for_completion(&w1_control_complete);
830 824
831 driver_unregister(&w1_driver); 825 driver_unregister(&w1_driver);
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h
index abbddaf3f8e2..4f0a986e33e3 100644
--- a/drivers/w1/w1.h
+++ b/drivers/w1/w1.h
@@ -1,8 +1,8 @@
1/* 1/*
2 * w1.h 2 * w1.h
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -74,36 +74,86 @@ struct w1_slave
74 int ttl; 74 int ttl;
75 75
76 struct w1_master *master; 76 struct w1_master *master;
77 struct w1_family *family; 77 struct w1_family *family;
78 struct device dev; 78 struct device dev;
79 struct completion dev_released; 79 struct completion dev_released;
80 80
81 struct bin_attribute attr_bin; 81 struct bin_attribute attr_bin;
82 struct device_attribute attr_name, attr_val; 82 struct device_attribute attr_name;
83}; 83};
84 84
85typedef void (* w1_slave_found_callback)(unsigned long, u64); 85typedef void (* w1_slave_found_callback)(unsigned long, u64);
86 86
87
88/**
89 * Note: read_bit and write_bit are very low level functions and should only
90 * be used with hardware that doesn't really support 1-wire operations,
91 * like a parallel/serial port.
92 * Either define read_bit and write_bit OR define, at minimum, touch_bit and
93 * reset_bus.
94 */
87struct w1_bus_master 95struct w1_bus_master
88{ 96{
89 unsigned long data; 97 /** the first parameter in all the functions below */
90 98 unsigned long data;
91 u8 (*read_bit)(unsigned long); 99
92 void (*write_bit)(unsigned long, u8); 100 /**
93 101 * Sample the line level
94 u8 (*read_byte)(unsigned long); 102 * @return the level read (0 or 1)
95 void (*write_byte)(unsigned long, u8); 103 */
96 104 u8 (*read_bit)(unsigned long);
97 u8 (*read_block)(unsigned long, u8 *, int); 105
98 void (*write_block)(unsigned long, u8 *, int); 106 /** Sets the line level */
99 107 void (*write_bit)(unsigned long, u8);
100 u8 (*touch_bit)(unsigned long, u8); 108
101 109 /**
102 u8 (*reset_bus)(unsigned long); 110 * touch_bit is the lowest-level function for devices that really
103 111 * support the 1-wire protocol.
104 void (*search)(unsigned long, w1_slave_found_callback); 112 * touch_bit(0) = write-0 cycle
113 * touch_bit(1) = write-1 / read cycle
114 * @return the bit read (0 or 1)
115 */
116 u8 (*touch_bit)(unsigned long, u8);
117
118 /**
119 * Reads a bytes. Same as 8 touch_bit(1) calls.
120 * @return the byte read
121 */
122 u8 (*read_byte)(unsigned long);
123
124 /**
125 * Writes a byte. Same as 8 touch_bit(x) calls.
126 */
127 void (*write_byte)(unsigned long, u8);
128
129 /**
130 * Same as a series of read_byte() calls
131 * @return the number of bytes read
132 */
133 u8 (*read_block)(unsigned long, u8 *, int);
134
135 /** Same as a series of write_byte() calls */
136 void (*write_block)(unsigned long, const u8 *, int);
137
138 /**
139 * Combines two reads and a smart write for ROM searches
140 * @return bit0=Id bit1=comp_id bit2=dir_taken
141 */
142 u8 (*triplet)(unsigned long, u8);
143
144 /**
145 * long write-0 with a read for the presence pulse detection
146 * @return -1=Error, 0=Device present, 1=No device present
147 */
148 u8 (*reset_bus)(unsigned long);
149
150 /** Really nice hardware can handles the ROM searches */
151 void (*search)(unsigned long, w1_slave_found_callback);
105}; 152};
106 153
154#define W1_MASTER_NEED_EXIT 0
155#define W1_MASTER_NEED_RECONNECT 1
156
107struct w1_master 157struct w1_master
108{ 158{
109 struct list_head w1_master_entry; 159 struct list_head w1_master_entry;
@@ -115,30 +165,31 @@ struct w1_master
115 int slave_ttl; 165 int slave_ttl;
116 int initialized; 166 int initialized;
117 u32 id; 167 u32 id;
168 int search_count;
118 169
119 atomic_t refcnt; 170 atomic_t refcnt;
120 171
121 void *priv; 172 void *priv;
122 int priv_size; 173 int priv_size;
123 174
124 int need_exit; 175 long flags;
176
125 pid_t kpid; 177 pid_t kpid;
126 struct semaphore mutex; 178 struct semaphore mutex;
127 179
128 struct device_driver *driver; 180 struct device_driver *driver;
129 struct device dev; 181 struct device dev;
130 struct completion dev_released; 182 struct completion dev_released;
131 struct completion dev_exited; 183 struct completion dev_exited;
132 184
133 struct w1_bus_master *bus_master; 185 struct w1_bus_master *bus_master;
134 186
135 u32 seq, groups; 187 u32 seq, groups;
136 struct sock *nls; 188 struct sock *nls;
137}; 189};
138 190
139int w1_create_master_attributes(struct w1_master *); 191int w1_create_master_attributes(struct w1_master *);
140void w1_destroy_master_attributes(struct w1_master *); 192void w1_search(struct w1_master *dev, w1_slave_found_callback cb);
141void w1_search(struct w1_master *dev);
142 193
143#endif /* __KERNEL__ */ 194#endif /* __KERNEL__ */
144 195
diff --git a/drivers/w1/w1_family.c b/drivers/w1/w1_family.c
index d1d56eca1061..02eee57d3c0c 100644
--- a/drivers/w1/w1_family.c
+++ b/drivers/w1/w1_family.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * w1_family.c 2 * w1_family.c
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -27,10 +27,11 @@
27 27
28DEFINE_SPINLOCK(w1_flock); 28DEFINE_SPINLOCK(w1_flock);
29static LIST_HEAD(w1_families); 29static LIST_HEAD(w1_families);
30extern void w1_reconnect_slaves(struct w1_family *f);
30 31
31static int w1_check_family(struct w1_family *f) 32static int w1_check_family(struct w1_family *f)
32{ 33{
33 if (!f->fops->rname || !f->fops->rbin || !f->fops->rval || !f->fops->rvalname) 34 if (!f->fops->rname || !f->fops->rbin)
34 return -EINVAL; 35 return -EINVAL;
35 36
36 return 0; 37 return 0;
@@ -60,9 +61,10 @@ int w1_register_family(struct w1_family *newf)
60 newf->need_exit = 0; 61 newf->need_exit = 0;
61 list_add_tail(&newf->family_entry, &w1_families); 62 list_add_tail(&newf->family_entry, &w1_families);
62 } 63 }
63
64 spin_unlock(&w1_flock); 64 spin_unlock(&w1_flock);
65 65
66 w1_reconnect_slaves(newf);
67
66 return ret; 68 return ret;
67} 69}
68 70
diff --git a/drivers/w1/w1_family.h b/drivers/w1/w1_family.h
index 07fa49412a90..b26da01bbc38 100644
--- a/drivers/w1/w1_family.h
+++ b/drivers/w1/w1_family.h
@@ -1,8 +1,8 @@
1/* 1/*
2 * w1_family.h 2 * w1_family.h
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -27,8 +27,11 @@
27#include <asm/atomic.h> 27#include <asm/atomic.h>
28 28
29#define W1_FAMILY_DEFAULT 0 29#define W1_FAMILY_DEFAULT 0
30#define W1_FAMILY_THERM 0x10 30#define W1_FAMILY_SMEM_01 0x01
31#define W1_FAMILY_SMEM 0x01 31#define W1_FAMILY_SMEM_81 0x81
32#define W1_THERM_DS18S20 0x10
33#define W1_THERM_DS1822 0x22
34#define W1_THERM_DS18B20 0x28
32 35
33#define MAXNAMELEN 32 36#define MAXNAMELEN 32
34 37
@@ -36,18 +39,15 @@ struct w1_family_ops
36{ 39{
37 ssize_t (* rname)(struct device *, struct device_attribute *, char *); 40 ssize_t (* rname)(struct device *, struct device_attribute *, char *);
38 ssize_t (* rbin)(struct kobject *, char *, loff_t, size_t); 41 ssize_t (* rbin)(struct kobject *, char *, loff_t, size_t);
39
40 ssize_t (* rval)(struct device *, struct device_attribute *, char *);
41 unsigned char rvalname[MAXNAMELEN];
42}; 42};
43 43
44struct w1_family 44struct w1_family
45{ 45{
46 struct list_head family_entry; 46 struct list_head family_entry;
47 u8 fid; 47 u8 fid;
48 48
49 struct w1_family_ops *fops; 49 struct w1_family_ops *fops;
50 50
51 atomic_t refcnt; 51 atomic_t refcnt;
52 u8 need_exit; 52 u8 need_exit;
53}; 53};
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 5f0bafbbd575..35e85d961702 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * w1_int.c 2 * w1_int.c
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -39,8 +39,9 @@ extern spinlock_t w1_mlock;
39 39
40extern int w1_process(void *); 40extern int w1_process(void *);
41 41
42struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl, 42static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
43 struct device_driver *driver, struct device *device) 43 struct device_driver *driver,
44 struct device *device)
44{ 45{
45 struct w1_master *dev; 46 struct w1_master *dev;
46 int err; 47 int err;
@@ -60,14 +61,15 @@ struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
60 61
61 dev->bus_master = (struct w1_bus_master *)(dev + 1); 62 dev->bus_master = (struct w1_bus_master *)(dev + 1);
62 63
63 dev->owner = THIS_MODULE; 64 dev->owner = THIS_MODULE;
64 dev->max_slave_count = slave_count; 65 dev->max_slave_count = slave_count;
65 dev->slave_count = 0; 66 dev->slave_count = 0;
66 dev->attempts = 0; 67 dev->attempts = 0;
67 dev->kpid = -1; 68 dev->kpid = -1;
68 dev->initialized = 0; 69 dev->initialized = 0;
69 dev->id = id; 70 dev->id = id;
70 dev->slave_ttl = slave_ttl; 71 dev->slave_ttl = slave_ttl;
72 dev->search_count = -1; /* continual scan */
71 73
72 atomic_set(&dev->refcnt, 2); 74 atomic_set(&dev->refcnt, 2);
73 75
@@ -105,7 +107,7 @@ struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
105 return dev; 107 return dev;
106} 108}
107 109
108void w1_free_dev(struct w1_master *dev) 110static void w1_free_dev(struct w1_master *dev)
109{ 111{
110 device_unregister(&dev->dev); 112 device_unregister(&dev->dev);
111 if (dev->nls && dev->nls->sk_socket) 113 if (dev->nls && dev->nls->sk_socket)
@@ -120,6 +122,13 @@ int w1_add_master_device(struct w1_bus_master *master)
120 int retval = 0; 122 int retval = 0;
121 struct w1_netlink_msg msg; 123 struct w1_netlink_msg msg;
122 124
125 /* validate minimum functionality */
126 if (!(master->touch_bit && master->reset_bus) &&
127 !(master->write_bit && master->read_bit)) {
128 printk(KERN_ERR "w1_add_master_device: invalid function set\n");
129 return(-EINVAL);
130 }
131
123 dev = w1_alloc_dev(w1_ids++, w1_max_slave_count, w1_max_slave_ttl, &w1_driver, &w1_device); 132 dev = w1_alloc_dev(w1_ids++, w1_max_slave_count, w1_max_slave_ttl, &w1_driver, &w1_device);
124 if (!dev) 133 if (!dev)
125 return -ENOMEM; 134 return -ENOMEM;
@@ -153,7 +162,7 @@ int w1_add_master_device(struct w1_bus_master *master)
153 return 0; 162 return 0;
154 163
155err_out_kill_thread: 164err_out_kill_thread:
156 dev->need_exit = 1; 165 set_bit(W1_MASTER_NEED_EXIT, &dev->flags);
157 if (kill_proc(dev->kpid, SIGTERM, 1)) 166 if (kill_proc(dev->kpid, SIGTERM, 1))
158 dev_err(&dev->dev, 167 dev_err(&dev->dev,
159 "Failed to send signal to w1 kernel thread %d.\n", 168 "Failed to send signal to w1 kernel thread %d.\n",
@@ -171,7 +180,7 @@ void __w1_remove_master_device(struct w1_master *dev)
171 int err; 180 int err;
172 struct w1_netlink_msg msg; 181 struct w1_netlink_msg msg;
173 182
174 dev->need_exit = 1; 183 set_bit(W1_MASTER_NEED_EXIT, &dev->flags);
175 err = kill_proc(dev->kpid, SIGTERM, 1); 184 err = kill_proc(dev->kpid, SIGTERM, 1);
176 if (err) 185 if (err)
177 dev_err(&dev->dev, 186 dev_err(&dev->dev,
@@ -197,10 +206,8 @@ void __w1_remove_master_device(struct w1_master *dev)
197void w1_remove_master_device(struct w1_bus_master *bm) 206void w1_remove_master_device(struct w1_bus_master *bm)
198{ 207{
199 struct w1_master *dev = NULL; 208 struct w1_master *dev = NULL;
200 struct list_head *ent, *n;
201 209
202 list_for_each_safe(ent, n, &w1_masters) { 210 list_for_each_entry(dev, &w1_masters, w1_master_entry) {
203 dev = list_entry(ent, struct w1_master, w1_master_entry);
204 if (!dev->initialized) 211 if (!dev->initialized)
205 continue; 212 continue;
206 213
diff --git a/drivers/w1/w1_int.h b/drivers/w1/w1_int.h
index fdb531e87faa..4274082d2262 100644
--- a/drivers/w1/w1_int.h
+++ b/drivers/w1/w1_int.h
@@ -1,8 +1,8 @@
1/* 1/*
2 * w1_int.h 2 * w1_int.h
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -27,8 +27,6 @@
27 27
28#include "w1.h" 28#include "w1.h"
29 29
30struct w1_master * w1_alloc_dev(u32, int, int, struct device_driver *, struct device *);
31void w1_free_dev(struct w1_master *dev);
32int w1_add_master_device(struct w1_bus_master *); 30int w1_add_master_device(struct w1_bus_master *);
33void w1_remove_master_device(struct w1_bus_master *); 31void w1_remove_master_device(struct w1_bus_master *);
34void __w1_remove_master_device(struct w1_master *); 32void __w1_remove_master_device(struct w1_master *);
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
index 02796b5a39f6..00f032220173 100644
--- a/drivers/w1/w1_io.c
+++ b/drivers/w1/w1_io.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * w1_io.c 2 * w1_io.c
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -55,15 +55,29 @@ void w1_delay(unsigned long tm)
55 udelay(tm * w1_delay_parm); 55 udelay(tm * w1_delay_parm);
56} 56}
57 57
58static void w1_write_bit(struct w1_master *dev, int bit);
59static u8 w1_read_bit(struct w1_master *dev);
60
61/**
62 * Generates a write-0 or write-1 cycle and samples the level.
63 */
58u8 w1_touch_bit(struct w1_master *dev, int bit) 64u8 w1_touch_bit(struct w1_master *dev, int bit)
59{ 65{
60 if (dev->bus_master->touch_bit) 66 if (dev->bus_master->touch_bit)
61 return dev->bus_master->touch_bit(dev->bus_master->data, bit); 67 return dev->bus_master->touch_bit(dev->bus_master->data, bit);
62 else 68 else if (bit)
63 return w1_read_bit(dev); 69 return w1_read_bit(dev);
70 else {
71 w1_write_bit(dev, 0);
72 return(0);
73 }
64} 74}
65 75
66void w1_write_bit(struct w1_master *dev, int bit) 76/**
77 * Generates a write-0 or write-1 cycle.
78 * Only call if dev->bus_master->touch_bit is NULL
79 */
80static void w1_write_bit(struct w1_master *dev, int bit)
67{ 81{
68 if (bit) { 82 if (bit) {
69 dev->bus_master->write_bit(dev->bus_master->data, 0); 83 dev->bus_master->write_bit(dev->bus_master->data, 0);
@@ -78,6 +92,12 @@ void w1_write_bit(struct w1_master *dev, int bit)
78 } 92 }
79} 93}
80 94
95/**
96 * Writes 8 bits.
97 *
98 * @param dev the master device
99 * @param byte the byte to write
100 */
81void w1_write_8(struct w1_master *dev, u8 byte) 101void w1_write_8(struct w1_master *dev, u8 byte)
82{ 102{
83 int i; 103 int i;
@@ -86,10 +106,15 @@ void w1_write_8(struct w1_master *dev, u8 byte)
86 dev->bus_master->write_byte(dev->bus_master->data, byte); 106 dev->bus_master->write_byte(dev->bus_master->data, byte);
87 else 107 else
88 for (i = 0; i < 8; ++i) 108 for (i = 0; i < 8; ++i)
89 w1_write_bit(dev, (byte >> i) & 0x1); 109 w1_touch_bit(dev, (byte >> i) & 0x1);
90} 110}
91 111
92u8 w1_read_bit(struct w1_master *dev) 112
113/**
114 * Generates a write-1 cycle and samples the level.
115 * Only call if dev->bus_master->touch_bit is NULL
116 */
117static u8 w1_read_bit(struct w1_master *dev)
93{ 118{
94 int result; 119 int result;
95 120
@@ -104,6 +129,53 @@ u8 w1_read_bit(struct w1_master *dev)
104 return result & 0x1; 129 return result & 0x1;
105} 130}
106 131
132/**
133 * Does a triplet - used for searching ROM addresses.
134 * Return bits:
135 * bit 0 = id_bit
136 * bit 1 = comp_bit
137 * bit 2 = dir_taken
138 * If both bits 0 & 1 are set, the search should be restarted.
139 *
140 * @param dev the master device
141 * @param bdir the bit to write if both id_bit and comp_bit are 0
142 * @return bit fields - see above
143 */
144u8 w1_triplet(struct w1_master *dev, int bdir)
145{
146 if ( dev->bus_master->triplet )
147 return(dev->bus_master->triplet(dev->bus_master->data, bdir));
148 else {
149 u8 id_bit = w1_touch_bit(dev, 1);
150 u8 comp_bit = w1_touch_bit(dev, 1);
151 u8 retval;
152
153 if ( id_bit && comp_bit )
154 return(0x03); /* error */
155
156 if ( !id_bit && !comp_bit ) {
157 /* Both bits are valid, take the direction given */
158 retval = bdir ? 0x04 : 0;
159 } else {
160 /* Only one bit is valid, take that direction */
161 bdir = id_bit;
162 retval = id_bit ? 0x05 : 0x02;
163 }
164
165 if ( dev->bus_master->touch_bit )
166 w1_touch_bit(dev, bdir);
167 else
168 w1_write_bit(dev, bdir);
169 return(retval);
170 }
171}
172
173/**
174 * Reads 8 bits.
175 *
176 * @param dev the master device
177 * @return the byte read
178 */
107u8 w1_read_8(struct w1_master * dev) 179u8 w1_read_8(struct w1_master * dev)
108{ 180{
109 int i; 181 int i;
@@ -113,12 +185,20 @@ u8 w1_read_8(struct w1_master * dev)
113 res = dev->bus_master->read_byte(dev->bus_master->data); 185 res = dev->bus_master->read_byte(dev->bus_master->data);
114 else 186 else
115 for (i = 0; i < 8; ++i) 187 for (i = 0; i < 8; ++i)
116 res |= (w1_read_bit(dev) << i); 188 res |= (w1_touch_bit(dev,1) << i);
117 189
118 return res; 190 return res;
119} 191}
120 192
121void w1_write_block(struct w1_master *dev, u8 *buf, int len) 193/**
194 * Writes a series of bytes.
195 *
196 * @param dev the master device
197 * @param buf pointer to the data to write
198 * @param len the number of bytes to write
199 * @return the byte read
200 */
201void w1_write_block(struct w1_master *dev, const u8 *buf, int len)
122{ 202{
123 int i; 203 int i;
124 204
@@ -129,6 +209,14 @@ void w1_write_block(struct w1_master *dev, u8 *buf, int len)
129 w1_write_8(dev, buf[i]); 209 w1_write_8(dev, buf[i]);
130} 210}
131 211
212/**
213 * Reads a series of bytes.
214 *
215 * @param dev the master device
216 * @param buf pointer to the buffer to fill
217 * @param len the number of bytes to read
218 * @return the number of bytes read
219 */
132u8 w1_read_block(struct w1_master *dev, u8 *buf, int len) 220u8 w1_read_block(struct w1_master *dev, u8 *buf, int len)
133{ 221{
134 int i; 222 int i;
@@ -145,9 +233,15 @@ u8 w1_read_block(struct w1_master *dev, u8 *buf, int len)
145 return ret; 233 return ret;
146} 234}
147 235
236/**
237 * Issues a reset bus sequence.
238 *
239 * @param dev The bus master pointer
240 * @return 0=Device present, 1=No device present or error
241 */
148int w1_reset_bus(struct w1_master *dev) 242int w1_reset_bus(struct w1_master *dev)
149{ 243{
150 int result = 0; 244 int result;
151 245
152 if (dev->bus_master->reset_bus) 246 if (dev->bus_master->reset_bus)
153 result = dev->bus_master->reset_bus(dev->bus_master->data) & 0x1; 247 result = dev->bus_master->reset_bus(dev->bus_master->data) & 0x1;
@@ -180,12 +274,11 @@ void w1_search_devices(struct w1_master *dev, w1_slave_found_callback cb)
180 if (dev->bus_master->search) 274 if (dev->bus_master->search)
181 dev->bus_master->search(dev->bus_master->data, cb); 275 dev->bus_master->search(dev->bus_master->data, cb);
182 else 276 else
183 w1_search(dev); 277 w1_search(dev, cb);
184} 278}
185 279
186EXPORT_SYMBOL(w1_write_bit); 280EXPORT_SYMBOL(w1_touch_bit);
187EXPORT_SYMBOL(w1_write_8); 281EXPORT_SYMBOL(w1_write_8);
188EXPORT_SYMBOL(w1_read_bit);
189EXPORT_SYMBOL(w1_read_8); 282EXPORT_SYMBOL(w1_read_8);
190EXPORT_SYMBOL(w1_reset_bus); 283EXPORT_SYMBOL(w1_reset_bus);
191EXPORT_SYMBOL(w1_calc_crc8); 284EXPORT_SYMBOL(w1_calc_crc8);
diff --git a/drivers/w1/w1_io.h b/drivers/w1/w1_io.h
index 6c573005a712..af5829778aaa 100644
--- a/drivers/w1/w1_io.h
+++ b/drivers/w1/w1_io.h
@@ -1,8 +1,8 @@
1/* 1/*
2 * w1_io.h 2 * w1_io.h
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -26,13 +26,12 @@
26 26
27void w1_delay(unsigned long); 27void w1_delay(unsigned long);
28u8 w1_touch_bit(struct w1_master *, int); 28u8 w1_touch_bit(struct w1_master *, int);
29void w1_write_bit(struct w1_master *, int); 29u8 w1_triplet(struct w1_master *dev, int bdir);
30void w1_write_8(struct w1_master *, u8); 30void w1_write_8(struct w1_master *, u8);
31u8 w1_read_bit(struct w1_master *);
32u8 w1_read_8(struct w1_master *); 31u8 w1_read_8(struct w1_master *);
33int w1_reset_bus(struct w1_master *); 32int w1_reset_bus(struct w1_master *);
34u8 w1_calc_crc8(u8 *, int); 33u8 w1_calc_crc8(u8 *, int);
35void w1_write_block(struct w1_master *, u8 *, int); 34void w1_write_block(struct w1_master *, const u8 *, int);
36u8 w1_read_block(struct w1_master *, u8 *, int); 35u8 w1_read_block(struct w1_master *, u8 *, int);
37void w1_search_devices(struct w1_master *dev, w1_slave_found_callback cb); 36void w1_search_devices(struct w1_master *dev, w1_slave_found_callback cb);
38 37
diff --git a/drivers/w1/w1_log.h b/drivers/w1/w1_log.h
index a6bf6f44dce2..fe6bdf43380f 100644
--- a/drivers/w1/w1_log.h
+++ b/drivers/w1/w1_log.h
@@ -1,8 +1,8 @@
1/* 1/*
2 * w1_log.h 2 * w1_log.h
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/w1/w1_netlink.h b/drivers/w1/w1_netlink.h
index ea1b530abad0..8615756946df 100644
--- a/drivers/w1/w1_netlink.h
+++ b/drivers/w1/w1_netlink.h
@@ -33,13 +33,13 @@ enum w1_netlink_message_types {
33 W1_MASTER_REMOVE, 33 W1_MASTER_REMOVE,
34}; 34};
35 35
36struct w1_netlink_msg 36struct w1_netlink_msg
37{ 37{
38 __u8 type; 38 __u8 type;
39 __u8 reserved[3]; 39 __u8 reserved[3];
40 union 40 union
41 { 41 {
42 struct w1_reg_num id; 42 struct w1_reg_num id;
43 __u64 w1_id; 43 __u64 w1_id;
44 struct 44 struct
45 { 45 {
diff --git a/drivers/w1/w1_smem.c b/drivers/w1/w1_smem.c
index 674eb75a9bad..70d2d469963c 100644
--- a/drivers/w1/w1_smem.c
+++ b/drivers/w1/w1_smem.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * w1_smem.c 2 * w1_smem.c
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the smems of the GNU General Public License as published by 8 * it under the smems of the GNU General Public License as published by
@@ -37,14 +37,11 @@ MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");
37MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, 64bit memory family."); 37MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, 64bit memory family.");
38 38
39static ssize_t w1_smem_read_name(struct device *, struct device_attribute *attr, char *); 39static ssize_t w1_smem_read_name(struct device *, struct device_attribute *attr, char *);
40static ssize_t w1_smem_read_val(struct device *, struct device_attribute *attr, char *);
41static ssize_t w1_smem_read_bin(struct kobject *, char *, loff_t, size_t); 40static ssize_t w1_smem_read_bin(struct kobject *, char *, loff_t, size_t);
42 41
43static struct w1_family_ops w1_smem_fops = { 42static struct w1_family_ops w1_smem_fops = {
44 .rname = &w1_smem_read_name, 43 .rname = &w1_smem_read_name,
45 .rbin = &w1_smem_read_bin, 44 .rbin = &w1_smem_read_bin,
46 .rval = &w1_smem_read_val,
47 .rvalname = "id",
48}; 45};
49 46
50static ssize_t w1_smem_read_name(struct device *dev, struct device_attribute *attr, char *buf) 47static ssize_t w1_smem_read_name(struct device *dev, struct device_attribute *attr, char *buf)
@@ -54,23 +51,10 @@ static ssize_t w1_smem_read_name(struct device *dev, struct device_attribute *at
54 return sprintf(buf, "%s\n", sl->name); 51 return sprintf(buf, "%s\n", sl->name);
55} 52}
56 53
57static ssize_t w1_smem_read_val(struct device *dev, struct device_attribute *attr, char *buf)
58{
59 struct w1_slave *sl = container_of(dev, struct w1_slave, dev);
60 int i;
61 ssize_t count = 0;
62
63 for (i = 0; i < 8; ++i)
64 count += sprintf(buf + count, "%02x ", ((u8 *)&sl->reg_num)[i]);
65 count += sprintf(buf + count, "\n");
66
67 return count;
68}
69
70static ssize_t w1_smem_read_bin(struct kobject *kobj, char *buf, loff_t off, size_t count) 54static ssize_t w1_smem_read_bin(struct kobject *kobj, char *buf, loff_t off, size_t count)
71{ 55{
72 struct w1_slave *sl = container_of(container_of(kobj, struct device, kobj), 56 struct w1_slave *sl = container_of(container_of(kobj, struct device, kobj),
73 struct w1_slave, dev); 57 struct w1_slave, dev);
74 int i; 58 int i;
75 59
76 atomic_inc(&sl->refcnt); 60 atomic_inc(&sl->refcnt);
@@ -90,7 +74,7 @@ static ssize_t w1_smem_read_bin(struct kobject *kobj, char *buf, loff_t off, siz
90 for (i = 0; i < 8; ++i) 74 for (i = 0; i < 8; ++i)
91 count += sprintf(buf + count, "%02x ", ((u8 *)&sl->reg_num)[i]); 75 count += sprintf(buf + count, "%02x ", ((u8 *)&sl->reg_num)[i]);
92 count += sprintf(buf + count, "\n"); 76 count += sprintf(buf + count, "\n");
93 77
94out: 78out:
95 up(&sl->master->mutex); 79 up(&sl->master->mutex);
96out_dec: 80out_dec:
@@ -99,19 +83,37 @@ out_dec:
99 return count; 83 return count;
100} 84}
101 85
102static struct w1_family w1_smem_family = { 86static struct w1_family w1_smem_family_01 = {
103 .fid = W1_FAMILY_SMEM, 87 .fid = W1_FAMILY_SMEM_01,
88 .fops = &w1_smem_fops,
89};
90
91static struct w1_family w1_smem_family_81 = {
92 .fid = W1_FAMILY_SMEM_81,
104 .fops = &w1_smem_fops, 93 .fops = &w1_smem_fops,
105}; 94};
106 95
107static int __init w1_smem_init(void) 96static int __init w1_smem_init(void)
108{ 97{
109 return w1_register_family(&w1_smem_family); 98 int err;
99
100 err = w1_register_family(&w1_smem_family_01);
101 if (err)
102 return err;
103
104 err = w1_register_family(&w1_smem_family_81);
105 if (err) {
106 w1_unregister_family(&w1_smem_family_01);
107 return err;
108 }
109
110 return 0;
110} 111}
111 112
112static void __exit w1_smem_fini(void) 113static void __exit w1_smem_fini(void)
113{ 114{
114 w1_unregister_family(&w1_smem_family); 115 w1_unregister_family(&w1_smem_family_01);
116 w1_unregister_family(&w1_smem_family_81);
115} 117}
116 118
117module_init(w1_smem_init); 119module_init(w1_smem_init);
diff --git a/drivers/w1/w1_therm.c b/drivers/w1/w1_therm.c
index 70310f7a722e..165526c9360a 100644
--- a/drivers/w1/w1_therm.c
+++ b/drivers/w1/w1_therm.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * w1_therm.c 2 * w1_therm.c
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the therms of the GNU General Public License as published by 8 * it under the therms of the GNU General Public License as published by
@@ -38,19 +38,56 @@ MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");
38MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, temperature family."); 38MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, temperature family.");
39 39
40static u8 bad_roms[][9] = { 40static u8 bad_roms[][9] = {
41 {0xaa, 0x00, 0x4b, 0x46, 0xff, 0xff, 0x0c, 0x10, 0x87}, 41 {0xaa, 0x00, 0x4b, 0x46, 0xff, 0xff, 0x0c, 0x10, 0x87},
42 {} 42 {}
43 }; 43 };
44 44
45static ssize_t w1_therm_read_name(struct device *, struct device_attribute *attr, char *); 45static ssize_t w1_therm_read_name(struct device *, struct device_attribute *attr, char *);
46static ssize_t w1_therm_read_temp(struct device *, struct device_attribute *attr, char *);
47static ssize_t w1_therm_read_bin(struct kobject *, char *, loff_t, size_t); 46static ssize_t w1_therm_read_bin(struct kobject *, char *, loff_t, size_t);
48 47
49static struct w1_family_ops w1_therm_fops = { 48static struct w1_family_ops w1_therm_fops = {
50 .rname = &w1_therm_read_name, 49 .rname = &w1_therm_read_name,
51 .rbin = &w1_therm_read_bin, 50 .rbin = &w1_therm_read_bin,
52 .rval = &w1_therm_read_temp, 51};
53 .rvalname = "temp1_input", 52
53static struct w1_family w1_therm_family_DS18S20 = {
54 .fid = W1_THERM_DS18S20,
55 .fops = &w1_therm_fops,
56};
57
58static struct w1_family w1_therm_family_DS18B20 = {
59 .fid = W1_THERM_DS18B20,
60 .fops = &w1_therm_fops,
61};
62static struct w1_family w1_therm_family_DS1822 = {
63 .fid = W1_THERM_DS1822,
64 .fops = &w1_therm_fops,
65};
66
67struct w1_therm_family_converter
68{
69 u8 broken;
70 u16 reserved;
71 struct w1_family *f;
72 int (*convert)(u8 rom[9]);
73};
74
75static inline int w1_DS18B20_convert_temp(u8 rom[9]);
76static inline int w1_DS18S20_convert_temp(u8 rom[9]);
77
78static struct w1_therm_family_converter w1_therm_families[] = {
79 {
80 .f = &w1_therm_family_DS18S20,
81 .convert = w1_DS18S20_convert_temp
82 },
83 {
84 .f = &w1_therm_family_DS1822,
85 .convert = w1_DS18B20_convert_temp
86 },
87 {
88 .f = &w1_therm_family_DS18B20,
89 .convert = w1_DS18B20_convert_temp
90 },
54}; 91};
55 92
56static ssize_t w1_therm_read_name(struct device *dev, struct device_attribute *attr, char *buf) 93static ssize_t w1_therm_read_name(struct device *dev, struct device_attribute *attr, char *buf)
@@ -60,9 +97,19 @@ static ssize_t w1_therm_read_name(struct device *dev, struct device_attribute *a
60 return sprintf(buf, "%s\n", sl->name); 97 return sprintf(buf, "%s\n", sl->name);
61} 98}
62 99
63static inline int w1_convert_temp(u8 rom[9]) 100static inline int w1_DS18B20_convert_temp(u8 rom[9])
101{
102 int t = (rom[1] << 8) | rom[0];
103 t /= 16;
104 return t;
105}
106
107static inline int w1_DS18S20_convert_temp(u8 rom[9])
64{ 108{
65 int t, h; 109 int t, h;
110
111 if (!rom[7])
112 return 0;
66 113
67 if (rom[1] == 0) 114 if (rom[1] == 0)
68 t = ((s32)rom[0] >> 1)*1000; 115 t = ((s32)rom[0] >> 1)*1000;
@@ -77,11 +124,15 @@ static inline int w1_convert_temp(u8 rom[9])
77 return t; 124 return t;
78} 125}
79 126
80static ssize_t w1_therm_read_temp(struct device *dev, struct device_attribute *attr, char *buf) 127static inline int w1_convert_temp(u8 rom[9], u8 fid)
81{ 128{
82 struct w1_slave *sl = container_of(dev, struct w1_slave, dev); 129 int i;
130
131 for (i=0; i<sizeof(w1_therm_families)/sizeof(w1_therm_families[0]); ++i)
132 if (w1_therm_families[i].f->fid == fid)
133 return w1_therm_families[i].convert(rom);
83 134
84 return sprintf(buf, "%d\n", w1_convert_temp(sl->rom)); 135 return 0;
85} 136}
86 137
87static int w1_therm_check_rom(u8 rom[9]) 138static int w1_therm_check_rom(u8 rom[9])
@@ -98,7 +149,7 @@ static int w1_therm_check_rom(u8 rom[9])
98static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, size_t count) 149static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, size_t count)
99{ 150{
100 struct w1_slave *sl = container_of(container_of(kobj, struct device, kobj), 151 struct w1_slave *sl = container_of(container_of(kobj, struct device, kobj),
101 struct w1_slave, dev); 152 struct w1_slave, dev);
102 struct w1_master *dev = sl->master; 153 struct w1_master *dev = sl->master;
103 u8 rom[9], crc, verdict; 154 u8 rom[9], crc, verdict;
104 int i, max_trying = 10; 155 int i, max_trying = 10;
@@ -133,7 +184,7 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si
133 unsigned int tm = 750; 184 unsigned int tm = 750;
134 185
135 memcpy(&match[1], (u64 *) & sl->reg_num, 8); 186 memcpy(&match[1], (u64 *) & sl->reg_num, 8);
136 187
137 w1_write_block(dev, match, 9); 188 w1_write_block(dev, match, 9);
138 189
139 w1_write_8(dev, W1_CONVERT_TEMP); 190 w1_write_8(dev, W1_CONVERT_TEMP);
@@ -146,7 +197,7 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si
146 197
147 if (!w1_reset_bus (dev)) { 198 if (!w1_reset_bus (dev)) {
148 w1_write_block(dev, match, 9); 199 w1_write_block(dev, match, 9);
149 200
150 w1_write_8(dev, W1_READ_SCRATCHPAD); 201 w1_write_8(dev, W1_READ_SCRATCHPAD);
151 if ((count = w1_read_block(dev, rom, 9)) != 9) { 202 if ((count = w1_read_block(dev, rom, 9)) != 9) {
152 dev_warn(&dev->dev, "w1_read_block() returned %d instead of 9.\n", count); 203 dev_warn(&dev->dev, "w1_read_block() returned %d instead of 9.\n", count);
@@ -176,7 +227,7 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si
176 for (i = 0; i < 9; ++i) 227 for (i = 0; i < 9; ++i)
177 count += sprintf(buf + count, "%02x ", sl->rom[i]); 228 count += sprintf(buf + count, "%02x ", sl->rom[i]);
178 229
179 count += sprintf(buf + count, "t=%d\n", w1_convert_temp(rom)); 230 count += sprintf(buf + count, "t=%d\n", w1_convert_temp(rom, sl->family->fid));
180out: 231out:
181 up(&dev->mutex); 232 up(&dev->mutex);
182out_dec: 233out_dec:
@@ -186,19 +237,26 @@ out_dec:
186 return count; 237 return count;
187} 238}
188 239
189static struct w1_family w1_therm_family = {
190 .fid = W1_FAMILY_THERM,
191 .fops = &w1_therm_fops,
192};
193
194static int __init w1_therm_init(void) 240static int __init w1_therm_init(void)
195{ 241{
196 return w1_register_family(&w1_therm_family); 242 int err, i;
243
244 for (i=0; i<sizeof(w1_therm_families)/sizeof(w1_therm_families[0]); ++i) {
245 err = w1_register_family(w1_therm_families[i].f);
246 if (err)
247 w1_therm_families[i].broken = 1;
248 }
249
250 return 0;
197} 251}
198 252
199static void __exit w1_therm_fini(void) 253static void __exit w1_therm_fini(void)
200{ 254{
201 w1_unregister_family(&w1_therm_family); 255 int i;
256
257 for (i=0; i<sizeof(w1_therm_families)/sizeof(w1_therm_families[0]); ++i)
258 if (!w1_therm_families[i].broken)
259 w1_unregister_family(w1_therm_families[i].f);
202} 260}
203 261
204module_init(w1_therm_init); 262module_init(w1_therm_init);
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index c7b2b8890188..9c09641ce907 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -185,6 +185,19 @@ int autofs4_wait(struct autofs_sb_info *,struct dentry *, enum autofs_notify);
185int autofs4_wait_release(struct autofs_sb_info *,autofs_wqt_t,int); 185int autofs4_wait_release(struct autofs_sb_info *,autofs_wqt_t,int);
186void autofs4_catatonic_mode(struct autofs_sb_info *); 186void autofs4_catatonic_mode(struct autofs_sb_info *);
187 187
188static inline int autofs4_follow_mount(struct vfsmount **mnt, struct dentry **dentry)
189{
190 int res = 0;
191
192 while (d_mountpoint(*dentry)) {
193 int followed = follow_down(mnt, dentry);
194 if (!followed)
195 break;
196 res = 1;
197 }
198 return res;
199}
200
188static inline int simple_positive(struct dentry *dentry) 201static inline int simple_positive(struct dentry *dentry)
189{ 202{
190 return dentry->d_inode && !d_unhashed(dentry); 203 return dentry->d_inode && !d_unhashed(dentry);
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index 500425e24fba..feb6ac427d05 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -56,12 +56,9 @@ static int autofs4_check_mount(struct vfsmount *mnt, struct dentry *dentry)
56 mntget(mnt); 56 mntget(mnt);
57 dget(dentry); 57 dget(dentry);
58 58
59 if (!follow_down(&mnt, &dentry)) 59 if (!autofs4_follow_mount(&mnt, &dentry))
60 goto done; 60 goto done;
61 61
62 while (d_mountpoint(dentry) && follow_down(&mnt, &dentry))
63 ;
64
65 /* This is an autofs submount, we can't expire it */ 62 /* This is an autofs submount, we can't expire it */
66 if (is_autofs4_dentry(dentry)) 63 if (is_autofs4_dentry(dentry))
67 goto done; 64 goto done;
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index 3765c047f157..2a771ec66956 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -205,7 +205,11 @@ static int autofs4_dir_open(struct inode *inode, struct file *file)
205 struct vfsmount *fp_mnt = mntget(mnt); 205 struct vfsmount *fp_mnt = mntget(mnt);
206 struct dentry *fp_dentry = dget(dentry); 206 struct dentry *fp_dentry = dget(dentry);
207 207
208 while (follow_down(&fp_mnt, &fp_dentry) && d_mountpoint(fp_dentry)); 208 if (!autofs4_follow_mount(&fp_mnt, &fp_dentry)) {
209 dput(fp_dentry);
210 mntput(fp_mnt);
211 return -ENOENT;
212 }
209 213
210 fp = dentry_open(fp_dentry, fp_mnt, file->f_flags); 214 fp = dentry_open(fp_dentry, fp_mnt, file->f_flags);
211 status = PTR_ERR(fp); 215 status = PTR_ERR(fp);
@@ -302,7 +306,14 @@ static int try_to_fill_dentry(struct dentry *dentry,
302 306
303 DPRINTK("expire done status=%d", status); 307 DPRINTK("expire done status=%d", status);
304 308
305 return 0; 309 /*
310 * If the directory still exists the mount request must
311 * continue otherwise it can't be followed at the right
312 * time during the walk.
313 */
314 status = d_invalidate(dentry);
315 if (status != -EBUSY)
316 return 0;
306 } 317 }
307 318
308 DPRINTK("dentry=%p %.*s ino=%p", 319 DPRINTK("dentry=%p %.*s ino=%p",
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index 5a40d36e5a51..fa2348dcd671 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -191,6 +191,13 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
191 } 191 }
192 192
193 if ( !wq ) { 193 if ( !wq ) {
194 /* Can't wait for an expire if there's no mount */
195 if (notify == NFY_NONE && !d_mountpoint(dentry)) {
196 kfree(name);
197 up(&sbi->wq_sem);
198 return -ENOENT;
199 }
200
194 /* Create a new wait queue */ 201 /* Create a new wait queue */
195 wq = kmalloc(sizeof(struct autofs_wait_queue),GFP_KERNEL); 202 wq = kmalloc(sizeof(struct autofs_wait_queue),GFP_KERNEL);
196 if ( !wq ) { 203 if ( !wq ) {
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
index 009b8920c1ff..dd9baabaf016 100644
--- a/fs/binfmt_aout.c
+++ b/fs/binfmt_aout.c
@@ -316,6 +316,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
316 current->mm->brk = ex.a_bss + 316 current->mm->brk = ex.a_bss +
317 (current->mm->start_brk = N_BSSADDR(ex)); 317 (current->mm->start_brk = N_BSSADDR(ex));
318 current->mm->free_area_cache = current->mm->mmap_base; 318 current->mm->free_area_cache = current->mm->mmap_base;
319 current->mm->cached_hole_size = 0;
319 320
320 set_mm_counter(current->mm, rss, 0); 321 set_mm_counter(current->mm, rss, 0);
321 current->mm->mmap = NULL; 322 current->mm->mmap = NULL;
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index f8f6b6b76179..7976a238f0a3 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -775,6 +775,7 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
775 change some of these later */ 775 change some of these later */
776 set_mm_counter(current->mm, rss, 0); 776 set_mm_counter(current->mm, rss, 0);
777 current->mm->free_area_cache = current->mm->mmap_base; 777 current->mm->free_area_cache = current->mm->mmap_base;
778 current->mm->cached_hole_size = 0;
778 retval = setup_arg_pages(bprm, randomize_stack_top(STACK_TOP), 779 retval = setup_arg_pages(bprm, randomize_stack_top(STACK_TOP),
779 executable_stack); 780 executable_stack);
780 if (retval < 0) { 781 if (retval < 0) {
diff --git a/fs/buffer.c b/fs/buffer.c
index 7e9e409feaa7..0befa724ab98 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -528,7 +528,7 @@ static void free_more_memory(void)
528 for_each_pgdat(pgdat) { 528 for_each_pgdat(pgdat) {
529 zones = pgdat->node_zonelists[GFP_NOFS&GFP_ZONEMASK].zones; 529 zones = pgdat->node_zonelists[GFP_NOFS&GFP_ZONEMASK].zones;
530 if (*zones) 530 if (*zones)
531 try_to_free_pages(zones, GFP_NOFS, 0); 531 try_to_free_pages(zones, GFP_NOFS);
532 } 532 }
533} 533}
534 534
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 2af3338f891b..3a9b6d179cbd 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -122,6 +122,9 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
122 122
123 start_addr = mm->free_area_cache; 123 start_addr = mm->free_area_cache;
124 124
125 if (len <= mm->cached_hole_size)
126 start_addr = TASK_UNMAPPED_BASE;
127
125full_search: 128full_search:
126 addr = ALIGN(start_addr, HPAGE_SIZE); 129 addr = ALIGN(start_addr, HPAGE_SIZE);
127 130
diff --git a/fs/isofs/dir.c b/fs/isofs/dir.c
index 6030956b894b..7901ac9f97ab 100644
--- a/fs/isofs/dir.c
+++ b/fs/isofs/dir.c
@@ -193,12 +193,17 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp,
193 193
194 /* Handle everything else. Do name translation if there 194 /* Handle everything else. Do name translation if there
195 is no Rock Ridge NM field. */ 195 is no Rock Ridge NM field. */
196 if (sbi->s_unhide == 'n') { 196
197 /* Do not report hidden or associated files */ 197 /*
198 if (de->flags[-sbi->s_high_sierra] & 5) { 198 * Do not report hidden files if so instructed, or associated
199 filp->f_pos += de_len; 199 * files unless instructed to do so
200 continue; 200 */
201 } 201 if ((sbi->s_hide == 'y' &&
202 (de->flags[-sbi->s_high_sierra] & 1)) ||
203 (sbi->s_showassoc =='n' &&
204 (de->flags[-sbi->s_high_sierra] & 4))) {
205 filp->f_pos += de_len;
206 continue;
202 } 207 }
203 208
204 map = 1; 209 map = 1;
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index abd7b12eeca7..1652de1b6cb9 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -28,11 +28,6 @@
28 28
29#define BEQUIET 29#define BEQUIET
30 30
31#ifdef LEAK_CHECK
32static int check_malloc;
33static int check_bread;
34#endif
35
36static int isofs_hashi(struct dentry *parent, struct qstr *qstr); 31static int isofs_hashi(struct dentry *parent, struct qstr *qstr);
37static int isofs_hash(struct dentry *parent, struct qstr *qstr); 32static int isofs_hash(struct dentry *parent, struct qstr *qstr);
38static int isofs_dentry_cmpi(struct dentry *dentry, struct qstr *a, struct qstr *b); 33static int isofs_dentry_cmpi(struct dentry *dentry, struct qstr *a, struct qstr *b);
@@ -55,11 +50,6 @@ static void isofs_put_super(struct super_block *sb)
55 } 50 }
56#endif 51#endif
57 52
58#ifdef LEAK_CHECK
59 printk("Outstanding mallocs:%d, outstanding buffers: %d\n",
60 check_malloc, check_bread);
61#endif
62
63 kfree(sbi); 53 kfree(sbi);
64 sb->s_fs_info = NULL; 54 sb->s_fs_info = NULL;
65 return; 55 return;
@@ -73,7 +63,7 @@ static kmem_cache_t *isofs_inode_cachep;
73static struct inode *isofs_alloc_inode(struct super_block *sb) 63static struct inode *isofs_alloc_inode(struct super_block *sb)
74{ 64{
75 struct iso_inode_info *ei; 65 struct iso_inode_info *ei;
76 ei = (struct iso_inode_info *)kmem_cache_alloc(isofs_inode_cachep, SLAB_KERNEL); 66 ei = kmem_cache_alloc(isofs_inode_cachep, SLAB_KERNEL);
77 if (!ei) 67 if (!ei)
78 return NULL; 68 return NULL;
79 return &ei->vfs_inode; 69 return &ei->vfs_inode;
@@ -84,9 +74,9 @@ static void isofs_destroy_inode(struct inode *inode)
84 kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode)); 74 kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode));
85} 75}
86 76
87static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 77static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags)
88{ 78{
89 struct iso_inode_info *ei = (struct iso_inode_info *) foo; 79 struct iso_inode_info *ei = foo;
90 80
91 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == 81 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
92 SLAB_CTOR_CONSTRUCTOR) 82 SLAB_CTOR_CONSTRUCTOR)
@@ -107,7 +97,8 @@ static int init_inodecache(void)
107static void destroy_inodecache(void) 97static void destroy_inodecache(void)
108{ 98{
109 if (kmem_cache_destroy(isofs_inode_cachep)) 99 if (kmem_cache_destroy(isofs_inode_cachep))
110 printk(KERN_INFO "iso_inode_cache: not all structures were freed\n"); 100 printk(KERN_INFO "iso_inode_cache: not all structures were "
101 "freed\n");
111} 102}
112 103
113static int isofs_remount(struct super_block *sb, int *flags, char *data) 104static int isofs_remount(struct super_block *sb, int *flags, char *data)
@@ -144,7 +135,7 @@ static struct dentry_operations isofs_dentry_ops[] = {
144 { 135 {
145 .d_hash = isofs_hashi_ms, 136 .d_hash = isofs_hashi_ms,
146 .d_compare = isofs_dentry_cmpi_ms, 137 .d_compare = isofs_dentry_cmpi_ms,
147 } 138 },
148#endif 139#endif
149}; 140};
150 141
@@ -153,7 +144,8 @@ struct iso9660_options{
153 char rock; 144 char rock;
154 char joliet; 145 char joliet;
155 char cruft; 146 char cruft;
156 char unhide; 147 char hide;
148 char showassoc;
157 char nocompress; 149 char nocompress;
158 unsigned char check; 150 unsigned char check;
159 unsigned int blocksize; 151 unsigned int blocksize;
@@ -219,8 +211,8 @@ isofs_hashi_common(struct dentry *dentry, struct qstr *qstr, int ms)
219/* 211/*
220 * Case insensitive compare of two isofs names. 212 * Case insensitive compare of two isofs names.
221 */ 213 */
222static int 214static int isofs_dentry_cmpi_common(struct dentry *dentry, struct qstr *a,
223isofs_dentry_cmpi_common(struct dentry *dentry,struct qstr *a,struct qstr *b,int ms) 215 struct qstr *b, int ms)
224{ 216{
225 int alen, blen; 217 int alen, blen;
226 218
@@ -243,8 +235,8 @@ isofs_dentry_cmpi_common(struct dentry *dentry,struct qstr *a,struct qstr *b,int
243/* 235/*
244 * Case sensitive compare of two isofs names. 236 * Case sensitive compare of two isofs names.
245 */ 237 */
246static int 238static int isofs_dentry_cmp_common(struct dentry *dentry, struct qstr *a,
247isofs_dentry_cmp_common(struct dentry *dentry,struct qstr *a,struct qstr *b,int ms) 239 struct qstr *b, int ms)
248{ 240{
249 int alen, blen; 241 int alen, blen;
250 242
@@ -318,13 +310,15 @@ enum {
318 Opt_block, Opt_check_r, Opt_check_s, Opt_cruft, Opt_gid, Opt_ignore, 310 Opt_block, Opt_check_r, Opt_check_s, Opt_cruft, Opt_gid, Opt_ignore,
319 Opt_iocharset, Opt_map_a, Opt_map_n, Opt_map_o, Opt_mode, Opt_nojoliet, 311 Opt_iocharset, Opt_map_a, Opt_map_n, Opt_map_o, Opt_mode, Opt_nojoliet,
320 Opt_norock, Opt_sb, Opt_session, Opt_uid, Opt_unhide, Opt_utf8, Opt_err, 312 Opt_norock, Opt_sb, Opt_session, Opt_uid, Opt_unhide, Opt_utf8, Opt_err,
321 Opt_nocompress, 313 Opt_nocompress, Opt_hide, Opt_showassoc,
322}; 314};
323 315
324static match_table_t tokens = { 316static match_table_t tokens = {
325 {Opt_norock, "norock"}, 317 {Opt_norock, "norock"},
326 {Opt_nojoliet, "nojoliet"}, 318 {Opt_nojoliet, "nojoliet"},
327 {Opt_unhide, "unhide"}, 319 {Opt_unhide, "unhide"},
320 {Opt_hide, "hide"},
321 {Opt_showassoc, "showassoc"},
328 {Opt_cruft, "cruft"}, 322 {Opt_cruft, "cruft"},
329 {Opt_utf8, "utf8"}, 323 {Opt_utf8, "utf8"},
330 {Opt_iocharset, "iocharset=%s"}, 324 {Opt_iocharset, "iocharset=%s"},
@@ -356,7 +350,7 @@ static match_table_t tokens = {
356 {Opt_err, NULL} 350 {Opt_err, NULL}
357}; 351};
358 352
359static int parse_options(char *options, struct iso9660_options * popt) 353static int parse_options(char *options, struct iso9660_options *popt)
360{ 354{
361 char *p; 355 char *p;
362 int option; 356 int option;
@@ -365,7 +359,8 @@ static int parse_options(char *options, struct iso9660_options * popt)
365 popt->rock = 'y'; 359 popt->rock = 'y';
366 popt->joliet = 'y'; 360 popt->joliet = 'y';
367 popt->cruft = 'n'; 361 popt->cruft = 'n';
368 popt->unhide = 'n'; 362 popt->hide = 'n';
363 popt->showassoc = 'n';
369 popt->check = 'u'; /* unset */ 364 popt->check = 'u'; /* unset */
370 popt->nocompress = 0; 365 popt->nocompress = 0;
371 popt->blocksize = 1024; 366 popt->blocksize = 1024;
@@ -398,8 +393,12 @@ static int parse_options(char *options, struct iso9660_options * popt)
398 case Opt_nojoliet: 393 case Opt_nojoliet:
399 popt->joliet = 'n'; 394 popt->joliet = 'n';
400 break; 395 break;
396 case Opt_hide:
397 popt->hide = 'y';
398 break;
401 case Opt_unhide: 399 case Opt_unhide:
402 popt->unhide = 'y'; 400 case Opt_showassoc:
401 popt->showassoc = 'y';
403 break; 402 break;
404 case Opt_cruft: 403 case Opt_cruft:
405 popt->cruft = 'y'; 404 popt->cruft = 'y';
@@ -493,7 +492,7 @@ static int parse_options(char *options, struct iso9660_options * popt)
493 */ 492 */
494#define WE_OBEY_THE_WRITTEN_STANDARDS 1 493#define WE_OBEY_THE_WRITTEN_STANDARDS 1
495 494
496static unsigned int isofs_get_last_session(struct super_block *sb,s32 session ) 495static unsigned int isofs_get_last_session(struct super_block *sb, s32 session)
497{ 496{
498 struct cdrom_multisession ms_info; 497 struct cdrom_multisession ms_info;
499 unsigned int vol_desc_start; 498 unsigned int vol_desc_start;
@@ -518,7 +517,8 @@ static unsigned int isofs_get_last_session(struct super_block *sb,s32 session )
518 printk(KERN_ERR "Invalid session number or type of track\n"); 517 printk(KERN_ERR "Invalid session number or type of track\n");
519 } 518 }
520 i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long) &ms_info); 519 i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long) &ms_info);
521 if(session > 0) printk(KERN_ERR "Invalid session number\n"); 520 if (session > 0)
521 printk(KERN_ERR "Invalid session number\n");
522#if 0 522#if 0
523 printk("isofs.inode: CDROMMULTISESSION: rc=%d\n",i); 523 printk("isofs.inode: CDROMMULTISESSION: rc=%d\n",i);
524 if (i==0) { 524 if (i==0) {
@@ -557,13 +557,13 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
557 struct iso9660_options opt; 557 struct iso9660_options opt;
558 struct isofs_sb_info * sbi; 558 struct isofs_sb_info * sbi;
559 559
560 sbi = kmalloc(sizeof(struct isofs_sb_info), GFP_KERNEL); 560 sbi = kmalloc(sizeof(*sbi), GFP_KERNEL);
561 if (!sbi) 561 if (!sbi)
562 return -ENOMEM; 562 return -ENOMEM;
563 s->s_fs_info = sbi; 563 s->s_fs_info = sbi;
564 memset(sbi, 0, sizeof(struct isofs_sb_info)); 564 memset(sbi, 0, sizeof(*sbi));
565 565
566 if (!parse_options((char *) data, &opt)) 566 if (!parse_options((char *)data, &opt))
567 goto out_freesbi; 567 goto out_freesbi;
568 568
569 /* 569 /*
@@ -792,7 +792,8 @@ root_found:
792 sbi->s_rock = (opt.rock == 'y' ? 2 : 0); 792 sbi->s_rock = (opt.rock == 'y' ? 2 : 0);
793 sbi->s_rock_offset = -1; /* initial offset, will guess until SP is found*/ 793 sbi->s_rock_offset = -1; /* initial offset, will guess until SP is found*/
794 sbi->s_cruft = opt.cruft; 794 sbi->s_cruft = opt.cruft;
795 sbi->s_unhide = opt.unhide; 795 sbi->s_hide = opt.hide;
796 sbi->s_showassoc = opt.showassoc;
796 sbi->s_uid = opt.uid; 797 sbi->s_uid = opt.uid;
797 sbi->s_gid = opt.gid; 798 sbi->s_gid = opt.gid;
798 sbi->s_utf8 = opt.utf8; 799 sbi->s_utf8 = opt.utf8;
@@ -1002,7 +1003,6 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock_s,
1002 rv++; 1003 rv++;
1003 } 1004 }
1004 1005
1005
1006abort: 1006abort:
1007 unlock_kernel(); 1007 unlock_kernel();
1008 return rv; 1008 return rv;
@@ -1014,7 +1014,7 @@ abort:
1014static int isofs_get_block(struct inode *inode, sector_t iblock, 1014static int isofs_get_block(struct inode *inode, sector_t iblock,
1015 struct buffer_head *bh_result, int create) 1015 struct buffer_head *bh_result, int create)
1016{ 1016{
1017 if ( create ) { 1017 if (create) {
1018 printk("isofs_get_block: Kernel tries to allocate a block\n"); 1018 printk("isofs_get_block: Kernel tries to allocate a block\n");
1019 return -EROFS; 1019 return -EROFS;
1020 } 1020 }
@@ -1061,19 +1061,17 @@ static struct address_space_operations isofs_aops = {
1061 1061
1062static inline void test_and_set_uid(uid_t *p, uid_t value) 1062static inline void test_and_set_uid(uid_t *p, uid_t value)
1063{ 1063{
1064 if(value) { 1064 if (value)
1065 *p = value; 1065 *p = value;
1066 }
1067} 1066}
1068 1067
1069static inline void test_and_set_gid(gid_t *p, gid_t value) 1068static inline void test_and_set_gid(gid_t *p, gid_t value)
1070{ 1069{
1071 if(value) { 1070 if (value)
1072 *p = value; 1071 *p = value;
1073 }
1074} 1072}
1075 1073
1076static int isofs_read_level3_size(struct inode * inode) 1074static int isofs_read_level3_size(struct inode *inode)
1077{ 1075{
1078 unsigned long bufsize = ISOFS_BUFFER_SIZE(inode); 1076 unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
1079 int high_sierra = ISOFS_SB(inode->i_sb)->s_high_sierra; 1077 int high_sierra = ISOFS_SB(inode->i_sb)->s_high_sierra;
@@ -1136,7 +1134,7 @@ static int isofs_read_level3_size(struct inode * inode)
1136 bh = sb_bread(inode->i_sb, block); 1134 bh = sb_bread(inode->i_sb, block);
1137 if (!bh) 1135 if (!bh)
1138 goto out_noread; 1136 goto out_noread;
1139 memcpy((void *) tmpde + slop, bh->b_data, offset); 1137 memcpy((void *)tmpde+slop, bh->b_data, offset);
1140 } 1138 }
1141 de = tmpde; 1139 de = tmpde;
1142 } 1140 }
@@ -1150,12 +1148,11 @@ static int isofs_read_level3_size(struct inode * inode)
1150 more_entries = de->flags[-high_sierra] & 0x80; 1148 more_entries = de->flags[-high_sierra] & 0x80;
1151 1149
1152 i++; 1150 i++;
1153 if(i > 100) 1151 if (i > 100)
1154 goto out_toomany; 1152 goto out_toomany;
1155 } while(more_entries); 1153 } while (more_entries);
1156out: 1154out:
1157 if (tmpde) 1155 kfree(tmpde);
1158 kfree(tmpde);
1159 if (bh) 1156 if (bh)
1160 brelse(bh); 1157 brelse(bh);
1161 return 0; 1158 return 0;
@@ -1179,7 +1176,7 @@ out_toomany:
1179 goto out; 1176 goto out;
1180} 1177}
1181 1178
1182static void isofs_read_inode(struct inode * inode) 1179static void isofs_read_inode(struct inode *inode)
1183{ 1180{
1184 struct super_block *sb = inode->i_sb; 1181 struct super_block *sb = inode->i_sb;
1185 struct isofs_sb_info *sbi = ISOFS_SB(sb); 1182 struct isofs_sb_info *sbi = ISOFS_SB(sb);
@@ -1249,7 +1246,7 @@ static void isofs_read_inode(struct inode * inode)
1249 ei->i_format_parm[2] = 0; 1246 ei->i_format_parm[2] = 0;
1250 1247
1251 ei->i_section_size = isonum_733 (de->size); 1248 ei->i_section_size = isonum_733 (de->size);
1252 if(de->flags[-high_sierra] & 0x80) { 1249 if (de->flags[-high_sierra] & 0x80) {
1253 if(isofs_read_level3_size(inode)) goto fail; 1250 if(isofs_read_level3_size(inode)) goto fail;
1254 } else { 1251 } else {
1255 ei->i_next_section_block = 0; 1252 ei->i_next_section_block = 0;
@@ -1336,16 +1333,16 @@ static void isofs_read_inode(struct inode * inode)
1336 /* XXX - parse_rock_ridge_inode() had already set i_rdev. */ 1333 /* XXX - parse_rock_ridge_inode() had already set i_rdev. */
1337 init_special_inode(inode, inode->i_mode, inode->i_rdev); 1334 init_special_inode(inode, inode->i_mode, inode->i_rdev);
1338 1335
1339 out: 1336out:
1340 if (tmpde) 1337 if (tmpde)
1341 kfree(tmpde); 1338 kfree(tmpde);
1342 if (bh) 1339 if (bh)
1343 brelse(bh); 1340 brelse(bh);
1344 return; 1341 return;
1345 1342
1346 out_badread: 1343out_badread:
1347 printk(KERN_WARNING "ISOFS: unable to read i-node block\n"); 1344 printk(KERN_WARNING "ISOFS: unable to read i-node block\n");
1348 fail: 1345fail:
1349 make_bad_inode(inode); 1346 make_bad_inode(inode);
1350 goto out; 1347 goto out;
1351} 1348}
@@ -1394,11 +1391,8 @@ struct inode *isofs_iget(struct super_block *sb,
1394 1391
1395 hashval = (block << sb->s_blocksize_bits) | offset; 1392 hashval = (block << sb->s_blocksize_bits) | offset;
1396 1393
1397 inode = iget5_locked(sb, 1394 inode = iget5_locked(sb, hashval, &isofs_iget5_test,
1398 hashval, 1395 &isofs_iget5_set, &data);
1399 &isofs_iget5_test,
1400 &isofs_iget5_set,
1401 &data);
1402 1396
1403 if (inode && (inode->i_state & I_NEW)) { 1397 if (inode && (inode->i_state & I_NEW)) {
1404 sb->s_op->read_inode(inode); 1398 sb->s_op->read_inode(inode);
@@ -1408,36 +1402,6 @@ struct inode *isofs_iget(struct super_block *sb,
1408 return inode; 1402 return inode;
1409} 1403}
1410 1404
1411#ifdef LEAK_CHECK
1412#undef malloc
1413#undef free_s
1414#undef sb_bread
1415#undef brelse
1416
1417void * leak_check_malloc(unsigned int size){
1418 void * tmp;
1419 check_malloc++;
1420 tmp = kmalloc(size, GFP_KERNEL);
1421 return tmp;
1422}
1423
1424void leak_check_free_s(void * obj, int size){
1425 check_malloc--;
1426 return kfree(obj);
1427}
1428
1429struct buffer_head * leak_check_bread(struct super_block *sb, int block){
1430 check_bread++;
1431 return sb_bread(sb, block);
1432}
1433
1434void leak_check_brelse(struct buffer_head * bh){
1435 check_bread--;
1436 return brelse(bh);
1437}
1438
1439#endif
1440
1441static struct super_block *isofs_get_sb(struct file_system_type *fs_type, 1405static struct super_block *isofs_get_sb(struct file_system_type *fs_type,
1442 int flags, const char *dev_name, void *data) 1406 int flags, const char *dev_name, void *data)
1443{ 1407{
diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h
index 9ce7b51fb614..38c75151fc66 100644
--- a/fs/isofs/isofs.h
+++ b/fs/isofs/isofs.h
@@ -47,6 +47,8 @@ struct isofs_sb_info {
47 unsigned char s_nosuid; 47 unsigned char s_nosuid;
48 unsigned char s_nodev; 48 unsigned char s_nodev;
49 unsigned char s_nocompress; 49 unsigned char s_nocompress;
50 unsigned char s_hide;
51 unsigned char s_showassoc;
50 52
51 mode_t s_mode; 53 mode_t s_mode;
52 gid_t s_gid; 54 gid_t s_gid;
diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c
index 690edf37173c..e37e82b7cbf0 100644
--- a/fs/isofs/namei.c
+++ b/fs/isofs/namei.c
@@ -131,14 +131,16 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry,
131 } 131 }
132 132
133 /* 133 /*
134 * Skip hidden or associated files unless unhide is set 134 * Skip hidden or associated files unless hide or showassoc,
135 * respectively, is set
135 */ 136 */
136 match = 0; 137 match = 0;
137 if (dlen > 0 && 138 if (dlen > 0 &&
138 (!(de->flags[-sbi->s_high_sierra] & 5) 139 (sbi->s_hide =='n' ||
139 || sbi->s_unhide == 'y')) 140 (!(de->flags[-sbi->s_high_sierra] & 1))) &&
140 { 141 (sbi->s_showassoc =='y' ||
141 match = (isofs_cmp(dentry,dpnt,dlen) == 0); 142 (!(de->flags[-sbi->s_high_sierra] & 4)))) {
143 match = (isofs_cmp(dentry, dpnt, dlen) == 0);
142 } 144 }
143 if (match) { 145 if (match) {
144 isofs_normalize_block_and_offset(de, 146 isofs_normalize_block_and_offset(de,
@@ -146,11 +148,11 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry,
146 &offset_saved); 148 &offset_saved);
147 *block_rv = block_saved; 149 *block_rv = block_saved;
148 *offset_rv = offset_saved; 150 *offset_rv = offset_saved;
149 if (bh) brelse(bh); 151 brelse(bh);
150 return 1; 152 return 1;
151 } 153 }
152 } 154 }
153 if (bh) brelse(bh); 155 brelse(bh);
154 return 0; 156 return 0;
155} 157}
156 158
diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c
index 089e79c65585..4326cb47f8fa 100644
--- a/fs/isofs/rock.c
+++ b/fs/isofs/rock.c
@@ -13,352 +13,542 @@
13#include "isofs.h" 13#include "isofs.h"
14#include "rock.h" 14#include "rock.h"
15 15
16/* These functions are designed to read the system areas of a directory record 16/*
17 * These functions are designed to read the system areas of a directory record
17 * and extract relevant information. There are different functions provided 18 * and extract relevant information. There are different functions provided
18 * depending upon what information we need at the time. One function fills 19 * depending upon what information we need at the time. One function fills
19 * out an inode structure, a second one extracts a filename, a third one 20 * out an inode structure, a second one extracts a filename, a third one
20 * returns a symbolic link name, and a fourth one returns the extent number 21 * returns a symbolic link name, and a fourth one returns the extent number
21 * for the file. */ 22 * for the file.
22 23 */
23#define SIG(A,B) ((A) | ((B) << 8)) /* isonum_721() */ 24
24 25#define SIG(A,B) ((A) | ((B) << 8)) /* isonum_721() */
25 26
26/* This is a way of ensuring that we have something in the system 27struct rock_state {
27 use fields that is compatible with Rock Ridge */ 28 void *buffer;
28#define CHECK_SP(FAIL) \ 29 unsigned char *chr;
29 if(rr->u.SP.magic[0] != 0xbe) FAIL; \ 30 int len;
30 if(rr->u.SP.magic[1] != 0xef) FAIL; \ 31 int cont_size;
31 ISOFS_SB(inode->i_sb)->s_rock_offset=rr->u.SP.skip; 32 int cont_extent;
32/* We define a series of macros because each function must do exactly the 33 int cont_offset;
33 same thing in certain places. We use the macros to ensure that everything 34 struct inode *inode;
34 is done correctly */ 35};
35 36
36#define CONTINUE_DECLS \ 37/*
37 int cont_extent = 0, cont_offset = 0, cont_size = 0; \ 38 * This is a way of ensuring that we have something in the system
38 void *buffer = NULL 39 * use fields that is compatible with Rock Ridge. Return zero on success.
39 40 */
40#define CHECK_CE \ 41
41 {cont_extent = isonum_733(rr->u.CE.extent); \ 42static int check_sp(struct rock_ridge *rr, struct inode *inode)
42 cont_offset = isonum_733(rr->u.CE.offset); \
43 cont_size = isonum_733(rr->u.CE.size);}
44
45#define SETUP_ROCK_RIDGE(DE,CHR,LEN) \
46 {LEN= sizeof(struct iso_directory_record) + DE->name_len[0]; \
47 if(LEN & 1) LEN++; \
48 CHR = ((unsigned char *) DE) + LEN; \
49 LEN = *((unsigned char *) DE) - LEN; \
50 if (LEN<0) LEN=0; \
51 if (ISOFS_SB(inode->i_sb)->s_rock_offset!=-1) \
52 { \
53 LEN-=ISOFS_SB(inode->i_sb)->s_rock_offset; \
54 CHR+=ISOFS_SB(inode->i_sb)->s_rock_offset; \
55 if (LEN<0) LEN=0; \
56 } \
57}
58
59#define MAYBE_CONTINUE(LABEL,DEV) \
60 {if (buffer) { kfree(buffer); buffer = NULL; } \
61 if (cont_extent){ \
62 int block, offset, offset1; \
63 struct buffer_head * pbh; \
64 buffer = kmalloc(cont_size,GFP_KERNEL); \
65 if (!buffer) goto out; \
66 block = cont_extent; \
67 offset = cont_offset; \
68 offset1 = 0; \
69 pbh = sb_bread(DEV->i_sb, block); \
70 if(pbh){ \
71 if (offset > pbh->b_size || offset + cont_size > pbh->b_size){ \
72 brelse(pbh); \
73 goto out; \
74 } \
75 memcpy(buffer + offset1, pbh->b_data + offset, cont_size - offset1); \
76 brelse(pbh); \
77 chr = (unsigned char *) buffer; \
78 len = cont_size; \
79 cont_extent = 0; \
80 cont_size = 0; \
81 cont_offset = 0; \
82 goto LABEL; \
83 } \
84 printk("Unable to read rock-ridge attributes\n"); \
85 }}
86
87/* return length of name field; 0: not found, -1: to be ignored */
88int get_rock_ridge_filename(struct iso_directory_record * de,
89 char * retname, struct inode * inode)
90{ 43{
91 int len; 44 if (rr->u.SP.magic[0] != 0xbe)
92 unsigned char * chr; 45 return -1;
93 CONTINUE_DECLS; 46 if (rr->u.SP.magic[1] != 0xef)
94 int retnamlen = 0, truncate=0; 47 return -1;
95 48 ISOFS_SB(inode->i_sb)->s_rock_offset = rr->u.SP.skip;
96 if (!ISOFS_SB(inode->i_sb)->s_rock) return 0; 49 return 0;
97 *retname = 0; 50}
98 51
99 SETUP_ROCK_RIDGE(de, chr, len); 52static void setup_rock_ridge(struct iso_directory_record *de,
100 repeat: 53 struct inode *inode, struct rock_state *rs)
101 { 54{
102 struct rock_ridge * rr; 55 rs->len = sizeof(struct iso_directory_record) + de->name_len[0];
103 int sig; 56 if (rs->len & 1)
104 57 (rs->len)++;
105 while (len > 2){ /* There may be one byte for padding somewhere */ 58 rs->chr = (unsigned char *)de + rs->len;
106 rr = (struct rock_ridge *) chr; 59 rs->len = *((unsigned char *)de) - rs->len;
107 if (rr->len < 3) goto out; /* Something got screwed up here */ 60 if (rs->len < 0)
108 sig = isonum_721(chr); 61 rs->len = 0;
109 chr += rr->len; 62
110 len -= rr->len; 63 if (ISOFS_SB(inode->i_sb)->s_rock_offset != -1) {
111 if (len < 0) goto out; /* corrupted isofs */ 64 rs->len -= ISOFS_SB(inode->i_sb)->s_rock_offset;
112 65 rs->chr += ISOFS_SB(inode->i_sb)->s_rock_offset;
113 switch(sig){ 66 if (rs->len < 0)
114 case SIG('R','R'): 67 rs->len = 0;
115 if((rr->u.RR.flags[0] & RR_NM) == 0) goto out; 68 }
116 break; 69}
117 case SIG('S','P'): 70
118 CHECK_SP(goto out); 71static void init_rock_state(struct rock_state *rs, struct inode *inode)
119 break; 72{
120 case SIG('C','E'): 73 memset(rs, 0, sizeof(*rs));
121 CHECK_CE; 74 rs->inode = inode;
122 break; 75}
123 case SIG('N','M'): 76
124 if (truncate) break; 77/*
125 if (rr->len < 5) break; 78 * Returns 0 if the caller should continue scanning, 1 if the scan must end
126 /* 79 * and -ve on error.
127 * If the flags are 2 or 4, this indicates '.' or '..'. 80 */
128 * We don't want to do anything with this, because it 81static int rock_continue(struct rock_state *rs)
129 * screws up the code that calls us. We don't really 82{
130 * care anyways, since we can just use the non-RR 83 int ret = 1;
131 * name. 84 int blocksize = 1 << rs->inode->i_blkbits;
132 */ 85 const int min_de_size = offsetof(struct rock_ridge, u);
133 if (rr->u.NM.flags & 6) { 86
134 break; 87 kfree(rs->buffer);
88 rs->buffer = NULL;
89
90 if ((unsigned)rs->cont_offset > blocksize - min_de_size ||
91 (unsigned)rs->cont_size > blocksize ||
92 (unsigned)(rs->cont_offset + rs->cont_size) > blocksize) {
93 printk(KERN_NOTICE "rock: corrupted directory entry. "
94 "extent=%d, offset=%d, size=%d\n",
95 rs->cont_extent, rs->cont_offset, rs->cont_size);
96 ret = -EIO;
97 goto out;
135 } 98 }
136 99
137 if (rr->u.NM.flags & ~1) { 100 if (rs->cont_extent) {
138 printk("Unsupported NM flag settings (%d)\n",rr->u.NM.flags); 101 struct buffer_head *bh;
139 break; 102
103 rs->buffer = kmalloc(rs->cont_size, GFP_KERNEL);
104 if (!rs->buffer) {
105 ret = -ENOMEM;
106 goto out;
107 }
108 ret = -EIO;
109 bh = sb_bread(rs->inode->i_sb, rs->cont_extent);
110 if (bh) {
111 memcpy(rs->buffer, bh->b_data + rs->cont_offset,
112 rs->cont_size);
113 put_bh(bh);
114 rs->chr = rs->buffer;
115 rs->len = rs->cont_size;
116 rs->cont_extent = 0;
117 rs->cont_size = 0;
118 rs->cont_offset = 0;
119 return 0;
120 }
121 printk("Unable to read rock-ridge attributes\n");
122 }
123out:
124 kfree(rs->buffer);
125 rs->buffer = NULL;
126 return ret;
127}
128
129/*
130 * We think there's a record of type `sig' at rs->chr. Parse the signature
131 * and make sure that there's really room for a record of that type.
132 */
133static int rock_check_overflow(struct rock_state *rs, int sig)
134{
135 int len;
136
137 switch (sig) {
138 case SIG('S', 'P'):
139 len = sizeof(struct SU_SP_s);
140 break;
141 case SIG('C', 'E'):
142 len = sizeof(struct SU_CE_s);
143 break;
144 case SIG('E', 'R'):
145 len = sizeof(struct SU_ER_s);
146 break;
147 case SIG('R', 'R'):
148 len = sizeof(struct RR_RR_s);
149 break;
150 case SIG('P', 'X'):
151 len = sizeof(struct RR_PX_s);
152 break;
153 case SIG('P', 'N'):
154 len = sizeof(struct RR_PN_s);
155 break;
156 case SIG('S', 'L'):
157 len = sizeof(struct RR_SL_s);
158 break;
159 case SIG('N', 'M'):
160 len = sizeof(struct RR_NM_s);
161 break;
162 case SIG('C', 'L'):
163 len = sizeof(struct RR_CL_s);
164 break;
165 case SIG('P', 'L'):
166 len = sizeof(struct RR_PL_s);
167 break;
168 case SIG('T', 'F'):
169 len = sizeof(struct RR_TF_s);
170 break;
171 case SIG('Z', 'F'):
172 len = sizeof(struct RR_ZF_s);
173 break;
174 default:
175 len = 0;
176 break;
140 } 177 }
141 if((strlen(retname) + rr->len - 5) >= 254) { 178 len += offsetof(struct rock_ridge, u);
142 truncate = 1; 179 if (len > rs->len) {
143 break; 180 printk(KERN_NOTICE "rock: directory entry would overflow "
181 "storage\n");
182 printk(KERN_NOTICE "rock: sig=0x%02x, size=%d, remaining=%d\n",
183 sig, len, rs->len);
184 return -EIO;
185 }
186 return 0;
187}
188
189/*
190 * return length of name field; 0: not found, -1: to be ignored
191 */
192int get_rock_ridge_filename(struct iso_directory_record *de,
193 char *retname, struct inode *inode)
194{
195 struct rock_state rs;
196 struct rock_ridge *rr;
197 int sig;
198 int retnamlen = 0;
199 int truncate = 0;
200 int ret = 0;
201
202 if (!ISOFS_SB(inode->i_sb)->s_rock)
203 return 0;
204 *retname = 0;
205
206 init_rock_state(&rs, inode);
207 setup_rock_ridge(de, inode, &rs);
208repeat:
209
210 while (rs.len > 2) { /* There may be one byte for padding somewhere */
211 rr = (struct rock_ridge *)rs.chr;
212 if (rr->len < 3)
213 goto out; /* Something got screwed up here */
214 sig = isonum_721(rs.chr);
215 if (rock_check_overflow(&rs, sig))
216 goto eio;
217 rs.chr += rr->len;
218 rs.len -= rr->len;
219 if (rs.len < 0)
220 goto eio; /* corrupted isofs */
221
222 switch (sig) {
223 case SIG('R', 'R'):
224 if ((rr->u.RR.flags[0] & RR_NM) == 0)
225 goto out;
226 break;
227 case SIG('S', 'P'):
228 if (check_sp(rr, inode))
229 goto out;
230 break;
231 case SIG('C', 'E'):
232 rs.cont_extent = isonum_733(rr->u.CE.extent);
233 rs.cont_offset = isonum_733(rr->u.CE.offset);
234 rs.cont_size = isonum_733(rr->u.CE.size);
235 break;
236 case SIG('N', 'M'):
237 if (truncate)
238 break;
239 if (rr->len < 5)
240 break;
241 /*
242 * If the flags are 2 or 4, this indicates '.' or '..'.
243 * We don't want to do anything with this, because it
244 * screws up the code that calls us. We don't really
245 * care anyways, since we can just use the non-RR
246 * name.
247 */
248 if (rr->u.NM.flags & 6)
249 break;
250
251 if (rr->u.NM.flags & ~1) {
252 printk("Unsupported NM flag settings (%d)\n",
253 rr->u.NM.flags);
254 break;
255 }
256 if ((strlen(retname) + rr->len - 5) >= 254) {
257 truncate = 1;
258 break;
259 }
260 strncat(retname, rr->u.NM.name, rr->len - 5);
261 retnamlen += rr->len - 5;
262 break;
263 case SIG('R', 'E'):
264 kfree(rs.buffer);
265 return -1;
266 default:
267 break;
268 }
144 } 269 }
145 strncat(retname, rr->u.NM.name, rr->len - 5); 270 ret = rock_continue(&rs);
146 retnamlen += rr->len - 5; 271 if (ret == 0)
147 break; 272 goto repeat;
148 case SIG('R','E'): 273 if (ret == 1)
149 if (buffer) kfree(buffer); 274 return retnamlen; /* If 0, this file did not have a NM field */
150 return -1; 275out:
151 default: 276 kfree(rs.buffer);
152 break; 277 return ret;
153 } 278eio:
154 } 279 ret = -EIO;
155 } 280 goto out;
156 MAYBE_CONTINUE(repeat,inode);
157 if (buffer) kfree(buffer);
158 return retnamlen; /* If 0, this file did not have a NM field */
159 out:
160 if(buffer) kfree(buffer);
161 return 0;
162} 281}
163 282
164static int 283static int
165parse_rock_ridge_inode_internal(struct iso_directory_record *de, 284parse_rock_ridge_inode_internal(struct iso_directory_record *de,
166 struct inode *inode, int regard_xa) 285 struct inode *inode, int regard_xa)
167{ 286{
168 int len; 287 int symlink_len = 0;
169 unsigned char * chr; 288 int cnt, sig;
170 int symlink_len = 0; 289 struct inode *reloc;
171 CONTINUE_DECLS; 290 struct rock_ridge *rr;
172 291 int rootflag;
173 if (!ISOFS_SB(inode->i_sb)->s_rock) return 0; 292 struct rock_state rs;
174 293 int ret = 0;
175 SETUP_ROCK_RIDGE(de, chr, len); 294
176 if (regard_xa) 295 if (!ISOFS_SB(inode->i_sb)->s_rock)
177 { 296 return 0;
178 chr+=14; 297
179 len-=14; 298 init_rock_state(&rs, inode);
180 if (len<0) len=0; 299 setup_rock_ridge(de, inode, &rs);
181 } 300 if (regard_xa) {
182 301 rs.chr += 14;
183 repeat: 302 rs.len -= 14;
184 { 303 if (rs.len < 0)
185 int cnt, sig; 304 rs.len = 0;
186 struct inode * reloc; 305 }
187 struct rock_ridge * rr; 306
188 int rootflag; 307repeat:
189 308 while (rs.len > 2) { /* There may be one byte for padding somewhere */
190 while (len > 2){ /* There may be one byte for padding somewhere */ 309 rr = (struct rock_ridge *)rs.chr;
191 rr = (struct rock_ridge *) chr; 310 if (rr->len < 3)
192 if (rr->len < 3) goto out; /* Something got screwed up here */ 311 goto out; /* Something got screwed up here */
193 sig = isonum_721(chr); 312 sig = isonum_721(rs.chr);
194 chr += rr->len; 313 if (rock_check_overflow(&rs, sig))
195 len -= rr->len; 314 goto eio;
196 if (len < 0) goto out; /* corrupted isofs */ 315 rs.chr += rr->len;
197 316 rs.len -= rr->len;
198 switch(sig){ 317 if (rs.len < 0)
318 goto eio; /* corrupted isofs */
319
320 switch (sig) {
199#ifndef CONFIG_ZISOFS /* No flag for SF or ZF */ 321#ifndef CONFIG_ZISOFS /* No flag for SF or ZF */
200 case SIG('R','R'): 322 case SIG('R', 'R'):
201 if((rr->u.RR.flags[0] & 323 if ((rr->u.RR.flags[0] &
202 (RR_PX | RR_TF | RR_SL | RR_CL)) == 0) goto out; 324 (RR_PX | RR_TF | RR_SL | RR_CL)) == 0)
203 break; 325 goto out;
326 break;
204#endif 327#endif
205 case SIG('S','P'): 328 case SIG('S', 'P'):
206 CHECK_SP(goto out); 329 if (check_sp(rr, inode))
207 break; 330 goto out;
208 case SIG('C','E'): 331 break;
209 CHECK_CE; 332 case SIG('C', 'E'):
210 break; 333 rs.cont_extent = isonum_733(rr->u.CE.extent);
211 case SIG('E','R'): 334 rs.cont_offset = isonum_733(rr->u.CE.offset);
212 ISOFS_SB(inode->i_sb)->s_rock = 1; 335 rs.cont_size = isonum_733(rr->u.CE.size);
213 printk(KERN_DEBUG "ISO 9660 Extensions: "); 336 break;
214 { int p; 337 case SIG('E', 'R'):
215 for(p=0;p<rr->u.ER.len_id;p++) printk("%c",rr->u.ER.data[p]); 338 ISOFS_SB(inode->i_sb)->s_rock = 1;
216 } 339 printk(KERN_DEBUG "ISO 9660 Extensions: ");
217 printk("\n"); 340 {
218 break; 341 int p;
219 case SIG('P','X'): 342 for (p = 0; p < rr->u.ER.len_id; p++)
220 inode->i_mode = isonum_733(rr->u.PX.mode); 343 printk("%c", rr->u.ER.data[p]);
221 inode->i_nlink = isonum_733(rr->u.PX.n_links); 344 }
222 inode->i_uid = isonum_733(rr->u.PX.uid); 345 printk("\n");
223 inode->i_gid = isonum_733(rr->u.PX.gid); 346 break;
224 break; 347 case SIG('P', 'X'):
225 case SIG('P','N'): 348 inode->i_mode = isonum_733(rr->u.PX.mode);
226 { int high, low; 349 inode->i_nlink = isonum_733(rr->u.PX.n_links);
227 high = isonum_733(rr->u.PN.dev_high); 350 inode->i_uid = isonum_733(rr->u.PX.uid);
228 low = isonum_733(rr->u.PN.dev_low); 351 inode->i_gid = isonum_733(rr->u.PX.gid);
229 /* 352 break;
230 * The Rock Ridge standard specifies that if sizeof(dev_t) <= 4, 353 case SIG('P', 'N'):
231 * then the high field is unused, and the device number is completely 354 {
232 * stored in the low field. Some writers may ignore this subtlety, 355 int high, low;
233 * and as a result we test to see if the entire device number is 356 high = isonum_733(rr->u.PN.dev_high);
234 * stored in the low field, and use that. 357 low = isonum_733(rr->u.PN.dev_low);
235 */ 358 /*
236 if((low & ~0xff) && high == 0) { 359 * The Rock Ridge standard specifies that if
237 inode->i_rdev = MKDEV(low >> 8, low & 0xff); 360 * sizeof(dev_t) <= 4, then the high field is
238 } else { 361 * unused, and the device number is completely
239 inode->i_rdev = MKDEV(high, low); 362 * stored in the low field. Some writers may
240 } 363 * ignore this subtlety,
241 } 364 * and as a result we test to see if the entire
242 break; 365 * device number is
243 case SIG('T','F'): 366 * stored in the low field, and use that.
244 /* Some RRIP writers incorrectly place ctime in the TF_CREATE field. 367 */
245 Try to handle this correctly for either case. */ 368 if ((low & ~0xff) && high == 0) {
246 cnt = 0; /* Rock ridge never appears on a High Sierra disk */ 369 inode->i_rdev =
247 if(rr->u.TF.flags & TF_CREATE) { 370 MKDEV(low >> 8, low & 0xff);
248 inode->i_ctime.tv_sec = iso_date(rr->u.TF.times[cnt++].time, 0); 371 } else {
249 inode->i_ctime.tv_nsec = 0; 372 inode->i_rdev =
250 } 373 MKDEV(high, low);
251 if(rr->u.TF.flags & TF_MODIFY) { 374 }
252 inode->i_mtime.tv_sec = iso_date(rr->u.TF.times[cnt++].time, 0); 375 }
253 inode->i_mtime.tv_nsec = 0; 376 break;
254 } 377 case SIG('T', 'F'):
255 if(rr->u.TF.flags & TF_ACCESS) { 378 /*
256 inode->i_atime.tv_sec = iso_date(rr->u.TF.times[cnt++].time, 0); 379 * Some RRIP writers incorrectly place ctime in the
257 inode->i_atime.tv_nsec = 0; 380 * TF_CREATE field. Try to handle this correctly for
258 } 381 * either case.
259 if(rr->u.TF.flags & TF_ATTRIBUTES) { 382 */
260 inode->i_ctime.tv_sec = iso_date(rr->u.TF.times[cnt++].time, 0); 383 /* Rock ridge never appears on a High Sierra disk */
261 inode->i_ctime.tv_nsec = 0; 384 cnt = 0;
262 } 385 if (rr->u.TF.flags & TF_CREATE) {
263 break; 386 inode->i_ctime.tv_sec =
264 case SIG('S','L'): 387 iso_date(rr->u.TF.times[cnt++].time,
265 {int slen; 388 0);
266 struct SL_component * slp; 389 inode->i_ctime.tv_nsec = 0;
267 struct SL_component * oldslp; 390 }
268 slen = rr->len - 5; 391 if (rr->u.TF.flags & TF_MODIFY) {
269 slp = &rr->u.SL.link; 392 inode->i_mtime.tv_sec =
270 inode->i_size = symlink_len; 393 iso_date(rr->u.TF.times[cnt++].time,
271 while (slen > 1){ 394 0);
272 rootflag = 0; 395 inode->i_mtime.tv_nsec = 0;
273 switch(slp->flags &~1){ 396 }
274 case 0: 397 if (rr->u.TF.flags & TF_ACCESS) {
275 inode->i_size += slp->len; 398 inode->i_atime.tv_sec =
276 break; 399 iso_date(rr->u.TF.times[cnt++].time,
277 case 2: 400 0);
278 inode->i_size += 1; 401 inode->i_atime.tv_nsec = 0;
279 break; 402 }
280 case 4: 403 if (rr->u.TF.flags & TF_ATTRIBUTES) {
281 inode->i_size += 2; 404 inode->i_ctime.tv_sec =
282 break; 405 iso_date(rr->u.TF.times[cnt++].time,
283 case 8: 406 0);
284 rootflag = 1; 407 inode->i_ctime.tv_nsec = 0;
285 inode->i_size += 1; 408 }
286 break; 409 break;
287 default: 410 case SIG('S', 'L'):
288 printk("Symlink component flag not implemented\n"); 411 {
289 } 412 int slen;
290 slen -= slp->len + 2; 413 struct SL_component *slp;
291 oldslp = slp; 414 struct SL_component *oldslp;
292 slp = (struct SL_component *) (((char *) slp) + slp->len + 2); 415 slen = rr->len - 5;
293 416 slp = &rr->u.SL.link;
294 if(slen < 2) { 417 inode->i_size = symlink_len;
295 if( ((rr->u.SL.flags & 1) != 0) 418 while (slen > 1) {
296 && ((oldslp->flags & 1) == 0) ) inode->i_size += 1; 419 rootflag = 0;
297 break; 420 switch (slp->flags & ~1) {
298 } 421 case 0:
299 422 inode->i_size +=
300 /* 423 slp->len;
301 * If this component record isn't continued, then append a '/'. 424 break;
302 */ 425 case 2:
303 if (!rootflag && (oldslp->flags & 1) == 0) 426 inode->i_size += 1;
304 inode->i_size += 1; 427 break;
305 } 428 case 4:
306 } 429 inode->i_size += 2;
307 symlink_len = inode->i_size; 430 break;
308 break; 431 case 8:
309 case SIG('R','E'): 432 rootflag = 1;
310 printk(KERN_WARNING "Attempt to read inode for relocated directory\n"); 433 inode->i_size += 1;
311 goto out; 434 break;
312 case SIG('C','L'): 435 default:
313 ISOFS_I(inode)->i_first_extent = isonum_733(rr->u.CL.location); 436 printk("Symlink component flag "
314 reloc = isofs_iget(inode->i_sb, ISOFS_I(inode)->i_first_extent, 0); 437 "not implemented\n");
315 if (!reloc) 438 }
316 goto out; 439 slen -= slp->len + 2;
317 inode->i_mode = reloc->i_mode; 440 oldslp = slp;
318 inode->i_nlink = reloc->i_nlink; 441 slp = (struct SL_component *)
319 inode->i_uid = reloc->i_uid; 442 (((char *)slp) + slp->len + 2);
320 inode->i_gid = reloc->i_gid; 443
321 inode->i_rdev = reloc->i_rdev; 444 if (slen < 2) {
322 inode->i_size = reloc->i_size; 445 if (((rr->u.SL.
323 inode->i_blocks = reloc->i_blocks; 446 flags & 1) != 0)
324 inode->i_atime = reloc->i_atime; 447 &&
325 inode->i_ctime = reloc->i_ctime; 448 ((oldslp->
326 inode->i_mtime = reloc->i_mtime; 449 flags & 1) == 0))
327 iput(reloc); 450 inode->i_size +=
328 break; 451 1;
452 break;
453 }
454
455 /*
456 * If this component record isn't
457 * continued, then append a '/'.
458 */
459 if (!rootflag
460 && (oldslp->flags & 1) == 0)
461 inode->i_size += 1;
462 }
463 }
464 symlink_len = inode->i_size;
465 break;
466 case SIG('R', 'E'):
467 printk(KERN_WARNING "Attempt to read inode for "
468 "relocated directory\n");
469 goto out;
470 case SIG('C', 'L'):
471 ISOFS_I(inode)->i_first_extent =
472 isonum_733(rr->u.CL.location);
473 reloc =
474 isofs_iget(inode->i_sb,
475 ISOFS_I(inode)->i_first_extent,
476 0);
477 if (!reloc)
478 goto out;
479 inode->i_mode = reloc->i_mode;
480 inode->i_nlink = reloc->i_nlink;
481 inode->i_uid = reloc->i_uid;
482 inode->i_gid = reloc->i_gid;
483 inode->i_rdev = reloc->i_rdev;
484 inode->i_size = reloc->i_size;
485 inode->i_blocks = reloc->i_blocks;
486 inode->i_atime = reloc->i_atime;
487 inode->i_ctime = reloc->i_ctime;
488 inode->i_mtime = reloc->i_mtime;
489 iput(reloc);
490 break;
329#ifdef CONFIG_ZISOFS 491#ifdef CONFIG_ZISOFS
330 case SIG('Z','F'): 492 case SIG('Z', 'F'): {
331 if ( !ISOFS_SB(inode->i_sb)->s_nocompress ) { 493 int algo;
332 int algo; 494
333 algo = isonum_721(rr->u.ZF.algorithm); 495 if (ISOFS_SB(inode->i_sb)->s_nocompress)
334 if ( algo == SIG('p','z') ) { 496 break;
335 int block_shift = isonum_711(&rr->u.ZF.parms[1]); 497 algo = isonum_721(rr->u.ZF.algorithm);
336 if ( block_shift < PAGE_CACHE_SHIFT || block_shift > 17 ) { 498 if (algo == SIG('p', 'z')) {
337 printk(KERN_WARNING "isofs: Can't handle ZF block size of 2^%d\n", block_shift); 499 int block_shift =
338 } else { 500 isonum_711(&rr->u.ZF.parms[1]);
339 /* Note: we don't change i_blocks here */ 501 if (block_shift < PAGE_CACHE_SHIFT
340 ISOFS_I(inode)->i_file_format = isofs_file_compressed; 502 || block_shift > 17) {
341 /* Parameters to compression algorithm (header size, block size) */ 503 printk(KERN_WARNING "isofs: "
342 ISOFS_I(inode)->i_format_parm[0] = isonum_711(&rr->u.ZF.parms[0]); 504 "Can't handle ZF block "
343 ISOFS_I(inode)->i_format_parm[1] = isonum_711(&rr->u.ZF.parms[1]); 505 "size of 2^%d\n",
344 inode->i_size = isonum_733(rr->u.ZF.real_size); 506 block_shift);
345 } 507 } else {
346 } else { 508 /*
347 printk(KERN_WARNING "isofs: Unknown ZF compression algorithm: %c%c\n", 509 * Note: we don't change
348 rr->u.ZF.algorithm[0], rr->u.ZF.algorithm[1]); 510 * i_blocks here
349 } 511 */
350 } 512 ISOFS_I(inode)->i_file_format =
351 break; 513 isofs_file_compressed;
514 /*
515 * Parameters to compression
516 * algorithm (header size,
517 * block size)
518 */
519 ISOFS_I(inode)->i_format_parm[0] =
520 isonum_711(&rr->u.ZF.parms[0]);
521 ISOFS_I(inode)->i_format_parm[1] =
522 isonum_711(&rr->u.ZF.parms[1]);
523 inode->i_size =
524 isonum_733(rr->u.ZF.
525 real_size);
526 }
527 } else {
528 printk(KERN_WARNING
529 "isofs: Unknown ZF compression "
530 "algorithm: %c%c\n",
531 rr->u.ZF.algorithm[0],
532 rr->u.ZF.algorithm[1]);
533 }
534 break;
535 }
352#endif 536#endif
353 default: 537 default:
354 break; 538 break;
355 } 539 }
356 } 540 }
357 } 541 ret = rock_continue(&rs);
358 MAYBE_CONTINUE(repeat,inode); 542 if (ret == 0)
359 out: 543 goto repeat;
360 if(buffer) kfree(buffer); 544 if (ret == 1)
361 return 0; 545 ret = 0;
546out:
547 kfree(rs.buffer);
548 return ret;
549eio:
550 ret = -EIO;
551 goto out;
362} 552}
363 553
364static char *get_symlink_chunk(char *rpnt, struct rock_ridge *rr, char *plimit) 554static char *get_symlink_chunk(char *rpnt, struct rock_ridge *rr, char *plimit)
@@ -376,32 +566,32 @@ static char *get_symlink_chunk(char *rpnt, struct rock_ridge *rr, char *plimit)
376 if (slp->len > plimit - rpnt) 566 if (slp->len > plimit - rpnt)
377 return NULL; 567 return NULL;
378 memcpy(rpnt, slp->text, slp->len); 568 memcpy(rpnt, slp->text, slp->len);
379 rpnt+=slp->len; 569 rpnt += slp->len;
380 break; 570 break;
381 case 2: 571 case 2:
382 if (rpnt >= plimit) 572 if (rpnt >= plimit)
383 return NULL; 573 return NULL;
384 *rpnt++='.'; 574 *rpnt++ = '.';
385 break; 575 break;
386 case 4: 576 case 4:
387 if (2 > plimit - rpnt) 577 if (2 > plimit - rpnt)
388 return NULL; 578 return NULL;
389 *rpnt++='.'; 579 *rpnt++ = '.';
390 *rpnt++='.'; 580 *rpnt++ = '.';
391 break; 581 break;
392 case 8: 582 case 8:
393 if (rpnt >= plimit) 583 if (rpnt >= plimit)
394 return NULL; 584 return NULL;
395 rootflag = 1; 585 rootflag = 1;
396 *rpnt++='/'; 586 *rpnt++ = '/';
397 break; 587 break;
398 default: 588 default:
399 printk("Symlink component flag not implemented (%d)\n", 589 printk("Symlink component flag not implemented (%d)\n",
400 slp->flags); 590 slp->flags);
401 } 591 }
402 slen -= slp->len + 2; 592 slen -= slp->len + 2;
403 oldslp = slp; 593 oldslp = slp;
404 slp = (struct SL_component *) ((char *) slp + slp->len + 2); 594 slp = (struct SL_component *)((char *)slp + slp->len + 2);
405 595
406 if (slen < 2) { 596 if (slen < 2) {
407 /* 597 /*
@@ -412,7 +602,7 @@ static char *get_symlink_chunk(char *rpnt, struct rock_ridge *rr, char *plimit)
412 !(oldslp->flags & 1)) { 602 !(oldslp->flags & 1)) {
413 if (rpnt >= plimit) 603 if (rpnt >= plimit)
414 return NULL; 604 return NULL;
415 *rpnt++='/'; 605 *rpnt++ = '/';
416 } 606 }
417 break; 607 break;
418 } 608 }
@@ -423,59 +613,61 @@ static char *get_symlink_chunk(char *rpnt, struct rock_ridge *rr, char *plimit)
423 if (!rootflag && !(oldslp->flags & 1)) { 613 if (!rootflag && !(oldslp->flags & 1)) {
424 if (rpnt >= plimit) 614 if (rpnt >= plimit)
425 return NULL; 615 return NULL;
426 *rpnt++='/'; 616 *rpnt++ = '/';
427 } 617 }
428 } 618 }
429 return rpnt; 619 return rpnt;
430} 620}
431 621
432int parse_rock_ridge_inode(struct iso_directory_record * de, 622int parse_rock_ridge_inode(struct iso_directory_record *de, struct inode *inode)
433 struct inode * inode)
434{ 623{
435 int result=parse_rock_ridge_inode_internal(de,inode,0); 624 int result = parse_rock_ridge_inode_internal(de, inode, 0);
436 /* if rockridge flag was reset and we didn't look for attributes
437 * behind eventual XA attributes, have a look there */
438 if ((ISOFS_SB(inode->i_sb)->s_rock_offset==-1)
439 &&(ISOFS_SB(inode->i_sb)->s_rock==2))
440 {
441 result=parse_rock_ridge_inode_internal(de,inode,14);
442 }
443 return result;
444}
445 625
446/* readpage() for symlinks: reads symlink contents into the page and either 626 /*
447 makes it uptodate and returns 0 or returns error (-EIO) */ 627 * if rockridge flag was reset and we didn't look for attributes
628 * behind eventual XA attributes, have a look there
629 */
630 if ((ISOFS_SB(inode->i_sb)->s_rock_offset == -1)
631 && (ISOFS_SB(inode->i_sb)->s_rock == 2)) {
632 result = parse_rock_ridge_inode_internal(de, inode, 14);
633 }
634 return result;
635}
448 636
637/*
638 * readpage() for symlinks: reads symlink contents into the page and either
639 * makes it uptodate and returns 0 or returns error (-EIO)
640 */
449static int rock_ridge_symlink_readpage(struct file *file, struct page *page) 641static int rock_ridge_symlink_readpage(struct file *file, struct page *page)
450{ 642{
451 struct inode *inode = page->mapping->host; 643 struct inode *inode = page->mapping->host;
452 struct iso_inode_info *ei = ISOFS_I(inode); 644 struct iso_inode_info *ei = ISOFS_I(inode);
453 char *link = kmap(page); 645 char *link = kmap(page);
454 unsigned long bufsize = ISOFS_BUFFER_SIZE(inode); 646 unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
455 struct buffer_head *bh; 647 struct buffer_head *bh;
456 char *rpnt = link; 648 char *rpnt = link;
457 unsigned char *pnt; 649 unsigned char *pnt;
458 struct iso_directory_record *raw_inode; 650 struct iso_directory_record *raw_de;
459 CONTINUE_DECLS;
460 unsigned long block, offset; 651 unsigned long block, offset;
461 int sig; 652 int sig;
462 int len;
463 unsigned char *chr;
464 struct rock_ridge *rr; 653 struct rock_ridge *rr;
654 struct rock_state rs;
655 int ret;
465 656
466 if (!ISOFS_SB(inode->i_sb)->s_rock) 657 if (!ISOFS_SB(inode->i_sb)->s_rock)
467 goto error; 658 goto error;
468 659
660 init_rock_state(&rs, inode);
469 block = ei->i_iget5_block; 661 block = ei->i_iget5_block;
470 lock_kernel(); 662 lock_kernel();
471 bh = sb_bread(inode->i_sb, block); 663 bh = sb_bread(inode->i_sb, block);
472 if (!bh) 664 if (!bh)
473 goto out_noread; 665 goto out_noread;
474 666
475 offset = ei->i_iget5_offset; 667 offset = ei->i_iget5_offset;
476 pnt = (unsigned char *) bh->b_data + offset; 668 pnt = (unsigned char *)bh->b_data + offset;
477 669
478 raw_inode = (struct iso_directory_record *) pnt; 670 raw_de = (struct iso_directory_record *)pnt;
479 671
480 /* 672 /*
481 * If we go past the end of the buffer, there is some sort of error. 673 * If we go past the end of the buffer, there is some sort of error.
@@ -483,20 +675,24 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page)
483 if (offset + *pnt > bufsize) 675 if (offset + *pnt > bufsize)
484 goto out_bad_span; 676 goto out_bad_span;
485 677
486 /* Now test for possible Rock Ridge extensions which will override 678 /*
487 some of these numbers in the inode structure. */ 679 * Now test for possible Rock Ridge extensions which will override
680 * some of these numbers in the inode structure.
681 */
488 682
489 SETUP_ROCK_RIDGE(raw_inode, chr, len); 683 setup_rock_ridge(raw_de, inode, &rs);
490 684
491 repeat: 685repeat:
492 while (len > 2) { /* There may be one byte for padding somewhere */ 686 while (rs.len > 2) { /* There may be one byte for padding somewhere */
493 rr = (struct rock_ridge *) chr; 687 rr = (struct rock_ridge *)rs.chr;
494 if (rr->len < 3) 688 if (rr->len < 3)
495 goto out; /* Something got screwed up here */ 689 goto out; /* Something got screwed up here */
496 sig = isonum_721(chr); 690 sig = isonum_721(rs.chr);
497 chr += rr->len; 691 if (rock_check_overflow(&rs, sig))
498 len -= rr->len; 692 goto out;
499 if (len < 0) 693 rs.chr += rr->len;
694 rs.len -= rr->len;
695 if (rs.len < 0)
500 goto out; /* corrupted isofs */ 696 goto out; /* corrupted isofs */
501 697
502 switch (sig) { 698 switch (sig) {
@@ -505,7 +701,8 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page)
505 goto out; 701 goto out;
506 break; 702 break;
507 case SIG('S', 'P'): 703 case SIG('S', 'P'):
508 CHECK_SP(goto out); 704 if (check_sp(rr, inode))
705 goto out;
509 break; 706 break;
510 case SIG('S', 'L'): 707 case SIG('S', 'L'):
511 rpnt = get_symlink_chunk(rpnt, rr, 708 rpnt = get_symlink_chunk(rpnt, rr,
@@ -515,14 +712,18 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page)
515 break; 712 break;
516 case SIG('C', 'E'): 713 case SIG('C', 'E'):
517 /* This tells is if there is a continuation record */ 714 /* This tells is if there is a continuation record */
518 CHECK_CE; 715 rs.cont_extent = isonum_733(rr->u.CE.extent);
716 rs.cont_offset = isonum_733(rr->u.CE.offset);
717 rs.cont_size = isonum_733(rr->u.CE.size);
519 default: 718 default:
520 break; 719 break;
521 } 720 }
522 } 721 }
523 MAYBE_CONTINUE(repeat, inode); 722 ret = rock_continue(&rs);
524 if (buffer) 723 if (ret == 0)
525 kfree(buffer); 724 goto repeat;
725 if (ret < 0)
726 goto fail;
526 727
527 if (rpnt == link) 728 if (rpnt == link)
528 goto fail; 729 goto fail;
@@ -535,19 +736,18 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page)
535 return 0; 736 return 0;
536 737
537 /* error exit from macro */ 738 /* error exit from macro */
538 out: 739out:
539 if (buffer) 740 kfree(rs.buffer);
540 kfree(buffer);
541 goto fail; 741 goto fail;
542 out_noread: 742out_noread:
543 printk("unable to read i-node block"); 743 printk("unable to read i-node block");
544 goto fail; 744 goto fail;
545 out_bad_span: 745out_bad_span:
546 printk("symlink spans iso9660 blocks\n"); 746 printk("symlink spans iso9660 blocks\n");
547 fail: 747fail:
548 brelse(bh); 748 brelse(bh);
549 unlock_kernel(); 749 unlock_kernel();
550 error: 750error:
551 SetPageError(page); 751 SetPageError(page);
552 kunmap(page); 752 kunmap(page);
553 unlock_page(page); 753 unlock_page(page);
@@ -555,5 +755,5 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page)
555} 755}
556 756
557struct address_space_operations isofs_symlink_aops = { 757struct address_space_operations isofs_symlink_aops = {
558 .readpage = rock_ridge_symlink_readpage 758 .readpage = rock_ridge_symlink_readpage
559}; 759};
diff --git a/fs/isofs/rock.h b/fs/isofs/rock.h
index deaf5c8e8b4a..ed09e2b08637 100644
--- a/fs/isofs/rock.h
+++ b/fs/isofs/rock.h
@@ -1,85 +1,88 @@
1/* These structs are used by the system-use-sharing protocol, in which the 1/*
2 Rock Ridge extensions are embedded. It is quite possible that other 2 * These structs are used by the system-use-sharing protocol, in which the
3 extensions are present on the disk, and this is fine as long as they 3 * Rock Ridge extensions are embedded. It is quite possible that other
4 all use SUSP */ 4 * extensions are present on the disk, and this is fine as long as they
5 5 * all use SUSP
6struct SU_SP{ 6 */
7 unsigned char magic[2]; 7
8 unsigned char skip; 8struct SU_SP_s {
9} __attribute__((packed)); 9 unsigned char magic[2];
10 10 unsigned char skip;
11struct SU_CE{ 11} __attribute__ ((packed));
12 char extent[8]; 12
13 char offset[8]; 13struct SU_CE_s {
14 char size[8]; 14 char extent[8];
15 char offset[8];
16 char size[8];
15}; 17};
16 18
17struct SU_ER{ 19struct SU_ER_s {
18 unsigned char len_id; 20 unsigned char len_id;
19 unsigned char len_des; 21 unsigned char len_des;
20 unsigned char len_src; 22 unsigned char len_src;
21 unsigned char ext_ver; 23 unsigned char ext_ver;
22 char data[0]; 24 char data[0];
23} __attribute__((packed)); 25} __attribute__ ((packed));
24 26
25struct RR_RR{ 27struct RR_RR_s {
26 char flags[1]; 28 char flags[1];
27} __attribute__((packed)); 29} __attribute__ ((packed));
28 30
29struct RR_PX{ 31struct RR_PX_s {
30 char mode[8]; 32 char mode[8];
31 char n_links[8]; 33 char n_links[8];
32 char uid[8]; 34 char uid[8];
33 char gid[8]; 35 char gid[8];
34}; 36};
35 37
36struct RR_PN{ 38struct RR_PN_s {
37 char dev_high[8]; 39 char dev_high[8];
38 char dev_low[8]; 40 char dev_low[8];
39}; 41};
40 42
43struct SL_component {
44 unsigned char flags;
45 unsigned char len;
46 char text[0];
47} __attribute__ ((packed));
41 48
42struct SL_component{ 49struct RR_SL_s {
43 unsigned char flags; 50 unsigned char flags;
44 unsigned char len; 51 struct SL_component link;
45 char text[0]; 52} __attribute__ ((packed));
46} __attribute__((packed));
47 53
48struct RR_SL{ 54struct RR_NM_s {
49 unsigned char flags; 55 unsigned char flags;
50 struct SL_component link; 56 char name[0];
51} __attribute__((packed)); 57} __attribute__ ((packed));
52 58
53struct RR_NM{ 59struct RR_CL_s {
54 unsigned char flags; 60 char location[8];
55 char name[0];
56} __attribute__((packed));
57
58struct RR_CL{
59 char location[8];
60}; 61};
61 62
62struct RR_PL{ 63struct RR_PL_s {
63 char location[8]; 64 char location[8];
64}; 65};
65 66
66struct stamp{ 67struct stamp {
67 char time[7]; 68 char time[7];
68} __attribute__((packed)); 69} __attribute__ ((packed));
69 70
70struct RR_TF{ 71struct RR_TF_s {
71 char flags; 72 char flags;
72 struct stamp times[0]; /* Variable number of these beasts */ 73 struct stamp times[0]; /* Variable number of these beasts */
73} __attribute__((packed)); 74} __attribute__ ((packed));
74 75
75/* Linux-specific extension for transparent decompression */ 76/* Linux-specific extension for transparent decompression */
76struct RR_ZF{ 77struct RR_ZF_s {
77 char algorithm[2]; 78 char algorithm[2];
78 char parms[2]; 79 char parms[2];
79 char real_size[8]; 80 char real_size[8];
80}; 81};
81 82
82/* These are the bits and their meanings for flags in the TF structure. */ 83/*
84 * These are the bits and their meanings for flags in the TF structure.
85 */
83#define TF_CREATE 1 86#define TF_CREATE 1
84#define TF_MODIFY 2 87#define TF_MODIFY 2
85#define TF_ACCESS 4 88#define TF_ACCESS 4
@@ -89,31 +92,31 @@ struct RR_ZF{
89#define TF_EFFECTIVE 64 92#define TF_EFFECTIVE 64
90#define TF_LONG_FORM 128 93#define TF_LONG_FORM 128
91 94
92struct rock_ridge{ 95struct rock_ridge {
93 char signature[2]; 96 char signature[2];
94 unsigned char len; 97 unsigned char len;
95 unsigned char version; 98 unsigned char version;
96 union{ 99 union {
97 struct SU_SP SP; 100 struct SU_SP_s SP;
98 struct SU_CE CE; 101 struct SU_CE_s CE;
99 struct SU_ER ER; 102 struct SU_ER_s ER;
100 struct RR_RR RR; 103 struct RR_RR_s RR;
101 struct RR_PX PX; 104 struct RR_PX_s PX;
102 struct RR_PN PN; 105 struct RR_PN_s PN;
103 struct RR_SL SL; 106 struct RR_SL_s SL;
104 struct RR_NM NM; 107 struct RR_NM_s NM;
105 struct RR_CL CL; 108 struct RR_CL_s CL;
106 struct RR_PL PL; 109 struct RR_PL_s PL;
107 struct RR_TF TF; 110 struct RR_TF_s TF;
108 struct RR_ZF ZF; 111 struct RR_ZF_s ZF;
109 } u; 112 } u;
110}; 113};
111 114
112#define RR_PX 1 /* POSIX attributes */ 115#define RR_PX 1 /* POSIX attributes */
113#define RR_PN 2 /* POSIX devices */ 116#define RR_PN 2 /* POSIX devices */
114#define RR_SL 4 /* Symbolic link */ 117#define RR_SL 4 /* Symbolic link */
115#define RR_NM 8 /* Alternate Name */ 118#define RR_NM 8 /* Alternate Name */
116#define RR_CL 16 /* Child link */ 119#define RR_CL 16 /* Child link */
117#define RR_PL 32 /* Parent link */ 120#define RR_PL 32 /* Parent link */
118#define RR_RE 64 /* Relocation directory */ 121#define RR_RE 64 /* Relocation directory */
119#define RR_TF 128 /* Timestamps */ 122#define RR_TF 128 /* Timestamps */
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index a60a3b3d8a7b..63a9fbf1ac51 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -219,6 +219,19 @@ static struct file_operations fragmentation_file_operations = {
219 .release = seq_release, 219 .release = seq_release,
220}; 220};
221 221
222extern struct seq_operations zoneinfo_op;
223static int zoneinfo_open(struct inode *inode, struct file *file)
224{
225 return seq_open(file, &zoneinfo_op);
226}
227
228static struct file_operations proc_zoneinfo_file_operations = {
229 .open = zoneinfo_open,
230 .read = seq_read,
231 .llseek = seq_lseek,
232 .release = seq_release,
233};
234
222static int version_read_proc(char *page, char **start, off_t off, 235static int version_read_proc(char *page, char **start, off_t off,
223 int count, int *eof, void *data) 236 int count, int *eof, void *data)
224{ 237{
@@ -589,6 +602,7 @@ void __init proc_misc_init(void)
589 create_seq_entry("slabinfo",S_IWUSR|S_IRUGO,&proc_slabinfo_operations); 602 create_seq_entry("slabinfo",S_IWUSR|S_IRUGO,&proc_slabinfo_operations);
590 create_seq_entry("buddyinfo",S_IRUGO, &fragmentation_file_operations); 603 create_seq_entry("buddyinfo",S_IRUGO, &fragmentation_file_operations);
591 create_seq_entry("vmstat",S_IRUGO, &proc_vmstat_file_operations); 604 create_seq_entry("vmstat",S_IRUGO, &proc_vmstat_file_operations);
605 create_seq_entry("zoneinfo",S_IRUGO, &proc_zoneinfo_file_operations);
592 create_seq_entry("diskstats", 0, &proc_diskstats_operations); 606 create_seq_entry("diskstats", 0, &proc_diskstats_operations);
593#ifdef CONFIG_MODULES 607#ifdef CONFIG_MODULES
594 create_seq_entry("modules", 0, &proc_modules_operations); 608 create_seq_entry("modules", 0, &proc_modules_operations);
diff --git a/fs/super.c b/fs/super.c
index 3a1b8ca04ba6..573bcc81bb82 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -835,6 +835,7 @@ do_kern_mount(const char *fstype, int flags, const char *name, void *data)
835 mnt->mnt_parent = mnt; 835 mnt->mnt_parent = mnt;
836 mnt->mnt_namespace = current->namespace; 836 mnt->mnt_namespace = current->namespace;
837 up_write(&sb->s_umount); 837 up_write(&sb->s_umount);
838 free_secdata(secdata);
838 put_filesystem(type); 839 put_filesystem(type);
839 return mnt; 840 return mnt;
840out_sb: 841out_sb:
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index 997963e53622..c60e69431e11 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -61,12 +61,13 @@
61 * File wide globals 61 * File wide globals
62 */ 62 */
63 63
64STATIC kmem_cache_t *pagebuf_cache; 64STATIC kmem_cache_t *pagebuf_zone;
65STATIC kmem_shaker_t pagebuf_shake; 65STATIC kmem_shaker_t pagebuf_shake;
66STATIC int pagebuf_daemon_wakeup(int, unsigned int); 66STATIC int xfsbufd_wakeup(int, unsigned int);
67STATIC void pagebuf_delwri_queue(xfs_buf_t *, int); 67STATIC void pagebuf_delwri_queue(xfs_buf_t *, int);
68STATIC struct workqueue_struct *pagebuf_logio_workqueue; 68
69STATIC struct workqueue_struct *pagebuf_dataio_workqueue; 69STATIC struct workqueue_struct *xfslogd_workqueue;
70STATIC struct workqueue_struct *xfsdatad_workqueue;
70 71
71/* 72/*
72 * Pagebuf debugging 73 * Pagebuf debugging
@@ -123,9 +124,9 @@ ktrace_t *pagebuf_trace_buf;
123 124
124 125
125#define pagebuf_allocate(flags) \ 126#define pagebuf_allocate(flags) \
126 kmem_zone_alloc(pagebuf_cache, pb_to_km(flags)) 127 kmem_zone_alloc(pagebuf_zone, pb_to_km(flags))
127#define pagebuf_deallocate(pb) \ 128#define pagebuf_deallocate(pb) \
128 kmem_zone_free(pagebuf_cache, (pb)); 129 kmem_zone_free(pagebuf_zone, (pb));
129 130
130/* 131/*
131 * Page Region interfaces. 132 * Page Region interfaces.
@@ -425,7 +426,7 @@ _pagebuf_lookup_pages(
425 __FUNCTION__, gfp_mask); 426 __FUNCTION__, gfp_mask);
426 427
427 XFS_STATS_INC(pb_page_retries); 428 XFS_STATS_INC(pb_page_retries);
428 pagebuf_daemon_wakeup(0, gfp_mask); 429 xfsbufd_wakeup(0, gfp_mask);
429 blk_congestion_wait(WRITE, HZ/50); 430 blk_congestion_wait(WRITE, HZ/50);
430 goto retry; 431 goto retry;
431 } 432 }
@@ -1136,8 +1137,8 @@ pagebuf_iodone(
1136 if ((pb->pb_iodone) || (pb->pb_flags & PBF_ASYNC)) { 1137 if ((pb->pb_iodone) || (pb->pb_flags & PBF_ASYNC)) {
1137 if (schedule) { 1138 if (schedule) {
1138 INIT_WORK(&pb->pb_iodone_work, pagebuf_iodone_work, pb); 1139 INIT_WORK(&pb->pb_iodone_work, pagebuf_iodone_work, pb);
1139 queue_work(dataio ? pagebuf_dataio_workqueue : 1140 queue_work(dataio ? xfsdatad_workqueue :
1140 pagebuf_logio_workqueue, &pb->pb_iodone_work); 1141 xfslogd_workqueue, &pb->pb_iodone_work);
1141 } else { 1142 } else {
1142 pagebuf_iodone_work(pb); 1143 pagebuf_iodone_work(pb);
1143 } 1144 }
@@ -1562,16 +1563,6 @@ xfs_free_buftarg(
1562 kmem_free(btp, sizeof(*btp)); 1563 kmem_free(btp, sizeof(*btp));
1563} 1564}
1564 1565
1565void
1566xfs_incore_relse(
1567 xfs_buftarg_t *btp,
1568 int delwri_only,
1569 int wait)
1570{
1571 invalidate_bdev(btp->pbr_bdev, 1);
1572 truncate_inode_pages(btp->pbr_mapping, 0LL);
1573}
1574
1575STATIC int 1566STATIC int
1576xfs_setsize_buftarg_flags( 1567xfs_setsize_buftarg_flags(
1577 xfs_buftarg_t *btp, 1568 xfs_buftarg_t *btp,
@@ -1742,27 +1733,27 @@ pagebuf_runall_queues(
1742} 1733}
1743 1734
1744/* Defines for pagebuf daemon */ 1735/* Defines for pagebuf daemon */
1745STATIC DECLARE_COMPLETION(pagebuf_daemon_done); 1736STATIC DECLARE_COMPLETION(xfsbufd_done);
1746STATIC struct task_struct *pagebuf_daemon_task; 1737STATIC struct task_struct *xfsbufd_task;
1747STATIC int pagebuf_daemon_active; 1738STATIC int xfsbufd_active;
1748STATIC int force_flush; 1739STATIC int xfsbufd_force_flush;
1749STATIC int force_sleep; 1740STATIC int xfsbufd_force_sleep;
1750 1741
1751STATIC int 1742STATIC int
1752pagebuf_daemon_wakeup( 1743xfsbufd_wakeup(
1753 int priority, 1744 int priority,
1754 unsigned int mask) 1745 unsigned int mask)
1755{ 1746{
1756 if (force_sleep) 1747 if (xfsbufd_force_sleep)
1757 return 0; 1748 return 0;
1758 force_flush = 1; 1749 xfsbufd_force_flush = 1;
1759 barrier(); 1750 barrier();
1760 wake_up_process(pagebuf_daemon_task); 1751 wake_up_process(xfsbufd_task);
1761 return 0; 1752 return 0;
1762} 1753}
1763 1754
1764STATIC int 1755STATIC int
1765pagebuf_daemon( 1756xfsbufd(
1766 void *data) 1757 void *data)
1767{ 1758{
1768 struct list_head tmp; 1759 struct list_head tmp;
@@ -1774,17 +1765,17 @@ pagebuf_daemon(
1774 daemonize("xfsbufd"); 1765 daemonize("xfsbufd");
1775 current->flags |= PF_MEMALLOC; 1766 current->flags |= PF_MEMALLOC;
1776 1767
1777 pagebuf_daemon_task = current; 1768 xfsbufd_task = current;
1778 pagebuf_daemon_active = 1; 1769 xfsbufd_active = 1;
1779 barrier(); 1770 barrier();
1780 1771
1781 INIT_LIST_HEAD(&tmp); 1772 INIT_LIST_HEAD(&tmp);
1782 do { 1773 do {
1783 if (unlikely(current->flags & PF_FREEZE)) { 1774 if (unlikely(current->flags & PF_FREEZE)) {
1784 force_sleep = 1; 1775 xfsbufd_force_sleep = 1;
1785 refrigerator(PF_FREEZE); 1776 refrigerator(PF_FREEZE);
1786 } else { 1777 } else {
1787 force_sleep = 0; 1778 xfsbufd_force_sleep = 0;
1788 } 1779 }
1789 1780
1790 set_current_state(TASK_INTERRUPTIBLE); 1781 set_current_state(TASK_INTERRUPTIBLE);
@@ -1797,7 +1788,7 @@ pagebuf_daemon(
1797 ASSERT(pb->pb_flags & PBF_DELWRI); 1788 ASSERT(pb->pb_flags & PBF_DELWRI);
1798 1789
1799 if (!pagebuf_ispin(pb) && !pagebuf_cond_lock(pb)) { 1790 if (!pagebuf_ispin(pb) && !pagebuf_cond_lock(pb)) {
1800 if (!force_flush && 1791 if (!xfsbufd_force_flush &&
1801 time_before(jiffies, 1792 time_before(jiffies,
1802 pb->pb_queuetime + age)) { 1793 pb->pb_queuetime + age)) {
1803 pagebuf_unlock(pb); 1794 pagebuf_unlock(pb);
@@ -1824,10 +1815,10 @@ pagebuf_daemon(
1824 if (as_list_len > 0) 1815 if (as_list_len > 0)
1825 purge_addresses(); 1816 purge_addresses();
1826 1817
1827 force_flush = 0; 1818 xfsbufd_force_flush = 0;
1828 } while (pagebuf_daemon_active); 1819 } while (xfsbufd_active);
1829 1820
1830 complete_and_exit(&pagebuf_daemon_done, 0); 1821 complete_and_exit(&xfsbufd_done, 0);
1831} 1822}
1832 1823
1833/* 1824/*
@@ -1844,8 +1835,8 @@ xfs_flush_buftarg(
1844 xfs_buf_t *pb, *n; 1835 xfs_buf_t *pb, *n;
1845 int pincount = 0; 1836 int pincount = 0;
1846 1837
1847 pagebuf_runall_queues(pagebuf_dataio_workqueue); 1838 pagebuf_runall_queues(xfsdatad_workqueue);
1848 pagebuf_runall_queues(pagebuf_logio_workqueue); 1839 pagebuf_runall_queues(xfslogd_workqueue);
1849 1840
1850 INIT_LIST_HEAD(&tmp); 1841 INIT_LIST_HEAD(&tmp);
1851 spin_lock(&pbd_delwrite_lock); 1842 spin_lock(&pbd_delwrite_lock);
@@ -1898,43 +1889,43 @@ xfs_flush_buftarg(
1898} 1889}
1899 1890
1900STATIC int 1891STATIC int
1901pagebuf_daemon_start(void) 1892xfs_buf_daemons_start(void)
1902{ 1893{
1903 int rval; 1894 int error = -ENOMEM;
1904 1895
1905 pagebuf_logio_workqueue = create_workqueue("xfslogd"); 1896 xfslogd_workqueue = create_workqueue("xfslogd");
1906 if (!pagebuf_logio_workqueue) 1897 if (!xfslogd_workqueue)
1907 return -ENOMEM; 1898 goto out;
1908 1899
1909 pagebuf_dataio_workqueue = create_workqueue("xfsdatad"); 1900 xfsdatad_workqueue = create_workqueue("xfsdatad");
1910 if (!pagebuf_dataio_workqueue) { 1901 if (!xfsdatad_workqueue)
1911 destroy_workqueue(pagebuf_logio_workqueue); 1902 goto out_destroy_xfslogd_workqueue;
1912 return -ENOMEM;
1913 }
1914 1903
1915 rval = kernel_thread(pagebuf_daemon, NULL, CLONE_FS|CLONE_FILES); 1904 error = kernel_thread(xfsbufd, NULL, CLONE_FS|CLONE_FILES);
1916 if (rval < 0) { 1905 if (error < 0)
1917 destroy_workqueue(pagebuf_logio_workqueue); 1906 goto out_destroy_xfsdatad_workqueue;
1918 destroy_workqueue(pagebuf_dataio_workqueue); 1907 return 0;
1919 }
1920 1908
1921 return rval; 1909 out_destroy_xfsdatad_workqueue:
1910 destroy_workqueue(xfsdatad_workqueue);
1911 out_destroy_xfslogd_workqueue:
1912 destroy_workqueue(xfslogd_workqueue);
1913 out:
1914 return error;
1922} 1915}
1923 1916
1924/* 1917/*
1925 * pagebuf_daemon_stop
1926 *
1927 * Note: do not mark as __exit, it is called from pagebuf_terminate. 1918 * Note: do not mark as __exit, it is called from pagebuf_terminate.
1928 */ 1919 */
1929STATIC void 1920STATIC void
1930pagebuf_daemon_stop(void) 1921xfs_buf_daemons_stop(void)
1931{ 1922{
1932 pagebuf_daemon_active = 0; 1923 xfsbufd_active = 0;
1933 barrier(); 1924 barrier();
1934 wait_for_completion(&pagebuf_daemon_done); 1925 wait_for_completion(&xfsbufd_done);
1935 1926
1936 destroy_workqueue(pagebuf_logio_workqueue); 1927 destroy_workqueue(xfslogd_workqueue);
1937 destroy_workqueue(pagebuf_dataio_workqueue); 1928 destroy_workqueue(xfsdatad_workqueue);
1938} 1929}
1939 1930
1940/* 1931/*
@@ -1944,27 +1935,37 @@ pagebuf_daemon_stop(void)
1944int __init 1935int __init
1945pagebuf_init(void) 1936pagebuf_init(void)
1946{ 1937{
1947 pagebuf_cache = kmem_cache_create("xfs_buf_t", sizeof(xfs_buf_t), 0, 1938 int error = -ENOMEM;
1948 SLAB_HWCACHE_ALIGN, NULL, NULL); 1939
1949 if (pagebuf_cache == NULL) { 1940 pagebuf_zone = kmem_zone_init(sizeof(xfs_buf_t), "xfs_buf");
1950 printk("XFS: couldn't init xfs_buf_t cache\n"); 1941 if (!pagebuf_zone)
1951 pagebuf_terminate(); 1942 goto out;
1952 return -ENOMEM;
1953 }
1954 1943
1955#ifdef PAGEBUF_TRACE 1944#ifdef PAGEBUF_TRACE
1956 pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP); 1945 pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP);
1957#endif 1946#endif
1958 1947
1959 pagebuf_daemon_start(); 1948 error = xfs_buf_daemons_start();
1949 if (error)
1950 goto out_free_buf_zone;
1960 1951
1961 pagebuf_shake = kmem_shake_register(pagebuf_daemon_wakeup); 1952 pagebuf_shake = kmem_shake_register(xfsbufd_wakeup);
1962 if (pagebuf_shake == NULL) { 1953 if (!pagebuf_shake) {
1963 pagebuf_terminate(); 1954 error = -ENOMEM;
1964 return -ENOMEM; 1955 goto out_stop_daemons;
1965 } 1956 }
1966 1957
1967 return 0; 1958 return 0;
1959
1960 out_stop_daemons:
1961 xfs_buf_daemons_stop();
1962 out_free_buf_zone:
1963#ifdef PAGEBUF_TRACE
1964 ktrace_free(pagebuf_trace_buf);
1965#endif
1966 kmem_zone_destroy(pagebuf_zone);
1967 out:
1968 return error;
1968} 1969}
1969 1970
1970 1971
@@ -1976,12 +1977,12 @@ pagebuf_init(void)
1976void 1977void
1977pagebuf_terminate(void) 1978pagebuf_terminate(void)
1978{ 1979{
1979 pagebuf_daemon_stop(); 1980 xfs_buf_daemons_stop();
1980 1981
1981#ifdef PAGEBUF_TRACE 1982#ifdef PAGEBUF_TRACE
1982 ktrace_free(pagebuf_trace_buf); 1983 ktrace_free(pagebuf_trace_buf);
1983#endif 1984#endif
1984 1985
1985 kmem_zone_destroy(pagebuf_cache); 1986 kmem_zone_destroy(pagebuf_zone);
1986 kmem_shake_deregister(pagebuf_shake); 1987 kmem_shake_deregister(pagebuf_shake);
1987} 1988}
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h
index 74deed8e6d90..3f8f69a66aea 100644
--- a/fs/xfs/linux-2.6/xfs_buf.h
+++ b/fs/xfs/linux-2.6/xfs_buf.h
@@ -576,7 +576,6 @@ extern xfs_buftarg_t *xfs_alloc_buftarg(struct block_device *, int);
576extern void xfs_free_buftarg(xfs_buftarg_t *, int); 576extern void xfs_free_buftarg(xfs_buftarg_t *, int);
577extern void xfs_wait_buftarg(xfs_buftarg_t *); 577extern void xfs_wait_buftarg(xfs_buftarg_t *);
578extern int xfs_setsize_buftarg(xfs_buftarg_t *, unsigned int, unsigned int); 578extern int xfs_setsize_buftarg(xfs_buftarg_t *, unsigned int, unsigned int);
579extern void xfs_incore_relse(xfs_buftarg_t *, int, int);
580extern int xfs_flush_buftarg(xfs_buftarg_t *, int); 579extern int xfs_flush_buftarg(xfs_buftarg_t *, int);
581 580
582#define xfs_getsize_buftarg(buftarg) \ 581#define xfs_getsize_buftarg(buftarg) \
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
index 24fa3b101b93..f1ce4323f56e 100644
--- a/fs/xfs/linux-2.6/xfs_file.c
+++ b/fs/xfs/linux-2.6/xfs_file.c
@@ -57,7 +57,9 @@
57#include <linux/smp_lock.h> 57#include <linux/smp_lock.h>
58 58
59static struct vm_operations_struct linvfs_file_vm_ops; 59static struct vm_operations_struct linvfs_file_vm_ops;
60 60#ifdef CONFIG_XFS_DMAPI
61static struct vm_operations_struct linvfs_dmapi_file_vm_ops;
62#endif
61 63
62STATIC inline ssize_t 64STATIC inline ssize_t
63__linvfs_read( 65__linvfs_read(
@@ -388,6 +390,14 @@ done:
388 return -error; 390 return -error;
389} 391}
390 392
393#ifdef CONFIG_XFS_DMAPI
394STATIC void
395linvfs_mmap_close(
396 struct vm_area_struct *vma)
397{
398 xfs_dm_mm_put(vma);
399}
400#endif /* CONFIG_XFS_DMAPI */
391 401
392STATIC int 402STATIC int
393linvfs_file_mmap( 403linvfs_file_mmap(
@@ -399,16 +409,19 @@ linvfs_file_mmap(
399 vattr_t va = { .va_mask = XFS_AT_UPDATIME }; 409 vattr_t va = { .va_mask = XFS_AT_UPDATIME };
400 int error; 410 int error;
401 411
412 vma->vm_ops = &linvfs_file_vm_ops;
413
402 if (vp->v_vfsp->vfs_flag & VFS_DMI) { 414 if (vp->v_vfsp->vfs_flag & VFS_DMI) {
403 xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp); 415 xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp);
404 416
405 error = -XFS_SEND_MMAP(mp, vma, 0); 417 error = -XFS_SEND_MMAP(mp, vma, 0);
406 if (error) 418 if (error)
407 return error; 419 return error;
420#ifdef CONFIG_XFS_DMAPI
421 vma->vm_ops = &linvfs_dmapi_file_vm_ops;
422#endif
408 } 423 }
409 424
410 vma->vm_ops = &linvfs_file_vm_ops;
411
412 VOP_SETATTR(vp, &va, XFS_AT_UPDATIME, NULL, error); 425 VOP_SETATTR(vp, &va, XFS_AT_UPDATIME, NULL, error);
413 if (!error) 426 if (!error)
414 vn_revalidate(vp); /* update Linux inode flags */ 427 vn_revalidate(vp); /* update Linux inode flags */
@@ -609,7 +622,15 @@ struct file_operations linvfs_dir_operations = {
609static struct vm_operations_struct linvfs_file_vm_ops = { 622static struct vm_operations_struct linvfs_file_vm_ops = {
610 .nopage = filemap_nopage, 623 .nopage = filemap_nopage,
611 .populate = filemap_populate, 624 .populate = filemap_populate,
625};
626
627#ifdef CONFIG_XFS_DMAPI
628static struct vm_operations_struct linvfs_dmapi_file_vm_ops = {
629 .close = linvfs_mmap_close,
630 .nopage = filemap_nopage,
631 .populate = filemap_populate,
612#ifdef HAVE_VMOP_MPROTECT 632#ifdef HAVE_VMOP_MPROTECT
613 .mprotect = linvfs_mprotect, 633 .mprotect = linvfs_mprotect,
614#endif 634#endif
615}; 635};
636#endif /* CONFIG_XFS_DMAPI */
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index 69809eef8a54..05a447e51cc0 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -1174,7 +1174,8 @@ xfs_ioc_xattr(
1174 1174
1175 switch (cmd) { 1175 switch (cmd) {
1176 case XFS_IOC_FSGETXATTR: { 1176 case XFS_IOC_FSGETXATTR: {
1177 va.va_mask = XFS_AT_XFLAGS|XFS_AT_EXTSIZE|XFS_AT_NEXTENTS; 1177 va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \
1178 XFS_AT_NEXTENTS | XFS_AT_PROJID;
1178 VOP_GETATTR(vp, &va, 0, NULL, error); 1179 VOP_GETATTR(vp, &va, 0, NULL, error);
1179 if (error) 1180 if (error)
1180 return -error; 1181 return -error;
@@ -1182,6 +1183,7 @@ xfs_ioc_xattr(
1182 fa.fsx_xflags = va.va_xflags; 1183 fa.fsx_xflags = va.va_xflags;
1183 fa.fsx_extsize = va.va_extsize; 1184 fa.fsx_extsize = va.va_extsize;
1184 fa.fsx_nextents = va.va_nextents; 1185 fa.fsx_nextents = va.va_nextents;
1186 fa.fsx_projid = va.va_projid;
1185 1187
1186 if (copy_to_user(arg, &fa, sizeof(fa))) 1188 if (copy_to_user(arg, &fa, sizeof(fa)))
1187 return -XFS_ERROR(EFAULT); 1189 return -XFS_ERROR(EFAULT);
@@ -1196,9 +1198,10 @@ xfs_ioc_xattr(
1196 if (filp->f_flags & (O_NDELAY|O_NONBLOCK)) 1198 if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
1197 attr_flags |= ATTR_NONBLOCK; 1199 attr_flags |= ATTR_NONBLOCK;
1198 1200
1199 va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE; 1201 va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | XFS_AT_PROJID;
1200 va.va_xflags = fa.fsx_xflags; 1202 va.va_xflags = fa.fsx_xflags;
1201 va.va_extsize = fa.fsx_extsize; 1203 va.va_extsize = fa.fsx_extsize;
1204 va.va_projid = fa.fsx_projid;
1202 1205
1203 VOP_SETATTR(vp, &va, attr_flags, NULL, error); 1206 VOP_SETATTR(vp, &va, attr_flags, NULL, error);
1204 if (!error) 1207 if (!error)
@@ -1207,7 +1210,8 @@ xfs_ioc_xattr(
1207 } 1210 }
1208 1211
1209 case XFS_IOC_FSGETXATTRA: { 1212 case XFS_IOC_FSGETXATTRA: {
1210 va.va_mask = XFS_AT_XFLAGS|XFS_AT_EXTSIZE|XFS_AT_ANEXTENTS; 1213 va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \
1214 XFS_AT_ANEXTENTS | XFS_AT_PROJID;
1211 VOP_GETATTR(vp, &va, 0, NULL, error); 1215 VOP_GETATTR(vp, &va, 0, NULL, error);
1212 if (error) 1216 if (error)
1213 return -error; 1217 return -error;
@@ -1215,6 +1219,7 @@ xfs_ioc_xattr(
1215 fa.fsx_xflags = va.va_xflags; 1219 fa.fsx_xflags = va.va_xflags;
1216 fa.fsx_extsize = va.va_extsize; 1220 fa.fsx_extsize = va.va_extsize;
1217 fa.fsx_nextents = va.va_anextents; 1221 fa.fsx_nextents = va.va_anextents;
1222 fa.fsx_projid = va.va_projid;
1218 1223
1219 if (copy_to_user(arg, &fa, sizeof(fa))) 1224 if (copy_to_user(arg, &fa, sizeof(fa)))
1220 return -XFS_ERROR(EFAULT); 1225 return -XFS_ERROR(EFAULT);
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h
index 71bb41019a12..42dc5e4662ed 100644
--- a/fs/xfs/linux-2.6/xfs_linux.h
+++ b/fs/xfs/linux-2.6/xfs_linux.h
@@ -145,10 +145,10 @@ static inline void set_buffer_unwritten_io(struct buffer_head *bh)
145#define xfs_inherit_nosymlinks xfs_params.inherit_nosym.val 145#define xfs_inherit_nosymlinks xfs_params.inherit_nosym.val
146#define xfs_rotorstep xfs_params.rotorstep.val 146#define xfs_rotorstep xfs_params.rotorstep.val
147 147
148#ifndef __smp_processor_id 148#ifndef raw_smp_processor_id
149#define __smp_processor_id() smp_processor_id() 149#define raw_smp_processor_id() smp_processor_id()
150#endif 150#endif
151#define current_cpu() __smp_processor_id() 151#define current_cpu() raw_smp_processor_id()
152#define current_pid() (current->pid) 152#define current_pid() (current->pid)
153#define current_fsuid(cred) (current->fsuid) 153#define current_fsuid(cred) (current->fsuid)
154#define current_fsgid(cred) (current->fsgid) 154#define current_fsgid(cred) (current->fsgid)
@@ -230,8 +230,10 @@ static inline void set_buffer_unwritten_io(struct buffer_head *bh)
230 * field (see the QCMD macro in quota.h). These macros help keep the 230 * field (see the QCMD macro in quota.h). These macros help keep the
231 * code portable - they are not visible from the syscall interface. 231 * code portable - they are not visible from the syscall interface.
232 */ 232 */
233#define Q_XSETGQLIM XQM_CMD(0x8) /* set groups disk limits */ 233#define Q_XSETGQLIM XQM_CMD(8) /* set groups disk limits */
234#define Q_XGETGQUOTA XQM_CMD(0x9) /* get groups disk limits */ 234#define Q_XGETGQUOTA XQM_CMD(9) /* get groups disk limits */
235#define Q_XSETPQLIM XQM_CMD(10) /* set projects disk limits */
236#define Q_XGETPQUOTA XQM_CMD(11) /* get projects disk limits */
235 237
236/* IRIX uses a dynamic sizing algorithm (ndquot = 200 + numprocs*2) */ 238/* IRIX uses a dynamic sizing algorithm (ndquot = 200 + numprocs*2) */
237/* we may well need to fine-tune this if it ever becomes an issue. */ 239/* we may well need to fine-tune this if it ever becomes an issue. */
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c
index aa9daaea6c34..acab58c48043 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.c
+++ b/fs/xfs/linux-2.6/xfs_lrw.c
@@ -209,30 +209,6 @@ unlock:
209 return (-status); 209 return (-status);
210} 210}
211 211
212/*
213 * xfs_inval_cached_pages
214 *
215 * This routine is responsible for keeping direct I/O and buffered I/O
216 * somewhat coherent. From here we make sure that we're at least
217 * temporarily holding the inode I/O lock exclusively and then call
218 * the page cache to flush and invalidate any cached pages. If there
219 * are no cached pages this routine will be very quick.
220 */
221void
222xfs_inval_cached_pages(
223 vnode_t *vp,
224 xfs_iocore_t *io,
225 xfs_off_t offset,
226 int write,
227 int relock)
228{
229 if (VN_CACHED(vp)) {
230 xfs_inval_cached_trace(io, offset, -1, ctooff(offtoct(offset)), -1);
231 VOP_FLUSHINVAL_PAGES(vp, ctooff(offtoct(offset)), -1, FI_REMAPF_LOCKED);
232 }
233
234}
235
236ssize_t /* bytes read, or (-) error */ 212ssize_t /* bytes read, or (-) error */
237xfs_read( 213xfs_read(
238 bhv_desc_t *bdp, 214 bhv_desc_t *bdp,
@@ -304,10 +280,11 @@ xfs_read(
304 if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) && 280 if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) &&
305 !(ioflags & IO_INVIS)) { 281 !(ioflags & IO_INVIS)) {
306 vrwlock_t locktype = VRWLOCK_READ; 282 vrwlock_t locktype = VRWLOCK_READ;
283 int dmflags = FILP_DELAY_FLAG(file) | DM_SEM_FLAG_RD(ioflags);
307 284
308 ret = -XFS_SEND_DATA(mp, DM_EVENT_READ, 285 ret = -XFS_SEND_DATA(mp, DM_EVENT_READ,
309 BHV_TO_VNODE(bdp), *offset, size, 286 BHV_TO_VNODE(bdp), *offset, size,
310 FILP_DELAY_FLAG(file), &locktype); 287 dmflags, &locktype);
311 if (ret) { 288 if (ret) {
312 xfs_iunlock(ip, XFS_IOLOCK_SHARED); 289 xfs_iunlock(ip, XFS_IOLOCK_SHARED);
313 goto unlock_isem; 290 goto unlock_isem;
@@ -867,11 +844,15 @@ retry:
867 !(ioflags & IO_INVIS)) { 844 !(ioflags & IO_INVIS)) {
868 845
869 xfs_rwunlock(bdp, locktype); 846 xfs_rwunlock(bdp, locktype);
847 if (need_isem)
848 up(&inode->i_sem);
870 error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp, 849 error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp,
871 DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL, 850 DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL,
872 0, 0, 0); /* Delay flag intentionally unused */ 851 0, 0, 0); /* Delay flag intentionally unused */
873 if (error) 852 if (error)
874 goto out_unlock_isem; 853 goto out_nounlocks;
854 if (need_isem)
855 down(&inode->i_sem);
875 xfs_rwlock(bdp, locktype); 856 xfs_rwlock(bdp, locktype);
876 pos = xip->i_d.di_size; 857 pos = xip->i_d.di_size;
877 ret = 0; 858 ret = 0;
@@ -986,6 +967,7 @@ retry:
986 out_unlock_isem: 967 out_unlock_isem:
987 if (need_isem) 968 if (need_isem)
988 up(&inode->i_sem); 969 up(&inode->i_sem);
970 out_nounlocks:
989 return -error; 971 return -error;
990} 972}
991 973
diff --git a/fs/xfs/linux-2.6/xfs_lrw.h b/fs/xfs/linux-2.6/xfs_lrw.h
index d723e35254a0..f197a720e394 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.h
+++ b/fs/xfs/linux-2.6/xfs_lrw.h
@@ -94,8 +94,6 @@ extern int xfs_bdstrat_cb(struct xfs_buf *);
94 94
95extern int xfs_zero_eof(struct vnode *, struct xfs_iocore *, xfs_off_t, 95extern int xfs_zero_eof(struct vnode *, struct xfs_iocore *, xfs_off_t,
96 xfs_fsize_t, xfs_fsize_t); 96 xfs_fsize_t, xfs_fsize_t);
97extern void xfs_inval_cached_pages(struct vnode *, struct xfs_iocore *,
98 xfs_off_t, int, int);
99extern ssize_t xfs_read(struct bhv_desc *, struct kiocb *, 97extern ssize_t xfs_read(struct bhv_desc *, struct kiocb *,
100 const struct iovec *, unsigned int, 98 const struct iovec *, unsigned int,
101 loff_t *, int, struct cred *); 99 loff_t *, int, struct cred *);
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 455e2b2fb964..5fe9af38aa20 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -590,8 +590,10 @@ linvfs_sync_super(
590 int error; 590 int error;
591 int flags = SYNC_FSDATA; 591 int flags = SYNC_FSDATA;
592 592
593 if (wait) 593 if (unlikely(sb->s_frozen == SB_FREEZE_WRITE))
594 flags |= SYNC_WAIT; 594 flags = SYNC_QUIESCE;
595 else
596 flags = SYNC_FSDATA | (wait ? SYNC_WAIT : 0);
595 597
596 VFS_SYNC(vfsp, flags, NULL, error); 598 VFS_SYNC(vfsp, flags, NULL, error);
597 sb->s_dirt = 0; 599 sb->s_dirt = 0;
@@ -701,7 +703,8 @@ linvfs_getxquota(
701 struct vfs *vfsp = LINVFS_GET_VFS(sb); 703 struct vfs *vfsp = LINVFS_GET_VFS(sb);
702 int error, getmode; 704 int error, getmode;
703 705
704 getmode = (type == GRPQUOTA) ? Q_XGETGQUOTA : Q_XGETQUOTA; 706 getmode = (type == USRQUOTA) ? Q_XGETQUOTA :
707 ((type == GRPQUOTA) ? Q_XGETGQUOTA : Q_XGETPQUOTA);
705 VFS_QUOTACTL(vfsp, getmode, id, (caddr_t)fdq, error); 708 VFS_QUOTACTL(vfsp, getmode, id, (caddr_t)fdq, error);
706 return -error; 709 return -error;
707} 710}
@@ -716,7 +719,8 @@ linvfs_setxquota(
716 struct vfs *vfsp = LINVFS_GET_VFS(sb); 719 struct vfs *vfsp = LINVFS_GET_VFS(sb);
717 int error, setmode; 720 int error, setmode;
718 721
719 setmode = (type == GRPQUOTA) ? Q_XSETGQLIM : Q_XSETQLIM; 722 setmode = (type == USRQUOTA) ? Q_XSETQLIM :
723 ((type == GRPQUOTA) ? Q_XSETGQLIM : Q_XSETPQLIM);
720 VFS_QUOTACTL(vfsp, setmode, id, (caddr_t)fdq, error); 724 VFS_QUOTACTL(vfsp, setmode, id, (caddr_t)fdq, error);
721 return -error; 725 return -error;
722} 726}
diff --git a/fs/xfs/linux-2.6/xfs_vfs.h b/fs/xfs/linux-2.6/xfs_vfs.h
index 76493991578f..7ee1f714e9ba 100644
--- a/fs/xfs/linux-2.6/xfs_vfs.h
+++ b/fs/xfs/linux-2.6/xfs_vfs.h
@@ -107,6 +107,7 @@ typedef enum {
107#define SYNC_FSDATA 0x0020 /* flush fs data (e.g. superblocks) */ 107#define SYNC_FSDATA 0x0020 /* flush fs data (e.g. superblocks) */
108#define SYNC_REFCACHE 0x0040 /* prune some of the nfs ref cache */ 108#define SYNC_REFCACHE 0x0040 /* prune some of the nfs ref cache */
109#define SYNC_REMOUNT 0x0080 /* remount readonly, no dummy LRs */ 109#define SYNC_REMOUNT 0x0080 /* remount readonly, no dummy LRs */
110#define SYNC_QUIESCE 0x0100 /* quiesce fileystem for a snapshot */
110 111
111typedef int (*vfs_mount_t)(bhv_desc_t *, 112typedef int (*vfs_mount_t)(bhv_desc_t *,
112 struct xfs_mount_args *, struct cred *); 113 struct xfs_mount_args *, struct cred *);
diff --git a/fs/xfs/linux-2.6/xfs_vnode.c b/fs/xfs/linux-2.6/xfs_vnode.c
index a832d165f24f..250cad54e892 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.c
+++ b/fs/xfs/linux-2.6/xfs_vnode.c
@@ -411,13 +411,13 @@ vn_remove(
411/* 0 */ (void *)(__psint_t)(vk), \ 411/* 0 */ (void *)(__psint_t)(vk), \
412/* 1 */ (void *)(s), \ 412/* 1 */ (void *)(s), \
413/* 2 */ (void *)(__psint_t) line, \ 413/* 2 */ (void *)(__psint_t) line, \
414/* 3 */ (void *)(vn_count(vp)), \ 414/* 3 */ (void *)(__psint_t)(vn_count(vp)), \
415/* 4 */ (void *)(ra), \ 415/* 4 */ (void *)(ra), \
416/* 5 */ (void *)(__psunsigned_t)(vp)->v_flag, \ 416/* 5 */ (void *)(__psunsigned_t)(vp)->v_flag, \
417/* 6 */ (void *)(__psint_t)current_cpu(), \ 417/* 6 */ (void *)(__psint_t)current_cpu(), \
418/* 7 */ (void *)(__psint_t)current_pid(), \ 418/* 7 */ (void *)(__psint_t)current_pid(), \
419/* 8 */ (void *)__return_address, \ 419/* 8 */ (void *)__return_address, \
420/* 9 */ 0, 0, 0, 0, 0, 0, 0) 420/* 9 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL)
421 421
422/* 422/*
423 * Vnode tracing code. 423 * Vnode tracing code.
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h
index 00466c3194ac..a6e57c647be4 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.h
+++ b/fs/xfs/linux-2.6/xfs_vnode.h
@@ -426,7 +426,7 @@ typedef struct vattr {
426 u_long va_extsize; /* file extent size */ 426 u_long va_extsize; /* file extent size */
427 u_long va_nextents; /* number of extents in file */ 427 u_long va_nextents; /* number of extents in file */
428 u_long va_anextents; /* number of attr extents in file */ 428 u_long va_anextents; /* number of attr extents in file */
429 int va_projid; /* project id */ 429 prid_t va_projid; /* project id */
430} vattr_t; 430} vattr_t;
431 431
432/* 432/*
diff --git a/fs/xfs/quota/xfs_dquot.c b/fs/xfs/quota/xfs_dquot.c
index 740d20d33187..46ce1e3ce1d6 100644
--- a/fs/xfs/quota/xfs_dquot.c
+++ b/fs/xfs/quota/xfs_dquot.c
@@ -101,7 +101,7 @@ int xfs_dqerror_mod = 33;
101 * is the d_id field. The idea is to fill in the entire q_core 101 * is the d_id field. The idea is to fill in the entire q_core
102 * when we read in the on disk dquot. 102 * when we read in the on disk dquot.
103 */ 103 */
104xfs_dquot_t * 104STATIC xfs_dquot_t *
105xfs_qm_dqinit( 105xfs_qm_dqinit(
106 xfs_mount_t *mp, 106 xfs_mount_t *mp,
107 xfs_dqid_t id, 107 xfs_dqid_t id,
@@ -286,7 +286,9 @@ xfs_qm_adjust_dqlimits(
286 * We also return 0 as the values of the timers in Q_GETQUOTA calls, when 286 * We also return 0 as the values of the timers in Q_GETQUOTA calls, when
287 * enforcement's off. 287 * enforcement's off.
288 * In contrast, warnings are a little different in that they don't 288 * In contrast, warnings are a little different in that they don't
289 * 'automatically' get started when limits get exceeded. 289 * 'automatically' get started when limits get exceeded. They do
290 * get reset to zero, however, when we find the count to be under
291 * the soft limit (they are only ever set non-zero via userspace).
290 */ 292 */
291void 293void
292xfs_qm_adjust_dqtimers( 294xfs_qm_adjust_dqtimers(
@@ -315,6 +317,8 @@ xfs_qm_adjust_dqtimers(
315 INT_GET(d->d_blk_hardlimit, ARCH_CONVERT)))) { 317 INT_GET(d->d_blk_hardlimit, ARCH_CONVERT)))) {
316 INT_SET(d->d_btimer, ARCH_CONVERT, 318 INT_SET(d->d_btimer, ARCH_CONVERT,
317 get_seconds() + XFS_QI_BTIMELIMIT(mp)); 319 get_seconds() + XFS_QI_BTIMELIMIT(mp));
320 } else {
321 d->d_bwarns = 0;
318 } 322 }
319 } else { 323 } else {
320 if ((!d->d_blk_softlimit || 324 if ((!d->d_blk_softlimit ||
@@ -336,6 +340,8 @@ xfs_qm_adjust_dqtimers(
336 INT_GET(d->d_ino_hardlimit, ARCH_CONVERT)))) { 340 INT_GET(d->d_ino_hardlimit, ARCH_CONVERT)))) {
337 INT_SET(d->d_itimer, ARCH_CONVERT, 341 INT_SET(d->d_itimer, ARCH_CONVERT,
338 get_seconds() + XFS_QI_ITIMELIMIT(mp)); 342 get_seconds() + XFS_QI_ITIMELIMIT(mp));
343 } else {
344 d->d_iwarns = 0;
339 } 345 }
340 } else { 346 } else {
341 if ((!d->d_ino_softlimit || 347 if ((!d->d_ino_softlimit ||
@@ -357,6 +363,8 @@ xfs_qm_adjust_dqtimers(
357 INT_GET(d->d_rtb_hardlimit, ARCH_CONVERT)))) { 363 INT_GET(d->d_rtb_hardlimit, ARCH_CONVERT)))) {
358 INT_SET(d->d_rtbtimer, ARCH_CONVERT, 364 INT_SET(d->d_rtbtimer, ARCH_CONVERT,
359 get_seconds() + XFS_QI_RTBTIMELIMIT(mp)); 365 get_seconds() + XFS_QI_RTBTIMELIMIT(mp));
366 } else {
367 d->d_rtbwarns = 0;
360 } 368 }
361 } else { 369 } else {
362 if ((!d->d_rtb_softlimit || 370 if ((!d->d_rtb_softlimit ||
@@ -371,68 +379,6 @@ xfs_qm_adjust_dqtimers(
371} 379}
372 380
373/* 381/*
374 * Increment or reset warnings of a given dquot.
375 */
376int
377xfs_qm_dqwarn(
378 xfs_disk_dquot_t *d,
379 uint flags)
380{
381 int warned;
382
383 /*
384 * root's limits are not real limits.
385 */
386 if (!d->d_id)
387 return (0);
388
389 warned = 0;
390 if (INT_GET(d->d_blk_softlimit, ARCH_CONVERT) &&
391 (INT_GET(d->d_bcount, ARCH_CONVERT) >=
392 INT_GET(d->d_blk_softlimit, ARCH_CONVERT))) {
393 if (flags & XFS_QMOPT_DOWARN) {
394 INT_MOD(d->d_bwarns, ARCH_CONVERT, +1);
395 warned++;
396 }
397 } else {
398 if (!d->d_blk_softlimit ||
399 (INT_GET(d->d_bcount, ARCH_CONVERT) <
400 INT_GET(d->d_blk_softlimit, ARCH_CONVERT))) {
401 d->d_bwarns = 0;
402 }
403 }
404
405 if (INT_GET(d->d_ino_softlimit, ARCH_CONVERT) > 0 &&
406 (INT_GET(d->d_icount, ARCH_CONVERT) >=
407 INT_GET(d->d_ino_softlimit, ARCH_CONVERT))) {
408 if (flags & XFS_QMOPT_DOWARN) {
409 INT_MOD(d->d_iwarns, ARCH_CONVERT, +1);
410 warned++;
411 }
412 } else {
413 if (!d->d_ino_softlimit ||
414 (INT_GET(d->d_icount, ARCH_CONVERT) <
415 INT_GET(d->d_ino_softlimit, ARCH_CONVERT))) {
416 d->d_iwarns = 0;
417 }
418 }
419#ifdef QUOTADEBUG
420 if (INT_GET(d->d_iwarns, ARCH_CONVERT))
421 cmn_err(CE_DEBUG,
422 "--------@@Inode warnings running : %Lu >= %Lu",
423 INT_GET(d->d_icount, ARCH_CONVERT),
424 INT_GET(d->d_ino_softlimit, ARCH_CONVERT));
425 if (INT_GET(d->d_bwarns, ARCH_CONVERT))
426 cmn_err(CE_DEBUG,
427 "--------@@Blks warnings running : %Lu >= %Lu",
428 INT_GET(d->d_bcount, ARCH_CONVERT),
429 INT_GET(d->d_blk_softlimit, ARCH_CONVERT));
430#endif
431 return (warned);
432}
433
434
435/*
436 * initialize a buffer full of dquots and log the whole thing 382 * initialize a buffer full of dquots and log the whole thing
437 */ 383 */
438STATIC void 384STATIC void
@@ -461,9 +407,9 @@ xfs_qm_init_dquot_blk(
461 for (i = 0; i < XFS_QM_DQPERBLK(mp); i++, d++, curid++) 407 for (i = 0; i < XFS_QM_DQPERBLK(mp); i++, d++, curid++)
462 xfs_qm_dqinit_core(curid, type, d); 408 xfs_qm_dqinit_core(curid, type, d);
463 xfs_trans_dquot_buf(tp, bp, 409 xfs_trans_dquot_buf(tp, bp,
464 type & XFS_DQ_USER ? 410 (type & XFS_DQ_USER ? XFS_BLI_UDQUOT_BUF :
465 XFS_BLI_UDQUOT_BUF : 411 ((type & XFS_DQ_PROJ) ? XFS_BLI_PDQUOT_BUF :
466 XFS_BLI_GDQUOT_BUF); 412 XFS_BLI_GDQUOT_BUF)));
467 xfs_trans_log_buf(tp, bp, 0, BBTOB(XFS_QI_DQCHUNKLEN(mp)) - 1); 413 xfs_trans_log_buf(tp, bp, 0, BBTOB(XFS_QI_DQCHUNKLEN(mp)) - 1);
468} 414}
469 415
@@ -544,8 +490,7 @@ xfs_qm_dqalloc(
544 * the entire thing. 490 * the entire thing.
545 */ 491 */
546 xfs_qm_init_dquot_blk(tp, mp, INT_GET(dqp->q_core.d_id, ARCH_CONVERT), 492 xfs_qm_init_dquot_blk(tp, mp, INT_GET(dqp->q_core.d_id, ARCH_CONVERT),
547 dqp->dq_flags & (XFS_DQ_USER|XFS_DQ_GROUP), 493 dqp->dq_flags & XFS_DQ_ALLTYPES, bp);
548 bp);
549 494
550 if ((error = xfs_bmap_finish(&tp, &flist, firstblock, &committed))) { 495 if ((error = xfs_bmap_finish(&tp, &flist, firstblock, &committed))) {
551 goto error1; 496 goto error1;
@@ -675,8 +620,7 @@ xfs_qm_dqtobp(
675 /* 620 /*
676 * A simple sanity check in case we got a corrupted dquot... 621 * A simple sanity check in case we got a corrupted dquot...
677 */ 622 */
678 if (xfs_qm_dqcheck(ddq, id, 623 if (xfs_qm_dqcheck(ddq, id, dqp->dq_flags & XFS_DQ_ALLTYPES,
679 dqp->dq_flags & (XFS_DQ_USER|XFS_DQ_GROUP),
680 flags & (XFS_QMOPT_DQREPAIR|XFS_QMOPT_DOWARN), 624 flags & (XFS_QMOPT_DQREPAIR|XFS_QMOPT_DOWARN),
681 "dqtobp")) { 625 "dqtobp")) {
682 if (!(flags & XFS_QMOPT_DQREPAIR)) { 626 if (!(flags & XFS_QMOPT_DQREPAIR)) {
@@ -953,8 +897,8 @@ int
953xfs_qm_dqget( 897xfs_qm_dqget(
954 xfs_mount_t *mp, 898 xfs_mount_t *mp,
955 xfs_inode_t *ip, /* locked inode (optional) */ 899 xfs_inode_t *ip, /* locked inode (optional) */
956 xfs_dqid_t id, /* gid or uid, depending on type */ 900 xfs_dqid_t id, /* uid/projid/gid depending on type */
957 uint type, /* UDQUOT or GDQUOT */ 901 uint type, /* XFS_DQ_USER/XFS_DQ_PROJ/XFS_DQ_GROUP */
958 uint flags, /* DQALLOC, DQSUSER, DQREPAIR, DOWARN */ 902 uint flags, /* DQALLOC, DQSUSER, DQREPAIR, DOWARN */
959 xfs_dquot_t **O_dqpp) /* OUT : locked incore dquot */ 903 xfs_dquot_t **O_dqpp) /* OUT : locked incore dquot */
960{ 904{
@@ -965,6 +909,7 @@ xfs_qm_dqget(
965 909
966 ASSERT(XFS_IS_QUOTA_RUNNING(mp)); 910 ASSERT(XFS_IS_QUOTA_RUNNING(mp));
967 if ((! XFS_IS_UQUOTA_ON(mp) && type == XFS_DQ_USER) || 911 if ((! XFS_IS_UQUOTA_ON(mp) && type == XFS_DQ_USER) ||
912 (! XFS_IS_PQUOTA_ON(mp) && type == XFS_DQ_PROJ) ||
968 (! XFS_IS_GQUOTA_ON(mp) && type == XFS_DQ_GROUP)) { 913 (! XFS_IS_GQUOTA_ON(mp) && type == XFS_DQ_GROUP)) {
969 return (ESRCH); 914 return (ESRCH);
970 } 915 }
@@ -983,7 +928,9 @@ xfs_qm_dqget(
983 again: 928 again:
984 929
985#ifdef DEBUG 930#ifdef DEBUG
986 ASSERT(type == XFS_DQ_USER || type == XFS_DQ_GROUP); 931 ASSERT(type == XFS_DQ_USER ||
932 type == XFS_DQ_PROJ ||
933 type == XFS_DQ_GROUP);
987 if (ip) { 934 if (ip) {
988 ASSERT(XFS_ISLOCKED_INODE_EXCL(ip)); 935 ASSERT(XFS_ISLOCKED_INODE_EXCL(ip));
989 if (type == XFS_DQ_USER) 936 if (type == XFS_DQ_USER)
@@ -1306,8 +1253,8 @@ xfs_qm_dqflush(
1306 return (error); 1253 return (error);
1307 } 1254 }
1308 1255
1309 if (xfs_qm_dqcheck(&dqp->q_core, INT_GET(ddqp->d_id, ARCH_CONVERT), 0, XFS_QMOPT_DOWARN, 1256 if (xfs_qm_dqcheck(&dqp->q_core, INT_GET(ddqp->d_id, ARCH_CONVERT),
1310 "dqflush (incore copy)")) { 1257 0, XFS_QMOPT_DOWARN, "dqflush (incore copy)")) {
1311 xfs_force_shutdown(dqp->q_mount, XFS_CORRUPT_INCORE); 1258 xfs_force_shutdown(dqp->q_mount, XFS_CORRUPT_INCORE);
1312 return XFS_ERROR(EIO); 1259 return XFS_ERROR(EIO);
1313 } 1260 }
@@ -1459,7 +1406,8 @@ xfs_dqlock2(
1459{ 1406{
1460 if (d1 && d2) { 1407 if (d1 && d2) {
1461 ASSERT(d1 != d2); 1408 ASSERT(d1 != d2);
1462 if (INT_GET(d1->q_core.d_id, ARCH_CONVERT) > INT_GET(d2->q_core.d_id, ARCH_CONVERT)) { 1409 if (INT_GET(d1->q_core.d_id, ARCH_CONVERT) >
1410 INT_GET(d2->q_core.d_id, ARCH_CONVERT)) {
1463 xfs_dqlock(d2); 1411 xfs_dqlock(d2);
1464 xfs_dqlock(d1); 1412 xfs_dqlock(d1);
1465 } else { 1413 } else {
@@ -1582,8 +1530,7 @@ xfs_qm_dqprint(xfs_dquot_t *dqp)
1582 cmn_err(CE_DEBUG, "-----------KERNEL DQUOT----------------"); 1530 cmn_err(CE_DEBUG, "-----------KERNEL DQUOT----------------");
1583 cmn_err(CE_DEBUG, "---- dquotID = %d", 1531 cmn_err(CE_DEBUG, "---- dquotID = %d",
1584 (int)INT_GET(dqp->q_core.d_id, ARCH_CONVERT)); 1532 (int)INT_GET(dqp->q_core.d_id, ARCH_CONVERT));
1585 cmn_err(CE_DEBUG, "---- type = %s", 1533 cmn_err(CE_DEBUG, "---- type = %s", DQFLAGTO_TYPESTR(dqp));
1586 XFS_QM_ISUDQ(dqp) ? "USR" : "GRP");
1587 cmn_err(CE_DEBUG, "---- fs = 0x%p", dqp->q_mount); 1534 cmn_err(CE_DEBUG, "---- fs = 0x%p", dqp->q_mount);
1588 cmn_err(CE_DEBUG, "---- blkno = 0x%x", (int) dqp->q_blkno); 1535 cmn_err(CE_DEBUG, "---- blkno = 0x%x", (int) dqp->q_blkno);
1589 cmn_err(CE_DEBUG, "---- boffset = 0x%x", (int) dqp->q_bufoffset); 1536 cmn_err(CE_DEBUG, "---- boffset = 0x%x", (int) dqp->q_bufoffset);
diff --git a/fs/xfs/quota/xfs_dquot.h b/fs/xfs/quota/xfs_dquot.h
index 0c3fe3175baa..39175103c8e0 100644
--- a/fs/xfs/quota/xfs_dquot.h
+++ b/fs/xfs/quota/xfs_dquot.h
@@ -114,25 +114,18 @@ typedef struct xfs_dquot {
114#define XFS_DQHOLD(dqp) ((dqp)->q_nrefs++) 114#define XFS_DQHOLD(dqp) ((dqp)->q_nrefs++)
115 115
116/* 116/*
117 * Quota Accounting flags 117 * Quota Accounting/Enforcement flags
118 */ 118 */
119#define XFS_ALL_QUOTA_ACCT (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT) 119#define XFS_ALL_QUOTA_ACCT \
120#define XFS_ALL_QUOTA_ENFD (XFS_UQUOTA_ENFD | XFS_GQUOTA_ENFD) 120 (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT)
121#define XFS_ALL_QUOTA_CHKD (XFS_UQUOTA_CHKD | XFS_GQUOTA_CHKD) 121#define XFS_ALL_QUOTA_ENFD (XFS_UQUOTA_ENFD | XFS_OQUOTA_ENFD)
122#define XFS_ALL_QUOTA_ACTV (XFS_UQUOTA_ACTIVE | XFS_GQUOTA_ACTIVE) 122#define XFS_ALL_QUOTA_CHKD (XFS_UQUOTA_CHKD | XFS_OQUOTA_CHKD)
123#define XFS_ALL_QUOTA_ACCT_ENFD (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
124 XFS_GQUOTA_ACCT|XFS_GQUOTA_ENFD)
125 123
126#define XFS_IS_QUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT) 124#define XFS_IS_QUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT)
127#define XFS_IS_UQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT)
128#define XFS_IS_GQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT)
129
130/*
131 * Quota Limit Enforcement flags
132 */
133#define XFS_IS_QUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ENFD) 125#define XFS_IS_QUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ENFD)
134#define XFS_IS_UQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD) 126#define XFS_IS_UQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT)
135#define XFS_IS_GQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_GQUOTA_ENFD) 127#define XFS_IS_PQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT)
128#define XFS_IS_GQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT)
136 129
137#ifdef DEBUG 130#ifdef DEBUG
138static inline int 131static inline int
@@ -167,6 +160,8 @@ XFS_DQ_IS_LOCKED(xfs_dquot_t *dqp)
167#define XFS_DQ_IS_ON_FREELIST(dqp) ((dqp)->dq_flnext != (dqp)) 160#define XFS_DQ_IS_ON_FREELIST(dqp) ((dqp)->dq_flnext != (dqp))
168#define XFS_DQ_IS_DIRTY(dqp) ((dqp)->dq_flags & XFS_DQ_DIRTY) 161#define XFS_DQ_IS_DIRTY(dqp) ((dqp)->dq_flags & XFS_DQ_DIRTY)
169#define XFS_QM_ISUDQ(dqp) ((dqp)->dq_flags & XFS_DQ_USER) 162#define XFS_QM_ISUDQ(dqp) ((dqp)->dq_flags & XFS_DQ_USER)
163#define XFS_QM_ISPDQ(dqp) ((dqp)->dq_flags & XFS_DQ_PROJ)
164#define XFS_QM_ISGDQ(dqp) ((dqp)->dq_flags & XFS_DQ_GROUP)
170#define XFS_DQ_TO_QINF(dqp) ((dqp)->q_mount->m_quotainfo) 165#define XFS_DQ_TO_QINF(dqp) ((dqp)->q_mount->m_quotainfo)
171#define XFS_DQ_TO_QIP(dqp) (XFS_QM_ISUDQ(dqp) ? \ 166#define XFS_DQ_TO_QIP(dqp) (XFS_QM_ISUDQ(dqp) ? \
172 XFS_DQ_TO_QINF(dqp)->qi_uquotaip : \ 167 XFS_DQ_TO_QINF(dqp)->qi_uquotaip : \
@@ -174,7 +169,7 @@ XFS_DQ_IS_LOCKED(xfs_dquot_t *dqp)
174 169
175#define XFS_IS_THIS_QUOTA_OFF(d) (! (XFS_QM_ISUDQ(d) ? \ 170#define XFS_IS_THIS_QUOTA_OFF(d) (! (XFS_QM_ISUDQ(d) ? \
176 (XFS_IS_UQUOTA_ON((d)->q_mount)) : \ 171 (XFS_IS_UQUOTA_ON((d)->q_mount)) : \
177 (XFS_IS_GQUOTA_ON((d)->q_mount)))) 172 (XFS_IS_OQUOTA_ON((d)->q_mount))))
178 173
179#ifdef XFS_DQUOT_TRACE 174#ifdef XFS_DQUOT_TRACE
180/* 175/*
@@ -211,7 +206,6 @@ extern void xfs_qm_adjust_dqtimers(xfs_mount_t *,
211 xfs_disk_dquot_t *); 206 xfs_disk_dquot_t *);
212extern void xfs_qm_adjust_dqlimits(xfs_mount_t *, 207extern void xfs_qm_adjust_dqlimits(xfs_mount_t *,
213 xfs_disk_dquot_t *); 208 xfs_disk_dquot_t *);
214extern int xfs_qm_dqwarn(xfs_disk_dquot_t *, uint);
215extern int xfs_qm_dqget(xfs_mount_t *, xfs_inode_t *, 209extern int xfs_qm_dqget(xfs_mount_t *, xfs_inode_t *,
216 xfs_dqid_t, uint, uint, xfs_dquot_t **); 210 xfs_dqid_t, uint, uint, xfs_dquot_t **);
217extern void xfs_qm_dqput(xfs_dquot_t *); 211extern void xfs_qm_dqput(xfs_dquot_t *);
diff --git a/fs/xfs/quota/xfs_dquot_item.c b/fs/xfs/quota/xfs_dquot_item.c
index a5425ee6e7bd..f5271b7b1e84 100644
--- a/fs/xfs/quota/xfs_dquot_item.c
+++ b/fs/xfs/quota/xfs_dquot_item.c
@@ -428,7 +428,7 @@ xfs_qm_dquot_logitem_committing(
428/* 428/*
429 * This is the ops vector for dquots 429 * This is the ops vector for dquots
430 */ 430 */
431struct xfs_item_ops xfs_dquot_item_ops = { 431STATIC struct xfs_item_ops xfs_dquot_item_ops = {
432 .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_size, 432 .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_size,
433 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 433 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
434 xfs_qm_dquot_logitem_format, 434 xfs_qm_dquot_logitem_format,
@@ -646,7 +646,7 @@ xfs_qm_qoffend_logitem_committing(xfs_qoff_logitem_t *qip, xfs_lsn_t commit_lsn)
646 return; 646 return;
647} 647}
648 648
649struct xfs_item_ops xfs_qm_qoffend_logitem_ops = { 649STATIC struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
650 .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size, 650 .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size,
651 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 651 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
652 xfs_qm_qoff_logitem_format, 652 xfs_qm_qoff_logitem_format,
@@ -669,7 +669,7 @@ struct xfs_item_ops xfs_qm_qoffend_logitem_ops = {
669/* 669/*
670 * This is the ops vector shared by all quotaoff-start log items. 670 * This is the ops vector shared by all quotaoff-start log items.
671 */ 671 */
672struct xfs_item_ops xfs_qm_qoff_logitem_ops = { 672STATIC struct xfs_item_ops xfs_qm_qoff_logitem_ops = {
673 .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size, 673 .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size,
674 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 674 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
675 xfs_qm_qoff_logitem_format, 675 xfs_qm_qoff_logitem_format,
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c
index 89f2cd656ebf..f665ca8f9e96 100644
--- a/fs/xfs/quota/xfs_qm.c
+++ b/fs/xfs/quota/xfs_qm.c
@@ -81,12 +81,18 @@ struct xfs_qm *xfs_Gqm;
81 81
82kmem_zone_t *qm_dqzone; 82kmem_zone_t *qm_dqzone;
83kmem_zone_t *qm_dqtrxzone; 83kmem_zone_t *qm_dqtrxzone;
84kmem_shaker_t xfs_qm_shaker; 84STATIC kmem_shaker_t xfs_qm_shaker;
85 85
86STATIC void xfs_qm_list_init(xfs_dqlist_t *, char *, int); 86STATIC void xfs_qm_list_init(xfs_dqlist_t *, char *, int);
87STATIC void xfs_qm_list_destroy(xfs_dqlist_t *); 87STATIC void xfs_qm_list_destroy(xfs_dqlist_t *);
88 88
89STATIC void xfs_qm_freelist_init(xfs_frlist_t *);
90STATIC void xfs_qm_freelist_destroy(xfs_frlist_t *);
91STATIC int xfs_qm_mplist_nowait(xfs_mount_t *);
92STATIC int xfs_qm_dqhashlock_nowait(xfs_dquot_t *);
93
89STATIC int xfs_qm_init_quotainos(xfs_mount_t *); 94STATIC int xfs_qm_init_quotainos(xfs_mount_t *);
95STATIC int xfs_qm_init_quotainfo(xfs_mount_t *);
90STATIC int xfs_qm_shake(int, unsigned int); 96STATIC int xfs_qm_shake(int, unsigned int);
91 97
92#ifdef DEBUG 98#ifdef DEBUG
@@ -184,7 +190,7 @@ xfs_Gqm_init(void)
184/* 190/*
185 * Destroy the global quota manager when its reference count goes to zero. 191 * Destroy the global quota manager when its reference count goes to zero.
186 */ 192 */
187void 193STATIC void
188xfs_qm_destroy( 194xfs_qm_destroy(
189 struct xfs_qm *xqm) 195 struct xfs_qm *xqm)
190{ 196{
@@ -304,9 +310,9 @@ xfs_qm_mount_quotainit(
304 uint flags) 310 uint flags)
305{ 311{
306 /* 312 /*
307 * User or group quotas has to be on. 313 * User, projects or group quotas has to be on.
308 */ 314 */
309 ASSERT(flags & (XFSMNT_UQUOTA | XFSMNT_GQUOTA)); 315 ASSERT(flags & (XFSMNT_UQUOTA | XFSMNT_PQUOTA | XFSMNT_GQUOTA));
310 316
311 /* 317 /*
312 * Initialize the flags in the mount structure. From this point 318 * Initialize the flags in the mount structure. From this point
@@ -324,7 +330,11 @@ xfs_qm_mount_quotainit(
324 if (flags & XFSMNT_GQUOTA) { 330 if (flags & XFSMNT_GQUOTA) {
325 mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE); 331 mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
326 if (flags & XFSMNT_GQUOTAENF) 332 if (flags & XFSMNT_GQUOTAENF)
327 mp->m_qflags |= XFS_GQUOTA_ENFD; 333 mp->m_qflags |= XFS_OQUOTA_ENFD;
334 } else if (flags & XFSMNT_PQUOTA) {
335 mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
336 if (flags & XFSMNT_PQUOTAENF)
337 mp->m_qflags |= XFS_OQUOTA_ENFD;
328 } 338 }
329} 339}
330 340
@@ -357,11 +367,11 @@ xfs_qm_mount_quotas(
357 367
358 /* 368 /*
359 * If a file system had quotas running earlier, but decided to 369 * If a file system had quotas running earlier, but decided to
360 * mount without -o quota/uquota/gquota options, revoke the 370 * mount without -o uquota/pquota/gquota options, revoke the
361 * quotachecked license, and bail out. 371 * quotachecked license, and bail out.
362 */ 372 */
363 if (! XFS_IS_QUOTA_ON(mp) && 373 if (! XFS_IS_QUOTA_ON(mp) &&
364 (mp->m_sb.sb_qflags & (XFS_UQUOTA_ACCT|XFS_GQUOTA_ACCT))) { 374 (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT)) {
365 mp->m_qflags = 0; 375 mp->m_qflags = 0;
366 goto write_changes; 376 goto write_changes;
367 } 377 }
@@ -509,7 +519,7 @@ out:
509 * Flush all dquots of the given file system to disk. The dquots are 519 * Flush all dquots of the given file system to disk. The dquots are
510 * _not_ purged from memory here, just their data written to disk. 520 * _not_ purged from memory here, just their data written to disk.
511 */ 521 */
512int 522STATIC int
513xfs_qm_dqflush_all( 523xfs_qm_dqflush_all(
514 xfs_mount_t *mp, 524 xfs_mount_t *mp,
515 int flags) 525 int flags)
@@ -613,7 +623,7 @@ xfs_qm_detach_gdquots(
613STATIC int 623STATIC int
614xfs_qm_dqpurge_int( 624xfs_qm_dqpurge_int(
615 xfs_mount_t *mp, 625 xfs_mount_t *mp,
616 uint flags) /* QUOTAOFF/UMOUNTING/UQUOTA/GQUOTA */ 626 uint flags) /* QUOTAOFF/UMOUNTING/UQUOTA/PQUOTA/GQUOTA */
617{ 627{
618 xfs_dquot_t *dqp; 628 xfs_dquot_t *dqp;
619 uint dqtype; 629 uint dqtype;
@@ -625,6 +635,7 @@ xfs_qm_dqpurge_int(
625 return (0); 635 return (0);
626 636
627 dqtype = (flags & XFS_QMOPT_UQUOTA) ? XFS_DQ_USER : 0; 637 dqtype = (flags & XFS_QMOPT_UQUOTA) ? XFS_DQ_USER : 0;
638 dqtype |= (flags & XFS_QMOPT_PQUOTA) ? XFS_DQ_PROJ : 0;
628 dqtype |= (flags & XFS_QMOPT_GQUOTA) ? XFS_DQ_GROUP : 0; 639 dqtype |= (flags & XFS_QMOPT_GQUOTA) ? XFS_DQ_GROUP : 0;
629 640
630 xfs_qm_mplist_lock(mp); 641 xfs_qm_mplist_lock(mp);
@@ -734,11 +745,11 @@ xfs_qm_dqattach_one(
734 745
735 /* 746 /*
736 * udqhint is the i_udquot field in inode, and is non-NULL only 747 * udqhint is the i_udquot field in inode, and is non-NULL only
737 * when the type arg is XFS_DQ_GROUP. Its purpose is to save a 748 * when the type arg is group/project. Its purpose is to save a
738 * lookup by dqid (xfs_qm_dqget) by caching a group dquot inside 749 * lookup by dqid (xfs_qm_dqget) by caching a group dquot inside
739 * the user dquot. 750 * the user dquot.
740 */ 751 */
741 ASSERT(!udqhint || type == XFS_DQ_GROUP); 752 ASSERT(!udqhint || type == XFS_DQ_GROUP || type == XFS_DQ_PROJ);
742 if (udqhint && !dolock) 753 if (udqhint && !dolock)
743 xfs_dqlock(udqhint); 754 xfs_dqlock(udqhint);
744 755
@@ -897,8 +908,8 @@ xfs_qm_dqattach_grouphint(
897 908
898 909
899/* 910/*
900 * Given a locked inode, attach dquot(s) to it, taking UQUOTAON / GQUOTAON 911 * Given a locked inode, attach dquot(s) to it, taking U/G/P-QUOTAON
901 * in to account. 912 * into account.
902 * If XFS_QMOPT_DQALLOC, the dquot(s) will be allocated if needed. 913 * If XFS_QMOPT_DQALLOC, the dquot(s) will be allocated if needed.
903 * If XFS_QMOPT_DQLOCK, the dquot(s) will be returned locked. This option pretty 914 * If XFS_QMOPT_DQLOCK, the dquot(s) will be returned locked. This option pretty
904 * much made this code a complete mess, but it has been pretty useful. 915 * much made this code a complete mess, but it has been pretty useful.
@@ -937,8 +948,13 @@ xfs_qm_dqattach(
937 nquotas++; 948 nquotas++;
938 } 949 }
939 ASSERT(XFS_ISLOCKED_INODE_EXCL(ip)); 950 ASSERT(XFS_ISLOCKED_INODE_EXCL(ip));
940 if (XFS_IS_GQUOTA_ON(mp)) { 951 if (XFS_IS_OQUOTA_ON(mp)) {
941 error = xfs_qm_dqattach_one(ip, ip->i_d.di_gid, XFS_DQ_GROUP, 952 error = XFS_IS_GQUOTA_ON(mp) ?
953 xfs_qm_dqattach_one(ip, ip->i_d.di_gid, XFS_DQ_GROUP,
954 flags & XFS_QMOPT_DQALLOC,
955 flags & XFS_QMOPT_DQLOCK,
956 ip->i_udquot, &ip->i_gdquot) :
957 xfs_qm_dqattach_one(ip, ip->i_d.di_projid, XFS_DQ_PROJ,
942 flags & XFS_QMOPT_DQALLOC, 958 flags & XFS_QMOPT_DQALLOC,
943 flags & XFS_QMOPT_DQLOCK, 959 flags & XFS_QMOPT_DQLOCK,
944 ip->i_udquot, &ip->i_gdquot); 960 ip->i_udquot, &ip->i_gdquot);
@@ -989,7 +1005,7 @@ xfs_qm_dqattach(
989 } 1005 }
990 if (XFS_IS_UQUOTA_ON(mp)) 1006 if (XFS_IS_UQUOTA_ON(mp))
991 ASSERT(ip->i_udquot); 1007 ASSERT(ip->i_udquot);
992 if (XFS_IS_GQUOTA_ON(mp)) 1008 if (XFS_IS_OQUOTA_ON(mp))
993 ASSERT(ip->i_gdquot); 1009 ASSERT(ip->i_gdquot);
994 } 1010 }
995#endif 1011#endif
@@ -1018,13 +1034,13 @@ xfs_qm_dqdetach(
1018 1034
1019 ASSERT(ip->i_ino != ip->i_mount->m_sb.sb_uquotino); 1035 ASSERT(ip->i_ino != ip->i_mount->m_sb.sb_uquotino);
1020 ASSERT(ip->i_ino != ip->i_mount->m_sb.sb_gquotino); 1036 ASSERT(ip->i_ino != ip->i_mount->m_sb.sb_gquotino);
1021 if (ip->i_udquot)
1022 xfs_dqtrace_entry_ino(ip->i_udquot, "DQDETTACH", ip);
1023 if (ip->i_udquot) { 1037 if (ip->i_udquot) {
1038 xfs_dqtrace_entry_ino(ip->i_udquot, "DQDETTACH", ip);
1024 xfs_qm_dqrele(ip->i_udquot); 1039 xfs_qm_dqrele(ip->i_udquot);
1025 ip->i_udquot = NULL; 1040 ip->i_udquot = NULL;
1026 } 1041 }
1027 if (ip->i_gdquot) { 1042 if (ip->i_gdquot) {
1043 xfs_dqtrace_entry_ino(ip->i_gdquot, "DQDETTACH", ip);
1028 xfs_qm_dqrele(ip->i_gdquot); 1044 xfs_qm_dqrele(ip->i_gdquot);
1029 ip->i_gdquot = NULL; 1045 ip->i_gdquot = NULL;
1030 } 1046 }
@@ -1149,7 +1165,7 @@ xfs_qm_sync(
1149 * This initializes all the quota information that's kept in the 1165 * This initializes all the quota information that's kept in the
1150 * mount structure 1166 * mount structure
1151 */ 1167 */
1152int 1168STATIC int
1153xfs_qm_init_quotainfo( 1169xfs_qm_init_quotainfo(
1154 xfs_mount_t *mp) 1170 xfs_mount_t *mp)
1155{ 1171{
@@ -1202,8 +1218,9 @@ xfs_qm_init_quotainfo(
1202 * and group quotas, at least not at this point. 1218 * and group quotas, at least not at this point.
1203 */ 1219 */
1204 error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)0, 1220 error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)0,
1205 (XFS_IS_UQUOTA_RUNNING(mp)) ? 1221 XFS_IS_UQUOTA_RUNNING(mp) ? XFS_DQ_USER :
1206 XFS_DQ_USER : XFS_DQ_GROUP, 1222 (XFS_IS_GQUOTA_RUNNING(mp) ? XFS_DQ_GROUP :
1223 XFS_DQ_PROJ),
1207 XFS_QMOPT_DQSUSER|XFS_QMOPT_DOWARN, 1224 XFS_QMOPT_DQSUSER|XFS_QMOPT_DOWARN,
1208 &dqp); 1225 &dqp);
1209 if (! error) { 1226 if (! error) {
@@ -1234,6 +1251,10 @@ xfs_qm_init_quotainfo(
1234 INT_GET(ddqp->d_iwarns, ARCH_CONVERT) ? 1251 INT_GET(ddqp->d_iwarns, ARCH_CONVERT) ?
1235 INT_GET(ddqp->d_iwarns, ARCH_CONVERT) : 1252 INT_GET(ddqp->d_iwarns, ARCH_CONVERT) :
1236 XFS_QM_IWARNLIMIT; 1253 XFS_QM_IWARNLIMIT;
1254 qinf->qi_rtbwarnlimit =
1255 INT_GET(ddqp->d_rtbwarns, ARCH_CONVERT) ?
1256 INT_GET(ddqp->d_rtbwarns, ARCH_CONVERT) :
1257 XFS_QM_RTBWARNLIMIT;
1237 qinf->qi_bhardlimit = 1258 qinf->qi_bhardlimit =
1238 INT_GET(ddqp->d_blk_hardlimit, ARCH_CONVERT); 1259 INT_GET(ddqp->d_blk_hardlimit, ARCH_CONVERT);
1239 qinf->qi_bsoftlimit = 1260 qinf->qi_bsoftlimit =
@@ -1259,6 +1280,7 @@ xfs_qm_init_quotainfo(
1259 qinf->qi_rtbtimelimit = XFS_QM_RTBTIMELIMIT; 1280 qinf->qi_rtbtimelimit = XFS_QM_RTBTIMELIMIT;
1260 qinf->qi_bwarnlimit = XFS_QM_BWARNLIMIT; 1281 qinf->qi_bwarnlimit = XFS_QM_BWARNLIMIT;
1261 qinf->qi_iwarnlimit = XFS_QM_IWARNLIMIT; 1282 qinf->qi_iwarnlimit = XFS_QM_IWARNLIMIT;
1283 qinf->qi_rtbwarnlimit = XFS_QM_RTBWARNLIMIT;
1262 } 1284 }
1263 1285
1264 return (0); 1286 return (0);
@@ -1366,13 +1388,20 @@ xfs_qm_dqget_noattach(
1366 ASSERT(udqp); 1388 ASSERT(udqp);
1367 } 1389 }
1368 1390
1369 if (XFS_IS_GQUOTA_ON(mp)) { 1391 if (XFS_IS_OQUOTA_ON(mp)) {
1370 ASSERT(ip->i_gdquot == NULL); 1392 ASSERT(ip->i_gdquot == NULL);
1371 if (udqp) 1393 if (udqp)
1372 xfs_dqunlock(udqp); 1394 xfs_dqunlock(udqp);
1373 if ((error = xfs_qm_dqget(mp, ip, ip->i_d.di_gid, XFS_DQ_GROUP, 1395 error = XFS_IS_GQUOTA_ON(mp) ?
1374 XFS_QMOPT_DQALLOC|XFS_QMOPT_DOWARN, 1396 xfs_qm_dqget(mp, ip,
1375 &gdqp))) { 1397 ip->i_d.di_gid, XFS_DQ_GROUP,
1398 XFS_QMOPT_DQALLOC|XFS_QMOPT_DOWARN,
1399 &gdqp) :
1400 xfs_qm_dqget(mp, ip,
1401 ip->i_d.di_projid, XFS_DQ_PROJ,
1402 XFS_QMOPT_DQALLOC|XFS_QMOPT_DOWARN,
1403 &gdqp);
1404 if (error) {
1376 if (udqp) 1405 if (udqp)
1377 xfs_qm_dqrele(udqp); 1406 xfs_qm_dqrele(udqp);
1378 ASSERT(error != ESRCH); 1407 ASSERT(error != ESRCH);
@@ -1521,8 +1550,10 @@ xfs_qm_reset_dqcounts(
1521 INT_SET(ddq->d_rtbcount, ARCH_CONVERT, 0ULL); 1550 INT_SET(ddq->d_rtbcount, ARCH_CONVERT, 0ULL);
1522 INT_SET(ddq->d_btimer, ARCH_CONVERT, (time_t)0); 1551 INT_SET(ddq->d_btimer, ARCH_CONVERT, (time_t)0);
1523 INT_SET(ddq->d_itimer, ARCH_CONVERT, (time_t)0); 1552 INT_SET(ddq->d_itimer, ARCH_CONVERT, (time_t)0);
1553 INT_SET(ddq->d_rtbtimer, ARCH_CONVERT, (time_t)0);
1524 INT_SET(ddq->d_bwarns, ARCH_CONVERT, 0UL); 1554 INT_SET(ddq->d_bwarns, ARCH_CONVERT, 0UL);
1525 INT_SET(ddq->d_iwarns, ARCH_CONVERT, 0UL); 1555 INT_SET(ddq->d_iwarns, ARCH_CONVERT, 0UL);
1556 INT_SET(ddq->d_rtbwarns, ARCH_CONVERT, 0UL);
1526 ddq = (xfs_disk_dquot_t *) ((xfs_dqblk_t *)ddq + 1); 1557 ddq = (xfs_disk_dquot_t *) ((xfs_dqblk_t *)ddq + 1);
1527 } 1558 }
1528 1559
@@ -1541,11 +1572,14 @@ xfs_qm_dqiter_bufs(
1541 int error; 1572 int error;
1542 int notcommitted; 1573 int notcommitted;
1543 int incr; 1574 int incr;
1575 int type;
1544 1576
1545 ASSERT(blkcnt > 0); 1577 ASSERT(blkcnt > 0);
1546 notcommitted = 0; 1578 notcommitted = 0;
1547 incr = (blkcnt > XFS_QM_MAX_DQCLUSTER_LOGSZ) ? 1579 incr = (blkcnt > XFS_QM_MAX_DQCLUSTER_LOGSZ) ?
1548 XFS_QM_MAX_DQCLUSTER_LOGSZ : blkcnt; 1580 XFS_QM_MAX_DQCLUSTER_LOGSZ : blkcnt;
1581 type = flags & XFS_QMOPT_UQUOTA ? XFS_DQ_USER :
1582 (flags & XFS_QMOPT_PQUOTA ? XFS_DQ_PROJ : XFS_DQ_GROUP);
1549 error = 0; 1583 error = 0;
1550 1584
1551 /* 1585 /*
@@ -1564,9 +1598,7 @@ xfs_qm_dqiter_bufs(
1564 if (error) 1598 if (error)
1565 break; 1599 break;
1566 1600
1567 (void) xfs_qm_reset_dqcounts(mp, bp, firstid, 1601 (void) xfs_qm_reset_dqcounts(mp, bp, firstid, type);
1568 flags & XFS_QMOPT_UQUOTA ?
1569 XFS_DQ_USER : XFS_DQ_GROUP);
1570 xfs_bdwrite(mp, bp); 1602 xfs_bdwrite(mp, bp);
1571 /* 1603 /*
1572 * goto the next block. 1604 * goto the next block.
@@ -1578,7 +1610,7 @@ xfs_qm_dqiter_bufs(
1578} 1610}
1579 1611
1580/* 1612/*
1581 * Iterate over all allocated USR/GRP dquots in the system, calling a 1613 * Iterate over all allocated USR/GRP/PRJ dquots in the system, calling a
1582 * caller supplied function for every chunk of dquots that we find. 1614 * caller supplied function for every chunk of dquots that we find.
1583 */ 1615 */
1584STATIC int 1616STATIC int
@@ -1849,7 +1881,7 @@ xfs_qm_dqusage_adjust(
1849 xfs_qm_quotacheck_dqadjust(udqp, nblks, rtblks); 1881 xfs_qm_quotacheck_dqadjust(udqp, nblks, rtblks);
1850 xfs_qm_dqput(udqp); 1882 xfs_qm_dqput(udqp);
1851 } 1883 }
1852 if (XFS_IS_GQUOTA_ON(mp)) { 1884 if (XFS_IS_OQUOTA_ON(mp)) {
1853 ASSERT(gdqp); 1885 ASSERT(gdqp);
1854 xfs_qm_quotacheck_dqadjust(gdqp, nblks, rtblks); 1886 xfs_qm_quotacheck_dqadjust(gdqp, nblks, rtblks);
1855 xfs_qm_dqput(gdqp); 1887 xfs_qm_dqput(gdqp);
@@ -1898,7 +1930,7 @@ xfs_qm_quotacheck(
1898 cmn_err(CE_NOTE, "XFS quotacheck %s: Please wait.", mp->m_fsname); 1930 cmn_err(CE_NOTE, "XFS quotacheck %s: Please wait.", mp->m_fsname);
1899 1931
1900 /* 1932 /*
1901 * First we go thru all the dquots on disk, USR and GRP, and reset 1933 * First we go thru all the dquots on disk, USR and GRP/PRJ, and reset
1902 * their counters to zero. We need a clean slate. 1934 * their counters to zero. We need a clean slate.
1903 * We don't log our changes till later. 1935 * We don't log our changes till later.
1904 */ 1936 */
@@ -1909,9 +1941,10 @@ xfs_qm_quotacheck(
1909 } 1941 }
1910 1942
1911 if ((gip = XFS_QI_GQIP(mp))) { 1943 if ((gip = XFS_QI_GQIP(mp))) {
1912 if ((error = xfs_qm_dqiterate(mp, gip, XFS_QMOPT_GQUOTA))) 1944 if ((error = xfs_qm_dqiterate(mp, gip, XFS_IS_GQUOTA_ON(mp) ?
1945 XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA)))
1913 goto error_return; 1946 goto error_return;
1914 flags |= XFS_GQUOTA_CHKD; 1947 flags |= XFS_OQUOTA_CHKD;
1915 } 1948 }
1916 1949
1917 do { 1950 do {
@@ -1938,7 +1971,7 @@ xfs_qm_quotacheck(
1938 if (error) { 1971 if (error) {
1939 xfs_qm_dqpurge_all(mp, 1972 xfs_qm_dqpurge_all(mp,
1940 XFS_QMOPT_UQUOTA|XFS_QMOPT_GQUOTA| 1973 XFS_QMOPT_UQUOTA|XFS_QMOPT_GQUOTA|
1941 XFS_QMOPT_QUOTAOFF); 1974 XFS_QMOPT_PQUOTA|XFS_QMOPT_QUOTAOFF);
1942 goto error_return; 1975 goto error_return;
1943 } 1976 }
1944 /* 1977 /*
@@ -1961,7 +1994,7 @@ xfs_qm_quotacheck(
1961 * quotachecked status, since we won't be doing accounting for 1994 * quotachecked status, since we won't be doing accounting for
1962 * that type anymore. 1995 * that type anymore.
1963 */ 1996 */
1964 mp->m_qflags &= ~(XFS_GQUOTA_CHKD | XFS_UQUOTA_CHKD); 1997 mp->m_qflags &= ~(XFS_OQUOTA_CHKD | XFS_UQUOTA_CHKD);
1965 mp->m_qflags |= flags; 1998 mp->m_qflags |= flags;
1966 1999
1967 XQM_LIST_PRINT(&(XFS_QI_MPL_LIST(mp)), MPL_NEXT, "++++ Mp list +++"); 2000 XQM_LIST_PRINT(&(XFS_QI_MPL_LIST(mp)), MPL_NEXT, "++++ Mp list +++");
@@ -2013,7 +2046,7 @@ xfs_qm_init_quotainos(
2013 0, 0, &uip, 0))) 2046 0, 0, &uip, 0)))
2014 return XFS_ERROR(error); 2047 return XFS_ERROR(error);
2015 } 2048 }
2016 if (XFS_IS_GQUOTA_ON(mp) && 2049 if (XFS_IS_OQUOTA_ON(mp) &&
2017 mp->m_sb.sb_gquotino != NULLFSINO) { 2050 mp->m_sb.sb_gquotino != NULLFSINO) {
2018 ASSERT(mp->m_sb.sb_gquotino > 0); 2051 ASSERT(mp->m_sb.sb_gquotino > 0);
2019 if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, 2052 if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino,
@@ -2043,10 +2076,12 @@ xfs_qm_init_quotainos(
2043 2076
2044 flags &= ~XFS_QMOPT_SBVERSION; 2077 flags &= ~XFS_QMOPT_SBVERSION;
2045 } 2078 }
2046 if (XFS_IS_GQUOTA_ON(mp) && gip == NULL) { 2079 if (XFS_IS_OQUOTA_ON(mp) && gip == NULL) {
2047 if ((error = xfs_qm_qino_alloc(mp, &gip, 2080 flags |= (XFS_IS_GQUOTA_ON(mp) ?
2048 sbflags | XFS_SB_GQUOTINO, 2081 XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA);
2049 flags | XFS_QMOPT_GQUOTA))) { 2082 error = xfs_qm_qino_alloc(mp, &gip,
2083 sbflags | XFS_SB_GQUOTINO, flags);
2084 if (error) {
2050 if (uip) 2085 if (uip)
2051 VN_RELE(XFS_ITOV(uip)); 2086 VN_RELE(XFS_ITOV(uip));
2052 2087
@@ -2452,6 +2487,7 @@ xfs_qm_vop_dqalloc(
2452 xfs_inode_t *ip, 2487 xfs_inode_t *ip,
2453 uid_t uid, 2488 uid_t uid,
2454 gid_t gid, 2489 gid_t gid,
2490 prid_t prid,
2455 uint flags, 2491 uint flags,
2456 xfs_dquot_t **O_udqpp, 2492 xfs_dquot_t **O_udqpp,
2457 xfs_dquot_t **O_gdqpp) 2493 xfs_dquot_t **O_gdqpp)
@@ -2483,8 +2519,7 @@ xfs_qm_vop_dqalloc(
2483 } 2519 }
2484 2520
2485 uq = gq = NULL; 2521 uq = gq = NULL;
2486 if ((flags & XFS_QMOPT_UQUOTA) && 2522 if ((flags & XFS_QMOPT_UQUOTA) && XFS_IS_UQUOTA_ON(mp)) {
2487 XFS_IS_UQUOTA_ON(mp)) {
2488 if (ip->i_d.di_uid != uid) { 2523 if (ip->i_d.di_uid != uid) {
2489 /* 2524 /*
2490 * What we need is the dquot that has this uid, and 2525 * What we need is the dquot that has this uid, and
@@ -2522,8 +2557,7 @@ xfs_qm_vop_dqalloc(
2522 xfs_dqunlock(uq); 2557 xfs_dqunlock(uq);
2523 } 2558 }
2524 } 2559 }
2525 if ((flags & XFS_QMOPT_GQUOTA) && 2560 if ((flags & XFS_QMOPT_GQUOTA) && XFS_IS_GQUOTA_ON(mp)) {
2526 XFS_IS_GQUOTA_ON(mp)) {
2527 if (ip->i_d.di_gid != gid) { 2561 if (ip->i_d.di_gid != gid) {
2528 xfs_iunlock(ip, lockflags); 2562 xfs_iunlock(ip, lockflags);
2529 if ((error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)gid, 2563 if ((error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)gid,
@@ -2546,6 +2580,29 @@ xfs_qm_vop_dqalloc(
2546 XFS_DQHOLD(gq); 2580 XFS_DQHOLD(gq);
2547 xfs_dqunlock(gq); 2581 xfs_dqunlock(gq);
2548 } 2582 }
2583 } else if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) {
2584 if (ip->i_d.di_projid != prid) {
2585 xfs_iunlock(ip, lockflags);
2586 if ((error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)prid,
2587 XFS_DQ_PROJ,
2588 XFS_QMOPT_DQALLOC |
2589 XFS_QMOPT_DOWARN,
2590 &gq))) {
2591 if (uq)
2592 xfs_qm_dqrele(uq);
2593 ASSERT(error != ENOENT);
2594 return (error);
2595 }
2596 xfs_dqunlock(gq);
2597 lockflags = XFS_ILOCK_SHARED;
2598 xfs_ilock(ip, lockflags);
2599 } else {
2600 ASSERT(ip->i_gdquot);
2601 gq = ip->i_gdquot;
2602 xfs_dqlock(gq);
2603 XFS_DQHOLD(gq);
2604 xfs_dqunlock(gq);
2605 }
2549 } 2606 }
2550 if (uq) 2607 if (uq)
2551 xfs_dqtrace_entry_ino(uq, "DQALLOC", ip); 2608 xfs_dqtrace_entry_ino(uq, "DQALLOC", ip);
@@ -2574,6 +2631,9 @@ xfs_qm_vop_chown(
2574 xfs_dquot_t *newdq) 2631 xfs_dquot_t *newdq)
2575{ 2632{
2576 xfs_dquot_t *prevdq; 2633 xfs_dquot_t *prevdq;
2634 uint bfield = XFS_IS_REALTIME_INODE(ip) ?
2635 XFS_TRANS_DQ_RTBCOUNT : XFS_TRANS_DQ_BCOUNT;
2636
2577 ASSERT(XFS_ISLOCKED_INODE_EXCL(ip)); 2637 ASSERT(XFS_ISLOCKED_INODE_EXCL(ip));
2578 ASSERT(XFS_IS_QUOTA_RUNNING(ip->i_mount)); 2638 ASSERT(XFS_IS_QUOTA_RUNNING(ip->i_mount));
2579 2639
@@ -2582,20 +2642,12 @@ xfs_qm_vop_chown(
2582 ASSERT(prevdq); 2642 ASSERT(prevdq);
2583 ASSERT(prevdq != newdq); 2643 ASSERT(prevdq != newdq);
2584 2644
2585 xfs_trans_mod_dquot(tp, prevdq, 2645 xfs_trans_mod_dquot(tp, prevdq, bfield, -(ip->i_d.di_nblocks));
2586 XFS_TRANS_DQ_BCOUNT, 2646 xfs_trans_mod_dquot(tp, prevdq, XFS_TRANS_DQ_ICOUNT, -1);
2587 -(ip->i_d.di_nblocks));
2588 xfs_trans_mod_dquot(tp, prevdq,
2589 XFS_TRANS_DQ_ICOUNT,
2590 -1);
2591 2647
2592 /* the sparkling new dquot */ 2648 /* the sparkling new dquot */
2593 xfs_trans_mod_dquot(tp, newdq, 2649 xfs_trans_mod_dquot(tp, newdq, bfield, ip->i_d.di_nblocks);
2594 XFS_TRANS_DQ_BCOUNT, 2650 xfs_trans_mod_dquot(tp, newdq, XFS_TRANS_DQ_ICOUNT, 1);
2595 ip->i_d.di_nblocks);
2596 xfs_trans_mod_dquot(tp, newdq,
2597 XFS_TRANS_DQ_ICOUNT,
2598 1);
2599 2651
2600 /* 2652 /*
2601 * Take an extra reference, because the inode 2653 * Take an extra reference, because the inode
@@ -2611,7 +2663,7 @@ xfs_qm_vop_chown(
2611} 2663}
2612 2664
2613/* 2665/*
2614 * Quota reservations for setattr(AT_UID|AT_GID). 2666 * Quota reservations for setattr(AT_UID|AT_GID|AT_PROJID).
2615 */ 2667 */
2616int 2668int
2617xfs_qm_vop_chown_reserve( 2669xfs_qm_vop_chown_reserve(
@@ -2623,7 +2675,7 @@ xfs_qm_vop_chown_reserve(
2623{ 2675{
2624 int error; 2676 int error;
2625 xfs_mount_t *mp; 2677 xfs_mount_t *mp;
2626 uint delblks; 2678 uint delblks, blkflags;
2627 xfs_dquot_t *unresudq, *unresgdq, *delblksudq, *delblksgdq; 2679 xfs_dquot_t *unresudq, *unresgdq, *delblksudq, *delblksgdq;
2628 2680
2629 ASSERT(XFS_ISLOCKED_INODE(ip)); 2681 ASSERT(XFS_ISLOCKED_INODE(ip));
@@ -2632,6 +2684,8 @@ xfs_qm_vop_chown_reserve(
2632 2684
2633 delblks = ip->i_delayed_blks; 2685 delblks = ip->i_delayed_blks;
2634 delblksudq = delblksgdq = unresudq = unresgdq = NULL; 2686 delblksudq = delblksgdq = unresudq = unresgdq = NULL;
2687 blkflags = XFS_IS_REALTIME_INODE(ip) ?
2688 XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS;
2635 2689
2636 if (XFS_IS_UQUOTA_ON(mp) && udqp && 2690 if (XFS_IS_UQUOTA_ON(mp) && udqp &&
2637 ip->i_d.di_uid != (uid_t)INT_GET(udqp->q_core.d_id, ARCH_CONVERT)) { 2691 ip->i_d.di_uid != (uid_t)INT_GET(udqp->q_core.d_id, ARCH_CONVERT)) {
@@ -2646,18 +2700,22 @@ xfs_qm_vop_chown_reserve(
2646 unresudq = ip->i_udquot; 2700 unresudq = ip->i_udquot;
2647 } 2701 }
2648 } 2702 }
2649 if (XFS_IS_GQUOTA_ON(ip->i_mount) && gdqp && 2703 if (XFS_IS_OQUOTA_ON(ip->i_mount) && gdqp) {
2650 ip->i_d.di_gid != INT_GET(gdqp->q_core.d_id, ARCH_CONVERT)) { 2704 if ((XFS_IS_GQUOTA_ON(ip->i_mount) && ip->i_d.di_gid !=
2651 delblksgdq = gdqp; 2705 INT_GET(gdqp->q_core.d_id, ARCH_CONVERT)) ||
2652 if (delblks) { 2706 (XFS_IS_PQUOTA_ON(ip->i_mount) && ip->i_d.di_projid !=
2653 ASSERT(ip->i_gdquot); 2707 INT_GET(gdqp->q_core.d_id, ARCH_CONVERT))) {
2654 unresgdq = ip->i_gdquot; 2708 delblksgdq = gdqp;
2709 if (delblks) {
2710 ASSERT(ip->i_gdquot);
2711 unresgdq = ip->i_gdquot;
2712 }
2655 } 2713 }
2656 } 2714 }
2657 2715
2658 if ((error = xfs_trans_reserve_quota_bydquots(tp, ip->i_mount, 2716 if ((error = xfs_trans_reserve_quota_bydquots(tp, ip->i_mount,
2659 delblksudq, delblksgdq, ip->i_d.di_nblocks, 1, 2717 delblksudq, delblksgdq, ip->i_d.di_nblocks, 1,
2660 flags | XFS_QMOPT_RES_REGBLKS))) 2718 flags | blkflags)))
2661 return (error); 2719 return (error);
2662 2720
2663 /* 2721 /*
@@ -2674,11 +2732,11 @@ xfs_qm_vop_chown_reserve(
2674 ASSERT(unresudq || unresgdq); 2732 ASSERT(unresudq || unresgdq);
2675 if ((error = xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount, 2733 if ((error = xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount,
2676 delblksudq, delblksgdq, (xfs_qcnt_t)delblks, 0, 2734 delblksudq, delblksgdq, (xfs_qcnt_t)delblks, 0,
2677 flags | XFS_QMOPT_RES_REGBLKS))) 2735 flags | blkflags)))
2678 return (error); 2736 return (error);
2679 xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount, 2737 xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount,
2680 unresudq, unresgdq, -((xfs_qcnt_t)delblks), 0, 2738 unresudq, unresgdq, -((xfs_qcnt_t)delblks), 0,
2681 XFS_QMOPT_RES_REGBLKS); 2739 blkflags);
2682 } 2740 }
2683 2741
2684 return (0); 2742 return (0);
@@ -2751,7 +2809,7 @@ xfs_qm_vop_dqattach_and_dqmod_newinode(
2751} 2809}
2752 2810
2753/* ------------- list stuff -----------------*/ 2811/* ------------- list stuff -----------------*/
2754void 2812STATIC void
2755xfs_qm_freelist_init(xfs_frlist_t *ql) 2813xfs_qm_freelist_init(xfs_frlist_t *ql)
2756{ 2814{
2757 ql->qh_next = ql->qh_prev = (xfs_dquot_t *) ql; 2815 ql->qh_next = ql->qh_prev = (xfs_dquot_t *) ql;
@@ -2760,7 +2818,7 @@ xfs_qm_freelist_init(xfs_frlist_t *ql)
2760 ql->qh_nelems = 0; 2818 ql->qh_nelems = 0;
2761} 2819}
2762 2820
2763void 2821STATIC void
2764xfs_qm_freelist_destroy(xfs_frlist_t *ql) 2822xfs_qm_freelist_destroy(xfs_frlist_t *ql)
2765{ 2823{
2766 xfs_dquot_t *dqp, *nextdqp; 2824 xfs_dquot_t *dqp, *nextdqp;
@@ -2786,7 +2844,7 @@ xfs_qm_freelist_destroy(xfs_frlist_t *ql)
2786 ASSERT(ql->qh_nelems == 0); 2844 ASSERT(ql->qh_nelems == 0);
2787} 2845}
2788 2846
2789void 2847STATIC void
2790xfs_qm_freelist_insert(xfs_frlist_t *ql, xfs_dquot_t *dq) 2848xfs_qm_freelist_insert(xfs_frlist_t *ql, xfs_dquot_t *dq)
2791{ 2849{
2792 dq->dq_flnext = ql->qh_next; 2850 dq->dq_flnext = ql->qh_next;
@@ -2816,7 +2874,7 @@ xfs_qm_freelist_append(xfs_frlist_t *ql, xfs_dquot_t *dq)
2816 xfs_qm_freelist_insert((xfs_frlist_t *)ql->qh_prev, dq); 2874 xfs_qm_freelist_insert((xfs_frlist_t *)ql->qh_prev, dq);
2817} 2875}
2818 2876
2819int 2877STATIC int
2820xfs_qm_dqhashlock_nowait( 2878xfs_qm_dqhashlock_nowait(
2821 xfs_dquot_t *dqp) 2879 xfs_dquot_t *dqp)
2822{ 2880{
@@ -2836,7 +2894,7 @@ xfs_qm_freelist_lock_nowait(
2836 return (locked); 2894 return (locked);
2837} 2895}
2838 2896
2839int 2897STATIC int
2840xfs_qm_mplist_nowait( 2898xfs_qm_mplist_nowait(
2841 xfs_mount_t *mp) 2899 xfs_mount_t *mp)
2842{ 2900{
diff --git a/fs/xfs/quota/xfs_qm.h b/fs/xfs/quota/xfs_qm.h
index dcf1a7a831d8..b03eecf3b6cb 100644
--- a/fs/xfs/quota/xfs_qm.h
+++ b/fs/xfs/quota/xfs_qm.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as 5 * under the terms of version 2 of the GNU General Public License as
@@ -133,8 +133,9 @@ typedef struct xfs_quotainfo {
133 time_t qi_btimelimit; /* limit for blks timer */ 133 time_t qi_btimelimit; /* limit for blks timer */
134 time_t qi_itimelimit; /* limit for inodes timer */ 134 time_t qi_itimelimit; /* limit for inodes timer */
135 time_t qi_rtbtimelimit;/* limit for rt blks timer */ 135 time_t qi_rtbtimelimit;/* limit for rt blks timer */
136 xfs_qwarncnt_t qi_bwarnlimit; /* limit for num warnings */ 136 xfs_qwarncnt_t qi_bwarnlimit; /* limit for blks warnings */
137 xfs_qwarncnt_t qi_iwarnlimit; /* limit for num warnings */ 137 xfs_qwarncnt_t qi_iwarnlimit; /* limit for inodes warnings */
138 xfs_qwarncnt_t qi_rtbwarnlimit;/* limit for rt blks warnings */
138 mutex_t qi_quotaofflock;/* to serialize quotaoff */ 139 mutex_t qi_quotaofflock;/* to serialize quotaoff */
139 xfs_filblks_t qi_dqchunklen; /* # BBs in a chunk of dqs */ 140 xfs_filblks_t qi_dqchunklen; /* # BBs in a chunk of dqs */
140 uint qi_dqperchunk; /* # ondisk dqs in above chunk */ 141 uint qi_dqperchunk; /* # ondisk dqs in above chunk */
@@ -176,6 +177,7 @@ typedef struct xfs_dquot_acct {
176 177
177#define XFS_QM_BWARNLIMIT 5 178#define XFS_QM_BWARNLIMIT 5
178#define XFS_QM_IWARNLIMIT 5 179#define XFS_QM_IWARNLIMIT 5
180#define XFS_QM_RTBWARNLIMIT 5
179 181
180#define XFS_QM_LOCK(xqm) (mutex_lock(&xqm##_lock, PINOD)) 182#define XFS_QM_LOCK(xqm) (mutex_lock(&xqm##_lock, PINOD))
181#define XFS_QM_UNLOCK(xqm) (mutex_unlock(&xqm##_lock)) 183#define XFS_QM_UNLOCK(xqm) (mutex_unlock(&xqm##_lock))
@@ -184,7 +186,6 @@ typedef struct xfs_dquot_acct {
184 186
185extern void xfs_mount_reset_sbqflags(xfs_mount_t *); 187extern void xfs_mount_reset_sbqflags(xfs_mount_t *);
186 188
187extern int xfs_qm_init_quotainfo(xfs_mount_t *);
188extern void xfs_qm_destroy_quotainfo(xfs_mount_t *); 189extern void xfs_qm_destroy_quotainfo(xfs_mount_t *);
189extern int xfs_qm_mount_quotas(xfs_mount_t *, int); 190extern int xfs_qm_mount_quotas(xfs_mount_t *, int);
190extern void xfs_qm_mount_quotainit(xfs_mount_t *, uint); 191extern void xfs_qm_mount_quotainit(xfs_mount_t *, uint);
@@ -203,7 +204,7 @@ extern void xfs_qm_dqrele_all_inodes(xfs_mount_t *, uint);
203 204
204/* vop stuff */ 205/* vop stuff */
205extern int xfs_qm_vop_dqalloc(xfs_mount_t *, xfs_inode_t *, 206extern int xfs_qm_vop_dqalloc(xfs_mount_t *, xfs_inode_t *,
206 uid_t, gid_t, uint, 207 uid_t, gid_t, prid_t, uint,
207 xfs_dquot_t **, xfs_dquot_t **); 208 xfs_dquot_t **, xfs_dquot_t **);
208extern void xfs_qm_vop_dqattach_and_dqmod_newinode( 209extern void xfs_qm_vop_dqattach_and_dqmod_newinode(
209 xfs_trans_t *, xfs_inode_t *, 210 xfs_trans_t *, xfs_inode_t *,
@@ -215,14 +216,9 @@ extern int xfs_qm_vop_chown_reserve(xfs_trans_t *, xfs_inode_t *,
215 xfs_dquot_t *, xfs_dquot_t *, uint); 216 xfs_dquot_t *, xfs_dquot_t *, uint);
216 217
217/* list stuff */ 218/* list stuff */
218extern void xfs_qm_freelist_init(xfs_frlist_t *);
219extern void xfs_qm_freelist_destroy(xfs_frlist_t *);
220extern void xfs_qm_freelist_insert(xfs_frlist_t *, xfs_dquot_t *);
221extern void xfs_qm_freelist_append(xfs_frlist_t *, xfs_dquot_t *); 219extern void xfs_qm_freelist_append(xfs_frlist_t *, xfs_dquot_t *);
222extern void xfs_qm_freelist_unlink(xfs_dquot_t *); 220extern void xfs_qm_freelist_unlink(xfs_dquot_t *);
223extern int xfs_qm_freelist_lock_nowait(xfs_qm_t *); 221extern int xfs_qm_freelist_lock_nowait(xfs_qm_t *);
224extern int xfs_qm_mplist_nowait(xfs_mount_t *);
225extern int xfs_qm_dqhashlock_nowait(xfs_dquot_t *);
226 222
227/* system call interface */ 223/* system call interface */
228extern int xfs_qm_quotactl(bhv_desc_t *, int, int, xfs_caddr_t); 224extern int xfs_qm_quotactl(bhv_desc_t *, int, int, xfs_caddr_t);
diff --git a/fs/xfs/quota/xfs_qm_bhv.c b/fs/xfs/quota/xfs_qm_bhv.c
index be67d9c265f8..dc3c37a1e158 100644
--- a/fs/xfs/quota/xfs_qm_bhv.c
+++ b/fs/xfs/quota/xfs_qm_bhv.c
@@ -71,10 +71,13 @@
71#define MNTOPT_NOQUOTA "noquota" /* no quotas */ 71#define MNTOPT_NOQUOTA "noquota" /* no quotas */
72#define MNTOPT_USRQUOTA "usrquota" /* user quota enabled */ 72#define MNTOPT_USRQUOTA "usrquota" /* user quota enabled */
73#define MNTOPT_GRPQUOTA "grpquota" /* group quota enabled */ 73#define MNTOPT_GRPQUOTA "grpquota" /* group quota enabled */
74#define MNTOPT_PRJQUOTA "prjquota" /* project quota enabled */
74#define MNTOPT_UQUOTA "uquota" /* user quota (IRIX variant) */ 75#define MNTOPT_UQUOTA "uquota" /* user quota (IRIX variant) */
75#define MNTOPT_GQUOTA "gquota" /* group quota (IRIX variant) */ 76#define MNTOPT_GQUOTA "gquota" /* group quota (IRIX variant) */
77#define MNTOPT_PQUOTA "pquota" /* project quota (IRIX variant) */
76#define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */ 78#define MNTOPT_UQUOTANOENF "uqnoenforce"/* user quota limit enforcement */
77#define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */ 79#define MNTOPT_GQUOTANOENF "gqnoenforce"/* group quota limit enforcement */
80#define MNTOPT_PQUOTANOENF "pqnoenforce"/* project quota limit enforcement */
78#define MNTOPT_QUOTANOENF "qnoenforce" /* same as uqnoenforce */ 81#define MNTOPT_QUOTANOENF "qnoenforce" /* same as uqnoenforce */
79 82
80STATIC int 83STATIC int
@@ -109,6 +112,14 @@ xfs_qm_parseargs(
109 args->flags |= XFSMNT_UQUOTA; 112 args->flags |= XFSMNT_UQUOTA;
110 args->flags &= ~XFSMNT_UQUOTAENF; 113 args->flags &= ~XFSMNT_UQUOTAENF;
111 referenced = 1; 114 referenced = 1;
115 } else if (!strcmp(this_char, MNTOPT_PQUOTA) ||
116 !strcmp(this_char, MNTOPT_PRJQUOTA)) {
117 args->flags |= XFSMNT_PQUOTA | XFSMNT_PQUOTAENF;
118 referenced = 1;
119 } else if (!strcmp(this_char, MNTOPT_PQUOTANOENF)) {
120 args->flags |= XFSMNT_PQUOTA;
121 args->flags &= ~XFSMNT_PQUOTAENF;
122 referenced = 1;
112 } else if (!strcmp(this_char, MNTOPT_GQUOTA) || 123 } else if (!strcmp(this_char, MNTOPT_GQUOTA) ||
113 !strcmp(this_char, MNTOPT_GRPQUOTA)) { 124 !strcmp(this_char, MNTOPT_GRPQUOTA)) {
114 args->flags |= XFSMNT_GQUOTA | XFSMNT_GQUOTAENF; 125 args->flags |= XFSMNT_GQUOTA | XFSMNT_GQUOTAENF;
@@ -127,6 +138,12 @@ xfs_qm_parseargs(
127 *this_char++ = ','; 138 *this_char++ = ',';
128 } 139 }
129 140
141 if ((args->flags & XFSMNT_GQUOTA) && (args->flags & XFSMNT_PQUOTA)) {
142 cmn_err(CE_WARN,
143 "XFS: cannot mount with both project and group quota");
144 return XFS_ERROR(EINVAL);
145 }
146
130 PVFS_PARSEARGS(BHV_NEXT(bhv), options, args, update, error); 147 PVFS_PARSEARGS(BHV_NEXT(bhv), options, args, update, error);
131 if (!error && !referenced) 148 if (!error && !referenced)
132 bhv_remove_vfsops(bhvtovfs(bhv), VFS_POSITION_QM); 149 bhv_remove_vfsops(bhvtovfs(bhv), VFS_POSITION_QM);
@@ -148,13 +165,19 @@ xfs_qm_showargs(
148 seq_puts(m, "," MNTOPT_UQUOTANOENF); 165 seq_puts(m, "," MNTOPT_UQUOTANOENF);
149 } 166 }
150 167
168 if (mp->m_qflags & XFS_PQUOTA_ACCT) {
169 (mp->m_qflags & XFS_OQUOTA_ENFD) ?
170 seq_puts(m, "," MNTOPT_PRJQUOTA) :
171 seq_puts(m, "," MNTOPT_PQUOTANOENF);
172 }
173
151 if (mp->m_qflags & XFS_GQUOTA_ACCT) { 174 if (mp->m_qflags & XFS_GQUOTA_ACCT) {
152 (mp->m_qflags & XFS_GQUOTA_ENFD) ? 175 (mp->m_qflags & XFS_OQUOTA_ENFD) ?
153 seq_puts(m, "," MNTOPT_GRPQUOTA) : 176 seq_puts(m, "," MNTOPT_GRPQUOTA) :
154 seq_puts(m, "," MNTOPT_GQUOTANOENF); 177 seq_puts(m, "," MNTOPT_GQUOTANOENF);
155 } 178 }
156 179
157 if (!(mp->m_qflags & (XFS_UQUOTA_ACCT|XFS_GQUOTA_ACCT))) 180 if (!(mp->m_qflags & XFS_ALL_QUOTA_ACCT))
158 seq_puts(m, "," MNTOPT_NOQUOTA); 181 seq_puts(m, "," MNTOPT_NOQUOTA);
159 182
160 PVFS_SHOWARGS(BHV_NEXT(bhv), m, error); 183 PVFS_SHOWARGS(BHV_NEXT(bhv), m, error);
@@ -171,7 +194,7 @@ xfs_qm_mount(
171 struct xfs_mount *mp = XFS_VFSTOM(vfsp); 194 struct xfs_mount *mp = XFS_VFSTOM(vfsp);
172 int error; 195 int error;
173 196
174 if (args->flags & (XFSMNT_UQUOTA | XFSMNT_GQUOTA)) 197 if (args->flags & (XFSMNT_UQUOTA | XFSMNT_GQUOTA | XFSMNT_PQUOTA))
175 xfs_qm_mount_quotainit(mp, args->flags); 198 xfs_qm_mount_quotainit(mp, args->flags);
176 PVFS_MOUNT(BHV_NEXT(bhv), args, cr, error); 199 PVFS_MOUNT(BHV_NEXT(bhv), args, cr, error);
177 return error; 200 return error;
@@ -255,16 +278,17 @@ xfs_qm_newmount(
255 uint *quotaflags) 278 uint *quotaflags)
256{ 279{
257 uint quotaondisk; 280 uint quotaondisk;
258 uint uquotaondisk = 0, gquotaondisk = 0; 281 uint uquotaondisk = 0, gquotaondisk = 0, pquotaondisk = 0;
259 282
260 *quotaflags = 0; 283 *quotaflags = 0;
261 *needquotamount = B_FALSE; 284 *needquotamount = B_FALSE;
262 285
263 quotaondisk = XFS_SB_VERSION_HASQUOTA(&mp->m_sb) && 286 quotaondisk = XFS_SB_VERSION_HASQUOTA(&mp->m_sb) &&
264 mp->m_sb.sb_qflags & (XFS_UQUOTA_ACCT|XFS_GQUOTA_ACCT); 287 (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT);
265 288
266 if (quotaondisk) { 289 if (quotaondisk) {
267 uquotaondisk = mp->m_sb.sb_qflags & XFS_UQUOTA_ACCT; 290 uquotaondisk = mp->m_sb.sb_qflags & XFS_UQUOTA_ACCT;
291 pquotaondisk = mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT;
268 gquotaondisk = mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT; 292 gquotaondisk = mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT;
269 } 293 }
270 294
@@ -277,13 +301,16 @@ xfs_qm_newmount(
277 301
278 if (((uquotaondisk && !XFS_IS_UQUOTA_ON(mp)) || 302 if (((uquotaondisk && !XFS_IS_UQUOTA_ON(mp)) ||
279 (!uquotaondisk && XFS_IS_UQUOTA_ON(mp)) || 303 (!uquotaondisk && XFS_IS_UQUOTA_ON(mp)) ||
304 (pquotaondisk && !XFS_IS_PQUOTA_ON(mp)) ||
305 (!pquotaondisk && XFS_IS_PQUOTA_ON(mp)) ||
280 (gquotaondisk && !XFS_IS_GQUOTA_ON(mp)) || 306 (gquotaondisk && !XFS_IS_GQUOTA_ON(mp)) ||
281 (!gquotaondisk && XFS_IS_GQUOTA_ON(mp))) && 307 (!gquotaondisk && XFS_IS_OQUOTA_ON(mp))) &&
282 xfs_dev_is_read_only(mp, "changing quota state")) { 308 xfs_dev_is_read_only(mp, "changing quota state")) {
283 cmn_err(CE_WARN, 309 cmn_err(CE_WARN,
284 "XFS: please mount with%s%s%s.", 310 "XFS: please mount with%s%s%s%s.",
285 (!quotaondisk ? "out quota" : ""), 311 (!quotaondisk ? "out quota" : ""),
286 (uquotaondisk ? " usrquota" : ""), 312 (uquotaondisk ? " usrquota" : ""),
313 (pquotaondisk ? " prjquota" : ""),
287 (gquotaondisk ? " grpquota" : "")); 314 (gquotaondisk ? " grpquota" : ""));
288 return XFS_ERROR(EPERM); 315 return XFS_ERROR(EPERM);
289 } 316 }
@@ -359,7 +386,7 @@ xfs_qm_dqrele_null(
359} 386}
360 387
361 388
362struct xfs_qmops xfs_qmcore_xfs = { 389STATIC struct xfs_qmops xfs_qmcore_xfs = {
363 .xfs_qminit = xfs_qm_newmount, 390 .xfs_qminit = xfs_qm_newmount,
364 .xfs_qmdone = xfs_qm_unmount_quotadestroy, 391 .xfs_qmdone = xfs_qm_unmount_quotadestroy,
365 .xfs_qmmount = xfs_qm_endmount, 392 .xfs_qmmount = xfs_qm_endmount,
diff --git a/fs/xfs/quota/xfs_qm_syscalls.c b/fs/xfs/quota/xfs_qm_syscalls.c
index 229f5b5a2d25..68e98962dbef 100644
--- a/fs/xfs/quota/xfs_qm_syscalls.c
+++ b/fs/xfs/quota/xfs_qm_syscalls.c
@@ -118,40 +118,41 @@ xfs_qm_quotactl(
118 * The following commands are valid even when quotaoff. 118 * The following commands are valid even when quotaoff.
119 */ 119 */
120 switch (cmd) { 120 switch (cmd) {
121 case Q_XQUOTARM:
121 /* 122 /*
122 * truncate quota files. quota must be off. 123 * Truncate quota files. quota must be off.
123 */ 124 */
124 case Q_XQUOTARM:
125 if (XFS_IS_QUOTA_ON(mp) || addr == NULL) 125 if (XFS_IS_QUOTA_ON(mp) || addr == NULL)
126 return XFS_ERROR(EINVAL); 126 return XFS_ERROR(EINVAL);
127 if (vfsp->vfs_flag & VFS_RDONLY) 127 if (vfsp->vfs_flag & VFS_RDONLY)
128 return XFS_ERROR(EROFS); 128 return XFS_ERROR(EROFS);
129 return (xfs_qm_scall_trunc_qfiles(mp, 129 return (xfs_qm_scall_trunc_qfiles(mp,
130 xfs_qm_import_qtype_flags(*(uint *)addr))); 130 xfs_qm_import_qtype_flags(*(uint *)addr)));
131
132 case Q_XGETQSTAT:
131 /* 133 /*
132 * Get quota status information. 134 * Get quota status information.
133 */ 135 */
134 case Q_XGETQSTAT:
135 return (xfs_qm_scall_getqstat(mp, (fs_quota_stat_t *)addr)); 136 return (xfs_qm_scall_getqstat(mp, (fs_quota_stat_t *)addr));
136 137
138 case Q_XQUOTAON:
137 /* 139 /*
138 * QUOTAON for root f/s and quota enforcement on others.. 140 * QUOTAON - enabling quota enforcement.
139 * Quota accounting for non-root f/s's must be turned on 141 * Quota accounting must be turned on at mount time.
140 * at mount time.
141 */ 142 */
142 case Q_XQUOTAON:
143 if (addr == NULL) 143 if (addr == NULL)
144 return XFS_ERROR(EINVAL); 144 return XFS_ERROR(EINVAL);
145 if (vfsp->vfs_flag & VFS_RDONLY) 145 if (vfsp->vfs_flag & VFS_RDONLY)
146 return XFS_ERROR(EROFS); 146 return XFS_ERROR(EROFS);
147 return (xfs_qm_scall_quotaon(mp, 147 return (xfs_qm_scall_quotaon(mp,
148 xfs_qm_import_flags(*(uint *)addr))); 148 xfs_qm_import_flags(*(uint *)addr)));
149 case Q_XQUOTAOFF: 149
150 case Q_XQUOTAOFF:
150 if (vfsp->vfs_flag & VFS_RDONLY) 151 if (vfsp->vfs_flag & VFS_RDONLY)
151 return XFS_ERROR(EROFS); 152 return XFS_ERROR(EROFS);
152 break; 153 break;
153 154
154 default: 155 default:
155 break; 156 break;
156 } 157 }
157 158
@@ -159,7 +160,7 @@ xfs_qm_quotactl(
159 return XFS_ERROR(ESRCH); 160 return XFS_ERROR(ESRCH);
160 161
161 switch (cmd) { 162 switch (cmd) {
162 case Q_XQUOTAOFF: 163 case Q_XQUOTAOFF:
163 if (vfsp->vfs_flag & VFS_RDONLY) 164 if (vfsp->vfs_flag & VFS_RDONLY)
164 return XFS_ERROR(EROFS); 165 return XFS_ERROR(EROFS);
165 error = xfs_qm_scall_quotaoff(mp, 166 error = xfs_qm_scall_quotaoff(mp,
@@ -167,42 +168,39 @@ xfs_qm_quotactl(
167 B_FALSE); 168 B_FALSE);
168 break; 169 break;
169 170
170 /* 171 case Q_XGETQUOTA:
171 * Defaults to XFS_GETUQUOTA.
172 */
173 case Q_XGETQUOTA:
174 error = xfs_qm_scall_getquota(mp, (xfs_dqid_t)id, XFS_DQ_USER, 172 error = xfs_qm_scall_getquota(mp, (xfs_dqid_t)id, XFS_DQ_USER,
175 (fs_disk_quota_t *)addr); 173 (fs_disk_quota_t *)addr);
176 break; 174 break;
177 /* 175 case Q_XGETGQUOTA:
178 * Set limits, both hard and soft. Defaults to Q_SETUQLIM. 176 error = xfs_qm_scall_getquota(mp, (xfs_dqid_t)id, XFS_DQ_GROUP,
179 */ 177 (fs_disk_quota_t *)addr);
180 case Q_XSETQLIM: 178 break;
179 case Q_XGETPQUOTA:
180 error = xfs_qm_scall_getquota(mp, (xfs_dqid_t)id, XFS_DQ_PROJ,
181 (fs_disk_quota_t *)addr);
182 break;
183
184 case Q_XSETQLIM:
181 if (vfsp->vfs_flag & VFS_RDONLY) 185 if (vfsp->vfs_flag & VFS_RDONLY)
182 return XFS_ERROR(EROFS); 186 return XFS_ERROR(EROFS);
183 error = xfs_qm_scall_setqlim(mp, (xfs_dqid_t)id, XFS_DQ_USER, 187 error = xfs_qm_scall_setqlim(mp, (xfs_dqid_t)id, XFS_DQ_USER,
184 (fs_disk_quota_t *)addr); 188 (fs_disk_quota_t *)addr);
185 break; 189 break;
186 190 case Q_XSETGQLIM:
187 case Q_XSETGQLIM:
188 if (vfsp->vfs_flag & VFS_RDONLY) 191 if (vfsp->vfs_flag & VFS_RDONLY)
189 return XFS_ERROR(EROFS); 192 return XFS_ERROR(EROFS);
190 error = xfs_qm_scall_setqlim(mp, (xfs_dqid_t)id, XFS_DQ_GROUP, 193 error = xfs_qm_scall_setqlim(mp, (xfs_dqid_t)id, XFS_DQ_GROUP,
191 (fs_disk_quota_t *)addr); 194 (fs_disk_quota_t *)addr);
192 break; 195 break;
193 196 case Q_XSETPQLIM:
194 197 if (vfsp->vfs_flag & VFS_RDONLY)
195 case Q_XGETGQUOTA: 198 return XFS_ERROR(EROFS);
196 error = xfs_qm_scall_getquota(mp, (xfs_dqid_t)id, XFS_DQ_GROUP, 199 error = xfs_qm_scall_setqlim(mp, (xfs_dqid_t)id, XFS_DQ_PROJ,
197 (fs_disk_quota_t *)addr); 200 (fs_disk_quota_t *)addr);
198 break; 201 break;
199 202
200 /* 203 default:
201 * Quotas are entirely undefined after quotaoff in XFS quotas.
202 * For instance, there's no way to set limits when quotaoff.
203 */
204
205 default:
206 error = XFS_ERROR(EINVAL); 204 error = XFS_ERROR(EINVAL);
207 break; 205 break;
208 } 206 }
@@ -286,8 +284,12 @@ xfs_qm_scall_quotaoff(
286 } 284 }
287 if (flags & XFS_GQUOTA_ACCT) { 285 if (flags & XFS_GQUOTA_ACCT) {
288 dqtype |= XFS_QMOPT_GQUOTA; 286 dqtype |= XFS_QMOPT_GQUOTA;
289 flags |= (XFS_GQUOTA_CHKD | XFS_GQUOTA_ENFD); 287 flags |= (XFS_OQUOTA_CHKD | XFS_OQUOTA_ENFD);
290 inactivate_flags |= XFS_GQUOTA_ACTIVE; 288 inactivate_flags |= XFS_GQUOTA_ACTIVE;
289 } else if (flags & XFS_PQUOTA_ACCT) {
290 dqtype |= XFS_QMOPT_PQUOTA;
291 flags |= (XFS_OQUOTA_CHKD | XFS_OQUOTA_ENFD);
292 inactivate_flags |= XFS_PQUOTA_ACTIVE;
291 } 293 }
292 294
293 /* 295 /*
@@ -364,7 +366,8 @@ xfs_qm_scall_quotaoff(
364 /* 366 /*
365 * If quotas is completely disabled, close shop. 367 * If quotas is completely disabled, close shop.
366 */ 368 */
367 if ((flags & XFS_MOUNT_QUOTA_ALL) == XFS_MOUNT_QUOTA_ALL) { 369 if (((flags & XFS_MOUNT_QUOTA_ALL) == XFS_MOUNT_QUOTA_SET1) ||
370 ((flags & XFS_MOUNT_QUOTA_ALL) == XFS_MOUNT_QUOTA_SET2)) {
368 mutex_unlock(&(XFS_QI_QOFFLOCK(mp))); 371 mutex_unlock(&(XFS_QI_QOFFLOCK(mp)));
369 xfs_qm_destroy_quotainfo(mp); 372 xfs_qm_destroy_quotainfo(mp);
370 return (0); 373 return (0);
@@ -378,7 +381,7 @@ xfs_qm_scall_quotaoff(
378 XFS_PURGE_INODE(XFS_QI_UQIP(mp)); 381 XFS_PURGE_INODE(XFS_QI_UQIP(mp));
379 XFS_QI_UQIP(mp) = NULL; 382 XFS_QI_UQIP(mp) = NULL;
380 } 383 }
381 if ((dqtype & XFS_QMOPT_GQUOTA) && XFS_QI_GQIP(mp)) { 384 if ((dqtype & (XFS_QMOPT_GQUOTA|XFS_QMOPT_PQUOTA)) && XFS_QI_GQIP(mp)) {
382 XFS_PURGE_INODE(XFS_QI_GQIP(mp)); 385 XFS_PURGE_INODE(XFS_QI_GQIP(mp));
383 XFS_QI_GQIP(mp) = NULL; 386 XFS_QI_GQIP(mp) = NULL;
384 } 387 }
@@ -411,7 +414,8 @@ xfs_qm_scall_trunc_qfiles(
411 } 414 }
412 } 415 }
413 416
414 if ((flags & XFS_DQ_GROUP) && mp->m_sb.sb_gquotino != NULLFSINO) { 417 if ((flags & (XFS_DQ_GROUP|XFS_DQ_PROJ)) &&
418 mp->m_sb.sb_gquotino != NULLFSINO) {
415 error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, 0, 0, &qip, 0); 419 error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino, 0, 0, &qip, 0);
416 if (! error) { 420 if (! error) {
417 (void) xfs_truncate_file(mp, qip); 421 (void) xfs_truncate_file(mp, qip);
@@ -434,7 +438,7 @@ xfs_qm_scall_quotaon(
434 uint flags) 438 uint flags)
435{ 439{
436 int error; 440 int error;
437 unsigned long s; 441 unsigned long s;
438 uint qf; 442 uint qf;
439 uint accflags; 443 uint accflags;
440 __int64_t sbflags; 444 __int64_t sbflags;
@@ -468,9 +472,13 @@ xfs_qm_scall_quotaon(
468 (mp->m_sb.sb_qflags & XFS_UQUOTA_ACCT) == 0 && 472 (mp->m_sb.sb_qflags & XFS_UQUOTA_ACCT) == 0 &&
469 (flags & XFS_UQUOTA_ENFD)) 473 (flags & XFS_UQUOTA_ENFD))
470 || 474 ||
475 ((flags & XFS_PQUOTA_ACCT) == 0 &&
476 (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT) == 0 &&
477 (flags & XFS_OQUOTA_ENFD))
478 ||
471 ((flags & XFS_GQUOTA_ACCT) == 0 && 479 ((flags & XFS_GQUOTA_ACCT) == 0 &&
472 (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) == 0 && 480 (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) == 0 &&
473 (flags & XFS_GQUOTA_ENFD))) { 481 (flags & XFS_OQUOTA_ENFD))) {
474 qdprintk("Can't enforce without acct, flags=%x sbflags=%x\n", 482 qdprintk("Can't enforce without acct, flags=%x sbflags=%x\n",
475 flags, mp->m_sb.sb_qflags); 483 flags, mp->m_sb.sb_qflags);
476 return XFS_ERROR(EINVAL); 484 return XFS_ERROR(EINVAL);
@@ -504,6 +512,10 @@ xfs_qm_scall_quotaon(
504 */ 512 */
505 if (((mp->m_sb.sb_qflags & XFS_UQUOTA_ACCT) != 513 if (((mp->m_sb.sb_qflags & XFS_UQUOTA_ACCT) !=
506 (mp->m_qflags & XFS_UQUOTA_ACCT)) || 514 (mp->m_qflags & XFS_UQUOTA_ACCT)) ||
515 ((mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT) !=
516 (mp->m_qflags & XFS_PQUOTA_ACCT)) ||
517 ((mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) !=
518 (mp->m_qflags & XFS_GQUOTA_ACCT)) ||
507 (flags & XFS_ALL_QUOTA_ENFD) == 0) 519 (flags & XFS_ALL_QUOTA_ENFD) == 0)
508 return (0); 520 return (0);
509 521
@@ -521,7 +533,6 @@ xfs_qm_scall_quotaon(
521} 533}
522 534
523 535
524
525/* 536/*
526 * Return quota status information, such as uquota-off, enforcements, etc. 537 * Return quota status information, such as uquota-off, enforcements, etc.
527 */ 538 */
@@ -606,7 +617,8 @@ xfs_qm_scall_setqlim(
606 if (!capable(CAP_SYS_ADMIN)) 617 if (!capable(CAP_SYS_ADMIN))
607 return XFS_ERROR(EPERM); 618 return XFS_ERROR(EPERM);
608 619
609 if ((newlim->d_fieldmask & (FS_DQ_LIMIT_MASK|FS_DQ_TIMER_MASK)) == 0) 620 if ((newlim->d_fieldmask &
621 (FS_DQ_LIMIT_MASK|FS_DQ_TIMER_MASK|FS_DQ_WARNS_MASK)) == 0)
610 return (0); 622 return (0);
611 623
612 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SETQLIM); 624 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SETQLIM);
@@ -691,12 +703,23 @@ xfs_qm_scall_setqlim(
691 qdprintk("ihard %Ld < isoft %Ld\n", hard, soft); 703 qdprintk("ihard %Ld < isoft %Ld\n", hard, soft);
692 } 704 }
693 705
706 /*
707 * Update warnings counter(s) if requested
708 */
709 if (newlim->d_fieldmask & FS_DQ_BWARNS)
710 INT_SET(ddq->d_bwarns, ARCH_CONVERT, newlim->d_bwarns);
711 if (newlim->d_fieldmask & FS_DQ_IWARNS)
712 INT_SET(ddq->d_iwarns, ARCH_CONVERT, newlim->d_iwarns);
713 if (newlim->d_fieldmask & FS_DQ_RTBWARNS)
714 INT_SET(ddq->d_rtbwarns, ARCH_CONVERT, newlim->d_rtbwarns);
715
694 if (id == 0) { 716 if (id == 0) {
695 /* 717 /*
696 * Timelimits for the super user set the relative time 718 * Timelimits for the super user set the relative time
697 * the other users can be over quota for this file system. 719 * the other users can be over quota for this file system.
698 * If it is zero a default is used. Ditto for the default 720 * If it is zero a default is used. Ditto for the default
699 * soft and hard limit values (already done, above). 721 * soft and hard limit values (already done, above), and
722 * for warnings.
700 */ 723 */
701 if (newlim->d_fieldmask & FS_DQ_BTIMER) { 724 if (newlim->d_fieldmask & FS_DQ_BTIMER) {
702 mp->m_quotainfo->qi_btimelimit = newlim->d_btimer; 725 mp->m_quotainfo->qi_btimelimit = newlim->d_btimer;
@@ -710,7 +733,13 @@ xfs_qm_scall_setqlim(
710 mp->m_quotainfo->qi_rtbtimelimit = newlim->d_rtbtimer; 733 mp->m_quotainfo->qi_rtbtimelimit = newlim->d_rtbtimer;
711 INT_SET(ddq->d_rtbtimer, ARCH_CONVERT, newlim->d_rtbtimer); 734 INT_SET(ddq->d_rtbtimer, ARCH_CONVERT, newlim->d_rtbtimer);
712 } 735 }
713 } else /* if (XFS_IS_QUOTA_ENFORCED(mp)) */ { 736 if (newlim->d_fieldmask & FS_DQ_BWARNS)
737 mp->m_quotainfo->qi_bwarnlimit = newlim->d_bwarns;
738 if (newlim->d_fieldmask & FS_DQ_IWARNS)
739 mp->m_quotainfo->qi_iwarnlimit = newlim->d_iwarns;
740 if (newlim->d_fieldmask & FS_DQ_RTBWARNS)
741 mp->m_quotainfo->qi_rtbwarnlimit = newlim->d_rtbwarns;
742 } else {
714 /* 743 /*
715 * If the user is now over quota, start the timelimit. 744 * If the user is now over quota, start the timelimit.
716 * The user will not be 'warned'. 745 * The user will not be 'warned'.
@@ -776,9 +805,9 @@ xfs_qm_log_quotaoff_end(
776 xfs_qoff_logitem_t *startqoff, 805 xfs_qoff_logitem_t *startqoff,
777 uint flags) 806 uint flags)
778{ 807{
779 xfs_trans_t *tp; 808 xfs_trans_t *tp;
780 int error; 809 int error;
781 xfs_qoff_logitem_t *qoffi; 810 xfs_qoff_logitem_t *qoffi;
782 811
783 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QUOTAOFF_END); 812 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QUOTAOFF_END);
784 813
@@ -928,18 +957,26 @@ xfs_qm_export_dquot(
928 957
929STATIC uint 958STATIC uint
930xfs_qm_import_qtype_flags( 959xfs_qm_import_qtype_flags(
931 uint uflags) 960 uint uflags)
932{ 961{
962 uint oflags = 0;
963
933 /* 964 /*
934 * Can't be both at the same time. 965 * Can't be more than one, or none.
935 */ 966 */
936 if (((uflags & (XFS_GROUP_QUOTA | XFS_USER_QUOTA)) == 967 if (((uflags & (XFS_GROUP_QUOTA | XFS_USER_QUOTA)) ==
937 (XFS_GROUP_QUOTA | XFS_USER_QUOTA)) || 968 (XFS_GROUP_QUOTA | XFS_USER_QUOTA)) ||
938 ((uflags & (XFS_GROUP_QUOTA | XFS_USER_QUOTA)) == 0)) 969 ((uflags & (XFS_GROUP_QUOTA | XFS_PROJ_QUOTA)) ==
970 (XFS_GROUP_QUOTA | XFS_PROJ_QUOTA)) ||
971 ((uflags & (XFS_USER_QUOTA | XFS_PROJ_QUOTA)) ==
972 (XFS_USER_QUOTA | XFS_PROJ_QUOTA)) ||
973 ((uflags & (XFS_GROUP_QUOTA|XFS_USER_QUOTA|XFS_PROJ_QUOTA)) == 0))
939 return (0); 974 return (0);
940 975
941 return (uflags & XFS_USER_QUOTA) ? 976 oflags |= (uflags & XFS_USER_QUOTA) ? XFS_DQ_USER : 0;
942 XFS_DQ_USER : XFS_DQ_GROUP; 977 oflags |= (uflags & XFS_PROJ_QUOTA) ? XFS_DQ_PROJ : 0;
978 oflags |= (uflags & XFS_GROUP_QUOTA) ? XFS_DQ_GROUP: 0;
979 return oflags;
943} 980}
944 981
945STATIC uint 982STATIC uint
@@ -947,14 +984,19 @@ xfs_qm_export_qtype_flags(
947 uint flags) 984 uint flags)
948{ 985{
949 /* 986 /*
950 * Can't be both at the same time. 987 * Can't be more than one, or none.
951 */ 988 */
952 ASSERT((flags & (XFS_GROUP_QUOTA | XFS_USER_QUOTA)) != 989 ASSERT((flags & (XFS_PROJ_QUOTA | XFS_USER_QUOTA)) !=
953 (XFS_GROUP_QUOTA | XFS_USER_QUOTA)); 990 (XFS_PROJ_QUOTA | XFS_USER_QUOTA));
954 ASSERT((flags & (XFS_GROUP_QUOTA | XFS_USER_QUOTA)) != 0); 991 ASSERT((flags & (XFS_PROJ_QUOTA | XFS_GROUP_QUOTA)) !=
992 (XFS_PROJ_QUOTA | XFS_GROUP_QUOTA));
993 ASSERT((flags & (XFS_USER_QUOTA | XFS_GROUP_QUOTA)) !=
994 (XFS_USER_QUOTA | XFS_GROUP_QUOTA));
995 ASSERT((flags & (XFS_PROJ_QUOTA|XFS_USER_QUOTA|XFS_GROUP_QUOTA)) != 0);
955 996
956 return (flags & XFS_DQ_USER) ? 997 return (flags & XFS_DQ_USER) ?
957 XFS_USER_QUOTA : XFS_GROUP_QUOTA; 998 XFS_USER_QUOTA : (flags & XFS_DQ_PROJ) ?
999 XFS_PROJ_QUOTA : XFS_GROUP_QUOTA;
958} 1000}
959 1001
960STATIC uint 1002STATIC uint
@@ -965,12 +1007,14 @@ xfs_qm_import_flags(
965 1007
966 if (uflags & XFS_QUOTA_UDQ_ACCT) 1008 if (uflags & XFS_QUOTA_UDQ_ACCT)
967 flags |= XFS_UQUOTA_ACCT; 1009 flags |= XFS_UQUOTA_ACCT;
1010 if (uflags & XFS_QUOTA_PDQ_ACCT)
1011 flags |= XFS_PQUOTA_ACCT;
968 if (uflags & XFS_QUOTA_GDQ_ACCT) 1012 if (uflags & XFS_QUOTA_GDQ_ACCT)
969 flags |= XFS_GQUOTA_ACCT; 1013 flags |= XFS_GQUOTA_ACCT;
970 if (uflags & XFS_QUOTA_UDQ_ENFD) 1014 if (uflags & XFS_QUOTA_UDQ_ENFD)
971 flags |= XFS_UQUOTA_ENFD; 1015 flags |= XFS_UQUOTA_ENFD;
972 if (uflags & XFS_QUOTA_GDQ_ENFD) 1016 if (uflags & (XFS_QUOTA_PDQ_ENFD|XFS_QUOTA_GDQ_ENFD))
973 flags |= XFS_GQUOTA_ENFD; 1017 flags |= XFS_OQUOTA_ENFD;
974 return (flags); 1018 return (flags);
975} 1019}
976 1020
@@ -984,12 +1028,16 @@ xfs_qm_export_flags(
984 uflags = 0; 1028 uflags = 0;
985 if (flags & XFS_UQUOTA_ACCT) 1029 if (flags & XFS_UQUOTA_ACCT)
986 uflags |= XFS_QUOTA_UDQ_ACCT; 1030 uflags |= XFS_QUOTA_UDQ_ACCT;
1031 if (flags & XFS_PQUOTA_ACCT)
1032 uflags |= XFS_QUOTA_PDQ_ACCT;
987 if (flags & XFS_GQUOTA_ACCT) 1033 if (flags & XFS_GQUOTA_ACCT)
988 uflags |= XFS_QUOTA_GDQ_ACCT; 1034 uflags |= XFS_QUOTA_GDQ_ACCT;
989 if (flags & XFS_UQUOTA_ENFD) 1035 if (flags & XFS_UQUOTA_ENFD)
990 uflags |= XFS_QUOTA_UDQ_ENFD; 1036 uflags |= XFS_QUOTA_UDQ_ENFD;
991 if (flags & XFS_GQUOTA_ENFD) 1037 if (flags & (XFS_OQUOTA_ENFD)) {
992 uflags |= XFS_QUOTA_GDQ_ENFD; 1038 uflags |= (flags & XFS_GQUOTA_ACCT) ?
1039 XFS_QUOTA_GDQ_ENFD : XFS_QUOTA_PDQ_ENFD;
1040 }
993 return (uflags); 1041 return (uflags);
994} 1042}
995 1043
@@ -1070,7 +1118,7 @@ again:
1070 xfs_qm_dqrele(ip->i_udquot); 1118 xfs_qm_dqrele(ip->i_udquot);
1071 ip->i_udquot = NULL; 1119 ip->i_udquot = NULL;
1072 } 1120 }
1073 if ((flags & XFS_GQUOTA_ACCT) && ip->i_gdquot) { 1121 if (flags & (XFS_PQUOTA_ACCT|XFS_GQUOTA_ACCT) && ip->i_gdquot) {
1074 xfs_qm_dqrele(ip->i_gdquot); 1122 xfs_qm_dqrele(ip->i_gdquot);
1075 ip->i_gdquot = NULL; 1123 ip->i_gdquot = NULL;
1076 } 1124 }
@@ -1160,7 +1208,6 @@ xfs_qm_dqtest_print(
1160{ 1208{
1161 cmn_err(CE_DEBUG, "-----------DQTEST DQUOT----------------"); 1209 cmn_err(CE_DEBUG, "-----------DQTEST DQUOT----------------");
1162 cmn_err(CE_DEBUG, "---- dquot ID = %d", d->d_id); 1210 cmn_err(CE_DEBUG, "---- dquot ID = %d", d->d_id);
1163 cmn_err(CE_DEBUG, "---- type = %s", XFS_QM_ISUDQ(d)? "USR" : "GRP");
1164 cmn_err(CE_DEBUG, "---- fs = 0x%p", d->q_mount); 1211 cmn_err(CE_DEBUG, "---- fs = 0x%p", d->q_mount);
1165 cmn_err(CE_DEBUG, "---- bcount = %Lu (0x%x)", 1212 cmn_err(CE_DEBUG, "---- bcount = %Lu (0x%x)",
1166 d->d_bcount, (int)d->d_bcount); 1213 d->d_bcount, (int)d->d_bcount);
@@ -1231,7 +1278,7 @@ xfs_dqtest_cmp2(
1231#ifdef QUOTADEBUG 1278#ifdef QUOTADEBUG
1232 if (!err) { 1279 if (!err) {
1233 cmn_err(CE_DEBUG, "%d [%s] [0x%p] qchecked", 1280 cmn_err(CE_DEBUG, "%d [%s] [0x%p] qchecked",
1234 d->d_id, XFS_QM_ISUDQ(d) ? "USR" : "GRP", d->q_mount); 1281 d->d_id, DQFLAGTO_TYPESTR(d), d->q_mount);
1235 } 1282 }
1236#endif 1283#endif
1237 return (err); 1284 return (err);
@@ -1287,6 +1334,7 @@ STATIC void
1287xfs_qm_internalqcheck_get_dquots( 1334xfs_qm_internalqcheck_get_dquots(
1288 xfs_mount_t *mp, 1335 xfs_mount_t *mp,
1289 xfs_dqid_t uid, 1336 xfs_dqid_t uid,
1337 xfs_dqid_t projid,
1290 xfs_dqid_t gid, 1338 xfs_dqid_t gid,
1291 xfs_dqtest_t **ud, 1339 xfs_dqtest_t **ud,
1292 xfs_dqtest_t **gd) 1340 xfs_dqtest_t **gd)
@@ -1295,6 +1343,8 @@ xfs_qm_internalqcheck_get_dquots(
1295 xfs_qm_internalqcheck_dqget(mp, uid, XFS_DQ_USER, ud); 1343 xfs_qm_internalqcheck_dqget(mp, uid, XFS_DQ_USER, ud);
1296 if (XFS_IS_GQUOTA_ON(mp)) 1344 if (XFS_IS_GQUOTA_ON(mp))
1297 xfs_qm_internalqcheck_dqget(mp, gid, XFS_DQ_GROUP, gd); 1345 xfs_qm_internalqcheck_dqget(mp, gid, XFS_DQ_GROUP, gd);
1346 else if (XFS_IS_PQUOTA_ON(mp))
1347 xfs_qm_internalqcheck_dqget(mp, projid, XFS_DQ_PROJ, gd);
1298} 1348}
1299 1349
1300 1350
@@ -1362,13 +1412,14 @@ xfs_qm_internalqcheck_adjust(
1362 } 1412 }
1363 xfs_qm_internalqcheck_get_dquots(mp, 1413 xfs_qm_internalqcheck_get_dquots(mp,
1364 (xfs_dqid_t) ip->i_d.di_uid, 1414 (xfs_dqid_t) ip->i_d.di_uid,
1415 (xfs_dqid_t) ip->i_d.di_projid,
1365 (xfs_dqid_t) ip->i_d.di_gid, 1416 (xfs_dqid_t) ip->i_d.di_gid,
1366 &ud, &gd); 1417 &ud, &gd);
1367 if (XFS_IS_UQUOTA_ON(mp)) { 1418 if (XFS_IS_UQUOTA_ON(mp)) {
1368 ASSERT(ud); 1419 ASSERT(ud);
1369 xfs_qm_internalqcheck_dqadjust(ip, ud); 1420 xfs_qm_internalqcheck_dqadjust(ip, ud);
1370 } 1421 }
1371 if (XFS_IS_GQUOTA_ON(mp)) { 1422 if (XFS_IS_OQUOTA_ON(mp)) {
1372 ASSERT(gd); 1423 ASSERT(gd);
1373 xfs_qm_internalqcheck_dqadjust(ip, gd); 1424 xfs_qm_internalqcheck_dqadjust(ip, gd);
1374 } 1425 }
diff --git a/fs/xfs/quota/xfs_quota_priv.h b/fs/xfs/quota/xfs_quota_priv.h
index 414b6004af21..bf413e70ec07 100644
--- a/fs/xfs/quota/xfs_quota_priv.h
+++ b/fs/xfs/quota/xfs_quota_priv.h
@@ -56,6 +56,7 @@
56#define XFS_QI_RTBTIMELIMIT(mp) ((mp)->m_quotainfo->qi_rtbtimelimit) 56#define XFS_QI_RTBTIMELIMIT(mp) ((mp)->m_quotainfo->qi_rtbtimelimit)
57#define XFS_QI_ITIMELIMIT(mp) ((mp)->m_quotainfo->qi_itimelimit) 57#define XFS_QI_ITIMELIMIT(mp) ((mp)->m_quotainfo->qi_itimelimit)
58#define XFS_QI_BWARNLIMIT(mp) ((mp)->m_quotainfo->qi_bwarnlimit) 58#define XFS_QI_BWARNLIMIT(mp) ((mp)->m_quotainfo->qi_bwarnlimit)
59#define XFS_QI_RTBWARNLIMIT(mp) ((mp)->m_quotainfo->qi_rtbwarnlimit)
59#define XFS_QI_IWARNLIMIT(mp) ((mp)->m_quotainfo->qi_iwarnlimit) 60#define XFS_QI_IWARNLIMIT(mp) ((mp)->m_quotainfo->qi_iwarnlimit)
60#define XFS_QI_QOFFLOCK(mp) ((mp)->m_quotainfo->qi_quotaofflock) 61#define XFS_QI_QOFFLOCK(mp) ((mp)->m_quotainfo->qi_quotaofflock)
61 62
@@ -102,7 +103,8 @@ static inline int XQMISLCKD(struct xfs_dqhash *h)
102 (xfs_Gqm->qm_grp_dqhtable + \ 103 (xfs_Gqm->qm_grp_dqhtable + \
103 XFS_DQ_HASHVAL(mp, id))) 104 XFS_DQ_HASHVAL(mp, id)))
104#define XFS_IS_DQTYPE_ON(mp, type) (type == XFS_DQ_USER ? \ 105#define XFS_IS_DQTYPE_ON(mp, type) (type == XFS_DQ_USER ? \
105 XFS_IS_UQUOTA_ON(mp):XFS_IS_GQUOTA_ON(mp)) 106 XFS_IS_UQUOTA_ON(mp) : \
107 XFS_IS_OQUOTA_ON(mp))
106#define XFS_IS_DQUOT_UNINITIALIZED(dqp) ( \ 108#define XFS_IS_DQUOT_UNINITIALIZED(dqp) ( \
107 !dqp->q_core.d_blk_hardlimit && \ 109 !dqp->q_core.d_blk_hardlimit && \
108 !dqp->q_core.d_blk_softlimit && \ 110 !dqp->q_core.d_blk_softlimit && \
@@ -177,16 +179,11 @@ for ((dqp) = (qlist)->qh_next; (dqp) != (xfs_dquot_t *)(qlist); \
177 (!((dqp)->q_core.d_id)) 179 (!((dqp)->q_core.d_id))
178 180
179#define XFS_PURGE_INODE(ip) \ 181#define XFS_PURGE_INODE(ip) \
180 { \ 182 IRELE(ip);
181 vmap_t dqvmap; \
182 vnode_t *dqvp; \
183 dqvp = XFS_ITOV(ip); \
184 VMAP(dqvp, dqvmap); \
185 VN_RELE(dqvp); \
186 }
187 183
188#define DQFLAGTO_TYPESTR(d) (((d)->dq_flags & XFS_DQ_USER) ? "USR" : \ 184#define DQFLAGTO_TYPESTR(d) (((d)->dq_flags & XFS_DQ_USER) ? "USR" : \
189 (((d)->dq_flags & XFS_DQ_GROUP) ? "GRP" : "???")) 185 (((d)->dq_flags & XFS_DQ_GROUP) ? "GRP" : \
186 (((d)->dq_flags & XFS_DQ_PROJ) ? "PRJ":"???")))
190#define DQFLAGTO_DIRTYSTR(d) (XFS_DQ_IS_DIRTY(d) ? "DIRTY" : "NOTDIRTY") 187#define DQFLAGTO_DIRTYSTR(d) (XFS_DQ_IS_DIRTY(d) ? "DIRTY" : "NOTDIRTY")
191 188
192#endif /* __XFS_QUOTA_PRIV_H__ */ 189#endif /* __XFS_QUOTA_PRIV_H__ */
diff --git a/fs/xfs/quota/xfs_trans_dquot.c b/fs/xfs/quota/xfs_trans_dquot.c
index 149b2a1fd949..3b99daf8a640 100644
--- a/fs/xfs/quota/xfs_trans_dquot.c
+++ b/fs/xfs/quota/xfs_trans_dquot.c
@@ -187,7 +187,7 @@ xfs_trans_dup_dqinfo(
187/* 187/*
188 * Wrap around mod_dquot to account for both user and group quotas. 188 * Wrap around mod_dquot to account for both user and group quotas.
189 */ 189 */
190void 190STATIC void
191xfs_trans_mod_dquot_byino( 191xfs_trans_mod_dquot_byino(
192 xfs_trans_t *tp, 192 xfs_trans_t *tp,
193 xfs_inode_t *ip, 193 xfs_inode_t *ip,
@@ -207,12 +207,10 @@ xfs_trans_mod_dquot_byino(
207 if (tp->t_dqinfo == NULL) 207 if (tp->t_dqinfo == NULL)
208 xfs_trans_alloc_dqinfo(tp); 208 xfs_trans_alloc_dqinfo(tp);
209 209
210 if (XFS_IS_UQUOTA_ON(mp) && ip->i_udquot) { 210 if (XFS_IS_UQUOTA_ON(mp) && ip->i_udquot)
211 (void) xfs_trans_mod_dquot(tp, ip->i_udquot, field, delta); 211 (void) xfs_trans_mod_dquot(tp, ip->i_udquot, field, delta);
212 } 212 if (XFS_IS_OQUOTA_ON(mp) && ip->i_gdquot)
213 if (XFS_IS_GQUOTA_ON(mp) && ip->i_gdquot) {
214 (void) xfs_trans_mod_dquot(tp, ip->i_gdquot, field, delta); 213 (void) xfs_trans_mod_dquot(tp, ip->i_gdquot, field, delta);
215 }
216} 214}
217 215
218STATIC xfs_dqtrx_t * 216STATIC xfs_dqtrx_t *
@@ -368,7 +366,7 @@ xfs_trans_dqlockedjoin(
368 * Unreserve just the reservations done by this transaction. 366 * Unreserve just the reservations done by this transaction.
369 * dquot is still left locked at exit. 367 * dquot is still left locked at exit.
370 */ 368 */
371void 369STATIC void
372xfs_trans_apply_dquot_deltas( 370xfs_trans_apply_dquot_deltas(
373 xfs_trans_t *tp) 371 xfs_trans_t *tp)
374{ 372{
@@ -499,7 +497,7 @@ xfs_trans_apply_dquot_deltas(
499 * Adjust the RT reservation. 497 * Adjust the RT reservation.
500 */ 498 */
501 if (qtrx->qt_rtblk_res != 0) { 499 if (qtrx->qt_rtblk_res != 0) {
502 if (qtrx->qt_blk_res != qtrx->qt_blk_res_used) { 500 if (qtrx->qt_rtblk_res != qtrx->qt_rtblk_res_used) {
503 if (qtrx->qt_rtblk_res > 501 if (qtrx->qt_rtblk_res >
504 qtrx->qt_rtblk_res_used) 502 qtrx->qt_rtblk_res_used)
505 dqp->q_res_rtbcount -= (xfs_qcnt_t) 503 dqp->q_res_rtbcount -= (xfs_qcnt_t)
@@ -532,12 +530,6 @@ xfs_trans_apply_dquot_deltas(
532 (xfs_qcnt_t)qtrx->qt_icount_delta; 530 (xfs_qcnt_t)qtrx->qt_icount_delta;
533 } 531 }
534 532
535
536#ifdef QUOTADEBUG
537 if (qtrx->qt_rtblk_res != 0)
538 cmn_err(CE_DEBUG, "RT res %d for 0x%p\n",
539 (int) qtrx->qt_rtblk_res, dqp);
540#endif
541 ASSERT(dqp->q_res_bcount >= 533 ASSERT(dqp->q_res_bcount >=
542 INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT)); 534 INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT));
543 ASSERT(dqp->q_res_icount >= 535 ASSERT(dqp->q_res_icount >=
@@ -638,7 +630,10 @@ xfs_trans_dqresv(
638 int error; 630 int error;
639 xfs_qcnt_t hardlimit; 631 xfs_qcnt_t hardlimit;
640 xfs_qcnt_t softlimit; 632 xfs_qcnt_t softlimit;
641 time_t btimer; 633 time_t timer;
634 xfs_qwarncnt_t warns;
635 xfs_qwarncnt_t warnlimit;
636 xfs_qcnt_t count;
642 xfs_qcnt_t *resbcountp; 637 xfs_qcnt_t *resbcountp;
643 xfs_quotainfo_t *q = mp->m_quotainfo; 638 xfs_quotainfo_t *q = mp->m_quotainfo;
644 639
@@ -653,7 +648,9 @@ xfs_trans_dqresv(
653 softlimit = INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT); 648 softlimit = INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT);
654 if (!softlimit) 649 if (!softlimit)
655 softlimit = q->qi_bsoftlimit; 650 softlimit = q->qi_bsoftlimit;
656 btimer = INT_GET(dqp->q_core.d_btimer, ARCH_CONVERT); 651 timer = INT_GET(dqp->q_core.d_btimer, ARCH_CONVERT);
652 warns = INT_GET(dqp->q_core.d_bwarns, ARCH_CONVERT);
653 warnlimit = XFS_QI_BWARNLIMIT(dqp->q_mount);
657 resbcountp = &dqp->q_res_bcount; 654 resbcountp = &dqp->q_res_bcount;
658 } else { 655 } else {
659 ASSERT(flags & XFS_TRANS_DQ_RES_RTBLKS); 656 ASSERT(flags & XFS_TRANS_DQ_RES_RTBLKS);
@@ -663,7 +660,9 @@ xfs_trans_dqresv(
663 softlimit = INT_GET(dqp->q_core.d_rtb_softlimit, ARCH_CONVERT); 660 softlimit = INT_GET(dqp->q_core.d_rtb_softlimit, ARCH_CONVERT);
664 if (!softlimit) 661 if (!softlimit)
665 softlimit = q->qi_rtbsoftlimit; 662 softlimit = q->qi_rtbsoftlimit;
666 btimer = INT_GET(dqp->q_core.d_rtbtimer, ARCH_CONVERT); 663 timer = INT_GET(dqp->q_core.d_rtbtimer, ARCH_CONVERT);
664 warns = INT_GET(dqp->q_core.d_rtbwarns, ARCH_CONVERT);
665 warnlimit = XFS_QI_RTBWARNLIMIT(dqp->q_mount);
667 resbcountp = &dqp->q_res_rtbcount; 666 resbcountp = &dqp->q_res_rtbcount;
668 } 667 }
669 error = 0; 668 error = 0;
@@ -693,37 +692,36 @@ xfs_trans_dqresv(
693 * If timer or warnings has expired, 692 * If timer or warnings has expired,
694 * return EDQUOT 693 * return EDQUOT
695 */ 694 */
696 if ((btimer != 0 && get_seconds() > btimer) || 695 if ((timer != 0 && get_seconds() > timer) ||
697 (dqp->q_core.d_bwarns && 696 (warns != 0 && warns >= warnlimit)) {
698 INT_GET(dqp->q_core.d_bwarns, ARCH_CONVERT) >=
699 XFS_QI_BWARNLIMIT(dqp->q_mount))) {
700 error = EDQUOT; 697 error = EDQUOT;
701 goto error_return; 698 goto error_return;
702 } 699 }
703 } 700 }
704 } 701 }
705 if (ninos > 0) { 702 if (ninos > 0) {
706 hardlimit = INT_GET(dqp->q_core.d_ino_hardlimit, ARCH_CONVERT); 703 count = INT_GET(dqp->q_core.d_icount, ARCH_CONVERT);
704 timer = INT_GET(dqp->q_core.d_itimer, ARCH_CONVERT);
705 warns = INT_GET(dqp->q_core.d_iwarns, ARCH_CONVERT);
706 warnlimit = XFS_QI_IWARNLIMIT(dqp->q_mount);
707 hardlimit = INT_GET(dqp->q_core.d_ino_hardlimit,
708 ARCH_CONVERT);
707 if (!hardlimit) 709 if (!hardlimit)
708 hardlimit = q->qi_ihardlimit; 710 hardlimit = q->qi_ihardlimit;
709 softlimit = INT_GET(dqp->q_core.d_ino_softlimit, ARCH_CONVERT); 711 softlimit = INT_GET(dqp->q_core.d_ino_softlimit,
712 ARCH_CONVERT);
710 if (!softlimit) 713 if (!softlimit)
711 softlimit = q->qi_isoftlimit; 714 softlimit = q->qi_isoftlimit;
712 if (hardlimit > 0ULL && 715 if (hardlimit > 0ULL && count >= hardlimit) {
713 INT_GET(dqp->q_core.d_icount, ARCH_CONVERT) >= hardlimit) {
714 error = EDQUOT; 716 error = EDQUOT;
715 goto error_return; 717 goto error_return;
716 } else if (softlimit > 0ULL && 718 } else if (softlimit > 0ULL && count >= softlimit) {
717 INT_GET(dqp->q_core.d_icount, ARCH_CONVERT) >= softlimit) {
718 /* 719 /*
719 * If timer or warnings has expired, 720 * If timer or warnings has expired,
720 * return EDQUOT 721 * return EDQUOT
721 */ 722 */
722 if ((dqp->q_core.d_itimer && 723 if ((timer != 0 && get_seconds() > timer) ||
723 get_seconds() > INT_GET(dqp->q_core.d_itimer, ARCH_CONVERT)) || 724 (warns != 0 && warns >= warnlimit)) {
724 (dqp->q_core.d_iwarns &&
725 INT_GET(dqp->q_core.d_iwarns, ARCH_CONVERT) >=
726 XFS_QI_IWARNLIMIT(dqp->q_mount))) {
727 error = EDQUOT; 725 error = EDQUOT;
728 goto error_return; 726 goto error_return;
729 } 727 }
diff --git a/fs/xfs/support/debug.c b/fs/xfs/support/debug.c
index 7d6e1f37df10..4ed7b6928cd7 100644
--- a/fs/xfs/support/debug.c
+++ b/fs/xfs/support/debug.c
@@ -36,7 +36,6 @@
36#include <linux/sched.h> 36#include <linux/sched.h>
37#include <linux/kernel.h> 37#include <linux/kernel.h>
38 38
39int doass = 1;
40static char message[256]; /* keep it off the stack */ 39static char message[256]; /* keep it off the stack */
41static DEFINE_SPINLOCK(xfs_err_lock); 40static DEFINE_SPINLOCK(xfs_err_lock);
42 41
diff --git a/fs/xfs/support/debug.h b/fs/xfs/support/debug.h
index 40b0f4c54d9e..c5b9365a7e2a 100644
--- a/fs/xfs/support/debug.h
+++ b/fs/xfs/support/debug.h
@@ -50,16 +50,11 @@ extern void cmn_err(int, char *, ...);
50#endif 50#endif
51 51
52#ifdef DEBUG 52#ifdef DEBUG
53# ifdef lint 53# define ASSERT(EX) ((EX) ? ((void)0) : assfail(#EX, __FILE__, __LINE__))
54# define ASSERT(EX) ((void)0) /* avoid "constant in conditional" babble */
55# else
56# define ASSERT(EX) ((!doass||(EX))?((void)0):assfail(#EX, __FILE__, __LINE__))
57# endif /* lint */
58#else 54#else
59# define ASSERT(x) ((void)0) 55# define ASSERT(x) ((void)0)
60#endif 56#endif
61 57
62extern int doass; /* dynamically turn off asserts */
63extern void assfail(char *, char *, int); 58extern void assfail(char *, char *, int);
64#ifdef DEBUG 59#ifdef DEBUG
65extern unsigned long random(void); 60extern unsigned long random(void);
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c
index 36603db10fe9..dcfe19703620 100644
--- a/fs/xfs/xfs_alloc.c
+++ b/fs/xfs/xfs_alloc.c
@@ -59,7 +59,7 @@
59#define XFSA_FIXUP_BNO_OK 1 59#define XFSA_FIXUP_BNO_OK 1
60#define XFSA_FIXUP_CNT_OK 2 60#define XFSA_FIXUP_CNT_OK 2
61 61
62int 62STATIC int
63xfs_alloc_search_busy(xfs_trans_t *tp, 63xfs_alloc_search_busy(xfs_trans_t *tp,
64 xfs_agnumber_t agno, 64 xfs_agnumber_t agno,
65 xfs_agblock_t bno, 65 xfs_agblock_t bno,
@@ -2562,7 +2562,7 @@ xfs_alloc_clear_busy(xfs_trans_t *tp,
2562/* 2562/*
2563 * returns non-zero if any of (agno,bno):len is in a busy list 2563 * returns non-zero if any of (agno,bno):len is in a busy list
2564 */ 2564 */
2565int 2565STATIC int
2566xfs_alloc_search_busy(xfs_trans_t *tp, 2566xfs_alloc_search_busy(xfs_trans_t *tp,
2567 xfs_agnumber_t agno, 2567 xfs_agnumber_t agno,
2568 xfs_agblock_t bno, 2568 xfs_agblock_t bno,
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index ee8b5904ec7c..a41ad3a5e554 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -71,6 +71,11 @@
71 * Provide the external interfaces to manage attribute lists. 71 * Provide the external interfaces to manage attribute lists.
72 */ 72 */
73 73
74#define ATTR_SYSCOUNT 2
75STATIC struct attrnames posix_acl_access;
76STATIC struct attrnames posix_acl_default;
77STATIC struct attrnames *attr_system_names[ATTR_SYSCOUNT];
78
74/*======================================================================== 79/*========================================================================
75 * Function prototypes for the kernel. 80 * Function prototypes for the kernel.
76 *========================================================================*/ 81 *========================================================================*/
@@ -83,6 +88,7 @@ STATIC int xfs_attr_shortform_addname(xfs_da_args_t *args);
83/* 88/*
84 * Internal routines when attribute list is one block. 89 * Internal routines when attribute list is one block.
85 */ 90 */
91STATIC int xfs_attr_leaf_get(xfs_da_args_t *args);
86STATIC int xfs_attr_leaf_addname(xfs_da_args_t *args); 92STATIC int xfs_attr_leaf_addname(xfs_da_args_t *args);
87STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args); 93STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args);
88STATIC int xfs_attr_leaf_list(xfs_attr_list_context_t *context); 94STATIC int xfs_attr_leaf_list(xfs_attr_list_context_t *context);
@@ -90,6 +96,7 @@ STATIC int xfs_attr_leaf_list(xfs_attr_list_context_t *context);
90/* 96/*
91 * Internal routines when attribute list is more than one block. 97 * Internal routines when attribute list is more than one block.
92 */ 98 */
99STATIC int xfs_attr_node_get(xfs_da_args_t *args);
93STATIC int xfs_attr_node_addname(xfs_da_args_t *args); 100STATIC int xfs_attr_node_addname(xfs_da_args_t *args);
94STATIC int xfs_attr_node_removename(xfs_da_args_t *args); 101STATIC int xfs_attr_node_removename(xfs_da_args_t *args);
95STATIC int xfs_attr_node_list(xfs_attr_list_context_t *context); 102STATIC int xfs_attr_node_list(xfs_attr_list_context_t *context);
@@ -1102,7 +1109,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
1102 * This leaf block cannot have a "remote" value, we only call this routine 1109 * This leaf block cannot have a "remote" value, we only call this routine
1103 * if bmap_one_block() says there is only one block (ie: no remote blks). 1110 * if bmap_one_block() says there is only one block (ie: no remote blks).
1104 */ 1111 */
1105int 1112STATIC int
1106xfs_attr_leaf_get(xfs_da_args_t *args) 1113xfs_attr_leaf_get(xfs_da_args_t *args)
1107{ 1114{
1108 xfs_dabuf_t *bp; 1115 xfs_dabuf_t *bp;
@@ -1707,7 +1714,7 @@ xfs_attr_refillstate(xfs_da_state_t *state)
1707 * block, ie: both true Btree attr lists and for single-leaf-blocks with 1714 * block, ie: both true Btree attr lists and for single-leaf-blocks with
1708 * "remote" values taking up more blocks. 1715 * "remote" values taking up more blocks.
1709 */ 1716 */
1710int 1717STATIC int
1711xfs_attr_node_get(xfs_da_args_t *args) 1718xfs_attr_node_get(xfs_da_args_t *args)
1712{ 1719{
1713 xfs_da_state_t *state; 1720 xfs_da_state_t *state;
@@ -2398,7 +2405,7 @@ posix_acl_default_exists(
2398 return xfs_acl_vhasacl_default(vp); 2405 return xfs_acl_vhasacl_default(vp);
2399} 2406}
2400 2407
2401struct attrnames posix_acl_access = { 2408STATIC struct attrnames posix_acl_access = {
2402 .attr_name = "posix_acl_access", 2409 .attr_name = "posix_acl_access",
2403 .attr_namelen = sizeof("posix_acl_access") - 1, 2410 .attr_namelen = sizeof("posix_acl_access") - 1,
2404 .attr_get = posix_acl_access_get, 2411 .attr_get = posix_acl_access_get,
@@ -2407,7 +2414,7 @@ struct attrnames posix_acl_access = {
2407 .attr_exists = posix_acl_access_exists, 2414 .attr_exists = posix_acl_access_exists,
2408}; 2415};
2409 2416
2410struct attrnames posix_acl_default = { 2417STATIC struct attrnames posix_acl_default = {
2411 .attr_name = "posix_acl_default", 2418 .attr_name = "posix_acl_default",
2412 .attr_namelen = sizeof("posix_acl_default") - 1, 2419 .attr_namelen = sizeof("posix_acl_default") - 1,
2413 .attr_get = posix_acl_default_get, 2420 .attr_get = posix_acl_default_get,
@@ -2416,7 +2423,7 @@ struct attrnames posix_acl_default = {
2416 .attr_exists = posix_acl_default_exists, 2423 .attr_exists = posix_acl_default_exists,
2417}; 2424};
2418 2425
2419struct attrnames *attr_system_names[] = 2426STATIC struct attrnames *attr_system_names[] =
2420 { &posix_acl_access, &posix_acl_default }; 2427 { &posix_acl_access, &posix_acl_default };
2421 2428
2422 2429
diff --git a/fs/xfs/xfs_attr.h b/fs/xfs/xfs_attr.h
index 67cd0f5ac1a7..45ab1c542baf 100644
--- a/fs/xfs/xfs_attr.h
+++ b/fs/xfs/xfs_attr.h
@@ -76,11 +76,6 @@ extern struct attrnames attr_system;
76extern struct attrnames attr_trusted; 76extern struct attrnames attr_trusted;
77extern struct attrnames *attr_namespaces[ATTR_NAMECOUNT]; 77extern struct attrnames *attr_namespaces[ATTR_NAMECOUNT];
78 78
79#define ATTR_SYSCOUNT 2
80extern struct attrnames posix_acl_access;
81extern struct attrnames posix_acl_default;
82extern struct attrnames *attr_system_names[ATTR_SYSCOUNT];
83
84extern attrnames_t *attr_lookup_namespace(char *, attrnames_t **, int); 79extern attrnames_t *attr_lookup_namespace(char *, attrnames_t **, int);
85extern int attr_generic_list(struct vnode *, void *, size_t, int, ssize_t *); 80extern int attr_generic_list(struct vnode *, void *, size_t, int, ssize_t *);
86 81
@@ -184,8 +179,6 @@ int xfs_attr_list(bhv_desc_t *, char *, int, int,
184 struct attrlist_cursor_kern *, struct cred *); 179 struct attrlist_cursor_kern *, struct cred *);
185int xfs_attr_inactive(struct xfs_inode *dp); 180int xfs_attr_inactive(struct xfs_inode *dp);
186 181
187int xfs_attr_node_get(struct xfs_da_args *);
188int xfs_attr_leaf_get(struct xfs_da_args *);
189int xfs_attr_shortform_getvalue(struct xfs_da_args *); 182int xfs_attr_shortform_getvalue(struct xfs_da_args *);
190int xfs_attr_fetch(struct xfs_inode *, char *, int, 183int xfs_attr_fetch(struct xfs_inode *, char *, int,
191 char *, int *, int, struct cred *); 184 char *, int *, int, struct cred *);
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index b11256e58bf4..1cdd574c63a9 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -79,6 +79,8 @@
79/* 79/*
80 * Routines used for growing the Btree. 80 * Routines used for growing the Btree.
81 */ 81 */
82STATIC int xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t which_block,
83 xfs_dabuf_t **bpp);
82STATIC int xfs_attr_leaf_add_work(xfs_dabuf_t *leaf_buffer, xfs_da_args_t *args, 84STATIC int xfs_attr_leaf_add_work(xfs_dabuf_t *leaf_buffer, xfs_da_args_t *args,
83 int freemap_index); 85 int freemap_index);
84STATIC void xfs_attr_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *leaf_buffer); 86STATIC void xfs_attr_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *leaf_buffer);
@@ -92,6 +94,16 @@ STATIC int xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
92 int *number_usedbytes_in_blk1); 94 int *number_usedbytes_in_blk1);
93 95
94/* 96/*
97 * Routines used for shrinking the Btree.
98 */
99STATIC int xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp,
100 xfs_dabuf_t *bp, int level);
101STATIC int xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp,
102 xfs_dabuf_t *bp);
103STATIC int xfs_attr_leaf_freextent(xfs_trans_t **trans, xfs_inode_t *dp,
104 xfs_dablk_t blkno, int blkcnt);
105
106/*
95 * Utility routines. 107 * Utility routines.
96 */ 108 */
97STATIC void xfs_attr_leaf_moveents(xfs_attr_leafblock_t *src_leaf, 109STATIC void xfs_attr_leaf_moveents(xfs_attr_leafblock_t *src_leaf,
@@ -99,6 +111,10 @@ STATIC void xfs_attr_leaf_moveents(xfs_attr_leafblock_t *src_leaf,
99 xfs_attr_leafblock_t *dst_leaf, 111 xfs_attr_leafblock_t *dst_leaf,
100 int dst_start, int move_count, 112 int dst_start, int move_count,
101 xfs_mount_t *mp); 113 xfs_mount_t *mp);
114STATIC int xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index);
115STATIC int xfs_attr_put_listent(xfs_attr_list_context_t *context,
116 attrnames_t *, char *name, int namelen,
117 int valuelen);
102 118
103 119
104/*======================================================================== 120/*========================================================================
@@ -774,7 +790,7 @@ out:
774 * Create the initial contents of a leaf attribute list 790 * Create the initial contents of a leaf attribute list
775 * or a leaf in a node attribute list. 791 * or a leaf in a node attribute list.
776 */ 792 */
777int 793STATIC int
778xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp) 794xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp)
779{ 795{
780 xfs_attr_leafblock_t *leaf; 796 xfs_attr_leafblock_t *leaf;
@@ -2209,7 +2225,7 @@ xfs_attr_leaf_lasthash(xfs_dabuf_t *bp, int *count)
2209 * Calculate the number of bytes used to store the indicated attribute 2225 * Calculate the number of bytes used to store the indicated attribute
2210 * (whether local or remote only calculate bytes in this block). 2226 * (whether local or remote only calculate bytes in this block).
2211 */ 2227 */
2212int 2228STATIC int
2213xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index) 2229xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index)
2214{ 2230{
2215 xfs_attr_leaf_name_local_t *name_loc; 2231 xfs_attr_leaf_name_local_t *name_loc;
@@ -2380,7 +2396,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
2380 * we may be reading them directly out of a user buffer. 2396 * we may be reading them directly out of a user buffer.
2381 */ 2397 */
2382/*ARGSUSED*/ 2398/*ARGSUSED*/
2383int 2399STATIC int
2384xfs_attr_put_listent(xfs_attr_list_context_t *context, 2400xfs_attr_put_listent(xfs_attr_list_context_t *context,
2385 attrnames_t *namesp, char *name, int namelen, int valuelen) 2401 attrnames_t *namesp, char *name, int namelen, int valuelen)
2386{ 2402{
@@ -2740,7 +2756,7 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp)
2740 * Recurse (gasp!) through the attribute nodes until we find leaves. 2756 * Recurse (gasp!) through the attribute nodes until we find leaves.
2741 * We're doing a depth-first traversal in order to invalidate everything. 2757 * We're doing a depth-first traversal in order to invalidate everything.
2742 */ 2758 */
2743int 2759STATIC int
2744xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp, 2760xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
2745 int level) 2761 int level)
2746{ 2762{
@@ -2849,7 +2865,7 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
2849 * Note that we must release the lock on the buffer so that we are not 2865 * Note that we must release the lock on the buffer so that we are not
2850 * caught holding something that the logging code wants to flush to disk. 2866 * caught holding something that the logging code wants to flush to disk.
2851 */ 2867 */
2852int 2868STATIC int
2853xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp) 2869xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
2854{ 2870{
2855 xfs_attr_leafblock_t *leaf; 2871 xfs_attr_leafblock_t *leaf;
@@ -2934,7 +2950,7 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
2934 * Look at all the extents for this logical region, 2950 * Look at all the extents for this logical region,
2935 * invalidate any buffers that are incore/in transactions. 2951 * invalidate any buffers that are incore/in transactions.
2936 */ 2952 */
2937int 2953STATIC int
2938xfs_attr_leaf_freextent(xfs_trans_t **trans, xfs_inode_t *dp, 2954xfs_attr_leaf_freextent(xfs_trans_t **trans, xfs_inode_t *dp,
2939 xfs_dablk_t blkno, int blkcnt) 2955 xfs_dablk_t blkno, int blkcnt)
2940{ 2956{
diff --git a/fs/xfs/xfs_attr_leaf.h b/fs/xfs/xfs_attr_leaf.h
index b1480e0b3349..0a4cfad6df91 100644
--- a/fs/xfs/xfs_attr_leaf.h
+++ b/fs/xfs/xfs_attr_leaf.h
@@ -261,8 +261,6 @@ int xfs_attr_leaf_flipflags(xfs_da_args_t *args);
261/* 261/*
262 * Routines used for growing the Btree. 262 * Routines used for growing the Btree.
263 */ 263 */
264int xfs_attr_leaf_create(struct xfs_da_args *args, xfs_dablk_t which_block,
265 struct xfs_dabuf **bpp);
266int xfs_attr_leaf_split(struct xfs_da_state *state, 264int xfs_attr_leaf_split(struct xfs_da_state *state,
267 struct xfs_da_state_blk *oldblk, 265 struct xfs_da_state_blk *oldblk,
268 struct xfs_da_state_blk *newblk); 266 struct xfs_da_state_blk *newblk);
@@ -284,12 +282,6 @@ void xfs_attr_leaf_unbalance(struct xfs_da_state *state,
284 struct xfs_da_state_blk *drop_blk, 282 struct xfs_da_state_blk *drop_blk,
285 struct xfs_da_state_blk *save_blk); 283 struct xfs_da_state_blk *save_blk);
286int xfs_attr_root_inactive(struct xfs_trans **trans, struct xfs_inode *dp); 284int xfs_attr_root_inactive(struct xfs_trans **trans, struct xfs_inode *dp);
287int xfs_attr_node_inactive(struct xfs_trans **trans, struct xfs_inode *dp,
288 struct xfs_dabuf *bp, int level);
289int xfs_attr_leaf_inactive(struct xfs_trans **trans, struct xfs_inode *dp,
290 struct xfs_dabuf *bp);
291int xfs_attr_leaf_freextent(struct xfs_trans **trans, struct xfs_inode *dp,
292 xfs_dablk_t blkno, int blkcnt);
293 285
294/* 286/*
295 * Utility routines. 287 * Utility routines.
@@ -299,10 +291,6 @@ int xfs_attr_leaf_order(struct xfs_dabuf *leaf1_bp,
299 struct xfs_dabuf *leaf2_bp); 291 struct xfs_dabuf *leaf2_bp);
300int xfs_attr_leaf_newentsize(struct xfs_da_args *args, int blocksize, 292int xfs_attr_leaf_newentsize(struct xfs_da_args *args, int blocksize,
301 int *local); 293 int *local);
302int xfs_attr_leaf_entsize(struct xfs_attr_leafblock *leaf, int index);
303int xfs_attr_put_listent(struct xfs_attr_list_context *context,
304 struct attrnames *, char *name, int namelen,
305 int valuelen);
306int xfs_attr_rolltrans(struct xfs_trans **transp, struct xfs_inode *dp); 294int xfs_attr_rolltrans(struct xfs_trans **transp, struct xfs_inode *dp);
307 295
308#endif /* __XFS_ATTR_LEAF_H__ */ 296#endif /* __XFS_ATTR_LEAF_H__ */
diff --git a/fs/xfs/xfs_bit.c b/fs/xfs/xfs_bit.c
index a20a6c3dc13e..76c9ad3875ef 100644
--- a/fs/xfs/xfs_bit.c
+++ b/fs/xfs/xfs_bit.c
@@ -45,7 +45,7 @@
45/* 45/*
46 * Index of high bit number in byte, -1 for none set, 0..7 otherwise. 46 * Index of high bit number in byte, -1 for none set, 0..7 otherwise.
47 */ 47 */
48const char xfs_highbit[256] = { 48STATIC const char xfs_highbit[256] = {
49 -1, 0, 1, 1, 2, 2, 2, 2, /* 00 .. 07 */ 49 -1, 0, 1, 1, 2, 2, 2, 2, /* 00 .. 07 */
50 3, 3, 3, 3, 3, 3, 3, 3, /* 08 .. 0f */ 50 3, 3, 3, 3, 3, 3, 3, 3, /* 08 .. 0f */
51 4, 4, 4, 4, 4, 4, 4, 4, /* 10 .. 17 */ 51 4, 4, 4, 4, 4, 4, 4, 4, /* 10 .. 17 */
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index de3162418663..6f5d283888aa 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -301,6 +301,19 @@ xfs_bmap_search_extents(
301 xfs_bmbt_irec_t *gotp, /* out: extent entry found */ 301 xfs_bmbt_irec_t *gotp, /* out: extent entry found */
302 xfs_bmbt_irec_t *prevp); /* out: previous extent entry found */ 302 xfs_bmbt_irec_t *prevp); /* out: previous extent entry found */
303 303
304/*
305 * Check the last inode extent to determine whether this allocation will result
306 * in blocks being allocated at the end of the file. When we allocate new data
307 * blocks at the end of the file which do not start at the previous data block,
308 * we will try to align the new blocks at stripe unit boundaries.
309 */
310STATIC int /* error */
311xfs_bmap_isaeof(
312 xfs_inode_t *ip, /* incore inode pointer */
313 xfs_fileoff_t off, /* file offset in fsblocks */
314 int whichfork, /* data or attribute fork */
315 char *aeof); /* return value */
316
304#ifdef XFS_BMAP_TRACE 317#ifdef XFS_BMAP_TRACE
305/* 318/*
306 * Add a bmap trace buffer entry. Base routine for the others. 319 * Add a bmap trace buffer entry. Base routine for the others.
@@ -4532,18 +4545,17 @@ xfs_bmapi(
4532 xfs_extlen_t alen; /* allocated extent length */ 4545 xfs_extlen_t alen; /* allocated extent length */
4533 xfs_fileoff_t aoff; /* allocated file offset */ 4546 xfs_fileoff_t aoff; /* allocated file offset */
4534 xfs_bmalloca_t bma; /* args for xfs_bmap_alloc */ 4547 xfs_bmalloca_t bma; /* args for xfs_bmap_alloc */
4535 char contig; /* allocation must be one extent */
4536 xfs_btree_cur_t *cur; /* bmap btree cursor */ 4548 xfs_btree_cur_t *cur; /* bmap btree cursor */
4537 char delay; /* this request is for delayed alloc */
4538 xfs_fileoff_t end; /* end of mapped file region */ 4549 xfs_fileoff_t end; /* end of mapped file region */
4539 int eof; /* we've hit the end of extent list */ 4550 int eof; /* we've hit the end of extent list */
4551 char contig; /* allocation must be one extent */
4552 char delay; /* this request is for delayed alloc */
4553 char exact; /* don't do all of wasdelayed extent */
4540 xfs_bmbt_rec_t *ep; /* extent list entry pointer */ 4554 xfs_bmbt_rec_t *ep; /* extent list entry pointer */
4541 int error; /* error return */ 4555 int error; /* error return */
4542 char exact; /* don't do all of wasdelayed extent */
4543 xfs_bmbt_irec_t got; /* current extent list record */ 4556 xfs_bmbt_irec_t got; /* current extent list record */
4544 xfs_ifork_t *ifp; /* inode fork pointer */ 4557 xfs_ifork_t *ifp; /* inode fork pointer */
4545 xfs_extlen_t indlen; /* indirect blocks length */ 4558 xfs_extlen_t indlen; /* indirect blocks length */
4546 char inhole; /* current location is hole in file */
4547 xfs_extnum_t lastx; /* last useful extent number */ 4559 xfs_extnum_t lastx; /* last useful extent number */
4548 int logflags; /* flags for transaction logging */ 4560 int logflags; /* flags for transaction logging */
4549 xfs_extlen_t minleft; /* min blocks left after allocation */ 4561 xfs_extlen_t minleft; /* min blocks left after allocation */
@@ -4554,13 +4566,15 @@ xfs_bmapi(
4554 xfs_extnum_t nextents; /* number of extents in file */ 4566 xfs_extnum_t nextents; /* number of extents in file */
4555 xfs_fileoff_t obno; /* old block number (offset) */ 4567 xfs_fileoff_t obno; /* old block number (offset) */
4556 xfs_bmbt_irec_t prev; /* previous extent list record */ 4568 xfs_bmbt_irec_t prev; /* previous extent list record */
4557 char stateless; /* ignore state flag set */
4558 int tmp_logflags; /* temp flags holder */ 4569 int tmp_logflags; /* temp flags holder */
4570 int whichfork; /* data or attr fork */
4571 char inhole; /* current location is hole in file */
4572 char stateless; /* ignore state flag set */
4559 char trim; /* output trimmed to match range */ 4573 char trim; /* output trimmed to match range */
4560 char userdata; /* allocating non-metadata */ 4574 char userdata; /* allocating non-metadata */
4561 char wasdelay; /* old extent was delayed */ 4575 char wasdelay; /* old extent was delayed */
4562 int whichfork; /* data or attr fork */
4563 char wr; /* this is a write request */ 4576 char wr; /* this is a write request */
4577 char rt; /* this is a realtime file */
4564 char rsvd; /* OK to allocate reserved blocks */ 4578 char rsvd; /* OK to allocate reserved blocks */
4565#ifdef DEBUG 4579#ifdef DEBUG
4566 xfs_fileoff_t orig_bno; /* original block number value */ 4580 xfs_fileoff_t orig_bno; /* original block number value */
@@ -4590,6 +4604,7 @@ xfs_bmapi(
4590 } 4604 }
4591 if (XFS_FORCED_SHUTDOWN(mp)) 4605 if (XFS_FORCED_SHUTDOWN(mp))
4592 return XFS_ERROR(EIO); 4606 return XFS_ERROR(EIO);
4607 rt = XFS_IS_REALTIME_INODE(ip);
4593 ifp = XFS_IFORK_PTR(ip, whichfork); 4608 ifp = XFS_IFORK_PTR(ip, whichfork);
4594 ASSERT(ifp->if_ext_max == 4609 ASSERT(ifp->if_ext_max ==
4595 XFS_IFORK_SIZE(ip, whichfork) / (uint)sizeof(xfs_bmbt_rec_t)); 4610 XFS_IFORK_SIZE(ip, whichfork) / (uint)sizeof(xfs_bmbt_rec_t));
@@ -4694,9 +4709,16 @@ xfs_bmapi(
4694 } 4709 }
4695 minlen = contig ? alen : 1; 4710 minlen = contig ? alen : 1;
4696 if (delay) { 4711 if (delay) {
4697 indlen = (xfs_extlen_t) 4712 xfs_extlen_t extsz = 0;
4698 xfs_bmap_worst_indlen(ip, alen); 4713
4699 ASSERT(indlen > 0); 4714 /* Figure out the extent size, adjust alen */
4715 if (rt) {
4716 if (!(extsz = ip->i_d.di_extsize))
4717 extsz = mp->m_sb.sb_rextsize;
4718 alen = roundup(alen, extsz);
4719 extsz = alen / mp->m_sb.sb_rextsize;
4720 }
4721
4700 /* 4722 /*
4701 * Make a transaction-less quota reservation for 4723 * Make a transaction-less quota reservation for
4702 * delayed allocation blocks. This number gets 4724 * delayed allocation blocks. This number gets
@@ -4704,8 +4726,10 @@ xfs_bmapi(
4704 * We return EDQUOT if we haven't allocated 4726 * We return EDQUOT if we haven't allocated
4705 * blks already inside this loop; 4727 * blks already inside this loop;
4706 */ 4728 */
4707 if (XFS_TRANS_RESERVE_BLKQUOTA( 4729 if (XFS_TRANS_RESERVE_QUOTA_NBLKS(
4708 mp, NULL, ip, (long)alen)) { 4730 mp, NULL, ip, (long)alen, 0,
4731 rt ? XFS_QMOPT_RES_RTBLKS :
4732 XFS_QMOPT_RES_REGBLKS)) {
4709 if (n == 0) { 4733 if (n == 0) {
4710 *nmap = 0; 4734 *nmap = 0;
4711 ASSERT(cur == NULL); 4735 ASSERT(cur == NULL);
@@ -4718,40 +4742,34 @@ xfs_bmapi(
4718 * Split changing sb for alen and indlen since 4742 * Split changing sb for alen and indlen since
4719 * they could be coming from different places. 4743 * they could be coming from different places.
4720 */ 4744 */
4721 if (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) { 4745 indlen = (xfs_extlen_t)
4722 xfs_extlen_t extsz; 4746 xfs_bmap_worst_indlen(ip, alen);
4723 xfs_extlen_t ralen; 4747 ASSERT(indlen > 0);
4724 if (!(extsz = ip->i_d.di_extsize))
4725 extsz = mp->m_sb.sb_rextsize;
4726 ralen = roundup(alen, extsz);
4727 ralen = ralen / mp->m_sb.sb_rextsize;
4728 if (xfs_mod_incore_sb(mp,
4729 XFS_SBS_FREXTENTS,
4730 -(ralen), rsvd)) {
4731 if (XFS_IS_QUOTA_ON(ip->i_mount))
4732 XFS_TRANS_UNRESERVE_BLKQUOTA(
4733 mp, NULL, ip,
4734 (long)alen);
4735 break;
4736 }
4737 } else {
4738 if (xfs_mod_incore_sb(mp,
4739 XFS_SBS_FDBLOCKS,
4740 -(alen), rsvd)) {
4741 if (XFS_IS_QUOTA_ON(ip->i_mount))
4742 XFS_TRANS_UNRESERVE_BLKQUOTA(
4743 mp, NULL, ip,
4744 (long)alen);
4745 break;
4746 }
4747 }
4748 4748
4749 if (xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS, 4749 if (rt)
4750 -(indlen), rsvd)) { 4750 error = xfs_mod_incore_sb(mp,
4751 XFS_TRANS_UNRESERVE_BLKQUOTA( 4751 XFS_SBS_FREXTENTS,
4752 mp, NULL, ip, (long)alen); 4752 -(extsz), rsvd);
4753 else
4754 error = xfs_mod_incore_sb(mp,
4755 XFS_SBS_FDBLOCKS,
4756 -(alen), rsvd);
4757 if (!error)
4758 error = xfs_mod_incore_sb(mp,
4759 XFS_SBS_FDBLOCKS,
4760 -(indlen), rsvd);
4761
4762 if (error) {
4763 if (XFS_IS_QUOTA_ON(ip->i_mount))
4764 /* unreserve the blocks now */
4765 XFS_TRANS_UNRESERVE_QUOTA_NBLKS(
4766 mp, NULL, ip,
4767 (long)alen, 0, rt ?
4768 XFS_QMOPT_RES_RTBLKS :
4769 XFS_QMOPT_RES_REGBLKS);
4753 break; 4770 break;
4754 } 4771 }
4772
4755 ip->i_delayed_blks += alen; 4773 ip->i_delayed_blks += alen;
4756 abno = NULLSTARTBLOCK(indlen); 4774 abno = NULLSTARTBLOCK(indlen);
4757 } else { 4775 } else {
@@ -5376,13 +5394,24 @@ xfs_bunmapi(
5376 } 5394 }
5377 if (wasdel) { 5395 if (wasdel) {
5378 ASSERT(STARTBLOCKVAL(del.br_startblock) > 0); 5396 ASSERT(STARTBLOCKVAL(del.br_startblock) > 0);
5379 xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS, 5397 /* Update realtim/data freespace, unreserve quota */
5380 (int)del.br_blockcount, rsvd); 5398 if (isrt) {
5381 /* Unreserve our quota space */ 5399 xfs_filblks_t rtexts;
5382 XFS_TRANS_RESERVE_QUOTA_NBLKS( 5400
5383 mp, NULL, ip, -((long)del.br_blockcount), 0, 5401 rtexts = XFS_FSB_TO_B(mp, del.br_blockcount);
5384 isrt ? XFS_QMOPT_RES_RTBLKS : 5402 do_div(rtexts, mp->m_sb.sb_rextsize);
5403 xfs_mod_incore_sb(mp, XFS_SBS_FREXTENTS,
5404 (int)rtexts, rsvd);
5405 XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, NULL, ip,
5406 -((long)del.br_blockcount), 0,
5407 XFS_QMOPT_RES_RTBLKS);
5408 } else {
5409 xfs_mod_incore_sb(mp, XFS_SBS_FDBLOCKS,
5410 (int)del.br_blockcount, rsvd);
5411 XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, NULL, ip,
5412 -((long)del.br_blockcount), 0,
5385 XFS_QMOPT_RES_REGBLKS); 5413 XFS_QMOPT_RES_REGBLKS);
5414 }
5386 ip->i_delayed_blks -= del.br_blockcount; 5415 ip->i_delayed_blks -= del.br_blockcount;
5387 if (cur) 5416 if (cur)
5388 cur->bc_private.b.flags |= 5417 cur->bc_private.b.flags |=
@@ -5714,7 +5743,7 @@ unlock_and_return:
5714 * blocks at the end of the file which do not start at the previous data block, 5743 * blocks at the end of the file which do not start at the previous data block,
5715 * we will try to align the new blocks at stripe unit boundaries. 5744 * we will try to align the new blocks at stripe unit boundaries.
5716 */ 5745 */
5717int /* error */ 5746STATIC int /* error */
5718xfs_bmap_isaeof( 5747xfs_bmap_isaeof(
5719 xfs_inode_t *ip, /* incore inode pointer */ 5748 xfs_inode_t *ip, /* incore inode pointer */
5720 xfs_fileoff_t off, /* file offset in fsblocks */ 5749 xfs_fileoff_t off, /* file offset in fsblocks */
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h
index f1bc22fb26ae..e6d22ec9b2e4 100644
--- a/fs/xfs/xfs_bmap.h
+++ b/fs/xfs/xfs_bmap.h
@@ -332,19 +332,6 @@ xfs_getbmap(
332 int iflags); /* interface flags */ 332 int iflags); /* interface flags */
333 333
334/* 334/*
335 * Check the last inode extent to determine whether this allocation will result
336 * in blocks being allocated at the end of the file. When we allocate new data
337 * blocks at the end of the file which do not start at the previous data block,
338 * we will try to align the new blocks at stripe unit boundaries.
339 */
340int
341xfs_bmap_isaeof(
342 struct xfs_inode *ip,
343 xfs_fileoff_t off,
344 int whichfork,
345 char *aeof);
346
347/*
348 * Check if the endoff is outside the last extent. If so the caller will grow 335 * Check if the endoff is outside the last extent. If so the caller will grow
349 * the allocation to a stripe unit boundary 336 * the allocation to a stripe unit boundary
350 */ 337 */
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c
index 163305a79fcc..09c413576ba8 100644
--- a/fs/xfs/xfs_bmap_btree.c
+++ b/fs/xfs/xfs_bmap_btree.c
@@ -2331,20 +2331,6 @@ xfs_bmbt_lookup_ge(
2331 return xfs_bmbt_lookup(cur, XFS_LOOKUP_GE, stat); 2331 return xfs_bmbt_lookup(cur, XFS_LOOKUP_GE, stat);
2332} 2332}
2333 2333
2334int /* error */
2335xfs_bmbt_lookup_le(
2336 xfs_btree_cur_t *cur,
2337 xfs_fileoff_t off,
2338 xfs_fsblock_t bno,
2339 xfs_filblks_t len,
2340 int *stat) /* success/failure */
2341{
2342 cur->bc_rec.b.br_startoff = off;
2343 cur->bc_rec.b.br_startblock = bno;
2344 cur->bc_rec.b.br_blockcount = len;
2345 return xfs_bmbt_lookup(cur, XFS_LOOKUP_LE, stat);
2346}
2347
2348/* 2334/*
2349 * Give the bmap btree a new root block. Copy the old broot contents 2335 * Give the bmap btree a new root block. Copy the old broot contents
2350 * down into a real block and make the broot point to it. 2336 * down into a real block and make the broot point to it.
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h
index 843ff12b4bf2..0a40cf126c28 100644
--- a/fs/xfs/xfs_bmap_btree.h
+++ b/fs/xfs/xfs_bmap_btree.h
@@ -580,14 +580,6 @@ xfs_bmbt_lookup_ge(
580 xfs_filblks_t, 580 xfs_filblks_t,
581 int *); 581 int *);
582 582
583int
584xfs_bmbt_lookup_le(
585 struct xfs_btree_cur *,
586 xfs_fileoff_t,
587 xfs_fsblock_t,
588 xfs_filblks_t,
589 int *);
590
591/* 583/*
592 * Give the bmap btree a new root block. Copy the old broot contents 584 * Give the bmap btree a new root block. Copy the old broot contents
593 * down into a real block and make the broot point to it. 585 * down into a real block and make the broot point to it.
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c
index 9dd22dd95487..0cc63d657a14 100644
--- a/fs/xfs/xfs_btree.c
+++ b/fs/xfs/xfs_btree.c
@@ -90,6 +90,16 @@ xfs_btree_maxrecs(
90 */ 90 */
91 91
92/* 92/*
93 * Retrieve the block pointer from the cursor at the given level.
94 * This may be a bmap btree root or from a buffer.
95 */
96STATIC xfs_btree_block_t * /* generic btree block pointer */
97xfs_btree_get_block(
98 xfs_btree_cur_t *cur, /* btree cursor */
99 int level, /* level in btree */
100 struct xfs_buf **bpp); /* buffer containing the block */
101
102/*
93 * Checking routine: return maxrecs for the block. 103 * Checking routine: return maxrecs for the block.
94 */ 104 */
95STATIC int /* number of records fitting in block */ 105STATIC int /* number of records fitting in block */
@@ -497,7 +507,7 @@ xfs_btree_firstrec(
497 * Retrieve the block pointer from the cursor at the given level. 507 * Retrieve the block pointer from the cursor at the given level.
498 * This may be a bmap btree root or from a buffer. 508 * This may be a bmap btree root or from a buffer.
499 */ 509 */
500xfs_btree_block_t * /* generic btree block pointer */ 510STATIC xfs_btree_block_t * /* generic btree block pointer */
501xfs_btree_get_block( 511xfs_btree_get_block(
502 xfs_btree_cur_t *cur, /* btree cursor */ 512 xfs_btree_cur_t *cur, /* btree cursor */
503 int level, /* level in btree */ 513 int level, /* level in btree */
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h
index 93872bba41f5..09b4e1532a35 100644
--- a/fs/xfs/xfs_btree.h
+++ b/fs/xfs/xfs_btree.h
@@ -325,16 +325,6 @@ xfs_btree_firstrec(
325 int level); /* level to change */ 325 int level); /* level to change */
326 326
327/* 327/*
328 * Retrieve the block pointer from the cursor at the given level.
329 * This may be a bmap btree root or from a buffer.
330 */
331xfs_btree_block_t * /* generic btree block pointer */
332xfs_btree_get_block(
333 xfs_btree_cur_t *cur, /* btree cursor */
334 int level, /* level in btree */
335 struct xfs_buf **bpp); /* buffer containing the block */
336
337/*
338 * Get a buffer for the block, return it with no data read. 328 * Get a buffer for the block, return it with no data read.
339 * Long-form addressing. 329 * Long-form addressing.
340 */ 330 */
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 9ab0039f07df..30b8285ad476 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -172,7 +172,7 @@ STATIC void xfs_buf_do_callbacks(xfs_buf_t *bp, xfs_log_item_t *lip);
172 * 172 *
173 * If the XFS_BLI_STALE flag has been set, then log nothing. 173 * If the XFS_BLI_STALE flag has been set, then log nothing.
174 */ 174 */
175uint 175STATIC uint
176xfs_buf_item_size( 176xfs_buf_item_size(
177 xfs_buf_log_item_t *bip) 177 xfs_buf_log_item_t *bip)
178{ 178{
@@ -240,7 +240,7 @@ xfs_buf_item_size(
240 * format structure, and the rest point to contiguous chunks 240 * format structure, and the rest point to contiguous chunks
241 * within the buffer. 241 * within the buffer.
242 */ 242 */
243void 243STATIC void
244xfs_buf_item_format( 244xfs_buf_item_format(
245 xfs_buf_log_item_t *bip, 245 xfs_buf_log_item_t *bip,
246 xfs_log_iovec_t *log_vector) 246 xfs_log_iovec_t *log_vector)
@@ -365,7 +365,7 @@ xfs_buf_item_format(
365 * item in memory so it cannot be written out. Simply call bpin() 365 * item in memory so it cannot be written out. Simply call bpin()
366 * on the buffer to do this. 366 * on the buffer to do this.
367 */ 367 */
368void 368STATIC void
369xfs_buf_item_pin( 369xfs_buf_item_pin(
370 xfs_buf_log_item_t *bip) 370 xfs_buf_log_item_t *bip)
371{ 371{
@@ -391,7 +391,7 @@ xfs_buf_item_pin(
391 * If the XFS_BLI_STALE flag is set and we are the last reference, 391 * If the XFS_BLI_STALE flag is set and we are the last reference,
392 * then free up the buf log item and unlock the buffer. 392 * then free up the buf log item and unlock the buffer.
393 */ 393 */
394void 394STATIC void
395xfs_buf_item_unpin( 395xfs_buf_item_unpin(
396 xfs_buf_log_item_t *bip, 396 xfs_buf_log_item_t *bip,
397 int stale) 397 int stale)
@@ -446,7 +446,7 @@ xfs_buf_item_unpin(
446 * so we need to free the item's descriptor (that points to the item) 446 * so we need to free the item's descriptor (that points to the item)
447 * in the transaction. 447 * in the transaction.
448 */ 448 */
449void 449STATIC void
450xfs_buf_item_unpin_remove( 450xfs_buf_item_unpin_remove(
451 xfs_buf_log_item_t *bip, 451 xfs_buf_log_item_t *bip,
452 xfs_trans_t *tp) 452 xfs_trans_t *tp)
@@ -493,7 +493,7 @@ xfs_buf_item_unpin_remove(
493 * the lock right away, return 0. If we can get the lock, pull the 493 * the lock right away, return 0. If we can get the lock, pull the
494 * buffer from the free list, mark it busy, and return 1. 494 * buffer from the free list, mark it busy, and return 1.
495 */ 495 */
496uint 496STATIC uint
497xfs_buf_item_trylock( 497xfs_buf_item_trylock(
498 xfs_buf_log_item_t *bip) 498 xfs_buf_log_item_t *bip)
499{ 499{
@@ -537,7 +537,7 @@ xfs_buf_item_trylock(
537 * This is for support of xfs_trans_bhold(). Make sure the 537 * This is for support of xfs_trans_bhold(). Make sure the
538 * XFS_BLI_HOLD field is cleared if we don't free the item. 538 * XFS_BLI_HOLD field is cleared if we don't free the item.
539 */ 539 */
540void 540STATIC void
541xfs_buf_item_unlock( 541xfs_buf_item_unlock(
542 xfs_buf_log_item_t *bip) 542 xfs_buf_log_item_t *bip)
543{ 543{
@@ -635,7 +635,7 @@ xfs_buf_item_unlock(
635 * by returning the original lsn of that transaction here rather than 635 * by returning the original lsn of that transaction here rather than
636 * the current one. 636 * the current one.
637 */ 637 */
638xfs_lsn_t 638STATIC xfs_lsn_t
639xfs_buf_item_committed( 639xfs_buf_item_committed(
640 xfs_buf_log_item_t *bip, 640 xfs_buf_log_item_t *bip,
641 xfs_lsn_t lsn) 641 xfs_lsn_t lsn)
@@ -654,7 +654,7 @@ xfs_buf_item_committed(
654 * and have aborted this transaction, we'll trap this buffer when it tries to 654 * and have aborted this transaction, we'll trap this buffer when it tries to
655 * get written out. 655 * get written out.
656 */ 656 */
657void 657STATIC void
658xfs_buf_item_abort( 658xfs_buf_item_abort(
659 xfs_buf_log_item_t *bip) 659 xfs_buf_log_item_t *bip)
660{ 660{
@@ -674,7 +674,7 @@ xfs_buf_item_abort(
674 * B_DELWRI set, then get it going out to disk with a call to bawrite(). 674 * B_DELWRI set, then get it going out to disk with a call to bawrite().
675 * If not, then just release the buffer. 675 * If not, then just release the buffer.
676 */ 676 */
677void 677STATIC void
678xfs_buf_item_push( 678xfs_buf_item_push(
679 xfs_buf_log_item_t *bip) 679 xfs_buf_log_item_t *bip)
680{ 680{
@@ -693,7 +693,7 @@ xfs_buf_item_push(
693} 693}
694 694
695/* ARGSUSED */ 695/* ARGSUSED */
696void 696STATIC void
697xfs_buf_item_committing(xfs_buf_log_item_t *bip, xfs_lsn_t commit_lsn) 697xfs_buf_item_committing(xfs_buf_log_item_t *bip, xfs_lsn_t commit_lsn)
698{ 698{
699} 699}
@@ -701,7 +701,7 @@ xfs_buf_item_committing(xfs_buf_log_item_t *bip, xfs_lsn_t commit_lsn)
701/* 701/*
702 * This is the ops vector shared by all buf log items. 702 * This is the ops vector shared by all buf log items.
703 */ 703 */
704struct xfs_item_ops xfs_buf_item_ops = { 704STATIC struct xfs_item_ops xfs_buf_item_ops = {
705 .iop_size = (uint(*)(xfs_log_item_t*))xfs_buf_item_size, 705 .iop_size = (uint(*)(xfs_log_item_t*))xfs_buf_item_size,
706 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 706 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
707 xfs_buf_item_format, 707 xfs_buf_item_format,
diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
index 5f1b0c9308f6..01aed5f2d579 100644
--- a/fs/xfs/xfs_buf_item.h
+++ b/fs/xfs/xfs_buf_item.h
@@ -80,7 +80,7 @@ typedef struct xfs_buf_log_format_t {
80 * user or group dquots and may require special recovery handling. 80 * user or group dquots and may require special recovery handling.
81 */ 81 */
82#define XFS_BLI_UDQUOT_BUF 0x4 82#define XFS_BLI_UDQUOT_BUF 0x4
83/* #define XFS_BLI_PDQUOT_BUF 0x8 */ 83#define XFS_BLI_PDQUOT_BUF 0x8
84#define XFS_BLI_GDQUOT_BUF 0x10 84#define XFS_BLI_GDQUOT_BUF 0x10
85 85
86#define XFS_BLI_CHUNK 128 86#define XFS_BLI_CHUNK 128
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index d7fe28866764..8b792ddf2164 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -113,7 +113,10 @@ STATIC void xfs_da_node_unbalance(xfs_da_state_t *state,
113STATIC uint xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count); 113STATIC uint xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count);
114STATIC int xfs_da_node_order(xfs_dabuf_t *node1_bp, xfs_dabuf_t *node2_bp); 114STATIC int xfs_da_node_order(xfs_dabuf_t *node1_bp, xfs_dabuf_t *node2_bp);
115STATIC xfs_dabuf_t *xfs_da_buf_make(int nbuf, xfs_buf_t **bps, inst_t *ra); 115STATIC xfs_dabuf_t *xfs_da_buf_make(int nbuf, xfs_buf_t **bps, inst_t *ra);
116 116STATIC int xfs_da_blk_unlink(xfs_da_state_t *state,
117 xfs_da_state_blk_t *drop_blk,
118 xfs_da_state_blk_t *save_blk);
119STATIC void xfs_da_state_kill_altpath(xfs_da_state_t *state);
117 120
118/*======================================================================== 121/*========================================================================
119 * Routines used for growing the Btree. 122 * Routines used for growing the Btree.
@@ -1424,7 +1427,7 @@ xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count)
1424/* 1427/*
1425 * Unlink a block from a doubly linked list of blocks. 1428 * Unlink a block from a doubly linked list of blocks.
1426 */ 1429 */
1427int /* error */ 1430STATIC int /* error */
1428xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, 1431xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1429 xfs_da_state_blk_t *save_blk) 1432 xfs_da_state_blk_t *save_blk)
1430{ 1433{
@@ -2381,7 +2384,7 @@ xfs_da_state_alloc(void)
2381/* 2384/*
2382 * Kill the altpath contents of a da-state structure. 2385 * Kill the altpath contents of a da-state structure.
2383 */ 2386 */
2384void 2387STATIC void
2385xfs_da_state_kill_altpath(xfs_da_state_t *state) 2388xfs_da_state_kill_altpath(xfs_da_state_t *state)
2386{ 2389{
2387 int i; 2390 int i;
diff --git a/fs/xfs/xfs_da_btree.h b/fs/xfs/xfs_da_btree.h
index 9fc699d96995..3a9b9e809c60 100644
--- a/fs/xfs/xfs_da_btree.h
+++ b/fs/xfs/xfs_da_btree.h
@@ -296,8 +296,6 @@ int xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
296/* 296/*
297 * Utility routines. 297 * Utility routines.
298 */ 298 */
299int xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
300 xfs_da_state_blk_t *save_blk);
301int xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk, 299int xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
302 xfs_da_state_blk_t *new_blk); 300 xfs_da_state_blk_t *new_blk);
303 301
@@ -320,7 +318,6 @@ uint xfs_da_hashname(uchar_t *name_string, int name_length);
320uint xfs_da_log2_roundup(uint i); 318uint xfs_da_log2_roundup(uint i);
321xfs_da_state_t *xfs_da_state_alloc(void); 319xfs_da_state_t *xfs_da_state_alloc(void);
322void xfs_da_state_free(xfs_da_state_t *state); 320void xfs_da_state_free(xfs_da_state_t *state);
323void xfs_da_state_kill_altpath(xfs_da_state_t *state);
324 321
325void xfs_da_buf_done(xfs_dabuf_t *dabuf); 322void xfs_da_buf_done(xfs_dabuf_t *dabuf);
326void xfs_da_log_buf(struct xfs_trans *tp, xfs_dabuf_t *dabuf, uint first, 323void xfs_da_log_buf(struct xfs_trans *tp, xfs_dabuf_t *dabuf, uint first,
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c
index 63abdc2ac7f4..681be5c93af5 100644
--- a/fs/xfs/xfs_dfrag.c
+++ b/fs/xfs/xfs_dfrag.c
@@ -180,9 +180,10 @@ xfs_swapext(
180 goto error0; 180 goto error0;
181 } 181 }
182 182
183 if (VN_CACHED(tvp) != 0) 183 if (VN_CACHED(tvp) != 0) {
184 xfs_inval_cached_pages(XFS_ITOV(tip), &(tip->i_iocore), 184 xfs_inval_cached_trace(&tip->i_iocore, 0, -1, 0, -1);
185 (xfs_off_t)0, 0, 0); 185 VOP_FLUSHINVAL_PAGES(tvp, 0, -1, FI_REMAPF_LOCKED);
186 }
186 187
187 /* Verify O_DIRECT for ftmp */ 188 /* Verify O_DIRECT for ftmp */
188 if (VN_CACHED(tvp) != 0) { 189 if (VN_CACHED(tvp) != 0) {
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c
index db9887a107de..a0aa0e44ff9d 100644
--- a/fs/xfs/xfs_dir2_data.c
+++ b/fs/xfs/xfs_dir2_data.c
@@ -304,7 +304,7 @@ xfs_dir2_data_freeinsert(
304/* 304/*
305 * Remove a bestfree entry from the table. 305 * Remove a bestfree entry from the table.
306 */ 306 */
307void 307STATIC void
308xfs_dir2_data_freeremove( 308xfs_dir2_data_freeremove(
309 xfs_dir2_data_t *d, /* data block pointer */ 309 xfs_dir2_data_t *d, /* data block pointer */
310 xfs_dir2_data_free_t *dfp, /* bestfree entry pointer */ 310 xfs_dir2_data_free_t *dfp, /* bestfree entry pointer */
diff --git a/fs/xfs/xfs_dir2_data.h b/fs/xfs/xfs_dir2_data.h
index 3f02294ccff0..476cac920bf5 100644
--- a/fs/xfs/xfs_dir2_data.h
+++ b/fs/xfs/xfs_dir2_data.h
@@ -193,10 +193,6 @@ extern xfs_dir2_data_free_t *
193 xfs_dir2_data_unused_t *dup, int *loghead); 193 xfs_dir2_data_unused_t *dup, int *loghead);
194 194
195extern void 195extern void
196 xfs_dir2_data_freeremove(xfs_dir2_data_t *d,
197 xfs_dir2_data_free_t *dfp, int *loghead);
198
199extern void
200 xfs_dir2_data_freescan(struct xfs_mount *mp, xfs_dir2_data_t *d, 196 xfs_dir2_data_freescan(struct xfs_mount *mp, xfs_dir2_data_t *d,
201 int *loghead, char *aendp); 197 int *loghead, char *aendp);
202 198
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index 262d1e86df30..056f5283904b 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -77,6 +77,10 @@ static void xfs_dir2_leaf_check(xfs_inode_t *dp, xfs_dabuf_t *bp);
77#endif 77#endif
78static int xfs_dir2_leaf_lookup_int(xfs_da_args_t *args, xfs_dabuf_t **lbpp, 78static int xfs_dir2_leaf_lookup_int(xfs_da_args_t *args, xfs_dabuf_t **lbpp,
79 int *indexp, xfs_dabuf_t **dbpp); 79 int *indexp, xfs_dabuf_t **dbpp);
80static void xfs_dir2_leaf_log_bests(struct xfs_trans *tp, struct xfs_dabuf *bp,
81 int first, int last);
82static void xfs_dir2_leaf_log_tail(struct xfs_trans *tp, struct xfs_dabuf *bp);
83
80 84
81/* 85/*
82 * Convert a block form directory to a leaf form directory. 86 * Convert a block form directory to a leaf form directory.
@@ -1214,7 +1218,7 @@ xfs_dir2_leaf_init(
1214/* 1218/*
1215 * Log the bests entries indicated from a leaf1 block. 1219 * Log the bests entries indicated from a leaf1 block.
1216 */ 1220 */
1217void 1221static void
1218xfs_dir2_leaf_log_bests( 1222xfs_dir2_leaf_log_bests(
1219 xfs_trans_t *tp, /* transaction pointer */ 1223 xfs_trans_t *tp, /* transaction pointer */
1220 xfs_dabuf_t *bp, /* leaf buffer */ 1224 xfs_dabuf_t *bp, /* leaf buffer */
@@ -1278,7 +1282,7 @@ xfs_dir2_leaf_log_header(
1278/* 1282/*
1279 * Log the tail of the leaf1 block. 1283 * Log the tail of the leaf1 block.
1280 */ 1284 */
1281void 1285STATIC void
1282xfs_dir2_leaf_log_tail( 1286xfs_dir2_leaf_log_tail(
1283 xfs_trans_t *tp, /* transaction pointer */ 1287 xfs_trans_t *tp, /* transaction pointer */
1284 xfs_dabuf_t *bp) /* leaf buffer */ 1288 xfs_dabuf_t *bp) /* leaf buffer */
diff --git a/fs/xfs/xfs_dir2_leaf.h b/fs/xfs/xfs_dir2_leaf.h
index 7f20eee56a52..3303cd6f4c00 100644
--- a/fs/xfs/xfs_dir2_leaf.h
+++ b/fs/xfs/xfs_dir2_leaf.h
@@ -330,15 +330,8 @@ extern void
330 int first, int last); 330 int first, int last);
331 331
332extern void 332extern void
333 xfs_dir2_leaf_log_bests(struct xfs_trans *tp, struct xfs_dabuf *bp,
334 int first, int last);
335
336extern void
337 xfs_dir2_leaf_log_header(struct xfs_trans *tp, struct xfs_dabuf *bp); 333 xfs_dir2_leaf_log_header(struct xfs_trans *tp, struct xfs_dabuf *bp);
338 334
339extern void
340 xfs_dir2_leaf_log_tail(struct xfs_trans *tp, struct xfs_dabuf *bp);
341
342extern int 335extern int
343 xfs_dir2_leaf_lookup(struct xfs_da_args *args); 336 xfs_dir2_leaf_lookup(struct xfs_da_args *args);
344 337
diff --git a/fs/xfs/xfs_dir_leaf.c b/fs/xfs/xfs_dir_leaf.c
index 617018d6bbdc..c2ea6171fb0e 100644
--- a/fs/xfs/xfs_dir_leaf.c
+++ b/fs/xfs/xfs_dir_leaf.c
@@ -91,6 +91,10 @@ STATIC int xfs_dir_leaf_figure_balance(xfs_da_state_t *state,
91 int *number_entries_in_blk1, 91 int *number_entries_in_blk1,
92 int *number_namebytes_in_blk1); 92 int *number_namebytes_in_blk1);
93 93
94STATIC int xfs_dir_leaf_create(struct xfs_da_args *args,
95 xfs_dablk_t which_block,
96 struct xfs_dabuf **bpp);
97
94/* 98/*
95 * Utility routines. 99 * Utility routines.
96 */ 100 */
@@ -781,7 +785,7 @@ xfs_dir_leaf_to_node(xfs_da_args_t *args)
781 * Create the initial contents of a leaf directory 785 * Create the initial contents of a leaf directory
782 * or a leaf in a node directory. 786 * or a leaf in a node directory.
783 */ 787 */
784int 788STATIC int
785xfs_dir_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp) 789xfs_dir_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp)
786{ 790{
787 xfs_dir_leafblock_t *leaf; 791 xfs_dir_leafblock_t *leaf;
diff --git a/fs/xfs/xfs_dir_leaf.h b/fs/xfs/xfs_dir_leaf.h
index 00d68d33cc7a..dd423ce1bc8d 100644
--- a/fs/xfs/xfs_dir_leaf.h
+++ b/fs/xfs/xfs_dir_leaf.h
@@ -202,8 +202,6 @@ int xfs_dir_leaf_to_shortform(struct xfs_da_args *args);
202/* 202/*
203 * Routines used for growing the Btree. 203 * Routines used for growing the Btree.
204 */ 204 */
205int xfs_dir_leaf_create(struct xfs_da_args *args, xfs_dablk_t which_block,
206 struct xfs_dabuf **bpp);
207int xfs_dir_leaf_split(struct xfs_da_state *state, 205int xfs_dir_leaf_split(struct xfs_da_state *state,
208 struct xfs_da_state_blk *oldblk, 206 struct xfs_da_state_blk *oldblk,
209 struct xfs_da_state_blk *newblk); 207 struct xfs_da_state_blk *newblk);
diff --git a/fs/xfs/xfs_dmapi.h b/fs/xfs/xfs_dmapi.h
index 55ae3e67d245..55c17adaaa37 100644
--- a/fs/xfs/xfs_dmapi.h
+++ b/fs/xfs/xfs_dmapi.h
@@ -166,27 +166,32 @@ typedef enum {
166#define DM_FLAGS_NDELAY 0x001 /* return EAGAIN after dm_pending() */ 166#define DM_FLAGS_NDELAY 0x001 /* return EAGAIN after dm_pending() */
167#define DM_FLAGS_UNWANTED 0x002 /* event not in fsys dm_eventset_t */ 167#define DM_FLAGS_UNWANTED 0x002 /* event not in fsys dm_eventset_t */
168#define DM_FLAGS_ISEM 0x004 /* thread holds i_sem */ 168#define DM_FLAGS_ISEM 0x004 /* thread holds i_sem */
169#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
170#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,21)
171/* i_alloc_sem was added in 2.4.22-pre1 */
172#define DM_FLAGS_IALLOCSEM_RD 0x010 /* thread holds i_alloc_sem rd */ 169#define DM_FLAGS_IALLOCSEM_RD 0x010 /* thread holds i_alloc_sem rd */
173#define DM_FLAGS_IALLOCSEM_WR 0x020 /* thread holds i_alloc_sem wr */ 170#define DM_FLAGS_IALLOCSEM_WR 0x020 /* thread holds i_alloc_sem wr */
174#endif
175#endif
176 171
177/* 172/*
178 * Based on IO_ISDIRECT, decide which i_ flag is set. 173 * Based on IO_ISDIRECT, decide which i_ flag is set.
179 */ 174 */
180#ifdef DM_FLAGS_IALLOCSEM_RD 175#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
176#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
177 DM_FLAGS_ISEM : 0)
178#define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_ISEM)
179#endif
180
181#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) && \
182 (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,22))
181#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \ 183#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
182 DM_FLAGS_IALLOCSEM_RD : DM_FLAGS_ISEM) 184 DM_FLAGS_IALLOCSEM_RD : DM_FLAGS_ISEM)
183#define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_ISEM) 185#define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_ISEM)
184#else 186#endif
187
188#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,21)
185#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \ 189#define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
186 0 : DM_FLAGS_ISEM) 190 0 : DM_FLAGS_ISEM)
187#define DM_SEM_FLAG_WR (DM_FLAGS_ISEM) 191#define DM_SEM_FLAG_WR (DM_FLAGS_ISEM)
188#endif 192#endif
189 193
194
190/* 195/*
191 * Macros to turn caller specified delay/block flags into 196 * Macros to turn caller specified delay/block flags into
192 * dm_send_xxxx_event flag DM_FLAGS_NDELAY. 197 * dm_send_xxxx_event flag DM_FLAGS_NDELAY.
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index bbe1dea11c08..dcd3fdd5c1f7 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -280,7 +280,7 @@ xfs_error_report(
280 } 280 }
281} 281}
282 282
283void 283STATIC void
284xfs_hex_dump(void *p, int length) 284xfs_hex_dump(void *p, int length)
285{ 285{
286 __uint8_t *uip = (__uint8_t*)p; 286 __uint8_t *uip = (__uint8_t*)p;
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
index 6bc0535c0a65..52ee2b90b5ed 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -73,9 +73,6 @@ xfs_corruption_error(
73 int linenum, 73 int linenum,
74 inst_t *ra); 74 inst_t *ra);
75 75
76extern void
77xfs_hex_dump(void *p, int length);
78
79#define XFS_ERROR_REPORT(e, lvl, mp) \ 76#define XFS_ERROR_REPORT(e, lvl, mp) \
80 xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address) 77 xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address)
81#define XFS_CORRUPTION_ERROR(e, lvl, mp, mem) \ 78#define XFS_CORRUPTION_ERROR(e, lvl, mp, mem) \
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index 5eafd5b63211..db7cbd1bc857 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -59,6 +59,18 @@ STATIC void xfs_efi_item_abort(xfs_efi_log_item_t *);
59STATIC void xfs_efd_item_abort(xfs_efd_log_item_t *); 59STATIC void xfs_efd_item_abort(xfs_efd_log_item_t *);
60 60
61 61
62void
63xfs_efi_item_free(xfs_efi_log_item_t *efip)
64{
65 int nexts = efip->efi_format.efi_nextents;
66
67 if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
68 kmem_free(efip, sizeof(xfs_efi_log_item_t) +
69 (nexts - 1) * sizeof(xfs_extent_t));
70 } else {
71 kmem_zone_free(xfs_efi_zone, efip);
72 }
73}
62 74
63/* 75/*
64 * This returns the number of iovecs needed to log the given efi item. 76 * This returns the number of iovecs needed to log the given efi item.
@@ -120,8 +132,6 @@ xfs_efi_item_pin(xfs_efi_log_item_t *efip)
120STATIC void 132STATIC void
121xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale) 133xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale)
122{ 134{
123 int nexts;
124 int size;
125 xfs_mount_t *mp; 135 xfs_mount_t *mp;
126 SPLDECL(s); 136 SPLDECL(s);
127 137
@@ -132,21 +142,11 @@ xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale)
132 * xfs_trans_delete_ail() drops the AIL lock. 142 * xfs_trans_delete_ail() drops the AIL lock.
133 */ 143 */
134 xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s); 144 xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
135 145 xfs_efi_item_free(efip);
136 nexts = efip->efi_format.efi_nextents;
137 if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
138 size = sizeof(xfs_efi_log_item_t);
139 size += (nexts - 1) * sizeof(xfs_extent_t);
140 kmem_free(efip, size);
141 } else {
142 kmem_zone_free(xfs_efi_zone, efip);
143 }
144 } else { 146 } else {
145 efip->efi_flags |= XFS_EFI_COMMITTED; 147 efip->efi_flags |= XFS_EFI_COMMITTED;
146 AIL_UNLOCK(mp, s); 148 AIL_UNLOCK(mp, s);
147 } 149 }
148
149 return;
150} 150}
151 151
152/* 152/*
@@ -159,8 +159,6 @@ xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale)
159STATIC void 159STATIC void
160xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp) 160xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp)
161{ 161{
162 int nexts;
163 int size;
164 xfs_mount_t *mp; 162 xfs_mount_t *mp;
165 xfs_log_item_desc_t *lidp; 163 xfs_log_item_desc_t *lidp;
166 SPLDECL(s); 164 SPLDECL(s);
@@ -178,23 +176,11 @@ xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp)
178 * xfs_trans_delete_ail() drops the AIL lock. 176 * xfs_trans_delete_ail() drops the AIL lock.
179 */ 177 */
180 xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s); 178 xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
181 /* 179 xfs_efi_item_free(efip);
182 * now free the item itself
183 */
184 nexts = efip->efi_format.efi_nextents;
185 if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
186 size = sizeof(xfs_efi_log_item_t);
187 size += (nexts - 1) * sizeof(xfs_extent_t);
188 kmem_free(efip, size);
189 } else {
190 kmem_zone_free(xfs_efi_zone, efip);
191 }
192 } else { 180 } else {
193 efip->efi_flags |= XFS_EFI_COMMITTED; 181 efip->efi_flags |= XFS_EFI_COMMITTED;
194 AIL_UNLOCK(mp, s); 182 AIL_UNLOCK(mp, s);
195 } 183 }
196
197 return;
198} 184}
199 185
200/* 186/*
@@ -245,18 +231,7 @@ xfs_efi_item_committed(xfs_efi_log_item_t *efip, xfs_lsn_t lsn)
245STATIC void 231STATIC void
246xfs_efi_item_abort(xfs_efi_log_item_t *efip) 232xfs_efi_item_abort(xfs_efi_log_item_t *efip)
247{ 233{
248 int nexts; 234 xfs_efi_item_free(efip);
249 int size;
250
251 nexts = efip->efi_format.efi_nextents;
252 if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
253 size = sizeof(xfs_efi_log_item_t);
254 size += (nexts - 1) * sizeof(xfs_extent_t);
255 kmem_free(efip, size);
256 } else {
257 kmem_zone_free(xfs_efi_zone, efip);
258 }
259 return;
260} 235}
261 236
262/* 237/*
@@ -288,7 +263,7 @@ xfs_efi_item_committing(xfs_efi_log_item_t *efip, xfs_lsn_t lsn)
288/* 263/*
289 * This is the ops vector shared by all efi log items. 264 * This is the ops vector shared by all efi log items.
290 */ 265 */
291struct xfs_item_ops xfs_efi_item_ops = { 266STATIC struct xfs_item_ops xfs_efi_item_ops = {
292 .iop_size = (uint(*)(xfs_log_item_t*))xfs_efi_item_size, 267 .iop_size = (uint(*)(xfs_log_item_t*))xfs_efi_item_size,
293 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 268 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
294 xfs_efi_item_format, 269 xfs_efi_item_format,
@@ -355,8 +330,6 @@ xfs_efi_release(xfs_efi_log_item_t *efip,
355{ 330{
356 xfs_mount_t *mp; 331 xfs_mount_t *mp;
357 int extents_left; 332 int extents_left;
358 uint size;
359 int nexts;
360 SPLDECL(s); 333 SPLDECL(s);
361 334
362 mp = efip->efi_item.li_mountp; 335 mp = efip->efi_item.li_mountp;
@@ -372,20 +345,10 @@ xfs_efi_release(xfs_efi_log_item_t *efip,
372 * xfs_trans_delete_ail() drops the AIL lock. 345 * xfs_trans_delete_ail() drops the AIL lock.
373 */ 346 */
374 xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s); 347 xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
348 xfs_efi_item_free(efip);
375 } else { 349 } else {
376 AIL_UNLOCK(mp, s); 350 AIL_UNLOCK(mp, s);
377 } 351 }
378
379 if (extents_left == 0) {
380 nexts = efip->efi_format.efi_nextents;
381 if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
382 size = sizeof(xfs_efi_log_item_t);
383 size += (nexts - 1) * sizeof(xfs_extent_t);
384 kmem_free(efip, size);
385 } else {
386 kmem_zone_free(xfs_efi_zone, efip);
387 }
388 }
389} 352}
390 353
391/* 354/*
@@ -398,8 +361,6 @@ STATIC void
398xfs_efi_cancel( 361xfs_efi_cancel(
399 xfs_efi_log_item_t *efip) 362 xfs_efi_log_item_t *efip)
400{ 363{
401 int nexts;
402 int size;
403 xfs_mount_t *mp; 364 xfs_mount_t *mp;
404 SPLDECL(s); 365 SPLDECL(s);
405 366
@@ -410,26 +371,25 @@ xfs_efi_cancel(
410 * xfs_trans_delete_ail() drops the AIL lock. 371 * xfs_trans_delete_ail() drops the AIL lock.
411 */ 372 */
412 xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s); 373 xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
413 374 xfs_efi_item_free(efip);
414 nexts = efip->efi_format.efi_nextents;
415 if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
416 size = sizeof(xfs_efi_log_item_t);
417 size += (nexts - 1) * sizeof(xfs_extent_t);
418 kmem_free(efip, size);
419 } else {
420 kmem_zone_free(xfs_efi_zone, efip);
421 }
422 } else { 375 } else {
423 efip->efi_flags |= XFS_EFI_CANCELED; 376 efip->efi_flags |= XFS_EFI_CANCELED;
424 AIL_UNLOCK(mp, s); 377 AIL_UNLOCK(mp, s);
425 } 378 }
426
427 return;
428} 379}
429 380
381STATIC void
382xfs_efd_item_free(xfs_efd_log_item_t *efdp)
383{
384 int nexts = efdp->efd_format.efd_nextents;
430 385
431 386 if (nexts > XFS_EFD_MAX_FAST_EXTENTS) {
432 387 kmem_free(efdp, sizeof(xfs_efd_log_item_t) +
388 (nexts - 1) * sizeof(xfs_extent_t));
389 } else {
390 kmem_zone_free(xfs_efd_zone, efdp);
391 }
392}
433 393
434/* 394/*
435 * This returns the number of iovecs needed to log the given efd item. 395 * This returns the number of iovecs needed to log the given efd item.
@@ -533,9 +493,6 @@ xfs_efd_item_unlock(xfs_efd_log_item_t *efdp)
533STATIC xfs_lsn_t 493STATIC xfs_lsn_t
534xfs_efd_item_committed(xfs_efd_log_item_t *efdp, xfs_lsn_t lsn) 494xfs_efd_item_committed(xfs_efd_log_item_t *efdp, xfs_lsn_t lsn)
535{ 495{
536 uint size;
537 int nexts;
538
539 /* 496 /*
540 * If we got a log I/O error, it's always the case that the LR with the 497 * If we got a log I/O error, it's always the case that the LR with the
541 * EFI got unpinned and freed before the EFD got aborted. 498 * EFI got unpinned and freed before the EFD got aborted.
@@ -543,15 +500,7 @@ xfs_efd_item_committed(xfs_efd_log_item_t *efdp, xfs_lsn_t lsn)
543 if ((efdp->efd_item.li_flags & XFS_LI_ABORTED) == 0) 500 if ((efdp->efd_item.li_flags & XFS_LI_ABORTED) == 0)
544 xfs_efi_release(efdp->efd_efip, efdp->efd_format.efd_nextents); 501 xfs_efi_release(efdp->efd_efip, efdp->efd_format.efd_nextents);
545 502
546 nexts = efdp->efd_format.efd_nextents; 503 xfs_efd_item_free(efdp);
547 if (nexts > XFS_EFD_MAX_FAST_EXTENTS) {
548 size = sizeof(xfs_efd_log_item_t);
549 size += (nexts - 1) * sizeof(xfs_extent_t);
550 kmem_free(efdp, size);
551 } else {
552 kmem_zone_free(xfs_efd_zone, efdp);
553 }
554
555 return (xfs_lsn_t)-1; 504 return (xfs_lsn_t)-1;
556} 505}
557 506
@@ -565,9 +514,6 @@ xfs_efd_item_committed(xfs_efd_log_item_t *efdp, xfs_lsn_t lsn)
565STATIC void 514STATIC void
566xfs_efd_item_abort(xfs_efd_log_item_t *efdp) 515xfs_efd_item_abort(xfs_efd_log_item_t *efdp)
567{ 516{
568 int nexts;
569 int size;
570
571 /* 517 /*
572 * If we got a log I/O error, it's always the case that the LR with the 518 * If we got a log I/O error, it's always the case that the LR with the
573 * EFI got unpinned and freed before the EFD got aborted. So don't 519 * EFI got unpinned and freed before the EFD got aborted. So don't
@@ -576,15 +522,7 @@ xfs_efd_item_abort(xfs_efd_log_item_t *efdp)
576 if ((efdp->efd_item.li_flags & XFS_LI_ABORTED) == 0) 522 if ((efdp->efd_item.li_flags & XFS_LI_ABORTED) == 0)
577 xfs_efi_cancel(efdp->efd_efip); 523 xfs_efi_cancel(efdp->efd_efip);
578 524
579 nexts = efdp->efd_format.efd_nextents; 525 xfs_efd_item_free(efdp);
580 if (nexts > XFS_EFD_MAX_FAST_EXTENTS) {
581 size = sizeof(xfs_efd_log_item_t);
582 size += (nexts - 1) * sizeof(xfs_extent_t);
583 kmem_free(efdp, size);
584 } else {
585 kmem_zone_free(xfs_efd_zone, efdp);
586 }
587 return;
588} 526}
589 527
590/* 528/*
@@ -615,7 +553,7 @@ xfs_efd_item_committing(xfs_efd_log_item_t *efip, xfs_lsn_t lsn)
615/* 553/*
616 * This is the ops vector shared by all efd log items. 554 * This is the ops vector shared by all efd log items.
617 */ 555 */
618struct xfs_item_ops xfs_efd_item_ops = { 556STATIC struct xfs_item_ops xfs_efd_item_ops = {
619 .iop_size = (uint(*)(xfs_log_item_t*))xfs_efd_item_size, 557 .iop_size = (uint(*)(xfs_log_item_t*))xfs_efd_item_size,
620 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 558 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
621 xfs_efd_item_format, 559 xfs_efd_item_format,
diff --git a/fs/xfs/xfs_extfree_item.h b/fs/xfs/xfs_extfree_item.h
index 7122d6101d15..d433bac9f59d 100644
--- a/fs/xfs/xfs_extfree_item.h
+++ b/fs/xfs/xfs_extfree_item.h
@@ -118,6 +118,8 @@ xfs_efi_log_item_t *xfs_efi_init(struct xfs_mount *, uint);
118xfs_efd_log_item_t *xfs_efd_init(struct xfs_mount *, xfs_efi_log_item_t *, 118xfs_efd_log_item_t *xfs_efd_init(struct xfs_mount *, xfs_efi_log_item_t *,
119 uint); 119 uint);
120 120
121void xfs_efi_item_free(xfs_efi_log_item_t *);
122
121#endif /* __KERNEL__ */ 123#endif /* __KERNEL__ */
122 124
123#endif /* __XFS_EXTFREE_ITEM_H__ */ 125#endif /* __XFS_EXTFREE_ITEM_H__ */
diff --git a/fs/xfs/xfs_fs.h b/fs/xfs/xfs_fs.h
index 6ee8443bf9d3..095af0a5cff3 100644
--- a/fs/xfs/xfs_fs.h
+++ b/fs/xfs/xfs_fs.h
@@ -60,7 +60,8 @@ struct fsxattr {
60 __u32 fsx_xflags; /* xflags field value (get/set) */ 60 __u32 fsx_xflags; /* xflags field value (get/set) */
61 __u32 fsx_extsize; /* extsize field value (get/set)*/ 61 __u32 fsx_extsize; /* extsize field value (get/set)*/
62 __u32 fsx_nextents; /* nextents field value (get) */ 62 __u32 fsx_nextents; /* nextents field value (get) */
63 unsigned char fsx_pad[16]; 63 __u32 fsx_projid; /* project identifier (get/set) */
64 unsigned char fsx_pad[12];
64}; 65};
65#endif 66#endif
66 67
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 21213057c27f..ca535d613190 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -559,32 +559,6 @@ xfs_reserve_blocks(
559 return(0); 559 return(0);
560} 560}
561 561
562void
563xfs_fs_log_dummy(xfs_mount_t *mp)
564{
565 xfs_trans_t *tp;
566 xfs_inode_t *ip;
567
568
569 tp = _xfs_trans_alloc(mp, XFS_TRANS_DUMMY1);
570 atomic_inc(&mp->m_active_trans);
571 if (xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0)) {
572 xfs_trans_cancel(tp, 0);
573 return;
574 }
575
576 ip = mp->m_rootip;
577 xfs_ilock(ip, XFS_ILOCK_EXCL);
578
579 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
580 xfs_trans_ihold(tp, ip);
581 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
582 xfs_trans_set_sync(tp);
583 xfs_trans_commit(tp, 0, NULL);
584
585 xfs_iunlock(ip, XFS_ILOCK_EXCL);
586}
587
588int 562int
589xfs_fs_goingdown( 563xfs_fs_goingdown(
590 xfs_mount_t *mp, 564 xfs_mount_t *mp,
diff --git a/fs/xfs/xfs_ialloc_btree.h b/fs/xfs/xfs_ialloc_btree.h
index 803c4d17a057..44be188674a6 100644
--- a/fs/xfs/xfs_ialloc_btree.h
+++ b/fs/xfs/xfs_ialloc_btree.h
@@ -100,9 +100,13 @@ xfs_inofree_t xfs_inobt_mask(int i);
100#endif 100#endif
101#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_IS_FREE) 101#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_IS_FREE)
102int xfs_inobt_is_free(xfs_inobt_rec_t *rp, int i); 102int xfs_inobt_is_free(xfs_inobt_rec_t *rp, int i);
103#define XFS_INOBT_IS_FREE(rp,i) xfs_inobt_is_free(rp,i) 103#define XFS_INOBT_IS_FREE(rp,i) xfs_inobt_is_free(rp,i)
104#define XFS_INOBT_IS_FREE_DISK(rp,i) xfs_inobt_is_free_disk(rp,i)
104#else 105#else
105#define XFS_INOBT_IS_FREE(rp,i) (((rp)->ir_free & XFS_INOBT_MASK(i)) != 0) 106#define XFS_INOBT_IS_FREE(rp,i) \
107 (((rp)->ir_free & XFS_INOBT_MASK(i)) != 0)
108#define XFS_INOBT_IS_FREE_DISK(rp,i) \
109 ((INT_GET((rp)->ir_free, ARCH_CONVERT) & XFS_INOBT_MASK(i)) != 0)
106#endif 110#endif
107#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_SET_FREE) 111#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_INOBT_SET_FREE)
108void xfs_inobt_set_free(xfs_inobt_rec_t *rp, int i); 112void xfs_inobt_set_free(xfs_inobt_rec_t *rp, int i);
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index bc8c8c7f9039..34bdf5909687 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -146,51 +146,6 @@ xfs_inobp_check(
146#endif 146#endif
147 147
148/* 148/*
149 * called from bwrite on xfs inode buffers
150 */
151void
152xfs_inobp_bwcheck(xfs_buf_t *bp)
153{
154 xfs_mount_t *mp;
155 int i;
156 int j;
157 xfs_dinode_t *dip;
158
159 ASSERT(XFS_BUF_FSPRIVATE3(bp, void *) != NULL);
160
161 mp = XFS_BUF_FSPRIVATE3(bp, xfs_mount_t *);
162
163
164 j = mp->m_inode_cluster_size >> mp->m_sb.sb_inodelog;
165
166 for (i = 0; i < j; i++) {
167 dip = (xfs_dinode_t *) xfs_buf_offset(bp,
168 i * mp->m_sb.sb_inodesize);
169 if (INT_GET(dip->di_core.di_magic, ARCH_CONVERT) != XFS_DINODE_MAGIC) {
170 cmn_err(CE_WARN,
171"Bad magic # 0x%x in XFS inode buffer 0x%Lx, starting blockno %Ld, offset 0x%x",
172 INT_GET(dip->di_core.di_magic, ARCH_CONVERT),
173 (__uint64_t)(__psunsigned_t) bp,
174 (__int64_t) XFS_BUF_ADDR(bp),
175 xfs_buf_offset(bp, i * mp->m_sb.sb_inodesize));
176 xfs_fs_cmn_err(CE_WARN, mp,
177 "corrupt, unmount and run xfs_repair");
178 }
179 if (!dip->di_next_unlinked) {
180 cmn_err(CE_WARN,
181"Bad next_unlinked field (0) in XFS inode buffer 0x%p, starting blockno %Ld, offset 0x%x",
182 (__uint64_t)(__psunsigned_t) bp,
183 (__int64_t) XFS_BUF_ADDR(bp),
184 xfs_buf_offset(bp, i * mp->m_sb.sb_inodesize));
185 xfs_fs_cmn_err(CE_WARN, mp,
186 "corrupt, unmount and run xfs_repair");
187 }
188 }
189
190 return;
191}
192
193/*
194 * This routine is called to map an inode number within a file 149 * This routine is called to map an inode number within a file
195 * system to the buffer containing the on-disk version of the 150 * system to the buffer containing the on-disk version of the
196 * inode. It returns a pointer to the buffer containing the 151 * inode. It returns a pointer to the buffer containing the
@@ -203,7 +158,7 @@ xfs_inobp_bwcheck(xfs_buf_t *bp)
203 * Use xfs_imap() to determine the size and location of the 158 * Use xfs_imap() to determine the size and location of the
204 * buffer to read from disk. 159 * buffer to read from disk.
205 */ 160 */
206int 161STATIC int
207xfs_inotobp( 162xfs_inotobp(
208 xfs_mount_t *mp, 163 xfs_mount_t *mp,
209 xfs_trans_t *tp, 164 xfs_trans_t *tp,
@@ -1247,26 +1202,32 @@ xfs_ialloc(
1247 case S_IFREG: 1202 case S_IFREG:
1248 case S_IFDIR: 1203 case S_IFDIR:
1249 if (unlikely(pip->i_d.di_flags & XFS_DIFLAG_ANY)) { 1204 if (unlikely(pip->i_d.di_flags & XFS_DIFLAG_ANY)) {
1250 if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT) { 1205 uint di_flags = 0;
1251 if ((mode & S_IFMT) == S_IFDIR) { 1206
1252 ip->i_d.di_flags |= XFS_DIFLAG_RTINHERIT; 1207 if ((mode & S_IFMT) == S_IFDIR) {
1253 } else { 1208 if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT)
1254 ip->i_d.di_flags |= XFS_DIFLAG_REALTIME; 1209 di_flags |= XFS_DIFLAG_RTINHERIT;
1210 } else {
1211 if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT) {
1212 di_flags |= XFS_DIFLAG_REALTIME;
1255 ip->i_iocore.io_flags |= XFS_IOCORE_RT; 1213 ip->i_iocore.io_flags |= XFS_IOCORE_RT;
1256 } 1214 }
1257 } 1215 }
1258 if ((pip->i_d.di_flags & XFS_DIFLAG_NOATIME) && 1216 if ((pip->i_d.di_flags & XFS_DIFLAG_NOATIME) &&
1259 xfs_inherit_noatime) 1217 xfs_inherit_noatime)
1260 ip->i_d.di_flags |= XFS_DIFLAG_NOATIME; 1218 di_flags |= XFS_DIFLAG_NOATIME;
1261 if ((pip->i_d.di_flags & XFS_DIFLAG_NODUMP) && 1219 if ((pip->i_d.di_flags & XFS_DIFLAG_NODUMP) &&
1262 xfs_inherit_nodump) 1220 xfs_inherit_nodump)
1263 ip->i_d.di_flags |= XFS_DIFLAG_NODUMP; 1221 di_flags |= XFS_DIFLAG_NODUMP;
1264 if ((pip->i_d.di_flags & XFS_DIFLAG_SYNC) && 1222 if ((pip->i_d.di_flags & XFS_DIFLAG_SYNC) &&
1265 xfs_inherit_sync) 1223 xfs_inherit_sync)
1266 ip->i_d.di_flags |= XFS_DIFLAG_SYNC; 1224 di_flags |= XFS_DIFLAG_SYNC;
1267 if ((pip->i_d.di_flags & XFS_DIFLAG_NOSYMLINKS) && 1225 if ((pip->i_d.di_flags & XFS_DIFLAG_NOSYMLINKS) &&
1268 xfs_inherit_nosymlinks) 1226 xfs_inherit_nosymlinks)
1269 ip->i_d.di_flags |= XFS_DIFLAG_NOSYMLINKS; 1227 di_flags |= XFS_DIFLAG_NOSYMLINKS;
1228 if (pip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
1229 di_flags |= XFS_DIFLAG_PROJINHERIT;
1230 ip->i_d.di_flags |= di_flags;
1270 } 1231 }
1271 /* FALLTHROUGH */ 1232 /* FALLTHROUGH */
1272 case S_IFLNK: 1233 case S_IFLNK:
@@ -2156,7 +2117,7 @@ static __inline__ int xfs_inode_clean(xfs_inode_t *ip)
2156 (ip->i_update_core == 0)); 2117 (ip->i_update_core == 0));
2157} 2118}
2158 2119
2159void 2120STATIC void
2160xfs_ifree_cluster( 2121xfs_ifree_cluster(
2161 xfs_inode_t *free_ip, 2122 xfs_inode_t *free_ip,
2162 xfs_trans_t *tp, 2123 xfs_trans_t *tp,
@@ -2875,7 +2836,7 @@ xfs_iunpin(
2875 * be subsequently pinned once someone is waiting for it to be 2836 * be subsequently pinned once someone is waiting for it to be
2876 * unpinned. 2837 * unpinned.
2877 */ 2838 */
2878void 2839STATIC void
2879xfs_iunpin_wait( 2840xfs_iunpin_wait(
2880 xfs_inode_t *ip) 2841 xfs_inode_t *ip)
2881{ 2842{
@@ -3601,107 +3562,43 @@ corrupt_out:
3601 3562
3602 3563
3603/* 3564/*
3604 * Flush all inactive inodes in mp. Return true if no user references 3565 * Flush all inactive inodes in mp.
3605 * were found, false otherwise.
3606 */ 3566 */
3607int 3567void
3608xfs_iflush_all( 3568xfs_iflush_all(
3609 xfs_mount_t *mp, 3569 xfs_mount_t *mp)
3610 int flag)
3611{ 3570{
3612 int busy;
3613 int done;
3614 int purged;
3615 xfs_inode_t *ip; 3571 xfs_inode_t *ip;
3616 vmap_t vmap;
3617 vnode_t *vp; 3572 vnode_t *vp;
3618 3573
3619 busy = done = 0; 3574 again:
3620 while (!done) { 3575 XFS_MOUNT_ILOCK(mp);
3621 purged = 0; 3576 ip = mp->m_inodes;
3622 XFS_MOUNT_ILOCK(mp); 3577 if (ip == NULL)
3623 ip = mp->m_inodes; 3578 goto out;
3624 if (ip == NULL) {
3625 break;
3626 }
3627 do {
3628 /* Make sure we skip markers inserted by sync */
3629 if (ip->i_mount == NULL) {
3630 ip = ip->i_mnext;
3631 continue;
3632 }
3633
3634 /*
3635 * It's up to our caller to purge the root
3636 * and quota vnodes later.
3637 */
3638 vp = XFS_ITOV_NULL(ip);
3639
3640 if (!vp) {
3641 XFS_MOUNT_IUNLOCK(mp);
3642 xfs_finish_reclaim(ip, 0, XFS_IFLUSH_ASYNC);
3643 purged = 1;
3644 break;
3645 }
3646 3579
3647 if (vn_count(vp) != 0) { 3580 do {
3648 if (vn_count(vp) == 1 && 3581 /* Make sure we skip markers inserted by sync */
3649 (ip == mp->m_rootip || 3582 if (ip->i_mount == NULL) {
3650 (mp->m_quotainfo && 3583 ip = ip->i_mnext;
3651 (ip->i_ino == mp->m_sb.sb_uquotino || 3584 continue;
3652 ip->i_ino == mp->m_sb.sb_gquotino)))) { 3585 }
3653 3586
3654 ip = ip->i_mnext; 3587 vp = XFS_ITOV_NULL(ip);
3655 continue; 3588 if (!vp) {
3656 }
3657 if (!(flag & XFS_FLUSH_ALL)) {
3658 busy = 1;
3659 done = 1;
3660 break;
3661 }
3662 /*
3663 * Ignore busy inodes but continue flushing
3664 * others.
3665 */
3666 ip = ip->i_mnext;
3667 continue;
3668 }
3669 /*
3670 * Sample vp mapping while holding mp locked on MP
3671 * systems, so we don't purge a reclaimed or
3672 * nonexistent vnode. We break from the loop
3673 * since we know that we modify
3674 * it by pulling ourselves from it in xfs_reclaim()
3675 * called via vn_purge() below. Set ip to the next
3676 * entry in the list anyway so we'll know below
3677 * whether we reached the end or not.
3678 */
3679 VMAP(vp, vmap);
3680 XFS_MOUNT_IUNLOCK(mp); 3589 XFS_MOUNT_IUNLOCK(mp);
3590 xfs_finish_reclaim(ip, 0, XFS_IFLUSH_ASYNC);
3591 goto again;
3592 }
3681 3593
3682 vn_purge(vp, &vmap); 3594 ASSERT(vn_count(vp) == 0);
3683 3595
3684 purged = 1; 3596 ip = ip->i_mnext;
3685 break; 3597 } while (ip != mp->m_inodes);
3686 } while (ip != mp->m_inodes); 3598 out:
3687 /*
3688 * We need to distinguish between when we exit the loop
3689 * after a purge and when we simply hit the end of the
3690 * list. We can't use the (ip == mp->m_inodes) test,
3691 * because when we purge an inode at the start of the list
3692 * the next inode on the list becomes mp->m_inodes. That
3693 * would cause such a test to bail out early. The purged
3694 * variable tells us how we got out of the loop.
3695 */
3696 if (!purged) {
3697 done = 1;
3698 }
3699 }
3700 XFS_MOUNT_IUNLOCK(mp); 3599 XFS_MOUNT_IUNLOCK(mp);
3701 return !busy;
3702} 3600}
3703 3601
3704
3705/* 3602/*
3706 * xfs_iaccess: check accessibility of inode for mode. 3603 * xfs_iaccess: check accessibility of inode for mode.
3707 */ 3604 */
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 37e1c316f3b6..54d9e54c7c95 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -412,11 +412,6 @@ void xfs_ifork_next_set(xfs_inode_t *ip, int w, int n);
412#define XFS_IFLUSH_DELWRI 5 412#define XFS_IFLUSH_DELWRI 5
413 413
414/* 414/*
415 * Flags for xfs_iflush_all.
416 */
417#define XFS_FLUSH_ALL 0x1
418
419/*
420 * Flags for xfs_itruncate_start(). 415 * Flags for xfs_itruncate_start().
421 */ 416 */
422#define XFS_ITRUNC_DEFINITE 0x1 417#define XFS_ITRUNC_DEFINITE 0x1
@@ -487,8 +482,6 @@ int xfs_finish_reclaim_all(struct xfs_mount *, int);
487/* 482/*
488 * xfs_inode.c prototypes. 483 * xfs_inode.c prototypes.
489 */ 484 */
490int xfs_inotobp(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
491 xfs_dinode_t **, struct xfs_buf **, int *);
492int xfs_itobp(struct xfs_mount *, struct xfs_trans *, 485int xfs_itobp(struct xfs_mount *, struct xfs_trans *,
493 xfs_inode_t *, xfs_dinode_t **, struct xfs_buf **, 486 xfs_inode_t *, xfs_dinode_t **, struct xfs_buf **,
494 xfs_daddr_t); 487 xfs_daddr_t);
@@ -522,7 +515,7 @@ void xfs_ipin(xfs_inode_t *);
522void xfs_iunpin(xfs_inode_t *); 515void xfs_iunpin(xfs_inode_t *);
523int xfs_iextents_copy(xfs_inode_t *, xfs_bmbt_rec_t *, int); 516int xfs_iextents_copy(xfs_inode_t *, xfs_bmbt_rec_t *, int);
524int xfs_iflush(xfs_inode_t *, uint); 517int xfs_iflush(xfs_inode_t *, uint);
525int xfs_iflush_all(struct xfs_mount *, int); 518void xfs_iflush_all(struct xfs_mount *);
526int xfs_iaccess(xfs_inode_t *, mode_t, cred_t *); 519int xfs_iaccess(xfs_inode_t *, mode_t, cred_t *);
527uint xfs_iroundup(uint); 520uint xfs_iroundup(uint);
528void xfs_ichgtime(xfs_inode_t *, int); 521void xfs_ichgtime(xfs_inode_t *, int);
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 768cb1816b8e..0eed30f5cb19 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -910,7 +910,7 @@ xfs_inode_item_committing(
910/* 910/*
911 * This is the ops vector shared by all buf log items. 911 * This is the ops vector shared by all buf log items.
912 */ 912 */
913struct xfs_item_ops xfs_inode_item_ops = { 913STATIC struct xfs_item_ops xfs_inode_item_ops = {
914 .iop_size = (uint(*)(xfs_log_item_t*))xfs_inode_item_size, 914 .iop_size = (uint(*)(xfs_log_item_t*))xfs_inode_item_size,
915 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) 915 .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*))
916 xfs_inode_item_format, 916 xfs_inode_item_format,
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 469e1a7939d4..2edd6769e5d3 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -385,15 +385,15 @@ xfs_iomap_write_direct(
385 int nimaps, maps; 385 int nimaps, maps;
386 int error; 386 int error;
387 int bmapi_flag; 387 int bmapi_flag;
388 int quota_flag;
388 int rt; 389 int rt;
389 xfs_trans_t *tp; 390 xfs_trans_t *tp;
390 xfs_bmbt_irec_t imap[XFS_WRITE_IMAPS], *imapp; 391 xfs_bmbt_irec_t imap[XFS_WRITE_IMAPS], *imapp;
391 xfs_bmap_free_t free_list; 392 xfs_bmap_free_t free_list;
392 int aeof; 393 int aeof;
393 xfs_filblks_t datablocks; 394 xfs_filblks_t datablocks, qblocks, resblks;
394 int committed; 395 int committed;
395 int numrtextents; 396 int numrtextents;
396 uint resblks;
397 397
398 /* 398 /*
399 * Make sure that the dquots are there. This doesn't hold 399 * Make sure that the dquots are there. This doesn't hold
@@ -419,7 +419,6 @@ xfs_iomap_write_direct(
419 xfs_fileoff_t map_last_fsb; 419 xfs_fileoff_t map_last_fsb;
420 420
421 map_last_fsb = ret_imap->br_blockcount + ret_imap->br_startoff; 421 map_last_fsb = ret_imap->br_blockcount + ret_imap->br_startoff;
422
423 if (map_last_fsb < last_fsb) { 422 if (map_last_fsb < last_fsb) {
424 last_fsb = map_last_fsb; 423 last_fsb = map_last_fsb;
425 count_fsb = last_fsb - offset_fsb; 424 count_fsb = last_fsb - offset_fsb;
@@ -428,56 +427,47 @@ xfs_iomap_write_direct(
428 } 427 }
429 428
430 /* 429 /*
431 * determine if reserving space on 430 * Determine if reserving space on the data or realtime partition.
432 * the data or realtime partition.
433 */ 431 */
434 if ((rt = XFS_IS_REALTIME_INODE(ip))) { 432 if ((rt = XFS_IS_REALTIME_INODE(ip))) {
435 int sbrtextsize, iprtextsize; 433 xfs_extlen_t extsz;
436 434
437 sbrtextsize = mp->m_sb.sb_rextsize; 435 if (!(extsz = ip->i_d.di_extsize))
438 iprtextsize = 436 extsz = mp->m_sb.sb_rextsize;
439 ip->i_d.di_extsize ? ip->i_d.di_extsize : sbrtextsize; 437 numrtextents = qblocks = (count_fsb + extsz - 1);
440 numrtextents = (count_fsb + iprtextsize - 1); 438 do_div(numrtextents, mp->m_sb.sb_rextsize);
441 do_div(numrtextents, sbrtextsize); 439 quota_flag = XFS_QMOPT_RES_RTBLKS;
442 datablocks = 0; 440 datablocks = 0;
443 } else { 441 } else {
444 datablocks = count_fsb; 442 datablocks = qblocks = count_fsb;
443 quota_flag = XFS_QMOPT_RES_REGBLKS;
445 numrtextents = 0; 444 numrtextents = 0;
446 } 445 }
447 446
448 /* 447 /*
449 * allocate and setup the transaction 448 * Allocate and setup the transaction
450 */ 449 */
451 xfs_iunlock(ip, XFS_ILOCK_EXCL); 450 xfs_iunlock(ip, XFS_ILOCK_EXCL);
452 tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT); 451 tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT);
453
454 resblks = XFS_DIOSTRAT_SPACE_RES(mp, datablocks); 452 resblks = XFS_DIOSTRAT_SPACE_RES(mp, datablocks);
455
456 error = xfs_trans_reserve(tp, resblks, 453 error = xfs_trans_reserve(tp, resblks,
457 XFS_WRITE_LOG_RES(mp), numrtextents, 454 XFS_WRITE_LOG_RES(mp), numrtextents,
458 XFS_TRANS_PERM_LOG_RES, 455 XFS_TRANS_PERM_LOG_RES,
459 XFS_WRITE_LOG_COUNT); 456 XFS_WRITE_LOG_COUNT);
460 457
461 /* 458 /*
462 * check for running out of space 459 * Check for running out of space, note: need lock to return
463 */ 460 */
464 if (error) 461 if (error)
465 /*
466 * Free the transaction structure.
467 */
468 xfs_trans_cancel(tp, 0); 462 xfs_trans_cancel(tp, 0);
469
470 xfs_ilock(ip, XFS_ILOCK_EXCL); 463 xfs_ilock(ip, XFS_ILOCK_EXCL);
471
472 if (error) 464 if (error)
473 goto error_out; /* Don't return in above if .. trans .., 465 goto error_out;
474 need lock to return */
475 466
476 if (XFS_TRANS_RESERVE_BLKQUOTA(mp, tp, ip, resblks)) { 467 if (XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, qblocks, 0, quota_flag)) {
477 error = (EDQUOT); 468 error = (EDQUOT);
478 goto error1; 469 goto error1;
479 } 470 }
480 nimaps = 1;
481 471
482 bmapi_flag = XFS_BMAPI_WRITE; 472 bmapi_flag = XFS_BMAPI_WRITE;
483 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); 473 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
@@ -487,31 +477,29 @@ xfs_iomap_write_direct(
487 bmapi_flag |= XFS_BMAPI_PREALLOC; 477 bmapi_flag |= XFS_BMAPI_PREALLOC;
488 478
489 /* 479 /*
490 * issue the bmapi() call to allocate the blocks 480 * Issue the bmapi() call to allocate the blocks
491 */ 481 */
492 XFS_BMAP_INIT(&free_list, &firstfsb); 482 XFS_BMAP_INIT(&free_list, &firstfsb);
483 nimaps = 1;
493 imapp = &imap[0]; 484 imapp = &imap[0];
494 error = xfs_bmapi(tp, ip, offset_fsb, count_fsb, 485 error = xfs_bmapi(tp, ip, offset_fsb, count_fsb,
495 bmapi_flag, &firstfsb, 0, imapp, &nimaps, &free_list); 486 bmapi_flag, &firstfsb, 0, imapp, &nimaps, &free_list);
496 if (error) { 487 if (error)
497 goto error0; 488 goto error0;
498 }
499 489
500 /* 490 /*
501 * complete the transaction 491 * Complete the transaction
502 */ 492 */
503
504 error = xfs_bmap_finish(&tp, &free_list, firstfsb, &committed); 493 error = xfs_bmap_finish(&tp, &free_list, firstfsb, &committed);
505 if (error) { 494 if (error)
506 goto error0; 495 goto error0;
507 }
508
509 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL); 496 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL);
510 if (error) { 497 if (error)
511 goto error_out; 498 goto error_out;
512 }
513 499
514 /* copy any maps to caller's array and return any error. */ 500 /*
501 * Copy any maps to caller's array and return any error.
502 */
515 if (nimaps == 0) { 503 if (nimaps == 0) {
516 error = (ENOSPC); 504 error = (ENOSPC);
517 goto error_out; 505 goto error_out;
@@ -530,10 +518,11 @@ xfs_iomap_write_direct(
530 } 518 }
531 return 0; 519 return 0;
532 520
533 error0: /* Cancel bmap, unlock inode, and cancel trans */ 521error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */
534 xfs_bmap_cancel(&free_list); 522 xfs_bmap_cancel(&free_list);
523 XFS_TRANS_UNRESERVE_QUOTA_NBLKS(mp, tp, ip, qblocks, 0, quota_flag);
535 524
536 error1: /* Just cancel transaction */ 525error1: /* Just cancel transaction */
537 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); 526 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT);
538 *nmaps = 0; /* nothing set-up here */ 527 *nmaps = 0; /* nothing set-up here */
539 528
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 092d5fb096b1..1cd2ac163877 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -134,7 +134,7 @@ STATIC void xlog_verify_tail_lsn(xlog_t *log, xlog_in_core_t *iclog,
134#define xlog_verify_tail_lsn(a,b,c) 134#define xlog_verify_tail_lsn(a,b,c)
135#endif 135#endif
136 136
137int xlog_iclogs_empty(xlog_t *log); 137STATIC int xlog_iclogs_empty(xlog_t *log);
138 138
139#ifdef DEBUG 139#ifdef DEBUG
140int xlog_do_error = 0; 140int xlog_do_error = 0;
@@ -1857,7 +1857,7 @@ xlog_write(xfs_mount_t * mp,
1857 * 1857 *
1858 * State Change: DIRTY -> ACTIVE 1858 * State Change: DIRTY -> ACTIVE
1859 */ 1859 */
1860void 1860STATIC void
1861xlog_state_clean_log(xlog_t *log) 1861xlog_state_clean_log(xlog_t *log)
1862{ 1862{
1863 xlog_in_core_t *iclog; 1863 xlog_in_core_t *iclog;
@@ -3542,7 +3542,7 @@ xfs_log_force_umount(
3542 return (retval); 3542 return (retval);
3543} 3543}
3544 3544
3545int 3545STATIC int
3546xlog_iclogs_empty(xlog_t *log) 3546xlog_iclogs_empty(xlog_t *log)
3547{ 3547{
3548 xlog_in_core_t *iclog; 3548 xlog_in_core_t *iclog;
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h
index c31e3ce3be66..1a1d452f15f9 100644
--- a/fs/xfs/xfs_log_priv.h
+++ b/fs/xfs/xfs_log_priv.h
@@ -535,7 +535,6 @@ typedef struct log {
535 535
536/* common routines */ 536/* common routines */
537extern xfs_lsn_t xlog_assign_tail_lsn(struct xfs_mount *mp); 537extern xfs_lsn_t xlog_assign_tail_lsn(struct xfs_mount *mp);
538extern int xlog_find_head(xlog_t *log, xfs_daddr_t *head_blk);
539extern int xlog_find_tail(xlog_t *log, 538extern int xlog_find_tail(xlog_t *log,
540 xfs_daddr_t *head_blk, 539 xfs_daddr_t *head_blk,
541 xfs_daddr_t *tail_blk, 540 xfs_daddr_t *tail_blk,
@@ -548,7 +547,6 @@ extern void xlog_recover_process_iunlinks(xlog_t *log);
548extern struct xfs_buf *xlog_get_bp(xlog_t *, int); 547extern struct xfs_buf *xlog_get_bp(xlog_t *, int);
549extern void xlog_put_bp(struct xfs_buf *); 548extern void xlog_put_bp(struct xfs_buf *);
550extern int xlog_bread(xlog_t *, xfs_daddr_t, int, struct xfs_buf *); 549extern int xlog_bread(xlog_t *, xfs_daddr_t, int, struct xfs_buf *);
551extern xfs_caddr_t xlog_align(xlog_t *, xfs_daddr_t, int, struct xfs_buf *);
552 550
553/* iclog tracing */ 551/* iclog tracing */
554#define XLOG_TRACE_GRAB_FLUSH 1 552#define XLOG_TRACE_GRAB_FLUSH 1
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 9824b5bf0ec0..0aac28ddb81c 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -148,7 +148,7 @@ xlog_bread(
148 * The buffer is kept locked across the write and is returned locked. 148 * The buffer is kept locked across the write and is returned locked.
149 * This can only be used for synchronous log writes. 149 * This can only be used for synchronous log writes.
150 */ 150 */
151int 151STATIC int
152xlog_bwrite( 152xlog_bwrite(
153 xlog_t *log, 153 xlog_t *log,
154 xfs_daddr_t blk_no, 154 xfs_daddr_t blk_no,
@@ -179,7 +179,7 @@ xlog_bwrite(
179 return error; 179 return error;
180} 180}
181 181
182xfs_caddr_t 182STATIC xfs_caddr_t
183xlog_align( 183xlog_align(
184 xlog_t *log, 184 xlog_t *log,
185 xfs_daddr_t blk_no, 185 xfs_daddr_t blk_no,
@@ -528,7 +528,7 @@ out:
528 * 528 *
529 * Return: zero if normal, non-zero if error. 529 * Return: zero if normal, non-zero if error.
530 */ 530 */
531int 531STATIC int
532xlog_find_head( 532xlog_find_head(
533 xlog_t *log, 533 xlog_t *log,
534 xfs_daddr_t *return_head_blk) 534 xfs_daddr_t *return_head_blk)
@@ -1964,7 +1964,8 @@ xlog_recover_do_reg_buffer(
1964 * probably a good thing to do for other buf types also. 1964 * probably a good thing to do for other buf types also.
1965 */ 1965 */
1966 error = 0; 1966 error = 0;
1967 if (buf_f->blf_flags & (XFS_BLI_UDQUOT_BUF|XFS_BLI_GDQUOT_BUF)) { 1967 if (buf_f->blf_flags &
1968 (XFS_BLI_UDQUOT_BUF|XFS_BLI_PDQUOT_BUF|XFS_BLI_GDQUOT_BUF)) {
1968 error = xfs_qm_dqcheck((xfs_disk_dquot_t *) 1969 error = xfs_qm_dqcheck((xfs_disk_dquot_t *)
1969 item->ri_buf[i].i_addr, 1970 item->ri_buf[i].i_addr,
1970 -1, 0, XFS_QMOPT_DOWARN, 1971 -1, 0, XFS_QMOPT_DOWARN,
@@ -2030,6 +2031,7 @@ xfs_qm_dqcheck(
2030 } 2031 }
2031 2032
2032 if (INT_GET(ddq->d_flags, ARCH_CONVERT) != XFS_DQ_USER && 2033 if (INT_GET(ddq->d_flags, ARCH_CONVERT) != XFS_DQ_USER &&
2034 INT_GET(ddq->d_flags, ARCH_CONVERT) != XFS_DQ_PROJ &&
2033 INT_GET(ddq->d_flags, ARCH_CONVERT) != XFS_DQ_GROUP) { 2035 INT_GET(ddq->d_flags, ARCH_CONVERT) != XFS_DQ_GROUP) {
2034 if (flags & XFS_QMOPT_DOWARN) 2036 if (flags & XFS_QMOPT_DOWARN)
2035 cmn_err(CE_ALERT, 2037 cmn_err(CE_ALERT,
@@ -2135,6 +2137,8 @@ xlog_recover_do_dquot_buffer(
2135 type = 0; 2137 type = 0;
2136 if (buf_f->blf_flags & XFS_BLI_UDQUOT_BUF) 2138 if (buf_f->blf_flags & XFS_BLI_UDQUOT_BUF)
2137 type |= XFS_DQ_USER; 2139 type |= XFS_DQ_USER;
2140 if (buf_f->blf_flags & XFS_BLI_PDQUOT_BUF)
2141 type |= XFS_DQ_PROJ;
2138 if (buf_f->blf_flags & XFS_BLI_GDQUOT_BUF) 2142 if (buf_f->blf_flags & XFS_BLI_GDQUOT_BUF)
2139 type |= XFS_DQ_GROUP; 2143 type |= XFS_DQ_GROUP;
2140 /* 2144 /*
@@ -2247,7 +2251,8 @@ xlog_recover_do_buffer_trans(
2247 error = 0; 2251 error = 0;
2248 if (flags & XFS_BLI_INODE_BUF) { 2252 if (flags & XFS_BLI_INODE_BUF) {
2249 error = xlog_recover_do_inode_buffer(mp, item, bp, buf_f); 2253 error = xlog_recover_do_inode_buffer(mp, item, bp, buf_f);
2250 } else if (flags & (XFS_BLI_UDQUOT_BUF | XFS_BLI_GDQUOT_BUF)) { 2254 } else if (flags &
2255 (XFS_BLI_UDQUOT_BUF|XFS_BLI_PDQUOT_BUF|XFS_BLI_GDQUOT_BUF)) {
2251 xlog_recover_do_dquot_buffer(mp, log, item, bp, buf_f); 2256 xlog_recover_do_dquot_buffer(mp, log, item, bp, buf_f);
2252 } else { 2257 } else {
2253 xlog_recover_do_reg_buffer(mp, item, bp, buf_f); 2258 xlog_recover_do_reg_buffer(mp, item, bp, buf_f);
@@ -2619,7 +2624,7 @@ xlog_recover_do_dquot_trans(
2619 * This type of quotas was turned off, so ignore this record. 2624 * This type of quotas was turned off, so ignore this record.
2620 */ 2625 */
2621 type = INT_GET(recddq->d_flags, ARCH_CONVERT) & 2626 type = INT_GET(recddq->d_flags, ARCH_CONVERT) &
2622 (XFS_DQ_USER | XFS_DQ_GROUP); 2627 (XFS_DQ_USER | XFS_DQ_PROJ | XFS_DQ_GROUP);
2623 ASSERT(type); 2628 ASSERT(type);
2624 if (log->l_quotaoffs_flag & type) 2629 if (log->l_quotaoffs_flag & type)
2625 return (0); 2630 return (0);
@@ -2742,7 +2747,6 @@ xlog_recover_do_efd_trans(
2742 xfs_efi_log_item_t *efip = NULL; 2747 xfs_efi_log_item_t *efip = NULL;
2743 xfs_log_item_t *lip; 2748 xfs_log_item_t *lip;
2744 int gen; 2749 int gen;
2745 int nexts;
2746 __uint64_t efi_id; 2750 __uint64_t efi_id;
2747 SPLDECL(s); 2751 SPLDECL(s);
2748 2752
@@ -2777,22 +2781,15 @@ xlog_recover_do_efd_trans(
2777 } 2781 }
2778 lip = xfs_trans_next_ail(mp, lip, &gen, NULL); 2782 lip = xfs_trans_next_ail(mp, lip, &gen, NULL);
2779 } 2783 }
2780 if (lip == NULL) {
2781 AIL_UNLOCK(mp, s);
2782 }
2783 2784
2784 /* 2785 /*
2785 * If we found it, then free it up. If it wasn't there, it 2786 * If we found it, then free it up. If it wasn't there, it
2786 * must have been overwritten in the log. Oh well. 2787 * must have been overwritten in the log. Oh well.
2787 */ 2788 */
2788 if (lip != NULL) { 2789 if (lip != NULL) {
2789 nexts = efip->efi_format.efi_nextents; 2790 xfs_efi_item_free(efip);
2790 if (nexts > XFS_EFI_MAX_FAST_EXTENTS) { 2791 } else {
2791 kmem_free(lip, sizeof(xfs_efi_log_item_t) + 2792 AIL_UNLOCK(mp, s);
2792 ((nexts - 1) * sizeof(xfs_extent_t)));
2793 } else {
2794 kmem_zone_free(xfs_efi_zone, efip);
2795 }
2796 } 2793 }
2797} 2794}
2798 2795
diff --git a/fs/xfs/xfs_macros.c b/fs/xfs/xfs_macros.c
index ce4f46c6b3ab..698c2cd62858 100644
--- a/fs/xfs/xfs_macros.c
+++ b/fs/xfs/xfs_macros.c
@@ -1658,6 +1658,11 @@ xfs_inobt_is_free(xfs_inobt_rec_t *rp, int i)
1658{ 1658{
1659 return XFS_INOBT_IS_FREE(rp, i); 1659 return XFS_INOBT_IS_FREE(rp, i);
1660} 1660}
1661int
1662xfs_inobt_is_free_disk(xfs_inobt_rec_t *rp, int i)
1663{
1664 return XFS_INOBT_IS_FREE_DISK(rp, i);
1665}
1661#endif 1666#endif
1662 1667
1663#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_IS_LAST_REC) 1668#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_INOBT_IS_LAST_REC)
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 2ec967d93e5a..82e1646e6243 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -64,6 +64,7 @@
64STATIC void xfs_mount_log_sbunit(xfs_mount_t *, __int64_t); 64STATIC void xfs_mount_log_sbunit(xfs_mount_t *, __int64_t);
65STATIC int xfs_uuid_mount(xfs_mount_t *); 65STATIC int xfs_uuid_mount(xfs_mount_t *);
66STATIC void xfs_uuid_unmount(xfs_mount_t *mp); 66STATIC void xfs_uuid_unmount(xfs_mount_t *mp);
67STATIC void xfs_unmountfs_wait(xfs_mount_t *);
67 68
68static struct { 69static struct {
69 short offset; 70 short offset;
@@ -555,7 +556,7 @@ xfs_readsb(xfs_mount_t *mp)
555 * fields from the superblock associated with the given 556 * fields from the superblock associated with the given
556 * mount structure 557 * mount structure
557 */ 558 */
558void 559STATIC void
559xfs_mount_common(xfs_mount_t *mp, xfs_sb_t *sbp) 560xfs_mount_common(xfs_mount_t *mp, xfs_sb_t *sbp)
560{ 561{
561 int i; 562 int i;
@@ -1081,7 +1082,7 @@ xfs_unmountfs(xfs_mount_t *mp, struct cred *cr)
1081 int64_t fsid; 1082 int64_t fsid;
1082#endif 1083#endif
1083 1084
1084 xfs_iflush_all(mp, XFS_FLUSH_ALL); 1085 xfs_iflush_all(mp);
1085 1086
1086 XFS_QM_DQPURGEALL(mp, 1087 XFS_QM_DQPURGEALL(mp,
1087 XFS_QMOPT_UQUOTA | XFS_QMOPT_GQUOTA | XFS_QMOPT_UMOUNTING); 1088 XFS_QMOPT_UQUOTA | XFS_QMOPT_GQUOTA | XFS_QMOPT_UMOUNTING);
@@ -1111,15 +1112,6 @@ xfs_unmountfs(xfs_mount_t *mp, struct cred *cr)
1111 */ 1112 */
1112 ASSERT(mp->m_inodes == NULL); 1113 ASSERT(mp->m_inodes == NULL);
1113 1114
1114 /*
1115 * We may have bufs that are in the process of getting written still.
1116 * We must wait for the I/O completion of those. The sync flag here
1117 * does a two pass iteration thru the bufcache.
1118 */
1119 if (XFS_FORCED_SHUTDOWN(mp)) {
1120 xfs_incore_relse(mp->m_ddev_targp, 0, 1); /* synchronous */
1121 }
1122
1123 xfs_unmountfs_close(mp, cr); 1115 xfs_unmountfs_close(mp, cr);
1124 if ((mp->m_flags & XFS_MOUNT_NOUUID) == 0) 1116 if ((mp->m_flags & XFS_MOUNT_NOUUID) == 0)
1125 xfs_uuid_unmount(mp); 1117 xfs_uuid_unmount(mp);
@@ -1146,7 +1138,7 @@ xfs_unmountfs_close(xfs_mount_t *mp, struct cred *cr)
1146 xfs_free_buftarg(mp->m_ddev_targp, 0); 1138 xfs_free_buftarg(mp->m_ddev_targp, 0);
1147} 1139}
1148 1140
1149void 1141STATIC void
1150xfs_unmountfs_wait(xfs_mount_t *mp) 1142xfs_unmountfs_wait(xfs_mount_t *mp)
1151{ 1143{
1152 if (mp->m_logdev_targp != mp->m_ddev_targp) 1144 if (mp->m_logdev_targp != mp->m_ddev_targp)
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 30dd08fb9f57..5affba38a577 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -141,7 +141,7 @@ typedef int (*xfs_dqattach_t)(struct xfs_inode *, uint);
141typedef void (*xfs_dqdetach_t)(struct xfs_inode *); 141typedef void (*xfs_dqdetach_t)(struct xfs_inode *);
142typedef int (*xfs_dqpurgeall_t)(struct xfs_mount *, uint); 142typedef int (*xfs_dqpurgeall_t)(struct xfs_mount *, uint);
143typedef int (*xfs_dqvopalloc_t)(struct xfs_mount *, 143typedef int (*xfs_dqvopalloc_t)(struct xfs_mount *,
144 struct xfs_inode *, uid_t, gid_t, uint, 144 struct xfs_inode *, uid_t, gid_t, prid_t, uint,
145 struct xfs_dquot **, struct xfs_dquot **); 145 struct xfs_dquot **, struct xfs_dquot **);
146typedef void (*xfs_dqvopcreate_t)(struct xfs_trans *, struct xfs_inode *, 146typedef void (*xfs_dqvopcreate_t)(struct xfs_trans *, struct xfs_inode *,
147 struct xfs_dquot *, struct xfs_dquot *); 147 struct xfs_dquot *, struct xfs_dquot *);
@@ -185,8 +185,8 @@ typedef struct xfs_qmops {
185 (*(mp)->m_qm_ops.xfs_dqdetach)(ip) 185 (*(mp)->m_qm_ops.xfs_dqdetach)(ip)
186#define XFS_QM_DQPURGEALL(mp, fl) \ 186#define XFS_QM_DQPURGEALL(mp, fl) \
187 (*(mp)->m_qm_ops.xfs_dqpurgeall)(mp, fl) 187 (*(mp)->m_qm_ops.xfs_dqpurgeall)(mp, fl)
188#define XFS_QM_DQVOPALLOC(mp, ip, uid, gid, fl, dq1, dq2) \ 188#define XFS_QM_DQVOPALLOC(mp, ip, uid, gid, prid, fl, dq1, dq2) \
189 (*(mp)->m_qm_ops.xfs_dqvopalloc)(mp, ip, uid, gid, fl, dq1, dq2) 189 (*(mp)->m_qm_ops.xfs_dqvopalloc)(mp, ip, uid, gid, prid, fl, dq1, dq2)
190#define XFS_QM_DQVOPCREATE(mp, tp, ip, dq1, dq2) \ 190#define XFS_QM_DQVOPCREATE(mp, tp, ip, dq1, dq2) \
191 (*(mp)->m_qm_ops.xfs_dqvopcreate)(tp, ip, dq1, dq2) 191 (*(mp)->m_qm_ops.xfs_dqvopcreate)(tp, ip, dq1, dq2)
192#define XFS_QM_DQVOPRENAME(mp, ip) \ 192#define XFS_QM_DQVOPRENAME(mp, ip) \
@@ -544,7 +544,6 @@ extern void xfs_mount_free(xfs_mount_t *mp, int remove_bhv);
544extern int xfs_mountfs(struct vfs *, xfs_mount_t *mp, int); 544extern int xfs_mountfs(struct vfs *, xfs_mount_t *mp, int);
545 545
546extern int xfs_unmountfs(xfs_mount_t *, struct cred *); 546extern int xfs_unmountfs(xfs_mount_t *, struct cred *);
547extern void xfs_unmountfs_wait(xfs_mount_t *);
548extern void xfs_unmountfs_close(xfs_mount_t *, struct cred *); 547extern void xfs_unmountfs_close(xfs_mount_t *, struct cred *);
549extern int xfs_unmountfs_writesb(xfs_mount_t *); 548extern int xfs_unmountfs_writesb(xfs_mount_t *);
550extern int xfs_unmount_flush(xfs_mount_t *, int); 549extern int xfs_unmount_flush(xfs_mount_t *, int);
diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h
index 703ec4efcb41..7134576ae7fa 100644
--- a/fs/xfs/xfs_quota.h
+++ b/fs/xfs/xfs_quota.h
@@ -96,7 +96,7 @@ typedef struct xfs_dqblk {
96 * flags for q_flags field in the dquot. 96 * flags for q_flags field in the dquot.
97 */ 97 */
98#define XFS_DQ_USER 0x0001 /* a user quota */ 98#define XFS_DQ_USER 0x0001 /* a user quota */
99/* #define XFS_DQ_PROJ 0x0002 -- project quota (IRIX) */ 99#define XFS_DQ_PROJ 0x0002 /* project quota */
100#define XFS_DQ_GROUP 0x0004 /* a group quota */ 100#define XFS_DQ_GROUP 0x0004 /* a group quota */
101#define XFS_DQ_FLOCKED 0x0008 /* flush lock taken */ 101#define XFS_DQ_FLOCKED 0x0008 /* flush lock taken */
102#define XFS_DQ_DIRTY 0x0010 /* dquot is dirty */ 102#define XFS_DQ_DIRTY 0x0010 /* dquot is dirty */
@@ -104,6 +104,8 @@ typedef struct xfs_dqblk {
104#define XFS_DQ_INACTIVE 0x0040 /* dq off mplist & hashlist */ 104#define XFS_DQ_INACTIVE 0x0040 /* dq off mplist & hashlist */
105#define XFS_DQ_MARKER 0x0080 /* sentinel */ 105#define XFS_DQ_MARKER 0x0080 /* sentinel */
106 106
107#define XFS_DQ_ALLTYPES (XFS_DQ_USER|XFS_DQ_PROJ|XFS_DQ_GROUP)
108
107/* 109/*
108 * In the worst case, when both user and group quotas are on, 110 * In the worst case, when both user and group quotas are on,
109 * we can have a max of three dquots changing in a single transaction. 111 * we can have a max of three dquots changing in a single transaction.
@@ -124,7 +126,7 @@ typedef struct xfs_dqblk {
124typedef struct xfs_dq_logformat { 126typedef struct xfs_dq_logformat {
125 __uint16_t qlf_type; /* dquot log item type */ 127 __uint16_t qlf_type; /* dquot log item type */
126 __uint16_t qlf_size; /* size of this item */ 128 __uint16_t qlf_size; /* size of this item */
127 xfs_dqid_t qlf_id; /* usr/grp id number : 32 bits */ 129 xfs_dqid_t qlf_id; /* usr/grp/proj id : 32 bits */
128 __int64_t qlf_blkno; /* blkno of dquot buffer */ 130 __int64_t qlf_blkno; /* blkno of dquot buffer */
129 __int32_t qlf_len; /* len of dquot buffer */ 131 __int32_t qlf_len; /* len of dquot buffer */
130 __uint32_t qlf_boffset; /* off of dquot in buffer */ 132 __uint32_t qlf_boffset; /* off of dquot in buffer */
@@ -152,9 +154,9 @@ typedef struct xfs_qoff_logformat {
152#define XFS_UQUOTA_ACCT 0x0001 /* user quota accounting ON */ 154#define XFS_UQUOTA_ACCT 0x0001 /* user quota accounting ON */
153#define XFS_UQUOTA_ENFD 0x0002 /* user quota limits enforced */ 155#define XFS_UQUOTA_ENFD 0x0002 /* user quota limits enforced */
154#define XFS_UQUOTA_CHKD 0x0004 /* quotacheck run on usr quotas */ 156#define XFS_UQUOTA_CHKD 0x0004 /* quotacheck run on usr quotas */
155#define XFS_PQUOTA_ACCT 0x0008 /* (IRIX) project quota accounting ON */ 157#define XFS_PQUOTA_ACCT 0x0008 /* project quota accounting ON */
156#define XFS_GQUOTA_ENFD 0x0010 /* group quota limits enforced */ 158#define XFS_OQUOTA_ENFD 0x0010 /* other (grp/prj) quota limits enforced */
157#define XFS_GQUOTA_CHKD 0x0020 /* quotacheck run on grp quotas */ 159#define XFS_OQUOTA_CHKD 0x0020 /* quotacheck run on other (grp/prj) quotas */
158#define XFS_GQUOTA_ACCT 0x0040 /* group quota accounting ON */ 160#define XFS_GQUOTA_ACCT 0x0040 /* group quota accounting ON */
159 161
160/* 162/*
@@ -162,17 +164,22 @@ typedef struct xfs_qoff_logformat {
162 * are in the process of getting turned off. These flags are in m_qflags but 164 * are in the process of getting turned off. These flags are in m_qflags but
163 * never in sb_qflags. 165 * never in sb_qflags.
164 */ 166 */
165#define XFS_UQUOTA_ACTIVE 0x0080 /* uquotas are being turned off */ 167#define XFS_UQUOTA_ACTIVE 0x0100 /* uquotas are being turned off */
166#define XFS_GQUOTA_ACTIVE 0x0100 /* gquotas are being turned off */ 168#define XFS_PQUOTA_ACTIVE 0x0200 /* pquotas are being turned off */
169#define XFS_GQUOTA_ACTIVE 0x0400 /* gquotas are being turned off */
167 170
168/* 171/*
169 * Checking XFS_IS_*QUOTA_ON() while holding any inode lock guarantees 172 * Checking XFS_IS_*QUOTA_ON() while holding any inode lock guarantees
170 * quota will be not be switched off as long as that inode lock is held. 173 * quota will be not be switched off as long as that inode lock is held.
171 */ 174 */
172#define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & (XFS_UQUOTA_ACTIVE | \ 175#define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & (XFS_UQUOTA_ACTIVE | \
173 XFS_GQUOTA_ACTIVE)) 176 XFS_GQUOTA_ACTIVE | \
177 XFS_PQUOTA_ACTIVE))
178#define XFS_IS_OQUOTA_ON(mp) ((mp)->m_qflags & (XFS_GQUOTA_ACTIVE | \
179 XFS_PQUOTA_ACTIVE))
174#define XFS_IS_UQUOTA_ON(mp) ((mp)->m_qflags & XFS_UQUOTA_ACTIVE) 180#define XFS_IS_UQUOTA_ON(mp) ((mp)->m_qflags & XFS_UQUOTA_ACTIVE)
175#define XFS_IS_GQUOTA_ON(mp) ((mp)->m_qflags & XFS_GQUOTA_ACTIVE) 181#define XFS_IS_GQUOTA_ON(mp) ((mp)->m_qflags & XFS_GQUOTA_ACTIVE)
182#define XFS_IS_PQUOTA_ON(mp) ((mp)->m_qflags & XFS_PQUOTA_ACTIVE)
176 183
177/* 184/*
178 * Flags to tell various functions what to do. Not all of these are meaningful 185 * Flags to tell various functions what to do. Not all of these are meaningful
@@ -182,7 +189,7 @@ typedef struct xfs_qoff_logformat {
182#define XFS_QMOPT_DQLOCK 0x0000001 /* dqlock */ 189#define XFS_QMOPT_DQLOCK 0x0000001 /* dqlock */
183#define XFS_QMOPT_DQALLOC 0x0000002 /* alloc dquot ondisk if needed */ 190#define XFS_QMOPT_DQALLOC 0x0000002 /* alloc dquot ondisk if needed */
184#define XFS_QMOPT_UQUOTA 0x0000004 /* user dquot requested */ 191#define XFS_QMOPT_UQUOTA 0x0000004 /* user dquot requested */
185#define XFS_QMOPT_GQUOTA 0x0000008 /* group dquot requested */ 192#define XFS_QMOPT_PQUOTA 0x0000008 /* project dquot requested */
186#define XFS_QMOPT_FORCE_RES 0x0000010 /* ignore quota limits */ 193#define XFS_QMOPT_FORCE_RES 0x0000010 /* ignore quota limits */
187#define XFS_QMOPT_DQSUSER 0x0000020 /* don't cache super users dquot */ 194#define XFS_QMOPT_DQSUSER 0x0000020 /* don't cache super users dquot */
188#define XFS_QMOPT_SBVERSION 0x0000040 /* change superblock version num */ 195#define XFS_QMOPT_SBVERSION 0x0000040 /* change superblock version num */
@@ -192,6 +199,7 @@ typedef struct xfs_qoff_logformat {
192#define XFS_QMOPT_DOWARN 0x0000400 /* increase warning cnt if necessary */ 199#define XFS_QMOPT_DOWARN 0x0000400 /* increase warning cnt if necessary */
193#define XFS_QMOPT_ILOCKED 0x0000800 /* inode is already locked (excl) */ 200#define XFS_QMOPT_ILOCKED 0x0000800 /* inode is already locked (excl) */
194#define XFS_QMOPT_DQREPAIR 0x0001000 /* repair dquot, if damaged. */ 201#define XFS_QMOPT_DQREPAIR 0x0001000 /* repair dquot, if damaged. */
202#define XFS_QMOPT_GQUOTA 0x0002000 /* group dquot requested */
195 203
196/* 204/*
197 * flags to xfs_trans_mod_dquot to indicate which field needs to be 205 * flags to xfs_trans_mod_dquot to indicate which field needs to be
@@ -231,7 +239,8 @@ typedef struct xfs_qoff_logformat {
231#define XFS_TRANS_DQ_DELRTBCOUNT XFS_QMOPT_DELRTBCOUNT 239#define XFS_TRANS_DQ_DELRTBCOUNT XFS_QMOPT_DELRTBCOUNT
232 240
233 241
234#define XFS_QMOPT_QUOTALL (XFS_QMOPT_UQUOTA|XFS_QMOPT_GQUOTA) 242#define XFS_QMOPT_QUOTALL \
243 (XFS_QMOPT_UQUOTA | XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA)
235#define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS) 244#define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS)
236 245
237#ifdef __KERNEL__ 246#ifdef __KERNEL__
@@ -246,21 +255,33 @@ typedef struct xfs_qoff_logformat {
246 */ 255 */
247#define XFS_NOT_DQATTACHED(mp, ip) ((XFS_IS_UQUOTA_ON(mp) &&\ 256#define XFS_NOT_DQATTACHED(mp, ip) ((XFS_IS_UQUOTA_ON(mp) &&\
248 (ip)->i_udquot == NULL) || \ 257 (ip)->i_udquot == NULL) || \
249 (XFS_IS_GQUOTA_ON(mp) && \ 258 (XFS_IS_OQUOTA_ON(mp) && \
250 (ip)->i_gdquot == NULL)) 259 (ip)->i_gdquot == NULL))
251 260
252#define XFS_QM_NEED_QUOTACHECK(mp) ((XFS_IS_UQUOTA_ON(mp) && \ 261#define XFS_QM_NEED_QUOTACHECK(mp) \
253 (mp->m_sb.sb_qflags & \ 262 ((XFS_IS_UQUOTA_ON(mp) && \
254 XFS_UQUOTA_CHKD) == 0) || \ 263 (mp->m_sb.sb_qflags & XFS_UQUOTA_CHKD) == 0) || \
255 (XFS_IS_GQUOTA_ON(mp) && \ 264 (XFS_IS_GQUOTA_ON(mp) && \
256 (mp->m_sb.sb_qflags & \ 265 ((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \
257 XFS_GQUOTA_CHKD) == 0)) 266 (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT))) || \
267 (XFS_IS_PQUOTA_ON(mp) && \
268 ((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \
269 (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT))))
270
271#define XFS_MOUNT_QUOTA_SET1 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
272 XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\
273 XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD)
274
275#define XFS_MOUNT_QUOTA_SET2 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
276 XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\
277 XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD)
258 278
259#define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ 279#define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
260 XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\ 280 XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\
261 XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD) 281 XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD|\
282 XFS_GQUOTA_ACCT)
262#define XFS_MOUNT_QUOTA_MASK (XFS_MOUNT_QUOTA_ALL | XFS_UQUOTA_ACTIVE | \ 283#define XFS_MOUNT_QUOTA_MASK (XFS_MOUNT_QUOTA_ALL | XFS_UQUOTA_ACTIVE | \
263 XFS_GQUOTA_ACTIVE) 284 XFS_GQUOTA_ACTIVE | XFS_PQUOTA_ACTIVE)
264 285
265 286
266/* 287/*
@@ -331,15 +352,8 @@ typedef struct xfs_dqtrxops {
331#define XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(mp, tp) \ 352#define XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(mp, tp) \
332 XFS_DQTRXOP_VOID(mp, tp, qo_unreserve_and_mod_dquots) 353 XFS_DQTRXOP_VOID(mp, tp, qo_unreserve_and_mod_dquots)
333 354
334#define XFS_TRANS_RESERVE_BLKQUOTA(mp, tp, ip, nblks) \ 355#define XFS_TRANS_UNRESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, ninos, flags) \
335 XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, 0, \ 356 XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, -(nblks), -(ninos), flags)
336 XFS_QMOPT_RES_REGBLKS)
337#define XFS_TRANS_RESERVE_BLKQUOTA_FORCE(mp, tp, ip, nblks) \
338 XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, 0, \
339 XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES)
340#define XFS_TRANS_UNRESERVE_BLKQUOTA(mp, tp, ip, nblks) \
341 XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, -(nblks), 0, \
342 XFS_QMOPT_RES_REGBLKS)
343#define XFS_TRANS_RESERVE_QUOTA(mp, tp, ud, gd, nb, ni, f) \ 357#define XFS_TRANS_RESERVE_QUOTA(mp, tp, ud, gd, nb, ni, f) \
344 XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, nb, ni, \ 358 XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, nb, ni, \
345 f | XFS_QMOPT_RES_REGBLKS) 359 f | XFS_QMOPT_RES_REGBLKS)
diff --git a/fs/xfs/xfs_rename.c b/fs/xfs/xfs_rename.c
index cb13f9a1d45b..23b48ac1cb7e 100644
--- a/fs/xfs/xfs_rename.c
+++ b/fs/xfs/xfs_rename.c
@@ -234,9 +234,6 @@ xfs_lock_for_rename(
234 return 0; 234 return 0;
235} 235}
236 236
237
238int rename_which_error_return = 0;
239
240/* 237/*
241 * xfs_rename 238 * xfs_rename
242 */ 239 */
@@ -316,7 +313,6 @@ xfs_rename(
316 &num_inodes); 313 &num_inodes);
317 314
318 if (error) { 315 if (error) {
319 rename_which_error_return = __LINE__;
320 /* 316 /*
321 * We have nothing locked, no inode references, and 317 * We have nothing locked, no inode references, and
322 * no transaction, so just get out. 318 * no transaction, so just get out.
@@ -332,7 +328,6 @@ xfs_rename(
332 */ 328 */
333 if (target_ip == NULL && (src_dp != target_dp) && 329 if (target_ip == NULL && (src_dp != target_dp) &&
334 target_dp->i_d.di_nlink >= XFS_MAXLINK) { 330 target_dp->i_d.di_nlink >= XFS_MAXLINK) {
335 rename_which_error_return = __LINE__;
336 error = XFS_ERROR(EMLINK); 331 error = XFS_ERROR(EMLINK);
337 xfs_rename_unlock4(inodes, XFS_ILOCK_SHARED); 332 xfs_rename_unlock4(inodes, XFS_ILOCK_SHARED);
338 goto rele_return; 333 goto rele_return;
@@ -359,7 +354,6 @@ xfs_rename(
359 XFS_TRANS_PERM_LOG_RES, XFS_RENAME_LOG_COUNT); 354 XFS_TRANS_PERM_LOG_RES, XFS_RENAME_LOG_COUNT);
360 } 355 }
361 if (error) { 356 if (error) {
362 rename_which_error_return = __LINE__;
363 xfs_trans_cancel(tp, 0); 357 xfs_trans_cancel(tp, 0);
364 goto rele_return; 358 goto rele_return;
365 } 359 }
@@ -369,7 +363,6 @@ xfs_rename(
369 */ 363 */
370 if ((error = XFS_QM_DQVOPRENAME(mp, inodes))) { 364 if ((error = XFS_QM_DQVOPRENAME(mp, inodes))) {
371 xfs_trans_cancel(tp, cancel_flags); 365 xfs_trans_cancel(tp, cancel_flags);
372 rename_which_error_return = __LINE__;
373 goto rele_return; 366 goto rele_return;
374 } 367 }
375 368
@@ -413,7 +406,6 @@ xfs_rename(
413 if (spaceres == 0 && 406 if (spaceres == 0 &&
414 (error = XFS_DIR_CANENTER(mp, tp, target_dp, target_name, 407 (error = XFS_DIR_CANENTER(mp, tp, target_dp, target_name,
415 target_namelen))) { 408 target_namelen))) {
416 rename_which_error_return = __LINE__;
417 goto error_return; 409 goto error_return;
418 } 410 }
419 /* 411 /*
@@ -425,11 +417,9 @@ xfs_rename(
425 target_namelen, src_ip->i_ino, 417 target_namelen, src_ip->i_ino,
426 &first_block, &free_list, spaceres); 418 &first_block, &free_list, spaceres);
427 if (error == ENOSPC) { 419 if (error == ENOSPC) {
428 rename_which_error_return = __LINE__;
429 goto error_return; 420 goto error_return;
430 } 421 }
431 if (error) { 422 if (error) {
432 rename_which_error_return = __LINE__;
433 goto abort_return; 423 goto abort_return;
434 } 424 }
435 xfs_ichgtime(target_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); 425 xfs_ichgtime(target_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
@@ -437,7 +427,6 @@ xfs_rename(
437 if (new_parent && src_is_directory) { 427 if (new_parent && src_is_directory) {
438 error = xfs_bumplink(tp, target_dp); 428 error = xfs_bumplink(tp, target_dp);
439 if (error) { 429 if (error) {
440 rename_which_error_return = __LINE__;
441 goto abort_return; 430 goto abort_return;
442 } 431 }
443 } 432 }
@@ -455,7 +444,6 @@ xfs_rename(
455 if (!(XFS_DIR_ISEMPTY(target_ip->i_mount, target_ip)) || 444 if (!(XFS_DIR_ISEMPTY(target_ip->i_mount, target_ip)) ||
456 (target_ip->i_d.di_nlink > 2)) { 445 (target_ip->i_d.di_nlink > 2)) {
457 error = XFS_ERROR(EEXIST); 446 error = XFS_ERROR(EEXIST);
458 rename_which_error_return = __LINE__;
459 goto error_return; 447 goto error_return;
460 } 448 }
461 } 449 }
@@ -473,7 +461,6 @@ xfs_rename(
473 target_namelen, src_ip->i_ino, &first_block, 461 target_namelen, src_ip->i_ino, &first_block,
474 &free_list, spaceres); 462 &free_list, spaceres);
475 if (error) { 463 if (error) {
476 rename_which_error_return = __LINE__;
477 goto abort_return; 464 goto abort_return;
478 } 465 }
479 xfs_ichgtime(target_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); 466 xfs_ichgtime(target_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
@@ -484,7 +471,6 @@ xfs_rename(
484 */ 471 */
485 error = xfs_droplink(tp, target_ip); 472 error = xfs_droplink(tp, target_ip);
486 if (error) { 473 if (error) {
487 rename_which_error_return = __LINE__;
488 goto abort_return; 474 goto abort_return;
489 } 475 }
490 target_ip_dropped = 1; 476 target_ip_dropped = 1;
@@ -495,7 +481,6 @@ xfs_rename(
495 */ 481 */
496 error = xfs_droplink(tp, target_ip); 482 error = xfs_droplink(tp, target_ip);
497 if (error) { 483 if (error) {
498 rename_which_error_return = __LINE__;
499 goto abort_return; 484 goto abort_return;
500 } 485 }
501 } 486 }
@@ -519,7 +504,6 @@ xfs_rename(
519 &free_list, spaceres); 504 &free_list, spaceres);
520 ASSERT(error != EEXIST); 505 ASSERT(error != EEXIST);
521 if (error) { 506 if (error) {
522 rename_which_error_return = __LINE__;
523 goto abort_return; 507 goto abort_return;
524 } 508 }
525 xfs_ichgtime(src_ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); 509 xfs_ichgtime(src_ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
@@ -550,7 +534,6 @@ xfs_rename(
550 */ 534 */
551 error = xfs_droplink(tp, src_dp); 535 error = xfs_droplink(tp, src_dp);
552 if (error) { 536 if (error) {
553 rename_which_error_return = __LINE__;
554 goto abort_return; 537 goto abort_return;
555 } 538 }
556 } 539 }
@@ -558,7 +541,6 @@ xfs_rename(
558 error = XFS_DIR_REMOVENAME(mp, tp, src_dp, src_name, src_namelen, 541 error = XFS_DIR_REMOVENAME(mp, tp, src_dp, src_name, src_namelen,
559 src_ip->i_ino, &first_block, &free_list, spaceres); 542 src_ip->i_ino, &first_block, &free_list, spaceres);
560 if (error) { 543 if (error) {
561 rename_which_error_return = __LINE__;
562 goto abort_return; 544 goto abort_return;
563 } 545 }
564 xfs_ichgtime(src_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); 546 xfs_ichgtime(src_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 3db0e2200775..06dfca531f79 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -332,25 +332,6 @@ undo_blocks:
332 332
333 333
334/* 334/*
335 * This is called to set the a callback to be called when the given
336 * transaction is committed to disk. The transaction pointer and the
337 * argument pointer will be passed to the callback routine.
338 *
339 * Only one callback can be associated with any single transaction.
340 */
341void
342xfs_trans_callback(
343 xfs_trans_t *tp,
344 xfs_trans_callback_t callback,
345 void *arg)
346{
347 ASSERT(tp->t_callback == NULL);
348 tp->t_callback = callback;
349 tp->t_callarg = arg;
350}
351
352
353/*
354 * Record the indicated change to the given field for application 335 * Record the indicated change to the given field for application
355 * to the file system's superblock when the transaction commits. 336 * to the file system's superblock when the transaction commits.
356 * For now, just store the change in the transaction structure. 337 * For now, just store the change in the transaction structure.
@@ -551,7 +532,7 @@ xfs_trans_apply_sb_deltas(
551 * 532 *
552 * This is done efficiently with a single call to xfs_mod_incore_sb_batch(). 533 * This is done efficiently with a single call to xfs_mod_incore_sb_batch().
553 */ 534 */
554void 535STATIC void
555xfs_trans_unreserve_and_mod_sb( 536xfs_trans_unreserve_and_mod_sb(
556 xfs_trans_t *tp) 537 xfs_trans_t *tp)
557{ 538{
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index bd37ccb85e76..ec541d66fa2a 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -987,8 +987,6 @@ xfs_trans_t *_xfs_trans_alloc(struct xfs_mount *, uint);
987xfs_trans_t *xfs_trans_dup(xfs_trans_t *); 987xfs_trans_t *xfs_trans_dup(xfs_trans_t *);
988int xfs_trans_reserve(xfs_trans_t *, uint, uint, uint, 988int xfs_trans_reserve(xfs_trans_t *, uint, uint, uint,
989 uint, uint); 989 uint, uint);
990void xfs_trans_callback(xfs_trans_t *,
991 void (*)(xfs_trans_t *, void *), void *);
992void xfs_trans_mod_sb(xfs_trans_t *, uint, long); 990void xfs_trans_mod_sb(xfs_trans_t *, uint, long);
993struct xfs_buf *xfs_trans_get_buf(xfs_trans_t *, struct xfs_buftarg *, xfs_daddr_t, 991struct xfs_buf *xfs_trans_get_buf(xfs_trans_t *, struct xfs_buftarg *, xfs_daddr_t,
994 int, uint); 992 int, uint);
@@ -1010,7 +1008,6 @@ int xfs_trans_iget(struct xfs_mount *, xfs_trans_t *,
1010 xfs_ino_t , uint, uint, struct xfs_inode **); 1008 xfs_ino_t , uint, uint, struct xfs_inode **);
1011void xfs_trans_ijoin(xfs_trans_t *, struct xfs_inode *, uint); 1009void xfs_trans_ijoin(xfs_trans_t *, struct xfs_inode *, uint);
1012void xfs_trans_ihold(xfs_trans_t *, struct xfs_inode *); 1010void xfs_trans_ihold(xfs_trans_t *, struct xfs_inode *);
1013void xfs_trans_ihold_release(xfs_trans_t *, struct xfs_inode *);
1014void xfs_trans_log_buf(xfs_trans_t *, struct xfs_buf *, uint, uint); 1011void xfs_trans_log_buf(xfs_trans_t *, struct xfs_buf *, uint, uint);
1015void xfs_trans_log_inode(xfs_trans_t *, struct xfs_inode *, uint); 1012void xfs_trans_log_inode(xfs_trans_t *, struct xfs_inode *, uint);
1016struct xfs_efi_log_item *xfs_trans_get_efi(xfs_trans_t *, uint); 1013struct xfs_efi_log_item *xfs_trans_get_efi(xfs_trans_t *, uint);
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index a9682b9510c1..144da7a85466 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -976,6 +976,7 @@ xfs_trans_dquot_buf(
976 ASSERT(XFS_BUF_FSPRIVATE2(bp, xfs_trans_t *) == tp); 976 ASSERT(XFS_BUF_FSPRIVATE2(bp, xfs_trans_t *) == tp);
977 ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL); 977 ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL);
978 ASSERT(type == XFS_BLI_UDQUOT_BUF || 978 ASSERT(type == XFS_BLI_UDQUOT_BUF ||
979 type == XFS_BLI_PDQUOT_BUF ||
979 type == XFS_BLI_GDQUOT_BUF); 980 type == XFS_BLI_GDQUOT_BUF);
980 981
981 bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *); 982 bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *);
diff --git a/fs/xfs/xfs_trans_inode.c b/fs/xfs/xfs_trans_inode.c
index e2c3706f453d..7e7631ca4979 100644
--- a/fs/xfs/xfs_trans_inode.c
+++ b/fs/xfs/xfs_trans_inode.c
@@ -253,24 +253,6 @@ xfs_trans_ihold(
253 ip->i_itemp->ili_flags |= XFS_ILI_HOLD; 253 ip->i_itemp->ili_flags |= XFS_ILI_HOLD;
254} 254}
255 255
256/*
257 * Cancel the previous inode hold request made on this inode
258 * for this transaction.
259 */
260/*ARGSUSED*/
261void
262xfs_trans_ihold_release(
263 xfs_trans_t *tp,
264 xfs_inode_t *ip)
265{
266 ASSERT(ip->i_transp == tp);
267 ASSERT(ip->i_itemp != NULL);
268 ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE));
269 ASSERT(ip->i_itemp->ili_flags & XFS_ILI_HOLD);
270
271 ip->i_itemp->ili_flags &= ~XFS_ILI_HOLD;
272}
273
274 256
275/* 257/*
276 * This is called to mark the fields indicated in fieldmask as needing 258 * This is called to mark the fields indicated in fieldmask as needing
diff --git a/fs/xfs/xfs_types.h b/fs/xfs/xfs_types.h
index e4bf711e48ff..16f5371ce102 100644
--- a/fs/xfs/xfs_types.h
+++ b/fs/xfs/xfs_types.h
@@ -55,7 +55,7 @@ typedef signed long long int __int64_t;
55typedef unsigned long long int __uint64_t; 55typedef unsigned long long int __uint64_t;
56 56
57typedef enum { B_FALSE,B_TRUE } boolean_t; 57typedef enum { B_FALSE,B_TRUE } boolean_t;
58typedef __int64_t prid_t; /* project ID */ 58typedef __uint32_t prid_t; /* project ID */
59typedef __uint32_t inst_t; /* an instruction */ 59typedef __uint32_t inst_t; /* an instruction */
60 60
61typedef __s64 xfs_off_t; /* <file offset> type */ 61typedef __s64 xfs_off_t; /* <file offset> type */
diff --git a/fs/xfs/xfs_utils.c b/fs/xfs/xfs_utils.c
index d1f8146a06ea..11351f08d438 100644
--- a/fs/xfs/xfs_utils.c
+++ b/fs/xfs/xfs_utils.c
@@ -428,7 +428,7 @@ xfs_truncate_file(
428 if (ip->i_ino != mp->m_sb.sb_uquotino) 428 if (ip->i_ino != mp->m_sb.sb_uquotino)
429 ASSERT(ip->i_udquot); 429 ASSERT(ip->i_udquot);
430 } 430 }
431 if (XFS_IS_GQUOTA_ON(mp)) { 431 if (XFS_IS_OQUOTA_ON(mp)) {
432 if (ip->i_ino != mp->m_sb.sb_gquotino) 432 if (ip->i_ino != mp->m_sb.sb_gquotino)
433 ASSERT(ip->i_gdquot); 433 ASSERT(ip->i_gdquot);
434 } 434 }
diff --git a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c
index b53736650100..42bcc0215203 100644
--- a/fs/xfs/xfs_vfsops.c
+++ b/fs/xfs/xfs_vfsops.c
@@ -368,16 +368,6 @@ xfs_finish_flags(
368 } 368 }
369 369
370 /* 370 /*
371 * disallow mount attempts with (IRIX) project quota enabled
372 */
373 if (XFS_SB_VERSION_HASQUOTA(&mp->m_sb) &&
374 (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT)) {
375 cmn_err(CE_WARN,
376 "XFS: cannot mount a filesystem with IRIX project quota enabled");
377 return XFS_ERROR(ENOSYS);
378 }
379
380 /*
381 * check for shared mount. 371 * check for shared mount.
382 */ 372 */
383 if (ap->flags & XFSMNT_SHARED) { 373 if (ap->flags & XFSMNT_SHARED) {
@@ -622,7 +612,34 @@ out:
622 return XFS_ERROR(error); 612 return XFS_ERROR(error);
623} 613}
624 614
625#define REMOUNT_READONLY_FLAGS (SYNC_REMOUNT|SYNC_ATTR|SYNC_WAIT) 615STATIC int
616xfs_quiesce_fs(
617 xfs_mount_t *mp)
618{
619 int count = 0, pincount;
620
621 xfs_refcache_purge_mp(mp);
622 xfs_flush_buftarg(mp->m_ddev_targp, 0);
623 xfs_finish_reclaim_all(mp, 0);
624
625 /* This loop must run at least twice.
626 * The first instance of the loop will flush
627 * most meta data but that will generate more
628 * meta data (typically directory updates).
629 * Which then must be flushed and logged before
630 * we can write the unmount record.
631 */
632 do {
633 xfs_syncsub(mp, SYNC_REMOUNT|SYNC_ATTR|SYNC_WAIT, 0, NULL);
634 pincount = xfs_flush_buftarg(mp->m_ddev_targp, 1);
635 if (!pincount) {
636 delay(50);
637 count++;
638 }
639 } while (count < 2);
640
641 return 0;
642}
626 643
627STATIC int 644STATIC int
628xfs_mntupdate( 645xfs_mntupdate(
@@ -632,8 +649,7 @@ xfs_mntupdate(
632{ 649{
633 struct vfs *vfsp = bhvtovfs(bdp); 650 struct vfs *vfsp = bhvtovfs(bdp);
634 xfs_mount_t *mp = XFS_BHVTOM(bdp); 651 xfs_mount_t *mp = XFS_BHVTOM(bdp);
635 int pincount, error; 652 int error;
636 int count = 0;
637 653
638 if (args->flags & XFSMNT_NOATIME) 654 if (args->flags & XFSMNT_NOATIME)
639 mp->m_flags |= XFS_MOUNT_NOATIME; 655 mp->m_flags |= XFS_MOUNT_NOATIME;
@@ -645,25 +661,7 @@ xfs_mntupdate(
645 } 661 }
646 662
647 if (*flags & MS_RDONLY) { 663 if (*flags & MS_RDONLY) {
648 xfs_refcache_purge_mp(mp); 664 xfs_quiesce_fs(mp);
649 xfs_flush_buftarg(mp->m_ddev_targp, 0);
650 xfs_finish_reclaim_all(mp, 0);
651
652 /* This loop must run at least twice.
653 * The first instance of the loop will flush
654 * most meta data but that will generate more
655 * meta data (typically directory updates).
656 * Which then must be flushed and logged before
657 * we can write the unmount record.
658 */
659 do {
660 VFS_SYNC(vfsp, REMOUNT_READONLY_FLAGS, NULL, error);
661 pincount = xfs_flush_buftarg(mp->m_ddev_targp, 1);
662 if (!pincount) {
663 delay(50);
664 count++;
665 }
666 } while (count < 2);
667 665
668 /* Ok now write out an unmount record */ 666 /* Ok now write out an unmount record */
669 xfs_log_unmount_write(mp); 667 xfs_log_unmount_write(mp);
@@ -879,10 +877,12 @@ xfs_sync(
879 int flags, 877 int flags,
880 cred_t *credp) 878 cred_t *credp)
881{ 879{
882 xfs_mount_t *mp; 880 xfs_mount_t *mp = XFS_BHVTOM(bdp);
883 881
884 mp = XFS_BHVTOM(bdp); 882 if (unlikely(flags == SYNC_QUIESCE))
885 return (xfs_syncsub(mp, flags, 0, NULL)); 883 return xfs_quiesce_fs(mp);
884 else
885 return xfs_syncsub(mp, flags, 0, NULL);
886} 886}
887 887
888/* 888/*
@@ -1681,7 +1681,7 @@ suffix_strtoul(const char *cp, char **endp, unsigned int base)
1681 return simple_strtoul(cp, endp, base) << shift_left_factor; 1681 return simple_strtoul(cp, endp, base) << shift_left_factor;
1682} 1682}
1683 1683
1684int 1684STATIC int
1685xfs_parseargs( 1685xfs_parseargs(
1686 struct bhv_desc *bhv, 1686 struct bhv_desc *bhv,
1687 char *options, 1687 char *options,
@@ -1867,7 +1867,7 @@ printk("XFS: irixsgid is now a sysctl(2) variable, option is deprecated.\n");
1867 return 0; 1867 return 0;
1868} 1868}
1869 1869
1870int 1870STATIC int
1871xfs_showargs( 1871xfs_showargs(
1872 struct bhv_desc *bhv, 1872 struct bhv_desc *bhv,
1873 struct seq_file *m) 1873 struct seq_file *m)
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 25a526629b12..1377c868f3f4 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as 5 * under the terms of version 2 of the GNU General Public License as
@@ -351,21 +351,28 @@ xfs_setattr(
351 * If the IDs do change before we take the ilock, we're covered 351 * If the IDs do change before we take the ilock, we're covered
352 * because the i_*dquot fields will get updated anyway. 352 * because the i_*dquot fields will get updated anyway.
353 */ 353 */
354 if (XFS_IS_QUOTA_ON(mp) && (mask & (XFS_AT_UID|XFS_AT_GID))) { 354 if (XFS_IS_QUOTA_ON(mp) &&
355 (mask & (XFS_AT_UID|XFS_AT_GID|XFS_AT_PROJID))) {
355 uint qflags = 0; 356 uint qflags = 0;
356 357
357 if (mask & XFS_AT_UID) { 358 if ((mask & XFS_AT_UID) && XFS_IS_UQUOTA_ON(mp)) {
358 uid = vap->va_uid; 359 uid = vap->va_uid;
359 qflags |= XFS_QMOPT_UQUOTA; 360 qflags |= XFS_QMOPT_UQUOTA;
360 } else { 361 } else {
361 uid = ip->i_d.di_uid; 362 uid = ip->i_d.di_uid;
362 } 363 }
363 if (mask & XFS_AT_GID) { 364 if ((mask & XFS_AT_GID) && XFS_IS_GQUOTA_ON(mp)) {
364 gid = vap->va_gid; 365 gid = vap->va_gid;
365 qflags |= XFS_QMOPT_GQUOTA; 366 qflags |= XFS_QMOPT_GQUOTA;
366 } else { 367 } else {
367 gid = ip->i_d.di_gid; 368 gid = ip->i_d.di_gid;
368 } 369 }
370 if ((mask & XFS_AT_PROJID) && XFS_IS_PQUOTA_ON(mp)) {
371 projid = vap->va_projid;
372 qflags |= XFS_QMOPT_PQUOTA;
373 } else {
374 projid = ip->i_d.di_projid;
375 }
369 /* 376 /*
370 * We take a reference when we initialize udqp and gdqp, 377 * We take a reference when we initialize udqp and gdqp,
371 * so it is important that we never blindly double trip on 378 * so it is important that we never blindly double trip on
@@ -373,7 +380,8 @@ xfs_setattr(
373 */ 380 */
374 ASSERT(udqp == NULL); 381 ASSERT(udqp == NULL);
375 ASSERT(gdqp == NULL); 382 ASSERT(gdqp == NULL);
376 code = XFS_QM_DQVOPALLOC(mp, ip, uid,gid, qflags, &udqp, &gdqp); 383 code = XFS_QM_DQVOPALLOC(mp, ip, uid, gid, projid, qflags,
384 &udqp, &gdqp);
377 if (code) 385 if (code)
378 return (code); 386 return (code);
379 } 387 }
@@ -499,8 +507,6 @@ xfs_setattr(
499 * that the group ID supplied to the chown() function 507 * that the group ID supplied to the chown() function
500 * shall be equal to either the group ID or one of the 508 * shall be equal to either the group ID or one of the
501 * supplementary group IDs of the calling process. 509 * supplementary group IDs of the calling process.
502 *
503 * XXX: How does restricted_chown affect projid?
504 */ 510 */
505 if (restricted_chown && 511 if (restricted_chown &&
506 (iuid != uid || (igid != gid && 512 (iuid != uid || (igid != gid &&
@@ -510,10 +516,11 @@ xfs_setattr(
510 goto error_return; 516 goto error_return;
511 } 517 }
512 /* 518 /*
513 * Do a quota reservation only if uid or gid is actually 519 * Do a quota reservation only if uid/projid/gid is actually
514 * going to change. 520 * going to change.
515 */ 521 */
516 if ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) || 522 if ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
523 (XFS_IS_PQUOTA_ON(mp) && iprojid != projid) ||
517 (XFS_IS_GQUOTA_ON(mp) && igid != gid)) { 524 (XFS_IS_GQUOTA_ON(mp) && igid != gid)) {
518 ASSERT(tp); 525 ASSERT(tp);
519 code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp, 526 code = XFS_QM_DQVOPCHOWNRESV(mp, tp, ip, udqp, gdqp,
@@ -774,6 +781,7 @@ xfs_setattr(
774 } 781 }
775 if (igid != gid) { 782 if (igid != gid) {
776 if (XFS_IS_GQUOTA_ON(mp)) { 783 if (XFS_IS_GQUOTA_ON(mp)) {
784 ASSERT(!XFS_IS_PQUOTA_ON(mp));
777 ASSERT(mask & XFS_AT_GID); 785 ASSERT(mask & XFS_AT_GID);
778 ASSERT(gdqp); 786 ASSERT(gdqp);
779 olddquot2 = XFS_QM_DQVOPCHOWN(mp, tp, ip, 787 olddquot2 = XFS_QM_DQVOPCHOWN(mp, tp, ip,
@@ -782,6 +790,13 @@ xfs_setattr(
782 ip->i_d.di_gid = gid; 790 ip->i_d.di_gid = gid;
783 } 791 }
784 if (iprojid != projid) { 792 if (iprojid != projid) {
793 if (XFS_IS_PQUOTA_ON(mp)) {
794 ASSERT(!XFS_IS_GQUOTA_ON(mp));
795 ASSERT(mask & XFS_AT_PROJID);
796 ASSERT(gdqp);
797 olddquot2 = XFS_QM_DQVOPCHOWN(mp, tp, ip,
798 &ip->i_gdquot, gdqp);
799 }
785 ip->i_d.di_projid = projid; 800 ip->i_d.di_projid = projid;
786 /* 801 /*
787 * We may have to rev the inode as well as 802 * We may have to rev the inode as well as
@@ -843,6 +858,8 @@ xfs_setattr(
843 di_flags |= XFS_DIFLAG_NOATIME; 858 di_flags |= XFS_DIFLAG_NOATIME;
844 if (vap->va_xflags & XFS_XFLAG_NODUMP) 859 if (vap->va_xflags & XFS_XFLAG_NODUMP)
845 di_flags |= XFS_DIFLAG_NODUMP; 860 di_flags |= XFS_DIFLAG_NODUMP;
861 if (vap->va_xflags & XFS_XFLAG_PROJINHERIT)
862 di_flags |= XFS_DIFLAG_PROJINHERIT;
846 if ((ip->i_d.di_mode & S_IFMT) == S_IFDIR) { 863 if ((ip->i_d.di_mode & S_IFMT) == S_IFDIR) {
847 if (vap->va_xflags & XFS_XFLAG_RTINHERIT) 864 if (vap->va_xflags & XFS_XFLAG_RTINHERIT)
848 di_flags |= XFS_DIFLAG_RTINHERIT; 865 di_flags |= XFS_DIFLAG_RTINHERIT;
@@ -1898,7 +1915,9 @@ xfs_create(
1898 /* Return through std_return after this point. */ 1915 /* Return through std_return after this point. */
1899 1916
1900 udqp = gdqp = NULL; 1917 udqp = gdqp = NULL;
1901 if (vap->va_mask & XFS_AT_PROJID) 1918 if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
1919 prid = dp->i_d.di_projid;
1920 else if (vap->va_mask & XFS_AT_PROJID)
1902 prid = (xfs_prid_t)vap->va_projid; 1921 prid = (xfs_prid_t)vap->va_projid;
1903 else 1922 else
1904 prid = (xfs_prid_t)dfltprid; 1923 prid = (xfs_prid_t)dfltprid;
@@ -1907,7 +1926,7 @@ xfs_create(
1907 * Make sure that we have allocated dquot(s) on disk. 1926 * Make sure that we have allocated dquot(s) on disk.
1908 */ 1927 */
1909 error = XFS_QM_DQVOPALLOC(mp, dp, 1928 error = XFS_QM_DQVOPALLOC(mp, dp,
1910 current_fsuid(credp), current_fsgid(credp), 1929 current_fsuid(credp), current_fsgid(credp), prid,
1911 XFS_QMOPT_QUOTALL|XFS_QMOPT_INHERIT, &udqp, &gdqp); 1930 XFS_QMOPT_QUOTALL|XFS_QMOPT_INHERIT, &udqp, &gdqp);
1912 if (error) 1931 if (error)
1913 goto std_return; 1932 goto std_return;
@@ -2604,17 +2623,7 @@ xfs_link(
2604 if (src_vp->v_type == VDIR) 2623 if (src_vp->v_type == VDIR)
2605 return XFS_ERROR(EPERM); 2624 return XFS_ERROR(EPERM);
2606 2625
2607 /*
2608 * For now, manually find the XFS behavior descriptor for
2609 * the source vnode. If it doesn't exist then something
2610 * is wrong and we should just return an error.
2611 * Eventually we need to figure out how link is going to
2612 * work in the face of stacked vnodes.
2613 */
2614 src_bdp = vn_bhv_lookup_unlocked(VN_BHV_HEAD(src_vp), &xfs_vnodeops); 2626 src_bdp = vn_bhv_lookup_unlocked(VN_BHV_HEAD(src_vp), &xfs_vnodeops);
2615 if (src_bdp == NULL) {
2616 return XFS_ERROR(EXDEV);
2617 }
2618 sip = XFS_BHVTOI(src_bdp); 2627 sip = XFS_BHVTOI(src_bdp);
2619 tdp = XFS_BHVTOI(target_dir_bdp); 2628 tdp = XFS_BHVTOI(target_dir_bdp);
2620 mp = tdp->i_mount; 2629 mp = tdp->i_mount;
@@ -2681,6 +2690,17 @@ xfs_link(
2681 goto error_return; 2690 goto error_return;
2682 } 2691 }
2683 2692
2693 /*
2694 * If we are using project inheritance, we only allow hard link
2695 * creation in our tree when the project IDs are the same; else
2696 * the tree quota mechanism could be circumvented.
2697 */
2698 if (unlikely((tdp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
2699 (tdp->i_d.di_projid != sip->i_d.di_projid))) {
2700 error = XFS_ERROR(EPERM);
2701 goto error_return;
2702 }
2703
2684 if (resblks == 0 && 2704 if (resblks == 0 &&
2685 (error = XFS_DIR_CANENTER(mp, tp, tdp, target_name, 2705 (error = XFS_DIR_CANENTER(mp, tp, tdp, target_name,
2686 target_namelen))) 2706 target_namelen)))
@@ -2803,7 +2823,9 @@ xfs_mkdir(
2803 2823
2804 mp = dp->i_mount; 2824 mp = dp->i_mount;
2805 udqp = gdqp = NULL; 2825 udqp = gdqp = NULL;
2806 if (vap->va_mask & XFS_AT_PROJID) 2826 if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
2827 prid = dp->i_d.di_projid;
2828 else if (vap->va_mask & XFS_AT_PROJID)
2807 prid = (xfs_prid_t)vap->va_projid; 2829 prid = (xfs_prid_t)vap->va_projid;
2808 else 2830 else
2809 prid = (xfs_prid_t)dfltprid; 2831 prid = (xfs_prid_t)dfltprid;
@@ -2812,7 +2834,7 @@ xfs_mkdir(
2812 * Make sure that we have allocated dquot(s) on disk. 2834 * Make sure that we have allocated dquot(s) on disk.
2813 */ 2835 */
2814 error = XFS_QM_DQVOPALLOC(mp, dp, 2836 error = XFS_QM_DQVOPALLOC(mp, dp,
2815 current_fsuid(credp), current_fsgid(credp), 2837 current_fsuid(credp), current_fsgid(credp), prid,
2816 XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp); 2838 XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp);
2817 if (error) 2839 if (error)
2818 goto std_return; 2840 goto std_return;
@@ -3357,7 +3379,9 @@ xfs_symlink(
3357 /* Return through std_return after this point. */ 3379 /* Return through std_return after this point. */
3358 3380
3359 udqp = gdqp = NULL; 3381 udqp = gdqp = NULL;
3360 if (vap->va_mask & XFS_AT_PROJID) 3382 if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
3383 prid = dp->i_d.di_projid;
3384 else if (vap->va_mask & XFS_AT_PROJID)
3361 prid = (xfs_prid_t)vap->va_projid; 3385 prid = (xfs_prid_t)vap->va_projid;
3362 else 3386 else
3363 prid = (xfs_prid_t)dfltprid; 3387 prid = (xfs_prid_t)dfltprid;
@@ -3366,7 +3390,7 @@ xfs_symlink(
3366 * Make sure that we have allocated dquot(s) on disk. 3390 * Make sure that we have allocated dquot(s) on disk.
3367 */ 3391 */
3368 error = XFS_QM_DQVOPALLOC(mp, dp, 3392 error = XFS_QM_DQVOPALLOC(mp, dp,
3369 current_fsuid(credp), current_fsgid(credp), 3393 current_fsuid(credp), current_fsgid(credp), prid,
3370 XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp); 3394 XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp);
3371 if (error) 3395 if (error)
3372 goto std_return; 3396 goto std_return;
@@ -4028,7 +4052,7 @@ xfs_finish_reclaim_all(xfs_mount_t *mp, int noblock)
4028 * errno on error 4052 * errno on error
4029 * 4053 *
4030 */ 4054 */
4031int 4055STATIC int
4032xfs_alloc_file_space( 4056xfs_alloc_file_space(
4033 xfs_inode_t *ip, 4057 xfs_inode_t *ip,
4034 xfs_off_t offset, 4058 xfs_off_t offset,
@@ -4151,9 +4175,8 @@ retry:
4151 break; 4175 break;
4152 } 4176 }
4153 xfs_ilock(ip, XFS_ILOCK_EXCL); 4177 xfs_ilock(ip, XFS_ILOCK_EXCL);
4154 error = XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, 4178 error = XFS_TRANS_RESERVE_QUOTA(mp, tp,
4155 ip->i_udquot, ip->i_gdquot, resblks, 0, rt ? 4179 ip->i_udquot, ip->i_gdquot, resblks, 0, 0);
4156 XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS);
4157 if (error) 4180 if (error)
4158 goto error1; 4181 goto error1;
4159 4182
@@ -4305,6 +4328,7 @@ xfs_free_file_space(
4305 xfs_off_t len, 4328 xfs_off_t len,
4306 int attr_flags) 4329 int attr_flags)
4307{ 4330{
4331 vnode_t *vp;
4308 int committed; 4332 int committed;
4309 int done; 4333 int done;
4310 xfs_off_t end_dmi_offset; 4334 xfs_off_t end_dmi_offset;
@@ -4325,9 +4349,11 @@ xfs_free_file_space(
4325 xfs_trans_t *tp; 4349 xfs_trans_t *tp;
4326 int need_iolock = 1; 4350 int need_iolock = 1;
4327 4351
4328 vn_trace_entry(XFS_ITOV(ip), __FUNCTION__, (inst_t *)__return_address); 4352 vp = XFS_ITOV(ip);
4329 mp = ip->i_mount; 4353 mp = ip->i_mount;
4330 4354
4355 vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
4356
4331 if ((error = XFS_QM_DQATTACH(mp, ip, 0))) 4357 if ((error = XFS_QM_DQATTACH(mp, ip, 0)))
4332 return error; 4358 return error;
4333 4359
@@ -4344,7 +4370,7 @@ xfs_free_file_space(
4344 DM_EVENT_ENABLED(XFS_MTOVFS(mp), ip, DM_EVENT_WRITE)) { 4370 DM_EVENT_ENABLED(XFS_MTOVFS(mp), ip, DM_EVENT_WRITE)) {
4345 if (end_dmi_offset > ip->i_d.di_size) 4371 if (end_dmi_offset > ip->i_d.di_size)
4346 end_dmi_offset = ip->i_d.di_size; 4372 end_dmi_offset = ip->i_d.di_size;
4347 error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, XFS_ITOV(ip), 4373 error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, vp,
4348 offset, end_dmi_offset - offset, 4374 offset, end_dmi_offset - offset,
4349 AT_DELAY_FLAG(attr_flags), NULL); 4375 AT_DELAY_FLAG(attr_flags), NULL);
4350 if (error) 4376 if (error)
@@ -4363,7 +4389,14 @@ xfs_free_file_space(
4363 ioffset = offset & ~(rounding - 1); 4389 ioffset = offset & ~(rounding - 1);
4364 if (ilen & (rounding - 1)) 4390 if (ilen & (rounding - 1))
4365 ilen = (ilen + rounding) & ~(rounding - 1); 4391 ilen = (ilen + rounding) & ~(rounding - 1);
4366 xfs_inval_cached_pages(XFS_ITOV(ip), &(ip->i_iocore), ioffset, 0, 0); 4392
4393 if (VN_CACHED(vp) != 0) {
4394 xfs_inval_cached_trace(&ip->i_iocore, ioffset, -1,
4395 ctooff(offtoct(ioffset)), -1);
4396 VOP_FLUSHINVAL_PAGES(vp, ctooff(offtoct(ioffset)),
4397 -1, FI_REMAPF_LOCKED);
4398 }
4399
4367 /* 4400 /*
4368 * Need to zero the stuff we're not freeing, on disk. 4401 * Need to zero the stuff we're not freeing, on disk.
4369 * If its a realtime file & can't use unwritten extents then we 4402 * If its a realtime file & can't use unwritten extents then we
diff --git a/include/asm-alpha/smp.h b/include/asm-alpha/smp.h
index cbc173ae45aa..9950706abdf8 100644
--- a/include/asm-alpha/smp.h
+++ b/include/asm-alpha/smp.h
@@ -43,7 +43,7 @@ extern struct cpuinfo_alpha cpu_data[NR_CPUS];
43#define PROC_CHANGE_PENALTY 20 43#define PROC_CHANGE_PENALTY 20
44 44
45#define hard_smp_processor_id() __hard_smp_processor_id() 45#define hard_smp_processor_id() __hard_smp_processor_id()
46#define smp_processor_id() (current_thread_info()->cpu) 46#define raw_smp_processor_id() (current_thread_info()->cpu)
47 47
48extern cpumask_t cpu_present_mask; 48extern cpumask_t cpu_present_mask;
49extern cpumask_t cpu_online_map; 49extern cpumask_t cpu_online_map;
diff --git a/include/asm-arm/arch-omap/tps65010.h b/include/asm-arm/arch-omap/tps65010.h
index 0f97bb2e8fce..b9aa2b3a3909 100644
--- a/include/asm-arm/arch-omap/tps65010.h
+++ b/include/asm-arm/arch-omap/tps65010.h
@@ -30,6 +30,66 @@
30 30
31/* 31/*
32 * ---------------------------------------------------------------------------- 32 * ----------------------------------------------------------------------------
33 * Registers, all 8 bits
34 * ----------------------------------------------------------------------------
35 */
36
37#define TPS_CHGSTATUS 0x01
38# define TPS_CHG_USB (1 << 7)
39# define TPS_CHG_AC (1 << 6)
40# define TPS_CHG_THERM (1 << 5)
41# define TPS_CHG_TERM (1 << 4)
42# define TPS_CHG_TAPER_TMO (1 << 3)
43# define TPS_CHG_CHG_TMO (1 << 2)
44# define TPS_CHG_PRECHG_TMO (1 << 1)
45# define TPS_CHG_TEMP_ERR (1 << 0)
46#define TPS_REGSTATUS 0x02
47# define TPS_REG_ONOFF (1 << 7)
48# define TPS_REG_COVER (1 << 6)
49# define TPS_REG_UVLO (1 << 5)
50# define TPS_REG_NO_CHG (1 << 4) /* tps65013 */
51# define TPS_REG_PG_LD02 (1 << 3)
52# define TPS_REG_PG_LD01 (1 << 2)
53# define TPS_REG_PG_MAIN (1 << 1)
54# define TPS_REG_PG_CORE (1 << 0)
55#define TPS_MASK1 0x03
56#define TPS_MASK2 0x04
57#define TPS_ACKINT1 0x05
58#define TPS_ACKINT2 0x06
59#define TPS_CHGCONFIG 0x07
60# define TPS_CHARGE_POR (1 << 7) /* 65010/65012 */
61# define TPS65013_AUA (1 << 7) /* 65011/65013 */
62# define TPS_CHARGE_RESET (1 << 6)
63# define TPS_CHARGE_FAST (1 << 5)
64# define TPS_CHARGE_CURRENT (3 << 3)
65# define TPS_VBUS_500MA (1 << 2)
66# define TPS_VBUS_CHARGING (1 << 1)
67# define TPS_CHARGE_ENABLE (1 << 0)
68#define TPS_LED1_ON 0x08
69#define TPS_LED1_PER 0x09
70#define TPS_LED2_ON 0x0a
71#define TPS_LED2_PER 0x0b
72#define TPS_VDCDC1 0x0c
73# define TPS_ENABLE_LP (1 << 3)
74#define TPS_VDCDC2 0x0d
75#define TPS_VREGS1 0x0e
76# define TPS_LDO2_ENABLE (1 << 7)
77# define TPS_LDO2_OFF (1 << 6)
78# define TPS_VLDO2_3_0V (3 << 4)
79# define TPS_VLDO2_2_75V (2 << 4)
80# define TPS_VLDO2_2_5V (1 << 4)
81# define TPS_VLDO2_1_8V (0 << 4)
82# define TPS_LDO1_ENABLE (1 << 3)
83# define TPS_LDO1_OFF (1 << 2)
84# define TPS_VLDO1_3_0V (3 << 0)
85# define TPS_VLDO1_2_75V (2 << 0)
86# define TPS_VLDO1_2_5V (1 << 0)
87# define TPS_VLDO1_ADJ (0 << 0)
88#define TPS_MASK3 0x0f
89#define TPS_DEFGPIO 0x10
90
91/*
92 * ----------------------------------------------------------------------------
33 * Macros used by exported functions 93 * Macros used by exported functions
34 * ---------------------------------------------------------------------------- 94 * ----------------------------------------------------------------------------
35 */ 95 */
@@ -71,10 +131,26 @@ extern int tps65010_set_gpio_out_value(unsigned gpio, unsigned value);
71 */ 131 */
72extern int tps65010_set_led(unsigned led, unsigned mode); 132extern int tps65010_set_led(unsigned led, unsigned mode);
73 133
134/* tps65010_set_vib parameter:
135 * value: ON or OFF
136 */
137extern int tps65010_set_vib(unsigned value);
138
74/* tps65010_set_low_pwr parameter: 139/* tps65010_set_low_pwr parameter:
75 * mode: ON or OFF 140 * mode: ON or OFF
76 */ 141 */
77extern int tps65010_set_low_pwr(unsigned mode); 142extern int tps65010_set_low_pwr(unsigned mode);
78 143
144/* tps65010_config_vregs1 parameter:
145 * value to be written to VREGS1 register
146 * Note: The complete register is written, set all bits you need
147 */
148extern int tps65010_config_vregs1(unsigned value);
149
150/* tps65013_set_low_pwr parameter:
151 * mode: ON or OFF
152 */
153extern int tps65013_set_low_pwr(unsigned mode);
154
79#endif /* __ASM_ARCH_TPS65010_H */ 155#endif /* __ASM_ARCH_TPS65010_H */
80 156
diff --git a/include/asm-arm/smp.h b/include/asm-arm/smp.h
index bd44f894690f..6c6c60adbbaa 100644
--- a/include/asm-arm/smp.h
+++ b/include/asm-arm/smp.h
@@ -21,7 +21,7 @@
21# error "<asm-arm/smp.h> included in non-SMP build" 21# error "<asm-arm/smp.h> included in non-SMP build"
22#endif 22#endif
23 23
24#define smp_processor_id() (current_thread_info()->cpu) 24#define raw_smp_processor_id() (current_thread_info()->cpu)
25 25
26extern cpumask_t cpu_present_mask; 26extern cpumask_t cpu_present_mask;
27#define cpu_possible_map cpu_present_mask 27#define cpu_possible_map cpu_present_mask
diff --git a/include/asm-arm/system.h b/include/asm-arm/system.h
index 8405eb6558ed..39dd7008013c 100644
--- a/include/asm-arm/system.h
+++ b/include/asm-arm/system.h
@@ -308,7 +308,7 @@ do { \
308({ \ 308({ \
309 unsigned long flags; \ 309 unsigned long flags; \
310 local_save_flags(flags); \ 310 local_save_flags(flags); \
311 flags & PSR_I_BIT; \ 311 (int)(flags & PSR_I_BIT); \
312}) 312})
313 313
314#ifdef CONFIG_SMP 314#ifdef CONFIG_SMP
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index 1f4ec7b70270..f40593565173 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -125,6 +125,9 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addres
125 125
126#ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_DIRTY 126#ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_DIRTY
127#define page_test_and_clear_dirty(page) (0) 127#define page_test_and_clear_dirty(page) (0)
128#define pte_maybe_dirty(pte) pte_dirty(pte)
129#else
130#define pte_maybe_dirty(pte) (1)
128#endif 131#endif
129 132
130#ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_YOUNG 133#ifndef __HAVE_ARCH_PAGE_TEST_AND_CLEAR_YOUNG
diff --git a/include/asm-i386/page.h b/include/asm-i386/page.h
index ed13969fa2d6..41400d342d44 100644
--- a/include/asm-i386/page.h
+++ b/include/asm-i386/page.h
@@ -68,6 +68,7 @@ typedef struct { unsigned long pgprot; } pgprot_t;
68#define HPAGE_MASK (~(HPAGE_SIZE - 1)) 68#define HPAGE_MASK (~(HPAGE_SIZE - 1))
69#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) 69#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
70#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA 70#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
71#define ARCH_HAS_HUGETLB_CLEAN_STALE_PGTABLE
71#endif 72#endif
72 73
73#define pgd_val(x) ((x).pgd) 74#define pgd_val(x) ((x).pgd)
diff --git a/include/asm-i386/pgtable.h b/include/asm-i386/pgtable.h
index 8d60c2b4b003..e9efe148fdf7 100644
--- a/include/asm-i386/pgtable.h
+++ b/include/asm-i386/pgtable.h
@@ -236,6 +236,7 @@ static inline pte_t pte_mkexec(pte_t pte) { (pte).pte_low |= _PAGE_USER; return
236static inline pte_t pte_mkdirty(pte_t pte) { (pte).pte_low |= _PAGE_DIRTY; return pte; } 236static inline pte_t pte_mkdirty(pte_t pte) { (pte).pte_low |= _PAGE_DIRTY; return pte; }
237static inline pte_t pte_mkyoung(pte_t pte) { (pte).pte_low |= _PAGE_ACCESSED; return pte; } 237static inline pte_t pte_mkyoung(pte_t pte) { (pte).pte_low |= _PAGE_ACCESSED; return pte; }
238static inline pte_t pte_mkwrite(pte_t pte) { (pte).pte_low |= _PAGE_RW; return pte; } 238static inline pte_t pte_mkwrite(pte_t pte) { (pte).pte_low |= _PAGE_RW; return pte; }
239static inline pte_t pte_mkhuge(pte_t pte) { (pte).pte_low |= _PAGE_PRESENT | _PAGE_PSE; return pte; }
239 240
240#ifdef CONFIG_X86_PAE 241#ifdef CONFIG_X86_PAE
241# include <asm/pgtable-3level.h> 242# include <asm/pgtable-3level.h>
@@ -275,7 +276,6 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
275 */ 276 */
276 277
277#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) 278#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
278#define mk_pte_huge(entry) ((entry).pte_low |= _PAGE_PRESENT | _PAGE_PSE)
279 279
280static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 280static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
281{ 281{
diff --git a/include/asm-i386/smp.h b/include/asm-i386/smp.h
index e03a206dfa36..55ef31f66bbe 100644
--- a/include/asm-i386/smp.h
+++ b/include/asm-i386/smp.h
@@ -51,7 +51,7 @@ extern u8 x86_cpu_to_apicid[];
51 * from the initial startup. We map APIC_BASE very early in page_setup(), 51 * from the initial startup. We map APIC_BASE very early in page_setup(),
52 * so this is correct in the x86 case. 52 * so this is correct in the x86 case.
53 */ 53 */
54#define __smp_processor_id() (current_thread_info()->cpu) 54#define raw_smp_processor_id() (current_thread_info()->cpu)
55 55
56extern cpumask_t cpu_callout_map; 56extern cpumask_t cpu_callout_map;
57extern cpumask_t cpu_callin_map; 57extern cpumask_t cpu_callin_map;
diff --git a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h
index 61bcc1b1e3f4..176413fb9ae3 100644
--- a/include/asm-i386/unistd.h
+++ b/include/asm-i386/unistd.h
@@ -256,7 +256,7 @@
256#define __NR_io_submit 248 256#define __NR_io_submit 248
257#define __NR_io_cancel 249 257#define __NR_io_cancel 249
258#define __NR_fadvise64 250 258#define __NR_fadvise64 250
259 259#define __NR_set_zone_reclaim 251
260#define __NR_exit_group 252 260#define __NR_exit_group 252
261#define __NR_lookup_dcookie 253 261#define __NR_lookup_dcookie 253
262#define __NR_epoll_create 254 262#define __NR_epoll_create 254
diff --git a/include/asm-ia64/mmzone.h b/include/asm-ia64/mmzone.h
index 9491dacc89cf..83ca4043fc11 100644
--- a/include/asm-ia64/mmzone.h
+++ b/include/asm-ia64/mmzone.h
@@ -15,6 +15,20 @@
15#include <asm/page.h> 15#include <asm/page.h>
16#include <asm/meminit.h> 16#include <asm/meminit.h>
17 17
18static inline int pfn_to_nid(unsigned long pfn)
19{
20#ifdef CONFIG_NUMA
21 extern int paddr_to_nid(unsigned long);
22 int nid = paddr_to_nid(pfn << PAGE_SHIFT);
23 if (nid < 0)
24 return 0;
25 else
26 return nid;
27#else
28 return 0;
29#endif
30}
31
18#ifdef CONFIG_DISCONTIGMEM 32#ifdef CONFIG_DISCONTIGMEM
19 33
20#ifdef CONFIG_IA64_DIG /* DIG systems are small */ 34#ifdef CONFIG_IA64_DIG /* DIG systems are small */
diff --git a/include/asm-ia64/pgtable.h b/include/asm-ia64/pgtable.h
index fcc9c3344ab4..48586e08f432 100644
--- a/include/asm-ia64/pgtable.h
+++ b/include/asm-ia64/pgtable.h
@@ -283,6 +283,7 @@ ia64_phys_addr_valid (unsigned long addr)
283#define pte_mkyoung(pte) (__pte(pte_val(pte) | _PAGE_A)) 283#define pte_mkyoung(pte) (__pte(pte_val(pte) | _PAGE_A))
284#define pte_mkclean(pte) (__pte(pte_val(pte) & ~_PAGE_D)) 284#define pte_mkclean(pte) (__pte(pte_val(pte) & ~_PAGE_D))
285#define pte_mkdirty(pte) (__pte(pte_val(pte) | _PAGE_D)) 285#define pte_mkdirty(pte) (__pte(pte_val(pte) | _PAGE_D))
286#define pte_mkhuge(pte) (__pte(pte_val(pte) | _PAGE_P))
286 287
287/* 288/*
288 * Macro to a page protection value as "uncacheable". Note that "protection" is really a 289 * Macro to a page protection value as "uncacheable". Note that "protection" is really a
diff --git a/include/asm-ia64/smp.h b/include/asm-ia64/smp.h
index 3ba1a061e4ae..a3914352c995 100644
--- a/include/asm-ia64/smp.h
+++ b/include/asm-ia64/smp.h
@@ -46,7 +46,7 @@ ia64_get_lid (void)
46#define SMP_IRQ_REDIRECTION (1 << 0) 46#define SMP_IRQ_REDIRECTION (1 << 0)
47#define SMP_IPI_REDIRECTION (1 << 1) 47#define SMP_IPI_REDIRECTION (1 << 1)
48 48
49#define smp_processor_id() (current_thread_info()->cpu) 49#define raw_smp_processor_id() (current_thread_info()->cpu)
50 50
51extern struct smp_boot_data { 51extern struct smp_boot_data {
52 int cpu_count; 52 int cpu_count;
diff --git a/include/asm-ia64/sn/mspec.h b/include/asm-ia64/sn/mspec.h
new file mode 100644
index 000000000000..dbe13c6121a8
--- /dev/null
+++ b/include/asm-ia64/sn/mspec.h
@@ -0,0 +1,59 @@
1/*
2 *
3 * This file is subject to the terms and conditions of the GNU General Public
4 * License. See the file "COPYING" in the main directory of this archive
5 * for more details.
6 *
7 * Copyright (c) 2001-2004 Silicon Graphics, Inc. All rights reserved.
8 */
9
10#ifndef _ASM_IA64_SN_MSPEC_H
11#define _ASM_IA64_SN_MSPEC_H
12
13#define FETCHOP_VAR_SIZE 64 /* 64 byte per fetchop variable */
14
15#define FETCHOP_LOAD 0
16#define FETCHOP_INCREMENT 8
17#define FETCHOP_DECREMENT 16
18#define FETCHOP_CLEAR 24
19
20#define FETCHOP_STORE 0
21#define FETCHOP_AND 24
22#define FETCHOP_OR 32
23
24#define FETCHOP_CLEAR_CACHE 56
25
26#define FETCHOP_LOAD_OP(addr, op) ( \
27 *(volatile long *)((char*) (addr) + (op)))
28
29#define FETCHOP_STORE_OP(addr, op, x) ( \
30 *(volatile long *)((char*) (addr) + (op)) = (long) (x))
31
32#ifdef __KERNEL__
33
34/*
35 * Each Atomic Memory Operation (AMO formerly known as fetchop)
36 * variable is 64 bytes long. The first 8 bytes are used. The
37 * remaining 56 bytes are unaddressable due to the operation taking
38 * that portion of the address.
39 *
40 * NOTE: The AMO_t _MUST_ be placed in either the first or second half
41 * of the cache line. The cache line _MUST NOT_ be used for anything
42 * other than additional AMO_t entries. This is because there are two
43 * addresses which reference the same physical cache line. One will
44 * be a cached entry with the memory type bits all set. This address
45 * may be loaded into processor cache. The AMO_t will be referenced
46 * uncached via the memory special memory type. If any portion of the
47 * cached cache-line is modified, when that line is flushed, it will
48 * overwrite the uncached value in physical memory and lead to
49 * inconsistency.
50 */
51typedef struct {
52 u64 variable;
53 u64 unused[7];
54} AMO_t;
55
56
57#endif /* __KERNEL__ */
58
59#endif /* _ASM_IA64_SN_MSPEC_H */
diff --git a/include/asm-ia64/uncached.h b/include/asm-ia64/uncached.h
new file mode 100644
index 000000000000..b82d923b73c1
--- /dev/null
+++ b/include/asm-ia64/uncached.h
@@ -0,0 +1,12 @@
1/*
2 * Copyright (C) 2001-2005 Silicon Graphics, Inc. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License
6 * as published by the Free Software Foundation.
7 *
8 * Prototypes for the uncached page allocator
9 */
10
11extern unsigned long uncached_alloc_page(int nid);
12extern void uncached_free_page(unsigned long);
diff --git a/include/asm-ia64/unistd.h b/include/asm-ia64/unistd.h
index 33e26c557c5c..f7f43ec2483a 100644
--- a/include/asm-ia64/unistd.h
+++ b/include/asm-ia64/unistd.h
@@ -263,6 +263,7 @@
263#define __NR_add_key 1271 263#define __NR_add_key 1271
264#define __NR_request_key 1272 264#define __NR_request_key 1272
265#define __NR_keyctl 1273 265#define __NR_keyctl 1273
266#define __NR_set_zone_reclaim 1276
266 267
267#ifdef __KERNEL__ 268#ifdef __KERNEL__
268 269
diff --git a/include/asm-m32r/div64.h b/include/asm-m32r/div64.h
index 417a51bd552d..6cd978cefb28 100644
--- a/include/asm-m32r/div64.h
+++ b/include/asm-m32r/div64.h
@@ -1,38 +1 @@
1#ifndef _ASM_M32R_DIV64 #include <asm-generic/div64.h>
2#define _ASM_M32R_DIV64
3
4/* $Id$ */
5
6/* unsigned long long division.
7 * Input:
8 * unsigned long long n
9 * unsigned long base
10 * Output:
11 * n = n / base;
12 * return value = n % base;
13 */
14#define do_div(n, base) \
15({ \
16 unsigned long _res, _high, _mid, _low; \
17 \
18 _low = (n) & 0xffffffffUL; \
19 _high = (n) >> 32; \
20 if (_high) { \
21 _mid = (_high % (unsigned long)(base)) << 16; \
22 _high = _high / (unsigned long)(base); \
23 _mid += _low >> 16; \
24 _low &= 0x0000ffffUL; \
25 _low += (_mid % (unsigned long)(base)) << 16; \
26 _mid = _mid / (unsigned long)(base); \
27 _res = _low % (unsigned long)(base); \
28 _low = _low / (unsigned long)(base); \
29 n = _low + ((long long)_mid << 16) + \
30 ((long long)_high << 32); \
31 } else { \
32 _res = _low % (unsigned long)(base); \
33 n = (_low / (unsigned long)(base)); \
34 } \
35 _res; \
36})
37
38#endif /* _ASM_M32R_DIV64 */
diff --git a/include/asm-m32r/ide.h b/include/asm-m32r/ide.h
index be64f24e37ee..194393bd8beb 100644
--- a/include/asm-m32r/ide.h
+++ b/include/asm-m32r/ide.h
@@ -35,7 +35,7 @@
35static __inline__ int ide_default_irq(unsigned long base) 35static __inline__ int ide_default_irq(unsigned long base)
36{ 36{
37 switch (base) { 37 switch (base) {
38#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2) 38#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2) || defined(CONFIG_PLAT_MAPPI3)
39 case 0x1f0: return PLD_IRQ_CFIREQ; 39 case 0x1f0: return PLD_IRQ_CFIREQ;
40 default: 40 default:
41 return 0; 41 return 0;
diff --git a/include/asm-m32r/m32102.h b/include/asm-m32r/m32102.h
index b56034026bf8..cb98101f4f6e 100644
--- a/include/asm-m32r/m32102.h
+++ b/include/asm-m32r/m32102.h
@@ -175,6 +175,7 @@
175#define M32R_ICU_CR5_PORTL (0x210+M32R_ICU_OFFSET) /* INT4 */ 175#define M32R_ICU_CR5_PORTL (0x210+M32R_ICU_OFFSET) /* INT4 */
176#define M32R_ICU_CR6_PORTL (0x214+M32R_ICU_OFFSET) /* INT5 */ 176#define M32R_ICU_CR6_PORTL (0x214+M32R_ICU_OFFSET) /* INT5 */
177#define M32R_ICU_CR7_PORTL (0x218+M32R_ICU_OFFSET) /* INT6 */ 177#define M32R_ICU_CR7_PORTL (0x218+M32R_ICU_OFFSET) /* INT6 */
178#define M32R_ICU_CR8_PORTL (0x219+M32R_ICU_OFFSET) /* INT7 */
178#define M32R_ICU_CR16_PORTL (0x23C+M32R_ICU_OFFSET) /* MFT0 */ 179#define M32R_ICU_CR16_PORTL (0x23C+M32R_ICU_OFFSET) /* MFT0 */
179#define M32R_ICU_CR17_PORTL (0x240+M32R_ICU_OFFSET) /* MFT1 */ 180#define M32R_ICU_CR17_PORTL (0x240+M32R_ICU_OFFSET) /* MFT1 */
180#define M32R_ICU_CR18_PORTL (0x244+M32R_ICU_OFFSET) /* MFT2 */ 181#define M32R_ICU_CR18_PORTL (0x244+M32R_ICU_OFFSET) /* MFT2 */
diff --git a/include/asm-m32r/m32102peri.h b/include/asm-m32r/m32102peri.h
deleted file mode 100644
index 3c12955ad0f0..000000000000
--- a/include/asm-m32r/m32102peri.h
+++ /dev/null
@@ -1,468 +0,0 @@
1/* $Id$
2 *
3 * This file is subject to the terms and conditions of the GNU General Public
4 * License. See the file "COPYING" in the main directory of this archive
5 * for more details.
6 *
7 * Copyright (C) 2000,2001 by Hiroyuki Kondo
8 */
9
10#ifndef __ASSEMBLY__
11
12typedef void V;
13typedef char B;
14typedef short S;
15typedef int W;
16typedef long L;
17typedef float F;
18typedef double D;
19typedef unsigned char UB;
20typedef unsigned short US;
21typedef unsigned int UW;
22typedef unsigned long UL;
23typedef const unsigned int CUW;
24
25/*********************************
26
27M32102 ICU
28
29*********************************/
30#define ICUISTS (UW *)0xa0EFF004
31#define ICUIREQ0 (UW *)0xa0EFF008
32#define ICUIREQ1 (UW *)0xa0EFF00C
33
34#define ICUSBICR (UW *)0xa0EFF018
35#define ICUIMASK (UW *)0xa0EFF01C
36
37#define ICUCR1 (UW *)0xa0EFF200 /* INT0 */
38#define ICUCR2 (UW *)0xa0EFF204 /* INT1 */
39#define ICUCR3 (UW *)0xa0EFF208 /* INT2 */
40#define ICUCR4 (UW *)0xa0EFF20C /* INT3 */
41#define ICUCR5 (UW *)0xa0EFF210 /* INT4 */
42#define ICUCR6 (UW *)0xa0EFF214 /* INT5 */
43#define ICUCR7 (UW *)0xa0EFF218 /* INT6 */
44
45#define ICUCR16 (UW *)0xa0EFF23C /* MFT0 */
46#define ICUCR17 (UW *)0xa0EFF240 /* MFT1 */
47#define ICUCR18 (UW *)0xa0EFF244 /* MFT2 */
48#define ICUCR19 (UW *)0xa0EFF248 /* MFT3 */
49#define ICUCR20 (UW *)0xa0EFF24C /* MFT4 */
50#define ICUCR21 (UW *)0xa0EFF250 /* MFT5 */
51
52#define ICUCR32 (UW *)0xa0EFF27C /* DMA0 */
53#define ICUCR33 (UW *)0xa0EFF280 /* DMA1 */
54
55#define ICUCR48 (UW *)0xa0EFF2BC /* SIO0R */
56#define ICUCR49 (UW *)0xa0EFF2C0 /* SIO0S */
57#define ICUCR50 (UW *)0xa0EFF2C4 /* SIO1R */
58#define ICUCR51 (UW *)0xa0EFF2C8 /* SIO1S */
59#define ICUCR52 (UW *)0xa0EFF2CC /* SIO2R */
60#define ICUCR53 (UW *)0xa0EFF2D0 /* SIO2S */
61#define ICUCR54 (UW *)0xa0EFF2D4 /* SIO3R */
62#define ICUCR55 (UW *)0xa0EFF2D8 /* SIO3S */
63#define ICUCR56 (UW *)0xa0EFF2DC /* SIO4R */
64#define ICUCR57 (UW *)0xa0EFF2E0 /* SIO4S */
65
66/*********************************
67
68M32102 MFT
69
70*********************************/
71#define MFTCR (US *)0xa0EFC002
72#define MFTRPR (UB *)0xa0EFC006
73
74#define MFT0MOD (US *)0xa0EFC102
75#define MFT0BOS (US *)0xa0EFC106
76#define MFT0CUT (US *)0xa0EFC10A
77#define MFT0RLD (US *)0xa0EFC10E
78#define MFT0CRLD (US *)0xa0EFC112
79
80#define MFT1MOD (US *)0xa0EFC202
81#define MFT1BOS (US *)0xa0EFC206
82#define MFT1CUT (US *)0xa0EFC20A
83#define MFT1RLD (US *)0xa0EFC20E
84#define MFT1CRLD (US *)0xa0EFC212
85
86#define MFT2MOD (US *)0xa0EFC302
87#define MFT2BOS (US *)0xa0EFC306
88#define MFT2CUT (US *)0xa0EFC30A
89#define MFT2RLD (US *)0xa0EFC30E
90#define MFT2CRLD (US *)0xa0EFC312
91
92#define MFT3MOD (US *)0xa0EFC402
93#define MFT3CUT (US *)0xa0EFC40A
94#define MFT3RLD (US *)0xa0EFC40E
95#define MFT3CRLD (US *)0xa0EFC412
96
97#define MFT4MOD (US *)0xa0EFC502
98#define MFT4CUT (US *)0xa0EFC50A
99#define MFT4RLD (US *)0xa0EFC50E
100#define MFT4CRLD (US *)0xa0EFC512
101
102#define MFT5MOD (US *)0xa0EFC602
103#define MFT5CUT (US *)0xa0EFC60A
104#define MFT5RLD (US *)0xa0EFC60E
105#define MFT5CRLD (US *)0xa0EFC612
106
107/*********************************
108
109M32102 SIO
110
111*********************************/
112
113#define SIO0CR (volatile int *)0xa0efd000
114#define SIO0MOD0 (volatile int *)0xa0efd004
115#define SIO0MOD1 (volatile int *)0xa0efd008
116#define SIO0STS (volatile int *)0xa0efd00c
117#define SIO0IMASK (volatile int *)0xa0efd010
118#define SIO0BAUR (volatile int *)0xa0efd014
119#define SIO0RBAUR (volatile int *)0xa0efd018
120#define SIO0TXB (volatile int *)0xa0efd01c
121#define SIO0RXB (volatile int *)0xa0efd020
122
123#define SIO1CR (volatile int *)0xa0efd100
124#define SIO1MOD0 (volatile int *)0xa0efd104
125#define SIO1MOD1 (volatile int *)0xa0efd108
126#define SIO1STS (volatile int *)0xa0efd10c
127#define SIO1IMASK (volatile int *)0xa0efd110
128#define SIO1BAUR (volatile int *)0xa0efd114
129#define SIO1RBAUR (volatile int *)0xa0efd118
130#define SIO1TXB (volatile int *)0xa0efd11c
131#define SIO1RXB (volatile int *)0xa0efd120
132/*********************************
133
134M32102 PORT
135
136*********************************/
137#define PIEN (UB *)0xa0EF1003 /* input enable */
138
139#define P0DATA (UB *)0xa0EF1020 /* data */
140#define P1DATA (UB *)0xa0EF1021
141#define P2DATA (UB *)0xa0EF1022
142#define P3DATA (UB *)0xa0EF1023
143#define P4DATA (UB *)0xa0EF1024
144#define P5DATA (UB *)0xa0EF1025
145#define P6DATA (UB *)0xa0EF1026
146#define P7DATA (UB *)0xa0EF1027
147
148#define P0DIR (UB *)0xa0EF1040 /* direction */
149#define P1DIR (UB *)0xa0EF1041
150#define P2DIR (UB *)0xa0EF1042
151#define P3DIR (UB *)0xa0EF1043
152#define P4DIR (UB *)0xa0EF1044
153#define P5DIR (UB *)0xa0EF1045
154#define P6DIR (UB *)0xa0EF1046
155#define P7DIR (UB *)0xa0EF1047
156
157#define P0MOD (US *)0xa0EF1060 /* mode control */
158#define P1MOD (US *)0xa0EF1062
159#define P2MOD (US *)0xa0EF1064
160#define P3MOD (US *)0xa0EF1066
161#define P4MOD (US *)0xa0EF1068
162#define P5MOD (US *)0xa0EF106A
163#define P6MOD (US *)0xa0EF106C
164#define P7MOD (US *)0xa0EF106E
165
166#define P0ODCR (UB *)0xa0EF1080 /* open-drain control */
167#define P1ODCR (UB *)0xa0EF1081
168#define P2ODCR (UB *)0xa0EF1082
169#define P3ODCR (UB *)0xa0EF1083
170#define P4ODCR (UB *)0xa0EF1084
171#define P5ODCR (UB *)0xa0EF1085
172#define P6ODCR (UB *)0xa0EF1086
173#define P7ODCR (UB *)0xa0EF1087
174
175/*********************************
176
177M32102 Cache
178
179********************************/
180
181#define MCCR (US *)0xFFFFFFFE
182
183
184#else /* __ASSEMBLY__ */
185
186;;
187;; PIO 0x80ef1000
188;;
189
190#define PIEN 0xa0ef1000
191
192#define P0DATA 0xa0ef1020
193#define P1DATA 0xa0ef1021
194#define P2DATA 0xa0ef1022
195#define P3DATA 0xa0ef1023
196#define P4DATA 0xa0ef1024
197#define P5DATA 0xa0ef1025
198#define P6DATA 0xa0ef1026
199#define P7DATA 0xa0ef1027
200
201#define P0DIR 0xa0ef1040
202#define P1DIR 0xa0ef1041
203#define P2DIR 0xa0ef1042
204#define P3DIR 0xa0ef1043
205#define P4DIR 0xa0ef1044
206#define P5DIR 0xa0ef1045
207#define P6DIR 0xa0ef1046
208#define P7DIR 0xa0ef1047
209
210#define P0MOD 0xa0ef1060
211#define P1MOD 0xa0ef1062
212#define P2MOD 0xa0ef1064
213#define P3MOD 0xa0ef1066
214#define P4MOD 0xa0ef1068
215#define P5MOD 0xa0ef106a
216#define P6MOD 0xa0ef106c
217#define P7MOD 0xa0ef106e
218;
219#define P0ODCR 0xa0ef1080
220#define P1ODCR 0xa0ef1081
221#define P2ODCR 0xa0ef1082
222#define P3ODCR 0xa0ef1083
223#define P4ODCR 0xa0ef1084
224#define P5ODCR 0xa0ef1085
225#define P6ODCR 0xa0ef1086
226#define P7ODCR 0xa0ef1087
227
228;;
229;; WDT 0xa0ef2000
230;;
231
232#define WDTCR 0xa0ef2000
233
234
235;;
236;; CLK 0xa0ef4000
237;;
238
239#define CPUCLKCR 0xa0ef4000
240#define CLKMOD 0xa0ef4004
241#define PLLCR 0xa0ef4008
242
243
244;;
245;; BSEL 0xa0ef5000
246;;
247
248#define BSEL0CR 0xa0ef5000
249#define BSEL1CR 0xa0ef5004
250#define BSEL2CR 0xa0ef5008
251#define BSEL3CR 0xa0ef500c
252#define BSEL4CR 0xa0ef5010
253#define BSEL5CR 0xa0ef5014
254
255
256;;
257;; SDRAMC 0xa0ef6000
258;;
259
260#define SDRF0 0xa0ef6000
261#define SDRF1 0xa0ef6004
262#define SDIR0 0xa0ef6008
263#define SDIR1 0xa0ef600c
264#define SDBR 0xa0ef6010
265
266;; CH0
267#define SD0ADR 0xa0ef6020
268#define SD0SZ 0xa0ef6022
269#define SD0ER 0xa0ef6024
270#define SD0TR 0xa0ef6028
271#define SD0MOD 0xa0ef602c
272
273;; CH1
274#define SD1ADR 0xa0ef6040
275#define SD1SZ 0xa0ef6042
276#define SD1ER 0xa0ef6044
277#define SD1TR 0xa0ef6048
278#define SD1MOD 0xa0ef604c
279
280
281;;
282;; DMAC 0xa0ef8000
283;;
284
285#define DMAEN 0xa0ef8000
286#define DMAISTS 0xa0ef8004
287#define DMAEDET 0xa0ef8008
288#define DMAASTS 0xa0ef800c
289
290;; CH0
291#define DMA0CR0 0xa0ef8100
292#define DMA0CR1 0xa0ef8104
293#define DMA0CSA 0xa0ef8108
294#define DMA0RSA 0xa0ef810c
295#define DMA0CDA 0xa0ef8110
296#define DMA0RDA 0xa0ef8114
297#define DMA0CBCUT 0xa0ef8118
298#define DMA0RBCUT 0xa0ef811c
299
300;; CH1
301#define DMA1CR0 0xa0ef8200
302#define DMA1CR1 0xa0ef8204
303#define DMA1CSA 0xa0ef8208
304#define DMA1RSA 0xa0ef820c
305#define DMA1CDA 0xa0ef8210
306#define DMA1RDA 0xa0ef8214
307#define DMA1CBCUT 0xa0ef8218
308#define DMA1RBCUT 0xa0ef821c
309
310
311;;
312;; MFT 0xa0efc000
313;;
314
315#define MFTCR 0xa0efc000
316#define MFTRPR 0xa0efc004
317
318;; CH0
319#define MFT0MOD 0xa0efc100
320#define MFT0BOS 0xa0efc104
321#define MFT0CUT 0xa0efc108
322#define MFT0RLD 0xa0efc10c
323#define MFT0CMPRLD 0xa0efc110
324
325;; CH1
326#define MFT1MOD 0xa0efc200
327#define MFT1BOS 0xa0efc204
328#define MFT1CUT 0xa0efc208
329#define MFT1RLD 0xa0efc20c
330#define MFT1CMPRLD 0xa0efc210
331
332;; CH2
333#define MFT2MOD 0xa0efc300
334#define MFT2BOS 0xa0efc304
335#define MFT2CUT 0xa0efc308
336#define MFT2RLD 0xa0efc30c
337#define MFT2CMPRLD 0xa0efc310
338
339;; CH3
340#define MFT3MOD 0xa0efc400
341#define MFT3BOS 0xa0efc404
342#define MFT3CUT 0xa0efc408
343#define MFT3RLD 0xa0efc40c
344#define MFT3CMPRLD 0xa0efc410
345
346;; CH4
347#define MFT4MOD 0xa0efc500
348#define MFT4BOS 0xa0efc504
349#define MFT4CUT 0xa0efc508
350#define MFT4RLD 0xa0efc50c
351#define MFT4CMPRLD 0xa0efc510
352
353;; CH5
354#define MFT5MOD 0xa0efc600
355#define MFT5BOS 0xa0efc604
356#define MFT5CUT 0xa0efc608
357#define MFT5RLD 0xa0efc60c
358#define MFT5CMPRLD 0xa0efc610
359
360
361;;
362;; SIO 0xa0efd000
363;;
364
365;; CH0
366#define SIO0CR 0xa0efd000
367#define SIO0MOD0 0xa0efd004
368#define SIO0MOD1 0xa0efd008
369#define SIO0STS 0xa0efd00c
370#define SIO0IMASK 0xa0efd010
371#define SIO0BAUR 0xa0efd014
372#define SIO0RBAUR 0xa0efd018
373#define SIO0TXB 0xa0efd01c
374#define SIO0RXB 0xa0efd020
375
376;; CH1
377#define SIO1CR 0xa0efd100
378#define SIO1MOD0 0xa0efd104
379#define SIO1MOD1 0xa0efd108
380#define SIO1STS 0xa0efd10c
381#define SIO1IMASK 0xa0efd110
382#define SIO1BAUR 0xa0efd114
383#define SIO1RBAUR 0xa0efd118
384#define SIO1TXB 0xa0efd11c
385#define SIO1RXB 0xa0efd120
386
387;; CH2
388#define SIO2CR 0xa0efd200
389#define SIO2MOD0 0xa0efd204
390#define SIO2MOD1 0xa0efd208
391#define SIO2STS 0xa0efd20c
392#define SIO2IMASK 0xa0efd210
393#define SIO2BAUR 0xa0efd214
394#define SIO2RBAUR 0xa0efd218
395#define SIO2TXB 0xa0efd21c
396#define SIO2RXB 0xa0efd220
397
398;; CH3
399#define SIO3CR 0xa0efd300
400#define SIO3MOD0 0xa0efd304
401#define SIO3MOD1 0xa0efd308
402#define SIO3STS 0xa0efd30c
403#define SIO3IMASK 0xa0efd310
404#define SIO3BAUR 0xa0efd314
405#define SIO3RBAUR 0xa0efd318
406#define SIO3TXB 0xa0efd31c
407#define SIO3RXB 0xa0efd320
408
409;; CH4
410#define SIO4CR 0xa0efd400
411#define SIO4MOD0 0xa0efd404
412#define SIO4MOD1 0xa0efd408
413#define SIO4STS 0xa0efd40c
414#define SIO4IMASK 0xa0efd410
415#define SIO4BAUR 0xa0efd414
416#define SIO4RBAUR 0xa0efd418
417#define SIO4TXB 0xa0efd41c
418#define SIO4RXB 0xa0efd420
419
420
421;;
422;; ICU 0xa0eff000
423;;
424
425#define ICUISTS 0xa0eff004
426#define ICUIREQ0 0xa0eff008
427#define ICUIREQ1 0xa0eff00c
428
429#define ICUSBICR 0xa0eff018
430#define ICUIMASK 0xa0eff01c
431
432#define ICUCR1 0xa0eff200
433#define ICUCR2 0xa0eff204
434#define ICUCR3 0xa0eff208
435#define ICUCR4 0xa0eff20c
436#define ICUCR5 0xa0eff210
437#define ICUCR6 0xa0eff214
438#define ICUCR7 0xa0eff218
439
440#define ICUCR16 0xa0eff23c
441#define ICUCR17 0xa0eff240
442#define ICUCR18 0xa0eff244
443#define ICUCR19 0xa0eff248
444#define ICUCR20 0xa0eff24c
445#define ICUCR21 0xa0eff250
446
447#define ICUCR32 0xa0eff27c
448#define ICUCR33 0xa0eff280
449
450#define ICUCR48 0xa0eff2bc
451#define ICUCR49 0xa0eff2c0
452#define ICUCR50 0xa0eff2c4
453#define ICUCR51 0xa0eff2c8
454#define ICUCR52 0xa0eff2cc
455#define ICUCR53 0xa0eff2d0
456#define ICUCR54 0xa0eff2d4
457#define ICUCR55 0xa0eff2d8
458#define ICUCR56 0xa0eff2dc
459#define ICUCR57 0xa0eff2e0
460
461;;
462;; CACHE
463;;
464
465#define MCCR 0xfffffffc
466
467
468#endif /* __ASSEMBLY__ */
diff --git a/include/asm-m32r/m32r.h b/include/asm-m32r/m32r.h
index f116649bbef3..ec142be00862 100644
--- a/include/asm-m32r/m32r.h
+++ b/include/asm-m32r/m32r.h
@@ -16,7 +16,6 @@
16 || defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_M32102) \ 16 || defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_M32102) \
17 || defined(CONFIG_CHIP_OPSP) 17 || defined(CONFIG_CHIP_OPSP)
18#include <asm/m32102.h> 18#include <asm/m32102.h>
19#include <asm/m32102peri.h>
20#endif 19#endif
21 20
22/* Platform type */ 21/* Platform type */
@@ -36,6 +35,10 @@
36#include <asm/mappi2/mappi2_pld.h> 35#include <asm/mappi2/mappi2_pld.h>
37#endif /* CONFIG_PLAT_MAPPI2 */ 36#endif /* CONFIG_PLAT_MAPPI2 */
38 37
38#if defined(CONFIG_PLAT_MAPPI3)
39#include <asm/mappi3/mappi3_pld.h>
40#endif /* CONFIG_PLAT_MAPPI3 */
41
39#if defined(CONFIG_PLAT_USRV) 42#if defined(CONFIG_PLAT_USRV)
40#include <asm/m32700ut/m32700ut_pld.h> 43#include <asm/m32700ut/m32700ut_pld.h>
41#endif 44#endif
diff --git a/include/asm-m32r/mappi3/mappi3_pld.h b/include/asm-m32r/mappi3/mappi3_pld.h
new file mode 100644
index 000000000000..3f1551f7f01f
--- /dev/null
+++ b/include/asm-m32r/mappi3/mappi3_pld.h
@@ -0,0 +1,143 @@
1/*
2 * include/asm/mappi3/mappi3_pld.h
3 *
4 * Definitions for Extended IO Logic on MAPPI3 board.
5 * based on m32700ut_pld.h
6 *
7 * This file is subject to the terms and conditions of the GNU General
8 * Public License. See the file "COPYING" in the main directory of
9 * this archive for more details.
10 *
11 */
12
13#ifndef _MAPPI3_PLD_H
14#define _MAPPI3_PLD_H
15
16#ifndef __ASSEMBLY__
17/* FIXME:
18 * Some C functions use non-cache address, so can't define non-cache address.
19 */
20#define PLD_BASE (0x1c000000 /* + NONCACHE_OFFSET */)
21#define __reg8 (volatile unsigned char *)
22#define __reg16 (volatile unsigned short *)
23#define __reg32 (volatile unsigned int *)
24#else
25#define PLD_BASE (0x1c000000 + NONCACHE_OFFSET)
26#define __reg8
27#define __reg16
28#define __reg32
29#endif /* __ASSEMBLY__ */
30
31/* CFC */
32#define PLD_CFRSTCR __reg16(PLD_BASE + 0x0000)
33#define PLD_CFSTS __reg16(PLD_BASE + 0x0002)
34#define PLD_CFIMASK __reg16(PLD_BASE + 0x0004)
35#define PLD_CFBUFCR __reg16(PLD_BASE + 0x0006)
36#define PLD_CFCR0 __reg16(PLD_BASE + 0x000a)
37#define PLD_CFCR1 __reg16(PLD_BASE + 0x000c)
38
39/* MMC */
40#define PLD_MMCCR __reg16(PLD_BASE + 0x4000)
41#define PLD_MMCMOD __reg16(PLD_BASE + 0x4002)
42#define PLD_MMCSTS __reg16(PLD_BASE + 0x4006)
43#define PLD_MMCBAUR __reg16(PLD_BASE + 0x400a)
44#define PLD_MMCCMDBCUT __reg16(PLD_BASE + 0x400c)
45#define PLD_MMCCDTBCUT __reg16(PLD_BASE + 0x400e)
46#define PLD_MMCDET __reg16(PLD_BASE + 0x4010)
47#define PLD_MMCWP __reg16(PLD_BASE + 0x4012)
48#define PLD_MMCWDATA __reg16(PLD_BASE + 0x5000)
49#define PLD_MMCRDATA __reg16(PLD_BASE + 0x6000)
50#define PLD_MMCCMDDATA __reg16(PLD_BASE + 0x7000)
51#define PLD_MMCRSPDATA __reg16(PLD_BASE + 0x7006)
52
53/* Power Control of MMC and CF */
54#define PLD_CPCR __reg16(PLD_BASE + 0x14000)
55
56
57/*==== ICU ====*/
58#define M32R_IRQ_PC104 (5) /* INT4(PC/104) */
59#define M32R_IRQ_I2C (28) /* I2C-BUS */
60#define PLD_IRQ_CFIREQ (6) /* INT5 CFC Card Interrupt */
61#define PLD_IRQ_CFC_INSERT (7) /* INT6 CFC Card Insert */
62#define PLD_IRQ_CFC_EJECT (8) /* INT7 CFC Card Eject */
63#define PLD_IRQ_MMCCARD (43) /* MMC Card Insert */
64#define PLD_IRQ_MMCIRQ (44) /* MMC Transfer Done */
65
66
67#if 0
68/* LED Control
69 *
70 * 1: DIP swich side
71 * 2: Reset switch side
72 */
73#define PLD_IOLEDCR __reg16(PLD_BASE + 0x14002)
74#define PLD_IOLED_1_ON 0x001
75#define PLD_IOLED_1_OFF 0x000
76#define PLD_IOLED_2_ON 0x002
77#define PLD_IOLED_2_OFF 0x000
78
79/* DIP Switch
80 * 0: Write-protect of Flash Memory (0:protected, 1:non-protected)
81 * 1: -
82 * 2: -
83 * 3: -
84 */
85#define PLD_IOSWSTS __reg16(PLD_BASE + 0x14004)
86#define PLD_IOSWSTS_IOSW2 0x0200
87#define PLD_IOSWSTS_IOSW1 0x0100
88#define PLD_IOSWSTS_IOWP0 0x0001
89
90#endif
91
92/* CRC */
93#define PLD_CRC7DATA __reg16(PLD_BASE + 0x18000)
94#define PLD_CRC7INDATA __reg16(PLD_BASE + 0x18002)
95#define PLD_CRC16DATA __reg16(PLD_BASE + 0x18004)
96#define PLD_CRC16INDATA __reg16(PLD_BASE + 0x18006)
97#define PLD_CRC16ADATA __reg16(PLD_BASE + 0x18008)
98#define PLD_CRC16AINDATA __reg16(PLD_BASE + 0x1800a)
99
100
101#if 0
102/* RTC */
103#define PLD_RTCCR __reg16(PLD_BASE + 0x1c000)
104#define PLD_RTCBAUR __reg16(PLD_BASE + 0x1c002)
105#define PLD_RTCWRDATA __reg16(PLD_BASE + 0x1c004)
106#define PLD_RTCRDDATA __reg16(PLD_BASE + 0x1c006)
107#define PLD_RTCRSTODT __reg16(PLD_BASE + 0x1c008)
108
109/* SIO0 */
110#define PLD_ESIO0CR __reg16(PLD_BASE + 0x20000)
111#define PLD_ESIO0CR_TXEN 0x0001
112#define PLD_ESIO0CR_RXEN 0x0002
113#define PLD_ESIO0MOD0 __reg16(PLD_BASE + 0x20002)
114#define PLD_ESIO0MOD0_CTSS 0x0040
115#define PLD_ESIO0MOD0_RTSS 0x0080
116#define PLD_ESIO0MOD1 __reg16(PLD_BASE + 0x20004)
117#define PLD_ESIO0MOD1_LMFS 0x0010
118#define PLD_ESIO0STS __reg16(PLD_BASE + 0x20006)
119#define PLD_ESIO0STS_TEMP 0x0001
120#define PLD_ESIO0STS_TXCP 0x0002
121#define PLD_ESIO0STS_RXCP 0x0004
122#define PLD_ESIO0STS_TXSC 0x0100
123#define PLD_ESIO0STS_RXSC 0x0200
124#define PLD_ESIO0STS_TXREADY (PLD_ESIO0STS_TXCP | PLD_ESIO0STS_TEMP)
125#define PLD_ESIO0INTCR __reg16(PLD_BASE + 0x20008)
126#define PLD_ESIO0INTCR_TXIEN 0x0002
127#define PLD_ESIO0INTCR_RXCEN 0x0004
128#define PLD_ESIO0BAUR __reg16(PLD_BASE + 0x2000a)
129#define PLD_ESIO0TXB __reg16(PLD_BASE + 0x2000c)
130#define PLD_ESIO0RXB __reg16(PLD_BASE + 0x2000e)
131
132/* SIM Card */
133#define PLD_SCCR __reg16(PLD_BASE + 0x38000)
134#define PLD_SCMOD __reg16(PLD_BASE + 0x38004)
135#define PLD_SCSTS __reg16(PLD_BASE + 0x38006)
136#define PLD_SCINTCR __reg16(PLD_BASE + 0x38008)
137#define PLD_SCBAUR __reg16(PLD_BASE + 0x3800a)
138#define PLD_SCTXB __reg16(PLD_BASE + 0x3800c)
139#define PLD_SCRXB __reg16(PLD_BASE + 0x3800e)
140
141#endif
142
143#endif /* _MAPPI3_PLD.H */
diff --git a/include/asm-m32r/smp.h b/include/asm-m32r/smp.h
index 8cd4d0da4be1..b9a20cdad65f 100644
--- a/include/asm-m32r/smp.h
+++ b/include/asm-m32r/smp.h
@@ -66,7 +66,7 @@ extern volatile int cpu_2_physid[NR_CPUS];
66#define physid_to_cpu(physid) physid_2_cpu[physid] 66#define physid_to_cpu(physid) physid_2_cpu[physid]
67#define cpu_to_physid(cpu_id) cpu_2_physid[cpu_id] 67#define cpu_to_physid(cpu_id) cpu_2_physid[cpu_id]
68 68
69#define smp_processor_id() (current_thread_info()->cpu) 69#define raw_smp_processor_id() (current_thread_info()->cpu)
70 70
71extern cpumask_t cpu_callout_map; 71extern cpumask_t cpu_callout_map;
72#define cpu_possible_map cpu_callout_map 72#define cpu_possible_map cpu_callout_map
diff --git a/include/asm-mips/smp.h b/include/asm-mips/smp.h
index 8ba370ecfd4c..5618f1e12f40 100644
--- a/include/asm-mips/smp.h
+++ b/include/asm-mips/smp.h
@@ -21,7 +21,7 @@
21#include <linux/cpumask.h> 21#include <linux/cpumask.h>
22#include <asm/atomic.h> 22#include <asm/atomic.h>
23 23
24#define smp_processor_id() (current_thread_info()->cpu) 24#define raw_smp_processor_id() (current_thread_info()->cpu)
25 25
26/* Map from cpu id to sequential logical cpu number. This will only 26/* Map from cpu id to sequential logical cpu number. This will only
27 not be idempotent when cpus failed to come on-line. */ 27 not be idempotent when cpus failed to come on-line. */
diff --git a/include/asm-mips/vr41xx/giu.h b/include/asm-mips/vr41xx/giu.h
new file mode 100644
index 000000000000..8590885a7638
--- /dev/null
+++ b/include/asm-mips/vr41xx/giu.h
@@ -0,0 +1,69 @@
1/*
2 * Include file for NEC VR4100 series General-purpose I/O Unit.
3 *
4 * Copyright (C) 2005 Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __NEC_VR41XX_GIU_H
21#define __NEC_VR41XX_GIU_H
22
23typedef enum {
24 IRQ_TRIGGER_LEVEL,
25 IRQ_TRIGGER_EDGE,
26 IRQ_TRIGGER_EDGE_FALLING,
27 IRQ_TRIGGER_EDGE_RISING,
28} irq_trigger_t;
29
30typedef enum {
31 IRQ_SIGNAL_THROUGH,
32 IRQ_SIGNAL_HOLD,
33} irq_signal_t;
34
35extern void vr41xx_set_irq_trigger(unsigned int pin, irq_trigger_t trigger, irq_signal_t signal);
36
37typedef enum {
38 IRQ_LEVEL_LOW,
39 IRQ_LEVEL_HIGH,
40} irq_level_t;
41
42extern void vr41xx_set_irq_level(unsigned int pin, irq_level_t level);
43
44typedef enum {
45 GPIO_DATA_LOW,
46 GPIO_DATA_HIGH,
47 GPIO_DATA_INVAL,
48} gpio_data_t;
49
50extern gpio_data_t vr41xx_gpio_get_pin(unsigned int pin);
51extern int vr41xx_gpio_set_pin(unsigned int pin, gpio_data_t data);
52
53typedef enum {
54 GPIO_INPUT,
55 GPIO_OUTPUT,
56 GPIO_OUTPUT_DISABLE,
57} gpio_direction_t;
58
59extern int vr41xx_gpio_set_direction(unsigned int pin, gpio_direction_t dir);
60
61typedef enum {
62 GPIO_PULL_DOWN,
63 GPIO_PULL_UP,
64 GPIO_PULL_DISABLE,
65} gpio_pull_t;
66
67extern int vr41xx_gpio_pullupdown(unsigned int pin, gpio_pull_t pull);
68
69#endif /* __NEC_VR41XX_GIU_H */
diff --git a/include/asm-mips/vr41xx/vr41xx.h b/include/asm-mips/vr41xx/vr41xx.h
index ad0d1ea144f0..7d41e44463f9 100644
--- a/include/asm-mips/vr41xx/vr41xx.h
+++ b/include/asm-mips/vr41xx/vr41xx.h
@@ -126,7 +126,6 @@ extern void vr41xx_mask_clock(vr41xx_clock_t clock);
126#define GIU_IRQ_BASE 40 126#define GIU_IRQ_BASE 40
127#define GIU_IRQ(x) (GIU_IRQ_BASE + (x)) /* IRQ 40-71 */ 127#define GIU_IRQ(x) (GIU_IRQ_BASE + (x)) /* IRQ 40-71 */
128#define GIU_IRQ_LAST GIU_IRQ(31) 128#define GIU_IRQ_LAST GIU_IRQ(31)
129#define GIU_IRQ_TO_PIN(x) ((x) - GIU_IRQ_BASE) /* Pin 0-31 */
130 129
131extern int vr41xx_set_intassign(unsigned int irq, unsigned char intassign); 130extern int vr41xx_set_intassign(unsigned int irq, unsigned char intassign);
132extern int vr41xx_cascade_irq(unsigned int irq, int (*get_irq_number)(int irq)); 131extern int vr41xx_cascade_irq(unsigned int irq, int (*get_irq_number)(int irq));
@@ -197,38 +196,4 @@ extern void vr41xx_disable_csiint(uint16_t mask);
197extern void vr41xx_enable_bcuint(void); 196extern void vr41xx_enable_bcuint(void);
198extern void vr41xx_disable_bcuint(void); 197extern void vr41xx_disable_bcuint(void);
199 198
200/*
201 * General-Purpose I/O Unit
202 */
203enum {
204 TRIGGER_LEVEL,
205 TRIGGER_EDGE,
206 TRIGGER_EDGE_FALLING,
207 TRIGGER_EDGE_RISING
208};
209
210enum {
211 SIGNAL_THROUGH,
212 SIGNAL_HOLD
213};
214
215extern void vr41xx_set_irq_trigger(int pin, int trigger, int hold);
216
217enum {
218 LEVEL_LOW,
219 LEVEL_HIGH
220};
221
222extern void vr41xx_set_irq_level(int pin, int level);
223
224enum {
225 PIO_INPUT,
226 PIO_OUTPUT
227};
228
229enum {
230 DATA_LOW,
231 DATA_HIGH
232};
233
234#endif /* __NEC_VR41XX_H */ 199#endif /* __NEC_VR41XX_H */
diff --git a/include/asm-parisc/smp.h b/include/asm-parisc/smp.h
index fde77ac35463..9413f67a540b 100644
--- a/include/asm-parisc/smp.h
+++ b/include/asm-parisc/smp.h
@@ -51,7 +51,7 @@ extern void smp_send_reschedule(int cpu);
51 51
52extern unsigned long cpu_present_mask; 52extern unsigned long cpu_present_mask;
53 53
54#define smp_processor_id() (current_thread_info()->cpu) 54#define raw_smp_processor_id() (current_thread_info()->cpu)
55 55
56#endif /* CONFIG_SMP */ 56#endif /* CONFIG_SMP */
57 57
diff --git a/include/asm-ppc/irq.h b/include/asm-ppc/irq.h
index 06b86be61ed1..a9b33324f562 100644
--- a/include/asm-ppc/irq.h
+++ b/include/asm-ppc/irq.h
@@ -176,7 +176,7 @@ static __inline__ int irq_canonicalize(int irq)
176*/ 176*/
177#include <asm/mpc85xx.h> 177#include <asm/mpc85xx.h>
178 178
179/* The MPC8560 openpic has 32 internal interrupts and 12 external 179/* The MPC8548 openpic has 48 internal interrupts and 12 external
180 * interrupts. 180 * interrupts.
181 * 181 *
182 * We are "flattening" the interrupt vectors of the cascaded CPM 182 * We are "flattening" the interrupt vectors of the cascaded CPM
@@ -184,7 +184,7 @@ static __inline__ int irq_canonicalize(int irq)
184 * single integer. 184 * single integer.
185 */ 185 */
186#define NR_CPM_INTS 64 186#define NR_CPM_INTS 64
187#define NR_EPIC_INTS 44 187#define NR_EPIC_INTS 60
188#ifndef NR_8259_INTS 188#ifndef NR_8259_INTS
189#define NR_8259_INTS 0 189#define NR_8259_INTS 0
190#endif 190#endif
@@ -223,9 +223,15 @@ static __inline__ int irq_canonicalize(int irq)
223#define MPC85xx_IRQ_RIO_RX (12 + MPC85xx_OPENPIC_IRQ_OFFSET) 223#define MPC85xx_IRQ_RIO_RX (12 + MPC85xx_OPENPIC_IRQ_OFFSET)
224#define MPC85xx_IRQ_TSEC1_TX (13 + MPC85xx_OPENPIC_IRQ_OFFSET) 224#define MPC85xx_IRQ_TSEC1_TX (13 + MPC85xx_OPENPIC_IRQ_OFFSET)
225#define MPC85xx_IRQ_TSEC1_RX (14 + MPC85xx_OPENPIC_IRQ_OFFSET) 225#define MPC85xx_IRQ_TSEC1_RX (14 + MPC85xx_OPENPIC_IRQ_OFFSET)
226#define MPC85xx_IRQ_TSEC3_TX (15 + MPC85xx_OPENPIC_IRQ_OFFSET)
227#define MPC85xx_IRQ_TSEC3_RX (16 + MPC85xx_OPENPIC_IRQ_OFFSET)
228#define MPC85xx_IRQ_TSEC3_ERROR (17 + MPC85xx_OPENPIC_IRQ_OFFSET)
226#define MPC85xx_IRQ_TSEC1_ERROR (18 + MPC85xx_OPENPIC_IRQ_OFFSET) 229#define MPC85xx_IRQ_TSEC1_ERROR (18 + MPC85xx_OPENPIC_IRQ_OFFSET)
227#define MPC85xx_IRQ_TSEC2_TX (19 + MPC85xx_OPENPIC_IRQ_OFFSET) 230#define MPC85xx_IRQ_TSEC2_TX (19 + MPC85xx_OPENPIC_IRQ_OFFSET)
228#define MPC85xx_IRQ_TSEC2_RX (20 + MPC85xx_OPENPIC_IRQ_OFFSET) 231#define MPC85xx_IRQ_TSEC2_RX (20 + MPC85xx_OPENPIC_IRQ_OFFSET)
232#define MPC85xx_IRQ_TSEC4_TX (21 + MPC85xx_OPENPIC_IRQ_OFFSET)
233#define MPC85xx_IRQ_TSEC4_RX (22 + MPC85xx_OPENPIC_IRQ_OFFSET)
234#define MPC85xx_IRQ_TSEC4_ERROR (23 + MPC85xx_OPENPIC_IRQ_OFFSET)
229#define MPC85xx_IRQ_TSEC2_ERROR (24 + MPC85xx_OPENPIC_IRQ_OFFSET) 235#define MPC85xx_IRQ_TSEC2_ERROR (24 + MPC85xx_OPENPIC_IRQ_OFFSET)
230#define MPC85xx_IRQ_FEC (25 + MPC85xx_OPENPIC_IRQ_OFFSET) 236#define MPC85xx_IRQ_FEC (25 + MPC85xx_OPENPIC_IRQ_OFFSET)
231#define MPC85xx_IRQ_DUART (26 + MPC85xx_OPENPIC_IRQ_OFFSET) 237#define MPC85xx_IRQ_DUART (26 + MPC85xx_OPENPIC_IRQ_OFFSET)
@@ -235,18 +241,18 @@ static __inline__ int irq_canonicalize(int irq)
235#define MPC85xx_IRQ_CPM (30 + MPC85xx_OPENPIC_IRQ_OFFSET) 241#define MPC85xx_IRQ_CPM (30 + MPC85xx_OPENPIC_IRQ_OFFSET)
236 242
237/* The 12 external interrupt lines */ 243/* The 12 external interrupt lines */
238#define MPC85xx_IRQ_EXT0 (32 + MPC85xx_OPENPIC_IRQ_OFFSET) 244#define MPC85xx_IRQ_EXT0 (48 + MPC85xx_OPENPIC_IRQ_OFFSET)
239#define MPC85xx_IRQ_EXT1 (33 + MPC85xx_OPENPIC_IRQ_OFFSET) 245#define MPC85xx_IRQ_EXT1 (49 + MPC85xx_OPENPIC_IRQ_OFFSET)
240#define MPC85xx_IRQ_EXT2 (34 + MPC85xx_OPENPIC_IRQ_OFFSET) 246#define MPC85xx_IRQ_EXT2 (50 + MPC85xx_OPENPIC_IRQ_OFFSET)
241#define MPC85xx_IRQ_EXT3 (35 + MPC85xx_OPENPIC_IRQ_OFFSET) 247#define MPC85xx_IRQ_EXT3 (51 + MPC85xx_OPENPIC_IRQ_OFFSET)
242#define MPC85xx_IRQ_EXT4 (36 + MPC85xx_OPENPIC_IRQ_OFFSET) 248#define MPC85xx_IRQ_EXT4 (52 + MPC85xx_OPENPIC_IRQ_OFFSET)
243#define MPC85xx_IRQ_EXT5 (37 + MPC85xx_OPENPIC_IRQ_OFFSET) 249#define MPC85xx_IRQ_EXT5 (53 + MPC85xx_OPENPIC_IRQ_OFFSET)
244#define MPC85xx_IRQ_EXT6 (38 + MPC85xx_OPENPIC_IRQ_OFFSET) 250#define MPC85xx_IRQ_EXT6 (54 + MPC85xx_OPENPIC_IRQ_OFFSET)
245#define MPC85xx_IRQ_EXT7 (39 + MPC85xx_OPENPIC_IRQ_OFFSET) 251#define MPC85xx_IRQ_EXT7 (55 + MPC85xx_OPENPIC_IRQ_OFFSET)
246#define MPC85xx_IRQ_EXT8 (40 + MPC85xx_OPENPIC_IRQ_OFFSET) 252#define MPC85xx_IRQ_EXT8 (56 + MPC85xx_OPENPIC_IRQ_OFFSET)
247#define MPC85xx_IRQ_EXT9 (41 + MPC85xx_OPENPIC_IRQ_OFFSET) 253#define MPC85xx_IRQ_EXT9 (57 + MPC85xx_OPENPIC_IRQ_OFFSET)
248#define MPC85xx_IRQ_EXT10 (42 + MPC85xx_OPENPIC_IRQ_OFFSET) 254#define MPC85xx_IRQ_EXT10 (58 + MPC85xx_OPENPIC_IRQ_OFFSET)
249#define MPC85xx_IRQ_EXT11 (43 + MPC85xx_OPENPIC_IRQ_OFFSET) 255#define MPC85xx_IRQ_EXT11 (59 + MPC85xx_OPENPIC_IRQ_OFFSET)
250 256
251/* CPM related interrupts */ 257/* CPM related interrupts */
252#define SIU_INT_ERROR ((uint)0x00+CPM_IRQ_OFFSET) 258#define SIU_INT_ERROR ((uint)0x00+CPM_IRQ_OFFSET)
diff --git a/include/asm-ppc/mpc10x.h b/include/asm-ppc/mpc10x.h
index d8e7e2d6128e..f5196a4efbe0 100644
--- a/include/asm-ppc/mpc10x.h
+++ b/include/asm-ppc/mpc10x.h
@@ -159,6 +159,12 @@ extern unsigned long ioremap_base;
159#define MPC10X_MAPA_EUMB_BASE (ioremap_base - MPC10X_EUMB_SIZE) 159#define MPC10X_MAPA_EUMB_BASE (ioremap_base - MPC10X_EUMB_SIZE)
160#define MPC10X_MAPB_EUMB_BASE MPC10X_MAPA_EUMB_BASE 160#define MPC10X_MAPB_EUMB_BASE MPC10X_MAPA_EUMB_BASE
161 161
162enum ppc_sys_devices {
163 MPC10X_IIC1,
164 MPC10X_DMA0,
165 MPC10X_DMA1,
166 MPC10X_DUART,
167};
162 168
163int mpc10x_bridge_init(struct pci_controller *hose, 169int mpc10x_bridge_init(struct pci_controller *hose,
164 uint current_map, 170 uint current_map,
diff --git a/include/asm-ppc/mpc85xx.h b/include/asm-ppc/mpc85xx.h
index 22713e331585..516984ee14b5 100644
--- a/include/asm-ppc/mpc85xx.h
+++ b/include/asm-ppc/mpc85xx.h
@@ -25,7 +25,7 @@
25#ifdef CONFIG_MPC8540_ADS 25#ifdef CONFIG_MPC8540_ADS
26#include <platforms/85xx/mpc8540_ads.h> 26#include <platforms/85xx/mpc8540_ads.h>
27#endif 27#endif
28#ifdef CONFIG_MPC8555_CDS 28#if defined(CONFIG_MPC8555_CDS) || defined(CONFIG_MPC8548_CDS)
29#include <platforms/85xx/mpc8555_cds.h> 29#include <platforms/85xx/mpc8555_cds.h>
30#endif 30#endif
31#ifdef CONFIG_MPC8560_ADS 31#ifdef CONFIG_MPC8560_ADS
@@ -74,7 +74,7 @@ extern unsigned char __res[];
74#define MPC85xx_GUTS_OFFSET (0xe0000) 74#define MPC85xx_GUTS_OFFSET (0xe0000)
75#define MPC85xx_GUTS_SIZE (0x01000) 75#define MPC85xx_GUTS_SIZE (0x01000)
76#define MPC85xx_IIC1_OFFSET (0x03000) 76#define MPC85xx_IIC1_OFFSET (0x03000)
77#define MPC85xx_IIC1_SIZE (0x01000) 77#define MPC85xx_IIC1_SIZE (0x00100)
78#define MPC85xx_OPENPIC_OFFSET (0x40000) 78#define MPC85xx_OPENPIC_OFFSET (0x40000)
79#define MPC85xx_OPENPIC_SIZE (0x40000) 79#define MPC85xx_OPENPIC_SIZE (0x40000)
80#define MPC85xx_PCI1_OFFSET (0x08000) 80#define MPC85xx_PCI1_OFFSET (0x08000)
@@ -127,8 +127,64 @@ enum ppc_sys_devices {
127 MPC85xx_CPM_MCC2, 127 MPC85xx_CPM_MCC2,
128 MPC85xx_CPM_SMC1, 128 MPC85xx_CPM_SMC1,
129 MPC85xx_CPM_SMC2, 129 MPC85xx_CPM_SMC2,
130 MPC85xx_eTSEC1,
131 MPC85xx_eTSEC2,
132 MPC85xx_eTSEC3,
133 MPC85xx_eTSEC4,
134 MPC85xx_IIC2,
130}; 135};
131 136
137/* Internal interrupts are all Level Sensitive, and Positive Polarity */
138#define MPC85XX_INTERNAL_IRQ_SENSES \
139 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 0 */ \
140 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 1 */ \
141 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 2 */ \
142 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 3 */ \
143 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 4 */ \
144 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 5 */ \
145 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 6 */ \
146 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 7 */ \
147 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 8 */ \
148 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 9 */ \
149 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 10 */ \
150 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 11 */ \
151 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 12 */ \
152 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 13 */ \
153 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 14 */ \
154 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 15 */ \
155 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 16 */ \
156 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 17 */ \
157 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 18 */ \
158 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 19 */ \
159 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 20 */ \
160 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 21 */ \
161 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 22 */ \
162 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 23 */ \
163 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 24 */ \
164 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 25 */ \
165 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 26 */ \
166 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 27 */ \
167 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 28 */ \
168 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 29 */ \
169 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 30 */ \
170 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 31 */ \
171 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 32 */ \
172 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 33 */ \
173 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 34 */ \
174 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 35 */ \
175 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 36 */ \
176 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 37 */ \
177 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 38 */ \
178 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 39 */ \
179 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 40 */ \
180 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 41 */ \
181 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 42 */ \
182 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 43 */ \
183 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 44 */ \
184 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 45 */ \
185 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 46 */ \
186 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE) /* Internal 47 */
187
132#endif /* CONFIG_85xx */ 188#endif /* CONFIG_85xx */
133#endif /* __ASM_MPC85xx_H__ */ 189#endif /* __ASM_MPC85xx_H__ */
134#endif /* __KERNEL__ */ 190#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/pgtable.h b/include/asm-ppc/pgtable.h
index a38606d15549..4d4b20c9de78 100644
--- a/include/asm-ppc/pgtable.h
+++ b/include/asm-ppc/pgtable.h
@@ -267,8 +267,6 @@ extern unsigned long ioremap_bot, ioremap_base;
267#define _PMD_PRESENT_MASK (PAGE_MASK) 267#define _PMD_PRESENT_MASK (PAGE_MASK)
268#define _PMD_BAD (~PAGE_MASK) 268#define _PMD_BAD (~PAGE_MASK)
269 269
270#define NUM_TLBCAMS (16)
271
272#elif defined(CONFIG_8xx) 270#elif defined(CONFIG_8xx)
273/* Definitions for 8xx embedded chips. */ 271/* Definitions for 8xx embedded chips. */
274#define _PAGE_PRESENT 0x0001 /* Page is valid */ 272#define _PAGE_PRESENT 0x0001 /* Page is valid */
diff --git a/include/asm-ppc/ppc_sys.h b/include/asm-ppc/ppc_sys.h
index 24b991c42769..8ea624566231 100644
--- a/include/asm-ppc/ppc_sys.h
+++ b/include/asm-ppc/ppc_sys.h
@@ -27,6 +27,8 @@
27#include <asm/mpc85xx.h> 27#include <asm/mpc85xx.h>
28#elif defined(CONFIG_PPC_MPC52xx) 28#elif defined(CONFIG_PPC_MPC52xx)
29#include <asm/mpc52xx.h> 29#include <asm/mpc52xx.h>
30#elif defined(CONFIG_MPC10X_BRIDGE)
31#include <asm/mpc10x.h>
30#else 32#else
31#error "need definition of ppc_sys_devices" 33#error "need definition of ppc_sys_devices"
32#endif 34#endif
diff --git a/include/asm-ppc/smp.h b/include/asm-ppc/smp.h
index ebfb614f55f6..17530c232c76 100644
--- a/include/asm-ppc/smp.h
+++ b/include/asm-ppc/smp.h
@@ -44,7 +44,7 @@ extern void smp_message_recv(int, struct pt_regs *);
44#define NO_PROC_ID 0xFF /* No processor magic marker */ 44#define NO_PROC_ID 0xFF /* No processor magic marker */
45#define PROC_CHANGE_PENALTY 20 45#define PROC_CHANGE_PENALTY 20
46 46
47#define smp_processor_id() (current_thread_info()->cpu) 47#define raw_smp_processor_id() (current_thread_info()->cpu)
48 48
49extern int __cpu_up(unsigned int cpu); 49extern int __cpu_up(unsigned int cpu);
50 50
diff --git a/include/asm-ppc64/dma.h b/include/asm-ppc64/dma.h
index d693b8026bc3..dfd1f69059ba 100644
--- a/include/asm-ppc64/dma.h
+++ b/include/asm-ppc64/dma.h
@@ -27,6 +27,8 @@
27/* Doesn't really apply... */ 27/* Doesn't really apply... */
28#define MAX_DMA_ADDRESS (~0UL) 28#define MAX_DMA_ADDRESS (~0UL)
29 29
30#if !defined(CONFIG_PPC_ISERIES) || defined(CONFIG_PCI)
31
30#define dma_outb outb 32#define dma_outb outb
31#define dma_inb inb 33#define dma_inb inb
32 34
@@ -323,4 +325,5 @@ extern int isa_dma_bridge_buggy;
323#else 325#else
324#define isa_dma_bridge_buggy (0) 326#define isa_dma_bridge_buggy (0)
325#endif 327#endif
328#endif /* !defined(CONFIG_PPC_ISERIES) || defined(CONFIG_PCI) */
326#endif /* _ASM_DMA_H */ 329#endif /* _ASM_DMA_H */
diff --git a/include/asm-ppc64/iSeries/HvCall.h b/include/asm-ppc64/iSeries/HvCall.h
index d9a2e74e2399..c3f19475c0d9 100644
--- a/include/asm-ppc64/iSeries/HvCall.h
+++ b/include/asm-ppc64/iSeries/HvCall.h
@@ -1,84 +1,36 @@
1/* 1/*
2 * HvCall.h 2 * HvCall.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation 3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */ 18 */
19 19/*
20//=========================================================================== 20 * This file contains the "hypervisor call" interface which is used to
21// 21 * drive the hypervisor from the OS.
22// This file contains the "hypervisor call" interface which is used to 22 */
23// drive the hypervisor from the OS.
24//
25//===========================================================================
26#ifndef _HVCALL_H 23#ifndef _HVCALL_H
27#define _HVCALL_H 24#define _HVCALL_H
28 25
29//-------------------------------------------------------------------
30// Standard Includes
31//-------------------------------------------------------------------
32#include <asm/iSeries/HvCallSc.h> 26#include <asm/iSeries/HvCallSc.h>
33#include <asm/iSeries/HvTypes.h> 27#include <asm/iSeries/HvTypes.h>
34#include <asm/paca.h> 28#include <asm/paca.h>
35 29
36/*
37enum HvCall_ReturnCode
38{
39 HvCall_Good = 0,
40 HvCall_Partial = 1,
41 HvCall_NotOwned = 2,
42 HvCall_NotFreed = 3,
43 HvCall_UnspecifiedError = 4
44};
45
46enum HvCall_TypeOfSIT
47{
48 HvCall_ReduceOnly = 0,
49 HvCall_Unconditional = 1
50};
51
52enum HvCall_TypeOfYield
53{
54 HvCall_YieldTimed = 0, // Yield until specified time
55 HvCall_YieldToActive = 1, // Yield until all active procs have run
56 HvCall_YieldToProc = 2 // Yield until the specified processor has run
57};
58
59enum HvCall_InterruptMasks
60{
61 HvCall_MaskIPI = 0x00000001,
62 HvCall_MaskLpEvent = 0x00000002,
63 HvCall_MaskLpProd = 0x00000004,
64 HvCall_MaskTimeout = 0x00000008
65};
66
67enum HvCall_VaryOffChunkRc
68{
69 HvCall_VaryOffSucceeded = 0,
70 HvCall_VaryOffWithdrawn = 1,
71 HvCall_ChunkInLoadArea = 2,
72 HvCall_ChunkInHPT = 3,
73 HvCall_ChunkNotAccessible = 4,
74 HvCall_ChunkInUse = 5
75};
76*/
77
78/* Type of yield for HvCallBaseYieldProcessor */ 30/* Type of yield for HvCallBaseYieldProcessor */
79#define HvCall_YieldTimed 0 // Yield until specified time (tb) 31#define HvCall_YieldTimed 0 /* Yield until specified time (tb) */
80#define HvCall_YieldToActive 1 // Yield until all active procs have run 32#define HvCall_YieldToActive 1 /* Yield until all active procs have run */
81#define HvCall_YieldToProc 2 // Yield until the specified processor has run 33#define HvCall_YieldToProc 2 /* Yield until the specified processor has run */
82 34
83/* interrupt masks for setEnabledInterrupts */ 35/* interrupt masks for setEnabledInterrupts */
84#define HvCall_MaskIPI 0x00000001 36#define HvCall_MaskIPI 0x00000001
@@ -86,7 +38,7 @@ enum HvCall_VaryOffChunkRc
86#define HvCall_MaskLpProd 0x00000004 38#define HvCall_MaskLpProd 0x00000004
87#define HvCall_MaskTimeout 0x00000008 39#define HvCall_MaskTimeout 0x00000008
88 40
89/* Log buffer formats */ 41/* Log buffer formats */
90#define HvCall_LogBuffer_ASCII 0 42#define HvCall_LogBuffer_ASCII 0
91#define HvCall_LogBuffer_EBCDIC 1 43#define HvCall_LogBuffer_EBCDIC 1
92 44
@@ -95,7 +47,7 @@ enum HvCall_VaryOffChunkRc
95#define HvCallBaseGetHwPatch HvCallBase + 2 47#define HvCallBaseGetHwPatch HvCallBase + 2
96#define HvCallBaseReIplSpAttn HvCallBase + 3 48#define HvCallBaseReIplSpAttn HvCallBase + 3
97#define HvCallBaseSetASR HvCallBase + 4 49#define HvCallBaseSetASR HvCallBase + 4
98#define HvCallBaseSetASRAndRfi HvCallBase + 5 50#define HvCallBaseSetASRAndRfi HvCallBase + 5
99#define HvCallBaseSetIMR HvCallBase + 6 51#define HvCallBaseSetIMR HvCallBase + 6
100#define HvCallBaseSendIPI HvCallBase + 7 52#define HvCallBaseSendIPI HvCallBase + 7
101#define HvCallBaseTerminateMachine HvCallBase + 8 53#define HvCallBaseTerminateMachine HvCallBase + 8
@@ -115,91 +67,47 @@ enum HvCall_VaryOffChunkRc
115#define HvCallBaseGetLogBufferCodePage HvCallBase + 22 67#define HvCallBaseGetLogBufferCodePage HvCallBase + 22
116#define HvCallBaseGetLogBufferFormat HvCallBase + 23 68#define HvCallBaseGetLogBufferFormat HvCallBase + 23
117#define HvCallBaseGetLogBufferLength HvCallBase + 24 69#define HvCallBaseGetLogBufferLength HvCallBase + 24
118#define HvCallBaseReadLogBuffer HvCallBase + 25 70#define HvCallBaseReadLogBuffer HvCallBase + 25
119#define HvCallBaseSetLogBufferFormatAndCodePage HvCallBase + 26 71#define HvCallBaseSetLogBufferFormatAndCodePage HvCallBase + 26
120#define HvCallBaseWriteLogBuffer HvCallBase + 27 72#define HvCallBaseWriteLogBuffer HvCallBase + 27
121#define HvCallBaseRouter28 HvCallBase + 28 73#define HvCallBaseRouter28 HvCallBase + 28
122#define HvCallBaseRouter29 HvCallBase + 29 74#define HvCallBaseRouter29 HvCallBase + 29
123#define HvCallBaseRouter30 HvCallBase + 30 75#define HvCallBaseRouter30 HvCallBase + 30
124#define HvCallBaseSetDebugBus HvCallBase + 31 76#define HvCallBaseSetDebugBus HvCallBase + 31
125 77
126#define HvCallCcSetDABR HvCallCc + 7 78#define HvCallCcSetDABR HvCallCc + 7
127 79
128//===================================================================================== 80static inline void HvCall_setVirtualDecr(void)
129static inline void HvCall_setVirtualDecr(void)
130{ 81{
131 /* Ignore any error return codes - most likely means that the target value for the 82 /*
132 * LP has been increased and this vary off would bring us below the new target. */ 83 * Ignore any error return codes - most likely means that the
84 * target value for the LP has been increased and this vary off
85 * would bring us below the new target.
86 */
133 HvCall0(HvCallBaseSetVirtualDecr); 87 HvCall0(HvCallBaseSetVirtualDecr);
134} 88}
135//=====================================================================
136static inline void HvCall_yieldProcessor(unsigned typeOfYield, u64 yieldParm)
137{
138 HvCall2( HvCallBaseYieldProcessor, typeOfYield, yieldParm );
139}
140//=====================================================================
141static inline void HvCall_setEnabledInterrupts(u64 enabledInterrupts)
142{
143 HvCall1(HvCallBaseSetEnabledInterrupts,enabledInterrupts);
144}
145
146//=====================================================================
147static inline void HvCall_clearLogBuffer(HvLpIndex lpindex)
148{
149 HvCall1(HvCallBaseClearLogBuffer,lpindex);
150}
151
152//=====================================================================
153static inline u32 HvCall_getLogBufferCodePage(HvLpIndex lpindex)
154{
155 u32 retVal = HvCall1(HvCallBaseGetLogBufferCodePage,lpindex);
156 return retVal;
157}
158
159//=====================================================================
160static inline int HvCall_getLogBufferFormat(HvLpIndex lpindex)
161{
162 int retVal = HvCall1(HvCallBaseGetLogBufferFormat,lpindex);
163 return retVal;
164}
165
166//=====================================================================
167static inline u32 HvCall_getLogBufferLength(HvLpIndex lpindex)
168{
169 u32 retVal = HvCall1(HvCallBaseGetLogBufferLength,lpindex);
170 return retVal;
171}
172 89
173//===================================================================== 90static inline void HvCall_yieldProcessor(unsigned typeOfYield, u64 yieldParm)
174static inline void HvCall_setLogBufferFormatAndCodepage(int format, u32 codePage)
175{ 91{
176 HvCall2(HvCallBaseSetLogBufferFormatAndCodePage,format, codePage); 92 HvCall2(HvCallBaseYieldProcessor, typeOfYield, yieldParm);
177} 93}
178 94
179//===================================================================== 95static inline void HvCall_setEnabledInterrupts(u64 enabledInterrupts)
180int HvCall_readLogBuffer(HvLpIndex lpindex, void *buffer, u64 bufLen);
181void HvCall_writeLogBuffer(const void *buffer, u64 bufLen);
182
183//=====================================================================
184static inline void HvCall_sendIPI(struct paca_struct * targetPaca)
185{ 96{
186 HvCall1( HvCallBaseSendIPI, targetPaca->paca_index ); 97 HvCall1(HvCallBaseSetEnabledInterrupts, enabledInterrupts);
187} 98}
188 99
189//===================================================================== 100static inline void HvCall_setLogBufferFormatAndCodepage(int format,
190static inline void HvCall_terminateMachineSrc(void) 101 u32 codePage)
191{ 102{
192 HvCall0( HvCallBaseTerminateMachineSrc ); 103 HvCall2(HvCallBaseSetLogBufferFormatAndCodePage, format, codePage);
193} 104}
194 105
195static inline void HvCall_setDABR(unsigned long val) 106extern void HvCall_writeLogBuffer(const void *buffer, u64 bufLen);
196{
197 HvCall1(HvCallCcSetDABR, val);
198}
199 107
200static inline void HvCall_setDebugBus(unsigned long val) 108static inline void HvCall_sendIPI(struct paca_struct *targetPaca)
201{ 109{
202 HvCall1(HvCallBaseSetDebugBus, val); 110 HvCall1(HvCallBaseSendIPI, targetPaca->paca_index);
203} 111}
204 112
205#endif /* _HVCALL_H */ 113#endif /* _HVCALL_H */
diff --git a/include/asm-ppc64/iSeries/HvCallCfg.h b/include/asm-ppc64/iSeries/HvCallCfg.h
deleted file mode 100644
index 9f40f16de533..000000000000
--- a/include/asm-ppc64/iSeries/HvCallCfg.h
+++ /dev/null
@@ -1,213 +0,0 @@
1/*
2 * HvCallCfg.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20//=====================================================================================
21//
22// This file contains the "hypervisor call" interface which is used to
23// drive the hypervisor from the OS.
24//
25//=====================================================================================
26#ifndef _HVCALLCFG_H
27#define _HVCALLCFG_H
28
29//-------------------------------------------------------------------
30// Standard Includes
31//-------------------------------------------------------------------
32#include <asm/iSeries/HvCallSc.h>
33#include <asm/iSeries/HvTypes.h>
34
35//-------------------------------------------------------------------------------------
36// Constants
37//-------------------------------------------------------------------------------------
38
39enum HvCallCfg_ReqQual
40{
41 HvCallCfg_Cur = 0,
42 HvCallCfg_Init = 1,
43 HvCallCfg_Max = 2,
44 HvCallCfg_Min = 3
45};
46
47#define HvCallCfgGetLps HvCallCfg + 0
48#define HvCallCfgGetActiveLpMap HvCallCfg + 1
49#define HvCallCfgGetLpVrmIndex HvCallCfg + 2
50#define HvCallCfgGetLpMinSupportedPlicVrmIndex HvCallCfg + 3
51#define HvCallCfgGetLpMinCompatablePlicVrmIndex HvCallCfg + 4
52#define HvCallCfgGetLpVrmName HvCallCfg + 5
53#define HvCallCfgGetSystemPhysicalProcessors HvCallCfg + 6
54#define HvCallCfgGetPhysicalProcessors HvCallCfg + 7
55#define HvCallCfgGetSystemMsChunks HvCallCfg + 8
56#define HvCallCfgGetMsChunks HvCallCfg + 9
57#define HvCallCfgGetInteractivePercentage HvCallCfg + 10
58#define HvCallCfgIsBusDedicated HvCallCfg + 11
59#define HvCallCfgGetBusOwner HvCallCfg + 12
60#define HvCallCfgGetBusAllocation HvCallCfg + 13
61#define HvCallCfgGetBusUnitOwner HvCallCfg + 14
62#define HvCallCfgGetBusUnitAllocation HvCallCfg + 15
63#define HvCallCfgGetVirtualBusPool HvCallCfg + 16
64#define HvCallCfgGetBusUnitInterruptProc HvCallCfg + 17
65#define HvCallCfgGetConfiguredBusUnitsForIntProc HvCallCfg + 18
66#define HvCallCfgGetRioSanBusPool HvCallCfg + 19
67#define HvCallCfgGetSharedPoolIndex HvCallCfg + 20
68#define HvCallCfgGetSharedProcUnits HvCallCfg + 21
69#define HvCallCfgGetNumProcsInSharedPool HvCallCfg + 22
70#define HvCallCfgRouter23 HvCallCfg + 23
71#define HvCallCfgRouter24 HvCallCfg + 24
72#define HvCallCfgRouter25 HvCallCfg + 25
73#define HvCallCfgRouter26 HvCallCfg + 26
74#define HvCallCfgRouter27 HvCallCfg + 27
75#define HvCallCfgGetMinRuntimeMsChunks HvCallCfg + 28
76#define HvCallCfgSetMinRuntimeMsChunks HvCallCfg + 29
77#define HvCallCfgGetVirtualLanIndexMap HvCallCfg + 30
78#define HvCallCfgGetLpExecutionMode HvCallCfg + 31
79#define HvCallCfgGetHostingLpIndex HvCallCfg + 32
80
81//====================================================================
82static inline HvLpIndex HvCallCfg_getLps(void)
83{
84 HvLpIndex retVal = HvCall0(HvCallCfgGetLps);
85 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
86 return retVal;
87}
88//====================================================================
89static inline int HvCallCfg_isBusDedicated(u64 busIndex)
90{
91 int retVal = HvCall1(HvCallCfgIsBusDedicated,busIndex);
92 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
93 return retVal;
94}
95//====================================================================
96static inline HvLpIndex HvCallCfg_getBusOwner(u64 busIndex)
97{
98 HvLpIndex retVal = HvCall1(HvCallCfgGetBusOwner,busIndex);
99 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
100 return retVal;
101}
102//====================================================================
103static inline HvLpIndexMap HvCallCfg_getBusAllocation(u64 busIndex)
104{
105 HvLpIndexMap retVal = HvCall1(HvCallCfgGetBusAllocation,busIndex);
106 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
107 return retVal;
108}
109//====================================================================
110static inline HvLpIndexMap HvCallCfg_getActiveLpMap(void)
111{
112 HvLpIndexMap retVal = HvCall0(HvCallCfgGetActiveLpMap);
113 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
114 return retVal;
115}
116//====================================================================
117static inline HvLpVirtualLanIndexMap HvCallCfg_getVirtualLanIndexMap(HvLpIndex lp)
118{
119 // This is a new function in V5R1 so calls to this on older
120 // hypervisors will return -1
121 u64 retVal = HvCall1(HvCallCfgGetVirtualLanIndexMap, lp);
122 if(retVal == -1)
123 retVal = 0;
124 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
125 return retVal;
126}
127//===================================================================
128static inline u64 HvCallCfg_getSystemMsChunks(void)
129{
130 u64 retVal = HvCall0(HvCallCfgGetSystemMsChunks);
131 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
132 return retVal;
133}
134//===================================================================
135static inline u64 HvCallCfg_getMsChunks(HvLpIndex lp,enum HvCallCfg_ReqQual qual)
136{
137 u64 retVal = HvCall2(HvCallCfgGetMsChunks,lp,qual);
138 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
139 return retVal;
140}
141//===================================================================
142static inline u64 HvCallCfg_getMinRuntimeMsChunks(HvLpIndex lp)
143{
144 // NOTE: This function was added in v5r1 so older hypervisors will return a -1 value
145 u64 retVal = HvCall1(HvCallCfgGetMinRuntimeMsChunks,lp);
146 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
147 return retVal;
148}
149//===================================================================
150static inline u64 HvCallCfg_setMinRuntimeMsChunks(u64 chunks)
151{
152 u64 retVal = HvCall1(HvCallCfgSetMinRuntimeMsChunks,chunks);
153 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
154 return retVal;
155}
156//===================================================================
157static inline u64 HvCallCfg_getSystemPhysicalProcessors(void)
158{
159 u64 retVal = HvCall0(HvCallCfgGetSystemPhysicalProcessors);
160 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
161 return retVal;
162}
163//===================================================================
164static inline u64 HvCallCfg_getPhysicalProcessors(HvLpIndex lp,enum HvCallCfg_ReqQual qual)
165{
166 u64 retVal = HvCall2(HvCallCfgGetPhysicalProcessors,lp,qual);
167 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
168 return retVal;
169}
170//===================================================================
171static inline u64 HvCallCfg_getConfiguredBusUnitsForInterruptProc(HvLpIndex lp,
172 u16 hvLogicalProcIndex)
173{
174 u64 retVal = HvCall2(HvCallCfgGetConfiguredBusUnitsForIntProc,lp,hvLogicalProcIndex);
175 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
176 return retVal;
177
178}
179//==================================================================
180static inline HvLpSharedPoolIndex HvCallCfg_getSharedPoolIndex(HvLpIndex lp)
181{
182 HvLpSharedPoolIndex retVal =
183 HvCall1(HvCallCfgGetSharedPoolIndex,lp);
184 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
185 return retVal;
186
187}
188//==================================================================
189static inline u64 HvCallCfg_getSharedProcUnits(HvLpIndex lp,enum HvCallCfg_ReqQual qual)
190{
191 u64 retVal = HvCall2(HvCallCfgGetSharedProcUnits,lp,qual);
192 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
193 return retVal;
194
195}
196//==================================================================
197static inline u64 HvCallCfg_getNumProcsInSharedPool(HvLpSharedPoolIndex sPI)
198{
199 u16 retVal = HvCall1(HvCallCfgGetNumProcsInSharedPool,sPI);
200 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
201 return retVal;
202
203}
204//==================================================================
205static inline HvLpIndex HvCallCfg_getHostingLpIndex(HvLpIndex lp)
206{
207 u64 retVal = HvCall1(HvCallCfgGetHostingLpIndex,lp);
208 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
209 return retVal;
210
211}
212
213#endif /* _HVCALLCFG_H */
diff --git a/include/asm-ppc64/iSeries/HvCallEvent.h b/include/asm-ppc64/iSeries/HvCallEvent.h
index 191ddce0c2c6..5d9a327d0122 100644
--- a/include/asm-ppc64/iSeries/HvCallEvent.h
+++ b/include/asm-ppc64/iSeries/HvCallEvent.h
@@ -1,32 +1,28 @@
1/* 1/*
2 * HvCallEvent.h 2 * HvCallEvent.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation 3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */ 18 */
19
20/* 19/*
21 * This file contains the "hypervisor call" interface which is used to 20 * This file contains the "hypervisor call" interface which is used to
22 * drive the hypervisor from the OS. 21 * drive the hypervisor from the OS.
23 */ 22 */
24#ifndef _HVCALLEVENT_H 23#ifndef _HVCALLEVENT_H
25#define _HVCALLEVENT_H 24#define _HVCALLEVENT_H
26 25
27/*
28 * Standard Includes
29 */
30#include <asm/iSeries/HvCallSc.h> 26#include <asm/iSeries/HvCallSc.h>
31#include <asm/iSeries/HvTypes.h> 27#include <asm/iSeries/HvTypes.h>
32#include <asm/abs_addr.h> 28#include <asm/abs_addr.h>
@@ -71,7 +67,7 @@ typedef u64 HvLpDma_Rc;
71#define HvCallEventCloseLpEventPath HvCallEvent + 2 67#define HvCallEventCloseLpEventPath HvCallEvent + 2
72#define HvCallEventDmaBufList HvCallEvent + 3 68#define HvCallEventDmaBufList HvCallEvent + 3
73#define HvCallEventDmaSingle HvCallEvent + 4 69#define HvCallEventDmaSingle HvCallEvent + 4
74#define HvCallEventDmaToSp HvCallEvent + 5 70#define HvCallEventDmaToSp HvCallEvent + 5
75#define HvCallEventGetOverflowLpEvents HvCallEvent + 6 71#define HvCallEventGetOverflowLpEvents HvCallEvent + 6
76#define HvCallEventGetSourceLpInstanceId HvCallEvent + 7 72#define HvCallEventGetSourceLpInstanceId HvCallEvent + 7
77#define HvCallEventGetTargetLpInstanceId HvCallEvent + 8 73#define HvCallEventGetTargetLpInstanceId HvCallEvent + 8
@@ -85,14 +81,12 @@ typedef u64 HvLpDma_Rc;
85 81
86static inline void HvCallEvent_getOverflowLpEvents(u8 queueIndex) 82static inline void HvCallEvent_getOverflowLpEvents(u8 queueIndex)
87{ 83{
88 HvCall1(HvCallEventGetOverflowLpEvents,queueIndex); 84 HvCall1(HvCallEventGetOverflowLpEvents, queueIndex);
89 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
90} 85}
91 86
92static inline void HvCallEvent_setInterLpQueueIndex(u8 queueIndex) 87static inline void HvCallEvent_setInterLpQueueIndex(u8 queueIndex)
93{ 88{
94 HvCall1(HvCallEventSetInterLpQueueIndex,queueIndex); 89 HvCall1(HvCallEventSetInterLpQueueIndex, queueIndex);
95 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
96} 90}
97 91
98static inline void HvCallEvent_setLpEventStack(u8 queueIndex, 92static inline void HvCallEvent_setLpEventStack(u8 queueIndex,
@@ -103,7 +97,6 @@ static inline void HvCallEvent_setLpEventStack(u8 queueIndex,
103 abs_addr = virt_to_abs(eventStackAddr); 97 abs_addr = virt_to_abs(eventStackAddr);
104 HvCall3(HvCallEventSetLpEventStack, queueIndex, abs_addr, 98 HvCall3(HvCallEventSetLpEventStack, queueIndex, abs_addr,
105 eventStackSize); 99 eventStackSize);
106 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
107} 100}
108 101
109static inline void HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex, 102static inline void HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex,
@@ -111,22 +104,18 @@ static inline void HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex,
111{ 104{
112 HvCall2(HvCallEventSetLpEventQueueInterruptProc, queueIndex, 105 HvCall2(HvCallEventSetLpEventQueueInterruptProc, queueIndex,
113 lpLogicalProcIndex); 106 lpLogicalProcIndex);
114 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
115} 107}
116 108
117static inline HvLpEvent_Rc HvCallEvent_signalLpEvent(struct HvLpEvent *event) 109static inline HvLpEvent_Rc HvCallEvent_signalLpEvent(struct HvLpEvent *event)
118{ 110{
119 u64 abs_addr; 111 u64 abs_addr;
120 HvLpEvent_Rc retVal;
121 112
122#ifdef DEBUG_SENDEVENT 113#ifdef DEBUG_SENDEVENT
123 printk("HvCallEvent_signalLpEvent: *event = %016lx\n ", 114 printk("HvCallEvent_signalLpEvent: *event = %016lx\n ",
124 (unsigned long)event); 115 (unsigned long)event);
125#endif 116#endif
126 abs_addr = virt_to_abs(event); 117 abs_addr = virt_to_abs(event);
127 retVal = (HvLpEvent_Rc)HvCall1(HvCallEventSignalLpEvent, abs_addr); 118 return HvCall1(HvCallEventSignalLpEvent, abs_addr);
128 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
129 return retVal;
130} 119}
131 120
132static inline HvLpEvent_Rc HvCallEvent_signalLpEventFast(HvLpIndex targetLp, 121static inline HvLpEvent_Rc HvCallEvent_signalLpEventFast(HvLpIndex targetLp,
@@ -136,9 +125,7 @@ static inline HvLpEvent_Rc HvCallEvent_signalLpEventFast(HvLpIndex targetLp,
136 u64 eventData1, u64 eventData2, u64 eventData3, 125 u64 eventData1, u64 eventData2, u64 eventData3,
137 u64 eventData4, u64 eventData5) 126 u64 eventData4, u64 eventData5)
138{ 127{
139 HvLpEvent_Rc retVal; 128 /* Pack the misc bits into a single Dword to pass to PLIC */
140
141 // Pack the misc bits into a single Dword to pass to PLIC
142 union { 129 union {
143 struct HvCallEvent_PackedParms parms; 130 struct HvCallEvent_PackedParms parms;
144 u64 dword; 131 u64 dword;
@@ -152,67 +139,49 @@ static inline HvLpEvent_Rc HvCallEvent_signalLpEventFast(HvLpIndex targetLp,
152 packed.parms.xSourceInstId = sourceInstanceId; 139 packed.parms.xSourceInstId = sourceInstanceId;
153 packed.parms.xTargetInstId = targetInstanceId; 140 packed.parms.xTargetInstId = targetInstanceId;
154 141
155 retVal = (HvLpEvent_Rc)HvCall7(HvCallEventSignalLpEventParms, 142 return HvCall7(HvCallEventSignalLpEventParms, packed.dword,
156 packed.dword, correlationToken, eventData1,eventData2, 143 correlationToken, eventData1, eventData2,
157 eventData3,eventData4, eventData5); 144 eventData3, eventData4, eventData5);
158 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
159 return retVal;
160} 145}
161 146
162static inline HvLpEvent_Rc HvCallEvent_ackLpEvent(struct HvLpEvent *event) 147static inline HvLpEvent_Rc HvCallEvent_ackLpEvent(struct HvLpEvent *event)
163{ 148{
164 u64 abs_addr; 149 u64 abs_addr;
165 HvLpEvent_Rc retVal;
166 150
167 abs_addr = virt_to_abs(event); 151 abs_addr = virt_to_abs(event);
168 retVal = (HvLpEvent_Rc)HvCall1(HvCallEventAckLpEvent, abs_addr); 152 return HvCall1(HvCallEventAckLpEvent, abs_addr);
169 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
170 return retVal;
171} 153}
172 154
173static inline HvLpEvent_Rc HvCallEvent_cancelLpEvent(struct HvLpEvent *event) 155static inline HvLpEvent_Rc HvCallEvent_cancelLpEvent(struct HvLpEvent *event)
174{ 156{
175 u64 abs_addr; 157 u64 abs_addr;
176 HvLpEvent_Rc retVal;
177 158
178 abs_addr = virt_to_abs(event); 159 abs_addr = virt_to_abs(event);
179 retVal = (HvLpEvent_Rc)HvCall1(HvCallEventCancelLpEvent, abs_addr); 160 return HvCall1(HvCallEventCancelLpEvent, abs_addr);
180 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
181 return retVal;
182} 161}
183 162
184static inline HvLpInstanceId HvCallEvent_getSourceLpInstanceId( 163static inline HvLpInstanceId HvCallEvent_getSourceLpInstanceId(
185 HvLpIndex targetLp, HvLpEvent_Type type) 164 HvLpIndex targetLp, HvLpEvent_Type type)
186{ 165{
187 HvLpInstanceId retVal; 166 return HvCall2(HvCallEventGetSourceLpInstanceId, targetLp, type);
188
189 retVal = HvCall2(HvCallEventGetSourceLpInstanceId, targetLp, type);
190 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
191 return retVal;
192} 167}
193 168
194static inline HvLpInstanceId HvCallEvent_getTargetLpInstanceId( 169static inline HvLpInstanceId HvCallEvent_getTargetLpInstanceId(
195 HvLpIndex targetLp, HvLpEvent_Type type) 170 HvLpIndex targetLp, HvLpEvent_Type type)
196{ 171{
197 HvLpInstanceId retVal; 172 return HvCall2(HvCallEventGetTargetLpInstanceId, targetLp, type);
198
199 retVal = HvCall2(HvCallEventGetTargetLpInstanceId, targetLp, type);
200 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
201 return retVal;
202} 173}
203 174
204static inline void HvCallEvent_openLpEventPath(HvLpIndex targetLp, 175static inline void HvCallEvent_openLpEventPath(HvLpIndex targetLp,
205 HvLpEvent_Type type) 176 HvLpEvent_Type type)
206{ 177{
207 HvCall2(HvCallEventOpenLpEventPath, targetLp, type); 178 HvCall2(HvCallEventOpenLpEventPath, targetLp, type);
208 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
209} 179}
210 180
211static inline void HvCallEvent_closeLpEventPath(HvLpIndex targetLp, 181static inline void HvCallEvent_closeLpEventPath(HvLpIndex targetLp,
212 HvLpEvent_Type type) 182 HvLpEvent_Type type)
213{ 183{
214 HvCall2(HvCallEventCloseLpEventPath, targetLp, type); 184 HvCall2(HvCallEventCloseLpEventPath, targetLp, type);
215 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
216} 185}
217 186
218static inline HvLpDma_Rc HvCallEvent_dmaBufList(HvLpEvent_Type type, 187static inline HvLpDma_Rc HvCallEvent_dmaBufList(HvLpEvent_Type type,
@@ -224,8 +193,7 @@ static inline HvLpDma_Rc HvCallEvent_dmaBufList(HvLpEvent_Type type,
224 /* Do these need to be converted to absolute addresses? */ 193 /* Do these need to be converted to absolute addresses? */
225 u64 localBufList, u64 remoteBufList, u32 transferLength) 194 u64 localBufList, u64 remoteBufList, u32 transferLength)
226{ 195{
227 HvLpDma_Rc retVal; 196 /* Pack the misc bits into a single Dword to pass to PLIC */
228 // Pack the misc bits into a single Dword to pass to PLIC
229 union { 197 union {
230 struct HvCallEvent_PackedDmaParms parms; 198 struct HvCallEvent_PackedDmaParms parms;
231 u64 dword; 199 u64 dword;
@@ -241,11 +209,8 @@ static inline HvLpDma_Rc HvCallEvent_dmaBufList(HvLpEvent_Type type,
241 packed.parms.xLocalInstId = localInstanceId; 209 packed.parms.xLocalInstId = localInstanceId;
242 packed.parms.xRemoteInstId = remoteInstanceId; 210 packed.parms.xRemoteInstId = remoteInstanceId;
243 211
244 retVal = (HvLpDma_Rc)HvCall4(HvCallEventDmaBufList, 212 return HvCall4(HvCallEventDmaBufList, packed.dword, localBufList,
245 packed.dword, localBufList, remoteBufList, 213 remoteBufList, transferLength);
246 transferLength);
247 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
248 return retVal;
249} 214}
250 215
251static inline HvLpDma_Rc HvCallEvent_dmaSingle(HvLpEvent_Type type, 216static inline HvLpDma_Rc HvCallEvent_dmaSingle(HvLpEvent_Type type,
@@ -256,8 +221,7 @@ static inline HvLpDma_Rc HvCallEvent_dmaSingle(HvLpEvent_Type type,
256 HvLpDma_AddressType remoteAddressType, 221 HvLpDma_AddressType remoteAddressType,
257 u64 localAddrOrTce, u64 remoteAddrOrTce, u32 transferLength) 222 u64 localAddrOrTce, u64 remoteAddrOrTce, u32 transferLength)
258{ 223{
259 HvLpDma_Rc retVal; 224 /* Pack the misc bits into a single Dword to pass to PLIC */
260 // Pack the misc bits into a single Dword to pass to PLIC
261 union { 225 union {
262 struct HvCallEvent_PackedDmaParms parms; 226 struct HvCallEvent_PackedDmaParms parms;
263 u64 dword; 227 u64 dword;
@@ -273,25 +237,17 @@ static inline HvLpDma_Rc HvCallEvent_dmaSingle(HvLpEvent_Type type,
273 packed.parms.xLocalInstId = localInstanceId; 237 packed.parms.xLocalInstId = localInstanceId;
274 packed.parms.xRemoteInstId = remoteInstanceId; 238 packed.parms.xRemoteInstId = remoteInstanceId;
275 239
276 retVal = (HvLpDma_Rc)HvCall4(HvCallEventDmaSingle, 240 return (HvLpDma_Rc)HvCall4(HvCallEventDmaSingle, packed.dword,
277 packed.dword, localAddrOrTce, remoteAddrOrTce, 241 localAddrOrTce, remoteAddrOrTce, transferLength);
278 transferLength);
279 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
280 return retVal;
281} 242}
282 243
283static inline HvLpDma_Rc HvCallEvent_dmaToSp(void* local, u32 remote, 244static inline HvLpDma_Rc HvCallEvent_dmaToSp(void *local, u32 remote,
284 u32 length, HvLpDma_Direction dir) 245 u32 length, HvLpDma_Direction dir)
285{ 246{
286 u64 abs_addr; 247 u64 abs_addr;
287 HvLpDma_Rc retVal;
288 248
289 abs_addr = virt_to_abs(local); 249 abs_addr = virt_to_abs(local);
290 retVal = (HvLpDma_Rc)HvCall4(HvCallEventDmaToSp, abs_addr, remote, 250 return HvCall4(HvCallEventDmaToSp, abs_addr, remote, length, dir);
291 length, dir);
292 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
293 return retVal;
294} 251}
295 252
296
297#endif /* _HVCALLEVENT_H */ 253#endif /* _HVCALLEVENT_H */
diff --git a/include/asm-ppc64/iSeries/HvCallHpt.h b/include/asm-ppc64/iSeries/HvCallHpt.h
index da769873d18b..66f38222ff75 100644
--- a/include/asm-ppc64/iSeries/HvCallHpt.h
+++ b/include/asm-ppc64/iSeries/HvCallHpt.h
@@ -1,17 +1,17 @@
1/* 1/*
2 * HvCallHpt.h 2 * HvCallHpt.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation 3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -19,21 +19,15 @@
19#ifndef _HVCALLHPT_H 19#ifndef _HVCALLHPT_H
20#define _HVCALLHPT_H 20#define _HVCALLHPT_H
21 21
22//============================================================================ 22/*
23// 23 * This file contains the "hypervisor call" interface which is used to
24// This file contains the "hypervisor call" interface which is used to 24 * drive the hypervisor from the OS.
25// drive the hypervisor from the OS. 25 */
26//
27//============================================================================
28 26
29#include <asm/iSeries/HvCallSc.h> 27#include <asm/iSeries/HvCallSc.h>
30#include <asm/iSeries/HvTypes.h> 28#include <asm/iSeries/HvTypes.h>
31#include <asm/mmu.h> 29#include <asm/mmu.h>
32 30
33//-----------------------------------------------------------------------------
34// Constants
35//-----------------------------------------------------------------------------
36
37#define HvCallHptGetHptAddress HvCallHpt + 0 31#define HvCallHptGetHptAddress HvCallHpt + 0
38#define HvCallHptGetHptPages HvCallHpt + 1 32#define HvCallHptGetHptPages HvCallHpt + 1
39#define HvCallHptSetPp HvCallHpt + 5 33#define HvCallHptSetPp HvCallHpt + 5
@@ -47,81 +41,63 @@
47#define HvCallHptInvalidateSetSwBitsGet HvCallHpt + 18 41#define HvCallHptInvalidateSetSwBitsGet HvCallHpt + 18
48 42
49 43
50//============================================================================ 44static inline u64 HvCallHpt_getHptAddress(void)
51static inline u64 HvCallHpt_getHptAddress(void)
52{ 45{
53 u64 retval = HvCall0(HvCallHptGetHptAddress); 46 return HvCall0(HvCallHptGetHptAddress);
54 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
55 return retval;
56} 47}
57//============================================================================ 48
58static inline u64 HvCallHpt_getHptPages(void) 49static inline u64 HvCallHpt_getHptPages(void)
59{ 50{
60 u64 retval = HvCall0(HvCallHptGetHptPages); 51 return HvCall0(HvCallHptGetHptPages);
61 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
62 return retval;
63} 52}
64//============================================================================= 53
65static inline void HvCallHpt_setPp(u32 hpteIndex, u8 value) 54static inline void HvCallHpt_setPp(u32 hpteIndex, u8 value)
66{ 55{
67 HvCall2( HvCallHptSetPp, hpteIndex, value ); 56 HvCall2(HvCallHptSetPp, hpteIndex, value);
68 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
69} 57}
70//============================================================================= 58
71static inline void HvCallHpt_setSwBits(u32 hpteIndex, u8 bitson, u8 bitsoff ) 59static inline void HvCallHpt_setSwBits(u32 hpteIndex, u8 bitson, u8 bitsoff)
72{ 60{
73 HvCall3( HvCallHptSetSwBits, hpteIndex, bitson, bitsoff ); 61 HvCall3(HvCallHptSetSwBits, hpteIndex, bitson, bitsoff);
74 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
75} 62}
76//============================================================================= 63
77static inline void HvCallHpt_invalidateNoSyncICache(u32 hpteIndex) 64static inline void HvCallHpt_invalidateNoSyncICache(u32 hpteIndex)
78
79{ 65{
80 HvCall1( HvCallHptInvalidateNoSyncICache, hpteIndex ); 66 HvCall1(HvCallHptInvalidateNoSyncICache, hpteIndex);
81 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
82} 67}
83//============================================================================= 68
84static inline u64 HvCallHpt_invalidateSetSwBitsGet(u32 hpteIndex, u8 bitson, u8 bitsoff ) 69static inline u64 HvCallHpt_invalidateSetSwBitsGet(u32 hpteIndex, u8 bitson,
85 70 u8 bitsoff)
86{ 71{
87 u64 compressedStatus; 72 u64 compressedStatus;
88 compressedStatus = HvCall4( HvCallHptInvalidateSetSwBitsGet, hpteIndex, bitson, bitsoff, 1 ); 73
89 HvCall1( HvCallHptInvalidateNoSyncICache, hpteIndex ); 74 compressedStatus = HvCall4(HvCallHptInvalidateSetSwBitsGet,
90 // getPaca()->adjustHmtForNoOfSpinLocksHeld(); 75 hpteIndex, bitson, bitsoff, 1);
76 HvCall1(HvCallHptInvalidateNoSyncICache, hpteIndex);
91 return compressedStatus; 77 return compressedStatus;
92} 78}
93//============================================================================= 79
94static inline u64 HvCallHpt_findValid( HPTE *hpte, u64 vpn ) 80static inline u64 HvCallHpt_findValid(HPTE *hpte, u64 vpn)
95{ 81{
96 u64 retIndex = HvCall3Ret16( HvCallHptFindValid, hpte, vpn, 0, 0 ); 82 return HvCall3Ret16(HvCallHptFindValid, hpte, vpn, 0, 0);
97 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
98 return retIndex;
99} 83}
100//============================================================================= 84
101static inline u64 HvCallHpt_findNextValid( HPTE *hpte, u32 hpteIndex, u8 bitson, u8 bitsoff ) 85static inline u64 HvCallHpt_findNextValid(HPTE *hpte, u32 hpteIndex,
86 u8 bitson, u8 bitsoff)
102{ 87{
103 u64 retIndex = HvCall3Ret16( HvCallHptFindNextValid, hpte, hpteIndex, bitson, bitsoff ); 88 return HvCall3Ret16(HvCallHptFindNextValid, hpte, hpteIndex,
104 // getPaca()->adjustHmtForNoOfSpinLocksHeld(); 89 bitson, bitsoff);
105 return retIndex;
106} 90}
107//============================================================================= 91
108static inline void HvCallHpt_get( HPTE *hpte, u32 hpteIndex ) 92static inline void HvCallHpt_get(HPTE *hpte, u32 hpteIndex)
109{ 93{
110 HvCall2Ret16( HvCallHptGet, hpte, hpteIndex, 0 ); 94 HvCall2Ret16(HvCallHptGet, hpte, hpteIndex, 0);
111 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
112} 95}
113//============================================================================ 96
114static inline void HvCallHpt_addValidate( u32 hpteIndex, 97static inline void HvCallHpt_addValidate(u32 hpteIndex, u32 hBit, HPTE *hpte)
115 u32 hBit,
116 HPTE *hpte )
117
118{ 98{
119 HvCall4( HvCallHptAddValidate, hpteIndex, 99 HvCall4(HvCallHptAddValidate, hpteIndex, hBit, (*((u64 *)hpte)),
120 hBit, (*((u64 *)hpte)), (*(((u64 *)hpte)+1)) ); 100 (*(((u64 *)hpte)+1)));
121 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
122} 101}
123 102
124
125//=============================================================================
126
127#endif /* _HVCALLHPT_H */ 103#endif /* _HVCALLHPT_H */
diff --git a/include/asm-ppc64/iSeries/HvCallPci.h b/include/asm-ppc64/iSeries/HvCallPci.h
index 6887b619288e..c8d675c40f5e 100644
--- a/include/asm-ppc64/iSeries/HvCallPci.h
+++ b/include/asm-ppc64/iSeries/HvCallPci.h
@@ -1,26 +1,26 @@
1/************************************************************************/ 1/*
2/* Provides the Hypervisor PCI calls for iSeries Linux Parition. */ 2 * Provides the Hypervisor PCI calls for iSeries Linux Parition.
3/* Copyright (C) 2001 <Wayne G Holm> <IBM Corporation> */ 3 * Copyright (C) 2001 <Wayne G Holm> <IBM Corporation>
4/* */ 4 *
5/* This program is free software; you can redistribute it and/or modify */ 5 * This program is free software; you can redistribute it and/or modify
6/* it under the terms of the GNU General Public License as published by */ 6 * it under the terms of the GNU General Public License as published by
7/* the Free Software Foundation; either version 2 of the License, or */ 7 * the Free Software Foundation; either version 2 of the License, or
8/* (at your option) any later version. */ 8 * (at your option) any later version.
9/* */ 9 *
10/* This program is distributed in the hope that it will be useful, */ 10 * This program is distributed in the hope that it will be useful,
11/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13/* GNU General Public License for more details. */ 13 * GNU General Public License for more details.
14/* */ 14 *
15/* You should have received a copy of the GNU General Public License */ 15 * You should have received a copy of the GNU General Public License
16/* along with this program; if not, write to the: */ 16 * along with this program; if not, write to the:
17/* Free Software Foundation, Inc., */ 17 * Free Software Foundation, Inc.,
18/* 59 Temple Place, Suite 330, */ 18 * 59 Temple Place, Suite 330,
19/* Boston, MA 02111-1307 USA */ 19 * Boston, MA 02111-1307 USA
20/************************************************************************/ 20 *
21/* Change Activity: */ 21 * Change Activity:
22/* Created, Jan 9, 2001 */ 22 * Created, Jan 9, 2001
23/************************************************************************/ 23 */
24 24
25#ifndef _HVCALLPCI_H 25#ifndef _HVCALLPCI_H
26#define _HVCALLPCI_H 26#define _HVCALLPCI_H
@@ -34,8 +34,8 @@
34 */ 34 */
35struct HvCallPci_DsaAddr { 35struct HvCallPci_DsaAddr {
36 u16 busNumber; /* PHB index? */ 36 u16 busNumber; /* PHB index? */
37 u8 subBusNumber; /* PCI bus number? */ 37 u8 subBusNumber; /* PCI bus number? */
38 u8 deviceId; /* device and function? */ 38 u8 deviceId; /* device and function? */
39 u8 barNumber; 39 u8 barNumber;
40 u8 reserved[3]; 40 u8 reserved[3];
41}; 41};
@@ -52,34 +52,37 @@ struct HvCallPci_LoadReturn {
52 52
53enum HvCallPci_DeviceType { 53enum HvCallPci_DeviceType {
54 HvCallPci_NodeDevice = 1, 54 HvCallPci_NodeDevice = 1,
55 HvCallPci_SpDevice = 2, 55 HvCallPci_SpDevice = 2,
56 HvCallPci_IopDevice = 3, 56 HvCallPci_IopDevice = 3,
57 HvCallPci_BridgeDevice = 4, 57 HvCallPci_BridgeDevice = 4,
58 HvCallPci_MultiFunctionDevice = 5, 58 HvCallPci_MultiFunctionDevice = 5,
59 HvCallPci_IoaDevice = 6 59 HvCallPci_IoaDevice = 6
60}; 60};
61 61
62 62
63struct HvCallPci_DeviceInfo { 63struct HvCallPci_DeviceInfo {
64 u32 deviceType; // See DeviceType enum for values 64 u32 deviceType; /* See DeviceType enum for values */
65}; 65};
66 66
67struct HvCallPci_BusUnitInfo { 67struct HvCallPci_BusUnitInfo {
68 u32 sizeReturned; // length of data returned 68 u32 sizeReturned; /* length of data returned */
69 u32 deviceType; // see DeviceType enum for values 69 u32 deviceType; /* see DeviceType enum for values */
70}; 70};
71 71
72struct HvCallPci_BridgeInfo { 72struct HvCallPci_BridgeInfo {
73 struct HvCallPci_BusUnitInfo busUnitInfo; // Generic bus unit info 73 struct HvCallPci_BusUnitInfo busUnitInfo; /* Generic bus unit info */
74 u8 subBusNumber; // Bus number of secondary bus 74 u8 subBusNumber; /* Bus number of secondary bus */
75 u8 maxAgents; // Max idsels on secondary bus 75 u8 maxAgents; /* Max idsels on secondary bus */
76 u8 maxSubBusNumber; // Max Sub Bus 76 u8 maxSubBusNumber; /* Max Sub Bus */
77 u8 logicalSlotNumber; // Logical Slot Number for IOA 77 u8 logicalSlotNumber; /* Logical Slot Number for IOA */
78}; 78};
79
80 79
81// Maximum BusUnitInfo buffer size. Provided for clients so they can allocate 80
82// a buffer big enough for any type of bus unit. Increase as needed. 81/*
82 * Maximum BusUnitInfo buffer size. Provided for clients so
83 * they can allocate a buffer big enough for any type of bus
84 * unit. Increase as needed.
85 */
83enum {HvCallPci_MaxBusUnitInfoSize = 128}; 86enum {HvCallPci_MaxBusUnitInfoSize = 128};
84 87
85struct HvCallPci_BarParms { 88struct HvCallPci_BarParms {
@@ -89,12 +92,12 @@ struct HvCallPci_BarParms {
89 u64 protectStart; 92 u64 protectStart;
90 u64 protectEnd; 93 u64 protectEnd;
91 u64 relocationOffset; 94 u64 relocationOffset;
92 u64 pciAddress; 95 u64 pciAddress;
93 u64 reserved[3]; 96 u64 reserved[3];
94}; 97};
95 98
96enum HvCallPci_VpdType { 99enum HvCallPci_VpdType {
97 HvCallPci_BusVpd = 1, 100 HvCallPci_BusVpd = 1,
98 HvCallPci_BusAdapterVpd = 2 101 HvCallPci_BusAdapterVpd = 2
99}; 102};
100 103
@@ -123,15 +126,13 @@ enum HvCallPci_VpdType {
123#define HvCallPciUnmaskInterrupts HvCallPci + 49 126#define HvCallPciUnmaskInterrupts HvCallPci + 49
124#define HvCallPciGetBusUnitInfo HvCallPci + 50 127#define HvCallPciGetBusUnitInfo HvCallPci + 50
125 128
126//============================================================================
127static inline u64 HvCallPci_configLoad8(u16 busNumber, u8 subBusNumber, 129static inline u64 HvCallPci_configLoad8(u16 busNumber, u8 subBusNumber,
128 u8 deviceId, u32 offset, 130 u8 deviceId, u32 offset, u8 *value)
129 u8 *value)
130{ 131{
131 struct HvCallPci_DsaAddr dsa; 132 struct HvCallPci_DsaAddr dsa;
132 struct HvCallPci_LoadReturn retVal; 133 struct HvCallPci_LoadReturn retVal;
133 134
134 *((u64*)&dsa) = 0; 135 *((u64*)&dsa) = 0;
135 136
136 dsa.busNumber = busNumber; 137 dsa.busNumber = busNumber;
137 dsa.subBusNumber = subBusNumber; 138 dsa.subBusNumber = subBusNumber;
@@ -139,21 +140,18 @@ static inline u64 HvCallPci_configLoad8(u16 busNumber, u8 subBusNumber,
139 140
140 HvCall3Ret16(HvCallPciConfigLoad8, &retVal, *(u64 *)&dsa, offset, 0); 141 HvCall3Ret16(HvCallPciConfigLoad8, &retVal, *(u64 *)&dsa, offset, 0);
141 142
142 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
143
144 *value = retVal.value; 143 *value = retVal.value;
145 144
146 return retVal.rc; 145 return retVal.rc;
147} 146}
148//============================================================================ 147
149static inline u64 HvCallPci_configLoad16(u16 busNumber, u8 subBusNumber, 148static inline u64 HvCallPci_configLoad16(u16 busNumber, u8 subBusNumber,
150 u8 deviceId, u32 offset, 149 u8 deviceId, u32 offset, u16 *value)
151 u16 *value)
152{ 150{
153 struct HvCallPci_DsaAddr dsa; 151 struct HvCallPci_DsaAddr dsa;
154 struct HvCallPci_LoadReturn retVal; 152 struct HvCallPci_LoadReturn retVal;
155 153
156 *((u64*)&dsa) = 0; 154 *((u64*)&dsa) = 0;
157 155
158 dsa.busNumber = busNumber; 156 dsa.busNumber = busNumber;
159 dsa.subBusNumber = subBusNumber; 157 dsa.subBusNumber = subBusNumber;
@@ -161,21 +159,18 @@ static inline u64 HvCallPci_configLoad16(u16 busNumber, u8 subBusNumber,
161 159
162 HvCall3Ret16(HvCallPciConfigLoad16, &retVal, *(u64 *)&dsa, offset, 0); 160 HvCall3Ret16(HvCallPciConfigLoad16, &retVal, *(u64 *)&dsa, offset, 0);
163 161
164 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
165
166 *value = retVal.value; 162 *value = retVal.value;
167 163
168 return retVal.rc; 164 return retVal.rc;
169} 165}
170//============================================================================ 166
171static inline u64 HvCallPci_configLoad32(u16 busNumber, u8 subBusNumber, 167static inline u64 HvCallPci_configLoad32(u16 busNumber, u8 subBusNumber,
172 u8 deviceId, u32 offset, 168 u8 deviceId, u32 offset, u32 *value)
173 u32 *value)
174{ 169{
175 struct HvCallPci_DsaAddr dsa; 170 struct HvCallPci_DsaAddr dsa;
176 struct HvCallPci_LoadReturn retVal; 171 struct HvCallPci_LoadReturn retVal;
177 172
178 *((u64*)&dsa) = 0; 173 *((u64*)&dsa) = 0;
179 174
180 dsa.busNumber = busNumber; 175 dsa.busNumber = busNumber;
181 dsa.subBusNumber = subBusNumber; 176 dsa.subBusNumber = subBusNumber;
@@ -183,84 +178,61 @@ static inline u64 HvCallPci_configLoad32(u16 busNumber, u8 subBusNumber,
183 178
184 HvCall3Ret16(HvCallPciConfigLoad32, &retVal, *(u64 *)&dsa, offset, 0); 179 HvCall3Ret16(HvCallPciConfigLoad32, &retVal, *(u64 *)&dsa, offset, 0);
185 180
186 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
187
188 *value = retVal.value; 181 *value = retVal.value;
189 182
190 return retVal.rc; 183 return retVal.rc;
191} 184}
192//============================================================================ 185
193static inline u64 HvCallPci_configStore8(u16 busNumber, u8 subBusNumber, 186static inline u64 HvCallPci_configStore8(u16 busNumber, u8 subBusNumber,
194 u8 deviceId, u32 offset, 187 u8 deviceId, u32 offset, u8 value)
195 u8 value)
196{ 188{
197 struct HvCallPci_DsaAddr dsa; 189 struct HvCallPci_DsaAddr dsa;
198 u64 retVal;
199 190
200 *((u64*)&dsa) = 0; 191 *((u64*)&dsa) = 0;
201 192
202 dsa.busNumber = busNumber; 193 dsa.busNumber = busNumber;
203 dsa.subBusNumber = subBusNumber; 194 dsa.subBusNumber = subBusNumber;
204 dsa.deviceId = deviceId; 195 dsa.deviceId = deviceId;
205 196
206 retVal = HvCall4(HvCallPciConfigStore8, *(u64 *)&dsa, offset, value, 0); 197 return HvCall4(HvCallPciConfigStore8, *(u64 *)&dsa, offset, value, 0);
207
208 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
209
210 return retVal;
211} 198}
212//============================================================================ 199
213static inline u64 HvCallPci_configStore16(u16 busNumber, u8 subBusNumber, 200static inline u64 HvCallPci_configStore16(u16 busNumber, u8 subBusNumber,
214 u8 deviceId, u32 offset, 201 u8 deviceId, u32 offset, u16 value)
215 u16 value)
216{ 202{
217 struct HvCallPci_DsaAddr dsa; 203 struct HvCallPci_DsaAddr dsa;
218 u64 retVal;
219 204
220 *((u64*)&dsa) = 0; 205 *((u64*)&dsa) = 0;
221 206
222 dsa.busNumber = busNumber; 207 dsa.busNumber = busNumber;
223 dsa.subBusNumber = subBusNumber; 208 dsa.subBusNumber = subBusNumber;
224 dsa.deviceId = deviceId; 209 dsa.deviceId = deviceId;
225 210
226 retVal = HvCall4(HvCallPciConfigStore16, *(u64 *)&dsa, offset, value, 0); 211 return HvCall4(HvCallPciConfigStore16, *(u64 *)&dsa, offset, value, 0);
227
228 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
229
230 return retVal;
231} 212}
232//============================================================================ 213
233static inline u64 HvCallPci_configStore32(u16 busNumber, u8 subBusNumber, 214static inline u64 HvCallPci_configStore32(u16 busNumber, u8 subBusNumber,
234 u8 deviceId, u32 offset, 215 u8 deviceId, u32 offset, u32 value)
235 u32 value)
236{ 216{
237 struct HvCallPci_DsaAddr dsa; 217 struct HvCallPci_DsaAddr dsa;
238 u64 retVal;
239 218
240 *((u64*)&dsa) = 0; 219 *((u64*)&dsa) = 0;
241 220
242 dsa.busNumber = busNumber; 221 dsa.busNumber = busNumber;
243 dsa.subBusNumber = subBusNumber; 222 dsa.subBusNumber = subBusNumber;
244 dsa.deviceId = deviceId; 223 dsa.deviceId = deviceId;
245 224
246 retVal = HvCall4(HvCallPciConfigStore32, *(u64 *)&dsa, offset, value, 0); 225 return HvCall4(HvCallPciConfigStore32, *(u64 *)&dsa, offset, value, 0);
247
248 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
249
250 return retVal;
251} 226}
252//============================================================================ 227
253static inline u64 HvCallPci_barLoad8(u16 busNumberParm, 228static inline u64 HvCallPci_barLoad8(u16 busNumberParm, u8 subBusParm,
254 u8 subBusParm, 229 u8 deviceIdParm, u8 barNumberParm, u64 offsetParm,
255 u8 deviceIdParm, 230 u8 *valueParm)
256 u8 barNumberParm,
257 u64 offsetParm,
258 u8* valueParm)
259{ 231{
260 struct HvCallPci_DsaAddr dsa; 232 struct HvCallPci_DsaAddr dsa;
261 struct HvCallPci_LoadReturn retVal; 233 struct HvCallPci_LoadReturn retVal;
262 234
263 *((u64*)&dsa) = 0; 235 *((u64*)&dsa) = 0;
264 236
265 dsa.busNumber = busNumberParm; 237 dsa.busNumber = busNumberParm;
266 dsa.subBusNumber = subBusParm; 238 dsa.subBusNumber = subBusParm;
@@ -269,24 +241,19 @@ static inline u64 HvCallPci_barLoad8(u16 busNumberParm,
269 241
270 HvCall3Ret16(HvCallPciBarLoad8, &retVal, *(u64 *)&dsa, offsetParm, 0); 242 HvCall3Ret16(HvCallPciBarLoad8, &retVal, *(u64 *)&dsa, offsetParm, 0);
271 243
272 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
273
274 *valueParm = retVal.value; 244 *valueParm = retVal.value;
275 245
276 return retVal.rc; 246 return retVal.rc;
277} 247}
278//============================================================================ 248
279static inline u64 HvCallPci_barLoad16(u16 busNumberParm, 249static inline u64 HvCallPci_barLoad16(u16 busNumberParm, u8 subBusParm,
280 u8 subBusParm, 250 u8 deviceIdParm, u8 barNumberParm, u64 offsetParm,
281 u8 deviceIdParm, 251 u16 *valueParm)
282 u8 barNumberParm,
283 u64 offsetParm,
284 u16* valueParm)
285{ 252{
286 struct HvCallPci_DsaAddr dsa; 253 struct HvCallPci_DsaAddr dsa;
287 struct HvCallPci_LoadReturn retVal; 254 struct HvCallPci_LoadReturn retVal;
288 255
289 *((u64*)&dsa) = 0; 256 *((u64*)&dsa) = 0;
290 257
291 dsa.busNumber = busNumberParm; 258 dsa.busNumber = busNumberParm;
292 dsa.subBusNumber = subBusParm; 259 dsa.subBusNumber = subBusParm;
@@ -295,24 +262,19 @@ static inline u64 HvCallPci_barLoad16(u16 busNumberParm,
295 262
296 HvCall3Ret16(HvCallPciBarLoad16, &retVal, *(u64 *)&dsa, offsetParm, 0); 263 HvCall3Ret16(HvCallPciBarLoad16, &retVal, *(u64 *)&dsa, offsetParm, 0);
297 264
298 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
299
300 *valueParm = retVal.value; 265 *valueParm = retVal.value;
301 266
302 return retVal.rc; 267 return retVal.rc;
303} 268}
304//============================================================================ 269
305static inline u64 HvCallPci_barLoad32(u16 busNumberParm, 270static inline u64 HvCallPci_barLoad32(u16 busNumberParm, u8 subBusParm,
306 u8 subBusParm, 271 u8 deviceIdParm, u8 barNumberParm, u64 offsetParm,
307 u8 deviceIdParm, 272 u32 *valueParm)
308 u8 barNumberParm,
309 u64 offsetParm,
310 u32* valueParm)
311{ 273{
312 struct HvCallPci_DsaAddr dsa; 274 struct HvCallPci_DsaAddr dsa;
313 struct HvCallPci_LoadReturn retVal; 275 struct HvCallPci_LoadReturn retVal;
314 276
315 *((u64*)&dsa) = 0; 277 *((u64*)&dsa) = 0;
316 278
317 dsa.busNumber = busNumberParm; 279 dsa.busNumber = busNumberParm;
318 dsa.subBusNumber = subBusParm; 280 dsa.subBusNumber = subBusParm;
@@ -321,24 +283,19 @@ static inline u64 HvCallPci_barLoad32(u16 busNumberParm,
321 283
322 HvCall3Ret16(HvCallPciBarLoad32, &retVal, *(u64 *)&dsa, offsetParm, 0); 284 HvCall3Ret16(HvCallPciBarLoad32, &retVal, *(u64 *)&dsa, offsetParm, 0);
323 285
324 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
325
326 *valueParm = retVal.value; 286 *valueParm = retVal.value;
327 287
328 return retVal.rc; 288 return retVal.rc;
329} 289}
330//============================================================================ 290
331static inline u64 HvCallPci_barLoad64(u16 busNumberParm, 291static inline u64 HvCallPci_barLoad64(u16 busNumberParm, u8 subBusParm,
332 u8 subBusParm, 292 u8 deviceIdParm, u8 barNumberParm, u64 offsetParm,
333 u8 deviceIdParm, 293 u64 *valueParm)
334 u8 barNumberParm,
335 u64 offsetParm,
336 u64* valueParm)
337{ 294{
338 struct HvCallPci_DsaAddr dsa; 295 struct HvCallPci_DsaAddr dsa;
339 struct HvCallPci_LoadReturn retVal; 296 struct HvCallPci_LoadReturn retVal;
340 297
341 *((u64*)&dsa) = 0; 298 *((u64*)&dsa) = 0;
342 299
343 dsa.busNumber = busNumberParm; 300 dsa.busNumber = busNumberParm;
344 dsa.subBusNumber = subBusParm; 301 dsa.subBusNumber = subBusParm;
@@ -347,112 +304,81 @@ static inline u64 HvCallPci_barLoad64(u16 busNumberParm,
347 304
348 HvCall3Ret16(HvCallPciBarLoad64, &retVal, *(u64 *)&dsa, offsetParm, 0); 305 HvCall3Ret16(HvCallPciBarLoad64, &retVal, *(u64 *)&dsa, offsetParm, 0);
349 306
350 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
351
352 *valueParm = retVal.value; 307 *valueParm = retVal.value;
353 308
354 return retVal.rc; 309 return retVal.rc;
355} 310}
356//============================================================================ 311
357static inline u64 HvCallPci_barStore8(u16 busNumberParm, 312static inline u64 HvCallPci_barStore8(u16 busNumberParm, u8 subBusParm,
358 u8 subBusParm, 313 u8 deviceIdParm, u8 barNumberParm, u64 offsetParm,
359 u8 deviceIdParm, 314 u8 valueParm)
360 u8 barNumberParm,
361 u64 offsetParm,
362 u8 valueParm)
363{ 315{
364 struct HvCallPci_DsaAddr dsa; 316 struct HvCallPci_DsaAddr dsa;
365 u64 retVal;
366 317
367 *((u64*)&dsa) = 0; 318 *((u64*)&dsa) = 0;
368 319
369 dsa.busNumber = busNumberParm; 320 dsa.busNumber = busNumberParm;
370 dsa.subBusNumber = subBusParm; 321 dsa.subBusNumber = subBusParm;
371 dsa.deviceId = deviceIdParm; 322 dsa.deviceId = deviceIdParm;
372 dsa.barNumber = barNumberParm; 323 dsa.barNumber = barNumberParm;
373 324
374 retVal = HvCall4(HvCallPciBarStore8, *(u64 *)&dsa, offsetParm, valueParm, 0); 325 return HvCall4(HvCallPciBarStore8, *(u64 *)&dsa, offsetParm,
375 326 valueParm, 0);
376 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
377
378 return retVal;
379} 327}
380//============================================================================ 328
381static inline u64 HvCallPci_barStore16(u16 busNumberParm, 329static inline u64 HvCallPci_barStore16(u16 busNumberParm, u8 subBusParm,
382 u8 subBusParm, 330 u8 deviceIdParm, u8 barNumberParm, u64 offsetParm,
383 u8 deviceIdParm, 331 u16 valueParm)
384 u8 barNumberParm,
385 u64 offsetParm,
386 u16 valueParm)
387{ 332{
388 struct HvCallPci_DsaAddr dsa; 333 struct HvCallPci_DsaAddr dsa;
389 u64 retVal;
390 334
391 *((u64*)&dsa) = 0; 335 *((u64*)&dsa) = 0;
392 336
393 dsa.busNumber = busNumberParm; 337 dsa.busNumber = busNumberParm;
394 dsa.subBusNumber = subBusParm; 338 dsa.subBusNumber = subBusParm;
395 dsa.deviceId = deviceIdParm; 339 dsa.deviceId = deviceIdParm;
396 dsa.barNumber = barNumberParm; 340 dsa.barNumber = barNumberParm;
397 341
398 retVal = HvCall4(HvCallPciBarStore16, *(u64 *)&dsa, offsetParm, valueParm, 0); 342 return HvCall4(HvCallPciBarStore16, *(u64 *)&dsa, offsetParm,
399 343 valueParm, 0);
400 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
401
402 return retVal;
403} 344}
404//============================================================================ 345
405static inline u64 HvCallPci_barStore32(u16 busNumberParm, 346static inline u64 HvCallPci_barStore32(u16 busNumberParm, u8 subBusParm,
406 u8 subBusParm, 347 u8 deviceIdParm, u8 barNumberParm, u64 offsetParm,
407 u8 deviceIdParm, 348 u32 valueParm)
408 u8 barNumberParm,
409 u64 offsetParm,
410 u32 valueParm)
411{ 349{
412 struct HvCallPci_DsaAddr dsa; 350 struct HvCallPci_DsaAddr dsa;
413 u64 retVal;
414 351
415 *((u64*)&dsa) = 0; 352 *((u64*)&dsa) = 0;
416 353
417 dsa.busNumber = busNumberParm; 354 dsa.busNumber = busNumberParm;
418 dsa.subBusNumber = subBusParm; 355 dsa.subBusNumber = subBusParm;
419 dsa.deviceId = deviceIdParm; 356 dsa.deviceId = deviceIdParm;
420 dsa.barNumber = barNumberParm; 357 dsa.barNumber = barNumberParm;
421 358
422 retVal = HvCall4(HvCallPciBarStore32, *(u64 *)&dsa, offsetParm, valueParm, 0); 359 return HvCall4(HvCallPciBarStore32, *(u64 *)&dsa, offsetParm,
423 360 valueParm, 0);
424 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
425
426 return retVal;
427} 361}
428//============================================================================ 362
429static inline u64 HvCallPci_barStore64(u16 busNumberParm, 363static inline u64 HvCallPci_barStore64(u16 busNumberParm, u8 subBusParm,
430 u8 subBusParm, 364 u8 deviceIdParm, u8 barNumberParm, u64 offsetParm,
431 u8 deviceIdParm, 365 u64 valueParm)
432 u8 barNumberParm,
433 u64 offsetParm,
434 u64 valueParm)
435{ 366{
436 struct HvCallPci_DsaAddr dsa; 367 struct HvCallPci_DsaAddr dsa;
437 u64 retVal;
438 368
439 *((u64*)&dsa) = 0; 369 *((u64*)&dsa) = 0;
440 370
441 dsa.busNumber = busNumberParm; 371 dsa.busNumber = busNumberParm;
442 dsa.subBusNumber = subBusParm; 372 dsa.subBusNumber = subBusParm;
443 dsa.deviceId = deviceIdParm; 373 dsa.deviceId = deviceIdParm;
444 dsa.barNumber = barNumberParm; 374 dsa.barNumber = barNumberParm;
445 375
446 retVal = HvCall4(HvCallPciBarStore64, *(u64 *)&dsa, offsetParm, valueParm, 0); 376 return HvCall4(HvCallPciBarStore64, *(u64 *)&dsa, offsetParm,
447 377 valueParm, 0);
448 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
449
450 return retVal;
451} 378}
452//============================================================================ 379
453static inline u64 HvCallPci_eoi(u16 busNumberParm, 380static inline u64 HvCallPci_eoi(u16 busNumberParm, u8 subBusParm,
454 u8 subBusParm, 381 u8 deviceIdParm)
455 u8 deviceIdParm)
456{ 382{
457 struct HvCallPci_DsaAddr dsa; 383 struct HvCallPci_DsaAddr dsa;
458 struct HvCallPci_LoadReturn retVal; 384 struct HvCallPci_LoadReturn retVal;
@@ -465,20 +391,13 @@ static inline u64 HvCallPci_eoi(u16 busNumberParm,
465 391
466 HvCall1Ret16(HvCallPciEoi, &retVal, *(u64*)&dsa); 392 HvCall1Ret16(HvCallPciEoi, &retVal, *(u64*)&dsa);
467 393
468 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
469
470 return retVal.rc; 394 return retVal.rc;
471} 395}
472//============================================================================ 396
473static inline u64 HvCallPci_getBarParms(u16 busNumberParm, 397static inline u64 HvCallPci_getBarParms(u16 busNumberParm, u8 subBusParm,
474 u8 subBusParm, 398 u8 deviceIdParm, u8 barNumberParm, u64 parms, u32 sizeofParms)
475 u8 deviceIdParm,
476 u8 barNumberParm,
477 u64 parms,
478 u32 sizeofParms)
479{ 399{
480 struct HvCallPci_DsaAddr dsa; 400 struct HvCallPci_DsaAddr dsa;
481 u64 retVal;
482 401
483 *((u64*)&dsa) = 0; 402 *((u64*)&dsa) = 0;
484 403
@@ -487,62 +406,41 @@ static inline u64 HvCallPci_getBarParms(u16 busNumberParm,
487 dsa.deviceId = deviceIdParm; 406 dsa.deviceId = deviceIdParm;
488 dsa.barNumber = barNumberParm; 407 dsa.barNumber = barNumberParm;
489 408
490 retVal = HvCall3(HvCallPciGetBarParms, *(u64*)&dsa, parms, sizeofParms); 409 return HvCall3(HvCallPciGetBarParms, *(u64*)&dsa, parms, sizeofParms);
491
492 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
493
494 return retVal;
495} 410}
496//============================================================================ 411
497static inline u64 HvCallPci_maskFisr(u16 busNumberParm, 412static inline u64 HvCallPci_maskFisr(u16 busNumberParm, u8 subBusParm,
498 u8 subBusParm, 413 u8 deviceIdParm, u64 fisrMask)
499 u8 deviceIdParm,
500 u64 fisrMask)
501{ 414{
502 struct HvCallPci_DsaAddr dsa; 415 struct HvCallPci_DsaAddr dsa;
503 u64 retVal;
504 416
505 *((u64*)&dsa) = 0; 417 *((u64*)&dsa) = 0;
506 418
507 dsa.busNumber = busNumberParm; 419 dsa.busNumber = busNumberParm;
508 dsa.subBusNumber = subBusParm; 420 dsa.subBusNumber = subBusParm;
509 dsa.deviceId = deviceIdParm; 421 dsa.deviceId = deviceIdParm;
510 422
511 retVal = HvCall2(HvCallPciMaskFisr, *(u64*)&dsa, fisrMask); 423 return HvCall2(HvCallPciMaskFisr, *(u64*)&dsa, fisrMask);
512
513 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
514
515 return retVal;
516} 424}
517//============================================================================ 425
518static inline u64 HvCallPci_unmaskFisr(u16 busNumberParm, 426static inline u64 HvCallPci_unmaskFisr(u16 busNumberParm, u8 subBusParm,
519 u8 subBusParm, 427 u8 deviceIdParm, u64 fisrMask)
520 u8 deviceIdParm,
521 u64 fisrMask)
522{ 428{
523 struct HvCallPci_DsaAddr dsa; 429 struct HvCallPci_DsaAddr dsa;
524 u64 retVal;
525 430
526 *((u64*)&dsa) = 0; 431 *((u64*)&dsa) = 0;
527 432
528 dsa.busNumber = busNumberParm; 433 dsa.busNumber = busNumberParm;
529 dsa.subBusNumber = subBusParm; 434 dsa.subBusNumber = subBusParm;
530 dsa.deviceId = deviceIdParm; 435 dsa.deviceId = deviceIdParm;
531 436
532 retVal = HvCall2(HvCallPciUnmaskFisr, *(u64*)&dsa, fisrMask); 437 return HvCall2(HvCallPciUnmaskFisr, *(u64*)&dsa, fisrMask);
533
534 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
535
536 return retVal;
537} 438}
538//============================================================================ 439
539static inline u64 HvCallPci_setSlotReset(u16 busNumberParm, 440static inline u64 HvCallPci_setSlotReset(u16 busNumberParm, u8 subBusParm,
540 u8 subBusParm, 441 u8 deviceIdParm, u64 onNotOff)
541 u8 deviceIdParm,
542 u64 onNotOff)
543{ 442{
544 struct HvCallPci_DsaAddr dsa; 443 struct HvCallPci_DsaAddr dsa;
545 u64 retVal;
546 444
547 *((u64*)&dsa) = 0; 445 *((u64*)&dsa) = 0;
548 446
@@ -550,21 +448,13 @@ static inline u64 HvCallPci_setSlotReset(u16 busNumberParm,
550 dsa.subBusNumber = subBusParm; 448 dsa.subBusNumber = subBusParm;
551 dsa.deviceId = deviceIdParm; 449 dsa.deviceId = deviceIdParm;
552 450
553 retVal = HvCall2(HvCallPciSetSlotReset, *(u64*)&dsa, onNotOff); 451 return HvCall2(HvCallPciSetSlotReset, *(u64*)&dsa, onNotOff);
554
555 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
556
557 return retVal;
558} 452}
559//============================================================================ 453
560static inline u64 HvCallPci_getDeviceInfo(u16 busNumberParm, 454static inline u64 HvCallPci_getDeviceInfo(u16 busNumberParm, u8 subBusParm,
561 u8 subBusParm, 455 u8 deviceNumberParm, u64 parms, u32 sizeofParms)
562 u8 deviceNumberParm,
563 u64 parms,
564 u32 sizeofParms)
565{ 456{
566 struct HvCallPci_DsaAddr dsa; 457 struct HvCallPci_DsaAddr dsa;
567 u64 retVal;
568 458
569 *((u64*)&dsa) = 0; 459 *((u64*)&dsa) = 0;
570 460
@@ -572,102 +462,72 @@ static inline u64 HvCallPci_getDeviceInfo(u16 busNumberParm,
572 dsa.subBusNumber = subBusParm; 462 dsa.subBusNumber = subBusParm;
573 dsa.deviceId = deviceNumberParm << 4; 463 dsa.deviceId = deviceNumberParm << 4;
574 464
575 retVal = HvCall3(HvCallPciGetDeviceInfo, *(u64*)&dsa, parms, sizeofParms); 465 return HvCall3(HvCallPciGetDeviceInfo, *(u64*)&dsa, parms, sizeofParms);
576
577 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
578
579 return retVal;
580} 466}
581//============================================================================ 467
582static inline u64 HvCallPci_maskInterrupts(u16 busNumberParm, 468static inline u64 HvCallPci_maskInterrupts(u16 busNumberParm, u8 subBusParm,
583 u8 subBusParm, 469 u8 deviceIdParm, u64 interruptMask)
584 u8 deviceIdParm,
585 u64 interruptMask)
586{ 470{
587 struct HvCallPci_DsaAddr dsa; 471 struct HvCallPci_DsaAddr dsa;
588 u64 retVal;
589 472
590 *((u64*)&dsa) = 0; 473 *((u64*)&dsa) = 0;
591 474
592 dsa.busNumber = busNumberParm; 475 dsa.busNumber = busNumberParm;
593 dsa.subBusNumber = subBusParm; 476 dsa.subBusNumber = subBusParm;
594 dsa.deviceId = deviceIdParm; 477 dsa.deviceId = deviceIdParm;
595 478
596 retVal = HvCall2(HvCallPciMaskInterrupts, *(u64*)&dsa, interruptMask); 479 return HvCall2(HvCallPciMaskInterrupts, *(u64*)&dsa, interruptMask);
597
598 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
599
600 return retVal;
601} 480}
602//============================================================================ 481
603static inline u64 HvCallPci_unmaskInterrupts(u16 busNumberParm, 482static inline u64 HvCallPci_unmaskInterrupts(u16 busNumberParm, u8 subBusParm,
604 u8 subBusParm, 483 u8 deviceIdParm, u64 interruptMask)
605 u8 deviceIdParm,
606 u64 interruptMask)
607{ 484{
608 struct HvCallPci_DsaAddr dsa; 485 struct HvCallPci_DsaAddr dsa;
609 u64 retVal;
610 486
611 *((u64*)&dsa) = 0; 487 *((u64*)&dsa) = 0;
612 488
613 dsa.busNumber = busNumberParm; 489 dsa.busNumber = busNumberParm;
614 dsa.subBusNumber = subBusParm; 490 dsa.subBusNumber = subBusParm;
615 dsa.deviceId = deviceIdParm; 491 dsa.deviceId = deviceIdParm;
616 492
617 retVal = HvCall2(HvCallPciUnmaskInterrupts, *(u64*)&dsa, interruptMask); 493 return HvCall2(HvCallPciUnmaskInterrupts, *(u64*)&dsa, interruptMask);
618
619 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
620
621 return retVal;
622} 494}
623//============================================================================
624 495
625static inline u64 HvCallPci_getBusUnitInfo(u16 busNumberParm, 496static inline u64 HvCallPci_getBusUnitInfo(u16 busNumberParm, u8 subBusParm,
626 u8 subBusParm, 497 u8 deviceIdParm, u64 parms, u32 sizeofParms)
627 u8 deviceIdParm,
628 u64 parms,
629 u32 sizeofParms)
630{ 498{
631 struct HvCallPci_DsaAddr dsa; 499 struct HvCallPci_DsaAddr dsa;
632 u64 retVal;
633 500
634 *((u64*)&dsa) = 0; 501 *((u64*)&dsa) = 0;
635 502
636 dsa.busNumber = busNumberParm; 503 dsa.busNumber = busNumberParm;
637 dsa.subBusNumber = subBusParm; 504 dsa.subBusNumber = subBusParm;
638 dsa.deviceId = deviceIdParm; 505 dsa.deviceId = deviceIdParm;
639 506
640 retVal = HvCall3(HvCallPciGetBusUnitInfo, *(u64*)&dsa, parms, sizeofParms); 507 return HvCall3(HvCallPciGetBusUnitInfo, *(u64*)&dsa, parms,
641 508 sizeofParms);
642 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
643
644 return retVal;
645} 509}
646//============================================================================
647 510
648static inline int HvCallPci_getBusVpd(u16 busNumParm, u64 destParm, u16 sizeParm) 511static inline int HvCallPci_getBusVpd(u16 busNumParm, u64 destParm,
512 u16 sizeParm)
649{ 513{
650 int xRetSize; 514 u64 xRc = HvCall4(HvCallPciGetCardVpd, busNumParm, destParm,
651 u64 xRc = HvCall4(HvCallPciGetCardVpd, busNumParm, destParm, sizeParm, HvCallPci_BusVpd); 515 sizeParm, HvCallPci_BusVpd);
652 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
653 if (xRc == -1) 516 if (xRc == -1)
654 xRetSize = -1; 517 return -1;
655 else 518 else
656 xRetSize = xRc & 0xFFFF; 519 return xRc & 0xFFFF;
657 return xRetSize;
658} 520}
659//============================================================================
660 521
661static inline int HvCallPci_getBusAdapterVpd(u16 busNumParm, u64 destParm, u16 sizeParm) 522static inline int HvCallPci_getBusAdapterVpd(u16 busNumParm, u64 destParm,
523 u16 sizeParm)
662{ 524{
663 int xRetSize; 525 u64 xRc = HvCall4(HvCallPciGetCardVpd, busNumParm, destParm,
664 u64 xRc = HvCall4(HvCallPciGetCardVpd, busNumParm, destParm, sizeParm, HvCallPci_BusAdapterVpd); 526 sizeParm, HvCallPci_BusAdapterVpd);
665 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
666 if (xRc == -1) 527 if (xRc == -1)
667 xRetSize = -1; 528 return -1;
668 else 529 else
669 xRetSize = xRc & 0xFFFF; 530 return xRc & 0xFFFF;
670 return xRetSize;
671} 531}
672//============================================================================ 532
673#endif /* _HVCALLPCI_H */ 533#endif /* _HVCALLPCI_H */
diff --git a/include/asm-ppc64/iSeries/HvCallSc.h b/include/asm-ppc64/iSeries/HvCallSc.h
index eea258447642..a62cef3822f9 100644
--- a/include/asm-ppc64/iSeries/HvCallSc.h
+++ b/include/asm-ppc64/iSeries/HvCallSc.h
@@ -1,17 +1,17 @@
1/* 1/*
2 * HvCallSc.h 2 * HvCallSc.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation 3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -19,7 +19,7 @@
19#ifndef _HVCALLSC_H 19#ifndef _HVCALLSC_H
20#define _HVCALLSC_H 20#define _HVCALLSC_H
21 21
22#include <asm/iSeries/HvTypes.h> 22#include <linux/types.h>
23 23
24#define HvCallBase 0x8000000000000000ul 24#define HvCallBase 0x8000000000000000ul
25#define HvCallCc 0x8001000000000000ul 25#define HvCallCc 0x8001000000000000ul
@@ -30,22 +30,22 @@
30#define HvCallSm 0x8007000000000000ul 30#define HvCallSm 0x8007000000000000ul
31#define HvCallXm 0x8009000000000000ul 31#define HvCallXm 0x8009000000000000ul
32 32
33u64 HvCall0( u64 ); 33extern u64 HvCall0(u64);
34u64 HvCall1( u64, u64 ); 34extern u64 HvCall1(u64, u64);
35u64 HvCall2( u64, u64, u64 ); 35extern u64 HvCall2(u64, u64, u64);
36u64 HvCall3( u64, u64, u64, u64 ); 36extern u64 HvCall3(u64, u64, u64, u64);
37u64 HvCall4( u64, u64, u64, u64, u64 ); 37extern u64 HvCall4(u64, u64, u64, u64, u64);
38u64 HvCall5( u64, u64, u64, u64, u64, u64 ); 38extern u64 HvCall5(u64, u64, u64, u64, u64, u64);
39u64 HvCall6( u64, u64, u64, u64, u64, u64, u64 ); 39extern u64 HvCall6(u64, u64, u64, u64, u64, u64, u64);
40u64 HvCall7( u64, u64, u64, u64, u64, u64, u64, u64 ); 40extern u64 HvCall7(u64, u64, u64, u64, u64, u64, u64, u64);
41 41
42u64 HvCall0Ret16( u64, void * ); 42extern u64 HvCall0Ret16(u64, void *);
43u64 HvCall1Ret16( u64, void *, u64 ); 43extern u64 HvCall1Ret16(u64, void *, u64);
44u64 HvCall2Ret16( u64, void *, u64, u64 ); 44extern u64 HvCall2Ret16(u64, void *, u64, u64);
45u64 HvCall3Ret16( u64, void *, u64, u64, u64 ); 45extern u64 HvCall3Ret16(u64, void *, u64, u64, u64);
46u64 HvCall4Ret16( u64, void *, u64, u64, u64, u64 ); 46extern u64 HvCall4Ret16(u64, void *, u64, u64, u64, u64);
47u64 HvCall5Ret16( u64, void *, u64, u64, u64, u64, u64 ); 47extern u64 HvCall5Ret16(u64, void *, u64, u64, u64, u64, u64);
48u64 HvCall6Ret16( u64, void *, u64, u64, u64, u64, u64, u64 ); 48extern u64 HvCall6Ret16(u64, void *, u64, u64, u64, u64, u64, u64);
49u64 HvCall7Ret16( u64, void *, u64, u64 ,u64 ,u64 ,u64 ,u64 ,u64 ); 49extern u64 HvCall7Ret16(u64, void *, u64, u64 ,u64 ,u64 ,u64 ,u64 ,u64);
50 50
51#endif /* _HVCALLSC_H */ 51#endif /* _HVCALLSC_H */
diff --git a/include/asm-ppc64/iSeries/HvCallSm.h b/include/asm-ppc64/iSeries/HvCallSm.h
index 9050c94a529d..8a3dbb071a43 100644
--- a/include/asm-ppc64/iSeries/HvCallSm.h
+++ b/include/asm-ppc64/iSeries/HvCallSm.h
@@ -1,17 +1,17 @@
1/* 1/*
2 * HvCallSm.h 2 * HvCallSm.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation 3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -19,34 +19,20 @@
19#ifndef _HVCALLSM_H 19#ifndef _HVCALLSM_H
20#define _HVCALLSM_H 20#define _HVCALLSM_H
21 21
22//============================================================================ 22/*
23// 23 * This file contains the "hypervisor call" interface which is used to
24// This file contains the "hypervisor call" interface which is used to 24 * drive the hypervisor from the OS.
25// drive the hypervisor from the OS. 25 */
26//
27//============================================================================
28 26
29//-------------------------------------------------------------------
30// Standard Includes
31//-------------------------------------------------------------------
32#include <asm/iSeries/HvCallSc.h> 27#include <asm/iSeries/HvCallSc.h>
33#include <asm/iSeries/HvTypes.h> 28#include <asm/iSeries/HvTypes.h>
34 29
35//-----------------------------------------------------------------------------
36// Constants
37//-----------------------------------------------------------------------------
38
39#define HvCallSmGet64BitsOfAccessMap HvCallSm + 11 30#define HvCallSmGet64BitsOfAccessMap HvCallSm + 11
40 31
41 32static inline u64 HvCallSm_get64BitsOfAccessMap(HvLpIndex lpIndex,
42//============================================================================ 33 u64 indexIntoBitMap)
43static inline u64 HvCallSm_get64BitsOfAccessMap(
44 HvLpIndex lpIndex, u64 indexIntoBitMap )
45{ 34{
46 u64 retval = HvCall2(HvCallSmGet64BitsOfAccessMap, lpIndex, 35 return HvCall2(HvCallSmGet64BitsOfAccessMap, lpIndex, indexIntoBitMap);
47 indexIntoBitMap );
48 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
49 return retval;
50} 36}
51//============================================================================ 37
52#endif /* _HVCALLSM_H */ 38#endif /* _HVCALLSM_H */
diff --git a/include/asm-ppc64/iSeries/HvCallXm.h b/include/asm-ppc64/iSeries/HvCallXm.h
index bfb898f4db8d..8b9ba608daaf 100644
--- a/include/asm-ppc64/iSeries/HvCallXm.h
+++ b/include/asm-ppc64/iSeries/HvCallXm.h
@@ -1,30 +1,13 @@
1//============================================================================ 1/*
2// Header File Id 2 * This file contains the "hypervisor call" interface which is used to
3// Name______________: HvCallXm.H 3 * drive the hypervisor from SLIC.
4// 4 */
5// Description_______:
6//
7// This file contains the "hypervisor call" interface which is used to
8// drive the hypervisor from SLIC.
9//
10//============================================================================
11#ifndef _HVCALLXM_H 5#ifndef _HVCALLXM_H
12#define _HVCALLXM_H 6#define _HVCALLXM_H
13 7
14//-------------------------------------------------------------------
15// Forward declarations
16//-------------------------------------------------------------------
17
18//-------------------------------------------------------------------
19// Standard Includes
20//-------------------------------------------------------------------
21#include <asm/iSeries/HvCallSc.h> 8#include <asm/iSeries/HvCallSc.h>
22#include <asm/iSeries/HvTypes.h> 9#include <asm/iSeries/HvTypes.h>
23 10
24//-----------------------------------------------------------------------------
25// Constants
26//-----------------------------------------------------------------------------
27
28#define HvCallXmGetTceTableParms HvCallXm + 0 11#define HvCallXmGetTceTableParms HvCallXm + 0
29#define HvCallXmTestBus HvCallXm + 1 12#define HvCallXmTestBus HvCallXm + 1
30#define HvCallXmConnectBusUnit HvCallXm + 2 13#define HvCallXmConnectBusUnit HvCallXm + 2
@@ -33,63 +16,63 @@
33#define HvCallXmSetTce HvCallXm + 11 16#define HvCallXmSetTce HvCallXm + 11
34#define HvCallXmSetTces HvCallXm + 13 17#define HvCallXmSetTces HvCallXm + 13
35 18
19/*
20 * Structure passed to HvCallXm_getTceTableParms
21 */
22struct iommu_table_cb {
23 unsigned long itc_busno; /* Bus number for this tce table */
24 unsigned long itc_start; /* Will be NULL for secondary */
25 unsigned long itc_totalsize; /* Size (in pages) of whole table */
26 unsigned long itc_offset; /* Index into real tce table of the
27 start of our section */
28 unsigned long itc_size; /* Size (in pages) of our section */
29 unsigned long itc_index; /* Index of this tce table */
30 unsigned short itc_maxtables; /* Max num of tables for partition */
31 unsigned char itc_virtbus; /* Flag to indicate virtual bus */
32 unsigned char itc_slotno; /* IOA Tce Slot Index */
33 unsigned char itc_rsvd[4];
34};
36 35
37 36static inline void HvCallXm_getTceTableParms(u64 cb)
38//============================================================================
39static inline void HvCallXm_getTceTableParms(u64 cb)
40{ 37{
41 HvCall1(HvCallXmGetTceTableParms, cb); 38 HvCall1(HvCallXmGetTceTableParms, cb);
42 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
43} 39}
44//============================================================================ 40
45static inline u64 HvCallXm_setTce(u64 tceTableToken, u64 tceOffset, u64 tce) 41static inline u64 HvCallXm_setTce(u64 tceTableToken, u64 tceOffset, u64 tce)
46{ 42{
47 u64 retval = HvCall3(HvCallXmSetTce, tceTableToken, tceOffset, tce ); 43 return HvCall3(HvCallXmSetTce, tceTableToken, tceOffset, tce);
48 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
49 return retval;
50}
51//============================================================================
52static inline u64 HvCallXm_setTces(u64 tceTableToken, u64 tceOffset, u64 numTces, u64 tce1, u64 tce2, u64 tce3, u64 tce4)
53{
54 u64 retval = HvCall7(HvCallXmSetTces, tceTableToken, tceOffset, numTces,
55 tce1, tce2, tce3, tce4 );
56 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
57 return retval;
58} 44}
59//============================================================================= 45
60static inline u64 HvCallXm_testBus(u16 busNumber) 46static inline u64 HvCallXm_setTces(u64 tceTableToken, u64 tceOffset,
47 u64 numTces, u64 tce1, u64 tce2, u64 tce3, u64 tce4)
61{ 48{
62 u64 retVal = HvCall1(HvCallXmTestBus, busNumber); 49 return HvCall7(HvCallXmSetTces, tceTableToken, tceOffset, numTces,
63 // getPaca()->adjustHmtForNoOfSpinLocksHeld(); 50 tce1, tce2, tce3, tce4);
64 return retVal;
65} 51}
66//===================================================================================== 52
67static inline u64 HvCallXm_testBusUnit(u16 busNumber, u8 subBusNumber, u8 deviceId) 53static inline u64 HvCallXm_testBus(u16 busNumber)
68{ 54{
69 u64 busUnitNumber = (subBusNumber << 8) | deviceId; 55 return HvCall1(HvCallXmTestBus, busNumber);
70 u64 retVal = HvCall2(HvCallXmTestBusUnit, busNumber, busUnitNumber);
71 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
72 return retVal;
73} 56}
74//===================================================================================== 57
75static inline u64 HvCallXm_connectBusUnit(u16 busNumber, u8 subBusNumber, u8 deviceId, 58static inline u64 HvCallXm_testBusUnit(u16 busNumber, u8 subBusNumber,
76 u64 interruptToken) 59 u8 deviceId)
77{ 60{
78 u64 busUnitNumber = (subBusNumber << 8) | deviceId; 61 return HvCall2(HvCallXmTestBusUnit, busNumber,
79 u64 queueIndex = 0; // HvLpConfig::mapDsaToQueueIndex(HvLpDSA(busNumber, xBoard, xCard)); 62 (subBusNumber << 8) | deviceId);
63}
80 64
81 u64 retVal = HvCall5(HvCallXmConnectBusUnit, busNumber, busUnitNumber, 65static inline u64 HvCallXm_connectBusUnit(u16 busNumber, u8 subBusNumber,
82 interruptToken, 0, queueIndex); 66 u8 deviceId, u64 interruptToken)
83 // getPaca()->adjustHmtForNoOfSpinLocksHeld(); 67{
84 return retVal; 68 return HvCall5(HvCallXmConnectBusUnit, busNumber,
69 (subBusNumber << 8) | deviceId, interruptToken, 0,
70 0 /* HvLpConfig::mapDsaToQueueIndex(HvLpDSA(busNumber, xBoard, xCard)) */);
85} 71}
86//===================================================================================== 72
87static inline u64 HvCallXm_loadTod(void) 73static inline u64 HvCallXm_loadTod(void)
88{ 74{
89 u64 retVal = HvCall0(HvCallXmLoadTod); 75 return HvCall0(HvCallXmLoadTod);
90 // getPaca()->adjustHmtForNoOfSpinLocksHeld();
91 return retVal;
92} 76}
93//=====================================================================================
94 77
95#endif /* _HVCALLXM_H */ 78#endif /* _HVCALLXM_H */
diff --git a/include/asm-ppc64/iSeries/HvLpConfig.h b/include/asm-ppc64/iSeries/HvLpConfig.h
index bdbd70f42c9d..f1cf1e70ca3c 100644
--- a/include/asm-ppc64/iSeries/HvLpConfig.h
+++ b/include/asm-ppc64/iSeries/HvLpConfig.h
@@ -1,17 +1,17 @@
1/* 1/*
2 * HvLpConfig.h 2 * HvLpConfig.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation 3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -19,262 +19,120 @@
19#ifndef _HVLPCONFIG_H 19#ifndef _HVLPCONFIG_H
20#define _HVLPCONFIG_H 20#define _HVLPCONFIG_H
21 21
22//=========================================================================== 22/*
23// 23 * This file contains the interface to the LPAR configuration data
24// This file contains the interface to the LPAR configuration data 24 * to determine which resources should be allocated to each partition.
25// to determine which resources should be allocated to each partition. 25 */
26//
27//===========================================================================
28 26
29#include <asm/iSeries/HvCallCfg.h> 27#include <asm/iSeries/HvCallSc.h>
30#include <asm/iSeries/HvTypes.h> 28#include <asm/iSeries/HvTypes.h>
31#include <asm/iSeries/ItLpNaca.h> 29#include <asm/iSeries/ItLpNaca.h>
32#include <asm/iSeries/LparData.h>
33 30
34//------------------------------------------------------------------- 31enum {
35// Constants 32 HvCallCfg_Cur = 0,
36//------------------------------------------------------------------- 33 HvCallCfg_Init = 1,
34 HvCallCfg_Max = 2,
35 HvCallCfg_Min = 3
36};
37
38#define HvCallCfgGetSystemPhysicalProcessors HvCallCfg + 6
39#define HvCallCfgGetPhysicalProcessors HvCallCfg + 7
40#define HvCallCfgGetMsChunks HvCallCfg + 9
41#define HvCallCfgGetSharedPoolIndex HvCallCfg + 20
42#define HvCallCfgGetSharedProcUnits HvCallCfg + 21
43#define HvCallCfgGetNumProcsInSharedPool HvCallCfg + 22
44#define HvCallCfgGetVirtualLanIndexMap HvCallCfg + 30
45#define HvCallCfgGetHostingLpIndex HvCallCfg + 32
37 46
38extern HvLpIndex HvLpConfig_getLpIndex_outline(void); 47extern HvLpIndex HvLpConfig_getLpIndex_outline(void);
39 48
40//===================================================================
41static inline HvLpIndex HvLpConfig_getLpIndex(void) 49static inline HvLpIndex HvLpConfig_getLpIndex(void)
42{ 50{
43 return itLpNaca.xLpIndex; 51 return itLpNaca.xLpIndex;
44} 52}
45//=================================================================== 53
46static inline HvLpIndex HvLpConfig_getPrimaryLpIndex(void) 54static inline HvLpIndex HvLpConfig_getPrimaryLpIndex(void)
47{ 55{
48 return itLpNaca.xPrimaryLpIndex; 56 return itLpNaca.xPrimaryLpIndex;
49} 57}
50//================================================================= 58
51static inline HvLpIndex HvLpConfig_getLps(void) 59static inline u64 HvLpConfig_getMsChunks(void)
52{
53 return HvCallCfg_getLps();
54}
55//=================================================================
56static inline HvLpIndexMap HvLpConfig_getActiveLpMap(void)
57{
58 return HvCallCfg_getActiveLpMap();
59}
60//=================================================================
61static inline u64 HvLpConfig_getSystemMsMegs(void)
62{
63 return HvCallCfg_getSystemMsChunks() / HVCHUNKSPERMEG;
64}
65//=================================================================
66static inline u64 HvLpConfig_getSystemMsChunks(void)
67{
68 return HvCallCfg_getSystemMsChunks();
69}
70//=================================================================
71static inline u64 HvLpConfig_getSystemMsPages(void)
72{
73 return HvCallCfg_getSystemMsChunks() * HVPAGESPERCHUNK;
74}
75//================================================================
76static inline u64 HvLpConfig_getMsMegs(void)
77{
78 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Cur) / HVCHUNKSPERMEG;
79}
80//================================================================
81static inline u64 HvLpConfig_getMsChunks(void)
82{
83 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Cur);
84}
85//================================================================
86static inline u64 HvLpConfig_getMsPages(void)
87{
88 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Cur) * HVPAGESPERCHUNK;
89}
90//================================================================
91static inline u64 HvLpConfig_getMinMsMegs(void)
92{
93 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Min) / HVCHUNKSPERMEG;
94}
95//================================================================
96static inline u64 HvLpConfig_getMinMsChunks(void)
97{
98 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Min);
99}
100//================================================================
101static inline u64 HvLpConfig_getMinMsPages(void)
102{
103 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Min) * HVPAGESPERCHUNK;
104}
105//================================================================
106static inline u64 HvLpConfig_getMinRuntimeMsMegs(void)
107{
108 return HvCallCfg_getMinRuntimeMsChunks(HvLpConfig_getLpIndex()) / HVCHUNKSPERMEG;
109}
110//===============================================================
111static inline u64 HvLpConfig_getMinRuntimeMsChunks(void)
112{
113 return HvCallCfg_getMinRuntimeMsChunks(HvLpConfig_getLpIndex());
114}
115//===============================================================
116static inline u64 HvLpConfig_getMinRuntimeMsPages(void)
117{
118 return HvCallCfg_getMinRuntimeMsChunks(HvLpConfig_getLpIndex()) * HVPAGESPERCHUNK;
119}
120//===============================================================
121static inline u64 HvLpConfig_getMaxMsMegs(void)
122{
123 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Max) / HVCHUNKSPERMEG;
124}
125//===============================================================
126static inline u64 HvLpConfig_getMaxMsChunks(void)
127{
128 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Max);
129}
130//===============================================================
131static inline u64 HvLpConfig_getMaxMsPages(void)
132{
133 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Max) * HVPAGESPERCHUNK;
134}
135//===============================================================
136static inline u64 HvLpConfig_getInitMsMegs(void)
137{
138 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Init) / HVCHUNKSPERMEG;
139}
140//===============================================================
141static inline u64 HvLpConfig_getInitMsChunks(void)
142{
143 return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Init);
144}
145//===============================================================
146static inline u64 HvLpConfig_getInitMsPages(void)
147{ return HvCallCfg_getMsChunks(HvLpConfig_getLpIndex(),HvCallCfg_Init) * HVPAGESPERCHUNK;
148}
149//===============================================================
150static inline u64 HvLpConfig_getSystemPhysicalProcessors(void)
151{
152 return HvCallCfg_getSystemPhysicalProcessors();
153}
154//===============================================================
155static inline u64 HvLpConfig_getSystemLogicalProcessors(void)
156{
157 return HvCallCfg_getSystemPhysicalProcessors() * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
158}
159//===============================================================
160static inline u64 HvLpConfig_getNumProcsInSharedPool(HvLpSharedPoolIndex sPI)
161{
162 return HvCallCfg_getNumProcsInSharedPool(sPI);
163}
164//===============================================================
165static inline u64 HvLpConfig_getPhysicalProcessors(void)
166{
167 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Cur);
168}
169//===============================================================
170static inline u64 HvLpConfig_getLogicalProcessors(void)
171{
172 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Cur) * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
173}
174//===============================================================
175static inline HvLpSharedPoolIndex HvLpConfig_getSharedPoolIndex(void)
176{
177 return HvCallCfg_getSharedPoolIndex(HvLpConfig_getLpIndex());
178}
179//===============================================================
180static inline u64 HvLpConfig_getSharedProcUnits(void)
181{
182 return HvCallCfg_getSharedProcUnits(HvLpConfig_getLpIndex(),HvCallCfg_Cur);
183}
184//===============================================================
185static inline u64 HvLpConfig_getMinSharedProcUnits(void)
186{
187 return HvCallCfg_getSharedProcUnits(HvLpConfig_getLpIndex(),HvCallCfg_Min);
188}
189//===============================================================
190static inline u64 HvLpConfig_getMaxSharedProcUnits(void)
191{
192 return HvCallCfg_getSharedProcUnits(HvLpConfig_getLpIndex(),HvCallCfg_Max);
193}
194//===============================================================
195static inline u64 HvLpConfig_getMinPhysicalProcessors(void)
196{
197 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Min);
198}
199//===============================================================
200static inline u64 HvLpConfig_getMinLogicalProcessors(void)
201{
202 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Min) * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
203}
204//===============================================================
205static inline u64 HvLpConfig_getMaxPhysicalProcessors(void)
206{
207 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Max);
208}
209//===============================================================
210static inline u64 HvLpConfig_getMaxLogicalProcessors(void)
211{
212 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Max) * (/*getPaca()->getSecondaryThreadCount() +*/ 1);
213}
214//===============================================================
215static inline u64 HvLpConfig_getInitPhysicalProcessors(void)
216{ 60{
217 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Init); 61 return HvCall2(HvCallCfgGetMsChunks, HvLpConfig_getLpIndex(),
62 HvCallCfg_Cur);
218} 63}
219//=============================================================== 64
220static inline u64 HvLpConfig_getInitLogicalProcessors(void) 65static inline u64 HvLpConfig_getSystemPhysicalProcessors(void)
221{ 66{
222 return HvCallCfg_getPhysicalProcessors(HvLpConfig_getLpIndex(),HvCallCfg_Init) * (/*getPaca()->getSecondaryThreadCount() +*/ 1); 67 return HvCall0(HvCallCfgGetSystemPhysicalProcessors);
223} 68}
224//================================================================ 69
225static inline HvLpVirtualLanIndexMap HvLpConfig_getVirtualLanIndexMap(void) 70static inline u64 HvLpConfig_getNumProcsInSharedPool(HvLpSharedPoolIndex sPI)
226{ 71{
227 return HvCallCfg_getVirtualLanIndexMap(HvLpConfig_getLpIndex_outline()); 72 return (u16)HvCall1(HvCallCfgGetNumProcsInSharedPool, sPI);
228} 73}
229//=============================================================== 74
230static inline HvLpVirtualLanIndexMap HvLpConfig_getVirtualLanIndexMapForLp(HvLpIndex lp) 75static inline u64 HvLpConfig_getPhysicalProcessors(void)
231{ 76{
232 return HvCallCfg_getVirtualLanIndexMap(lp); 77 return HvCall2(HvCallCfgGetPhysicalProcessors, HvLpConfig_getLpIndex(),
78 HvCallCfg_Cur);
233} 79}
234//================================================================ 80
235static inline HvLpIndex HvLpConfig_getBusOwner(HvBusNumber busNumber) 81static inline HvLpSharedPoolIndex HvLpConfig_getSharedPoolIndex(void)
236{ 82{
237 return HvCallCfg_getBusOwner(busNumber); 83 return HvCall1(HvCallCfgGetSharedPoolIndex, HvLpConfig_getLpIndex());
238} 84}
239//=============================================================== 85
240static inline int HvLpConfig_isBusDedicated(HvBusNumber busNumber) 86static inline u64 HvLpConfig_getSharedProcUnits(void)
241{ 87{
242 return HvCallCfg_isBusDedicated(busNumber); 88 return HvCall2(HvCallCfgGetSharedProcUnits, HvLpConfig_getLpIndex(),
89 HvCallCfg_Cur);
243} 90}
244//================================================================ 91
245static inline HvLpIndexMap HvLpConfig_getBusAllocation(HvBusNumber busNumber) 92static inline u64 HvLpConfig_getMaxSharedProcUnits(void)
246{ 93{
247 return HvCallCfg_getBusAllocation(busNumber); 94 return HvCall2(HvCallCfgGetSharedProcUnits, HvLpConfig_getLpIndex(),
95 HvCallCfg_Max);
248} 96}
249//================================================================ 97
250// returns the absolute real address of the load area 98static inline u64 HvLpConfig_getMaxPhysicalProcessors(void)
251static inline u64 HvLpConfig_getLoadAddress(void)
252{ 99{
253 return itLpNaca.xLoadAreaAddr & 0x7fffffffffffffff; 100 return HvCall2(HvCallCfgGetPhysicalProcessors, HvLpConfig_getLpIndex(),
101 HvCallCfg_Max);
254} 102}
255//================================================================ 103
256static inline u64 HvLpConfig_getLoadPages(void) 104static inline HvLpVirtualLanIndexMap HvLpConfig_getVirtualLanIndexMapForLp(
257{ 105 HvLpIndex lp)
258 return itLpNaca.xLoadAreaChunks * HVPAGESPERCHUNK; 106{
107 /*
108 * This is a new function in V5R1 so calls to this on older
109 * hypervisors will return -1
110 */
111 u64 retVal = HvCall1(HvCallCfgGetVirtualLanIndexMap, lp);
112 if (retVal == -1)
113 retVal = 0;
114 return retVal;
259} 115}
260//================================================================ 116
261static inline int HvLpConfig_isBusOwnedByThisLp(HvBusNumber busNumber) 117static inline HvLpVirtualLanIndexMap HvLpConfig_getVirtualLanIndexMap(void)
262{ 118{
263 HvLpIndex busOwner = HvLpConfig_getBusOwner(busNumber); 119 return HvLpConfig_getVirtualLanIndexMapForLp(
264 return (busOwner == HvLpConfig_getLpIndex()); 120 HvLpConfig_getLpIndex_outline());
265} 121}
266//================================================================ 122
267static inline int HvLpConfig_doLpsCommunicateOnVirtualLan(HvLpIndex lp1, HvLpIndex lp2) 123static inline int HvLpConfig_doLpsCommunicateOnVirtualLan(HvLpIndex lp1,
124 HvLpIndex lp2)
268{ 125{
269 HvLpVirtualLanIndexMap virtualLanIndexMap1 = HvCallCfg_getVirtualLanIndexMap( lp1 ); 126 HvLpVirtualLanIndexMap virtualLanIndexMap1 =
270 HvLpVirtualLanIndexMap virtualLanIndexMap2 = HvCallCfg_getVirtualLanIndexMap( lp2 ); 127 HvLpConfig_getVirtualLanIndexMapForLp(lp1);
128 HvLpVirtualLanIndexMap virtualLanIndexMap2 =
129 HvLpConfig_getVirtualLanIndexMapForLp(lp2);
271 return ((virtualLanIndexMap1 & virtualLanIndexMap2) != 0); 130 return ((virtualLanIndexMap1 & virtualLanIndexMap2) != 0);
272} 131}
273//================================================================ 132
274static inline HvLpIndex HvLpConfig_getHostingLpIndex(HvLpIndex lp) 133static inline HvLpIndex HvLpConfig_getHostingLpIndex(HvLpIndex lp)
275{ 134{
276 return HvCallCfg_getHostingLpIndex(lp); 135 return HvCall1(HvCallCfgGetHostingLpIndex, lp);
277} 136}
278//================================================================
279 137
280#endif /* _HVLPCONFIG_H */ 138#endif /* _HVLPCONFIG_H */
diff --git a/include/asm-ppc64/iSeries/HvLpEvent.h b/include/asm-ppc64/iSeries/HvLpEvent.h
index 30936e433064..865000de79b6 100644
--- a/include/asm-ppc64/iSeries/HvLpEvent.h
+++ b/include/asm-ppc64/iSeries/HvLpEvent.h
@@ -1,27 +1,24 @@
1/* 1/*
2 * HvLpEvent.h 2 * HvLpEvent.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation 3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */ 18 */
19 19
20//====================================================================== 20/* This file contains the class for HV events in the system. */
21// 21
22// This file contains the class for HV events in the system.
23//
24//=====================================================================
25#ifndef _HVLPEVENT_H 22#ifndef _HVLPEVENT_H
26#define _HVLPEVENT_H 23#define _HVLPEVENT_H
27 24
@@ -30,69 +27,70 @@
30#include <asm/iSeries/HvTypes.h> 27#include <asm/iSeries/HvTypes.h>
31#include <asm/iSeries/HvCallEvent.h> 28#include <asm/iSeries/HvCallEvent.h>
32 29
33//===================================================================== 30/*
34// 31 * HvLpEvent is the structure for Lp Event messages passed between
35// HvLpEvent is the structure for Lp Event messages passed between 32 * partitions through PLIC.
36// partitions through PLIC. 33 */
37// 34
38//===================================================================== 35struct HvEventFlags {
39 36 u8 xValid:1; /* Indicates a valid request x00-x00 */
40struct HvEventFlags 37 u8 xRsvd1:4; /* Reserved ... */
41{ 38 u8 xAckType:1; /* Immediate or deferred ... */
42 u8 xValid:1; // Indicates a valid request x00-x00 39 u8 xAckInd:1; /* Indicates if ACK required ... */
43 u8 xRsvd1:4; // Reserved ... 40 u8 xFunction:1; /* Interrupt or Acknowledge ... */
44 u8 xAckType:1; // Immediate or deferred ...
45 u8 xAckInd:1; // Indicates if ACK required ...
46 u8 xFunction:1; // Interrupt or Acknowledge ...
47}; 41};
48 42
49 43
50struct HvLpEvent 44struct HvLpEvent {
51{ 45 struct HvEventFlags xFlags; /* Event flags x00-x00 */
52 struct HvEventFlags xFlags; // Event flags x00-x00 46 u8 xType; /* Type of message x01-x01 */
53 u8 xType; // Type of message x01-x01 47 u16 xSubtype; /* Subtype for event x02-x03 */
54 u16 xSubtype; // Subtype for event x02-x03 48 u8 xSourceLp; /* Source LP x04-x04 */
55 u8 xSourceLp; // Source LP x04-x04 49 u8 xTargetLp; /* Target LP x05-x05 */
56 u8 xTargetLp; // Target LP x05-x05 50 u8 xSizeMinus1; /* Size of Derived class - 1 x06-x06 */
57 u8 xSizeMinus1; // Size of Derived class - 1 x06-x06 51 u8 xRc; /* RC for Ack flows x07-x07 */
58 u8 xRc; // RC for Ack flows x07-x07 52 u16 xSourceInstanceId; /* Source sides instance id x08-x09 */
59 u16 xSourceInstanceId; // Source sides instance id x08-x09 53 u16 xTargetInstanceId; /* Target sides instance id x0A-x0B */
60 u16 xTargetInstanceId; // Target sides instance id x0A-x0B
61 union { 54 union {
62 u32 xSubtypeData; // Data usable by the subtype x0C-x0F 55 u32 xSubtypeData; /* Data usable by the subtype x0C-x0F */
63 u16 xSubtypeDataShort[2]; // Data as 2 shorts 56 u16 xSubtypeDataShort[2]; /* Data as 2 shorts */
64 u8 xSubtypeDataChar[4]; // Data as 4 chars 57 u8 xSubtypeDataChar[4]; /* Data as 4 chars */
65 } x; 58 } x;
66 59
67 u64 xCorrelationToken; // Unique value for source/type x10-x17 60 u64 xCorrelationToken; /* Unique value for source/type x10-x17 */
68}; 61};
69 62
70// Lp Event handler function
71typedef void (*LpEventHandler)(struct HvLpEvent *, struct pt_regs *); 63typedef void (*LpEventHandler)(struct HvLpEvent *, struct pt_regs *);
72 64
73// Register a handler for an event type 65/* Register a handler for an event type - returns 0 on success */
74// returns 0 on success 66extern int HvLpEvent_registerHandler(HvLpEvent_Type eventType,
75extern int HvLpEvent_registerHandler( HvLpEvent_Type eventType, LpEventHandler hdlr); 67 LpEventHandler hdlr);
76
77// Unregister a handler for an event type
78// This call will sleep until the handler being removed is guaranteed to
79// be no longer executing on any CPU. Do not call with locks held.
80//
81// returns 0 on success
82// Unregister will fail if there are any paths open for the type
83extern int HvLpEvent_unregisterHandler( HvLpEvent_Type eventType );
84 68
85// Open an Lp Event Path for an event type 69/*
86// returns 0 on success 70 * Unregister a handler for an event type
87// openPath will fail if there is no handler registered for the event type. 71 *
88// The lpIndex specified is the partition index for the target partition 72 * This call will sleep until the handler being removed is guaranteed to
89// (for VirtualIo, VirtualLan and SessionMgr) other types specify zero) 73 * be no longer executing on any CPU. Do not call with locks held.
90extern int HvLpEvent_openPath( HvLpEvent_Type eventType, HvLpIndex lpIndex ); 74 *
75 * returns 0 on success
76 * Unregister will fail if there are any paths open for the type
77 */
78extern int HvLpEvent_unregisterHandler(HvLpEvent_Type eventType);
91 79
80/*
81 * Open an Lp Event Path for an event type
82 * returns 0 on success
83 * openPath will fail if there is no handler registered for the event type.
84 * The lpIndex specified is the partition index for the target partition
85 * (for VirtualIo, VirtualLan and SessionMgr) other types specify zero)
86 */
87extern int HvLpEvent_openPath(HvLpEvent_Type eventType, HvLpIndex lpIndex);
92 88
93// Close an Lp Event Path for a type and partition 89/*
94// returns 0 on sucess 90 * Close an Lp Event Path for a type and partition
95extern int HvLpEvent_closePath( HvLpEvent_Type eventType, HvLpIndex lpIndex ); 91 * returns 0 on sucess
92 */
93extern int HvLpEvent_closePath(HvLpEvent_Type eventType, HvLpIndex lpIndex);
96 94
97#define HvLpEvent_Type_Hypervisor 0 95#define HvLpEvent_Type_Hypervisor 0
98#define HvLpEvent_Type_MachineFac 1 96#define HvLpEvent_Type_MachineFac 1
@@ -141,4 +139,4 @@ extern int HvLpEvent_closePath( HvLpEvent_Type eventType, HvLpIndex lpIndex );
141#define HvLpDma_Rc_InvalidAddress 4 139#define HvLpDma_Rc_InvalidAddress 4
142#define HvLpDma_Rc_InvalidLength 5 140#define HvLpDma_Rc_InvalidLength 5
143 141
144#endif // _HVLPEVENT_H 142#endif /* _HVLPEVENT_H */
diff --git a/include/asm-ppc64/iSeries/HvReleaseData.h b/include/asm-ppc64/iSeries/HvReleaseData.h
index 183e5e738c26..01a1f13ea4a0 100644
--- a/include/asm-ppc64/iSeries/HvReleaseData.h
+++ b/include/asm-ppc64/iSeries/HvReleaseData.h
@@ -1,17 +1,17 @@
1/* 1/*
2 * HvReleaseData.h 2 * HvReleaseData.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation 3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -19,47 +19,45 @@
19#ifndef _HVRELEASEDATA_H 19#ifndef _HVRELEASEDATA_H
20#define _HVRELEASEDATA_H 20#define _HVRELEASEDATA_H
21 21
22//============================================================================= 22/*
23// 23 * This control block contains the critical information about the
24// This control block contains the critical information about the 24 * release so that it can be changed in the future (ie, the virtual
25// release so that it can be changed in the future (ie, the virtual 25 * address of the OS's NACA).
26// address of the OS's NACA). 26 */
27//
28#include <asm/types.h> 27#include <asm/types.h>
29#include <asm/naca.h> 28#include <asm/naca.h>
30 29
31//============================================================================= 30/*
32// 31 * When we IPL a secondary partition, we will check if if the
33// When we IPL a secondary partition, we will check if if the 32 * secondary xMinPlicVrmIndex > the primary xVrmIndex.
34// secondary xMinPlicVrmIndex > the primary xVrmIndex. 33 * If it is then this tells PLIC that this secondary is not
35// If it is then this tells PLIC that this secondary is not 34 * supported running on this "old" of a level of PLIC.
36// supported running on this "old" of a level of PLIC. 35 *
37// 36 * Likewise, we will compare the primary xMinSlicVrmIndex to
38// Likewise, we will compare the primary xMinSlicVrmIndex to 37 * the secondary xVrmIndex.
39// the secondary xVrmIndex. 38 * If the primary xMinSlicVrmDelta > secondary xVrmDelta then we
40// If the primary xMinSlicVrmDelta > secondary xVrmDelta then we 39 * know that this PLIC does not support running an OS "that old".
41// know that this PLIC does not support running an OS "that old". 40 */
42//
43//=============================================================================
44 41
45struct HvReleaseData 42struct HvReleaseData {
46{ 43 u32 xDesc; /* Descriptor "HvRD" ebcdic x00-x03 */
47 u32 xDesc; // Descriptor "HvRD" ebcdic x00-x03 44 u16 xSize; /* Size of this control block x04-x05 */
48 u16 xSize; // Size of this control block x04-x05 45 u16 xVpdAreasPtrOffset; /* Offset in NACA of ItVpdAreas x06-x07 */
49 u16 xVpdAreasPtrOffset; // Offset in NACA of ItVpdAreas x06-x07 46 struct naca_struct *xSlicNacaAddr; /* Virt addr of SLIC NACA x08-x0F */
50 struct naca_struct * xSlicNacaAddr; // Virt addr of SLIC NACA x08-x0F 47 u32 xMsNucDataOffset; /* Offset of Linux Mapping Data x10-x13 */
51 u32 xMsNucDataOffset; // Offset of Linux Mapping Data x10-x13 48 u32 xRsvd1; /* Reserved x14-x17 */
52 u32 xRsvd1; // Reserved x14-x17 49 u16 xTagsMode:1; /* 0 == tags active, 1 == tags inactive */
53 u16 xTagsMode:1; // 0 == tags active, 1 == tags inactive 50 u16 xAddressSize:1; /* 0 == 64-bit, 1 == 32-bit */
54 u16 xAddressSize:1; // 0 == 64-bit, 1 == 32-bit 51 u16 xNoSharedProcs:1; /* 0 == shared procs, 1 == no shared */
55 u16 xNoSharedProcs:1; // 0 == shared procs, 1 == no shared 52 u16 xNoHMT:1; /* 0 == allow HMT, 1 == no HMT */
56 u16 xNoHMT:1; // 0 == allow HMT, 1 == no HMT 53 u16 xRsvd2:12; /* Reserved x18-x19 */
57 u16 xRsvd2:12; // Reserved x18-x19 54 u16 xVrmIndex; /* VRM Index of OS image x1A-x1B */
58 u16 xVrmIndex; // VRM Index of OS image x1A-x1B 55 u16 xMinSupportedPlicVrmIndex; /* Min PLIC level (soft) x1C-x1D */
59 u16 xMinSupportedPlicVrmIndex;// Min PLIC level (soft) x1C-x1D 56 u16 xMinCompatablePlicVrmIndex; /* Min PLIC levelP (hard) x1E-x1F */
60 u16 xMinCompatablePlicVrmIndex;// Min PLIC levelP (hard) x1E-x1F 57 char xVrmName[12]; /* Displayable name x20-x2B */
61 char xVrmName[12]; // Displayable name x20-x2B 58 char xRsvd3[20]; /* Reserved x2C-x3F */
62 char xRsvd3[20]; // Reserved x2C-x3F
63}; 59};
64 60
61extern struct HvReleaseData hvReleaseData;
62
65#endif /* _HVRELEASEDATA_H */ 63#endif /* _HVRELEASEDATA_H */
diff --git a/include/asm-ppc64/iSeries/HvTypes.h b/include/asm-ppc64/iSeries/HvTypes.h
index 3ec49c1aec32..b1ef2b4cb3e3 100644
--- a/include/asm-ppc64/iSeries/HvTypes.h
+++ b/include/asm-ppc64/iSeries/HvTypes.h
@@ -1,17 +1,17 @@
1/* 1/*
2 * HvTypes.h 2 * HvTypes.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation 3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -19,74 +19,60 @@
19#ifndef _HVTYPES_H 19#ifndef _HVTYPES_H
20#define _HVTYPES_H 20#define _HVTYPES_H
21 21
22//=========================================================================== 22/*
23// Header File Id 23 * General typedefs for the hypervisor.
24// Name______________: HvTypes.H 24 */
25//
26// Description_______:
27//
28// General typedefs for the hypervisor.
29//
30// Declared Class(es):
31//
32//===========================================================================
33 25
34#include <asm/types.h> 26#include <asm/types.h>
35 27
36//-------------------------------------------------------------------
37// Typedefs
38//-------------------------------------------------------------------
39typedef u8 HvLpIndex; 28typedef u8 HvLpIndex;
40typedef u16 HvLpInstanceId; 29typedef u16 HvLpInstanceId;
41typedef u64 HvLpTOD; 30typedef u64 HvLpTOD;
42typedef u64 HvLpSystemSerialNum; 31typedef u64 HvLpSystemSerialNum;
43typedef u8 HvLpDeviceSerialNum[12]; 32typedef u8 HvLpDeviceSerialNum[12];
44typedef u16 HvLpSanHwSet; 33typedef u16 HvLpSanHwSet;
45typedef u16 HvLpBus; 34typedef u16 HvLpBus;
46typedef u16 HvLpBoard; 35typedef u16 HvLpBoard;
47typedef u16 HvLpCard; 36typedef u16 HvLpCard;
48typedef u8 HvLpDeviceType[4]; 37typedef u8 HvLpDeviceType[4];
49typedef u8 HvLpDeviceModel[3]; 38typedef u8 HvLpDeviceModel[3];
50typedef u64 HvIoToken; 39typedef u64 HvIoToken;
51typedef u8 HvLpName[8]; 40typedef u8 HvLpName[8];
52typedef u32 HvIoId; 41typedef u32 HvIoId;
53typedef u64 HvRealMemoryIndex; 42typedef u64 HvRealMemoryIndex;
54typedef u32 HvLpIndexMap; // Must hold HvMaxArchitectedLps bits!!! 43typedef u32 HvLpIndexMap; /* Must hold HVMAXARCHITECTEDLPS bits!!! */
55typedef u16 HvLpVrmIndex; 44typedef u16 HvLpVrmIndex;
56typedef u32 HvXmGenerationId; 45typedef u32 HvXmGenerationId;
57typedef u8 HvLpBusPool; 46typedef u8 HvLpBusPool;
58typedef u8 HvLpSharedPoolIndex; 47typedef u8 HvLpSharedPoolIndex;
59typedef u16 HvLpSharedProcUnitsX100; 48typedef u16 HvLpSharedProcUnitsX100;
60typedef u8 HvLpVirtualLanIndex; 49typedef u8 HvLpVirtualLanIndex;
61typedef u16 HvLpVirtualLanIndexMap; // Must hold HvMaxArchitectedVirtualLans bits!!! 50typedef u16 HvLpVirtualLanIndexMap; /* Must hold HVMAXARCHITECTEDVIRTUALLANS bits!!! */
62typedef u16 HvBusNumber; // Hypervisor Bus Number 51typedef u16 HvBusNumber; /* Hypervisor Bus Number */
63typedef u8 HvSubBusNumber; // Hypervisor SubBus Number 52typedef u8 HvSubBusNumber; /* Hypervisor SubBus Number */
64typedef u8 HvAgentId; // Hypervisor DevFn 53typedef u8 HvAgentId; /* Hypervisor DevFn */
54
65 55
56#define HVMAXARCHITECTEDLPS 32
57#define HVMAXARCHITECTEDVIRTUALLANS 16
58#define HVMAXARCHITECTEDVIRTUALDISKS 32
59#define HVMAXARCHITECTEDVIRTUALCDROMS 8
60#define HVMAXARCHITECTEDVIRTUALTAPES 8
61#define HVCHUNKSIZE (256 * 1024)
62#define HVPAGESIZE (4 * 1024)
63#define HVLPMINMEGSPRIMARY 256
64#define HVLPMINMEGSSECONDARY 64
65#define HVCHUNKSPERMEG 4
66#define HVPAGESPERMEG 256
67#define HVPAGESPERCHUNK 64
66 68
67#define HVMAXARCHITECTEDLPS 32
68#define HVMAXARCHITECTEDVIRTUALLANS 16
69#define HVMAXARCHITECTEDVIRTUALDISKS 32
70#define HVMAXARCHITECTEDVIRTUALCDROMS 8
71#define HVMAXARCHITECTEDVIRTUALTAPES 8
72#define HVCHUNKSIZE 256 * 1024
73#define HVPAGESIZE 4 * 1024
74#define HVLPMINMEGSPRIMARY 256
75#define HVLPMINMEGSSECONDARY 64
76#define HVCHUNKSPERMEG 4
77#define HVPAGESPERMEG 256
78#define HVPAGESPERCHUNK 64
79
80#define HvMaxArchitectedLps ((HvLpIndex)HVMAXARCHITECTEDLPS)
81#define HvMaxArchitectedVirtualLans ((HvLpVirtualLanIndex)16)
82#define HvLpIndexInvalid ((HvLpIndex)0xff) 69#define HvLpIndexInvalid ((HvLpIndex)0xff)
83 70
84//-------------------------------------------------------------------- 71/*
85// Enums for the sub-components under PLIC 72 * Enums for the sub-components under PLIC
86// Used in HvCall and HvPrimaryCall 73 * Used in HvCall and HvPrimaryCall
87//-------------------------------------------------------------------- 74 */
88enum HvCallCompIds 75enum {
89{
90 HvCallCompId = 0, 76 HvCallCompId = 0,
91 HvCallCpuCtlsCompId = 1, 77 HvCallCpuCtlsCompId = 1,
92 HvCallCfgCompId = 2, 78 HvCallCfgCompId = 2,
@@ -97,18 +83,18 @@ enum HvCallCompIds
97 HvCallSmCompId = 7, 83 HvCallSmCompId = 7,
98 HvCallSpdCompId = 8, 84 HvCallSpdCompId = 8,
99 HvCallXmCompId = 9, 85 HvCallXmCompId = 9,
100 HvCallRioCompId = 10, 86 HvCallRioCompId = 10,
101 HvCallRsvd3CompId = 11, 87 HvCallRsvd3CompId = 11,
102 HvCallRsvd2CompId = 12, 88 HvCallRsvd2CompId = 12,
103 HvCallRsvd1CompId = 13, 89 HvCallRsvd1CompId = 13,
104 HvCallMaxCompId = 14, 90 HvCallMaxCompId = 14,
105 HvPrimaryCallCompId = 0, 91 HvPrimaryCallCompId = 0,
106 HvPrimaryCallCfgCompId = 1, 92 HvPrimaryCallCfgCompId = 1,
107 HvPrimaryCallPciCompId = 2, 93 HvPrimaryCallPciCompId = 2,
108 HvPrimaryCallSmCompId = 3, 94 HvPrimaryCallSmCompId = 3,
109 HvPrimaryCallSpdCompId = 4, 95 HvPrimaryCallSpdCompId = 4,
110 HvPrimaryCallXmCompId = 5, 96 HvPrimaryCallXmCompId = 5,
111 HvPrimaryCallRioCompId = 6, 97 HvPrimaryCallRioCompId = 6,
112 HvPrimaryCallRsvd7CompId = 7, 98 HvPrimaryCallRsvd7CompId = 7,
113 HvPrimaryCallRsvd6CompId = 8, 99 HvPrimaryCallRsvd6CompId = 8,
114 HvPrimaryCallRsvd5CompId = 9, 100 HvPrimaryCallRsvd5CompId = 9,
@@ -116,7 +102,7 @@ enum HvCallCompIds
116 HvPrimaryCallRsvd3CompId = 11, 102 HvPrimaryCallRsvd3CompId = 11,
117 HvPrimaryCallRsvd2CompId = 12, 103 HvPrimaryCallRsvd2CompId = 12,
118 HvPrimaryCallRsvd1CompId = 13, 104 HvPrimaryCallRsvd1CompId = 13,
119 HvPrimaryCallMaxCompId = HvCallMaxCompId 105 HvPrimaryCallMaxCompId = HvCallMaxCompId
120}; 106};
121 107
122struct HvLpBufferList { 108struct HvLpBufferList {
diff --git a/include/asm-ppc64/iSeries/IoHriMainStore.h b/include/asm-ppc64/iSeries/IoHriMainStore.h
index ff00e865f620..45ed3ea67d06 100644
--- a/include/asm-ppc64/iSeries/IoHriMainStore.h
+++ b/include/asm-ppc64/iSeries/IoHriMainStore.h
@@ -1,17 +1,17 @@
1/* 1/*
2 * IoHriMainStore.h 2 * IoHriMainStore.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation 3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -21,7 +21,7 @@
21#define _IOHRIMAINSTORE_H 21#define _IOHRIMAINSTORE_H
22 22
23/* Main Store Vpd for Condor,iStar,sStar */ 23/* Main Store Vpd for Condor,iStar,sStar */
24struct IoHriMainStoreSegment4 { 24struct IoHriMainStoreSegment4 {
25 u8 msArea0Exists:1; 25 u8 msArea0Exists:1;
26 u8 msArea1Exists:1; 26 u8 msArea1Exists:1;
27 u8 msArea2Exists:1; 27 u8 msArea2Exists:1;
@@ -51,7 +51,7 @@ struct IoHriMainStoreSegment4 {
51 u8 msArea1HasRiserVpd:1; 51 u8 msArea1HasRiserVpd:1;
52 u8 msArea2HasRiserVpd:1; 52 u8 msArea2HasRiserVpd:1;
53 u8 msArea3HasRiserVpd:1; 53 u8 msArea3HasRiserVpd:1;
54 u8 reserved5:4; 54 u8 reserved5:4;
55 u8 reserved6; 55 u8 reserved6;
56 u16 reserved7; 56 u16 reserved7;
57 57
@@ -82,8 +82,8 @@ struct IoHriMainStoreVpdFruData {
82}; 82};
83 83
84struct IoHriMainStoreAdrRangeBlock { 84struct IoHriMainStoreAdrRangeBlock {
85 void * blockStart __attribute((packed)); 85 void *blockStart __attribute((packed));
86 void * blockEnd __attribute((packed)); 86 void *blockEnd __attribute((packed));
87 u32 blockProcChipId __attribute((packed)); 87 u32 blockProcChipId __attribute((packed));
88}; 88};
89 89
@@ -102,7 +102,7 @@ struct IoHriMainStoreArea4 {
102 u32 procNodeId __attribute((packed)); 102 u32 procNodeId __attribute((packed));
103 103
104 u32 numAdrRangeBlocks __attribute((packed)); 104 u32 numAdrRangeBlocks __attribute((packed));
105 struct IoHriMainStoreAdrRangeBlock xAdrRangeBlock[MaxAreaAdrRangeBlocks] __attribute((packed)); 105 struct IoHriMainStoreAdrRangeBlock xAdrRangeBlock[MaxAreaAdrRangeBlocks] __attribute((packed));
106 106
107 struct IoHriMainStoreChipInfo1 chipInfo0 __attribute((packed)); 107 struct IoHriMainStoreChipInfo1 chipInfo0 __attribute((packed));
108 struct IoHriMainStoreChipInfo1 chipInfo1 __attribute((packed)); 108 struct IoHriMainStoreChipInfo1 chipInfo1 __attribute((packed));
@@ -113,17 +113,17 @@ struct IoHriMainStoreArea4 {
113 struct IoHriMainStoreChipInfo1 chipInfo6 __attribute((packed)); 113 struct IoHriMainStoreChipInfo1 chipInfo6 __attribute((packed));
114 struct IoHriMainStoreChipInfo1 chipInfo7 __attribute((packed)); 114 struct IoHriMainStoreChipInfo1 chipInfo7 __attribute((packed));
115 115
116 void * msRamAreaArray __attribute((packed)); 116 void *msRamAreaArray __attribute((packed));
117 u32 msRamAreaArrayNumEntries __attribute((packed)); 117 u32 msRamAreaArrayNumEntries __attribute((packed));
118 u32 msRamAreaArrayEntrySize __attribute((packed)); 118 u32 msRamAreaArrayEntrySize __attribute((packed));
119 119
120 u32 numaDimmExists __attribute((packed)); 120 u32 numaDimmExists __attribute((packed));
121 u32 numaDimmFunctional __attribute((packed)); 121 u32 numaDimmFunctional __attribute((packed));
122 void * numaDimmArray __attribute((packed)); 122 void *numaDimmArray __attribute((packed));
123 u32 numaDimmArrayNumEntries __attribute((packed)); 123 u32 numaDimmArrayNumEntries __attribute((packed));
124 u32 numaDimmArrayEntrySize __attribute((packed)); 124 u32 numaDimmArrayEntrySize __attribute((packed));
125 125
126 struct IoHriMainStoreVpdIdData idData __attribute((packed)); 126 struct IoHriMainStoreVpdIdData idData __attribute((packed));
127 127
128 u64 powerData __attribute((packed)); 128 u64 powerData __attribute((packed));
129 u64 cardAssemblyPartNum __attribute((packed)); 129 u64 cardAssemblyPartNum __attribute((packed));
@@ -143,7 +143,7 @@ struct IoHriMainStoreArea4 {
143}; 143};
144 144
145 145
146struct IoHriMainStoreSegment5 { 146struct IoHriMainStoreSegment5 {
147 u16 reserved1; 147 u16 reserved1;
148 u8 reserved2; 148 u8 reserved2;
149 u8 msVpdFormat; 149 u8 msVpdFormat;
@@ -151,17 +151,16 @@ struct IoHriMainStoreSegment5 {
151 u32 totalMainStore; 151 u32 totalMainStore;
152 u64 maxConfiguredMsAdr; 152 u64 maxConfiguredMsAdr;
153 153
154 struct IoHriMainStoreArea4* msAreaArray; 154 struct IoHriMainStoreArea4 *msAreaArray;
155 u32 msAreaArrayNumEntries; 155 u32 msAreaArrayNumEntries;
156 u32 msAreaArrayEntrySize; 156 u32 msAreaArrayEntrySize;
157 157
158 u32 msAreaExists; 158 u32 msAreaExists;
159 u32 msAreaFunctional; 159 u32 msAreaFunctional;
160 160
161 u64 reserved3; 161 u64 reserved3;
162}; 162};
163 163
164extern u64 xMsVpd[];
164 165
165 166#endif /* _IOHRIMAINSTORE_H */
166#endif // _IOHRIMAINSTORE_H
167
diff --git a/include/asm-ppc64/iSeries/IoHriProcessorVpd.h b/include/asm-ppc64/iSeries/IoHriProcessorVpd.h
index 965433888653..73b73d80b8b1 100644
--- a/include/asm-ppc64/iSeries/IoHriProcessorVpd.h
+++ b/include/asm-ppc64/iSeries/IoHriProcessorVpd.h
@@ -1,17 +1,17 @@
1/* 1/*
2 * IoHriProcessorVpd.h 2 * IoHriProcessorVpd.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation 3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -19,16 +19,12 @@
19#ifndef _IOHRIPROCESSORVPD_H 19#ifndef _IOHRIPROCESSORVPD_H
20#define _IOHRIPROCESSORVPD_H 20#define _IOHRIPROCESSORVPD_H
21 21
22//===================================================================
23//
24// This struct maps Processor Vpd that is DMAd to SLIC by CSP
25//
26
27#include <asm/types.h> 22#include <asm/types.h>
28 23
29struct IoHriProcessorVpd 24/*
30{ 25 * This struct maps Processor Vpd that is DMAd to SLIC by CSP
31 26 */
27struct IoHriProcessorVpd {
32 u8 xFormat; // VPD format indicator x00-x00 28 u8 xFormat; // VPD format indicator x00-x00
33 u8 xProcStatus:8; // Processor State x01-x01 29 u8 xProcStatus:8; // Processor State x01-x01
34 u8 xSecondaryThreadCount; // Secondary thread cnt x02-x02 30 u8 xSecondaryThreadCount; // Secondary thread cnt x02-x02
@@ -40,12 +36,12 @@ struct IoHriProcessorVpd
40 u16 xRsvd2; // Reserved x06-x07 36 u16 xRsvd2; // Reserved x06-x07
41 u32 xHwNodeId; // Hardware node id x08-x0B 37 u32 xHwNodeId; // Hardware node id x08-x0B
42 u32 xHwProcId; // Hardware processor id x0C-x0F 38 u32 xHwProcId; // Hardware processor id x0C-x0F
43 39
44 u32 xTypeNum; // Card Type/CCIN number x10-x13 40 u32 xTypeNum; // Card Type/CCIN number x10-x13
45 u32 xModelNum; // Model/Feature number x14-x17 41 u32 xModelNum; // Model/Feature number x14-x17
46 u64 xSerialNum; // Serial number x18-x1F 42 u64 xSerialNum; // Serial number x18-x1F
47 char xPartNum[12]; // Book Part or FPU number x20-x2B 43 char xPartNum[12]; // Book Part or FPU number x20-x2B
48 char xMfgID[4]; // Manufacturing ID x2C-x2F 44 char xMfgID[4]; // Manufacturing ID x2C-x2F
49 45
50 u32 xProcFreq; // Processor Frequency x30-x33 46 u32 xProcFreq; // Processor Frequency x30-x33
51 u32 xTimeBaseFreq; // Time Base Frequency x34-x37 47 u32 xTimeBaseFreq; // Time Base Frequency x34-x37
@@ -71,7 +67,7 @@ struct IoHriProcessorVpd
71 u32 xDataL3CacheSizeKB; // L3 data cache size in KB x80-x83 67 u32 xDataL3CacheSizeKB; // L3 data cache size in KB x80-x83
72 u32 xDataL3CacheLineSize; // L3 data cache block size x84-x87 68 u32 xDataL3CacheLineSize; // L3 data cache block size x84-x87
73 u64 xRsvd6; // Reserved x88-x8F 69 u64 xRsvd6; // Reserved x88-x8F
74 70
75 u64 xFruLabel; // Card Location Label x90-x97 71 u64 xFruLabel; // Card Location Label x90-x97
76 u8 xSlotsOnCard; // Slots on card (0=no slots) x98-x98 72 u8 xSlotsOnCard; // Slots on card (0=no slots) x98-x98
77 u8 xPartLocFlag; // Location flag (0-pluggable 1-imbedded) x99-x99 73 u8 xPartLocFlag; // Location flag (0-pluggable 1-imbedded) x99-x99
@@ -79,10 +75,12 @@ struct IoHriProcessorVpd
79 u8 xSmartCardPortNo; // Smart card port number x9C-x9C 75 u8 xSmartCardPortNo; // Smart card port number x9C-x9C
80 u8 xRsvd7; // Reserved x9D-x9D 76 u8 xRsvd7; // Reserved x9D-x9D
81 u16 xFrameIdAndRackUnit; // Frame ID and rack unit adr x9E-x9F 77 u16 xFrameIdAndRackUnit; // Frame ID and rack unit adr x9E-x9F
82 78
83 u8 xRsvd8[24]; // Reserved xA0-xB7 79 u8 xRsvd8[24]; // Reserved xA0-xB7
84 80
85 char xProcSrc[72]; // CSP format SRC xB8-xFF 81 char xProcSrc[72]; // CSP format SRC xB8-xFF
86}; 82};
87 83
84extern struct IoHriProcessorVpd xIoHriProcessorVpd[];
85
88#endif /* _IOHRIPROCESSORVPD_H */ 86#endif /* _IOHRIPROCESSORVPD_H */
diff --git a/include/asm-ppc64/iSeries/ItExtVpdPanel.h b/include/asm-ppc64/iSeries/ItExtVpdPanel.h
index dee6b1273031..4c546a8802b4 100644
--- a/include/asm-ppc64/iSeries/ItExtVpdPanel.h
+++ b/include/asm-ppc64/iSeries/ItExtVpdPanel.h
@@ -1,17 +1,17 @@
1/* 1/*
2 * ItExtVpdPanel.h 2 * ItExtVpdPanel.h
3 * Copyright (C) 2002 Dave Boutcher IBM Corporation 3 * Copyright (C) 2002 Dave Boutcher IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -20,39 +20,33 @@
20#define _ITEXTVPDPANEL_H 20#define _ITEXTVPDPANEL_H
21 21
22/* 22/*
23 * 23 * This struct maps the panel information
24 * This struct maps the panel information
25 * 24 *
26 * Warning: 25 * Warning:
27 * This data must match the architecture for the panel information 26 * This data must match the architecture for the panel information
28 *
29 */ 27 */
30 28
31
32/*-------------------------------------------------------------------
33 * Standard Includes
34 *-------------------------------------------------------------------
35*/
36#include <asm/types.h> 29#include <asm/types.h>
37 30
38struct ItExtVpdPanel 31struct ItExtVpdPanel {
39{ 32 /* Definition of the Extended Vpd On Panel Data Area */
40 // Definition of the Extended Vpd On Panel Data Area 33 char systemSerial[8];
41 char systemSerial[8]; 34 char mfgID[4];
42 char mfgID[4]; 35 char reserved1[24];
43 char reserved1[24]; 36 char machineType[4];
44 char machineType[4]; 37 char systemID[6];
45 char systemID[6]; 38 char somUniqueCnt[4];
46 char somUniqueCnt[4]; 39 char serialNumberCount;
47 char serialNumberCount; 40 char reserved2[7];
48 char reserved2[7]; 41 u16 bbu3;
49 u16 bbu3; 42 u16 bbu2;
50 u16 bbu2; 43 u16 bbu1;
51 u16 bbu1; 44 char xLocationLabel[8];
52 char xLocationLabel[8]; 45 u8 xRsvd1[6];
53 u8 xRsvd1[6]; 46 u16 xFrameId;
54 u16 xFrameId; 47 u8 xRsvd2[48];
55 u8 xRsvd2[48];
56}; 48};
57 49
58#endif /* _ITEXTVPDPANEL_H */ 50extern struct ItExtVpdPanel xItExtVpdPanel;
51
52#endif /* _ITEXTVPDPANEL_H */
diff --git a/include/asm-ppc64/iSeries/ItIplParmsReal.h b/include/asm-ppc64/iSeries/ItIplParmsReal.h
index 4d8b430ab12d..ae3417dc599e 100644
--- a/include/asm-ppc64/iSeries/ItIplParmsReal.h
+++ b/include/asm-ppc64/iSeries/ItIplParmsReal.h
@@ -1,17 +1,17 @@
1/* 1/*
2 * ItIplParmsReal.h 2 * ItIplParmsReal.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation 3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -19,58 +19,53 @@
19#ifndef _ITIPLPARMSREAL_H 19#ifndef _ITIPLPARMSREAL_H
20#define _ITIPLPARMSREAL_H 20#define _ITIPLPARMSREAL_H
21 21
22//============================================================================== 22/*
23// 23 * This struct maps the IPL Parameters DMA'd from the SP.
24// This struct maps the IPL Parameters DMA'd from the SP. 24 *
25// 25 * Warning:
26// Warning: 26 * This data must map in exactly 64 bytes and match the architecture for
27// This data must map in exactly 64 bytes and match the architecture for 27 * the IPL parms
28// the IPL parms 28 */
29//
30//=============================================================================
31
32 29
33//-------------------------------------------------------------------
34// Standard Includes
35//-------------------------------------------------------------------
36#include <asm/types.h> 30#include <asm/types.h>
37 31
38struct ItIplParmsReal 32struct ItIplParmsReal {
39{ 33 u8 xFormat; // Defines format of IplParms x00-x00
40 u8 xFormat; // Defines format of IplParms x00-x00 34 u8 xRsvd01:6; // Reserved x01-x01
41 u8 xRsvd01:6; // Reserved x01-x01 35 u8 xAlternateSearch:1; // Alternate search indicator ...
42 u8 xAlternateSearch:1; // Alternate search indicator ... 36 u8 xUaSupplied:1; // UA Supplied on programmed IPL...
43 u8 xUaSupplied:1; // UA Supplied on programmed IPL ... 37 u8 xLsUaFormat; // Format byte for UA x02-x02
44 u8 xLsUaFormat; // Format byte for UA x02-x02 38 u8 xRsvd02; // Reserved x03-x03
45 u8 xRsvd02; // Reserved x03-x03 39 u32 xLsUa; // LS UA x04-x07
46 u32 xLsUa; // LS UA x04-x07 40 u32 xUnusedLsLid; // First OS LID to load x08-x0B
47 u32 xUnusedLsLid; // First OS LID to load x08-x0B 41 u16 xLsBusNumber; // LS Bus Number x0C-x0D
48 u16 xLsBusNumber; // LS Bus Number x0C-x0D 42 u8 xLsCardAdr; // LS Card Address x0E-x0E
49 u8 xLsCardAdr; // LS Card Address x0E-x0E 43 u8 xLsBoardAdr; // LS Board Address x0F-x0F
50 u8 xLsBoardAdr; // LS Board Address x0F-x0F 44 u32 xRsvd03; // Reserved x10-x13
51 u32 xRsvd03; // Reserved x10-x13 45 u8 xSpcnPresent:1; // SPCN present x14-x14
52 u8 xSpcnPresent:1; // SPCN present x14-x14 46 u8 xCpmPresent:1; // CPM present ...
53 u8 xCpmPresent:1; // CPM present ... 47 u8 xRsvd04:6; // Reserved ...
54 u8 xRsvd04:6; // Reserved ... 48 u8 xRsvd05:4; // Reserved x15-x15
55 u8 xRsvd05:4; // Reserved x15-x15 49 u8 xKeyLock:4; // Keylock setting ...
56 u8 xKeyLock:4; // Keylock setting ... 50 u8 xRsvd06:6; // Reserved x16-x16
57 u8 xRsvd06:6; // Reserved x16-x16 51 u8 xIplMode:2; // Ipl mode (A|B|C|D) ...
58 u8 xIplMode:2; // Ipl mode (A|B|C|D) ... 52 u8 xHwIplType; // Fast v slow v slow EC HW IPL x17-x17
59 u8 xHwIplType; // Fast v slow v slow EC HW IPL x17-x17 53 u16 xCpmEnabledIpl:1; // CPM in effect when IPL initiatedx18-x19
60 u16 xCpmEnabledIpl:1; // CPM in effect when IPL initiated x18-x19 54 u16 xPowerOnResetIpl:1; // Indicate POR condition ...
61 u16 xPowerOnResetIpl:1; // Indicate POR condition ... 55 u16 xMainStorePreserved:1; // Main Storage is preserved ...
62 u16 xMainStorePreserved:1; // Main Storage is preserved ... 56 u16 xRsvd07:13; // Reserved ...
63 u16 xRsvd07:13; // Reserved ... 57 u16 xIplSource:16; // Ipl source x1A-x1B
64 u16 xIplSource:16; // Ipl source x1A-x1B 58 u8 xIplReason:8; // Reason for this IPL x1C-x1C
65 u8 xIplReason:8; // Reason for this IPL x1C-x1C 59 u8 xRsvd08; // Reserved x1D-x1D
66 u8 xRsvd08; // Reserved x1D-x1D 60 u16 xRsvd09; // Reserved x1E-x1F
67 u16 xRsvd09; // Reserved x1E-x1F 61 u16 xSysBoxType; // System Box Type x20-x21
68 u16 xSysBoxType; // System Box Type x20-x21 62 u16 xSysProcType; // System Processor Type x22-x23
69 u16 xSysProcType; // System Processor Type x22-x23 63 u32 xRsvd10; // Reserved x24-x27
70 u32 xRsvd10; // Reserved x24-x27 64 u64 xRsvd11; // Reserved x28-x2F
71 u64 xRsvd11; // Reserved x28-x2F 65 u64 xRsvd12; // Reserved x30-x37
72 u64 xRsvd12; // Reserved x30-x37 66 u64 xRsvd13; // Reserved x38-x3F
73 u64 xRsvd13; // Reserved x38-x3F
74}; 67};
75 68
69extern struct ItIplParmsReal xItIplParmsReal;
70
76#endif /* _ITIPLPARMSREAL_H */ 71#endif /* _ITIPLPARMSREAL_H */
diff --git a/include/asm-ppc64/iSeries/ItLpNaca.h b/include/asm-ppc64/iSeries/ItLpNaca.h
index 5baffddfae1b..225d0176779d 100644
--- a/include/asm-ppc64/iSeries/ItLpNaca.h
+++ b/include/asm-ppc64/iSeries/ItLpNaca.h
@@ -1,17 +1,17 @@
1/* 1/*
2 * ItLpNaca.h 2 * ItLpNaca.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation 3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -19,18 +19,15 @@
19#ifndef _ITLPNACA_H 19#ifndef _ITLPNACA_H
20#define _ITLPNACA_H 20#define _ITLPNACA_H
21 21
22//============================================================================= 22#include <linux/types.h>
23//
24// This control block contains the data that is shared between the
25// hypervisor (PLIC) and the OS.
26//
27//=============================================================================
28 23
29struct ItLpNaca 24/*
30{ 25 * This control block contains the data that is shared between the
31//============================================================================= 26 * hypervisor (PLIC) and the OS.
27 */
28
29struct ItLpNaca {
32// CACHE_LINE_1 0x0000 - 0x007F Contains read-only data 30// CACHE_LINE_1 0x0000 - 0x007F Contains read-only data
33//=============================================================================
34 u32 xDesc; // Eye catcher x00-x03 31 u32 xDesc; // Eye catcher x00-x03
35 u16 xSize; // Size of this class x04-x05 32 u16 xSize; // Size of this class x04-x05
36 u16 xIntHdlrOffset; // Offset to IntHdlr array x06-x07 33 u16 xIntHdlrOffset; // Offset to IntHdlr array x06-x07
@@ -59,30 +56,25 @@ struct ItLpNaca
59 u64 xLoadAreaAddr; // ER address of load area x28-x2F 56 u64 xLoadAreaAddr; // ER address of load area x28-x2F
60 u32 xLoadAreaChunks; // Chunks for the load area x30-x33 57 u32 xLoadAreaChunks; // Chunks for the load area x30-x33
61 u32 xPaseSysCallCRMask; // Mask used to test CR before x34-x37 58 u32 xPaseSysCallCRMask; // Mask used to test CR before x34-x37
62 // doing an ASR switch on PASE 59 // doing an ASR switch on PASE
63 // system call. 60 // system call.
64 u64 xSlicSegmentTablePtr; // Pointer to Slic seg table. x38-x3f 61 u64 xSlicSegmentTablePtr; // Pointer to Slic seg table. x38-x3f
65 u8 xRsvd1_4[64]; // x40-x7F 62 u8 xRsvd1_4[64]; // x40-x7F
66 63
67//=============================================================================
68// CACHE_LINE_2 0x0080 - 0x00FF Contains local read-write data 64// CACHE_LINE_2 0x0080 - 0x00FF Contains local read-write data
69//=============================================================================
70 u8 xRsvd2_0[128]; // Reserved x00-x7F 65 u8 xRsvd2_0[128]; // Reserved x00-x7F
71 66
72//=============================================================================
73// CACHE_LINE_3-6 0x0100 - 0x02FF Contains LP Queue indicators 67// CACHE_LINE_3-6 0x0100 - 0x02FF Contains LP Queue indicators
74// NB: Padding required to keep xInterrruptHdlr at x300 which is required 68// NB: Padding required to keep xInterrruptHdlr at x300 which is required
75// for v4r4 PLIC. 69// for v4r4 PLIC.
76//=============================================================================
77 u8 xOldLpQueue[128]; // LP Queue needed for v4r4 100-17F 70 u8 xOldLpQueue[128]; // LP Queue needed for v4r4 100-17F
78 u8 xRsvd3_0[384]; // Reserved 180-2FF 71 u8 xRsvd3_0[384]; // Reserved 180-2FF
79//============================================================================= 72
80// CACHE_LINE_7-8 0x0300 - 0x03FF Contains the address of the OS interrupt 73// CACHE_LINE_7-8 0x0300 - 0x03FF Contains the address of the OS interrupt
81// handlers 74// handlers
82//=============================================================================
83 u64 xInterruptHdlr[32]; // Interrupt handlers 300-x3FF 75 u64 xInterruptHdlr[32]; // Interrupt handlers 300-x3FF
84}; 76};
85 77
86//============================================================================= 78extern struct ItLpNaca itLpNaca;
87 79
88#endif /* _ITLPNACA_H */ 80#endif /* _ITLPNACA_H */
diff --git a/include/asm-ppc64/iSeries/ItLpQueue.h b/include/asm-ppc64/iSeries/ItLpQueue.h
index 4f4dde2a638d..393299e04d7f 100644
--- a/include/asm-ppc64/iSeries/ItLpQueue.h
+++ b/include/asm-ppc64/iSeries/ItLpQueue.h
@@ -1,17 +1,17 @@
1/* 1/*
2 * ItLpQueue.h 2 * ItLpQueue.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation 3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -19,54 +19,54 @@
19#ifndef _ITLPQUEUE_H 19#ifndef _ITLPQUEUE_H
20#define _ITLPQUEUE_H 20#define _ITLPQUEUE_H
21 21
22//============================================================================= 22/*
23// 23 * This control block defines the simple LP queue structure that is
24// This control block defines the simple LP queue structure that is 24 * shared between the hypervisor (PLIC) and the OS in order to send
25// shared between the hypervisor (PLIC) and the OS in order to send 25 * events to an LP.
26// events to an LP. 26 */
27//
28 27
29#include <asm/types.h> 28#include <asm/types.h>
30#include <asm/ptrace.h> 29#include <asm/ptrace.h>
31 30
32struct HvLpEvent; 31struct HvLpEvent;
33 32
34#define ITMaxLpQueues 8 33#define ITMaxLpQueues 8
35 34
36#define NotUsed 0 // Queue will not be used by PLIC 35#define NotUsed 0 // Queue will not be used by PLIC
37#define DedicatedIo 1 // Queue dedicated to IO processor specified 36#define DedicatedIo 1 // Queue dedicated to IO processor specified
38#define DedicatedLp 2 // Queue dedicated to LP specified 37#define DedicatedLp 2 // Queue dedicated to LP specified
39#define Shared 3 // Queue shared for both IO and LP 38#define Shared 3 // Queue shared for both IO and LP
40 39
41#define LpEventStackSize 4096 40#define LpEventStackSize 4096
42#define LpEventMaxSize 256 41#define LpEventMaxSize 256
43#define LpEventAlign 64 42#define LpEventAlign 64
44 43
45struct ItLpQueue 44struct ItLpQueue {
46{ 45/*
47// 46 * The xSlicCurEventPtr is the pointer to the next event stack entry
48// The xSlicCurEventPtr is the pointer to the next event stack entry that will 47 * that will become valid. The OS must peek at this entry to determine
49// become valid. The OS must peek at this entry to determine if it is valid. 48 * if it is valid. PLIC will set the valid indicator as the very last
50// PLIC will set the valid indicator as the very last store into that entry. 49 * store into that entry.
51// 50 *
52// When the OS has completed processing of the event then it will mark the event 51 * When the OS has completed processing of the event then it will mark
53// as invalid so that PLIC knows it can store into that event location again. 52 * the event as invalid so that PLIC knows it can store into that event
54// 53 * location again.
55// If the event stack fills and there are overflow events, then PLIC will set 54 *
56// the xPlicOverflowIntPending flag in which case the OS will have to fetch the 55 * If the event stack fills and there are overflow events, then PLIC
57// additional LP events once they have drained the event stack. 56 * will set the xPlicOverflowIntPending flag in which case the OS will
58// 57 * have to fetch the additional LP events once they have drained the
59// The first 16-bytes are known by both the OS and PLIC. The remainder of the 58 * event stack.
60// cache line is for use by the OS. 59 *
61// 60 * The first 16-bytes are known by both the OS and PLIC. The remainder
62//============================================================================= 61 * of the cache line is for use by the OS.
62 */
63 u8 xPlicOverflowIntPending;// 0x00 Overflow events are pending 63 u8 xPlicOverflowIntPending;// 0x00 Overflow events are pending
64 u8 xPlicStatus; // 0x01 DedicatedIo or DedicatedLp or NotUsed 64 u8 xPlicStatus; // 0x01 DedicatedIo or DedicatedLp or NotUsed
65 u16 xSlicLogicalProcIndex; // 0x02 Logical Proc Index for correlation 65 u16 xSlicLogicalProcIndex; // 0x02 Logical Proc Index for correlation
66 u8 xPlicRsvd[12]; // 0x04 66 u8 xPlicRsvd[12]; // 0x04
67 char* xSlicCurEventPtr; // 0x10 67 char *xSlicCurEventPtr; // 0x10
68 char* xSlicLastValidEventPtr; // 0x18 68 char *xSlicLastValidEventPtr; // 0x18
69 char* xSlicEventStackPtr; // 0x20 69 char *xSlicEventStackPtr; // 0x20
70 u8 xIndex; // 0x28 unique sequential index. 70 u8 xIndex; // 0x28 unique sequential index.
71 u8 xSlicRsvd[3]; // 0x29-2b 71 u8 xSlicRsvd[3]; // 0x29-2b
72 u32 xInUseWord; // 0x2C 72 u32 xInUseWord; // 0x2C
@@ -76,17 +76,9 @@ struct ItLpQueue
76 76
77extern struct ItLpQueue xItLpQueue; 77extern struct ItLpQueue xItLpQueue;
78 78
79extern struct HvLpEvent * ItLpQueue_getNextLpEvent( struct ItLpQueue * ); 79extern struct HvLpEvent *ItLpQueue_getNextLpEvent(struct ItLpQueue *);
80extern int ItLpQueue_isLpIntPending( struct ItLpQueue * ); 80extern int ItLpQueue_isLpIntPending(struct ItLpQueue *);
81extern unsigned ItLpQueue_process( struct ItLpQueue *, struct pt_regs * ); 81extern unsigned ItLpQueue_process(struct ItLpQueue *, struct pt_regs *);
82extern void ItLpQueue_clearValid( struct HvLpEvent * ); 82extern void ItLpQueue_clearValid(struct HvLpEvent *);
83
84static __inline__ void process_iSeries_events( void )
85{
86 __asm__ __volatile__ (
87 " li 0,0x5555 \n\
88 sc"
89 : : : "r0", "r3" );
90}
91 83
92#endif /* _ITLPQUEUE_H */ 84#endif /* _ITLPQUEUE_H */
diff --git a/include/asm-ppc64/iSeries/ItLpRegSave.h b/include/asm-ppc64/iSeries/ItLpRegSave.h
index dafc4c813788..1b3087e76205 100644
--- a/include/asm-ppc64/iSeries/ItLpRegSave.h
+++ b/include/asm-ppc64/iSeries/ItLpRegSave.h
@@ -1,17 +1,17 @@
1/* 1/*
2 * ItLpRegSave.h 2 * ItLpRegSave.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation 3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -19,33 +19,30 @@
19#ifndef _ITLPREGSAVE_H 19#ifndef _ITLPREGSAVE_H
20#define _ITLPREGSAVE_H 20#define _ITLPREGSAVE_H
21 21
22//===================================================================================== 22/*
23// 23 * This control block contains the data that is shared between PLIC
24// This control block contains the data that is shared between PLIC 24 * and the OS
25// and the OS 25 */
26//
27//
28 26
29struct ItLpRegSave 27struct ItLpRegSave {
30{
31 u32 xDesc; // Eye catcher "LpRS" ebcdic 000-003 28 u32 xDesc; // Eye catcher "LpRS" ebcdic 000-003
32 u16 xSize; // Size of this class 004-005 29 u16 xSize; // Size of this class 004-005
33 u8 xInUse; // Area is live 006-007 30 u8 xInUse; // Area is live 006-007
34 u8 xRsvd1[9]; // Reserved 007-00F 31 u8 xRsvd1[9]; // Reserved 007-00F
35 32
36 u8 xFixedRegSave[352]; // Fixed Register Save Area 010-16F 33 u8 xFixedRegSave[352]; // Fixed Register Save Area 010-16F
37 u32 xCTRL; // Control Register 170-173 34 u32 xCTRL; // Control Register 170-173
38 u32 xDEC; // Decrementer 174-177 35 u32 xDEC; // Decrementer 174-177
39 u32 xFPSCR; // FP Status and Control Reg 178-17B 36 u32 xFPSCR; // FP Status and Control Reg 178-17B
40 u32 xPVR; // Processor Version Number 17C-17F 37 u32 xPVR; // Processor Version Number 17C-17F
41 38
42 u64 xMMCR0; // Monitor Mode Control Reg 0 180-187 39 u64 xMMCR0; // Monitor Mode Control Reg 0 180-187
43 u32 xPMC1; // Perf Monitor Counter 1 188-18B 40 u32 xPMC1; // Perf Monitor Counter 1 188-18B
44 u32 xPMC2; // Perf Monitor Counter 2 18C-18F 41 u32 xPMC2; // Perf Monitor Counter 2 18C-18F
45 u32 xPMC3; // Perf Monitor Counter 3 190-193 42 u32 xPMC3; // Perf Monitor Counter 3 190-193
46 u32 xPMC4; // Perf Monitor Counter 4 194-197 43 u32 xPMC4; // Perf Monitor Counter 4 194-197
47 u32 xPIR; // Processor ID Reg 198-19B 44 u32 xPIR; // Processor ID Reg 198-19B
48 45
49 u32 xMMCR1; // Monitor Mode Control Reg 1 19C-19F 46 u32 xMMCR1; // Monitor Mode Control Reg 1 19C-19F
50 u32 xMMCRA; // Monitor Mode Control Reg A 1A0-1A3 47 u32 xMMCRA; // Monitor Mode Control Reg A 1A0-1A3
51 u32 xPMC5; // Perf Monitor Counter 5 1A4-1A7 48 u32 xPMC5; // Perf Monitor Counter 5 1A4-1A7
@@ -57,17 +54,17 @@ struct ItLpRegSave
57 u32 xRsvd; // Reserved 1BC-1BF 54 u32 xRsvd; // Reserved 1BC-1BF
58 55
59 u64 xACCR; // Address Compare Control Reg 1C0-1C7 56 u64 xACCR; // Address Compare Control Reg 1C0-1C7
60 u64 xIMR; // Instruction Match Register 1C8-1CF 57 u64 xIMR; // Instruction Match Register 1C8-1CF
61 u64 xSDR1; // Storage Description Reg 1 1D0-1D7 58 u64 xSDR1; // Storage Description Reg 1 1D0-1D7
62 u64 xSPRG0; // Special Purpose Reg General0 1D8-1DF 59 u64 xSPRG0; // Special Purpose Reg General0 1D8-1DF
63 u64 xSPRG1; // Special Purpose Reg General1 1E0-1E7 60 u64 xSPRG1; // Special Purpose Reg General1 1E0-1E7
64 u64 xSPRG2; // Special Purpose Reg General2 1E8-1EF 61 u64 xSPRG2; // Special Purpose Reg General2 1E8-1EF
65 u64 xSPRG3; // Special Purpose Reg General3 1F0-1F7 62 u64 xSPRG3; // Special Purpose Reg General3 1F0-1F7
66 u64 xTB; // Time Base Register 1F8-1FF 63 u64 xTB; // Time Base Register 1F8-1FF
67 64
68 u64 xFPR[32]; // Floating Point Registers 200-2FF 65 u64 xFPR[32]; // Floating Point Registers 200-2FF
69 66
70 u64 xMSR; // Machine State Register 300-307 67 u64 xMSR; // Machine State Register 300-307
71 u64 xNIA; // Next Instruction Address 308-30F 68 u64 xNIA; // Next Instruction Address 308-30F
72 69
73 u64 xDABR; // Data Address Breakpoint Reg 310-317 70 u64 xDABR; // Data Address Breakpoint Reg 310-317
@@ -76,8 +73,8 @@ struct ItLpRegSave
76 u64 xHID0; // HW Implementation Dependent0 320-327 73 u64 xHID0; // HW Implementation Dependent0 320-327
77 74
78 u64 xHID4; // HW Implementation Dependent4 328-32F 75 u64 xHID4; // HW Implementation Dependent4 328-32F
79 u64 xSCOMd; // SCON Data Reg (SPRG4) 330-337 76 u64 xSCOMd; // SCON Data Reg (SPRG4) 330-337
80 u64 xSCOMc; // SCON Command Reg (SPRG5) 338-33F 77 u64 xSCOMc; // SCON Command Reg (SPRG5) 338-33F
81 u64 xSDAR; // Sample Data Address Register 340-347 78 u64 xSDAR; // Sample Data Address Register 340-347
82 u64 xSIAR; // Sample Inst Address Register 348-34F 79 u64 xSIAR; // Sample Inst Address Register 348-34F
83 80
diff --git a/include/asm-ppc64/iSeries/ItSpCommArea.h b/include/asm-ppc64/iSeries/ItSpCommArea.h
index f1b56f9e11e2..5535f8271c9f 100644
--- a/include/asm-ppc64/iSeries/ItSpCommArea.h
+++ b/include/asm-ppc64/iSeries/ItSpCommArea.h
@@ -1,29 +1,27 @@
1/* 1/*
2 * ItSpCommArea.h 2 * ItSpCommArea.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation 3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */ 18 */
19 19
20
21#ifndef _ITSPCOMMAREA_H 20#ifndef _ITSPCOMMAREA_H
22#define _ITSPCOMMAREA_H 21#define _ITSPCOMMAREA_H
23 22
24 23
25struct SpCommArea 24struct SpCommArea {
26{
27 u32 xDesc; // Descriptor (only in new formats) 000-003 25 u32 xDesc; // Descriptor (only in new formats) 000-003
28 u8 xFormat; // Format (only in new formats) 004-004 26 u8 xFormat; // Format (only in new formats) 004-004
29 u8 xRsvd1[11]; // Reserved 005-00F 27 u8 xRsvd1[11]; // Reserved 005-00F
diff --git a/include/asm-ppc64/iSeries/ItVpdAreas.h b/include/asm-ppc64/iSeries/ItVpdAreas.h
index d120439f30a5..71b3ad24f95a 100644
--- a/include/asm-ppc64/iSeries/ItVpdAreas.h
+++ b/include/asm-ppc64/iSeries/ItVpdAreas.h
@@ -1,17 +1,17 @@
1/* 1/*
2 * ItVpdAreas.h 2 * ItVpdAreas.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation 3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -19,78 +19,71 @@
19#ifndef _ITVPDAREAS_H 19#ifndef _ITVPDAREAS_H
20#define _ITVPDAREAS_H 20#define _ITVPDAREAS_H
21 21
22//===================================================================================== 22/*
23// 23 * This file defines the address and length of all of the VPD area passed to
24// This file defines the address and length of all of the VPD area passed to 24 * the OS from PLIC (most of which start from the SP).
25// the OS from PLIC (most of which start from the SP). 25 */
26//
27 26
28#include <asm/types.h> 27#include <asm/types.h>
29 28
30// VPD Entry index is carved in stone - cannot be changed (easily). 29/* VPD Entry index is carved in stone - cannot be changed (easily). */
31#define ItVpdCecVpd 0 30#define ItVpdCecVpd 0
32#define ItVpdDynamicSpace 1 31#define ItVpdDynamicSpace 1
33#define ItVpdExtVpd 2 32#define ItVpdExtVpd 2
34#define ItVpdExtVpdOnPanel 3 33#define ItVpdExtVpdOnPanel 3
35#define ItVpdFirstPaca 4 34#define ItVpdFirstPaca 4
36#define ItVpdIoVpd 5 35#define ItVpdIoVpd 5
37#define ItVpdIplParms 6 36#define ItVpdIplParms 6
38#define ItVpdMsVpd 7 37#define ItVpdMsVpd 7
39#define ItVpdPanelVpd 8 38#define ItVpdPanelVpd 8
40#define ItVpdLpNaca 9 39#define ItVpdLpNaca 9
41#define ItVpdBackplaneAndMaybeClockCardVpd 10 40#define ItVpdBackplaneAndMaybeClockCardVpd 10
42#define ItVpdRecoveryLogBuffer 11 41#define ItVpdRecoveryLogBuffer 11
43#define ItVpdSpCommArea 12 42#define ItVpdSpCommArea 12
44#define ItVpdSpLogBuffer 13 43#define ItVpdSpLogBuffer 13
45#define ItVpdSpLogBufferSave 14 44#define ItVpdSpLogBufferSave 14
46#define ItVpdSpCardVpd 15 45#define ItVpdSpCardVpd 15
47#define ItVpdFirstProcVpd 16 46#define ItVpdFirstProcVpd 16
48#define ItVpdApModelVpd 17 47#define ItVpdApModelVpd 17
49#define ItVpdClockCardVpd 18 48#define ItVpdClockCardVpd 18
50#define ItVpdBusExtCardVpd 19 49#define ItVpdBusExtCardVpd 19
51#define ItVpdProcCapacityVpd 20 50#define ItVpdProcCapacityVpd 20
52#define ItVpdInteractiveCapacityVpd 21 51#define ItVpdInteractiveCapacityVpd 21
53#define ItVpdFirstSlotLabel 22 52#define ItVpdFirstSlotLabel 22
54#define ItVpdFirstLpQueue 23 53#define ItVpdFirstLpQueue 23
55#define ItVpdFirstL3CacheVpd 24 54#define ItVpdFirstL3CacheVpd 24
56#define ItVpdFirstProcFruVpd 25 55#define ItVpdFirstProcFruVpd 25
57
58#define ItVpdMaxEntries 26
59 56
57#define ItVpdMaxEntries 26
60 58
61#define ItDmaMaxEntries 10 59#define ItDmaMaxEntries 10
62 60
63#define ItVpdAreasMaxSlotLabels 192 61#define ItVpdAreasMaxSlotLabels 192
64 62
65 63
66struct SlicVpdAdrs { 64struct ItVpdAreas {
67 u32 pad1; 65 u32 xSlicDesc; // Descriptor 000-003
68 void * vpdAddr; 66 u16 xSlicSize; // Size of this control block 004-005
67 u16 xPlicAdjustVpdLens:1; // Flag to indicate new interface006-007
68 u16 xRsvd1:15; // Reserved bits ...
69 u16 xSlicVpdEntries; // Number of VPD entries 008-009
70 u16 xSlicDmaEntries; // Number of DMA entries 00A-00B
71 u16 xSlicMaxLogicalProcs; // Maximum logical processors 00C-00D
72 u16 xSlicMaxPhysicalProcs; // Maximum physical processors 00E-00F
73 u16 xSlicDmaToksOffset; // Offset into this of array 010-011
74 u16 xSlicVpdAdrsOffset; // Offset into this of array 012-013
75 u16 xSlicDmaLensOffset; // Offset into this of array 014-015
76 u16 xSlicVpdLensOffset; // Offset into this of array 016-017
77 u16 xSlicMaxSlotLabels; // Maximum number of slot labels018-019
78 u16 xSlicMaxLpQueues; // Maximum number of LP Queues 01A-01B
79 u8 xRsvd2[4]; // Reserved 01C-01F
80 u64 xRsvd3[12]; // Reserved 020-07F
81 u32 xPlicDmaLens[ItDmaMaxEntries];// Array of DMA lengths 080-0A7
82 u32 xPlicDmaToks[ItDmaMaxEntries];// Array of DMA tokens 0A8-0CF
83 u32 xSlicVpdLens[ItVpdMaxEntries];// Array of VPD lengths 0D0-12F
84 void *xSlicVpdAdrs[ItVpdMaxEntries];// Array of VPD buffers 130-1EF
69}; 85};
70 86
71 87extern struct ItVpdAreas itVpdAreas;
72struct ItVpdAreas
73{
74 u32 xSlicDesc; // Descriptor 000-003
75 u16 xSlicSize; // Size of this control block 004-005
76 u16 xPlicAdjustVpdLens:1; // Flag to indicate new interface 006-007
77 u16 xRsvd1:15; // Reserved bits ...
78 u16 xSlicVpdEntries; // Number of VPD entries 008-009
79 u16 xSlicDmaEntries; // Number of DMA entries 00A-00B
80 u16 xSlicMaxLogicalProcs; // Maximum logical processors 00C-00D
81 u16 xSlicMaxPhysicalProcs; // Maximum physical processors 00E-00F
82 u16 xSlicDmaToksOffset; // Offset into this of array 010-011
83 u16 xSlicVpdAdrsOffset; // Offset into this of array 012-013
84 u16 xSlicDmaLensOffset; // Offset into this of array 014-015
85 u16 xSlicVpdLensOffset; // Offset into this of array 016-017
86 u16 xSlicMaxSlotLabels; // Maximum number of slot labels 018-019
87 u16 xSlicMaxLpQueues; // Maximum number of LP Queues 01A-01B
88 u8 xRsvd2[4]; // Reserved 01C-01F
89 u64 xRsvd3[12]; // Reserved 020-07F
90 u32 xPlicDmaLens[ItDmaMaxEntries];// Array of DMA lengths 080-0A7
91 u32 xPlicDmaToks[ItDmaMaxEntries];// Array of DMA tokens 0A8-0CF
92 u32 xSlicVpdLens[ItVpdMaxEntries];// Array of VPD lengths 0D0-12F
93 void * xSlicVpdAdrs[ItVpdMaxEntries];// Array of VPD buffers 130-1EF
94};
95 88
96#endif /* _ITVPDAREAS_H */ 89#endif /* _ITVPDAREAS_H */
diff --git a/include/asm-ppc64/iSeries/LparData.h b/include/asm-ppc64/iSeries/LparData.h
deleted file mode 100644
index e54f3b686e58..000000000000
--- a/include/asm-ppc64/iSeries/LparData.h
+++ /dev/null
@@ -1,49 +0,0 @@
1/*
2 * LparData.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef _LPARDATA_H
21#define _LPARDATA_H
22
23#include <asm/types.h>
24#include <asm/page.h>
25#include <asm/abs_addr.h>
26
27#include <asm/iSeries/ItLpNaca.h>
28#include <asm/iSeries/ItLpRegSave.h>
29#include <asm/iSeries/HvReleaseData.h>
30#include <asm/iSeries/LparMap.h>
31#include <asm/iSeries/ItVpdAreas.h>
32#include <asm/iSeries/ItIplParmsReal.h>
33#include <asm/iSeries/ItExtVpdPanel.h>
34#include <asm/iSeries/ItLpQueue.h>
35#include <asm/iSeries/IoHriProcessorVpd.h>
36
37extern struct LparMap xLparMap;
38extern struct HvReleaseData hvReleaseData;
39extern struct ItLpNaca itLpNaca;
40extern struct ItIplParmsReal xItIplParmsReal;
41extern struct ItExtVpdPanel xItExtVpdPanel;
42extern struct IoHriProcessorVpd xIoHriProcessorVpd[];
43extern struct ItLpQueue xItLpQueue;
44extern struct ItVpdAreas itVpdAreas;
45extern u64 xMsVpd[];
46extern struct msChunks msChunks;
47
48
49#endif /* _LPARDATA_H */
diff --git a/include/asm-ppc64/iSeries/LparMap.h b/include/asm-ppc64/iSeries/LparMap.h
index 075205bb0f4a..038e5df7e9f8 100644
--- a/include/asm-ppc64/iSeries/LparMap.h
+++ b/include/asm-ppc64/iSeries/LparMap.h
@@ -1,17 +1,17 @@
1/* 1/*
2 * LparMap.h 2 * LparMap.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation 3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -21,13 +21,14 @@
21 21
22#include <asm/types.h> 22#include <asm/types.h>
23 23
24/* The iSeries hypervisor will set up mapping for one or more 24/*
25 * The iSeries hypervisor will set up mapping for one or more
25 * ESID/VSID pairs (in SLB/segment registers) and will set up 26 * ESID/VSID pairs (in SLB/segment registers) and will set up
26 * mappings of one or more ranges of pages to VAs. 27 * mappings of one or more ranges of pages to VAs.
27 * We will have the hypervisor set up the ESID->VSID mapping 28 * We will have the hypervisor set up the ESID->VSID mapping
28 * for the four kernel segments (C-F). With shared processors, 29 * for the four kernel segments (C-F). With shared processors,
29 * the hypervisor will clear all segment registers and reload 30 * the hypervisor will clear all segment registers and reload
30 * these four whenever the processor is switched from one 31 * these four whenever the processor is switched from one
31 * partition to another. 32 * partition to another.
32 */ 33 */
33 34
@@ -38,30 +39,31 @@
38 * need to be located within the load area (if the total partition size 39 * need to be located within the load area (if the total partition size
39 * is 64 MB), but cannot be mapped. Typically, this should specify 40 * is 64 MB), but cannot be mapped. Typically, this should specify
40 * to map half (32 MB) of the load area. 41 * to map half (32 MB) of the load area.
41 * 42 *
42 * The hypervisor will set up page table entries for the number of 43 * The hypervisor will set up page table entries for the number of
43 * pages specified. 44 * pages specified.
44 * 45 *
45 * In 32-bit mode, the hypervisor will load all four of the 46 * In 32-bit mode, the hypervisor will load all four of the
46 * segment registers (identified by the low-order four bits of the 47 * segment registers (identified by the low-order four bits of the
47 * Esid field. In 64-bit mode, the hypervisor will load one SLB 48 * Esid field. In 64-bit mode, the hypervisor will load one SLB
48 * entry to map the Esid to the Vsid. 49 * entry to map the Esid to the Vsid.
49*/ 50*/
50 51
51// Hypervisor initially maps 32MB of the load area 52/* Hypervisor initially maps 32MB of the load area */
52#define HvPagesToMap 8192 53#define HvPagesToMap 8192
53 54
54struct LparMap 55struct LparMap {
55{ 56 u64 xNumberEsids; // Number of ESID/VSID pairs (1)
56 u64 xNumberEsids; // Number of ESID/VSID pairs (1) 57 u64 xNumberRanges; // Number of VA ranges to map (1)
57 u64 xNumberRanges; // Number of VA ranges to map (1) 58 u64 xSegmentTableOffs; // Page number within load area of seg table (0)
58 u64 xSegmentTableOffs; // Page number within load area of seg table (0) 59 u64 xRsvd[5];
59 u64 xRsvd[5]; // Reserved (0) 60 u64 xKernelEsid; // Esid used to map kernel load (0x0C00000000)
60 u64 xKernelEsid; // Esid used to map kernel load (0x0C00000000) 61 u64 xKernelVsid; // Vsid used to map kernel load (0x0C00000000)
61 u64 xKernelVsid; // Vsid used to map kernel load (0x0C00000000) 62 u64 xPages; // Number of pages to be mapped (8192)
62 u64 xPages; // Number of pages to be mapped (8192) 63 u64 xOffset; // Offset from start of load area (0)
63 u64 xOffset; // Offset from start of load area (0) 64 u64 xVPN; // Virtual Page Number (0x000C000000000000)
64 u64 xVPN; // Virtual Page Number (0x000C000000000000)
65}; 65};
66 66
67extern struct LparMap xLparMap;
68
67#endif /* _LPARMAP_H */ 69#endif /* _LPARMAP_H */
diff --git a/include/asm-ppc64/iSeries/XmPciLpEvent.h b/include/asm-ppc64/iSeries/XmPciLpEvent.h
deleted file mode 100644
index a3d27f116e49..000000000000
--- a/include/asm-ppc64/iSeries/XmPciLpEvent.h
+++ /dev/null
@@ -1,18 +0,0 @@
1
2#ifndef __XMPCILPEVENT_H__
3#define __XMPCILPEVENT_H__
4
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10int XmPciLpEvent_init(void);
11void ppc_irq_dispatch_handler(struct pt_regs *regs, int irq);
12
13
14#ifdef __cplusplus
15}
16#endif
17
18#endif /* __XMPCILPEVENT_H__ */
diff --git a/include/asm-ppc64/iSeries/iSeries_io.h b/include/asm-ppc64/iSeries/iSeries_io.h
index f52b7599b372..9f79413342b3 100644
--- a/include/asm-ppc64/iSeries/iSeries_io.h
+++ b/include/asm-ppc64/iSeries/iSeries_io.h
@@ -5,32 +5,33 @@
5 5
6#ifdef CONFIG_PPC_ISERIES 6#ifdef CONFIG_PPC_ISERIES
7#include <linux/types.h> 7#include <linux/types.h>
8/************************************************************************/ 8/*
9/* File iSeries_io.h created by Allan Trautman on Thu Dec 28 2000. */ 9 * File iSeries_io.h created by Allan Trautman on Thu Dec 28 2000.
10/************************************************************************/ 10 *
11/* Remaps the io.h for the iSeries Io */ 11 * Remaps the io.h for the iSeries Io
12/* Copyright (C) 20yy Allan H Trautman, IBM Corporation */ 12 * Copyright (C) 2000 Allan H Trautman, IBM Corporation
13/* */ 13 *
14/* This program is free software; you can redistribute it and/or modify */ 14 * This program is free software; you can redistribute it and/or modify
15/* it under the terms of the GNU General Public License as published by */ 15 * it under the terms of the GNU General Public License as published by
16/* the Free Software Foundation; either version 2 of the License, or */ 16 * the Free Software Foundation; either version 2 of the License, or
17/* (at your option) any later version. */ 17 * (at your option) any later version.
18/* */ 18 *
19/* This program is distributed in the hope that it will be useful, */ 19 * This program is distributed in the hope that it will be useful,
20/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22/* GNU General Public License for more details. */ 22 * GNU General Public License for more details.
23/* */ 23 *
24/* You should have received a copy of the GNU General Public License */ 24 * You should have received a copy of the GNU General Public License
25/* along with this program; if not, write to the: */ 25 * along with this program; if not, write to the:
26/* Free Software Foundation, Inc., */ 26 * Free Software Foundation, Inc.,
27/* 59 Temple Place, Suite 330, */ 27 * 59 Temple Place, Suite 330,
28/* Boston, MA 02111-1307 USA */ 28 * Boston, MA 02111-1307 USA
29/************************************************************************/ 29 *
30/* Change Activity: */ 30 * Change Activity:
31/* Created December 28, 2000 */ 31 * Created December 28, 2000
32/* End Change Activity */ 32 * End Change Activity
33/************************************************************************/ 33 */
34
34extern u8 iSeries_Read_Byte(const volatile void __iomem * IoAddress); 35extern u8 iSeries_Read_Byte(const volatile void __iomem * IoAddress);
35extern u16 iSeries_Read_Word(const volatile void __iomem * IoAddress); 36extern u16 iSeries_Read_Word(const volatile void __iomem * IoAddress);
36extern u32 iSeries_Read_Long(const volatile void __iomem * IoAddress); 37extern u32 iSeries_Read_Long(const volatile void __iomem * IoAddress);
@@ -39,8 +40,10 @@ extern void iSeries_Write_Word(u16 IoData, volatile void __iomem * IoAddress);
39extern void iSeries_Write_Long(u32 IoData, volatile void __iomem * IoAddress); 40extern void iSeries_Write_Long(u32 IoData, volatile void __iomem * IoAddress);
40 41
41extern void iSeries_memset_io(volatile void __iomem *dest, char x, size_t n); 42extern void iSeries_memset_io(volatile void __iomem *dest, char x, size_t n);
42extern void iSeries_memcpy_toio(volatile void __iomem *dest, void *source, size_t n); 43extern void iSeries_memcpy_toio(volatile void __iomem *dest, void *source,
43extern void iSeries_memcpy_fromio(void *dest, const volatile void __iomem *source, size_t n); 44 size_t n);
45extern void iSeries_memcpy_fromio(void *dest,
46 const volatile void __iomem *source, size_t n);
44 47
45#endif /* CONFIG_PPC_ISERIES */ 48#endif /* CONFIG_PPC_ISERIES */
46#endif /* _ISERIES_IO_H */ 49#endif /* _ISERIES_IO_H */
diff --git a/include/asm-ppc64/iSeries/iSeries_irq.h b/include/asm-ppc64/iSeries/iSeries_irq.h
index ff8ddede038c..6c9767ac1302 100644
--- a/include/asm-ppc64/iSeries/iSeries_irq.h
+++ b/include/asm-ppc64/iSeries/iSeries_irq.h
@@ -1,19 +1,8 @@
1#ifndef __ISERIES_IRQ_H__ 1#ifndef __ISERIES_IRQ_H__
2#define __ISERIES_IRQ_H__ 2#define __ISERIES_IRQ_H__
3 3
4#ifdef __cplusplus 4extern void iSeries_init_IRQ(void);
5extern "C" { 5extern int iSeries_allocate_IRQ(HvBusNumber, HvSubBusNumber, HvAgentId);
6#endif 6extern void iSeries_activate_IRQs(void);
7
8void iSeries_init_IRQ(void);
9int iSeries_allocate_IRQ(HvBusNumber, HvSubBusNumber, HvAgentId);
10int iSeries_assign_IRQ(int, HvBusNumber, HvSubBusNumber, HvAgentId);
11void iSeries_activate_IRQs(void);
12
13int XmPciLpEvent_init(void);
14
15#ifdef __cplusplus
16}
17#endif
18 7
19#endif /* __ISERIES_IRQ_H__ */ 8#endif /* __ISERIES_IRQ_H__ */
diff --git a/include/asm-ppc64/iSeries/iSeries_pci.h b/include/asm-ppc64/iSeries/iSeries_pci.h
index 5769cff4c00c..575f611f8b33 100644
--- a/include/asm-ppc64/iSeries/iSeries_pci.h
+++ b/include/asm-ppc64/iSeries/iSeries_pci.h
@@ -1,112 +1,88 @@
1#ifndef _ISERIES_64_PCI_H 1#ifndef _ISERIES_64_PCI_H
2#define _ISERIES_64_PCI_H 2#define _ISERIES_64_PCI_H
3 3
4/************************************************************************/ 4/*
5/* File iSeries_pci.h created by Allan Trautman on Tue Feb 20, 2001. */ 5 * File iSeries_pci.h created by Allan Trautman on Tue Feb 20, 2001.
6/************************************************************************/ 6 *
7/* Define some useful macros for the iSeries pci routines. */ 7 * Define some useful macros for the iSeries pci routines.
8/* Copyright (C) 2001 Allan H Trautman, IBM Corporation */ 8 * Copyright (C) 2001 Allan H Trautman, IBM Corporation
9/* */ 9 *
10/* This program is free software; you can redistribute it and/or modify */ 10 * This program is free software; you can redistribute it and/or modify
11/* it under the terms of the GNU General Public License as published by */ 11 * it under the terms of the GNU General Public License as published by
12/* the Free Software Foundation; either version 2 of the License, or */ 12 * the Free Software Foundation; either version 2 of the License, or
13/* (at your option) any later version. */ 13 * (at your option) any later version.
14/* */ 14 *
15/* This program is distributed in the hope that it will be useful, */ 15 * This program is distributed in the hope that it will be useful,
16/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18/* GNU General Public License for more details. */ 18 * GNU General Public License for more details.
19/* */ 19 *
20/* You should have received a copy of the GNU General Public License */ 20 * You should have received a copy of the GNU General Public License
21/* along with this program; if not, write to the: */ 21 * along with this program; if not, write to the:
22/* Free Software Foundation, Inc., */ 22 * Free Software Foundation, Inc.,
23/* 59 Temple Place, Suite 330, */ 23 * 59 Temple Place, Suite 330,
24/* Boston, MA 02111-1307 USA */ 24 * Boston, MA 02111-1307 USA
25/************************************************************************/ 25 *
26/* Change Activity: */ 26 * Change Activity:
27/* Created Feb 20, 2001 */ 27 * Created Feb 20, 2001
28/* Added device reset, March 22, 2001 */ 28 * Added device reset, March 22, 2001
29/* Ported to ppc64, May 25, 2001 */ 29 * Ported to ppc64, May 25, 2001
30/* End Change Activity */ 30 * End Change Activity
31/************************************************************************/ 31 */
32 32
33#include <asm/iSeries/HvCallPci.h> 33#include <asm/iSeries/HvCallPci.h>
34#include <asm/abs_addr.h> 34#include <asm/abs_addr.h>
35 35
36struct pci_dev; /* For Forward Reference */ 36struct pci_dev; /* For Forward Reference */
37struct iSeries_Device_Node; 37struct iSeries_Device_Node;
38 38
39/************************************************************************/ 39/*
40/* Gets iSeries Bus, SubBus, DevFn using iSeries_Device_Node structure */ 40 * Gets iSeries Bus, SubBus, DevFn using iSeries_Device_Node structure
41/************************************************************************/ 41 */
42 42
43#define ISERIES_BUS(DevPtr) DevPtr->DsaAddr.Dsa.busNumber 43#define ISERIES_BUS(DevPtr) DevPtr->DsaAddr.Dsa.busNumber
44#define ISERIES_SUBBUS(DevPtr) DevPtr->DsaAddr.Dsa.subBusNumber 44#define ISERIES_SUBBUS(DevPtr) DevPtr->DsaAddr.Dsa.subBusNumber
45#define ISERIES_DEVICE(DevPtr) DevPtr->DsaAddr.Dsa.deviceId 45#define ISERIES_DEVICE(DevPtr) DevPtr->DsaAddr.Dsa.deviceId
46#define ISERIES_DSA(DevPtr) DevPtr->DsaAddr.DsaAddr 46#define ISERIES_DSA(DevPtr) DevPtr->DsaAddr.DsaAddr
47#define ISERIES_DEVFUN(DevPtr) DevPtr->DevFn 47#define ISERIES_DEVNODE(PciDev) ((struct iSeries_Device_Node *)PciDev->sysdata)
48#define ISERIES_DEVNODE(PciDev) ((struct iSeries_Device_Node*)PciDev->sysdata)
49 48
50#define EADsMaxAgents 7 49#define EADsMaxAgents 7
51 50
52/************************************************************************/
53/* Decodes Linux DevFn to iSeries DevFn, bridge device, or function. */
54/* For Linux, see PCI_SLOT and PCI_FUNC in include/linux/pci.h */
55/************************************************************************/
56
57#define ISERIES_PCI_AGENTID(idsel,func) ((idsel & 0x0F) << 4) | (func & 0x07)
58#define ISERIES_ENCODE_DEVICE(agentid) ((0x10) | ((agentid&0x20)>>2) | (agentid&07))
59
60#define ISERIES_GET_DEVICE_FROM_SUBBUS(subbus) ((subbus >> 5) & 0x7)
61#define ISERIES_GET_FUNCTION_FROM_SUBBUS(subbus) ((subbus >> 2) & 0x7)
62
63/* 51/*
64 * N.B. the ISERIES_DECODE_* macros are not used anywhere, and I think 52 * Decodes Linux DevFn to iSeries DevFn, bridge device, or function.
65 * the 0x71 (at least) must be wrong - 0x78 maybe? -- paulus. 53 * For Linux, see PCI_SLOT and PCI_FUNC in include/linux/pci.h
66 */ 54 */
67#define ISERIES_DECODE_DEVFN(linuxdevfn) (((linuxdevfn & 0x71) << 1) | (linuxdevfn & 0x07))
68#define ISERIES_DECODE_DEVICE(linuxdevfn) (((linuxdevfn & 0x38) >> 3) |(((linuxdevfn & 0x40) >> 2) + 0x10))
69#define ISERIES_DECODE_FUNCTION(linuxdevfn) (linuxdevfn & 0x07)
70 55
71/************************************************************************/ 56#define ISERIES_PCI_AGENTID(idsel, func) \
72/* Converts Virtual Address to Real Address for Hypervisor calls */ 57 (((idsel & 0x0F) << 4) | (func & 0x07))
73/************************************************************************/ 58#define ISERIES_ENCODE_DEVICE(agentid) \
59 ((0x10) | ((agentid & 0x20) >> 2) | (agentid & 0x07))
74 60
75#define ISERIES_HV_ADDR(virtaddr) (0x8000000000000000 | virt_to_abs(virtaddr)) 61#define ISERIES_GET_DEVICE_FROM_SUBBUS(subbus) ((subbus >> 5) & 0x7)
62#define ISERIES_GET_FUNCTION_FROM_SUBBUS(subbus) ((subbus >> 2) & 0x7)
76 63
77/************************************************************************/ 64/*
78/* iSeries Device Information */ 65 * Converts Virtual Address to Real Address for Hypervisor calls
79/************************************************************************/ 66 */
67#define ISERIES_HV_ADDR(virtaddr) \
68 (0x8000000000000000 | virt_to_abs(virtaddr))
80 69
70/*
71 * iSeries Device Information
72 */
81struct iSeries_Device_Node { 73struct iSeries_Device_Node {
82 struct list_head Device_List; 74 struct list_head Device_List;
83 struct pci_dev* PciDev; /* Pointer to pci_dev structure*/ 75 struct pci_dev *PciDev;
84 union HvDsaMap DsaAddr; /* Direct Select Address */ 76 union HvDsaMap DsaAddr; /* Direct Select Address */
85 /* busNumber,subBusNumber, */ 77 /* busNumber, subBusNumber, */
86 /* deviceId, barNumber */ 78 /* deviceId, barNumber */
87 HvAgentId AgentId; /* Hypervisor DevFn */ 79 int DevFn; /* Linux devfn */
88 int DevFn; /* Linux devfn */ 80 int Irq; /* Assigned IRQ */
89 int BarOffset; 81 int Flags; /* Possible flags(disable/bist)*/
90 int Irq; /* Assigned IRQ */ 82 u8 LogicalSlot; /* Hv Slot Index for Tces */
91 int ReturnCode; /* Return Code Holder */ 83 struct iommu_table *iommu_table;/* Device TCE Table */
92 int IoRetry; /* Current Retry Count */
93 int Flags; /* Possible flags(disable/bist)*/
94 u16 Vendor; /* Vendor ID */
95 u8 LogicalSlot; /* Hv Slot Index for Tces */
96 struct iommu_table* iommu_table;/* Device TCE Table */
97 u8 PhbId; /* Phb Card is on. */
98 u16 Board; /* Board Number */
99 u8 FrameId; /* iSeries spcn Frame Id */
100 char CardLocation[4];/* Char format of planar vpd */
101 char Location[20]; /* Frame 1, Card C10 */
102}; 84};
103 85
104/************************************************************************/ 86extern void iSeries_Device_Information(struct pci_dev*, int);
105/* Functions */
106/************************************************************************/
107
108extern int iSeries_Device_Information(struct pci_dev*,char*, int);
109extern void iSeries_Get_Location_Code(struct iSeries_Device_Node*);
110extern int iSeries_Device_ToggleReset(struct pci_dev* PciDev, int AssertTime, int DelayTime);
111 87
112#endif /* _ISERIES_64_PCI_H */ 88#endif /* _ISERIES_64_PCI_H */
diff --git a/include/asm-ppc64/iSeries/iSeries_proc.h b/include/asm-ppc64/iSeries/iSeries_proc.h
deleted file mode 100644
index adb6dc14dd4d..000000000000
--- a/include/asm-ppc64/iSeries/iSeries_proc.h
+++ /dev/null
@@ -1,24 +0,0 @@
1/*
2 * iSeries_proc.h
3 * Copyright (C) 2001 Kyle A. Lucke IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef _ISERIES_PROC_H
20#define _ISERIES_PROC_H
21
22extern void iSeries_proc_early_init(void);
23
24#endif /* _iSeries_PROC_H */
diff --git a/include/asm-ppc64/iSeries/mf.h b/include/asm-ppc64/iSeries/mf.h
index db333e1ee216..7e6a0d936999 100644
--- a/include/asm-ppc64/iSeries/mf.h
+++ b/include/asm-ppc64/iSeries/mf.h
@@ -9,17 +9,16 @@
9 * all partitions in the iSeries. It also provides miscellaneous low-level 9 * all partitions in the iSeries. It also provides miscellaneous low-level
10 * machine facility type operations. 10 * machine facility type operations.
11 * 11 *
12 *
13 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by 13 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or 14 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version. 15 * (at your option) any later version.
17 * 16 *
18 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 20 * GNU General Public License for more details.
22 * 21 *
23 * You should have received a copy of the GNU General Public License 22 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software 23 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
diff --git a/include/asm-ppc64/iSeries/vio.h b/include/asm-ppc64/iSeries/vio.h
index 3e5766a849d6..6c05e6257f53 100644
--- a/include/asm-ppc64/iSeries/vio.h
+++ b/include/asm-ppc64/iSeries/vio.h
@@ -8,32 +8,32 @@
8 * Colin Devilbiss <devilbis@us.ibm.com> 8 * Colin Devilbiss <devilbis@us.ibm.com>
9 * 9 *
10 * (C) Copyright 2000 IBM Corporation 10 * (C) Copyright 2000 IBM Corporation
11 * 11 *
12 * This header file is used by the iSeries virtual I/O device 12 * This header file is used by the iSeries virtual I/O device
13 * drivers. It defines the interfaces to the common functions 13 * drivers. It defines the interfaces to the common functions
14 * (implemented in drivers/char/viopath.h) as well as defining 14 * (implemented in drivers/char/viopath.h) as well as defining
15 * common functions and structures. Currently (at the time I 15 * common functions and structures. Currently (at the time I
16 * wrote this comment) the iSeries virtual I/O device drivers 16 * wrote this comment) the iSeries virtual I/O device drivers
17 * that use this are 17 * that use this are
18 * drivers/block/viodasd.c 18 * drivers/block/viodasd.c
19 * drivers/char/viocons.c 19 * drivers/char/viocons.c
20 * drivers/char/viotape.c 20 * drivers/char/viotape.c
21 * drivers/cdrom/viocd.c 21 * drivers/cdrom/viocd.c
22 * 22 *
23 * The iSeries virtual ethernet support (veth.c) uses a whole 23 * The iSeries virtual ethernet support (veth.c) uses a whole
24 * different set of functions. 24 * different set of functions.
25 * 25 *
26 * This program is free software; you can redistribute it and/or 26 * This program is free software; you can redistribute it and/or
27 * modify it under the terms of the GNU General Public License as 27 * modify it under the terms of the GNU General Public License as
28 * published by the Free Software Foundation; either version 2 of the 28 * published by the Free Software Foundation; either version 2 of the
29 * License, or (at your option) anyu later version. 29 * License, or (at your option) anyu later version.
30 * 30 *
31 * This program is distributed in the hope that it will be useful, but 31 * This program is distributed in the hope that it will be useful, but
32 * WITHOUT ANY WARRANTY; without even the implied warranty of 32 * WITHOUT ANY WARRANTY; without even the implied warranty of
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34 * General Public License for more details. 34 * General Public License for more details.
35 * 35 *
36 * You should have received a copy of the GNU General Public License 36 * You should have received a copy of the GNU General Public License
37 * along with this program; if not, write to the Free Software Foundation, 37 * along with this program; if not, write to the Free Software Foundation,
38 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 38 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39 * 39 *
@@ -44,39 +44,41 @@
44#include <asm/iSeries/HvTypes.h> 44#include <asm/iSeries/HvTypes.h>
45#include <asm/iSeries/HvLpEvent.h> 45#include <asm/iSeries/HvLpEvent.h>
46 46
47/* iSeries virtual I/O events use the subtype field in 47/*
48 * iSeries virtual I/O events use the subtype field in
48 * HvLpEvent to figure out what kind of vio event is coming 49 * HvLpEvent to figure out what kind of vio event is coming
49 * in. We use a table to route these, and this defines 50 * in. We use a table to route these, and this defines
50 * the maximum number of distinct subtypes 51 * the maximum number of distinct subtypes
51 */ 52 */
52#define VIO_MAX_SUBTYPES 8 53#define VIO_MAX_SUBTYPES 8
53 54
54/* Each subtype can register a handler to process their events. 55/*
56 * Each subtype can register a handler to process their events.
55 * The handler must have this interface. 57 * The handler must have this interface.
56 */ 58 */
57typedef void (vio_event_handler_t) (struct HvLpEvent * event); 59typedef void (vio_event_handler_t) (struct HvLpEvent * event);
58 60
59int viopath_open(HvLpIndex remoteLp, int subtype, int numReq); 61extern int viopath_open(HvLpIndex remoteLp, int subtype, int numReq);
60int viopath_close(HvLpIndex remoteLp, int subtype, int numReq); 62extern int viopath_close(HvLpIndex remoteLp, int subtype, int numReq);
61int vio_setHandler(int subtype, vio_event_handler_t * beh); 63extern int vio_setHandler(int subtype, vio_event_handler_t * beh);
62int vio_clearHandler(int subtype); 64extern int vio_clearHandler(int subtype);
63int viopath_isactive(HvLpIndex lp); 65extern int viopath_isactive(HvLpIndex lp);
64HvLpInstanceId viopath_sourceinst(HvLpIndex lp); 66extern HvLpInstanceId viopath_sourceinst(HvLpIndex lp);
65HvLpInstanceId viopath_targetinst(HvLpIndex lp); 67extern HvLpInstanceId viopath_targetinst(HvLpIndex lp);
66void vio_set_hostlp(void); 68extern void vio_set_hostlp(void);
67void *vio_get_event_buffer(int subtype); 69extern void *vio_get_event_buffer(int subtype);
68void vio_free_event_buffer(int subtype, void *buffer); 70extern void vio_free_event_buffer(int subtype, void *buffer);
69 71
70extern HvLpIndex viopath_hostLp; 72extern HvLpIndex viopath_hostLp;
71extern HvLpIndex viopath_ourLp; 73extern HvLpIndex viopath_ourLp;
72 74
73#define VIOCHAR_MAX_DATA 200 75#define VIOCHAR_MAX_DATA 200
74 76
75#define VIOMAJOR_SUBTYPE_MASK 0xff00 77#define VIOMAJOR_SUBTYPE_MASK 0xff00
76#define VIOMINOR_SUBTYPE_MASK 0x00ff 78#define VIOMINOR_SUBTYPE_MASK 0x00ff
77#define VIOMAJOR_SUBTYPE_SHIFT 8 79#define VIOMAJOR_SUBTYPE_SHIFT 8
78 80
79#define VIOVERSION 0x0101 81#define VIOVERSION 0x0101
80 82
81/* 83/*
82 * This is the general structure for VIO errors; each module should have 84 * This is the general structure for VIO errors; each module should have
@@ -89,8 +91,8 @@ struct vio_error_entry {
89 int errno; 91 int errno;
90 const char *msg; 92 const char *msg;
91}; 93};
92const struct vio_error_entry *vio_lookup_rc(const struct vio_error_entry 94extern const struct vio_error_entry *vio_lookup_rc(
93 *local_table, u16 rc); 95 const struct vio_error_entry *local_table, u16 rc);
94 96
95enum viosubtypes { 97enum viosubtypes {
96 viomajorsubtype_monitor = 0x0100, 98 viomajorsubtype_monitor = 0x0100,
@@ -102,7 +104,6 @@ enum viosubtypes {
102 viomajorsubtype_scsi = 0x0700 104 viomajorsubtype_scsi = 0x0700
103}; 105};
104 106
105
106enum vioconfigsubtype { 107enum vioconfigsubtype {
107 vioconfigget = 0x0001, 108 vioconfigget = 0x0001,
108}; 109};
diff --git a/include/asm-ppc64/imalloc.h b/include/asm-ppc64/imalloc.h
index 3a45e918bf16..e46ff68a6e41 100644
--- a/include/asm-ppc64/imalloc.h
+++ b/include/asm-ppc64/imalloc.h
@@ -4,9 +4,9 @@
4/* 4/*
5 * Define the address range of the imalloc VM area. 5 * Define the address range of the imalloc VM area.
6 */ 6 */
7#define PHBS_IO_BASE IOREGIONBASE 7#define PHBS_IO_BASE VMALLOC_END
8#define IMALLOC_BASE (IOREGIONBASE + 0x80000000ul) /* Reserve 2 gigs for PHBs */ 8#define IMALLOC_BASE (PHBS_IO_BASE + 0x80000000ul) /* Reserve 2 gigs for PHBs */
9#define IMALLOC_END (IOREGIONBASE + EADDR_MASK) 9#define IMALLOC_END (VMALLOC_START + EADDR_MASK)
10 10
11 11
12/* imalloc region types */ 12/* imalloc region types */
@@ -18,7 +18,9 @@
18 18
19extern struct vm_struct * im_get_free_area(unsigned long size); 19extern struct vm_struct * im_get_free_area(unsigned long size);
20extern struct vm_struct * im_get_area(unsigned long v_addr, unsigned long size, 20extern struct vm_struct * im_get_area(unsigned long v_addr, unsigned long size,
21 int region_type); 21 int region_type);
22unsigned long im_free(void *addr); 22extern void im_free(void *addr);
23
24extern unsigned long ioremap_bot;
23 25
24#endif /* _PPC64_IMALLOC_H */ 26#endif /* _PPC64_IMALLOC_H */
diff --git a/include/asm-ppc64/iommu.h b/include/asm-ppc64/iommu.h
index bd53ca4dcfa2..729de5cc21d9 100644
--- a/include/asm-ppc64/iommu.h
+++ b/include/asm-ppc64/iommu.h
@@ -82,24 +82,6 @@ struct iommu_table {
82 unsigned long *it_map; /* A simple allocation bitmap for now */ 82 unsigned long *it_map; /* A simple allocation bitmap for now */
83}; 83};
84 84
85#ifdef CONFIG_PPC_ISERIES
86struct iommu_table_cb {
87 unsigned long itc_busno; /* Bus number for this tce table */
88 unsigned long itc_start; /* Will be NULL for secondary */
89 unsigned long itc_totalsize; /* Size (in pages) of whole table */
90 unsigned long itc_offset; /* Index into real tce table of the
91 start of our section */
92 unsigned long itc_size; /* Size (in pages) of our section */
93 unsigned long itc_index; /* Index of this tce table */
94 unsigned short itc_maxtables; /* Max num of tables for partition */
95 unsigned char itc_virtbus; /* Flag to indicate virtual bus */
96 unsigned char itc_slotno; /* IOA Tce Slot Index */
97 unsigned char itc_rsvd[4];
98};
99
100extern struct iommu_table vio_tce_table; /* Tce table for virtual bus */
101#endif /* CONFIG_PPC_ISERIES */
102
103struct scatterlist; 85struct scatterlist;
104 86
105#ifdef CONFIG_PPC_MULTIPLATFORM 87#ifdef CONFIG_PPC_MULTIPLATFORM
@@ -122,9 +104,6 @@ extern void iommu_devnode_init_pSeries(struct device_node *dn);
122 104
123#ifdef CONFIG_PPC_ISERIES 105#ifdef CONFIG_PPC_ISERIES
124 106
125/* Walks all buses and creates iommu tables */
126extern void iommu_setup_iSeries(void);
127
128/* Initializes tables for bio buses */ 107/* Initializes tables for bio buses */
129extern void __init iommu_vio_init(void); 108extern void __init iommu_vio_init(void);
130 109
@@ -158,8 +137,12 @@ extern void iommu_init_early_pSeries(void);
158extern void iommu_init_early_iSeries(void); 137extern void iommu_init_early_iSeries(void);
159extern void iommu_init_early_u3(void); 138extern void iommu_init_early_u3(void);
160 139
140#ifdef CONFIG_PCI
161extern void pci_iommu_init(void); 141extern void pci_iommu_init(void);
162extern void pci_direct_iommu_init(void); 142extern void pci_direct_iommu_init(void);
143#else
144static inline void pci_iommu_init(void) { }
145#endif
163 146
164extern void alloc_u3_dart_table(void); 147extern void alloc_u3_dart_table(void);
165 148
diff --git a/include/asm-ppc64/paca.h b/include/asm-ppc64/paca.h
index 1a0223b5f3b8..ae76cae1483f 100644
--- a/include/asm-ppc64/paca.h
+++ b/include/asm-ppc64/paca.h
@@ -20,13 +20,13 @@
20#include <asm/types.h> 20#include <asm/types.h>
21#include <asm/lppaca.h> 21#include <asm/lppaca.h>
22#include <asm/iSeries/ItLpRegSave.h> 22#include <asm/iSeries/ItLpRegSave.h>
23#include <asm/iSeries/ItLpQueue.h>
23#include <asm/mmu.h> 24#include <asm/mmu.h>
24 25
25register struct paca_struct *local_paca asm("r13"); 26register struct paca_struct *local_paca asm("r13");
26#define get_paca() local_paca 27#define get_paca() local_paca
27 28
28struct task_struct; 29struct task_struct;
29struct ItLpQueue;
30 30
31/* 31/*
32 * Defines the layout of the paca. 32 * Defines the layout of the paca.
diff --git a/include/asm-ppc64/page.h b/include/asm-ppc64/page.h
index bcd21789d3b7..257d87eb7c34 100644
--- a/include/asm-ppc64/page.h
+++ b/include/asm-ppc64/page.h
@@ -202,9 +202,7 @@ extern u64 ppc64_pft_size; /* Log 2 of page table size */
202#define PAGE_OFFSET ASM_CONST(0xC000000000000000) 202#define PAGE_OFFSET ASM_CONST(0xC000000000000000)
203#define KERNELBASE PAGE_OFFSET 203#define KERNELBASE PAGE_OFFSET
204#define VMALLOCBASE ASM_CONST(0xD000000000000000) 204#define VMALLOCBASE ASM_CONST(0xD000000000000000)
205#define IOREGIONBASE ASM_CONST(0xE000000000000000)
206 205
207#define IO_REGION_ID (IOREGIONBASE >> REGION_SHIFT)
208#define VMALLOC_REGION_ID (VMALLOCBASE >> REGION_SHIFT) 206#define VMALLOC_REGION_ID (VMALLOCBASE >> REGION_SHIFT)
209#define KERNEL_REGION_ID (KERNELBASE >> REGION_SHIFT) 207#define KERNEL_REGION_ID (KERNELBASE >> REGION_SHIFT)
210#define USER_REGION_ID (0UL) 208#define USER_REGION_ID (0UL)
diff --git a/include/asm-ppc64/pgtable.h b/include/asm-ppc64/pgtable.h
index 264c4f7993be..46cf61c2ff69 100644
--- a/include/asm-ppc64/pgtable.h
+++ b/include/asm-ppc64/pgtable.h
@@ -53,7 +53,8 @@
53 * Define the address range of the vmalloc VM area. 53 * Define the address range of the vmalloc VM area.
54 */ 54 */
55#define VMALLOC_START (0xD000000000000000ul) 55#define VMALLOC_START (0xD000000000000000ul)
56#define VMALLOC_END (VMALLOC_START + EADDR_MASK) 56#define VMALLOC_SIZE (0x10000000000UL)
57#define VMALLOC_END (VMALLOC_START + VMALLOC_SIZE)
57 58
58/* 59/*
59 * Bits in a linux-style PTE. These match the bits in the 60 * Bits in a linux-style PTE. These match the bits in the
@@ -239,9 +240,6 @@ static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot)
239/* This now only contains the vmalloc pages */ 240/* This now only contains the vmalloc pages */
240#define pgd_offset_k(address) pgd_offset(&init_mm, address) 241#define pgd_offset_k(address) pgd_offset(&init_mm, address)
241 242
242/* to find an entry in the ioremap page-table-directory */
243#define pgd_offset_i(address) (ioremap_pgd + pgd_index(address))
244
245/* 243/*
246 * The following only work if pte_present() is true. 244 * The following only work if pte_present() is true.
247 * Undefined behaviour if not.. 245 * Undefined behaviour if not..
@@ -459,15 +457,12 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long addr,
459#define __HAVE_ARCH_PTE_SAME 457#define __HAVE_ARCH_PTE_SAME
460#define pte_same(A,B) (((pte_val(A) ^ pte_val(B)) & ~_PAGE_HPTEFLAGS) == 0) 458#define pte_same(A,B) (((pte_val(A) ^ pte_val(B)) & ~_PAGE_HPTEFLAGS) == 0)
461 459
462extern unsigned long ioremap_bot, ioremap_base;
463
464#define pmd_ERROR(e) \ 460#define pmd_ERROR(e) \
465 printk("%s:%d: bad pmd %08x.\n", __FILE__, __LINE__, pmd_val(e)) 461 printk("%s:%d: bad pmd %08x.\n", __FILE__, __LINE__, pmd_val(e))
466#define pgd_ERROR(e) \ 462#define pgd_ERROR(e) \
467 printk("%s:%d: bad pgd %08x.\n", __FILE__, __LINE__, pgd_val(e)) 463 printk("%s:%d: bad pgd %08x.\n", __FILE__, __LINE__, pgd_val(e))
468 464
469extern pgd_t swapper_pg_dir[]; 465extern pgd_t swapper_pg_dir[];
470extern pgd_t ioremap_dir[];
471 466
472extern void paging_init(void); 467extern void paging_init(void);
473 468
diff --git a/include/asm-ppc64/processor.h b/include/asm-ppc64/processor.h
index 809c634ba1df..3084099086a8 100644
--- a/include/asm-ppc64/processor.h
+++ b/include/asm-ppc64/processor.h
@@ -430,16 +430,6 @@ struct thread_struct {
430} 430}
431 431
432/* 432/*
433 * Note: the vm_start and vm_end fields here should *not*
434 * be in kernel space. (Could vm_end == vm_start perhaps?)
435 */
436#define IOREMAP_MMAP { &ioremap_mm, 0, 0x1000, NULL, \
437 PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, \
438 1, NULL, NULL }
439
440extern struct mm_struct ioremap_mm;
441
442/*
443 * Return saved PC of a blocked thread. For now, this is the "user" PC 433 * Return saved PC of a blocked thread. For now, this is the "user" PC
444 */ 434 */
445#define thread_saved_pc(tsk) \ 435#define thread_saved_pc(tsk) \
diff --git a/include/asm-ppc64/smp.h b/include/asm-ppc64/smp.h
index c8646fa999c2..8115ecb8feee 100644
--- a/include/asm-ppc64/smp.h
+++ b/include/asm-ppc64/smp.h
@@ -45,7 +45,7 @@ void generic_cpu_die(unsigned int cpu);
45void generic_mach_cpu_die(void); 45void generic_mach_cpu_die(void);
46#endif 46#endif
47 47
48#define __smp_processor_id() (get_paca()->paca_index) 48#define raw_smp_processor_id() (get_paca()->paca_index)
49#define hard_smp_processor_id() (get_paca()->hw_cpu_id) 49#define hard_smp_processor_id() (get_paca()->hw_cpu_id)
50 50
51extern cpumask_t cpu_sibling_map[NR_CPUS]; 51extern cpumask_t cpu_sibling_map[NR_CPUS];
diff --git a/include/asm-s390/smp.h b/include/asm-s390/smp.h
index 9473786387a3..dd50e57a928f 100644
--- a/include/asm-s390/smp.h
+++ b/include/asm-s390/smp.h
@@ -47,7 +47,7 @@ extern int smp_call_function_on(void (*func) (void *info), void *info,
47 47
48#define PROC_CHANGE_PENALTY 20 /* Schedule penalty */ 48#define PROC_CHANGE_PENALTY 20 /* Schedule penalty */
49 49
50#define smp_processor_id() (S390_lowcore.cpu_data.cpu_nr) 50#define raw_smp_processor_id() (S390_lowcore.cpu_data.cpu_nr)
51 51
52extern int smp_get_cpu(cpumask_t cpu_map); 52extern int smp_get_cpu(cpumask_t cpu_map);
53extern void smp_put_cpu(int cpu); 53extern void smp_put_cpu(int cpu);
diff --git a/include/asm-sh/page.h b/include/asm-sh/page.h
index 4c6d129e7d91..180467be8e7b 100644
--- a/include/asm-sh/page.h
+++ b/include/asm-sh/page.h
@@ -31,6 +31,7 @@
31#define HPAGE_SIZE (1UL << HPAGE_SHIFT) 31#define HPAGE_SIZE (1UL << HPAGE_SHIFT)
32#define HPAGE_MASK (~(HPAGE_SIZE-1)) 32#define HPAGE_MASK (~(HPAGE_SIZE-1))
33#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT-PAGE_SHIFT) 33#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT-PAGE_SHIFT)
34#define ARCH_HAS_SETCLEAR_HUGE_PTE
34#endif 35#endif
35 36
36#ifdef __KERNEL__ 37#ifdef __KERNEL__
diff --git a/include/asm-sh/pgtable.h b/include/asm-sh/pgtable.h
index cd847a47a9aa..ecb909572d3f 100644
--- a/include/asm-sh/pgtable.h
+++ b/include/asm-sh/pgtable.h
@@ -196,6 +196,7 @@ static inline pte_t pte_mkexec(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _
196static inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; } 196static inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; }
197static inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; } 197static inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; }
198static inline pte_t pte_mkwrite(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_RW)); return pte; } 198static inline pte_t pte_mkwrite(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_RW)); return pte; }
199static inline pte_t pte_mkhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_SZHUGE)); return pte; }
199 200
200/* 201/*
201 * Macro and implementation to make a page protection as uncachable. 202 * Macro and implementation to make a page protection as uncachable.
diff --git a/include/asm-sh/smp.h b/include/asm-sh/smp.h
index 38b54469d7d1..f19a8b3b69a6 100644
--- a/include/asm-sh/smp.h
+++ b/include/asm-sh/smp.h
@@ -25,7 +25,7 @@ extern cpumask_t cpu_possible_map;
25 25
26#define cpu_online(cpu) cpu_isset(cpu, cpu_online_map) 26#define cpu_online(cpu) cpu_isset(cpu, cpu_online_map)
27 27
28#define smp_processor_id() (current_thread_info()->cpu) 28#define raw_smp_processor_id() (current_thread_info()->cpu)
29 29
30/* I've no idea what the real meaning of this is */ 30/* I've no idea what the real meaning of this is */
31#define PROC_CHANGE_PENALTY 20 31#define PROC_CHANGE_PENALTY 20
diff --git a/include/asm-sh64/page.h b/include/asm-sh64/page.h
index e1f7f5a41210..d6167f1c0e99 100644
--- a/include/asm-sh64/page.h
+++ b/include/asm-sh64/page.h
@@ -41,6 +41,7 @@
41#define HPAGE_SIZE (1UL << HPAGE_SHIFT) 41#define HPAGE_SIZE (1UL << HPAGE_SHIFT)
42#define HPAGE_MASK (~(HPAGE_SIZE-1)) 42#define HPAGE_MASK (~(HPAGE_SIZE-1))
43#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT-PAGE_SHIFT) 43#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT-PAGE_SHIFT)
44#define ARCH_HAS_SETCLEAR_HUGE_PTE
44#endif 45#endif
45 46
46#ifdef __KERNEL__ 47#ifdef __KERNEL__
diff --git a/include/asm-sh64/pgtable.h b/include/asm-sh64/pgtable.h
index 525e1523ef5f..78ac6be2d9ef 100644
--- a/include/asm-sh64/pgtable.h
+++ b/include/asm-sh64/pgtable.h
@@ -430,6 +430,8 @@ extern inline pte_t pte_mkwrite(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) |
430extern inline pte_t pte_mkexec(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_EXECUTE)); return pte; } 430extern inline pte_t pte_mkexec(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_EXECUTE)); return pte; }
431extern inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; } 431extern inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; }
432extern inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; } 432extern inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; }
433extern inline pte_t pte_mkhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_SZHUGE)); return pte; }
434
433 435
434/* 436/*
435 * Conversion functions: convert a page and protection to a page entry. 437 * Conversion functions: convert a page and protection to a page entry.
diff --git a/include/asm-sparc/smp.h b/include/asm-sparc/smp.h
index f986c0d0922a..4f96d8333a12 100644
--- a/include/asm-sparc/smp.h
+++ b/include/asm-sparc/smp.h
@@ -148,7 +148,7 @@ extern __inline__ int hard_smp_processor_id(void)
148} 148}
149#endif 149#endif
150 150
151#define smp_processor_id() (current_thread_info()->cpu) 151#define raw_smp_processor_id() (current_thread_info()->cpu)
152 152
153#define prof_multiplier(__cpu) cpu_data(__cpu).multiplier 153#define prof_multiplier(__cpu) cpu_data(__cpu).multiplier
154#define prof_counter(__cpu) cpu_data(__cpu).counter 154#define prof_counter(__cpu) cpu_data(__cpu).counter
diff --git a/include/asm-sparc64/page.h b/include/asm-sparc64/page.h
index 219ea043a14a..b87dbbd64bc9 100644
--- a/include/asm-sparc64/page.h
+++ b/include/asm-sparc64/page.h
@@ -95,6 +95,8 @@ typedef unsigned long pgprot_t;
95#define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT) 95#define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT)
96#define HPAGE_MASK (~(HPAGE_SIZE - 1UL)) 96#define HPAGE_MASK (~(HPAGE_SIZE - 1UL))
97#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) 97#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
98#define ARCH_HAS_SETCLEAR_HUGE_PTE
99#define ARCH_HAS_HUGETLB_PREFAULT_HOOK
98#endif 100#endif
99 101
100#define TASK_UNMAPPED_BASE (test_thread_flag(TIF_32BIT) ? \ 102#define TASK_UNMAPPED_BASE (test_thread_flag(TIF_32BIT) ? \
diff --git a/include/asm-sparc64/pgtable.h b/include/asm-sparc64/pgtable.h
index ae2cd5b09a7c..1ae00c5087f1 100644
--- a/include/asm-sparc64/pgtable.h
+++ b/include/asm-sparc64/pgtable.h
@@ -286,6 +286,7 @@ static inline pte_t pte_modify(pte_t orig_pte, pgprot_t new_prot)
286#define pte_mkyoung(pte) (__pte(pte_val(pte) | _PAGE_ACCESSED | _PAGE_R)) 286#define pte_mkyoung(pte) (__pte(pte_val(pte) | _PAGE_ACCESSED | _PAGE_R))
287#define pte_mkwrite(pte) (__pte(pte_val(pte) | _PAGE_WRITE)) 287#define pte_mkwrite(pte) (__pte(pte_val(pte) | _PAGE_WRITE))
288#define pte_mkdirty(pte) (__pte(pte_val(pte) | _PAGE_MODIFIED | _PAGE_W)) 288#define pte_mkdirty(pte) (__pte(pte_val(pte) | _PAGE_MODIFIED | _PAGE_W))
289#define pte_mkhuge(pte) (__pte(pte_val(pte) | _PAGE_SZHUGE))
289 290
290/* to find an entry in a page-table-directory. */ 291/* to find an entry in a page-table-directory. */
291#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1)) 292#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
diff --git a/include/asm-sparc64/processor.h b/include/asm-sparc64/processor.h
index bc1445b904ef..d0bee2413560 100644
--- a/include/asm-sparc64/processor.h
+++ b/include/asm-sparc64/processor.h
@@ -192,6 +192,40 @@ extern unsigned long get_wchan(struct task_struct *task);
192 192
193#define cpu_relax() barrier() 193#define cpu_relax() barrier()
194 194
195/* Prefetch support. This is tuned for UltraSPARC-III and later.
196 * UltraSPARC-I will treat these as nops, and UltraSPARC-II has
197 * a shallower prefetch queue than later chips.
198 */
199#define ARCH_HAS_PREFETCH
200#define ARCH_HAS_PREFETCHW
201#define ARCH_HAS_SPINLOCK_PREFETCH
202
203static inline void prefetch(const void *x)
204{
205 /* We do not use the read prefetch mnemonic because that
206 * prefetches into the prefetch-cache which only is accessible
207 * by floating point operations in UltraSPARC-III and later.
208 * By contrast, "#one_write" prefetches into the L2 cache
209 * in shared state.
210 */
211 __asm__ __volatile__("prefetch [%0], #one_write"
212 : /* no outputs */
213 : "r" (x));
214}
215
216static inline void prefetchw(const void *x)
217{
218 /* The most optimal prefetch to use for writes is
219 * "#n_writes". This brings the cacheline into the
220 * L2 cache in "owned" state.
221 */
222 __asm__ __volatile__("prefetch [%0], #n_writes"
223 : /* no outputs */
224 : "r" (x));
225}
226
227#define spin_lock_prefetch(x) prefetchw(x)
228
195#endif /* !(__ASSEMBLY__) */ 229#endif /* !(__ASSEMBLY__) */
196 230
197#endif /* !(__ASM_SPARC64_PROCESSOR_H) */ 231#endif /* !(__ASM_SPARC64_PROCESSOR_H) */
diff --git a/include/asm-sparc64/smp.h b/include/asm-sparc64/smp.h
index 5e3e06d908fe..110a2de89123 100644
--- a/include/asm-sparc64/smp.h
+++ b/include/asm-sparc64/smp.h
@@ -64,7 +64,7 @@ static __inline__ int hard_smp_processor_id(void)
64 } 64 }
65} 65}
66 66
67#define smp_processor_id() (current_thread_info()->cpu) 67#define raw_smp_processor_id() (current_thread_info()->cpu)
68 68
69#endif /* !(__ASSEMBLY__) */ 69#endif /* !(__ASSEMBLY__) */
70 70
diff --git a/include/asm-um/smp.h b/include/asm-um/smp.h
index 4412d5d9c26b..d879eba2b52c 100644
--- a/include/asm-um/smp.h
+++ b/include/asm-um/smp.h
@@ -8,7 +8,8 @@
8#include "asm/current.h" 8#include "asm/current.h"
9#include "linux/cpumask.h" 9#include "linux/cpumask.h"
10 10
11#define smp_processor_id() (current_thread->cpu) 11#define raw_smp_processor_id() (current_thread->cpu)
12
12#define cpu_logical_map(n) (n) 13#define cpu_logical_map(n) (n)
13#define cpu_number_map(n) (n) 14#define cpu_number_map(n) (n)
14#define PROC_CHANGE_PENALTY 15 /* Pick a number, any number */ 15#define PROC_CHANGE_PENALTY 15 /* Pick a number, any number */
diff --git a/include/asm-x86_64/a.out.h b/include/asm-x86_64/a.out.h
index 5952914f4121..7255cde06538 100644
--- a/include/asm-x86_64/a.out.h
+++ b/include/asm-x86_64/a.out.h
@@ -21,7 +21,7 @@ struct exec
21 21
22#ifdef __KERNEL__ 22#ifdef __KERNEL__
23#include <linux/thread_info.h> 23#include <linux/thread_info.h>
24#define STACK_TOP (test_thread_flag(TIF_IA32) ? IA32_PAGE_OFFSET : TASK_SIZE) 24#define STACK_TOP TASK_SIZE
25#endif 25#endif
26 26
27#endif /* __A_OUT_GNU_H__ */ 27#endif /* __A_OUT_GNU_H__ */
diff --git a/include/asm-x86_64/page.h b/include/asm-x86_64/page.h
index f43048035a03..9ce338c3a71e 100644
--- a/include/asm-x86_64/page.h
+++ b/include/asm-x86_64/page.h
@@ -28,6 +28,7 @@
28#define HPAGE_SIZE ((1UL) << HPAGE_SHIFT) 28#define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
29#define HPAGE_MASK (~(HPAGE_SIZE - 1)) 29#define HPAGE_MASK (~(HPAGE_SIZE - 1))
30#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) 30#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
31#define ARCH_HAS_HUGETLB_CLEAN_STALE_PGTABLE
31 32
32#ifdef __KERNEL__ 33#ifdef __KERNEL__
33#ifndef __ASSEMBLY__ 34#ifndef __ASSEMBLY__
diff --git a/include/asm-x86_64/pgtable.h b/include/asm-x86_64/pgtable.h
index db2a0efbf573..4eec176c3c39 100644
--- a/include/asm-x86_64/pgtable.h
+++ b/include/asm-x86_64/pgtable.h
@@ -253,6 +253,7 @@ extern inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED;
253extern inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; } 253extern inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; }
254static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } 254static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; }
255 255
256#define __LARGE_PTE (_PAGE_PSE|_PAGE_PRESENT)
256extern inline pte_t pte_rdprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_USER)); return pte; } 257extern inline pte_t pte_rdprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_USER)); return pte; }
257extern inline pte_t pte_exprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_USER)); return pte; } 258extern inline pte_t pte_exprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_USER)); return pte; }
258extern inline pte_t pte_mkclean(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_DIRTY)); return pte; } 259extern inline pte_t pte_mkclean(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_DIRTY)); return pte; }
@@ -263,6 +264,7 @@ extern inline pte_t pte_mkexec(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _
263extern inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; } 264extern inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; }
264extern inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; } 265extern inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; }
265extern inline pte_t pte_mkwrite(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_RW)); return pte; } 266extern inline pte_t pte_mkwrite(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_RW)); return pte; }
267extern inline pte_t pte_mkhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | __LARGE_PTE)); return pte; }
266 268
267struct vm_area_struct; 269struct vm_area_struct;
268 270
@@ -290,7 +292,6 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
290 */ 292 */
291#define pgprot_noncached(prot) (__pgprot(pgprot_val(prot) | _PAGE_PCD | _PAGE_PWT)) 293#define pgprot_noncached(prot) (__pgprot(pgprot_val(prot) | _PAGE_PCD | _PAGE_PWT))
292 294
293#define __LARGE_PTE (_PAGE_PSE|_PAGE_PRESENT)
294static inline int pmd_large(pmd_t pte) { 295static inline int pmd_large(pmd_t pte) {
295 return (pmd_val(pte) & __LARGE_PTE) == __LARGE_PTE; 296 return (pmd_val(pte) & __LARGE_PTE) == __LARGE_PTE;
296} 297}
diff --git a/include/asm-x86_64/processor.h b/include/asm-x86_64/processor.h
index d641b19f6da5..8b55f139968f 100644
--- a/include/asm-x86_64/processor.h
+++ b/include/asm-x86_64/processor.h
@@ -160,16 +160,17 @@ static inline void clear_in_cr4 (unsigned long mask)
160/* 160/*
161 * User space process size. 47bits minus one guard page. 161 * User space process size. 47bits minus one guard page.
162 */ 162 */
163#define TASK_SIZE (0x800000000000UL - 4096) 163#define TASK_SIZE64 (0x800000000000UL - 4096)
164 164
165/* This decides where the kernel will search for a free chunk of vm 165/* This decides where the kernel will search for a free chunk of vm
166 * space during mmap's. 166 * space during mmap's.
167 */ 167 */
168#define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? 0xc0000000 : 0xFFFFe000) 168#define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? 0xc0000000 : 0xFFFFe000)
169#define TASK_UNMAPPED_32 PAGE_ALIGN(IA32_PAGE_OFFSET/3) 169
170#define TASK_UNMAPPED_64 PAGE_ALIGN(TASK_SIZE/3) 170#define TASK_SIZE (test_thread_flag(TIF_IA32) ? IA32_PAGE_OFFSET : TASK_SIZE64)
171#define TASK_UNMAPPED_BASE \ 171#define TASK_SIZE_OF(child) ((test_tsk_thread_flag(child, TIF_IA32)) ? IA32_PAGE_OFFSET : TASK_SIZE64)
172 (test_thread_flag(TIF_IA32) ? TASK_UNMAPPED_32 : TASK_UNMAPPED_64) 172
173#define TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE/3)
173 174
174/* 175/*
175 * Size of io_bitmap. 176 * Size of io_bitmap.
diff --git a/include/asm-x86_64/smp.h b/include/asm-x86_64/smp.h
index 96844fecbde8..a7425aa5a3b7 100644
--- a/include/asm-x86_64/smp.h
+++ b/include/asm-x86_64/smp.h
@@ -68,7 +68,7 @@ static inline int num_booting_cpus(void)
68 return cpus_weight(cpu_callout_map); 68 return cpus_weight(cpu_callout_map);
69} 69}
70 70
71#define __smp_processor_id() read_pda(cpunumber) 71#define raw_smp_processor_id() read_pda(cpunumber)
72 72
73extern __inline int hard_smp_processor_id(void) 73extern __inline int hard_smp_processor_id(void)
74{ 74{
diff --git a/include/linux/arcfb.h b/include/linux/arcfb.h
new file mode 100644
index 000000000000..721e7654daeb
--- /dev/null
+++ b/include/linux/arcfb.h
@@ -0,0 +1,8 @@
1#ifndef __LINUX_ARCFB_H__
2#define __LINUX_ARCFB_H__
3
4#define FBIO_WAITEVENT _IO('F', 0x88)
5#define FBIO_GETCONTROL2 _IOR('F', 0x89, size_t)
6
7#endif
8
diff --git a/include/linux/auto_fs4.h b/include/linux/auto_fs4.h
index a1657fb99516..9343c89d843c 100644
--- a/include/linux/auto_fs4.h
+++ b/include/linux/auto_fs4.h
@@ -23,7 +23,7 @@
23#define AUTOFS_MIN_PROTO_VERSION 3 23#define AUTOFS_MIN_PROTO_VERSION 3
24#define AUTOFS_MAX_PROTO_VERSION 4 24#define AUTOFS_MAX_PROTO_VERSION 4
25 25
26#define AUTOFS_PROTO_SUBVERSION 6 26#define AUTOFS_PROTO_SUBVERSION 7
27 27
28/* Mask for expire behaviour */ 28/* Mask for expire behaviour */
29#define AUTOFS_EXP_IMMEDIATE 1 29#define AUTOFS_EXP_IMMEDIATE 1
diff --git a/include/linux/fb.h b/include/linux/fb.h
index b468bf496547..bc24beeed971 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -524,11 +524,11 @@ struct fb_pixmap {
524 u32 offset; /* current offset to buffer */ 524 u32 offset; /* current offset to buffer */
525 u32 buf_align; /* byte alignment of each bitmap */ 525 u32 buf_align; /* byte alignment of each bitmap */
526 u32 scan_align; /* alignment per scanline */ 526 u32 scan_align; /* alignment per scanline */
527 u32 access_align; /* alignment per read/write */ 527 u32 access_align; /* alignment per read/write (bits) */
528 u32 flags; /* see FB_PIXMAP_* */ 528 u32 flags; /* see FB_PIXMAP_* */
529 /* access methods */ 529 /* access methods */
530 void (*outbuf)(struct fb_info *info, u8 *addr, u8 *src, unsigned int size); 530 void (*writeio)(struct fb_info *info, void __iomem *dst, void *src, unsigned int size);
531 u8 (*inbuf) (struct fb_info *info, u8 *addr); 531 void (*readio) (struct fb_info *info, void *dst, void __iomem *src, unsigned int size);
532}; 532};
533 533
534 534
@@ -816,18 +816,9 @@ extern int unregister_framebuffer(struct fb_info *fb_info);
816extern int fb_prepare_logo(struct fb_info *fb_info); 816extern int fb_prepare_logo(struct fb_info *fb_info);
817extern int fb_show_logo(struct fb_info *fb_info); 817extern int fb_show_logo(struct fb_info *fb_info);
818extern char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size); 818extern char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size);
819extern void fb_iomove_buf_unaligned(struct fb_info *info, struct fb_pixmap *buf, 819extern void fb_pad_unaligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 idx,
820 u8 *dst, u32 d_pitch, u8 *src, u32 idx,
821 u32 height, u32 shift_high, u32 shift_low, u32 mod); 820 u32 height, u32 shift_high, u32 shift_low, u32 mod);
822extern void fb_iomove_buf_aligned(struct fb_info *info, struct fb_pixmap *buf, 821extern void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u32 height);
823 u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch,
824 u32 height);
825extern void fb_sysmove_buf_unaligned(struct fb_info *info, struct fb_pixmap *buf,
826 u8 *dst, u32 d_pitch, u8 *src, u32 idx,
827 u32 height, u32 shift_high, u32 shift_low, u32 mod);
828extern void fb_sysmove_buf_aligned(struct fb_info *info, struct fb_pixmap *buf,
829 u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch,
830 u32 height);
831extern void fb_set_suspend(struct fb_info *info, int state); 822extern void fb_set_suspend(struct fb_info *info, int state);
832extern int fb_get_color_depth(struct fb_var_screeninfo *var); 823extern int fb_get_color_depth(struct fb_var_screeninfo *var);
833extern int fb_get_options(char *name, char **option); 824extern int fb_get_options(char *name, char **option);
diff --git a/include/linux/font.h b/include/linux/font.h
index fc2d690c9d5f..8fc80a7d78ac 100644
--- a/include/linux/font.h
+++ b/include/linux/font.h
@@ -25,19 +25,23 @@ struct font_desc {
25#define VGA8x16_IDX 1 25#define VGA8x16_IDX 1
26#define PEARL8x8_IDX 2 26#define PEARL8x8_IDX 2
27#define VGA6x11_IDX 3 27#define VGA6x11_IDX 3
28#define SUN8x16_IDX 4 28#define FONT7x14_IDX 4
29#define SUN12x22_IDX 5 29#define FONT10x18_IDX 5
30#define ACORN8x8_IDX 6 30#define SUN8x16_IDX 6
31#define MINI4x6_IDX 7 31#define SUN12x22_IDX 7
32#define ACORN8x8_IDX 8
33#define MINI4x6_IDX 9
32 34
33extern struct font_desc font_vga_8x8, 35extern struct font_desc font_vga_8x8,
34 font_vga_8x16, 36 font_vga_8x16,
35 font_pearl_8x8, 37 font_pearl_8x8,
36 font_vga_6x11, 38 font_vga_6x11,
37 font_sun_8x16, 39 font_7x14,
38 font_sun_12x22, 40 font_10x18,
39 font_acorn_8x8, 41 font_sun_8x16,
40 font_mini_4x6; 42 font_sun_12x22,
43 font_acorn_8x8,
44 font_mini_4x6;
41 45
42/* Find a font with a specific name */ 46/* Find a font with a specific name */
43 47
diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
index faaff4c64559..70f54af87b9f 100644
--- a/include/linux/fsl_devices.h
+++ b/include/linux/fsl_devices.h
@@ -51,6 +51,7 @@ struct gianfar_platform_data {
51 51
52 /* board specific information */ 52 /* board specific information */
53 u32 board_flags; 53 u32 board_flags;
54 u32 phy_flags;
54 u32 phyid; 55 u32 phyid;
55 u32 interruptPHY; 56 u32 interruptPHY;
56 u8 mac_addr[6]; 57 u8 mac_addr[6];
@@ -61,9 +62,14 @@ struct gianfar_platform_data {
61#define FSL_GIANFAR_DEV_HAS_COALESCE 0x00000002 62#define FSL_GIANFAR_DEV_HAS_COALESCE 0x00000002
62#define FSL_GIANFAR_DEV_HAS_RMON 0x00000004 63#define FSL_GIANFAR_DEV_HAS_RMON 0x00000004
63#define FSL_GIANFAR_DEV_HAS_MULTI_INTR 0x00000008 64#define FSL_GIANFAR_DEV_HAS_MULTI_INTR 0x00000008
65#define FSL_GIANFAR_DEV_HAS_CSUM 0x00000010
66#define FSL_GIANFAR_DEV_HAS_VLAN 0x00000020
67#define FSL_GIANFAR_DEV_HAS_EXTENDED_HASH 0x00000040
68#define FSL_GIANFAR_DEV_HAS_PADDING 0x00000080
64 69
65/* Flags in gianfar_platform_data */ 70/* Flags in gianfar_platform_data */
66#define FSL_GIANFAR_BRD_HAS_PHY_INTR 0x00000001 /* if not set use a timer */ 71#define FSL_GIANFAR_BRD_HAS_PHY_INTR 0x00000001 /* set or use a timer */
72#define FSL_GIANFAR_BRD_IS_REDUCED 0x00000002 /* Set if RGMII, RMII */
67 73
68struct fsl_i2c_platform_data { 74struct fsl_i2c_platform_data {
69 /* device specific information */ 75 /* device specific information */
diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h
new file mode 100644
index 000000000000..7fd0576a4454
--- /dev/null
+++ b/include/linux/genalloc.h
@@ -0,0 +1,40 @@
1/*
2 * Basic general purpose allocator for managing special purpose memory
3 * not managed by the regular kmalloc/kfree interface.
4 * Uses for this includes on-device special memory, uncached memory
5 * etc.
6 *
7 * This code is based on the buddy allocator found in the sym53c8xx_2
8 * driver, adapted for general purpose use.
9 *
10 * This source code is licensed under the GNU General Public License,
11 * Version 2. See the file COPYING for more details.
12 */
13
14#include <linux/spinlock.h>
15
16#define ALLOC_MIN_SHIFT 5 /* 32 bytes minimum */
17/*
18 * Link between free memory chunks of a given size.
19 */
20struct gen_pool_link {
21 struct gen_pool_link *next;
22};
23
24/*
25 * Memory pool descriptor.
26 */
27struct gen_pool {
28 spinlock_t lock;
29 unsigned long (*get_new_chunk)(struct gen_pool *);
30 struct gen_pool *next;
31 struct gen_pool_link *h;
32 unsigned long private;
33 int max_chunk_shift;
34};
35
36unsigned long gen_pool_alloc(struct gen_pool *poolp, int size);
37void gen_pool_free(struct gen_pool *mp, unsigned long ptr, int size);
38struct gen_pool *gen_pool_create(int nr_chunks, int max_chunk_shift,
39 unsigned long (*fp)(struct gen_pool *),
40 unsigned long data);
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index af7407e8cfc5..8d6bf608b199 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -39,6 +39,7 @@ struct vm_area_struct;
39#define __GFP_COMP 0x4000u /* Add compound page metadata */ 39#define __GFP_COMP 0x4000u /* Add compound page metadata */
40#define __GFP_ZERO 0x8000u /* Return zeroed page on success */ 40#define __GFP_ZERO 0x8000u /* Return zeroed page on success */
41#define __GFP_NOMEMALLOC 0x10000u /* Don't use emergency reserves */ 41#define __GFP_NOMEMALLOC 0x10000u /* Don't use emergency reserves */
42#define __GFP_NORECLAIM 0x20000u /* No realy zone reclaim during allocation */
42 43
43#define __GFP_BITS_SHIFT 20 /* Room for 20 __GFP_FOO bits */ 44#define __GFP_BITS_SHIFT 20 /* Room for 20 __GFP_FOO bits */
44#define __GFP_BITS_MASK ((1 << __GFP_BITS_SHIFT) - 1) 45#define __GFP_BITS_MASK ((1 << __GFP_BITS_SHIFT) - 1)
@@ -47,7 +48,7 @@ struct vm_area_struct;
47#define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \ 48#define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \
48 __GFP_COLD|__GFP_NOWARN|__GFP_REPEAT| \ 49 __GFP_COLD|__GFP_NOWARN|__GFP_REPEAT| \
49 __GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP| \ 50 __GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP| \
50 __GFP_NOMEMALLOC) 51 __GFP_NOMEMALLOC|__GFP_NORECLAIM)
51 52
52#define GFP_ATOMIC (__GFP_HIGH) 53#define GFP_ATOMIC (__GFP_HIGH)
53#define GFP_NOIO (__GFP_WAIT) 54#define GFP_NOIO (__GFP_WAIT)
@@ -132,5 +133,10 @@ extern void FASTCALL(free_cold_page(struct page *page));
132#define free_page(addr) free_pages((addr),0) 133#define free_page(addr) free_pages((addr),0)
133 134
134void page_alloc_init(void); 135void page_alloc_init(void);
136#ifdef CONFIG_NUMA
137void drain_remote_pages(void);
138#else
139static inline void drain_remote_pages(void) { };
140#endif
135 141
136#endif /* __LINUX_GFP_H */ 142#endif /* __LINUX_GFP_H */
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 6af1ae4a8211..f529d1442815 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -4,6 +4,7 @@
4#ifdef CONFIG_HUGETLB_PAGE 4#ifdef CONFIG_HUGETLB_PAGE
5 5
6#include <linux/mempolicy.h> 6#include <linux/mempolicy.h>
7#include <asm/tlbflush.h>
7 8
8struct ctl_table; 9struct ctl_table;
9 10
@@ -22,12 +23,6 @@ int hugetlb_report_meminfo(char *);
22int hugetlb_report_node_meminfo(int, char *); 23int hugetlb_report_node_meminfo(int, char *);
23int is_hugepage_mem_enough(size_t); 24int is_hugepage_mem_enough(size_t);
24unsigned long hugetlb_total_pages(void); 25unsigned long hugetlb_total_pages(void);
25struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address,
26 int write);
27struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address,
28 pmd_t *pmd, int write);
29int is_aligned_hugepage_range(unsigned long addr, unsigned long len);
30int pmd_huge(pmd_t pmd);
31struct page *alloc_huge_page(void); 26struct page *alloc_huge_page(void);
32void free_huge_page(struct page *); 27void free_huge_page(struct page *);
33 28
@@ -35,6 +30,17 @@ extern unsigned long max_huge_pages;
35extern const unsigned long hugetlb_zero, hugetlb_infinity; 30extern const unsigned long hugetlb_zero, hugetlb_infinity;
36extern int sysctl_hugetlb_shm_group; 31extern int sysctl_hugetlb_shm_group;
37 32
33/* arch callbacks */
34
35pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr);
36pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr);
37struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address,
38 int write);
39struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address,
40 pmd_t *pmd, int write);
41int is_aligned_hugepage_range(unsigned long addr, unsigned long len);
42int pmd_huge(pmd_t pmd);
43
38#ifndef ARCH_HAS_HUGEPAGE_ONLY_RANGE 44#ifndef ARCH_HAS_HUGEPAGE_ONLY_RANGE
39#define is_hugepage_only_range(mm, addr, len) 0 45#define is_hugepage_only_range(mm, addr, len) 0
40#define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) \ 46#define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) \
@@ -48,6 +54,28 @@ extern int sysctl_hugetlb_shm_group;
48int prepare_hugepage_range(unsigned long addr, unsigned long len); 54int prepare_hugepage_range(unsigned long addr, unsigned long len);
49#endif 55#endif
50 56
57#ifndef ARCH_HAS_SETCLEAR_HUGE_PTE
58#define set_huge_pte_at(mm, addr, ptep, pte) set_pte_at(mm, addr, ptep, pte)
59#define huge_ptep_get_and_clear(mm, addr, ptep) ptep_get_and_clear(mm, addr, ptep)
60#else
61void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
62 pte_t *ptep, pte_t pte);
63pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
64 pte_t *ptep);
65#endif
66
67#ifndef ARCH_HAS_HUGETLB_PREFAULT_HOOK
68#define hugetlb_prefault_arch_hook(mm) do { } while (0)
69#else
70void hugetlb_prefault_arch_hook(struct mm_struct *mm);
71#endif
72
73#ifndef ARCH_HAS_HUGETLB_CLEAN_STALE_PGTABLE
74#define hugetlb_clean_stale_pgtable(pte) BUG()
75#else
76void hugetlb_clean_stale_pgtable(pte_t *pte);
77#endif
78
51#else /* !CONFIG_HUGETLB_PAGE */ 79#else /* !CONFIG_HUGETLB_PAGE */
52 80
53static inline int is_vm_hugetlb_page(struct vm_area_struct *vma) 81static inline int is_vm_hugetlb_page(struct vm_area_struct *vma)
diff --git a/include/linux/i2c-sysfs.h b/include/linux/hwmon-sysfs.h
index d7bf6ce11679..1b5018a965f5 100644
--- a/include/linux/i2c-sysfs.h
+++ b/include/linux/hwmon-sysfs.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * i2c-sysfs.h - i2c chip driver sysfs defines 2 * hwmon-sysfs.h - hardware monitoring chip driver sysfs defines
3 * 3 *
4 * Copyright (C) 2005 Yani Ioannou <yani.ioannou@gmail.com> 4 * Copyright (C) 2005 Yani Ioannou <yani.ioannou@gmail.com>
5 * 5 *
@@ -17,8 +17,8 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 19 */
20#ifndef _LINUX_I2C_SYSFS_H 20#ifndef _LINUX_HWMON_SYSFS_H
21#define _LINUX_I2C_SYSFS_H 21#define _LINUX_HWMON_SYSFS_H
22 22
23struct sensor_device_attribute{ 23struct sensor_device_attribute{
24 struct device_attribute dev_attr; 24 struct device_attribute dev_attr;
@@ -33,4 +33,4 @@ struct sensor_device_attribute sensor_dev_attr_##_name = { \
33 .index = _index, \ 33 .index = _index, \
34} 34}
35 35
36#endif /* _LINUX_I2C_SYSFS_H */ 36#endif /* _LINUX_HWMON_SYSFS_H */
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h
index 89270ce51470..33f08258f22b 100644
--- a/include/linux/i2c-id.h
+++ b/include/linux/i2c-id.h
@@ -108,6 +108,7 @@
108#define I2C_DRIVERID_TDA7313 62 /* TDA7313 audio processor */ 108#define I2C_DRIVERID_TDA7313 62 /* TDA7313 audio processor */
109#define I2C_DRIVERID_MAX6900 63 /* MAX6900 real-time clock */ 109#define I2C_DRIVERID_MAX6900 63 /* MAX6900 real-time clock */
110#define I2C_DRIVERID_SAA7114H 64 /* video decoder */ 110#define I2C_DRIVERID_SAA7114H 64 /* video decoder */
111#define I2C_DRIVERID_DS1374 65 /* DS1374 real time clock */
111 112
112 113
113#define I2C_DRIVERID_EXP0 0xF0 /* experimental use id's */ 114#define I2C_DRIVERID_EXP0 0xF0 /* experimental use id's */
diff --git a/include/linux/i2c-vid.h b/include/linux/i2c-vid.h
index 974835e3530f..41d0635e0ba9 100644
--- a/include/linux/i2c-vid.h
+++ b/include/linux/i2c-vid.h
@@ -97,3 +97,15 @@ static inline int vid_from_reg(int val, int vrm)
97 2050 - (val) * 50); 97 2050 - (val) * 50);
98 } 98 }
99} 99}
100
101static inline int vid_to_reg(int val, int vrm)
102{
103 switch (vrm) {
104 case 91: /* VRM 9.1 */
105 case 90: /* VRM 9.0 */
106 return ((val >= 1100) && (val <= 1850) ?
107 ((18499 - val * 10) / 25 + 5) / 10 : -1);
108 default:
109 return -1;
110 }
111}
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index ebcd745f4cd6..be837b13f297 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -290,11 +290,8 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data)
290 */ 290 */
291struct i2c_client_address_data { 291struct i2c_client_address_data {
292 unsigned short *normal_i2c; 292 unsigned short *normal_i2c;
293 unsigned short *normal_i2c_range;
294 unsigned short *probe; 293 unsigned short *probe;
295 unsigned short *probe_range;
296 unsigned short *ignore; 294 unsigned short *ignore;
297 unsigned short *ignore_range;
298 unsigned short *force; 295 unsigned short *force;
299}; 296};
300 297
@@ -563,24 +560,15 @@ union i2c_smbus_data {
563#define I2C_CLIENT_INSMOD \ 560#define I2C_CLIENT_INSMOD \
564 I2C_CLIENT_MODULE_PARM(probe, \ 561 I2C_CLIENT_MODULE_PARM(probe, \
565 "List of adapter,address pairs to scan additionally"); \ 562 "List of adapter,address pairs to scan additionally"); \
566 I2C_CLIENT_MODULE_PARM(probe_range, \
567 "List of adapter,start-addr,end-addr triples to scan " \
568 "additionally"); \
569 I2C_CLIENT_MODULE_PARM(ignore, \ 563 I2C_CLIENT_MODULE_PARM(ignore, \
570 "List of adapter,address pairs not to scan"); \ 564 "List of adapter,address pairs not to scan"); \
571 I2C_CLIENT_MODULE_PARM(ignore_range, \
572 "List of adapter,start-addr,end-addr triples not to " \
573 "scan"); \
574 I2C_CLIENT_MODULE_PARM(force, \ 565 I2C_CLIENT_MODULE_PARM(force, \
575 "List of adapter,address pairs to boldly assume " \ 566 "List of adapter,address pairs to boldly assume " \
576 "to be present"); \ 567 "to be present"); \
577 static struct i2c_client_address_data addr_data = { \ 568 static struct i2c_client_address_data addr_data = { \
578 .normal_i2c = normal_i2c, \ 569 .normal_i2c = normal_i2c, \
579 .normal_i2c_range = normal_i2c_range, \
580 .probe = probe, \ 570 .probe = probe, \
581 .probe_range = probe_range, \
582 .ignore = ignore, \ 571 .ignore = ignore, \
583 .ignore_range = ignore_range, \
584 .force = force, \ 572 .force = force, \
585 } 573 }
586 574
diff --git a/include/linux/ioc4.h b/include/linux/ioc4.h
new file mode 100644
index 000000000000..3dd18b785ebd
--- /dev/null
+++ b/include/linux/ioc4.h
@@ -0,0 +1,179 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
7 */
8
9#ifndef _LINUX_IOC4_H
10#define _LINUX_IOC4_H
11
12#include <linux/interrupt.h>
13
14/***************
15 * Definitions *
16 ***************/
17
18/* Miscellaneous values inherent to hardware */
19
20#define IOC4_EXTINT_COUNT_DIVISOR 520 /* PCI clocks per COUNT tick */
21
22/***********************************
23 * Structures needed by subdrivers *
24 ***********************************/
25
26/* This structure fully describes the IOC4 miscellaneous registers which
27 * appear at bar[0]+0x00000 through bar[0]+0x0005c. The corresponding
28 * PCI resource is managed by the main IOC4 driver because it contains
29 * registers of interest to many different IOC4 subdrivers.
30 */
31struct ioc4_misc_regs {
32 /* Miscellaneous IOC4 registers */
33 union ioc4_pci_err_addr_l {
34 uint32_t raw;
35 struct {
36 uint32_t valid:1; /* Address captured */
37 uint32_t master_id:4; /* Unit causing error
38 * 0/1: Serial port 0 TX/RX
39 * 2/3: Serial port 1 TX/RX
40 * 4/5: Serial port 2 TX/RX
41 * 6/7: Serial port 3 TX/RX
42 * 8: ATA/ATAPI
43 * 9-15: Undefined
44 */
45 uint32_t mul_err:1; /* Multiple errors occurred */
46 uint32_t addr:26; /* Bits 31-6 of error addr */
47 } fields;
48 } pci_err_addr_l;
49 uint32_t pci_err_addr_h; /* Bits 63-32 of error addr */
50 union ioc4_sio_int {
51 uint32_t raw;
52 struct {
53 uint8_t tx_mt:1; /* TX ring buffer empty */
54 uint8_t rx_full:1; /* RX ring buffer full */
55 uint8_t rx_high:1; /* RX high-water exceeded */
56 uint8_t rx_timer:1; /* RX timer has triggered */
57 uint8_t delta_dcd:1; /* DELTA_DCD seen */
58 uint8_t delta_cts:1; /* DELTA_CTS seen */
59 uint8_t intr_pass:1; /* Interrupt pass-through */
60 uint8_t tx_explicit:1; /* TX, MCW, or delay complete */
61 } fields[4];
62 } sio_ir; /* Serial interrupt state */
63 union ioc4_other_int {
64 uint32_t raw;
65 struct {
66 uint32_t ata_int:1; /* ATA port passthru */
67 uint32_t ata_memerr:1; /* ATA halted by mem error */
68 uint32_t memerr:4; /* Serial halted by mem err */
69 uint32_t kbd_int:1; /* kbd/mouse intr asserted */
70 uint32_t reserved:16; /* zero */
71 uint32_t rt_int:1; /* INT_OUT section latch */
72 uint32_t gen_int:8; /* Intr. from generic pins */
73 } fields;
74 } other_ir; /* Other interrupt state */
75 union ioc4_sio_int sio_ies; /* Serial interrupt enable set */
76 union ioc4_other_int other_ies; /* Other interrupt enable set */
77 union ioc4_sio_int sio_iec; /* Serial interrupt enable clear */
78 union ioc4_other_int other_iec; /* Other interrupt enable clear */
79 union ioc4_sio_cr {
80 uint32_t raw;
81 struct {
82 uint32_t cmd_pulse:4; /* Bytebus strobe width */
83 uint32_t arb_diag:3; /* PCI bus requester */
84 uint32_t sio_diag_idle:1; /* Active ser req? */
85 uint32_t ata_diag_idle:1; /* Active ATA req? */
86 uint32_t ata_diag_active:1; /* ATA req is winner */
87 uint32_t reserved:22; /* zero */
88 } fields;
89 } sio_cr;
90 uint32_t unused1;
91 union ioc4_int_out {
92 uint32_t raw;
93 struct {
94 uint32_t count:16; /* Period control */
95 uint32_t mode:3; /* Output signal shape */
96 uint32_t reserved:11; /* zero */
97 uint32_t diag:1; /* Timebase control */
98 uint32_t int_out:1; /* Current value */
99 } fields;
100 } int_out; /* External interrupt output control */
101 uint32_t unused2;
102 union ioc4_gpcr {
103 uint32_t raw;
104 struct {
105 uint32_t dir:8; /* Pin direction */
106 uint32_t edge:8; /* Edge/level mode */
107 uint32_t reserved1:4; /* zero */
108 uint32_t int_out_en:1; /* INT_OUT enable */
109 uint32_t reserved2:11; /* zero */
110 } fields;
111 } gpcr_s; /* Generic PIO control set */
112 union ioc4_gpcr gpcr_c; /* Generic PIO control clear */
113 union ioc4_gpdr {
114 uint32_t raw;
115 struct {
116 uint32_t gen_pin:8; /* State of pins */
117 uint32_t reserved:24;
118 } fields;
119 } gpdr; /* Generic PIO data */
120 uint32_t unused3;
121 union ioc4_gppr {
122 uint32_t raw;
123 struct {
124 uint32_t gen_pin:1; /* Single pin state */
125 uint32_t reserved:31;
126 } fields;
127 } gppr[8]; /* Generic PIO pins */
128};
129
130/* Masks for GPCR DIR pins */
131#define IOC4_GPCR_DIR_0 0x01 /* External interrupt output */
132#define IOC4_GPCR_DIR_1 0x02 /* External interrupt input */
133#define IOC4_GPCR_DIR_2 0x04
134#define IOC4_GPCR_DIR_3 0x08 /* Keyboard/mouse presence */
135#define IOC4_GPCR_DIR_4 0x10 /* Ser. port 0 xcvr select (0=232, 1=422) */
136#define IOC4_GPCR_DIR_5 0x20 /* Ser. port 1 xcvr select (0=232, 1=422) */
137#define IOC4_GPCR_DIR_6 0x40 /* Ser. port 2 xcvr select (0=232, 1=422) */
138#define IOC4_GPCR_DIR_7 0x80 /* Ser. port 3 xcvr select (0=232, 1=422) */
139
140/* Masks for GPCR EDGE pins */
141#define IOC4_GPCR_EDGE_0 0x01
142#define IOC4_GPCR_EDGE_1 0x02 /* External interrupt input */
143#define IOC4_GPCR_EDGE_2 0x04
144#define IOC4_GPCR_EDGE_3 0x08
145#define IOC4_GPCR_EDGE_4 0x10
146#define IOC4_GPCR_EDGE_5 0x20
147#define IOC4_GPCR_EDGE_6 0x40
148#define IOC4_GPCR_EDGE_7 0x80
149
150/* One of these per IOC4 */
151struct ioc4_driver_data {
152 struct list_head idd_list;
153 unsigned long idd_bar0;
154 struct pci_dev *idd_pdev;
155 const struct pci_device_id *idd_pci_id;
156 struct __iomem ioc4_misc_regs *idd_misc_regs;
157 unsigned long count_period;
158 void *idd_serial_data;
159};
160
161/* One per submodule */
162struct ioc4_submodule {
163 struct list_head is_list;
164 char *is_name;
165 struct module *is_owner;
166 int (*is_probe) (struct ioc4_driver_data *);
167 int (*is_remove) (struct ioc4_driver_data *);
168};
169
170#define IOC4_NUM_CARDS 8 /* max cards per partition */
171
172/**********************************
173 * Functions needed by submodules *
174 **********************************/
175
176extern int ioc4_register_submodule(struct ioc4_submodule *);
177extern void ioc4_unregister_submodule(struct ioc4_submodule *);
178
179#endif /* _LINUX_IOC4_H */
diff --git a/include/linux/ioc4_common.h b/include/linux/ioc4_common.h
deleted file mode 100644
index b03bcc46df55..000000000000
--- a/include/linux/ioc4_common.h
+++ /dev/null
@@ -1,21 +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) 2005 Silicon Graphics, Inc. All Rights Reserved.
7 */
8
9#ifndef _LINUX_IOC4_COMMON_H
10#define _LINUX_IOC4_COMMON_H
11
12/* prototypes */
13
14int ioc4_serial_init(void);
15
16int ioc4_serial_attach_one(struct pci_dev *pdev, const struct
17 pci_device_id *pci_id);
18int ioc4_ide_attach_one(struct pci_dev *pdev, const struct
19 pci_device_id *pci_id);
20
21#endif /* _LINUX_IOC4_COMMON_H */
diff --git a/include/linux/irq.h b/include/linux/irq.h
index c3ff4d101667..7fc1022be9ee 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -47,6 +47,10 @@ struct hw_interrupt_type {
47 void (*ack)(unsigned int irq); 47 void (*ack)(unsigned int irq);
48 void (*end)(unsigned int irq); 48 void (*end)(unsigned int irq);
49 void (*set_affinity)(unsigned int irq, cpumask_t dest); 49 void (*set_affinity)(unsigned int irq, cpumask_t dest);
50 /* Currently used only by UML, might disappear one day.*/
51#ifdef CONFIG_IRQ_RELEASE_METHOD
52 void (*release)(unsigned int irq, void *dev_id);
53#endif
50}; 54};
51 55
52typedef struct hw_interrupt_type hw_irq_controller; 56typedef struct hw_interrupt_type hw_irq_controller;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 17518fe0b311..1813b162b0a8 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -691,6 +691,12 @@ extern void show_mem(void);
691extern void si_meminfo(struct sysinfo * val); 691extern void si_meminfo(struct sysinfo * val);
692extern void si_meminfo_node(struct sysinfo *val, int nid); 692extern void si_meminfo_node(struct sysinfo *val, int nid);
693 693
694#ifdef CONFIG_NUMA
695extern void setup_per_cpu_pageset(void);
696#else
697static inline void setup_per_cpu_pageset(void) {}
698#endif
699
694/* prio_tree.c */ 700/* prio_tree.c */
695void vma_prio_tree_add(struct vm_area_struct *, struct vm_area_struct *old); 701void vma_prio_tree_add(struct vm_area_struct *, struct vm_area_struct *old);
696void vma_prio_tree_insert(struct vm_area_struct *, struct prio_tree_root *); 702void vma_prio_tree_insert(struct vm_area_struct *, struct prio_tree_root *);
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index e530c6c092f1..4733d35d8223 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -63,6 +63,12 @@ struct per_cpu_pageset {
63#endif 63#endif
64} ____cacheline_aligned_in_smp; 64} ____cacheline_aligned_in_smp;
65 65
66#ifdef CONFIG_NUMA
67#define zone_pcp(__z, __cpu) ((__z)->pageset[(__cpu)])
68#else
69#define zone_pcp(__z, __cpu) (&(__z)->pageset[(__cpu)])
70#endif
71
66#define ZONE_DMA 0 72#define ZONE_DMA 0
67#define ZONE_NORMAL 1 73#define ZONE_NORMAL 1
68#define ZONE_HIGHMEM 2 74#define ZONE_HIGHMEM 2
@@ -122,8 +128,11 @@ struct zone {
122 */ 128 */
123 unsigned long lowmem_reserve[MAX_NR_ZONES]; 129 unsigned long lowmem_reserve[MAX_NR_ZONES];
124 130
131#ifdef CONFIG_NUMA
132 struct per_cpu_pageset *pageset[NR_CPUS];
133#else
125 struct per_cpu_pageset pageset[NR_CPUS]; 134 struct per_cpu_pageset pageset[NR_CPUS];
126 135#endif
127 /* 136 /*
128 * free areas of different sizes 137 * free areas of different sizes
129 */ 138 */
@@ -145,6 +154,14 @@ struct zone {
145 int all_unreclaimable; /* All pages pinned */ 154 int all_unreclaimable; /* All pages pinned */
146 155
147 /* 156 /*
157 * Does the allocator try to reclaim pages from the zone as soon
158 * as it fails a watermark_ok() in __alloc_pages?
159 */
160 int reclaim_pages;
161 /* A count of how many reclaimers are scanning this zone */
162 atomic_t reclaim_in_progress;
163
164 /*
148 * prev_priority holds the scanning priority for this zone. It is 165 * prev_priority holds the scanning priority for this zone. It is
149 * defined as the scanning priority at which we achieved our reclaim 166 * defined as the scanning priority at which we achieved our reclaim
150 * target at the previous try_to_free_pages() or balance_pgdat() 167 * target at the previous try_to_free_pages() or balance_pgdat()
@@ -381,7 +398,7 @@ int lowmem_reserve_ratio_sysctl_handler(struct ctl_table *, int, struct file *,
381 398
382#include <linux/topology.h> 399#include <linux/topology.h>
383/* Returns the number of the current Node. */ 400/* Returns the number of the current Node. */
384#define numa_node_id() (cpu_to_node(_smp_processor_id())) 401#define numa_node_id() (cpu_to_node(raw_smp_processor_id()))
385 402
386#ifndef CONFIG_DISCONTIGMEM 403#ifndef CONFIG_DISCONTIGMEM
387 404
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 39ab8c6b5652..f5a6695d4d21 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -61,21 +61,20 @@
61#define PG_active 6 61#define PG_active 6
62#define PG_slab 7 /* slab debug (Suparna wants this) */ 62#define PG_slab 7 /* slab debug (Suparna wants this) */
63 63
64#define PG_highmem 8 64#define PG_checked 8 /* kill me in 2.5.<early>. */
65#define PG_checked 9 /* kill me in 2.5.<early>. */ 65#define PG_arch_1 9
66#define PG_arch_1 10 66#define PG_reserved 10
67#define PG_reserved 11 67#define PG_private 11 /* Has something at ->private */
68 68
69#define PG_private 12 /* Has something at ->private */ 69#define PG_writeback 12 /* Page is under writeback */
70#define PG_writeback 13 /* Page is under writeback */ 70#define PG_nosave 13 /* Used for system suspend/resume */
71#define PG_nosave 14 /* Used for system suspend/resume */ 71#define PG_compound 14 /* Part of a compound page */
72#define PG_compound 15 /* Part of a compound page */ 72#define PG_swapcache 15 /* Swap page: swp_entry_t in private */
73 73
74#define PG_swapcache 16 /* Swap page: swp_entry_t in private */ 74#define PG_mappedtodisk 16 /* Has blocks allocated on-disk */
75#define PG_mappedtodisk 17 /* Has blocks allocated on-disk */ 75#define PG_reclaim 17 /* To be reclaimed asap */
76#define PG_reclaim 18 /* To be reclaimed asap */ 76#define PG_nosave_free 18 /* Free, should not be written */
77#define PG_nosave_free 19 /* Free, should not be written */ 77#define PG_uncached 19 /* Page has been mapped as uncached */
78#define PG_uncached 20 /* Page has been mapped as uncached */
79 78
80/* 79/*
81 * Global page accounting. One instance per CPU. Only unsigned longs are 80 * Global page accounting. One instance per CPU. Only unsigned longs are
@@ -136,8 +135,8 @@ struct page_state {
136 135
137extern void get_page_state(struct page_state *ret); 136extern void get_page_state(struct page_state *ret);
138extern void get_full_page_state(struct page_state *ret); 137extern void get_full_page_state(struct page_state *ret);
139extern unsigned long __read_page_state(unsigned offset); 138extern unsigned long __read_page_state(unsigned long offset);
140extern void __mod_page_state(unsigned offset, unsigned long delta); 139extern void __mod_page_state(unsigned long offset, unsigned long delta);
141 140
142#define read_page_state(member) \ 141#define read_page_state(member) \
143 __read_page_state(offsetof(struct page_state, member)) 142 __read_page_state(offsetof(struct page_state, member))
@@ -215,7 +214,7 @@ extern void __mod_page_state(unsigned offset, unsigned long delta);
215#define TestSetPageSlab(page) test_and_set_bit(PG_slab, &(page)->flags) 214#define TestSetPageSlab(page) test_and_set_bit(PG_slab, &(page)->flags)
216 215
217#ifdef CONFIG_HIGHMEM 216#ifdef CONFIG_HIGHMEM
218#define PageHighMem(page) test_bit(PG_highmem, &(page)->flags) 217#define PageHighMem(page) is_highmem(page_zone(page))
219#else 218#else
220#define PageHighMem(page) 0 /* needed to optimize away at compile time */ 219#define PageHighMem(page) 0 /* needed to optimize away at compile time */
221#endif 220#endif
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 0422031161ba..d9a25647a295 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -52,12 +52,12 @@ void release_pages(struct page **pages, int nr, int cold);
52 52
53static inline struct page *page_cache_alloc(struct address_space *x) 53static inline struct page *page_cache_alloc(struct address_space *x)
54{ 54{
55 return alloc_pages(mapping_gfp_mask(x), 0); 55 return alloc_pages(mapping_gfp_mask(x)|__GFP_NORECLAIM, 0);
56} 56}
57 57
58static inline struct page *page_cache_alloc_cold(struct address_space *x) 58static inline struct page *page_cache_alloc_cold(struct address_space *x)
59{ 59{
60 return alloc_pages(mapping_gfp_mask(x)|__GFP_COLD, 0); 60 return alloc_pages(mapping_gfp_mask(x)|__GFP_COLD|__GFP_NORECLAIM, 0);
61} 61}
62 62
63typedef int filler_t(void *, struct page *); 63typedef int filler_t(void *, struct page *);
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index b8b4ebf9abf1..63e89e47b8e9 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -575,6 +575,7 @@
575#define PCI_DEVICE_ID_CT_65550 0x00e0 575#define PCI_DEVICE_ID_CT_65550 0x00e0
576#define PCI_DEVICE_ID_CT_65554 0x00e4 576#define PCI_DEVICE_ID_CT_65554 0x00e4
577#define PCI_DEVICE_ID_CT_65555 0x00e5 577#define PCI_DEVICE_ID_CT_65555 0x00e5
578#define PCI_DEVICE_ID_CT_69000 0x00c0
578 579
579#define PCI_VENDOR_ID_MIRO 0x1031 580#define PCI_VENDOR_ID_MIRO 0x1031
580#define PCI_DEVICE_ID_MIRO_36050 0x5601 581#define PCI_DEVICE_ID_MIRO_36050 0x5601
diff --git a/include/linux/raid/bitmap.h b/include/linux/raid/bitmap.h
new file mode 100644
index 000000000000..e24b74b11150
--- /dev/null
+++ b/include/linux/raid/bitmap.h
@@ -0,0 +1,273 @@
1/*
2 * bitmap.h: Copyright (C) Peter T. Breuer (ptb@ot.uc3m.es) 2003
3 *
4 * additions: Copyright (C) 2003-2004, Paul Clements, SteelEye Technology, Inc.
5 */
6#ifndef BITMAP_H
7#define BITMAP_H 1
8
9#define BITMAP_MAJOR 3
10#define BITMAP_MINOR 38
11
12/*
13 * in-memory bitmap:
14 *
15 * Use 16 bit block counters to track pending writes to each "chunk".
16 * The 2 high order bits are special-purpose, the first is a flag indicating
17 * whether a resync is needed. The second is a flag indicating whether a
18 * resync is active.
19 * This means that the counter is actually 14 bits:
20 *
21 * +--------+--------+------------------------------------------------+
22 * | resync | resync | counter |
23 * | needed | active | |
24 * | (0-1) | (0-1) | (0-16383) |
25 * +--------+--------+------------------------------------------------+
26 *
27 * The "resync needed" bit is set when:
28 * a '1' bit is read from storage at startup.
29 * a write request fails on some drives
30 * a resync is aborted on a chunk with 'resync active' set
31 * It is cleared (and resync-active set) when a resync starts across all drives
32 * of the chunk.
33 *
34 *
35 * The "resync active" bit is set when:
36 * a resync is started on all drives, and resync_needed is set.
37 * resync_needed will be cleared (as long as resync_active wasn't already set).
38 * It is cleared when a resync completes.
39 *
40 * The counter counts pending write requests, plus the on-disk bit.
41 * When the counter is '1' and the resync bits are clear, the on-disk
42 * bit can be cleared aswell, thus setting the counter to 0.
43 * When we set a bit, or in the counter (to start a write), if the fields is
44 * 0, we first set the disk bit and set the counter to 1.
45 *
46 * If the counter is 0, the on-disk bit is clear and the stipe is clean
47 * Anything that dirties the stipe pushes the counter to 2 (at least)
48 * and sets the on-disk bit (lazily).
49 * If a periodic sweep find the counter at 2, it is decremented to 1.
50 * If the sweep find the counter at 1, the on-disk bit is cleared and the
51 * counter goes to zero.
52 *
53 * Also, we'll hijack the "map" pointer itself and use it as two 16 bit block
54 * counters as a fallback when "page" memory cannot be allocated:
55 *
56 * Normal case (page memory allocated):
57 *
58 * page pointer (32-bit)
59 *
60 * [ ] ------+
61 * |
62 * +-------> [ ][ ]..[ ] (4096 byte page == 2048 counters)
63 * c1 c2 c2048
64 *
65 * Hijacked case (page memory allocation failed):
66 *
67 * hijacked page pointer (32-bit)
68 *
69 * [ ][ ] (no page memory allocated)
70 * counter #1 (16-bit) counter #2 (16-bit)
71 *
72 */
73
74#ifdef __KERNEL__
75
76#define PAGE_BITS (PAGE_SIZE << 3)
77#define PAGE_BIT_SHIFT (PAGE_SHIFT + 3)
78
79typedef __u16 bitmap_counter_t;
80#define COUNTER_BITS 16
81#define COUNTER_BIT_SHIFT 4
82#define COUNTER_BYTE_RATIO (COUNTER_BITS / 8)
83#define COUNTER_BYTE_SHIFT (COUNTER_BIT_SHIFT - 3)
84
85#define NEEDED_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 1)))
86#define RESYNC_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 2)))
87#define COUNTER_MAX ((bitmap_counter_t) RESYNC_MASK - 1)
88#define NEEDED(x) (((bitmap_counter_t) x) & NEEDED_MASK)
89#define RESYNC(x) (((bitmap_counter_t) x) & RESYNC_MASK)
90#define COUNTER(x) (((bitmap_counter_t) x) & COUNTER_MAX)
91
92/* how many counters per page? */
93#define PAGE_COUNTER_RATIO (PAGE_BITS / COUNTER_BITS)
94/* same, except a shift value for more efficient bitops */
95#define PAGE_COUNTER_SHIFT (PAGE_BIT_SHIFT - COUNTER_BIT_SHIFT)
96/* same, except a mask value for more efficient bitops */
97#define PAGE_COUNTER_MASK (PAGE_COUNTER_RATIO - 1)
98
99#define BITMAP_BLOCK_SIZE 512
100#define BITMAP_BLOCK_SHIFT 9
101
102/* how many blocks per chunk? (this is variable) */
103#define CHUNK_BLOCK_RATIO(bitmap) ((bitmap)->chunksize >> BITMAP_BLOCK_SHIFT)
104#define CHUNK_BLOCK_SHIFT(bitmap) ((bitmap)->chunkshift - BITMAP_BLOCK_SHIFT)
105#define CHUNK_BLOCK_MASK(bitmap) (CHUNK_BLOCK_RATIO(bitmap) - 1)
106
107/* when hijacked, the counters and bits represent even larger "chunks" */
108/* there will be 1024 chunks represented by each counter in the page pointers */
109#define PAGEPTR_BLOCK_RATIO(bitmap) \
110 (CHUNK_BLOCK_RATIO(bitmap) << PAGE_COUNTER_SHIFT >> 1)
111#define PAGEPTR_BLOCK_SHIFT(bitmap) \
112 (CHUNK_BLOCK_SHIFT(bitmap) + PAGE_COUNTER_SHIFT - 1)
113#define PAGEPTR_BLOCK_MASK(bitmap) (PAGEPTR_BLOCK_RATIO(bitmap) - 1)
114
115/*
116 * on-disk bitmap:
117 *
118 * Use one bit per "chunk" (block set). We do the disk I/O on the bitmap
119 * file a page at a time. There's a superblock at the start of the file.
120 */
121
122/* map chunks (bits) to file pages - offset by the size of the superblock */
123#define CHUNK_BIT_OFFSET(chunk) ((chunk) + (sizeof(bitmap_super_t) << 3))
124
125#endif
126
127/*
128 * bitmap structures:
129 */
130
131#define BITMAP_MAGIC 0x6d746962
132
133/* use these for bitmap->flags and bitmap->sb->state bit-fields */
134enum bitmap_state {
135 BITMAP_ACTIVE = 0x001, /* the bitmap is in use */
136 BITMAP_STALE = 0x002 /* the bitmap file is out of date or had -EIO */
137};
138
139/* the superblock at the front of the bitmap file -- little endian */
140typedef struct bitmap_super_s {
141 __u32 magic; /* 0 BITMAP_MAGIC */
142 __u32 version; /* 4 the bitmap major for now, could change... */
143 __u8 uuid[16]; /* 8 128 bit uuid - must match md device uuid */
144 __u64 events; /* 24 event counter for the bitmap (1)*/
145 __u64 events_cleared;/*32 event counter when last bit cleared (2) */
146 __u64 sync_size; /* 40 the size of the md device's sync range(3) */
147 __u32 state; /* 48 bitmap state information */
148 __u32 chunksize; /* 52 the bitmap chunk size in bytes */
149 __u32 daemon_sleep; /* 56 seconds between disk flushes */
150
151 __u8 pad[256 - 60]; /* set to zero */
152} bitmap_super_t;
153
154/* notes:
155 * (1) This event counter is updated before the eventcounter in the md superblock
156 * When a bitmap is loaded, it is only accepted if this event counter is equal
157 * to, or one greater than, the event counter in the superblock.
158 * (2) This event counter is updated when the other one is *if*and*only*if* the
159 * array is not degraded. As bits are not cleared when the array is degraded,
160 * this represents the last time that any bits were cleared.
161 * If a device is being added that has an event count with this value or
162 * higher, it is accepted as conforming to the bitmap.
163 * (3)This is the number of sectors represented by the bitmap, and is the range that
164 * resync happens across. For raid1 and raid5/6 it is the size of individual
165 * devices. For raid10 it is the size of the array.
166 */
167
168#ifdef __KERNEL__
169
170/* the in-memory bitmap is represented by bitmap_pages */
171struct bitmap_page {
172 /*
173 * map points to the actual memory page
174 */
175 char *map;
176 /*
177 * in emergencies (when map cannot be alloced), hijack the map
178 * pointer and use it as two counters itself
179 */
180 unsigned int hijacked:1;
181 /*
182 * count of dirty bits on the page
183 */
184 unsigned int count:31;
185};
186
187/* keep track of bitmap file pages that have pending writes on them */
188struct page_list {
189 struct list_head list;
190 struct page *page;
191};
192
193/* the main bitmap structure - one per mddev */
194struct bitmap {
195 struct bitmap_page *bp;
196 unsigned long pages; /* total number of pages in the bitmap */
197 unsigned long missing_pages; /* number of pages not yet allocated */
198
199 mddev_t *mddev; /* the md device that the bitmap is for */
200
201 int counter_bits; /* how many bits per block counter */
202
203 /* bitmap chunksize -- how much data does each bit represent? */
204 unsigned long chunksize;
205 unsigned long chunkshift; /* chunksize = 2^chunkshift (for bitops) */
206 unsigned long chunks; /* total number of data chunks for the array */
207
208 /* We hold a count on the chunk currently being synced, and drop
209 * it when the last block is started. If the resync is aborted
210 * midway, we need to be able to drop that count, so we remember
211 * the counted chunk..
212 */
213 unsigned long syncchunk;
214
215 __u64 events_cleared;
216
217 /* bitmap spinlock */
218 spinlock_t lock;
219
220 long offset; /* offset from superblock if file is NULL */
221 struct file *file; /* backing disk file */
222 struct page *sb_page; /* cached copy of the bitmap file superblock */
223 struct page **filemap; /* list of cache pages for the file */
224 unsigned long *filemap_attr; /* attributes associated w/ filemap pages */
225 unsigned long file_pages; /* number of pages in the file */
226
227 unsigned long flags;
228
229 /*
230 * the bitmap daemon - periodically wakes up and sweeps the bitmap
231 * file, cleaning up bits and flushing out pages to disk as necessary
232 */
233 unsigned long daemon_lastrun; /* jiffies of last run */
234 unsigned long daemon_sleep; /* how many seconds between updates? */
235
236 /*
237 * bitmap_writeback_daemon waits for file-pages that have been written,
238 * as there is no way to get a call-back when a page write completes.
239 */
240 mdk_thread_t *writeback_daemon;
241 spinlock_t write_lock;
242 wait_queue_head_t write_wait;
243 struct list_head complete_pages;
244 mempool_t *write_pool;
245};
246
247/* the bitmap API */
248
249/* these are used only by md/bitmap */
250int bitmap_create(mddev_t *mddev);
251void bitmap_destroy(mddev_t *mddev);
252int bitmap_active(struct bitmap *bitmap);
253
254char *file_path(struct file *file, char *buf, int count);
255void bitmap_print_sb(struct bitmap *bitmap);
256int bitmap_update_sb(struct bitmap *bitmap);
257
258int bitmap_setallbits(struct bitmap *bitmap);
259void bitmap_write_all(struct bitmap *bitmap);
260
261/* these are exported */
262int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors);
263void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors,
264 int success);
265int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks);
266void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted);
267void bitmap_close_sync(struct bitmap *bitmap);
268
269int bitmap_unplug(struct bitmap *bitmap);
270int bitmap_daemon_work(struct bitmap *bitmap);
271#endif
272
273#endif
diff --git a/include/linux/raid/md.h b/include/linux/raid/md.h
index a6a67d102bfa..ffa316ce4dc8 100644
--- a/include/linux/raid/md.h
+++ b/include/linux/raid/md.h
@@ -60,7 +60,14 @@
60 */ 60 */
61#define MD_MAJOR_VERSION 0 61#define MD_MAJOR_VERSION 0
62#define MD_MINOR_VERSION 90 62#define MD_MINOR_VERSION 90
63#define MD_PATCHLEVEL_VERSION 1 63/*
64 * MD_PATCHLEVEL_VERSION indicates kernel functionality.
65 * >=1 means different superblock formats are selectable using SET_ARRAY_INFO
66 * and major_version/minor_version accordingly
67 * >=2 means that Internal bitmaps are supported by setting MD_SB_BITMAP_PRESENT
68 * in the super status byte
69 */
70#define MD_PATCHLEVEL_VERSION 2
64 71
65extern int register_md_personality (int p_num, mdk_personality_t *p); 72extern int register_md_personality (int p_num, mdk_personality_t *p);
66extern int unregister_md_personality (int p_num); 73extern int unregister_md_personality (int p_num);
@@ -69,7 +76,7 @@ extern mdk_thread_t * md_register_thread (void (*run) (mddev_t *mddev),
69extern void md_unregister_thread (mdk_thread_t *thread); 76extern void md_unregister_thread (mdk_thread_t *thread);
70extern void md_wakeup_thread(mdk_thread_t *thread); 77extern void md_wakeup_thread(mdk_thread_t *thread);
71extern void md_check_recovery(mddev_t *mddev); 78extern void md_check_recovery(mddev_t *mddev);
72extern void md_write_start(mddev_t *mddev); 79extern void md_write_start(mddev_t *mddev, struct bio *bi);
73extern void md_write_end(mddev_t *mddev); 80extern void md_write_end(mddev_t *mddev);
74extern void md_handle_safemode(mddev_t *mddev); 81extern void md_handle_safemode(mddev_t *mddev);
75extern void md_done_sync(mddev_t *mddev, int blocks, int ok); 82extern void md_done_sync(mddev_t *mddev, int blocks, int ok);
@@ -78,6 +85,12 @@ extern void md_unplug_mddev(mddev_t *mddev);
78 85
79extern void md_print_devices (void); 86extern void md_print_devices (void);
80 87
88extern void md_super_write(mddev_t *mddev, mdk_rdev_t *rdev,
89 sector_t sector, int size, struct page *page);
90extern int sync_page_io(struct block_device *bdev, sector_t sector, int size,
91 struct page *page, int rw);
92
93
81#define MD_BUG(x...) { printk("md: bug in file %s, line %d\n", __FILE__, __LINE__); md_print_devices(); } 94#define MD_BUG(x...) { printk("md: bug in file %s, line %d\n", __FILE__, __LINE__); md_print_devices(); }
82 95
83#endif 96#endif
diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h
index c9a0d4013be7..8c14ba565a45 100644
--- a/include/linux/raid/md_k.h
+++ b/include/linux/raid/md_k.h
@@ -15,6 +15,9 @@
15#ifndef _MD_K_H 15#ifndef _MD_K_H
16#define _MD_K_H 16#define _MD_K_H
17 17
18/* and dm-bio-list.h is not under include/linux because.... ??? */
19#include "../../../drivers/md/dm-bio-list.h"
20
18#define MD_RESERVED 0UL 21#define MD_RESERVED 0UL
19#define LINEAR 1UL 22#define LINEAR 1UL
20#define RAID0 2UL 23#define RAID0 2UL
@@ -180,6 +183,10 @@ struct mdk_rdev_s
180 183
181 int desc_nr; /* descriptor index in the superblock */ 184 int desc_nr; /* descriptor index in the superblock */
182 int raid_disk; /* role of device in array */ 185 int raid_disk; /* role of device in array */
186 int saved_raid_disk; /* role that device used to have in the
187 * array and could again if we did a partial
188 * resync from the bitmap
189 */
183 190
184 atomic_t nr_pending; /* number of pending requests. 191 atomic_t nr_pending; /* number of pending requests.
185 * only maintained for arrays that 192 * only maintained for arrays that
@@ -252,6 +259,11 @@ struct mddev_s
252 atomic_t recovery_active; /* blocks scheduled, but not written */ 259 atomic_t recovery_active; /* blocks scheduled, but not written */
253 wait_queue_head_t recovery_wait; 260 wait_queue_head_t recovery_wait;
254 sector_t recovery_cp; 261 sector_t recovery_cp;
262
263 spinlock_t write_lock;
264 wait_queue_head_t sb_wait; /* for waiting on superblock updates */
265 atomic_t pending_writes; /* number of active superblock writes */
266
255 unsigned int safemode; /* if set, update "clean" superblock 267 unsigned int safemode; /* if set, update "clean" superblock
256 * when no writes pending. 268 * when no writes pending.
257 */ 269 */
@@ -260,6 +272,13 @@ struct mddev_s
260 atomic_t writes_pending; 272 atomic_t writes_pending;
261 request_queue_t *queue; /* for plugging ... */ 273 request_queue_t *queue; /* for plugging ... */
262 274
275 struct bitmap *bitmap; /* the bitmap for the device */
276 struct file *bitmap_file; /* the bitmap file */
277 long bitmap_offset; /* offset from superblock of
278 * start of bitmap. May be
279 * negative, but not '0'
280 */
281
263 struct list_head all_mddevs; 282 struct list_head all_mddevs;
264}; 283};
265 284
@@ -291,7 +310,7 @@ struct mdk_personality_s
291 int (*hot_add_disk) (mddev_t *mddev, mdk_rdev_t *rdev); 310 int (*hot_add_disk) (mddev_t *mddev, mdk_rdev_t *rdev);
292 int (*hot_remove_disk) (mddev_t *mddev, int number); 311 int (*hot_remove_disk) (mddev_t *mddev, int number);
293 int (*spare_active) (mddev_t *mddev); 312 int (*spare_active) (mddev_t *mddev);
294 int (*sync_request)(mddev_t *mddev, sector_t sector_nr, int go_faster); 313 sector_t (*sync_request)(mddev_t *mddev, sector_t sector_nr, int *skipped, int go_faster);
295 int (*resize) (mddev_t *mddev, sector_t sectors); 314 int (*resize) (mddev_t *mddev, sector_t sectors);
296 int (*reshape) (mddev_t *mddev, int raid_disks); 315 int (*reshape) (mddev_t *mddev, int raid_disks);
297 int (*reconfig) (mddev_t *mddev, int layout, int chunk_size); 316 int (*reconfig) (mddev_t *mddev, int layout, int chunk_size);
@@ -334,6 +353,7 @@ typedef struct mdk_thread_s {
334 unsigned long flags; 353 unsigned long flags;
335 struct completion *event; 354 struct completion *event;
336 struct task_struct *tsk; 355 struct task_struct *tsk;
356 unsigned long timeout;
337 const char *name; 357 const char *name;
338} mdk_thread_t; 358} mdk_thread_t;
339 359
diff --git a/include/linux/raid/md_p.h b/include/linux/raid/md_p.h
index 8ba95d67329f..dc65cd435494 100644
--- a/include/linux/raid/md_p.h
+++ b/include/linux/raid/md_p.h
@@ -96,6 +96,7 @@ typedef struct mdp_device_descriptor_s {
96#define MD_SB_CLEAN 0 96#define MD_SB_CLEAN 0
97#define MD_SB_ERRORS 1 97#define MD_SB_ERRORS 1
98 98
99#define MD_SB_BITMAP_PRESENT 8 /* bitmap may be present nearby */
99typedef struct mdp_superblock_s { 100typedef struct mdp_superblock_s {
100 /* 101 /*
101 * Constant generic information 102 * Constant generic information
@@ -184,7 +185,7 @@ struct mdp_superblock_1 {
184 /* constant array information - 128 bytes */ 185 /* constant array information - 128 bytes */
185 __u32 magic; /* MD_SB_MAGIC: 0xa92b4efc - little endian */ 186 __u32 magic; /* MD_SB_MAGIC: 0xa92b4efc - little endian */
186 __u32 major_version; /* 1 */ 187 __u32 major_version; /* 1 */
187 __u32 feature_map; /* 0 for now */ 188 __u32 feature_map; /* bit 0 set if 'bitmap_offset' is meaningful */
188 __u32 pad0; /* always set to 0 when writing */ 189 __u32 pad0; /* always set to 0 when writing */
189 190
190 __u8 set_uuid[16]; /* user-space generated. */ 191 __u8 set_uuid[16]; /* user-space generated. */
@@ -197,7 +198,11 @@ struct mdp_superblock_1 {
197 198
198 __u32 chunksize; /* in 512byte sectors */ 199 __u32 chunksize; /* in 512byte sectors */
199 __u32 raid_disks; 200 __u32 raid_disks;
200 __u8 pad1[128-96]; /* set to 0 when written */ 201 __u32 bitmap_offset; /* sectors after start of superblock that bitmap starts
202 * NOTE: signed, so bitmap can be before superblock
203 * only meaningful of feature_map[0] is set.
204 */
205 __u8 pad1[128-100]; /* set to 0 when written */
201 206
202 /* constant this-device information - 64 bytes */ 207 /* constant this-device information - 64 bytes */
203 __u64 data_offset; /* sector start of data, often 0 */ 208 __u64 data_offset; /* sector start of data, often 0 */
diff --git a/include/linux/raid/md_u.h b/include/linux/raid/md_u.h
index a2df5c2a42af..81da20ccec4d 100644
--- a/include/linux/raid/md_u.h
+++ b/include/linux/raid/md_u.h
@@ -23,6 +23,7 @@
23#define GET_DISK_INFO _IOR (MD_MAJOR, 0x12, mdu_disk_info_t) 23#define GET_DISK_INFO _IOR (MD_MAJOR, 0x12, mdu_disk_info_t)
24#define PRINT_RAID_DEBUG _IO (MD_MAJOR, 0x13) 24#define PRINT_RAID_DEBUG _IO (MD_MAJOR, 0x13)
25#define RAID_AUTORUN _IO (MD_MAJOR, 0x14) 25#define RAID_AUTORUN _IO (MD_MAJOR, 0x14)
26#define GET_BITMAP_FILE _IOR (MD_MAJOR, 0x15, mdu_bitmap_file_t)
26 27
27/* configuration */ 28/* configuration */
28#define CLEAR_ARRAY _IO (MD_MAJOR, 0x20) 29#define CLEAR_ARRAY _IO (MD_MAJOR, 0x20)
@@ -36,6 +37,7 @@
36#define HOT_ADD_DISK _IO (MD_MAJOR, 0x28) 37#define HOT_ADD_DISK _IO (MD_MAJOR, 0x28)
37#define SET_DISK_FAULTY _IO (MD_MAJOR, 0x29) 38#define SET_DISK_FAULTY _IO (MD_MAJOR, 0x29)
38#define HOT_GENERATE_ERROR _IO (MD_MAJOR, 0x2a) 39#define HOT_GENERATE_ERROR _IO (MD_MAJOR, 0x2a)
40#define SET_BITMAP_FILE _IOW (MD_MAJOR, 0x2b, int)
39 41
40/* usage */ 42/* usage */
41#define RUN_ARRAY _IOW (MD_MAJOR, 0x30, mdu_param_t) 43#define RUN_ARRAY _IOW (MD_MAJOR, 0x30, mdu_param_t)
@@ -106,6 +108,11 @@ typedef struct mdu_start_info_s {
106 108
107} mdu_start_info_t; 109} mdu_start_info_t;
108 110
111typedef struct mdu_bitmap_file_s
112{
113 char pathname[4096];
114} mdu_bitmap_file_t;
115
109typedef struct mdu_param_s 116typedef struct mdu_param_s
110{ 117{
111 int personality; /* 1,2,3,4 */ 118 int personality; /* 1,2,3,4 */
diff --git a/include/linux/raid/raid1.h b/include/linux/raid/raid1.h
index abbfdd9afe1e..9d93cf12e890 100644
--- a/include/linux/raid/raid1.h
+++ b/include/linux/raid/raid1.h
@@ -36,12 +36,21 @@ struct r1_private_data_s {
36 spinlock_t device_lock; 36 spinlock_t device_lock;
37 37
38 struct list_head retry_list; 38 struct list_head retry_list;
39 /* queue pending writes and submit them on unplug */
40 struct bio_list pending_bio_list;
41 /* queue of writes that have been unplugged */
42 struct bio_list flushing_bio_list;
43
39 /* for use when syncing mirrors: */ 44 /* for use when syncing mirrors: */
40 45
41 spinlock_t resync_lock; 46 spinlock_t resync_lock;
42 int nr_pending; 47 int nr_pending;
43 int barrier; 48 int barrier;
44 sector_t next_resync; 49 sector_t next_resync;
50 int fullsync; /* set to 1 if a full sync is needed,
51 * (fresh device added).
52 * Cleared when a sync completes.
53 */
45 54
46 wait_queue_head_t wait_idle; 55 wait_queue_head_t wait_idle;
47 wait_queue_head_t wait_resume; 56 wait_queue_head_t wait_resume;
@@ -85,14 +94,17 @@ struct r1bio_s {
85 int read_disk; 94 int read_disk;
86 95
87 struct list_head retry_list; 96 struct list_head retry_list;
97 struct bitmap_update *bitmap_update;
88 /* 98 /*
89 * if the IO is in WRITE direction, then multiple bios are used. 99 * if the IO is in WRITE direction, then multiple bios are used.
90 * We choose the number when they are allocated. 100 * We choose the number when they are allocated.
91 */ 101 */
92 struct bio *bios[0]; 102 struct bio *bios[0];
103 /* DO NOT PUT ANY NEW FIELDS HERE - bios array is contiguously alloced*/
93}; 104};
94 105
95/* bits for r1bio.state */ 106/* bits for r1bio.state */
96#define R1BIO_Uptodate 0 107#define R1BIO_Uptodate 0
97#define R1BIO_IsSync 1 108#define R1BIO_IsSync 1
109#define R1BIO_Degraded 2
98#endif 110#endif
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 4dbb109022f3..b58afd97a180 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -201,8 +201,8 @@ extern unsigned long
201arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr, 201arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
202 unsigned long len, unsigned long pgoff, 202 unsigned long len, unsigned long pgoff,
203 unsigned long flags); 203 unsigned long flags);
204extern void arch_unmap_area(struct vm_area_struct *area); 204extern void arch_unmap_area(struct mm_struct *, unsigned long);
205extern void arch_unmap_area_topdown(struct vm_area_struct *area); 205extern void arch_unmap_area_topdown(struct mm_struct *, unsigned long);
206 206
207#define set_mm_counter(mm, member, value) (mm)->_##member = (value) 207#define set_mm_counter(mm, member, value) (mm)->_##member = (value)
208#define get_mm_counter(mm, member) ((mm)->_##member) 208#define get_mm_counter(mm, member) ((mm)->_##member)
@@ -218,9 +218,10 @@ struct mm_struct {
218 unsigned long (*get_unmapped_area) (struct file *filp, 218 unsigned long (*get_unmapped_area) (struct file *filp,
219 unsigned long addr, unsigned long len, 219 unsigned long addr, unsigned long len,
220 unsigned long pgoff, unsigned long flags); 220 unsigned long pgoff, unsigned long flags);
221 void (*unmap_area) (struct vm_area_struct *area); 221 void (*unmap_area) (struct mm_struct *mm, unsigned long addr);
222 unsigned long mmap_base; /* base of mmap area */ 222 unsigned long mmap_base; /* base of mmap area */
223 unsigned long free_area_cache; /* first hole */ 223 unsigned long cached_hole_size; /* if non-zero, the largest hole below free_area_cache */
224 unsigned long free_area_cache; /* first hole of size cached_hole_size or larger */
224 pgd_t * pgd; 225 pgd_t * pgd;
225 atomic_t mm_users; /* How many users with user space? */ 226 atomic_t mm_users; /* How many users with user space? */
226 atomic_t mm_count; /* How many references to "struct mm_struct" (users count as 1) */ 227 atomic_t mm_count; /* How many references to "struct mm_struct" (users count as 1) */
diff --git a/include/linux/smp.h b/include/linux/smp.h
index dcf1db3b35d3..9dfa3ee769ae 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -92,10 +92,7 @@ void smp_prepare_boot_cpu(void);
92/* 92/*
93 * These macros fold the SMP functionality into a single CPU system 93 * These macros fold the SMP functionality into a single CPU system
94 */ 94 */
95 95#define raw_smp_processor_id() 0
96#if !defined(__smp_processor_id) || !defined(CONFIG_PREEMPT)
97# define smp_processor_id() 0
98#endif
99#define hard_smp_processor_id() 0 96#define hard_smp_processor_id() 0
100#define smp_call_function(func,info,retry,wait) ({ 0; }) 97#define smp_call_function(func,info,retry,wait) ({ 0; })
101#define on_each_cpu(func,info,retry,wait) ({ func(info); 0; }) 98#define on_each_cpu(func,info,retry,wait) ({ func(info); 0; })
@@ -106,30 +103,25 @@ static inline void smp_send_reschedule(int cpu) { }
106#endif /* !SMP */ 103#endif /* !SMP */
107 104
108/* 105/*
109 * DEBUG_PREEMPT support: check whether smp_processor_id() is being 106 * smp_processor_id(): get the current CPU ID.
110 * used in a preemption-safe way.
111 * 107 *
112 * An architecture has to enable this debugging code explicitly. 108 * if DEBUG_PREEMPT is enabled the we check whether it is
113 * It can do so by renaming the smp_processor_id() macro to 109 * used in a preemption-safe way. (smp_processor_id() is safe
114 * __smp_processor_id(). This should only be done after some minimal 110 * if it's used in a preemption-off critical section, or in
115 * testing, because usually there are a number of false positives 111 * a thread that is bound to the current CPU.)
116 * that an architecture will trigger.
117 * 112 *
118 * To fix a false positive (i.e. smp_processor_id() use that the 113 * NOTE: raw_smp_processor_id() is for internal use only
119 * debugging code reports but which use for some reason is legal), 114 * (smp_processor_id() is the preferred variant), but in rare
120 * change the smp_processor_id() reference to _smp_processor_id(), 115 * instances it might also be used to turn off false positives
121 * which is the nondebug variant. NOTE: don't use this to hack around 116 * (i.e. smp_processor_id() use that the debugging code reports but
122 * real bugs. 117 * which use for some reason is legal). Don't use this to hack around
118 * the warning message, as your code might not work under PREEMPT.
123 */ 119 */
124#ifdef __smp_processor_id 120#ifdef CONFIG_DEBUG_PREEMPT
125# if defined(CONFIG_PREEMPT) && defined(CONFIG_DEBUG_PREEMPT) 121 extern unsigned int debug_smp_processor_id(void);
126 extern unsigned int smp_processor_id(void); 122# define smp_processor_id() debug_smp_processor_id()
127# else
128# define smp_processor_id() __smp_processor_id()
129# endif
130# define _smp_processor_id() __smp_processor_id()
131#else 123#else
132# define _smp_processor_id() smp_processor_id() 124# define smp_processor_id() raw_smp_processor_id()
133#endif 125#endif
134 126
135#define get_cpu() ({ preempt_disable(); smp_processor_id(); }) 127#define get_cpu() ({ preempt_disable(); smp_processor_id(); })
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 3bbc41be9bd0..2343f999e6e1 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -172,7 +172,8 @@ extern int rotate_reclaimable_page(struct page *page);
172extern void swap_setup(void); 172extern void swap_setup(void);
173 173
174/* linux/mm/vmscan.c */ 174/* linux/mm/vmscan.c */
175extern int try_to_free_pages(struct zone **, unsigned int, unsigned int); 175extern int try_to_free_pages(struct zone **, unsigned int);
176extern int zone_reclaim(struct zone *, unsigned int, unsigned int);
176extern int shrink_all_memory(int); 177extern int shrink_all_memory(int);
177extern int vm_swappiness; 178extern int vm_swappiness;
178 179
diff --git a/include/net/route.h b/include/net/route.h
index d34ca8fc6756..c3cd069a9aca 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -107,7 +107,7 @@ struct rt_cache_stat
107 107
108extern struct rt_cache_stat *rt_cache_stat; 108extern struct rt_cache_stat *rt_cache_stat;
109#define RT_CACHE_STAT_INC(field) \ 109#define RT_CACHE_STAT_INC(field) \
110 (per_cpu_ptr(rt_cache_stat, _smp_processor_id())->field++) 110 (per_cpu_ptr(rt_cache_stat, raw_smp_processor_id())->field++)
111 111
112extern struct ip_rt_acct *ip_rt_acct; 112extern struct ip_rt_acct *ip_rt_acct;
113 113
diff --git a/include/net/snmp.h b/include/net/snmp.h
index a15ab256276e..a36bed8ea210 100644
--- a/include/net/snmp.h
+++ b/include/net/snmp.h
@@ -128,18 +128,18 @@ struct linux_mib {
128#define SNMP_STAT_USRPTR(name) (name[1]) 128#define SNMP_STAT_USRPTR(name) (name[1])
129 129
130#define SNMP_INC_STATS_BH(mib, field) \ 130#define SNMP_INC_STATS_BH(mib, field) \
131 (per_cpu_ptr(mib[0], _smp_processor_id())->mibs[field]++) 131 (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field]++)
132#define SNMP_INC_STATS_OFFSET_BH(mib, field, offset) \ 132#define SNMP_INC_STATS_OFFSET_BH(mib, field, offset) \
133 (per_cpu_ptr(mib[0], _smp_processor_id())->mibs[field + (offset)]++) 133 (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field + (offset)]++)
134#define SNMP_INC_STATS_USER(mib, field) \ 134#define SNMP_INC_STATS_USER(mib, field) \
135 (per_cpu_ptr(mib[1], _smp_processor_id())->mibs[field]++) 135 (per_cpu_ptr(mib[1], raw_smp_processor_id())->mibs[field]++)
136#define SNMP_INC_STATS(mib, field) \ 136#define SNMP_INC_STATS(mib, field) \
137 (per_cpu_ptr(mib[!in_softirq()], _smp_processor_id())->mibs[field]++) 137 (per_cpu_ptr(mib[!in_softirq()], raw_smp_processor_id())->mibs[field]++)
138#define SNMP_DEC_STATS(mib, field) \ 138#define SNMP_DEC_STATS(mib, field) \
139 (per_cpu_ptr(mib[!in_softirq()], _smp_processor_id())->mibs[field]--) 139 (per_cpu_ptr(mib[!in_softirq()], raw_smp_processor_id())->mibs[field]--)
140#define SNMP_ADD_STATS_BH(mib, field, addend) \ 140#define SNMP_ADD_STATS_BH(mib, field, addend) \
141 (per_cpu_ptr(mib[0], _smp_processor_id())->mibs[field] += addend) 141 (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field] += addend)
142#define SNMP_ADD_STATS_USER(mib, field, addend) \ 142#define SNMP_ADD_STATS_USER(mib, field, addend) \
143 (per_cpu_ptr(mib[1], _smp_processor_id())->mibs[field] += addend) 143 (per_cpu_ptr(mib[1], raw_smp_processor_id())->mibs[field] += addend)
144 144
145#endif 145#endif
diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 2433e279e071..1309c12b8f71 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -437,6 +437,7 @@ struct snd_ac97_build_ops {
437 void (*suspend) (ac97_t *ac97); 437 void (*suspend) (ac97_t *ac97);
438 void (*resume) (ac97_t *ac97); 438 void (*resume) (ac97_t *ac97);
439#endif 439#endif
440 void (*update_jacks) (ac97_t *ac97); /* for jack-sharing */
440}; 441};
441 442
442struct _snd_ac97_bus_ops { 443struct _snd_ac97_bus_ops {
@@ -516,6 +517,9 @@ struct _snd_ac97 {
516 } ad18xx; 517 } ad18xx;
517 unsigned int dev_flags; /* device specific */ 518 unsigned int dev_flags; /* device specific */
518 } spec; 519 } spec;
520 /* jack-sharing info */
521 unsigned char indep_surround;
522 unsigned char channel_mode;
519}; 523};
520 524
521/* conditions */ 525/* conditions */
@@ -569,8 +573,8 @@ enum {
569}; 573};
570 574
571struct ac97_quirk { 575struct ac97_quirk {
572 unsigned short vendor; /* PCI vendor id */ 576 unsigned short subvendor; /* PCI subsystem vendor id */
573 unsigned short device; /* PCI device id */ 577 unsigned short subdevice; /* PCI sybsystem device id */
574 unsigned short mask; /* device id bit mask, 0 = accept all */ 578 unsigned short mask; /* device id bit mask, 0 = accept all */
575 unsigned int codec_id; /* codec id (if any), 0 = accept all */ 579 unsigned int codec_id; /* codec id (if any), 0 = accept all */
576 const char *name; /* name shown as info */ 580 const char *name; /* name shown as info */
diff --git a/include/sound/asound.h b/include/sound/asound.h
index a4d149f34541..9974f83cca44 100644
--- a/include/sound/asound.h
+++ b/include/sound/asound.h
@@ -113,9 +113,10 @@ enum sndrv_hwdep_iface {
113 SNDRV_HWDEP_IFACE_BLUETOOTH, /* Bluetooth audio */ 113 SNDRV_HWDEP_IFACE_BLUETOOTH, /* Bluetooth audio */
114 SNDRV_HWDEP_IFACE_USX2Y_PCM, /* Tascam US122, US224 & US428 rawusb pcm */ 114 SNDRV_HWDEP_IFACE_USX2Y_PCM, /* Tascam US122, US224 & US428 rawusb pcm */
115 SNDRV_HWDEP_IFACE_PCXHR, /* Digigram PCXHR */ 115 SNDRV_HWDEP_IFACE_PCXHR, /* Digigram PCXHR */
116 SNDRV_HWDEP_IFACE_SB_RC, /* SB Extigy/Audigy2NX remote control */
116 117
117 /* Don't forget to change the following: */ 118 /* Don't forget to change the following: */
118 SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_PCXHR 119 SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_SB_RC
119}; 120};
120 121
121struct sndrv_hwdep_info { 122struct sndrv_hwdep_info {
@@ -344,7 +345,7 @@ enum sndrv_pcm_hw_param {
344 SNDRV_PCM_HW_PARAM_LAST_INTERVAL = SNDRV_PCM_HW_PARAM_TICK_TIME 345 SNDRV_PCM_HW_PARAM_LAST_INTERVAL = SNDRV_PCM_HW_PARAM_TICK_TIME
345}; 346};
346 347
347#define SNDRV_PCM_HW_PARAMS_RUNTIME (1<<0) 348#define SNDRV_PCM_HW_PARAMS_NORESAMPLE (1<<0) /* avoid rate resampling */
348 349
349struct sndrv_interval { 350struct sndrv_interval {
350 unsigned int min, max; 351 unsigned int min, max;
@@ -559,7 +560,7 @@ enum {
559 * Timer section - /dev/snd/timer 560 * Timer section - /dev/snd/timer
560 */ 561 */
561 562
562#define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 2) 563#define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 4)
563 564
564enum sndrv_timer_class { 565enum sndrv_timer_class {
565 SNDRV_TIMER_CLASS_NONE = -1, 566 SNDRV_TIMER_CLASS_NONE = -1,
@@ -672,10 +673,11 @@ enum {
672 SNDRV_TIMER_IOCTL_INFO = _IOR('T', 0x11, struct sndrv_timer_info), 673 SNDRV_TIMER_IOCTL_INFO = _IOR('T', 0x11, struct sndrv_timer_info),
673 SNDRV_TIMER_IOCTL_PARAMS = _IOW('T', 0x12, struct sndrv_timer_params), 674 SNDRV_TIMER_IOCTL_PARAMS = _IOW('T', 0x12, struct sndrv_timer_params),
674 SNDRV_TIMER_IOCTL_STATUS = _IOR('T', 0x14, struct sndrv_timer_status), 675 SNDRV_TIMER_IOCTL_STATUS = _IOR('T', 0x14, struct sndrv_timer_status),
675 SNDRV_TIMER_IOCTL_START = _IO('T', 0x20), 676 /* The following four ioctls are changed since 1.0.9 due to confliction */
676 SNDRV_TIMER_IOCTL_STOP = _IO('T', 0x21), 677 SNDRV_TIMER_IOCTL_START = _IO('T', 0xa0),
677 SNDRV_TIMER_IOCTL_CONTINUE = _IO('T', 0x22), 678 SNDRV_TIMER_IOCTL_STOP = _IO('T', 0xa1),
678 SNDRV_TIMER_IOCTL_PAUSE = _IO('T', 0x23), 679 SNDRV_TIMER_IOCTL_CONTINUE = _IO('T', 0xa2),
680 SNDRV_TIMER_IOCTL_PAUSE = _IO('T', 0xa3),
679}; 681};
680 682
681struct sndrv_timer_read { 683struct sndrv_timer_read {
diff --git a/include/sound/control.h b/include/sound/control.h
index 7b9444cd02f4..ef7903c7a327 100644
--- a/include/sound/control.h
+++ b/include/sound/control.h
@@ -106,7 +106,7 @@ typedef int (*snd_kctl_ioctl_func_t) (snd_card_t * card,
106void snd_ctl_notify(snd_card_t * card, unsigned int mask, snd_ctl_elem_id_t * id); 106void snd_ctl_notify(snd_card_t * card, unsigned int mask, snd_ctl_elem_id_t * id);
107 107
108snd_kcontrol_t *snd_ctl_new(snd_kcontrol_t * kcontrol, unsigned int access); 108snd_kcontrol_t *snd_ctl_new(snd_kcontrol_t * kcontrol, unsigned int access);
109snd_kcontrol_t *snd_ctl_new1(snd_kcontrol_new_t * kcontrolnew, void * private_data); 109snd_kcontrol_t *snd_ctl_new1(const snd_kcontrol_new_t * kcontrolnew, void * private_data);
110void snd_ctl_free_one(snd_kcontrol_t * kcontrol); 110void snd_ctl_free_one(snd_kcontrol_t * kcontrol);
111int snd_ctl_add(snd_card_t * card, snd_kcontrol_t * kcontrol); 111int snd_ctl_add(snd_card_t * card, snd_kcontrol_t * kcontrol);
112int snd_ctl_remove(snd_card_t * card, snd_kcontrol_t * kcontrol); 112int snd_ctl_remove(snd_card_t * card, snd_kcontrol_t * kcontrol);
diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h
index 43b6786abae5..c50b91958ff9 100644
--- a/include/sound/emu10k1.h
+++ b/include/sound/emu10k1.h
@@ -83,7 +83,8 @@
83#define IPR 0x08 /* Global interrupt pending register */ 83#define IPR 0x08 /* Global interrupt pending register */
84 /* Clear pending interrupts by writing a 1 to */ 84 /* Clear pending interrupts by writing a 1 to */
85 /* the relevant bits and zero to the other bits */ 85 /* the relevant bits and zero to the other bits */
86 86#define IPR_P16V 0x80000000 /* Bit set when the CA0151 P16V chip wishes
87 to interrupt */
87#define IPR_GPIOMSG 0x20000000 /* GPIO message interrupt (RE'd, still not sure 88#define IPR_GPIOMSG 0x20000000 /* GPIO message interrupt (RE'd, still not sure
88 which INTE bits enable it) */ 89 which INTE bits enable it) */
89 90
@@ -746,6 +747,7 @@
746 /* Assumes sample lock */ 747 /* Assumes sample lock */
747 748
748/* These three bitfields apply to CDSRCS, GPSRCS, and (except as noted) ZVSRCS. */ 749/* These three bitfields apply to CDSRCS, GPSRCS, and (except as noted) ZVSRCS. */
750#define SRCS_SPDIFVALID 0x04000000 /* SPDIF stream valid */
749#define SRCS_SPDIFLOCKED 0x02000000 /* SPDIF stream locked */ 751#define SRCS_SPDIFLOCKED 0x02000000 /* SPDIF stream locked */
750#define SRCS_RATELOCKED 0x01000000 /* Sample rate locked */ 752#define SRCS_RATELOCKED 0x01000000 /* Sample rate locked */
751#define SRCS_ESTSAMPLERATE 0x0007ffff /* Do not modify this field. */ 753#define SRCS_ESTSAMPLERATE 0x0007ffff /* Do not modify this field. */
@@ -803,10 +805,26 @@
803#define A_FXWC2 0x75 /* Selects 0x9f-0x80 for FX recording */ 805#define A_FXWC2 0x75 /* Selects 0x9f-0x80 for FX recording */
804 806
805#define A_SPDIF_SAMPLERATE 0x76 /* Set the sample rate of SPDIF output */ 807#define A_SPDIF_SAMPLERATE 0x76 /* Set the sample rate of SPDIF output */
806#define A_SPDIF_RATE_MASK 0x000000c0 808#define A_SAMPLE_RATE 0x76 /* Various sample rate settings. */
809#define A_SAMPLE_RATE_NOT_USED 0x0ffc111e /* Bits that are not used and cannot be set. */
810#define A_SAMPLE_RATE_UNKNOWN 0xf0030001 /* Bits that can be set, but have unknown use. */
811#define A_SPDIF_RATE_MASK 0x000000e0 /* Any other values for rates, just use 48000 */
807#define A_SPDIF_48000 0x00000000 812#define A_SPDIF_48000 0x00000000
808#define A_SPDIF_44100 0x00000080 813#define A_SPDIF_192000 0x00000020
809#define A_SPDIF_96000 0x00000040 814#define A_SPDIF_96000 0x00000040
815#define A_SPDIF_44100 0x00000080
816
817#define A_I2S_CAPTURE_RATE_MASK 0x00000e00 /* This sets the capture PCM rate, but it is */
818#define A_I2S_CAPTURE_48000 0x00000000 /* unclear if this sets the ADC rate as well. */
819#define A_I2S_CAPTURE_192000 0x00000200
820#define A_I2S_CAPTURE_96000 0x00000400
821#define A_I2S_CAPTURE_44100 0x00000800
822
823#define A_PCM_RATE_MASK 0x0000e000 /* This sets the playback PCM rate on the P16V */
824#define A_PCM_48000 0x00000000
825#define A_PCM_192000 0x00002000
826#define A_PCM_96000 0x00004000
827#define A_PCM_44100 0x00008000
810 828
811/* 0x77,0x78,0x79 "something i2s-related" - default to 0x01080000 on my audigy 2 ZS --rlrevell */ 829/* 0x77,0x78,0x79 "something i2s-related" - default to 0x01080000 on my audigy 2 ZS --rlrevell */
812/* 0x7a, 0x7b - lookup tables */ 830/* 0x7a, 0x7b - lookup tables */
@@ -1039,28 +1057,28 @@ typedef struct {
1039 u32 vendor; 1057 u32 vendor;
1040 u32 device; 1058 u32 device;
1041 u32 subsystem; 1059 u32 subsystem;
1060 unsigned char revision;
1042 unsigned char emu10k1_chip; /* Original SB Live. Not SB Live 24bit. */ 1061 unsigned char emu10k1_chip; /* Original SB Live. Not SB Live 24bit. */
1043 unsigned char emu10k2_chip; /* Audigy 1 or Audigy 2. */ 1062 unsigned char emu10k2_chip; /* Audigy 1 or Audigy 2. */
1044 unsigned char ca0102_chip; /* Audigy 1 or Audigy 2. Not SB Audigy 2 Value. */ 1063 unsigned char ca0102_chip; /* Audigy 1 or Audigy 2. Not SB Audigy 2 Value. */
1045 unsigned char ca0108_chip; /* Audigy 2 Value */ 1064 unsigned char ca0108_chip; /* Audigy 2 Value */
1046 unsigned char ca0151_chip; /* P16V */ 1065 unsigned char ca0151_chip; /* P16V */
1047 unsigned char spk71; /* Has 7.1 speakers */ 1066 unsigned char spk71; /* Has 7.1 speakers */
1067 unsigned char sblive51; /* SBLive! 5.1 - extout 0x11 -> center, 0x12 -> lfe */
1048 unsigned char spdif_bug; /* Has Spdif phasing bug */ 1068 unsigned char spdif_bug; /* Has Spdif phasing bug */
1049 unsigned char ac97_chip; /* Has an AC97 chip */ 1069 unsigned char ac97_chip; /* Has an AC97 chip */
1050 unsigned char ecard; /* APS EEPROM */ 1070 unsigned char ecard; /* APS EEPROM */
1051 char * driver; 1071 const char *driver;
1052 char * name; 1072 const char *name;
1073 const char *id; /* for backward compatibility - can be NULL if not needed */
1053} emu_chip_details_t; 1074} emu_chip_details_t;
1054 1075
1055struct _snd_emu10k1 { 1076struct _snd_emu10k1 {
1056 int irq; 1077 int irq;
1057 1078
1058 unsigned long port; /* I/O port number */ 1079 unsigned long port; /* I/O port number */
1059 unsigned int APS: 1, /* APS flag */ 1080 unsigned int tos_link: 1, /* tos link detected */
1060 no_ac97: 1, /* no AC'97 */ 1081 rear_ac97: 1; /* rear channels are on AC'97 */
1061 tos_link: 1, /* tos link detected */
1062 rear_ac97: 1, /* rear channels are on AC'97 */
1063 spk71:1; /* 7.1 configuration (Audigy 2 ZS) */
1064 const emu_chip_details_t *card_capabilities; /* Contains profile of card capabilities */ 1082 const emu_chip_details_t *card_capabilities; /* Contains profile of card capabilities */
1065 unsigned int audigy; /* is Audigy? */ 1083 unsigned int audigy; /* is Audigy? */
1066 unsigned int revision; /* chip revision */ 1084 unsigned int revision; /* chip revision */
@@ -1109,7 +1127,10 @@ struct _snd_emu10k1 {
1109 1127
1110 emu10k1_voice_t voices[NUM_G]; 1128 emu10k1_voice_t voices[NUM_G];
1111 emu10k1_voice_t p16v_voices[4]; 1129 emu10k1_voice_t p16v_voices[4];
1130 emu10k1_voice_t p16v_capture_voice;
1112 int p16v_device_offset; 1131 int p16v_device_offset;
1132 u32 p16v_capture_source;
1133 u32 p16v_capture_channel;
1113 emu10k1_pcm_mixer_t pcm_mixer[32]; 1134 emu10k1_pcm_mixer_t pcm_mixer[32];
1114 emu10k1_pcm_mixer_t efx_pcm_mixer[NUM_EFX_PLAYBACK]; 1135 emu10k1_pcm_mixer_t efx_pcm_mixer[NUM_EFX_PLAYBACK];
1115 snd_kcontrol_t *ctl_send_routing; 1136 snd_kcontrol_t *ctl_send_routing;
@@ -1453,7 +1474,6 @@ int snd_emu10k1_fx8010_unregister_irq_handler(emu10k1_t *emu,
1453#endif 1474#endif
1454 1475
1455typedef struct { 1476typedef struct {
1456 unsigned int card; /* card type */
1457 unsigned int internal_tram_size; /* in samples */ 1477 unsigned int internal_tram_size; /* in samples */
1458 unsigned int external_tram_size; /* in samples */ 1478 unsigned int external_tram_size; /* in samples */
1459 char fxbus_names[16][32]; /* names of FXBUSes */ 1479 char fxbus_names[16][32]; /* names of FXBUSes */
diff --git a/include/sound/gus.h b/include/sound/gus.h
index 8b6287a6fff5..b4b461ca173d 100644
--- a/include/sound/gus.h
+++ b/include/sound/gus.h
@@ -526,9 +526,6 @@ extern void snd_gf1_adlib_write(snd_gus_card_t * gus, unsigned char reg, unsigne
526extern void snd_gf1_dram_addr(snd_gus_card_t * gus, unsigned int addr); 526extern void snd_gf1_dram_addr(snd_gus_card_t * gus, unsigned int addr);
527extern void snd_gf1_poke(snd_gus_card_t * gus, unsigned int addr, unsigned char data); 527extern void snd_gf1_poke(snd_gus_card_t * gus, unsigned int addr, unsigned char data);
528extern unsigned char snd_gf1_peek(snd_gus_card_t * gus, unsigned int addr); 528extern unsigned char snd_gf1_peek(snd_gus_card_t * gus, unsigned int addr);
529extern void snd_gf1_pokew(snd_gus_card_t * gus, unsigned int addr, unsigned short data);
530extern unsigned short snd_gf1_peekw(snd_gus_card_t * gus, unsigned int addr);
531extern void snd_gf1_dram_setmem(snd_gus_card_t * gus, unsigned int addr, unsigned short value, unsigned int count);
532extern void snd_gf1_write_addr(snd_gus_card_t * gus, unsigned char reg, unsigned int addr, short w_16bit); 529extern void snd_gf1_write_addr(snd_gus_card_t * gus, unsigned char reg, unsigned int addr, short w_16bit);
533extern unsigned int snd_gf1_read_addr(snd_gus_card_t * gus, unsigned char reg, short w_16bit); 530extern unsigned int snd_gf1_read_addr(snd_gus_card_t * gus, unsigned char reg, short w_16bit);
534extern void snd_gf1_i_ctrl_stop(snd_gus_card_t * gus, unsigned char reg); 531extern void snd_gf1_i_ctrl_stop(snd_gus_card_t * gus, unsigned char reg);
@@ -544,9 +541,6 @@ extern inline unsigned short snd_gf1_i_read16(snd_gus_card_t * gus, unsigned cha
544{ 541{
545 return snd_gf1_i_look16(gus, reg | 0x80); 542 return snd_gf1_i_look16(gus, reg | 0x80);
546} 543}
547extern void snd_gf1_i_adlib_write(snd_gus_card_t * gus, unsigned char reg, unsigned char data);
548extern void snd_gf1_i_write_addr(snd_gus_card_t * gus, unsigned char reg, unsigned int addr, short w_16bit);
549extern unsigned int snd_gf1_i_read_addr(snd_gus_card_t * gus, unsigned char reg, short w_16bit);
550 544
551extern void snd_gf1_select_active_voices(snd_gus_card_t * gus); 545extern void snd_gf1_select_active_voices(snd_gus_card_t * gus);
552 546
@@ -580,10 +574,6 @@ extern void snd_gf1_lfo_command(snd_gus_card_t * gus, int voice, unsigned char *
580 574
581void snd_gf1_mem_lock(snd_gf1_mem_t * alloc, int xup); 575void snd_gf1_mem_lock(snd_gf1_mem_t * alloc, int xup);
582int snd_gf1_mem_xfree(snd_gf1_mem_t * alloc, snd_gf1_mem_block_t * block); 576int snd_gf1_mem_xfree(snd_gf1_mem_t * alloc, snd_gf1_mem_block_t * block);
583snd_gf1_mem_block_t *snd_gf1_mem_look(snd_gf1_mem_t * alloc,
584 unsigned int address);
585snd_gf1_mem_block_t *snd_gf1_mem_share(snd_gf1_mem_t * alloc,
586 unsigned int *share_id);
587snd_gf1_mem_block_t *snd_gf1_mem_alloc(snd_gf1_mem_t * alloc, int owner, 577snd_gf1_mem_block_t *snd_gf1_mem_alloc(snd_gf1_mem_t * alloc, int owner,
588 char *name, int size, int w_16, 578 char *name, int size, int w_16,
589 int align, unsigned int *share_id); 579 int align, unsigned int *share_id);
@@ -608,23 +598,13 @@ int snd_gf1_dma_transfer_block(snd_gus_card_t * gus,
608/* gus_volume.c */ 598/* gus_volume.c */
609 599
610unsigned short snd_gf1_lvol_to_gvol_raw(unsigned int vol); 600unsigned short snd_gf1_lvol_to_gvol_raw(unsigned int vol);
611unsigned int snd_gf1_gvol_to_lvol_raw(unsigned short gf1_vol);
612unsigned int snd_gf1_calc_ramp_rate(snd_gus_card_t * gus,
613 unsigned short start,
614 unsigned short end,
615 unsigned int us);
616unsigned short snd_gf1_translate_freq(snd_gus_card_t * gus, unsigned int freq2); 601unsigned short snd_gf1_translate_freq(snd_gus_card_t * gus, unsigned int freq2);
617unsigned short snd_gf1_compute_pitchbend(unsigned short pitchbend, unsigned short sens);
618unsigned short snd_gf1_compute_freq(unsigned int freq,
619 unsigned int rate,
620 unsigned short mix_rate);
621 602
622/* gus_reset.c */ 603/* gus_reset.c */
623 604
624void snd_gf1_set_default_handlers(snd_gus_card_t * gus, unsigned int what); 605void snd_gf1_set_default_handlers(snd_gus_card_t * gus, unsigned int what);
625void snd_gf1_smart_stop_voice(snd_gus_card_t * gus, unsigned short voice); 606void snd_gf1_smart_stop_voice(snd_gus_card_t * gus, unsigned short voice);
626void snd_gf1_stop_voice(snd_gus_card_t * gus, unsigned short voice); 607void snd_gf1_stop_voice(snd_gus_card_t * gus, unsigned short voice);
627void snd_gf1_clear_voices(snd_gus_card_t * gus, unsigned short v_min, unsigned short v_max);
628void snd_gf1_stop_voices(snd_gus_card_t * gus, unsigned short v_min, unsigned short v_max); 608void snd_gf1_stop_voices(snd_gus_card_t * gus, unsigned short v_min, unsigned short v_max);
629snd_gus_voice_t *snd_gf1_alloc_voice(snd_gus_card_t * gus, int type, int client, int port); 609snd_gus_voice_t *snd_gf1_alloc_voice(snd_gus_card_t * gus, int type, int client, int port);
630void snd_gf1_free_voice(snd_gus_card_t * gus, snd_gus_voice_t *voice); 610void snd_gf1_free_voice(snd_gus_card_t * gus, snd_gus_voice_t *voice);
@@ -641,9 +621,6 @@ int snd_gf1_pcm_new(snd_gus_card_t * gus, int pcm_dev, int control_index, snd_pc
641 621
642#ifdef CONFIG_SND_DEBUG 622#ifdef CONFIG_SND_DEBUG
643extern void snd_gf1_print_voice_registers(snd_gus_card_t * gus); 623extern void snd_gf1_print_voice_registers(snd_gus_card_t * gus);
644extern void snd_gf1_print_global_registers(snd_gus_card_t * gus);
645extern void snd_gf1_print_setup_registers(snd_gus_card_t * gus);
646extern void snd_gf1_peek_print_block(snd_gus_card_t * gus, unsigned int addr, int count, int w_16bit);
647#endif 624#endif
648 625
649/* gus.c */ 626/* gus.c */
diff --git a/include/sound/hdspm.h b/include/sound/hdspm.h
new file mode 100644
index 000000000000..c34427ccd0b3
--- /dev/null
+++ b/include/sound/hdspm.h
@@ -0,0 +1,131 @@
1#ifndef __SOUND_HDSPM_H /* -*- linux-c -*- */
2#define __SOUND_HDSPM_H
3/*
4 * Copyright (C) 2003 Winfried Ritsch (IEM)
5 * based on hdsp.h from Thomas Charbonnel (thomas@undata.org)
6 *
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., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23/* Maximum channels is 64 even on 56Mode you have 64playbacks to matrix */
24#define HDSPM_MAX_CHANNELS 64
25
26/* -------------------- IOCTL Peak/RMS Meters -------------------- */
27
28typedef struct _snd_hdspm_peak_rms hdspm_peak_rms_t;
29
30/* peam rms level structure like we get from hardware
31
32 maybe in future we can memory map it so I just copy it
33 to user on ioctl call now an dont change anything
34 rms are made out of low and high values
35 where (long) ????_rms = (????_rms_l >> 8) + ((????_rms_h & 0xFFFFFF00)<<24)
36 (i asume so from the code)
37*/
38
39struct _snd_hdspm_peak_rms {
40
41 unsigned int level_offset[1024];
42
43 unsigned int input_peak[64];
44 unsigned int playback_peak[64];
45 unsigned int output_peak[64];
46 unsigned int xxx_peak[64]; /* not used */
47
48 unsigned int reserved[256]; /* not used */
49
50 unsigned int input_rms_l[64];
51 unsigned int playback_rms_l[64];
52 unsigned int output_rms_l[64];
53 unsigned int xxx_rms_l[64]; /* not used */
54
55 unsigned int input_rms_h[64];
56 unsigned int playback_rms_h[64];
57 unsigned int output_rms_h[64];
58 unsigned int xxx_rms_h[64]; /* not used */
59};
60
61struct sndrv_hdspm_peak_rms_ioctl {
62 hdspm_peak_rms_t *peak;
63};
64
65/* use indirect access due to the limit of ioctl bit size */
66#define SNDRV_HDSPM_IOCTL_GET_PEAK_RMS _IOR('H', 0x40, struct sndrv_hdspm_peak_rms_ioctl)
67
68/* ------------ CONFIG block IOCTL ---------------------- */
69
70typedef struct _snd_hdspm_config_info hdspm_config_info_t;
71
72struct _snd_hdspm_config_info {
73 unsigned char pref_sync_ref;
74 unsigned char wordclock_sync_check;
75 unsigned char madi_sync_check;
76 unsigned int system_sample_rate;
77 unsigned int autosync_sample_rate;
78 unsigned char system_clock_mode;
79 unsigned char clock_source;
80 unsigned char autosync_ref;
81 unsigned char line_out;
82 unsigned int passthru;
83 unsigned int analog_out;
84};
85
86#define SNDRV_HDSPM_IOCTL_GET_CONFIG_INFO _IOR('H', 0x41, hdspm_config_info_t)
87
88
89/* get Soundcard Version */
90
91typedef struct _snd_hdspm_version hdspm_version_t;
92
93struct _snd_hdspm_version {
94 unsigned short firmware_rev;
95};
96
97#define SNDRV_HDSPM_IOCTL_GET_VERSION _IOR('H', 0x43, hdspm_version_t)
98
99
100/* ------------- get Matrix Mixer IOCTL --------------- */
101
102/* MADI mixer: 64inputs+64playback in 64outputs = 8192 => *4Byte = 32768 Bytes */
103
104/* organisation is 64 channelfader in a continous memory block */
105/* equivalent to hardware definition, maybe for future feature of mmap of them */
106/* each of 64 outputs has 64 infader and 64 outfader:
107 Ins to Outs mixer[out].in[in], Outstreams to Outs mixer[out].pb[pb] */
108
109#define HDSPM_MIXER_CHANNELS HDSPM_MAX_CHANNELS
110
111typedef struct _snd_hdspm_channelfader snd_hdspm_channelfader_t;
112
113struct _snd_hdspm_channelfader {
114 unsigned int in[HDSPM_MIXER_CHANNELS];
115 unsigned int pb[HDSPM_MIXER_CHANNELS];
116};
117
118typedef struct _snd_hdspm_mixer hdspm_mixer_t;
119
120struct _snd_hdspm_mixer {
121 snd_hdspm_channelfader_t ch[HDSPM_MIXER_CHANNELS];
122};
123
124struct sndrv_hdspm_mixer_ioctl {
125 hdspm_mixer_t *mixer;
126};
127
128/* use indirect access due to the limit of ioctl bit size */
129#define SNDRV_HDSPM_IOCTL_GET_MIXER _IOR('H', 0x44, struct sndrv_hdspm_mixer_ioctl)
130
131#endif /* __SOUND_HDSPM_H */
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 53fc04d75bad..d935417575b5 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -848,23 +848,6 @@ int snd_interval_ratnum(snd_interval_t *i,
848 848
849void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params); 849void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params);
850void _snd_pcm_hw_param_setempty(snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var); 850void _snd_pcm_hw_param_setempty(snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var);
851int snd_pcm_hw_param_min(snd_pcm_substream_t *substream,
852 snd_pcm_hw_params_t *params,
853 snd_pcm_hw_param_t var,
854 unsigned int val, int *dir);
855int snd_pcm_hw_param_max(snd_pcm_substream_t *substream,
856 snd_pcm_hw_params_t *params,
857 snd_pcm_hw_param_t var,
858 unsigned int val, int *dir);
859int snd_pcm_hw_param_setinteger(snd_pcm_substream_t *substream,
860 snd_pcm_hw_params_t *params,
861 snd_pcm_hw_param_t var);
862int snd_pcm_hw_param_first(snd_pcm_substream_t *substream,
863 snd_pcm_hw_params_t *params,
864 snd_pcm_hw_param_t var, int *dir);
865int snd_pcm_hw_param_last(snd_pcm_substream_t *substream,
866 snd_pcm_hw_params_t *params,
867 snd_pcm_hw_param_t var, int *dir);
868int snd_pcm_hw_param_near(snd_pcm_substream_t *substream, 851int snd_pcm_hw_param_near(snd_pcm_substream_t *substream,
869 snd_pcm_hw_params_t *params, 852 snd_pcm_hw_params_t *params,
870 snd_pcm_hw_param_t var, 853 snd_pcm_hw_param_t var,
@@ -876,7 +859,6 @@ int snd_pcm_hw_param_set(snd_pcm_substream_t *pcm,
876int snd_pcm_hw_params_choose(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params); 859int snd_pcm_hw_params_choose(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params);
877 860
878int snd_pcm_hw_refine(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params); 861int snd_pcm_hw_refine(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params);
879int snd_pcm_hw_params(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params);
880 862
881int snd_pcm_hw_constraints_init(snd_pcm_substream_t *substream); 863int snd_pcm_hw_constraints_init(snd_pcm_substream_t *substream);
882int snd_pcm_hw_constraints_complete(snd_pcm_substream_t *substream); 864int snd_pcm_hw_constraints_complete(snd_pcm_substream_t *substream);
@@ -922,8 +904,22 @@ int snd_pcm_format_unsigned(snd_pcm_format_t format);
922int snd_pcm_format_linear(snd_pcm_format_t format); 904int snd_pcm_format_linear(snd_pcm_format_t format);
923int snd_pcm_format_little_endian(snd_pcm_format_t format); 905int snd_pcm_format_little_endian(snd_pcm_format_t format);
924int snd_pcm_format_big_endian(snd_pcm_format_t format); 906int snd_pcm_format_big_endian(snd_pcm_format_t format);
907/**
908 * snd_pcm_format_cpu_endian - Check the PCM format is CPU-endian
909 * @format: the format to check
910 *
911 * Returns 1 if the given PCM format is CPU-endian, 0 if
912 * opposite, or a negative error code if endian not specified.
913 */
914/* int snd_pcm_format_cpu_endian(snd_pcm_format_t format); */
915#ifdef SNDRV_LITTLE_ENDIAN
916#define snd_pcm_format_cpu_endian snd_pcm_format_little_endian
917#else
918#define snd_pcm_format_cpu_endian snd_pcm_format_big_endian
919#endif
925int snd_pcm_format_width(snd_pcm_format_t format); /* in bits */ 920int snd_pcm_format_width(snd_pcm_format_t format); /* in bits */
926int snd_pcm_format_physical_width(snd_pcm_format_t format); /* in bits */ 921int snd_pcm_format_physical_width(snd_pcm_format_t format); /* in bits */
922ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples);
927const unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format); 923const unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format);
928int snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int frames); 924int snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int frames);
929snd_pcm_format_t snd_pcm_build_linear_format(int width, int unsignd, int big_endian); 925snd_pcm_format_t snd_pcm_build_linear_format(int width, int unsignd, int big_endian);
diff --git a/include/sound/seq_midi_event.h b/include/sound/seq_midi_event.h
index 4357cac07500..8857e2bd31a5 100644
--- a/include/sound/seq_midi_event.h
+++ b/include/sound/seq_midi_event.h
@@ -41,9 +41,7 @@ struct snd_midi_event_t {
41}; 41};
42 42
43int snd_midi_event_new(int bufsize, snd_midi_event_t **rdev); 43int snd_midi_event_new(int bufsize, snd_midi_event_t **rdev);
44int snd_midi_event_resize_buffer(snd_midi_event_t *dev, int bufsize);
45void snd_midi_event_free(snd_midi_event_t *dev); 44void snd_midi_event_free(snd_midi_event_t *dev);
46void snd_midi_event_init(snd_midi_event_t *dev);
47void snd_midi_event_reset_encode(snd_midi_event_t *dev); 45void snd_midi_event_reset_encode(snd_midi_event_t *dev);
48void snd_midi_event_reset_decode(snd_midi_event_t *dev); 46void snd_midi_event_reset_decode(snd_midi_event_t *dev);
49void snd_midi_event_no_status(snd_midi_event_t *dev, int on); 47void snd_midi_event_no_status(snd_midi_event_t *dev, int on);
diff --git a/include/sound/seq_virmidi.h b/include/sound/seq_virmidi.h
index cf4e2388103f..1ad27e859af3 100644
--- a/include/sound/seq_virmidi.h
+++ b/include/sound/seq_virmidi.h
@@ -79,6 +79,5 @@ struct _snd_virmidi_dev {
79#define SNDRV_VIRMIDI_SEQ_DISPATCH 2 79#define SNDRV_VIRMIDI_SEQ_DISPATCH 2
80 80
81int snd_virmidi_new(snd_card_t *card, int device, snd_rawmidi_t **rrmidi); 81int snd_virmidi_new(snd_card_t *card, int device, snd_rawmidi_t **rrmidi);
82int snd_virmidi_receive(snd_rawmidi_t *rmidi, snd_seq_event_t *ev);
83 82
84#endif /* __SOUND_SEQ_VIRMIDI */ 83#endif /* __SOUND_SEQ_VIRMIDI */
diff --git a/include/sound/timer.h b/include/sound/timer.h
index 57fde990606e..1898511a0f38 100644
--- a/include/sound/timer.h
+++ b/include/sound/timer.h
@@ -152,6 +152,4 @@ extern int snd_timer_pause(snd_timer_instance_t * timeri);
152 152
153extern void snd_timer_interrupt(snd_timer_t * timer, unsigned long ticks_left); 153extern void snd_timer_interrupt(snd_timer_t * timer, unsigned long ticks_left);
154 154
155extern unsigned int snd_timer_system_resolution(void);
156
157#endif /* __SOUND_TIMER_H */ 155#endif /* __SOUND_TIMER_H */
diff --git a/include/sound/version.h b/include/sound/version.h
index 98b4230778ed..46acfa8c9988 100644
--- a/include/sound/version.h
+++ b/include/sound/version.h
@@ -1,3 +1,3 @@
1/* include/version.h. Generated by configure. */ 1/* include/version.h. Generated by configure. */
2#define CONFIG_SND_VERSION "1.0.9rc2" 2#define CONFIG_SND_VERSION "1.0.9"
3#define CONFIG_SND_DATE " (Thu Mar 24 10:33:39 2005 UTC)" 3#define CONFIG_SND_DATE " (Sun May 29 07:31:02 2005 UTC)"
diff --git a/init/main.c b/init/main.c
index 40bf367ffdf1..d324801729ba 100644
--- a/init/main.c
+++ b/init/main.c
@@ -490,6 +490,7 @@ asmlinkage void __init start_kernel(void)
490 vfs_caches_init_early(); 490 vfs_caches_init_early();
491 mem_init(); 491 mem_init();
492 kmem_cache_init(); 492 kmem_cache_init();
493 setup_per_cpu_pageset();
493 numa_policy_init(); 494 numa_policy_init();
494 if (late_time_init) 495 if (late_time_init)
495 late_time_init(); 496 late_time_init();
diff --git a/kernel/fork.c b/kernel/fork.c
index f42a17f88699..a28d11e10877 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -194,6 +194,7 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm)
194 mm->mmap = NULL; 194 mm->mmap = NULL;
195 mm->mmap_cache = NULL; 195 mm->mmap_cache = NULL;
196 mm->free_area_cache = oldmm->mmap_base; 196 mm->free_area_cache = oldmm->mmap_base;
197 mm->cached_hole_size = ~0UL;
197 mm->map_count = 0; 198 mm->map_count = 0;
198 set_mm_counter(mm, rss, 0); 199 set_mm_counter(mm, rss, 0);
199 set_mm_counter(mm, anon_rss, 0); 200 set_mm_counter(mm, anon_rss, 0);
@@ -249,8 +250,9 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm)
249 250
250 /* 251 /*
251 * Link in the new vma and copy the page table entries: 252 * Link in the new vma and copy the page table entries:
252 * link in first so that swapoff can see swap entries, 253 * link in first so that swapoff can see swap entries.
253 * and try_to_unmap_one's find_vma find the new vma. 254 * Note that, exceptionally, here the vma is inserted
255 * without holding mm->mmap_sem.
254 */ 256 */
255 spin_lock(&mm->page_table_lock); 257 spin_lock(&mm->page_table_lock);
256 *pprev = tmp; 258 *pprev = tmp;
@@ -322,6 +324,7 @@ static struct mm_struct * mm_init(struct mm_struct * mm)
322 mm->ioctx_list = NULL; 324 mm->ioctx_list = NULL;
323 mm->default_kioctx = (struct kioctx)INIT_KIOCTX(mm->default_kioctx, *mm); 325 mm->default_kioctx = (struct kioctx)INIT_KIOCTX(mm->default_kioctx, *mm);
324 mm->free_area_cache = TASK_UNMAPPED_BASE; 326 mm->free_area_cache = TASK_UNMAPPED_BASE;
327 mm->cached_hole_size = ~0UL;
325 328
326 if (likely(!mm_alloc_pgd(mm))) { 329 if (likely(!mm_alloc_pgd(mm))) {
327 mm->def_flags = 0; 330 mm->def_flags = 0;
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 5202e4c4a5b6..ac6700985705 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -6,6 +6,7 @@
6 * This file contains driver APIs to the irq subsystem. 6 * This file contains driver APIs to the irq subsystem.
7 */ 7 */
8 8
9#include <linux/config.h>
9#include <linux/irq.h> 10#include <linux/irq.h>
10#include <linux/module.h> 11#include <linux/module.h>
11#include <linux/random.h> 12#include <linux/random.h>
@@ -255,6 +256,13 @@ void free_irq(unsigned int irq, void *dev_id)
255 256
256 /* Found it - now remove it from the list of entries */ 257 /* Found it - now remove it from the list of entries */
257 *pp = action->next; 258 *pp = action->next;
259
260 /* Currently used only by UML, might disappear one day.*/
261#ifdef CONFIG_IRQ_RELEASE_METHOD
262 if (desc->handler->release)
263 desc->handler->release(irq, dev_id);
264#endif
265
258 if (!desc->action) { 266 if (!desc->action) {
259 desc->status |= IRQ_DISABLED; 267 desc->status |= IRQ_DISABLED;
260 if (desc->handler->shutdown) 268 if (desc->handler->shutdown)
diff --git a/kernel/module.c b/kernel/module.c
index 83b3d376708c..a566745dde62 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -379,7 +379,7 @@ static void module_unload_init(struct module *mod)
379 for (i = 0; i < NR_CPUS; i++) 379 for (i = 0; i < NR_CPUS; i++)
380 local_set(&mod->ref[i].count, 0); 380 local_set(&mod->ref[i].count, 0);
381 /* Hold reference count during initialization. */ 381 /* Hold reference count during initialization. */
382 local_set(&mod->ref[_smp_processor_id()].count, 1); 382 local_set(&mod->ref[raw_smp_processor_id()].count, 1);
383 /* Backwards compatibility macros put refcount during init. */ 383 /* Backwards compatibility macros put refcount during init. */
384 mod->waiter = current; 384 mod->waiter = current;
385} 385}
diff --git a/kernel/power/smp.c b/kernel/power/smp.c
index cba3584b80fe..457c2302ed42 100644
--- a/kernel/power/smp.c
+++ b/kernel/power/smp.c
@@ -48,11 +48,11 @@ void disable_nonboot_cpus(void)
48{ 48{
49 oldmask = current->cpus_allowed; 49 oldmask = current->cpus_allowed;
50 set_cpus_allowed(current, cpumask_of_cpu(0)); 50 set_cpus_allowed(current, cpumask_of_cpu(0));
51 printk("Freezing CPUs (at %d)", _smp_processor_id()); 51 printk("Freezing CPUs (at %d)", raw_smp_processor_id());
52 current->state = TASK_INTERRUPTIBLE; 52 current->state = TASK_INTERRUPTIBLE;
53 schedule_timeout(HZ); 53 schedule_timeout(HZ);
54 printk("..."); 54 printk("...");
55 BUG_ON(_smp_processor_id() != 0); 55 BUG_ON(raw_smp_processor_id() != 0);
56 56
57 /* FIXME: for this to work, all the CPUs must be running 57 /* FIXME: for this to work, all the CPUs must be running
58 * "idle" thread (or we deadlock). Is that guaranteed? */ 58 * "idle" thread (or we deadlock). Is that guaranteed? */
diff --git a/kernel/sched.c b/kernel/sched.c
index f12a0c8a7d98..deca041fc364 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3814,7 +3814,7 @@ EXPORT_SYMBOL(yield);
3814 */ 3814 */
3815void __sched io_schedule(void) 3815void __sched io_schedule(void)
3816{ 3816{
3817 struct runqueue *rq = &per_cpu(runqueues, _smp_processor_id()); 3817 struct runqueue *rq = &per_cpu(runqueues, raw_smp_processor_id());
3818 3818
3819 atomic_inc(&rq->nr_iowait); 3819 atomic_inc(&rq->nr_iowait);
3820 schedule(); 3820 schedule();
@@ -3825,7 +3825,7 @@ EXPORT_SYMBOL(io_schedule);
3825 3825
3826long __sched io_schedule_timeout(long timeout) 3826long __sched io_schedule_timeout(long timeout)
3827{ 3827{
3828 struct runqueue *rq = &per_cpu(runqueues, _smp_processor_id()); 3828 struct runqueue *rq = &per_cpu(runqueues, raw_smp_processor_id());
3829 long ret; 3829 long ret;
3830 3830
3831 atomic_inc(&rq->nr_iowait); 3831 atomic_inc(&rq->nr_iowait);
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
index 6116b25aa7cf..84a9d18aa8da 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
@@ -100,7 +100,7 @@ static int stop_machine(void)
100 stopmachine_state = STOPMACHINE_WAIT; 100 stopmachine_state = STOPMACHINE_WAIT;
101 101
102 for_each_online_cpu(i) { 102 for_each_online_cpu(i) {
103 if (i == _smp_processor_id()) 103 if (i == raw_smp_processor_id())
104 continue; 104 continue;
105 ret = kernel_thread(stopmachine, (void *)(long)i,CLONE_KERNEL); 105 ret = kernel_thread(stopmachine, (void *)(long)i,CLONE_KERNEL);
106 if (ret < 0) 106 if (ret < 0)
@@ -182,7 +182,7 @@ struct task_struct *__stop_machine_run(int (*fn)(void *), void *data,
182 182
183 /* If they don't care which CPU fn runs on, bind to any online one. */ 183 /* If they don't care which CPU fn runs on, bind to any online one. */
184 if (cpu == NR_CPUS) 184 if (cpu == NR_CPUS)
185 cpu = _smp_processor_id(); 185 cpu = raw_smp_processor_id();
186 186
187 p = kthread_create(do_stop, &smdata, "kstopmachine"); 187 p = kthread_create(do_stop, &smdata, "kstopmachine");
188 if (!IS_ERR(p)) { 188 if (!IS_ERR(p)) {
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index 0dda70ed1f98..6f15bea7d1a8 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -77,6 +77,7 @@ cond_syscall(sys_request_key);
77cond_syscall(sys_keyctl); 77cond_syscall(sys_keyctl);
78cond_syscall(compat_sys_keyctl); 78cond_syscall(compat_sys_keyctl);
79cond_syscall(compat_sys_socketcall); 79cond_syscall(compat_sys_socketcall);
80cond_syscall(sys_set_zone_reclaim);
80 81
81/* arch-specific weak syscall entries */ 82/* arch-specific weak syscall entries */
82cond_syscall(sys_pciconfig_read); 83cond_syscall(sys_pciconfig_read);
diff --git a/lib/Kconfig b/lib/Kconfig
index eeb45225248f..2d4d4e3bc4aa 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -40,6 +40,12 @@ config ZLIB_DEFLATE
40 tristate 40 tristate
41 41
42# 42#
43# Generic allocator support is selected if needed
44#
45config GENERIC_ALLOCATOR
46 boolean
47
48#
43# reed solomon support is select'ed if needed 49# reed solomon support is select'ed if needed
44# 50#
45config REED_SOLOMON 51config REED_SOLOMON
diff --git a/lib/Makefile b/lib/Makefile
index 9eccea9429a7..dcb4231916e2 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -20,6 +20,7 @@ lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
20lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o 20lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
21lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o 21lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o
22obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o 22obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o
23obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
23 24
24ifneq ($(CONFIG_HAVE_DEC_LOCK),y) 25ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
25 lib-y += dec_and_lock.o 26 lib-y += dec_and_lock.o
@@ -29,6 +30,7 @@ obj-$(CONFIG_CRC_CCITT) += crc-ccitt.o
29obj-$(CONFIG_CRC32) += crc32.o 30obj-$(CONFIG_CRC32) += crc32.o
30obj-$(CONFIG_LIBCRC32C) += libcrc32c.o 31obj-$(CONFIG_LIBCRC32C) += libcrc32c.o
31obj-$(CONFIG_GENERIC_IOMAP) += iomap.o 32obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
33obj-$(CONFIG_GENERIC_ALLOCATOR) += genalloc.o
32 34
33obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/ 35obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/
34obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/ 36obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/
diff --git a/lib/genalloc.c b/lib/genalloc.c
new file mode 100644
index 000000000000..d6d30d2e7166
--- /dev/null
+++ b/lib/genalloc.c
@@ -0,0 +1,188 @@
1/*
2 * Basic general purpose allocator for managing special purpose memory
3 * not managed by the regular kmalloc/kfree interface.
4 * Uses for this includes on-device special memory, uncached memory
5 * etc.
6 *
7 * This code is based on the buddy allocator found in the sym53c8xx_2
8 * driver Copyright (C) 1999-2001 Gerard Roudier <groudier@free.fr>,
9 * and adapted for general purpose use.
10 *
11 * Copyright 2005 (C) Jes Sorensen <jes@trained-monkey.org>
12 *
13 * This source code is licensed under the GNU General Public License,
14 * Version 2. See the file COPYING for more details.
15 */
16
17#include <linux/module.h>
18#include <linux/stddef.h>
19#include <linux/kernel.h>
20#include <linux/string.h>
21#include <linux/slab.h>
22#include <linux/init.h>
23#include <linux/mm.h>
24#include <linux/spinlock.h>
25#include <linux/genalloc.h>
26
27#include <asm/page.h>
28
29
30struct gen_pool *gen_pool_create(int nr_chunks, int max_chunk_shift,
31 unsigned long (*fp)(struct gen_pool *),
32 unsigned long data)
33{
34 struct gen_pool *poolp;
35 unsigned long tmp;
36 int i;
37
38 /*
39 * This is really an arbitrary limit, +10 is enough for
40 * IA64_GRANULE_SHIFT, aka 16MB. If anyone needs a large limit
41 * this can be increased without problems.
42 */
43 if ((max_chunk_shift > (PAGE_SHIFT + 10)) ||
44 ((max_chunk_shift < ALLOC_MIN_SHIFT) && max_chunk_shift))
45 return NULL;
46
47 if (!max_chunk_shift)
48 max_chunk_shift = PAGE_SHIFT;
49
50 poolp = kmalloc(sizeof(struct gen_pool), GFP_KERNEL);
51 if (!poolp)
52 return NULL;
53 memset(poolp, 0, sizeof(struct gen_pool));
54 poolp->h = kmalloc(sizeof(struct gen_pool_link) *
55 (max_chunk_shift - ALLOC_MIN_SHIFT + 1),
56 GFP_KERNEL);
57 if (!poolp->h) {
58 printk(KERN_WARNING "gen_pool_alloc() failed to allocate\n");
59 kfree(poolp);
60 return NULL;
61 }
62 memset(poolp->h, 0, sizeof(struct gen_pool_link) *
63 (max_chunk_shift - ALLOC_MIN_SHIFT + 1));
64
65 spin_lock_init(&poolp->lock);
66 poolp->get_new_chunk = fp;
67 poolp->max_chunk_shift = max_chunk_shift;
68 poolp->private = data;
69
70 for (i = 0; i < nr_chunks; i++) {
71 tmp = poolp->get_new_chunk(poolp);
72 printk(KERN_INFO "allocated %lx\n", tmp);
73 if (!tmp)
74 break;
75 gen_pool_free(poolp, tmp, (1 << poolp->max_chunk_shift));
76 }
77
78 return poolp;
79}
80EXPORT_SYMBOL(gen_pool_create);
81
82
83/*
84 * Simple power of two buddy-like generic allocator.
85 * Provides naturally aligned memory chunks.
86 */
87unsigned long gen_pool_alloc(struct gen_pool *poolp, int size)
88{
89 int j, i, s, max_chunk_size;
90 unsigned long a, flags;
91 struct gen_pool_link *h = poolp->h;
92
93 max_chunk_size = 1 << poolp->max_chunk_shift;
94
95 if (size > max_chunk_size)
96 return 0;
97
98 i = 0;
99
100 size = max(size, 1 << ALLOC_MIN_SHIFT);
101 s = roundup_pow_of_two(size);
102
103 j = i;
104
105 spin_lock_irqsave(&poolp->lock, flags);
106 while (!h[j].next) {
107 if (s == max_chunk_size) {
108 struct gen_pool_link *ptr;
109 spin_unlock_irqrestore(&poolp->lock, flags);
110 ptr = (struct gen_pool_link *)poolp->get_new_chunk(poolp);
111 spin_lock_irqsave(&poolp->lock, flags);
112 h[j].next = ptr;
113 if (h[j].next)
114 h[j].next->next = NULL;
115 break;
116 }
117 j++;
118 s <<= 1;
119 }
120 a = (unsigned long) h[j].next;
121 if (a) {
122 h[j].next = h[j].next->next;
123 /*
124 * This should be split into a seperate function doing
125 * the chunk split in order to support custom
126 * handling memory not physically accessible by host
127 */
128 while (j > i) {
129 j -= 1;
130 s >>= 1;
131 h[j].next = (struct gen_pool_link *) (a + s);
132 h[j].next->next = NULL;
133 }
134 }
135 spin_unlock_irqrestore(&poolp->lock, flags);
136 return a;
137}
138EXPORT_SYMBOL(gen_pool_alloc);
139
140
141/*
142 * Counter-part of the generic allocator.
143 */
144void gen_pool_free(struct gen_pool *poolp, unsigned long ptr, int size)
145{
146 struct gen_pool_link *q;
147 struct gen_pool_link *h = poolp->h;
148 unsigned long a, b, flags;
149 int i, s, max_chunk_size;
150
151 max_chunk_size = 1 << poolp->max_chunk_shift;
152
153 if (size > max_chunk_size)
154 return;
155
156 i = 0;
157
158 size = max(size, 1 << ALLOC_MIN_SHIFT);
159 s = roundup_pow_of_two(size);
160
161 a = ptr;
162
163 spin_lock_irqsave(&poolp->lock, flags);
164 while (1) {
165 if (s == max_chunk_size) {
166 ((struct gen_pool_link *)a)->next = h[i].next;
167 h[i].next = (struct gen_pool_link *)a;
168 break;
169 }
170 b = a ^ s;
171 q = &h[i];
172
173 while (q->next && q->next != (struct gen_pool_link *)b)
174 q = q->next;
175
176 if (!q->next) {
177 ((struct gen_pool_link *)a)->next = h[i].next;
178 h[i].next = (struct gen_pool_link *)a;
179 break;
180 }
181 q->next = q->next->next;
182 a = a & b;
183 s <<= 1;
184 i++;
185 }
186 spin_unlock_irqrestore(&poolp->lock, flags);
187}
188EXPORT_SYMBOL(gen_pool_free);
diff --git a/lib/idr.c b/lib/idr.c
index 81fc430602ee..c5be889de449 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -175,7 +175,7 @@ build_up:
175 * Add a new layer to the top of the tree if the requested 175 * Add a new layer to the top of the tree if the requested
176 * id is larger than the currently allocated space. 176 * id is larger than the currently allocated space.
177 */ 177 */
178 while ((layers < MAX_LEVEL) && (id >= (1 << (layers*IDR_BITS)))) { 178 while ((layers < (MAX_LEVEL - 1)) && (id >= (1 << (layers*IDR_BITS)))) {
179 layers++; 179 layers++;
180 if (!p->count) 180 if (!p->count)
181 continue; 181 continue;
diff --git a/lib/kernel_lock.c b/lib/kernel_lock.c
index 99b0ae3d51dd..bd2bc5d887b8 100644
--- a/lib/kernel_lock.c
+++ b/lib/kernel_lock.c
@@ -9,61 +9,6 @@
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/kallsyms.h> 10#include <linux/kallsyms.h>
11 11
12#if defined(CONFIG_PREEMPT) && defined(__smp_processor_id) && \
13 defined(CONFIG_DEBUG_PREEMPT)
14
15/*
16 * Debugging check.
17 */
18unsigned int smp_processor_id(void)
19{
20 unsigned long preempt_count = preempt_count();
21 int this_cpu = __smp_processor_id();
22 cpumask_t this_mask;
23
24 if (likely(preempt_count))
25 goto out;
26
27 if (irqs_disabled())
28 goto out;
29
30 /*
31 * Kernel threads bound to a single CPU can safely use
32 * smp_processor_id():
33 */
34 this_mask = cpumask_of_cpu(this_cpu);
35
36 if (cpus_equal(current->cpus_allowed, this_mask))
37 goto out;
38
39 /*
40 * It is valid to assume CPU-locality during early bootup:
41 */
42 if (system_state != SYSTEM_RUNNING)
43 goto out;
44
45 /*
46 * Avoid recursion:
47 */
48 preempt_disable();
49
50 if (!printk_ratelimit())
51 goto out_enable;
52
53 printk(KERN_ERR "BUG: using smp_processor_id() in preemptible [%08x] code: %s/%d\n", preempt_count(), current->comm, current->pid);
54 print_symbol("caller is %s\n", (long)__builtin_return_address(0));
55 dump_stack();
56
57out_enable:
58 preempt_enable_no_resched();
59out:
60 return this_cpu;
61}
62
63EXPORT_SYMBOL(smp_processor_id);
64
65#endif /* PREEMPT && __smp_processor_id && DEBUG_PREEMPT */
66
67#ifdef CONFIG_PREEMPT_BKL 12#ifdef CONFIG_PREEMPT_BKL
68/* 13/*
69 * The 'big kernel semaphore' 14 * The 'big kernel semaphore'
diff --git a/lib/smp_processor_id.c b/lib/smp_processor_id.c
new file mode 100644
index 000000000000..42c08ef828c5
--- /dev/null
+++ b/lib/smp_processor_id.c
@@ -0,0 +1,55 @@
1/*
2 * lib/smp_processor_id.c
3 *
4 * DEBUG_PREEMPT variant of smp_processor_id().
5 */
6#include <linux/module.h>
7#include <linux/kallsyms.h>
8
9unsigned int debug_smp_processor_id(void)
10{
11 unsigned long preempt_count = preempt_count();
12 int this_cpu = raw_smp_processor_id();
13 cpumask_t this_mask;
14
15 if (likely(preempt_count))
16 goto out;
17
18 if (irqs_disabled())
19 goto out;
20
21 /*
22 * Kernel threads bound to a single CPU can safely use
23 * smp_processor_id():
24 */
25 this_mask = cpumask_of_cpu(this_cpu);
26
27 if (cpus_equal(current->cpus_allowed, this_mask))
28 goto out;
29
30 /*
31 * It is valid to assume CPU-locality during early bootup:
32 */
33 if (system_state != SYSTEM_RUNNING)
34 goto out;
35
36 /*
37 * Avoid recursion:
38 */
39 preempt_disable();
40
41 if (!printk_ratelimit())
42 goto out_enable;
43
44 printk(KERN_ERR "BUG: using smp_processor_id() in preemptible [%08x] code: %s/%d\n", preempt_count(), current->comm, current->pid);
45 print_symbol("caller is %s\n", (long)__builtin_return_address(0));
46 dump_stack();
47
48out_enable:
49 preempt_enable_no_resched();
50out:
51 return this_cpu;
52}
53
54EXPORT_SYMBOL(debug_smp_processor_id);
55
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 4eb5ae3fbe10..fbd1111ea119 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -7,10 +7,14 @@
7#include <linux/init.h> 7#include <linux/init.h>
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/mm.h> 9#include <linux/mm.h>
10#include <linux/hugetlb.h>
11#include <linux/sysctl.h> 10#include <linux/sysctl.h>
12#include <linux/highmem.h> 11#include <linux/highmem.h>
13#include <linux/nodemask.h> 12#include <linux/nodemask.h>
13#include <linux/pagemap.h>
14#include <asm/page.h>
15#include <asm/pgtable.h>
16
17#include <linux/hugetlb.h>
14 18
15const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL; 19const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
16static unsigned long nr_huge_pages, free_huge_pages; 20static unsigned long nr_huge_pages, free_huge_pages;
@@ -249,6 +253,72 @@ struct vm_operations_struct hugetlb_vm_ops = {
249 .nopage = hugetlb_nopage, 253 .nopage = hugetlb_nopage,
250}; 254};
251 255
256static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page)
257{
258 pte_t entry;
259
260 if (vma->vm_flags & VM_WRITE) {
261 entry =
262 pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot)));
263 } else {
264 entry = pte_wrprotect(mk_pte(page, vma->vm_page_prot));
265 }
266 entry = pte_mkyoung(entry);
267 entry = pte_mkhuge(entry);
268
269 return entry;
270}
271
272int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
273 struct vm_area_struct *vma)
274{
275 pte_t *src_pte, *dst_pte, entry;
276 struct page *ptepage;
277 unsigned long addr = vma->vm_start;
278 unsigned long end = vma->vm_end;
279
280 while (addr < end) {
281 dst_pte = huge_pte_alloc(dst, addr);
282 if (!dst_pte)
283 goto nomem;
284 src_pte = huge_pte_offset(src, addr);
285 BUG_ON(!src_pte || pte_none(*src_pte)); /* prefaulted */
286 entry = *src_pte;
287 ptepage = pte_page(entry);
288 get_page(ptepage);
289 add_mm_counter(dst, rss, HPAGE_SIZE / PAGE_SIZE);
290 set_huge_pte_at(dst, addr, dst_pte, entry);
291 addr += HPAGE_SIZE;
292 }
293 return 0;
294
295nomem:
296 return -ENOMEM;
297}
298
299void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
300 unsigned long end)
301{
302 struct mm_struct *mm = vma->vm_mm;
303 unsigned long address;
304 pte_t pte;
305 struct page *page;
306
307 WARN_ON(!is_vm_hugetlb_page(vma));
308 BUG_ON(start & ~HPAGE_MASK);
309 BUG_ON(end & ~HPAGE_MASK);
310
311 for (address = start; address < end; address += HPAGE_SIZE) {
312 pte = huge_ptep_get_and_clear(mm, address, huge_pte_offset(mm, address));
313 if (pte_none(pte))
314 continue;
315 page = pte_page(pte);
316 put_page(page);
317 }
318 add_mm_counter(mm, rss, -((end - start) >> PAGE_SHIFT));
319 flush_tlb_range(vma, start, end);
320}
321
252void zap_hugepage_range(struct vm_area_struct *vma, 322void zap_hugepage_range(struct vm_area_struct *vma,
253 unsigned long start, unsigned long length) 323 unsigned long start, unsigned long length)
254{ 324{
@@ -258,3 +328,108 @@ void zap_hugepage_range(struct vm_area_struct *vma,
258 unmap_hugepage_range(vma, start, start + length); 328 unmap_hugepage_range(vma, start, start + length);
259 spin_unlock(&mm->page_table_lock); 329 spin_unlock(&mm->page_table_lock);
260} 330}
331
332int hugetlb_prefault(struct address_space *mapping, struct vm_area_struct *vma)
333{
334 struct mm_struct *mm = current->mm;
335 unsigned long addr;
336 int ret = 0;
337
338 WARN_ON(!is_vm_hugetlb_page(vma));
339 BUG_ON(vma->vm_start & ~HPAGE_MASK);
340 BUG_ON(vma->vm_end & ~HPAGE_MASK);
341
342 hugetlb_prefault_arch_hook(mm);
343
344 spin_lock(&mm->page_table_lock);
345 for (addr = vma->vm_start; addr < vma->vm_end; addr += HPAGE_SIZE) {
346 unsigned long idx;
347 pte_t *pte = huge_pte_alloc(mm, addr);
348 struct page *page;
349
350 if (!pte) {
351 ret = -ENOMEM;
352 goto out;
353 }
354 if (! pte_none(*pte))
355 hugetlb_clean_stale_pgtable(pte);
356
357 idx = ((addr - vma->vm_start) >> HPAGE_SHIFT)
358 + (vma->vm_pgoff >> (HPAGE_SHIFT - PAGE_SHIFT));
359 page = find_get_page(mapping, idx);
360 if (!page) {
361 /* charge the fs quota first */
362 if (hugetlb_get_quota(mapping)) {
363 ret = -ENOMEM;
364 goto out;
365 }
366 page = alloc_huge_page();
367 if (!page) {
368 hugetlb_put_quota(mapping);
369 ret = -ENOMEM;
370 goto out;
371 }
372 ret = add_to_page_cache(page, mapping, idx, GFP_ATOMIC);
373 if (! ret) {
374 unlock_page(page);
375 } else {
376 hugetlb_put_quota(mapping);
377 free_huge_page(page);
378 goto out;
379 }
380 }
381 add_mm_counter(mm, rss, HPAGE_SIZE / PAGE_SIZE);
382 set_huge_pte_at(mm, addr, pte, make_huge_pte(vma, page));
383 }
384out:
385 spin_unlock(&mm->page_table_lock);
386 return ret;
387}
388
389int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma,
390 struct page **pages, struct vm_area_struct **vmas,
391 unsigned long *position, int *length, int i)
392{
393 unsigned long vpfn, vaddr = *position;
394 int remainder = *length;
395
396 BUG_ON(!is_vm_hugetlb_page(vma));
397
398 vpfn = vaddr/PAGE_SIZE;
399 while (vaddr < vma->vm_end && remainder) {
400
401 if (pages) {
402 pte_t *pte;
403 struct page *page;
404
405 /* Some archs (sparc64, sh*) have multiple
406 * pte_ts to each hugepage. We have to make
407 * sure we get the first, for the page
408 * indexing below to work. */
409 pte = huge_pte_offset(mm, vaddr & HPAGE_MASK);
410
411 /* hugetlb should be locked, and hence, prefaulted */
412 WARN_ON(!pte || pte_none(*pte));
413
414 page = &pte_page(*pte)[vpfn % (HPAGE_SIZE/PAGE_SIZE)];
415
416 WARN_ON(!PageCompound(page));
417
418 get_page(page);
419 pages[i] = page;
420 }
421
422 if (vmas)
423 vmas[i] = vma;
424
425 vaddr += PAGE_SIZE;
426 ++vpfn;
427 --remainder;
428 ++i;
429 }
430
431 *length = remainder;
432 *position = vaddr;
433
434 return i;
435}
diff --git a/mm/madvise.c b/mm/madvise.c
index 944b5e52d812..e3108054733c 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -8,17 +8,47 @@
8#include <linux/mman.h> 8#include <linux/mman.h>
9#include <linux/pagemap.h> 9#include <linux/pagemap.h>
10#include <linux/syscalls.h> 10#include <linux/syscalls.h>
11#include <linux/mempolicy.h>
11#include <linux/hugetlb.h> 12#include <linux/hugetlb.h>
12 13
13/* 14/*
14 * We can potentially split a vm area into separate 15 * We can potentially split a vm area into separate
15 * areas, each area with its own behavior. 16 * areas, each area with its own behavior.
16 */ 17 */
17static long madvise_behavior(struct vm_area_struct * vma, unsigned long start, 18static long madvise_behavior(struct vm_area_struct * vma,
18 unsigned long end, int behavior) 19 struct vm_area_struct **prev,
20 unsigned long start, unsigned long end, int behavior)
19{ 21{
20 struct mm_struct * mm = vma->vm_mm; 22 struct mm_struct * mm = vma->vm_mm;
21 int error = 0; 23 int error = 0;
24 pgoff_t pgoff;
25 int new_flags = vma->vm_flags & ~VM_READHINTMASK;
26
27 switch (behavior) {
28 case MADV_SEQUENTIAL:
29 new_flags |= VM_SEQ_READ;
30 break;
31 case MADV_RANDOM:
32 new_flags |= VM_RAND_READ;
33 break;
34 default:
35 break;
36 }
37
38 if (new_flags == vma->vm_flags) {
39 *prev = vma;
40 goto success;
41 }
42
43 pgoff = vma->vm_pgoff + ((start - vma->vm_start) >> PAGE_SHIFT);
44 *prev = vma_merge(mm, *prev, start, end, new_flags, vma->anon_vma,
45 vma->vm_file, pgoff, vma_policy(vma));
46 if (*prev) {
47 vma = *prev;
48 goto success;
49 }
50
51 *prev = vma;
22 52
23 if (start != vma->vm_start) { 53 if (start != vma->vm_start) {
24 error = split_vma(mm, vma, start, 1); 54 error = split_vma(mm, vma, start, 1);
@@ -36,21 +66,12 @@ static long madvise_behavior(struct vm_area_struct * vma, unsigned long start,
36 * vm_flags is protected by the mmap_sem held in write mode. 66 * vm_flags is protected by the mmap_sem held in write mode.
37 */ 67 */
38 VM_ClearReadHint(vma); 68 VM_ClearReadHint(vma);
39 69 vma->vm_flags = new_flags;
40 switch (behavior) {
41 case MADV_SEQUENTIAL:
42 vma->vm_flags |= VM_SEQ_READ;
43 break;
44 case MADV_RANDOM:
45 vma->vm_flags |= VM_RAND_READ;
46 break;
47 default:
48 break;
49 }
50 70
51out: 71out:
52 if (error == -ENOMEM) 72 if (error == -ENOMEM)
53 error = -EAGAIN; 73 error = -EAGAIN;
74success:
54 return error; 75 return error;
55} 76}
56 77
@@ -58,6 +79,7 @@ out:
58 * Schedule all required I/O operations. Do not wait for completion. 79 * Schedule all required I/O operations. Do not wait for completion.
59 */ 80 */
60static long madvise_willneed(struct vm_area_struct * vma, 81static long madvise_willneed(struct vm_area_struct * vma,
82 struct vm_area_struct ** prev,
61 unsigned long start, unsigned long end) 83 unsigned long start, unsigned long end)
62{ 84{
63 struct file *file = vma->vm_file; 85 struct file *file = vma->vm_file;
@@ -65,6 +87,7 @@ static long madvise_willneed(struct vm_area_struct * vma,
65 if (!file) 87 if (!file)
66 return -EBADF; 88 return -EBADF;
67 89
90 *prev = vma;
68 start = ((start - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff; 91 start = ((start - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
69 if (end > vma->vm_end) 92 if (end > vma->vm_end)
70 end = vma->vm_end; 93 end = vma->vm_end;
@@ -95,8 +118,10 @@ static long madvise_willneed(struct vm_area_struct * vma,
95 * dirty pages is already available as msync(MS_INVALIDATE). 118 * dirty pages is already available as msync(MS_INVALIDATE).
96 */ 119 */
97static long madvise_dontneed(struct vm_area_struct * vma, 120static long madvise_dontneed(struct vm_area_struct * vma,
121 struct vm_area_struct ** prev,
98 unsigned long start, unsigned long end) 122 unsigned long start, unsigned long end)
99{ 123{
124 *prev = vma;
100 if ((vma->vm_flags & VM_LOCKED) || is_vm_hugetlb_page(vma)) 125 if ((vma->vm_flags & VM_LOCKED) || is_vm_hugetlb_page(vma))
101 return -EINVAL; 126 return -EINVAL;
102 127
@@ -111,8 +136,8 @@ static long madvise_dontneed(struct vm_area_struct * vma,
111 return 0; 136 return 0;
112} 137}
113 138
114static long madvise_vma(struct vm_area_struct * vma, unsigned long start, 139static long madvise_vma(struct vm_area_struct *vma, struct vm_area_struct **prev,
115 unsigned long end, int behavior) 140 unsigned long start, unsigned long end, int behavior)
116{ 141{
117 long error = -EBADF; 142 long error = -EBADF;
118 143
@@ -120,15 +145,15 @@ static long madvise_vma(struct vm_area_struct * vma, unsigned long start,
120 case MADV_NORMAL: 145 case MADV_NORMAL:
121 case MADV_SEQUENTIAL: 146 case MADV_SEQUENTIAL:
122 case MADV_RANDOM: 147 case MADV_RANDOM:
123 error = madvise_behavior(vma, start, end, behavior); 148 error = madvise_behavior(vma, prev, start, end, behavior);
124 break; 149 break;
125 150
126 case MADV_WILLNEED: 151 case MADV_WILLNEED:
127 error = madvise_willneed(vma, start, end); 152 error = madvise_willneed(vma, prev, start, end);
128 break; 153 break;
129 154
130 case MADV_DONTNEED: 155 case MADV_DONTNEED:
131 error = madvise_dontneed(vma, start, end); 156 error = madvise_dontneed(vma, prev, start, end);
132 break; 157 break;
133 158
134 default: 159 default:
@@ -175,8 +200,8 @@ static long madvise_vma(struct vm_area_struct * vma, unsigned long start,
175 */ 200 */
176asmlinkage long sys_madvise(unsigned long start, size_t len_in, int behavior) 201asmlinkage long sys_madvise(unsigned long start, size_t len_in, int behavior)
177{ 202{
178 unsigned long end; 203 unsigned long end, tmp;
179 struct vm_area_struct * vma; 204 struct vm_area_struct * vma, *prev;
180 int unmapped_error = 0; 205 int unmapped_error = 0;
181 int error = -EINVAL; 206 int error = -EINVAL;
182 size_t len; 207 size_t len;
@@ -202,40 +227,42 @@ asmlinkage long sys_madvise(unsigned long start, size_t len_in, int behavior)
202 /* 227 /*
203 * If the interval [start,end) covers some unmapped address 228 * If the interval [start,end) covers some unmapped address
204 * ranges, just ignore them, but return -ENOMEM at the end. 229 * ranges, just ignore them, but return -ENOMEM at the end.
230 * - different from the way of handling in mlock etc.
205 */ 231 */
206 vma = find_vma(current->mm, start); 232 vma = find_vma_prev(current->mm, start, &prev);
233 if (!vma && prev)
234 vma = prev->vm_next;
207 for (;;) { 235 for (;;) {
208 /* Still start < end. */ 236 /* Still start < end. */
209 error = -ENOMEM; 237 error = -ENOMEM;
210 if (!vma) 238 if (!vma)
211 goto out; 239 goto out;
212 240
213 /* Here start < vma->vm_end. */ 241 /* Here start < (end|vma->vm_end). */
214 if (start < vma->vm_start) { 242 if (start < vma->vm_start) {
215 unmapped_error = -ENOMEM; 243 unmapped_error = -ENOMEM;
216 start = vma->vm_start; 244 start = vma->vm_start;
245 if (start >= end)
246 goto out;
217 } 247 }
218 248
219 /* Here vma->vm_start <= start < vma->vm_end. */ 249 /* Here vma->vm_start <= start < (end|vma->vm_end) */
220 if (end <= vma->vm_end) { 250 tmp = vma->vm_end;
221 if (start < end) { 251 if (end < tmp)
222 error = madvise_vma(vma, start, end, 252 tmp = end;
223 behavior);
224 if (error)
225 goto out;
226 }
227 error = unmapped_error;
228 goto out;
229 }
230 253
231 /* Here vma->vm_start <= start < vma->vm_end < end. */ 254 /* Here vma->vm_start <= start < tmp <= (end|vma->vm_end). */
232 error = madvise_vma(vma, start, vma->vm_end, behavior); 255 error = madvise_vma(vma, &prev, start, tmp, behavior);
233 if (error) 256 if (error)
234 goto out; 257 goto out;
235 start = vma->vm_end; 258 start = tmp;
236 vma = vma->vm_next; 259 if (start < prev->vm_end)
260 start = prev->vm_end;
261 error = unmapped_error;
262 if (start >= end)
263 goto out;
264 vma = prev->vm_next;
237 } 265 }
238
239out: 266out:
240 up_write(&current->mm->mmap_sem); 267 up_write(&current->mm->mmap_sem);
241 return error; 268 return error;
diff --git a/mm/memory.c b/mm/memory.c
index d209f745db7f..da91b7bf9986 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -840,23 +840,8 @@ check_user_page_readable(struct mm_struct *mm, unsigned long address)
840{ 840{
841 return __follow_page(mm, address, /*read*/1, /*write*/0) != NULL; 841 return __follow_page(mm, address, /*read*/1, /*write*/0) != NULL;
842} 842}
843
844EXPORT_SYMBOL(check_user_page_readable); 843EXPORT_SYMBOL(check_user_page_readable);
845 844
846/*
847 * Given a physical address, is there a useful struct page pointing to
848 * it? This may become more complex in the future if we start dealing
849 * with IO-aperture pages for direct-IO.
850 */
851
852static inline struct page *get_page_map(struct page *page)
853{
854 if (!pfn_valid(page_to_pfn(page)))
855 return NULL;
856 return page;
857}
858
859
860static inline int 845static inline int
861untouched_anonymous_page(struct mm_struct* mm, struct vm_area_struct *vma, 846untouched_anonymous_page(struct mm_struct* mm, struct vm_area_struct *vma,
862 unsigned long address) 847 unsigned long address)
@@ -887,7 +872,6 @@ untouched_anonymous_page(struct mm_struct* mm, struct vm_area_struct *vma,
887 return 0; 872 return 0;
888} 873}
889 874
890
891int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, 875int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
892 unsigned long start, int len, int write, int force, 876 unsigned long start, int len, int write, int force,
893 struct page **pages, struct vm_area_struct **vmas) 877 struct page **pages, struct vm_area_struct **vmas)
@@ -951,21 +935,21 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
951 } 935 }
952 spin_lock(&mm->page_table_lock); 936 spin_lock(&mm->page_table_lock);
953 do { 937 do {
954 struct page *map; 938 struct page *page;
955 int lookup_write = write; 939 int lookup_write = write;
956 940
957 cond_resched_lock(&mm->page_table_lock); 941 cond_resched_lock(&mm->page_table_lock);
958 while (!(map = follow_page(mm, start, lookup_write))) { 942 while (!(page = follow_page(mm, start, lookup_write))) {
959 /* 943 /*
960 * Shortcut for anonymous pages. We don't want 944 * Shortcut for anonymous pages. We don't want
961 * to force the creation of pages tables for 945 * to force the creation of pages tables for
962 * insanly big anonymously mapped areas that 946 * insanely big anonymously mapped areas that
963 * nobody touched so far. This is important 947 * nobody touched so far. This is important
964 * for doing a core dump for these mappings. 948 * for doing a core dump for these mappings.
965 */ 949 */
966 if (!lookup_write && 950 if (!lookup_write &&
967 untouched_anonymous_page(mm,vma,start)) { 951 untouched_anonymous_page(mm,vma,start)) {
968 map = ZERO_PAGE(start); 952 page = ZERO_PAGE(start);
969 break; 953 break;
970 } 954 }
971 spin_unlock(&mm->page_table_lock); 955 spin_unlock(&mm->page_table_lock);
@@ -994,30 +978,21 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
994 spin_lock(&mm->page_table_lock); 978 spin_lock(&mm->page_table_lock);
995 } 979 }
996 if (pages) { 980 if (pages) {
997 pages[i] = get_page_map(map); 981 pages[i] = page;
998 if (!pages[i]) { 982 flush_dcache_page(page);
999 spin_unlock(&mm->page_table_lock); 983 if (!PageReserved(page))
1000 while (i--) 984 page_cache_get(page);
1001 page_cache_release(pages[i]);
1002 i = -EFAULT;
1003 goto out;
1004 }
1005 flush_dcache_page(pages[i]);
1006 if (!PageReserved(pages[i]))
1007 page_cache_get(pages[i]);
1008 } 985 }
1009 if (vmas) 986 if (vmas)
1010 vmas[i] = vma; 987 vmas[i] = vma;
1011 i++; 988 i++;
1012 start += PAGE_SIZE; 989 start += PAGE_SIZE;
1013 len--; 990 len--;
1014 } while(len && start < vma->vm_end); 991 } while (len && start < vma->vm_end);
1015 spin_unlock(&mm->page_table_lock); 992 spin_unlock(&mm->page_table_lock);
1016 } while(len); 993 } while (len);
1017out:
1018 return i; 994 return i;
1019} 995}
1020
1021EXPORT_SYMBOL(get_user_pages); 996EXPORT_SYMBOL(get_user_pages);
1022 997
1023static int zeromap_pte_range(struct mm_struct *mm, pmd_t *pmd, 998static int zeromap_pte_range(struct mm_struct *mm, pmd_t *pmd,
@@ -1264,7 +1239,7 @@ static int do_wp_page(struct mm_struct *mm, struct vm_area_struct * vma,
1264 } 1239 }
1265 old_page = pfn_to_page(pfn); 1240 old_page = pfn_to_page(pfn);
1266 1241
1267 if (!TestSetPageLocked(old_page)) { 1242 if (PageAnon(old_page) && !TestSetPageLocked(old_page)) {
1268 int reuse = can_share_swap_page(old_page); 1243 int reuse = can_share_swap_page(old_page);
1269 unlock_page(old_page); 1244 unlock_page(old_page);
1270 if (reuse) { 1245 if (reuse) {
@@ -1711,10 +1686,6 @@ static int do_swap_page(struct mm_struct * mm,
1711 } 1686 }
1712 1687
1713 /* The page isn't present yet, go ahead with the fault. */ 1688 /* The page isn't present yet, go ahead with the fault. */
1714
1715 swap_free(entry);
1716 if (vm_swap_full())
1717 remove_exclusive_swap_page(page);
1718 1689
1719 inc_mm_counter(mm, rss); 1690 inc_mm_counter(mm, rss);
1720 pte = mk_pte(page, vma->vm_page_prot); 1691 pte = mk_pte(page, vma->vm_page_prot);
@@ -1722,12 +1693,16 @@ static int do_swap_page(struct mm_struct * mm,
1722 pte = maybe_mkwrite(pte_mkdirty(pte), vma); 1693 pte = maybe_mkwrite(pte_mkdirty(pte), vma);
1723 write_access = 0; 1694 write_access = 0;
1724 } 1695 }
1725 unlock_page(page);
1726 1696
1727 flush_icache_page(vma, page); 1697 flush_icache_page(vma, page);
1728 set_pte_at(mm, address, page_table, pte); 1698 set_pte_at(mm, address, page_table, pte);
1729 page_add_anon_rmap(page, vma, address); 1699 page_add_anon_rmap(page, vma, address);
1730 1700
1701 swap_free(entry);
1702 if (vm_swap_full())
1703 remove_exclusive_swap_page(page);
1704 unlock_page(page);
1705
1731 if (write_access) { 1706 if (write_access) {
1732 if (do_wp_page(mm, vma, address, 1707 if (do_wp_page(mm, vma, address,
1733 page_table, pmd, pte) == VM_FAULT_OOM) 1708 page_table, pmd, pte) == VM_FAULT_OOM)
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 08c41da429cf..cb41c31e7c87 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -238,46 +238,80 @@ static struct mempolicy *mpol_new(int mode, unsigned long *nodes)
238} 238}
239 239
240/* Ensure all existing pages follow the policy. */ 240/* Ensure all existing pages follow the policy. */
241static int 241static int check_pte_range(struct mm_struct *mm, pmd_t *pmd,
242verify_pages(struct mm_struct *mm, 242 unsigned long addr, unsigned long end, unsigned long *nodes)
243 unsigned long addr, unsigned long end, unsigned long *nodes)
244{ 243{
245 while (addr < end) { 244 pte_t *orig_pte;
246 struct page *p; 245 pte_t *pte;
247 pte_t *pte; 246
248 pmd_t *pmd; 247 spin_lock(&mm->page_table_lock);
249 pud_t *pud; 248 orig_pte = pte = pte_offset_map(pmd, addr);
250 pgd_t *pgd; 249 do {
251 pgd = pgd_offset(mm, addr); 250 unsigned long pfn;
252 if (pgd_none(*pgd)) { 251 unsigned int nid;
253 unsigned long next = (addr + PGDIR_SIZE) & PGDIR_MASK; 252
254 if (next > addr) 253 if (!pte_present(*pte))
255 break;
256 addr = next;
257 continue; 254 continue;
258 } 255 pfn = pte_pfn(*pte);
259 pud = pud_offset(pgd, addr); 256 if (!pfn_valid(pfn))
260 if (pud_none(*pud)) {
261 addr = (addr + PUD_SIZE) & PUD_MASK;
262 continue; 257 continue;
263 } 258 nid = pfn_to_nid(pfn);
264 pmd = pmd_offset(pud, addr); 259 if (!test_bit(nid, nodes))
265 if (pmd_none(*pmd)) { 260 break;
266 addr = (addr + PMD_SIZE) & PMD_MASK; 261 } while (pte++, addr += PAGE_SIZE, addr != end);
262 pte_unmap(orig_pte);
263 spin_unlock(&mm->page_table_lock);
264 return addr != end;
265}
266
267static inline int check_pmd_range(struct mm_struct *mm, pud_t *pud,
268 unsigned long addr, unsigned long end, unsigned long *nodes)
269{
270 pmd_t *pmd;
271 unsigned long next;
272
273 pmd = pmd_offset(pud, addr);
274 do {
275 next = pmd_addr_end(addr, end);
276 if (pmd_none_or_clear_bad(pmd))
267 continue; 277 continue;
268 } 278 if (check_pte_range(mm, pmd, addr, next, nodes))
269 p = NULL; 279 return -EIO;
270 pte = pte_offset_map(pmd, addr); 280 } while (pmd++, addr = next, addr != end);
271 if (pte_present(*pte)) 281 return 0;
272 p = pte_page(*pte); 282}
273 pte_unmap(pte); 283
274 if (p) { 284static inline int check_pud_range(struct mm_struct *mm, pgd_t *pgd,
275 unsigned nid = page_to_nid(p); 285 unsigned long addr, unsigned long end, unsigned long *nodes)
276 if (!test_bit(nid, nodes)) 286{
277 return -EIO; 287 pud_t *pud;
278 } 288 unsigned long next;
279 addr += PAGE_SIZE; 289
280 } 290 pud = pud_offset(pgd, addr);
291 do {
292 next = pud_addr_end(addr, end);
293 if (pud_none_or_clear_bad(pud))
294 continue;
295 if (check_pmd_range(mm, pud, addr, next, nodes))
296 return -EIO;
297 } while (pud++, addr = next, addr != end);
298 return 0;
299}
300
301static inline int check_pgd_range(struct mm_struct *mm,
302 unsigned long addr, unsigned long end, unsigned long *nodes)
303{
304 pgd_t *pgd;
305 unsigned long next;
306
307 pgd = pgd_offset(mm, addr);
308 do {
309 next = pgd_addr_end(addr, end);
310 if (pgd_none_or_clear_bad(pgd))
311 continue;
312 if (check_pud_range(mm, pgd, addr, next, nodes))
313 return -EIO;
314 } while (pgd++, addr = next, addr != end);
281 return 0; 315 return 0;
282} 316}
283 317
@@ -299,7 +333,7 @@ check_range(struct mm_struct *mm, unsigned long start, unsigned long end,
299 if (prev && prev->vm_end < vma->vm_start) 333 if (prev && prev->vm_end < vma->vm_start)
300 return ERR_PTR(-EFAULT); 334 return ERR_PTR(-EFAULT);
301 if ((flags & MPOL_MF_STRICT) && !is_vm_hugetlb_page(vma)) { 335 if ((flags & MPOL_MF_STRICT) && !is_vm_hugetlb_page(vma)) {
302 err = verify_pages(vma->vm_mm, 336 err = check_pgd_range(vma->vm_mm,
303 vma->vm_start, vma->vm_end, nodes); 337 vma->vm_start, vma->vm_end, nodes);
304 if (err) { 338 if (err) {
305 first = ERR_PTR(err); 339 first = ERR_PTR(err);
@@ -721,7 +755,7 @@ static struct page *alloc_page_interleave(unsigned int __nocast gfp, unsigned or
721 zl = NODE_DATA(nid)->node_zonelists + (gfp & GFP_ZONEMASK); 755 zl = NODE_DATA(nid)->node_zonelists + (gfp & GFP_ZONEMASK);
722 page = __alloc_pages(gfp, order, zl); 756 page = __alloc_pages(gfp, order, zl);
723 if (page && page_zone(page) == zl->zones[0]) { 757 if (page && page_zone(page) == zl->zones[0]) {
724 zl->zones[0]->pageset[get_cpu()].interleave_hit++; 758 zone_pcp(zl->zones[0],get_cpu())->interleave_hit++;
725 put_cpu(); 759 put_cpu();
726 } 760 }
727 return page; 761 return page;
diff --git a/mm/mmap.c b/mm/mmap.c
index de54acd9942f..da3fa90a0aae 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1175,7 +1175,12 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
1175 (!vma || addr + len <= vma->vm_start)) 1175 (!vma || addr + len <= vma->vm_start))
1176 return addr; 1176 return addr;
1177 } 1177 }
1178 start_addr = addr = mm->free_area_cache; 1178 if (len > mm->cached_hole_size) {
1179 start_addr = addr = mm->free_area_cache;
1180 } else {
1181 start_addr = addr = TASK_UNMAPPED_BASE;
1182 mm->cached_hole_size = 0;
1183 }
1179 1184
1180full_search: 1185full_search:
1181 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) { 1186 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
@@ -1186,7 +1191,9 @@ full_search:
1186 * some holes. 1191 * some holes.
1187 */ 1192 */
1188 if (start_addr != TASK_UNMAPPED_BASE) { 1193 if (start_addr != TASK_UNMAPPED_BASE) {
1189 start_addr = addr = TASK_UNMAPPED_BASE; 1194 addr = TASK_UNMAPPED_BASE;
1195 start_addr = addr;
1196 mm->cached_hole_size = 0;
1190 goto full_search; 1197 goto full_search;
1191 } 1198 }
1192 return -ENOMEM; 1199 return -ENOMEM;
@@ -1198,19 +1205,22 @@ full_search:
1198 mm->free_area_cache = addr + len; 1205 mm->free_area_cache = addr + len;
1199 return addr; 1206 return addr;
1200 } 1207 }
1208 if (addr + mm->cached_hole_size < vma->vm_start)
1209 mm->cached_hole_size = vma->vm_start - addr;
1201 addr = vma->vm_end; 1210 addr = vma->vm_end;
1202 } 1211 }
1203} 1212}
1204#endif 1213#endif
1205 1214
1206void arch_unmap_area(struct vm_area_struct *area) 1215void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
1207{ 1216{
1208 /* 1217 /*
1209 * Is this a new hole at the lowest possible address? 1218 * Is this a new hole at the lowest possible address?
1210 */ 1219 */
1211 if (area->vm_start >= TASK_UNMAPPED_BASE && 1220 if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache) {
1212 area->vm_start < area->vm_mm->free_area_cache) 1221 mm->free_area_cache = addr;
1213 area->vm_mm->free_area_cache = area->vm_start; 1222 mm->cached_hole_size = ~0UL;
1223 }
1214} 1224}
1215 1225
1216/* 1226/*
@@ -1240,6 +1250,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
1240 return addr; 1250 return addr;
1241 } 1251 }
1242 1252
1253 /* check if free_area_cache is useful for us */
1254 if (len <= mm->cached_hole_size) {
1255 mm->cached_hole_size = 0;
1256 mm->free_area_cache = mm->mmap_base;
1257 }
1258
1243 /* either no address requested or can't fit in requested address hole */ 1259 /* either no address requested or can't fit in requested address hole */
1244 addr = mm->free_area_cache; 1260 addr = mm->free_area_cache;
1245 1261
@@ -1251,6 +1267,9 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
1251 return (mm->free_area_cache = addr-len); 1267 return (mm->free_area_cache = addr-len);
1252 } 1268 }
1253 1269
1270 if (mm->mmap_base < len)
1271 goto bottomup;
1272
1254 addr = mm->mmap_base-len; 1273 addr = mm->mmap_base-len;
1255 1274
1256 do { 1275 do {
@@ -1264,38 +1283,45 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
1264 /* remember the address as a hint for next time */ 1283 /* remember the address as a hint for next time */
1265 return (mm->free_area_cache = addr); 1284 return (mm->free_area_cache = addr);
1266 1285
1286 /* remember the largest hole we saw so far */
1287 if (addr + mm->cached_hole_size < vma->vm_start)
1288 mm->cached_hole_size = vma->vm_start - addr;
1289
1267 /* try just below the current vma->vm_start */ 1290 /* try just below the current vma->vm_start */
1268 addr = vma->vm_start-len; 1291 addr = vma->vm_start-len;
1269 } while (len < vma->vm_start); 1292 } while (len < vma->vm_start);
1270 1293
1294bottomup:
1271 /* 1295 /*
1272 * A failed mmap() very likely causes application failure, 1296 * A failed mmap() very likely causes application failure,
1273 * so fall back to the bottom-up function here. This scenario 1297 * so fall back to the bottom-up function here. This scenario
1274 * can happen with large stack limits and large mmap() 1298 * can happen with large stack limits and large mmap()
1275 * allocations. 1299 * allocations.
1276 */ 1300 */
1277 mm->free_area_cache = TASK_UNMAPPED_BASE; 1301 mm->cached_hole_size = ~0UL;
1302 mm->free_area_cache = TASK_UNMAPPED_BASE;
1278 addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags); 1303 addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
1279 /* 1304 /*
1280 * Restore the topdown base: 1305 * Restore the topdown base:
1281 */ 1306 */
1282 mm->free_area_cache = mm->mmap_base; 1307 mm->free_area_cache = mm->mmap_base;
1308 mm->cached_hole_size = ~0UL;
1283 1309
1284 return addr; 1310 return addr;
1285} 1311}
1286#endif 1312#endif
1287 1313
1288void arch_unmap_area_topdown(struct vm_area_struct *area) 1314void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
1289{ 1315{
1290 /* 1316 /*
1291 * Is this a new hole at the highest possible address? 1317 * Is this a new hole at the highest possible address?
1292 */ 1318 */
1293 if (area->vm_end > area->vm_mm->free_area_cache) 1319 if (addr > mm->free_area_cache)
1294 area->vm_mm->free_area_cache = area->vm_end; 1320 mm->free_area_cache = addr;
1295 1321
1296 /* dont allow allocations above current base */ 1322 /* dont allow allocations above current base */
1297 if (area->vm_mm->free_area_cache > area->vm_mm->mmap_base) 1323 if (mm->free_area_cache > mm->mmap_base)
1298 area->vm_mm->free_area_cache = area->vm_mm->mmap_base; 1324 mm->free_area_cache = mm->mmap_base;
1299} 1325}
1300 1326
1301unsigned long 1327unsigned long
@@ -1595,7 +1621,6 @@ static void unmap_vma(struct mm_struct *mm, struct vm_area_struct *area)
1595 if (area->vm_flags & VM_LOCKED) 1621 if (area->vm_flags & VM_LOCKED)
1596 area->vm_mm->locked_vm -= len >> PAGE_SHIFT; 1622 area->vm_mm->locked_vm -= len >> PAGE_SHIFT;
1597 vm_stat_unaccount(area); 1623 vm_stat_unaccount(area);
1598 area->vm_mm->unmap_area(area);
1599 remove_vm_struct(area); 1624 remove_vm_struct(area);
1600} 1625}
1601 1626
@@ -1649,6 +1674,7 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
1649{ 1674{
1650 struct vm_area_struct **insertion_point; 1675 struct vm_area_struct **insertion_point;
1651 struct vm_area_struct *tail_vma = NULL; 1676 struct vm_area_struct *tail_vma = NULL;
1677 unsigned long addr;
1652 1678
1653 insertion_point = (prev ? &prev->vm_next : &mm->mmap); 1679 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
1654 do { 1680 do {
@@ -1659,6 +1685,11 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
1659 } while (vma && vma->vm_start < end); 1685 } while (vma && vma->vm_start < end);
1660 *insertion_point = vma; 1686 *insertion_point = vma;
1661 tail_vma->vm_next = NULL; 1687 tail_vma->vm_next = NULL;
1688 if (mm->unmap_area == arch_unmap_area)
1689 addr = prev ? prev->vm_end : mm->mmap_base;
1690 else
1691 addr = vma ? vma->vm_start : mm->mmap_base;
1692 mm->unmap_area(mm, addr);
1662 mm->mmap_cache = NULL; /* Kill the cache. */ 1693 mm->mmap_cache = NULL; /* Kill the cache. */
1663} 1694}
1664 1695
diff --git a/mm/msync.c b/mm/msync.c
index 090f426bca7d..d0f5a1bce7cb 100644
--- a/mm/msync.c
+++ b/mm/msync.c
@@ -34,6 +34,8 @@ static void sync_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
34 34
35 if (!pte_present(*pte)) 35 if (!pte_present(*pte))
36 continue; 36 continue;
37 if (!pte_maybe_dirty(*pte))
38 continue;
37 pfn = pte_pfn(*pte); 39 pfn = pte_pfn(*pte);
38 if (!pfn_valid(pfn)) 40 if (!pfn_valid(pfn))
39 continue; 41 continue;
diff --git a/mm/nommu.c b/mm/nommu.c
index c53e9c8f6b4a..ce74452c02d9 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1067,7 +1067,7 @@ unsigned long arch_get_unmapped_area(struct file *file, unsigned long addr,
1067 return -ENOMEM; 1067 return -ENOMEM;
1068} 1068}
1069 1069
1070void arch_unmap_area(struct vm_area_struct *area) 1070void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
1071{ 1071{
1072} 1072}
1073 1073
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 4bbb1cb10495..59666d905f19 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -258,6 +258,10 @@ void out_of_memory(unsigned int __nocast gfp_mask)
258 struct mm_struct *mm = NULL; 258 struct mm_struct *mm = NULL;
259 task_t * p; 259 task_t * p;
260 260
261 printk("oom-killer: gfp_mask=0x%x\n", gfp_mask);
262 /* print memory stats */
263 show_mem();
264
261 read_lock(&tasklist_lock); 265 read_lock(&tasklist_lock);
262retry: 266retry:
263 p = select_bad_process(); 267 p = select_bad_process();
@@ -268,12 +272,9 @@ retry:
268 /* Found nothing?!?! Either we hang forever, or we panic. */ 272 /* Found nothing?!?! Either we hang forever, or we panic. */
269 if (!p) { 273 if (!p) {
270 read_unlock(&tasklist_lock); 274 read_unlock(&tasklist_lock);
271 show_free_areas();
272 panic("Out of memory and no killable processes...\n"); 275 panic("Out of memory and no killable processes...\n");
273 } 276 }
274 277
275 printk("oom-killer: gfp_mask=0x%x\n", gfp_mask);
276 show_free_areas();
277 mm = oom_kill_process(p); 278 mm = oom_kill_process(p);
278 if (!mm) 279 if (!mm)
279 goto retry; 280 goto retry;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index b1061b1962f8..206920796f5f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -105,11 +105,13 @@ static void bad_page(const char *function, struct page *page)
105 printk(KERN_EMERG "Backtrace:\n"); 105 printk(KERN_EMERG "Backtrace:\n");
106 dump_stack(); 106 dump_stack();
107 printk(KERN_EMERG "Trying to fix it up, but a reboot is needed\n"); 107 printk(KERN_EMERG "Trying to fix it up, but a reboot is needed\n");
108 page->flags &= ~(1 << PG_private | 108 page->flags &= ~(1 << PG_lru |
109 1 << PG_private |
109 1 << PG_locked | 110 1 << PG_locked |
110 1 << PG_lru |
111 1 << PG_active | 111 1 << PG_active |
112 1 << PG_dirty | 112 1 << PG_dirty |
113 1 << PG_reclaim |
114 1 << PG_slab |
113 1 << PG_swapcache | 115 1 << PG_swapcache |
114 1 << PG_writeback); 116 1 << PG_writeback);
115 set_page_count(page, 0); 117 set_page_count(page, 0);
@@ -440,14 +442,17 @@ void set_page_refs(struct page *page, int order)
440 */ 442 */
441static void prep_new_page(struct page *page, int order) 443static void prep_new_page(struct page *page, int order)
442{ 444{
443 if (page->mapping || page_mapcount(page) || 445 if ( page_mapcount(page) ||
444 (page->flags & ( 446 page->mapping != NULL ||
447 page_count(page) != 0 ||
448 (page->flags & (
449 1 << PG_lru |
445 1 << PG_private | 450 1 << PG_private |
446 1 << PG_locked | 451 1 << PG_locked |
447 1 << PG_lru |
448 1 << PG_active | 452 1 << PG_active |
449 1 << PG_dirty | 453 1 << PG_dirty |
450 1 << PG_reclaim | 454 1 << PG_reclaim |
455 1 << PG_slab |
451 1 << PG_swapcache | 456 1 << PG_swapcache |
452 1 << PG_writeback ))) 457 1 << PG_writeback )))
453 bad_page(__FUNCTION__, page); 458 bad_page(__FUNCTION__, page);
@@ -511,6 +516,36 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order,
511 return allocated; 516 return allocated;
512} 517}
513 518
519#ifdef CONFIG_NUMA
520/* Called from the slab reaper to drain remote pagesets */
521void drain_remote_pages(void)
522{
523 struct zone *zone;
524 int i;
525 unsigned long flags;
526
527 local_irq_save(flags);
528 for_each_zone(zone) {
529 struct per_cpu_pageset *pset;
530
531 /* Do not drain local pagesets */
532 if (zone->zone_pgdat->node_id == numa_node_id())
533 continue;
534
535 pset = zone->pageset[smp_processor_id()];
536 for (i = 0; i < ARRAY_SIZE(pset->pcp); i++) {
537 struct per_cpu_pages *pcp;
538
539 pcp = &pset->pcp[i];
540 if (pcp->count)
541 pcp->count -= free_pages_bulk(zone, pcp->count,
542 &pcp->list, 0);
543 }
544 }
545 local_irq_restore(flags);
546}
547#endif
548
514#if defined(CONFIG_PM) || defined(CONFIG_HOTPLUG_CPU) 549#if defined(CONFIG_PM) || defined(CONFIG_HOTPLUG_CPU)
515static void __drain_pages(unsigned int cpu) 550static void __drain_pages(unsigned int cpu)
516{ 551{
@@ -520,7 +555,7 @@ static void __drain_pages(unsigned int cpu)
520 for_each_zone(zone) { 555 for_each_zone(zone) {
521 struct per_cpu_pageset *pset; 556 struct per_cpu_pageset *pset;
522 557
523 pset = &zone->pageset[cpu]; 558 pset = zone_pcp(zone, cpu);
524 for (i = 0; i < ARRAY_SIZE(pset->pcp); i++) { 559 for (i = 0; i < ARRAY_SIZE(pset->pcp); i++) {
525 struct per_cpu_pages *pcp; 560 struct per_cpu_pages *pcp;
526 561
@@ -583,12 +618,12 @@ static void zone_statistics(struct zonelist *zonelist, struct zone *z)
583 618
584 local_irq_save(flags); 619 local_irq_save(flags);
585 cpu = smp_processor_id(); 620 cpu = smp_processor_id();
586 p = &z->pageset[cpu]; 621 p = zone_pcp(z,cpu);
587 if (pg == orig) { 622 if (pg == orig) {
588 z->pageset[cpu].numa_hit++; 623 p->numa_hit++;
589 } else { 624 } else {
590 p->numa_miss++; 625 p->numa_miss++;
591 zonelist->zones[0]->pageset[cpu].numa_foreign++; 626 zone_pcp(zonelist->zones[0], cpu)->numa_foreign++;
592 } 627 }
593 if (pg == NODE_DATA(numa_node_id())) 628 if (pg == NODE_DATA(numa_node_id()))
594 p->local_node++; 629 p->local_node++;
@@ -615,12 +650,12 @@ static void fastcall free_hot_cold_page(struct page *page, int cold)
615 if (PageAnon(page)) 650 if (PageAnon(page))
616 page->mapping = NULL; 651 page->mapping = NULL;
617 free_pages_check(__FUNCTION__, page); 652 free_pages_check(__FUNCTION__, page);
618 pcp = &zone->pageset[get_cpu()].pcp[cold]; 653 pcp = &zone_pcp(zone, get_cpu())->pcp[cold];
619 local_irq_save(flags); 654 local_irq_save(flags);
620 if (pcp->count >= pcp->high)
621 pcp->count -= free_pages_bulk(zone, pcp->batch, &pcp->list, 0);
622 list_add(&page->lru, &pcp->list); 655 list_add(&page->lru, &pcp->list);
623 pcp->count++; 656 pcp->count++;
657 if (pcp->count >= pcp->high)
658 pcp->count -= free_pages_bulk(zone, pcp->batch, &pcp->list, 0);
624 local_irq_restore(flags); 659 local_irq_restore(flags);
625 put_cpu(); 660 put_cpu();
626} 661}
@@ -659,7 +694,7 @@ buffered_rmqueue(struct zone *zone, int order, unsigned int __nocast gfp_flags)
659 if (order == 0) { 694 if (order == 0) {
660 struct per_cpu_pages *pcp; 695 struct per_cpu_pages *pcp;
661 696
662 pcp = &zone->pageset[get_cpu()].pcp[cold]; 697 pcp = &zone_pcp(zone, get_cpu())->pcp[cold];
663 local_irq_save(flags); 698 local_irq_save(flags);
664 if (pcp->count <= pcp->low) 699 if (pcp->count <= pcp->low)
665 pcp->count += rmqueue_bulk(zone, 0, 700 pcp->count += rmqueue_bulk(zone, 0,
@@ -724,6 +759,16 @@ int zone_watermark_ok(struct zone *z, int order, unsigned long mark,
724 return 1; 759 return 1;
725} 760}
726 761
762static inline int
763should_reclaim_zone(struct zone *z, unsigned int gfp_mask)
764{
765 if (!z->reclaim_pages)
766 return 0;
767 if (gfp_mask & __GFP_NORECLAIM)
768 return 0;
769 return 1;
770}
771
727/* 772/*
728 * This is the 'heart' of the zoned buddy allocator. 773 * This is the 'heart' of the zoned buddy allocator.
729 */ 774 */
@@ -760,17 +805,32 @@ __alloc_pages(unsigned int __nocast gfp_mask, unsigned int order,
760 805
761 classzone_idx = zone_idx(zones[0]); 806 classzone_idx = zone_idx(zones[0]);
762 807
763 restart: 808restart:
764 /* Go through the zonelist once, looking for a zone with enough free */ 809 /* Go through the zonelist once, looking for a zone with enough free */
765 for (i = 0; (z = zones[i]) != NULL; i++) { 810 for (i = 0; (z = zones[i]) != NULL; i++) {
766 811 int do_reclaim = should_reclaim_zone(z, gfp_mask);
767 if (!zone_watermark_ok(z, order, z->pages_low,
768 classzone_idx, 0, 0))
769 continue;
770 812
771 if (!cpuset_zone_allowed(z)) 813 if (!cpuset_zone_allowed(z))
772 continue; 814 continue;
773 815
816 /*
817 * If the zone is to attempt early page reclaim then this loop
818 * will try to reclaim pages and check the watermark a second
819 * time before giving up and falling back to the next zone.
820 */
821zone_reclaim_retry:
822 if (!zone_watermark_ok(z, order, z->pages_low,
823 classzone_idx, 0, 0)) {
824 if (!do_reclaim)
825 continue;
826 else {
827 zone_reclaim(z, gfp_mask, order);
828 /* Only try reclaim once */
829 do_reclaim = 0;
830 goto zone_reclaim_retry;
831 }
832 }
833
774 page = buffered_rmqueue(z, order, gfp_mask); 834 page = buffered_rmqueue(z, order, gfp_mask);
775 if (page) 835 if (page)
776 goto got_pg; 836 goto got_pg;
@@ -829,7 +889,7 @@ rebalance:
829 reclaim_state.reclaimed_slab = 0; 889 reclaim_state.reclaimed_slab = 0;
830 p->reclaim_state = &reclaim_state; 890 p->reclaim_state = &reclaim_state;
831 891
832 did_some_progress = try_to_free_pages(zones, gfp_mask, order); 892 did_some_progress = try_to_free_pages(zones, gfp_mask);
833 893
834 p->reclaim_state = NULL; 894 p->reclaim_state = NULL;
835 p->flags &= ~PF_MEMALLOC; 895 p->flags &= ~PF_MEMALLOC;
@@ -905,6 +965,7 @@ nopage:
905 " order:%d, mode:0x%x\n", 965 " order:%d, mode:0x%x\n",
906 p->comm, order, gfp_mask); 966 p->comm, order, gfp_mask);
907 dump_stack(); 967 dump_stack();
968 show_mem();
908 } 969 }
909 return NULL; 970 return NULL;
910got_pg: 971got_pg:
@@ -1114,7 +1175,7 @@ void get_full_page_state(struct page_state *ret)
1114 __get_page_state(ret, sizeof(*ret) / sizeof(unsigned long)); 1175 __get_page_state(ret, sizeof(*ret) / sizeof(unsigned long));
1115} 1176}
1116 1177
1117unsigned long __read_page_state(unsigned offset) 1178unsigned long __read_page_state(unsigned long offset)
1118{ 1179{
1119 unsigned long ret = 0; 1180 unsigned long ret = 0;
1120 int cpu; 1181 int cpu;
@@ -1128,7 +1189,7 @@ unsigned long __read_page_state(unsigned offset)
1128 return ret; 1189 return ret;
1129} 1190}
1130 1191
1131void __mod_page_state(unsigned offset, unsigned long delta) 1192void __mod_page_state(unsigned long offset, unsigned long delta)
1132{ 1193{
1133 unsigned long flags; 1194 unsigned long flags;
1134 void* ptr; 1195 void* ptr;
@@ -1237,22 +1298,23 @@ void show_free_areas(void)
1237 if (!cpu_possible(cpu)) 1298 if (!cpu_possible(cpu))
1238 continue; 1299 continue;
1239 1300
1240 pageset = zone->pageset + cpu; 1301 pageset = zone_pcp(zone, cpu);
1241 1302
1242 for (temperature = 0; temperature < 2; temperature++) 1303 for (temperature = 0; temperature < 2; temperature++)
1243 printk("cpu %d %s: low %d, high %d, batch %d\n", 1304 printk("cpu %d %s: low %d, high %d, batch %d used:%d\n",
1244 cpu, 1305 cpu,
1245 temperature ? "cold" : "hot", 1306 temperature ? "cold" : "hot",
1246 pageset->pcp[temperature].low, 1307 pageset->pcp[temperature].low,
1247 pageset->pcp[temperature].high, 1308 pageset->pcp[temperature].high,
1248 pageset->pcp[temperature].batch); 1309 pageset->pcp[temperature].batch,
1310 pageset->pcp[temperature].count);
1249 } 1311 }
1250 } 1312 }
1251 1313
1252 get_page_state(&ps); 1314 get_page_state(&ps);
1253 get_zone_counts(&active, &inactive, &free); 1315 get_zone_counts(&active, &inactive, &free);
1254 1316
1255 printk("\nFree pages: %11ukB (%ukB HighMem)\n", 1317 printk("Free pages: %11ukB (%ukB HighMem)\n",
1256 K(nr_free_pages()), 1318 K(nr_free_pages()),
1257 K(nr_free_highpages())); 1319 K(nr_free_highpages()));
1258 1320
@@ -1620,6 +1682,155 @@ void zone_init_free_lists(struct pglist_data *pgdat, struct zone *zone,
1620 memmap_init_zone((size), (nid), (zone), (start_pfn)) 1682 memmap_init_zone((size), (nid), (zone), (start_pfn))
1621#endif 1683#endif
1622 1684
1685static int __devinit zone_batchsize(struct zone *zone)
1686{
1687 int batch;
1688
1689 /*
1690 * The per-cpu-pages pools are set to around 1000th of the
1691 * size of the zone. But no more than 1/4 of a meg - there's
1692 * no point in going beyond the size of L2 cache.
1693 *
1694 * OK, so we don't know how big the cache is. So guess.
1695 */
1696 batch = zone->present_pages / 1024;
1697 if (batch * PAGE_SIZE > 256 * 1024)
1698 batch = (256 * 1024) / PAGE_SIZE;
1699 batch /= 4; /* We effectively *= 4 below */
1700 if (batch < 1)
1701 batch = 1;
1702
1703 /*
1704 * Clamp the batch to a 2^n - 1 value. Having a power
1705 * of 2 value was found to be more likely to have
1706 * suboptimal cache aliasing properties in some cases.
1707 *
1708 * For example if 2 tasks are alternately allocating
1709 * batches of pages, one task can end up with a lot
1710 * of pages of one half of the possible page colors
1711 * and the other with pages of the other colors.
1712 */
1713 batch = (1 << fls(batch + batch/2)) - 1;
1714 return batch;
1715}
1716
1717inline void setup_pageset(struct per_cpu_pageset *p, unsigned long batch)
1718{
1719 struct per_cpu_pages *pcp;
1720
1721 pcp = &p->pcp[0]; /* hot */
1722 pcp->count = 0;
1723 pcp->low = 2 * batch;
1724 pcp->high = 6 * batch;
1725 pcp->batch = max(1UL, 1 * batch);
1726 INIT_LIST_HEAD(&pcp->list);
1727
1728 pcp = &p->pcp[1]; /* cold*/
1729 pcp->count = 0;
1730 pcp->low = 0;
1731 pcp->high = 2 * batch;
1732 pcp->batch = max(1UL, 1 * batch);
1733 INIT_LIST_HEAD(&pcp->list);
1734}
1735
1736#ifdef CONFIG_NUMA
1737/*
1738 * Boot pageset table. One per cpu which is going to be used for all
1739 * zones and all nodes. The parameters will be set in such a way
1740 * that an item put on a list will immediately be handed over to
1741 * the buddy list. This is safe since pageset manipulation is done
1742 * with interrupts disabled.
1743 *
1744 * Some NUMA counter updates may also be caught by the boot pagesets.
1745 * These will be discarded when bootup is complete.
1746 */
1747static struct per_cpu_pageset
1748 boot_pageset[NR_CPUS] __initdata;
1749
1750/*
1751 * Dynamically allocate memory for the
1752 * per cpu pageset array in struct zone.
1753 */
1754static int __devinit process_zones(int cpu)
1755{
1756 struct zone *zone, *dzone;
1757
1758 for_each_zone(zone) {
1759
1760 zone->pageset[cpu] = kmalloc_node(sizeof(struct per_cpu_pageset),
1761 GFP_KERNEL, cpu_to_node(cpu));
1762 if (!zone->pageset[cpu])
1763 goto bad;
1764
1765 setup_pageset(zone->pageset[cpu], zone_batchsize(zone));
1766 }
1767
1768 return 0;
1769bad:
1770 for_each_zone(dzone) {
1771 if (dzone == zone)
1772 break;
1773 kfree(dzone->pageset[cpu]);
1774 dzone->pageset[cpu] = NULL;
1775 }
1776 return -ENOMEM;
1777}
1778
1779static inline void free_zone_pagesets(int cpu)
1780{
1781#ifdef CONFIG_NUMA
1782 struct zone *zone;
1783
1784 for_each_zone(zone) {
1785 struct per_cpu_pageset *pset = zone_pcp(zone, cpu);
1786
1787 zone_pcp(zone, cpu) = NULL;
1788 kfree(pset);
1789 }
1790#endif
1791}
1792
1793static int __devinit pageset_cpuup_callback(struct notifier_block *nfb,
1794 unsigned long action,
1795 void *hcpu)
1796{
1797 int cpu = (long)hcpu;
1798 int ret = NOTIFY_OK;
1799
1800 switch (action) {
1801 case CPU_UP_PREPARE:
1802 if (process_zones(cpu))
1803 ret = NOTIFY_BAD;
1804 break;
1805#ifdef CONFIG_HOTPLUG_CPU
1806 case CPU_DEAD:
1807 free_zone_pagesets(cpu);
1808 break;
1809#endif
1810 default:
1811 break;
1812 }
1813 return ret;
1814}
1815
1816static struct notifier_block pageset_notifier =
1817 { &pageset_cpuup_callback, NULL, 0 };
1818
1819void __init setup_per_cpu_pageset()
1820{
1821 int err;
1822
1823 /* Initialize per_cpu_pageset for cpu 0.
1824 * A cpuup callback will do this for every cpu
1825 * as it comes online
1826 */
1827 err = process_zones(smp_processor_id());
1828 BUG_ON(err);
1829 register_cpu_notifier(&pageset_notifier);
1830}
1831
1832#endif
1833
1623/* 1834/*
1624 * Set up the zone data structures: 1835 * Set up the zone data structures:
1625 * - mark all pages reserved 1836 * - mark all pages reserved
@@ -1662,48 +1873,16 @@ static void __init free_area_init_core(struct pglist_data *pgdat,
1662 1873
1663 zone->temp_priority = zone->prev_priority = DEF_PRIORITY; 1874 zone->temp_priority = zone->prev_priority = DEF_PRIORITY;
1664 1875
1665 /* 1876 batch = zone_batchsize(zone);
1666 * The per-cpu-pages pools are set to around 1000th of the
1667 * size of the zone. But no more than 1/4 of a meg - there's
1668 * no point in going beyond the size of L2 cache.
1669 *
1670 * OK, so we don't know how big the cache is. So guess.
1671 */
1672 batch = zone->present_pages / 1024;
1673 if (batch * PAGE_SIZE > 256 * 1024)
1674 batch = (256 * 1024) / PAGE_SIZE;
1675 batch /= 4; /* We effectively *= 4 below */
1676 if (batch < 1)
1677 batch = 1;
1678
1679 /*
1680 * Clamp the batch to a 2^n - 1 value. Having a power
1681 * of 2 value was found to be more likely to have
1682 * suboptimal cache aliasing properties in some cases.
1683 *
1684 * For example if 2 tasks are alternately allocating
1685 * batches of pages, one task can end up with a lot
1686 * of pages of one half of the possible page colors
1687 * and the other with pages of the other colors.
1688 */
1689 batch = (1 << fls(batch + batch/2)) - 1;
1690 1877
1691 for (cpu = 0; cpu < NR_CPUS; cpu++) { 1878 for (cpu = 0; cpu < NR_CPUS; cpu++) {
1692 struct per_cpu_pages *pcp; 1879#ifdef CONFIG_NUMA
1693 1880 /* Early boot. Slab allocator not functional yet */
1694 pcp = &zone->pageset[cpu].pcp[0]; /* hot */ 1881 zone->pageset[cpu] = &boot_pageset[cpu];
1695 pcp->count = 0; 1882 setup_pageset(&boot_pageset[cpu],0);
1696 pcp->low = 2 * batch; 1883#else
1697 pcp->high = 6 * batch; 1884 setup_pageset(zone_pcp(zone,cpu), batch);
1698 pcp->batch = 1 * batch; 1885#endif
1699 INIT_LIST_HEAD(&pcp->list);
1700
1701 pcp = &zone->pageset[cpu].pcp[1]; /* cold */
1702 pcp->count = 0;
1703 pcp->low = 0;
1704 pcp->high = 2 * batch;
1705 pcp->batch = 1 * batch;
1706 INIT_LIST_HEAD(&pcp->list);
1707 } 1886 }
1708 printk(KERN_DEBUG " %s zone: %lu pages, LIFO batch:%lu\n", 1887 printk(KERN_DEBUG " %s zone: %lu pages, LIFO batch:%lu\n",
1709 zone_names[j], realsize, batch); 1888 zone_names[j], realsize, batch);
@@ -1713,6 +1892,7 @@ static void __init free_area_init_core(struct pglist_data *pgdat,
1713 zone->nr_scan_inactive = 0; 1892 zone->nr_scan_inactive = 0;
1714 zone->nr_active = 0; 1893 zone->nr_active = 0;
1715 zone->nr_inactive = 0; 1894 zone->nr_inactive = 0;
1895 atomic_set(&zone->reclaim_in_progress, -1);
1716 if (!size) 1896 if (!size)
1717 continue; 1897 continue;
1718 1898
@@ -1853,6 +2033,115 @@ struct seq_operations fragmentation_op = {
1853 .show = frag_show, 2033 .show = frag_show,
1854}; 2034};
1855 2035
2036/*
2037 * Output information about zones in @pgdat.
2038 */
2039static int zoneinfo_show(struct seq_file *m, void *arg)
2040{
2041 pg_data_t *pgdat = arg;
2042 struct zone *zone;
2043 struct zone *node_zones = pgdat->node_zones;
2044 unsigned long flags;
2045
2046 for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; zone++) {
2047 int i;
2048
2049 if (!zone->present_pages)
2050 continue;
2051
2052 spin_lock_irqsave(&zone->lock, flags);
2053 seq_printf(m, "Node %d, zone %8s", pgdat->node_id, zone->name);
2054 seq_printf(m,
2055 "\n pages free %lu"
2056 "\n min %lu"
2057 "\n low %lu"
2058 "\n high %lu"
2059 "\n active %lu"
2060 "\n inactive %lu"
2061 "\n scanned %lu (a: %lu i: %lu)"
2062 "\n spanned %lu"
2063 "\n present %lu",
2064 zone->free_pages,
2065 zone->pages_min,
2066 zone->pages_low,
2067 zone->pages_high,
2068 zone->nr_active,
2069 zone->nr_inactive,
2070 zone->pages_scanned,
2071 zone->nr_scan_active, zone->nr_scan_inactive,
2072 zone->spanned_pages,
2073 zone->present_pages);
2074 seq_printf(m,
2075 "\n protection: (%lu",
2076 zone->lowmem_reserve[0]);
2077 for (i = 1; i < ARRAY_SIZE(zone->lowmem_reserve); i++)
2078 seq_printf(m, ", %lu", zone->lowmem_reserve[i]);
2079 seq_printf(m,
2080 ")"
2081 "\n pagesets");
2082 for (i = 0; i < ARRAY_SIZE(zone->pageset); i++) {
2083 struct per_cpu_pageset *pageset;
2084 int j;
2085
2086 pageset = zone_pcp(zone, i);
2087 for (j = 0; j < ARRAY_SIZE(pageset->pcp); j++) {
2088 if (pageset->pcp[j].count)
2089 break;
2090 }
2091 if (j == ARRAY_SIZE(pageset->pcp))
2092 continue;
2093 for (j = 0; j < ARRAY_SIZE(pageset->pcp); j++) {
2094 seq_printf(m,
2095 "\n cpu: %i pcp: %i"
2096 "\n count: %i"
2097 "\n low: %i"
2098 "\n high: %i"
2099 "\n batch: %i",
2100 i, j,
2101 pageset->pcp[j].count,
2102 pageset->pcp[j].low,
2103 pageset->pcp[j].high,
2104 pageset->pcp[j].batch);
2105 }
2106#ifdef CONFIG_NUMA
2107 seq_printf(m,
2108 "\n numa_hit: %lu"
2109 "\n numa_miss: %lu"
2110 "\n numa_foreign: %lu"
2111 "\n interleave_hit: %lu"
2112 "\n local_node: %lu"
2113 "\n other_node: %lu",
2114 pageset->numa_hit,
2115 pageset->numa_miss,
2116 pageset->numa_foreign,
2117 pageset->interleave_hit,
2118 pageset->local_node,
2119 pageset->other_node);
2120#endif
2121 }
2122 seq_printf(m,
2123 "\n all_unreclaimable: %u"
2124 "\n prev_priority: %i"
2125 "\n temp_priority: %i"
2126 "\n start_pfn: %lu",
2127 zone->all_unreclaimable,
2128 zone->prev_priority,
2129 zone->temp_priority,
2130 zone->zone_start_pfn);
2131 spin_unlock_irqrestore(&zone->lock, flags);
2132 seq_putc(m, '\n');
2133 }
2134 return 0;
2135}
2136
2137struct seq_operations zoneinfo_op = {
2138 .start = frag_start, /* iterate over all zones. The same as in
2139 * fragmentation. */
2140 .next = frag_next,
2141 .stop = frag_stop,
2142 .show = zoneinfo_show,
2143};
2144
1856static char *vmstat_text[] = { 2145static char *vmstat_text[] = {
1857 "nr_dirty", 2146 "nr_dirty",
1858 "nr_writeback", 2147 "nr_writeback",
@@ -2058,10 +2347,10 @@ static void setup_per_zone_pages_min(void)
2058 min_pages = 128; 2347 min_pages = 128;
2059 zone->pages_min = min_pages; 2348 zone->pages_min = min_pages;
2060 } else { 2349 } else {
2061 /* if it's a lowmem zone, reserve a number of pages 2350 /* if it's a lowmem zone, reserve a number of pages
2062 * proportionate to the zone's size. 2351 * proportionate to the zone's size.
2063 */ 2352 */
2064 zone->pages_min = (pages_min * zone->present_pages) / 2353 zone->pages_min = (pages_min * zone->present_pages) /
2065 lowmem_pages; 2354 lowmem_pages;
2066 } 2355 }
2067 2356
diff --git a/mm/rmap.c b/mm/rmap.c
index 9827409eb7c7..89770bd25f31 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -539,27 +539,6 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma)
539 goto out_unmap; 539 goto out_unmap;
540 } 540 }
541 541
542 /*
543 * Don't pull an anonymous page out from under get_user_pages.
544 * GUP carefully breaks COW and raises page count (while holding
545 * page_table_lock, as we have here) to make sure that the page
546 * cannot be freed. If we unmap that page here, a user write
547 * access to the virtual address will bring back the page, but
548 * its raised count will (ironically) be taken to mean it's not
549 * an exclusive swap page, do_wp_page will replace it by a copy
550 * page, and the user never get to see the data GUP was holding
551 * the original page for.
552 *
553 * This test is also useful for when swapoff (unuse_process) has
554 * to drop page lock: its reference to the page stops existing
555 * ptes from being unmapped, so swapoff can make progress.
556 */
557 if (PageSwapCache(page) &&
558 page_count(page) != page_mapcount(page) + 2) {
559 ret = SWAP_FAIL;
560 goto out_unmap;
561 }
562
563 /* Nuke the page table entry. */ 542 /* Nuke the page table entry. */
564 flush_cache_page(vma, address, page_to_pfn(page)); 543 flush_cache_page(vma, address, page_to_pfn(page));
565 pteval = ptep_clear_flush(vma, address, pte); 544 pteval = ptep_clear_flush(vma, address, pte);
diff --git a/mm/shmem.c b/mm/shmem.c
index 61574b81d979..e64fa726a790 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -6,8 +6,8 @@
6 * 2000-2001 Christoph Rohland 6 * 2000-2001 Christoph Rohland
7 * 2000-2001 SAP AG 7 * 2000-2001 SAP AG
8 * 2002 Red Hat Inc. 8 * 2002 Red Hat Inc.
9 * Copyright (C) 2002-2004 Hugh Dickins. 9 * Copyright (C) 2002-2005 Hugh Dickins.
10 * Copyright (C) 2002-2004 VERITAS Software Corporation. 10 * Copyright (C) 2002-2005 VERITAS Software Corporation.
11 * Copyright (C) 2004 Andi Kleen, SuSE Labs 11 * Copyright (C) 2004 Andi Kleen, SuSE Labs
12 * 12 *
13 * Extended attribute support for tmpfs: 13 * Extended attribute support for tmpfs:
@@ -194,7 +194,7 @@ static DEFINE_SPINLOCK(shmem_swaplist_lock);
194static void shmem_free_blocks(struct inode *inode, long pages) 194static void shmem_free_blocks(struct inode *inode, long pages)
195{ 195{
196 struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); 196 struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
197 if (sbinfo) { 197 if (sbinfo->max_blocks) {
198 spin_lock(&sbinfo->stat_lock); 198 spin_lock(&sbinfo->stat_lock);
199 sbinfo->free_blocks += pages; 199 sbinfo->free_blocks += pages;
200 inode->i_blocks -= pages*BLOCKS_PER_PAGE; 200 inode->i_blocks -= pages*BLOCKS_PER_PAGE;
@@ -357,7 +357,7 @@ static swp_entry_t *shmem_swp_alloc(struct shmem_inode_info *info, unsigned long
357 * page (and perhaps indirect index pages) yet to allocate: 357 * page (and perhaps indirect index pages) yet to allocate:
358 * a waste to allocate index if we cannot allocate data. 358 * a waste to allocate index if we cannot allocate data.
359 */ 359 */
360 if (sbinfo) { 360 if (sbinfo->max_blocks) {
361 spin_lock(&sbinfo->stat_lock); 361 spin_lock(&sbinfo->stat_lock);
362 if (sbinfo->free_blocks <= 1) { 362 if (sbinfo->free_blocks <= 1) {
363 spin_unlock(&sbinfo->stat_lock); 363 spin_unlock(&sbinfo->stat_lock);
@@ -677,8 +677,8 @@ static void shmem_delete_inode(struct inode *inode)
677 spin_unlock(&shmem_swaplist_lock); 677 spin_unlock(&shmem_swaplist_lock);
678 } 678 }
679 } 679 }
680 if (sbinfo) { 680 BUG_ON(inode->i_blocks);
681 BUG_ON(inode->i_blocks); 681 if (sbinfo->max_inodes) {
682 spin_lock(&sbinfo->stat_lock); 682 spin_lock(&sbinfo->stat_lock);
683 sbinfo->free_inodes++; 683 sbinfo->free_inodes++;
684 spin_unlock(&sbinfo->stat_lock); 684 spin_unlock(&sbinfo->stat_lock);
@@ -1080,7 +1080,7 @@ repeat:
1080 } else { 1080 } else {
1081 shmem_swp_unmap(entry); 1081 shmem_swp_unmap(entry);
1082 sbinfo = SHMEM_SB(inode->i_sb); 1082 sbinfo = SHMEM_SB(inode->i_sb);
1083 if (sbinfo) { 1083 if (sbinfo->max_blocks) {
1084 spin_lock(&sbinfo->stat_lock); 1084 spin_lock(&sbinfo->stat_lock);
1085 if (sbinfo->free_blocks == 0 || 1085 if (sbinfo->free_blocks == 0 ||
1086 shmem_acct_block(info->flags)) { 1086 shmem_acct_block(info->flags)) {
@@ -1269,7 +1269,7 @@ shmem_get_inode(struct super_block *sb, int mode, dev_t dev)
1269 struct shmem_inode_info *info; 1269 struct shmem_inode_info *info;
1270 struct shmem_sb_info *sbinfo = SHMEM_SB(sb); 1270 struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
1271 1271
1272 if (sbinfo) { 1272 if (sbinfo->max_inodes) {
1273 spin_lock(&sbinfo->stat_lock); 1273 spin_lock(&sbinfo->stat_lock);
1274 if (!sbinfo->free_inodes) { 1274 if (!sbinfo->free_inodes) {
1275 spin_unlock(&sbinfo->stat_lock); 1275 spin_unlock(&sbinfo->stat_lock);
@@ -1319,7 +1319,7 @@ shmem_get_inode(struct super_block *sb, int mode, dev_t dev)
1319 mpol_shared_policy_init(&info->policy); 1319 mpol_shared_policy_init(&info->policy);
1320 break; 1320 break;
1321 } 1321 }
1322 } else if (sbinfo) { 1322 } else if (sbinfo->max_inodes) {
1323 spin_lock(&sbinfo->stat_lock); 1323 spin_lock(&sbinfo->stat_lock);
1324 sbinfo->free_inodes++; 1324 sbinfo->free_inodes++;
1325 spin_unlock(&sbinfo->stat_lock); 1325 spin_unlock(&sbinfo->stat_lock);
@@ -1328,31 +1328,6 @@ shmem_get_inode(struct super_block *sb, int mode, dev_t dev)
1328} 1328}
1329 1329
1330#ifdef CONFIG_TMPFS 1330#ifdef CONFIG_TMPFS
1331
1332static int shmem_set_size(struct shmem_sb_info *sbinfo,
1333 unsigned long max_blocks, unsigned long max_inodes)
1334{
1335 int error;
1336 unsigned long blocks, inodes;
1337
1338 spin_lock(&sbinfo->stat_lock);
1339 blocks = sbinfo->max_blocks - sbinfo->free_blocks;
1340 inodes = sbinfo->max_inodes - sbinfo->free_inodes;
1341 error = -EINVAL;
1342 if (max_blocks < blocks)
1343 goto out;
1344 if (max_inodes < inodes)
1345 goto out;
1346 error = 0;
1347 sbinfo->max_blocks = max_blocks;
1348 sbinfo->free_blocks = max_blocks - blocks;
1349 sbinfo->max_inodes = max_inodes;
1350 sbinfo->free_inodes = max_inodes - inodes;
1351out:
1352 spin_unlock(&sbinfo->stat_lock);
1353 return error;
1354}
1355
1356static struct inode_operations shmem_symlink_inode_operations; 1331static struct inode_operations shmem_symlink_inode_operations;
1357static struct inode_operations shmem_symlink_inline_operations; 1332static struct inode_operations shmem_symlink_inline_operations;
1358 1333
@@ -1607,15 +1582,17 @@ static int shmem_statfs(struct super_block *sb, struct kstatfs *buf)
1607 buf->f_type = TMPFS_MAGIC; 1582 buf->f_type = TMPFS_MAGIC;
1608 buf->f_bsize = PAGE_CACHE_SIZE; 1583 buf->f_bsize = PAGE_CACHE_SIZE;
1609 buf->f_namelen = NAME_MAX; 1584 buf->f_namelen = NAME_MAX;
1610 if (sbinfo) { 1585 spin_lock(&sbinfo->stat_lock);
1611 spin_lock(&sbinfo->stat_lock); 1586 if (sbinfo->max_blocks) {
1612 buf->f_blocks = sbinfo->max_blocks; 1587 buf->f_blocks = sbinfo->max_blocks;
1613 buf->f_bavail = buf->f_bfree = sbinfo->free_blocks; 1588 buf->f_bavail = buf->f_bfree = sbinfo->free_blocks;
1589 }
1590 if (sbinfo->max_inodes) {
1614 buf->f_files = sbinfo->max_inodes; 1591 buf->f_files = sbinfo->max_inodes;
1615 buf->f_ffree = sbinfo->free_inodes; 1592 buf->f_ffree = sbinfo->free_inodes;
1616 spin_unlock(&sbinfo->stat_lock);
1617 } 1593 }
1618 /* else leave those fields 0 like simple_statfs */ 1594 /* else leave those fields 0 like simple_statfs */
1595 spin_unlock(&sbinfo->stat_lock);
1619 return 0; 1596 return 0;
1620} 1597}
1621 1598
@@ -1672,7 +1649,7 @@ static int shmem_link(struct dentry *old_dentry, struct inode *dir, struct dentr
1672 * but each new link needs a new dentry, pinning lowmem, and 1649 * but each new link needs a new dentry, pinning lowmem, and
1673 * tmpfs dentries cannot be pruned until they are unlinked. 1650 * tmpfs dentries cannot be pruned until they are unlinked.
1674 */ 1651 */
1675 if (sbinfo) { 1652 if (sbinfo->max_inodes) {
1676 spin_lock(&sbinfo->stat_lock); 1653 spin_lock(&sbinfo->stat_lock);
1677 if (!sbinfo->free_inodes) { 1654 if (!sbinfo->free_inodes) {
1678 spin_unlock(&sbinfo->stat_lock); 1655 spin_unlock(&sbinfo->stat_lock);
@@ -1697,7 +1674,7 @@ static int shmem_unlink(struct inode *dir, struct dentry *dentry)
1697 1674
1698 if (inode->i_nlink > 1 && !S_ISDIR(inode->i_mode)) { 1675 if (inode->i_nlink > 1 && !S_ISDIR(inode->i_mode)) {
1699 struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); 1676 struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
1700 if (sbinfo) { 1677 if (sbinfo->max_inodes) {
1701 spin_lock(&sbinfo->stat_lock); 1678 spin_lock(&sbinfo->stat_lock);
1702 sbinfo->free_inodes++; 1679 sbinfo->free_inodes++;
1703 spin_unlock(&sbinfo->stat_lock); 1680 spin_unlock(&sbinfo->stat_lock);
@@ -1921,22 +1898,42 @@ bad_val:
1921static int shmem_remount_fs(struct super_block *sb, int *flags, char *data) 1898static int shmem_remount_fs(struct super_block *sb, int *flags, char *data)
1922{ 1899{
1923 struct shmem_sb_info *sbinfo = SHMEM_SB(sb); 1900 struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
1924 unsigned long max_blocks = 0; 1901 unsigned long max_blocks = sbinfo->max_blocks;
1925 unsigned long max_inodes = 0; 1902 unsigned long max_inodes = sbinfo->max_inodes;
1903 unsigned long blocks;
1904 unsigned long inodes;
1905 int error = -EINVAL;
1906
1907 if (shmem_parse_options(data, NULL, NULL, NULL,
1908 &max_blocks, &max_inodes))
1909 return error;
1926 1910
1927 if (sbinfo) { 1911 spin_lock(&sbinfo->stat_lock);
1928 max_blocks = sbinfo->max_blocks; 1912 blocks = sbinfo->max_blocks - sbinfo->free_blocks;
1929 max_inodes = sbinfo->max_inodes; 1913 inodes = sbinfo->max_inodes - sbinfo->free_inodes;
1930 } 1914 if (max_blocks < blocks)
1931 if (shmem_parse_options(data, NULL, NULL, NULL, &max_blocks, &max_inodes)) 1915 goto out;
1932 return -EINVAL; 1916 if (max_inodes < inodes)
1933 /* Keep it simple: disallow limited <-> unlimited remount */ 1917 goto out;
1934 if ((max_blocks || max_inodes) == !sbinfo) 1918 /*
1935 return -EINVAL; 1919 * Those tests also disallow limited->unlimited while any are in
1936 /* But allow the pointless unlimited -> unlimited remount */ 1920 * use, so i_blocks will always be zero when max_blocks is zero;
1937 if (!sbinfo) 1921 * but we must separately disallow unlimited->limited, because
1938 return 0; 1922 * in that case we have no record of how much is already in use.
1939 return shmem_set_size(sbinfo, max_blocks, max_inodes); 1923 */
1924 if (max_blocks && !sbinfo->max_blocks)
1925 goto out;
1926 if (max_inodes && !sbinfo->max_inodes)
1927 goto out;
1928
1929 error = 0;
1930 sbinfo->max_blocks = max_blocks;
1931 sbinfo->free_blocks = max_blocks - blocks;
1932 sbinfo->max_inodes = max_inodes;
1933 sbinfo->free_inodes = max_inodes - inodes;
1934out:
1935 spin_unlock(&sbinfo->stat_lock);
1936 return error;
1940} 1937}
1941#endif 1938#endif
1942 1939
@@ -1961,11 +1958,11 @@ static int shmem_fill_super(struct super_block *sb,
1961 uid_t uid = current->fsuid; 1958 uid_t uid = current->fsuid;
1962 gid_t gid = current->fsgid; 1959 gid_t gid = current->fsgid;
1963 int err = -ENOMEM; 1960 int err = -ENOMEM;
1964 1961 struct shmem_sb_info *sbinfo;
1965#ifdef CONFIG_TMPFS
1966 unsigned long blocks = 0; 1962 unsigned long blocks = 0;
1967 unsigned long inodes = 0; 1963 unsigned long inodes = 0;
1968 1964
1965#ifdef CONFIG_TMPFS
1969 /* 1966 /*
1970 * Per default we only allow half of the physical ram per 1967 * Per default we only allow half of the physical ram per
1971 * tmpfs instance, limiting inodes to one per page of lowmem; 1968 * tmpfs instance, limiting inodes to one per page of lowmem;
@@ -1976,34 +1973,34 @@ static int shmem_fill_super(struct super_block *sb,
1976 inodes = totalram_pages - totalhigh_pages; 1973 inodes = totalram_pages - totalhigh_pages;
1977 if (inodes > blocks) 1974 if (inodes > blocks)
1978 inodes = blocks; 1975 inodes = blocks;
1979 1976 if (shmem_parse_options(data, &mode, &uid, &gid,
1980 if (shmem_parse_options(data, &mode, 1977 &blocks, &inodes))
1981 &uid, &gid, &blocks, &inodes))
1982 return -EINVAL; 1978 return -EINVAL;
1983 } 1979 }
1984
1985 if (blocks || inodes) {
1986 struct shmem_sb_info *sbinfo;
1987 sbinfo = kmalloc(sizeof(struct shmem_sb_info), GFP_KERNEL);
1988 if (!sbinfo)
1989 return -ENOMEM;
1990 sb->s_fs_info = sbinfo;
1991 spin_lock_init(&sbinfo->stat_lock);
1992 sbinfo->max_blocks = blocks;
1993 sbinfo->free_blocks = blocks;
1994 sbinfo->max_inodes = inodes;
1995 sbinfo->free_inodes = inodes;
1996 }
1997 sb->s_xattr = shmem_xattr_handlers;
1998#else 1980#else
1999 sb->s_flags |= MS_NOUSER; 1981 sb->s_flags |= MS_NOUSER;
2000#endif 1982#endif
2001 1983
1984 /* Round up to L1_CACHE_BYTES to resist false sharing */
1985 sbinfo = kmalloc(max((int)sizeof(struct shmem_sb_info),
1986 L1_CACHE_BYTES), GFP_KERNEL);
1987 if (!sbinfo)
1988 return -ENOMEM;
1989
1990 spin_lock_init(&sbinfo->stat_lock);
1991 sbinfo->max_blocks = blocks;
1992 sbinfo->free_blocks = blocks;
1993 sbinfo->max_inodes = inodes;
1994 sbinfo->free_inodes = inodes;
1995
1996 sb->s_fs_info = sbinfo;
2002 sb->s_maxbytes = SHMEM_MAX_BYTES; 1997 sb->s_maxbytes = SHMEM_MAX_BYTES;
2003 sb->s_blocksize = PAGE_CACHE_SIZE; 1998 sb->s_blocksize = PAGE_CACHE_SIZE;
2004 sb->s_blocksize_bits = PAGE_CACHE_SHIFT; 1999 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
2005 sb->s_magic = TMPFS_MAGIC; 2000 sb->s_magic = TMPFS_MAGIC;
2006 sb->s_op = &shmem_ops; 2001 sb->s_op = &shmem_ops;
2002 sb->s_xattr = shmem_xattr_handlers;
2003
2007 inode = shmem_get_inode(sb, S_IFDIR | mode, 0); 2004 inode = shmem_get_inode(sb, S_IFDIR | mode, 0);
2008 if (!inode) 2005 if (!inode)
2009 goto failed; 2006 goto failed;
diff --git a/mm/slab.c b/mm/slab.c
index c78d343b3c5f..93cbbbb39f42 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2851,6 +2851,7 @@ next:
2851 } 2851 }
2852 check_irq_on(); 2852 check_irq_on();
2853 up(&cache_chain_sem); 2853 up(&cache_chain_sem);
2854 drain_remote_pages();
2854 /* Setup the next iteration */ 2855 /* Setup the next iteration */
2855 schedule_delayed_work(&__get_cpu_var(reap_work), REAPTIMEOUT_CPUC + smp_processor_id()); 2856 schedule_delayed_work(&__get_cpu_var(reap_work), REAPTIMEOUT_CPUC + smp_processor_id());
2856} 2857}
diff --git a/mm/swapfile.c b/mm/swapfile.c
index da48405cd9a3..60cd24a55204 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -276,61 +276,37 @@ void swap_free(swp_entry_t entry)
276} 276}
277 277
278/* 278/*
279 * Check if we're the only user of a swap page, 279 * How many references to page are currently swapped out?
280 * when the page is locked.
281 */ 280 */
282static int exclusive_swap_page(struct page *page) 281static inline int page_swapcount(struct page *page)
283{ 282{
284 int retval = 0; 283 int count = 0;
285 struct swap_info_struct * p; 284 struct swap_info_struct *p;
286 swp_entry_t entry; 285 swp_entry_t entry;
287 286
288 entry.val = page->private; 287 entry.val = page->private;
289 p = swap_info_get(entry); 288 p = swap_info_get(entry);
290 if (p) { 289 if (p) {
291 /* Is the only swap cache user the cache itself? */ 290 /* Subtract the 1 for the swap cache itself */
292 if (p->swap_map[swp_offset(entry)] == 1) { 291 count = p->swap_map[swp_offset(entry)] - 1;
293 /* Recheck the page count with the swapcache lock held.. */
294 write_lock_irq(&swapper_space.tree_lock);
295 if (page_count(page) == 2)
296 retval = 1;
297 write_unlock_irq(&swapper_space.tree_lock);
298 }
299 swap_info_put(p); 292 swap_info_put(p);
300 } 293 }
301 return retval; 294 return count;
302} 295}
303 296
304/* 297/*
305 * We can use this swap cache entry directly 298 * We can use this swap cache entry directly
306 * if there are no other references to it. 299 * if there are no other references to it.
307 *
308 * Here "exclusive_swap_page()" does the real
309 * work, but we opportunistically check whether
310 * we need to get all the locks first..
311 */ 300 */
312int can_share_swap_page(struct page *page) 301int can_share_swap_page(struct page *page)
313{ 302{
314 int retval = 0; 303 int count;
315 304
316 if (!PageLocked(page)) 305 BUG_ON(!PageLocked(page));
317 BUG(); 306 count = page_mapcount(page);
318 switch (page_count(page)) { 307 if (count <= 1 && PageSwapCache(page))
319 case 3: 308 count += page_swapcount(page);
320 if (!PagePrivate(page)) 309 return count == 1;
321 break;
322 /* Fallthrough */
323 case 2:
324 if (!PageSwapCache(page))
325 break;
326 retval = exclusive_swap_page(page);
327 break;
328 case 1:
329 if (PageReserved(page))
330 break;
331 retval = 1;
332 }
333 return retval;
334} 310}
335 311
336/* 312/*
@@ -529,9 +505,10 @@ static int unuse_mm(struct mm_struct *mm,
529 505
530 if (!down_read_trylock(&mm->mmap_sem)) { 506 if (!down_read_trylock(&mm->mmap_sem)) {
531 /* 507 /*
532 * Our reference to the page stops try_to_unmap_one from 508 * Activate page so shrink_cache is unlikely to unmap its
533 * unmapping its ptes, so swapoff can make progress. 509 * ptes while lock is dropped, so swapoff can make progress.
534 */ 510 */
511 activate_page(page);
535 unlock_page(page); 512 unlock_page(page);
536 down_read(&mm->mmap_sem); 513 down_read(&mm->mmap_sem);
537 lock_page(page); 514 lock_page(page);
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 269eded9b459..4b8e62a19370 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -74,6 +74,9 @@ struct scan_control {
74 74
75 int may_writepage; 75 int may_writepage;
76 76
77 /* Can pages be swapped as part of reclaim? */
78 int may_swap;
79
77 /* This context's SWAP_CLUSTER_MAX. If freeing memory for 80 /* This context's SWAP_CLUSTER_MAX. If freeing memory for
78 * suspend, we effectively ignore SWAP_CLUSTER_MAX. 81 * suspend, we effectively ignore SWAP_CLUSTER_MAX.
79 * In this context, it doesn't matter that we scan the 82 * In this context, it doesn't matter that we scan the
@@ -180,17 +183,20 @@ EXPORT_SYMBOL(remove_shrinker);
180 * `lru_pages' represents the number of on-LRU pages in all the zones which 183 * `lru_pages' represents the number of on-LRU pages in all the zones which
181 * are eligible for the caller's allocation attempt. It is used for balancing 184 * are eligible for the caller's allocation attempt. It is used for balancing
182 * slab reclaim versus page reclaim. 185 * slab reclaim versus page reclaim.
186 *
187 * Returns the number of slab objects which we shrunk.
183 */ 188 */
184static int shrink_slab(unsigned long scanned, unsigned int gfp_mask, 189static int shrink_slab(unsigned long scanned, unsigned int gfp_mask,
185 unsigned long lru_pages) 190 unsigned long lru_pages)
186{ 191{
187 struct shrinker *shrinker; 192 struct shrinker *shrinker;
193 int ret = 0;
188 194
189 if (scanned == 0) 195 if (scanned == 0)
190 scanned = SWAP_CLUSTER_MAX; 196 scanned = SWAP_CLUSTER_MAX;
191 197
192 if (!down_read_trylock(&shrinker_rwsem)) 198 if (!down_read_trylock(&shrinker_rwsem))
193 return 0; 199 return 1; /* Assume we'll be able to shrink next time */
194 200
195 list_for_each_entry(shrinker, &shrinker_list, list) { 201 list_for_each_entry(shrinker, &shrinker_list, list) {
196 unsigned long long delta; 202 unsigned long long delta;
@@ -209,10 +215,14 @@ static int shrink_slab(unsigned long scanned, unsigned int gfp_mask,
209 while (total_scan >= SHRINK_BATCH) { 215 while (total_scan >= SHRINK_BATCH) {
210 long this_scan = SHRINK_BATCH; 216 long this_scan = SHRINK_BATCH;
211 int shrink_ret; 217 int shrink_ret;
218 int nr_before;
212 219
220 nr_before = (*shrinker->shrinker)(0, gfp_mask);
213 shrink_ret = (*shrinker->shrinker)(this_scan, gfp_mask); 221 shrink_ret = (*shrinker->shrinker)(this_scan, gfp_mask);
214 if (shrink_ret == -1) 222 if (shrink_ret == -1)
215 break; 223 break;
224 if (shrink_ret < nr_before)
225 ret += nr_before - shrink_ret;
216 mod_page_state(slabs_scanned, this_scan); 226 mod_page_state(slabs_scanned, this_scan);
217 total_scan -= this_scan; 227 total_scan -= this_scan;
218 228
@@ -222,7 +232,7 @@ static int shrink_slab(unsigned long scanned, unsigned int gfp_mask,
222 shrinker->nr += total_scan; 232 shrinker->nr += total_scan;
223 } 233 }
224 up_read(&shrinker_rwsem); 234 up_read(&shrinker_rwsem);
225 return 0; 235 return ret;
226} 236}
227 237
228/* Called without lock on whether page is mapped, so answer is unstable */ 238/* Called without lock on whether page is mapped, so answer is unstable */
@@ -407,7 +417,7 @@ static int shrink_list(struct list_head *page_list, struct scan_control *sc)
407 * Anonymous process memory has backing store? 417 * Anonymous process memory has backing store?
408 * Try to allocate it some swap space here. 418 * Try to allocate it some swap space here.
409 */ 419 */
410 if (PageAnon(page) && !PageSwapCache(page)) { 420 if (PageAnon(page) && !PageSwapCache(page) && sc->may_swap) {
411 if (!add_to_swap(page)) 421 if (!add_to_swap(page))
412 goto activate_locked; 422 goto activate_locked;
413 } 423 }
@@ -890,7 +900,9 @@ shrink_caches(struct zone **zones, struct scan_control *sc)
890 if (zone->all_unreclaimable && sc->priority != DEF_PRIORITY) 900 if (zone->all_unreclaimable && sc->priority != DEF_PRIORITY)
891 continue; /* Let kswapd poll it */ 901 continue; /* Let kswapd poll it */
892 902
903 atomic_inc(&zone->reclaim_in_progress);
893 shrink_zone(zone, sc); 904 shrink_zone(zone, sc);
905 atomic_dec(&zone->reclaim_in_progress);
894 } 906 }
895} 907}
896 908
@@ -907,8 +919,7 @@ shrink_caches(struct zone **zones, struct scan_control *sc)
907 * holds filesystem locks which prevent writeout this might not work, and the 919 * holds filesystem locks which prevent writeout this might not work, and the
908 * allocation attempt will fail. 920 * allocation attempt will fail.
909 */ 921 */
910int try_to_free_pages(struct zone **zones, 922int try_to_free_pages(struct zone **zones, unsigned int gfp_mask)
911 unsigned int gfp_mask, unsigned int order)
912{ 923{
913 int priority; 924 int priority;
914 int ret = 0; 925 int ret = 0;
@@ -920,6 +931,7 @@ int try_to_free_pages(struct zone **zones,
920 931
921 sc.gfp_mask = gfp_mask; 932 sc.gfp_mask = gfp_mask;
922 sc.may_writepage = 0; 933 sc.may_writepage = 0;
934 sc.may_swap = 1;
923 935
924 inc_page_state(allocstall); 936 inc_page_state(allocstall);
925 937
@@ -1020,6 +1032,7 @@ loop_again:
1020 total_reclaimed = 0; 1032 total_reclaimed = 0;
1021 sc.gfp_mask = GFP_KERNEL; 1033 sc.gfp_mask = GFP_KERNEL;
1022 sc.may_writepage = 0; 1034 sc.may_writepage = 0;
1035 sc.may_swap = 1;
1023 sc.nr_mapped = read_page_state(nr_mapped); 1036 sc.nr_mapped = read_page_state(nr_mapped);
1024 1037
1025 inc_page_state(pageoutrun); 1038 inc_page_state(pageoutrun);
@@ -1079,6 +1092,7 @@ scan:
1079 */ 1092 */
1080 for (i = 0; i <= end_zone; i++) { 1093 for (i = 0; i <= end_zone; i++) {
1081 struct zone *zone = pgdat->node_zones + i; 1094 struct zone *zone = pgdat->node_zones + i;
1095 int nr_slab;
1082 1096
1083 if (zone->present_pages == 0) 1097 if (zone->present_pages == 0)
1084 continue; 1098 continue;
@@ -1098,16 +1112,19 @@ scan:
1098 sc.nr_reclaimed = 0; 1112 sc.nr_reclaimed = 0;
1099 sc.priority = priority; 1113 sc.priority = priority;
1100 sc.swap_cluster_max = nr_pages? nr_pages : SWAP_CLUSTER_MAX; 1114 sc.swap_cluster_max = nr_pages? nr_pages : SWAP_CLUSTER_MAX;
1115 atomic_inc(&zone->reclaim_in_progress);
1101 shrink_zone(zone, &sc); 1116 shrink_zone(zone, &sc);
1117 atomic_dec(&zone->reclaim_in_progress);
1102 reclaim_state->reclaimed_slab = 0; 1118 reclaim_state->reclaimed_slab = 0;
1103 shrink_slab(sc.nr_scanned, GFP_KERNEL, lru_pages); 1119 nr_slab = shrink_slab(sc.nr_scanned, GFP_KERNEL,
1120 lru_pages);
1104 sc.nr_reclaimed += reclaim_state->reclaimed_slab; 1121 sc.nr_reclaimed += reclaim_state->reclaimed_slab;
1105 total_reclaimed += sc.nr_reclaimed; 1122 total_reclaimed += sc.nr_reclaimed;
1106 total_scanned += sc.nr_scanned; 1123 total_scanned += sc.nr_scanned;
1107 if (zone->all_unreclaimable) 1124 if (zone->all_unreclaimable)
1108 continue; 1125 continue;
1109 if (zone->pages_scanned >= (zone->nr_active + 1126 if (nr_slab == 0 && zone->pages_scanned >=
1110 zone->nr_inactive) * 4) 1127 (zone->nr_active + zone->nr_inactive) * 4)
1111 zone->all_unreclaimable = 1; 1128 zone->all_unreclaimable = 1;
1112 /* 1129 /*
1113 * If we've done a decent amount of scanning and 1130 * If we've done a decent amount of scanning and
@@ -1309,3 +1326,73 @@ static int __init kswapd_init(void)
1309} 1326}
1310 1327
1311module_init(kswapd_init) 1328module_init(kswapd_init)
1329
1330
1331/*
1332 * Try to free up some pages from this zone through reclaim.
1333 */
1334int zone_reclaim(struct zone *zone, unsigned int gfp_mask, unsigned int order)
1335{
1336 struct scan_control sc;
1337 int nr_pages = 1 << order;
1338 int total_reclaimed = 0;
1339
1340 /* The reclaim may sleep, so don't do it if sleep isn't allowed */
1341 if (!(gfp_mask & __GFP_WAIT))
1342 return 0;
1343 if (zone->all_unreclaimable)
1344 return 0;
1345
1346 sc.gfp_mask = gfp_mask;
1347 sc.may_writepage = 0;
1348 sc.may_swap = 0;
1349 sc.nr_mapped = read_page_state(nr_mapped);
1350 sc.nr_scanned = 0;
1351 sc.nr_reclaimed = 0;
1352 /* scan at the highest priority */
1353 sc.priority = 0;
1354
1355 if (nr_pages > SWAP_CLUSTER_MAX)
1356 sc.swap_cluster_max = nr_pages;
1357 else
1358 sc.swap_cluster_max = SWAP_CLUSTER_MAX;
1359
1360 /* Don't reclaim the zone if there are other reclaimers active */
1361 if (!atomic_inc_and_test(&zone->reclaim_in_progress))
1362 goto out;
1363
1364 shrink_zone(zone, &sc);
1365 total_reclaimed = sc.nr_reclaimed;
1366
1367 out:
1368 atomic_dec(&zone->reclaim_in_progress);
1369 return total_reclaimed;
1370}
1371
1372asmlinkage long sys_set_zone_reclaim(unsigned int node, unsigned int zone,
1373 unsigned int state)
1374{
1375 struct zone *z;
1376 int i;
1377
1378 if (node >= MAX_NUMNODES || !node_online(node))
1379 return -EINVAL;
1380
1381 /* This will break if we ever add more zones */
1382 if (!(zone & (1<<ZONE_DMA|1<<ZONE_NORMAL|1<<ZONE_HIGHMEM)))
1383 return -EINVAL;
1384
1385 for (i = 0; i < MAX_NR_ZONES; i++) {
1386 if (!(zone & 1<<i))
1387 continue;
1388
1389 z = &NODE_DATA(node)->node_zones[i];
1390
1391 if (state)
1392 z->reclaim_pages = 1;
1393 else
1394 z->reclaim_pages = 0;
1395 }
1396
1397 return 0;
1398}
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index 05107e0dc145..567b03b1c349 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -2,7 +2,7 @@
2# IP configuration 2# IP configuration
3# 3#
4choice 4choice
5 prompt "Choose IP: FIB lookup"" 5 prompt "Choose IP: FIB lookup"
6 depends on INET 6 depends on INET
7 default IP_FIB_HASH 7 default IP_FIB_HASH
8 8
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index db845cbd5841..87302a49067b 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -1945,6 +1945,7 @@ static int selinux_sb_copy_data(struct file_system_type *type, void *orig, void
1945 } while (*in_end++); 1945 } while (*in_end++);
1946 1946
1947 copy_page(in_save, nosec_save); 1947 copy_page(in_save, nosec_save);
1948 free_page((unsigned long)nosec_save);
1948out: 1949out:
1949 return rc; 1950 return rc;
1950} 1951}
diff --git a/sound/Kconfig b/sound/Kconfig
index 047d59ea0573..ee794ae06040 100644
--- a/sound/Kconfig
+++ b/sound/Kconfig
@@ -42,6 +42,11 @@ menu "Advanced Linux Sound Architecture"
42config SND 42config SND
43 tristate "Advanced Linux Sound Architecture" 43 tristate "Advanced Linux Sound Architecture"
44 depends on SOUND 44 depends on SOUND
45 help
46 Say 'Y' or 'M' to enable ALSA (Advanced Linux Sound Architecture),
47 the new base sound system.
48
49 For more information, see <http://www.alsa-project.org/>
45 50
46source "sound/core/Kconfig" 51source "sound/core/Kconfig"
47 52
diff --git a/sound/arm/Kconfig b/sound/arm/Kconfig
index cdacf4d3a387..34c1740aa6e9 100644
--- a/sound/arm/Kconfig
+++ b/sound/arm/Kconfig
@@ -14,5 +14,11 @@ config SND_SA11XX_UDA1341
14 To compile this driver as a module, choose M here: the module 14 To compile this driver as a module, choose M here: the module
15 will be called snd-sa11xx-uda1341. 15 will be called snd-sa11xx-uda1341.
16 16
17config SND_ARMAACI
18 tristate "ARM PrimeCell PL041 AC Link support"
19 depends on SND && ARM_AMBA
20 select SND_PCM
21 select SND_AC97_CODEC
22
17endmenu 23endmenu
18 24
diff --git a/sound/arm/Makefile b/sound/arm/Makefile
index d7e7dc0c3cdf..f74ec28e1068 100644
--- a/sound/arm/Makefile
+++ b/sound/arm/Makefile
@@ -6,3 +6,6 @@ snd-sa11xx-uda1341-objs := sa11xx-uda1341.o
6 6
7# Toplevel Module Dependency 7# Toplevel Module Dependency
8obj-$(CONFIG_SND_SA11XX_UDA1341) += snd-sa11xx-uda1341.o 8obj-$(CONFIG_SND_SA11XX_UDA1341) += snd-sa11xx-uda1341.o
9
10obj-$(CONFIG_SND_ARMAACI) += snd-aaci.o
11snd-aaci-objs := aaci.o devdma.o
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c
new file mode 100644
index 000000000000..08cc3ddca96f
--- /dev/null
+++ b/sound/arm/aaci.c
@@ -0,0 +1,968 @@
1/*
2 * linux/sound/arm/aaci.c - ARM PrimeCell AACI PL041 driver
3 *
4 * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Documentation: ARM DDI 0173B
11 */
12#include <linux/module.h>
13#include <linux/delay.h>
14#include <linux/init.h>
15#include <linux/ioport.h>
16#include <linux/device.h>
17#include <linux/spinlock.h>
18#include <linux/interrupt.h>
19#include <linux/err.h>
20
21#include <asm/io.h>
22#include <asm/irq.h>
23#include <asm/hardware/amba.h>
24
25#include <sound/driver.h>
26#include <sound/core.h>
27#include <sound/initval.h>
28#include <sound/ac97_codec.h>
29#include <sound/pcm.h>
30#include <sound/pcm_params.h>
31
32#include "aaci.h"
33#include "devdma.h"
34
35#define DRIVER_NAME "aaci-pl041"
36
37/*
38 * PM support is not complete. Turn it off.
39 */
40#undef CONFIG_PM
41
42static void aaci_ac97_select_codec(struct aaci *aaci, ac97_t *ac97)
43{
44 u32 v, maincr = aaci->maincr | MAINCR_SCRA(ac97->num);
45
46 /*
47 * Ensure that the slot 1/2 RX registers are empty.
48 */
49 v = readl(aaci->base + AACI_SLFR);
50 if (v & SLFR_2RXV)
51 readl(aaci->base + AACI_SL2RX);
52 if (v & SLFR_1RXV)
53 readl(aaci->base + AACI_SL1RX);
54
55 writel(maincr, aaci->base + AACI_MAINCR);
56}
57
58/*
59 * P29:
60 * The recommended use of programming the external codec through slot 1
61 * and slot 2 data is to use the channels during setup routines and the
62 * slot register at any other time. The data written into slot 1, slot 2
63 * and slot 12 registers is transmitted only when their corresponding
64 * SI1TxEn, SI2TxEn and SI12TxEn bits are set in the AACI_MAINCR
65 * register.
66 */
67static void aaci_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val)
68{
69 struct aaci *aaci = ac97->private_data;
70 u32 v;
71
72 if (ac97->num >= 4)
73 return;
74
75 down(&aaci->ac97_sem);
76
77 aaci_ac97_select_codec(aaci, ac97);
78
79 /*
80 * P54: You must ensure that AACI_SL2TX is always written
81 * to, if required, before data is written to AACI_SL1TX.
82 */
83 writel(val << 4, aaci->base + AACI_SL2TX);
84 writel(reg << 12, aaci->base + AACI_SL1TX);
85
86 /*
87 * Wait for the transmission of both slots to complete.
88 */
89 do {
90 v = readl(aaci->base + AACI_SLFR);
91 } while (v & (SLFR_1TXB|SLFR_2TXB));
92
93 up(&aaci->ac97_sem);
94}
95
96/*
97 * Read an AC'97 register.
98 */
99static unsigned short aaci_ac97_read(ac97_t *ac97, unsigned short reg)
100{
101 struct aaci *aaci = ac97->private_data;
102 u32 v;
103
104 if (ac97->num >= 4)
105 return ~0;
106
107 down(&aaci->ac97_sem);
108
109 aaci_ac97_select_codec(aaci, ac97);
110
111 /*
112 * Write the register address to slot 1.
113 */
114 writel((reg << 12) | (1 << 19), aaci->base + AACI_SL1TX);
115
116 /*
117 * Wait for the transmission to complete.
118 */
119 do {
120 v = readl(aaci->base + AACI_SLFR);
121 } while (v & SLFR_1TXB);
122
123 /*
124 * Give the AC'97 codec more than enough time
125 * to respond. (42us = ~2 frames at 48kHz.)
126 */
127 udelay(42);
128
129 /*
130 * Wait for slot 2 to indicate data.
131 */
132 do {
133 cond_resched();
134 v = readl(aaci->base + AACI_SLFR) & (SLFR_1RXV|SLFR_2RXV);
135 } while (v != (SLFR_1RXV|SLFR_2RXV));
136
137 v = readl(aaci->base + AACI_SL1RX) >> 12;
138 if (v == reg) {
139 v = readl(aaci->base + AACI_SL2RX) >> 4;
140 } else {
141 dev_err(&aaci->dev->dev,
142 "wrong ac97 register read back (%x != %x)\n",
143 v, reg);
144 v = ~0;
145 }
146
147 up(&aaci->ac97_sem);
148 return v;
149}
150
151static inline void aaci_chan_wait_ready(struct aaci_runtime *aacirun)
152{
153 u32 val;
154 int timeout = 5000;
155
156 do {
157 val = readl(aacirun->base + AACI_SR);
158 } while (val & (SR_TXB|SR_RXB) && timeout--);
159}
160
161
162
163/*
164 * Interrupt support.
165 */
166static void aaci_fifo_irq(struct aaci *aaci, u32 mask)
167{
168 if (mask & ISR_URINTR) {
169 writel(ICLR_TXUEC1, aaci->base + AACI_INTCLR);
170 }
171
172 if (mask & ISR_TXINTR) {
173 struct aaci_runtime *aacirun = &aaci->playback;
174 void *ptr;
175
176 if (!aacirun->substream || !aacirun->start) {
177 dev_warn(&aaci->dev->dev, "TX interrupt???");
178 writel(0, aacirun->base + AACI_IE);
179 return;
180 }
181
182 ptr = aacirun->ptr;
183 do {
184 unsigned int len = aacirun->fifosz;
185 u32 val;
186
187 if (aacirun->bytes <= 0) {
188 aacirun->bytes += aacirun->period;
189 aacirun->ptr = ptr;
190 spin_unlock(&aaci->lock);
191 snd_pcm_period_elapsed(aacirun->substream);
192 spin_lock(&aaci->lock);
193 }
194 if (!(aacirun->cr & TXCR_TXEN))
195 break;
196
197 val = readl(aacirun->base + AACI_SR);
198 if (!(val & SR_TXHE))
199 break;
200 if (!(val & SR_TXFE))
201 len >>= 1;
202
203 aacirun->bytes -= len;
204
205 /* writing 16 bytes at a time */
206 for ( ; len > 0; len -= 16) {
207 asm(
208 "ldmia %0!, {r0, r1, r2, r3}\n\t"
209 "stmia %1, {r0, r1, r2, r3}"
210 : "+r" (ptr)
211 : "r" (aacirun->fifo)
212 : "r0", "r1", "r2", "r3", "cc");
213
214 if (ptr >= aacirun->end)
215 ptr = aacirun->start;
216 }
217 } while (1);
218
219 aacirun->ptr = ptr;
220 }
221}
222
223static irqreturn_t aaci_irq(int irq, void *devid, struct pt_regs *regs)
224{
225 struct aaci *aaci = devid;
226 u32 mask;
227 int i;
228
229 spin_lock(&aaci->lock);
230 mask = readl(aaci->base + AACI_ALLINTS);
231 if (mask) {
232 u32 m = mask;
233 for (i = 0; i < 4; i++, m >>= 7) {
234 if (m & 0x7f) {
235 aaci_fifo_irq(aaci, m);
236 }
237 }
238 }
239 spin_unlock(&aaci->lock);
240
241 return mask ? IRQ_HANDLED : IRQ_NONE;
242}
243
244
245
246/*
247 * ALSA support.
248 */
249
250struct aaci_stream {
251 unsigned char codec_idx;
252 unsigned char rate_idx;
253};
254
255static struct aaci_stream aaci_streams[] = {
256 [ACSTREAM_FRONT] = {
257 .codec_idx = 0,
258 .rate_idx = AC97_RATES_FRONT_DAC,
259 },
260 [ACSTREAM_SURROUND] = {
261 .codec_idx = 0,
262 .rate_idx = AC97_RATES_SURR_DAC,
263 },
264 [ACSTREAM_LFE] = {
265 .codec_idx = 0,
266 .rate_idx = AC97_RATES_LFE_DAC,
267 },
268};
269
270static inline unsigned int aaci_rate_mask(struct aaci *aaci, int streamid)
271{
272 struct aaci_stream *s = aaci_streams + streamid;
273 return aaci->ac97_bus->codec[s->codec_idx]->rates[s->rate_idx];
274}
275
276static unsigned int rate_list[] = {
277 5512, 8000, 11025, 16000, 22050, 32000, 44100,
278 48000, 64000, 88200, 96000, 176400, 192000
279};
280
281/*
282 * Double-rate rule: we can support double rate iff channels == 2
283 * (unimplemented)
284 */
285static int
286aaci_rule_rate_by_channels(snd_pcm_hw_params_t *p, snd_pcm_hw_rule_t *rule)
287{
288 struct aaci *aaci = rule->private;
289 unsigned int rate_mask = SNDRV_PCM_RATE_8000_48000|SNDRV_PCM_RATE_5512;
290 snd_interval_t *c = hw_param_interval(p, SNDRV_PCM_HW_PARAM_CHANNELS);
291
292 switch (c->max) {
293 case 6:
294 rate_mask &= aaci_rate_mask(aaci, ACSTREAM_LFE);
295 case 4:
296 rate_mask &= aaci_rate_mask(aaci, ACSTREAM_SURROUND);
297 case 2:
298 rate_mask &= aaci_rate_mask(aaci, ACSTREAM_FRONT);
299 }
300
301 return snd_interval_list(hw_param_interval(p, rule->var),
302 ARRAY_SIZE(rate_list), rate_list,
303 rate_mask);
304}
305
306static snd_pcm_hardware_t aaci_hw_info = {
307 .info = SNDRV_PCM_INFO_MMAP |
308 SNDRV_PCM_INFO_MMAP_VALID |
309 SNDRV_PCM_INFO_INTERLEAVED |
310 SNDRV_PCM_INFO_BLOCK_TRANSFER |
311 SNDRV_PCM_INFO_RESUME,
312
313 /*
314 * ALSA doesn't support 18-bit or 20-bit packed into 32-bit
315 * words. It also doesn't support 12-bit at all.
316 */
317 .formats = SNDRV_PCM_FMTBIT_S16_LE,
318
319 /* should this be continuous or knot? */
320 .rates = SNDRV_PCM_RATE_CONTINUOUS,
321 .rate_max = 48000,
322 .rate_min = 4000,
323 .channels_min = 2,
324 .channels_max = 6,
325 .buffer_bytes_max = 64 * 1024,
326 .period_bytes_min = 256,
327 .period_bytes_max = PAGE_SIZE,
328 .periods_min = 4,
329 .periods_max = PAGE_SIZE / 16,
330};
331
332static int aaci_pcm_open(struct aaci *aaci, snd_pcm_substream_t *substream,
333 struct aaci_runtime *aacirun)
334{
335 snd_pcm_runtime_t *runtime = substream->runtime;
336 int ret;
337
338 aacirun->substream = substream;
339 runtime->private_data = aacirun;
340 runtime->hw = aaci_hw_info;
341
342 /*
343 * FIXME: ALSA specifies fifo_size in bytes. If we're in normal
344 * mode, each 32-bit word contains one sample. If we're in
345 * compact mode, each 32-bit word contains two samples, effectively
346 * halving the FIFO size. However, we don't know for sure which
347 * we'll be using at this point. We set this to the lower limit.
348 */
349 runtime->hw.fifo_size = aaci->fifosize * 2;
350
351 /*
352 * Add rule describing hardware rate dependency
353 * on the number of channels.
354 */
355 ret = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
356 aaci_rule_rate_by_channels, aaci,
357 SNDRV_PCM_HW_PARAM_CHANNELS,
358 SNDRV_PCM_HW_PARAM_RATE, -1);
359 if (ret)
360 goto out;
361
362 ret = request_irq(aaci->dev->irq[0], aaci_irq, SA_SHIRQ|SA_INTERRUPT,
363 DRIVER_NAME, aaci);
364 if (ret)
365 goto out;
366
367 return 0;
368
369 out:
370 return ret;
371}
372
373
374/*
375 * Common ALSA stuff
376 */
377static int aaci_pcm_close(snd_pcm_substream_t *substream)
378{
379 struct aaci *aaci = substream->private_data;
380 struct aaci_runtime *aacirun = substream->runtime->private_data;
381
382 WARN_ON(aacirun->cr & TXCR_TXEN);
383
384 aacirun->substream = NULL;
385 free_irq(aaci->dev->irq[0], aaci);
386
387 return 0;
388}
389
390static int aaci_pcm_hw_free(snd_pcm_substream_t *substream)
391{
392 struct aaci_runtime *aacirun = substream->runtime->private_data;
393
394 /*
395 * This must not be called with the device enabled.
396 */
397 WARN_ON(aacirun->cr & TXCR_TXEN);
398
399 if (aacirun->pcm_open)
400 snd_ac97_pcm_close(aacirun->pcm);
401 aacirun->pcm_open = 0;
402
403 /*
404 * Clear out the DMA and any allocated buffers.
405 */
406 devdma_hw_free(NULL, substream);
407
408 return 0;
409}
410
411static int aaci_pcm_hw_params(snd_pcm_substream_t *substream,
412 struct aaci_runtime *aacirun,
413 snd_pcm_hw_params_t *params)
414{
415 int err;
416
417 aaci_pcm_hw_free(substream);
418
419 err = devdma_hw_alloc(NULL, substream,
420 params_buffer_bytes(params));
421 if (err < 0)
422 goto out;
423
424 err = snd_ac97_pcm_open(aacirun->pcm, params_rate(params),
425 params_channels(params),
426 aacirun->pcm->r[0].slots);
427 if (err)
428 goto out;
429
430 aacirun->pcm_open = 1;
431
432 out:
433 return err;
434}
435
436static int aaci_pcm_prepare(snd_pcm_substream_t *substream)
437{
438 snd_pcm_runtime_t *runtime = substream->runtime;
439 struct aaci_runtime *aacirun = runtime->private_data;
440
441 aacirun->start = (void *)runtime->dma_area;
442 aacirun->end = aacirun->start + runtime->dma_bytes;
443 aacirun->ptr = aacirun->start;
444 aacirun->period =
445 aacirun->bytes = frames_to_bytes(runtime, runtime->period_size);
446
447 return 0;
448}
449
450static snd_pcm_uframes_t aaci_pcm_pointer(snd_pcm_substream_t *substream)
451{
452 snd_pcm_runtime_t *runtime = substream->runtime;
453 struct aaci_runtime *aacirun = runtime->private_data;
454 ssize_t bytes = aacirun->ptr - aacirun->start;
455
456 return bytes_to_frames(runtime, bytes);
457}
458
459static int aaci_pcm_mmap(snd_pcm_substream_t *substream, struct vm_area_struct *vma)
460{
461 return devdma_mmap(NULL, substream, vma);
462}
463
464
465/*
466 * Playback specific ALSA stuff
467 */
468static const u32 channels_to_txmask[] = {
469 [2] = TXCR_TX3 | TXCR_TX4,
470 [4] = TXCR_TX3 | TXCR_TX4 | TXCR_TX7 | TXCR_TX8,
471 [6] = TXCR_TX3 | TXCR_TX4 | TXCR_TX7 | TXCR_TX8 | TXCR_TX6 | TXCR_TX9,
472};
473
474/*
475 * We can support two and four channel audio. Unfortunately
476 * six channel audio requires a non-standard channel ordering:
477 * 2 -> FL(3), FR(4)
478 * 4 -> FL(3), FR(4), SL(7), SR(8)
479 * 6 -> FL(3), FR(4), SL(7), SR(8), C(6), LFE(9) (required)
480 * FL(3), FR(4), C(6), SL(7), SR(8), LFE(9) (actual)
481 * This requires an ALSA configuration file to correct.
482 */
483static unsigned int channel_list[] = { 2, 4, 6 };
484
485static int
486aaci_rule_channels(snd_pcm_hw_params_t *p, snd_pcm_hw_rule_t *rule)
487{
488 struct aaci *aaci = rule->private;
489 unsigned int chan_mask = 1 << 0, slots;
490
491 /*
492 * pcms[0] is the our 5.1 PCM instance.
493 */
494 slots = aaci->ac97_bus->pcms[0].r[0].slots;
495 if (slots & (1 << AC97_SLOT_PCM_SLEFT)) {
496 chan_mask |= 1 << 1;
497 if (slots & (1 << AC97_SLOT_LFE))
498 chan_mask |= 1 << 2;
499 }
500
501 return snd_interval_list(hw_param_interval(p, rule->var),
502 ARRAY_SIZE(channel_list), channel_list,
503 chan_mask);
504}
505
506static int aaci_pcm_playback_open(snd_pcm_substream_t *substream)
507{
508 struct aaci *aaci = substream->private_data;
509 int ret;
510
511 /*
512 * Add rule describing channel dependency.
513 */
514 ret = snd_pcm_hw_rule_add(substream->runtime, 0,
515 SNDRV_PCM_HW_PARAM_CHANNELS,
516 aaci_rule_channels, aaci,
517 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
518 if (ret)
519 return ret;
520
521 return aaci_pcm_open(aaci, substream, &aaci->playback);
522}
523
524static int aaci_pcm_playback_hw_params(snd_pcm_substream_t *substream,
525 snd_pcm_hw_params_t *params)
526{
527 struct aaci *aaci = substream->private_data;
528 struct aaci_runtime *aacirun = substream->runtime->private_data;
529 unsigned int channels = params_channels(params);
530 int ret;
531
532 WARN_ON(channels >= ARRAY_SIZE(channels_to_txmask) ||
533 !channels_to_txmask[channels]);
534
535 ret = aaci_pcm_hw_params(substream, aacirun, params);
536
537 /*
538 * Enable FIFO, compact mode, 16 bits per sample.
539 * FIXME: double rate slots?
540 */
541 if (ret >= 0) {
542 aacirun->cr = TXCR_FEN | TXCR_COMPACT | TXCR_TSZ16;
543 aacirun->cr |= channels_to_txmask[channels];
544
545 aacirun->fifosz = aaci->fifosize * 4;
546 if (aacirun->cr & TXCR_COMPACT)
547 aacirun->fifosz >>= 1;
548 }
549 return ret;
550}
551
552static void aaci_pcm_playback_stop(struct aaci_runtime *aacirun)
553{
554 u32 ie;
555
556 ie = readl(aacirun->base + AACI_IE);
557 ie &= ~(IE_URIE|IE_TXIE);
558 writel(ie, aacirun->base + AACI_IE);
559 aacirun->cr &= ~TXCR_TXEN;
560 aaci_chan_wait_ready(aacirun);
561 writel(aacirun->cr, aacirun->base + AACI_TXCR);
562}
563
564static void aaci_pcm_playback_start(struct aaci_runtime *aacirun)
565{
566 u32 ie;
567
568 aaci_chan_wait_ready(aacirun);
569 aacirun->cr |= TXCR_TXEN;
570
571 ie = readl(aacirun->base + AACI_IE);
572 ie |= IE_URIE | IE_TXIE;
573 writel(ie, aacirun->base + AACI_IE);
574 writel(aacirun->cr, aacirun->base + AACI_TXCR);
575}
576
577static int aaci_pcm_playback_trigger(snd_pcm_substream_t *substream, int cmd)
578{
579 struct aaci *aaci = substream->private_data;
580 struct aaci_runtime *aacirun = substream->runtime->private_data;
581 unsigned long flags;
582 int ret = 0;
583
584 spin_lock_irqsave(&aaci->lock, flags);
585 switch (cmd) {
586 case SNDRV_PCM_TRIGGER_START:
587 aaci_pcm_playback_start(aacirun);
588 break;
589
590 case SNDRV_PCM_TRIGGER_RESUME:
591 aaci_pcm_playback_start(aacirun);
592 break;
593
594 case SNDRV_PCM_TRIGGER_STOP:
595 aaci_pcm_playback_stop(aacirun);
596 break;
597
598 case SNDRV_PCM_TRIGGER_SUSPEND:
599 aaci_pcm_playback_stop(aacirun);
600 break;
601
602 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
603 break;
604
605 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
606 break;
607
608 default:
609 ret = -EINVAL;
610 }
611 spin_unlock_irqrestore(&aaci->lock, flags);
612
613 return ret;
614}
615
616static snd_pcm_ops_t aaci_playback_ops = {
617 .open = aaci_pcm_playback_open,
618 .close = aaci_pcm_close,
619 .ioctl = snd_pcm_lib_ioctl,
620 .hw_params = aaci_pcm_playback_hw_params,
621 .hw_free = aaci_pcm_hw_free,
622 .prepare = aaci_pcm_prepare,
623 .trigger = aaci_pcm_playback_trigger,
624 .pointer = aaci_pcm_pointer,
625 .mmap = aaci_pcm_mmap,
626};
627
628
629
630/*
631 * Power Management.
632 */
633#ifdef CONFIG_PM
634static int aaci_do_suspend(snd_card_t *card, unsigned int state)
635{
636 struct aaci *aaci = card->private_data;
637 if (aaci->card->power_state != SNDRV_CTL_POWER_D3cold) {
638 snd_pcm_suspend_all(aaci->pcm);
639 snd_power_change_state(aaci->card, SNDRV_CTL_POWER_D3cold);
640 }
641 return 0;
642}
643
644static int aaci_do_resume(snd_card_t *card, unsigned int state)
645{
646 struct aaci *aaci = card->private_data;
647 if (aaci->card->power_state != SNDRV_CTL_POWER_D0) {
648 snd_power_change_state(aaci->card, SNDRV_CTL_POWER_D0);
649 }
650 return 0;
651}
652
653static int aaci_suspend(struct amba_device *dev, u32 state)
654{
655 snd_card_t *card = amba_get_drvdata(dev);
656 return card ? aaci_do_suspend(card) : 0;
657}
658
659static int aaci_resume(struct amba_device *dev)
660{
661 snd_card_t *card = amba_get_drvdata(dev);
662 return card ? aaci_do_resume(card) : 0;
663}
664#else
665#define aaci_do_suspend NULL
666#define aaci_do_resume NULL
667#define aaci_suspend NULL
668#define aaci_resume NULL
669#endif
670
671
672static struct ac97_pcm ac97_defs[] __devinitdata = {
673 [0] = { /* Front PCM */
674 .exclusive = 1,
675 .r = {
676 [0] = {
677 .slots = (1 << AC97_SLOT_PCM_LEFT) |
678 (1 << AC97_SLOT_PCM_RIGHT) |
679 (1 << AC97_SLOT_PCM_CENTER) |
680 (1 << AC97_SLOT_PCM_SLEFT) |
681 (1 << AC97_SLOT_PCM_SRIGHT) |
682 (1 << AC97_SLOT_LFE),
683 },
684 },
685 },
686 [1] = { /* PCM in */
687 .stream = 1,
688 .exclusive = 1,
689 .r = {
690 [0] = {
691 .slots = (1 << AC97_SLOT_PCM_LEFT) |
692 (1 << AC97_SLOT_PCM_RIGHT),
693 },
694 },
695 },
696 [2] = { /* Mic in */
697 .stream = 1,
698 .exclusive = 1,
699 .r = {
700 [0] = {
701 .slots = (1 << AC97_SLOT_MIC),
702 },
703 },
704 }
705};
706
707static ac97_bus_ops_t aaci_bus_ops = {
708 .write = aaci_ac97_write,
709 .read = aaci_ac97_read,
710};
711
712static int __devinit aaci_probe_ac97(struct aaci *aaci)
713{
714 ac97_template_t ac97_template;
715 ac97_bus_t *ac97_bus;
716 ac97_t *ac97;
717 int ret;
718
719 /*
720 * Assert AACIRESET for 2us
721 */
722 writel(0, aaci->base + AACI_RESET);
723 udelay(2);
724 writel(RESET_NRST, aaci->base + AACI_RESET);
725
726 /*
727 * Give the AC'97 codec more than enough time
728 * to wake up. (42us = ~2 frames at 48kHz.)
729 */
730 udelay(42);
731
732 ret = snd_ac97_bus(aaci->card, 0, &aaci_bus_ops, aaci, &ac97_bus);
733 if (ret)
734 goto out;
735
736 ac97_bus->clock = 48000;
737 aaci->ac97_bus = ac97_bus;
738
739 memset(&ac97_template, 0, sizeof(ac97_template_t));
740 ac97_template.private_data = aaci;
741 ac97_template.num = 0;
742 ac97_template.scaps = AC97_SCAP_SKIP_MODEM;
743
744 ret = snd_ac97_mixer(ac97_bus, &ac97_template, &ac97);
745 if (ret)
746 goto out;
747
748 /*
749 * Disable AC97 PC Beep input on audio codecs.
750 */
751 if (ac97_is_audio(ac97))
752 snd_ac97_write_cache(ac97, AC97_PC_BEEP, 0x801e);
753
754 ret = snd_ac97_pcm_assign(ac97_bus, ARRAY_SIZE(ac97_defs), ac97_defs);
755 if (ret)
756 goto out;
757
758 aaci->playback.pcm = &ac97_bus->pcms[0];
759
760 out:
761 return ret;
762}
763
764static void aaci_free_card(snd_card_t *card)
765{
766 struct aaci *aaci = card->private_data;
767 if (aaci->base)
768 iounmap(aaci->base);
769}
770
771static struct aaci * __devinit aaci_init_card(struct amba_device *dev)
772{
773 struct aaci *aaci;
774 snd_card_t *card;
775
776 card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
777 THIS_MODULE, sizeof(struct aaci));
778 if (card == NULL)
779 return ERR_PTR(-ENOMEM);
780
781 card->private_free = aaci_free_card;
782 snd_card_set_pm_callback(card, aaci_do_suspend, aaci_do_resume, NULL);
783
784 strlcpy(card->driver, DRIVER_NAME, sizeof(card->driver));
785 strlcpy(card->shortname, "ARM AC'97 Interface", sizeof(card->shortname));
786 snprintf(card->longname, sizeof(card->longname),
787 "%s at 0x%08lx, irq %d",
788 card->shortname, dev->res.start, dev->irq[0]);
789
790 aaci = card->private_data;
791 init_MUTEX(&aaci->ac97_sem);
792 spin_lock_init(&aaci->lock);
793 aaci->card = card;
794 aaci->dev = dev;
795
796 /* Set MAINCR to allow slot 1 and 2 data IO */
797 aaci->maincr = MAINCR_IE | MAINCR_SL1RXEN | MAINCR_SL1TXEN |
798 MAINCR_SL2RXEN | MAINCR_SL2TXEN;
799
800 return aaci;
801}
802
803static int __devinit aaci_init_pcm(struct aaci *aaci)
804{
805 snd_pcm_t *pcm;
806 int ret;
807
808 ret = snd_pcm_new(aaci->card, "AACI AC'97", 0, 1, 0, &pcm);
809 if (ret == 0) {
810 aaci->pcm = pcm;
811 pcm->private_data = aaci;
812 pcm->info_flags = 0;
813
814 strlcpy(pcm->name, DRIVER_NAME, sizeof(pcm->name));
815
816 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &aaci_playback_ops);
817 }
818
819 return ret;
820}
821
822static unsigned int __devinit aaci_size_fifo(struct aaci *aaci)
823{
824 void *base = aaci->base + AACI_CSCH1;
825 int i;
826
827 writel(TXCR_FEN | TXCR_TSZ16 | TXCR_TXEN, base + AACI_TXCR);
828
829 for (i = 0; !(readl(base + AACI_SR) & SR_TXFF) && i < 4096; i++)
830 writel(0, aaci->base + AACI_DR1);
831
832 writel(0, base + AACI_TXCR);
833
834 /*
835 * Re-initialise the AACI after the FIFO depth test, to
836 * ensure that the FIFOs are empty. Unfortunately, merely
837 * disabling the channel doesn't clear the FIFO.
838 */
839 writel(aaci->maincr & ~MAINCR_IE, aaci->base + AACI_MAINCR);
840 writel(aaci->maincr, aaci->base + AACI_MAINCR);
841
842 /*
843 * If we hit 4096, we failed. Go back to the specified
844 * fifo depth.
845 */
846 if (i == 4096)
847 i = 8;
848
849 return i;
850}
851
852static int __devinit aaci_probe(struct amba_device *dev, void *id)
853{
854 struct aaci *aaci;
855 int ret, i;
856
857 ret = amba_request_regions(dev, NULL);
858 if (ret)
859 return ret;
860
861 aaci = aaci_init_card(dev);
862 if (IS_ERR(aaci)) {
863 ret = PTR_ERR(aaci);
864 goto out;
865 }
866
867 aaci->base = ioremap(dev->res.start, SZ_4K);
868 if (!aaci->base) {
869 ret = -ENOMEM;
870 goto out;
871 }
872
873 /*
874 * Playback uses AACI channel 0
875 */
876 aaci->playback.base = aaci->base + AACI_CSCH1;
877 aaci->playback.fifo = aaci->base + AACI_DR1;
878
879 for (i = 0; i < 4; i++) {
880 void *base = aaci->base + i * 0x14;
881
882 writel(0, base + AACI_IE);
883 writel(0, base + AACI_TXCR);
884 writel(0, base + AACI_RXCR);
885 }
886
887 writel(0x1fff, aaci->base + AACI_INTCLR);
888 writel(aaci->maincr, aaci->base + AACI_MAINCR);
889
890 /*
891 * Size the FIFOs.
892 */
893 aaci->fifosize = aaci_size_fifo(aaci);
894
895 ret = aaci_probe_ac97(aaci);
896 if (ret)
897 goto out;
898
899 ret = aaci_init_pcm(aaci);
900 if (ret)
901 goto out;
902
903 ret = snd_card_register(aaci->card);
904 if (ret == 0) {
905 dev_info(&dev->dev, "%s, fifo %d\n", aaci->card->longname,
906 aaci->fifosize);
907 amba_set_drvdata(dev, aaci->card);
908 return ret;
909 }
910
911 out:
912 if (aaci)
913 snd_card_free(aaci->card);
914 amba_release_regions(dev);
915 return ret;
916}
917
918static int __devexit aaci_remove(struct amba_device *dev)
919{
920 snd_card_t *card = amba_get_drvdata(dev);
921
922 amba_set_drvdata(dev, NULL);
923
924 if (card) {
925 struct aaci *aaci = card->private_data;
926 writel(0, aaci->base + AACI_MAINCR);
927
928 snd_card_free(card);
929 amba_release_regions(dev);
930 }
931
932 return 0;
933}
934
935static struct amba_id aaci_ids[] = {
936 {
937 .id = 0x00041041,
938 .mask = 0x000fffff,
939 },
940 { 0, 0 },
941};
942
943static struct amba_driver aaci_driver = {
944 .drv = {
945 .name = DRIVER_NAME,
946 },
947 .probe = aaci_probe,
948 .remove = __devexit_p(aaci_remove),
949 .suspend = aaci_suspend,
950 .resume = aaci_resume,
951 .id_table = aaci_ids,
952};
953
954static int __init aaci_init(void)
955{
956 return amba_driver_register(&aaci_driver);
957}
958
959static void __exit aaci_exit(void)
960{
961 amba_driver_unregister(&aaci_driver);
962}
963
964module_init(aaci_init);
965module_exit(aaci_exit);
966
967MODULE_LICENSE("GPL");
968MODULE_DESCRIPTION("ARM PrimeCell PL041 Advanced Audio CODEC Interface driver");
diff --git a/sound/arm/aaci.h b/sound/arm/aaci.h
new file mode 100644
index 000000000000..d752e6426894
--- /dev/null
+++ b/sound/arm/aaci.h
@@ -0,0 +1,246 @@
1/*
2 * linux/sound/arm/aaci.c - ARM PrimeCell AACI PL041 driver
3 *
4 * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef AACI_H
11#define AACI_H
12
13/*
14 * Control and status register offsets
15 * P39.
16 */
17#define AACI_CSCH1 0x000
18#define AACI_CSCH2 0x014
19#define AACI_CSCH3 0x028
20#define AACI_CSCH4 0x03c
21
22#define AACI_RXCR 0x000 /* 29 bits Control Rx FIFO */
23#define AACI_TXCR 0x004 /* 17 bits Control Tx FIFO */
24#define AACI_SR 0x008 /* 12 bits Status */
25#define AACI_ISR 0x00c /* 7 bits Int Status */
26#define AACI_IE 0x010 /* 7 bits Int Enable */
27
28/*
29 * Other registers
30 */
31#define AACI_SL1RX 0x050
32#define AACI_SL1TX 0x054
33#define AACI_SL2RX 0x058
34#define AACI_SL2TX 0x05c
35#define AACI_SL12RX 0x060
36#define AACI_SL12TX 0x064
37#define AACI_SLFR 0x068 /* slot flags */
38#define AACI_SLISTAT 0x06c /* slot interrupt status */
39#define AACI_SLIEN 0x070 /* slot interrupt enable */
40#define AACI_INTCLR 0x074 /* interrupt clear */
41#define AACI_MAINCR 0x078 /* main control */
42#define AACI_RESET 0x07c /* reset control */
43#define AACI_SYNC 0x080 /* sync control */
44#define AACI_ALLINTS 0x084 /* all fifo interrupt status */
45#define AACI_MAINFR 0x088 /* main flag register */
46#define AACI_DR1 0x090 /* data read/written fifo 1 */
47#define AACI_DR2 0x0b0 /* data read/written fifo 2 */
48#define AACI_DR3 0x0d0 /* data read/written fifo 3 */
49#define AACI_DR4 0x0f0 /* data read/written fifo 4 */
50
51/*
52 * transmit fifo control register. P48
53 */
54#define TXCR_FEN (1 << 16) /* fifo enable */
55#define TXCR_COMPACT (1 << 15) /* compact mode */
56#define TXCR_TSZ16 (0 << 13) /* 16 bits */
57#define TXCR_TSZ18 (1 << 13) /* 18 bits */
58#define TXCR_TSZ20 (2 << 13) /* 20 bits */
59#define TXCR_TSZ12 (3 << 13) /* 12 bits */
60#define TXCR_TX12 (1 << 12) /* transmits slot 12 */
61#define TXCR_TX11 (1 << 11) /* transmits slot 12 */
62#define TXCR_TX10 (1 << 10) /* transmits slot 12 */
63#define TXCR_TX9 (1 << 9) /* transmits slot 12 */
64#define TXCR_TX8 (1 << 8) /* transmits slot 12 */
65#define TXCR_TX7 (1 << 7) /* transmits slot 12 */
66#define TXCR_TX6 (1 << 6) /* transmits slot 12 */
67#define TXCR_TX5 (1 << 5) /* transmits slot 12 */
68#define TXCR_TX4 (1 << 4) /* transmits slot 12 */
69#define TXCR_TX3 (1 << 3) /* transmits slot 12 */
70#define TXCR_TX2 (1 << 2) /* transmits slot 12 */
71#define TXCR_TX1 (1 << 1) /* transmits slot 12 */
72#define TXCR_TXEN (1 << 0) /* transmit enable */
73
74/*
75 * status register bits. P49
76 */
77#define SR_RXTOFE (1 << 11) /* rx timeout fifo empty */
78#define SR_TXTO (1 << 10) /* rx timeout fifo nonempty */
79#define SR_TXU (1 << 9) /* tx underrun */
80#define SR_RXO (1 << 8) /* rx overrun */
81#define SR_TXB (1 << 7) /* tx busy */
82#define SR_RXB (1 << 6) /* rx busy */
83#define SR_TXFF (1 << 5) /* tx fifo full */
84#define SR_RXFF (1 << 4) /* rx fifo full */
85#define SR_TXHE (1 << 3) /* tx fifo half empty */
86#define SR_RXHF (1 << 2) /* rx fifo half full */
87#define SR_TXFE (1 << 1) /* tx fifo empty */
88#define SR_RXFE (1 << 0) /* rx fifo empty */
89
90/*
91 * interrupt status register bits.
92 */
93#define ISR_RXTOFEINTR (1 << 6) /* rx fifo empty */
94#define ISR_URINTR (1 << 5) /* tx underflow */
95#define ISR_ORINTR (1 << 4) /* rx overflow */
96#define ISR_RXINTR (1 << 3) /* rx fifo */
97#define ISR_TXINTR (1 << 2) /* tx fifo intr */
98#define ISR_RXTOINTR (1 << 1) /* tx timeout */
99#define ISR_TXCINTR (1 << 0) /* tx complete */
100
101/*
102 * interrupt enable register bits.
103 */
104#define IE_RXTOIE (1 << 6)
105#define IE_URIE (1 << 5)
106#define IE_ORIE (1 << 4)
107#define IE_RXIE (1 << 3)
108#define IE_TXIE (1 << 2)
109#define IE_RXTIE (1 << 1)
110#define IE_TXCIE (1 << 0)
111
112/*
113 * interrupt status. P51
114 */
115#define ISR_RXTOFE (1 << 6) /* rx timeout fifo empty */
116#define ISR_UR (1 << 5) /* tx fifo underrun */
117#define ISR_OR (1 << 4) /* rx fifo overrun */
118#define ISR_RX (1 << 3) /* rx interrupt status */
119#define ISR_TX (1 << 2) /* tx interrupt status */
120#define ISR_RXTO (1 << 1) /* rx timeout */
121#define ISR_TXC (1 << 0) /* tx complete */
122
123/*
124 * interrupt enable. P52
125 */
126#define IE_RXTOFE (1 << 6) /* rx timeout fifo empty */
127#define IE_UR (1 << 5) /* tx fifo underrun */
128#define IE_OR (1 << 4) /* rx fifo overrun */
129#define IE_RX (1 << 3) /* rx interrupt status */
130#define IE_TX (1 << 2) /* tx interrupt status */
131#define IE_RXTO (1 << 1) /* rx timeout */
132#define IE_TXC (1 << 0) /* tx complete */
133
134/*
135 * slot flag register bits. P56
136 */
137#define SLFR_RWIS (1 << 13) /* raw wake-up interrupt status */
138#define SLFR_RGPIOINTR (1 << 12) /* raw gpio interrupt */
139#define SLFR_12TXE (1 << 11) /* slot 12 tx empty */
140#define SLFR_12RXV (1 << 10) /* slot 12 rx valid */
141#define SLFR_2TXE (1 << 9) /* slot 2 tx empty */
142#define SLFR_2RXV (1 << 8) /* slot 2 rx valid */
143#define SLFR_1TXE (1 << 7) /* slot 1 tx empty */
144#define SLFR_1RXV (1 << 6) /* slot 1 rx valid */
145#define SLFR_12TXB (1 << 5) /* slot 12 tx busy */
146#define SLFR_12RXB (1 << 4) /* slot 12 rx busy */
147#define SLFR_2TXB (1 << 3) /* slot 2 tx busy */
148#define SLFR_2RXB (1 << 2) /* slot 2 rx busy */
149#define SLFR_1TXB (1 << 1) /* slot 1 tx busy */
150#define SLFR_1RXB (1 << 0) /* slot 1 rx busy */
151
152/*
153 * Interrupt clear register.
154 */
155#define ICLR_RXTOFEC4 (1 << 12)
156#define ICLR_RXTOFEC3 (1 << 11)
157#define ICLR_RXTOFEC2 (1 << 10)
158#define ICLR_RXTOFEC1 (1 << 9)
159#define ICLR_TXUEC4 (1 << 8)
160#define ICLR_TXUEC3 (1 << 7)
161#define ICLR_TXUEC2 (1 << 6)
162#define ICLR_TXUEC1 (1 << 5)
163#define ICLR_RXOEC4 (1 << 4)
164#define ICLR_RXOEC3 (1 << 3)
165#define ICLR_RXOEC2 (1 << 2)
166#define ICLR_RXOEC1 (1 << 1)
167#define ICLR_WISC (1 << 0)
168
169/*
170 * Main control register bits. P62
171 */
172#define MAINCR_SCRA(x) ((x) << 10) /* secondary codec reg access */
173#define MAINCR_DMAEN (1 << 9) /* dma enable */
174#define MAINCR_SL12TXEN (1 << 8) /* slot 12 transmit enable */
175#define MAINCR_SL12RXEN (1 << 7) /* slot 12 receive enable */
176#define MAINCR_SL2TXEN (1 << 6) /* slot 2 transmit enable */
177#define MAINCR_SL2RXEN (1 << 5) /* slot 2 receive enable */
178#define MAINCR_SL1TXEN (1 << 4) /* slot 1 transmit enable */
179#define MAINCR_SL1RXEN (1 << 3) /* slot 1 receive enable */
180#define MAINCR_LPM (1 << 2) /* low power mode */
181#define MAINCR_LOOPBK (1 << 1) /* loopback */
182#define MAINCR_IE (1 << 0) /* aaci interface enable */
183
184/*
185 * Reset register bits. P65
186 */
187#define RESET_NRST (1 << 0)
188
189/*
190 * Sync register bits. P65
191 */
192#define SYNC_FORCE (1 << 0)
193
194/*
195 * Main flag register bits. P66
196 */
197#define MAINFR_TXB (1 << 1) /* transmit busy */
198#define MAINFR_RXB (1 << 0) /* receive busy */
199
200
201
202struct aaci_runtime {
203 void *base;
204 void *fifo;
205
206 struct ac97_pcm *pcm;
207 int pcm_open;
208
209 u32 cr;
210 snd_pcm_substream_t *substream;
211
212 /*
213 * PIO support
214 */
215 void *start;
216 void *end;
217 void *ptr;
218 int bytes;
219 unsigned int period;
220 unsigned int fifosz;
221};
222
223struct aaci {
224 struct amba_device *dev;
225 snd_card_t *card;
226 void *base;
227 unsigned int fifosize;
228
229 /* AC'97 */
230 struct semaphore ac97_sem;
231 ac97_bus_t *ac97_bus;
232
233 u32 maincr;
234 spinlock_t lock;
235
236 struct aaci_runtime playback;
237 struct aaci_runtime capture;
238
239 snd_pcm_t *pcm;
240};
241
242#define ACSTREAM_FRONT 0
243#define ACSTREAM_SURROUND 1
244#define ACSTREAM_LFE 2
245
246#endif
diff --git a/sound/arm/devdma.c b/sound/arm/devdma.c
new file mode 100644
index 000000000000..60826a5324b4
--- /dev/null
+++ b/sound/arm/devdma.c
@@ -0,0 +1,81 @@
1/*
2 * linux/sound/arm/devdma.c
3 *
4 * Copyright (C) 2003-2004 Russell King, All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ARM DMA shim for ALSA.
11 */
12#include <linux/device.h>
13#include <linux/dma-mapping.h>
14
15#include <sound/driver.h>
16#include <sound/core.h>
17#include <sound/pcm.h>
18
19#include "devdma.h"
20
21void devdma_hw_free(struct device *dev, snd_pcm_substream_t *substream)
22{
23 snd_pcm_runtime_t *runtime = substream->runtime;
24 struct snd_dma_buffer *buf = runtime->dma_buffer_p;
25
26 if (runtime->dma_area == NULL)
27 return;
28
29 if (buf != &substream->dma_buffer) {
30 dma_free_coherent(buf->dev.dev, buf->bytes, buf->area, buf->addr);
31 kfree(runtime->dma_buffer_p);
32 }
33
34 snd_pcm_set_runtime_buffer(substream, NULL);
35}
36
37int devdma_hw_alloc(struct device *dev, snd_pcm_substream_t *substream, size_t size)
38{
39 snd_pcm_runtime_t *runtime = substream->runtime;
40 struct snd_dma_buffer *buf = runtime->dma_buffer_p;
41 int ret = 0;
42
43 if (buf) {
44 if (buf->bytes >= size)
45 goto out;
46 devdma_hw_free(dev, substream);
47 }
48
49 if (substream->dma_buffer.area != NULL && substream->dma_buffer.bytes >= size) {
50 buf = &substream->dma_buffer;
51 } else {
52 buf = kmalloc(sizeof(struct snd_dma_buffer), GFP_KERNEL);
53 if (!buf)
54 goto nomem;
55
56 buf->dev.type = SNDRV_DMA_TYPE_DEV;
57 buf->dev.dev = dev;
58 buf->area = dma_alloc_coherent(dev, size, &buf->addr, GFP_KERNEL);
59 buf->bytes = size;
60 buf->private_data = NULL;
61
62 if (!buf->area)
63 goto free;
64 }
65 snd_pcm_set_runtime_buffer(substream, buf);
66 ret = 1;
67 out:
68 runtime->dma_bytes = size;
69 return ret;
70
71 free:
72 kfree(buf);
73 nomem:
74 return -ENOMEM;
75}
76
77int devdma_mmap(struct device *dev, snd_pcm_substream_t *substream, struct vm_area_struct *vma)
78{
79 snd_pcm_runtime_t *runtime = substream->runtime;
80 return dma_mmap_coherent(dev, vma, runtime->dma_area, runtime->dma_addr, runtime->dma_bytes);
81}
diff --git a/sound/arm/devdma.h b/sound/arm/devdma.h
new file mode 100644
index 000000000000..5a33b6bacc34
--- /dev/null
+++ b/sound/arm/devdma.h
@@ -0,0 +1,3 @@
1void devdma_hw_free(struct device *dev, snd_pcm_substream_t *substream);
2int devdma_hw_alloc(struct device *dev, snd_pcm_substream_t *substream, size_t size);
3int devdma_mmap(struct device *dev, snd_pcm_substream_t *substream, struct vm_area_struct *vma);
diff --git a/sound/core/control.c b/sound/core/control.c
index f4ea6bff1dd3..227f3cf02771 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -215,7 +215,7 @@ snd_kcontrol_t *snd_ctl_new(snd_kcontrol_t * control, unsigned int access)
215 * 215 *
216 * Returns the pointer of the newly generated instance, or NULL on failure. 216 * Returns the pointer of the newly generated instance, or NULL on failure.
217 */ 217 */
218snd_kcontrol_t *snd_ctl_new1(snd_kcontrol_new_t * ncontrol, void *private_data) 218snd_kcontrol_t *snd_ctl_new1(const snd_kcontrol_new_t * ncontrol, void *private_data)
219{ 219{
220 snd_kcontrol_t kctl; 220 snd_kcontrol_t kctl;
221 unsigned int access; 221 unsigned int access;
@@ -1102,7 +1102,7 @@ static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg
1102 } 1102 }
1103 } 1103 }
1104 up_read(&snd_ioctl_rwsem); 1104 up_read(&snd_ioctl_rwsem);
1105 snd_printd("unknown ioctl = 0x%x\n", cmd); 1105 snd_printdd("unknown ioctl = 0x%x\n", cmd);
1106 return -ENOTTY; 1106 return -ENOTTY;
1107} 1107}
1108 1108
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c
index 344a83fd7c2e..dbc23e35fa06 100644
--- a/sound/core/memalloc.c
+++ b/sound/core/memalloc.c
@@ -28,6 +28,7 @@
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/mm.h> 30#include <linux/mm.h>
31#include <asm/uaccess.h>
31#include <linux/dma-mapping.h> 32#include <linux/dma-mapping.h>
32#include <linux/moduleparam.h> 33#include <linux/moduleparam.h>
33#include <asm/semaphore.h> 34#include <asm/semaphore.h>
@@ -46,13 +47,6 @@ MODULE_LICENSE("GPL");
46#define SNDRV_CARDS 8 47#define SNDRV_CARDS 8
47#endif 48#endif
48 49
49/* FIXME: so far only some PCI devices have the preallocation table */
50#ifdef CONFIG_PCI
51static int enable[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 1};
52module_param_array(enable, bool, NULL, 0444);
53MODULE_PARM_DESC(enable, "Enable cards to allocate buffers.");
54#endif
55
56/* 50/*
57 */ 51 */
58 52
@@ -451,9 +445,13 @@ size_t snd_dma_get_reserved_buf(struct snd_dma_buffer *dmab, unsigned int id)
451 list_for_each(p, &mem_list_head) { 445 list_for_each(p, &mem_list_head) {
452 mem = list_entry(p, struct snd_mem_list, list); 446 mem = list_entry(p, struct snd_mem_list, list);
453 if (mem->id == id && 447 if (mem->id == id &&
454 ! memcmp(&mem->buffer.dev, &dmab->dev, sizeof(dmab->dev))) { 448 (mem->buffer.dev.dev == NULL || dmab->dev.dev == NULL ||
449 ! memcmp(&mem->buffer.dev, &dmab->dev, sizeof(dmab->dev)))) {
450 struct device *dev = dmab->dev.dev;
455 list_del(p); 451 list_del(p);
456 *dmab = mem->buffer; 452 *dmab = mem->buffer;
453 if (dmab->dev.dev == NULL)
454 dmab->dev.dev = dev;
457 kfree(mem); 455 kfree(mem);
458 up(&list_mutex); 456 up(&list_mutex);
459 return dmab->bytes; 457 return dmab->bytes;
@@ -508,91 +506,13 @@ static void free_all_reserved_pages(void)
508} 506}
509 507
510 508
511
512/*
513 * allocation of buffers for pre-defined devices
514 */
515
516#ifdef CONFIG_PCI
517/* FIXME: for pci only - other bus? */
518struct prealloc_dev {
519 unsigned short vendor;
520 unsigned short device;
521 unsigned long dma_mask;
522 unsigned int size;
523 unsigned int buffers;
524};
525
526#define HAMMERFALL_BUFFER_SIZE (16*1024*4*(26+1)+0x10000)
527
528static struct prealloc_dev prealloc_devices[] __initdata = {
529 {
530 /* hammerfall */
531 .vendor = 0x10ee,
532 .device = 0x3fc4,
533 .dma_mask = 0xffffffff,
534 .size = HAMMERFALL_BUFFER_SIZE,
535 .buffers = 2
536 },
537 {
538 /* HDSP */
539 .vendor = 0x10ee,
540 .device = 0x3fc5,
541 .dma_mask = 0xffffffff,
542 .size = HAMMERFALL_BUFFER_SIZE,
543 .buffers = 2
544 },
545 { }, /* terminator */
546};
547
548static void __init preallocate_cards(void)
549{
550 struct pci_dev *pci = NULL;
551 int card;
552
553 card = 0;
554
555 while ((pci = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci)) != NULL) {
556 struct prealloc_dev *dev;
557 unsigned int i;
558 if (card >= SNDRV_CARDS)
559 break;
560 for (dev = prealloc_devices; dev->vendor; dev++) {
561 if (dev->vendor == pci->vendor && dev->device == pci->device)
562 break;
563 }
564 if (! dev->vendor)
565 continue;
566 if (! enable[card++]) {
567 printk(KERN_DEBUG "snd-page-alloc: skipping card %d, device %04x:%04x\n", card, pci->vendor, pci->device);
568 continue;
569 }
570
571 if (pci_set_dma_mask(pci, dev->dma_mask) < 0 ||
572 pci_set_consistent_dma_mask(pci, dev->dma_mask) < 0) {
573 printk(KERN_ERR "snd-page-alloc: cannot set DMA mask %lx for pci %04x:%04x\n", dev->dma_mask, dev->vendor, dev->device);
574 continue;
575 }
576 for (i = 0; i < dev->buffers; i++) {
577 struct snd_dma_buffer dmab;
578 memset(&dmab, 0, sizeof(dmab));
579 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
580 dev->size, &dmab) < 0)
581 printk(KERN_WARNING "snd-page-alloc: cannot allocate buffer pages (size = %d)\n", dev->size);
582 else
583 snd_dma_reserve_buf(&dmab, snd_dma_pci_buf_id(pci));
584 }
585 }
586}
587#else
588#define preallocate_cards() /* NOP */
589#endif
590
591
592#ifdef CONFIG_PROC_FS 509#ifdef CONFIG_PROC_FS
593/* 510/*
594 * proc file interface 511 * proc file interface
595 */ 512 */
513#define SND_MEM_PROC_FILE "driver/snd-page-alloc"
514struct proc_dir_entry *snd_mem_proc;
515
596static int snd_mem_proc_read(char *page, char **start, off_t off, 516static int snd_mem_proc_read(char *page, char **start, off_t off,
597 int count, int *eof, void *data) 517 int count, int *eof, void *data)
598{ 518{
@@ -621,6 +541,97 @@ static int snd_mem_proc_read(char *page, char **start, off_t off,
621 up(&list_mutex); 541 up(&list_mutex);
622 return len; 542 return len;
623} 543}
544
545/* FIXME: for pci only - other bus? */
546#ifdef CONFIG_PCI
547#define gettoken(bufp) strsep(bufp, " \t\n")
548
549static int snd_mem_proc_write(struct file *file, const char __user *buffer,
550 unsigned long count, void *data)
551{
552 char buf[128];
553 char *token, *p;
554
555 if (count > ARRAY_SIZE(buf) - 1)
556 count = ARRAY_SIZE(buf) - 1;
557 if (copy_from_user(buf, buffer, count))
558 return -EFAULT;
559 buf[ARRAY_SIZE(buf) - 1] = '\0';
560
561 p = buf;
562 token = gettoken(&p);
563 if (! token || *token == '#')
564 return (int)count;
565 if (strcmp(token, "add") == 0) {
566 char *endp;
567 int vendor, device, size, buffers;
568 long mask;
569 int i, alloced;
570 struct pci_dev *pci;
571
572 if ((token = gettoken(&p)) == NULL ||
573 (vendor = simple_strtol(token, NULL, 0)) <= 0 ||
574 (token = gettoken(&p)) == NULL ||
575 (device = simple_strtol(token, NULL, 0)) <= 0 ||
576 (token = gettoken(&p)) == NULL ||
577 (mask = simple_strtol(token, NULL, 0)) < 0 ||
578 (token = gettoken(&p)) == NULL ||
579 (size = memparse(token, &endp)) < 64*1024 ||
580 size > 16*1024*1024 /* too big */ ||
581 (token = gettoken(&p)) == NULL ||
582 (buffers = simple_strtol(token, NULL, 0)) <= 0 ||
583 buffers > 4) {
584 printk(KERN_ERR "snd-page-alloc: invalid proc write format\n");
585 return (int)count;
586 }
587 vendor &= 0xffff;
588 device &= 0xffff;
589
590 alloced = 0;
591 pci = NULL;
592 while ((pci = pci_find_device(vendor, device, pci)) != NULL) {
593 if (mask > 0 && mask < 0xffffffff) {
594 if (pci_set_dma_mask(pci, mask) < 0 ||
595 pci_set_consistent_dma_mask(pci, mask) < 0) {
596 printk(KERN_ERR "snd-page-alloc: cannot set DMA mask %lx for pci %04x:%04x\n", mask, vendor, device);
597 return (int)count;
598 }
599 }
600 for (i = 0; i < buffers; i++) {
601 struct snd_dma_buffer dmab;
602 memset(&dmab, 0, sizeof(dmab));
603 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
604 size, &dmab) < 0) {
605 printk(KERN_ERR "snd-page-alloc: cannot allocate buffer pages (size = %d)\n", size);
606 return (int)count;
607 }
608 snd_dma_reserve_buf(&dmab, snd_dma_pci_buf_id(pci));
609 }
610 alloced++;
611 }
612 if (! alloced) {
613 for (i = 0; i < buffers; i++) {
614 struct snd_dma_buffer dmab;
615 memset(&dmab, 0, sizeof(dmab));
616 /* FIXME: We can allocate only in ZONE_DMA
617 * without a device pointer!
618 */
619 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, NULL,
620 size, &dmab) < 0) {
621 printk(KERN_ERR "snd-page-alloc: cannot allocate buffer pages (size = %d)\n", size);
622 break;
623 }
624 snd_dma_reserve_buf(&dmab, (unsigned int)((vendor << 16) | device));
625 }
626 }
627 } else if (strcmp(token, "erase") == 0)
628 /* FIXME: need for releasing each buffer chunk? */
629 free_all_reserved_pages();
630 else
631 printk(KERN_ERR "snd-page-alloc: invalid proc cmd\n");
632 return (int)count;
633}
634#endif /* CONFIG_PCI */
624#endif /* CONFIG_PROC_FS */ 635#endif /* CONFIG_PROC_FS */
625 636
626/* 637/*
@@ -630,15 +641,21 @@ static int snd_mem_proc_read(char *page, char **start, off_t off,
630static int __init snd_mem_init(void) 641static int __init snd_mem_init(void)
631{ 642{
632#ifdef CONFIG_PROC_FS 643#ifdef CONFIG_PROC_FS
633 create_proc_read_entry("driver/snd-page-alloc", 0, NULL, snd_mem_proc_read, NULL); 644 snd_mem_proc = create_proc_entry(SND_MEM_PROC_FILE, 0644, NULL);
645 if (snd_mem_proc) {
646 snd_mem_proc->read_proc = snd_mem_proc_read;
647#ifdef CONFIG_PCI
648 snd_mem_proc->write_proc = snd_mem_proc_write;
649#endif
650 }
634#endif 651#endif
635 preallocate_cards();
636 return 0; 652 return 0;
637} 653}
638 654
639static void __exit snd_mem_exit(void) 655static void __exit snd_mem_exit(void)
640{ 656{
641 remove_proc_entry("driver/snd-page-alloc", NULL); 657 if (snd_mem_proc)
658 remove_proc_entry(SND_MEM_PROC_FILE, NULL);
642 free_all_reserved_pages(); 659 free_all_reserved_pages();
643 if (snd_allocated_pages > 0) 660 if (snd_allocated_pages > 0)
644 printk(KERN_ERR "snd-malloc: Memory leak? pages not freed = %li\n", snd_allocated_pages); 661 printk(KERN_ERR "snd-malloc: Memory leak? pages not freed = %li\n", snd_allocated_pages);
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 1a805020f57a..cab30977e7c0 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -125,17 +125,26 @@ int snd_pcm_plugin_append(snd_pcm_plugin_t *plugin)
125static long snd_pcm_oss_bytes(snd_pcm_substream_t *substream, long frames) 125static long snd_pcm_oss_bytes(snd_pcm_substream_t *substream, long frames)
126{ 126{
127 snd_pcm_runtime_t *runtime = substream->runtime; 127 snd_pcm_runtime_t *runtime = substream->runtime;
128 snd_pcm_uframes_t buffer_size = snd_pcm_lib_buffer_bytes(substream); 128 long buffer_size = snd_pcm_lib_buffer_bytes(substream);
129 frames = frames_to_bytes(runtime, frames); 129 long bytes = frames_to_bytes(runtime, frames);
130 if (buffer_size == runtime->oss.buffer_bytes) 130 if (buffer_size == runtime->oss.buffer_bytes)
131 return frames; 131 return bytes;
132 return (runtime->oss.buffer_bytes * frames) / buffer_size; 132#if BITS_PER_LONG >= 64
133 return runtime->oss.buffer_bytes * bytes / buffer_size;
134#else
135 {
136 u64 bsize = (u64)runtime->oss.buffer_bytes * (u64)bytes;
137 u32 rem;
138 div64_32(&bsize, buffer_size, &rem);
139 return (long)bsize;
140 }
141#endif
133} 142}
134 143
135static long snd_pcm_alsa_frames(snd_pcm_substream_t *substream, long bytes) 144static long snd_pcm_alsa_frames(snd_pcm_substream_t *substream, long bytes)
136{ 145{
137 snd_pcm_runtime_t *runtime = substream->runtime; 146 snd_pcm_runtime_t *runtime = substream->runtime;
138 snd_pcm_uframes_t buffer_size = snd_pcm_lib_buffer_bytes(substream); 147 long buffer_size = snd_pcm_lib_buffer_bytes(substream);
139 if (buffer_size == runtime->oss.buffer_bytes) 148 if (buffer_size == runtime->oss.buffer_bytes)
140 return bytes_to_frames(runtime, bytes); 149 return bytes_to_frames(runtime, bytes);
141 return bytes_to_frames(runtime, (buffer_size * bytes) / runtime->oss.buffer_bytes); 150 return bytes_to_frames(runtime, (buffer_size * bytes) / runtime->oss.buffer_bytes);
@@ -464,7 +473,8 @@ static int snd_pcm_oss_change_params(snd_pcm_substream_t *substream)
464 sw_params->tstamp_mode = SNDRV_PCM_TSTAMP_NONE; 473 sw_params->tstamp_mode = SNDRV_PCM_TSTAMP_NONE;
465 sw_params->period_step = 1; 474 sw_params->period_step = 1;
466 sw_params->sleep_min = 0; 475 sw_params->sleep_min = 0;
467 sw_params->avail_min = 1; 476 sw_params->avail_min = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
477 1 : runtime->period_size;
468 sw_params->xfer_align = 1; 478 sw_params->xfer_align = 1;
469 if (atomic_read(&runtime->mmap_count) || 479 if (atomic_read(&runtime->mmap_count) ||
470 (substream->oss.setup && substream->oss.setup->nosilence)) { 480 (substream->oss.setup && substream->oss.setup->nosilence)) {
@@ -1527,12 +1537,15 @@ static int snd_pcm_oss_get_ptr(snd_pcm_oss_file_t *pcm_oss_file, int stream, str
1527 snd_pcm_oss_simulate_fill(substream, delay); 1537 snd_pcm_oss_simulate_fill(substream, delay);
1528 info.bytes = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr) & INT_MAX; 1538 info.bytes = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr) & INT_MAX;
1529 } else { 1539 } else {
1530 delay = snd_pcm_oss_bytes(substream, delay) + fixup; 1540 delay = snd_pcm_oss_bytes(substream, delay);
1531 info.blocks = delay / runtime->oss.period_bytes; 1541 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
1532 if (stream == SNDRV_PCM_STREAM_PLAYBACK) 1542 info.blocks = (runtime->oss.buffer_bytes - delay - fixup) / runtime->oss.period_bytes;
1533 info.bytes = (runtime->oss.bytes - delay) & INT_MAX; 1543 info.bytes = (runtime->oss.bytes - delay) & INT_MAX;
1534 else 1544 } else {
1545 delay += fixup;
1546 info.blocks = delay / runtime->oss.period_bytes;
1535 info.bytes = (runtime->oss.bytes + delay) & INT_MAX; 1547 info.bytes = (runtime->oss.bytes + delay) & INT_MAX;
1548 }
1536 } 1549 }
1537 if (copy_to_user(_info, &info, sizeof(info))) 1550 if (copy_to_user(_info, &info, sizeof(info)))
1538 return -EFAULT; 1551 return -EFAULT;
diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c
index 6bb31009f0b4..6430410c6c04 100644
--- a/sound/core/oss/pcm_plugin.c
+++ b/sound/core/oss/pcm_plugin.c
@@ -663,10 +663,7 @@ static int snd_pcm_plug_playback_channels_mask(snd_pcm_plug_t *plug,
663 bitset_t *dstmask = bs; 663 bitset_t *dstmask = bs;
664 int err; 664 int err;
665 bitset_one(dstmask, schannels); 665 bitset_one(dstmask, schannels);
666 if (plugin == NULL) { 666
667 bitset_and(client_vmask, dstmask, schannels);
668 return 0;
669 }
670 while (1) { 667 while (1) {
671 err = plugin->src_channels_mask(plugin, dstmask, &srcmask); 668 err = plugin->src_channels_mask(plugin, dstmask, &srcmask);
672 if (err < 0) 669 if (err < 0)
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 8d94325529a8..9f4c9209b271 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -451,6 +451,7 @@ static int snd_pcm_stream_proc_init(snd_pcm_str_t *pstr)
451 entry->c.text.read = snd_pcm_xrun_debug_read; 451 entry->c.text.read = snd_pcm_xrun_debug_read;
452 entry->c.text.write_size = 64; 452 entry->c.text.write_size = 64;
453 entry->c.text.write = snd_pcm_xrun_debug_write; 453 entry->c.text.write = snd_pcm_xrun_debug_write;
454 entry->mode |= S_IWUSR;
454 entry->private_data = pstr; 455 entry->private_data = pstr;
455 if (snd_info_register(entry) < 0) { 456 if (snd_info_register(entry) < 0) {
456 snd_info_free_entry(entry); 457 snd_info_free_entry(entry);
@@ -1048,7 +1049,6 @@ EXPORT_SYMBOL(snd_pcm_release_substream);
1048EXPORT_SYMBOL(snd_pcm_format_name); 1049EXPORT_SYMBOL(snd_pcm_format_name);
1049 /* pcm_native.c */ 1050 /* pcm_native.c */
1050EXPORT_SYMBOL(snd_pcm_link_rwlock); 1051EXPORT_SYMBOL(snd_pcm_link_rwlock);
1051EXPORT_SYMBOL(snd_pcm_start);
1052#ifdef CONFIG_PM 1052#ifdef CONFIG_PM
1053EXPORT_SYMBOL(snd_pcm_suspend); 1053EXPORT_SYMBOL(snd_pcm_suspend);
1054EXPORT_SYMBOL(snd_pcm_suspend_all); 1054EXPORT_SYMBOL(snd_pcm_suspend_all);
@@ -1068,6 +1068,7 @@ EXPORT_SYMBOL(snd_pcm_format_little_endian);
1068EXPORT_SYMBOL(snd_pcm_format_big_endian); 1068EXPORT_SYMBOL(snd_pcm_format_big_endian);
1069EXPORT_SYMBOL(snd_pcm_format_width); 1069EXPORT_SYMBOL(snd_pcm_format_width);
1070EXPORT_SYMBOL(snd_pcm_format_physical_width); 1070EXPORT_SYMBOL(snd_pcm_format_physical_width);
1071EXPORT_SYMBOL(snd_pcm_format_size);
1071EXPORT_SYMBOL(snd_pcm_format_silence_64); 1072EXPORT_SYMBOL(snd_pcm_format_silence_64);
1072EXPORT_SYMBOL(snd_pcm_format_set_silence); 1073EXPORT_SYMBOL(snd_pcm_format_set_silence);
1073EXPORT_SYMBOL(snd_pcm_build_linear_format); 1074EXPORT_SYMBOL(snd_pcm_build_linear_format);
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 151fd99ca2c9..c5bfd0918cff 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -1143,7 +1143,8 @@ int snd_pcm_hw_constraint_pow2(snd_pcm_runtime_t *runtime,
1143#define INT_MIN ((int)((unsigned int)INT_MAX+1)) 1143#define INT_MIN ((int)((unsigned int)INT_MAX+1))
1144#endif 1144#endif
1145 1145
1146void _snd_pcm_hw_param_any(snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var) 1146static void _snd_pcm_hw_param_any(snd_pcm_hw_params_t *params,
1147 snd_pcm_hw_param_t var)
1147{ 1148{
1148 if (hw_is_mask(var)) { 1149 if (hw_is_mask(var)) {
1149 snd_mask_any(hw_param_mask(params, var)); 1150 snd_mask_any(hw_param_mask(params, var));
@@ -1160,6 +1161,7 @@ void _snd_pcm_hw_param_any(snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var)
1160 snd_BUG(); 1161 snd_BUG();
1161} 1162}
1162 1163
1164#if 0
1163/** 1165/**
1164 * snd_pcm_hw_param_any 1166 * snd_pcm_hw_param_any
1165 */ 1167 */
@@ -1169,6 +1171,7 @@ int snd_pcm_hw_param_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
1169 _snd_pcm_hw_param_any(params, var); 1171 _snd_pcm_hw_param_any(params, var);
1170 return snd_pcm_hw_refine(pcm, params); 1172 return snd_pcm_hw_refine(pcm, params);
1171} 1173}
1174#endif /* 0 */
1172 1175
1173void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params) 1176void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params)
1174{ 1177{
@@ -1181,6 +1184,7 @@ void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params)
1181 params->info = ~0U; 1184 params->info = ~0U;
1182} 1185}
1183 1186
1187#if 0
1184/** 1188/**
1185 * snd_pcm_hw_params_any 1189 * snd_pcm_hw_params_any
1186 * 1190 *
@@ -1191,6 +1195,7 @@ int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
1191 _snd_pcm_hw_params_any(params); 1195 _snd_pcm_hw_params_any(params);
1192 return snd_pcm_hw_refine(pcm, params); 1196 return snd_pcm_hw_refine(pcm, params);
1193} 1197}
1198#endif /* 0 */
1194 1199
1195/** 1200/**
1196 * snd_pcm_hw_param_value 1201 * snd_pcm_hw_param_value
@@ -1198,8 +1203,8 @@ int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
1198 * Return the value for field PAR if it's fixed in configuration space 1203 * Return the value for field PAR if it's fixed in configuration space
1199 * defined by PARAMS. Return -EINVAL otherwise 1204 * defined by PARAMS. Return -EINVAL otherwise
1200 */ 1205 */
1201int snd_pcm_hw_param_value(const snd_pcm_hw_params_t *params, 1206static int snd_pcm_hw_param_value(const snd_pcm_hw_params_t *params,
1202 snd_pcm_hw_param_t var, int *dir) 1207 snd_pcm_hw_param_t var, int *dir)
1203{ 1208{
1204 if (hw_is_mask(var)) { 1209 if (hw_is_mask(var)) {
1205 const snd_mask_t *mask = hw_param_mask_c(params, var); 1210 const snd_mask_t *mask = hw_param_mask_c(params, var);
@@ -1296,6 +1301,7 @@ int _snd_pcm_hw_param_setinteger(snd_pcm_hw_params_t *params,
1296 return changed; 1301 return changed;
1297} 1302}
1298 1303
1304#if 0
1299/** 1305/**
1300 * snd_pcm_hw_param_setinteger 1306 * snd_pcm_hw_param_setinteger
1301 * 1307 *
@@ -1317,9 +1323,10 @@ int snd_pcm_hw_param_setinteger(snd_pcm_t *pcm,
1317 } 1323 }
1318 return 0; 1324 return 0;
1319} 1325}
1326#endif /* 0 */
1320 1327
1321int _snd_pcm_hw_param_first(snd_pcm_hw_params_t *params, 1328static int _snd_pcm_hw_param_first(snd_pcm_hw_params_t *params,
1322 snd_pcm_hw_param_t var) 1329 snd_pcm_hw_param_t var)
1323{ 1330{
1324 int changed; 1331 int changed;
1325 if (hw_is_mask(var)) 1332 if (hw_is_mask(var))
@@ -1345,9 +1352,9 @@ int _snd_pcm_hw_param_first(snd_pcm_hw_params_t *params,
1345 * values > minimum. Reduce configuration space accordingly. 1352 * values > minimum. Reduce configuration space accordingly.
1346 * Return the minimum. 1353 * Return the minimum.
1347 */ 1354 */
1348int snd_pcm_hw_param_first(snd_pcm_t *pcm, 1355static int snd_pcm_hw_param_first(snd_pcm_t *pcm,
1349 snd_pcm_hw_params_t *params, 1356 snd_pcm_hw_params_t *params,
1350 snd_pcm_hw_param_t var, int *dir) 1357 snd_pcm_hw_param_t var, int *dir)
1351{ 1358{
1352 int changed = _snd_pcm_hw_param_first(params, var); 1359 int changed = _snd_pcm_hw_param_first(params, var);
1353 if (changed < 0) 1360 if (changed < 0)
@@ -1359,8 +1366,8 @@ int snd_pcm_hw_param_first(snd_pcm_t *pcm,
1359 return snd_pcm_hw_param_value(params, var, dir); 1366 return snd_pcm_hw_param_value(params, var, dir);
1360} 1367}
1361 1368
1362int _snd_pcm_hw_param_last(snd_pcm_hw_params_t *params, 1369static int _snd_pcm_hw_param_last(snd_pcm_hw_params_t *params,
1363 snd_pcm_hw_param_t var) 1370 snd_pcm_hw_param_t var)
1364{ 1371{
1365 int changed; 1372 int changed;
1366 if (hw_is_mask(var)) 1373 if (hw_is_mask(var))
@@ -1386,9 +1393,9 @@ int _snd_pcm_hw_param_last(snd_pcm_hw_params_t *params,
1386 * values < maximum. Reduce configuration space accordingly. 1393 * values < maximum. Reduce configuration space accordingly.
1387 * Return the maximum. 1394 * Return the maximum.
1388 */ 1395 */
1389int snd_pcm_hw_param_last(snd_pcm_t *pcm, 1396static int snd_pcm_hw_param_last(snd_pcm_t *pcm,
1390 snd_pcm_hw_params_t *params, 1397 snd_pcm_hw_params_t *params,
1391 snd_pcm_hw_param_t var, int *dir) 1398 snd_pcm_hw_param_t var, int *dir)
1392{ 1399{
1393 int changed = _snd_pcm_hw_param_last(params, var); 1400 int changed = _snd_pcm_hw_param_last(params, var);
1394 if (changed < 0) 1401 if (changed < 0)
@@ -1437,8 +1444,9 @@ int _snd_pcm_hw_param_min(snd_pcm_hw_params_t *params,
1437 * values < VAL. Reduce configuration space accordingly. 1444 * values < VAL. Reduce configuration space accordingly.
1438 * Return new minimum or -EINVAL if the configuration space is empty 1445 * Return new minimum or -EINVAL if the configuration space is empty
1439 */ 1446 */
1440int snd_pcm_hw_param_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, 1447static int snd_pcm_hw_param_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
1441 snd_pcm_hw_param_t var, unsigned int val, int *dir) 1448 snd_pcm_hw_param_t var, unsigned int val,
1449 int *dir)
1442{ 1450{
1443 int changed = _snd_pcm_hw_param_min(params, var, val, dir ? *dir : 0); 1451 int changed = _snd_pcm_hw_param_min(params, var, val, dir ? *dir : 0);
1444 if (changed < 0) 1452 if (changed < 0)
@@ -1451,8 +1459,9 @@ int snd_pcm_hw_param_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
1451 return snd_pcm_hw_param_value_min(params, var, dir); 1459 return snd_pcm_hw_param_value_min(params, var, dir);
1452} 1460}
1453 1461
1454int _snd_pcm_hw_param_max(snd_pcm_hw_params_t *params, 1462static int _snd_pcm_hw_param_max(snd_pcm_hw_params_t *params,
1455 snd_pcm_hw_param_t var, unsigned int val, int dir) 1463 snd_pcm_hw_param_t var, unsigned int val,
1464 int dir)
1456{ 1465{
1457 int changed; 1466 int changed;
1458 int open = 0; 1467 int open = 0;
@@ -1490,8 +1499,9 @@ int _snd_pcm_hw_param_max(snd_pcm_hw_params_t *params,
1490 * values >= VAL + 1. Reduce configuration space accordingly. 1499 * values >= VAL + 1. Reduce configuration space accordingly.
1491 * Return new maximum or -EINVAL if the configuration space is empty 1500 * Return new maximum or -EINVAL if the configuration space is empty
1492 */ 1501 */
1493int snd_pcm_hw_param_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, 1502static int snd_pcm_hw_param_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
1494 snd_pcm_hw_param_t var, unsigned int val, int *dir) 1503 snd_pcm_hw_param_t var, unsigned int val,
1504 int *dir)
1495{ 1505{
1496 int changed = _snd_pcm_hw_param_max(params, var, val, dir ? *dir : 0); 1506 int changed = _snd_pcm_hw_param_max(params, var, val, dir ? *dir : 0);
1497 if (changed < 0) 1507 if (changed < 0)
@@ -2564,9 +2574,6 @@ snd_pcm_sframes_t snd_pcm_lib_readv(snd_pcm_substream_t *substream,
2564EXPORT_SYMBOL(snd_interval_refine); 2574EXPORT_SYMBOL(snd_interval_refine);
2565EXPORT_SYMBOL(snd_interval_list); 2575EXPORT_SYMBOL(snd_interval_list);
2566EXPORT_SYMBOL(snd_interval_ratnum); 2576EXPORT_SYMBOL(snd_interval_ratnum);
2567EXPORT_SYMBOL(snd_interval_muldivk);
2568EXPORT_SYMBOL(snd_interval_mulkdiv);
2569EXPORT_SYMBOL(snd_interval_div);
2570EXPORT_SYMBOL(_snd_pcm_hw_params_any); 2577EXPORT_SYMBOL(_snd_pcm_hw_params_any);
2571EXPORT_SYMBOL(_snd_pcm_hw_param_min); 2578EXPORT_SYMBOL(_snd_pcm_hw_param_min);
2572EXPORT_SYMBOL(_snd_pcm_hw_param_set); 2579EXPORT_SYMBOL(_snd_pcm_hw_param_set);
@@ -2580,7 +2587,6 @@ EXPORT_SYMBOL(snd_pcm_hw_param_last);
2580EXPORT_SYMBOL(snd_pcm_hw_param_near); 2587EXPORT_SYMBOL(snd_pcm_hw_param_near);
2581EXPORT_SYMBOL(snd_pcm_hw_param_set); 2588EXPORT_SYMBOL(snd_pcm_hw_param_set);
2582EXPORT_SYMBOL(snd_pcm_hw_refine); 2589EXPORT_SYMBOL(snd_pcm_hw_refine);
2583EXPORT_SYMBOL(snd_pcm_hw_params);
2584EXPORT_SYMBOL(snd_pcm_hw_constraints_init); 2590EXPORT_SYMBOL(snd_pcm_hw_constraints_init);
2585EXPORT_SYMBOL(snd_pcm_hw_constraints_complete); 2591EXPORT_SYMBOL(snd_pcm_hw_constraints_complete);
2586EXPORT_SYMBOL(snd_pcm_hw_constraint_list); 2592EXPORT_SYMBOL(snd_pcm_hw_constraint_list);
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c
index f1d5f7a6ee0c..9a174fb96565 100644
--- a/sound/core/pcm_memory.c
+++ b/sound/core/pcm_memory.c
@@ -204,6 +204,7 @@ static int snd_pcm_lib_preallocate_pages1(snd_pcm_substream_t *substream,
204 entry->c.text.read = snd_pcm_lib_preallocate_proc_read; 204 entry->c.text.read = snd_pcm_lib_preallocate_proc_read;
205 entry->c.text.write_size = 64; 205 entry->c.text.write_size = 64;
206 entry->c.text.write = snd_pcm_lib_preallocate_proc_write; 206 entry->c.text.write = snd_pcm_lib_preallocate_proc_write;
207 entry->mode |= S_IWUSR;
207 entry->private_data = substream; 208 entry->private_data = substream;
208 if (snd_info_register(entry) < 0) { 209 if (snd_info_register(entry) < 0) {
209 snd_info_free_entry(entry); 210 snd_info_free_entry(entry);
diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c
index 422b8db14154..1453743e4da0 100644
--- a/sound/core/pcm_misc.c
+++ b/sound/core/pcm_misc.c
@@ -270,22 +270,6 @@ int snd_pcm_format_big_endian(snd_pcm_format_t format)
270} 270}
271 271
272/** 272/**
273 * snd_pcm_format_cpu_endian - Check the PCM format is CPU-endian
274 * @format: the format to check
275 *
276 * Returns 1 if the given PCM format is CPU-endian, 0 if
277 * opposite, or a negative error code if endian not specified.
278 */
279int snd_pcm_format_cpu_endian(snd_pcm_format_t format)
280{
281#ifdef SNDRV_LITTLE_ENDIAN
282 return snd_pcm_format_little_endian(format);
283#else
284 return snd_pcm_format_big_endian(format);
285#endif
286}
287
288/**
289 * snd_pcm_format_width - return the bit-width of the format 273 * snd_pcm_format_width - return the bit-width of the format
290 * @format: the format to check 274 * @format: the format to check
291 * 275 *
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index cad9bbde9986..10c2c9832649 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -337,8 +337,8 @@ out:
337 return err; 337 return err;
338} 338}
339 339
340int snd_pcm_hw_params(snd_pcm_substream_t *substream, 340static int snd_pcm_hw_params(snd_pcm_substream_t *substream,
341 snd_pcm_hw_params_t *params) 341 snd_pcm_hw_params_t *params)
342{ 342{
343 snd_pcm_runtime_t *runtime; 343 snd_pcm_runtime_t *runtime;
344 int err; 344 int err;
@@ -1368,43 +1368,32 @@ static int snd_pcm_drain(snd_pcm_substream_t *substream)
1368 if (runtime->status->state == SNDRV_PCM_STATE_OPEN) 1368 if (runtime->status->state == SNDRV_PCM_STATE_OPEN)
1369 return -EBADFD; 1369 return -EBADFD;
1370 1370
1371 down_read(&snd_pcm_link_rwsem);
1372 snd_power_lock(card); 1371 snd_power_lock(card);
1373 if (runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) { 1372 if (runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {
1374 result = snd_power_wait(card, SNDRV_CTL_POWER_D0, substream->ffile); 1373 result = snd_power_wait(card, SNDRV_CTL_POWER_D0, substream->ffile);
1375 if (result < 0) 1374 if (result < 0) {
1376 goto _unlock; 1375 snd_power_unlock(card);
1376 return result;
1377 }
1377 } 1378 }
1378 1379
1379 /* allocate temporary record for drain sync */ 1380 /* allocate temporary record for drain sync */
1381 down_read(&snd_pcm_link_rwsem);
1380 if (snd_pcm_stream_linked(substream)) { 1382 if (snd_pcm_stream_linked(substream)) {
1381 drec = kmalloc(substream->group->count * sizeof(*drec), GFP_KERNEL); 1383 drec = kmalloc(substream->group->count * sizeof(*drec), GFP_KERNEL);
1382 if (! drec) { 1384 if (! drec) {
1383 result = -ENOMEM; 1385 up_read(&snd_pcm_link_rwsem);
1384 goto _unlock; 1386 snd_power_unlock(card);
1387 return -ENOMEM;
1385 } 1388 }
1386 } else 1389 } else
1387 drec = &drec_tmp; 1390 drec = &drec_tmp;
1388 1391
1389 snd_pcm_stream_lock_irq(substream); 1392 /* count only playback streams */
1390 /* resume pause */
1391 if (runtime->status->state == SNDRV_PCM_STATE_PAUSED)
1392 snd_pcm_pause(substream, 0);
1393
1394 /* pre-start/stop - all running streams are changed to DRAINING state */
1395 result = snd_pcm_action(&snd_pcm_action_drain_init, substream, 0);
1396 if (result < 0)
1397 goto _end;
1398
1399 /* check streams with PLAYBACK & DRAINING */
1400 num_drecs = 0; 1393 num_drecs = 0;
1401 snd_pcm_group_for_each(pos, substream) { 1394 snd_pcm_group_for_each(pos, substream) {
1402 snd_pcm_substream_t *s = snd_pcm_group_substream_entry(pos); 1395 snd_pcm_substream_t *s = snd_pcm_group_substream_entry(pos);
1403 runtime = s->runtime; 1396 runtime = s->runtime;
1404 if (runtime->status->state != SNDRV_PCM_STATE_DRAINING) {
1405 runtime->status->state = SNDRV_PCM_STATE_SETUP;
1406 continue;
1407 }
1408 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { 1397 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1409 d = &drec[num_drecs++]; 1398 d = &drec[num_drecs++];
1410 d->substream = s; 1399 d->substream = s;
@@ -1418,9 +1407,21 @@ static int snd_pcm_drain(snd_pcm_substream_t *substream)
1418 runtime->stop_threshold = runtime->buffer_size; 1407 runtime->stop_threshold = runtime->buffer_size;
1419 } 1408 }
1420 } 1409 }
1421 1410 up_read(&snd_pcm_link_rwsem);
1422 if (! num_drecs) 1411 if (! num_drecs)
1423 goto _end; 1412 goto _error;
1413
1414 snd_pcm_stream_lock_irq(substream);
1415 /* resume pause */
1416 if (runtime->status->state == SNDRV_PCM_STATE_PAUSED)
1417 snd_pcm_pause(substream, 0);
1418
1419 /* pre-start/stop - all running streams are changed to DRAINING state */
1420 result = snd_pcm_action(&snd_pcm_action_drain_init, substream, 0);
1421 if (result < 0) {
1422 snd_pcm_stream_unlock_irq(substream);
1423 goto _error;
1424 }
1424 1425
1425 for (;;) { 1426 for (;;) {
1426 long tout; 1427 long tout;
@@ -1428,6 +1429,15 @@ static int snd_pcm_drain(snd_pcm_substream_t *substream)
1428 result = -ERESTARTSYS; 1429 result = -ERESTARTSYS;
1429 break; 1430 break;
1430 } 1431 }
1432 /* all finished? */
1433 for (i = 0; i < num_drecs; i++) {
1434 runtime = drec[i].substream->runtime;
1435 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING)
1436 break;
1437 }
1438 if (i == num_drecs)
1439 break; /* yes, all drained */
1440
1431 set_current_state(TASK_INTERRUPTIBLE); 1441 set_current_state(TASK_INTERRUPTIBLE);
1432 snd_pcm_stream_unlock_irq(substream); 1442 snd_pcm_stream_unlock_irq(substream);
1433 snd_power_unlock(card); 1443 snd_power_unlock(card);
@@ -1444,15 +1454,11 @@ static int snd_pcm_drain(snd_pcm_substream_t *substream)
1444 } 1454 }
1445 break; 1455 break;
1446 } 1456 }
1447 /* all finished? */
1448 for (i = 0; i < num_drecs; i++) {
1449 runtime = drec[i].substream->runtime;
1450 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING)
1451 break;
1452 }
1453 if (i == num_drecs)
1454 break;
1455 } 1457 }
1458
1459 snd_pcm_stream_unlock_irq(substream);
1460
1461 _error:
1456 for (i = 0; i < num_drecs; i++) { 1462 for (i = 0; i < num_drecs; i++) {
1457 d = &drec[i]; 1463 d = &drec[i];
1458 runtime = d->substream->runtime; 1464 runtime = d->substream->runtime;
@@ -1460,13 +1466,9 @@ static int snd_pcm_drain(snd_pcm_substream_t *substream)
1460 runtime->stop_threshold = d->stop_threshold; 1466 runtime->stop_threshold = d->stop_threshold;
1461 } 1467 }
1462 1468
1463 _end:
1464 snd_pcm_stream_unlock_irq(substream);
1465 if (drec != &drec_tmp) 1469 if (drec != &drec_tmp)
1466 kfree(drec); 1470 kfree(drec);
1467 _unlock:
1468 snd_power_unlock(card); 1471 snd_power_unlock(card);
1469 up_read(&snd_pcm_link_rwsem);
1470 1472
1471 return result; 1473 return result;
1472} 1474}
diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c
index 638cc148706d..1a7736cbf3a4 100644
--- a/sound/core/seq/oss/seq_oss_synth.c
+++ b/sound/core/seq/oss/seq_oss_synth.c
@@ -325,14 +325,10 @@ snd_seq_oss_synth_cleanup(seq_oss_devinfo_t *dp)
325 } 325 }
326 snd_use_lock_free(&rec->use_lock); 326 snd_use_lock_free(&rec->use_lock);
327 } 327 }
328 if (info->sysex) { 328 kfree(info->sysex);
329 kfree(info->sysex); 329 info->sysex = NULL;
330 info->sysex = NULL; 330 kfree(info->ch);
331 } 331 info->ch = NULL;
332 if (info->ch) {
333 kfree(info->ch);
334 info->ch = NULL;
335 }
336 } 332 }
337 dp->synth_opened = 0; 333 dp->synth_opened = 0;
338 dp->max_synthdev = 0; 334 dp->max_synthdev = 0;
@@ -418,14 +414,10 @@ snd_seq_oss_synth_reset(seq_oss_devinfo_t *dp, int dev)
418 dp->file_mode) < 0) { 414 dp->file_mode) < 0) {
419 midi_synth_dev.opened--; 415 midi_synth_dev.opened--;
420 info->opened = 0; 416 info->opened = 0;
421 if (info->sysex) { 417 kfree(info->sysex);
422 kfree(info->sysex); 418 info->sysex = NULL;
423 info->sysex = NULL; 419 kfree(info->ch);
424 } 420 info->ch = NULL;
425 if (info->ch) {
426 kfree(info->ch);
427 info->ch = NULL;
428 }
429 } 421 }
430 return; 422 return;
431 } 423 }
diff --git a/sound/core/seq/seq_dummy.c b/sound/core/seq/seq_dummy.c
index e88967c5b93d..ea945a5d2a0b 100644
--- a/sound/core/seq/seq_dummy.c
+++ b/sound/core/seq/seq_dummy.c
@@ -140,10 +140,7 @@ dummy_input(snd_seq_event_t *ev, int direct, void *private_data, int atomic, int
140static void 140static void
141dummy_free(void *private_data) 141dummy_free(void *private_data)
142{ 142{
143 snd_seq_dummy_port_t *p; 143 kfree(private_data);
144
145 p = private_data;
146 kfree(p);
147} 144}
148 145
149/* 146/*
diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c
index 18247db45db6..57be9155eb62 100644
--- a/sound/core/seq/seq_midi.c
+++ b/sound/core/seq/seq_midi.c
@@ -414,6 +414,8 @@ snd_seq_midisynth_register_port(snd_seq_device_t *dev)
414 if (newclient) 414 if (newclient)
415 synths[card->number] = client; 415 synths[card->number] = client;
416 up(&register_mutex); 416 up(&register_mutex);
417 kfree(info);
418 kfree(port);
417 return 0; /* success */ 419 return 0; /* success */
418 420
419 __nomem: 421 __nomem:
diff --git a/sound/core/seq/seq_midi_event.c b/sound/core/seq/seq_midi_event.c
index 21e569062bc3..df1e2bb39745 100644
--- a/sound/core/seq/seq_midi_event.c
+++ b/sound/core/seq/seq_midi_event.c
@@ -171,11 +171,13 @@ void snd_midi_event_reset_decode(snd_midi_event_t *dev)
171 spin_unlock_irqrestore(&dev->lock, flags); 171 spin_unlock_irqrestore(&dev->lock, flags);
172} 172}
173 173
174#if 0
174void snd_midi_event_init(snd_midi_event_t *dev) 175void snd_midi_event_init(snd_midi_event_t *dev)
175{ 176{
176 snd_midi_event_reset_encode(dev); 177 snd_midi_event_reset_encode(dev);
177 snd_midi_event_reset_decode(dev); 178 snd_midi_event_reset_decode(dev);
178} 179}
180#endif /* 0 */
179 181
180void snd_midi_event_no_status(snd_midi_event_t *dev, int on) 182void snd_midi_event_no_status(snd_midi_event_t *dev, int on)
181{ 183{
@@ -185,6 +187,7 @@ void snd_midi_event_no_status(snd_midi_event_t *dev, int on)
185/* 187/*
186 * resize buffer 188 * resize buffer
187 */ 189 */
190#if 0
188int snd_midi_event_resize_buffer(snd_midi_event_t *dev, int bufsize) 191int snd_midi_event_resize_buffer(snd_midi_event_t *dev, int bufsize)
189{ 192{
190 unsigned char *new_buf, *old_buf; 193 unsigned char *new_buf, *old_buf;
@@ -204,6 +207,7 @@ int snd_midi_event_resize_buffer(snd_midi_event_t *dev, int bufsize)
204 kfree(old_buf); 207 kfree(old_buf);
205 return 0; 208 return 0;
206} 209}
210#endif /* 0 */
207 211
208/* 212/*
209 * read bytes and encode to sequencer event if finished 213 * read bytes and encode to sequencer event if finished
@@ -517,8 +521,6 @@ static int extra_decode_xrpn(snd_midi_event_t *dev, unsigned char *buf, int coun
517 521
518EXPORT_SYMBOL(snd_midi_event_new); 522EXPORT_SYMBOL(snd_midi_event_new);
519EXPORT_SYMBOL(snd_midi_event_free); 523EXPORT_SYMBOL(snd_midi_event_free);
520EXPORT_SYMBOL(snd_midi_event_resize_buffer);
521EXPORT_SYMBOL(snd_midi_event_init);
522EXPORT_SYMBOL(snd_midi_event_reset_encode); 524EXPORT_SYMBOL(snd_midi_event_reset_encode);
523EXPORT_SYMBOL(snd_midi_event_reset_decode); 525EXPORT_SYMBOL(snd_midi_event_reset_decode);
524EXPORT_SYMBOL(snd_midi_event_no_status); 526EXPORT_SYMBOL(snd_midi_event_no_status);
diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c
index 3afc7cc0c9a7..98de2e711fde 100644
--- a/sound/core/seq/seq_queue.c
+++ b/sound/core/seq/seq_queue.c
@@ -672,7 +672,8 @@ static void queue_broadcast_event(queue_t *q, snd_seq_event_t *ev, int atomic, i
672 * process a received queue-control event. 672 * process a received queue-control event.
673 * this function is exported for seq_sync.c. 673 * this function is exported for seq_sync.c.
674 */ 674 */
675void snd_seq_queue_process_event(queue_t *q, snd_seq_event_t *ev, int atomic, int hop) 675static void snd_seq_queue_process_event(queue_t *q, snd_seq_event_t *ev,
676 int atomic, int hop)
676{ 677{
677 switch (ev->type) { 678 switch (ev->type) {
678 case SNDRV_SEQ_EVENT_START: 679 case SNDRV_SEQ_EVENT_START:
diff --git a/sound/core/seq/seq_queue.h b/sound/core/seq/seq_queue.h
index b1bf5519fb3b..ea3c54216ea8 100644
--- a/sound/core/seq/seq_queue.h
+++ b/sound/core/seq/seq_queue.h
@@ -111,7 +111,6 @@ int snd_seq_queue_use(int queueid, int client, int use);
111int snd_seq_queue_is_used(int queueid, int client); 111int snd_seq_queue_is_used(int queueid, int client);
112 112
113int snd_seq_control_queue(snd_seq_event_t *ev, int atomic, int hop); 113int snd_seq_control_queue(snd_seq_event_t *ev, int atomic, int hop);
114void snd_seq_queue_process_event(queue_t *q, snd_seq_event_t *ev, int atomic, int hop);
115 114
116/* 115/*
117 * 64bit division - for sync stuff.. 116 * 64bit division - for sync stuff..
diff --git a/sound/core/seq/seq_timer.c b/sound/core/seq/seq_timer.c
index 753f1c0863cc..a7f76fc95280 100644
--- a/sound/core/seq/seq_timer.c
+++ b/sound/core/seq/seq_timer.c
@@ -36,7 +36,8 @@ extern int seq_default_timer_resolution;
36 36
37#define SKEW_BASE 0x10000 /* 16bit shift */ 37#define SKEW_BASE 0x10000 /* 16bit shift */
38 38
39void snd_seq_timer_set_tick_resolution(seq_timer_tick_t *tick, int tempo, int ppq, int nticks) 39static void snd_seq_timer_set_tick_resolution(seq_timer_tick_t *tick,
40 int tempo, int ppq, int nticks)
40{ 41{
41 if (tempo < 1000000) 42 if (tempo < 1000000)
42 tick->resolution = (tempo * 1000) / ppq; 43 tick->resolution = (tempo * 1000) / ppq;
diff --git a/sound/core/seq/seq_timer.h b/sound/core/seq/seq_timer.h
index 4c0872df8931..287ed68591de 100644
--- a/sound/core/seq/seq_timer.h
+++ b/sound/core/seq/seq_timer.h
@@ -64,8 +64,6 @@ extern seq_timer_t *snd_seq_timer_new(void);
64/* delete timer (destructor) */ 64/* delete timer (destructor) */
65extern void snd_seq_timer_delete(seq_timer_t **tmr); 65extern void snd_seq_timer_delete(seq_timer_t **tmr);
66 66
67void snd_seq_timer_set_tick_resolution(seq_timer_tick_t *tick, int tempo, int ppq, int nticks);
68
69/* */ 67/* */
70static inline void snd_seq_timer_update_tick(seq_timer_tick_t *tick, unsigned long resolution) 68static inline void snd_seq_timer_update_tick(seq_timer_tick_t *tick, unsigned long resolution)
71{ 69{
diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c
index 6b4e630ace54..a66484b5cf0e 100644
--- a/sound/core/seq/seq_virmidi.c
+++ b/sound/core/seq/seq_virmidi.c
@@ -110,7 +110,7 @@ static int snd_virmidi_dev_receive_event(snd_virmidi_dev_t *rdev, snd_seq_event_
110 * handler of a remote port which is attached to the virmidi via 110 * handler of a remote port which is attached to the virmidi via
111 * SNDRV_VIRMIDI_SEQ_ATTACH. 111 * SNDRV_VIRMIDI_SEQ_ATTACH.
112 */ 112 */
113/* exported */ 113#if 0
114int snd_virmidi_receive(snd_rawmidi_t *rmidi, snd_seq_event_t *ev) 114int snd_virmidi_receive(snd_rawmidi_t *rmidi, snd_seq_event_t *ev)
115{ 115{
116 snd_virmidi_dev_t *rdev; 116 snd_virmidi_dev_t *rdev;
@@ -118,6 +118,7 @@ int snd_virmidi_receive(snd_rawmidi_t *rmidi, snd_seq_event_t *ev)
118 rdev = rmidi->private_data; 118 rdev = rmidi->private_data;
119 return snd_virmidi_dev_receive_event(rdev, ev); 119 return snd_virmidi_dev_receive_event(rdev, ev);
120} 120}
121#endif /* 0 */
121 122
122/* 123/*
123 * event handler of virmidi port 124 * event handler of virmidi port
@@ -384,7 +385,7 @@ static int snd_virmidi_dev_attach_seq(snd_virmidi_dev_t *rdev)
384 info->client = client; 385 info->client = client;
385 info->type = KERNEL_CLIENT; 386 info->type = KERNEL_CLIENT;
386 sprintf(info->name, "%s %d-%d", rdev->rmidi->name, rdev->card->number, rdev->device); 387 sprintf(info->name, "%s %d-%d", rdev->rmidi->name, rdev->card->number, rdev->device);
387 snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, &info); 388 snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, info);
388 389
389 /* create a port */ 390 /* create a port */
390 memset(pinfo, 0, sizeof(*pinfo)); 391 memset(pinfo, 0, sizeof(*pinfo));
@@ -405,7 +406,7 @@ static int snd_virmidi_dev_attach_seq(snd_virmidi_dev_t *rdev)
405 pcallbacks.unuse = snd_virmidi_unuse; 406 pcallbacks.unuse = snd_virmidi_unuse;
406 pcallbacks.event_input = snd_virmidi_event_input; 407 pcallbacks.event_input = snd_virmidi_event_input;
407 pinfo->kernel = &pcallbacks; 408 pinfo->kernel = &pcallbacks;
408 err = snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_CREATE_PORT, &pinfo); 409 err = snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_CREATE_PORT, pinfo);
409 if (err < 0) { 410 if (err < 0) {
410 snd_seq_delete_kernel_client(client); 411 snd_seq_delete_kernel_client(client);
411 rdev->client = -1; 412 rdev->client = -1;
@@ -548,4 +549,3 @@ module_init(alsa_virmidi_init)
548module_exit(alsa_virmidi_exit) 549module_exit(alsa_virmidi_exit)
549 550
550EXPORT_SYMBOL(snd_virmidi_new); 551EXPORT_SYMBOL(snd_virmidi_new);
551EXPORT_SYMBOL(snd_virmidi_receive);
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 33eaa5e5d284..0815fadeb3ec 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -431,7 +431,6 @@ EXPORT_SYMBOL(snd_card_pci_resume);
431EXPORT_SYMBOL(snd_device_new); 431EXPORT_SYMBOL(snd_device_new);
432EXPORT_SYMBOL(snd_device_register); 432EXPORT_SYMBOL(snd_device_register);
433EXPORT_SYMBOL(snd_device_free); 433EXPORT_SYMBOL(snd_device_free);
434EXPORT_SYMBOL(snd_device_free_all);
435 /* isadma.c */ 434 /* isadma.c */
436#ifdef CONFIG_ISA 435#ifdef CONFIG_ISA
437EXPORT_SYMBOL(snd_dma_program); 436EXPORT_SYMBOL(snd_dma_program);
diff --git a/sound/core/timer.c b/sound/core/timer.c
index fa762ca439be..b498e5482d77 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -69,6 +69,7 @@ typedef struct {
69 struct timespec tstamp; /* trigger tstamp */ 69 struct timespec tstamp; /* trigger tstamp */
70 wait_queue_head_t qchange_sleep; 70 wait_queue_head_t qchange_sleep;
71 struct fasync_struct *fasync; 71 struct fasync_struct *fasync;
72 struct semaphore tread_sem;
72} snd_timer_user_t; 73} snd_timer_user_t;
73 74
74/* list of timers */ 75/* list of timers */
@@ -844,7 +845,7 @@ int snd_timer_dev_register(snd_device_t *dev)
844 return 0; 845 return 0;
845} 846}
846 847
847int snd_timer_unregister(snd_timer_t *timer) 848static int snd_timer_unregister(snd_timer_t *timer)
848{ 849{
849 struct list_head *p, *n; 850 struct list_head *p, *n;
850 snd_timer_instance_t *ti; 851 snd_timer_instance_t *ti;
@@ -945,11 +946,6 @@ struct snd_timer_system_private {
945 unsigned long correction; 946 unsigned long correction;
946}; 947};
947 948
948unsigned int snd_timer_system_resolution(void)
949{
950 return 1000000000L / HZ;
951}
952
953static void snd_timer_s_function(unsigned long data) 949static void snd_timer_s_function(unsigned long data)
954{ 950{
955 snd_timer_t *timer = (snd_timer_t *)data; 951 snd_timer_t *timer = (snd_timer_t *)data;
@@ -1208,6 +1204,7 @@ static int snd_timer_user_open(struct inode *inode, struct file *file)
1208 return -ENOMEM; 1204 return -ENOMEM;
1209 spin_lock_init(&tu->qlock); 1205 spin_lock_init(&tu->qlock);
1210 init_waitqueue_head(&tu->qchange_sleep); 1206 init_waitqueue_head(&tu->qchange_sleep);
1207 init_MUTEX(&tu->tread_sem);
1211 tu->ticks = 1; 1208 tu->ticks = 1;
1212 tu->queue_size = 128; 1209 tu->queue_size = 128;
1213 tu->queue = (snd_timer_read_t *)kmalloc(tu->queue_size * sizeof(snd_timer_read_t), GFP_KERNEL); 1210 tu->queue = (snd_timer_read_t *)kmalloc(tu->queue_size * sizeof(snd_timer_read_t), GFP_KERNEL);
@@ -1454,46 +1451,51 @@ static int snd_timer_user_tselect(struct file *file, snd_timer_select_t __user *
1454 snd_timer_user_t *tu; 1451 snd_timer_user_t *tu;
1455 snd_timer_select_t tselect; 1452 snd_timer_select_t tselect;
1456 char str[32]; 1453 char str[32];
1457 int err; 1454 int err = 0;
1458 1455
1459 tu = file->private_data; 1456 tu = file->private_data;
1460 if (tu->timeri) 1457 down(&tu->tread_sem);
1458 if (tu->timeri) {
1461 snd_timer_close(tu->timeri); 1459 snd_timer_close(tu->timeri);
1462 if (copy_from_user(&tselect, _tselect, sizeof(tselect))) 1460 tu->timeri = NULL;
1463 return -EFAULT; 1461 }
1462 if (copy_from_user(&tselect, _tselect, sizeof(tselect))) {
1463 err = -EFAULT;
1464 goto __err;
1465 }
1464 sprintf(str, "application %i", current->pid); 1466 sprintf(str, "application %i", current->pid);
1465 if (tselect.id.dev_class != SNDRV_TIMER_CLASS_SLAVE) 1467 if (tselect.id.dev_class != SNDRV_TIMER_CLASS_SLAVE)
1466 tselect.id.dev_sclass = SNDRV_TIMER_SCLASS_APPLICATION; 1468 tselect.id.dev_sclass = SNDRV_TIMER_SCLASS_APPLICATION;
1467 if ((err = snd_timer_open(&tu->timeri, str, &tselect.id, current->pid)) < 0) 1469 if ((err = snd_timer_open(&tu->timeri, str, &tselect.id, current->pid)) < 0)
1468 return err; 1470 goto __err;
1469 1471
1470 if (tu->queue) { 1472 kfree(tu->queue);
1471 kfree(tu->queue); 1473 tu->queue = NULL;
1472 tu->queue = NULL; 1474 kfree(tu->tqueue);
1473 } 1475 tu->tqueue = NULL;
1474 if (tu->tqueue) {
1475 kfree(tu->tqueue);
1476 tu->tqueue = NULL;
1477 }
1478 if (tu->tread) { 1476 if (tu->tread) {
1479 tu->tqueue = (snd_timer_tread_t *)kmalloc(tu->queue_size * sizeof(snd_timer_tread_t), GFP_KERNEL); 1477 tu->tqueue = (snd_timer_tread_t *)kmalloc(tu->queue_size * sizeof(snd_timer_tread_t), GFP_KERNEL);
1480 if (tu->tqueue == NULL) { 1478 if (tu->tqueue == NULL)
1481 snd_timer_close(tu->timeri); 1479 err = -ENOMEM;
1482 return -ENOMEM;
1483 }
1484 } else { 1480 } else {
1485 tu->queue = (snd_timer_read_t *)kmalloc(tu->queue_size * sizeof(snd_timer_read_t), GFP_KERNEL); 1481 tu->queue = (snd_timer_read_t *)kmalloc(tu->queue_size * sizeof(snd_timer_read_t), GFP_KERNEL);
1486 if (tu->queue == NULL) { 1482 if (tu->queue == NULL)
1487 snd_timer_close(tu->timeri); 1483 err = -ENOMEM;
1488 return -ENOMEM;
1489 }
1490 } 1484 }
1491 1485
1492 tu->timeri->flags |= SNDRV_TIMER_IFLG_FAST; 1486 if (err < 0) {
1493 tu->timeri->callback = tu->tread ? snd_timer_user_tinterrupt : snd_timer_user_interrupt; 1487 snd_timer_close(tu->timeri);
1494 tu->timeri->ccallback = snd_timer_user_ccallback; 1488 tu->timeri = NULL;
1495 tu->timeri->callback_data = (void *)tu; 1489 } else {
1496 return 0; 1490 tu->timeri->flags |= SNDRV_TIMER_IFLG_FAST;
1491 tu->timeri->callback = tu->tread ? snd_timer_user_tinterrupt : snd_timer_user_interrupt;
1492 tu->timeri->ccallback = snd_timer_user_ccallback;
1493 tu->timeri->callback_data = (void *)tu;
1494 }
1495
1496 __err:
1497 up(&tu->tread_sem);
1498 return err;
1497} 1499}
1498 1500
1499static int snd_timer_user_info(struct file *file, snd_timer_info_t __user *_info) 1501static int snd_timer_user_info(struct file *file, snd_timer_info_t __user *_info)
@@ -1669,6 +1671,23 @@ static int snd_timer_user_continue(struct file *file)
1669 return (err = snd_timer_continue(tu->timeri)) < 0 ? err : 0; 1671 return (err = snd_timer_continue(tu->timeri)) < 0 ? err : 0;
1670} 1672}
1671 1673
1674static int snd_timer_user_pause(struct file *file)
1675{
1676 int err;
1677 snd_timer_user_t *tu;
1678
1679 tu = file->private_data;
1680 snd_assert(tu->timeri != NULL, return -ENXIO);
1681 return (err = snd_timer_pause(tu->timeri)) < 0 ? err : 0;
1682}
1683
1684enum {
1685 SNDRV_TIMER_IOCTL_START_OLD = _IO('T', 0x20),
1686 SNDRV_TIMER_IOCTL_STOP_OLD = _IO('T', 0x21),
1687 SNDRV_TIMER_IOCTL_CONTINUE_OLD = _IO('T', 0x22),
1688 SNDRV_TIMER_IOCTL_PAUSE_OLD = _IO('T', 0x23),
1689};
1690
1672static long snd_timer_user_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 1691static long snd_timer_user_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1673{ 1692{
1674 snd_timer_user_t *tu; 1693 snd_timer_user_t *tu;
@@ -1685,11 +1704,17 @@ static long snd_timer_user_ioctl(struct file *file, unsigned int cmd, unsigned l
1685 { 1704 {
1686 int xarg; 1705 int xarg;
1687 1706
1688 if (tu->timeri) /* too late */ 1707 down(&tu->tread_sem);
1708 if (tu->timeri) { /* too late */
1709 up(&tu->tread_sem);
1689 return -EBUSY; 1710 return -EBUSY;
1690 if (get_user(xarg, p)) 1711 }
1712 if (get_user(xarg, p)) {
1713 up(&tu->tread_sem);
1691 return -EFAULT; 1714 return -EFAULT;
1715 }
1692 tu->tread = xarg ? 1 : 0; 1716 tu->tread = xarg ? 1 : 0;
1717 up(&tu->tread_sem);
1693 return 0; 1718 return 0;
1694 } 1719 }
1695 case SNDRV_TIMER_IOCTL_GINFO: 1720 case SNDRV_TIMER_IOCTL_GINFO:
@@ -1707,11 +1732,17 @@ static long snd_timer_user_ioctl(struct file *file, unsigned int cmd, unsigned l
1707 case SNDRV_TIMER_IOCTL_STATUS: 1732 case SNDRV_TIMER_IOCTL_STATUS:
1708 return snd_timer_user_status(file, argp); 1733 return snd_timer_user_status(file, argp);
1709 case SNDRV_TIMER_IOCTL_START: 1734 case SNDRV_TIMER_IOCTL_START:
1735 case SNDRV_TIMER_IOCTL_START_OLD:
1710 return snd_timer_user_start(file); 1736 return snd_timer_user_start(file);
1711 case SNDRV_TIMER_IOCTL_STOP: 1737 case SNDRV_TIMER_IOCTL_STOP:
1738 case SNDRV_TIMER_IOCTL_STOP_OLD:
1712 return snd_timer_user_stop(file); 1739 return snd_timer_user_stop(file);
1713 case SNDRV_TIMER_IOCTL_CONTINUE: 1740 case SNDRV_TIMER_IOCTL_CONTINUE:
1741 case SNDRV_TIMER_IOCTL_CONTINUE_OLD:
1714 return snd_timer_user_continue(file); 1742 return snd_timer_user_continue(file);
1743 case SNDRV_TIMER_IOCTL_PAUSE:
1744 case SNDRV_TIMER_IOCTL_PAUSE_OLD:
1745 return snd_timer_user_pause(file);
1715 } 1746 }
1716 return -ENOTTY; 1747 return -ENOTTY;
1717} 1748}
@@ -1898,4 +1929,3 @@ EXPORT_SYMBOL(snd_timer_global_free);
1898EXPORT_SYMBOL(snd_timer_global_register); 1929EXPORT_SYMBOL(snd_timer_global_register);
1899EXPORT_SYMBOL(snd_timer_global_unregister); 1930EXPORT_SYMBOL(snd_timer_global_unregister);
1900EXPORT_SYMBOL(snd_timer_interrupt); 1931EXPORT_SYMBOL(snd_timer_interrupt);
1901EXPORT_SYMBOL(snd_timer_system_resolution);
diff --git a/sound/core/timer_compat.c b/sound/core/timer_compat.c
index 9fbc3957a22d..3de552dfe80f 100644
--- a/sound/core/timer_compat.c
+++ b/sound/core/timer_compat.c
@@ -106,8 +106,13 @@ static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, uns
106 case SNDRV_TIMER_IOCTL_SELECT: 106 case SNDRV_TIMER_IOCTL_SELECT:
107 case SNDRV_TIMER_IOCTL_PARAMS: 107 case SNDRV_TIMER_IOCTL_PARAMS:
108 case SNDRV_TIMER_IOCTL_START: 108 case SNDRV_TIMER_IOCTL_START:
109 case SNDRV_TIMER_IOCTL_START_OLD:
109 case SNDRV_TIMER_IOCTL_STOP: 110 case SNDRV_TIMER_IOCTL_STOP:
111 case SNDRV_TIMER_IOCTL_STOP_OLD:
110 case SNDRV_TIMER_IOCTL_CONTINUE: 112 case SNDRV_TIMER_IOCTL_CONTINUE:
113 case SNDRV_TIMER_IOCTL_CONTINUE_OLD:
114 case SNDRV_TIMER_IOCTL_PAUSE:
115 case SNDRV_TIMER_IOCTL_PAUSE_OLD:
111 case SNDRV_TIMER_IOCTL_NEXT_DEVICE: 116 case SNDRV_TIMER_IOCTL_NEXT_DEVICE:
112 return snd_timer_user_ioctl(file, cmd, (unsigned long)argp); 117 return snd_timer_user_ioctl(file, cmd, (unsigned long)argp);
113 case SNDRV_TIMER_IOCTL_INFO32: 118 case SNDRV_TIMER_IOCTL_INFO32:
diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c
index 98587176b327..af381b15fe5c 100644
--- a/sound/drivers/vx/vx_pcm.c
+++ b/sound/drivers/vx/vx_pcm.c
@@ -1264,14 +1264,10 @@ static void snd_vx_pcm_free(snd_pcm_t *pcm)
1264{ 1264{
1265 vx_core_t *chip = pcm->private_data; 1265 vx_core_t *chip = pcm->private_data;
1266 chip->pcm[pcm->device] = NULL; 1266 chip->pcm[pcm->device] = NULL;
1267 if (chip->playback_pipes) { 1267 kfree(chip->playback_pipes);
1268 kfree(chip->playback_pipes); 1268 chip->playback_pipes = NULL;
1269 chip->playback_pipes = NULL; 1269 kfree(chip->capture_pipes);
1270 } 1270 chip->capture_pipes = NULL;
1271 if (chip->capture_pipes) {
1272 kfree(chip->capture_pipes);
1273 chip->capture_pipes = NULL;
1274 }
1275} 1271}
1276 1272
1277/* 1273/*
diff --git a/sound/i2c/tea6330t.c b/sound/i2c/tea6330t.c
index bb503e70b664..2da8d7f157f4 100644
--- a/sound/i2c/tea6330t.c
+++ b/sound/i2c/tea6330t.c
@@ -266,8 +266,7 @@ TEA6330T_TREBLE("Tone Control - Treble", 0)
266 266
267static void snd_tea6330_free(snd_i2c_device_t *device) 267static void snd_tea6330_free(snd_i2c_device_t *device)
268{ 268{
269 tea6330t_t *tea = device->private_data; 269 kfree(device->private_data);
270 kfree(tea);
271} 270}
272 271
273int snd_tea6330t_update_mixer(snd_card_t * card, 272int snd_tea6330t_update_mixer(snd_card_t * card,
diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig
index 3a3228b18726..148a856a43ad 100644
--- a/sound/isa/Kconfig
+++ b/sound/isa/Kconfig
@@ -179,6 +179,7 @@ config SND_INTERWAVE_STB
179 select SND_RAWMIDI 179 select SND_RAWMIDI
180 select SND_CS4231_LIB 180 select SND_CS4231_LIB
181 select SND_GUS_SYNTH 181 select SND_GUS_SYNTH
182 select ISAPNP
182 help 183 help
183 Say Y here to include support for AMD InterWave based 184 Say Y here to include support for AMD InterWave based
184 soundcards with a TEA6330T bass and treble regulator 185 soundcards with a TEA6330T bass and treble regulator
diff --git a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c
index 9fa7a78da6c3..563296d02894 100644
--- a/sound/isa/ad1816a/ad1816a.c
+++ b/sound/isa/ad1816a/ad1816a.c
@@ -83,6 +83,8 @@ struct snd_card_ad1816a {
83static struct pnp_card_device_id snd_ad1816a_pnpids[] = { 83static struct pnp_card_device_id snd_ad1816a_pnpids[] = {
84 /* Analog Devices AD1815 */ 84 /* Analog Devices AD1815 */
85 { .id = "ADS7150", .devs = { { .id = "ADS7150" }, { .id = "ADS7151" } } }, 85 { .id = "ADS7150", .devs = { { .id = "ADS7150" }, { .id = "ADS7151" } } },
86 /* Analog Device AD1816? */
87 { .id = "ADS7180", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } },
86 /* Analog Devices AD1816A - added by Kenneth Platz <kxp@atl.hp.com> */ 88 /* Analog Devices AD1816A - added by Kenneth Platz <kxp@atl.hp.com> */
87 { .id = "ADS7181", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } }, 89 { .id = "ADS7181", .devs = { { .id = "ADS7180" }, { .id = "ADS7181" } } },
88 /* Analog Devices AD1816A - Aztech/Newcom SC-16 3D */ 90 /* Analog Devices AD1816A - Aztech/Newcom SC-16 3D */
diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
index e745a54e00a1..39f4eff44f5c 100644
--- a/sound/isa/cs423x/cs4236.c
+++ b/sound/isa/cs423x/cs4236.c
@@ -349,8 +349,7 @@ static int __devinit snd_card_cs4236_pnp(int dev, struct snd_card_cs4236 *acard,
349 pnp_init_resource_table(cfg); 349 pnp_init_resource_table(cfg);
350 if (mpu_port[dev] != SNDRV_AUTO_PORT) 350 if (mpu_port[dev] != SNDRV_AUTO_PORT)
351 pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2); 351 pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2);
352 if (mpu_irq[dev] != SNDRV_AUTO_IRQ && mpu_irq[dev] >= 0 && 352 if (mpu_irq[dev] != SNDRV_AUTO_IRQ && mpu_irq[dev] >= 0)
353 pnp_irq_valid(pdev, 0))
354 pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1); 353 pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1);
355 err = pnp_manual_config_dev(pdev, cfg, 0); 354 err = pnp_manual_config_dev(pdev, cfg, 0);
356 if (err < 0) 355 if (err < 0)
diff --git a/sound/isa/gus/gus_io.c b/sound/isa/gus/gus_io.c
index f0570f2bf75f..337b0e2a8a36 100644
--- a/sound/isa/gus/gus_io.c
+++ b/sound/isa/gus/gus_io.c
@@ -244,6 +244,8 @@ unsigned short snd_gf1_i_look16(snd_gus_card_t * gus, unsigned char reg)
244 return res; 244 return res;
245} 245}
246 246
247#if 0
248
247void snd_gf1_i_adlib_write(snd_gus_card_t * gus, 249void snd_gf1_i_adlib_write(snd_gus_card_t * gus,
248 unsigned char reg, 250 unsigned char reg,
249 unsigned char data) 251 unsigned char data)
@@ -265,6 +267,8 @@ void snd_gf1_i_write_addr(snd_gus_card_t * gus, unsigned char reg,
265 spin_unlock_irqrestore(&gus->reg_lock, flags); 267 spin_unlock_irqrestore(&gus->reg_lock, flags);
266} 268}
267 269
270#endif /* 0 */
271
268unsigned int snd_gf1_i_read_addr(snd_gus_card_t * gus, 272unsigned int snd_gf1_i_read_addr(snd_gus_card_t * gus,
269 unsigned char reg, short w_16bit) 273 unsigned char reg, short w_16bit)
270{ 274{
@@ -329,6 +333,8 @@ unsigned char snd_gf1_peek(snd_gus_card_t * gus, unsigned int addr)
329 return res; 333 return res;
330} 334}
331 335
336#if 0
337
332void snd_gf1_pokew(snd_gus_card_t * gus, unsigned int addr, unsigned short data) 338void snd_gf1_pokew(snd_gus_card_t * gus, unsigned int addr, unsigned short data)
333{ 339{
334 unsigned long flags; 340 unsigned long flags;
@@ -405,9 +411,7 @@ void snd_gf1_dram_setmem(snd_gus_card_t * gus, unsigned int addr,
405 spin_unlock_irqrestore(&gus->reg_lock, flags); 411 spin_unlock_irqrestore(&gus->reg_lock, flags);
406} 412}
407 413
408/* 414#endif /* 0 */
409
410 */
411 415
412void snd_gf1_select_active_voices(snd_gus_card_t * gus) 416void snd_gf1_select_active_voices(snd_gus_card_t * gus)
413{ 417{
@@ -469,6 +473,8 @@ void snd_gf1_print_voice_registers(snd_gus_card_t * gus)
469 printk(" -%i- GF1 pan = 0x%x\n", voice, snd_gf1_i_read8(gus, 0x0c)); 473 printk(" -%i- GF1 pan = 0x%x\n", voice, snd_gf1_i_read8(gus, 0x0c));
470} 474}
471 475
476#if 0
477
472void snd_gf1_print_global_registers(snd_gus_card_t * gus) 478void snd_gf1_print_global_registers(snd_gus_card_t * gus)
473{ 479{
474 unsigned char global_mode = 0x00; 480 unsigned char global_mode = 0x00;
@@ -528,4 +534,6 @@ void snd_gf1_peek_print_block(snd_gus_card_t * gus, unsigned int addr, int count
528 } 534 }
529} 535}
530 536
537#endif /* 0 */
538
531#endif 539#endif
diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c
index 73f81c14f768..94bbd344be5e 100644
--- a/sound/isa/gus/gus_main.c
+++ b/sound/isa/gus/gus_main.c
@@ -459,7 +459,6 @@ EXPORT_SYMBOL(snd_gf1_write16);
459EXPORT_SYMBOL(snd_gf1_look16); 459EXPORT_SYMBOL(snd_gf1_look16);
460EXPORT_SYMBOL(snd_gf1_i_write8); 460EXPORT_SYMBOL(snd_gf1_i_write8);
461EXPORT_SYMBOL(snd_gf1_i_look8); 461EXPORT_SYMBOL(snd_gf1_i_look8);
462EXPORT_SYMBOL(snd_gf1_i_write16);
463EXPORT_SYMBOL(snd_gf1_i_look16); 462EXPORT_SYMBOL(snd_gf1_i_look16);
464EXPORT_SYMBOL(snd_gf1_dram_addr); 463EXPORT_SYMBOL(snd_gf1_dram_addr);
465EXPORT_SYMBOL(snd_gf1_write_addr); 464EXPORT_SYMBOL(snd_gf1_write_addr);
@@ -470,8 +469,6 @@ EXPORT_SYMBOL(snd_gf1_alloc_voice);
470EXPORT_SYMBOL(snd_gf1_free_voice); 469EXPORT_SYMBOL(snd_gf1_free_voice);
471EXPORT_SYMBOL(snd_gf1_ctrl_stop); 470EXPORT_SYMBOL(snd_gf1_ctrl_stop);
472EXPORT_SYMBOL(snd_gf1_stop_voice); 471EXPORT_SYMBOL(snd_gf1_stop_voice);
473EXPORT_SYMBOL(snd_gf1_start);
474EXPORT_SYMBOL(snd_gf1_stop);
475 /* gus_mixer.c */ 472 /* gus_mixer.c */
476EXPORT_SYMBOL(snd_gf1_new_mixer); 473EXPORT_SYMBOL(snd_gf1_new_mixer);
477 /* gus_pcm.c */ 474 /* gus_pcm.c */
diff --git a/sound/isa/gus/gus_mem.c b/sound/isa/gus/gus_mem.c
index bfc2b91001d5..609838e8ef67 100644
--- a/sound/isa/gus/gus_mem.c
+++ b/sound/isa/gus/gus_mem.c
@@ -39,8 +39,8 @@ void snd_gf1_mem_lock(snd_gf1_mem_t * alloc, int xup)
39 } 39 }
40} 40}
41 41
42snd_gf1_mem_block_t *snd_gf1_mem_xalloc(snd_gf1_mem_t * alloc, 42static snd_gf1_mem_block_t *snd_gf1_mem_xalloc(snd_gf1_mem_t * alloc,
43 snd_gf1_mem_block_t * block) 43 snd_gf1_mem_block_t * block)
44{ 44{
45 snd_gf1_mem_block_t *pblock, *nblock; 45 snd_gf1_mem_block_t *pblock, *nblock;
46 46
@@ -105,8 +105,8 @@ int snd_gf1_mem_xfree(snd_gf1_mem_t * alloc, snd_gf1_mem_block_t * block)
105 return 0; 105 return 0;
106} 106}
107 107
108snd_gf1_mem_block_t *snd_gf1_mem_look(snd_gf1_mem_t * alloc, 108static snd_gf1_mem_block_t *snd_gf1_mem_look(snd_gf1_mem_t * alloc,
109 unsigned int address) 109 unsigned int address)
110{ 110{
111 snd_gf1_mem_block_t *block; 111 snd_gf1_mem_block_t *block;
112 112
@@ -118,8 +118,8 @@ snd_gf1_mem_block_t *snd_gf1_mem_look(snd_gf1_mem_t * alloc,
118 return NULL; 118 return NULL;
119} 119}
120 120
121snd_gf1_mem_block_t *snd_gf1_mem_share(snd_gf1_mem_t * alloc, 121static snd_gf1_mem_block_t *snd_gf1_mem_share(snd_gf1_mem_t * alloc,
122 unsigned int *share_id) 122 unsigned int *share_id)
123{ 123{
124 snd_gf1_mem_block_t *block; 124 snd_gf1_mem_block_t *block;
125 125
diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c
index 8995ad9c516d..b75066ab46fc 100644
--- a/sound/isa/gus/gus_pcm.c
+++ b/sound/isa/gus/gus_pcm.c
@@ -656,8 +656,7 @@ static snd_pcm_hardware_t snd_gf1_pcm_capture =
656 656
657static void snd_gf1_pcm_playback_free(snd_pcm_runtime_t *runtime) 657static void snd_gf1_pcm_playback_free(snd_pcm_runtime_t *runtime)
658{ 658{
659 gus_pcm_private_t * pcmp = runtime->private_data; 659 kfree(runtime->private_data);
660 kfree(pcmp);
661} 660}
662 661
663static int snd_gf1_pcm_playback_open(snd_pcm_substream_t *substream) 662static int snd_gf1_pcm_playback_open(snd_pcm_substream_t *substream)
diff --git a/sound/isa/gus/gus_reset.c b/sound/isa/gus/gus_reset.c
index b4e66f6a10ae..ef687abc7070 100644
--- a/sound/isa/gus/gus_reset.c
+++ b/sound/isa/gus/gus_reset.c
@@ -161,7 +161,8 @@ void snd_gf1_stop_voice(snd_gus_card_t * gus, unsigned short voice)
161#endif 161#endif
162} 162}
163 163
164void snd_gf1_clear_voices(snd_gus_card_t * gus, unsigned short v_min, unsigned short v_max) 164static void snd_gf1_clear_voices(snd_gus_card_t * gus, unsigned short v_min,
165 unsigned short v_max)
165{ 166{
166 unsigned long flags; 167 unsigned long flags;
167 unsigned int daddr; 168 unsigned int daddr;
diff --git a/sound/isa/gus/gus_synth.c b/sound/isa/gus/gus_synth.c
index 66552e6013a4..f51c386ee192 100644
--- a/sound/isa/gus/gus_synth.c
+++ b/sound/isa/gus/gus_synth.c
@@ -99,7 +99,8 @@ static void snd_gus_synth_free_private_instruments(snd_gus_port_t *p, int client
99 snd_seq_instr_list_free_cond(p->gus->gf1.ilist, &ifree, client, 0); 99 snd_seq_instr_list_free_cond(p->gus->gf1.ilist, &ifree, client, 0);
100} 100}
101 101
102int snd_gus_synth_event_input(snd_seq_event_t *ev, int direct, void *private_data, int atomic, int hop) 102static int snd_gus_synth_event_input(snd_seq_event_t *ev, int direct,
103 void *private_data, int atomic, int hop)
103{ 104{
104 snd_gus_port_t * p = (snd_gus_port_t *) private_data; 105 snd_gus_port_t * p = (snd_gus_port_t *) private_data;
105 106
diff --git a/sound/isa/gus/gus_tables.h b/sound/isa/gus/gus_tables.h
index ed8e9d85ad31..4adf098d3269 100644
--- a/sound/isa/gus/gus_tables.h
+++ b/sound/isa/gus/gus_tables.h
@@ -23,6 +23,8 @@
23 23
24#ifdef __GUS_TABLES_ALLOC__ 24#ifdef __GUS_TABLES_ALLOC__
25 25
26#if 0
27
26unsigned int snd_gf1_scale_table[SNDRV_GF1_SCALE_TABLE_SIZE] = 28unsigned int snd_gf1_scale_table[SNDRV_GF1_SCALE_TABLE_SIZE] =
27{ 29{
28 8372, 8870, 9397, 9956, 10548, 11175, 30 8372, 8870, 9397, 9956, 10548, 11175,
@@ -49,6 +51,8 @@ unsigned int snd_gf1_scale_table[SNDRV_GF1_SCALE_TABLE_SIZE] =
49 12123977, 12844906 51 12123977, 12844906
50}; 52};
51 53
54#endif /* 0 */
55
52unsigned short snd_gf1_atten_table[SNDRV_GF1_ATTEN_TABLE_SIZE] = { 56unsigned short snd_gf1_atten_table[SNDRV_GF1_ATTEN_TABLE_SIZE] = {
53 4095 /* 0 */,1789 /* 1 */,1533 /* 2 */,1383 /* 3 */,1277 /* 4 */, 57 4095 /* 0 */,1789 /* 1 */,1533 /* 2 */,1383 /* 3 */,1277 /* 4 */,
54 1195 /* 5 */,1127 /* 6 */,1070 /* 7 */,1021 /* 8 */,978 /* 9 */, 58 1195 /* 5 */,1127 /* 6 */,1070 /* 7 */,1021 /* 8 */,978 /* 9 */,
diff --git a/sound/isa/gus/gus_volume.c b/sound/isa/gus/gus_volume.c
index b72bcfb28617..3d36f6c8ee6a 100644
--- a/sound/isa/gus/gus_volume.c
+++ b/sound/isa/gus/gus_volume.c
@@ -55,6 +55,8 @@ unsigned short snd_gf1_lvol_to_gvol_raw(unsigned int vol)
55 return (e << 8) | m; 55 return (e << 8) | m;
56} 56}
57 57
58#if 0
59
58unsigned int snd_gf1_gvol_to_lvol_raw(unsigned short gf1_vol) 60unsigned int snd_gf1_gvol_to_lvol_raw(unsigned short gf1_vol)
59{ 61{
60 unsigned int rvol; 62 unsigned int rvol;
@@ -108,6 +110,8 @@ unsigned int snd_gf1_calc_ramp_rate(snd_gus_card_t * gus,
108 return (range << 6) | (increment & 0x3f); 110 return (range << 6) | (increment & 0x3f);
109} 111}
110 112
113#endif /* 0 */
114
111unsigned short snd_gf1_translate_freq(snd_gus_card_t * gus, unsigned int freq16) 115unsigned short snd_gf1_translate_freq(snd_gus_card_t * gus, unsigned int freq16)
112{ 116{
113 freq16 >>= 3; 117 freq16 >>= 3;
@@ -120,6 +124,8 @@ unsigned short snd_gf1_translate_freq(snd_gus_card_t * gus, unsigned int freq16)
120 return ((freq16 << 9) + (gus->gf1.playback_freq >> 1)) / gus->gf1.playback_freq; 124 return ((freq16 << 9) + (gus->gf1.playback_freq >> 1)) / gus->gf1.playback_freq;
121} 125}
122 126
127#if 0
128
123short snd_gf1_compute_vibrato(short cents, unsigned short fc_register) 129short snd_gf1_compute_vibrato(short cents, unsigned short fc_register)
124{ 130{
125 static short vibrato_table[] = 131 static short vibrato_table[] =
@@ -208,3 +214,5 @@ unsigned short snd_gf1_compute_freq(unsigned int freq,
208 } 214 }
209 return (unsigned short) fc; 215 return (unsigned short) fc;
210} 216}
217
218#endif /* 0 */
diff --git a/sound/oss/rme96xx.c b/sound/oss/rme96xx.c
index 76774bbc1436..b4278eecc917 100644
--- a/sound/oss/rme96xx.c
+++ b/sound/oss/rme96xx.c
@@ -807,7 +807,7 @@ static void* busmaster_malloc(int size) {
807 struct page* page, *last_page; 807 struct page* page, *last_page;
808 808
809 page = virt_to_page(buf); 809 page = virt_to_page(buf);
810 last_page = virt_to_page(buf + (1 << pg)); 810 last_page = page + (1 << pg);
811 DBG(printk("setting reserved bit\n")); 811 DBG(printk("setting reserved bit\n"));
812 while (page < last_page) { 812 while (page < last_page) {
813 SetPageReserved(page); 813 SetPageReserved(page);
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index 428efdbd70a1..6d7a00f34d82 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -274,6 +274,19 @@ config SND_HDSP
274 To compile this driver as a module, choose M here: the module 274 To compile this driver as a module, choose M here: the module
275 will be called snd-hdsp. 275 will be called snd-hdsp.
276 276
277config SND_HDSPM
278 tristate "RME Hammerfall DSP MADI"
279 depends on SND
280 select SND_HWDEP
281 select SND_RAWMIDI
282 select SND_PCM
283 help
284 Say Y here to include support for RME Hammerfall DSP MADI
285 soundcards.
286
287 To compile this driver as a module, choose M here: the module
288 will be called snd-hdspm.
289
277config SND_TRIDENT 290config SND_TRIDENT
278 tristate "Trident 4D-Wave DX/NX; SiS 7018" 291 tristate "Trident 4D-Wave DX/NX; SiS 7018"
279 depends on SND 292 depends on SND
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index 0b024ec1f709..a4b72cd2eea0 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -120,6 +120,7 @@ static const ac97_codec_id_t snd_ac97_codec_ids[] = {
120{ 0x414c4770, 0xfffffff0, "ALC203", NULL, NULL }, 120{ 0x414c4770, 0xfffffff0, "ALC203", NULL, NULL },
121{ 0x434d4941, 0xffffffff, "CMI9738", patch_cm9738, NULL }, 121{ 0x434d4941, 0xffffffff, "CMI9738", patch_cm9738, NULL },
122{ 0x434d4961, 0xffffffff, "CMI9739", patch_cm9739, NULL }, 122{ 0x434d4961, 0xffffffff, "CMI9739", patch_cm9739, NULL },
123{ 0x434d4969, 0xffffffff, "CMI9780", patch_cm9780, NULL },
123{ 0x434d4978, 0xffffffff, "CMI9761", patch_cm9761, NULL }, 124{ 0x434d4978, 0xffffffff, "CMI9761", patch_cm9761, NULL },
124{ 0x434d4982, 0xffffffff, "CMI9761", patch_cm9761, NULL }, 125{ 0x434d4982, 0xffffffff, "CMI9761", patch_cm9761, NULL },
125{ 0x434d4983, 0xffffffff, "CMI9761", patch_cm9761, NULL }, 126{ 0x434d4983, 0xffffffff, "CMI9761", patch_cm9761, NULL },
@@ -149,7 +150,7 @@ static const ac97_codec_id_t snd_ac97_codec_ids[] = {
149{ 0x4e534331, 0xffffffff, "LM4549", NULL, NULL }, 150{ 0x4e534331, 0xffffffff, "LM4549", NULL, NULL },
150{ 0x4e534350, 0xffffffff, "LM4550", NULL, NULL }, 151{ 0x4e534350, 0xffffffff, "LM4550", NULL, NULL },
151{ 0x50534304, 0xffffffff, "UCB1400", NULL, NULL }, 152{ 0x50534304, 0xffffffff, "UCB1400", NULL, NULL },
152{ 0x53494c20, 0xffffffe0, "Si3036,8", NULL, mpatch_si3036 }, 153{ 0x53494c20, 0xffffffe0, "Si3036,8", mpatch_si3036, mpatch_si3036, AC97_MODEM_PATCH },
153{ 0x54524102, 0xffffffff, "TR28022", NULL, NULL }, 154{ 0x54524102, 0xffffffff, "TR28022", NULL, NULL },
154{ 0x54524106, 0xffffffff, "TR28026", NULL, NULL }, 155{ 0x54524106, 0xffffffff, "TR28026", NULL, NULL },
155{ 0x54524108, 0xffffffff, "TR28028", patch_tritech_tr28028, NULL }, // added by xin jin [07/09/99] 156{ 0x54524108, 0xffffffff, "TR28028", patch_tritech_tr28028, NULL }, // added by xin jin [07/09/99]
@@ -462,12 +463,14 @@ int snd_ac97_get_enum_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * u
462{ 463{
463 ac97_t *ac97 = snd_kcontrol_chip(kcontrol); 464 ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
464 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; 465 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value;
465 unsigned short val; 466 unsigned short val, bitmask;
466 467
468 for (bitmask = 1; bitmask < e->mask; bitmask <<= 1)
469 ;
467 val = snd_ac97_read_cache(ac97, e->reg); 470 val = snd_ac97_read_cache(ac97, e->reg);
468 ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & (e->mask - 1); 471 ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & (bitmask - 1);
469 if (e->shift_l != e->shift_r) 472 if (e->shift_l != e->shift_r)
470 ucontrol->value.enumerated.item[1] = (val >> e->shift_r) & (e->mask - 1); 473 ucontrol->value.enumerated.item[1] = (val >> e->shift_r) & (bitmask - 1);
471 474
472 return 0; 475 return 0;
473} 476}
@@ -477,17 +480,19 @@ int snd_ac97_put_enum_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * u
477 ac97_t *ac97 = snd_kcontrol_chip(kcontrol); 480 ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
478 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; 481 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value;
479 unsigned short val; 482 unsigned short val;
480 unsigned short mask; 483 unsigned short mask, bitmask;
481 484
485 for (bitmask = 1; bitmask < e->mask; bitmask <<= 1)
486 ;
482 if (ucontrol->value.enumerated.item[0] > e->mask - 1) 487 if (ucontrol->value.enumerated.item[0] > e->mask - 1)
483 return -EINVAL; 488 return -EINVAL;
484 val = ucontrol->value.enumerated.item[0] << e->shift_l; 489 val = ucontrol->value.enumerated.item[0] << e->shift_l;
485 mask = (e->mask - 1) << e->shift_l; 490 mask = (bitmask - 1) << e->shift_l;
486 if (e->shift_l != e->shift_r) { 491 if (e->shift_l != e->shift_r) {
487 if (ucontrol->value.enumerated.item[1] > e->mask - 1) 492 if (ucontrol->value.enumerated.item[1] > e->mask - 1)
488 return -EINVAL; 493 return -EINVAL;
489 val |= ucontrol->value.enumerated.item[1] << e->shift_r; 494 val |= ucontrol->value.enumerated.item[1] << e->shift_r;
490 mask |= (e->mask - 1) << e->shift_r; 495 mask |= (bitmask - 1) << e->shift_r;
491 } 496 }
492 return snd_ac97_update_bits(ac97, e->reg, mask, val); 497 return snd_ac97_update_bits(ac97, e->reg, mask, val);
493} 498}
@@ -658,14 +663,14 @@ AC97_SINGLE("LFE Playback Switch", AC97_CENTER_LFE_MASTER, 15, 1, 1),
658AC97_SINGLE("LFE Playback Volume", AC97_CENTER_LFE_MASTER, 8, 31, 1) 663AC97_SINGLE("LFE Playback Volume", AC97_CENTER_LFE_MASTER, 8, 31, 1)
659}; 664};
660 665
661static const snd_kcontrol_new_t snd_ac97_controls_surround[2] = {
662AC97_DOUBLE("Surround Playback Switch", AC97_SURROUND_MASTER, 15, 7, 1, 1),
663AC97_DOUBLE("Surround Playback Volume", AC97_SURROUND_MASTER, 8, 0, 31, 1),
664};
665
666static const snd_kcontrol_new_t snd_ac97_control_eapd = 666static const snd_kcontrol_new_t snd_ac97_control_eapd =
667AC97_SINGLE("External Amplifier", AC97_POWERDOWN, 15, 1, 1); 667AC97_SINGLE("External Amplifier", AC97_POWERDOWN, 15, 1, 1);
668 668
669static const snd_kcontrol_new_t snd_ac97_controls_modem_switches[2] = {
670AC97_SINGLE("Off-hook Switch", AC97_GPIO_STATUS, 0, 1, 0),
671AC97_SINGLE("Caller ID Switch", AC97_GPIO_STATUS, 2, 1, 0)
672};
673
669/* change the existing EAPD control as inverted */ 674/* change the existing EAPD control as inverted */
670static void set_inv_eapd(ac97_t *ac97, snd_kcontrol_t *kctl) 675static void set_inv_eapd(ac97_t *ac97, snd_kcontrol_t *kctl)
671{ 676{
@@ -1072,9 +1077,9 @@ static void check_volume_resolution(ac97_t *ac97, int reg, unsigned char *lo_max
1072 unsigned short val; 1077 unsigned short val;
1073 snd_ac97_write(ac97, reg, 0x8080 | cbit[i] | (cbit[i] << 8)); 1078 snd_ac97_write(ac97, reg, 0x8080 | cbit[i] | (cbit[i] << 8));
1074 val = snd_ac97_read(ac97, reg); 1079 val = snd_ac97_read(ac97, reg);
1075 if (! *lo_max && (val & cbit[i])) 1080 if (! *lo_max && (val & 0x7f) == cbit[i])
1076 *lo_max = max[i]; 1081 *lo_max = max[i];
1077 if (! *hi_max && (val & (cbit[i] << 8))) 1082 if (! *hi_max && ((val >> 8) & 0x7f) == cbit[i])
1078 *hi_max = max[i]; 1083 *hi_max = max[i];
1079 if (*lo_max && *hi_max) 1084 if (*lo_max && *hi_max)
1080 break; 1085 break;
@@ -1526,13 +1531,25 @@ static int snd_ac97_mixer_build(ac97_t * ac97)
1526 1531
1527static int snd_ac97_modem_build(snd_card_t * card, ac97_t * ac97) 1532static int snd_ac97_modem_build(snd_card_t * card, ac97_t * ac97)
1528{ 1533{
1529 /* TODO */ 1534 int err, idx;
1535
1530 //printk("AC97_GPIO_CFG = %x\n",snd_ac97_read(ac97,AC97_GPIO_CFG)); 1536 //printk("AC97_GPIO_CFG = %x\n",snd_ac97_read(ac97,AC97_GPIO_CFG));
1531 snd_ac97_write(ac97, AC97_GPIO_CFG, 0xffff & ~(AC97_GPIO_LINE1_OH)); 1537 snd_ac97_write(ac97, AC97_GPIO_CFG, 0xffff & ~(AC97_GPIO_LINE1_OH));
1532 snd_ac97_write(ac97, AC97_GPIO_POLARITY, 0xffff & ~(AC97_GPIO_LINE1_OH)); 1538 snd_ac97_write(ac97, AC97_GPIO_POLARITY, 0xffff & ~(AC97_GPIO_LINE1_OH));
1533 snd_ac97_write(ac97, AC97_GPIO_STICKY, 0xffff); 1539 snd_ac97_write(ac97, AC97_GPIO_STICKY, 0xffff);
1534 snd_ac97_write(ac97, AC97_GPIO_WAKEUP, 0x0); 1540 snd_ac97_write(ac97, AC97_GPIO_WAKEUP, 0x0);
1535 snd_ac97_write(ac97, AC97_MISC_AFE, 0x0); 1541 snd_ac97_write(ac97, AC97_MISC_AFE, 0x0);
1542
1543 /* build modem switches */
1544 for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_modem_switches); idx++)
1545 if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_modem_switches[idx], ac97))) < 0)
1546 return err;
1547
1548 /* build chip specific controls */
1549 if (ac97->build_ops->build_specific)
1550 if ((err = ac97->build_ops->build_specific(ac97)) < 0)
1551 return err;
1552
1536 return 0; 1553 return 0;
1537} 1554}
1538 1555
@@ -1872,7 +1889,11 @@ int snd_ac97_mixer(ac97_bus_t *bus, ac97_template_t *template, ac97_t **rac97)
1872 goto __access_ok; 1889 goto __access_ok;
1873 } 1890 }
1874 1891
1875 snd_ac97_write(ac97, AC97_RESET, 0); /* reset to defaults */ 1892 /* reset to defaults */
1893 if (!(ac97->scaps & AC97_SCAP_SKIP_AUDIO))
1894 snd_ac97_write(ac97, AC97_RESET, 0);
1895 if (!(ac97->scaps & AC97_SCAP_SKIP_MODEM))
1896 snd_ac97_write(ac97, AC97_EXTENDED_MID, 0);
1876 if (bus->ops->wait) 1897 if (bus->ops->wait)
1877 bus->ops->wait(ac97); 1898 bus->ops->wait(ac97);
1878 else { 1899 else {
@@ -1964,21 +1985,21 @@ int snd_ac97_mixer(ac97_bus_t *bus, ac97_template_t *template, ac97_t **rac97)
1964 /* note: it's important to set the rate at first */ 1985 /* note: it's important to set the rate at first */
1965 tmp = AC97_MEA_GPIO; 1986 tmp = AC97_MEA_GPIO;
1966 if (ac97->ext_mid & AC97_MEI_LINE1) { 1987 if (ac97->ext_mid & AC97_MEI_LINE1) {
1967 snd_ac97_write_cache(ac97, AC97_LINE1_RATE, 12000); 1988 snd_ac97_write_cache(ac97, AC97_LINE1_RATE, 8000);
1968 tmp |= AC97_MEA_ADC1 | AC97_MEA_DAC1; 1989 tmp |= AC97_MEA_ADC1 | AC97_MEA_DAC1;
1969 } 1990 }
1970 if (ac97->ext_mid & AC97_MEI_LINE2) { 1991 if (ac97->ext_mid & AC97_MEI_LINE2) {
1971 snd_ac97_write_cache(ac97, AC97_LINE2_RATE, 12000); 1992 snd_ac97_write_cache(ac97, AC97_LINE2_RATE, 8000);
1972 tmp |= AC97_MEA_ADC2 | AC97_MEA_DAC2; 1993 tmp |= AC97_MEA_ADC2 | AC97_MEA_DAC2;
1973 } 1994 }
1974 if (ac97->ext_mid & AC97_MEI_HANDSET) { 1995 if (ac97->ext_mid & AC97_MEI_HANDSET) {
1975 snd_ac97_write_cache(ac97, AC97_HANDSET_RATE, 12000); 1996 snd_ac97_write_cache(ac97, AC97_HANDSET_RATE, 8000);
1976 tmp |= AC97_MEA_HADC | AC97_MEA_HDAC; 1997 tmp |= AC97_MEA_HADC | AC97_MEA_HDAC;
1977 } 1998 }
1978 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0xff00 & ~(tmp << 8)); 1999 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0);
1979 udelay(100); 2000 udelay(100);
1980 /* nothing should be in powerdown mode */ 2001 /* nothing should be in powerdown mode */
1981 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0xff00 & ~(tmp << 8)); 2002 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0);
1982 end_time = jiffies + (HZ / 10); 2003 end_time = jiffies + (HZ / 10);
1983 do { 2004 do {
1984 if ((snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS) & tmp) == tmp) 2005 if ((snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS) & tmp) == tmp)
@@ -2521,11 +2542,11 @@ int snd_ac97_tune_hardware(ac97_t *ac97, struct ac97_quirk *quirk, const char *o
2521 return result; 2542 return result;
2522 } 2543 }
2523 2544
2524 for (; quirk->vendor; quirk++) { 2545 for (; quirk->subvendor; quirk++) {
2525 if (quirk->vendor != ac97->subsystem_vendor) 2546 if (quirk->subvendor != ac97->subsystem_vendor)
2526 continue; 2547 continue;
2527 if ((! quirk->mask && quirk->device == ac97->subsystem_device) || 2548 if ((! quirk->mask && quirk->subdevice == ac97->subsystem_device) ||
2528 quirk->device == (quirk->mask & ac97->subsystem_device)) { 2549 quirk->subdevice == (quirk->mask & ac97->subsystem_device)) {
2529 if (quirk->codec_id && quirk->codec_id != ac97->id) 2550 if (quirk->codec_id && quirk->codec_id != ac97->id)
2530 continue; 2551 continue;
2531 snd_printdd("ac97 quirk for %s (%04x:%04x)\n", quirk->name, ac97->subsystem_vendor, ac97->subsystem_device); 2552 snd_printdd("ac97 quirk for %s (%04x:%04x)\n", quirk->name, ac97->subsystem_vendor, ac97->subsystem_device);
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index 13c34a5d8206..a15eb8522b7c 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -64,6 +64,116 @@ static int ac97_update_bits_page(ac97_t *ac97, unsigned short reg, unsigned shor
64 return ret; 64 return ret;
65} 65}
66 66
67/*
68 * shared line-in/mic controls
69 */
70static int ac97_enum_text_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo,
71 const char **texts, unsigned int nums)
72{
73 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
74 uinfo->count = 1;
75 uinfo->value.enumerated.items = nums;
76 if (uinfo->value.enumerated.item > nums - 1)
77 uinfo->value.enumerated.item = nums - 1;
78 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
79 return 0;
80}
81
82static int ac97_surround_jack_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
83{
84 static const char *texts[] = { "Shared", "Independent" };
85 return ac97_enum_text_info(kcontrol, uinfo, texts, 2);
86}
87
88static int ac97_surround_jack_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
89{
90 ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
91
92 ucontrol->value.enumerated.item[0] = ac97->indep_surround;
93 return 0;
94}
95
96static int ac97_surround_jack_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
97{
98 ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
99 unsigned char indep = !!ucontrol->value.enumerated.item[0];
100
101 if (indep != ac97->indep_surround) {
102 ac97->indep_surround = indep;
103 if (ac97->build_ops->update_jacks)
104 ac97->build_ops->update_jacks(ac97);
105 return 1;
106 }
107 return 0;
108}
109
110static int ac97_channel_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
111{
112 static const char *texts[] = { "2ch", "4ch", "6ch" };
113 if (kcontrol->private_value)
114 return ac97_enum_text_info(kcontrol, uinfo, texts, 2); /* 4ch only */
115 return ac97_enum_text_info(kcontrol, uinfo, texts, 3);
116}
117
118static int ac97_channel_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
119{
120 ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
121
122 ucontrol->value.enumerated.item[0] = ac97->channel_mode;
123 return 0;
124}
125
126static int ac97_channel_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
127{
128 ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
129 unsigned char mode = ucontrol->value.enumerated.item[0];
130
131 if (mode != ac97->channel_mode) {
132 ac97->channel_mode = mode;
133 if (ac97->build_ops->update_jacks)
134 ac97->build_ops->update_jacks(ac97);
135 return 1;
136 }
137 return 0;
138}
139
140#define AC97_SURROUND_JACK_MODE_CTL \
141 { \
142 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
143 .name = "Surround Jack Mode", \
144 .info = ac97_surround_jack_mode_info, \
145 .get = ac97_surround_jack_mode_get, \
146 .put = ac97_surround_jack_mode_put, \
147 }
148#define AC97_CHANNEL_MODE_CTL \
149 { \
150 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
151 .name = "Channel Mode", \
152 .info = ac97_channel_mode_info, \
153 .get = ac97_channel_mode_get, \
154 .put = ac97_channel_mode_put, \
155 }
156#define AC97_CHANNEL_MODE_4CH_CTL \
157 { \
158 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
159 .name = "Channel Mode", \
160 .info = ac97_channel_mode_info, \
161 .get = ac97_channel_mode_get, \
162 .put = ac97_channel_mode_put, \
163 .private_value = 1, \
164 }
165
166static inline int is_shared_linein(ac97_t *ac97)
167{
168 return ! ac97->indep_surround && ac97->channel_mode >= 1;
169}
170
171static inline int is_shared_micin(ac97_t *ac97)
172{
173 return ! ac97->indep_surround && ac97->channel_mode >= 2;
174}
175
176
67/* The following snd_ac97_ymf753_... items added by David Shust (dshust@shustring.com) */ 177/* The following snd_ac97_ymf753_... items added by David Shust (dshust@shustring.com) */
68 178
69/* It is possible to indicate to the Yamaha YMF753 the type of speakers being used. */ 179/* It is possible to indicate to the Yamaha YMF753 the type of speakers being used. */
@@ -1390,6 +1500,16 @@ static int snd_ac97_ad1888_downmix_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_va
1390 AC97_AD198X_DMIX0 | AC97_AD198X_DMIX1, val); 1500 AC97_AD198X_DMIX0 | AC97_AD198X_DMIX1, val);
1391} 1501}
1392 1502
1503static void ad1888_update_jacks(ac97_t *ac97)
1504{
1505 /* shared Line-In */
1506 snd_ac97_update_bits(ac97, AC97_AD_MISC, 1 << 12,
1507 is_shared_linein(ac97) ? 0 : 1 << 12);
1508 /* shared Mic */
1509 snd_ac97_update_bits(ac97, AC97_AD_MISC, 1 << 11,
1510 is_shared_micin(ac97) ? 0 : 1 << 11);
1511}
1512
1393static const snd_kcontrol_new_t snd_ac97_ad1888_controls[] = { 1513static const snd_kcontrol_new_t snd_ac97_ad1888_controls[] = {
1394 { 1514 {
1395 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1515 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -1406,8 +1526,8 @@ static const snd_kcontrol_new_t snd_ac97_ad1888_controls[] = {
1406 .get = snd_ac97_ad1888_downmix_get, 1526 .get = snd_ac97_ad1888_downmix_get,
1407 .put = snd_ac97_ad1888_downmix_put 1527 .put = snd_ac97_ad1888_downmix_put
1408 }, 1528 },
1409 AC97_SINGLE("Surround Jack as Input", AC97_AD_MISC, 12, 1, 0), 1529 AC97_SURROUND_JACK_MODE_CTL,
1410 AC97_SINGLE("Center/LFE Jack as Input", AC97_AD_MISC, 11, 1, 0), 1530 AC97_CHANNEL_MODE_CTL,
1411}; 1531};
1412 1532
1413static int patch_ad1888_specific(ac97_t *ac97) 1533static int patch_ad1888_specific(ac97_t *ac97)
@@ -1422,8 +1542,9 @@ static struct snd_ac97_build_ops patch_ad1888_build_ops = {
1422 .build_post_spdif = patch_ad198x_post_spdif, 1542 .build_post_spdif = patch_ad198x_post_spdif,
1423 .build_specific = patch_ad1888_specific, 1543 .build_specific = patch_ad1888_specific,
1424#ifdef CONFIG_PM 1544#ifdef CONFIG_PM
1425 .resume = ad18xx_resume 1545 .resume = ad18xx_resume,
1426#endif 1546#endif
1547 .update_jacks = ad1888_update_jacks,
1427}; 1548};
1428 1549
1429int patch_ad1888(ac97_t * ac97) 1550int patch_ad1888(ac97_t * ac97)
@@ -1459,8 +1580,9 @@ static struct snd_ac97_build_ops patch_ad1980_build_ops = {
1459 .build_post_spdif = patch_ad198x_post_spdif, 1580 .build_post_spdif = patch_ad198x_post_spdif,
1460 .build_specific = patch_ad1980_specific, 1581 .build_specific = patch_ad1980_specific,
1461#ifdef CONFIG_PM 1582#ifdef CONFIG_PM
1462 .resume = ad18xx_resume 1583 .resume = ad18xx_resume,
1463#endif 1584#endif
1585 .update_jacks = ad1888_update_jacks,
1464}; 1586};
1465 1587
1466int patch_ad1980(ac97_t * ac97) 1588int patch_ad1980(ac97_t * ac97)
@@ -1471,10 +1593,21 @@ int patch_ad1980(ac97_t * ac97)
1471} 1593}
1472 1594
1473static const snd_kcontrol_new_t snd_ac97_ad1985_controls[] = { 1595static const snd_kcontrol_new_t snd_ac97_ad1985_controls[] = {
1474 AC97_SINGLE("Center/LFE Jack as Mic", AC97_AD_SERIAL_CFG, 9, 1, 0),
1475 AC97_SINGLE("Exchange Center/LFE", AC97_AD_SERIAL_CFG, 3, 1, 0) 1596 AC97_SINGLE("Exchange Center/LFE", AC97_AD_SERIAL_CFG, 3, 1, 0)
1476}; 1597};
1477 1598
1599static void ad1985_update_jacks(ac97_t *ac97)
1600{
1601 /* shared Line-In */
1602 snd_ac97_update_bits(ac97, AC97_AD_MISC, 1 << 12,
1603 is_shared_linein(ac97) ? 0 : 1 << 12);
1604 /* shared Mic */
1605 snd_ac97_update_bits(ac97, AC97_AD_MISC, 1 << 11,
1606 is_shared_micin(ac97) ? 0 : 1 << 11);
1607 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 1 << 9,
1608 is_shared_micin(ac97) ? 0 : 1 << 9);
1609}
1610
1478static int patch_ad1985_specific(ac97_t *ac97) 1611static int patch_ad1985_specific(ac97_t *ac97)
1479{ 1612{
1480 int err; 1613 int err;
@@ -1488,8 +1621,9 @@ static struct snd_ac97_build_ops patch_ad1985_build_ops = {
1488 .build_post_spdif = patch_ad198x_post_spdif, 1621 .build_post_spdif = patch_ad198x_post_spdif,
1489 .build_specific = patch_ad1985_specific, 1622 .build_specific = patch_ad1985_specific,
1490#ifdef CONFIG_PM 1623#ifdef CONFIG_PM
1491 .resume = ad18xx_resume 1624 .resume = ad18xx_resume,
1492#endif 1625#endif
1626 .update_jacks = ad1985_update_jacks,
1493}; 1627};
1494 1628
1495int patch_ad1985(ac97_t * ac97) 1629int patch_ad1985(ac97_t * ac97)
@@ -1521,31 +1655,25 @@ int patch_ad1985(ac97_t * ac97)
1521/* 1655/*
1522 * realtek ALC65x/850 codecs 1656 * realtek ALC65x/850 codecs
1523 */ 1657 */
1524static int snd_ac97_alc650_mic_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol) 1658static void alc650_update_jacks(ac97_t *ac97)
1525{
1526 ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
1527 ucontrol->value.integer.value[0] = (ac97->regs[AC97_ALC650_MULTICH] >> 10) & 1;
1528 return 0;
1529}
1530
1531static int snd_ac97_alc650_mic_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol)
1532{ 1659{
1533 ac97_t *ac97 = snd_kcontrol_chip(kcontrol); 1660 int shared;
1534 int change, val; 1661
1535 val = !!(snd_ac97_read(ac97, AC97_ALC650_MULTICH) & (1 << 10)); 1662 /* shared Line-In */
1536 change = (ucontrol->value.integer.value[0] != val); 1663 shared = is_shared_linein(ac97);
1537 if (change) { 1664 snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 9,
1538 /* disable/enable vref */ 1665 shared ? (1 << 9) : 0);
1539 snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12, 1666 /* update shared Mic */
1540 ucontrol->value.integer.value[0] ? (1 << 12) : 0); 1667 shared = is_shared_micin(ac97);
1541 /* turn on/off center-on-mic */ 1668 /* disable/enable vref */
1542 snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 10, 1669 snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12,
1543 ucontrol->value.integer.value[0] ? (1 << 10) : 0); 1670 shared ? (1 << 12) : 0);
1544 /* GPIO0 high for mic */ 1671 /* turn on/off center-on-mic */
1545 snd_ac97_update_bits(ac97, AC97_ALC650_GPIO_STATUS, 0x100, 1672 snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 10,
1546 ucontrol->value.integer.value[0] ? 0 : 0x100); 1673 shared ? (1 << 10) : 0);
1547 } 1674 /* GPIO0 high for mic */
1548 return change; 1675 snd_ac97_update_bits(ac97, AC97_ALC650_GPIO_STATUS, 0x100,
1676 shared ? 0 : 0x100);
1549} 1677}
1550 1678
1551static const snd_kcontrol_new_t snd_ac97_controls_alc650[] = { 1679static const snd_kcontrol_new_t snd_ac97_controls_alc650[] = {
@@ -1558,8 +1686,8 @@ static const snd_kcontrol_new_t snd_ac97_controls_alc650[] = {
1558 /* 6: Independent Master Volume Right */ 1686 /* 6: Independent Master Volume Right */
1559 /* 7: Independent Master Volume Left */ 1687 /* 7: Independent Master Volume Left */
1560 /* 8: reserved */ 1688 /* 8: reserved */
1561 AC97_SINGLE("Line-In As Surround", AC97_ALC650_MULTICH, 9, 1, 0), 1689 /* 9: Line-In/Surround share */
1562 /* 10: mic, see below */ 1690 /* 10: Mic/CLFE share */
1563 /* 11-13: in IEC958 controls */ 1691 /* 11-13: in IEC958 controls */
1564 AC97_SINGLE("Swap Surround Slot", AC97_ALC650_MULTICH, 14, 1, 0), 1692 AC97_SINGLE("Swap Surround Slot", AC97_ALC650_MULTICH, 14, 1, 0),
1565#if 0 /* always set in patch_alc650 */ 1693#if 0 /* always set in patch_alc650 */
@@ -1570,14 +1698,8 @@ static const snd_kcontrol_new_t snd_ac97_controls_alc650[] = {
1570 AC97_SINGLE("Center/LFE DAC Switch", AC97_ALC650_LFE_DAC_VOL, 15, 1, 1), 1698 AC97_SINGLE("Center/LFE DAC Switch", AC97_ALC650_LFE_DAC_VOL, 15, 1, 1),
1571 AC97_DOUBLE("Center/LFE DAC Volume", AC97_ALC650_LFE_DAC_VOL, 8, 0, 31, 1), 1699 AC97_DOUBLE("Center/LFE DAC Volume", AC97_ALC650_LFE_DAC_VOL, 8, 0, 31, 1),
1572#endif 1700#endif
1573 { 1701 AC97_SURROUND_JACK_MODE_CTL,
1574 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1702 AC97_CHANNEL_MODE_CTL,
1575 .name = "Mic As Center/LFE",
1576 .info = snd_ac97_info_volsw,
1577 .get = snd_ac97_alc650_mic_get,
1578 .put = snd_ac97_alc650_mic_put,
1579 .private_value = AC97_SINGLE_VALUE(0, 0, 1, 0) /* only mask needed */
1580 },
1581}; 1703};
1582 1704
1583static const snd_kcontrol_new_t snd_ac97_spdif_controls_alc650[] = { 1705static const snd_kcontrol_new_t snd_ac97_spdif_controls_alc650[] = {
@@ -1601,7 +1723,8 @@ static int patch_alc650_specific(ac97_t * ac97)
1601} 1723}
1602 1724
1603static struct snd_ac97_build_ops patch_alc650_ops = { 1725static struct snd_ac97_build_ops patch_alc650_ops = {
1604 .build_specific = patch_alc650_specific 1726 .build_specific = patch_alc650_specific,
1727 .update_jacks = alc650_update_jacks
1605}; 1728};
1606 1729
1607int patch_alc650(ac97_t * ac97) 1730int patch_alc650(ac97_t * ac97)
@@ -1659,37 +1782,27 @@ int patch_alc650(ac97_t * ac97)
1659 return 0; 1782 return 0;
1660} 1783}
1661 1784
1662static int snd_ac97_alc655_mic_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol) 1785static void alc655_update_jacks(ac97_t *ac97)
1663{
1664 ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
1665 ucontrol->value.integer.value[0] = (ac97->regs[AC97_ALC650_MULTICH] >> 10) & 1;
1666 return 0;
1667}
1668
1669static int snd_ac97_alc655_mic_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol)
1670{ 1786{
1671 ac97_t *ac97 = snd_kcontrol_chip(kcontrol); 1787 int shared;
1672 1788
1789 /* shared Line-In */
1790 shared = is_shared_linein(ac97);
1791 ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 1 << 9,
1792 shared ? (1 << 9) : 0, 0);
1793 /* update shared mic */
1794 shared = is_shared_micin(ac97);
1673 /* misc control; vrefout disable */ 1795 /* misc control; vrefout disable */
1674 snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12, 1796 snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12,
1675 ucontrol->value.integer.value[0] ? (1 << 12) : 0); 1797 shared ? (1 << 12) : 0);
1676 return ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 1 << 10, 1798 ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 1 << 10,
1677 ucontrol->value.integer.value[0] ? (1 << 10) : 0, 1799 shared ? (1 << 10) : 0, 0);
1678 0);
1679} 1800}
1680 1801
1681
1682static const snd_kcontrol_new_t snd_ac97_controls_alc655[] = { 1802static const snd_kcontrol_new_t snd_ac97_controls_alc655[] = {
1683 AC97_PAGE_SINGLE("Duplicate Front", AC97_ALC650_MULTICH, 0, 1, 0, 0), 1803 AC97_PAGE_SINGLE("Duplicate Front", AC97_ALC650_MULTICH, 0, 1, 0, 0),
1684 AC97_PAGE_SINGLE("Line-In As Surround", AC97_ALC650_MULTICH, 9, 1, 0, 0), 1804 AC97_SURROUND_JACK_MODE_CTL,
1685 { 1805 AC97_CHANNEL_MODE_CTL,
1686 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1687 .name = "Mic As Center/LFE",
1688 .info = snd_ac97_info_volsw,
1689 .get = snd_ac97_alc655_mic_get,
1690 .put = snd_ac97_alc655_mic_put,
1691 .private_value = AC97_SINGLE_VALUE(0, 0, 1, 0) /* only mask needed */
1692 },
1693}; 1806};
1694 1807
1695static int alc655_iec958_route_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) 1808static int alc655_iec958_route_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
@@ -1759,7 +1872,8 @@ static int patch_alc655_specific(ac97_t * ac97)
1759} 1872}
1760 1873
1761static struct snd_ac97_build_ops patch_alc655_ops = { 1874static struct snd_ac97_build_ops patch_alc655_ops = {
1762 .build_specific = patch_alc655_specific 1875 .build_specific = patch_alc655_specific,
1876 .update_jacks = alc655_update_jacks
1763}; 1877};
1764 1878
1765int patch_alc655(ac97_t * ac97) 1879int patch_alc655(ac97_t * ac97)
@@ -1798,63 +1912,33 @@ int patch_alc655(ac97_t * ac97)
1798#define AC97_ALC850_JACK_SELECT 0x76 1912#define AC97_ALC850_JACK_SELECT 0x76
1799#define AC97_ALC850_MISC1 0x7a 1913#define AC97_ALC850_MISC1 0x7a
1800 1914
1801static int ac97_alc850_surround_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol) 1915static void alc850_update_jacks(ac97_t *ac97)
1802{
1803 ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
1804 ucontrol->value.integer.value[0] = ((ac97->regs[AC97_ALC850_JACK_SELECT] >> 12) & 7) == 2;
1805 return 0;
1806}
1807
1808static int ac97_alc850_surround_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol)
1809{ 1916{
1810 ac97_t *ac97 = snd_kcontrol_chip(kcontrol); 1917 int shared;
1811 1918
1919 /* shared Line-In */
1920 shared = is_shared_linein(ac97);
1812 /* SURR 1kOhm (bit4), Amp (bit5) */ 1921 /* SURR 1kOhm (bit4), Amp (bit5) */
1813 snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<4)|(1<<5), 1922 snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<4)|(1<<5),
1814 ucontrol->value.integer.value[0] ? (1<<5) : (1<<4)); 1923 shared ? (1<<5) : (1<<4));
1815 /* LINE-IN = 0, SURROUND = 2 */ 1924 /* LINE-IN = 0, SURROUND = 2 */
1816 return snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 12, 1925 snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 12,
1817 ucontrol->value.integer.value[0] ? (2<<12) : (0<<12)); 1926 shared ? (2<<12) : (0<<12));
1818} 1927 /* update shared mic */
1819 1928 shared = is_shared_micin(ac97);
1820static int ac97_alc850_mic_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol)
1821{
1822 ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
1823 ucontrol->value.integer.value[0] = ((ac97->regs[AC97_ALC850_JACK_SELECT] >> 4) & 7) == 2;
1824 return 0;
1825}
1826
1827static int ac97_alc850_mic_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol)
1828{
1829 ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
1830
1831 /* Vref disable (bit12), 1kOhm (bit13) */ 1929 /* Vref disable (bit12), 1kOhm (bit13) */
1832 snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<12)|(1<<13), 1930 snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<12)|(1<<13),
1833 ucontrol->value.integer.value[0] ? (1<<12) : (1<<13)); 1931 shared ? (1<<12) : (1<<13));
1834 /* MIC-IN = 1, CENTER-LFE = 2 */ 1932 /* MIC-IN = 1, CENTER-LFE = 2 */
1835 return snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 4, 1933 snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 4,
1836 ucontrol->value.integer.value[0] ? (2<<4) : (1<<4)); 1934 shared ? (2<<4) : (1<<4));
1837} 1935}
1838 1936
1839static const snd_kcontrol_new_t snd_ac97_controls_alc850[] = { 1937static const snd_kcontrol_new_t snd_ac97_controls_alc850[] = {
1840 AC97_PAGE_SINGLE("Duplicate Front", AC97_ALC650_MULTICH, 0, 1, 0, 0), 1938 AC97_PAGE_SINGLE("Duplicate Front", AC97_ALC650_MULTICH, 0, 1, 0, 0),
1841 { 1939 AC97_SINGLE("Mic Front Input Switch", AC97_ALC850_JACK_SELECT, 15, 1, 1),
1842 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1940 AC97_SURROUND_JACK_MODE_CTL,
1843 .name = "Line-In As Surround", 1941 AC97_CHANNEL_MODE_CTL,
1844 .info = snd_ac97_info_volsw,
1845 .get = ac97_alc850_surround_get,
1846 .put = ac97_alc850_surround_put,
1847 .private_value = AC97_SINGLE_VALUE(0, 0, 1, 0) /* only mask needed */
1848 },
1849 {
1850 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1851 .name = "Mic As Center/LFE",
1852 .info = snd_ac97_info_volsw,
1853 .get = ac97_alc850_mic_get,
1854 .put = ac97_alc850_mic_put,
1855 .private_value = AC97_SINGLE_VALUE(0, 0, 1, 0) /* only mask needed */
1856 },
1857
1858}; 1942};
1859 1943
1860static int patch_alc850_specific(ac97_t *ac97) 1944static int patch_alc850_specific(ac97_t *ac97)
@@ -1871,7 +1955,8 @@ static int patch_alc850_specific(ac97_t *ac97)
1871} 1955}
1872 1956
1873static struct snd_ac97_build_ops patch_alc850_ops = { 1957static struct snd_ac97_build_ops patch_alc850_ops = {
1874 .build_specific = patch_alc850_specific 1958 .build_specific = patch_alc850_specific,
1959 .update_jacks = alc850_update_jacks
1875}; 1960};
1876 1961
1877int patch_alc850(ac97_t *ac97) 1962int patch_alc850(ac97_t *ac97)
@@ -1911,9 +1996,17 @@ int patch_alc850(ac97_t *ac97)
1911/* 1996/*
1912 * C-Media CM97xx codecs 1997 * C-Media CM97xx codecs
1913 */ 1998 */
1999static void cm9738_update_jacks(ac97_t *ac97)
2000{
2001 /* shared Line-In */
2002 snd_ac97_update_bits(ac97, AC97_CM9738_VENDOR_CTRL, 1 << 10,
2003 is_shared_linein(ac97) ? (1 << 10) : 0);
2004}
2005
1914static const snd_kcontrol_new_t snd_ac97_cm9738_controls[] = { 2006static const snd_kcontrol_new_t snd_ac97_cm9738_controls[] = {
1915 AC97_SINGLE("Line-In As Surround", AC97_CM9738_VENDOR_CTRL, 10, 1, 0),
1916 AC97_SINGLE("Duplicate Front", AC97_CM9738_VENDOR_CTRL, 13, 1, 0), 2007 AC97_SINGLE("Duplicate Front", AC97_CM9738_VENDOR_CTRL, 13, 1, 0),
2008 AC97_SURROUND_JACK_MODE_CTL,
2009 AC97_CHANNEL_MODE_4CH_CTL,
1917}; 2010};
1918 2011
1919static int patch_cm9738_specific(ac97_t * ac97) 2012static int patch_cm9738_specific(ac97_t * ac97)
@@ -1922,7 +2015,8 @@ static int patch_cm9738_specific(ac97_t * ac97)
1922} 2015}
1923 2016
1924static struct snd_ac97_build_ops patch_cm9738_ops = { 2017static struct snd_ac97_build_ops patch_cm9738_ops = {
1925 .build_specific = patch_cm9738_specific 2018 .build_specific = patch_cm9738_specific,
2019 .update_jacks = cm9738_update_jacks
1926}; 2020};
1927 2021
1928int patch_cm9738(ac97_t * ac97) 2022int patch_cm9738(ac97_t * ac97)
@@ -1986,34 +2080,19 @@ static const snd_kcontrol_new_t snd_ac97_cm9739_controls_spdif[] = {
1986 /* BIT 8: SPD32 - 32bit SPDIF - not supported yet */ 2080 /* BIT 8: SPD32 - 32bit SPDIF - not supported yet */
1987}; 2081};
1988 2082
1989static int snd_ac97_cm9739_center_mic_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 2083static void cm9739_update_jacks(ac97_t *ac97)
1990{
1991 ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
1992 if (ac97->regs[AC97_CM9739_MULTI_CHAN] & 0x1000)
1993 ucontrol->value.integer.value[0] = 1;
1994 else
1995 ucontrol->value.integer.value[0] = 0;
1996 return 0;
1997}
1998
1999static int snd_ac97_cm9739_center_mic_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
2000{ 2084{
2001 ac97_t *ac97 = snd_kcontrol_chip(kcontrol); 2085 /* shared Line-In */
2002 return snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 0x3000, 2086 snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 1 << 10,
2003 ucontrol->value.integer.value[0] ? 2087 is_shared_linein(ac97) ? (1 << 10) : 0);
2004 0x1000 : 0x2000); 2088 /* shared Mic */
2089 snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 0x3000,
2090 is_shared_micin(ac97) ? 0x1000 : 0x2000);
2005} 2091}
2006 2092
2007static const snd_kcontrol_new_t snd_ac97_cm9739_controls[] = { 2093static const snd_kcontrol_new_t snd_ac97_cm9739_controls[] = {
2008 AC97_SINGLE("Line-In As Surround", AC97_CM9739_MULTI_CHAN, 10, 1, 0), 2094 AC97_SURROUND_JACK_MODE_CTL,
2009 { 2095 AC97_CHANNEL_MODE_CTL,
2010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2011 .name = "Mic As Center/LFE",
2012 .info = snd_ac97_info_volsw,
2013 .get = snd_ac97_cm9739_center_mic_get,
2014 .put = snd_ac97_cm9739_center_mic_put,
2015 .private_value = AC97_SINGLE_VALUE(0, 0, 1, 0) /* only mask needed */
2016 },
2017}; 2096};
2018 2097
2019static int patch_cm9739_specific(ac97_t * ac97) 2098static int patch_cm9739_specific(ac97_t * ac97)
@@ -2028,7 +2107,8 @@ static int patch_cm9739_post_spdif(ac97_t * ac97)
2028 2107
2029static struct snd_ac97_build_ops patch_cm9739_ops = { 2108static struct snd_ac97_build_ops patch_cm9739_ops = {
2030 .build_specific = patch_cm9739_specific, 2109 .build_specific = patch_cm9739_specific,
2031 .build_post_spdif = patch_cm9739_post_spdif 2110 .build_post_spdif = patch_cm9739_post_spdif,
2111 .update_jacks = cm9739_update_jacks
2032}; 2112};
2033 2113
2034int patch_cm9739(ac97_t * ac97) 2114int patch_cm9739(ac97_t * ac97)
@@ -2087,71 +2167,97 @@ int patch_cm9739(ac97_t * ac97)
2087} 2167}
2088 2168
2089#define AC97_CM9761_MULTI_CHAN 0x64 2169#define AC97_CM9761_MULTI_CHAN 0x64
2170#define AC97_CM9761_FUNC 0x66
2090#define AC97_CM9761_SPDIF_CTRL 0x6c 2171#define AC97_CM9761_SPDIF_CTRL 0x6c
2091 2172
2092static int snd_ac97_cm9761_linein_rear_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 2173static void cm9761_update_jacks(ac97_t *ac97)
2093{
2094 ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
2095 if (ac97->regs[AC97_CM9739_MULTI_CHAN] & 0x0400)
2096 ucontrol->value.integer.value[0] = 1;
2097 else
2098 ucontrol->value.integer.value[0] = 0;
2099 return 0;
2100}
2101
2102static int snd_ac97_cm9761_linein_rear_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
2103{ 2174{
2104 ac97_t *ac97 = snd_kcontrol_chip(kcontrol); 2175 unsigned short surr_vals[2][2] = {
2105 unsigned short vals[2][2] = {
2106 { 0x0008, 0x0400 }, /* off, on */ 2176 { 0x0008, 0x0400 }, /* off, on */
2107 { 0x0000, 0x0408 }, /* off, on (9761-82 rev.B) */ 2177 { 0x0000, 0x0408 }, /* off, on (9761-82 rev.B) */
2108 }; 2178 };
2109 return snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 0x0408, 2179 unsigned short clfe_vals[2][2] = {
2110 vals[ac97->spec.dev_flags][!!ucontrol->value.integer.value[0]]); 2180 { 0x2000, 0x1880 }, /* off, on */
2181 { 0x1000, 0x2880 }, /* off, on (9761-82 rev.B) */
2182 };
2183
2184 /* shared Line-In */
2185 snd_ac97_update_bits(ac97, AC97_CM9761_MULTI_CHAN, 0x0408,
2186 surr_vals[ac97->spec.dev_flags][is_shared_linein(ac97)]);
2187 /* shared Mic */
2188 snd_ac97_update_bits(ac97, AC97_CM9761_MULTI_CHAN, 0x3880,
2189 clfe_vals[ac97->spec.dev_flags][is_shared_micin(ac97)]);
2190}
2191
2192static const snd_kcontrol_new_t snd_ac97_cm9761_controls[] = {
2193 AC97_SURROUND_JACK_MODE_CTL,
2194 AC97_CHANNEL_MODE_CTL,
2195};
2196
2197static int cm9761_spdif_out_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
2198{
2199 static char *texts[] = { "AC-Link", "ADC", "SPDIF-In" };
2200
2201 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2202 uinfo->count = 1;
2203 uinfo->value.enumerated.items = 3;
2204 if (uinfo->value.enumerated.item > 2)
2205 uinfo->value.enumerated.item = 2;
2206 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2207 return 0;
2111} 2208}
2112 2209
2113static int snd_ac97_cm9761_center_mic_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 2210static int cm9761_spdif_out_source_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
2114{ 2211{
2115 ac97_t *ac97 = snd_kcontrol_chip(kcontrol); 2212 ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
2116 if (ac97->regs[AC97_CM9739_MULTI_CHAN] & 0x1000) 2213
2117 ucontrol->value.integer.value[0] = 1; 2214 if (ac97->regs[AC97_CM9761_FUNC] & 0x1)
2215 ucontrol->value.enumerated.item[0] = 2; /* SPDIF-loopback */
2216 else if (ac97->regs[AC97_CM9761_SPDIF_CTRL] & 0x2)
2217 ucontrol->value.enumerated.item[0] = 1; /* ADC loopback */
2118 else 2218 else
2119 ucontrol->value.integer.value[0] = 0; 2219 ucontrol->value.enumerated.item[0] = 0; /* AC-link */
2120 if (ac97->spec.dev_flags) /* 9761-82 rev.B */
2121 ucontrol->value.integer.value[0] = !ucontrol->value.integer.value[0];
2122 return 0; 2220 return 0;
2123} 2221}
2124 2222
2125static int snd_ac97_cm9761_center_mic_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 2223static int cm9761_spdif_out_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
2126{ 2224{
2127 ac97_t *ac97 = snd_kcontrol_chip(kcontrol); 2225 ac97_t *ac97 = snd_kcontrol_chip(kcontrol);
2128 unsigned short vals[2][2] = { 2226
2129 { 0x2000, 0x1880 }, /* off, on */ 2227 if (ucontrol->value.enumerated.item[0] == 2)
2130 { 0x1000, 0x2880 }, /* off, on (9761-82 rev.B) */ 2228 return snd_ac97_update_bits(ac97, AC97_CM9761_FUNC, 0x1, 0x1);
2131 }; 2229 snd_ac97_update_bits(ac97, AC97_CM9761_FUNC, 0x1, 0);
2132 return snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 0x3880, 2230 return snd_ac97_update_bits(ac97, AC97_CM9761_SPDIF_CTRL, 0x2,
2133 vals[ac97->spec.dev_flags][!!ucontrol->value.integer.value[0]]); 2231 ucontrol->value.enumerated.item[0] == 1 ? 0x2 : 0);
2134} 2232}
2135 2233
2136static const snd_kcontrol_new_t snd_ac97_cm9761_controls[] = { 2234static const char *cm9761_dac_clock[] = { "AC-Link", "SPDIF-In", "Both" };
2137 { 2235static const struct ac97_enum cm9761_dac_clock_enum =
2138 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2236 AC97_ENUM_SINGLE(AC97_CM9761_SPDIF_CTRL, 9, 3, cm9761_dac_clock);
2139 .name = "Line-In As Surround", 2237
2140 .info = snd_ac97_info_volsw, 2238static const snd_kcontrol_new_t snd_ac97_cm9761_controls_spdif[] = {
2141 .get = snd_ac97_cm9761_linein_rear_get, 2239 { /* BIT 1: SPDIFS */
2142 .put = snd_ac97_cm9761_linein_rear_put, 2240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2143 .private_value = AC97_SINGLE_VALUE(0, 0, 1, 0) /* only mask needed */ 2241 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source",
2144 }, 2242 .info = cm9761_spdif_out_source_info,
2145 { 2243 .get = cm9761_spdif_out_source_get,
2146 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2244 .put = cm9761_spdif_out_source_put,
2147 .name = "Mic As Center/LFE",
2148 .info = snd_ac97_info_volsw,
2149 .get = snd_ac97_cm9761_center_mic_get,
2150 .put = snd_ac97_cm9761_center_mic_put,
2151 .private_value = AC97_SINGLE_VALUE(0, 0, 1, 0) /* only mask needed */
2152 }, 2245 },
2246 /* BIT 2: IG_SPIV */
2247 AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,NONE) "Valid Switch", AC97_CM9761_SPDIF_CTRL, 2, 1, 0),
2248 /* BIT 3: SPI2F */
2249 AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,NONE) "Monitor", AC97_CM9761_SPDIF_CTRL, 3, 1, 0),
2250 /* BIT 4: SPI2SDI */
2251 AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), AC97_CM9761_SPDIF_CTRL, 4, 1, 0),
2252 /* BIT 9-10: DAC_CTL */
2253 AC97_ENUM("DAC Clock Source", cm9761_dac_clock_enum),
2153}; 2254};
2154 2255
2256static int patch_cm9761_post_spdif(ac97_t * ac97)
2257{
2258 return patch_build_controls(ac97, snd_ac97_cm9761_controls_spdif, ARRAY_SIZE(snd_ac97_cm9761_controls_spdif));
2259}
2260
2155static int patch_cm9761_specific(ac97_t * ac97) 2261static int patch_cm9761_specific(ac97_t * ac97)
2156{ 2262{
2157 return patch_build_controls(ac97, snd_ac97_cm9761_controls, ARRAY_SIZE(snd_ac97_cm9761_controls)); 2263 return patch_build_controls(ac97, snd_ac97_cm9761_controls, ARRAY_SIZE(snd_ac97_cm9761_controls));
@@ -2159,7 +2265,8 @@ static int patch_cm9761_specific(ac97_t * ac97)
2159 2265
2160static struct snd_ac97_build_ops patch_cm9761_ops = { 2266static struct snd_ac97_build_ops patch_cm9761_ops = {
2161 .build_specific = patch_cm9761_specific, 2267 .build_specific = patch_cm9761_specific,
2162 .build_post_spdif = patch_cm9739_post_spdif /* hope it's identical... */ 2268 .build_post_spdif = patch_cm9761_post_spdif,
2269 .update_jacks = cm9761_update_jacks
2163}; 2270};
2164 2271
2165int patch_cm9761(ac97_t *ac97) 2272int patch_cm9761(ac97_t *ac97)
@@ -2193,24 +2300,25 @@ int patch_cm9761(ac97_t *ac97)
2193 /* to be sure: we overwrite the ext status bits */ 2300 /* to be sure: we overwrite the ext status bits */
2194 snd_ac97_write_cache(ac97, AC97_EXTENDED_STATUS, 0x05c0); 2301 snd_ac97_write_cache(ac97, AC97_EXTENDED_STATUS, 0x05c0);
2195 /* Don't set 0x0200 here. This results in the silent analog output */ 2302 /* Don't set 0x0200 here. This results in the silent analog output */
2196 snd_ac97_write_cache(ac97, AC97_CM9761_SPDIF_CTRL, 0x0009); 2303 snd_ac97_write_cache(ac97, AC97_CM9761_SPDIF_CTRL, 0x0001); /* enable spdif-in */
2197 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */ 2304 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
2198 2305
2199 /* set-up multi channel */ 2306 /* set-up multi channel */
2200 /* bit 15: pc master beep off 2307 /* bit 15: pc master beep off
2201 * bit 14: ?? 2308 * bit 14: pin47 = EAPD/SPDIF
2202 * bit 13: vref ctl [= cm9739] 2309 * bit 13: vref ctl [= cm9739]
2203 * bit 12: center/mic [= cm9739] (reverted on rev B) 2310 * bit 12: CLFE control (reverted on rev B)
2204 * bit 11: ?? (mic/center/lfe) (reverted on rev B) 2311 * bit 11: Mic/center share (reverted on rev B)
2205 * bit 10: suddound/line [= cm9739] 2312 * bit 10: suddound/line share
2206 * bit 9: mix 2 surround 2313 * bit 9: Analog-in mix -> surround
2207 * bit 8: ? 2314 * bit 8: Analog-in mix -> CLFE
2208 * bit 7: ?? (mic/center/lfe) 2315 * bit 7: Mic/LFE share (mic/center/lfe)
2209 * bit 4: ?? (front) 2316 * bit 5: vref select (9761A)
2210 * bit 3: ?? (line-in/rear share) (revereted with rev B) 2317 * bit 4: front control
2211 * bit 2: ?? (surround) 2318 * bit 3: surround control (revereted with rev B)
2212 * bit 1: front mic 2319 * bit 2: front mic
2213 * bit 0: mic boost 2320 * bit 1: stereo mic
2321 * bit 0: mic boost level (0=20dB, 1=30dB)
2214 */ 2322 */
2215 2323
2216#if 0 2324#if 0
@@ -2230,6 +2338,47 @@ int patch_cm9761(ac97_t *ac97)
2230 return 0; 2338 return 0;
2231} 2339}
2232 2340
2341#define AC97_CM9780_SIDE 0x60
2342#define AC97_CM9780_JACK 0x62
2343#define AC97_CM9780_MIXER 0x64
2344#define AC97_CM9780_MULTI_CHAN 0x66
2345#define AC97_CM9780_SPDIF 0x6c
2346
2347static const char *cm9780_ch_select[] = { "Front", "Side", "Center/LFE", "Rear" };
2348static const struct ac97_enum cm9780_ch_select_enum =
2349 AC97_ENUM_SINGLE(AC97_CM9780_MULTI_CHAN, 6, 4, cm9780_ch_select);
2350static const snd_kcontrol_new_t cm9780_controls[] = {
2351 AC97_DOUBLE("Side Playback Switch", AC97_CM9780_SIDE, 15, 7, 1, 1),
2352 AC97_DOUBLE("Side Playback Volume", AC97_CM9780_SIDE, 8, 0, 31, 0),
2353 AC97_ENUM("Side Playback Route", cm9780_ch_select_enum),
2354};
2355
2356static int patch_cm9780_specific(ac97_t *ac97)
2357{
2358 return patch_build_controls(ac97, cm9780_controls, ARRAY_SIZE(cm9780_controls));
2359}
2360
2361static struct snd_ac97_build_ops patch_cm9780_ops = {
2362 .build_specific = patch_cm9780_specific,
2363 .build_post_spdif = patch_cm9761_post_spdif /* identical with CM9761 */
2364};
2365
2366int patch_cm9780(ac97_t *ac97)
2367{
2368 unsigned short val;
2369
2370 ac97->build_ops = &patch_cm9780_ops;
2371
2372 /* enable spdif */
2373 if (ac97->ext_id & AC97_EI_SPDIF) {
2374 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
2375 val = snd_ac97_read(ac97, AC97_CM9780_SPDIF);
2376 val |= 0x1; /* SPDI_EN */
2377 snd_ac97_write_cache(ac97, AC97_CM9780_SPDIF, val);
2378 }
2379
2380 return 0;
2381}
2233 2382
2234/* 2383/*
2235 * VIA VT1616 codec 2384 * VIA VT1616 codec
@@ -2263,9 +2412,21 @@ int patch_vt1616(ac97_t * ac97)
2263 return 0; 2412 return 0;
2264} 2413}
2265 2414
2415/*
2416 */
2417static void it2646_update_jacks(ac97_t *ac97)
2418{
2419 /* shared Line-In */
2420 snd_ac97_update_bits(ac97, 0x76, 1 << 9,
2421 is_shared_linein(ac97) ? (1<<9) : 0);
2422 /* shared Mic */
2423 snd_ac97_update_bits(ac97, 0x76, 1 << 10,
2424 is_shared_micin(ac97) ? (1<<10) : 0);
2425}
2426
2266static const snd_kcontrol_new_t snd_ac97_controls_it2646[] = { 2427static const snd_kcontrol_new_t snd_ac97_controls_it2646[] = {
2267 AC97_SINGLE("Line-In As Surround", 0x76, 9, 1, 0), 2428 AC97_SURROUND_JACK_MODE_CTL,
2268 AC97_SINGLE("Mic As Center/LFE", 0x76, 10, 1, 0), 2429 AC97_CHANNEL_MODE_CTL,
2269}; 2430};
2270 2431
2271static const snd_kcontrol_new_t snd_ac97_spdif_controls_it2646[] = { 2432static const snd_kcontrol_new_t snd_ac97_spdif_controls_it2646[] = {
@@ -2285,7 +2446,8 @@ static int patch_it2646_specific(ac97_t * ac97)
2285} 2446}
2286 2447
2287static struct snd_ac97_build_ops patch_it2646_ops = { 2448static struct snd_ac97_build_ops patch_it2646_ops = {
2288 .build_specific = patch_it2646_specific 2449 .build_specific = patch_it2646_specific,
2450 .update_jacks = it2646_update_jacks
2289}; 2451};
2290 2452
2291int patch_it2646(ac97_t * ac97) 2453int patch_it2646(ac97_t * ac97)
@@ -2297,12 +2459,29 @@ int patch_it2646(ac97_t * ac97)
2297 return 0; 2459 return 0;
2298} 2460}
2299 2461
2300/* Si3036/8 specific registers */ 2462/*
2463 * Si3036 codec
2464 */
2465
2301#define AC97_SI3036_CHIP_ID 0x5a 2466#define AC97_SI3036_CHIP_ID 0x5a
2467#define AC97_SI3036_LINE_CFG 0x5c
2468
2469static const snd_kcontrol_new_t snd_ac97_controls_si3036[] = {
2470AC97_DOUBLE("Modem Speaker Volume", 0x5c, 14, 12, 3, 1)
2471};
2472
2473static int patch_si3036_specific(ac97_t * ac97)
2474{
2475 return patch_build_controls(ac97, snd_ac97_controls_si3036, ARRAY_SIZE(snd_ac97_controls_si3036));
2476}
2477
2478static struct snd_ac97_build_ops patch_si3036_ops = {
2479 .build_specific = patch_si3036_specific,
2480};
2302 2481
2303int mpatch_si3036(ac97_t * ac97) 2482int mpatch_si3036(ac97_t * ac97)
2304{ 2483{
2305 //printk("mpatch_si3036: chip id = %x\n", snd_ac97_read(ac97, 0x5a)); 2484 ac97->build_ops = &patch_si3036_ops;
2306 snd_ac97_write_cache(ac97, 0x5c, 0xf210 ); 2485 snd_ac97_write_cache(ac97, 0x5c, 0xf210 );
2307 snd_ac97_write_cache(ac97, 0x68, 0); 2486 snd_ac97_write_cache(ac97, 0x68, 0);
2308 return 0; 2487 return 0;
diff --git a/sound/pci/ac97/ac97_patch.h b/sound/pci/ac97/ac97_patch.h
index 6db51c96f5d0..7b7377d0f2ae 100644
--- a/sound/pci/ac97/ac97_patch.h
+++ b/sound/pci/ac97/ac97_patch.h
@@ -54,6 +54,7 @@ int patch_alc850(ac97_t * ac97);
54int patch_cm9738(ac97_t * ac97); 54int patch_cm9738(ac97_t * ac97);
55int patch_cm9739(ac97_t * ac97); 55int patch_cm9739(ac97_t * ac97);
56int patch_cm9761(ac97_t * ac97); 56int patch_cm9761(ac97_t * ac97);
57int patch_cm9780(ac97_t * ac97);
57int patch_vt1616(ac97_t * ac97); 58int patch_vt1616(ac97_t * ac97);
58int patch_it2646(ac97_t * ac97); 59int patch_it2646(ac97_t * ac97);
59int mpatch_si3036(ac97_t * ac97); 60int mpatch_si3036(ac97_t * ac97);
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index 984d5d4ba4e1..eb5c36d31a52 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -98,6 +98,8 @@ MODULE_PARM_DESC(spdif, "Support SPDIF I/O");
98#define ALI_LEF_CHANNEL 23 98#define ALI_LEF_CHANNEL 23
99#define ALI_SURR_LEFT_CHANNEL 26 99#define ALI_SURR_LEFT_CHANNEL 26
100#define ALI_SURR_RIGHT_CHANNEL 25 100#define ALI_SURR_RIGHT_CHANNEL 25
101#define ALI_MODEM_IN_CHANNEL 21
102#define ALI_MODEM_OUT_CHANNEL 20
101 103
102#define SNDRV_ALI_VOICE_TYPE_PCM 01 104#define SNDRV_ALI_VOICE_TYPE_PCM 01
103#define SNDRV_ALI_VOICE_TYPE_OTH 02 105#define SNDRV_ALI_VOICE_TYPE_OTH 02
@@ -122,7 +124,15 @@ MODULE_PARM_DESC(spdif, "Support SPDIF I/O");
122 124
123#define ALI_SCTRL 0x48 125#define ALI_SCTRL 0x48
124#define ALI_SPDIF_OUT_ENABLE 0x20 126#define ALI_SPDIF_OUT_ENABLE 0x20
127#define ALI_SCTRL_LINE_IN2 (1 << 9)
128#define ALI_SCTRL_GPIO_IN2 (1 << 13)
129#define ALI_SCTRL_LINE_OUT_EN (1 << 20)
130#define ALI_SCTRL_GPIO_OUT_EN (1 << 23)
131#define ALI_SCTRL_CODEC1_READY (1 << 24)
132#define ALI_SCTRL_CODEC2_READY (1 << 25)
125#define ALI_AC97_GPIO 0x4c 133#define ALI_AC97_GPIO 0x4c
134#define ALI_AC97_GPIO_ENABLE 0x8000
135#define ALI_AC97_GPIO_DATA_SHIFT 16
126#define ALI_SPDIF_CS 0x70 136#define ALI_SPDIF_CS 0x70
127#define ALI_SPDIF_CTRL 0x74 137#define ALI_SPDIF_CTRL 0x74
128#define ALI_SPDIF_IN_FUNC_ENABLE 0x02 138#define ALI_SPDIF_IN_FUNC_ENABLE 0x02
@@ -143,6 +153,7 @@ MODULE_PARM_DESC(spdif, "Support SPDIF I/O");
143 #define TARGET_REACHED 0x00008000 153 #define TARGET_REACHED 0x00008000
144 #define MIXER_OVERFLOW 0x00000800 154 #define MIXER_OVERFLOW 0x00000800
145 #define MIXER_UNDERFLOW 0x00000400 155 #define MIXER_UNDERFLOW 0x00000400
156 #define GPIO_IRQ 0x01000000
146#define ALI_SBBL_SBCL 0xc0 157#define ALI_SBBL_SBCL 0xc0
147#define ALI_SBCTRL_SBE2R_SBDD 0xc4 158#define ALI_SBCTRL_SBE2R_SBDD 0xc4
148#define ALI_STIMER 0xc8 159#define ALI_STIMER 0xc8
@@ -162,6 +173,9 @@ MODULE_PARM_DESC(spdif, "Support SPDIF I/O");
162 173
163#define ALI_REG(codec, x) ((codec)->port + x) 174#define ALI_REG(codec, x) ((codec)->port + x)
164 175
176#define MAX_CODECS 2
177
178
165typedef struct snd_stru_ali ali_t; 179typedef struct snd_stru_ali ali_t;
166typedef struct snd_ali_stru_voice snd_ali_voice_t; 180typedef struct snd_ali_stru_voice snd_ali_voice_t;
167 181
@@ -245,7 +259,7 @@ struct snd_stru_ali {
245 struct pci_dev *pci_m7101; 259 struct pci_dev *pci_m7101;
246 260
247 snd_card_t *card; 261 snd_card_t *card;
248 snd_pcm_t *pcm; 262 snd_pcm_t *pcm[MAX_CODECS];
249 alidev_t synth; 263 alidev_t synth;
250 snd_ali_channel_control_t chregs; 264 snd_ali_channel_control_t chregs;
251 265
@@ -255,8 +269,10 @@ struct snd_stru_ali {
255 unsigned int spurious_irq_count; 269 unsigned int spurious_irq_count;
256 unsigned int spurious_irq_max_delta; 270 unsigned int spurious_irq_max_delta;
257 271
272 unsigned int num_of_codecs;
273
258 ac97_bus_t *ac97_bus; 274 ac97_bus_t *ac97_bus;
259 ac97_t *ac97; 275 ac97_t *ac97[MAX_CODECS];
260 unsigned short ac97_ext_id; 276 unsigned short ac97_ext_id;
261 unsigned short ac97_ext_status; 277 unsigned short ac97_ext_status;
262 278
@@ -489,7 +505,12 @@ static void snd_ali_codec_write(ac97_t *ac97,
489 ali_t *codec = ac97->private_data; 505 ali_t *codec = ac97->private_data;
490 506
491 snd_ali_printk("codec_write: reg=%xh data=%xh.\n", reg, val); 507 snd_ali_printk("codec_write: reg=%xh data=%xh.\n", reg, val);
492 snd_ali_codec_poke(codec, 0, reg, val); 508 if(reg == AC97_GPIO_STATUS) {
509 outl((val << ALI_AC97_GPIO_DATA_SHIFT)|ALI_AC97_GPIO_ENABLE,
510 ALI_REG(codec, ALI_AC97_GPIO));
511 return;
512 }
513 snd_ali_codec_poke(codec, ac97->num, reg, val);
493 return ; 514 return ;
494} 515}
495 516
@@ -499,7 +520,7 @@ static unsigned short snd_ali_codec_read(ac97_t *ac97, unsigned short reg)
499 ali_t *codec = ac97->private_data; 520 ali_t *codec = ac97->private_data;
500 521
501 snd_ali_printk("codec_read reg=%xh.\n", reg); 522 snd_ali_printk("codec_read reg=%xh.\n", reg);
502 return (snd_ali_codec_peek(codec, 0, reg)); 523 return (snd_ali_codec_peek(codec, ac97->num, reg));
503} 524}
504 525
505/* 526/*
@@ -1051,7 +1072,7 @@ static irqreturn_t snd_ali_card_interrupt(int irq,
1051} 1072}
1052 1073
1053 1074
1054static snd_ali_voice_t *snd_ali_alloc_voice(ali_t * codec, int type, int rec) 1075static snd_ali_voice_t *snd_ali_alloc_voice(ali_t * codec, int type, int rec, int channel)
1055{ 1076{
1056 snd_ali_voice_t *pvoice = NULL; 1077 snd_ali_voice_t *pvoice = NULL;
1057 unsigned long flags; 1078 unsigned long flags;
@@ -1061,7 +1082,8 @@ static snd_ali_voice_t *snd_ali_alloc_voice(ali_t * codec, int type, int rec)
1061 1082
1062 spin_lock_irqsave(&codec->voice_alloc, flags); 1083 spin_lock_irqsave(&codec->voice_alloc, flags);
1063 if (type == SNDRV_ALI_VOICE_TYPE_PCM) { 1084 if (type == SNDRV_ALI_VOICE_TYPE_PCM) {
1064 idx = snd_ali_find_free_channel(codec,rec); 1085 idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) :
1086 snd_ali_find_free_channel(codec,rec);
1065 if(idx < 0) { 1087 if(idx < 0) {
1066 snd_printk("ali_alloc_voice: err.\n"); 1088 snd_printk("ali_alloc_voice: err.\n");
1067 spin_unlock_irqrestore(&codec->voice_alloc, flags); 1089 spin_unlock_irqrestore(&codec->voice_alloc, flags);
@@ -1297,7 +1319,7 @@ static int snd_ali_playback_hw_params(snd_pcm_substream_t * substream,
1297 1319
1298 if (params_buffer_size(hw_params)/2 != params_period_size(hw_params)) { 1320 if (params_buffer_size(hw_params)/2 != params_period_size(hw_params)) {
1299 if (evoice == NULL) { 1321 if (evoice == NULL) {
1300 evoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, 0); 1322 evoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, 0, -1);
1301 if (evoice == NULL) 1323 if (evoice == NULL)
1302 return -ENOMEM; 1324 return -ENOMEM;
1303 pvoice->extra = evoice; 1325 pvoice->extra = evoice;
@@ -1328,13 +1350,13 @@ static int snd_ali_playback_hw_free(snd_pcm_substream_t * substream)
1328 return 0; 1350 return 0;
1329} 1351}
1330 1352
1331static int snd_ali_capture_hw_params(snd_pcm_substream_t * substream, 1353static int snd_ali_hw_params(snd_pcm_substream_t * substream,
1332 snd_pcm_hw_params_t * hw_params) 1354 snd_pcm_hw_params_t * hw_params)
1333{ 1355{
1334 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 1356 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
1335} 1357}
1336 1358
1337static int snd_ali_capture_hw_free(snd_pcm_substream_t * substream) 1359static int snd_ali_hw_free(snd_pcm_substream_t * substream)
1338{ 1360{
1339 return snd_pcm_lib_free_pages(substream); 1361 return snd_pcm_lib_free_pages(substream);
1340} 1362}
@@ -1428,7 +1450,7 @@ static int snd_ali_playback_prepare(snd_pcm_substream_t * substream)
1428} 1450}
1429 1451
1430 1452
1431static int snd_ali_capture_prepare(snd_pcm_substream_t * substream) 1453static int snd_ali_prepare(snd_pcm_substream_t * substream)
1432{ 1454{
1433 ali_t *codec = snd_pcm_substream_chip(substream); 1455 ali_t *codec = snd_pcm_substream_chip(substream);
1434 snd_pcm_runtime_t *runtime = substream->runtime; 1456 snd_pcm_runtime_t *runtime = substream->runtime;
@@ -1446,11 +1468,13 @@ static int snd_ali_capture_prepare(snd_pcm_substream_t * substream)
1446 1468
1447 spin_lock_irqsave(&codec->reg_lock, flags); 1469 spin_lock_irqsave(&codec->reg_lock, flags);
1448 1470
1449 snd_ali_printk("capture_prepare...\n"); 1471 snd_ali_printk("ali_prepare...\n");
1450 1472
1451 snd_ali_enable_special_channel(codec,pvoice->number); 1473 snd_ali_enable_special_channel(codec,pvoice->number);
1452 1474
1453 Delta = snd_ali_convert_rate(runtime->rate, 1); 1475 Delta = (pvoice->number == ALI_MODEM_IN_CHANNEL ||
1476 pvoice->number == ALI_MODEM_OUT_CHANNEL) ?
1477 0x1000 : snd_ali_convert_rate(runtime->rate, pvoice->mode);
1454 1478
1455 // Prepare capture intr channel 1479 // Prepare capture intr channel
1456 if (pvoice->number == ALI_SPDIF_IN_CHANNEL) { 1480 if (pvoice->number == ALI_SPDIF_IN_CHANNEL) {
@@ -1534,7 +1558,7 @@ static snd_pcm_uframes_t snd_ali_playback_pointer(snd_pcm_substream_t *substream
1534} 1558}
1535 1559
1536 1560
1537static snd_pcm_uframes_t snd_ali_capture_pointer(snd_pcm_substream_t *substream) 1561static snd_pcm_uframes_t snd_ali_pointer(snd_pcm_substream_t *substream)
1538{ 1562{
1539 ali_t *codec = snd_pcm_substream_chip(substream); 1563 ali_t *codec = snd_pcm_substream_chip(substream);
1540 snd_pcm_runtime_t *runtime = substream->runtime; 1564 snd_pcm_runtime_t *runtime = substream->runtime;
@@ -1616,7 +1640,8 @@ static void snd_ali_pcm_free_substream(snd_pcm_runtime_t *runtime)
1616 } 1640 }
1617} 1641}
1618 1642
1619static int snd_ali_playback_open(snd_pcm_substream_t * substream) 1643static int snd_ali_open(snd_pcm_substream_t * substream, int rec, int channel,
1644 snd_pcm_hardware_t *phw)
1620{ 1645{
1621 ali_t *codec = snd_pcm_substream_chip(substream); 1646 ali_t *codec = snd_pcm_substream_chip(substream);
1622 snd_pcm_runtime_t *runtime = substream->runtime; 1647 snd_pcm_runtime_t *runtime = substream->runtime;
@@ -1624,7 +1649,7 @@ static int snd_ali_playback_open(snd_pcm_substream_t * substream)
1624 unsigned long flags = 0; 1649 unsigned long flags = 0;
1625 1650
1626 spin_lock_irqsave(&codec->reg_lock, flags); 1651 spin_lock_irqsave(&codec->reg_lock, flags);
1627 pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, 0); 1652 pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, rec, channel);
1628 if (pvoice == NULL) { 1653 if (pvoice == NULL) {
1629 spin_unlock_irqrestore(&codec->reg_lock, flags); 1654 spin_unlock_irqrestore(&codec->reg_lock, flags);
1630 return -EAGAIN; 1655 return -EAGAIN;
@@ -1636,49 +1661,31 @@ static int snd_ali_playback_open(snd_pcm_substream_t * substream)
1636 runtime->private_data = pvoice; 1661 runtime->private_data = pvoice;
1637 runtime->private_free = snd_ali_pcm_free_substream; 1662 runtime->private_free = snd_ali_pcm_free_substream;
1638 1663
1639 runtime->hw = snd_ali_playback; 1664 runtime->hw = *phw;
1640 snd_pcm_set_sync(substream); 1665 snd_pcm_set_sync(substream);
1641 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 64*1024); 1666 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 64*1024);
1642 return 0; 1667 return 0;
1643} 1668}
1644 1669
1670static int snd_ali_playback_open(snd_pcm_substream_t * substream)
1671{
1672 return snd_ali_open(substream, 0, -1, &snd_ali_playback);
1673}
1645 1674
1646static int snd_ali_capture_open(snd_pcm_substream_t * substream) 1675static int snd_ali_capture_open(snd_pcm_substream_t * substream)
1647{ 1676{
1648 ali_t *codec = snd_pcm_substream_chip(substream); 1677 return snd_ali_open(substream, 1, -1, &snd_ali_capture);
1649 snd_pcm_runtime_t *runtime = substream->runtime;
1650 snd_ali_voice_t *pvoice;
1651 unsigned long flags;
1652
1653 spin_lock_irqsave(&codec->reg_lock, flags);
1654 pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, 1);
1655 if (pvoice == NULL) {
1656 spin_unlock_irqrestore(&codec->reg_lock, flags);
1657 return -EAGAIN;
1658 }
1659 pvoice->codec = codec;
1660 spin_unlock_irqrestore(&codec->reg_lock, flags);
1661
1662 pvoice->substream = substream;
1663 runtime->private_data = pvoice;
1664 runtime->private_free = snd_ali_pcm_free_substream;
1665 runtime->hw = snd_ali_capture;
1666 snd_pcm_set_sync(substream);
1667 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0, 64*1024);
1668 return 0;
1669} 1678}
1670 1679
1671
1672static int snd_ali_playback_close(snd_pcm_substream_t * substream) 1680static int snd_ali_playback_close(snd_pcm_substream_t * substream)
1673{ 1681{
1674 return 0; 1682 return 0;
1675} 1683}
1676 1684
1677static int snd_ali_capture_close(snd_pcm_substream_t * substream) 1685static int snd_ali_close(snd_pcm_substream_t * substream)
1678{ 1686{
1679 ali_t *codec = snd_pcm_substream_chip(substream); 1687 ali_t *codec = snd_pcm_substream_chip(substream);
1680 snd_pcm_runtime_t *runtime = substream->runtime; 1688 snd_ali_voice_t *pvoice = (snd_ali_voice_t *) substream->runtime->private_data;
1681 snd_ali_voice_t *pvoice = (snd_ali_voice_t *) runtime->private_data;
1682 1689
1683 snd_ali_disable_special_channel(codec,pvoice->number); 1690 snd_ali_disable_special_channel(codec,pvoice->number);
1684 1691
@@ -1698,29 +1705,121 @@ static snd_pcm_ops_t snd_ali_playback_ops = {
1698 1705
1699static snd_pcm_ops_t snd_ali_capture_ops = { 1706static snd_pcm_ops_t snd_ali_capture_ops = {
1700 .open = snd_ali_capture_open, 1707 .open = snd_ali_capture_open,
1701 .close = snd_ali_capture_close, 1708 .close = snd_ali_close,
1702 .ioctl = snd_ali_ioctl, 1709 .ioctl = snd_ali_ioctl,
1703 .hw_params = snd_ali_capture_hw_params, 1710 .hw_params = snd_ali_hw_params,
1704 .hw_free = snd_ali_capture_hw_free, 1711 .hw_free = snd_ali_hw_free,
1705 .prepare = snd_ali_capture_prepare, 1712 .prepare = snd_ali_prepare,
1713 .trigger = snd_ali_trigger,
1714 .pointer = snd_ali_pointer,
1715};
1716
1717/*
1718 * Modem PCM
1719 */
1720
1721static int snd_ali_modem_hw_params(snd_pcm_substream_t * substream,
1722 snd_pcm_hw_params_t * hw_params)
1723{
1724 ali_t *chip = snd_pcm_substream_chip(substream);
1725 unsigned int modem_num = chip->num_of_codecs - 1;
1726 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_RATE, params_rate(hw_params));
1727 snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_LEVEL, 0);
1728 return snd_ali_hw_params(substream, hw_params);
1729}
1730
1731static snd_pcm_hardware_t snd_ali_modem =
1732{
1733 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
1734 SNDRV_PCM_INFO_BLOCK_TRANSFER |
1735 SNDRV_PCM_INFO_MMAP_VALID |
1736 SNDRV_PCM_INFO_RESUME |
1737 SNDRV_PCM_INFO_SYNC_START),
1738 .formats = SNDRV_PCM_FMTBIT_S16_LE,
1739 .rates = SNDRV_PCM_RATE_KNOT|SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000,
1740 .rate_min = 8000,
1741 .rate_max = 16000,
1742 .channels_min = 1,
1743 .channels_max = 1,
1744 .buffer_bytes_max = (256*1024),
1745 .period_bytes_min = 64,
1746 .period_bytes_max = (256*1024),
1747 .periods_min = 1,
1748 .periods_max = 1024,
1749 .fifo_size = 0,
1750};
1751
1752static int snd_ali_modem_open(snd_pcm_substream_t * substream, int rec, int channel)
1753{
1754 static unsigned int rates [] = {8000,9600,12000,16000};
1755 static snd_pcm_hw_constraint_list_t hw_constraint_rates = {
1756 .count = ARRAY_SIZE(rates),
1757 .list = rates,
1758 .mask = 0,
1759 };
1760 int err = snd_ali_open(substream, rec, channel, &snd_ali_modem);
1761 if (err)
1762 return err;
1763 return snd_pcm_hw_constraint_list(substream->runtime, 0,
1764 SNDRV_PCM_HW_PARAM_RATE, &hw_constraint_rates);
1765}
1766
1767static int snd_ali_modem_playback_open(snd_pcm_substream_t * substream)
1768{
1769 return snd_ali_modem_open(substream, 0, ALI_MODEM_OUT_CHANNEL);
1770}
1771
1772static int snd_ali_modem_capture_open(snd_pcm_substream_t * substream)
1773{
1774 return snd_ali_modem_open(substream, 1, ALI_MODEM_IN_CHANNEL);
1775}
1776
1777static snd_pcm_ops_t snd_ali_modem_playback_ops = {
1778 .open = snd_ali_modem_playback_open,
1779 .close = snd_ali_close,
1780 .ioctl = snd_pcm_lib_ioctl,
1781 .hw_params = snd_ali_modem_hw_params,
1782 .hw_free = snd_ali_hw_free,
1783 .prepare = snd_ali_prepare,
1784 .trigger = snd_ali_trigger,
1785 .pointer = snd_ali_pointer,
1786};
1787
1788static snd_pcm_ops_t snd_ali_modem_capture_ops = {
1789 .open = snd_ali_modem_capture_open,
1790 .close = snd_ali_close,
1791 .ioctl = snd_pcm_lib_ioctl,
1792 .hw_params = snd_ali_modem_hw_params,
1793 .hw_free = snd_ali_hw_free,
1794 .prepare = snd_ali_prepare,
1706 .trigger = snd_ali_trigger, 1795 .trigger = snd_ali_trigger,
1707 .pointer = snd_ali_capture_pointer, 1796 .pointer = snd_ali_pointer,
1797};
1798
1799
1800struct ali_pcm_description {
1801 char *name;
1802 unsigned int playback_num;
1803 unsigned int capture_num;
1804 snd_pcm_ops_t *playback_ops;
1805 snd_pcm_ops_t *capture_ops;
1708}; 1806};
1709 1807
1710 1808
1711static void snd_ali_pcm_free(snd_pcm_t *pcm) 1809static void snd_ali_pcm_free(snd_pcm_t *pcm)
1712{ 1810{
1713 ali_t *codec = pcm->private_data; 1811 ali_t *codec = pcm->private_data;
1714 codec->pcm = NULL; 1812 codec->pcm[pcm->device] = NULL;
1715} 1813}
1716 1814
1717static int __devinit snd_ali_pcm(ali_t * codec, int device, snd_pcm_t ** rpcm) 1815
1816static int __devinit snd_ali_pcm(ali_t * codec, int device, struct ali_pcm_description *desc)
1718{ 1817{
1719 snd_pcm_t *pcm; 1818 snd_pcm_t *pcm;
1720 int err; 1819 int err;
1721 1820
1722 if (rpcm) *rpcm = NULL; 1821 err = snd_pcm_new(codec->card, desc->name, device,
1723 err = snd_pcm_new(codec->card, "ALI 5451", device, ALI_CHANNELS, 1, &pcm); 1822 desc->playback_num, desc->capture_num, &pcm);
1724 if (err < 0) { 1823 if (err < 0) {
1725 snd_printk("snd_ali_pcm: err called snd_pcm_new.\n"); 1824 snd_printk("snd_ali_pcm: err called snd_pcm_new.\n");
1726 return err; 1825 return err;
@@ -1728,20 +1827,36 @@ static int __devinit snd_ali_pcm(ali_t * codec, int device, snd_pcm_t ** rpcm)
1728 pcm->private_data = codec; 1827 pcm->private_data = codec;
1729 pcm->private_free = snd_ali_pcm_free; 1828 pcm->private_free = snd_ali_pcm_free;
1730 pcm->info_flags = 0; 1829 pcm->info_flags = 0;
1731 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ali_playback_ops); 1830 if (desc->playback_ops)
1732 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ali_capture_ops); 1831 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, desc->playback_ops);
1832 if (desc->capture_ops)
1833 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, desc->capture_ops);
1733 1834
1734 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 1835 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1735 snd_dma_pci_data(codec->pci), 64*1024, 128*1024); 1836 snd_dma_pci_data(codec->pci), 64*1024, 128*1024);
1736 1837
1737 pcm->info_flags = 0; 1838 pcm->info_flags = 0;
1738 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; 1839 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX;
1739 strcpy(pcm->name, "ALI 5451"); 1840 strcpy(pcm->name, desc->name);
1740 codec->pcm = pcm; 1841 codec->pcm[0] = pcm;
1741 if (rpcm) *rpcm = pcm;
1742 return 0; 1842 return 0;
1743} 1843}
1744 1844
1845struct ali_pcm_description ali_pcms[] = {
1846 { "ALI 5451", ALI_CHANNELS, 1, &snd_ali_playback_ops, &snd_ali_capture_ops },
1847 { "ALI 5451 modem", 1, 1, &snd_ali_modem_playback_ops, &snd_ali_modem_capture_ops }
1848};
1849
1850static int __devinit snd_ali_build_pcms(ali_t *codec)
1851{
1852 int i, err;
1853 for(i = 0 ; i < codec->num_of_codecs && i < ARRAY_SIZE(ali_pcms) ; i++)
1854 if((err = snd_ali_pcm(codec, i, &ali_pcms[i])) < 0)
1855 return err;
1856 return 0;
1857}
1858
1859
1745#define ALI5451_SPDIF(xname, xindex, value) \ 1860#define ALI5451_SPDIF(xname, xindex, value) \
1746{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\ 1861{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex,\
1747.info = snd_ali5451_spdif_info, .get = snd_ali5451_spdif_get, \ 1862.info = snd_ali5451_spdif_info, .get = snd_ali5451_spdif_get, \
@@ -1860,14 +1975,14 @@ static void snd_ali_mixer_free_ac97_bus(ac97_bus_t *bus)
1860static void snd_ali_mixer_free_ac97(ac97_t *ac97) 1975static void snd_ali_mixer_free_ac97(ac97_t *ac97)
1861{ 1976{
1862 ali_t *codec = ac97->private_data; 1977 ali_t *codec = ac97->private_data;
1863 codec->ac97 = NULL; 1978 codec->ac97[ac97->num] = NULL;
1864} 1979}
1865 1980
1866static int __devinit snd_ali_mixer(ali_t * codec) 1981static int __devinit snd_ali_mixer(ali_t * codec)
1867{ 1982{
1868 ac97_template_t ac97; 1983 ac97_template_t ac97;
1869 unsigned int idx; 1984 unsigned int idx;
1870 int err; 1985 int i, err;
1871 static ac97_bus_ops_t ops = { 1986 static ac97_bus_ops_t ops = {
1872 .write = snd_ali_codec_write, 1987 .write = snd_ali_codec_write,
1873 .read = snd_ali_codec_read, 1988 .read = snd_ali_codec_read,
@@ -1880,10 +1995,16 @@ static int __devinit snd_ali_mixer(ali_t * codec)
1880 memset(&ac97, 0, sizeof(ac97)); 1995 memset(&ac97, 0, sizeof(ac97));
1881 ac97.private_data = codec; 1996 ac97.private_data = codec;
1882 ac97.private_free = snd_ali_mixer_free_ac97; 1997 ac97.private_free = snd_ali_mixer_free_ac97;
1883 if ((err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97)) < 0) { 1998
1884 snd_printk("ali mixer creating error.\n"); 1999 for ( i = 0 ; i < codec->num_of_codecs ; i++) {
2000 ac97.num = i;
2001 if ((err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i])) < 0) {
2002 snd_printk("ali mixer %d creating error.\n", i);
2003 if(i == 0)
1885 return err; 2004 return err;
1886 } 2005 }
2006 }
2007
1887 if (codec->spdif_support) { 2008 if (codec->spdif_support) {
1888 for(idx = 0; idx < ARRAY_SIZE(snd_ali5451_mixer_spdif); idx++) { 2009 for(idx = 0; idx < ARRAY_SIZE(snd_ali5451_mixer_spdif); idx++) {
1889 err=snd_ctl_add(codec->card, snd_ctl_new1(&snd_ali5451_mixer_spdif[idx], codec)); 2010 err=snd_ctl_add(codec->card, snd_ctl_new1(&snd_ali5451_mixer_spdif[idx], codec));
@@ -1904,8 +2025,12 @@ static int ali_suspend(snd_card_t *card, pm_message_t state)
1904 if (! im) 2025 if (! im)
1905 return 0; 2026 return 0;
1906 2027
1907 snd_pcm_suspend_all(chip->pcm); 2028 for(i = 0 ; i < chip->num_of_codecs ; i++) {
1908 snd_ac97_suspend(chip->ac97); 2029 if (chip->pcm[i])
2030 snd_pcm_suspend_all(chip->pcm[i]);
2031 if(chip->ac97[i])
2032 snd_ac97_suspend(chip->ac97[i]);
2033 }
1909 2034
1910 spin_lock_irq(&chip->reg_lock); 2035 spin_lock_irq(&chip->reg_lock);
1911 2036
@@ -1969,7 +2094,9 @@ static int ali_resume(snd_card_t *card)
1969 2094
1970 spin_unlock_irq(&chip->reg_lock); 2095 spin_unlock_irq(&chip->reg_lock);
1971 2096
1972 snd_ac97_resume(chip->ac97); 2097 for(i = 0 ; i < chip->num_of_codecs ; i++)
2098 if(chip->ac97[i])
2099 snd_ac97_resume(chip->ac97[i]);
1973 2100
1974 return 0; 2101 return 0;
1975} 2102}
@@ -2036,11 +2163,37 @@ static int snd_ali_chip_init(ali_t *codec)
2036 codec->spdif_mask = 0x00000002; 2163 codec->spdif_mask = 0x00000002;
2037 } 2164 }
2038 2165
2166 codec->num_of_codecs = 1;
2167
2168 /* secondary codec - modem */
2169 if (inl(ALI_REG(codec, ALI_SCTRL)) & ALI_SCTRL_CODEC2_READY) {
2170 codec->num_of_codecs++;
2171 outl(inl(ALI_REG(codec, ALI_SCTRL)) |
2172 (ALI_SCTRL_LINE_IN2|ALI_SCTRL_GPIO_IN2|ALI_SCTRL_LINE_OUT_EN),
2173 ALI_REG(codec, ALI_SCTRL));
2174 }
2175
2039 snd_ali_printk("chip initialize succeed.\n"); 2176 snd_ali_printk("chip initialize succeed.\n");
2040 return 0; 2177 return 0;
2041 2178
2042} 2179}
2043 2180
2181/* proc for register dump */
2182static void snd_ali_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buf)
2183{
2184 ali_t *codec = entry->private_data;
2185 int i;
2186 for(i = 0 ; i < 256 ; i+= 4)
2187 snd_iprintf(buf, "%02x: %08x\n", i, inl(ALI_REG(codec, i)));
2188}
2189
2190static void __devinit snd_ali_proc_init(ali_t *codec)
2191{
2192 snd_info_entry_t *entry;
2193 if(!snd_card_proc_new(codec->card, "ali5451", &entry))
2194 snd_info_set_text_ops(entry, codec, 1024, snd_ali_proc_read);
2195}
2196
2044static int __devinit snd_ali_resources(ali_t *codec) 2197static int __devinit snd_ali_resources(ali_t *codec)
2045{ 2198{
2046 int err; 2199 int err;
@@ -2233,11 +2386,13 @@ static int __devinit snd_ali_probe(struct pci_dev *pci,
2233 } 2386 }
2234 2387
2235 snd_ali_printk("pcm building ...\n"); 2388 snd_ali_printk("pcm building ...\n");
2236 if ((err = snd_ali_pcm(codec, 0, NULL)) < 0) { 2389 if ((err = snd_ali_build_pcms(codec)) < 0) {
2237 snd_card_free(card); 2390 snd_card_free(card);
2238 return err; 2391 return err;
2239 } 2392 }
2240 2393
2394 snd_ali_proc_init(codec);
2395
2241 strcpy(card->driver, "ALI5451"); 2396 strcpy(card->driver, "ALI5451");
2242 strcpy(card->shortname, "ALI 5451"); 2397 strcpy(card->shortname, "ALI 5451");
2243 2398
@@ -2270,7 +2425,7 @@ static struct pci_driver driver = {
2270 2425
2271static int __init alsa_card_ali_init(void) 2426static int __init alsa_card_ali_init(void)
2272{ 2427{
2273 return pci_module_init(&driver); 2428 return pci_register_driver(&driver);
2274} 2429}
2275 2430
2276static void __exit alsa_card_ali_exit(void) 2431static void __exit alsa_card_ali_exit(void)
diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c
index f1a5f5723ee6..ca28b229c704 100644
--- a/sound/pci/als4000.c
+++ b/sound/pci/als4000.c
@@ -367,7 +367,7 @@ static irqreturn_t snd_als4000_interrupt(int irq, void *dev_id, struct pt_regs *
367 if ((gcr_status & 0x40) && (chip->capture_substream)) /* capturing */ 367 if ((gcr_status & 0x40) && (chip->capture_substream)) /* capturing */
368 snd_pcm_period_elapsed(chip->capture_substream); 368 snd_pcm_period_elapsed(chip->capture_substream);
369 if ((gcr_status & 0x10) && (chip->rmidi)) /* MPU401 interrupt */ 369 if ((gcr_status & 0x10) && (chip->rmidi)) /* MPU401 interrupt */
370 snd_mpu401_uart_interrupt(irq, chip->rmidi, regs); 370 snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data, regs);
371 /* release the gcr */ 371 /* release the gcr */
372 outb(gcr_status, chip->alt_port + 0xe); 372 outb(gcr_status, chip->alt_port + 0xe);
373 373
@@ -777,7 +777,7 @@ static struct pci_driver driver = {
777 777
778static int __init alsa_card_als4000_init(void) 778static int __init alsa_card_als4000_init(void)
779{ 779{
780 return pci_module_init(&driver); 780 return pci_register_driver(&driver);
781} 781}
782 782
783static void __exit alsa_card_als4000_exit(void) 783static void __exit alsa_card_als4000_exit(void)
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index 6b04c0acc6f7..cafab4af5c57 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -1334,8 +1334,8 @@ static irqreturn_t snd_atiixp_interrupt(int irq, void *dev_id, struct pt_regs *r
1334 1334
1335static struct ac97_quirk ac97_quirks[] __devinitdata = { 1335static struct ac97_quirk ac97_quirks[] __devinitdata = {
1336 { 1336 {
1337 .vendor = 0x103c, 1337 .subvendor = 0x103c,
1338 .device = 0x006b, 1338 .subdevice = 0x006b,
1339 .name = "HP Pavilion ZV5030US", 1339 .name = "HP Pavilion ZV5030US",
1340 .type = AC97_TUNE_MUTE_LED 1340 .type = AC97_TUNE_MUTE_LED
1341 }, 1341 },
@@ -1645,7 +1645,7 @@ static struct pci_driver driver = {
1645 1645
1646static int __init alsa_card_atiixp_init(void) 1646static int __init alsa_card_atiixp_init(void)
1647{ 1647{
1648 return pci_module_init(&driver); 1648 return pci_register_driver(&driver);
1649} 1649}
1650 1650
1651static void __exit alsa_card_atiixp_exit(void) 1651static void __exit alsa_card_atiixp_exit(void)
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index fb7cecea846d..a6b4b8d589fd 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -463,6 +463,11 @@ static unsigned short snd_atiixp_ac97_read(ac97_t *ac97, unsigned short reg)
463static void snd_atiixp_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) 463static void snd_atiixp_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val)
464{ 464{
465 atiixp_t *chip = ac97->private_data; 465 atiixp_t *chip = ac97->private_data;
466 if (reg == AC97_GPIO_STATUS) {
467 atiixp_write(chip, MODEM_OUT_GPIO,
468 (val << ATI_REG_MODEM_OUT_GPIO_DATA_SHIFT) | ATI_REG_MODEM_OUT_GPIO_EN);
469 return;
470 }
466 snd_atiixp_codec_write(chip, ac97->num, reg, val); 471 snd_atiixp_codec_write(chip, ac97->num, reg, val);
467} 472}
468 473
@@ -663,44 +668,33 @@ static int snd_atiixp_pcm_trigger(snd_pcm_substream_t *substream, int cmd)
663{ 668{
664 atiixp_t *chip = snd_pcm_substream_chip(substream); 669 atiixp_t *chip = snd_pcm_substream_chip(substream);
665 atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data; 670 atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data;
666 unsigned int reg = 0; 671 int err = 0;
667 int i;
668 672
669 snd_assert(dma->ops->enable_transfer && dma->ops->flush_dma, return -EINVAL); 673 snd_assert(dma->ops->enable_transfer && dma->ops->flush_dma, return -EINVAL);
670 674
671 if (cmd != SNDRV_PCM_TRIGGER_START && cmd != SNDRV_PCM_TRIGGER_STOP)
672 return -EINVAL;
673
674 spin_lock(&chip->reg_lock); 675 spin_lock(&chip->reg_lock);
675 676 switch(cmd) {
676 /* hook off/on: via GPIO_OUT */ 677 case SNDRV_PCM_TRIGGER_START:
677 for (i = 0; i < NUM_ATI_CODECS; i++) {
678 if (chip->ac97[i]) {
679 reg = snd_ac97_read(chip->ac97[i], AC97_GPIO_STATUS);
680 break;
681 }
682 }
683 if(cmd == SNDRV_PCM_TRIGGER_START)
684 reg |= AC97_GPIO_LINE1_OH;
685 else
686 reg &= ~AC97_GPIO_LINE1_OH;
687 reg = (reg << ATI_REG_MODEM_OUT_GPIO_DATA_SHIFT) | ATI_REG_MODEM_OUT_GPIO_EN ;
688 atiixp_write(chip, MODEM_OUT_GPIO, reg);
689
690 if (cmd == SNDRV_PCM_TRIGGER_START) {
691 dma->ops->enable_transfer(chip, 1); 678 dma->ops->enable_transfer(chip, 1);
692 dma->running = 1; 679 dma->running = 1;
693 } else { 680 break;
681 case SNDRV_PCM_TRIGGER_STOP:
694 dma->ops->enable_transfer(chip, 0); 682 dma->ops->enable_transfer(chip, 0);
695 dma->running = 0; 683 dma->running = 0;
684 break;
685 default:
686 err = -EINVAL;
687 break;
696 } 688 }
689 if (! err) {
697 snd_atiixp_check_bus_busy(chip); 690 snd_atiixp_check_bus_busy(chip);
698 if (cmd == SNDRV_PCM_TRIGGER_STOP) { 691 if (cmd == SNDRV_PCM_TRIGGER_STOP) {
699 dma->ops->flush_dma(chip); 692 dma->ops->flush_dma(chip);
700 snd_atiixp_check_bus_busy(chip); 693 snd_atiixp_check_bus_busy(chip);
701 } 694 }
695 }
702 spin_unlock(&chip->reg_lock); 696 spin_unlock(&chip->reg_lock);
703 return 0; 697 return err;
704} 698}
705 699
706 700
@@ -1332,7 +1326,7 @@ static struct pci_driver driver = {
1332 1326
1333static int __init alsa_card_atiixp_init(void) 1327static int __init alsa_card_atiixp_init(void)
1334{ 1328{
1335 return pci_module_init(&driver); 1329 return pci_register_driver(&driver);
1336} 1330}
1337 1331
1338static void __exit alsa_card_atiixp_exit(void) 1332static void __exit alsa_card_atiixp_exit(void)
diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c
index 889b4a1a51a1..f6236c63aaaa 100644
--- a/sound/pci/au88x0/au88x0.c
+++ b/sound/pci/au88x0/au88x0.c
@@ -375,7 +375,7 @@ static struct pci_driver driver = {
375// initialization of the module 375// initialization of the module
376static int __init alsa_card_vortex_init(void) 376static int __init alsa_card_vortex_init(void)
377{ 377{
378 return pci_module_init(&driver); 378 return pci_register_driver(&driver);
379} 379}
380 380
381// clean up the module 381// clean up the module
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index b8ae534125c1..72bba7b2d983 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -1520,7 +1520,7 @@ static int __init alsa_card_azf3328_init(void)
1520{ 1520{
1521 int err; 1521 int err;
1522 snd_azf3328_dbgcallenter(); 1522 snd_azf3328_dbgcallenter();
1523 err = pci_module_init(&driver); 1523 err = pci_register_driver(&driver);
1524 snd_azf3328_dbgcallleave(); 1524 snd_azf3328_dbgcallleave();
1525 return err; 1525 return err;
1526} 1526}
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index 89a7ffe5e7d7..defdc5a459f0 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -918,7 +918,7 @@ static int __init alsa_card_bt87x_init(void)
918{ 918{
919 if (load_all) 919 if (load_all)
920 driver.id_table = snd_bt87x_default_ids; 920 driver.id_table = snd_bt87x_default_ids;
921 return pci_module_init(&driver); 921 return pci_register_driver(&driver);
922} 922}
923 923
924static void __exit alsa_card_bt87x_exit(void) 924static void __exit alsa_card_bt87x_exit(void)
diff --git a/sound/pci/ca0106/ca0106.h b/sound/pci/ca0106/ca0106.h
index deb028851056..da09cab405a9 100644
--- a/sound/pci/ca0106/ca0106.h
+++ b/sound/pci/ca0106/ca0106.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk> 2 * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk>
3 * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit 3 * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit
4 * Version: 0.0.20 4 * Version: 0.0.21
5 * 5 *
6 * FEATURES currently supported: 6 * FEATURES currently supported:
7 * See ca0106_main.c for features. 7 * See ca0106_main.c for features.
@@ -45,6 +45,8 @@
45 * Added I2C and SPI registers. Filled in interrupt enable. 45 * Added I2C and SPI registers. Filled in interrupt enable.
46 * 0.0.20 46 * 0.0.20
47 * Added GPIO info for SB Live 24bit. 47 * Added GPIO info for SB Live 24bit.
48 * 0.0.21
49 * Implement support for Line-in capture on SB Live 24bit.
48 * 50 *
49 * 51 *
50 * This code was initally based on code from ALSA's emu10k1x.c which is: 52 * This code was initally based on code from ALSA's emu10k1x.c which is:
@@ -152,7 +154,7 @@
152 * bit 9 0 = Mute / 1 = Analog out. 154 * bit 9 0 = Mute / 1 = Analog out.
153 * bit 10 0 = Line-in / 1 = Mic-in. 155 * bit 10 0 = Line-in / 1 = Mic-in.
154 * bit 11 0 = ? / 1 = ? 156 * bit 11 0 = ? / 1 = ?
155 * bit 12 0 = ? / 1 = ? 157 * bit 12 0 = 48 Khz / 1 = 96 Khz Analog out on SB Live 24bit.
156 * bit 13 0 = ? / 1 = ? 158 * bit 13 0 = ? / 1 = ?
157 * bit 14 0 = Mute / 1 = Analog out 159 * bit 14 0 = Mute / 1 = Analog out
158 * bit 15 0 = ? / 1 = ? 160 * bit 15 0 = ? / 1 = ?
@@ -475,9 +477,56 @@
475 /* Causes interrupts based on timer intervals. */ 477 /* Causes interrupts based on timer intervals. */
476#define SPI 0x7a /* SPI: Serial Interface Register */ 478#define SPI 0x7a /* SPI: Serial Interface Register */
477#define I2C_A 0x7b /* I2C Address. 32 bit */ 479#define I2C_A 0x7b /* I2C Address. 32 bit */
478#define I2C_0 0x7c /* I2C Data Port 0. 32 bit */ 480#define I2C_D0 0x7c /* I2C Data Port 0. 32 bit */
479#define I2C_1 0x7d /* I2C Data Port 1. 32 bit */ 481#define I2C_D1 0x7d /* I2C Data Port 1. 32 bit */
482//I2C values
483#define I2C_A_ADC_ADD_MASK 0x000000fe //The address is a 7 bit address
484#define I2C_A_ADC_RW_MASK 0x00000001 //bit mask for R/W
485#define I2C_A_ADC_TRANS_MASK 0x00000010 //Bit mask for I2c address DAC value
486#define I2C_A_ADC_ABORT_MASK 0x00000020 //Bit mask for I2C transaction abort flag
487#define I2C_A_ADC_LAST_MASK 0x00000040 //Bit mask for Last word transaction
488#define I2C_A_ADC_BYTE_MASK 0x00000080 //Bit mask for Byte Mode
480 489
490#define I2C_A_ADC_ADD 0x00000034 //This is the Device address for ADC
491#define I2C_A_ADC_READ 0x00000001 //To perform a read operation
492#define I2C_A_ADC_START 0x00000100 //Start I2C transaction
493#define I2C_A_ADC_ABORT 0x00000200 //I2C transaction abort
494#define I2C_A_ADC_LAST 0x00000400 //I2C last transaction
495#define I2C_A_ADC_BYTE 0x00000800 //I2C one byte mode
496
497#define I2C_D_ADC_REG_MASK 0xfe000000 //ADC address register
498#define I2C_D_ADC_DAT_MASK 0x01ff0000 //ADC data register
499
500#define ADC_TIMEOUT 0x00000007 //ADC Timeout Clock Disable
501#define ADC_IFC_CTRL 0x0000000b //ADC Interface Control
502#define ADC_MASTER 0x0000000c //ADC Master Mode Control
503#define ADC_POWER 0x0000000d //ADC PowerDown Control
504#define ADC_ATTEN_ADCL 0x0000000e //ADC Attenuation ADCL
505#define ADC_ATTEN_ADCR 0x0000000f //ADC Attenuation ADCR
506#define ADC_ALC_CTRL1 0x00000010 //ADC ALC Control 1
507#define ADC_ALC_CTRL2 0x00000011 //ADC ALC Control 2
508#define ADC_ALC_CTRL3 0x00000012 //ADC ALC Control 3
509#define ADC_NOISE_CTRL 0x00000013 //ADC Noise Gate Control
510#define ADC_LIMIT_CTRL 0x00000014 //ADC Limiter Control
511#define ADC_MUX 0x00000015 //ADC Mux offset
512
513#if 0
514/* FIXME: Not tested yet. */
515#define ADC_GAIN_MASK 0x000000ff //Mask for ADC Gain
516#define ADC_ZERODB 0x000000cf //Value to set ADC to 0dB
517#define ADC_MUTE_MASK 0x000000c0 //Mask for ADC mute
518#define ADC_MUTE 0x000000c0 //Value to mute ADC
519#define ADC_OSR 0x00000008 //Mask for ADC oversample rate select
520#define ADC_TIMEOUT_DISABLE 0x00000008 //Value and mask to disable Timeout clock
521#define ADC_HPF_DISABLE 0x00000100 //Value and mask to disable High pass filter
522#define ADC_TRANWIN_MASK 0x00000070 //Mask for Length of Transient Window
523#endif
524
525#define ADC_MUX_MASK 0x0000000f //Mask for ADC Mux
526#define ADC_MUX_MIC 0x00000002 //Value to select Mic at ADC Mux
527#define ADC_MUX_LINEIN 0x00000004 //Value to select LineIn at ADC Mux
528#define ADC_MUX_PHONE 0x00000001 //Value to select TAD at ADC Mux (Not used)
529#define ADC_MUX_AUX 0x00000008 //Value to select Aux at ADC Mux
481 530
482#define SET_CHANNEL 0 /* Testing channel outputs 0=Front, 1=Center/LFE, 2=Unknown, 3=Rear */ 531#define SET_CHANNEL 0 /* Testing channel outputs 0=Front, 1=Center/LFE, 2=Unknown, 3=Rear */
483#define PCM_FRONT_CHANNEL 0 532#define PCM_FRONT_CHANNEL 0
@@ -508,9 +557,18 @@ struct snd_ca0106_pcm {
508 unsigned short running; 557 unsigned short running;
509}; 558};
510 559
560typedef struct {
561 u32 serial;
562 char * name;
563 int ac97;
564 int gpio_type;
565 int i2c_adc;
566} ca0106_details_t;
567
511// definition of the chip-specific record 568// definition of the chip-specific record
512struct snd_ca0106 { 569struct snd_ca0106 {
513 snd_card_t *card; 570 snd_card_t *card;
571 ca0106_details_t *details;
514 struct pci_dev *pci; 572 struct pci_dev *pci;
515 573
516 unsigned long port; 574 unsigned long port;
@@ -531,6 +589,7 @@ struct snd_ca0106 {
531 u32 spdif_bits[4]; /* s/pdif out setup */ 589 u32 spdif_bits[4]; /* s/pdif out setup */
532 int spdif_enable; 590 int spdif_enable;
533 int capture_source; 591 int capture_source;
592 int capture_mic_line_in;
534 593
535 struct snd_dma_buffer buffer; 594 struct snd_dma_buffer buffer;
536}; 595};
@@ -547,3 +606,6 @@ void snd_ca0106_ptr_write(ca0106_t *emu,
547 unsigned int chn, 606 unsigned int chn,
548 unsigned int data); 607 unsigned int data);
549 608
609int snd_ca0106_i2c_write(ca0106_t *emu, u32 reg, u32 value);
610
611
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index 82533b45bc8c..95c289284267 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk> 2 * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk>
3 * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit 3 * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit
4 * Version: 0.0.22 4 * Version: 0.0.23
5 * 5 *
6 * FEATURES currently supported: 6 * FEATURES currently supported:
7 * Front, Rear and Center/LFE. 7 * Front, Rear and Center/LFE.
@@ -77,6 +77,8 @@
77 * Add SPDIF capture using optional digital I/O module for SB Live 24bit. (Analog capture does not yet work.) 77 * Add SPDIF capture using optional digital I/O module for SB Live 24bit. (Analog capture does not yet work.)
78 * 0.0.22 78 * 0.0.22
79 * Add support for MSI K8N Diamond Motherboard with onboard SB Live 24bit without AC97. From kiksen, bug #901 79 * Add support for MSI K8N Diamond Motherboard with onboard SB Live 24bit without AC97. From kiksen, bug #901
80 * 0.0.23
81 * Implement support for Line-in capture on SB Live 24bit.
80 * 82 *
81 * BUGS: 83 * BUGS:
82 * Some stability problems when unloading the snd-ca0106 kernel module. 84 * Some stability problems when unloading the snd-ca0106 kernel module.
@@ -136,6 +138,7 @@
136#include <linux/pci.h> 138#include <linux/pci.h>
137#include <linux/slab.h> 139#include <linux/slab.h>
138#include <linux/moduleparam.h> 140#include <linux/moduleparam.h>
141#include <linux/dma-mapping.h>
139#include <sound/core.h> 142#include <sound/core.h>
140#include <sound/initval.h> 143#include <sound/initval.h>
141#include <sound/pcm.h> 144#include <sound/pcm.h>
@@ -161,18 +164,32 @@ MODULE_PARM_DESC(enable, "Enable the CA0106 soundcard.");
161 164
162#include "ca0106.h" 165#include "ca0106.h"
163 166
164typedef struct { 167static ca0106_details_t ca0106_chip_details[] = {
165 u32 serial; 168 /* AudigyLS[SB0310] */
166 char * name; 169 { .serial = 0x10021102,
167} ca0106_names_t; 170 .name = "AudigyLS [SB0310]",
168 171 .ac97 = 1 } ,
169static ca0106_names_t ca0106_chip_names[] = { 172 /* Unknown AudigyLS that also says SB0310 on it */
170 { 0x10021102, "AudigyLS [SB0310]"} , 173 { .serial = 0x10051102,
171 { 0x10051102, "AudigyLS [SB0310b]"} , /* Unknown AudigyLS that also says SB0310 on it */ 174 .name = "AudigyLS [SB0310b]",
172 { 0x10061102, "Live! 7.1 24bit [SB0410]"} , /* New Sound Blaster Live! 7.1 24bit. This does not have an AC97. 53SB041000001 */ 175 .ac97 = 1 } ,
173 { 0x10071102, "Live! 7.1 24bit [SB0413]"} , /* New Dell Sound Blaster Live! 7.1 24bit. This does not have an AC97. */ 176 /* New Sound Blaster Live! 7.1 24bit. This does not have an AC97. 53SB041000001 */
174 { 0x10091462, "MSI K8N Diamond MB [SB0438]"}, /* MSI K8N Diamond Motherboard with onboard SB Live 24bit without AC97 */ 177 { .serial = 0x10061102,
175 { 0, "AudigyLS [Unknown]" } 178 .name = "Live! 7.1 24bit [SB0410]",
179 .gpio_type = 1,
180 .i2c_adc = 1 } ,
181 /* New Dell Sound Blaster Live! 7.1 24bit. This does not have an AC97. */
182 { .serial = 0x10071102,
183 .name = "Live! 7.1 24bit [SB0413]",
184 .gpio_type = 1,
185 .i2c_adc = 1 } ,
186 /* MSI K8N Diamond Motherboard with onboard SB Live 24bit without AC97 */
187 { .serial = 0x10091462,
188 .name = "MSI K8N Diamond MB [SB0438]",
189 .gpio_type = 1,
190 .i2c_adc = 1 } ,
191 { .serial = 0,
192 .name = "AudigyLS [Unknown]" }
176}; 193};
177 194
178/* hardware definition */ 195/* hardware definition */
@@ -200,10 +217,10 @@ static snd_pcm_hardware_t snd_ca0106_capture_hw = {
200 SNDRV_PCM_INFO_INTERLEAVED | 217 SNDRV_PCM_INFO_INTERLEAVED |
201 SNDRV_PCM_INFO_BLOCK_TRANSFER | 218 SNDRV_PCM_INFO_BLOCK_TRANSFER |
202 SNDRV_PCM_INFO_MMAP_VALID), 219 SNDRV_PCM_INFO_MMAP_VALID),
203 .formats = SNDRV_PCM_FMTBIT_S16_LE, 220 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
204 .rates = SNDRV_PCM_RATE_48000, 221 .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000,
205 .rate_min = 48000, 222 .rate_min = 44100,
206 .rate_max = 48000, 223 .rate_max = 192000,
207 .channels_min = 2, 224 .channels_min = 2,
208 .channels_max = 2, 225 .channels_max = 2,
209 .buffer_bytes_max = ((65536 - 64) * 8), 226 .buffer_bytes_max = ((65536 - 64) * 8),
@@ -246,6 +263,62 @@ void snd_ca0106_ptr_write(ca0106_t *emu,
246 spin_unlock_irqrestore(&emu->emu_lock, flags); 263 spin_unlock_irqrestore(&emu->emu_lock, flags);
247} 264}
248 265
266int snd_ca0106_i2c_write(ca0106_t *emu,
267 u32 reg,
268 u32 value)
269{
270 u32 tmp;
271 int timeout=0;
272 int status;
273 int retry;
274 if ((reg > 0x7f) || (value > 0x1ff))
275 {
276 snd_printk("i2c_write: invalid values.\n");
277 return -EINVAL;
278 }
279
280 tmp = reg << 25 | value << 16;
281 /* Not sure what this I2C channel controls. */
282 /* snd_ca0106_ptr_write(emu, I2C_D0, 0, tmp); */
283
284 /* This controls the I2C connected to the WM8775 ADC Codec */
285 snd_ca0106_ptr_write(emu, I2C_D1, 0, tmp);
286
287 for(retry=0;retry<10;retry++)
288 {
289 /* Send the data to i2c */
290 tmp = snd_ca0106_ptr_read(emu, I2C_A, 0);
291 tmp = tmp & ~(I2C_A_ADC_READ|I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD_MASK);
292 tmp = tmp | (I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD);
293 snd_ca0106_ptr_write(emu, I2C_A, 0, tmp);
294
295 /* Wait till the transaction ends */
296 while(1)
297 {
298 status = snd_ca0106_ptr_read(emu, I2C_A, 0);
299 //snd_printk("I2C:status=0x%x\n", status);
300 timeout++;
301 if((status & I2C_A_ADC_START)==0)
302 break;
303
304 if(timeout>1000)
305 break;
306 }
307 //Read back and see if the transaction is successful
308 if((status & I2C_A_ADC_ABORT)==0)
309 break;
310 }
311
312 if(retry==10)
313 {
314 snd_printk("Writing to ADC failed!\n");
315 return -EINVAL;
316 }
317
318 return 0;
319}
320
321
249static void snd_ca0106_intr_enable(ca0106_t *emu, unsigned int intrenb) 322static void snd_ca0106_intr_enable(ca0106_t *emu, unsigned int intrenb)
250{ 323{
251 unsigned long flags; 324 unsigned long flags;
@@ -259,11 +332,7 @@ static void snd_ca0106_intr_enable(ca0106_t *emu, unsigned int intrenb)
259 332
260static void snd_ca0106_pcm_free_substream(snd_pcm_runtime_t *runtime) 333static void snd_ca0106_pcm_free_substream(snd_pcm_runtime_t *runtime)
261{ 334{
262 ca0106_pcm_t *epcm = runtime->private_data; 335 kfree(runtime->private_data);
263
264 if (epcm) {
265 kfree(epcm);
266 }
267} 336}
268 337
269/* open_playback callback */ 338/* open_playback callback */
@@ -538,6 +607,61 @@ static int snd_ca0106_pcm_prepare_capture(snd_pcm_substream_t *substream)
538 snd_pcm_runtime_t *runtime = substream->runtime; 607 snd_pcm_runtime_t *runtime = substream->runtime;
539 ca0106_pcm_t *epcm = runtime->private_data; 608 ca0106_pcm_t *epcm = runtime->private_data;
540 int channel = epcm->channel_id; 609 int channel = epcm->channel_id;
610 u32 hcfg_mask = HCFG_CAPTURE_S32_LE;
611 u32 hcfg_set = 0x00000000;
612 u32 hcfg;
613 u32 over_sampling=0x2;
614 u32 reg71_mask = 0x0000c000 ; /* Global. Set ADC rate. */
615 u32 reg71_set = 0;
616 u32 reg71;
617
618 //snd_printk("prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, periods=%u, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, runtime->periods, frames_to_bytes(runtime, 1));
619 //snd_printk("dma_addr=%x, dma_area=%p, table_base=%p\n",runtime->dma_addr, runtime->dma_area, table_base);
620 //snd_printk("dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",emu->buffer.addr, emu->buffer.area, emu->buffer.bytes);
621 /* reg71 controls ADC rate. */
622 switch (runtime->rate) {
623 case 44100:
624 reg71_set = 0x00004000;
625 break;
626 case 48000:
627 reg71_set = 0;
628 break;
629 case 96000:
630 reg71_set = 0x00008000;
631 over_sampling=0xa;
632 break;
633 case 192000:
634 reg71_set = 0x0000c000;
635 over_sampling=0xa;
636 break;
637 default:
638 reg71_set = 0;
639 break;
640 }
641 /* Format is a global setting */
642 /* FIXME: Only let the first channel accessed set this. */
643 switch (runtime->format) {
644 case SNDRV_PCM_FORMAT_S16_LE:
645 hcfg_set = 0;
646 break;
647 case SNDRV_PCM_FORMAT_S32_LE:
648 hcfg_set = HCFG_CAPTURE_S32_LE;
649 break;
650 default:
651 hcfg_set = 0;
652 break;
653 }
654 hcfg = inl(emu->port + HCFG) ;
655 hcfg = (hcfg & ~hcfg_mask) | hcfg_set;
656 outl(hcfg, emu->port + HCFG);
657 reg71 = snd_ca0106_ptr_read(emu, 0x71, 0);
658 reg71 = (reg71 & ~reg71_mask) | reg71_set;
659 snd_ca0106_ptr_write(emu, 0x71, 0, reg71);
660 if (emu->details->i2c_adc == 1) { /* The SB0410 and SB0413 use I2C to control ADC. */
661 snd_ca0106_i2c_write(emu, ADC_MASTER, over_sampling); /* Adjust the over sampler to better suit the capture rate. */
662 }
663
664
541 //printk("prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, frames_to_bytes(runtime, 1)); 665 //printk("prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, frames_to_bytes(runtime, 1));
542 snd_ca0106_ptr_write(emu, 0x13, channel, 0); 666 snd_ca0106_ptr_write(emu, 0x13, channel, 0);
543 snd_ca0106_ptr_write(emu, CAPTURE_DMA_ADDR, channel, runtime->dma_addr); 667 snd_ca0106_ptr_write(emu, CAPTURE_DMA_ADDR, channel, runtime->dma_addr);
@@ -810,6 +934,7 @@ static int snd_ca0106_ac97(ca0106_t *chip)
810 934
811 memset(&ac97, 0, sizeof(ac97)); 935 memset(&ac97, 0, sizeof(ac97));
812 ac97.private_data = chip; 936 ac97.private_data = chip;
937 ac97.scaps = AC97_SCAP_NO_SPDIF;
813 return snd_ac97_mixer(pbus, &ac97, &chip->ac97); 938 return snd_ac97_mixer(pbus, &ac97, &chip->ac97);
814} 939}
815 940
@@ -993,6 +1118,7 @@ static int __devinit snd_ca0106_create(snd_card_t *card,
993 ca0106_t **rchip) 1118 ca0106_t **rchip)
994{ 1119{
995 ca0106_t *chip; 1120 ca0106_t *chip;
1121 ca0106_details_t *c;
996 int err; 1122 int err;
997 int ch; 1123 int ch;
998 static snd_device_ops_t ops = { 1124 static snd_device_ops_t ops = {
@@ -1003,8 +1129,8 @@ static int __devinit snd_ca0106_create(snd_card_t *card,
1003 1129
1004 if ((err = pci_enable_device(pci)) < 0) 1130 if ((err = pci_enable_device(pci)) < 0)
1005 return err; 1131 return err;
1006 if (pci_set_dma_mask(pci, 0xffffffffUL) < 0 || 1132 if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0 ||
1007 pci_set_consistent_dma_mask(pci, 0xffffffffUL) < 0) { 1133 pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0) {
1008 printk(KERN_ERR "error to set 32bit mask DMA\n"); 1134 printk(KERN_ERR "error to set 32bit mask DMA\n");
1009 pci_disable_device(pci); 1135 pci_disable_device(pci);
1010 return -ENXIO; 1136 return -ENXIO;
@@ -1054,6 +1180,15 @@ static int __devinit snd_ca0106_create(snd_card_t *card,
1054 printk(KERN_INFO "Model %04x Rev %08x Serial %08x\n", chip->model, 1180 printk(KERN_INFO "Model %04x Rev %08x Serial %08x\n", chip->model,
1055 chip->revision, chip->serial); 1181 chip->revision, chip->serial);
1056#endif 1182#endif
1183 strcpy(card->driver, "CA0106");
1184 strcpy(card->shortname, "CA0106");
1185
1186 for (c=ca0106_chip_details; c->serial; c++) {
1187 if (c->serial == chip->serial) break;
1188 }
1189 chip->details = c;
1190 sprintf(card->longname, "%s at 0x%lx irq %i",
1191 c->name, chip->port, chip->irq);
1057 1192
1058 outl(0, chip->port + INTE); 1193 outl(0, chip->port + INTE);
1059 1194
@@ -1113,7 +1248,7 @@ static int __devinit snd_ca0106_create(snd_card_t *card,
1113 //snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0xf0f003f); /* OSS drivers set this. */ 1248 //snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0xf0f003f); /* OSS drivers set this. */
1114 /* Analog or Digital output */ 1249 /* Analog or Digital output */
1115 snd_ca0106_ptr_write(chip, SPDIF_SELECT1, 0, 0xf); 1250 snd_ca0106_ptr_write(chip, SPDIF_SELECT1, 0, 0xf);
1116 snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0x000b0000); /* 0x0b000000 for digital, 0x000b0000 for analog, from win2000 drivers */ 1251 snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0x000f0000); /* 0x0b000000 for digital, 0x000b0000 for analog, from win2000 drivers. Use 0x000f0000 for surround71 */
1117 chip->spdif_enable = 0; /* Set digital SPDIF output off */ 1252 chip->spdif_enable = 0; /* Set digital SPDIF output off */
1118 chip->capture_source = 3; /* Set CAPTURE_SOURCE */ 1253 chip->capture_source = 3; /* Set CAPTURE_SOURCE */
1119 //snd_ca0106_ptr_write(chip, 0x45, 0, 0); /* Analogue out */ 1254 //snd_ca0106_ptr_write(chip, 0x45, 0, 0); /* Analogue out */
@@ -1138,13 +1273,11 @@ static int __devinit snd_ca0106_create(snd_card_t *card,
1138 snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); /* Select MIC, Line in, TAD in, AUX in */ 1273 snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); /* Select MIC, Line in, TAD in, AUX in */
1139 chip->capture_source = 3; /* Set CAPTURE_SOURCE */ 1274 chip->capture_source = 3; /* Set CAPTURE_SOURCE */
1140 1275
1141 if ((chip->serial == 0x10061102) || 1276 if (chip->details->gpio_type == 1) { /* The SB0410 and SB0413 use GPIO differently. */
1142 (chip->serial == 0x10071102) ||
1143 (chip->serial == 0x10091462)) { /* The SB0410 and SB0413 use GPIO differently. */
1144 /* FIXME: Still need to find out what the other GPIO bits do. E.g. For digital spdif out. */ 1277 /* FIXME: Still need to find out what the other GPIO bits do. E.g. For digital spdif out. */
1145 outl(0x0, chip->port+GPIO); 1278 outl(0x0, chip->port+GPIO);
1146 //outl(0x00f0e000, chip->port+GPIO); /* Analog */ 1279 //outl(0x00f0e000, chip->port+GPIO); /* Analog */
1147 outl(0x005f4300, chip->port+GPIO); /* Analog */ 1280 outl(0x005f5301, chip->port+GPIO); /* Analog */
1148 } else { 1281 } else {
1149 outl(0x0, chip->port+GPIO); 1282 outl(0x0, chip->port+GPIO);
1150 outl(0x005f03a3, chip->port+GPIO); /* Analog */ 1283 outl(0x005f03a3, chip->port+GPIO); /* Analog */
@@ -1157,6 +1290,10 @@ static int __devinit snd_ca0106_create(snd_card_t *card,
1157 //outl(0x00000009, chip->port+HCFG); 1290 //outl(0x00000009, chip->port+HCFG);
1158 outl(HCFG_AC97 | HCFG_AUDIOENABLE, chip->port+HCFG); /* AC97 2.0, Enable outputs. */ 1291 outl(HCFG_AC97 | HCFG_AUDIOENABLE, chip->port+HCFG); /* AC97 2.0, Enable outputs. */
1159 1292
1293 if (chip->details->i2c_adc == 1) { /* The SB0410 and SB0413 use I2C to control ADC. */
1294 snd_ca0106_i2c_write(chip, ADC_MUX, ADC_MUX_LINEIN); /* Enable Line-in capture. MIC in currently untested. */
1295 }
1296
1160 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, 1297 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL,
1161 chip, &ops)) < 0) { 1298 chip, &ops)) < 0) {
1162 snd_ca0106_free(chip); 1299 snd_ca0106_free(chip);
@@ -1172,7 +1309,6 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci,
1172 static int dev; 1309 static int dev;
1173 snd_card_t *card; 1310 snd_card_t *card;
1174 ca0106_t *chip; 1311 ca0106_t *chip;
1175 ca0106_names_t *c;
1176 int err; 1312 int err;
1177 1313
1178 if (dev >= SNDRV_CARDS) 1314 if (dev >= SNDRV_CARDS)
@@ -1207,9 +1343,7 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci,
1207 snd_card_free(card); 1343 snd_card_free(card);
1208 return err; 1344 return err;
1209 } 1345 }
1210 if ((chip->serial != 0x10061102) && 1346 if (chip->details->ac97 == 1) { /* The SB0410 and SB0413 do not have an AC97 chip. */
1211 (chip->serial != 0x10071102) &&
1212 (chip->serial != 0x10091462) ) { /* The SB0410 and SB0413 do not have an ac97 chip. */
1213 if ((err = snd_ca0106_ac97(chip)) < 0) { 1347 if ((err = snd_ca0106_ac97(chip)) < 0) {
1214 snd_card_free(card); 1348 snd_card_free(card);
1215 return err; 1349 return err;
@@ -1222,15 +1356,6 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci,
1222 1356
1223 snd_ca0106_proc_init(chip); 1357 snd_ca0106_proc_init(chip);
1224 1358
1225 strcpy(card->driver, "CA0106");
1226 strcpy(card->shortname, "CA0106");
1227
1228 for (c=ca0106_chip_names; c->serial; c++) {
1229 if (c->serial == chip->serial) break;
1230 }
1231 sprintf(card->longname, "%s at 0x%lx irq %i",
1232 c->name, chip->port, chip->irq);
1233
1234 if ((err = snd_card_register(card)) < 0) { 1359 if ((err = snd_card_register(card)) < 0) {
1235 snd_card_free(card); 1360 snd_card_free(card);
1236 return err; 1361 return err;
@@ -1267,7 +1392,7 @@ static int __init alsa_card_ca0106_init(void)
1267{ 1392{
1268 int err; 1393 int err;
1269 1394
1270 if ((err = pci_module_init(&driver)) > 0) 1395 if ((err = pci_register_driver(&driver)) > 0)
1271 return err; 1396 return err;
1272 1397
1273 return 0; 1398 return 0;
diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c
index 97bed1b0899d..0e5e9ce0ff28 100644
--- a/sound/pci/ca0106/ca0106_mixer.c
+++ b/sound/pci/ca0106/ca0106_mixer.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk> 2 * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk>
3 * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit 3 * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit
4 * Version: 0.0.16 4 * Version: 0.0.17
5 * 5 *
6 * FEATURES currently supported: 6 * FEATURES currently supported:
7 * See ca0106_main.c for features. 7 * See ca0106_main.c for features.
@@ -37,6 +37,8 @@
37 * Separated ca0106.c into separate functional .c files. 37 * Separated ca0106.c into separate functional .c files.
38 * 0.0.16 38 * 0.0.16
39 * Modified Copyright message. 39 * Modified Copyright message.
40 * 0.0.17
41 * Implement Mic and Line in Capture.
40 * 42 *
41 * This code was initally based on code from ALSA's emu10k1x.c which is: 43 * This code was initally based on code from ALSA's emu10k1x.c which is:
42 * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com> 44 * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com>
@@ -113,7 +115,7 @@ static int snd_ca0106_shared_spdif_put(snd_kcontrol_t * kcontrol,
113 } else { 115 } else {
114 /* Analog */ 116 /* Analog */
115 snd_ca0106_ptr_write(emu, SPDIF_SELECT1, 0, 0xf); 117 snd_ca0106_ptr_write(emu, SPDIF_SELECT1, 0, 0xf);
116 snd_ca0106_ptr_write(emu, SPDIF_SELECT2, 0, 0x000b0000); 118 snd_ca0106_ptr_write(emu, SPDIF_SELECT2, 0, 0x000f0000);
117 snd_ca0106_ptr_write(emu, CAPTURE_CONTROL, 0, 119 snd_ca0106_ptr_write(emu, CAPTURE_CONTROL, 0,
118 snd_ca0106_ptr_read(emu, CAPTURE_CONTROL, 0) | 0x1000); 120 snd_ca0106_ptr_read(emu, CAPTURE_CONTROL, 0) | 0x1000);
119 mask = inl(emu->port + GPIO) | 0x101; 121 mask = inl(emu->port + GPIO) | 0x101;
@@ -183,6 +185,65 @@ static snd_kcontrol_new_t snd_ca0106_capture_source __devinitdata =
183 .put = snd_ca0106_capture_source_put 185 .put = snd_ca0106_capture_source_put
184}; 186};
185 187
188static int snd_ca0106_capture_mic_line_in_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
189{
190 static char *texts[2] = { "Line in", "Mic in" };
191
192 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
193 uinfo->count = 1;
194 uinfo->value.enumerated.items = 2;
195 if (uinfo->value.enumerated.item > 1)
196 uinfo->value.enumerated.item = 1;
197 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
198 return 0;
199}
200
201static int snd_ca0106_capture_mic_line_in_get(snd_kcontrol_t * kcontrol,
202 snd_ctl_elem_value_t * ucontrol)
203{
204 ca0106_t *emu = snd_kcontrol_chip(kcontrol);
205
206 ucontrol->value.enumerated.item[0] = emu->capture_mic_line_in;
207 return 0;
208}
209
210static int snd_ca0106_capture_mic_line_in_put(snd_kcontrol_t * kcontrol,
211 snd_ctl_elem_value_t * ucontrol)
212{
213 ca0106_t *emu = snd_kcontrol_chip(kcontrol);
214 unsigned int val;
215 int change = 0;
216 u32 tmp;
217
218 val = ucontrol->value.enumerated.item[0] ;
219 change = (emu->capture_mic_line_in != val);
220 if (change) {
221 emu->capture_mic_line_in = val;
222 if (val) {
223 snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_PHONE); /* Mute input */
224 tmp = inl(emu->port+GPIO) & ~0x400;
225 tmp = tmp | 0x400;
226 outl(tmp, emu->port+GPIO);
227 snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_MIC);
228 } else {
229 snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_PHONE); /* Mute input */
230 tmp = inl(emu->port+GPIO) & ~0x400;
231 outl(tmp, emu->port+GPIO);
232 snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_LINEIN);
233 }
234 }
235 return change;
236}
237
238static snd_kcontrol_new_t snd_ca0106_capture_mic_line_in __devinitdata =
239{
240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
241 .name = "Mic/Line in Capture",
242 .info = snd_ca0106_capture_mic_line_in_info,
243 .get = snd_ca0106_capture_mic_line_in_get,
244 .put = snd_ca0106_capture_mic_line_in_put
245};
246
186static int snd_ca0106_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 247static int snd_ca0106_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
187{ 248{
188 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; 249 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
@@ -437,7 +498,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_analog_center_lfe =
437static snd_kcontrol_new_t snd_ca0106_volume_control_analog_unknown = 498static snd_kcontrol_new_t snd_ca0106_volume_control_analog_unknown =
438{ 499{
439 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 500 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
440 .name = "Analog Unknown Volume", 501 .name = "Analog Side Volume",
441 .info = snd_ca0106_volume_info, 502 .info = snd_ca0106_volume_info,
442 .get = snd_ca0106_volume_get_analog_unknown, 503 .get = snd_ca0106_volume_get_analog_unknown,
443 .put = snd_ca0106_volume_put_analog_unknown 504 .put = snd_ca0106_volume_put_analog_unknown
@@ -620,10 +681,11 @@ int __devinit snd_ca0106_mixer(ca0106_t *emu)
620 return -ENOMEM; 681 return -ENOMEM;
621 if ((err = snd_ctl_add(card, kctl))) 682 if ((err = snd_ctl_add(card, kctl)))
622 return err; 683 return err;
623 if ((kctl = ctl_find(card, SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT))) != NULL) { 684 if (emu->details->i2c_adc == 1) {
624 /* already defined by ac97, remove it */ 685 if ((kctl = snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu)) == NULL)
625 /* FIXME: or do we need both controls? */ 686 return -ENOMEM;
626 remove_ctl(card, SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT)); 687 if ((err = snd_ctl_add(card, kctl)))
688 return err;
627 } 689 }
628 if ((kctl = snd_ctl_new1(&snd_ca0106_spdif_control, emu)) == NULL) 690 if ((kctl = snd_ctl_new1(&snd_ca0106_spdif_control, emu)) == NULL)
629 return -ENOMEM; 691 return -ENOMEM;
diff --git a/sound/pci/ca0106/ca0106_proc.c b/sound/pci/ca0106/ca0106_proc.c
index afb711421e47..1c9cc821d1b9 100644
--- a/sound/pci/ca0106/ca0106_proc.c
+++ b/sound/pci/ca0106/ca0106_proc.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk> 2 * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk>
3 * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit 3 * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit
4 * Version: 0.0.17 4 * Version: 0.0.18
5 * 5 *
6 * FEATURES currently supported: 6 * FEATURES currently supported:
7 * See ca0106_main.c for features. 7 * See ca0106_main.c for features.
@@ -39,7 +39,9 @@
39 * Modified Copyright message. 39 * Modified Copyright message.
40 * 0.0.17 40 * 0.0.17
41 * Add iec958 file in proc file system to show status of SPDIF in. 41 * Add iec958 file in proc file system to show status of SPDIF in.
42 * 42 * 0.0.18
43 * Implement support for Line-in capture on SB Live 24bit.
44 *
43 * This code was initally based on code from ALSA's emu10k1x.c which is: 45 * This code was initally based on code from ALSA's emu10k1x.c which is:
44 * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com> 46 * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com>
45 * 47 *
@@ -95,7 +97,7 @@ static struct snd_ca0106_category_str snd_ca0106_con_category[] = {
95}; 97};
96 98
97 99
98void snd_ca0106_proc_dump_iec958( snd_info_buffer_t *buffer, u32 value) 100static void snd_ca0106_proc_dump_iec958( snd_info_buffer_t *buffer, u32 value)
99{ 101{
100 int i; 102 int i;
101 u32 status[4]; 103 u32 status[4];
@@ -407,6 +409,20 @@ static void snd_ca0106_proc_reg_write(snd_info_entry_t *entry,
407 } 409 }
408} 410}
409 411
412static void snd_ca0106_proc_i2c_write(snd_info_entry_t *entry,
413 snd_info_buffer_t * buffer)
414{
415 ca0106_t *emu = entry->private_data;
416 char line[64];
417 unsigned int reg, val;
418 while (!snd_info_get_line(buffer, line, sizeof(line))) {
419 if (sscanf(line, "%x %x", &reg, &val) != 2)
420 continue;
421 if ((reg <= 0x7f) || (val <= 0x1ff)) {
422 snd_ca0106_i2c_write(emu, reg, val);
423 }
424 }
425}
410 426
411int __devinit snd_ca0106_proc_init(ca0106_t * emu) 427int __devinit snd_ca0106_proc_init(ca0106_t * emu)
412{ 428{
@@ -418,6 +434,7 @@ int __devinit snd_ca0106_proc_init(ca0106_t * emu)
418 snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_reg_read32); 434 snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_reg_read32);
419 entry->c.text.write_size = 64; 435 entry->c.text.write_size = 64;
420 entry->c.text.write = snd_ca0106_proc_reg_write32; 436 entry->c.text.write = snd_ca0106_proc_reg_write32;
437 entry->mode |= S_IWUSR;
421 } 438 }
422 if(! snd_card_proc_new(emu->card, "ca0106_reg16", &entry)) 439 if(! snd_card_proc_new(emu->card, "ca0106_reg16", &entry))
423 snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_reg_read16); 440 snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_reg_read16);
@@ -427,6 +444,14 @@ int __devinit snd_ca0106_proc_init(ca0106_t * emu)
427 snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_reg_read1); 444 snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_reg_read1);
428 entry->c.text.write_size = 64; 445 entry->c.text.write_size = 64;
429 entry->c.text.write = snd_ca0106_proc_reg_write; 446 entry->c.text.write = snd_ca0106_proc_reg_write;
447 entry->mode |= S_IWUSR;
448// entry->private_data = emu;
449 }
450 if(! snd_card_proc_new(emu->card, "ca0106_i2c", &entry)) {
451 snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_i2c_write);
452 entry->c.text.write_size = 64;
453 entry->c.text.write = snd_ca0106_proc_i2c_write;
454 entry->mode |= S_IWUSR;
430// entry->private_data = emu; 455// entry->private_data = emu;
431 } 456 }
432 if(! snd_card_proc_new(emu->card, "ca0106_regs2", &entry)) 457 if(! snd_card_proc_new(emu->card, "ca0106_regs2", &entry))
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index 113208fbde1b..b4503385ea69 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -519,40 +519,50 @@ inline static unsigned char snd_cmipci_read_b(cmipci_t *cm, unsigned int cmd)
519} 519}
520 520
521/* bit operations for dword register */ 521/* bit operations for dword register */
522static void snd_cmipci_set_bit(cmipci_t *cm, unsigned int cmd, unsigned int flag) 522static int snd_cmipci_set_bit(cmipci_t *cm, unsigned int cmd, unsigned int flag)
523{ 523{
524 unsigned int val; 524 unsigned int val, oval;
525 val = inl(cm->iobase + cmd); 525 val = oval = inl(cm->iobase + cmd);
526 val |= flag; 526 val |= flag;
527 if (val == oval)
528 return 0;
527 outl(val, cm->iobase + cmd); 529 outl(val, cm->iobase + cmd);
530 return 1;
528} 531}
529 532
530static void snd_cmipci_clear_bit(cmipci_t *cm, unsigned int cmd, unsigned int flag) 533static int snd_cmipci_clear_bit(cmipci_t *cm, unsigned int cmd, unsigned int flag)
531{ 534{
532 unsigned int val; 535 unsigned int val, oval;
533 val = inl(cm->iobase + cmd); 536 val = oval = inl(cm->iobase + cmd);
534 val &= ~flag; 537 val &= ~flag;
538 if (val == oval)
539 return 0;
535 outl(val, cm->iobase + cmd); 540 outl(val, cm->iobase + cmd);
541 return 1;
536} 542}
537 543
538#if 0 // not used
539/* bit operations for byte register */ 544/* bit operations for byte register */
540static void snd_cmipci_set_bit_b(cmipci_t *cm, unsigned int cmd, unsigned char flag) 545static int snd_cmipci_set_bit_b(cmipci_t *cm, unsigned int cmd, unsigned char flag)
541{ 546{
542 unsigned char val; 547 unsigned char val, oval;
543 val = inb(cm->iobase + cmd); 548 val = oval = inb(cm->iobase + cmd);
544 val |= flag; 549 val |= flag;
550 if (val == oval)
551 return 0;
545 outb(val, cm->iobase + cmd); 552 outb(val, cm->iobase + cmd);
553 return 1;
546} 554}
547 555
548static void snd_cmipci_clear_bit_b(cmipci_t *cm, unsigned int cmd, unsigned char flag) 556static int snd_cmipci_clear_bit_b(cmipci_t *cm, unsigned int cmd, unsigned char flag)
549{ 557{
550 unsigned char val; 558 unsigned char val, oval;
551 val = inb(cm->iobase + cmd); 559 val = oval = inb(cm->iobase + cmd);
552 val &= ~flag; 560 val &= ~flag;
561 if (val == oval)
562 return 0;
553 outb(val, cm->iobase + cmd); 563 outb(val, cm->iobase + cmd);
564 return 1;
554} 565}
555#endif
556 566
557 567
558/* 568/*
@@ -2250,8 +2260,8 @@ DEFINE_SWITCH_ARG(exchange_dac, CM_REG_MISC_CTRL, CM_XCHGDAC, 0, 0, 0); /* rever
2250DEFINE_SWITCH_ARG(exchange_dac, CM_REG_MISC_CTRL, CM_XCHGDAC, CM_XCHGDAC, 0, 0); 2260DEFINE_SWITCH_ARG(exchange_dac, CM_REG_MISC_CTRL, CM_XCHGDAC, CM_XCHGDAC, 0, 0);
2251#endif 2261#endif
2252DEFINE_BIT_SWITCH_ARG(fourch, CM_REG_MISC_CTRL, CM_N4SPK3D, 0, 0); 2262DEFINE_BIT_SWITCH_ARG(fourch, CM_REG_MISC_CTRL, CM_N4SPK3D, 0, 0);
2253DEFINE_BIT_SWITCH_ARG(line_rear, CM_REG_MIXER1, CM_SPK4, 1, 0); 2263// DEFINE_BIT_SWITCH_ARG(line_rear, CM_REG_MIXER1, CM_SPK4, 1, 0);
2254DEFINE_BIT_SWITCH_ARG(line_bass, CM_REG_LEGACY_CTRL, CM_LINE_AS_BASS, 0, 0); 2264// DEFINE_BIT_SWITCH_ARG(line_bass, CM_REG_LEGACY_CTRL, CM_LINE_AS_BASS, 0, 0);
2255// DEFINE_BIT_SWITCH_ARG(joystick, CM_REG_FUNCTRL1, CM_JYSTK_EN, 0, 0); /* now module option */ 2265// DEFINE_BIT_SWITCH_ARG(joystick, CM_REG_FUNCTRL1, CM_JYSTK_EN, 0, 0); /* now module option */
2256DEFINE_SWITCH_ARG(modem, CM_REG_MISC_CTRL, CM_FLINKON|CM_FLINKOFF, CM_FLINKON, 0, 0); 2266DEFINE_SWITCH_ARG(modem, CM_REG_MISC_CTRL, CM_FLINKON|CM_FLINKOFF, CM_FLINKON, 0, 0);
2257 2267
@@ -2300,10 +2310,114 @@ static int snd_cmipci_spdout_enable_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_v
2300} 2310}
2301 2311
2302 2312
2313static int snd_cmipci_line_in_mode_info(snd_kcontrol_t *kcontrol,
2314 snd_ctl_elem_info_t *uinfo)
2315{
2316 cmipci_t *cm = snd_kcontrol_chip(kcontrol);
2317 static char *texts[3] = { "Line-In", "Rear Output", "Bass Output" };
2318 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2319 uinfo->count = 1;
2320 uinfo->value.enumerated.items = cm->chip_version >= 39 ? 3 : 2;
2321 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
2322 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
2323 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2324 return 0;
2325}
2326
2327static inline unsigned int get_line_in_mode(cmipci_t *cm)
2328{
2329 unsigned int val;
2330 if (cm->chip_version >= 39) {
2331 val = snd_cmipci_read(cm, CM_REG_LEGACY_CTRL);
2332 if (val & CM_LINE_AS_BASS)
2333 return 2;
2334 }
2335 val = snd_cmipci_read_b(cm, CM_REG_MIXER1);
2336 if (val & CM_SPK4)
2337 return 1;
2338 return 0;
2339}
2340
2341static int snd_cmipci_line_in_mode_get(snd_kcontrol_t *kcontrol,
2342 snd_ctl_elem_value_t *ucontrol)
2343{
2344 cmipci_t *cm = snd_kcontrol_chip(kcontrol);
2345
2346 spin_lock_irq(&cm->reg_lock);
2347 ucontrol->value.enumerated.item[0] = get_line_in_mode(cm);
2348 spin_unlock_irq(&cm->reg_lock);
2349 return 0;
2350}
2351
2352static int snd_cmipci_line_in_mode_put(snd_kcontrol_t *kcontrol,
2353 snd_ctl_elem_value_t *ucontrol)
2354{
2355 cmipci_t *cm = snd_kcontrol_chip(kcontrol);
2356 int change;
2357
2358 spin_lock_irq(&cm->reg_lock);
2359 if (ucontrol->value.enumerated.item[0] == 2)
2360 change = snd_cmipci_set_bit(cm, CM_REG_LEGACY_CTRL, CM_LINE_AS_BASS);
2361 else
2362 change = snd_cmipci_clear_bit(cm, CM_REG_LEGACY_CTRL, CM_LINE_AS_BASS);
2363 if (ucontrol->value.enumerated.item[0] == 1)
2364 change |= snd_cmipci_set_bit_b(cm, CM_REG_MIXER1, CM_SPK4);
2365 else
2366 change |= snd_cmipci_clear_bit_b(cm, CM_REG_MIXER1, CM_SPK4);
2367 spin_unlock_irq(&cm->reg_lock);
2368 return change;
2369}
2370
2371static int snd_cmipci_mic_in_mode_info(snd_kcontrol_t *kcontrol,
2372 snd_ctl_elem_info_t *uinfo)
2373{
2374 static char *texts[2] = { "Mic-In", "Center/LFE Output" };
2375 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2376 uinfo->count = 1;
2377 uinfo->value.enumerated.items = 2;
2378 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
2379 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
2380 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2381 return 0;
2382}
2383
2384static int snd_cmipci_mic_in_mode_get(snd_kcontrol_t *kcontrol,
2385 snd_ctl_elem_value_t *ucontrol)
2386{
2387 cmipci_t *cm = snd_kcontrol_chip(kcontrol);
2388 /* same bit as spdi_phase */
2389 spin_lock_irq(&cm->reg_lock);
2390 ucontrol->value.enumerated.item[0] =
2391 (snd_cmipci_read_b(cm, CM_REG_MISC) & CM_SPDIF_INVERSE) ? 1 : 0;
2392 spin_unlock_irq(&cm->reg_lock);
2393 return 0;
2394}
2395
2396static int snd_cmipci_mic_in_mode_put(snd_kcontrol_t *kcontrol,
2397 snd_ctl_elem_value_t *ucontrol)
2398{
2399 cmipci_t *cm = snd_kcontrol_chip(kcontrol);
2400 int change;
2401
2402 spin_lock_irq(&cm->reg_lock);
2403 if (ucontrol->value.enumerated.item[0])
2404 change = snd_cmipci_set_bit_b(cm, CM_REG_MISC, CM_SPDIF_INVERSE);
2405 else
2406 change = snd_cmipci_clear_bit_b(cm, CM_REG_MISC, CM_SPDIF_INVERSE);
2407 spin_unlock_irq(&cm->reg_lock);
2408 return change;
2409}
2410
2303/* both for CM8338/8738 */ 2411/* both for CM8338/8738 */
2304static snd_kcontrol_new_t snd_cmipci_mixer_switches[] __devinitdata = { 2412static snd_kcontrol_new_t snd_cmipci_mixer_switches[] __devinitdata = {
2305 DEFINE_MIXER_SWITCH("Four Channel Mode", fourch), 2413 DEFINE_MIXER_SWITCH("Four Channel Mode", fourch),
2306 DEFINE_MIXER_SWITCH("Line-In As Rear", line_rear), 2414 {
2415 .name = "Line-In Mode",
2416 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2417 .info = snd_cmipci_line_in_mode_info,
2418 .get = snd_cmipci_line_in_mode_get,
2419 .put = snd_cmipci_line_in_mode_put,
2420 },
2307}; 2421};
2308 2422
2309/* for non-multichannel chips */ 2423/* for non-multichannel chips */
@@ -2341,10 +2455,15 @@ static snd_kcontrol_new_t snd_cmipci_old_mixer_switches[] __devinitdata = {
2341 2455
2342/* only for model 039 or later */ 2456/* only for model 039 or later */
2343static snd_kcontrol_new_t snd_cmipci_extra_mixer_switches[] __devinitdata = { 2457static snd_kcontrol_new_t snd_cmipci_extra_mixer_switches[] __devinitdata = {
2344 DEFINE_MIXER_SWITCH("Line-In As Bass", line_bass),
2345 DEFINE_MIXER_SWITCH("IEC958 In Select", spdif_in_sel2), 2458 DEFINE_MIXER_SWITCH("IEC958 In Select", spdif_in_sel2),
2346 DEFINE_MIXER_SWITCH("IEC958 In Phase Inverse", spdi_phase2), 2459 DEFINE_MIXER_SWITCH("IEC958 In Phase Inverse", spdi_phase2),
2347 DEFINE_MIXER_SWITCH("Mic As Center/LFE", spdi_phase), /* same bit as spdi_phase */ 2460 {
2461 .name = "Mic-In Mode",
2462 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2463 .info = snd_cmipci_mic_in_mode_info,
2464 .get = snd_cmipci_mic_in_mode_get,
2465 .put = snd_cmipci_mic_in_mode_put,
2466 }
2348}; 2467};
2349 2468
2350/* card control switches */ 2469/* card control switches */
@@ -2944,7 +3063,7 @@ static struct pci_driver driver = {
2944 3063
2945static int __init alsa_card_cmipci_init(void) 3064static int __init alsa_card_cmipci_init(void)
2946{ 3065{
2947 return pci_module_init(&driver); 3066 return pci_register_driver(&driver);
2948} 3067}
2949 3068
2950static void __exit alsa_card_cmipci_exit(void) 3069static void __exit alsa_card_cmipci_exit(void)
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
index d7e06b3caf97..b6e1854e9389 100644
--- a/sound/pci/cs4281.c
+++ b/sound/pci/cs4281.c
@@ -206,7 +206,10 @@ MODULE_PARM_DESC(dual_codec, "Secondary Codec ID (0 = disabled).");
206 206
207#define BA0_PMCS 0x0344 /* Power Management Control/Status */ 207#define BA0_PMCS 0x0344 /* Power Management Control/Status */
208#define BA0_CWPR 0x03e0 /* Configuration Write Protect */ 208#define BA0_CWPR 0x03e0 /* Configuration Write Protect */
209
209#define BA0_EPPMC 0x03e4 /* Extended PCI Power Management Control */ 210#define BA0_EPPMC 0x03e4 /* Extended PCI Power Management Control */
211#define BA0_EPPMC_FPDN (1<<14) /* Full Power DowN */
212
210#define BA0_GPIOR 0x03e8 /* GPIO Pin Interface Register */ 213#define BA0_GPIOR 0x03e8 /* GPIO Pin Interface Register */
211 214
212#define BA0_SPMC 0x03ec /* Serial Port Power Management Control (& ASDIN2 enable) */ 215#define BA0_SPMC 0x03ec /* Serial Port Power Management Control (& ASDIN2 enable) */
@@ -1461,6 +1464,11 @@ static int snd_cs4281_chip_init(cs4281_t *chip)
1461 int timeout; 1464 int timeout;
1462 int retry_count = 2; 1465 int retry_count = 2;
1463 1466
1467 /* Having EPPMC.FPDN=1 prevent proper chip initialisation */
1468 tmp = snd_cs4281_peekBA0(chip, BA0_EPPMC);
1469 if (tmp & BA0_EPPMC_FPDN)
1470 snd_cs4281_pokeBA0(chip, BA0_EPPMC, tmp & ~BA0_EPPMC_FPDN);
1471
1464 __retry: 1472 __retry:
1465 tmp = snd_cs4281_peekBA0(chip, BA0_CFLR); 1473 tmp = snd_cs4281_peekBA0(chip, BA0_CFLR);
1466 if (tmp != BA0_CFLR_DEFAULT) { 1474 if (tmp != BA0_CFLR_DEFAULT) {
@@ -2124,7 +2132,7 @@ static struct pci_driver driver = {
2124 2132
2125static int __init alsa_card_cs4281_init(void) 2133static int __init alsa_card_cs4281_init(void)
2126{ 2134{
2127 return pci_module_init(&driver); 2135 return pci_register_driver(&driver);
2128} 2136}
2129 2137
2130static void __exit alsa_card_cs4281_exit(void) 2138static void __exit alsa_card_cs4281_exit(void)
diff --git a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c
index 25d6466a867c..db212ecd792a 100644
--- a/sound/pci/cs46xx/cs46xx.c
+++ b/sound/pci/cs46xx/cs46xx.c
@@ -171,7 +171,7 @@ static struct pci_driver driver = {
171 171
172static int __init alsa_card_cs46xx_init(void) 172static int __init alsa_card_cs46xx_init(void)
173{ 173{
174 return pci_module_init(&driver); 174 return pci_register_driver(&driver);
175} 175}
176 176
177static void __exit alsa_card_cs46xx_exit(void) 177static void __exit alsa_card_cs46xx_exit(void)
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 5f2ffb7efa06..fd4c50c88bc9 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -1295,8 +1295,7 @@ static snd_pcm_hw_constraint_list_t hw_constraints_period_sizes = {
1295 1295
1296static void snd_cs46xx_pcm_free_substream(snd_pcm_runtime_t *runtime) 1296static void snd_cs46xx_pcm_free_substream(snd_pcm_runtime_t *runtime)
1297{ 1297{
1298 cs46xx_pcm_t * cpcm = runtime->private_data; 1298 kfree(runtime->private_data);
1299 kfree(cpcm);
1300} 1299}
1301 1300
1302static int _cs46xx_playback_open_channel (snd_pcm_substream_t * substream,int pcm_channel_id) 1301static int _cs46xx_playback_open_channel (snd_pcm_substream_t * substream,int pcm_channel_id)
diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c
index 6446afe19d80..2085a998eaeb 100644
--- a/sound/pci/emu10k1/emu10k1.c
+++ b/sound/pci/emu10k1/emu10k1.c
@@ -228,7 +228,7 @@ static struct pci_driver driver = {
228 228
229static int __init alsa_card_emu10k1_init(void) 229static int __init alsa_card_emu10k1_init(void)
230{ 230{
231 return pci_module_init(&driver); 231 return pci_register_driver(&driver);
232} 232}
233 233
234static void __exit alsa_card_emu10k1_exit(void) 234static void __exit alsa_card_emu10k1_exit(void)
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index c3c96f9f2c7f..a341e758acde 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -170,7 +170,7 @@ static int __devinit snd_emu10k1_init(emu10k1_t * emu, int enable_ir)
170 SPCS_GENERATIONSTATUS | 0x00001200 | 170 SPCS_GENERATIONSTATUS | 0x00001200 |
171 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); 171 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT);
172 172
173 if (emu->audigy && emu->revision == 4) { /* audigy2 */ 173 if (emu->card_capabilities->ca0151_chip) { /* audigy2 */
174 /* Hacks for Alice3 to work independent of haP16V driver */ 174 /* Hacks for Alice3 to work independent of haP16V driver */
175 u32 tmp; 175 u32 tmp;
176 176
@@ -189,7 +189,7 @@ static int __devinit snd_emu10k1_init(emu10k1_t * emu, int enable_ir)
189 /* Enabled Phased (8-channel) P16V playback */ 189 /* Enabled Phased (8-channel) P16V playback */
190 outl(0x0201, emu->port + HCFG2); 190 outl(0x0201, emu->port + HCFG2);
191 /* Set playback routing. */ 191 /* Set playback routing. */
192 snd_emu10k1_ptr_write(emu, CAPTURE_P16V_SOURCE, 0, 78e4); 192 snd_emu10k1_ptr20_write(emu, CAPTURE_P16V_SOURCE, 0, 0x78e4);
193 } 193 }
194 if (emu->audigy && (emu->serial == 0x10011102) ) { /* audigy2 Value */ 194 if (emu->audigy && (emu->serial == 0x10011102) ) { /* audigy2 Value */
195 /* Hacks for Alice3 to work independent of haP16V driver */ 195 /* Hacks for Alice3 to work independent of haP16V driver */
@@ -600,7 +600,7 @@ static int snd_emu10k1_free(emu10k1_t *emu)
600 if (emu->port) 600 if (emu->port)
601 pci_release_regions(emu->pci); 601 pci_release_regions(emu->pci);
602 pci_disable_device(emu->pci); 602 pci_disable_device(emu->pci);
603 if (emu->audigy && emu->revision == 4) /* P16V */ 603 if (emu->card_capabilities->ca0151_chip) /* P16V */
604 snd_p16v_free(emu); 604 snd_p16v_free(emu);
605 kfree(emu); 605 kfree(emu);
606 return 0; 606 return 0;
@@ -612,21 +612,24 @@ static int snd_emu10k1_dev_free(snd_device_t *device)
612 return snd_emu10k1_free(emu); 612 return snd_emu10k1_free(emu);
613} 613}
614 614
615/* vendor, device, subsystem, emu10k1_chip, emu10k2_chip, ca0102_chip, ca0108_chip, ca0151_chip, spk71, spdif_bug, ac97_chip, ecard, driver, name */
616
617static emu_chip_details_t emu_chip_details[] = { 615static emu_chip_details_t emu_chip_details[] = {
618 /* Audigy 2 Value AC3 out does not work yet. Need to find out how to turn off interpolators.*/ 616 /* Audigy 2 Value AC3 out does not work yet. Need to find out how to turn off interpolators.*/
619 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102, 617 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102,
620 .driver = "Audigy2", .name = "Audigy 2 Value [SB0400]", 618 .driver = "Audigy2", .name = "Audigy 2 Value [SB0400]",
619 .id = "Audigy2",
621 .emu10k2_chip = 1, 620 .emu10k2_chip = 1,
622 .ca0108_chip = 1, 621 .ca0108_chip = 1,
623 .spk71 = 1} , 622 .spk71 = 1,
623 .ac97_chip = 1} ,
624 {.vendor = 0x1102, .device = 0x0008, 624 {.vendor = 0x1102, .device = 0x0008,
625 .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", 625 .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]",
626 .id = "Audigy2",
626 .emu10k2_chip = 1, 627 .emu10k2_chip = 1,
627 .ca0108_chip = 1} , 628 .ca0108_chip = 1,
629 .ac97_chip = 1} ,
628 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102, 630 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102,
629 .driver = "Audigy2", .name = "Audigy 4 PRO [SB0380]", 631 .driver = "Audigy2", .name = "Audigy 4 PRO [SB0380]",
632 .id = "Audigy2",
630 .emu10k2_chip = 1, 633 .emu10k2_chip = 1,
631 .ca0102_chip = 1, 634 .ca0102_chip = 1,
632 .ca0151_chip = 1, 635 .ca0151_chip = 1,
@@ -635,6 +638,7 @@ static emu_chip_details_t emu_chip_details[] = {
635 .ac97_chip = 1} , 638 .ac97_chip = 1} ,
636 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102, 639 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102,
637 .driver = "Audigy2", .name = "Audigy 2 ZS [SB0350]", 640 .driver = "Audigy2", .name = "Audigy 2 ZS [SB0350]",
641 .id = "Audigy2",
638 .emu10k2_chip = 1, 642 .emu10k2_chip = 1,
639 .ca0102_chip = 1, 643 .ca0102_chip = 1,
640 .ca0151_chip = 1, 644 .ca0151_chip = 1,
@@ -643,6 +647,7 @@ static emu_chip_details_t emu_chip_details[] = {
643 .ac97_chip = 1} , 647 .ac97_chip = 1} ,
644 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102, 648 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102,
645 .driver = "Audigy2", .name = "Audigy 2 ZS [2001]", 649 .driver = "Audigy2", .name = "Audigy 2 ZS [2001]",
650 .id = "Audigy2",
646 .emu10k2_chip = 1, 651 .emu10k2_chip = 1,
647 .ca0102_chip = 1, 652 .ca0102_chip = 1,
648 .ca0151_chip = 1, 653 .ca0151_chip = 1,
@@ -651,6 +656,7 @@ static emu_chip_details_t emu_chip_details[] = {
651 .ac97_chip = 1} , 656 .ac97_chip = 1} ,
652 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102, 657 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102,
653 .driver = "Audigy2", .name = "Audigy 2 [SB0240]", 658 .driver = "Audigy2", .name = "Audigy 2 [SB0240]",
659 .id = "Audigy2",
654 .emu10k2_chip = 1, 660 .emu10k2_chip = 1,
655 .ca0102_chip = 1, 661 .ca0102_chip = 1,
656 .ca0151_chip = 1, 662 .ca0151_chip = 1,
@@ -659,35 +665,165 @@ static emu_chip_details_t emu_chip_details[] = {
659 .ac97_chip = 1} , 665 .ac97_chip = 1} ,
660 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102, 666 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102,
661 .driver = "Audigy2", .name = "Audigy 2 EX [1005]", 667 .driver = "Audigy2", .name = "Audigy 2 EX [1005]",
668 .id = "Audigy2",
662 .emu10k2_chip = 1, 669 .emu10k2_chip = 1,
663 .ca0102_chip = 1, 670 .ca0102_chip = 1,
664 .ca0151_chip = 1, 671 .ca0151_chip = 1,
665 .spdif_bug = 1} , 672 .spdif_bug = 1} ,
666 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102, 673 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102,
667 .driver = "Audigy2", .name = "Audigy 2 Platinum [SB0240P]", 674 .driver = "Audigy2", .name = "Audigy 2 Platinum [SB0240P]",
675 .id = "Audigy2",
668 .emu10k2_chip = 1, 676 .emu10k2_chip = 1,
669 .ca0102_chip = 1, 677 .ca0102_chip = 1,
670 .ca0151_chip = 1, 678 .ca0151_chip = 1,
671 .spk71 = 1, 679 .spk71 = 1,
672 .spdif_bug = 1, 680 .spdif_bug = 1,
673 .ac97_chip = 1} , 681 .ac97_chip = 1} ,
682 {.vendor = 0x1102, .device = 0x0004, .revision = 0x04,
683 .driver = "Audigy2", .name = "Audigy 2 [Unknown]",
684 .id = "Audigy2",
685 .emu10k2_chip = 1,
686 .ca0102_chip = 1,
687 .ca0151_chip = 1,
688 .spdif_bug = 1,
689 .ac97_chip = 1} ,
690 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10020052,
691 .driver = "Audigy", .name = "Audigy 1 ES [SB0160]",
692 .id = "Audigy",
693 .emu10k2_chip = 1,
694 .ca0102_chip = 1,
695 .spdif_bug = 1,
696 .ac97_chip = 1} ,
697 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00531102,
698 .driver = "Audigy", .name = "Audigy 1 [SB0090]",
699 .id = "Audigy",
700 .emu10k2_chip = 1,
701 .ca0102_chip = 1,
702 .ac97_chip = 1} ,
703 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00511102,
704 .driver = "Audigy", .name = "Audigy 1 [SB0090]",
705 .id = "Audigy",
706 .emu10k2_chip = 1,
707 .ca0102_chip = 1,
708 .ac97_chip = 1} ,
674 {.vendor = 0x1102, .device = 0x0004, 709 {.vendor = 0x1102, .device = 0x0004,
675 .driver = "Audigy", .name = "Audigy 1 or 2 [Unknown]", 710 .driver = "Audigy", .name = "Audigy 1 [Unknown]",
711 .id = "Audigy",
676 .emu10k2_chip = 1, 712 .emu10k2_chip = 1,
677 .ca0102_chip = 1, 713 .ca0102_chip = 1,
678 .spdif_bug = 1} , 714 .ac97_chip = 1} ,
679 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x40011102, 715 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x40011102,
680 .driver = "EMU10K1", .name = "E-mu APS [4001]", 716 .driver = "EMU10K1", .name = "E-mu APS [4001]",
717 .id = "APS",
681 .emu10k1_chip = 1, 718 .emu10k1_chip = 1,
682 .ecard = 1} , 719 .ecard = 1} ,
720 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102,
721 .driver = "EMU10K1", .name = "SBLive! Player 5.1 [SB0060]",
722 .id = "Live",
723 .emu10k1_chip = 1,
724 .ac97_chip = 1,
725 .sblive51 = 1} ,
683 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102, 726 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102,
684 .driver = "EMU10K1", .name = "SB Live 5.1", 727 .driver = "EMU10K1", .name = "SB Live 5.1",
728 .id = "Live",
729 .emu10k1_chip = 1,
730 .ac97_chip = 1,
731 .sblive51 = 1} ,
732 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80401102,
733 .driver = "EMU10K1", .name = "SBLive! Platinum [CT4760P]",
734 .id = "Live",
685 .emu10k1_chip = 1, 735 .emu10k1_chip = 1,
686 .ac97_chip = 1} , 736 .ac97_chip = 1} ,
737 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00211102,
738 .driver = "EMU10K1", .name = "SBLive! [CT4620]",
739 .id = "Live",
740 .emu10k1_chip = 1,
741 .ac97_chip = 1,
742 .sblive51 = 1} ,
743 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00201102,
744 .driver = "EMU10K1", .name = "SBLive! Value [CT4670]",
745 .id = "Live",
746 .emu10k1_chip = 1,
747 .ac97_chip = 1,
748 .sblive51 = 1} ,
749 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80221102,
750 .driver = "EMU10K1", .name = "SBLive! Value [CT4780]",
751 .id = "Live",
752 .emu10k1_chip = 1,
753 .ac97_chip = 1,
754 .sblive51 = 1} ,
755 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80231102,
756 .driver = "EMU10K1", .name = "SB PCI512 [CT4790]",
757 .id = "Live",
758 .emu10k1_chip = 1,
759 .ac97_chip = 1,
760 .sblive51 = 1} ,
761 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80261102,
762 .driver = "EMU10K1", .name = "SBLive! Value [CT4830]",
763 .id = "Live",
764 .emu10k1_chip = 1,
765 .ac97_chip = 1,
766 .sblive51 = 1} ,
767 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80311102,
768 .driver = "EMU10K1", .name = "SBLive! Value [CT4831]",
769 .id = "Live",
770 .emu10k1_chip = 1,
771 .ac97_chip = 1,
772 .sblive51 = 1} ,
773 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80271102,
774 .driver = "EMU10K1", .name = "SBLive! Value [CT4832]",
775 .id = "Live",
776 .emu10k1_chip = 1,
777 .ac97_chip = 1,
778 .sblive51 = 1} ,
779 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102,
780 .driver = "EMU10K1", .name = "SBLive! Value [CT4850]",
781 .id = "Live",
782 .emu10k1_chip = 1,
783 .ac97_chip = 1,
784 .sblive51 = 1} ,
785 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80281102,
786 .driver = "EMU10K1", .name = "SBLive! Value [CT4870]",
787 .id = "Live",
788 .emu10k1_chip = 1,
789 .ac97_chip = 1,
790 .sblive51 = 1} ,
791 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80321102,
792 .driver = "EMU10K1", .name = "SBLive! Value [CT4871]",
793 .id = "Live",
794 .emu10k1_chip = 1,
795 .ac97_chip = 1,
796 .sblive51 = 1} ,
797 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102,
798 .driver = "EMU10K1", .name = "SBLive! Value [SB0060]",
799 .id = "Live",
800 .emu10k1_chip = 1,
801 .ac97_chip = 1,
802 .sblive51 = 1} ,
803 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80691102,
804 .driver = "EMU10K1", .name = "SBLive! Value [SB0101]",
805 .id = "Live",
806 .emu10k1_chip = 1,
807 .ac97_chip = 1,
808 .sblive51 = 1} ,
809 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806A1102,
810 .driver = "EMU10K1", .name = "SBLive! Value [SB0103]",
811 .id = "Live",
812 .emu10k1_chip = 1,
813 .ac97_chip = 1,
814 .sblive51 = 1} ,
815 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806B1102,
816 .driver = "EMU10K1", .name = "SBLive! [SB0105]",
817 .id = "Live",
818 .emu10k1_chip = 1,
819 .ac97_chip = 1,
820 .sblive51 = 1} ,
687 {.vendor = 0x1102, .device = 0x0002, 821 {.vendor = 0x1102, .device = 0x0002,
688 .driver = "EMU10K1", .name = "SB Live [Unknown]", 822 .driver = "EMU10K1", .name = "SB Live [Unknown]",
823 .id = "Live",
689 .emu10k1_chip = 1, 824 .emu10k1_chip = 1,
690 .ac97_chip = 1} , 825 .ac97_chip = 1,
826 .sblive51 = 1} ,
691 { } /* terminator */ 827 { } /* terminator */
692}; 828};
693 829
@@ -738,13 +874,15 @@ int __devinit snd_emu10k1_create(snd_card_t * card,
738 emu->revision = revision; 874 emu->revision = revision;
739 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial); 875 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial);
740 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model); 876 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model);
741 emu->card_type = EMU10K1_CARD_CREATIVE;
742 snd_printdd("vendor=0x%x, device=0x%x, subsystem_vendor_id=0x%x, subsystem_id=0x%x\n",pci->vendor, pci->device, emu->serial, emu->model); 877 snd_printdd("vendor=0x%x, device=0x%x, subsystem_vendor_id=0x%x, subsystem_id=0x%x\n",pci->vendor, pci->device, emu->serial, emu->model);
743 878
744 for (c = emu_chip_details; c->vendor; c++) { 879 for (c = emu_chip_details; c->vendor; c++) {
745 if (c->vendor == pci->vendor && c->device == pci->device) { 880 if (c->vendor == pci->vendor && c->device == pci->device) {
746 if (c->subsystem == emu->serial) break; 881 if (c->subsystem && c->subsystem != emu->serial)
747 if (c->subsystem == 0) break; 882 continue;
883 if (c->revision && c->revision != emu->revision)
884 continue;
885 break;
748 } 886 }
749 } 887 }
750 if (c->vendor == 0) { 888 if (c->vendor == 0) {
@@ -759,6 +897,23 @@ int __devinit snd_emu10k1_create(snd_card_t * card,
759 else 897 else
760 snd_printdd("Sound card name=%s, vendor=0x%x, device=0x%x, subsystem=0x%x\n", c->name, pci->vendor, pci->device, emu->serial); 898 snd_printdd("Sound card name=%s, vendor=0x%x, device=0x%x, subsystem=0x%x\n", c->name, pci->vendor, pci->device, emu->serial);
761 899
900 if (!*card->id && c->id) {
901 int i, n = 0;
902 strlcpy(card->id, c->id, sizeof(card->id));
903 for (;;) {
904 for (i = 0; i < snd_ecards_limit; i++) {
905 if (snd_cards[i] && !strcmp(snd_cards[i]->id, card->id))
906 break;
907 }
908 if (i >= snd_ecards_limit)
909 break;
910 n++;
911 if (n >= SNDRV_CARDS)
912 break;
913 snprintf(card->id, sizeof(card->id), "%s_%d", c->id, n);
914 }
915 }
916
762 is_audigy = emu->audigy = c->emu10k2_chip; 917 is_audigy = emu->audigy = c->emu10k2_chip;
763 918
764 /* set the DMA transfer mask */ 919 /* set the DMA transfer mask */
@@ -816,15 +971,6 @@ int __devinit snd_emu10k1_create(snd_card_t * card,
816 971
817 pci_set_master(pci); 972 pci_set_master(pci);
818 973
819 if (c->ecard) {
820 emu->card_type = EMU10K1_CARD_EMUAPS;
821 emu->APS = 1;
822 }
823 if (! c->ac97_chip)
824 emu->no_ac97 = 1;
825
826 emu->spk71 = c->spk71;
827
828 emu->fx8010.fxbus_mask = 0x303f; 974 emu->fx8010.fxbus_mask = 0x303f;
829 if (extin_mask == 0) 975 if (extin_mask == 0)
830 extin_mask = 0x3fcf; 976 extin_mask = 0x3fcf;
@@ -833,7 +979,7 @@ int __devinit snd_emu10k1_create(snd_card_t * card,
833 emu->fx8010.extin_mask = extin_mask; 979 emu->fx8010.extin_mask = extin_mask;
834 emu->fx8010.extout_mask = extout_mask; 980 emu->fx8010.extout_mask = extout_mask;
835 981
836 if (emu->APS) { 982 if (emu->card_capabilities->ecard) {
837 if ((err = snd_emu10k1_ecard_init(emu)) < 0) { 983 if ((err = snd_emu10k1_ecard_init(emu)) < 0) {
838 snd_emu10k1_free(emu); 984 snd_emu10k1_free(emu);
839 return err; 985 return err;
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c
index 27dfd8ddddf4..e90c5ddd1d17 100644
--- a/sound/pci/emu10k1/emu10k1x.c
+++ b/sound/pci/emu10k1/emu10k1x.c
@@ -361,10 +361,7 @@ static void snd_emu10k1x_gpio_write(emu10k1x_t *emu, unsigned int value)
361 361
362static void snd_emu10k1x_pcm_free_substream(snd_pcm_runtime_t *runtime) 362static void snd_emu10k1x_pcm_free_substream(snd_pcm_runtime_t *runtime)
363{ 363{
364 emu10k1x_pcm_t *epcm = runtime->private_data; 364 kfree(runtime->private_data);
365
366 if (epcm)
367 kfree(epcm);
368} 365}
369 366
370static void snd_emu10k1x_pcm_interrupt(emu10k1x_t *emu, emu10k1x_voice_t *voice) 367static void snd_emu10k1x_pcm_interrupt(emu10k1x_t *emu, emu10k1x_voice_t *voice)
@@ -1075,6 +1072,7 @@ static int __devinit snd_emu10k1x_proc_init(emu10k1x_t * emu)
1075 snd_info_set_text_ops(entry, emu, 1024, snd_emu10k1x_proc_reg_read); 1072 snd_info_set_text_ops(entry, emu, 1024, snd_emu10k1x_proc_reg_read);
1076 entry->c.text.write_size = 64; 1073 entry->c.text.write_size = 64;
1077 entry->c.text.write = snd_emu10k1x_proc_reg_write; 1074 entry->c.text.write = snd_emu10k1x_proc_reg_write;
1075 entry->mode |= S_IWUSR;
1078 entry->private_data = emu; 1076 entry->private_data = emu;
1079 } 1077 }
1080 1078
@@ -1627,7 +1625,7 @@ static int __init alsa_card_emu10k1x_init(void)
1627{ 1625{
1628 int err; 1626 int err;
1629 1627
1630 if ((err = pci_module_init(&driver)) > 0) 1628 if ((err = pci_register_driver(&driver)) > 0)
1631 return err; 1629 return err;
1632 1630
1633 return 0; 1631 return 0;
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index b9fa2e887fee..0529fb281125 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -1077,7 +1077,7 @@ static int __devinit _snd_emu10k1_audigy_init_efx(emu10k1_t *emu)
1077 gpr += 2; 1077 gpr += 2;
1078 1078
1079 /* PCM Side Playback (independent from stereo mix) */ 1079 /* PCM Side Playback (independent from stereo mix) */
1080 if (emu->spk71) { 1080 if (emu->card_capabilities->spk71) {
1081 A_OP(icode, &ptr, iMAC0, A_GPR(playback+6), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_SIDE)); 1081 A_OP(icode, &ptr, iMAC0, A_GPR(playback+6), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_SIDE));
1082 A_OP(icode, &ptr, iMAC0, A_GPR(playback+7), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT_SIDE)); 1082 A_OP(icode, &ptr, iMAC0, A_GPR(playback+7), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT_SIDE));
1083 snd_emu10k1_init_stereo_control(&controls[nctl++], "PCM Side Playback Volume", gpr, 100); 1083 snd_emu10k1_init_stereo_control(&controls[nctl++], "PCM Side Playback Volume", gpr, 100);
@@ -1145,14 +1145,14 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1145 A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_SPDIF_CD_L); 1145 A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_SPDIF_CD_L);
1146 A_ADD_VOLUME_IN(stereo_mix+1, gpr+1, A_EXTIN_SPDIF_CD_R); 1146 A_ADD_VOLUME_IN(stereo_mix+1, gpr+1, A_EXTIN_SPDIF_CD_R);
1147 snd_emu10k1_init_stereo_control(&controls[nctl++], 1147 snd_emu10k1_init_stereo_control(&controls[nctl++],
1148 emu->no_ac97 ? "CD Playback Volume" : "Audigy CD Playback Volume", 1148 emu->card_capabilities->ac97_chip ? "Audigy CD Playback Volume" : "CD Playback Volume",
1149 gpr, 0); 1149 gpr, 0);
1150 gpr += 2; 1150 gpr += 2;
1151 /* Audigy CD Capture Volume */ 1151 /* Audigy CD Capture Volume */
1152 A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_SPDIF_CD_L); 1152 A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_SPDIF_CD_L);
1153 A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_SPDIF_CD_R); 1153 A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_SPDIF_CD_R);
1154 snd_emu10k1_init_stereo_control(&controls[nctl++], 1154 snd_emu10k1_init_stereo_control(&controls[nctl++],
1155 emu->no_ac97 ? "CD Capture Volume" : "Audigy CD Capture Volume", 1155 emu->card_capabilities->ac97_chip ? "Audigy CD Capture Volume" : "CD Capture Volume",
1156 gpr, 0); 1156 gpr, 0);
1157 gpr += 2; 1157 gpr += 2;
1158 1158
@@ -1171,14 +1171,14 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1171 A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_LINE2_L); 1171 A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_LINE2_L);
1172 A_ADD_VOLUME_IN(stereo_mix+1, gpr+1, A_EXTIN_LINE2_R); 1172 A_ADD_VOLUME_IN(stereo_mix+1, gpr+1, A_EXTIN_LINE2_R);
1173 snd_emu10k1_init_stereo_control(&controls[nctl++], 1173 snd_emu10k1_init_stereo_control(&controls[nctl++],
1174 emu->no_ac97 ? "Line Playback Volume" : "Line2 Playback Volume", 1174 emu->card_capabilities->ac97_chip ? "Line2 Playback Volume" : "Line Playback Volume",
1175 gpr, 0); 1175 gpr, 0);
1176 gpr += 2; 1176 gpr += 2;
1177 /* Line2 Capture Volume */ 1177 /* Line2 Capture Volume */
1178 A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_LINE2_L); 1178 A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_LINE2_L);
1179 A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_LINE2_R); 1179 A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_LINE2_R);
1180 snd_emu10k1_init_stereo_control(&controls[nctl++], 1180 snd_emu10k1_init_stereo_control(&controls[nctl++],
1181 emu->no_ac97 ? "Line Capture Volume" : "Line2 Capture Volume", 1181 emu->card_capabilities->ac97_chip ? "Line2 Capture Volume" : "Line Capture Volume",
1182 gpr, 0); 1182 gpr, 0);
1183 gpr += 2; 1183 gpr += 2;
1184 1184
@@ -1197,14 +1197,14 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1197 A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_AUX2_L); 1197 A_ADD_VOLUME_IN(stereo_mix, gpr, A_EXTIN_AUX2_L);
1198 A_ADD_VOLUME_IN(stereo_mix+1, gpr+1, A_EXTIN_AUX2_R); 1198 A_ADD_VOLUME_IN(stereo_mix+1, gpr+1, A_EXTIN_AUX2_R);
1199 snd_emu10k1_init_stereo_control(&controls[nctl++], 1199 snd_emu10k1_init_stereo_control(&controls[nctl++],
1200 emu->no_ac97 ? "Aux Playback Volume" : "Aux2 Playback Volume", 1200 emu->card_capabilities->ac97_chip ? "Aux2 Playback Volume" : "Aux Playback Volume",
1201 gpr, 0); 1201 gpr, 0);
1202 gpr += 2; 1202 gpr += 2;
1203 /* Aux2 Capture Volume */ 1203 /* Aux2 Capture Volume */
1204 A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_AUX2_L); 1204 A_ADD_VOLUME_IN(capture, gpr, A_EXTIN_AUX2_L);
1205 A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_AUX2_R); 1205 A_ADD_VOLUME_IN(capture+1, gpr+1, A_EXTIN_AUX2_R);
1206 snd_emu10k1_init_stereo_control(&controls[nctl++], 1206 snd_emu10k1_init_stereo_control(&controls[nctl++],
1207 emu->no_ac97 ? "Aux Capture Volume" : "Aux2 Capture Volume", 1207 emu->card_capabilities->ac97_chip ? "Aux2 Capture Volume" : "Aux Capture Volume",
1208 gpr, 0); 1208 gpr, 0);
1209 gpr += 2; 1209 gpr += 2;
1210 1210
@@ -1232,7 +1232,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1232 snd_emu10k1_init_mono_control(&controls[nctl++], "LFE Playback Volume", gpr, 0); 1232 snd_emu10k1_init_mono_control(&controls[nctl++], "LFE Playback Volume", gpr, 0);
1233 gpr++; 1233 gpr++;
1234 1234
1235 if (emu->spk71) { 1235 if (emu->card_capabilities->spk71) {
1236 /* Stereo Mix Side Playback */ 1236 /* Stereo Mix Side Playback */
1237 A_OP(icode, &ptr, iMAC0, A_GPR(playback+6), A_GPR(playback+6), A_GPR(gpr), A_GPR(stereo_mix)); 1237 A_OP(icode, &ptr, iMAC0, A_GPR(playback+6), A_GPR(playback+6), A_GPR(gpr), A_GPR(stereo_mix));
1238 A_OP(icode, &ptr, iMAC0, A_GPR(playback+7), A_GPR(playback+7), A_GPR(gpr+1), A_GPR(stereo_mix+1)); 1238 A_OP(icode, &ptr, iMAC0, A_GPR(playback+7), A_GPR(playback+7), A_GPR(gpr+1), A_GPR(stereo_mix+1));
@@ -1266,7 +1266,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1266 A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 3), A_GPR(playback + 3), A_C_00000000, A_C_00000000); /* rear right */ 1266 A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 3), A_GPR(playback + 3), A_C_00000000, A_C_00000000); /* rear right */
1267 A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 4), A_GPR(playback + 4), A_C_00000000, A_C_00000000); /* center */ 1267 A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 4), A_GPR(playback + 4), A_C_00000000, A_C_00000000); /* center */
1268 A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 5), A_GPR(playback + 5), A_C_00000000, A_C_00000000); /* LFE */ 1268 A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 5), A_GPR(playback + 5), A_C_00000000, A_C_00000000); /* LFE */
1269 if (emu->spk71) { 1269 if (emu->card_capabilities->spk71) {
1270 A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 6), A_GPR(playback + 6), A_C_00000000, A_C_00000000); /* side left */ 1270 A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 6), A_GPR(playback + 6), A_C_00000000, A_C_00000000); /* side left */
1271 A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 7), A_GPR(playback + 7), A_C_00000000, A_C_00000000); /* side right */ 1271 A_OP(icode, &ptr, iACC3, A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 7), A_GPR(playback + 7), A_C_00000000, A_C_00000000); /* side right */
1272 } 1272 }
@@ -1359,7 +1359,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1359 A_PUT_STEREO_OUTPUT(A_EXTOUT_AREAR_L, A_EXTOUT_AREAR_R, playback+2 + SND_EMU10K1_PLAYBACK_CHANNELS); 1359 A_PUT_STEREO_OUTPUT(A_EXTOUT_AREAR_L, A_EXTOUT_AREAR_R, playback+2 + SND_EMU10K1_PLAYBACK_CHANNELS);
1360 A_PUT_OUTPUT(A_EXTOUT_ACENTER, playback+4 + SND_EMU10K1_PLAYBACK_CHANNELS); 1360 A_PUT_OUTPUT(A_EXTOUT_ACENTER, playback+4 + SND_EMU10K1_PLAYBACK_CHANNELS);
1361 A_PUT_OUTPUT(A_EXTOUT_ALFE, playback+5 + SND_EMU10K1_PLAYBACK_CHANNELS); 1361 A_PUT_OUTPUT(A_EXTOUT_ALFE, playback+5 + SND_EMU10K1_PLAYBACK_CHANNELS);
1362 if (emu->spk71) 1362 if (emu->card_capabilities->spk71)
1363 A_PUT_STEREO_OUTPUT(A_EXTOUT_ASIDE_L, A_EXTOUT_ASIDE_R, playback+6 + SND_EMU10K1_PLAYBACK_CHANNELS); 1363 A_PUT_STEREO_OUTPUT(A_EXTOUT_ASIDE_L, A_EXTOUT_ASIDE_R, playback+6 + SND_EMU10K1_PLAYBACK_CHANNELS);
1364 1364
1365 /* headphone */ 1365 /* headphone */
@@ -1982,22 +1982,27 @@ static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu)
1982 OP(icode, &ptr, iACC3, EXTOUT(EXTOUT_MIC_CAP), GPR(capture + 2), C_00000000, C_00000000); 1982 OP(icode, &ptr, iACC3, EXTOUT(EXTOUT_MIC_CAP), GPR(capture + 2), C_00000000, C_00000000);
1983 1983
1984 /* EFX capture - capture the 16 EXTINS */ 1984 /* EFX capture - capture the 16 EXTINS */
1985 OP(icode, &ptr, iACC3, FXBUS2(14), C_00000000, C_00000000, EXTIN(0)); 1985 if (emu->card_capabilities->sblive51) {
1986 OP(icode, &ptr, iACC3, FXBUS2(15), C_00000000, C_00000000, EXTIN(1)); 1986 /* On the Live! 5.1, FXBUS2(1) and FXBUS(2) are shared with EXTOUT_ACENTER
1987 OP(icode, &ptr, iACC3, FXBUS2(0), C_00000000, C_00000000, EXTIN(2)); 1987 * and EXTOUT_ALFE, so we can't connect inputs to them for multitrack recording.
1988 OP(icode, &ptr, iACC3, FXBUS2(3), C_00000000, C_00000000, EXTIN(3)); 1988 *
1989 /* Dont connect anything to FXBUS2 1 and 2. These are shared with 1989 * Since only 14 of the 16 EXTINs are used, this is not a big problem.
1990 * Center/LFE on the SBLive 5.1. The kX driver only changes the 1990 * We route AC97L and R to FX capture 14 and 15, SPDIF CD in to FX capture
1991 * routing when it detects an SBLive 5.1. 1991 * 0 and 3, then the rest of the EXTINs to the corresponding FX capture
1992 * 1992 * channel. Multitrack recorders will still see the center/lfe output signal
1993 * Since only 14 of the 16 EXTINs are used, this is not a big problem. 1993 * on the second and third channels.
1994 * We route AC97L and R to FX capture 14 and 15, SPDIF CD in to FX capture 1994 */
1995 * 0 and 3, then the rest of the EXTINs to the corresponding FX capture 1995 OP(icode, &ptr, iACC3, FXBUS2(14), C_00000000, C_00000000, EXTIN(0));
1996 * channel. 1996 OP(icode, &ptr, iACC3, FXBUS2(15), C_00000000, C_00000000, EXTIN(1));
1997 */ 1997 OP(icode, &ptr, iACC3, FXBUS2(0), C_00000000, C_00000000, EXTIN(2));
1998 for (z = 4; z < 14; z++) { 1998 OP(icode, &ptr, iACC3, FXBUS2(3), C_00000000, C_00000000, EXTIN(3));
1999 OP(icode, &ptr, iACC3, FXBUS2(z), C_00000000, C_00000000, EXTIN(z)); 1999 for (z = 4; z < 14; z++)
2000 OP(icode, &ptr, iACC3, FXBUS2(z), C_00000000, C_00000000, EXTIN(z));
2001 } else {
2002 for (z = 0; z < 16; z++)
2003 OP(icode, &ptr, iACC3, FXBUS2(z), C_00000000, C_00000000, EXTIN(z));
2000 } 2004 }
2005
2001 2006
2002 if (gpr > tmp) { 2007 if (gpr > tmp) {
2003 snd_BUG(); 2008 snd_BUG();
@@ -2128,7 +2133,6 @@ static int snd_emu10k1_fx8010_info(emu10k1_t *emu, emu10k1_fx8010_info_t *info)
2128 int res; 2133 int res;
2129 2134
2130 memset(info, 0, sizeof(info)); 2135 memset(info, 0, sizeof(info));
2131 info->card = emu->card_type;
2132 info->internal_tram_size = emu->fx8010.itram_size; 2136 info->internal_tram_size = emu->fx8010.itram_size;
2133 info->external_tram_size = emu->fx8010.etram_pages.bytes / 2; 2137 info->external_tram_size = emu->fx8010.etram_pages.bytes / 2;
2134 fxbus = fxbuses; 2138 fxbus = fxbuses;
diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c
index 044663d31aa7..6be82c5fe138 100644
--- a/sound/pci/emu10k1/emumixer.c
+++ b/sound/pci/emu10k1/emumixer.c
@@ -68,6 +68,7 @@ static int snd_emu10k1_spdif_get_mask(snd_kcontrol_t * kcontrol,
68 return 0; 68 return 0;
69} 69}
70 70
71#if 0
71static int snd_audigy_spdif_output_rate_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 72static int snd_audigy_spdif_output_rate_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
72{ 73{
73 static char *texts[] = {"44100", "48000", "96000"}; 74 static char *texts[] = {"44100", "48000", "96000"};
@@ -152,6 +153,7 @@ static snd_kcontrol_new_t snd_audigy_spdif_output_rate =
152 .get = snd_audigy_spdif_output_rate_get, 153 .get = snd_audigy_spdif_output_rate_get,
153 .put = snd_audigy_spdif_output_rate_put 154 .put = snd_audigy_spdif_output_rate_put
154}; 155};
156#endif
155 157
156static int snd_emu10k1_spdif_put(snd_kcontrol_t * kcontrol, 158static int snd_emu10k1_spdif_put(snd_kcontrol_t * kcontrol,
157 snd_ctl_elem_value_t * ucontrol) 159 snd_ctl_elem_value_t * ucontrol)
@@ -791,7 +793,7 @@ int __devinit snd_emu10k1_mixer(emu10k1_t *emu)
791 NULL 793 NULL
792 }; 794 };
793 795
794 if (!emu->no_ac97) { 796 if (emu->card_capabilities->ac97_chip) {
795 ac97_bus_t *pbus; 797 ac97_bus_t *pbus;
796 ac97_template_t ac97; 798 ac97_template_t ac97;
797 static ac97_bus_ops_t ops = { 799 static ac97_bus_ops_t ops = {
@@ -833,7 +835,7 @@ int __devinit snd_emu10k1_mixer(emu10k1_t *emu)
833 for (; *c; c++) 835 for (; *c; c++)
834 remove_ctl(card, *c); 836 remove_ctl(card, *c);
835 } else { 837 } else {
836 if (emu->APS) 838 if (emu->card_capabilities->ecard)
837 strcpy(emu->card->mixername, "EMU APS"); 839 strcpy(emu->card->mixername, "EMU APS");
838 else if (emu->audigy) 840 else if (emu->audigy)
839 strcpy(emu->card->mixername, "SB Audigy"); 841 strcpy(emu->card->mixername, "SB Audigy");
@@ -918,7 +920,7 @@ int __devinit snd_emu10k1_mixer(emu10k1_t *emu)
918 mix->attn[0] = 0xffff; 920 mix->attn[0] = 0xffff;
919 } 921 }
920 922
921 if (! emu->APS) { /* FIXME: APS has these controls? */ 923 if (! emu->card_capabilities->ecard) { /* FIXME: APS has these controls? */
922 /* sb live! and audigy */ 924 /* sb live! and audigy */
923 if ((kctl = snd_ctl_new1(&snd_emu10k1_spdif_mask_control, emu)) == NULL) 925 if ((kctl = snd_ctl_new1(&snd_emu10k1_spdif_mask_control, emu)) == NULL)
924 return -ENOMEM; 926 return -ENOMEM;
@@ -935,18 +937,20 @@ int __devinit snd_emu10k1_mixer(emu10k1_t *emu)
935 return -ENOMEM; 937 return -ENOMEM;
936 if ((err = snd_ctl_add(card, kctl))) 938 if ((err = snd_ctl_add(card, kctl)))
937 return err; 939 return err;
940#if 0
938 if ((kctl = snd_ctl_new1(&snd_audigy_spdif_output_rate, emu)) == NULL) 941 if ((kctl = snd_ctl_new1(&snd_audigy_spdif_output_rate, emu)) == NULL)
939 return -ENOMEM; 942 return -ENOMEM;
940 if ((err = snd_ctl_add(card, kctl))) 943 if ((err = snd_ctl_add(card, kctl)))
941 return err; 944 return err;
942 } else if (! emu->APS) { 945#endif
946 } else if (! emu->card_capabilities->ecard) {
943 /* sb live! */ 947 /* sb live! */
944 if ((kctl = snd_ctl_new1(&snd_emu10k1_shared_spdif, emu)) == NULL) 948 if ((kctl = snd_ctl_new1(&snd_emu10k1_shared_spdif, emu)) == NULL)
945 return -ENOMEM; 949 return -ENOMEM;
946 if ((err = snd_ctl_add(card, kctl))) 950 if ((err = snd_ctl_add(card, kctl)))
947 return err; 951 return err;
948 } 952 }
949 if (emu->audigy && emu->revision == 4) { /* P16V */ 953 if (emu->card_capabilities->ca0151_chip) { /* P16V */
950 if ((err = snd_p16v_mixer(emu))) 954 if ((err = snd_p16v_mixer(emu)))
951 return err; 955 return err;
952 } 956 }
diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c
index d1c2a02c486b..520b99af5f55 100644
--- a/sound/pci/emu10k1/emupcm.c
+++ b/sound/pci/emu10k1/emupcm.c
@@ -262,7 +262,7 @@ static unsigned int emu10k1_select_interprom(unsigned int pitch_target)
262 * 262 *
263 * returns: cache invalidate size in samples 263 * returns: cache invalidate size in samples
264 */ 264 */
265static int inline emu10k1_ccis(int stereo, int w_16) 265static inline int emu10k1_ccis(int stereo, int w_16)
266{ 266{
267 if (w_16) { 267 if (w_16) {
268 return stereo ? 24 : 26; 268 return stereo ? 24 : 26;
@@ -991,9 +991,7 @@ static void snd_emu10k1_pcm_efx_mixer_notify(emu10k1_t *emu, int idx, int activa
991 991
992static void snd_emu10k1_pcm_free_substream(snd_pcm_runtime_t *runtime) 992static void snd_emu10k1_pcm_free_substream(snd_pcm_runtime_t *runtime)
993{ 993{
994 emu10k1_pcm_t *epcm = runtime->private_data; 994 kfree(runtime->private_data);
995
996 kfree(epcm);
997} 995}
998 996
999static int snd_emu10k1_efx_playback_close(snd_pcm_substream_t * substream) 997static int snd_emu10k1_efx_playback_close(snd_pcm_substream_t * substream)
diff --git a/sound/pci/emu10k1/emuproc.c b/sound/pci/emu10k1/emuproc.c
index d990d5eb45a8..cc22707c91fa 100644
--- a/sound/pci/emu10k1/emuproc.c
+++ b/sound/pci/emu10k1/emuproc.c
@@ -30,6 +30,7 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <sound/core.h> 31#include <sound/core.h>
32#include <sound/emu10k1.h> 32#include <sound/emu10k1.h>
33#include "p16v.h"
33 34
34static void snd_emu10k1_proc_spdif_status(emu10k1_t * emu, 35static void snd_emu10k1_proc_spdif_status(emu10k1_t * emu,
35 snd_info_buffer_t * buffer, 36 snd_info_buffer_t * buffer,
@@ -44,28 +45,34 @@ static void snd_emu10k1_proc_spdif_status(emu10k1_t * emu,
44 unsigned int status, rate = 0; 45 unsigned int status, rate = 0;
45 46
46 status = snd_emu10k1_ptr_read(emu, status_reg, 0); 47 status = snd_emu10k1_ptr_read(emu, status_reg, 0);
47 if (rate_reg > 0)
48 rate = snd_emu10k1_ptr_read(emu, rate_reg, 0);
49 48
50 snd_iprintf(buffer, "\n%s\n", title); 49 snd_iprintf(buffer, "\n%s\n", title);
51 50
52 snd_iprintf(buffer, "Professional Mode : %s\n", (status & SPCS_PROFESSIONAL) ? "yes" : "no"); 51 if (status != 0xffffffff) {
53 snd_iprintf(buffer, "Not Audio Data : %s\n", (status & SPCS_NOTAUDIODATA) ? "yes" : "no"); 52 snd_iprintf(buffer, "Professional Mode : %s\n", (status & SPCS_PROFESSIONAL) ? "yes" : "no");
54 snd_iprintf(buffer, "Copyright : %s\n", (status & SPCS_COPYRIGHT) ? "yes" : "no"); 53 snd_iprintf(buffer, "Not Audio Data : %s\n", (status & SPCS_NOTAUDIODATA) ? "yes" : "no");
55 snd_iprintf(buffer, "Emphasis : %s\n", emphasis[(status & SPCS_EMPHASISMASK) >> 3]); 54 snd_iprintf(buffer, "Copyright : %s\n", (status & SPCS_COPYRIGHT) ? "yes" : "no");
56 snd_iprintf(buffer, "Mode : %i\n", (status & SPCS_MODEMASK) >> 6); 55 snd_iprintf(buffer, "Emphasis : %s\n", emphasis[(status & SPCS_EMPHASISMASK) >> 3]);
57 snd_iprintf(buffer, "Category Code : 0x%x\n", (status & SPCS_CATEGORYCODEMASK) >> 8); 56 snd_iprintf(buffer, "Mode : %i\n", (status & SPCS_MODEMASK) >> 6);
58 snd_iprintf(buffer, "Generation Status : %s\n", status & SPCS_GENERATIONSTATUS ? "original" : "copy"); 57 snd_iprintf(buffer, "Category Code : 0x%x\n", (status & SPCS_CATEGORYCODEMASK) >> 8);
59 snd_iprintf(buffer, "Source Mask : %i\n", (status & SPCS_SOURCENUMMASK) >> 16); 58 snd_iprintf(buffer, "Generation Status : %s\n", status & SPCS_GENERATIONSTATUS ? "original" : "copy");
60 snd_iprintf(buffer, "Channel Number : %s\n", channel[(status & SPCS_CHANNELNUMMASK) >> 20]); 59 snd_iprintf(buffer, "Source Mask : %i\n", (status & SPCS_SOURCENUMMASK) >> 16);
61 snd_iprintf(buffer, "Sample Rate : %iHz\n", samplerate[(status & SPCS_SAMPLERATEMASK) >> 24]); 60 snd_iprintf(buffer, "Channel Number : %s\n", channel[(status & SPCS_CHANNELNUMMASK) >> 20]);
62 snd_iprintf(buffer, "Clock Accuracy : %s\n", clkaccy[(status & SPCS_CLKACCYMASK) >> 28]); 61 snd_iprintf(buffer, "Sample Rate : %iHz\n", samplerate[(status & SPCS_SAMPLERATEMASK) >> 24]);
63 62 snd_iprintf(buffer, "Clock Accuracy : %s\n", clkaccy[(status & SPCS_CLKACCYMASK) >> 28]);
64 if (rate_reg > 0) { 63
65 snd_iprintf(buffer, "S/PDIF Locked : %s\n", rate & SRCS_SPDIFLOCKED ? "on" : "off"); 64 if (rate_reg > 0) {
66 snd_iprintf(buffer, "Rate Locked : %s\n", rate & SRCS_RATELOCKED ? "on" : "off"); 65 rate = snd_emu10k1_ptr_read(emu, rate_reg, 0);
67 snd_iprintf(buffer, "Estimated Sample Rate : 0x%x\n", rate & SRCS_ESTSAMPLERATE); 66 snd_iprintf(buffer, "S/PDIF Valid : %s\n", rate & SRCS_SPDIFVALID ? "on" : "off");
67 snd_iprintf(buffer, "S/PDIF Locked : %s\n", rate & SRCS_SPDIFLOCKED ? "on" : "off");
68 snd_iprintf(buffer, "Rate Locked : %s\n", rate & SRCS_RATELOCKED ? "on" : "off");
69 /* From ((Rate * 48000 ) / 262144); */
70 snd_iprintf(buffer, "Estimated Sample Rate : %d\n", ((rate & 0xFFFFF ) * 375) >> 11);
71 }
72 } else {
73 snd_iprintf(buffer, "No signal detected.\n");
68 } 74 }
75
69} 76}
70 77
71static void snd_emu10k1_proc_read(snd_info_entry_t *entry, 78static void snd_emu10k1_proc_read(snd_info_entry_t *entry,
@@ -182,7 +189,7 @@ static void snd_emu10k1_proc_read(snd_info_entry_t *entry,
182 189
183 snd_iprintf(buffer, "EMU10K1\n\n"); 190 snd_iprintf(buffer, "EMU10K1\n\n");
184 snd_iprintf(buffer, "Card : %s\n", 191 snd_iprintf(buffer, "Card : %s\n",
185 emu->audigy ? "Audigy" : (emu->APS ? "EMU APS" : "Creative")); 192 emu->audigy ? "Audigy" : (emu->card_capabilities->ecard ? "EMU APS" : "Creative"));
186 snd_iprintf(buffer, "Internal TRAM (words) : 0x%x\n", emu->fx8010.itram_size); 193 snd_iprintf(buffer, "Internal TRAM (words) : 0x%x\n", emu->fx8010.itram_size);
187 snd_iprintf(buffer, "External TRAM (words) : 0x%x\n", (int)emu->fx8010.etram_pages.bytes / 2); 194 snd_iprintf(buffer, "External TRAM (words) : 0x%x\n", (int)emu->fx8010.etram_pages.bytes / 2);
188 snd_iprintf(buffer, "\n"); 195 snd_iprintf(buffer, "\n");
@@ -223,15 +230,35 @@ static void snd_emu10k1_proc_read(snd_info_entry_t *entry,
223 snd_iprintf(buffer, "\nAll FX Outputs :\n"); 230 snd_iprintf(buffer, "\nAll FX Outputs :\n");
224 for (idx = 0; idx < (emu->audigy ? 64 : 32); idx++) 231 for (idx = 0; idx < (emu->audigy ? 64 : 32); idx++)
225 snd_iprintf(buffer, " Output %02i [%s]\n", idx, outputs[idx]); 232 snd_iprintf(buffer, " Output %02i [%s]\n", idx, outputs[idx]);
226 snd_emu10k1_proc_spdif_status(emu, buffer, "S/PDIF Output 0", SPCS0, -1); 233}
227 snd_emu10k1_proc_spdif_status(emu, buffer, "S/PDIF Output 1", SPCS1, -1); 234
228 snd_emu10k1_proc_spdif_status(emu, buffer, "S/PDIF Output 2/3", SPCS2, -1); 235static void snd_emu10k1_proc_spdif_read(snd_info_entry_t *entry,
229 snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF", CDCS, CDSRCS); 236 snd_info_buffer_t * buffer)
230 snd_emu10k1_proc_spdif_status(emu, buffer, "General purpose S/PDIF", GPSCS, GPSRCS); 237{
238 emu10k1_t *emu = entry->private_data;
239 snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF In", CDCS, CDSRCS);
240 snd_emu10k1_proc_spdif_status(emu, buffer, "Optical or Coax S/PDIF In", GPSCS, GPSRCS);
241#if 0
231 val = snd_emu10k1_ptr_read(emu, ZVSRCS, 0); 242 val = snd_emu10k1_ptr_read(emu, ZVSRCS, 0);
232 snd_iprintf(buffer, "\nZoomed Video\n"); 243 snd_iprintf(buffer, "\nZoomed Video\n");
233 snd_iprintf(buffer, "Rate Locked : %s\n", val & SRCS_RATELOCKED ? "on" : "off"); 244 snd_iprintf(buffer, "Rate Locked : %s\n", val & SRCS_RATELOCKED ? "on" : "off");
234 snd_iprintf(buffer, "Estimated Sample Rate : 0x%x\n", val & SRCS_ESTSAMPLERATE); 245 snd_iprintf(buffer, "Estimated Sample Rate : 0x%x\n", val & SRCS_ESTSAMPLERATE);
246#endif
247}
248
249static void snd_emu10k1_proc_rates_read(snd_info_entry_t *entry,
250 snd_info_buffer_t * buffer)
251{
252 static int samplerate[8] = { 44100, 48000, 96000, 192000, 4, 5, 6, 7 };
253 emu10k1_t *emu = entry->private_data;
254 unsigned int val, tmp, n;
255 val = snd_emu10k1_ptr20_read(emu, CAPTURE_RATE_STATUS, 0);
256 tmp = (val >> 16) & 0x8;
257 for (n=0;n<4;n++) {
258 tmp = val >> (16 + (n*4));
259 if (tmp & 0x8) snd_iprintf(buffer, "Channel %d: Rate=%d\n", n, samplerate[tmp & 0x7]);
260 else snd_iprintf(buffer, "Channel %d: No input\n", n);
261 }
235} 262}
236 263
237static void snd_emu10k1_proc_acode_read(snd_info_entry_t *entry, 264static void snd_emu10k1_proc_acode_read(snd_info_entry_t *entry,
@@ -500,32 +527,46 @@ int __devinit snd_emu10k1_proc_init(emu10k1_t * emu)
500 snd_info_set_text_ops(entry, emu, 1024, snd_emu_proc_io_reg_read); 527 snd_info_set_text_ops(entry, emu, 1024, snd_emu_proc_io_reg_read);
501 entry->c.text.write_size = 64; 528 entry->c.text.write_size = 64;
502 entry->c.text.write = snd_emu_proc_io_reg_write; 529 entry->c.text.write = snd_emu_proc_io_reg_write;
530 entry->mode |= S_IWUSR;
503 } 531 }
504 if (! snd_card_proc_new(emu->card, "ptr_regs00a", &entry)) { 532 if (! snd_card_proc_new(emu->card, "ptr_regs00a", &entry)) {
505 snd_info_set_text_ops(entry, emu, 65536, snd_emu_proc_ptr_reg_read00a); 533 snd_info_set_text_ops(entry, emu, 65536, snd_emu_proc_ptr_reg_read00a);
506 entry->c.text.write_size = 64; 534 entry->c.text.write_size = 64;
507 entry->c.text.write = snd_emu_proc_ptr_reg_write00; 535 entry->c.text.write = snd_emu_proc_ptr_reg_write00;
536 entry->mode |= S_IWUSR;
508 } 537 }
509 if (! snd_card_proc_new(emu->card, "ptr_regs00b", &entry)) { 538 if (! snd_card_proc_new(emu->card, "ptr_regs00b", &entry)) {
510 snd_info_set_text_ops(entry, emu, 65536, snd_emu_proc_ptr_reg_read00b); 539 snd_info_set_text_ops(entry, emu, 65536, snd_emu_proc_ptr_reg_read00b);
511 entry->c.text.write_size = 64; 540 entry->c.text.write_size = 64;
512 entry->c.text.write = snd_emu_proc_ptr_reg_write00; 541 entry->c.text.write = snd_emu_proc_ptr_reg_write00;
542 entry->mode |= S_IWUSR;
513 } 543 }
514 if (! snd_card_proc_new(emu->card, "ptr_regs20a", &entry)) { 544 if (! snd_card_proc_new(emu->card, "ptr_regs20a", &entry)) {
515 snd_info_set_text_ops(entry, emu, 65536, snd_emu_proc_ptr_reg_read20a); 545 snd_info_set_text_ops(entry, emu, 65536, snd_emu_proc_ptr_reg_read20a);
516 entry->c.text.write_size = 64; 546 entry->c.text.write_size = 64;
517 entry->c.text.write = snd_emu_proc_ptr_reg_write20; 547 entry->c.text.write = snd_emu_proc_ptr_reg_write20;
548 entry->mode |= S_IWUSR;
518 } 549 }
519 if (! snd_card_proc_new(emu->card, "ptr_regs20b", &entry)) { 550 if (! snd_card_proc_new(emu->card, "ptr_regs20b", &entry)) {
520 snd_info_set_text_ops(entry, emu, 65536, snd_emu_proc_ptr_reg_read20b); 551 snd_info_set_text_ops(entry, emu, 65536, snd_emu_proc_ptr_reg_read20b);
521 entry->c.text.write_size = 64; 552 entry->c.text.write_size = 64;
522 entry->c.text.write = snd_emu_proc_ptr_reg_write20; 553 entry->c.text.write = snd_emu_proc_ptr_reg_write20;
554 entry->mode |= S_IWUSR;
523 } 555 }
524#endif 556#endif
525 557
526 if (! snd_card_proc_new(emu->card, "emu10k1", &entry)) 558 if (! snd_card_proc_new(emu->card, "emu10k1", &entry))
527 snd_info_set_text_ops(entry, emu, 2048, snd_emu10k1_proc_read); 559 snd_info_set_text_ops(entry, emu, 2048, snd_emu10k1_proc_read);
528 560
561 if (emu->card_capabilities->emu10k2_chip) {
562 if (! snd_card_proc_new(emu->card, "spdif-in", &entry))
563 snd_info_set_text_ops(entry, emu, 2048, snd_emu10k1_proc_spdif_read);
564 }
565 if (emu->card_capabilities->ca0151_chip) {
566 if (! snd_card_proc_new(emu->card, "capture-rates", &entry))
567 snd_info_set_text_ops(entry, emu, 2048, snd_emu10k1_proc_rates_read);
568 }
569
529 if (! snd_card_proc_new(emu->card, "voices", &entry)) 570 if (! snd_card_proc_new(emu->card, "voices", &entry))
530 snd_info_set_text_ops(entry, emu, 2048, snd_emu10k1_proc_voices_read); 571 snd_info_set_text_ops(entry, emu, 2048, snd_emu10k1_proc_voices_read);
531 572
diff --git a/sound/pci/emu10k1/irq.c b/sound/pci/emu10k1/irq.c
index b81a7cafff39..cd8460d56752 100644
--- a/sound/pci/emu10k1/irq.c
+++ b/sound/pci/emu10k1/irq.c
@@ -37,7 +37,7 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
37 int handled = 0; 37 int handled = 0;
38 38
39 while ((status = inl(emu->port + IPR)) != 0) { 39 while ((status = inl(emu->port + IPR)) != 0) {
40 // printk("irq - status = 0x%x\n", status); 40 //printk("emu10k1 irq - status = 0x%x\n", status);
41 orig_status = status; 41 orig_status = status;
42 handled = 1; 42 handled = 1;
43 if (status & IPR_PCIERROR) { 43 if (status & IPR_PCIERROR) {
@@ -147,9 +147,36 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
147 snd_emu10k1_intr_disable(emu, INTE_FXDSPENABLE); 147 snd_emu10k1_intr_disable(emu, INTE_FXDSPENABLE);
148 status &= ~IPR_FXDSP; 148 status &= ~IPR_FXDSP;
149 } 149 }
150 if (status & IPR_P16V) {
151 while ((status2 = inl(emu->port + IPR2)) != 0) {
152 u32 mask = INTE2_PLAYBACK_CH_0_LOOP; /* Full Loop */
153 emu10k1_voice_t *pvoice = &(emu->p16v_voices[0]);
154 emu10k1_voice_t *cvoice = &(emu->p16v_capture_voice);
155
156 //printk(KERN_INFO "status2=0x%x\n", status2);
157 orig_status2 = status2;
158 if(status2 & mask) {
159 if(pvoice->use) {
160 snd_pcm_period_elapsed(pvoice->epcm->substream);
161 } else {
162 snd_printk(KERN_ERR "p16v: status: 0x%08x, mask=0x%08x, pvoice=%p, use=%d\n", status2, mask, pvoice, pvoice->use);
163 }
164 }
165 if(status2 & 0x110000) {
166 //printk(KERN_INFO "capture int found\n");
167 if(cvoice->use) {
168 //printk(KERN_INFO "capture period_elapsed\n");
169 snd_pcm_period_elapsed(cvoice->epcm->substream);
170 }
171 }
172 outl(orig_status2, emu->port + IPR2); /* ack all */
173 }
174 status &= ~IPR_P16V;
175 }
176
150 if (status) { 177 if (status) {
151 unsigned int bits; 178 unsigned int bits;
152 //snd_printk(KERN_ERR "emu10k1: unhandled interrupt: 0x%08x\n", status); 179 snd_printk(KERN_ERR "emu10k1: unhandled interrupt: 0x%08x\n", status);
153 //make sure any interrupts we don't handle are disabled: 180 //make sure any interrupts we don't handle are disabled:
154 bits = INTE_FXDSPENABLE | 181 bits = INTE_FXDSPENABLE |
155 INTE_PCIERRORENABLE | 182 INTE_PCIERRORENABLE |
@@ -170,20 +197,5 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
170 } 197 }
171 outl(orig_status, emu->port + IPR); /* ack all */ 198 outl(orig_status, emu->port + IPR); /* ack all */
172 } 199 }
173 if (emu->audigy && emu->revision == 4) { /* P16V */
174 while ((status2 = inl(emu->port + IPR2)) != 0) {
175 u32 mask = INTE2_PLAYBACK_CH_0_LOOP; /* Full Loop */
176 emu10k1_voice_t *pvoice = &(emu->p16v_voices[0]);
177 orig_status2 = status2;
178 if(status2 & mask) {
179 if(pvoice->use) {
180 snd_pcm_period_elapsed(pvoice->epcm->substream);
181 } else {
182 snd_printk(KERN_ERR "p16v: status: 0x%08x, mask=0x%08x, pvoice=%p, use=%d\n", status2, mask, pvoice, pvoice->use);
183 }
184 }
185 outl(orig_status2, emu->port + IPR2); /* ack all */
186 }
187 }
188 return IRQ_RETVAL(handled); 200 return IRQ_RETVAL(handled);
189} 201}
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c
index d03cb2fefc9e..98f980189892 100644
--- a/sound/pci/emu10k1/p16v.c
+++ b/sound/pci/emu10k1/p16v.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk> 2 * Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk>
3 * Driver p16v chips 3 * Driver p16v chips
4 * Version: 0.22 4 * Version: 0.25
5 * 5 *
6 * FEATURES currently supported: 6 * FEATURES currently supported:
7 * Output fixed at S32_LE, 2 channel to hw:0,0 7 * Output fixed at S32_LE, 2 channel to hw:0,0
@@ -41,7 +41,15 @@
41 * Integrated with snd-emu10k1 driver. 41 * Integrated with snd-emu10k1 driver.
42 * 0.22 42 * 0.22
43 * Removed #if 0 ... #endif 43 * Removed #if 0 ... #endif
44 * 44 * 0.23
45 * Implement different capture rates.
46 * 0.24
47 * Implement different capture source channels.
48 * e.g. When HD Capture source is set to SPDIF,
49 * setting HD Capture channel to 0 captures from CDROM digital input.
50 * setting HD Capture channel to 1 captures from SPDIF in.
51 * 0.25
52 * Include capture buffer sizes.
45 * 53 *
46 * BUGS: 54 * BUGS:
47 * Some stability problems when unloading the snd-p16v kernel module. 55 * Some stability problems when unloading the snd-p16v kernel module.
@@ -119,22 +127,41 @@ static snd_pcm_hardware_t snd_p16v_playback_hw = {
119 SNDRV_PCM_INFO_BLOCK_TRANSFER | 127 SNDRV_PCM_INFO_BLOCK_TRANSFER |
120 SNDRV_PCM_INFO_MMAP_VALID), 128 SNDRV_PCM_INFO_MMAP_VALID),
121 .formats = SNDRV_PCM_FMTBIT_S32_LE, /* Only supports 24-bit samples padded to 32 bits. */ 129 .formats = SNDRV_PCM_FMTBIT_S32_LE, /* Only supports 24-bit samples padded to 32 bits. */
122 .rates = SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_48000 , 130 .rates = SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100,
123 .rate_min = 48000, 131 .rate_min = 44100,
124 .rate_max = 192000, 132 .rate_max = 192000,
125 .channels_min = 8, 133 .channels_min = 8,
126 .channels_max = 8, 134 .channels_max = 8,
127 .buffer_bytes_max = (32*1024), 135 .buffer_bytes_max = ((65536 - 64) * 8),
128 .period_bytes_min = 64, 136 .period_bytes_min = 64,
129 .period_bytes_max = (16*1024), 137 .period_bytes_max = (65536 - 64),
130 .periods_min = 2, 138 .periods_min = 2,
131 .periods_max = 8, 139 .periods_max = 8,
132 .fifo_size = 0, 140 .fifo_size = 0,
133}; 141};
134 142
143static snd_pcm_hardware_t snd_p16v_capture_hw = {
144 .info = (SNDRV_PCM_INFO_MMAP |
145 SNDRV_PCM_INFO_INTERLEAVED |
146 SNDRV_PCM_INFO_BLOCK_TRANSFER |
147 SNDRV_PCM_INFO_MMAP_VALID),
148 .formats = SNDRV_PCM_FMTBIT_S32_LE,
149 .rates = SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100,
150 .rate_min = 44100,
151 .rate_max = 192000,
152 .channels_min = 2,
153 .channels_max = 2,
154 .buffer_bytes_max = (65536 - 64),
155 .period_bytes_min = 64,
156 .period_bytes_max = (65536 - 128) >> 1, /* size has to be N*64 bytes */
157 .periods_min = 2,
158 .periods_max = 2,
159 .fifo_size = 0,
160};
161
135static void snd_p16v_pcm_free_substream(snd_pcm_runtime_t *runtime) 162static void snd_p16v_pcm_free_substream(snd_pcm_runtime_t *runtime)
136{ 163{
137 snd_pcm_t *epcm = runtime->private_data; 164 emu10k1_pcm_t *epcm = runtime->private_data;
138 165
139 if (epcm) { 166 if (epcm) {
140 //snd_printk("epcm free: %p\n", epcm); 167 //snd_printk("epcm free: %p\n", epcm);
@@ -178,15 +205,63 @@ static int snd_p16v_pcm_open_playback_channel(snd_pcm_substream_t *substream, in
178 205
179 return 0; 206 return 0;
180} 207}
208/* open_capture callback */
209static int snd_p16v_pcm_open_capture_channel(snd_pcm_substream_t *substream, int channel_id)
210{
211 emu10k1_t *emu = snd_pcm_substream_chip(substream);
212 emu10k1_voice_t *channel = &(emu->p16v_capture_voice);
213 emu10k1_pcm_t *epcm;
214 snd_pcm_runtime_t *runtime = substream->runtime;
215 int err;
216
217 epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL);
218 //snd_printk("epcm kcalloc: %p\n", epcm);
219
220 if (epcm == NULL)
221 return -ENOMEM;
222 epcm->emu = emu;
223 epcm->substream = substream;
224 //snd_printk("epcm device=%d, channel_id=%d\n", substream->pcm->device, channel_id);
225
226 runtime->private_data = epcm;
227 runtime->private_free = snd_p16v_pcm_free_substream;
228
229 runtime->hw = snd_p16v_capture_hw;
230
231 channel->emu = emu;
232 channel->number = channel_id;
233
234 channel->use=1;
235 //snd_printk("p16v: open channel_id=%d, channel=%p, use=0x%x\n", channel_id, channel, channel->use);
236 //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel);
237 //channel->interrupt = snd_p16v_pcm_channel_interrupt;
238 channel->epcm=epcm;
239 if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
240 return err;
241
242 return 0;
243}
244
181 245
182/* close callback */ 246/* close callback */
183static int snd_p16v_pcm_close_playback(snd_pcm_substream_t *substream) 247static int snd_p16v_pcm_close_playback(snd_pcm_substream_t *substream)
184{ 248{
185 emu10k1_t *emu = snd_pcm_substream_chip(substream); 249 emu10k1_t *emu = snd_pcm_substream_chip(substream);
186 //snd_pcm_runtime_t *runtime = substream->runtime; 250 //snd_pcm_runtime_t *runtime = substream->runtime;
187 //emu10k1_pcm_t *epcm = runtime->private_data; 251 //emu10k1_pcm_t *epcm = runtime->private_data;
188 emu->p16v_voices[substream->pcm->device - emu->p16v_device_offset].use=0; 252 emu->p16v_voices[substream->pcm->device - emu->p16v_device_offset].use=0;
189/* FIXME: maybe zero others */ 253 /* FIXME: maybe zero others */
254 return 0;
255}
256
257/* close callback */
258static int snd_p16v_pcm_close_capture(snd_pcm_substream_t *substream)
259{
260 emu10k1_t *emu = snd_pcm_substream_chip(substream);
261 //snd_pcm_runtime_t *runtime = substream->runtime;
262 //emu10k1_pcm_t *epcm = runtime->private_data;
263 emu->p16v_capture_voice.use=0;
264 /* FIXME: maybe zero others */
190 return 0; 265 return 0;
191} 266}
192 267
@@ -195,36 +270,55 @@ static int snd_p16v_pcm_open_playback_front(snd_pcm_substream_t *substream)
195 return snd_p16v_pcm_open_playback_channel(substream, PCM_FRONT_CHANNEL); 270 return snd_p16v_pcm_open_playback_channel(substream, PCM_FRONT_CHANNEL);
196} 271}
197 272
273static int snd_p16v_pcm_open_capture(snd_pcm_substream_t *substream)
274{
275 // Only using channel 0 for now, but the card has 2 channels.
276 return snd_p16v_pcm_open_capture_channel(substream, 0);
277}
278
198/* hw_params callback */ 279/* hw_params callback */
199static int snd_p16v_pcm_hw_params_playback(snd_pcm_substream_t *substream, 280static int snd_p16v_pcm_hw_params_playback(snd_pcm_substream_t *substream,
200 snd_pcm_hw_params_t * hw_params) 281 snd_pcm_hw_params_t * hw_params)
201{ 282{
202 int result; 283 int result;
203 //snd_printk("hw_params alloc: substream=%p\n", substream);
204 result = snd_pcm_lib_malloc_pages(substream, 284 result = snd_pcm_lib_malloc_pages(substream,
205 params_buffer_bytes(hw_params)); 285 params_buffer_bytes(hw_params));
206 //snd_printk("hw_params alloc: result=%d\n", result);
207 //dump_stack();
208 return result; 286 return result;
209} 287}
210 288
289/* hw_params callback */
290static int snd_p16v_pcm_hw_params_capture(snd_pcm_substream_t *substream,
291 snd_pcm_hw_params_t * hw_params)
292{
293 int result;
294 result = snd_pcm_lib_malloc_pages(substream,
295 params_buffer_bytes(hw_params));
296 return result;
297}
298
299
211/* hw_free callback */ 300/* hw_free callback */
212static int snd_p16v_pcm_hw_free_playback(snd_pcm_substream_t *substream) 301static int snd_p16v_pcm_hw_free_playback(snd_pcm_substream_t *substream)
213{ 302{
214 int result; 303 int result;
215 //snd_printk("hw_params free: substream=%p\n", substream);
216 result = snd_pcm_lib_free_pages(substream); 304 result = snd_pcm_lib_free_pages(substream);
217 //snd_printk("hw_params free: result=%d\n", result);
218 //dump_stack();
219 return result; 305 return result;
220} 306}
221 307
308/* hw_free callback */
309static int snd_p16v_pcm_hw_free_capture(snd_pcm_substream_t *substream)
310{
311 int result;
312 result = snd_pcm_lib_free_pages(substream);
313 return result;
314}
315
316
222/* prepare playback callback */ 317/* prepare playback callback */
223static int snd_p16v_pcm_prepare_playback(snd_pcm_substream_t *substream) 318static int snd_p16v_pcm_prepare_playback(snd_pcm_substream_t *substream)
224{ 319{
225 emu10k1_t *emu = snd_pcm_substream_chip(substream); 320 emu10k1_t *emu = snd_pcm_substream_chip(substream);
226 snd_pcm_runtime_t *runtime = substream->runtime; 321 snd_pcm_runtime_t *runtime = substream->runtime;
227 //emu10k1_pcm_t *epcm = runtime->private_data;
228 int channel = substream->pcm->device - emu->p16v_device_offset; 322 int channel = substream->pcm->device - emu->p16v_device_offset;
229 u32 *table_base = (u32 *)(emu->p16v_buffer.area+(8*16*channel)); 323 u32 *table_base = (u32 *)(emu->p16v_buffer.area+(8*16*channel));
230 u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size); 324 u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size);
@@ -237,23 +331,21 @@ static int snd_p16v_pcm_prepare_playback(snd_pcm_substream_t *substream)
237 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, channel); 331 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, channel);
238 switch (runtime->rate) { 332 switch (runtime->rate) {
239 case 44100: 333 case 44100:
240 snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0xe000) | 0x8000); /* FIXME: This will change the capture rate as well! */ 334 snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0xe0e0) | 0x8080);
241 break;
242 case 48000:
243 snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0xe000) | 0x0000); /* FIXME: This will change the capture rate as well! */
244 break; 335 break;
245 case 96000: 336 case 96000:
246 snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0xe000) | 0x4000); /* FIXME: This will change the capture rate as well! */ 337 snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0xe0e0) | 0x4040);
247 break; 338 break;
248 case 192000: 339 case 192000:
249 snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0xe000) | 0x2000); /* FIXME: This will change the capture rate as well! */ 340 snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0xe0e0) | 0x2020);
250 break; 341 break;
342 case 48000:
251 default: 343 default:
252 snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, 0x0000); /* FIXME: This will change the capture rate as well! */ 344 snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0xe0e0) | 0x0000);
253 break; 345 break;
254 } 346 }
255 /* FIXME: Check emu->buffer.size before actually writing to it. */ 347 /* FIXME: Check emu->buffer.size before actually writing to it. */
256 for(i=0; i < runtime->periods; i++) { 348 for(i=0; i < runtime->periods; i++) {
257 table_base[i*2]=runtime->dma_addr+(i*period_size_bytes); 349 table_base[i*2]=runtime->dma_addr+(i*period_size_bytes);
258 table_base[(i*2)+1]=period_size_bytes<<16; 350 table_base[(i*2)+1]=period_size_bytes<<16;
259 } 351 }
@@ -262,7 +354,8 @@ static int snd_p16v_pcm_prepare_playback(snd_pcm_substream_t *substream)
262 snd_emu10k1_ptr20_write(emu, PLAYBACK_LIST_SIZE, channel, (runtime->periods - 1) << 19); 354 snd_emu10k1_ptr20_write(emu, PLAYBACK_LIST_SIZE, channel, (runtime->periods - 1) << 19);
263 snd_emu10k1_ptr20_write(emu, PLAYBACK_LIST_PTR, channel, 0); 355 snd_emu10k1_ptr20_write(emu, PLAYBACK_LIST_PTR, channel, 0);
264 snd_emu10k1_ptr20_write(emu, PLAYBACK_DMA_ADDR, channel, runtime->dma_addr); 356 snd_emu10k1_ptr20_write(emu, PLAYBACK_DMA_ADDR, channel, runtime->dma_addr);
265 snd_emu10k1_ptr20_write(emu, PLAYBACK_PERIOD_SIZE, channel, frames_to_bytes(runtime, runtime->period_size)<<16); // buffer size in bytes 357 //snd_emu10k1_ptr20_write(emu, PLAYBACK_PERIOD_SIZE, channel, frames_to_bytes(runtime, runtime->period_size)<<16); // buffer size in bytes
358 snd_emu10k1_ptr20_write(emu, PLAYBACK_PERIOD_SIZE, channel, 0); // buffer size in bytes
266 snd_emu10k1_ptr20_write(emu, PLAYBACK_POINTER, channel, 0); 359 snd_emu10k1_ptr20_write(emu, PLAYBACK_POINTER, channel, 0);
267 snd_emu10k1_ptr20_write(emu, 0x07, channel, 0x0); 360 snd_emu10k1_ptr20_write(emu, 0x07, channel, 0x0);
268 snd_emu10k1_ptr20_write(emu, 0x08, channel, 0); 361 snd_emu10k1_ptr20_write(emu, 0x08, channel, 0);
@@ -270,6 +363,41 @@ static int snd_p16v_pcm_prepare_playback(snd_pcm_substream_t *substream)
270 return 0; 363 return 0;
271} 364}
272 365
366/* prepare capture callback */
367static int snd_p16v_pcm_prepare_capture(snd_pcm_substream_t *substream)
368{
369 emu10k1_t *emu = snd_pcm_substream_chip(substream);
370 snd_pcm_runtime_t *runtime = substream->runtime;
371 int channel = substream->pcm->device - emu->p16v_device_offset;
372 u32 tmp;
373 //printk("prepare capture:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, frames_to_bytes(runtime, 1));
374 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, channel);
375 switch (runtime->rate) {
376 case 44100:
377 snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0x0e00) | 0x0800);
378 break;
379 case 96000:
380 snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0x0e00) | 0x0400);
381 break;
382 case 192000:
383 snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0x0e00) | 0x0200);
384 break;
385 case 48000:
386 default:
387 snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, channel, (tmp & ~0x0e00) | 0x0000);
388 break;
389 }
390 /* FIXME: Check emu->buffer.size before actually writing to it. */
391 snd_emu10k1_ptr20_write(emu, 0x13, channel, 0);
392 snd_emu10k1_ptr20_write(emu, CAPTURE_DMA_ADDR, channel, runtime->dma_addr);
393 snd_emu10k1_ptr20_write(emu, CAPTURE_BUFFER_SIZE, channel, frames_to_bytes(runtime, runtime->buffer_size)<<16); // buffer size in bytes
394 snd_emu10k1_ptr20_write(emu, CAPTURE_POINTER, channel, 0);
395 //snd_emu10k1_ptr20_write(emu, CAPTURE_SOURCE, 0x0, 0x333300e4); /* Select MIC or Line in */
396 //snd_emu10k1_ptr20_write(emu, EXTENDED_INT_MASK, 0, snd_emu10k1_ptr20_read(emu, EXTENDED_INT_MASK, 0) | (0x110000<<channel));
397
398 return 0;
399}
400
273static void snd_p16v_intr_enable(emu10k1_t *emu, unsigned int intrenb) 401static void snd_p16v_intr_enable(emu10k1_t *emu, unsigned int intrenb)
274{ 402{
275 unsigned long flags; 403 unsigned long flags;
@@ -345,6 +473,36 @@ static int snd_p16v_pcm_trigger_playback(snd_pcm_substream_t *substream,
345 return result; 473 return result;
346} 474}
347 475
476/* trigger_capture callback */
477static int snd_p16v_pcm_trigger_capture(snd_pcm_substream_t *substream,
478 int cmd)
479{
480 emu10k1_t *emu = snd_pcm_substream_chip(substream);
481 snd_pcm_runtime_t *runtime = substream->runtime;
482 emu10k1_pcm_t *epcm = runtime->private_data;
483 int channel = 0;
484 int result = 0;
485 u32 inte = INTE2_CAPTURE_CH_0_LOOP | INTE2_CAPTURE_CH_0_HALF_LOOP;
486
487 switch (cmd) {
488 case SNDRV_PCM_TRIGGER_START:
489 snd_p16v_intr_enable(emu, inte);
490 snd_emu10k1_ptr20_write(emu, BASIC_INTERRUPT, 0, snd_emu10k1_ptr20_read(emu, BASIC_INTERRUPT, 0)|(0x100<<channel));
491 epcm->running = 1;
492 break;
493 case SNDRV_PCM_TRIGGER_STOP:
494 snd_emu10k1_ptr20_write(emu, BASIC_INTERRUPT, 0, snd_emu10k1_ptr20_read(emu, BASIC_INTERRUPT, 0) & ~(0x100<<channel));
495 snd_p16v_intr_disable(emu, inte);
496 //snd_emu10k1_ptr20_write(emu, EXTENDED_INT_MASK, 0, snd_emu10k1_ptr20_read(emu, EXTENDED_INT_MASK, 0) & ~(0x110000<<channel));
497 epcm->running = 0;
498 break;
499 default:
500 result = -EINVAL;
501 break;
502 }
503 return result;
504}
505
348/* pointer_playback callback */ 506/* pointer_playback callback */
349static snd_pcm_uframes_t 507static snd_pcm_uframes_t
350snd_p16v_pcm_pointer_playback(snd_pcm_substream_t *substream) 508snd_p16v_pcm_pointer_playback(snd_pcm_substream_t *substream)
@@ -370,6 +528,31 @@ snd_p16v_pcm_pointer_playback(snd_pcm_substream_t *substream)
370 return ptr; 528 return ptr;
371} 529}
372 530
531/* pointer_capture callback */
532static snd_pcm_uframes_t
533snd_p16v_pcm_pointer_capture(snd_pcm_substream_t *substream)
534{
535 emu10k1_t *emu = snd_pcm_substream_chip(substream);
536 snd_pcm_runtime_t *runtime = substream->runtime;
537 emu10k1_pcm_t *epcm = runtime->private_data;
538 snd_pcm_uframes_t ptr, ptr1, ptr2 = 0;
539 int channel = 0;
540
541 if (!epcm->running)
542 return 0;
543
544 ptr1 = snd_emu10k1_ptr20_read(emu, CAPTURE_POINTER, channel);
545 ptr2 = bytes_to_frames(runtime, ptr1);
546 ptr=ptr2;
547 if (ptr >= runtime->buffer_size) {
548 ptr -= runtime->buffer_size;
549 printk("buffer capture limited!\n");
550 }
551 //printk("ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n", ptr1, ptr2, ptr, (int)runtime->buffer_size, (int)runtime->period_size, (int)runtime->frame_bits, (int)runtime->rate);
552
553 return ptr;
554}
555
373/* operators */ 556/* operators */
374static snd_pcm_ops_t snd_p16v_playback_front_ops = { 557static snd_pcm_ops_t snd_p16v_playback_front_ops = {
375 .open = snd_p16v_pcm_open_playback_front, 558 .open = snd_p16v_pcm_open_playback_front,
@@ -382,6 +565,18 @@ static snd_pcm_ops_t snd_p16v_playback_front_ops = {
382 .pointer = snd_p16v_pcm_pointer_playback, 565 .pointer = snd_p16v_pcm_pointer_playback,
383}; 566};
384 567
568static snd_pcm_ops_t snd_p16v_capture_ops = {
569 .open = snd_p16v_pcm_open_capture,
570 .close = snd_p16v_pcm_close_capture,
571 .ioctl = snd_pcm_lib_ioctl,
572 .hw_params = snd_p16v_pcm_hw_params_capture,
573 .hw_free = snd_p16v_pcm_hw_free_capture,
574 .prepare = snd_p16v_pcm_prepare_capture,
575 .trigger = snd_p16v_pcm_trigger_capture,
576 .pointer = snd_p16v_pcm_pointer_capture,
577};
578
579
385int snd_p16v_free(emu10k1_t *chip) 580int snd_p16v_free(emu10k1_t *chip)
386{ 581{
387 // release the data 582 // release the data
@@ -405,20 +600,22 @@ int snd_p16v_pcm(emu10k1_t *emu, int device, snd_pcm_t **rpcm)
405 snd_pcm_t *pcm; 600 snd_pcm_t *pcm;
406 snd_pcm_substream_t *substream; 601 snd_pcm_substream_t *substream;
407 int err; 602 int err;
408 int capture=0; 603 int capture=1;
409 604
410 //snd_printk("snd_p16v_pcm called. device=%d\n", device); 605 //snd_printk("snd_p16v_pcm called. device=%d\n", device);
411 emu->p16v_device_offset = device; 606 emu->p16v_device_offset = device;
412 if (rpcm) 607 if (rpcm)
413 *rpcm = NULL; 608 *rpcm = NULL;
414 //if (device == 0) capture=1; 609
415 if ((err = snd_pcm_new(emu->card, "p16v", device, 1, capture, &pcm)) < 0) 610 if ((err = snd_pcm_new(emu->card, "p16v", device, 1, capture, &pcm)) < 0)
416 return err; 611 return err;
417 612
418 pcm->private_data = emu; 613 pcm->private_data = emu;
419 pcm->private_free = snd_p16v_pcm_free; 614 pcm->private_free = snd_p16v_pcm_free;
420 615 // Single playback 8 channel device.
616 // Single capture 2 channel device.
421 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_p16v_playback_front_ops); 617 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_p16v_playback_front_ops);
618 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_p16v_capture_ops);
422 619
423 pcm->info_flags = 0; 620 pcm->info_flags = 0;
424 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; 621 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX;
@@ -431,7 +628,7 @@ int snd_p16v_pcm(emu10k1_t *emu, int device, snd_pcm_t **rpcm)
431 if ((err = snd_pcm_lib_preallocate_pages(substream, 628 if ((err = snd_pcm_lib_preallocate_pages(substream,
432 SNDRV_DMA_TYPE_DEV, 629 SNDRV_DMA_TYPE_DEV,
433 snd_dma_pci_data(emu->pci), 630 snd_dma_pci_data(emu->pci),
434 64*1024, 64*1024)) < 0) /* FIXME: 32*1024 for sound buffer, between 32and64 for Periods table. */ 631 ((65536 - 64) * 8), ((65536 - 64) * 8))) < 0)
435 return err; 632 return err;
436 //snd_printk("preallocate playback substream: err=%d\n", err); 633 //snd_printk("preallocate playback substream: err=%d\n", err);
437 } 634 }
@@ -442,7 +639,7 @@ int snd_p16v_pcm(emu10k1_t *emu, int device, snd_pcm_t **rpcm)
442 if ((err = snd_pcm_lib_preallocate_pages(substream, 639 if ((err = snd_pcm_lib_preallocate_pages(substream,
443 SNDRV_DMA_TYPE_DEV, 640 SNDRV_DMA_TYPE_DEV,
444 snd_dma_pci_data(emu->pci), 641 snd_dma_pci_data(emu->pci),
445 64*1024, 64*1024)) < 0) 642 65536 - 64, 65536 - 64)) < 0)
446 return err; 643 return err;
447 //snd_printk("preallocate capture substream: err=%d\n", err); 644 //snd_printk("preallocate capture substream: err=%d\n", err);
448 } 645 }
@@ -694,6 +891,106 @@ static snd_kcontrol_new_t snd_p16v_volume_control_spdif_rear =
694 .put = snd_p16v_volume_put_spdif_rear 891 .put = snd_p16v_volume_put_spdif_rear
695}; 892};
696 893
894static int snd_p16v_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
895{
896 static char *texts[8] = { "SPDIF", "I2S", "SRC48", "SRCMulti_SPDIF", "SRCMulti_I2S", "CDIF", "FX", "AC97" };
897
898 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
899 uinfo->count = 1;
900 uinfo->value.enumerated.items = 8;
901 if (uinfo->value.enumerated.item > 7)
902 uinfo->value.enumerated.item = 7;
903 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
904 return 0;
905}
906
907static int snd_p16v_capture_source_get(snd_kcontrol_t * kcontrol,
908 snd_ctl_elem_value_t * ucontrol)
909{
910 emu10k1_t *emu = snd_kcontrol_chip(kcontrol);
911
912 ucontrol->value.enumerated.item[0] = emu->p16v_capture_source;
913 return 0;
914}
915
916static int snd_p16v_capture_source_put(snd_kcontrol_t * kcontrol,
917 snd_ctl_elem_value_t * ucontrol)
918{
919 emu10k1_t *emu = snd_kcontrol_chip(kcontrol);
920 unsigned int val;
921 int change = 0;
922 u32 mask;
923 u32 source;
924
925 val = ucontrol->value.enumerated.item[0] ;
926 change = (emu->p16v_capture_source != val);
927 if (change) {
928 emu->p16v_capture_source = val;
929 source = (val << 28) | (val << 24) | (val << 20) | (val << 16);
930 mask = snd_emu10k1_ptr20_read(emu, BASIC_INTERRUPT, 0) & 0xffff;
931 snd_emu10k1_ptr20_write(emu, BASIC_INTERRUPT, 0, source | mask);
932 }
933 return change;
934}
935
936static snd_kcontrol_new_t snd_p16v_capture_source __devinitdata =
937{
938 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
939 .name = "HD Capture source",
940 .info = snd_p16v_capture_source_info,
941 .get = snd_p16v_capture_source_get,
942 .put = snd_p16v_capture_source_put
943};
944
945static int snd_p16v_capture_channel_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
946{
947 static char *texts[4] = { "0", "1", "2", "3", };
948
949 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
950 uinfo->count = 1;
951 uinfo->value.enumerated.items = 4;
952 if (uinfo->value.enumerated.item > 3)
953 uinfo->value.enumerated.item = 3;
954 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
955 return 0;
956}
957
958static int snd_p16v_capture_channel_get(snd_kcontrol_t * kcontrol,
959 snd_ctl_elem_value_t * ucontrol)
960{
961 emu10k1_t *emu = snd_kcontrol_chip(kcontrol);
962
963 ucontrol->value.enumerated.item[0] = emu->p16v_capture_channel;
964 return 0;
965}
966
967static int snd_p16v_capture_channel_put(snd_kcontrol_t * kcontrol,
968 snd_ctl_elem_value_t * ucontrol)
969{
970 emu10k1_t *emu = snd_kcontrol_chip(kcontrol);
971 unsigned int val;
972 int change = 0;
973 u32 tmp;
974
975 val = ucontrol->value.enumerated.item[0] ;
976 change = (emu->p16v_capture_channel != val);
977 if (change) {
978 emu->p16v_capture_channel = val;
979 tmp = snd_emu10k1_ptr20_read(emu, CAPTURE_P16V_SOURCE, 0) & 0xfffc;
980 snd_emu10k1_ptr20_write(emu, CAPTURE_P16V_SOURCE, 0, tmp | val);
981 }
982 return change;
983}
984
985static snd_kcontrol_new_t snd_p16v_capture_channel __devinitdata =
986{
987 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
988 .name = "HD Capture channel",
989 .info = snd_p16v_capture_channel_info,
990 .get = snd_p16v_capture_channel_get,
991 .put = snd_p16v_capture_channel_put
992};
993
697int snd_p16v_mixer(emu10k1_t *emu) 994int snd_p16v_mixer(emu10k1_t *emu)
698{ 995{
699 int err; 996 int err;
@@ -731,6 +1028,14 @@ int snd_p16v_mixer(emu10k1_t *emu)
731 return -ENOMEM; 1028 return -ENOMEM;
732 if ((err = snd_ctl_add(card, kctl))) 1029 if ((err = snd_ctl_add(card, kctl)))
733 return err; 1030 return err;
1031 if ((kctl = snd_ctl_new1(&snd_p16v_capture_source, emu)) == NULL)
1032 return -ENOMEM;
1033 if ((err = snd_ctl_add(card, kctl)))
1034 return err;
1035 if ((kctl = snd_ctl_new1(&snd_p16v_capture_channel, emu)) == NULL)
1036 return -ENOMEM;
1037 if ((err = snd_ctl_add(card, kctl)))
1038 return err;
734 return 0; 1039 return 0;
735} 1040}
736 1041
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index f910399db5c3..4e63498a58b2 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -2401,7 +2401,7 @@ static struct pci_driver driver = {
2401 2401
2402static int __init alsa_card_ens137x_init(void) 2402static int __init alsa_card_ens137x_init(void)
2403{ 2403{
2404 return pci_module_init(&driver); 2404 return pci_register_driver(&driver);
2405} 2405}
2406 2406
2407static void __exit alsa_card_ens137x_exit(void) 2407static void __exit alsa_card_ens137x_exit(void)
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index b4ca8adf393c..b492777bc30f 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -1761,7 +1761,7 @@ static struct pci_driver driver = {
1761 1761
1762static int __init alsa_card_es1938_init(void) 1762static int __init alsa_card_es1938_init(void)
1763{ 1763{
1764 return pci_module_init(&driver); 1764 return pci_register_driver(&driver);
1765} 1765}
1766 1766
1767static void __exit alsa_card_es1938_exit(void) 1767static void __exit alsa_card_es1938_exit(void)
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index faf63ff19c42..ea889b311390 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -2559,6 +2559,7 @@ static struct ess_device_list pm_whitelist[] __devinitdata = {
2559 { TYPE_MAESTRO2E, 0x103c }, 2559 { TYPE_MAESTRO2E, 0x103c },
2560 { TYPE_MAESTRO2E, 0x1179 }, 2560 { TYPE_MAESTRO2E, 0x1179 },
2561 { TYPE_MAESTRO2E, 0x14c0 }, /* HP omnibook 4150 */ 2561 { TYPE_MAESTRO2E, 0x14c0 }, /* HP omnibook 4150 */
2562 { TYPE_MAESTRO2E, 0x1558 },
2562}; 2563};
2563 2564
2564static struct ess_device_list mpu_blacklist[] __devinitdata = { 2565static struct ess_device_list mpu_blacklist[] __devinitdata = {
@@ -2795,7 +2796,7 @@ static struct pci_driver driver = {
2795 2796
2796static int __init alsa_card_es1968_init(void) 2797static int __init alsa_card_es1968_init(void)
2797{ 2798{
2798 return pci_module_init(&driver); 2799 return pci_register_driver(&driver);
2799} 2800}
2800 2801
2801static void __exit alsa_card_es1968_exit(void) 2802static void __exit alsa_card_es1968_exit(void)
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index 08e7c5a296d5..ff10e637a95e 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -195,6 +195,7 @@ struct _snd_fm801 {
195 195
196static struct pci_device_id snd_fm801_ids[] = { 196static struct pci_device_id snd_fm801_ids[] = {
197 { 0x1319, 0x0801, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0, }, /* FM801 */ 197 { 0x1319, 0x0801, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0, }, /* FM801 */
198 { 0x5213, 0x0510, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_AUDIO << 8, 0xffff00, 0, }, /* Gallant Odyssey Sound 4 */
198 { 0, } 199 { 0, }
199}; 200};
200 201
@@ -1468,7 +1469,7 @@ static struct pci_driver driver = {
1468 1469
1469static int __init alsa_card_fm801_init(void) 1470static int __init alsa_card_fm801_init(void)
1470{ 1471{
1471 return pci_module_init(&driver); 1472 return pci_register_driver(&driver);
1472} 1473}
1473 1474
1474static void __exit alsa_card_fm801_exit(void) 1475static void __exit alsa_card_fm801_exit(void)
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
index 570a59d33b41..bd8cb33c4fb4 100644
--- a/sound/pci/hda/Makefile
+++ b/sound/pci/hda/Makefile
@@ -1,5 +1,5 @@
1snd-hda-intel-objs := hda_intel.o 1snd-hda-intel-objs := hda_intel.o
2snd-hda-codec-objs := hda_codec.o hda_generic.o patch_realtek.o patch_cmedia.o patch_analog.o 2snd-hda-codec-objs := hda_codec.o hda_generic.o patch_realtek.o patch_cmedia.o patch_analog.o patch_sigmatel.o
3ifdef CONFIG_PROC_FS 3ifdef CONFIG_PROC_FS
4snd-hda-codec-objs += hda_proc.o 4snd-hda-codec-objs += hda_proc.o
5endif 5endif
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 9ed117ac0c09..e2cf02387289 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -49,8 +49,10 @@ struct hda_vendor_id {
49/* codec vendor labels */ 49/* codec vendor labels */
50static struct hda_vendor_id hda_vendor_ids[] = { 50static struct hda_vendor_id hda_vendor_ids[] = {
51 { 0x10ec, "Realtek" }, 51 { 0x10ec, "Realtek" },
52 { 0x11d4, "Analog Devices" },
52 { 0x13f6, "C-Media" }, 53 { 0x13f6, "C-Media" },
53 { 0x434d, "C-Media" }, 54 { 0x434d, "C-Media" },
55 { 0x8384, "SigmaTel" },
54 {} /* terminator */ 56 {} /* terminator */
55}; 57};
56 58
@@ -508,7 +510,7 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
508 /* FIXME: support for multiple AFGs? */ 510 /* FIXME: support for multiple AFGs? */
509 codec->afg = look_for_afg_node(codec); 511 codec->afg = look_for_afg_node(codec);
510 if (! codec->afg) { 512 if (! codec->afg) {
511 snd_printk(KERN_ERR "hda_codec: no AFG node found\n"); 513 snd_printdd("hda_codec: no AFG node found\n");
512 snd_hda_codec_free(codec); 514 snd_hda_codec_free(codec);
513 return -ENODEV; 515 return -ENODEV;
514 } 516 }
@@ -548,6 +550,9 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
548void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag, 550void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag,
549 int channel_id, int format) 551 int channel_id, int format)
550{ 552{
553 if (! nid)
554 return;
555
551 snd_printdd("hda_codec_setup_stream: NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n", 556 snd_printdd("hda_codec_setup_stream: NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n",
552 nid, stream_tag, channel_id, format); 557 nid, stream_tag, channel_id, format);
553 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, 558 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID,
@@ -561,9 +566,10 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stre
561 * amp access functions 566 * amp access functions
562 */ 567 */
563 568
564#define HDA_HASH_KEY(nid,dir,idx) (u32)((nid) + (idx) * 32 + (dir) * 64) 569/* FIXME: more better hash key? */
570#define HDA_HASH_KEY(nid,dir,idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24))
565#define INFO_AMP_CAPS (1<<0) 571#define INFO_AMP_CAPS (1<<0)
566#define INFO_AMP_VOL (1<<1) 572#define INFO_AMP_VOL(ch) (1 << (1 + (ch)))
567 573
568/* initialize the hash table */ 574/* initialize the hash table */
569static void init_amp_hash(struct hda_codec *codec) 575static void init_amp_hash(struct hda_codec *codec)
@@ -622,28 +628,29 @@ static u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction)
622 628
623/* 629/*
624 * read the current volume to info 630 * read the current volume to info
625 * if the cache exists, read from the cache. 631 * if the cache exists, read the cache value.
626 */ 632 */
627static void get_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, 633static unsigned int get_vol_mute(struct hda_codec *codec, struct hda_amp_info *info,
628 hda_nid_t nid, int ch, int direction, int index) 634 hda_nid_t nid, int ch, int direction, int index)
629{ 635{
630 u32 val, parm; 636 u32 val, parm;
631 637
632 if (info->status & (INFO_AMP_VOL << ch)) 638 if (info->status & INFO_AMP_VOL(ch))
633 return; 639 return info->vol[ch];
634 640
635 parm = ch ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT; 641 parm = ch ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT;
636 parm |= direction == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT; 642 parm |= direction == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT;
637 parm |= index; 643 parm |= index;
638 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, parm); 644 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, parm);
639 info->vol[ch] = val & 0xff; 645 info->vol[ch] = val & 0xff;
640 info->status |= INFO_AMP_VOL << ch; 646 info->status |= INFO_AMP_VOL(ch);
647 return info->vol[ch];
641} 648}
642 649
643/* 650/*
644 * write the current volume in info to the h/w 651 * write the current volume in info to the h/w and update the cache
645 */ 652 */
646static void put_vol_mute(struct hda_codec *codec, 653static void put_vol_mute(struct hda_codec *codec, struct hda_amp_info *info,
647 hda_nid_t nid, int ch, int direction, int index, int val) 654 hda_nid_t nid, int ch, int direction, int index, int val)
648{ 655{
649 u32 parm; 656 u32 parm;
@@ -653,30 +660,34 @@ static void put_vol_mute(struct hda_codec *codec,
653 parm |= index << AC_AMP_SET_INDEX_SHIFT; 660 parm |= index << AC_AMP_SET_INDEX_SHIFT;
654 parm |= val; 661 parm |= val;
655 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, parm); 662 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, parm);
663 info->vol[ch] = val;
656} 664}
657 665
658/* 666/*
659 * read/write AMP value. The volume is between 0 to 0x7f, 0x80 = mute bit. 667 * read AMP value. The volume is between 0 to 0x7f, 0x80 = mute bit.
660 */ 668 */
661int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, int direction, int index) 669static int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, int direction, int index)
662{ 670{
663 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, index)); 671 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, index));
664 if (! info) 672 if (! info)
665 return 0; 673 return 0;
666 get_vol_mute(codec, info, nid, ch, direction, index); 674 return get_vol_mute(codec, info, nid, ch, direction, index);
667 return info->vol[ch];
668} 675}
669 676
670int snd_hda_codec_amp_write(struct hda_codec *codec, hda_nid_t nid, int ch, int direction, int idx, int val) 677/*
678 * update the AMP value, mask = bit mask to set, val = the value
679 */
680static int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch, int direction, int idx, int mask, int val)
671{ 681{
672 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx)); 682 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx));
683
673 if (! info) 684 if (! info)
674 return 0; 685 return 0;
675 get_vol_mute(codec, info, nid, ch, direction, idx); 686 val &= mask;
687 val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask;
676 if (info->vol[ch] == val && ! codec->in_resume) 688 if (info->vol[ch] == val && ! codec->in_resume)
677 return 0; 689 return 0;
678 put_vol_mute(codec, nid, ch, direction, idx, val); 690 put_vol_mute(codec, info, nid, ch, direction, idx, val);
679 info->vol[ch] = val;
680 return 1; 691 return 1;
681} 692}
682 693
@@ -735,21 +746,15 @@ int snd_hda_mixer_amp_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t
735 int chs = get_amp_channels(kcontrol); 746 int chs = get_amp_channels(kcontrol);
736 int dir = get_amp_direction(kcontrol); 747 int dir = get_amp_direction(kcontrol);
737 int idx = get_amp_index(kcontrol); 748 int idx = get_amp_index(kcontrol);
738 int val;
739 long *valp = ucontrol->value.integer.value; 749 long *valp = ucontrol->value.integer.value;
740 int change = 0; 750 int change = 0;
741 751
742 if (chs & 1) { 752 if (chs & 1)
743 val = *valp & 0x7f; 753 change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx,
744 val |= snd_hda_codec_amp_read(codec, nid, 0, dir, idx) & 0x80; 754 0x7f, *valp);
745 change = snd_hda_codec_amp_write(codec, nid, 0, dir, idx, val); 755 if (chs & 2)
746 valp++; 756 change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx,
747 } 757 0x7f, valp[1]);
748 if (chs & 2) {
749 val = *valp & 0x7f;
750 val |= snd_hda_codec_amp_read(codec, nid, 1, dir, idx) & 0x80;
751 change |= snd_hda_codec_amp_write(codec, nid, 1, dir, idx, val);
752 }
753 return change; 758 return change;
754} 759}
755 760
@@ -788,21 +793,15 @@ int snd_hda_mixer_amp_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t
788 int chs = get_amp_channels(kcontrol); 793 int chs = get_amp_channels(kcontrol);
789 int dir = get_amp_direction(kcontrol); 794 int dir = get_amp_direction(kcontrol);
790 int idx = get_amp_index(kcontrol); 795 int idx = get_amp_index(kcontrol);
791 int val;
792 long *valp = ucontrol->value.integer.value; 796 long *valp = ucontrol->value.integer.value;
793 int change = 0; 797 int change = 0;
794 798
795 if (chs & 1) { 799 if (chs & 1)
796 val = snd_hda_codec_amp_read(codec, nid, 0, dir, idx) & 0x7f; 800 change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx,
797 val |= *valp ? 0 : 0x80; 801 0x80, *valp ? 0 : 0x80);
798 change = snd_hda_codec_amp_write(codec, nid, 0, dir, idx, val); 802 if (chs & 2)
799 valp++; 803 change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx,
800 } 804 0x80, valp[1] ? 0 : 0x80);
801 if (chs & 2) {
802 val = snd_hda_codec_amp_read(codec, nid, 1, dir, idx) & 0x7f;
803 val |= *valp ? 0 : 0x80;
804 change = snd_hda_codec_amp_write(codec, nid, 1, dir, idx, val);
805 }
806 return change; 805 return change;
807} 806}
808 807
@@ -1448,10 +1447,6 @@ static int set_pcm_default_values(struct hda_codec *codec, struct hda_pcm_stream
1448 snd_assert(info->nid, return -EINVAL); 1447 snd_assert(info->nid, return -EINVAL);
1449 info->ops.prepare = hda_pcm_default_prepare; 1448 info->ops.prepare = hda_pcm_default_prepare;
1450 } 1449 }
1451 if (info->ops.prepare == NULL) {
1452 snd_assert(info->nid, return -EINVAL);
1453 info->ops.prepare = hda_pcm_default_prepare;
1454 }
1455 if (info->ops.cleanup == NULL) { 1450 if (info->ops.cleanup == NULL) {
1456 snd_assert(info->nid, return -EINVAL); 1451 snd_assert(info->nid, return -EINVAL);
1457 info->ops.cleanup = hda_pcm_default_cleanup; 1452 info->ops.cleanup = hda_pcm_default_cleanup;
@@ -1525,12 +1520,12 @@ int snd_hda_build_pcms(struct hda_bus *bus)
1525 * 1520 *
1526 * If no entries are matching, the function returns a negative value. 1521 * If no entries are matching, the function returns a negative value.
1527 */ 1522 */
1528int snd_hda_check_board_config(struct hda_codec *codec, struct hda_board_config *tbl) 1523int snd_hda_check_board_config(struct hda_codec *codec, const struct hda_board_config *tbl)
1529{ 1524{
1530 struct hda_board_config *c; 1525 const struct hda_board_config *c;
1531 1526
1532 if (codec->bus->modelname) { 1527 if (codec->bus->modelname) {
1533 for (c = tbl; c->modelname || c->pci_vendor; c++) { 1528 for (c = tbl; c->modelname || c->pci_subvendor; c++) {
1534 if (c->modelname && 1529 if (c->modelname &&
1535 ! strcmp(codec->bus->modelname, c->modelname)) { 1530 ! strcmp(codec->bus->modelname, c->modelname)) {
1536 snd_printd(KERN_INFO "hda_codec: model '%s' is selected\n", c->modelname); 1531 snd_printd(KERN_INFO "hda_codec: model '%s' is selected\n", c->modelname);
@@ -1543,9 +1538,10 @@ int snd_hda_check_board_config(struct hda_codec *codec, struct hda_board_config
1543 u16 subsystem_vendor, subsystem_device; 1538 u16 subsystem_vendor, subsystem_device;
1544 pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); 1539 pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor);
1545 pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_ID, &subsystem_device); 1540 pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_ID, &subsystem_device);
1546 for (c = tbl; c->modelname || c->pci_vendor; c++) { 1541 for (c = tbl; c->modelname || c->pci_subvendor; c++) {
1547 if (c->pci_vendor == subsystem_vendor && 1542 if (c->pci_subvendor == subsystem_vendor &&
1548 c->pci_device == subsystem_device) 1543 (! c->pci_subdevice /* all match */||
1544 (c->pci_subdevice == subsystem_device)))
1549 return c->config; 1545 return c->config;
1550 } 1546 }
1551 } 1547 }
@@ -1687,11 +1683,12 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_o
1687 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 0, format); 1683 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 0, format);
1688 /* surrounds */ 1684 /* surrounds */
1689 for (i = 1; i < mout->num_dacs; i++) { 1685 for (i = 1; i < mout->num_dacs; i++) {
1690 if (i == HDA_REAR && chs == 2) /* copy front to rear */ 1686 if (chs >= (i + 1) * 2) /* independent out */
1691 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, 0, format);
1692 else if (chs >= (i + 1) * 2) /* independent out */
1693 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, i * 2, 1687 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, i * 2,
1694 format); 1688 format);
1689 else /* copy front */
1690 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, 0,
1691 format);
1695 } 1692 }
1696 return 0; 1693 return 0;
1697} 1694}
@@ -1717,6 +1714,105 @@ int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, struct hda_multi_o
1717 return 0; 1714 return 0;
1718} 1715}
1719 1716
1717/*
1718 * Helper for automatic ping configuration
1719 */
1720/* parse all pin widgets and store the useful pin nids to cfg */
1721int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg)
1722{
1723 hda_nid_t nid, nid_start;
1724 int i, j, nodes;
1725 short seq, sequences[4], assoc_line_out;
1726
1727 memset(cfg, 0, sizeof(*cfg));
1728
1729 memset(sequences, 0, sizeof(sequences));
1730 assoc_line_out = 0;
1731
1732 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid_start);
1733 for (nid = nid_start; nid < nodes + nid_start; nid++) {
1734 unsigned int wid_caps = snd_hda_param_read(codec, nid,
1735 AC_PAR_AUDIO_WIDGET_CAP);
1736 unsigned int wid_type = (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1737 unsigned int def_conf;
1738 short assoc, loc;
1739
1740 /* read all default configuration for pin complex */
1741 if (wid_type != AC_WID_PIN)
1742 continue;
1743 def_conf = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
1744 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
1745 continue;
1746 loc = get_defcfg_location(def_conf);
1747 switch (get_defcfg_device(def_conf)) {
1748 case AC_JACK_LINE_OUT:
1749 case AC_JACK_SPEAKER:
1750 seq = get_defcfg_sequence(def_conf);
1751 assoc = get_defcfg_association(def_conf);
1752 if (! assoc)
1753 continue;
1754 if (! assoc_line_out)
1755 assoc_line_out = assoc;
1756 else if (assoc_line_out != assoc)
1757 continue;
1758 if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins))
1759 continue;
1760 cfg->line_out_pins[cfg->line_outs] = nid;
1761 sequences[cfg->line_outs] = seq;
1762 cfg->line_outs++;
1763 break;
1764 case AC_JACK_HP_OUT:
1765 cfg->hp_pin = nid;
1766 break;
1767 case AC_JACK_MIC_IN:
1768 if (loc == AC_JACK_LOC_FRONT)
1769 cfg->input_pins[AUTO_PIN_FRONT_MIC] = nid;
1770 else
1771 cfg->input_pins[AUTO_PIN_MIC] = nid;
1772 break;
1773 case AC_JACK_LINE_IN:
1774 if (loc == AC_JACK_LOC_FRONT)
1775 cfg->input_pins[AUTO_PIN_FRONT_LINE] = nid;
1776 else
1777 cfg->input_pins[AUTO_PIN_LINE] = nid;
1778 break;
1779 case AC_JACK_CD:
1780 cfg->input_pins[AUTO_PIN_CD] = nid;
1781 break;
1782 case AC_JACK_AUX:
1783 cfg->input_pins[AUTO_PIN_AUX] = nid;
1784 break;
1785 case AC_JACK_SPDIF_OUT:
1786 cfg->dig_out_pin = nid;
1787 break;
1788 case AC_JACK_SPDIF_IN:
1789 cfg->dig_in_pin = nid;
1790 break;
1791 }
1792 }
1793
1794 /* sort by sequence */
1795 for (i = 0; i < cfg->line_outs; i++)
1796 for (j = i + 1; j < cfg->line_outs; j++)
1797 if (sequences[i] > sequences[j]) {
1798 seq = sequences[i];
1799 sequences[i] = sequences[j];
1800 sequences[j] = seq;
1801 nid = cfg->line_out_pins[i];
1802 cfg->line_out_pins[i] = cfg->line_out_pins[j];
1803 cfg->line_out_pins[j] = nid;
1804 }
1805
1806 /* Swap surround and CLFE: the association order is front/CLFE/surr/back */
1807 if (cfg->line_outs >= 3) {
1808 nid = cfg->line_out_pins[1];
1809 cfg->line_out_pins[1] = cfg->line_out_pins[2];
1810 cfg->line_out_pins[2] = nid;
1811 }
1812
1813 return 0;
1814}
1815
1720#ifdef CONFIG_PM 1816#ifdef CONFIG_PM
1721/* 1817/*
1722 * power management 1818 * power management
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index c9e9dc9c7c98..59991560d492 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -75,6 +75,9 @@ enum {
75#define AC_VERB_GET_DIGI_CONVERT 0x0f0d 75#define AC_VERB_GET_DIGI_CONVERT 0x0f0d
76#define AC_VERB_GET_VOLUME_KNOB_CONTROL 0x0f0f 76#define AC_VERB_GET_VOLUME_KNOB_CONTROL 0x0f0f
77/* f10-f1a: GPIO */ 77/* f10-f1a: GPIO */
78#define AC_VERB_GET_GPIO_DATA 0x0f15
79#define AC_VERB_GET_GPIO_MASK 0x0f16
80#define AC_VERB_GET_GPIO_DIRECTION 0x0f17
78#define AC_VERB_GET_CONFIG_DEFAULT 0x0f1c 81#define AC_VERB_GET_CONFIG_DEFAULT 0x0f1c
79 82
80/* 83/*
@@ -97,6 +100,9 @@ enum {
97#define AC_VERB_SET_DIGI_CONVERT_1 0x70d 100#define AC_VERB_SET_DIGI_CONVERT_1 0x70d
98#define AC_VERB_SET_DIGI_CONVERT_2 0x70e 101#define AC_VERB_SET_DIGI_CONVERT_2 0x70e
99#define AC_VERB_SET_VOLUME_KNOB_CONTROL 0x70f 102#define AC_VERB_SET_VOLUME_KNOB_CONTROL 0x70f
103#define AC_VERB_SET_GPIO_DATA 0x715
104#define AC_VERB_SET_GPIO_MASK 0x716
105#define AC_VERB_SET_GPIO_DIRECTION 0x717
100#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 0x71c 106#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 0x71c
101#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_1 0x71d 107#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_1 0x71d
102#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_2 0x71e 108#define AC_VERB_SET_CONFIG_DEFAULT_BYTES_2 0x71e
@@ -176,16 +182,15 @@ enum {
176#define AC_PINCAP_OUT (1<<4) /* output capable */ 182#define AC_PINCAP_OUT (1<<4) /* output capable */
177#define AC_PINCAP_IN (1<<5) /* input capable */ 183#define AC_PINCAP_IN (1<<5) /* input capable */
178#define AC_PINCAP_BALANCE (1<<6) /* balanced I/O capable */ 184#define AC_PINCAP_BALANCE (1<<6) /* balanced I/O capable */
179#define AC_PINCAP_VREF (7<<8) 185#define AC_PINCAP_VREF (0x37<<8)
180#define AC_PINCAP_VREF_SHIFT 8 186#define AC_PINCAP_VREF_SHIFT 8
181#define AC_PINCAP_EAPD (1<<16) /* EAPD capable */ 187#define AC_PINCAP_EAPD (1<<16) /* EAPD capable */
182/* Vref status (used in pin cap and pin ctl) */ 188/* Vref status (used in pin cap) */
183#define AC_PIN_VREF_HIZ (1<<0) /* Hi-Z */ 189#define AC_PINCAP_VREF_HIZ (1<<0) /* Hi-Z */
184#define AC_PIN_VREF_50 (1<<1) /* 50% */ 190#define AC_PINCAP_VREF_50 (1<<1) /* 50% */
185#define AC_PIN_VREF_GRD (1<<2) /* ground */ 191#define AC_PINCAP_VREF_GRD (1<<2) /* ground */
186#define AC_PIN_VREF_80 (1<<4) /* 80% */ 192#define AC_PINCAP_VREF_80 (1<<4) /* 80% */
187#define AC_PIN_VREF_100 (1<<5) /* 100% */ 193#define AC_PINCAP_VREF_100 (1<<5) /* 100% */
188
189 194
190/* Amplifier capabilities */ 195/* Amplifier capabilities */
191#define AC_AMPCAP_OFFSET (0x7f<<0) /* 0dB offset */ 196#define AC_AMPCAP_OFFSET (0x7f<<0) /* 0dB offset */
@@ -248,6 +253,11 @@ enum {
248 253
249/* Pin widget control - 8bit */ 254/* Pin widget control - 8bit */
250#define AC_PINCTL_VREFEN (0x7<<0) 255#define AC_PINCTL_VREFEN (0x7<<0)
256#define AC_PINCTL_VREF_HIZ 0 /* Hi-Z */
257#define AC_PINCTL_VREF_50 1 /* 50% */
258#define AC_PINCTL_VREF_GRD 2 /* ground */
259#define AC_PINCTL_VREF_80 4 /* 80% */
260#define AC_PINCTL_VREF_100 5 /* 100% */
251#define AC_PINCTL_IN_EN (1<<5) 261#define AC_PINCTL_IN_EN (1<<5)
252#define AC_PINCTL_OUT_EN (1<<6) 262#define AC_PINCTL_OUT_EN (1<<6)
253#define AC_PINCTL_HP_EN (1<<7) 263#define AC_PINCTL_HP_EN (1<<7)
@@ -255,7 +265,9 @@ enum {
255/* configuration default - 32bit */ 265/* configuration default - 32bit */
256#define AC_DEFCFG_SEQUENCE (0xf<<0) 266#define AC_DEFCFG_SEQUENCE (0xf<<0)
257#define AC_DEFCFG_DEF_ASSOC (0xf<<4) 267#define AC_DEFCFG_DEF_ASSOC (0xf<<4)
268#define AC_DEFCFG_ASSOC_SHIFT 4
258#define AC_DEFCFG_MISC (0xf<<8) 269#define AC_DEFCFG_MISC (0xf<<8)
270#define AC_DEFCFG_MISC_SHIFT 8
259#define AC_DEFCFG_COLOR (0xf<<12) 271#define AC_DEFCFG_COLOR (0xf<<12)
260#define AC_DEFCFG_COLOR_SHIFT 12 272#define AC_DEFCFG_COLOR_SHIFT 12
261#define AC_DEFCFG_CONN_TYPE (0xf<<16) 273#define AC_DEFCFG_CONN_TYPE (0xf<<16)
@@ -413,7 +425,7 @@ struct hda_bus {
413 425
414 /* codec linked list */ 426 /* codec linked list */
415 struct list_head codec_list; 427 struct list_head codec_list;
416 struct hda_codec *caddr_tbl[HDA_MAX_CODEC_ADDRESS]; /* caddr -> codec */ 428 struct hda_codec *caddr_tbl[HDA_MAX_CODEC_ADDRESS + 1]; /* caddr -> codec */
417 429
418 struct semaphore cmd_mutex; 430 struct semaphore cmd_mutex;
419 431
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 69f7b6c4cf83..2d046abb5911 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -44,7 +44,7 @@ struct hda_gnode {
44 struct list_head list; 44 struct list_head list;
45}; 45};
46 46
47/* pathc-specific record */ 47/* patch-specific record */
48struct hda_gspec { 48struct hda_gspec {
49 struct hda_gnode *dac_node; /* DAC node */ 49 struct hda_gnode *dac_node; /* DAC node */
50 struct hda_gnode *out_pin_node; /* Output pin (Line-Out) node */ 50 struct hda_gnode *out_pin_node; /* Output pin (Line-Out) node */
@@ -68,8 +68,8 @@ struct hda_gspec {
68/* 68/*
69 * retrieve the default device type from the default config value 69 * retrieve the default device type from the default config value
70 */ 70 */
71#define get_defcfg_type(node) (((node)->def_cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT) 71#define defcfg_type(node) (((node)->def_cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT)
72#define get_defcfg_location(node) (((node)->def_cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT) 72#define defcfg_location(node) (((node)->def_cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT)
73 73
74/* 74/*
75 * destructor 75 * destructor
@@ -323,7 +323,7 @@ static struct hda_gnode *parse_output_jack(struct hda_codec *codec,
323 if (! (node->pin_caps & AC_PINCAP_OUT)) 323 if (! (node->pin_caps & AC_PINCAP_OUT))
324 continue; 324 continue;
325 if (jack_type >= 0) { 325 if (jack_type >= 0) {
326 if (jack_type != get_defcfg_type(node)) 326 if (jack_type != defcfg_type(node))
327 continue; 327 continue;
328 if (node->wid_caps & AC_WCAP_DIGITAL) 328 if (node->wid_caps & AC_WCAP_DIGITAL)
329 continue; /* skip SPDIF */ 329 continue; /* skip SPDIF */
@@ -418,15 +418,15 @@ static int capture_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uc
418 */ 418 */
419static const char *get_input_type(struct hda_gnode *node, unsigned int *pinctl) 419static const char *get_input_type(struct hda_gnode *node, unsigned int *pinctl)
420{ 420{
421 unsigned int location = get_defcfg_location(node); 421 unsigned int location = defcfg_location(node);
422 switch (get_defcfg_type(node)) { 422 switch (defcfg_type(node)) {
423 case AC_JACK_LINE_IN: 423 case AC_JACK_LINE_IN:
424 if ((location & 0x0f) == AC_JACK_LOC_FRONT) 424 if ((location & 0x0f) == AC_JACK_LOC_FRONT)
425 return "Front Line"; 425 return "Front Line";
426 return "Line"; 426 return "Line";
427 case AC_JACK_CD: 427 case AC_JACK_CD:
428 if (pinctl) 428 if (pinctl)
429 *pinctl |= AC_PIN_VREF_GRD; 429 *pinctl |= AC_PINCTL_VREF_GRD;
430 return "CD"; 430 return "CD";
431 case AC_JACK_AUX: 431 case AC_JACK_AUX:
432 if ((location & 0x0f) == AC_JACK_LOC_FRONT) 432 if ((location & 0x0f) == AC_JACK_LOC_FRONT)
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 959953ca320a..5e0cca36ed57 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -51,6 +51,7 @@ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
51static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 51static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
52static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 52static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
53static char *model[SNDRV_CARDS]; 53static char *model[SNDRV_CARDS];
54static int position_fix[SNDRV_CARDS];
54 55
55module_param_array(index, int, NULL, 0444); 56module_param_array(index, int, NULL, 0444);
56MODULE_PARM_DESC(index, "Index value for Intel HD audio interface."); 57MODULE_PARM_DESC(index, "Index value for Intel HD audio interface.");
@@ -60,12 +61,17 @@ module_param_array(enable, bool, NULL, 0444);
60MODULE_PARM_DESC(enable, "Enable Intel HD audio interface."); 61MODULE_PARM_DESC(enable, "Enable Intel HD audio interface.");
61module_param_array(model, charp, NULL, 0444); 62module_param_array(model, charp, NULL, 0444);
62MODULE_PARM_DESC(model, "Use the given board model."); 63MODULE_PARM_DESC(model, "Use the given board model.");
64module_param_array(position_fix, int, NULL, 0444);
65MODULE_PARM_DESC(position_fix, "Fix DMA pointer (0 = FIFO size, 1 = none, 2 = POSBUF).");
63 66
64MODULE_LICENSE("GPL"); 67MODULE_LICENSE("GPL");
65MODULE_SUPPORTED_DEVICE("{{Intel, ICH6}," 68MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
66 "{Intel, ICH6M}," 69 "{Intel, ICH6M},"
67 "{Intel, ICH7}," 70 "{Intel, ICH7},"
68 "{Intel, ESB2}}"); 71 "{Intel, ESB2},"
72 "{ATI, SB450},"
73 "{VIA, VT8251},"
74 "{VIA, VT8237A}}");
69MODULE_DESCRIPTION("Intel HDA driver"); 75MODULE_DESCRIPTION("Intel HDA driver");
70 76
71#define SFX "hda-intel: " 77#define SFX "hda-intel: "
@@ -150,7 +156,7 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
150 156
151/* STATESTS int mask: SD2,SD1,SD0 */ 157/* STATESTS int mask: SD2,SD1,SD0 */
152#define STATESTS_INT_MASK 0x07 158#define STATESTS_INT_MASK 0x07
153#define AZX_MAX_CODECS 3 159#define AZX_MAX_CODECS 4
154 160
155/* SD_CTL bits */ 161/* SD_CTL bits */
156#define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */ 162#define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */
@@ -183,6 +189,18 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
183#define ICH6_MAX_CORB_ENTRIES 256 189#define ICH6_MAX_CORB_ENTRIES 256
184#define ICH6_MAX_RIRB_ENTRIES 256 190#define ICH6_MAX_RIRB_ENTRIES 256
185 191
192/* position fix mode */
193enum {
194 POS_FIX_FIFO,
195 POS_FIX_NONE,
196 POS_FIX_POSBUF
197};
198
199/* Defines for ATI HD Audio support in SB450 south bridge */
200#define ATI_SB450_HDAUDIO_PCI_DEVICE_ID 0x437b
201#define ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR 0x42
202#define ATI_SB450_HDAUDIO_ENABLE_SNOOP 0x02
203
186 204
187/* 205/*
188 * Use CORB/RIRB for communication from/to codecs. 206 * Use CORB/RIRB for communication from/to codecs.
@@ -191,12 +209,6 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
191#define USE_CORB_RIRB 209#define USE_CORB_RIRB
192 210
193/* 211/*
194 * Define this if use the position buffer instead of reading SD_LPIB
195 * It's not used as default since SD_LPIB seems to give more accurate position
196 */
197/* #define USE_POSBUF */
198
199/*
200 */ 212 */
201 213
202typedef struct snd_azx azx_t; 214typedef struct snd_azx azx_t;
@@ -271,6 +283,10 @@ struct snd_azx {
271 struct snd_dma_buffer bdl; 283 struct snd_dma_buffer bdl;
272 struct snd_dma_buffer rb; 284 struct snd_dma_buffer rb;
273 struct snd_dma_buffer posbuf; 285 struct snd_dma_buffer posbuf;
286
287 /* flags */
288 int position_fix;
289 unsigned int initialized: 1;
274}; 290};
275 291
276/* 292/*
@@ -638,7 +654,7 @@ static void azx_stream_stop(azx_t *chip, azx_dev_t *azx_dev)
638 */ 654 */
639static void azx_init_chip(azx_t *chip) 655static void azx_init_chip(azx_t *chip)
640{ 656{
641 unsigned char tcsel_reg; 657 unsigned char tcsel_reg, ati_misc_cntl2;
642 658
643 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) 659 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44)
644 * TCSEL == Traffic Class Select Register, which sets PCI express QOS 660 * TCSEL == Traffic Class Select Register, which sets PCI express QOS
@@ -657,11 +673,20 @@ static void azx_init_chip(azx_t *chip)
657 /* initialize the codec command I/O */ 673 /* initialize the codec command I/O */
658 azx_init_cmd_io(chip); 674 azx_init_cmd_io(chip);
659 675
660#ifdef USE_POSBUF 676 if (chip->position_fix == POS_FIX_POSBUF) {
661 /* program the position buffer */ 677 /* program the position buffer */
662 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr); 678 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr);
663 azx_writel(chip, DPUBASE, upper_32bit(chip->posbuf.addr)); 679 azx_writel(chip, DPUBASE, upper_32bit(chip->posbuf.addr));
664#endif 680 }
681
682 /* For ATI SB450 azalia HD audio, we need to enable snoop */
683 if (chip->pci->vendor == PCI_VENDOR_ID_ATI &&
684 chip->pci->device == ATI_SB450_HDAUDIO_PCI_DEVICE_ID) {
685 pci_read_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR,
686 &ati_misc_cntl2);
687 pci_write_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR,
688 (ati_misc_cntl2 & 0xf8) | ATI_SB450_HDAUDIO_ENABLE_SNOOP);
689 }
665} 690}
666 691
667 692
@@ -791,11 +816,12 @@ static int azx_setup_controller(azx_t *chip, azx_dev_t *azx_dev)
791 /* upper BDL address */ 816 /* upper BDL address */
792 azx_sd_writel(azx_dev, SD_BDLPU, upper_32bit(azx_dev->bdl_addr)); 817 azx_sd_writel(azx_dev, SD_BDLPU, upper_32bit(azx_dev->bdl_addr));
793 818
794#ifdef USE_POSBUF 819 if (chip->position_fix == POS_FIX_POSBUF) {
795 /* enable the position buffer */ 820 /* enable the position buffer */
796 if (! (azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE)) 821 if (! (azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE))
797 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE); 822 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE);
798#endif 823 }
824
799 /* set the interrupt enable bits in the descriptor control register */ 825 /* set the interrupt enable bits in the descriptor control register */
800 azx_sd_writel(azx_dev, SD_CTL, azx_sd_readl(azx_dev, SD_CTL) | SD_INT_MASK); 826 azx_sd_writel(azx_dev, SD_CTL, azx_sd_readl(azx_dev, SD_CTL) | SD_INT_MASK);
801 827
@@ -1036,16 +1062,20 @@ static int azx_pcm_trigger(snd_pcm_substream_t *substream, int cmd)
1036 1062
1037static snd_pcm_uframes_t azx_pcm_pointer(snd_pcm_substream_t *substream) 1063static snd_pcm_uframes_t azx_pcm_pointer(snd_pcm_substream_t *substream)
1038{ 1064{
1065 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
1066 azx_t *chip = apcm->chip;
1039 azx_dev_t *azx_dev = get_azx_dev(substream); 1067 azx_dev_t *azx_dev = get_azx_dev(substream);
1040 unsigned int pos; 1068 unsigned int pos;
1041 1069
1042#ifdef USE_POSBUF 1070 if (chip->position_fix == POS_FIX_POSBUF) {
1043 /* use the position buffer */ 1071 /* use the position buffer */
1044 pos = *azx_dev->posbuf; 1072 pos = *azx_dev->posbuf;
1045#else 1073 } else {
1046 /* read LPIB */ 1074 /* read LPIB */
1047 pos = azx_sd_readl(azx_dev, SD_LPIB) + azx_dev->fifo_size; 1075 pos = azx_sd_readl(azx_dev, SD_LPIB);
1048#endif 1076 if (chip->position_fix == POS_FIX_FIFO)
1077 pos += azx_dev->fifo_size;
1078 }
1049 if (pos >= azx_dev->bufsize) 1079 if (pos >= azx_dev->bufsize)
1050 pos = 0; 1080 pos = 0;
1051 return bytes_to_frames(substream->runtime, pos); 1081 return bytes_to_frames(substream->runtime, pos);
@@ -1155,9 +1185,8 @@ static int __devinit azx_init_stream(azx_t *chip)
1155 azx_dev_t *azx_dev = &chip->azx_dev[i]; 1185 azx_dev_t *azx_dev = &chip->azx_dev[i];
1156 azx_dev->bdl = (u32 *)(chip->bdl.area + off); 1186 azx_dev->bdl = (u32 *)(chip->bdl.area + off);
1157 azx_dev->bdl_addr = chip->bdl.addr + off; 1187 azx_dev->bdl_addr = chip->bdl.addr + off;
1158#ifdef USE_POSBUF 1188 if (chip->position_fix == POS_FIX_POSBUF)
1159 azx_dev->posbuf = (volatile u32 *)(chip->posbuf.area + i * 8); 1189 azx_dev->posbuf = (volatile u32 *)(chip->posbuf.area + i * 8);
1160#endif
1161 /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */ 1190 /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
1162 azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80); 1191 azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80);
1163 /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */ 1192 /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */
@@ -1207,7 +1236,7 @@ static int azx_resume(snd_card_t *card)
1207 */ 1236 */
1208static int azx_free(azx_t *chip) 1237static int azx_free(azx_t *chip)
1209{ 1238{
1210 if (chip->remap_addr) { 1239 if (chip->initialized) {
1211 int i; 1240 int i;
1212 1241
1213 for (i = 0; i < MAX_ICH6_DEV; i++) 1242 for (i = 0; i < MAX_ICH6_DEV; i++)
@@ -1237,10 +1266,8 @@ static int azx_free(azx_t *chip)
1237 snd_dma_free_pages(&chip->bdl); 1266 snd_dma_free_pages(&chip->bdl);
1238 if (chip->rb.area) 1267 if (chip->rb.area)
1239 snd_dma_free_pages(&chip->rb); 1268 snd_dma_free_pages(&chip->rb);
1240#ifdef USE_POSBUF
1241 if (chip->posbuf.area) 1269 if (chip->posbuf.area)
1242 snd_dma_free_pages(&chip->posbuf); 1270 snd_dma_free_pages(&chip->posbuf);
1243#endif
1244 pci_release_regions(chip->pci); 1271 pci_release_regions(chip->pci);
1245 pci_disable_device(chip->pci); 1272 pci_disable_device(chip->pci);
1246 kfree(chip); 1273 kfree(chip);
@@ -1256,7 +1283,8 @@ static int azx_dev_free(snd_device_t *device)
1256/* 1283/*
1257 * constructor 1284 * constructor
1258 */ 1285 */
1259static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, azx_t **rchip) 1286static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci,
1287 int posfix, azx_t **rchip)
1260{ 1288{
1261 azx_t *chip; 1289 azx_t *chip;
1262 int err = 0; 1290 int err = 0;
@@ -1283,6 +1311,8 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, azx_t **r
1283 chip->pci = pci; 1311 chip->pci = pci;
1284 chip->irq = -1; 1312 chip->irq = -1;
1285 1313
1314 chip->position_fix = posfix;
1315
1286 if ((err = pci_request_regions(pci, "ICH HD audio")) < 0) { 1316 if ((err = pci_request_regions(pci, "ICH HD audio")) < 0) {
1287 kfree(chip); 1317 kfree(chip);
1288 pci_disable_device(pci); 1318 pci_disable_device(pci);
@@ -1314,14 +1344,14 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, azx_t **r
1314 snd_printk(KERN_ERR SFX "cannot allocate BDL\n"); 1344 snd_printk(KERN_ERR SFX "cannot allocate BDL\n");
1315 goto errout; 1345 goto errout;
1316 } 1346 }
1317#ifdef USE_POSBUF 1347 if (chip->position_fix == POS_FIX_POSBUF) {
1318 /* allocate memory for the position buffer */ 1348 /* allocate memory for the position buffer */
1319 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 1349 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
1320 MAX_ICH6_DEV * 8, &chip->posbuf)) < 0) { 1350 MAX_ICH6_DEV * 8, &chip->posbuf)) < 0) {
1321 snd_printk(KERN_ERR SFX "cannot allocate posbuf\n"); 1351 snd_printk(KERN_ERR SFX "cannot allocate posbuf\n");
1322 goto errout; 1352 goto errout;
1353 }
1323 } 1354 }
1324#endif
1325 /* allocate CORB/RIRB */ 1355 /* allocate CORB/RIRB */
1326 if ((err = azx_alloc_cmd_io(chip)) < 0) 1356 if ((err = azx_alloc_cmd_io(chip)) < 0)
1327 goto errout; 1357 goto errout;
@@ -1332,6 +1362,8 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, azx_t **r
1332 /* initialize chip */ 1362 /* initialize chip */
1333 azx_init_chip(chip); 1363 azx_init_chip(chip);
1334 1364
1365 chip->initialized = 1;
1366
1335 /* codec detection */ 1367 /* codec detection */
1336 if (! chip->codec_mask) { 1368 if (! chip->codec_mask) {
1337 snd_printk(KERN_ERR SFX "no codecs found!\n"); 1369 snd_printk(KERN_ERR SFX "no codecs found!\n");
@@ -1372,7 +1404,7 @@ static int __devinit azx_probe(struct pci_dev *pci, const struct pci_device_id *
1372 return -ENOMEM; 1404 return -ENOMEM;
1373 } 1405 }
1374 1406
1375 if ((err = azx_create(card, pci, &chip)) < 0) { 1407 if ((err = azx_create(card, pci, position_fix[dev], &chip)) < 0) {
1376 snd_card_free(card); 1408 snd_card_free(card);
1377 return err; 1409 return err;
1378 } 1410 }
@@ -1424,6 +1456,9 @@ static struct pci_device_id azx_ids[] = {
1424 { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH6 */ 1456 { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH6 */
1425 { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH7 */ 1457 { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH7 */
1426 { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ESB2 */ 1458 { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ESB2 */
1459 { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ATI SB450 */
1460 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* VIA VT8251/VT8237A */
1461 { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ALI 5461? */
1427 { 0, } 1462 { 0, }
1428}; 1463};
1429MODULE_DEVICE_TABLE(pci, azx_ids); 1464MODULE_DEVICE_TABLE(pci, azx_ids);
@@ -1439,7 +1474,7 @@ static struct pci_driver driver = {
1439 1474
1440static int __init alsa_card_azx_init(void) 1475static int __init alsa_card_azx_init(void)
1441{ 1476{
1442 return pci_module_init(&driver); 1477 return pci_register_driver(&driver);
1443} 1478}
1444 1479
1445static void __exit alsa_card_azx_exit(void) 1480static void __exit alsa_card_azx_exit(void)
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 7c7b849875a0..810cfd2d9bba 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -126,11 +126,11 @@ static inline int snd_hda_codec_proc_new(struct hda_codec *codec) { return 0; }
126struct hda_board_config { 126struct hda_board_config {
127 const char *modelname; 127 const char *modelname;
128 int config; 128 int config;
129 unsigned short pci_vendor; 129 unsigned short pci_subvendor;
130 unsigned short pci_device; 130 unsigned short pci_subdevice;
131}; 131};
132 132
133int snd_hda_check_board_config(struct hda_codec *codec, struct hda_board_config *tbl); 133int snd_hda_check_board_config(struct hda_codec *codec, const struct hda_board_config *tbl);
134int snd_hda_add_new_ctls(struct hda_codec *codec, snd_kcontrol_new_t *knew); 134int snd_hda_add_new_ctls(struct hda_codec *codec, snd_kcontrol_new_t *knew);
135 135
136/* 136/*
@@ -158,4 +158,35 @@ struct hda_bus_unsolicited {
158 struct work_struct work; 158 struct work_struct work;
159}; 159};
160 160
161/*
162 * Helper for automatic ping configuration
163 */
164
165enum {
166 AUTO_PIN_MIC,
167 AUTO_PIN_FRONT_MIC,
168 AUTO_PIN_LINE,
169 AUTO_PIN_FRONT_LINE,
170 AUTO_PIN_CD,
171 AUTO_PIN_AUX,
172 AUTO_PIN_LAST
173};
174
175struct auto_pin_cfg {
176 int line_outs;
177 hda_nid_t line_out_pins[4]; /* sorted in the order of Front/Surr/CLFE/Side */
178 hda_nid_t hp_pin;
179 hda_nid_t input_pins[AUTO_PIN_LAST];
180 hda_nid_t dig_out_pin;
181 hda_nid_t dig_in_pin;
182};
183
184#define get_defcfg_connect(cfg) ((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT)
185#define get_defcfg_association(cfg) ((cfg & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT)
186#define get_defcfg_location(cfg) ((cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT)
187#define get_defcfg_sequence(cfg) (cfg & AC_DEFCFG_SEQUENCE)
188#define get_defcfg_device(cfg) ((cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT)
189
190int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg);
191
161#endif /* __SOUND_HDA_LOCAL_H */ 192#endif /* __SOUND_HDA_LOCAL_H */
diff --git a/sound/pci/hda/hda_patch.h b/sound/pci/hda/hda_patch.h
index cf6abce42bc9..a5de684b6944 100644
--- a/sound/pci/hda/hda_patch.h
+++ b/sound/pci/hda/hda_patch.h
@@ -8,10 +8,13 @@ extern struct hda_codec_preset snd_hda_preset_realtek[];
8extern struct hda_codec_preset snd_hda_preset_cmedia[]; 8extern struct hda_codec_preset snd_hda_preset_cmedia[];
9/* Analog Devices codecs */ 9/* Analog Devices codecs */
10extern struct hda_codec_preset snd_hda_preset_analog[]; 10extern struct hda_codec_preset snd_hda_preset_analog[];
11/* SigmaTel codecs */
12extern struct hda_codec_preset snd_hda_preset_sigmatel[];
11 13
12static const struct hda_codec_preset *hda_preset_tables[] = { 14static const struct hda_codec_preset *hda_preset_tables[] = {
13 snd_hda_preset_realtek, 15 snd_hda_preset_realtek,
14 snd_hda_preset_cmedia, 16 snd_hda_preset_cmedia,
15 snd_hda_preset_analog, 17 snd_hda_preset_analog,
18 snd_hda_preset_sigmatel,
16 NULL 19 NULL
17}; 20};
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
index 4d5db7faad8d..de1217bd8e68 100644
--- a/sound/pci/hda/hda_proc.c
+++ b/sound/pci/hda/hda_proc.c
@@ -68,21 +68,27 @@ static void print_amp_caps(snd_info_buffer_t *buffer,
68 68
69static void print_amp_vals(snd_info_buffer_t *buffer, 69static void print_amp_vals(snd_info_buffer_t *buffer,
70 struct hda_codec *codec, hda_nid_t nid, 70 struct hda_codec *codec, hda_nid_t nid,
71 int dir, int stereo) 71 int dir, int stereo, int indices)
72{ 72{
73 unsigned int val; 73 unsigned int val;
74 if (stereo) { 74 int i;
75
76 if (dir == HDA_OUTPUT)
77 dir = AC_AMP_GET_OUTPUT;
78 else
79 dir = AC_AMP_GET_INPUT;
80 for (i = 0; i < indices; i++) {
81 snd_iprintf(buffer, " [");
82 if (stereo) {
83 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE,
84 AC_AMP_GET_LEFT | dir | i);
85 snd_iprintf(buffer, "0x%02x ", val);
86 }
75 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, 87 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE,
76 AC_AMP_GET_LEFT | 88 AC_AMP_GET_RIGHT | dir | i);
77 (dir == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : 89 snd_iprintf(buffer, "0x%02x]", val);
78 AC_AMP_GET_INPUT));
79 snd_iprintf(buffer, "0x%02x ", val);
80 } 90 }
81 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, 91 snd_iprintf(buffer, "\n");
82 AC_AMP_GET_RIGHT |
83 (dir == HDA_OUTPUT ? AC_AMP_GET_OUTPUT :
84 AC_AMP_GET_INPUT));
85 snd_iprintf(buffer, "0x%02x\n", val);
86} 92}
87 93
88static void print_pcm_caps(snd_info_buffer_t *buffer, 94static void print_pcm_caps(snd_info_buffer_t *buffer,
@@ -157,6 +163,7 @@ static const char *get_jack_color(u32 cfg)
157static void print_pin_caps(snd_info_buffer_t *buffer, 163static void print_pin_caps(snd_info_buffer_t *buffer,
158 struct hda_codec *codec, hda_nid_t nid) 164 struct hda_codec *codec, hda_nid_t nid)
159{ 165{
166 static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" };
160 static char *jack_types[16] = { 167 static char *jack_types[16] = {
161 "Line Out", "Speaker", "HP Out", "CD", 168 "Line Out", "Speaker", "HP Out", "CD",
162 "SPDIF Out", "Digital Out", "Modem Line", "Modem Hand", 169 "SPDIF Out", "Digital Out", "Modem Line", "Modem Hand",
@@ -176,7 +183,8 @@ static void print_pin_caps(snd_info_buffer_t *buffer,
176 snd_iprintf(buffer, " HP"); 183 snd_iprintf(buffer, " HP");
177 snd_iprintf(buffer, "\n"); 184 snd_iprintf(buffer, "\n");
178 caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 185 caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
179 snd_iprintf(buffer, " Pin Default 0x%08x: %s at %s %s\n", caps, 186 snd_iprintf(buffer, " Pin Default 0x%08x: [%s] %s at %s %s\n", caps,
187 jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT],
180 jack_types[(caps & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT], 188 jack_types[(caps & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT],
181 jack_locations[(caps >> (AC_DEFCFG_LOCATION_SHIFT + 4)) & 3], 189 jack_locations[(caps >> (AC_DEFCFG_LOCATION_SHIFT + 4)) & 3],
182 get_jack_location(caps)); 190 get_jack_location(caps));
@@ -215,6 +223,9 @@ static void print_codec_info(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
215 unsigned int wid_caps = snd_hda_param_read(codec, nid, 223 unsigned int wid_caps = snd_hda_param_read(codec, nid,
216 AC_PAR_AUDIO_WIDGET_CAP); 224 AC_PAR_AUDIO_WIDGET_CAP);
217 unsigned int wid_type = (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 225 unsigned int wid_type = (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
226 int conn_len = 0;
227 hda_nid_t conn[HDA_MAX_CONNECTIONS];
228
218 snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid, 229 snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid,
219 get_wid_type_name(wid_type), wid_caps); 230 get_wid_type_name(wid_type), wid_caps);
220 if (wid_caps & AC_WCAP_STEREO) 231 if (wid_caps & AC_WCAP_STEREO)
@@ -229,19 +240,23 @@ static void print_codec_info(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
229 snd_iprintf(buffer, " Amp-Out"); 240 snd_iprintf(buffer, " Amp-Out");
230 snd_iprintf(buffer, "\n"); 241 snd_iprintf(buffer, "\n");
231 242
243 if (wid_caps & AC_WCAP_CONN_LIST)
244 conn_len = snd_hda_get_connections(codec, nid, conn,
245 HDA_MAX_CONNECTIONS);
246
232 if (wid_caps & AC_WCAP_IN_AMP) { 247 if (wid_caps & AC_WCAP_IN_AMP) {
233 snd_iprintf(buffer, " Amp-In caps: "); 248 snd_iprintf(buffer, " Amp-In caps: ");
234 print_amp_caps(buffer, codec, nid, HDA_INPUT); 249 print_amp_caps(buffer, codec, nid, HDA_INPUT);
235 snd_iprintf(buffer, " Amp-In vals: "); 250 snd_iprintf(buffer, " Amp-In vals: ");
236 print_amp_vals(buffer, codec, nid, HDA_INPUT, 251 print_amp_vals(buffer, codec, nid, HDA_INPUT,
237 wid_caps & AC_WCAP_STEREO); 252 wid_caps & AC_WCAP_STEREO, conn_len);
238 } 253 }
239 if (wid_caps & AC_WCAP_OUT_AMP) { 254 if (wid_caps & AC_WCAP_OUT_AMP) {
240 snd_iprintf(buffer, " Amp-Out caps: "); 255 snd_iprintf(buffer, " Amp-Out caps: ");
241 print_amp_caps(buffer, codec, nid, HDA_OUTPUT); 256 print_amp_caps(buffer, codec, nid, HDA_OUTPUT);
242 snd_iprintf(buffer, " Amp-Out vals: "); 257 snd_iprintf(buffer, " Amp-Out vals: ");
243 print_amp_vals(buffer, codec, nid, HDA_OUTPUT, 258 print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
244 wid_caps & AC_WCAP_STEREO); 259 wid_caps & AC_WCAP_STEREO, 1);
245 } 260 }
246 261
247 if (wid_type == AC_WID_PIN) { 262 if (wid_type == AC_WID_PIN) {
@@ -265,14 +280,17 @@ static void print_codec_info(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
265 } 280 }
266 281
267 if (wid_caps & AC_WCAP_CONN_LIST) { 282 if (wid_caps & AC_WCAP_CONN_LIST) {
268 hda_nid_t conn[HDA_MAX_CONNECTIONS]; 283 int c, curr = -1;
269 int c, conn_len; 284 if (conn_len > 1 && wid_type != AC_WID_AUD_MIX)
270 conn_len = snd_hda_get_connections(codec, nid, conn, 285 curr = snd_hda_codec_read(codec, nid, 0,
271 HDA_MAX_CONNECTIONS); 286 AC_VERB_GET_CONNECT_SEL, 0);
272 snd_iprintf(buffer, " Connection: %d\n", conn_len); 287 snd_iprintf(buffer, " Connection: %d\n", conn_len);
273 snd_iprintf(buffer, " "); 288 snd_iprintf(buffer, " ");
274 for (c = 0; c < conn_len; c++) 289 for (c = 0; c < conn_len; c++) {
275 snd_iprintf(buffer, " 0x%02x", conn[c]); 290 snd_iprintf(buffer, " 0x%02x", conn[c]);
291 if (c == curr)
292 snd_iprintf(buffer, "*");
293 }
276 snd_iprintf(buffer, "\n"); 294 snd_iprintf(buffer, "\n");
277 } 295 }
278 } 296 }
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 75d23849f71a..2fd05bb84136 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * HD audio interface patch for AD1986A 2 * HD audio interface patch for AD1981HD, AD1983, AD1986A
3 * 3 *
4 * Copyright (c) 2005 Takashi Iwai <tiwai@suse.de> 4 * Copyright (c) 2005 Takashi Iwai <tiwai@suse.de>
5 * 5 *
@@ -27,13 +27,239 @@
27#include "hda_codec.h" 27#include "hda_codec.h"
28#include "hda_local.h" 28#include "hda_local.h"
29 29
30struct ad1986a_spec { 30struct ad198x_spec {
31 struct semaphore amp_mutex; /* PCM volume/mute control mutex */ 31 struct semaphore amp_mutex; /* PCM volume/mute control mutex */
32 struct hda_multi_out multiout; /* playback */ 32 struct hda_multi_out multiout; /* playback */
33 hda_nid_t adc_nid;
34 const struct hda_input_mux *input_mux;
33 unsigned int cur_mux; /* capture source */ 35 unsigned int cur_mux; /* capture source */
36 unsigned int spdif_route;
37 snd_kcontrol_new_t *mixers;
38 const struct hda_verb *init_verbs;
34 struct hda_pcm pcm_rec[2]; /* PCM information */ 39 struct hda_pcm pcm_rec[2]; /* PCM information */
35}; 40};
36 41
42/*
43 * input MUX handling (common part)
44 */
45static int ad198x_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
46{
47 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
48 struct ad198x_spec *spec = codec->spec;
49
50 return snd_hda_input_mux_info(spec->input_mux, uinfo);
51}
52
53static int ad198x_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
54{
55 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
56 struct ad198x_spec *spec = codec->spec;
57
58 ucontrol->value.enumerated.item[0] = spec->cur_mux;
59 return 0;
60}
61
62static int ad198x_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
63{
64 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
65 struct ad198x_spec *spec = codec->spec;
66
67 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
68 spec->adc_nid, &spec->cur_mux);
69}
70
71/*
72 * initialization (common callbacks)
73 */
74static int ad198x_init(struct hda_codec *codec)
75{
76 struct ad198x_spec *spec = codec->spec;
77 snd_hda_sequence_write(codec, spec->init_verbs);
78 return 0;
79}
80
81static int ad198x_build_controls(struct hda_codec *codec)
82{
83 struct ad198x_spec *spec = codec->spec;
84 int err;
85
86 err = snd_hda_add_new_ctls(codec, spec->mixers);
87 if (err < 0)
88 return err;
89 if (spec->multiout.dig_out_nid)
90 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
91 if (err < 0)
92 return err;
93 return 0;
94}
95
96/*
97 * Analog playback callbacks
98 */
99static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo,
100 struct hda_codec *codec,
101 snd_pcm_substream_t *substream)
102{
103 struct ad198x_spec *spec = codec->spec;
104 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
105}
106
107static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
108 struct hda_codec *codec,
109 unsigned int stream_tag,
110 unsigned int format,
111 snd_pcm_substream_t *substream)
112{
113 struct ad198x_spec *spec = codec->spec;
114 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
115 format, substream);
116}
117
118static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
119 struct hda_codec *codec,
120 snd_pcm_substream_t *substream)
121{
122 struct ad198x_spec *spec = codec->spec;
123 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
124}
125
126/*
127 * Digital out
128 */
129static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
130 struct hda_codec *codec,
131 snd_pcm_substream_t *substream)
132{
133 struct ad198x_spec *spec = codec->spec;
134 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
135}
136
137static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
138 struct hda_codec *codec,
139 snd_pcm_substream_t *substream)
140{
141 struct ad198x_spec *spec = codec->spec;
142 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
143}
144
145/*
146 * Analog capture
147 */
148static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
149 struct hda_codec *codec,
150 unsigned int stream_tag,
151 unsigned int format,
152 snd_pcm_substream_t *substream)
153{
154 struct ad198x_spec *spec = codec->spec;
155 snd_hda_codec_setup_stream(codec, spec->adc_nid, stream_tag, 0, format);
156 return 0;
157}
158
159static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
160 struct hda_codec *codec,
161 snd_pcm_substream_t *substream)
162{
163 struct ad198x_spec *spec = codec->spec;
164 snd_hda_codec_setup_stream(codec, spec->adc_nid, 0, 0, 0);
165 return 0;
166}
167
168
169/*
170 */
171static struct hda_pcm_stream ad198x_pcm_analog_playback = {
172 .substreams = 1,
173 .channels_min = 2,
174 .channels_max = 6,
175 .nid = 0, /* fill later */
176 .ops = {
177 .open = ad198x_playback_pcm_open,
178 .prepare = ad198x_playback_pcm_prepare,
179 .cleanup = ad198x_playback_pcm_cleanup
180 },
181};
182
183static struct hda_pcm_stream ad198x_pcm_analog_capture = {
184 .substreams = 2,
185 .channels_min = 2,
186 .channels_max = 2,
187 .nid = 0, /* fill later */
188 .ops = {
189 .prepare = ad198x_capture_pcm_prepare,
190 .cleanup = ad198x_capture_pcm_cleanup
191 },
192};
193
194static struct hda_pcm_stream ad198x_pcm_digital_playback = {
195 .substreams = 1,
196 .channels_min = 2,
197 .channels_max = 2,
198 .nid = 0, /* fill later */
199 .ops = {
200 .open = ad198x_dig_playback_pcm_open,
201 .close = ad198x_dig_playback_pcm_close
202 },
203};
204
205static int ad198x_build_pcms(struct hda_codec *codec)
206{
207 struct ad198x_spec *spec = codec->spec;
208 struct hda_pcm *info = spec->pcm_rec;
209
210 codec->num_pcms = 1;
211 codec->pcm_info = info;
212
213 info->name = "AD198x Analog";
214 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_analog_playback;
215 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->multiout.max_channels;
216 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
217 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_analog_capture;
218 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nid;
219
220 if (spec->multiout.dig_out_nid) {
221 info++;
222 codec->num_pcms++;
223 info->name = "AD198x Digital";
224 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback;
225 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
226 }
227
228 return 0;
229}
230
231static void ad198x_free(struct hda_codec *codec)
232{
233 kfree(codec->spec);
234}
235
236#ifdef CONFIG_PM
237static int ad198x_resume(struct hda_codec *codec)
238{
239 struct ad198x_spec *spec = codec->spec;
240
241 ad198x_init(codec);
242 snd_hda_resume_ctls(codec, spec->mixers);
243 snd_hda_resume_spdif_out(codec);
244 return 0;
245}
246#endif
247
248static struct hda_codec_ops ad198x_patch_ops = {
249 .build_controls = ad198x_build_controls,
250 .build_pcms = ad198x_build_pcms,
251 .init = ad198x_init,
252 .free = ad198x_free,
253#ifdef CONFIG_PM
254 .resume = ad198x_resume,
255#endif
256};
257
258
259/*
260 * AD1986A specific
261 */
262
37#define AD1986A_SPDIF_OUT 0x02 263#define AD1986A_SPDIF_OUT 0x02
38#define AD1986A_FRONT_DAC 0x03 264#define AD1986A_FRONT_DAC 0x03
39#define AD1986A_SURR_DAC 0x04 265#define AD1986A_SURR_DAC 0x04
@@ -68,7 +294,7 @@ static struct hda_input_mux ad1986a_capture_source = {
68static int ad1986a_pcm_amp_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 294static int ad1986a_pcm_amp_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
69{ 295{
70 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 296 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
71 struct ad1986a_spec *ad = codec->spec; 297 struct ad198x_spec *ad = codec->spec;
72 298
73 down(&ad->amp_mutex); 299 down(&ad->amp_mutex);
74 snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); 300 snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
@@ -79,7 +305,7 @@ static int ad1986a_pcm_amp_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_
79static int ad1986a_pcm_amp_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 305static int ad1986a_pcm_amp_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
80{ 306{
81 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 307 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
82 struct ad1986a_spec *ad = codec->spec; 308 struct ad198x_spec *ad = codec->spec;
83 int i, change = 0; 309 int i, change = 0;
84 310
85 down(&ad->amp_mutex); 311 down(&ad->amp_mutex);
@@ -92,12 +318,12 @@ static int ad1986a_pcm_amp_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_
92 return change; 318 return change;
93} 319}
94 320
95#define ad1986a_pcm_amp_sw_info snd_hda_mixer_amp_volume_info 321#define ad1986a_pcm_amp_sw_info snd_hda_mixer_amp_switch_info
96 322
97static int ad1986a_pcm_amp_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 323static int ad1986a_pcm_amp_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
98{ 324{
99 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 325 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
100 struct ad1986a_spec *ad = codec->spec; 326 struct ad198x_spec *ad = codec->spec;
101 327
102 down(&ad->amp_mutex); 328 down(&ad->amp_mutex);
103 snd_hda_mixer_amp_switch_get(kcontrol, ucontrol); 329 snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
@@ -108,7 +334,7 @@ static int ad1986a_pcm_amp_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t
108static int ad1986a_pcm_amp_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 334static int ad1986a_pcm_amp_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
109{ 335{
110 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 336 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
111 struct ad1986a_spec *ad = codec->spec; 337 struct ad198x_spec *ad = codec->spec;
112 int i, change = 0; 338 int i, change = 0;
113 339
114 down(&ad->amp_mutex); 340 down(&ad->amp_mutex);
@@ -122,32 +348,6 @@ static int ad1986a_pcm_amp_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t
122} 348}
123 349
124/* 350/*
125 * input MUX handling
126 */
127static int ad1986a_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
128{
129 return snd_hda_input_mux_info(&ad1986a_capture_source, uinfo);
130}
131
132static int ad1986a_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
133{
134 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
135 struct ad1986a_spec *spec = codec->spec;
136
137 ucontrol->value.enumerated.item[0] = spec->cur_mux;
138 return 0;
139}
140
141static int ad1986a_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
142{
143 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
144 struct ad1986a_spec *spec = codec->spec;
145
146 return snd_hda_input_mux_put(codec, &ad1986a_capture_source, ucontrol,
147 AD1986A_ADC, &spec->cur_mux);
148}
149
150/*
151 * mixers 351 * mixers
152 */ 352 */
153static snd_kcontrol_new_t ad1986a_mixers[] = { 353static snd_kcontrol_new_t ad1986a_mixers[] = {
@@ -194,9 +394,9 @@ static snd_kcontrol_new_t ad1986a_mixers[] = {
194 { 394 {
195 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 395 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
196 .name = "Capture Source", 396 .name = "Capture Source",
197 .info = ad1986a_mux_enum_info, 397 .info = ad198x_mux_enum_info,
198 .get = ad1986a_mux_enum_get, 398 .get = ad198x_mux_enum_get,
199 .put = ad1986a_mux_enum_put, 399 .put = ad198x_mux_enum_put,
200 }, 400 },
201 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT), 401 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT),
202 { } /* end */ 402 { } /* end */
@@ -241,183 +441,328 @@ static struct hda_verb ad1986a_init_verbs[] = {
241 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 441 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
242 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 442 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
243 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 443 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
444 /* HP Pin */
445 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
446 /* Front, Surround, CLFE Pins */
447 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
448 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
449 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
450 /* Mono Pin */
451 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
452 /* Mic Pin */
453 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
454 /* Line, Aux, CD, Beep-In Pin */
455 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
456 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
457 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
458 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
459 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
244 { } /* end */ 460 { } /* end */
245}; 461};
246 462
247 463
248static int ad1986a_init(struct hda_codec *codec) 464static int patch_ad1986a(struct hda_codec *codec)
249{ 465{
250 snd_hda_sequence_write(codec, ad1986a_init_verbs); 466 struct ad198x_spec *spec;
251 return 0;
252}
253 467
254static int ad1986a_build_controls(struct hda_codec *codec) 468 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
255{ 469 if (spec == NULL)
256 int err; 470 return -ENOMEM;
471
472 init_MUTEX(&spec->amp_mutex);
473 codec->spec = spec;
474
475 spec->multiout.max_channels = 6;
476 spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids);
477 spec->multiout.dac_nids = ad1986a_dac_nids;
478 spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT;
479 spec->adc_nid = AD1986A_ADC;
480 spec->input_mux = &ad1986a_capture_source;
481 spec->mixers = ad1986a_mixers;
482 spec->init_verbs = ad1986a_init_verbs;
483
484 codec->patch_ops = ad198x_patch_ops;
257 485
258 err = snd_hda_add_new_ctls(codec, ad1986a_mixers);
259 if (err < 0)
260 return err;
261 err = snd_hda_create_spdif_out_ctls(codec, AD1986A_SPDIF_OUT);
262 if (err < 0)
263 return err;
264 return 0; 486 return 0;
265} 487}
266 488
267/* 489/*
268 * Analog playback callbacks 490 * AD1983 specific
269 */ 491 */
270static int ad1986a_playback_pcm_open(struct hda_pcm_stream *hinfo,
271 struct hda_codec *codec,
272 snd_pcm_substream_t *substream)
273{
274 struct ad1986a_spec *spec = codec->spec;
275 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
276}
277 492
278static int ad1986a_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 493#define AD1983_SPDIF_OUT 0x02
279 struct hda_codec *codec, 494#define AD1983_DAC 0x03
280 unsigned int stream_tag, 495#define AD1983_ADC 0x04
281 unsigned int format,
282 snd_pcm_substream_t *substream)
283{
284 struct ad1986a_spec *spec = codec->spec;
285 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
286 format, substream);
287}
288 496
289static int ad1986a_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 497static hda_nid_t ad1983_dac_nids[1] = { AD1983_DAC };
290 struct hda_codec *codec, 498
291 snd_pcm_substream_t *substream) 499static struct hda_input_mux ad1983_capture_source = {
292{ 500 .num_items = 4,
293 struct ad1986a_spec *spec = codec->spec; 501 .items = {
294 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); 502 { "Mic", 0x0 },
295} 503 { "Line", 0x1 },
504 { "Mix", 0x2 },
505 { "Mix Mono", 0x3 },
506 },
507};
296 508
297/* 509/*
298 * Digital out 510 * SPDIF playback route
299 */ 511 */
300static int ad1986a_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, 512static int ad1983_spdif_route_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
301 struct hda_codec *codec,
302 snd_pcm_substream_t *substream)
303{ 513{
304 struct ad1986a_spec *spec = codec->spec; 514 static char *texts[] = { "PCM", "ADC" };
305 return snd_hda_multi_out_dig_open(codec, &spec->multiout); 515
516 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
517 uinfo->count = 1;
518 uinfo->value.enumerated.items = 2;
519 if (uinfo->value.enumerated.item > 1)
520 uinfo->value.enumerated.item = 1;
521 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
522 return 0;
306} 523}
307 524
308static int ad1986a_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 525static int ad1983_spdif_route_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
309 struct hda_codec *codec,
310 snd_pcm_substream_t *substream)
311{ 526{
312 struct ad1986a_spec *spec = codec->spec; 527 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
313 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 528 struct ad198x_spec *spec = codec->spec;
314}
315 529
316/* 530 ucontrol->value.enumerated.item[0] = spec->spdif_route;
317 * Analog capture
318 */
319static int ad1986a_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
320 struct hda_codec *codec,
321 unsigned int stream_tag,
322 unsigned int format,
323 snd_pcm_substream_t *substream)
324{
325 snd_hda_codec_setup_stream(codec, AD1986A_ADC, stream_tag, 0, format);
326 return 0; 531 return 0;
327} 532}
328 533
329static int ad1986a_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 534static int ad1983_spdif_route_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
330 struct hda_codec *codec,
331 snd_pcm_substream_t *substream)
332{ 535{
333 snd_hda_codec_setup_stream(codec, AD1986A_ADC, 0, 0, 0); 536 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
537 struct ad198x_spec *spec = codec->spec;
538
539 if (spec->spdif_route != ucontrol->value.enumerated.item[0]) {
540 spec->spdif_route = ucontrol->value.enumerated.item[0];
541 snd_hda_codec_write(codec, spec->multiout.dig_out_nid, 0,
542 AC_VERB_SET_CONNECT_SEL, spec->spdif_route);
543 return 1;
544 }
334 return 0; 545 return 0;
335} 546}
336 547
337 548static snd_kcontrol_new_t ad1983_mixers[] = {
338/* 549 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
339 */ 550 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
340static struct hda_pcm_stream ad1986a_pcm_analog_playback = { 551 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
341 .substreams = 1, 552 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
342 .channels_min = 2, 553 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
343 .channels_max = 6, 554 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
344 .nid = AD1986A_FRONT_DAC, /* NID to query formats and rates */ 555 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
345 .ops = { 556 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
346 .open = ad1986a_playback_pcm_open, 557 HDA_CODEC_VOLUME("Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
347 .prepare = ad1986a_playback_pcm_prepare, 558 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
348 .cleanup = ad1986a_playback_pcm_cleanup 559 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
560 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
561 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT),
562 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT),
563 HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT),
564 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
565 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
566 {
567 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
568 .name = "Capture Source",
569 .info = ad198x_mux_enum_info,
570 .get = ad198x_mux_enum_get,
571 .put = ad198x_mux_enum_put,
349 }, 572 },
350}; 573 {
351 574 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
352static struct hda_pcm_stream ad1986a_pcm_analog_capture = { 575 .name = "IEC958 Playback Route",
353 .substreams = 2, 576 .info = ad1983_spdif_route_info,
354 .channels_min = 2, 577 .get = ad1983_spdif_route_get,
355 .channels_max = 2, 578 .put = ad1983_spdif_route_put,
356 .nid = AD1986A_ADC, /* NID to query formats and rates */
357 .ops = {
358 .prepare = ad1986a_capture_pcm_prepare,
359 .cleanup = ad1986a_capture_pcm_cleanup
360 }, 579 },
580 { } /* end */
361}; 581};
362 582
363static struct hda_pcm_stream ad1986a_pcm_digital_playback = { 583static struct hda_verb ad1983_init_verbs[] = {
364 .substreams = 1, 584 /* Front, HP, Mono; mute as default */
365 .channels_min = 2, 585 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
366 .channels_max = 2, 586 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
367 .nid = AD1986A_SPDIF_OUT, 587 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
368 .ops = { 588 /* Beep, PCM, Mic, Line-In: mute */
369 .open = ad1986a_dig_playback_pcm_open, 589 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
370 .close = ad1986a_dig_playback_pcm_close 590 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
371 }, 591 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
592 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
593 /* Front, HP selectors; from Mix */
594 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
595 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
596 /* Mono selector; from Mix */
597 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
598 /* Mic selector; Mic */
599 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
600 /* Line-in selector: Line-in */
601 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
602 /* Mic boost: 0dB */
603 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
604 /* Record selector: mic */
605 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
606 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
607 /* SPDIF route: PCM */
608 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
609 /* Front Pin */
610 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
611 /* HP Pin */
612 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
613 /* Mono Pin */
614 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
615 /* Mic Pin */
616 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
617 /* Line Pin */
618 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
619 { } /* end */
372}; 620};
373 621
374static int ad1986a_build_pcms(struct hda_codec *codec) 622static int patch_ad1983(struct hda_codec *codec)
375{ 623{
376 struct ad1986a_spec *spec = codec->spec; 624 struct ad198x_spec *spec;
377 struct hda_pcm *info = spec->pcm_rec;
378 625
379 codec->num_pcms = 2; 626 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
380 codec->pcm_info = info; 627 if (spec == NULL)
628 return -ENOMEM;
381 629
382 info->name = "AD1986A Analog"; 630 init_MUTEX(&spec->amp_mutex);
383 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad1986a_pcm_analog_playback; 631 codec->spec = spec;
384 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad1986a_pcm_analog_capture; 632
385 info++; 633 spec->multiout.max_channels = 2;
634 spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids);
635 spec->multiout.dac_nids = ad1983_dac_nids;
636 spec->multiout.dig_out_nid = AD1983_SPDIF_OUT;
637 spec->adc_nid = AD1983_ADC;
638 spec->input_mux = &ad1983_capture_source;
639 spec->mixers = ad1983_mixers;
640 spec->init_verbs = ad1983_init_verbs;
641 spec->spdif_route = 0;
386 642
387 info->name = "AD1986A Digital"; 643 codec->patch_ops = ad198x_patch_ops;
388 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad1986a_pcm_digital_playback;
389 644
390 return 0; 645 return 0;
391} 646}
392 647
393static void ad1986a_free(struct hda_codec *codec)
394{
395 kfree(codec->spec);
396}
397 648
398#ifdef CONFIG_PM 649/*
399static int ad1986a_resume(struct hda_codec *codec) 650 * AD1981 HD specific
400{ 651 */
401 ad1986a_init(codec);
402 snd_hda_resume_ctls(codec, ad1986a_mixers);
403 snd_hda_resume_spdif_out(codec);
404 return 0;
405}
406#endif
407 652
408static struct hda_codec_ops ad1986a_patch_ops = { 653#define AD1981_SPDIF_OUT 0x02
409 .build_controls = ad1986a_build_controls, 654#define AD1981_DAC 0x03
410 .build_pcms = ad1986a_build_pcms, 655#define AD1981_ADC 0x04
411 .init = ad1986a_init, 656
412 .free = ad1986a_free, 657static hda_nid_t ad1981_dac_nids[1] = { AD1981_DAC };
413#ifdef CONFIG_PM 658
414 .resume = ad1986a_resume, 659/* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */
415#endif 660static struct hda_input_mux ad1981_capture_source = {
661 .num_items = 7,
662 .items = {
663 { "Front Mic", 0x0 },
664 { "Line", 0x1 },
665 { "Mix", 0x2 },
666 { "Mix Mono", 0x3 },
667 { "CD", 0x4 },
668 { "Mic", 0x6 },
669 { "Aux", 0x7 },
670 },
416}; 671};
417 672
418static int patch_ad1986a(struct hda_codec *codec) 673static snd_kcontrol_new_t ad1981_mixers[] = {
674 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),
675 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),
676 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),
677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),
678 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),
679 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),
680 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),
681 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),
682 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),
683 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
684 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
685 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
686 HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
687 HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
688 HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
689 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
690 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
691 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
692 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
693 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT),
694 HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT),
695 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT),
696 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
697 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
698 {
699 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
700 .name = "Capture Source",
701 .info = ad198x_mux_enum_info,
702 .get = ad198x_mux_enum_get,
703 .put = ad198x_mux_enum_put,
704 },
705 /* identical with AD1983 */
706 {
707 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
708 .name = "IEC958 Playback Route",
709 .info = ad1983_spdif_route_info,
710 .get = ad1983_spdif_route_get,
711 .put = ad1983_spdif_route_put,
712 },
713 { } /* end */
714};
715
716static struct hda_verb ad1981_init_verbs[] = {
717 /* Front, HP, Mono; mute as default */
718 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
719 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
720 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
721 /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */
722 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
723 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
724 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
725 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
726 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
727 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
728 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
729 /* Front, HP selectors; from Mix */
730 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
731 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},
732 /* Mono selector; from Mix */
733 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},
734 /* Mic Mixer; select Front Mic */
735 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
736 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
737 /* Mic boost: 0dB */
738 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
739 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
740 /* Record selector: Front mic */
741 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
742 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
743 /* SPDIF route: PCM */
744 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},
745 /* Front Pin */
746 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
747 /* HP Pin */
748 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
749 /* Mono Pin */
750 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
751 /* Front & Rear Mic Pins */
752 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
753 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
754 /* Line Pin */
755 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
756 /* Digital Beep */
757 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
758 /* Line-Out as Input: disabled */
759 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
760 { } /* end */
761};
762
763static int patch_ad1981(struct hda_codec *codec)
419{ 764{
420 struct ad1986a_spec *spec; 765 struct ad198x_spec *spec;
421 766
422 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 767 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
423 if (spec == NULL) 768 if (spec == NULL)
@@ -426,20 +771,28 @@ static int patch_ad1986a(struct hda_codec *codec)
426 init_MUTEX(&spec->amp_mutex); 771 init_MUTEX(&spec->amp_mutex);
427 codec->spec = spec; 772 codec->spec = spec;
428 773
429 spec->multiout.max_channels = 6; 774 spec->multiout.max_channels = 2;
430 spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids); 775 spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids);
431 spec->multiout.dac_nids = ad1986a_dac_nids; 776 spec->multiout.dac_nids = ad1981_dac_nids;
432 spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT; 777 spec->multiout.dig_out_nid = AD1981_SPDIF_OUT;
778 spec->adc_nid = AD1981_ADC;
779 spec->input_mux = &ad1981_capture_source;
780 spec->mixers = ad1981_mixers;
781 spec->init_verbs = ad1981_init_verbs;
782 spec->spdif_route = 0;
433 783
434 codec->patch_ops = ad1986a_patch_ops; 784 codec->patch_ops = ad198x_patch_ops;
435 785
436 return 0; 786 return 0;
437} 787}
438 788
789
439/* 790/*
440 * patch entries 791 * patch entries
441 */ 792 */
442struct hda_codec_preset snd_hda_preset_analog[] = { 793struct hda_codec_preset snd_hda_preset_analog[] = {
794 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
795 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
443 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a }, 796 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
444 {} /* terminator */ 797 {} /* terminator */
445}; 798};
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c
index b7cc8e4bffb7..2d6e3e3d0a38 100644
--- a/sound/pci/hda/patch_cmedia.c
+++ b/sound/pci/hda/patch_cmedia.c
@@ -29,6 +29,7 @@
29#include <sound/core.h> 29#include <sound/core.h>
30#include "hda_codec.h" 30#include "hda_codec.h"
31#include "hda_local.h" 31#include "hda_local.h"
32#define NUM_PINS 11
32 33
33 34
34/* board config type */ 35/* board config type */
@@ -38,6 +39,7 @@ enum {
38 CMI_FULL, /* back 6-jack + front-panel 2-jack */ 39 CMI_FULL, /* back 6-jack + front-panel 2-jack */
39 CMI_FULL_DIG, /* back 6-jack + front-panel 2-jack + digital I/O */ 40 CMI_FULL_DIG, /* back 6-jack + front-panel 2-jack + digital I/O */
40 CMI_ALLOUT, /* back 5-jack + front-panel 2-jack + digital out */ 41 CMI_ALLOUT, /* back 5-jack + front-panel 2-jack + digital out */
42 CMI_AUTO, /* let driver guess it */
41}; 43};
42 44
43struct cmi_spec { 45struct cmi_spec {
@@ -48,6 +50,8 @@ struct cmi_spec {
48 50
49 /* playback */ 51 /* playback */
50 struct hda_multi_out multiout; 52 struct hda_multi_out multiout;
53 hda_nid_t dac_nids[4]; /* NID for each DAC */
54 int num_dacs;
51 55
52 /* capture */ 56 /* capture */
53 hda_nid_t *adc_nids; 57 hda_nid_t *adc_nids;
@@ -63,8 +67,30 @@ struct cmi_spec {
63 const struct cmi_channel_mode *channel_modes; 67 const struct cmi_channel_mode *channel_modes;
64 68
65 struct hda_pcm pcm_rec[2]; /* PCM information */ 69 struct hda_pcm pcm_rec[2]; /* PCM information */
70
71 /* pin deafault configuration */
72 hda_nid_t pin_nid[NUM_PINS];
73 unsigned int def_conf[NUM_PINS];
74 unsigned int pin_def_confs;
75
76 /* multichannel pins */
77 hda_nid_t multich_pin[4]; /* max 8-channel */
78 struct hda_verb multi_init[9]; /* 2 verbs for each pin + terminator */
66}; 79};
67 80
81/* amp values */
82#define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8))
83#define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8))
84#define AMP_OUT_MUTE 0xb080
85#define AMP_OUT_UNMUTE 0xb000
86#define AMP_OUT_ZERO 0xb000
87/* pinctl values */
88#define PIN_IN 0x20
89#define PIN_VREF80 0x24
90#define PIN_VREF50 0x21
91#define PIN_OUT 0x40
92#define PIN_HP 0xc0
93
68/* 94/*
69 * input MUX 95 * input MUX
70 */ 96 */
@@ -102,9 +128,9 @@ static int cmi_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon
102/* 3-stack / 2 channel */ 128/* 3-stack / 2 channel */
103static struct hda_verb cmi9880_ch2_init[] = { 129static struct hda_verb cmi9880_ch2_init[] = {
104 /* set line-in PIN for input */ 130 /* set line-in PIN for input */
105 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 131 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
106 /* set mic PIN for input, also enable vref */ 132 /* set mic PIN for input, also enable vref */
107 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 133 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
108 /* route front PCM (DAC1) to HP */ 134 /* route front PCM (DAC1) to HP */
109 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 135 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
110 {} 136 {}
@@ -113,9 +139,9 @@ static struct hda_verb cmi9880_ch2_init[] = {
113/* 3-stack / 6 channel */ 139/* 3-stack / 6 channel */
114static struct hda_verb cmi9880_ch6_init[] = { 140static struct hda_verb cmi9880_ch6_init[] = {
115 /* set line-in PIN for output */ 141 /* set line-in PIN for output */
116 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 142 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
117 /* set mic PIN for output */ 143 /* set mic PIN for output */
118 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 144 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
119 /* route front PCM (DAC1) to HP */ 145 /* route front PCM (DAC1) to HP */
120 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 146 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
121 {} 147 {}
@@ -124,9 +150,9 @@ static struct hda_verb cmi9880_ch6_init[] = {
124/* 3-stack+front / 8 channel */ 150/* 3-stack+front / 8 channel */
125static struct hda_verb cmi9880_ch8_init[] = { 151static struct hda_verb cmi9880_ch8_init[] = {
126 /* set line-in PIN for output */ 152 /* set line-in PIN for output */
127 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 153 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
128 /* set mic PIN for output */ 154 /* set mic PIN for output */
129 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 155 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
130 /* route rear-surround PCM (DAC4) to HP */ 156 /* route rear-surround PCM (DAC4) to HP */
131 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x03 }, 157 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x03 },
132 {} 158 {}
@@ -269,25 +295,27 @@ static hda_nid_t cmi9880_adc_nids[2] = {
269 */ 295 */
270static struct hda_verb cmi9880_basic_init[] = { 296static struct hda_verb cmi9880_basic_init[] = {
271 /* port-D for line out (rear panel) */ 297 /* port-D for line out (rear panel) */
272 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 298 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
273 /* port-E for HP out (front panel) */ 299 /* port-E for HP out (front panel) */
274 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 300 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
275 /* route front PCM to HP */ 301 /* route front PCM to HP */
276 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 302 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
277 /* port-A for surround (rear panel) */ 303 /* port-A for surround (rear panel) */
278 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 304 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
279 /* port-G for CLFE (rear panel) */ 305 /* port-G for CLFE (rear panel) */
280 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 306 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
307 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x02 },
281 /* port-H for side (rear panel) */ 308 /* port-H for side (rear panel) */
282 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 309 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
310 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x01 },
283 /* port-C for line-in (rear panel) */ 311 /* port-C for line-in (rear panel) */
284 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 312 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
285 /* port-B for mic-in (rear panel) with vref */ 313 /* port-B for mic-in (rear panel) with vref */
286 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 314 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
287 /* port-F for mic-in (front panel) with vref */ 315 /* port-F for mic-in (front panel) with vref */
288 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 316 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
289 /* CD-in */ 317 /* CD-in */
290 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 318 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
291 /* route front mic to ADC1/2 */ 319 /* route front mic to ADC1/2 */
292 { 0x08, AC_VERB_SET_CONNECT_SEL, 0x05 }, 320 { 0x08, AC_VERB_SET_CONNECT_SEL, 0x05 },
293 { 0x09, AC_VERB_SET_CONNECT_SEL, 0x05 }, 321 { 0x09, AC_VERB_SET_CONNECT_SEL, 0x05 },
@@ -296,23 +324,27 @@ static struct hda_verb cmi9880_basic_init[] = {
296 324
297static struct hda_verb cmi9880_allout_init[] = { 325static struct hda_verb cmi9880_allout_init[] = {
298 /* port-D for line out (rear panel) */ 326 /* port-D for line out (rear panel) */
299 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 327 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
300 /* port-E for HP out (front panel) */ 328 /* port-E for HP out (front panel) */
301 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 329 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
302 /* route front PCM to HP */ 330 /* route front PCM to HP */
303 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 331 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
304 /* port-A for side (rear panel) */ 332 /* port-A for side (rear panel) */
305 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 333 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
306 /* port-G for CLFE (rear panel) */ 334 /* port-G for CLFE (rear panel) */
307 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 335 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
336 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x02 },
337 /* port-H for side (rear panel) */
338 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
339 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x01 },
308 /* port-C for surround (rear panel) */ 340 /* port-C for surround (rear panel) */
309 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 341 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
310 /* port-B for mic-in (rear panel) with vref */ 342 /* port-B for mic-in (rear panel) with vref */
311 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 343 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
312 /* port-F for mic-in (front panel) with vref */ 344 /* port-F for mic-in (front panel) with vref */
313 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 345 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
314 /* CD-in */ 346 /* CD-in */
315 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 347 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
316 /* route front mic to ADC1/2 */ 348 /* route front mic to ADC1/2 */
317 { 0x08, AC_VERB_SET_CONNECT_SEL, 0x05 }, 349 { 0x08, AC_VERB_SET_CONNECT_SEL, 0x05 },
318 { 0x09, AC_VERB_SET_CONNECT_SEL, 0x05 }, 350 { 0x09, AC_VERB_SET_CONNECT_SEL, 0x05 },
@@ -347,6 +379,81 @@ static int cmi9880_build_controls(struct hda_codec *codec)
347 return 0; 379 return 0;
348} 380}
349 381
382/* fill in the multi_dac_nids table, which will decide
383 which audio widget to use for each channel */
384static int cmi9880_fill_multi_dac_nids(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
385{
386 struct cmi_spec *spec = codec->spec;
387 hda_nid_t nid;
388 int assigned[4];
389 int i, j;
390
391 /* clear the table, only one c-media dac assumed here */
392 memset(spec->dac_nids, 0, sizeof(spec->dac_nids));
393 memset(assigned, 0, sizeof(assigned));
394 /* check the pins we found */
395 for (i = 0; i < cfg->line_outs; i++) {
396 nid = cfg->line_out_pins[i];
397 /* nid 0x0b~0x0e is hardwired to audio widget 0x3~0x6 */
398 if (nid >= 0x0b && nid <= 0x0e) {
399 spec->dac_nids[i] = (nid - 0x0b) + 0x03;
400 assigned[nid - 0x0b] = 1;
401 }
402 }
403 /* left pin can be connect to any audio widget */
404 for (i = 0; i < cfg->line_outs; i++) {
405 nid = cfg->line_out_pins[i];
406 if (nid <= 0x0e)
407 continue;
408 /* search for an empty channel */
409 for (j = 0; j < cfg->line_outs; j++) {
410 if (! assigned[j]) {
411 spec->dac_nids[i] = i + 0x03;
412 assigned[j] = 1;
413 break;
414 }
415 }
416 }
417 spec->num_dacs = cfg->line_outs;
418 return 0;
419}
420
421/* create multi_init table, which is used for multichannel initialization */
422static int cmi9880_fill_multi_init(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
423{
424 struct cmi_spec *spec = codec->spec;
425 hda_nid_t nid;
426 int i, j, k, len;
427
428 /* clear the table, only one c-media dac assumed here */
429 memset(spec->multi_init, 0, sizeof(spec->multi_init));
430 for (j = 0, i = 0; i < cfg->line_outs; i++) {
431 hda_nid_t conn[4];
432 nid = cfg->line_out_pins[i];
433 /* set as output */
434 spec->multi_init[j].nid = nid;
435 spec->multi_init[j].verb = AC_VERB_SET_PIN_WIDGET_CONTROL;
436 spec->multi_init[j].param = PIN_OUT;
437 j++;
438 if (nid > 0x0e) {
439 /* set connection */
440 spec->multi_init[j].nid = nid;
441 spec->multi_init[j].verb = AC_VERB_SET_CONNECT_SEL;
442 spec->multi_init[j].param = 0;
443 /* find the index in connect list */
444 len = snd_hda_get_connections(codec, nid, conn, 4);
445 for (k = 0; k < len; k++)
446 if (conn[k] == spec->dac_nids[i]) {
447 spec->multi_init[j].param = j;
448 break;
449 }
450 j++;
451 break;
452 }
453 }
454 return 0;
455}
456
350static int cmi9880_init(struct hda_codec *codec) 457static int cmi9880_init(struct hda_codec *codec)
351{ 458{
352 struct cmi_spec *spec = codec->spec; 459 struct cmi_spec *spec = codec->spec;
@@ -354,6 +461,8 @@ static int cmi9880_init(struct hda_codec *codec)
354 snd_hda_sequence_write(codec, cmi9880_allout_init); 461 snd_hda_sequence_write(codec, cmi9880_allout_init);
355 else 462 else
356 snd_hda_sequence_write(codec, cmi9880_basic_init); 463 snd_hda_sequence_write(codec, cmi9880_basic_init);
464 if (spec->board_config == CMI_AUTO)
465 snd_hda_sequence_write(codec, spec->multi_init);
357 return 0; 466 return 0;
358} 467}
359 468
@@ -540,6 +649,7 @@ static struct hda_board_config cmi9880_cfg_tbl[] = {
540 { .modelname = "full", .config = CMI_FULL }, 649 { .modelname = "full", .config = CMI_FULL },
541 { .modelname = "full_dig", .config = CMI_FULL_DIG }, 650 { .modelname = "full_dig", .config = CMI_FULL_DIG },
542 { .modelname = "allout", .config = CMI_ALLOUT }, 651 { .modelname = "allout", .config = CMI_ALLOUT },
652 { .modelname = "auto", .config = CMI_AUTO },
543 {} /* terminator */ 653 {} /* terminator */
544}; 654};
545 655
@@ -564,10 +674,14 @@ static int patch_cmi9880(struct hda_codec *codec)
564 codec->spec = spec; 674 codec->spec = spec;
565 spec->board_config = snd_hda_check_board_config(codec, cmi9880_cfg_tbl); 675 spec->board_config = snd_hda_check_board_config(codec, cmi9880_cfg_tbl);
566 if (spec->board_config < 0) { 676 if (spec->board_config < 0) {
567 snd_printd(KERN_INFO "hda_codec: Unknown model for CMI9880\n"); 677 snd_printdd(KERN_INFO "hda_codec: Unknown model for CMI9880\n");
568 spec->board_config = CMI_FULL_DIG; /* try everything */ 678 spec->board_config = CMI_AUTO; /* try everything */
569 } 679 }
570 680
681 /* copy default DAC NIDs */
682 memcpy(spec->dac_nids, cmi9880_dac_nids, sizeof(spec->dac_nids));
683 spec->num_dacs = 4;
684
571 switch (spec->board_config) { 685 switch (spec->board_config) {
572 case CMI_MINIMAL: 686 case CMI_MINIMAL:
573 case CMI_MIN_FP: 687 case CMI_MIN_FP:
@@ -599,10 +713,58 @@ static int patch_cmi9880(struct hda_codec *codec)
599 spec->input_mux = &cmi9880_no_line_mux; 713 spec->input_mux = &cmi9880_no_line_mux;
600 spec->multiout.dig_out_nid = CMI_DIG_OUT_NID; 714 spec->multiout.dig_out_nid = CMI_DIG_OUT_NID;
601 break; 715 break;
716 case CMI_AUTO:
717 {
718 unsigned int port_e, port_f, port_g, port_h;
719 unsigned int port_spdifi, port_spdifo;
720 struct auto_pin_cfg cfg;
721
722 /* collect pin default configuration */
723 port_e = snd_hda_codec_read(codec, 0x0f, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
724 port_f = snd_hda_codec_read(codec, 0x10, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
725 spec->front_panel = 1;
726 if (get_defcfg_connect(port_e) == AC_JACK_PORT_NONE ||
727 get_defcfg_connect(port_f) == AC_JACK_PORT_NONE) {
728 port_g = snd_hda_codec_read(codec, 0x1f, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
729 port_h = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
730 spec->surr_switch = 1;
731 /* no front panel */
732 if (get_defcfg_connect(port_g) == AC_JACK_PORT_NONE ||
733 get_defcfg_connect(port_h) == AC_JACK_PORT_NONE) {
734 /* no optional rear panel */
735 spec->board_config = CMI_MINIMAL;
736 spec->front_panel = 0;
737 spec->num_ch_modes = 2;
738 } else {
739 spec->board_config = CMI_MIN_FP;
740 spec->num_ch_modes = 3;
741 }
742 spec->channel_modes = cmi9880_channel_modes;
743 spec->input_mux = &cmi9880_basic_mux;
744 spec->multiout.max_channels = cmi9880_channel_modes[0].channels;
745 } else {
746 spec->input_mux = &cmi9880_basic_mux;
747 port_spdifi = snd_hda_codec_read(codec, 0x13, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
748 port_spdifo = snd_hda_codec_read(codec, 0x12, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
749 if (get_defcfg_connect(port_spdifo) != AC_JACK_PORT_NONE)
750 spec->multiout.dig_out_nid = CMI_DIG_OUT_NID;
751 if (get_defcfg_connect(port_spdifi) != AC_JACK_PORT_NONE)
752 spec->dig_in_nid = CMI_DIG_IN_NID;
753 spec->multiout.max_channels = 8;
754 }
755 snd_hda_parse_pin_def_config(codec, &cfg);
756 if (cfg.line_outs) {
757 spec->multiout.max_channels = cfg.line_outs * 2;
758 cmi9880_fill_multi_dac_nids(codec, &cfg);
759 cmi9880_fill_multi_init(codec, &cfg);
760 } else
761 snd_printd("patch_cmedia: cannot detect association in defcfg\n");
762 break;
763 }
602 } 764 }
603 765
604 spec->multiout.num_dacs = 4; 766 spec->multiout.num_dacs = spec->num_dacs;
605 spec->multiout.dac_nids = cmi9880_dac_nids; 767 spec->multiout.dac_nids = spec->dac_nids;
606 768
607 spec->adc_nids = cmi9880_adc_nids; 769 spec->adc_nids = cmi9880_adc_nids;
608 770
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 17c5062423ae..9edd558d6bd3 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -33,38 +33,73 @@
33 33
34/* ALC880 board config type */ 34/* ALC880 board config type */
35enum { 35enum {
36 ALC880_MINIMAL,
37 ALC880_3ST, 36 ALC880_3ST,
38 ALC880_3ST_DIG, 37 ALC880_3ST_DIG,
39 ALC880_5ST, 38 ALC880_5ST,
40 ALC880_5ST_DIG, 39 ALC880_5ST_DIG,
41 ALC880_W810, 40 ALC880_W810,
41 ALC880_Z71V,
42 ALC880_AUTO,
43 ALC880_6ST_DIG,
44 ALC880_F1734,
45 ALC880_ASUS,
46 ALC880_ASUS_DIG,
47 ALC880_ASUS_W1V,
48 ALC880_UNIWILL_DIG,
49#ifdef CONFIG_SND_DEBUG
50 ALC880_TEST,
51#endif
52 ALC880_MODEL_LAST /* last tag */
53};
54
55/* ALC260 models */
56enum {
57 ALC260_BASIC,
58 ALC260_HP,
59 ALC260_MODEL_LAST /* last tag */
42}; 60};
43 61
62/* amp values */
63#define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8))
64#define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8))
65#define AMP_OUT_MUTE 0xb080
66#define AMP_OUT_UNMUTE 0xb000
67#define AMP_OUT_ZERO 0xb000
68/* pinctl values */
69#define PIN_IN 0x20
70#define PIN_VREF80 0x24
71#define PIN_VREF50 0x21
72#define PIN_OUT 0x40
73#define PIN_HP 0xc0
74
44struct alc_spec { 75struct alc_spec {
45 /* codec parameterization */ 76 /* codec parameterization */
46 unsigned int front_panel: 1; 77 snd_kcontrol_new_t *mixers[3]; /* mixer arrays */
47
48 snd_kcontrol_new_t* mixers[2];
49 unsigned int num_mixers; 78 unsigned int num_mixers;
50 79
51 struct hda_verb *init_verbs; 80 const struct hda_verb *init_verbs[3]; /* initialization verbs
81 * don't forget NULL termination!
82 */
83 unsigned int num_init_verbs;
52 84
53 char* stream_name_analog; 85 char *stream_name_analog; /* analog PCM stream */
54 struct hda_pcm_stream *stream_analog_playback; 86 struct hda_pcm_stream *stream_analog_playback;
55 struct hda_pcm_stream *stream_analog_capture; 87 struct hda_pcm_stream *stream_analog_capture;
56 88
57 char* stream_name_digital; 89 char *stream_name_digital; /* digital PCM stream */
58 struct hda_pcm_stream *stream_digital_playback; 90 struct hda_pcm_stream *stream_digital_playback;
59 struct hda_pcm_stream *stream_digital_capture; 91 struct hda_pcm_stream *stream_digital_capture;
60 92
61 /* playback */ 93 /* playback */
62 struct hda_multi_out multiout; 94 struct hda_multi_out multiout; /* playback set-up
95 * max_channels, dacs must be set
96 * dig_out_nid and hp_nid are optional
97 */
63 98
64 /* capture */ 99 /* capture */
65 unsigned int num_adc_nids; 100 unsigned int num_adc_nids;
66 hda_nid_t *adc_nids; 101 hda_nid_t *adc_nids;
67 hda_nid_t dig_in_nid; 102 hda_nid_t dig_in_nid; /* digital-in NID; optional */
68 103
69 /* capture source */ 104 /* capture source */
70 const struct hda_input_mux *input_mux; 105 const struct hda_input_mux *input_mux;
@@ -75,61 +110,17 @@ struct alc_spec {
75 int num_channel_mode; 110 int num_channel_mode;
76 111
77 /* PCM information */ 112 /* PCM information */
78 struct hda_pcm pcm_rec[2]; 113 struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */
79};
80
81/* DAC/ADC assignment */
82
83static hda_nid_t alc880_dac_nids[4] = {
84 /* front, rear, clfe, rear_surr */
85 0x02, 0x05, 0x04, 0x03
86};
87
88static hda_nid_t alc880_w810_dac_nids[3] = {
89 /* front, rear/surround, clfe */
90 0x02, 0x03, 0x04
91};
92
93static hda_nid_t alc880_adc_nids[3] = {
94 /* ADC0-2 */
95 0x07, 0x08, 0x09,
96};
97
98#define ALC880_DIGOUT_NID 0x06
99#define ALC880_DIGIN_NID 0x0a
100 114
101static hda_nid_t alc260_dac_nids[1] = { 115 struct semaphore bind_mutex; /* for bound controls */
102 /* front */
103 0x02,
104};
105 116
106static hda_nid_t alc260_adc_nids[2] = { 117 /* dynamic controls, init_verbs and input_mux */
107 /* ADC0-1 */ 118 struct auto_pin_cfg autocfg;
108 0x04, 0x05, 119 unsigned int num_kctl_alloc, num_kctl_used;
120 snd_kcontrol_new_t *kctl_alloc;
121 struct hda_input_mux private_imux;
109}; 122};
110 123
111#define ALC260_DIGOUT_NID 0x03
112#define ALC260_DIGIN_NID 0x06
113
114static struct hda_input_mux alc880_capture_source = {
115 .num_items = 4,
116 .items = {
117 { "Mic", 0x0 },
118 { "Front Mic", 0x3 },
119 { "Line", 0x2 },
120 { "CD", 0x4 },
121 },
122};
123
124static struct hda_input_mux alc260_capture_source = {
125 .num_items = 4,
126 .items = {
127 { "Mic", 0x0 },
128 { "Front Mic", 0x1 },
129 { "Line", 0x2 },
130 { "CD", 0x4 },
131 },
132};
133 124
134/* 125/*
135 * input MUX handling 126 * input MUX handling
@@ -160,6 +151,7 @@ static int alc_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon
160 spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]); 151 spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
161} 152}
162 153
154
163/* 155/*
164 * channel mode setting 156 * channel mode setting
165 */ 157 */
@@ -168,135 +160,18 @@ struct alc_channel_mode {
168 const struct hda_verb *sequence; 160 const struct hda_verb *sequence;
169}; 161};
170 162
171
172/*
173 * channel source setting (2/6 channel selection for 3-stack)
174 */
175
176/*
177 * set the path ways for 2 channel output
178 * need to set the codec line out and mic 1 pin widgets to inputs
179 */
180static struct hda_verb alc880_threestack_ch2_init[] = {
181 /* set pin widget 1Ah (line in) for input */
182 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
183 /* set pin widget 18h (mic1) for input, for mic also enable the vref */
184 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
185 /* mute the output for Line In PW */
186 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
187 /* mute for Mic1 PW */
188 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
189 { } /* end */
190};
191
192/*
193 * 6ch mode
194 * need to set the codec line out and mic 1 pin widgets to outputs
195 */
196static struct hda_verb alc880_threestack_ch6_init[] = {
197 /* set pin widget 1Ah (line in) for output */
198 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
199 /* set pin widget 18h (mic1) for output */
200 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
201 /* unmute the output for Line In PW */
202 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
203 /* unmute for Mic1 PW */
204 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
205 /* for rear channel output using Line In 1
206 * set select widget connection (nid = 0x12) - to summer node
207 * for rear NID = 0x0f...offset 3 in connection list
208 */
209 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x3 },
210 /* for Mic1 - retask for center/lfe */
211 /* set select widget connection (nid = 0x10) - to summer node for
212 * front CLFE NID = 0x0e...offset 2 in connection list
213 */
214 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x2 },
215 { } /* end */
216};
217
218static struct alc_channel_mode alc880_threestack_modes[2] = {
219 { 2, alc880_threestack_ch2_init },
220 { 6, alc880_threestack_ch6_init },
221};
222
223
224/*
225 * channel source setting (6/8 channel selection for 5-stack)
226 */
227
228/* set the path ways for 6 channel output
229 * need to set the codec line out and mic 1 pin widgets to inputs
230 */
231static struct hda_verb alc880_fivestack_ch6_init[] = {
232 /* set pin widget 1Ah (line in) for input */
233 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
234 /* mute the output for Line In PW */
235 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
236 { } /* end */
237};
238
239/* need to set the codec line out and mic 1 pin widgets to outputs */
240static struct hda_verb alc880_fivestack_ch8_init[] = {
241 /* set pin widget 1Ah (line in) for output */
242 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
243 /* unmute the output for Line In PW */
244 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 },
245 /* output for surround channel output using Line In 1 */
246 /* set select widget connection (nid = 0x12) - to summer node
247 * for surr_rear NID = 0x0d...offset 1 in connection list
248 */
249 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x1 },
250 { } /* end */
251};
252
253static struct alc_channel_mode alc880_fivestack_modes[2] = {
254 { 6, alc880_fivestack_ch6_init },
255 { 8, alc880_fivestack_ch8_init },
256};
257
258/*
259 * channel source setting for W810 system
260 *
261 * W810 has rear IO for:
262 * Front (DAC 02)
263 * Surround (DAC 03)
264 * Center/LFE (DAC 04)
265 * Digital out (06)
266 *
267 * The system also has a pair of internal speakers, and a headphone jack.
268 * These are both connected to Line2 on the codec, hence to DAC 02.
269 *
270 * There is a variable resistor to control the speaker or headphone
271 * volume. This is a hardware-only device without a software API.
272 *
273 * Plugging headphones in will disable the internal speakers. This is
274 * implemented in hardware, not via the driver using jack sense. In
275 * a similar fashion, plugging into the rear socket marked "front" will
276 * disable both the speakers and headphones.
277 *
278 * For input, there's a microphone jack, and an "audio in" jack.
279 * These may not do anything useful with this driver yet, because I
280 * haven't setup any initialization verbs for these yet...
281 */
282
283static struct alc_channel_mode alc880_w810_modes[1] = {
284 { 6, NULL }
285};
286
287/*
288 */
289static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) 163static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
290{ 164{
291 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 165 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
292 struct alc_spec *spec = codec->spec; 166 struct alc_spec *spec = codec->spec;
167 int items = kcontrol->private_value ? (int)kcontrol->private_value : 2;
293 168
294 snd_assert(spec->channel_mode, return -ENXIO); 169 snd_assert(spec->channel_mode, return -ENXIO);
295 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 170 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
296 uinfo->count = 1; 171 uinfo->count = 1;
297 uinfo->value.enumerated.items = 2; 172 uinfo->value.enumerated.items = items;
298 if (uinfo->value.enumerated.item >= 2) 173 if (uinfo->value.enumerated.item >= items)
299 uinfo->value.enumerated.item = 1; 174 uinfo->value.enumerated.item = items - 1;
300 sprintf(uinfo->value.enumerated.name, "%dch", 175 sprintf(uinfo->value.enumerated.name, "%dch",
301 spec->channel_mode[uinfo->value.enumerated.item].channels); 176 spec->channel_mode[uinfo->value.enumerated.item].channels);
302 return 0; 177 return 0;
@@ -306,10 +181,16 @@ static int alc880_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uc
306{ 181{
307 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 182 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
308 struct alc_spec *spec = codec->spec; 183 struct alc_spec *spec = codec->spec;
184 int items = kcontrol->private_value ? (int)kcontrol->private_value : 2;
185 int i;
309 186
310 snd_assert(spec->channel_mode, return -ENXIO); 187 snd_assert(spec->channel_mode, return -ENXIO);
311 ucontrol->value.enumerated.item[0] = 188 for (i = 0; i < items; i++) {
312 (spec->multiout.max_channels == spec->channel_mode[0].channels) ? 0 : 1; 189 if (spec->multiout.max_channels == spec->channel_mode[i].channels) {
190 ucontrol->value.enumerated.item[0] = i;
191 break;
192 }
193 }
313 return 0; 194 return 0;
314} 195}
315 196
@@ -335,21 +216,149 @@ static int alc880_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uc
335 216
336 217
337/* 218/*
219 * bound volume controls
220 *
221 * bind multiple volumes (# indices, from 0)
222 */
223
224#define AMP_VAL_IDX_SHIFT 19
225#define AMP_VAL_IDX_MASK (0x0f<<19)
226
227static int alc_bind_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
228{
229 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
230 struct alc_spec *spec = codec->spec;
231 unsigned long pval;
232
233 down(&spec->bind_mutex);
234 pval = kcontrol->private_value;
235 kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
236 snd_hda_mixer_amp_switch_info(kcontrol, uinfo);
237 kcontrol->private_value = pval;
238 up(&spec->bind_mutex);
239 return 0;
240}
241
242static int alc_bind_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
243{
244 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
245 struct alc_spec *spec = codec->spec;
246 unsigned long pval;
247
248 down(&spec->bind_mutex);
249 pval = kcontrol->private_value;
250 kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
251 snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
252 kcontrol->private_value = pval;
253 up(&spec->bind_mutex);
254 return 0;
255}
256
257static int alc_bind_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
258{
259 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
260 struct alc_spec *spec = codec->spec;
261 unsigned long pval;
262 int i, indices, change = 0;
263
264 down(&spec->bind_mutex);
265 pval = kcontrol->private_value;
266 indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT;
267 for (i = 0; i < indices; i++) {
268 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | (i << AMP_VAL_IDX_SHIFT);
269 change |= snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
270 }
271 kcontrol->private_value = pval;
272 up(&spec->bind_mutex);
273 return change;
274}
275
276#define ALC_BIND_MUTE_MONO(xname, nid, channel, indices, direction) \
277 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
278 .info = alc_bind_switch_info, \
279 .get = alc_bind_switch_get, \
280 .put = alc_bind_switch_put, \
281 .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, indices, direction) }
282
283#define ALC_BIND_MUTE(xname,nid,indices,dir) ALC_BIND_MUTE_MONO(xname,nid,3,indices,dir)
284
285
286/*
287 * ALC880 3-stack model
288 *
289 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
290 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
291 * HP = 0x19
338 */ 292 */
339 293
340/* 3-stack mode 294static hda_nid_t alc880_dac_nids[4] = {
341 * Pin assignment: Front=0x14, Line-In/Rear=0x1a, Mic/CLFE=0x18, F-Mic=0x1b 295 /* front, rear, clfe, rear_surr */
342 * HP=0x19 296 0x02, 0x05, 0x04, 0x03
297};
298
299static hda_nid_t alc880_adc_nids[3] = {
300 /* ADC0-2 */
301 0x07, 0x08, 0x09,
302};
303
304/* The datasheet says the node 0x07 is connected from inputs,
305 * but it shows zero connection in the real implementation on some devices.
343 */ 306 */
344static snd_kcontrol_new_t alc880_base_mixer[] = { 307static hda_nid_t alc880_adc_nids_alt[2] = {
308 /* ADC1-2 */
309 0x08, 0x09,
310};
311
312#define ALC880_DIGOUT_NID 0x06
313#define ALC880_DIGIN_NID 0x0a
314
315static struct hda_input_mux alc880_capture_source = {
316 .num_items = 4,
317 .items = {
318 { "Mic", 0x0 },
319 { "Front Mic", 0x3 },
320 { "Line", 0x2 },
321 { "CD", 0x4 },
322 },
323};
324
325/* channel source setting (2/6 channel selection for 3-stack) */
326/* 2ch mode */
327static struct hda_verb alc880_threestack_ch2_init[] = {
328 /* set line-in to input, mute it */
329 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
330 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
331 /* set mic-in to input vref 80%, mute it */
332 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
333 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
334 { } /* end */
335};
336
337/* 6ch mode */
338static struct hda_verb alc880_threestack_ch6_init[] = {
339 /* set line-in to output, unmute it */
340 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
341 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
342 /* set mic-in to output, unmute it */
343 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
344 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
345 { } /* end */
346};
347
348static struct alc_channel_mode alc880_threestack_modes[2] = {
349 { 2, alc880_threestack_ch2_init },
350 { 6, alc880_threestack_ch6_init },
351};
352
353static snd_kcontrol_new_t alc880_three_stack_mixer[] = {
345 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 354 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
346 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 355 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
347 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 356 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
348 HDA_CODEC_MUTE("Surround Playback Switch", 0x1a, 0x0, HDA_OUTPUT), 357 ALC_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
349 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 358 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
350 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 359 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
351 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x18, 1, 0x0, HDA_OUTPUT), 360 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
352 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x18, 2, 0x0, HDA_OUTPUT), 361 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
353 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 362 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
354 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 363 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
355 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 364 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
@@ -360,12 +369,25 @@ static snd_kcontrol_new_t alc880_base_mixer[] = {
360 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), 369 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
361 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 370 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
362 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 371 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
363 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
364 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), 372 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
373 {
374 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
375 .name = "Channel Mode",
376 .info = alc880_ch_mode_info,
377 .get = alc880_ch_mode_get,
378 .put = alc880_ch_mode_put,
379 },
380 { } /* end */
381};
382
383/* capture mixer elements */
384static snd_kcontrol_new_t alc880_capture_mixer[] = {
365 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), 385 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
366 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), 386 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
367 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), 387 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
368 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), 388 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
389 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
390 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
369 { 391 {
370 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 392 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
371 /* The multiple "Capture Source" controls confuse alsamixer 393 /* The multiple "Capture Source" controls confuse alsamixer
@@ -374,65 +396,125 @@ static snd_kcontrol_new_t alc880_base_mixer[] = {
374 */ 396 */
375 /* .name = "Capture Source", */ 397 /* .name = "Capture Source", */
376 .name = "Input Source", 398 .name = "Input Source",
377 .count = 2, 399 .count = 3,
378 .info = alc_mux_enum_info, 400 .info = alc_mux_enum_info,
379 .get = alc_mux_enum_get, 401 .get = alc_mux_enum_get,
380 .put = alc_mux_enum_put, 402 .put = alc_mux_enum_put,
381 }, 403 },
404 { } /* end */
405};
406
407/* capture mixer elements (in case NID 0x07 not available) */
408static snd_kcontrol_new_t alc880_capture_alt_mixer[] = {
409 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
410 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
411 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
412 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
382 { 413 {
383 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
384 .name = "Channel Mode", 415 /* The multiple "Capture Source" controls confuse alsamixer
385 .info = alc880_ch_mode_info, 416 * So call somewhat different..
386 .get = alc880_ch_mode_get, 417 * FIXME: the controls appear in the "playback" view!
387 .put = alc880_ch_mode_put, 418 */
419 /* .name = "Capture Source", */
420 .name = "Input Source",
421 .count = 2,
422 .info = alc_mux_enum_info,
423 .get = alc_mux_enum_get,
424 .put = alc_mux_enum_put,
388 }, 425 },
389 { } /* end */ 426 { } /* end */
390}; 427};
391 428
392/* 5-stack mode 429
393 * Pin assignment: Front=0x14, Rear=0x17, CLFE=0x16 430
394 * Line-In/Side=0x1a, Mic=0x18, F-Mic=0x1b, HP=0x19 431/*
432 * ALC880 5-stack model
433 *
434 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
435 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
436 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
395 */ 437 */
438
439/* additional mixers to alc880_three_stack_mixer */
396static snd_kcontrol_new_t alc880_five_stack_mixer[] = { 440static snd_kcontrol_new_t alc880_five_stack_mixer[] = {
441 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
442 ALC_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
443 { } /* end */
444};
445
446/* channel source setting (6/8 channel selection for 5-stack) */
447/* 6ch mode */
448static struct hda_verb alc880_fivestack_ch6_init[] = {
449 /* set line-in to input, mute it */
450 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
451 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
452 { } /* end */
453};
454
455/* 8ch mode */
456static struct hda_verb alc880_fivestack_ch8_init[] = {
457 /* set line-in to output, unmute it */
458 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
459 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
460 { } /* end */
461};
462
463static struct alc_channel_mode alc880_fivestack_modes[2] = {
464 { 6, alc880_fivestack_ch6_init },
465 { 8, alc880_fivestack_ch8_init },
466};
467
468
469/*
470 * ALC880 6-stack model
471 *
472 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
473 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
474 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
475 */
476
477static hda_nid_t alc880_6st_dac_nids[4] = {
478 /* front, rear, clfe, rear_surr */
479 0x02, 0x03, 0x04, 0x05
480};
481
482static struct hda_input_mux alc880_6stack_capture_source = {
483 .num_items = 4,
484 .items = {
485 { "Mic", 0x0 },
486 { "Front Mic", 0x1 },
487 { "Line", 0x2 },
488 { "CD", 0x4 },
489 },
490};
491
492/* fixed 8-channels */
493static struct alc_channel_mode alc880_sixstack_modes[1] = {
494 { 8, NULL },
495};
496
497static snd_kcontrol_new_t alc880_six_stack_mixer[] = {
397 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 498 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
398 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 499 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
399 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 500 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
400 HDA_CODEC_MUTE("Surround Playback Switch", 0x17, 0x0, HDA_OUTPUT), 501 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
401 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 502 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
402 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 503 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
403 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT), 504 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
404 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), 505 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
405 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 506 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
406 HDA_CODEC_MUTE("Side Playback Switch", 0x1a, 0x0, HDA_OUTPUT), 507 ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
407 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 508 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
408 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 509 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
409 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 510 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
410 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 511 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
411 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 512 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
412 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 513 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
413 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), 514 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
414 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), 515 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
415 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 516 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
416 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 517 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
417 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
418 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
419 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
420 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
421 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
422 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
423 {
424 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
425 /* The multiple "Capture Source" controls confuse alsamixer
426 * So call somewhat different..
427 * FIXME: the controls appear in the "playback" view!
428 */
429 /* .name = "Capture Source", */
430 .name = "Input Source",
431 .count = 2,
432 .info = alc_mux_enum_info,
433 .get = alc_mux_enum_get,
434 .put = alc_mux_enum_put,
435 },
436 { 518 {
437 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 519 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
438 .name = "Channel Mode", 520 .name = "Channel Mode",
@@ -443,39 +525,169 @@ static snd_kcontrol_new_t alc880_five_stack_mixer[] = {
443 { } /* end */ 525 { } /* end */
444}; 526};
445 527
528
529/*
530 * ALC880 W810 model
531 *
532 * W810 has rear IO for:
533 * Front (DAC 02)
534 * Surround (DAC 03)
535 * Center/LFE (DAC 04)
536 * Digital out (06)
537 *
538 * The system also has a pair of internal speakers, and a headphone jack.
539 * These are both connected to Line2 on the codec, hence to DAC 02.
540 *
541 * There is a variable resistor to control the speaker or headphone
542 * volume. This is a hardware-only device without a software API.
543 *
544 * Plugging headphones in will disable the internal speakers. This is
545 * implemented in hardware, not via the driver using jack sense. In
546 * a similar fashion, plugging into the rear socket marked "front" will
547 * disable both the speakers and headphones.
548 *
549 * For input, there's a microphone jack, and an "audio in" jack.
550 * These may not do anything useful with this driver yet, because I
551 * haven't setup any initialization verbs for these yet...
552 */
553
554static hda_nid_t alc880_w810_dac_nids[3] = {
555 /* front, rear/surround, clfe */
556 0x02, 0x03, 0x04
557};
558
559/* fixed 6 channels */
560static struct alc_channel_mode alc880_w810_modes[1] = {
561 { 6, NULL }
562};
563
564/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
446static snd_kcontrol_new_t alc880_w810_base_mixer[] = { 565static snd_kcontrol_new_t alc880_w810_base_mixer[] = {
447 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 566 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
448 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 567 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
449 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 568 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
450 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT), 569 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
451 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 570 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
452 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 571 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
453 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT), 572 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
454 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), 573 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
455 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 574 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
456 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), 575 { } /* end */
457 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), 576};
458 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), 577
459 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), 578
460 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), 579/*
461 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), 580 * Z710V model
581 *
582 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
583 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
584 */
585
586static hda_nid_t alc880_z71v_dac_nids[1] = {
587 0x02
588};
589#define ALC880_Z71V_HP_DAC 0x03
590
591/* fixed 2 channels */
592static struct alc_channel_mode alc880_2_jack_modes[1] = {
593 { 2, NULL }
594};
595
596static snd_kcontrol_new_t alc880_z71v_mixer[] = {
597 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
598 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
599 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
600 ALC_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
601 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
602 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
605 { } /* end */
606};
607
608
609/* FIXME! */
610/*
611 * ALC880 F1734 model
612 *
613 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
614 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
615 */
616
617static hda_nid_t alc880_f1734_dac_nids[1] = {
618 0x03
619};
620#define ALC880_F1734_HP_DAC 0x02
621
622static snd_kcontrol_new_t alc880_f1734_mixer[] = {
623 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
624 ALC_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
625 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
626 ALC_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
627 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
628 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
629 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
630 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
631 { } /* end */
632};
633
634
635/* FIXME! */
636/*
637 * ALC880 ASUS model
638 *
639 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
640 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
641 * Mic = 0x18, Line = 0x1a
642 */
643
644#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
645#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
646
647static snd_kcontrol_new_t alc880_asus_mixer[] = {
648 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
649 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
650 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
651 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
652 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
653 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
654 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
655 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
656 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
657 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
658 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
659 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
660 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
661 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
462 { 662 {
463 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 663 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
464 /* The multiple "Capture Source" controls confuse alsamixer 664 .name = "Channel Mode",
465 * So call somewhat different.. 665 .info = alc880_ch_mode_info,
466 * FIXME: the controls appear in the "playback" view! 666 .get = alc880_ch_mode_get,
467 */ 667 .put = alc880_ch_mode_put,
468 /* .name = "Capture Source", */
469 .name = "Input Source",
470 .count = 3,
471 .info = alc_mux_enum_info,
472 .get = alc_mux_enum_get,
473 .put = alc_mux_enum_put,
474 }, 668 },
475 { } /* end */ 669 { } /* end */
476}; 670};
477 671
672/* FIXME! */
478/* 673/*
674 * ALC880 ASUS W1V model
675 *
676 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
677 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
678 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
679 */
680
681/* additional mixers to alc880_asus_mixer */
682static snd_kcontrol_new_t alc880_asus_w1v_mixer[] = {
683 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
684 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
685 { } /* end */
686};
687
688
689/*
690 * build control elements
479 */ 691 */
480static int alc_build_controls(struct hda_codec *codec) 692static int alc_build_controls(struct hda_codec *codec)
481{ 693{
@@ -502,227 +714,297 @@ static int alc_build_controls(struct hda_codec *codec)
502 return 0; 714 return 0;
503} 715}
504 716
717
505/* 718/*
506 * initialize the codec volumes, etc 719 * initialize the codec volumes, etc
507 */ 720 */
508 721
509static struct hda_verb alc880_init_verbs_three_stack[] = { 722/*
510 /* Line In pin widget for input */ 723 * generic initialization of ADC, input mixers and output mixers
511 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 724 */
512 /* CD pin widget for input */ 725static struct hda_verb alc880_volume_init_verbs[] = {
513 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 726 /*
514 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 727 * Unmute ADC0-2 and set the default input to mic-in
515 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 728 */
516 /* Mic2 (front panel) pin widget for input and vref at 80% */ 729 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
517 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 730 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
518 /* unmute amp left and right */ 731 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
519 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 732 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
520 /* set connection select to line in (default select for this ADC) */ 733 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
521 {0x07, AC_VERB_SET_CONNECT_SEL, 0x02}, 734 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
522 /* unmute front mixer amp left (volume = 0) */ 735
523 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 736 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
524 /* mute pin widget amp left and right (no gain on this amp) */ 737 * mixer widget
525 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
526 /* unmute rear mixer amp left and right (volume = 0) */
527 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
528 /* mute pin widget amp left and right (no gain on this amp) */
529 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
530 /* unmute rear mixer amp left and right (volume = 0) */
531 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
532 /* mute pin widget amp left and right (no gain on this amp) */
533 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
534
535 /* using rear surround as the path for headphone output */
536 /* unmute rear surround mixer amp left and right (volume = 0) */
537 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
538 /* PASD 3 stack boards use the Mic 2 as the headphone output */
539 /* need to program the selector associated with the Mic 2 pin widget to
540 * surround path (index 0x01) for headphone output */
541 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
542 /* mute pin widget amp left and right (no gain on this amp) */
543 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
544 /* need to retask the Mic 2 pin widget to output */
545 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
546
547 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) for mixer widget(nid=0x0B)
548 * to support the input path of analog loopback
549 * Note: PASD motherboards uses the Line In 2 as the input for front panel 738 * Note: PASD motherboards uses the Line In 2 as the input for front panel
550 * mic (mic 2) 739 * mic (mic 2)
551 */ 740 */
552 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 741 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
553 /* unmute CD */ 742 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
554 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 743 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
555 /* unmute Line In */ 744 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
556 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 745 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
557 /* unmute Mic 1 */ 746 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
558 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 747
559 /* unmute Line In 2 (for PASD boards Mic 2) */ 748 /*
560 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, 749 * Set up output mixers (0x0c - 0x0f)
561
562 /* Unmute input amps for the line out paths to support the output path of
563 * analog loopback
564 * the mixers on the output path has 2 inputs, one from the DAC and one
565 * from the mixer
566 */ 750 */
567 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ 751 /* set vol=0 to output mixers */
568 /* Unmute Front out path */ 752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
569 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 753 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
570 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 754 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
571 /* Unmute Surround (used as HP) out path */ 755 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
572 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 756 /* set up input amps for analog loopback */
573 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 757 /* Amp Indices: DAC = 0, mixer = 1 */
574 /* Unmute C/LFE out path */ 758 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
575 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 759 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
576 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))}, /* mute */ 760 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
577 /* Unmute rear Surround out path */ 761 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
578 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 762 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
579 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 763 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
764 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
765 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
580 766
581 { } 767 { }
582}; 768};
583 769
584static struct hda_verb alc880_init_verbs_five_stack[] = { 770/*
585 /* Line In pin widget for input */ 771 * 3-stack pin configuration:
586 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 772 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
587 /* CD pin widget for input */ 773 */
588 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 774static struct hda_verb alc880_pin_3stack_init_verbs[] = {
589 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 775 /*
590 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 776 * preset connection lists of input pins
591 /* Mic2 (front panel) pin widget for input and vref at 80% */ 777 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
592 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
593 /* unmute amp left and right */
594 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
595 /* set connection select to line in (default select for this ADC) */
596 {0x07, AC_VERB_SET_CONNECT_SEL, 0x02},
597 /* unmute front mixer amp left and right (volume = 0) */
598 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
599 /* mute pin widget amp left and right (no gain on this amp) */
600 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
601 /* five rear and clfe */
602 /* unmute rear mixer amp left and right (volume = 0) */
603 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
604 /* mute pin widget amp left and right (no gain on this amp) */
605 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
606 /* unmute clfe mixer amp left and right (volume = 0) */
607 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
608 /* mute pin widget amp left and right (no gain on this amp) */
609 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
610
611 /* using rear surround as the path for headphone output */
612 /* unmute rear surround mixer amp left and right (volume = 0) */
613 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
614 /* PASD 3 stack boards use the Mic 2 as the headphone output */
615 /* need to program the selector associated with the Mic 2 pin widget to
616 * surround path (index 0x01) for headphone output
617 */
618 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
619 /* mute pin widget amp left and right (no gain on this amp) */
620 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
621 /* need to retask the Mic 2 pin widget to output */
622 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
623
624 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) for mixer
625 * widget(nid=0x0B) to support the input path of analog loopback
626 */ 778 */
627 /* Note: PASD motherboards uses the Line In 2 as the input for front panel mic (mic 2) */ 779 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
628 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03*/ 780 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
629 /* unmute CD */ 781 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
630 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 782
631 /* unmute Line In */ 783 /*
632 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 784 * Set pin mode and muting
633 /* unmute Mic 1 */
634 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
635 /* unmute Line In 2 (for PASD boards Mic 2) */
636 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
637
638 /* Unmute input amps for the line out paths to support the output path of
639 * analog loopback
640 * the mixers on the output path has 2 inputs, one from the DAC and
641 * one from the mixer
642 */ 785 */
643 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ 786 /* set front pin widgets 0x14 for output */
644 /* Unmute Front out path */ 787 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
645 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 788 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
646 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 789 /* Mic1 (rear panel) pin widget for input and vref at 80% */
647 /* Unmute Surround (used as HP) out path */ 790 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
648 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 791 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
649 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 792 /* Mic2 (as headphone out) for HP output */
650 /* Unmute C/LFE out path */ 793 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
651 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 794 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
652 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))}, /* mute */ 795 /* Line In pin widget for input */
653 /* Unmute rear Surround out path */ 796 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
654 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 797 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
655 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 798 /* Line2 (as front mic) pin widget for input and vref at 80% */
799 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
800 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
801 /* CD pin widget for input */
802 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
656 803
657 { } 804 { }
658}; 805};
659 806
660static struct hda_verb alc880_w810_init_verbs[] = { 807/*
661 /* front channel selector/amp: input 0: DAC: unmuted, (no volume selection) */ 808 * 5-stack pin configuration:
662 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 809 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
663 810 * line-in/side = 0x1a, f-mic = 0x1b
664 /* front channel selector/amp: input 1: capture mix: muted, (no volume selection) */ 811 */
665 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180}, 812static struct hda_verb alc880_pin_5stack_init_verbs[] = {
666 813 /*
667 /* front channel selector/amp: output 0: unmuted, max volume */ 814 * preset connection lists of input pins
668 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 815 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
669 816 */
670 /* front out pin: muted, (no volume selection) */ 817 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
671 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 818 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
672
673 /* front out pin: NOT headphone enable, out enable, vref disabled */
674 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
675 819
820 /*
821 * Set pin mode and muting
822 */
823 /* set pin widgets 0x14-0x17 for output */
824 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
825 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
826 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
827 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
828 /* unmute pins for output (no gain on this amp) */
829 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
830 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
831 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
832 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
676 833
677 /* surround channel selector/amp: input 0: DAC: unmuted, (no volume selection) */ 834 /* Mic1 (rear panel) pin widget for input and vref at 80% */
678 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 835 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
836 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
837 /* Mic2 (as headphone out) for HP output */
838 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
839 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
840 /* Line In pin widget for input */
841 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
842 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
843 /* Line2 (as front mic) pin widget for input and vref at 80% */
844 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
845 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
846 /* CD pin widget for input */
847 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
679 848
680 /* surround channel selector/amp: input 1: capture mix: muted, (no volume selection) */ 849 { }
681 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180}, 850};
682 851
683 /* surround channel selector/amp: output 0: unmuted, max volume */ 852/*
684 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 853 * W810 pin configuration:
854 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
855 */
856static struct hda_verb alc880_pin_w810_init_verbs[] = {
857 /* hphone/speaker input selector: front DAC */
858 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
685 859
686 /* surround out pin: muted, (no volume selection) */ 860 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
687 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 861 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
862 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
863 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
864 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
865 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
688 866
689 /* surround out pin: NOT headphone enable, out enable, vref disabled */ 867 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
690 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 868 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
691 869
870 { }
871};
692 872
693 /* c/lfe channel selector/amp: input 0: DAC: unmuted, (no volume selection) */ 873/*
694 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 874 * Z71V pin configuration:
875 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
876 */
877static struct hda_verb alc880_pin_z71v_init_verbs[] = {
878 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
879 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
880 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
881 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
695 882
696 /* c/lfe channel selector/amp: input 1: capture mix: muted, (no volume selection) */ 883 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
697 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180}, 884 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
885 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
886 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
698 887
699 /* c/lfe channel selector/amp: output 0: unmuted, max volume */ 888 { }
700 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 889};
701 890
702 /* c/lfe out pin: muted, (no volume selection) */ 891/*
703 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 892 * 6-stack pin configuration:
893 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
894 * line = 0x1a, HP = 0x1b
895 */
896static struct hda_verb alc880_pin_6stack_init_verbs[] = {
897 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
898
899 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
900 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
901 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
902 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
903 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
904 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
905 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
906 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
907
908 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
909 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
910 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
911 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
912 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
913 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
914 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
915 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
916 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
917
918 { }
919};
704 920
705 /* c/lfe out pin: NOT headphone enable, out enable, vref disabled */ 921/* FIXME! */
706 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 922/*
923 * F1734 pin configuration:
924 * HP = 0x14, speaker-out = 0x15, mic = 0x18
925 */
926static struct hda_verb alc880_pin_f1734_init_verbs[] = {
927 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
928 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
929 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
930 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
931
932 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
933 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
934 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
935 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
936
937 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
938 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
939 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
940 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
941 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
942 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
943 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
944 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
945 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
707 946
947 { }
948};
708 949
709 /* hphone/speaker input selector: front DAC */ 950/* FIXME! */
710 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, 951/*
952 * ASUS pin configuration:
953 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
954 */
955static struct hda_verb alc880_pin_asus_init_verbs[] = {
956 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
957 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
958 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
959 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
960
961 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
962 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
963 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
964 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
965 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
966 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
967 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
968 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
969
970 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
971 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
972 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
973 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
974 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
975 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
976 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
977 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
978 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
979
980 { }
981};
711 982
712 /* hphone/speaker out pin: muted, (no volume selection) */ 983/* Enable GPIO mask and set output */
713 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 984static struct hda_verb alc880_gpio1_init_verbs[] = {
985 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
986 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
987 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
988};
714 989
715 /* hphone/speaker out pin: NOT headphone enable, out enable, vref disabled */ 990/* Enable GPIO mask and set output */
716 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 991static struct hda_verb alc880_gpio2_init_verbs[] = {
992 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
993 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
994 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
995};
717 996
718 997
719 { } 998/*
720}; 999 */
721 1000
722static int alc_init(struct hda_codec *codec) 1001static int alc_init(struct hda_codec *codec)
723{ 1002{
724 struct alc_spec *spec = codec->spec; 1003 struct alc_spec *spec = codec->spec;
725 snd_hda_sequence_write(codec, spec->init_verbs); 1004 unsigned int i;
1005
1006 for (i = 0; i < spec->num_init_verbs; i++)
1007 snd_hda_sequence_write(codec, spec->init_verbs[i]);
726 return 0; 1008 return 0;
727} 1009}
728 1010
@@ -736,9 +1018,8 @@ static int alc_resume(struct hda_codec *codec)
736 int i; 1018 int i;
737 1019
738 alc_init(codec); 1020 alc_init(codec);
739 for (i = 0; i < spec->num_mixers; i++) { 1021 for (i = 0; i < spec->num_mixers; i++)
740 snd_hda_resume_ctls(codec, spec->mixers[i]); 1022 snd_hda_resume_ctls(codec, spec->mixers[i]);
741 }
742 if (spec->multiout.dig_out_nid) 1023 if (spec->multiout.dig_out_nid)
743 snd_hda_resume_spdif_out(codec); 1024 snd_hda_resume_spdif_out(codec);
744 if (spec->dig_in_nid) 1025 if (spec->dig_in_nid)
@@ -830,7 +1111,7 @@ static struct hda_pcm_stream alc880_pcm_analog_playback = {
830 .substreams = 1, 1111 .substreams = 1,
831 .channels_min = 2, 1112 .channels_min = 2,
832 .channels_max = 8, 1113 .channels_max = 8,
833 .nid = 0x02, /* NID to query formats and rates */ 1114 /* NID is set in alc_build_pcms */
834 .ops = { 1115 .ops = {
835 .open = alc880_playback_pcm_open, 1116 .open = alc880_playback_pcm_open,
836 .prepare = alc880_playback_pcm_prepare, 1117 .prepare = alc880_playback_pcm_prepare,
@@ -842,7 +1123,7 @@ static struct hda_pcm_stream alc880_pcm_analog_capture = {
842 .substreams = 2, 1123 .substreams = 2,
843 .channels_min = 2, 1124 .channels_min = 2,
844 .channels_max = 2, 1125 .channels_max = 2,
845 .nid = 0x07, /* NID to query formats and rates */ 1126 /* NID is set in alc_build_pcms */
846 .ops = { 1127 .ops = {
847 .prepare = alc880_capture_pcm_prepare, 1128 .prepare = alc880_capture_pcm_prepare,
848 .cleanup = alc880_capture_pcm_cleanup 1129 .cleanup = alc880_capture_pcm_cleanup
@@ -878,7 +1159,9 @@ static int alc_build_pcms(struct hda_codec *codec)
878 1159
879 info->name = spec->stream_name_analog; 1160 info->name = spec->stream_name_analog;
880 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); 1161 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1162 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
881 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); 1163 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1164 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
882 1165
883 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; 1166 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
884 for (i = 0; i < spec->num_channel_mode; i++) { 1167 for (i = 0; i < spec->num_channel_mode; i++) {
@@ -906,7 +1189,18 @@ static int alc_build_pcms(struct hda_codec *codec)
906 1189
907static void alc_free(struct hda_codec *codec) 1190static void alc_free(struct hda_codec *codec)
908{ 1191{
909 kfree(codec->spec); 1192 struct alc_spec *spec = codec->spec;
1193 unsigned int i;
1194
1195 if (! spec)
1196 return;
1197
1198 if (spec->kctl_alloc) {
1199 for (i = 0; i < spec->num_kctl_used; i++)
1200 kfree(spec->kctl_alloc[i].name);
1201 kfree(spec->kctl_alloc);
1202 }
1203 kfree(spec);
910} 1204}
911 1205
912/* 1206/*
@@ -921,153 +1215,915 @@ static struct hda_codec_ops alc_patch_ops = {
921#endif 1215#endif
922}; 1216};
923 1217
1218
1219/*
1220 * Test configuration for debugging
1221 *
1222 * Almost all inputs/outputs are enabled. I/O pins can be configured via
1223 * enum controls.
1224 */
1225#ifdef CONFIG_SND_DEBUG
1226static hda_nid_t alc880_test_dac_nids[4] = {
1227 0x02, 0x03, 0x04, 0x05
1228};
1229
1230static struct hda_input_mux alc880_test_capture_source = {
1231 .num_items = 5,
1232 .items = {
1233 { "In-1", 0x0 },
1234 { "In-2", 0x1 },
1235 { "In-3", 0x2 },
1236 { "In-4", 0x3 },
1237 { "CD", 0x4 },
1238 },
1239};
1240
1241static struct alc_channel_mode alc880_test_modes[4] = {
1242 { 2, NULL },
1243 { 4, NULL },
1244 { 6, NULL },
1245 { 8, NULL },
1246};
1247
1248static int alc_test_pin_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
1249{
1250 static char *texts[] = {
1251 "N/A", "Line Out", "HP Out",
1252 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1253 };
1254 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1255 uinfo->count = 1;
1256 uinfo->value.enumerated.items = 8;
1257 if (uinfo->value.enumerated.item >= 8)
1258 uinfo->value.enumerated.item = 7;
1259 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1260 return 0;
1261}
1262
1263static int alc_test_pin_ctl_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1264{
1265 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1266 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1267 unsigned int pin_ctl, item = 0;
1268
1269 pin_ctl = snd_hda_codec_read(codec, nid, 0,
1270 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1271 if (pin_ctl & AC_PINCTL_OUT_EN) {
1272 if (pin_ctl & AC_PINCTL_HP_EN)
1273 item = 2;
1274 else
1275 item = 1;
1276 } else if (pin_ctl & AC_PINCTL_IN_EN) {
1277 switch (pin_ctl & AC_PINCTL_VREFEN) {
1278 case AC_PINCTL_VREF_HIZ: item = 3; break;
1279 case AC_PINCTL_VREF_50: item = 4; break;
1280 case AC_PINCTL_VREF_GRD: item = 5; break;
1281 case AC_PINCTL_VREF_80: item = 6; break;
1282 case AC_PINCTL_VREF_100: item = 7; break;
1283 }
1284 }
1285 ucontrol->value.enumerated.item[0] = item;
1286 return 0;
1287}
1288
1289static int alc_test_pin_ctl_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1290{
1291 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1292 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1293 static unsigned int ctls[] = {
1294 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1295 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1296 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1297 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1298 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1299 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1300 };
1301 unsigned int old_ctl, new_ctl;
1302
1303 old_ctl = snd_hda_codec_read(codec, nid, 0,
1304 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1305 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1306 if (old_ctl != new_ctl) {
1307 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
1308 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
1309 ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
1310 return 1;
1311 }
1312 return 0;
1313}
1314
1315static int alc_test_pin_src_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
1316{
1317 static char *texts[] = {
1318 "Front", "Surround", "CLFE", "Side"
1319 };
1320 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1321 uinfo->count = 1;
1322 uinfo->value.enumerated.items = 4;
1323 if (uinfo->value.enumerated.item >= 4)
1324 uinfo->value.enumerated.item = 3;
1325 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1326 return 0;
1327}
1328
1329static int alc_test_pin_src_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1330{
1331 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1332 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1333 unsigned int sel;
1334
1335 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1336 ucontrol->value.enumerated.item[0] = sel & 3;
1337 return 0;
1338}
1339
1340static int alc_test_pin_src_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1341{
1342 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1343 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1344 unsigned int sel;
1345
1346 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
1347 if (ucontrol->value.enumerated.item[0] != sel) {
1348 sel = ucontrol->value.enumerated.item[0] & 3;
1349 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
1350 return 1;
1351 }
1352 return 0;
1353}
1354
1355#define PIN_CTL_TEST(xname,nid) { \
1356 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1357 .name = xname, \
1358 .info = alc_test_pin_ctl_info, \
1359 .get = alc_test_pin_ctl_get, \
1360 .put = alc_test_pin_ctl_put, \
1361 .private_value = nid \
1362 }
1363
1364#define PIN_SRC_TEST(xname,nid) { \
1365 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1366 .name = xname, \
1367 .info = alc_test_pin_src_info, \
1368 .get = alc_test_pin_src_get, \
1369 .put = alc_test_pin_src_put, \
1370 .private_value = nid \
1371 }
1372
1373static snd_kcontrol_new_t alc880_test_mixer[] = {
1374 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1375 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1376 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
1377 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1378 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1379 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1380 ALC_BIND_MUTE("CLFE Playback Volume", 0x0e, 2, HDA_INPUT),
1381 ALC_BIND_MUTE("Side Playback Volume", 0x0f, 2, HDA_INPUT),
1382 PIN_CTL_TEST("Front Pin Mode", 0x14),
1383 PIN_CTL_TEST("Surround Pin Mode", 0x15),
1384 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
1385 PIN_CTL_TEST("Side Pin Mode", 0x17),
1386 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
1387 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
1388 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
1389 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
1390 PIN_SRC_TEST("In-1 Pin Source", 0x18),
1391 PIN_SRC_TEST("In-2 Pin Source", 0x19),
1392 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
1393 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
1394 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
1395 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
1396 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
1397 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
1398 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
1399 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
1400 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
1401 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
1402 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
1403 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
1404 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1405 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1406 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1407 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
1408 {
1409 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1410 .name = "Input Source",
1411 .count = 2,
1412 .info = alc_mux_enum_info,
1413 .get = alc_mux_enum_get,
1414 .put = alc_mux_enum_put,
1415 },
1416 {
1417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1418 .name = "Channel Mode",
1419 .info = alc880_ch_mode_info,
1420 .get = alc880_ch_mode_get,
1421 .put = alc880_ch_mode_put,
1422 },
1423 { } /* end */
1424};
1425
1426static struct hda_verb alc880_test_init_verbs[] = {
1427 /* Unmute inputs of 0x0c - 0x0f */
1428 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1429 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1430 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1431 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1432 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1433 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1434 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1435 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1436 /* Vol output for 0x0c-0x0f */
1437 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1438 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1439 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1440 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1441 /* Set output pins 0x14-0x17 */
1442 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1444 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1445 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1446 /* Unmute output pins 0x14-0x17 */
1447 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1449 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1450 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1451 /* Set input pins 0x18-0x1c */
1452 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1453 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1454 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1455 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1456 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1457 /* Mute input pins 0x18-0x1b */
1458 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1459 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1460 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1461 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1462 /* ADC set up */
1463 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1464 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1465 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1466 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1467 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1468 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1469 /* Analog input/passthru */
1470 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1471 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1472 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1473 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1474 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1475 { }
1476};
1477#endif
1478
924/* 1479/*
925 */ 1480 */
926 1481
927static struct hda_board_config alc880_cfg_tbl[] = { 1482static struct hda_board_config alc880_cfg_tbl[] = {
928 /* Back 3 jack, front 2 jack */ 1483 /* Back 3 jack, front 2 jack */
929 { .modelname = "3stack", .config = ALC880_3ST }, 1484 { .modelname = "3stack", .config = ALC880_3ST },
930 { .pci_vendor = 0x8086, .pci_device = 0xe200, .config = ALC880_3ST }, 1485 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
931 { .pci_vendor = 0x8086, .pci_device = 0xe201, .config = ALC880_3ST }, 1486 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
932 { .pci_vendor = 0x8086, .pci_device = 0xe202, .config = ALC880_3ST }, 1487 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
933 { .pci_vendor = 0x8086, .pci_device = 0xe203, .config = ALC880_3ST }, 1488 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
934 { .pci_vendor = 0x8086, .pci_device = 0xe204, .config = ALC880_3ST }, 1489 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
935 { .pci_vendor = 0x8086, .pci_device = 0xe205, .config = ALC880_3ST }, 1490 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
936 { .pci_vendor = 0x8086, .pci_device = 0xe206, .config = ALC880_3ST }, 1491 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
937 { .pci_vendor = 0x8086, .pci_device = 0xe207, .config = ALC880_3ST }, 1492 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
938 { .pci_vendor = 0x8086, .pci_device = 0xe208, .config = ALC880_3ST }, 1493 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
939 { .pci_vendor = 0x8086, .pci_device = 0xe209, .config = ALC880_3ST }, 1494 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
940 { .pci_vendor = 0x8086, .pci_device = 0xe20a, .config = ALC880_3ST }, 1495 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
941 { .pci_vendor = 0x8086, .pci_device = 0xe20b, .config = ALC880_3ST }, 1496 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
942 { .pci_vendor = 0x8086, .pci_device = 0xe20c, .config = ALC880_3ST }, 1497 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
943 { .pci_vendor = 0x8086, .pci_device = 0xe20d, .config = ALC880_3ST }, 1498 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
944 { .pci_vendor = 0x8086, .pci_device = 0xe20e, .config = ALC880_3ST }, 1499 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
945 { .pci_vendor = 0x8086, .pci_device = 0xe20f, .config = ALC880_3ST }, 1500 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
946 { .pci_vendor = 0x8086, .pci_device = 0xe210, .config = ALC880_3ST }, 1501 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
947 { .pci_vendor = 0x8086, .pci_device = 0xe211, .config = ALC880_3ST }, 1502 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
948 { .pci_vendor = 0x8086, .pci_device = 0xe214, .config = ALC880_3ST }, 1503 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
949 { .pci_vendor = 0x8086, .pci_device = 0xe302, .config = ALC880_3ST }, 1504 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
950 { .pci_vendor = 0x8086, .pci_device = 0xe303, .config = ALC880_3ST }, 1505 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
951 { .pci_vendor = 0x8086, .pci_device = 0xe304, .config = ALC880_3ST }, 1506 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
952 { .pci_vendor = 0x8086, .pci_device = 0xe306, .config = ALC880_3ST }, 1507 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
953 { .pci_vendor = 0x8086, .pci_device = 0xe307, .config = ALC880_3ST }, 1508 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
954 { .pci_vendor = 0x8086, .pci_device = 0xe404, .config = ALC880_3ST }, 1509 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
955 { .pci_vendor = 0x8086, .pci_device = 0xa101, .config = ALC880_3ST }, 1510 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
956 { .pci_vendor = 0x107b, .pci_device = 0x3031, .config = ALC880_3ST }, 1511 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
957 { .pci_vendor = 0x107b, .pci_device = 0x4036, .config = ALC880_3ST }, 1512 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
958 { .pci_vendor = 0x107b, .pci_device = 0x4037, .config = ALC880_3ST }, 1513 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
959 { .pci_vendor = 0x107b, .pci_device = 0x4038, .config = ALC880_3ST }, 1514 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
960 { .pci_vendor = 0x107b, .pci_device = 0x4040, .config = ALC880_3ST }, 1515 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
961 { .pci_vendor = 0x107b, .pci_device = 0x4041, .config = ALC880_3ST }, 1516 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
962 1517
963 /* Back 3 jack, front 2 jack (Internal add Aux-In) */ 1518 /* Back 3 jack, front 2 jack (Internal add Aux-In) */
964 { .pci_vendor = 0x1025, .pci_device = 0xe310, .config = ALC880_3ST }, 1519 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
1520 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
965 1521
966 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */ 1522 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
967 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG }, 1523 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
968 { .pci_vendor = 0x8086, .pci_device = 0xe308, .config = ALC880_3ST_DIG }, 1524 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
969 1525
970 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/ 1526 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
971 { .pci_vendor = 0x8086, .pci_device = 0xe305, .config = ALC880_3ST_DIG }, 1527 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
972 { .pci_vendor = 0x8086, .pci_device = 0xd402, .config = ALC880_3ST_DIG }, 1528 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
973 { .pci_vendor = 0x1025, .pci_device = 0xe309, .config = ALC880_3ST_DIG }, 1529 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
974 1530
975 /* Back 5 jack, front 2 jack */ 1531 /* Back 5 jack, front 2 jack */
976 { .modelname = "5stack", .config = ALC880_5ST }, 1532 { .modelname = "5stack", .config = ALC880_5ST },
977 { .pci_vendor = 0x107b, .pci_device = 0x3033, .config = ALC880_5ST }, 1533 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
978 { .pci_vendor = 0x107b, .pci_device = 0x4039, .config = ALC880_5ST }, 1534 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
979 { .pci_vendor = 0x107b, .pci_device = 0x3032, .config = ALC880_5ST }, 1535 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
980 { .pci_vendor = 0x103c, .pci_device = 0x2a09, .config = ALC880_5ST }, 1536 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
1537 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
981 1538
982 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */ 1539 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
983 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG }, 1540 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
984 { .pci_vendor = 0x8086, .pci_device = 0xe224, .config = ALC880_5ST_DIG }, 1541 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
985 { .pci_vendor = 0x8086, .pci_device = 0xe400, .config = ALC880_5ST_DIG }, 1542 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
986 { .pci_vendor = 0x8086, .pci_device = 0xe401, .config = ALC880_5ST_DIG }, 1543 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
987 { .pci_vendor = 0x8086, .pci_device = 0xe402, .config = ALC880_5ST_DIG }, 1544 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
988 { .pci_vendor = 0x8086, .pci_device = 0xd400, .config = ALC880_5ST_DIG }, 1545 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
989 { .pci_vendor = 0x8086, .pci_device = 0xd401, .config = ALC880_5ST_DIG }, 1546 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
990 { .pci_vendor = 0x8086, .pci_device = 0xa100, .config = ALC880_5ST_DIG }, 1547 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
991 { .pci_vendor = 0x1565, .pci_device = 0x8202, .config = ALC880_5ST_DIG }, 1548 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
1549 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
1550 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG },
1551 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
1552 { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG },
992 1553
993 { .modelname = "w810", .config = ALC880_W810 }, 1554 { .modelname = "w810", .config = ALC880_W810 },
994 { .pci_vendor = 0x161f, .pci_device = 0x203d, .config = ALC880_W810 }, 1555 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
1556
1557 { .modelname = "z71v", .config = ALC880_Z71V },
1558 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
1559
1560 { .modelname = "6statack-digout", .config = ALC880_6ST_DIG },
1561 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
1562 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
1563 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
1564 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
1565
1566 { .modelname = "asus", .config = ALC880_ASUS },
1567 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
1568 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
1569 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
1570 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
1571 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
1572 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
1573 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
1574 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
1575 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
1576 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
1577
1578 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
1579 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
1580
1581 { .modelname = "F1734", .config = ALC880_F1734 },
1582 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
1583
1584#ifdef CONFIG_SND_DEBUG
1585 { .modelname = "test", .config = ALC880_TEST },
1586#endif
995 1587
996 {} 1588 {}
997}; 1589};
998 1590
1591/*
1592 * configuration template - to be copied to the spec instance
1593 */
1594struct alc_config_preset {
1595 snd_kcontrol_new_t *mixers[4];
1596 const struct hda_verb *init_verbs[4];
1597 unsigned int num_dacs;
1598 hda_nid_t *dac_nids;
1599 hda_nid_t dig_out_nid; /* optional */
1600 hda_nid_t hp_nid; /* optional */
1601 unsigned int num_adc_nids;
1602 hda_nid_t *adc_nids;
1603 unsigned int num_channel_mode;
1604 const struct alc_channel_mode *channel_mode;
1605 const struct hda_input_mux *input_mux;
1606};
1607
1608static struct alc_config_preset alc880_presets[] = {
1609 [ALC880_3ST] = {
1610 .mixers = { alc880_three_stack_mixer },
1611 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
1612 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1613 .dac_nids = alc880_dac_nids,
1614 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1615 .channel_mode = alc880_threestack_modes,
1616 .input_mux = &alc880_capture_source,
1617 },
1618 [ALC880_3ST_DIG] = {
1619 .mixers = { alc880_three_stack_mixer },
1620 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
1621 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1622 .dac_nids = alc880_dac_nids,
1623 .dig_out_nid = ALC880_DIGOUT_NID,
1624 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1625 .channel_mode = alc880_threestack_modes,
1626 .input_mux = &alc880_capture_source,
1627 },
1628 [ALC880_5ST] = {
1629 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
1630 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
1631 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1632 .dac_nids = alc880_dac_nids,
1633 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1634 .channel_mode = alc880_fivestack_modes,
1635 .input_mux = &alc880_capture_source,
1636 },
1637 [ALC880_5ST_DIG] = {
1638 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
1639 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
1640 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1641 .dac_nids = alc880_dac_nids,
1642 .dig_out_nid = ALC880_DIGOUT_NID,
1643 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1644 .channel_mode = alc880_fivestack_modes,
1645 .input_mux = &alc880_capture_source,
1646 },
1647 [ALC880_6ST_DIG] = {
1648 .mixers = { alc880_six_stack_mixer },
1649 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
1650 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1651 .dac_nids = alc880_6st_dac_nids,
1652 .dig_out_nid = ALC880_DIGOUT_NID,
1653 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1654 .channel_mode = alc880_sixstack_modes,
1655 .input_mux = &alc880_6stack_capture_source,
1656 },
1657 [ALC880_W810] = {
1658 .mixers = { alc880_w810_base_mixer },
1659 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs },
1660 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
1661 .dac_nids = alc880_w810_dac_nids,
1662 .dig_out_nid = ALC880_DIGOUT_NID,
1663 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
1664 .channel_mode = alc880_w810_modes,
1665 .input_mux = &alc880_capture_source,
1666 },
1667 [ALC880_Z71V] = {
1668 .mixers = { alc880_z71v_mixer },
1669 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs,
1670 alc880_gpio2_init_verbs },
1671 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
1672 .dac_nids = alc880_z71v_dac_nids,
1673 .dig_out_nid = ALC880_DIGOUT_NID,
1674 .hp_nid = 0x03,
1675 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1676 .channel_mode = alc880_2_jack_modes,
1677 .input_mux = &alc880_capture_source,
1678 },
1679 [ALC880_F1734] = {
1680 .mixers = { alc880_f1734_mixer },
1681 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
1682 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
1683 .dac_nids = alc880_f1734_dac_nids,
1684 .hp_nid = 0x02,
1685 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1686 .channel_mode = alc880_2_jack_modes,
1687 .input_mux = &alc880_capture_source,
1688 },
1689 [ALC880_ASUS] = {
1690 .mixers = { alc880_asus_mixer },
1691 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1692 alc880_gpio1_init_verbs },
1693 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1694 .dac_nids = alc880_asus_dac_nids,
1695 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1696 .channel_mode = alc880_asus_modes,
1697 .input_mux = &alc880_capture_source,
1698 },
1699 [ALC880_ASUS_DIG] = {
1700 .mixers = { alc880_asus_mixer },
1701 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1702 alc880_gpio1_init_verbs },
1703 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1704 .dac_nids = alc880_asus_dac_nids,
1705 .dig_out_nid = ALC880_DIGOUT_NID,
1706 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1707 .channel_mode = alc880_asus_modes,
1708 .input_mux = &alc880_capture_source,
1709 },
1710 [ALC880_ASUS_W1V] = {
1711 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
1712 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
1713 alc880_gpio1_init_verbs },
1714 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1715 .dac_nids = alc880_asus_dac_nids,
1716 .dig_out_nid = ALC880_DIGOUT_NID,
1717 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1718 .channel_mode = alc880_asus_modes,
1719 .input_mux = &alc880_capture_source,
1720 },
1721 [ALC880_UNIWILL_DIG] = {
1722 .mixers = { alc880_asus_mixer },
1723 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
1724 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1725 .dac_nids = alc880_asus_dac_nids,
1726 .dig_out_nid = ALC880_DIGOUT_NID,
1727 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1728 .channel_mode = alc880_asus_modes,
1729 .input_mux = &alc880_capture_source,
1730 },
1731#ifdef CONFIG_SND_DEBUG
1732 [ALC880_TEST] = {
1733 .mixers = { alc880_test_mixer },
1734 .init_verbs = { alc880_test_init_verbs },
1735 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
1736 .dac_nids = alc880_test_dac_nids,
1737 .dig_out_nid = ALC880_DIGOUT_NID,
1738 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
1739 .channel_mode = alc880_test_modes,
1740 .input_mux = &alc880_test_capture_source,
1741 },
1742#endif
1743};
1744
1745/*
1746 * Automatic parse of I/O pins from the BIOS configuration
1747 */
1748
1749#define NUM_CONTROL_ALLOC 32
1750#define NUM_VERB_ALLOC 32
1751
1752enum {
1753 ALC_CTL_WIDGET_VOL,
1754 ALC_CTL_WIDGET_MUTE,
1755 ALC_CTL_BIND_MUTE,
1756};
1757static snd_kcontrol_new_t alc880_control_templates[] = {
1758 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
1759 HDA_CODEC_MUTE(NULL, 0, 0, 0),
1760 ALC_BIND_MUTE(NULL, 0, 0, 0),
1761};
1762
1763/* add dynamic controls */
1764static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
1765{
1766 snd_kcontrol_new_t *knew;
1767
1768 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1769 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1770
1771 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1772 if (! knew)
1773 return -ENOMEM;
1774 if (spec->kctl_alloc) {
1775 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
1776 kfree(spec->kctl_alloc);
1777 }
1778 spec->kctl_alloc = knew;
1779 spec->num_kctl_alloc = num;
1780 }
1781
1782 knew = &spec->kctl_alloc[spec->num_kctl_used];
1783 *knew = alc880_control_templates[type];
1784 knew->name = snd_kmalloc_strdup(name, GFP_KERNEL);
1785 if (! knew->name)
1786 return -ENOMEM;
1787 knew->private_value = val;
1788 spec->num_kctl_used++;
1789 return 0;
1790}
1791
1792#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
1793#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
1794#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
1795#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
1796#define alc880_is_input_pin(nid) ((nid) >= 0x18)
1797#define alc880_input_pin_idx(nid) ((nid) - 0x18)
1798#define alc880_idx_to_dac(nid) ((nid) + 0x02)
1799#define alc880_dac_to_idx(nid) ((nid) - 0x02)
1800#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
1801#define alc880_idx_to_selector(nid) ((nid) + 0x10)
1802#define ALC880_PIN_CD_NID 0x1c
1803
1804/* fill in the dac_nids table from the parsed pin configuration */
1805static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
1806{
1807 hda_nid_t nid;
1808 int assigned[4];
1809 int i, j;
1810
1811 memset(assigned, 0, sizeof(assigned));
1812
1813 /* check the pins hardwired to audio widget */
1814 for (i = 0; i < cfg->line_outs; i++) {
1815 nid = cfg->line_out_pins[i];
1816 if (alc880_is_fixed_pin(nid)) {
1817 int idx = alc880_fixed_pin_idx(nid);
1818 spec->multiout.dac_nids[i] = alc880_dac_to_idx(idx);
1819 assigned[idx] = 1;
1820 }
1821 }
1822 /* left pins can be connect to any audio widget */
1823 for (i = 0; i < cfg->line_outs; i++) {
1824 nid = cfg->line_out_pins[i];
1825 if (alc880_is_fixed_pin(nid))
1826 continue;
1827 /* search for an empty channel */
1828 for (j = 0; j < cfg->line_outs; j++) {
1829 if (! assigned[j]) {
1830 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
1831 assigned[j] = 1;
1832 break;
1833 }
1834 }
1835 }
1836 spec->multiout.num_dacs = cfg->line_outs;
1837 return 0;
1838}
1839
1840/* add playback controls from the parsed DAC table */
1841static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
1842{
1843 char name[32];
1844 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
1845 hda_nid_t nid;
1846 int i, err;
1847
1848 for (i = 0; i < cfg->line_outs; i++) {
1849 if (! spec->multiout.dac_nids[i])
1850 continue;
1851 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
1852 if (i == 2) {
1853 /* Center/LFE */
1854 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
1855 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
1856 return err;
1857 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
1858 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
1859 return err;
1860 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
1861 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
1862 return err;
1863 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
1864 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
1865 return err;
1866 } else {
1867 sprintf(name, "%s Playback Volume", chname[i]);
1868 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
1869 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
1870 return err;
1871 sprintf(name, "%s Playback Switch", chname[i]);
1872 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
1873 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
1874 return err;
1875 }
1876 }
1877
1878 return 0;
1879}
1880
1881/* add playback controls for HP output */
1882static int alc880_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
1883{
1884 hda_nid_t nid;
1885 int err;
1886
1887 if (! pin)
1888 return 0;
1889
1890 if (alc880_is_fixed_pin(pin)) {
1891 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
1892 if (! spec->multiout.dac_nids[0]) {
1893 /* use this as the primary output */
1894 spec->multiout.dac_nids[0] = nid;
1895 if (! spec->multiout.num_dacs)
1896 spec->multiout.num_dacs = 1;
1897 } else
1898 /* specify the DAC as the extra HP output */
1899 spec->multiout.hp_nid = nid;
1900 /* control HP volume/switch on the output mixer amp */
1901 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
1902 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
1903 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
1904 return err;
1905 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Headphone Playback Switch",
1906 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
1907 return err;
1908 } else if (alc880_is_multi_pin(pin)) {
1909 /* set manual connection */
1910 if (! spec->multiout.dac_nids[0]) {
1911 /* use this as the primary output */
1912 spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));
1913 if (! spec->multiout.num_dacs)
1914 spec->multiout.num_dacs = 1;
1915 }
1916 /* we have only a switch on HP-out PIN */
1917 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
1918 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
1919 return err;
1920 }
1921 return 0;
1922}
1923
1924/* create input playback/capture controls for the given pin */
1925static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname)
1926{
1927 char name[32];
1928 int err, idx;
1929
1930 sprintf(name, "%s Playback Volume", ctlname);
1931 idx = alc880_input_pin_idx(pin);
1932 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
1933 HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0)
1934 return err;
1935 sprintf(name, "%s Playback Switch", ctlname);
1936 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
1937 HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0)
1938 return err;
1939 return 0;
1940}
1941
1942/* create playback/capture controls for input pins */
1943static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
1944{
1945 static char *labels[AUTO_PIN_LAST] = {
1946 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
1947 };
1948 struct hda_input_mux *imux = &spec->private_imux;
1949 int i, err;
1950
1951 for (i = 0; i < AUTO_PIN_LAST; i++) {
1952 if (alc880_is_input_pin(cfg->input_pins[i])) {
1953 err = new_analog_input(spec, cfg->input_pins[i], labels[i]);
1954 if (err < 0)
1955 return err;
1956 imux->items[imux->num_items].label = labels[i];
1957 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
1958 imux->num_items++;
1959 }
1960 }
1961 return 0;
1962}
1963
1964static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, int pin_type,
1965 int dac_idx)
1966{
1967 /* set as output */
1968 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
1969 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
1970 /* need the manual connection? */
1971 if (alc880_is_multi_pin(nid)) {
1972 struct alc_spec *spec = codec->spec;
1973 int idx = alc880_multi_pin_idx(nid);
1974 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
1975 AC_VERB_SET_CONNECT_SEL,
1976 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
1977 }
1978}
1979
1980static void alc880_auto_init_multi_out(struct hda_codec *codec)
1981{
1982 struct alc_spec *spec = codec->spec;
1983 int i;
1984
1985 for (i = 0; i < spec->autocfg.line_outs; i++) {
1986 hda_nid_t nid = spec->autocfg.line_out_pins[i];
1987 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
1988 }
1989}
1990
1991static void alc880_auto_init_hp_out(struct hda_codec *codec)
1992{
1993 struct alc_spec *spec = codec->spec;
1994 hda_nid_t pin;
1995
1996 pin = spec->autocfg.hp_pin;
1997 if (pin) /* connect to front */
1998 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
1999}
2000
2001static void alc880_auto_init_analog_input(struct hda_codec *codec)
2002{
2003 struct alc_spec *spec = codec->spec;
2004 int i;
2005
2006 for (i = 0; i < AUTO_PIN_LAST; i++) {
2007 hda_nid_t nid = spec->autocfg.input_pins[i];
2008 if (alc880_is_input_pin(nid)) {
2009 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
2010 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
2011 if (nid != ALC880_PIN_CD_NID)
2012 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2013 AMP_OUT_MUTE);
2014 }
2015 }
2016}
2017
2018/* parse the BIOS configuration and set up the alc_spec */
2019/* return 1 if successful, 0 if the proper config is not found, or a negative error code */
2020static int alc880_parse_auto_config(struct hda_codec *codec)
2021{
2022 struct alc_spec *spec = codec->spec;
2023 int err;
2024
2025 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0)
2026 return err;
2027 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0)
2028 return err;
2029 if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin)
2030 return 0; /* can't find valid BIOS pin config */
2031 if ((err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
2032 (err = alc880_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
2033 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2034 return err;
2035
2036 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2037
2038 if (spec->autocfg.dig_out_pin)
2039 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
2040 if (spec->autocfg.dig_in_pin)
2041 spec->dig_in_nid = ALC880_DIGIN_NID;
2042
2043 if (spec->kctl_alloc)
2044 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2045
2046 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
2047
2048 spec->input_mux = &spec->private_imux;
2049
2050 return 1;
2051}
2052
2053/* init callback for auto-configuration model -- overriding the default init */
2054static int alc880_auto_init(struct hda_codec *codec)
2055{
2056 alc_init(codec);
2057 alc880_auto_init_multi_out(codec);
2058 alc880_auto_init_hp_out(codec);
2059 alc880_auto_init_analog_input(codec);
2060 return 0;
2061}
2062
2063/*
2064 * OK, here we have finally the patch for ALC880
2065 */
2066
999static int patch_alc880(struct hda_codec *codec) 2067static int patch_alc880(struct hda_codec *codec)
1000{ 2068{
1001 struct alc_spec *spec; 2069 struct alc_spec *spec;
1002 int board_config; 2070 int board_config;
2071 int i, err;
1003 2072
1004 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 2073 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
1005 if (spec == NULL) 2074 if (spec == NULL)
1006 return -ENOMEM; 2075 return -ENOMEM;
1007 2076
2077 init_MUTEX(&spec->bind_mutex);
1008 codec->spec = spec; 2078 codec->spec = spec;
1009 2079
1010 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl); 2080 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
1011 if (board_config < 0) { 2081 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
1012 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC880\n"); 2082 printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
1013 board_config = ALC880_MINIMAL; 2083 board_config = ALC880_AUTO;
1014 } 2084 }
1015 2085
1016 switch (board_config) { 2086 if (board_config == ALC880_AUTO) {
1017 case ALC880_W810: 2087 /* automatic parse from the BIOS config */
1018 spec->mixers[spec->num_mixers] = alc880_w810_base_mixer; 2088 err = alc880_parse_auto_config(codec);
1019 spec->num_mixers++; 2089 if (err < 0) {
1020 break; 2090 alc_free(codec);
1021 case ALC880_5ST: 2091 return err;
1022 case ALC880_5ST_DIG: 2092 } else if (! err) {
1023 spec->mixers[spec->num_mixers] = alc880_five_stack_mixer; 2093 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
1024 spec->num_mixers++; 2094 board_config = ALC880_3ST;
1025 break; 2095 }
1026 default:
1027 spec->mixers[spec->num_mixers] = alc880_base_mixer;
1028 spec->num_mixers++;
1029 break;
1030 } 2096 }
1031 2097
1032 switch (board_config) { 2098 if (board_config != ALC880_AUTO) {
1033 case ALC880_3ST_DIG: 2099 /* set up from the preset table */
1034 case ALC880_5ST_DIG: 2100 const struct alc_config_preset *preset;
1035 case ALC880_W810:
1036 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
1037 break;
1038 default:
1039 break;
1040 }
1041 2101
1042 switch (board_config) { 2102 preset = &alc880_presets[board_config];
1043 case ALC880_3ST:
1044 case ALC880_3ST_DIG:
1045 case ALC880_5ST:
1046 case ALC880_5ST_DIG:
1047 case ALC880_W810:
1048 spec->front_panel = 1;
1049 break;
1050 default:
1051 break;
1052 }
1053 2103
1054 switch (board_config) { 2104 for (i = 0; preset->mixers[i]; i++) {
1055 case ALC880_5ST: 2105 snd_assert(spec->num_mixers < ARRAY_SIZE(spec->mixers), break);
1056 case ALC880_5ST_DIG: 2106 spec->mixers[spec->num_mixers++] = preset->mixers[i];
1057 spec->init_verbs = alc880_init_verbs_five_stack; 2107 }
1058 spec->channel_mode = alc880_fivestack_modes; 2108 for (i = 0; preset->init_verbs[i]; i++) {
1059 spec->num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes); 2109 snd_assert(spec->num_init_verbs < ARRAY_SIZE(spec->init_verbs), break);
1060 break; 2110 spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
1061 case ALC880_W810: 2111 }
1062 spec->init_verbs = alc880_w810_init_verbs; 2112
1063 spec->channel_mode = alc880_w810_modes; 2113 spec->channel_mode = preset->channel_mode;
1064 spec->num_channel_mode = ARRAY_SIZE(alc880_w810_modes); 2114 spec->num_channel_mode = preset->num_channel_mode;
1065 break; 2115
1066 default: 2116 spec->multiout.max_channels = spec->channel_mode[0].channels;
1067 spec->init_verbs = alc880_init_verbs_three_stack; 2117
1068 spec->channel_mode = alc880_threestack_modes; 2118 spec->multiout.num_dacs = preset->num_dacs;
1069 spec->num_channel_mode = ARRAY_SIZE(alc880_threestack_modes); 2119 spec->multiout.dac_nids = preset->dac_nids;
1070 break; 2120 spec->multiout.dig_out_nid = preset->dig_out_nid;
2121 spec->multiout.hp_nid = preset->hp_nid;
2122
2123 spec->input_mux = preset->input_mux;
2124
2125 spec->num_adc_nids = preset->num_adc_nids;
2126 spec->adc_nids = preset->adc_nids;
1071 } 2127 }
1072 2128
1073 spec->stream_name_analog = "ALC880 Analog"; 2129 spec->stream_name_analog = "ALC880 Analog";
@@ -1078,34 +2134,64 @@ static int patch_alc880(struct hda_codec *codec)
1078 spec->stream_digital_playback = &alc880_pcm_digital_playback; 2134 spec->stream_digital_playback = &alc880_pcm_digital_playback;
1079 spec->stream_digital_capture = &alc880_pcm_digital_capture; 2135 spec->stream_digital_capture = &alc880_pcm_digital_capture;
1080 2136
1081 spec->multiout.max_channels = spec->channel_mode[0].channels; 2137 if (! spec->adc_nids && spec->input_mux) {
1082 2138 /* check whether NID 0x07 is valid */
1083 switch (board_config) { 2139 unsigned int wcap = snd_hda_param_read(codec, alc880_adc_nids[0],
1084 case ALC880_W810: 2140 AC_PAR_AUDIO_WIDGET_CAP);
1085 spec->multiout.num_dacs = ARRAY_SIZE(alc880_w810_dac_nids); 2141 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
1086 spec->multiout.dac_nids = alc880_w810_dac_nids; 2142 if (wcap != AC_WID_AUD_IN) {
1087 // No dedicated headphone socket - it's shared with built-in speakers. 2143 spec->adc_nids = alc880_adc_nids_alt;
1088 break; 2144 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
1089 default: 2145 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
1090 spec->multiout.num_dacs = ARRAY_SIZE(alc880_dac_nids); 2146 spec->num_mixers++;
1091 spec->multiout.dac_nids = alc880_dac_nids; 2147 } else {
1092 spec->multiout.hp_nid = 0x03; /* rear-surround NID */ 2148 spec->adc_nids = alc880_adc_nids;
1093 break; 2149 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
2150 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
2151 spec->num_mixers++;
2152 }
1094 } 2153 }
1095 2154
1096 spec->input_mux = &alc880_capture_source;
1097 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
1098 spec->adc_nids = alc880_adc_nids;
1099
1100 codec->patch_ops = alc_patch_ops; 2155 codec->patch_ops = alc_patch_ops;
2156 if (board_config == ALC880_AUTO)
2157 codec->patch_ops.init = alc880_auto_init;
1101 2158
1102 return 0; 2159 return 0;
1103} 2160}
1104 2161
2162
1105/* 2163/*
1106 * ALC260 support 2164 * ALC260 support
1107 */ 2165 */
1108 2166
2167static hda_nid_t alc260_dac_nids[1] = {
2168 /* front */
2169 0x02,
2170};
2171
2172static hda_nid_t alc260_adc_nids[1] = {
2173 /* ADC0 */
2174 0x04,
2175};
2176
2177static hda_nid_t alc260_hp_adc_nids[1] = {
2178 /* ADC1 */
2179 0x05,
2180};
2181
2182#define ALC260_DIGOUT_NID 0x03
2183#define ALC260_DIGIN_NID 0x06
2184
2185static struct hda_input_mux alc260_capture_source = {
2186 .num_items = 4,
2187 .items = {
2188 { "Mic", 0x0 },
2189 { "Front Mic", 0x1 },
2190 { "Line", 0x2 },
2191 { "CD", 0x4 },
2192 },
2193};
2194
1109/* 2195/*
1110 * This is just place-holder, so there's something for alc_build_pcms to look 2196 * This is just place-holder, so there's something for alc_build_pcms to look
1111 * at when it calculates the maximum number of channels. ALC260 has no mixer 2197 * at when it calculates the maximum number of channels. ALC260 has no mixer
@@ -1116,11 +2202,9 @@ static struct alc_channel_mode alc260_modes[1] = {
1116 { 2, NULL }, 2202 { 2, NULL },
1117}; 2203};
1118 2204
1119snd_kcontrol_new_t alc260_base_mixer[] = { 2205static snd_kcontrol_new_t alc260_base_mixer[] = {
1120 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), 2206 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
1121 /* use LINE2 for the output */ 2207 ALC_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
1122 /* HDA_CODEC_MUTE("Front Playback Switch", 0x0f, 0x0, HDA_OUTPUT), */
1123 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
1124 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 2208 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
1125 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 2209 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
1126 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), 2210 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
@@ -1132,9 +2216,9 @@ snd_kcontrol_new_t alc260_base_mixer[] = {
1132 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), 2216 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
1133 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), 2217 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
1134 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), 2218 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
1135 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT), 2219 ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
1136 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 2220 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
1137 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), 2221 ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_OUTPUT),
1138 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), 2222 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
1139 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), 2223 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
1140 { 2224 {
@@ -1147,60 +2231,91 @@ snd_kcontrol_new_t alc260_base_mixer[] = {
1147 { } /* end */ 2231 { } /* end */
1148}; 2232};
1149 2233
2234static snd_kcontrol_new_t alc260_hp_mixer[] = {
2235 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
2236 ALC_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
2237 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
2238 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
2239 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
2240 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
2241 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
2242 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
2243 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
2244 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
2245 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
2246 ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
2247 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
2248 ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_OUTPUT),
2249 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
2250 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
2251 {
2252 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2253 .name = "Capture Source",
2254 .info = alc_mux_enum_info,
2255 .get = alc_mux_enum_get,
2256 .put = alc_mux_enum_put,
2257 },
2258 { } /* end */
2259};
2260
1150static struct hda_verb alc260_init_verbs[] = { 2261static struct hda_verb alc260_init_verbs[] = {
1151 /* Line In pin widget for input */ 2262 /* Line In pin widget for input */
1152 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 2263 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1153 /* CD pin widget for input */ 2264 /* CD pin widget for input */
1154 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 2265 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1155 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 2266 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1156 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 2267 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1157 /* Mic2 (front panel) pin widget for input and vref at 80% */ 2268 /* Mic2 (front panel) pin widget for input and vref at 80% */
1158 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 2269 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1159 /* LINE-2 is used for line-out in rear */ 2270 /* LINE-2 is used for line-out in rear */
1160 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 2271 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1161 /* select line-out */ 2272 /* select line-out */
1162 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 2273 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1163 /* LINE-OUT pin */ 2274 /* LINE-OUT pin */
1164 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 2275 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1165 /* enable HP */ 2276 /* enable HP */
1166 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 2277 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1167 /* enable Mono */ 2278 /* enable Mono */
1168 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 2279 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1169 /* unmute amp left and right */ 2280 /* mute capture amp left and right */
1170 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 2281 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1171 /* set connection select to line in (default select for this ADC) */ 2282 /* set connection select to line in (default select for this ADC) */
1172 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, 2283 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
1173 /* unmute Line-Out mixer amp left and right (volume = 0) */ 2284 /* mute capture amp left and right */
1174 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 2285 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1175 /* mute pin widget amp left and right (no gain on this amp) */ 2286 /* set connection select to line in (default select for this ADC) */
1176 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 2287 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
1177 /* unmute HP mixer amp left and right (volume = 0) */ 2288 /* set vol=0 Line-Out mixer amp left and right */
1178 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 2289 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1179 /* mute pin widget amp left and right (no gain on this amp) */ 2290 /* unmute pin widget amp left and right (no gain on this amp) */
1180 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 2291 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1181 /* unmute Mono mixer amp left and right (volume = 0) */ 2292 /* set vol=0 HP mixer amp left and right */
1182 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 2293 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1183 /* mute pin widget amp left and right (no gain on this amp) */ 2294 /* unmute pin widget amp left and right (no gain on this amp) */
1184 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 2295 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1185 /* mute LINE-2 out */ 2296 /* set vol=0 Mono mixer amp left and right */
1186 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 2297 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2298 /* unmute pin widget amp left and right (no gain on this amp) */
2299 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2300 /* unmute LINE-2 out pin */
2301 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1187 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 2302 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
1188 /* unmute CD */ 2303 /* mute CD */
1189 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 2304 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
1190 /* unmute Line In */ 2305 /* mute Line In */
1191 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 2306 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
1192 /* unmute Mic */ 2307 /* mute Mic */
1193 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 2308 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1194 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ 2309 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
1195 /* Unmute Front out path */ 2310 /* mute Front out path */
1196 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 2311 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1197 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 2312 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1198 /* Unmute Headphone out path */ 2313 /* mute Headphone out path */
1199 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 2314 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1200 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 2315 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1201 /* Unmute Mono out path */ 2316 /* mute Mono out path */
1202 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 2317 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1203 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 2318 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1204 { } 2319 { }
1205}; 2320};
1206 2321
@@ -1208,30 +2323,52 @@ static struct hda_pcm_stream alc260_pcm_analog_playback = {
1208 .substreams = 1, 2323 .substreams = 1,
1209 .channels_min = 2, 2324 .channels_min = 2,
1210 .channels_max = 2, 2325 .channels_max = 2,
1211 .nid = 0x2,
1212}; 2326};
1213 2327
1214static struct hda_pcm_stream alc260_pcm_analog_capture = { 2328static struct hda_pcm_stream alc260_pcm_analog_capture = {
1215 .substreams = 1, 2329 .substreams = 1,
1216 .channels_min = 2, 2330 .channels_min = 2,
1217 .channels_max = 2, 2331 .channels_max = 2,
1218 .nid = 0x4, 2332};
2333
2334static struct hda_board_config alc260_cfg_tbl[] = {
2335 { .modelname = "hp", .config = ALC260_HP },
2336 { .pci_subvendor = 0x103c, .config = ALC260_HP },
2337 {}
1219}; 2338};
1220 2339
1221static int patch_alc260(struct hda_codec *codec) 2340static int patch_alc260(struct hda_codec *codec)
1222{ 2341{
1223 struct alc_spec *spec; 2342 struct alc_spec *spec;
2343 int board_config;
1224 2344
1225 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 2345 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
1226 if (spec == NULL) 2346 if (spec == NULL)
1227 return -ENOMEM; 2347 return -ENOMEM;
1228 2348
2349 init_MUTEX(&spec->bind_mutex);
1229 codec->spec = spec; 2350 codec->spec = spec;
1230 2351
1231 spec->mixers[spec->num_mixers] = alc260_base_mixer; 2352 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
1232 spec->num_mixers++; 2353 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
2354 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
2355 board_config = ALC260_BASIC;
2356 }
2357
2358 switch (board_config) {
2359 case ALC260_HP:
2360 spec->mixers[spec->num_mixers] = alc260_hp_mixer;
2361 spec->num_mixers++;
2362 break;
2363 default:
2364 spec->mixers[spec->num_mixers] = alc260_base_mixer;
2365 spec->num_mixers++;
2366 break;
2367 }
2368
2369 spec->init_verbs[0] = alc260_init_verbs;
2370 spec->num_init_verbs = 1;
1233 2371
1234 spec->init_verbs = alc260_init_verbs;
1235 spec->channel_mode = alc260_modes; 2372 spec->channel_mode = alc260_modes;
1236 spec->num_channel_mode = ARRAY_SIZE(alc260_modes); 2373 spec->num_channel_mode = ARRAY_SIZE(alc260_modes);
1237 2374
@@ -1244,14 +2381,23 @@ static int patch_alc260(struct hda_codec *codec)
1244 spec->multiout.dac_nids = alc260_dac_nids; 2381 spec->multiout.dac_nids = alc260_dac_nids;
1245 2382
1246 spec->input_mux = &alc260_capture_source; 2383 spec->input_mux = &alc260_capture_source;
1247 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); 2384 switch (board_config) {
1248 spec->adc_nids = alc260_adc_nids; 2385 case ALC260_HP:
2386 spec->num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids);
2387 spec->adc_nids = alc260_hp_adc_nids;
2388 break;
2389 default:
2390 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
2391 spec->adc_nids = alc260_adc_nids;
2392 break;
2393 }
1249 2394
1250 codec->patch_ops = alc_patch_ops; 2395 codec->patch_ops = alc_patch_ops;
1251 2396
1252 return 0; 2397 return 0;
1253} 2398}
1254 2399
2400
1255/* 2401/*
1256 * ALC882 support 2402 * ALC882 support
1257 * 2403 *
@@ -1324,15 +2470,15 @@ static int alc882_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u
1324 */ 2470 */
1325static snd_kcontrol_new_t alc882_base_mixer[] = { 2471static snd_kcontrol_new_t alc882_base_mixer[] = {
1326 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 2472 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1327 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 2473 ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1328 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 2474 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1329 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT), 2475 ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1330 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 2476 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1331 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 2477 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1332 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT), 2478 ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1333 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), 2479 ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_OUTPUT),
1334 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 2480 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1335 HDA_CODEC_MUTE("Side Playback Switch", 0x17, 0x0, HDA_OUTPUT), 2481 ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1336 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 2482 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1337 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 2483 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1338 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 2484 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
@@ -1364,89 +2510,80 @@ static snd_kcontrol_new_t alc882_base_mixer[] = {
1364 2510
1365static struct hda_verb alc882_init_verbs[] = { 2511static struct hda_verb alc882_init_verbs[] = {
1366 /* Front mixer: unmute input/output amp left and right (volume = 0) */ 2512 /* Front mixer: unmute input/output amp left and right (volume = 0) */
1367 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 2513 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1368 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 2514 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2515 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1369 /* Rear mixer */ 2516 /* Rear mixer */
1370 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 2517 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1371 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 2518 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2519 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1372 /* CLFE mixer */ 2520 /* CLFE mixer */
1373 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 2521 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1374 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 2522 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2523 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1375 /* Side mixer */ 2524 /* Side mixer */
1376 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 2525 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1377 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 2526 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1378 2527 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1379 /* Front Pin: to output mode */ 2528
1380 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 2529 /* Front Pin: output 0 (0x0c) */
1381 /* Front Pin: mute amp left and right (no volume) */ 2530 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1382 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 2531 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1383 /* select Front mixer (0x0c, index 0) */
1384 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 2532 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1385 /* Rear Pin */ 2533 /* Rear Pin: output 1 (0x0d) */
1386 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 2534 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1387 /* Rear Pin: mute amp left and right (no volume) */ 2535 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1388 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
1389 /* select Rear mixer (0x0d, index 1) */
1390 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 2536 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
1391 /* CLFE Pin */ 2537 /* CLFE Pin: output 2 (0x0e) */
1392 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 2538 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1393 /* CLFE Pin: mute amp left and right (no volume) */ 2539 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1394 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
1395 /* select CLFE mixer (0x0e, index 2) */
1396 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, 2540 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1397 /* Side Pin */ 2541 /* Side Pin: output 3 (0x0f) */
1398 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 2542 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1399 /* Side Pin: mute amp left and right (no volume) */ 2543 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1400 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
1401 /* select Side mixer (0x0f, index 3) */
1402 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, 2544 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1403 /* Headphone Pin */ 2545 /* Mic (rear) pin: input vref at 80% */
1404 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 2546 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1405 /* Headphone Pin: mute amp left and right (no volume) */ 2547 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1406 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 2548 /* Front Mic pin: input vref at 80% */
1407 /* select Front mixer (0x0c, index 0) */ 2549 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2550 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2551 /* Line In pin: input */
2552 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2553 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2554 /* Line-2 In: Headphone output (output 0 - 0x0c) */
2555 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2556 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1408 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 2557 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1409 /* Mic (rear) pin widget for input and vref at 80% */
1410 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
1411 /* Front Mic pin widget for input and vref at 80% */
1412 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
1413 /* Line In pin widget for input */
1414 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
1415 /* CD pin widget for input */ 2558 /* CD pin widget for input */
1416 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 2559 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1417 2560
1418 /* FIXME: use matrix-type input source selection */ 2561 /* FIXME: use matrix-type input source selection */
1419 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 2562 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
1420 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 2563 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
1421 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 2564 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1422 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 2565 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1423 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 2566 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1424 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 2567 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1425 /* Input mixer2 */ 2568 /* Input mixer2 */
1426 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 2569 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1427 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 2570 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1428 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 2571 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1429 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 2572 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1430 /* Input mixer3 */ 2573 /* Input mixer3 */
1431 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 2574 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1432 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 2575 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1433 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 2576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1434 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 2577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1435 /* ADC1: unmute amp left and right */ 2578 /* ADC1: mute amp left and right */
1436 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 2579 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1437 /* ADC2: unmute amp left and right */ 2580 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1438 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 2581 /* ADC2: mute amp left and right */
1439 /* ADC3: unmute amp left and right */ 2582 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1440 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 2583 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1441 2584 /* ADC3: mute amp left and right */
1442 /* Unmute front loopback */ 2585 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1443 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 2586 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1444 /* Unmute rear loopback */
1445 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1446 /* Mute CLFE loopback */
1447 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
1448 /* Unmute side loopback */
1449 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1450 2587
1451 { } 2588 { }
1452}; 2589};
@@ -1459,6 +2596,7 @@ static int patch_alc882(struct hda_codec *codec)
1459 if (spec == NULL) 2596 if (spec == NULL)
1460 return -ENOMEM; 2597 return -ENOMEM;
1461 2598
2599 init_MUTEX(&spec->bind_mutex);
1462 codec->spec = spec; 2600 codec->spec = spec;
1463 2601
1464 spec->mixers[spec->num_mixers] = alc882_base_mixer; 2602 spec->mixers[spec->num_mixers] = alc882_base_mixer;
@@ -1466,8 +2604,9 @@ static int patch_alc882(struct hda_codec *codec)
1466 2604
1467 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; 2605 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
1468 spec->dig_in_nid = ALC880_DIGIN_NID; 2606 spec->dig_in_nid = ALC880_DIGIN_NID;
1469 spec->front_panel = 1; 2607 spec->init_verbs[0] = alc882_init_verbs;
1470 spec->init_verbs = alc882_init_verbs; 2608 spec->num_init_verbs = 1;
2609
1471 spec->channel_mode = alc882_ch_modes; 2610 spec->channel_mode = alc882_ch_modes;
1472 spec->num_channel_mode = ARRAY_SIZE(alc882_ch_modes); 2611 spec->num_channel_mode = ARRAY_SIZE(alc882_ch_modes);
1473 2612
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
new file mode 100644
index 000000000000..013be2ea513a
--- /dev/null
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -0,0 +1,666 @@
1/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for SigmaTel STAC92xx
5 *
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
7 * <matt@embeddedalley.com>
8 *
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
11 *
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
27#include <sound/driver.h>
28#include <linux/init.h>
29#include <linux/delay.h>
30#include <linux/slab.h>
31#include <linux/pci.h>
32#include <sound/core.h>
33#include "hda_codec.h"
34#include "hda_local.h"
35
36#undef STAC_TEST
37
38struct sigmatel_spec {
39 /* playback */
40 struct hda_multi_out multiout;
41 hda_nid_t playback_nid;
42
43 /* capture */
44 hda_nid_t *adc_nids;
45 unsigned int num_adcs;
46 hda_nid_t *mux_nids;
47 unsigned int num_muxes;
48 hda_nid_t capture_nid;
49 hda_nid_t dig_in_nid;
50
51 /* power management*/
52 hda_nid_t *pstate_nids;
53 unsigned int num_pstates;
54
55 /* pin widgets */
56 hda_nid_t *pin_nids;
57 unsigned int num_pins;
58#ifdef STAC_TEST
59 unsigned int *pin_configs;
60#endif
61
62 /* codec specific stuff */
63 struct hda_verb *init;
64 snd_kcontrol_new_t *mixer;
65
66 /* capture source */
67 struct hda_input_mux input_mux;
68 char input_labels[HDA_MAX_NUM_INPUTS][16];
69 unsigned int cur_mux[2];
70
71 /* channel mode */
72 unsigned int num_ch_modes;
73 unsigned int cur_ch_mode;
74 const struct sigmatel_channel_mode *channel_modes;
75
76 struct hda_pcm pcm_rec[1]; /* PCM information */
77};
78
79static hda_nid_t stac9200_adc_nids[1] = {
80 0x03,
81};
82
83static hda_nid_t stac9200_mux_nids[1] = {
84 0x0c,
85};
86
87static hda_nid_t stac9200_dac_nids[1] = {
88 0x02,
89};
90
91static hda_nid_t stac9200_pstate_nids[3] = {
92 0x01, 0x02, 0x03,
93};
94
95static hda_nid_t stac9200_pin_nids[8] = {
96 0x08, 0x09, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
97};
98
99static hda_nid_t stac922x_adc_nids[2] = {
100 0x06, 0x07,
101};
102
103static hda_nid_t stac922x_mux_nids[2] = {
104 0x12, 0x13,
105};
106
107static hda_nid_t stac922x_dac_nids[4] = {
108 0x02, 0x03, 0x04, 0x05,
109};
110
111static hda_nid_t stac922x_pstate_nids[8] = {
112 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x11,
113};
114
115static hda_nid_t stac922x_pin_nids[10] = {
116 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
117 0x0f, 0x10, 0x11, 0x15, 0x1b,
118};
119
120static int stac92xx_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
121{
122 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
123 struct sigmatel_spec *spec = codec->spec;
124 return snd_hda_input_mux_info(&spec->input_mux, uinfo);
125}
126
127static int stac92xx_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
128{
129 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
130 struct sigmatel_spec *spec = codec->spec;
131 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
132
133 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
134 return 0;
135}
136
137static int stac92xx_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
138{
139 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
140 struct sigmatel_spec *spec = codec->spec;
141 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
142
143 return snd_hda_input_mux_put(codec, &spec->input_mux, ucontrol,
144 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
145}
146
147static struct hda_verb stac9200_ch2_init[] = {
148 /* set dac0mux for dac converter */
149 { 0x07, 0x701, 0x00},
150 {}
151};
152
153static struct hda_verb stac922x_ch2_init[] = {
154 /* set master volume and direct control */
155 { 0x16, 0x70f, 0xff},
156 {}
157};
158
159struct sigmatel_channel_mode {
160 unsigned int channels;
161 const struct hda_verb *sequence;
162};
163
164static snd_kcontrol_new_t stac9200_mixer[] = {
165 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
166 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
167 {
168 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
169 .name = "Input Source",
170 .count = 1,
171 .info = stac92xx_mux_enum_info,
172 .get = stac92xx_mux_enum_get,
173 .put = stac92xx_mux_enum_put,
174 },
175 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
176 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
177 HDA_CODEC_VOLUME("Input Mux Volume", 0x0c, 0, HDA_OUTPUT),
178 { } /* end */
179};
180
181static snd_kcontrol_new_t stac922x_mixer[] = {
182 HDA_CODEC_VOLUME("PCM Playback Volume", 0x2, 0x0, HDA_OUTPUT),
183 HDA_CODEC_MUTE("PCM Playback Switch", 0x2, 0x0, HDA_OUTPUT),
184 {
185 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
186 .name = "Input Source",
187 .count = 1,
188 .info = stac92xx_mux_enum_info,
189 .get = stac92xx_mux_enum_get,
190 .put = stac92xx_mux_enum_put,
191 },
192 HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT),
193 HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT),
194 HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT),
195 { } /* end */
196};
197
198static int stac92xx_build_controls(struct hda_codec *codec)
199{
200 struct sigmatel_spec *spec = codec->spec;
201 int err;
202
203 err = snd_hda_add_new_ctls(codec, spec->mixer);
204 if (err < 0)
205 return err;
206 if (spec->multiout.dig_out_nid) {
207 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
208 if (err < 0)
209 return err;
210 }
211 if (spec->dig_in_nid) {
212 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
213 if (err < 0)
214 return err;
215 }
216 return 0;
217}
218
219#ifdef STAC_TEST
220static unsigned int stac9200_pin_configs[8] = {
221 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
222 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
223};
224
225static unsigned int stac922x_pin_configs[14] = {
226 0x40000100, 0x40000100, 0x40000100, 0x01114010,
227 0x01813122, 0x40000100, 0x01447010, 0x01c47010,
228 0x40000100, 0x40000100,
229};
230
231static void stac92xx_set_config_regs(struct hda_codec *codec)
232{
233 int i;
234 struct sigmatel_spec *spec = codec->spec;
235 unsigned int pin_cfg;
236
237 for (i=0; i < spec->num_pins; i++) {
238 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
239 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
240 spec->pin_configs[i] & 0x000000ff);
241 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
242 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
243 (spec->pin_configs[i] & 0x0000ff00) >> 8);
244 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
245 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
246 (spec->pin_configs[i] & 0x00ff0000) >> 16);
247 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
248 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
249 spec->pin_configs[i] >> 24);
250 pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0,
251 AC_VERB_GET_CONFIG_DEFAULT,
252 0x00);
253 printk("pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg);
254 }
255}
256#endif
257
258static int stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, unsigned int value)
259{
260 unsigned int pin_ctl;
261
262 pin_ctl = snd_hda_codec_read(codec, nid, 0,
263 AC_VERB_GET_PIN_WIDGET_CONTROL,
264 0x00);
265 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
266 pin_ctl | value);
267
268 return 0;
269}
270
271static int stac92xx_set_vref(struct hda_codec *codec, hda_nid_t nid)
272{
273 unsigned int vref_caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP) >> AC_PINCAP_VREF_SHIFT;
274 unsigned int vref_ctl = AC_PINCTL_VREF_HIZ;
275
276 if (vref_caps & AC_PINCAP_VREF_100)
277 vref_ctl = AC_PINCTL_VREF_100;
278 else if (vref_caps & AC_PINCAP_VREF_80)
279 vref_ctl = AC_PINCTL_VREF_80;
280 else if (vref_caps & AC_PINCAP_VREF_50)
281 vref_ctl = AC_PINCTL_VREF_50;
282 else if (vref_caps & AC_PINCAP_VREF_GRD)
283 vref_ctl = AC_PINCTL_VREF_GRD;
284
285 stac92xx_set_pinctl(codec, nid, vref_ctl);
286
287 return 0;
288}
289
290/*
291 * retrieve the default device type from the default config value
292 */
293#define get_defcfg_type(cfg) ((cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT)
294#define get_defcfg_location(cfg) ((cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT)
295
296static int stac92xx_config_pin(struct hda_codec *codec, hda_nid_t nid, unsigned int pin_cfg)
297{
298 struct sigmatel_spec *spec = codec->spec;
299 u32 location = get_defcfg_location(pin_cfg);
300 char *label;
301 const char *type = NULL;
302 int ainput = 0;
303
304 switch(get_defcfg_type(pin_cfg)) {
305 case AC_JACK_HP_OUT:
306 /* Enable HP amp */
307 stac92xx_set_pinctl(codec, nid, AC_PINCTL_HP_EN);
308 /* Fall through */
309 case AC_JACK_SPDIF_OUT:
310 case AC_JACK_LINE_OUT:
311 case AC_JACK_SPEAKER:
312 /* Enable output */
313 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
314 break;
315 case AC_JACK_SPDIF_IN:
316 stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN);
317 break;
318 case AC_JACK_MIC_IN:
319 if ((location & 0x0f) == AC_JACK_LOC_FRONT)
320 type = "Front Mic";
321 else
322 type = "Mic";
323 ainput = 1;
324 /* Set vref */
325 stac92xx_set_vref(codec, nid);
326 stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN);
327 break;
328 case AC_JACK_CD:
329 type = "CD";
330 ainput = 1;
331 stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN);
332 break;
333 case AC_JACK_LINE_IN:
334 if ((location & 0x0f) == AC_JACK_LOC_FRONT)
335 type = "Front Line";
336 else
337 type = "Line";
338 ainput = 1;
339 stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN);
340 break;
341 case AC_JACK_AUX:
342 if ((location & 0x0f) == AC_JACK_LOC_FRONT)
343 type = "Front Aux";
344 else
345 type = "Aux";
346 ainput = 1;
347 stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN);
348 break;
349 }
350
351 if (ainput) {
352 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
353 int i, j, num_cons, index = -1;
354 if (!type)
355 type = "Input";
356 label = spec->input_labels[spec->input_mux.num_items];
357 strcpy(label, type);
358 spec->input_mux.items[spec->input_mux.num_items].label = label;
359 for (i=0; i<spec->num_muxes; i++) {
360 num_cons = snd_hda_get_connections(codec, spec->mux_nids[i], con_lst, HDA_MAX_NUM_INPUTS);
361 for (j=0; j<num_cons; j++)
362 if (con_lst[j] == nid) {
363 index = j;
364 break;
365 }
366 if (index >= 0)
367 break;
368 }
369 spec->input_mux.items[spec->input_mux.num_items].index = index;
370 spec->input_mux.num_items++;
371 }
372
373 return 0;
374}
375
376static int stac92xx_config_pins(struct hda_codec *codec)
377{
378 struct sigmatel_spec *spec = codec->spec;
379 int i;
380 unsigned int pin_cfg;
381
382 for (i=0; i < spec->num_pins; i++) {
383 /* Default to disabled */
384 snd_hda_codec_write(codec, spec->pin_nids[i], 0,
385 AC_VERB_SET_PIN_WIDGET_CONTROL,
386 0x00);
387
388 pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0,
389 AC_VERB_GET_CONFIG_DEFAULT,
390 0x00);
391 if (((pin_cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT) == AC_JACK_PORT_NONE)
392 continue; /* Move on */
393
394 stac92xx_config_pin(codec, spec->pin_nids[i], pin_cfg);
395 }
396
397 return 0;
398}
399
400static int stac92xx_init(struct hda_codec *codec)
401{
402 struct sigmatel_spec *spec = codec->spec;
403 int i;
404
405 for (i=0; i < spec->num_pstates; i++)
406 snd_hda_codec_write(codec, spec->pstate_nids[i], 0,
407 AC_VERB_SET_POWER_STATE, 0x00);
408
409 mdelay(100);
410
411 snd_hda_sequence_write(codec, spec->init);
412
413#ifdef STAC_TEST
414 stac92xx_set_config_regs(codec);
415#endif
416
417 stac92xx_config_pins(codec);
418
419 return 0;
420}
421
422/*
423 * Analog playback callbacks
424 */
425static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
426 struct hda_codec *codec,
427 snd_pcm_substream_t *substream)
428{
429 struct sigmatel_spec *spec = codec->spec;
430 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
431}
432
433static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
434 struct hda_codec *codec,
435 unsigned int stream_tag,
436 unsigned int format,
437 snd_pcm_substream_t *substream)
438{
439 struct sigmatel_spec *spec = codec->spec;
440 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
441 format, substream);
442}
443
444static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
445 struct hda_codec *codec,
446 snd_pcm_substream_t *substream)
447{
448 struct sigmatel_spec *spec = codec->spec;
449 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
450}
451
452/*
453 * Digital playback callbacks
454 */
455static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
456 struct hda_codec *codec,
457 snd_pcm_substream_t *substream)
458{
459 struct sigmatel_spec *spec = codec->spec;
460 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
461}
462
463static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
464 struct hda_codec *codec,
465 snd_pcm_substream_t *substream)
466{
467 struct sigmatel_spec *spec = codec->spec;
468 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
469}
470
471
472/*
473 * Analog capture callbacks
474 */
475static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
476 struct hda_codec *codec,
477 unsigned int stream_tag,
478 unsigned int format,
479 snd_pcm_substream_t *substream)
480{
481 struct sigmatel_spec *spec = codec->spec;
482
483 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
484 stream_tag, 0, format);
485 return 0;
486}
487
488static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
489 struct hda_codec *codec,
490 snd_pcm_substream_t *substream)
491{
492 struct sigmatel_spec *spec = codec->spec;
493
494 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
495 return 0;
496}
497
498static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
499 .substreams = 1,
500 .channels_min = 2,
501 .channels_max = 2,
502 /* NID is set in stac92xx_build_pcms */
503 .ops = {
504 .open = stac92xx_dig_playback_pcm_open,
505 .close = stac92xx_dig_playback_pcm_close
506 },
507};
508
509static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
510 .substreams = 1,
511 .channels_min = 2,
512 .channels_max = 2,
513 /* NID is set in stac92xx_build_pcms */
514};
515
516static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
517 .substreams = 1,
518 .channels_min = 2,
519 .channels_max = 2,
520 .nid = 0x02, /* NID to query formats and rates */
521 .ops = {
522 .open = stac92xx_playback_pcm_open,
523 .prepare = stac92xx_playback_pcm_prepare,
524 .cleanup = stac92xx_playback_pcm_cleanup
525 },
526};
527
528static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
529 .substreams = 2,
530 .channels_min = 2,
531 .channels_max = 2,
532 .nid = 0x06, /* NID to query formats and rates */
533 .ops = {
534 .prepare = stac92xx_capture_pcm_prepare,
535 .cleanup = stac92xx_capture_pcm_cleanup
536 },
537};
538
539static int stac92xx_build_pcms(struct hda_codec *codec)
540{
541 struct sigmatel_spec *spec = codec->spec;
542 struct hda_pcm *info = spec->pcm_rec;
543
544 codec->num_pcms = 1;
545 codec->pcm_info = info;
546
547 info->name = "STAC92xx";
548 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
549 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->playback_nid;
550 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
551 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->capture_nid;
552
553 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
554 codec->num_pcms++;
555 info++;
556 info->name = "STAC92xx Digital";
557 if (spec->multiout.dig_out_nid) {
558 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
559 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
560 }
561 if (spec->dig_in_nid) {
562 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
563 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
564 }
565 }
566
567 return 0;
568}
569
570static void stac92xx_free(struct hda_codec *codec)
571{
572 kfree(codec->spec);
573}
574
575static struct hda_codec_ops stac92xx_patch_ops = {
576 .build_controls = stac92xx_build_controls,
577 .build_pcms = stac92xx_build_pcms,
578 .init = stac92xx_init,
579 .free = stac92xx_free,
580};
581
582static int patch_stac9200(struct hda_codec *codec)
583{
584 struct sigmatel_spec *spec;
585
586 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
587 if (spec == NULL)
588 return -ENOMEM;
589
590 codec->spec = spec;
591
592 spec->multiout.max_channels = 2;
593 spec->multiout.num_dacs = 1;
594 spec->multiout.dac_nids = stac9200_dac_nids;
595 spec->multiout.dig_out_nid = 0x05;
596 spec->dig_in_nid = 0x04;
597 spec->adc_nids = stac9200_adc_nids;
598 spec->mux_nids = stac9200_mux_nids;
599 spec->num_muxes = 1;
600 spec->input_mux.num_items = 0;
601 spec->pstate_nids = stac9200_pstate_nids;
602 spec->num_pstates = 3;
603 spec->pin_nids = stac9200_pin_nids;
604#ifdef STAC_TEST
605 spec->pin_configs = stac9200_pin_configs;
606#endif
607 spec->num_pins = 8;
608 spec->init = stac9200_ch2_init;
609 spec->mixer = stac9200_mixer;
610 spec->playback_nid = 0x02;
611 spec->capture_nid = 0x03;
612
613 codec->patch_ops = stac92xx_patch_ops;
614
615 return 0;
616}
617
618static int patch_stac922x(struct hda_codec *codec)
619{
620 struct sigmatel_spec *spec;
621
622 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
623 if (spec == NULL)
624 return -ENOMEM;
625
626 codec->spec = spec;
627
628 spec->multiout.max_channels = 2;
629 spec->multiout.num_dacs = 4;
630 spec->multiout.dac_nids = stac922x_dac_nids;
631 spec->multiout.dig_out_nid = 0x08;
632 spec->dig_in_nid = 0x09;
633 spec->adc_nids = stac922x_adc_nids;
634 spec->mux_nids = stac922x_mux_nids;
635 spec->num_muxes = 2;
636 spec->input_mux.num_items = 0;
637 spec->pstate_nids = stac922x_pstate_nids;
638 spec->num_pstates = 8;
639 spec->pin_nids = stac922x_pin_nids;
640#ifdef STAC_TEST
641 spec->pin_configs = stac922x_pin_configs;
642#endif
643 spec->num_pins = 10;
644 spec->init = stac922x_ch2_init;
645 spec->mixer = stac922x_mixer;
646 spec->playback_nid = 0x02;
647 spec->capture_nid = 0x06;
648
649 codec->patch_ops = stac92xx_patch_ops;
650
651 return 0;
652}
653
654/*
655 * patch entries
656 */
657struct hda_codec_preset snd_hda_preset_sigmatel[] = {
658 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
659 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
660 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
661 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
662 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
663 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
664 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
665 {} /* terminator */
666};
diff --git a/sound/pci/ice1712/amp.c b/sound/pci/ice1712/amp.c
index 779951725e1e..289b0b5711e4 100644
--- a/sound/pci/ice1712/amp.c
+++ b/sound/pci/ice1712/amp.c
@@ -30,16 +30,39 @@
30#include <sound/core.h> 30#include <sound/core.h>
31 31
32#include "ice1712.h" 32#include "ice1712.h"
33#include "envy24ht.h"
33#include "amp.h" 34#include "amp.h"
34 35
36static void wm_put(ice1712_t *ice, int reg, unsigned short val)
37{
38 unsigned short cval;
39 cval = (reg << 9) | val;
40 snd_vt1724_write_i2c(ice, WM_DEV, cval >> 8, cval & 0xff);
41}
35 42
36static int __devinit snd_vt1724_amp_init(ice1712_t *ice) 43static int __devinit snd_vt1724_amp_init(ice1712_t *ice)
37{ 44{
45 static unsigned short wm_inits[] = {
46 WM_ATTEN_L, 0x0000, /* 0 db */
47 WM_ATTEN_R, 0x0000, /* 0 db */
48 WM_DAC_CTRL, 0x0008, /* 24bit I2S */
49 WM_INT_CTRL, 0x0001, /* 24bit I2S */
50 };
51
52 unsigned int i;
53
38 /* only use basic functionality for now */ 54 /* only use basic functionality for now */
39 55
40 ice->num_total_dacs = 2; /* only PSDOUT0 is connected */ 56 ice->num_total_dacs = 2; /* only PSDOUT0 is connected */
41 ice->num_total_adcs = 2; 57 ice->num_total_adcs = 2;
42 58
59 /* Chaintech AV-710 has another codecs, which need initialization */
60 /* initialize WM8728 codec */
61 if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AV710) {
62 for (i = 0; i < ARRAY_SIZE(wm_inits); i += 2)
63 wm_put(ice, wm_inits[i], wm_inits[i+1]);
64 }
65
43 return 0; 66 return 0;
44} 67}
45 68
@@ -54,6 +77,13 @@ static int __devinit snd_vt1724_amp_add_controls(ice1712_t *ice)
54/* entry point */ 77/* entry point */
55struct snd_ice1712_card_info snd_vt1724_amp_cards[] __devinitdata = { 78struct snd_ice1712_card_info snd_vt1724_amp_cards[] __devinitdata = {
56 { 79 {
80 .subvendor = VT1724_SUBDEVICE_AV710,
81 .name = "Chaintech AV-710",
82 .model = "av710",
83 .chip_init = snd_vt1724_amp_init,
84 .build_controls = snd_vt1724_amp_add_controls,
85 },
86 {
57 .subvendor = VT1724_SUBDEVICE_AUDIO2000, 87 .subvendor = VT1724_SUBDEVICE_AUDIO2000,
58 .name = "AMP Ltd AUDIO2000", 88 .name = "AMP Ltd AUDIO2000",
59 .model = "amp2000", 89 .model = "amp2000",
diff --git a/sound/pci/ice1712/amp.h b/sound/pci/ice1712/amp.h
index d58d43383e83..a0fc89b48122 100644
--- a/sound/pci/ice1712/amp.h
+++ b/sound/pci/ice1712/amp.h
@@ -24,9 +24,23 @@
24 * 24 *
25 */ 25 */
26 26
27#define AMP_AUDIO2000_DEVICE_DESC "{AMP Ltd,AUDIO2000}," 27#define AMP_AUDIO2000_DEVICE_DESC "{AMP Ltd,AUDIO2000},"\
28 "{Chaintech,AV-710},"
28 29
30#if 0
29#define VT1724_SUBDEVICE_AUDIO2000 0x12142417 /* Advanced Micro Peripherals Ltd AUDIO2000 */ 31#define VT1724_SUBDEVICE_AUDIO2000 0x12142417 /* Advanced Micro Peripherals Ltd AUDIO2000 */
32#else
33#define VT1724_SUBDEVICE_AUDIO2000 0x00030003 /* a dummy ID for AMP Audio2000 */
34#endif
35#define VT1724_SUBDEVICE_AV710 0x12142417 /* AV710 - the same ID with Audio2000! */
36
37/* WM8728 on I2C for AV710 */
38#define WM_DEV 0x36
39
40#define WM_ATTEN_L 0x00
41#define WM_ATTEN_R 0x01
42#define WM_DAC_CTRL 0x02
43#define WM_INT_CTRL 0x03
30 44
31extern struct snd_ice1712_card_info snd_vt1724_amp_cards[]; 45extern struct snd_ice1712_card_info snd_vt1724_amp_cards[];
32 46
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 79fba6be3503..a2545a5b26c4 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -2748,7 +2748,7 @@ static struct pci_driver driver = {
2748 2748
2749static int __init alsa_card_ice1712_init(void) 2749static int __init alsa_card_ice1712_init(void)
2750{ 2750{
2751 return pci_module_init(&driver); 2751 return pci_register_driver(&driver);
2752} 2752}
2753 2753
2754static void __exit alsa_card_ice1712_exit(void) 2754static void __exit alsa_card_ice1712_exit(void)
diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h
index 8bb1c58c26a0..5ad4728daa7b 100644
--- a/sound/pci/ice1712/ice1712.h
+++ b/sound/pci/ice1712/ice1712.h
@@ -373,6 +373,11 @@ struct _snd_ice1712 {
373 unsigned short master[2]; 373 unsigned short master[2];
374 unsigned short vol[8]; 374 unsigned short vol[8];
375 } aureon; 375 } aureon;
376 /* AC97 register cache for Phase28 */
377 struct phase28_spec {
378 unsigned short master[2];
379 unsigned short vol[8];
380 } phase28;
376 /* Hoontech-specific setting */ 381 /* Hoontech-specific setting */
377 struct hoontech_spec { 382 struct hoontech_spec {
378 unsigned char boxbits[4]; 383 unsigned char boxbits[4];
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 95500f06f0c6..79b5f12e06fc 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -2328,7 +2328,7 @@ static struct pci_driver driver = {
2328 2328
2329static int __init alsa_card_ice1724_init(void) 2329static int __init alsa_card_ice1724_init(void)
2330{ 2330{
2331 return pci_module_init(&driver); 2331 return pci_register_driver(&driver);
2332} 2332}
2333 2333
2334static void __exit alsa_card_ice1724_exit(void) 2334static void __exit alsa_card_ice1724_exit(void)
diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c
index d1f90832443c..5bf734b04fa0 100644
--- a/sound/pci/ice1712/phase.c
+++ b/sound/pci/ice1712/phase.c
@@ -45,6 +45,47 @@
45#include "envy24ht.h" 45#include "envy24ht.h"
46#include "phase.h" 46#include "phase.h"
47 47
48/* WM8770 registers */
49#define WM_DAC_ATTEN 0x00 /* DAC1-8 analog attenuation */
50#define WM_DAC_MASTER_ATTEN 0x08 /* DAC master analog attenuation */
51#define WM_DAC_DIG_ATTEN 0x09 /* DAC1-8 digital attenuation */
52#define WM_DAC_DIG_MASTER_ATTEN 0x11 /* DAC master digital attenuation */
53#define WM_PHASE_SWAP 0x12 /* DAC phase */
54#define WM_DAC_CTRL1 0x13 /* DAC control bits */
55#define WM_MUTE 0x14 /* mute controls */
56#define WM_DAC_CTRL2 0x15 /* de-emphasis and zefo-flag */
57#define WM_INT_CTRL 0x16 /* interface control */
58#define WM_MASTER 0x17 /* master clock and mode */
59#define WM_POWERDOWN 0x18 /* power-down controls */
60#define WM_ADC_GAIN 0x19 /* ADC gain L(19)/R(1a) */
61#define WM_ADC_MUX 0x1b /* input MUX */
62#define WM_OUT_MUX1 0x1c /* output MUX */
63#define WM_OUT_MUX2 0x1e /* output MUX */
64#define WM_RESET 0x1f /* software reset */
65
66
67/*
68 * Logarithmic volume values for WM8770
69 * Computed as 20 * Log10(255 / x)
70 */
71static unsigned char wm_vol[256] = {
72 127, 48, 42, 39, 36, 34, 33, 31, 30, 29, 28, 27, 27, 26, 25, 25, 24, 24, 23,
73 23, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17,
74 17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 13,
75 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11,
76 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8,
77 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6,
78 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
79 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3,
80 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
81 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
82 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
83 0, 0
84};
85
86#define WM_VOL_MAX (sizeof(wm_vol) - 1)
87#define WM_VOL_MUTE 0x8000
88
48static akm4xxx_t akm_phase22 __devinitdata = { 89static akm4xxx_t akm_phase22 __devinitdata = {
49 .type = SND_AK4524, 90 .type = SND_AK4524,
50 .num_dacs = 2, 91 .num_dacs = 2,
@@ -124,6 +165,684 @@ static unsigned char phase22_eeprom[] __devinitdata = {
124 0x00, /* GPIO_STATE2 */ 165 0x00, /* GPIO_STATE2 */
125}; 166};
126 167
168static unsigned char phase28_eeprom[] __devinitdata = {
169 0x0b, /* SYSCONF: clock 512, spdif-in/ADC, 4DACs */
170 0x80, /* ACLINK: I2S */
171 0xfc, /* I2S: vol, 96k, 24bit, 192k */
172 0xc3, /* SPDIF: out-en, out-int, spdif-in */
173 0xff, /* GPIO_DIR */
174 0xff, /* GPIO_DIR1 */
175 0x5f, /* GPIO_DIR2 */
176 0x00, /* GPIO_MASK */
177 0x00, /* GPIO_MASK1 */
178 0x00, /* GPIO_MASK2 */
179 0x00, /* GPIO_STATE */
180 0x00, /* GPIO_STATE1 */
181 0x00, /* GPIO_STATE2 */
182};
183
184/*
185 * write data in the SPI mode
186 */
187static void phase28_spi_write(ice1712_t *ice, unsigned int cs, unsigned int data, int bits)
188{
189 unsigned int tmp;
190 int i;
191
192 tmp = snd_ice1712_gpio_read(ice);
193
194 snd_ice1712_gpio_set_mask(ice, ~(PHASE28_WM_RW|PHASE28_SPI_MOSI|PHASE28_SPI_CLK|
195 PHASE28_WM_CS));
196 tmp |= PHASE28_WM_RW;
197 tmp &= ~cs;
198 snd_ice1712_gpio_write(ice, tmp);
199 udelay(1);
200
201 for (i = bits - 1; i >= 0; i--) {
202 tmp &= ~PHASE28_SPI_CLK;
203 snd_ice1712_gpio_write(ice, tmp);
204 udelay(1);
205 if (data & (1 << i))
206 tmp |= PHASE28_SPI_MOSI;
207 else
208 tmp &= ~PHASE28_SPI_MOSI;
209 snd_ice1712_gpio_write(ice, tmp);
210 udelay(1);
211 tmp |= PHASE28_SPI_CLK;
212 snd_ice1712_gpio_write(ice, tmp);
213 udelay(1);
214 }
215
216 tmp &= ~PHASE28_SPI_CLK;
217 tmp |= cs;
218 snd_ice1712_gpio_write(ice, tmp);
219 udelay(1);
220 tmp |= PHASE28_SPI_CLK;
221 snd_ice1712_gpio_write(ice, tmp);
222 udelay(1);
223}
224
225/*
226 * get the current register value of WM codec
227 */
228static unsigned short wm_get(ice1712_t *ice, int reg)
229{
230 reg <<= 1;
231 return ((unsigned short)ice->akm[0].images[reg] << 8) |
232 ice->akm[0].images[reg + 1];
233}
234
235/*
236 * set the register value of WM codec
237 */
238static void wm_put_nocache(ice1712_t *ice, int reg, unsigned short val)
239{
240 phase28_spi_write(ice, PHASE28_WM_CS, (reg << 9) | (val & 0x1ff), 16);
241}
242
243/*
244 * set the register value of WM codec and remember it
245 */
246static void wm_put(ice1712_t *ice, int reg, unsigned short val)
247{
248 wm_put_nocache(ice, reg, val);
249 reg <<= 1;
250 ice->akm[0].images[reg] = val >> 8;
251 ice->akm[0].images[reg + 1] = val;
252}
253
254static void wm_set_vol(ice1712_t *ice, unsigned int index, unsigned short vol, unsigned short master)
255{
256 unsigned char nvol;
257
258 if ((master & WM_VOL_MUTE) || (vol & WM_VOL_MUTE))
259 nvol = 0;
260 else
261 nvol = 127 - wm_vol[(((vol & ~WM_VOL_MUTE) * (master & ~WM_VOL_MUTE)) / 127) & WM_VOL_MAX];
262
263 wm_put(ice, index, nvol);
264 wm_put_nocache(ice, index, 0x180 | nvol);
265}
266
267/*
268 * DAC mute control
269 */
270#define wm_pcm_mute_info phase28_mono_bool_info
271
272static int wm_pcm_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
273{
274 ice1712_t *ice = snd_kcontrol_chip(kcontrol);
275
276 down(&ice->gpio_mutex);
277 ucontrol->value.integer.value[0] = (wm_get(ice, WM_MUTE) & 0x10) ? 0 : 1;
278 up(&ice->gpio_mutex);
279 return 0;
280}
281
282static int wm_pcm_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
283{
284 ice1712_t *ice = snd_kcontrol_chip(kcontrol);
285 unsigned short nval, oval;
286 int change;
287
288 snd_ice1712_save_gpio_status(ice);
289 oval = wm_get(ice, WM_MUTE);
290 nval = (oval & ~0x10) | (ucontrol->value.integer.value[0] ? 0 : 0x10);
291 if ((change = (nval != oval)))
292 wm_put(ice, WM_MUTE, nval);
293 snd_ice1712_restore_gpio_status(ice);
294
295 return change;
296}
297
298/*
299 * Master volume attenuation mixer control
300 */
301static int wm_master_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
302{
303 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
304 uinfo->count = 2;
305 uinfo->value.integer.min = 0;
306 uinfo->value.integer.max = WM_VOL_MAX;
307 return 0;
308}
309
310static int wm_master_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
311{
312 ice1712_t *ice = snd_kcontrol_chip(kcontrol);
313 int i;
314 for (i=0; i<2; i++)
315 ucontrol->value.integer.value[i] = ice->spec.phase28.master[i] & ~WM_VOL_MUTE;
316 return 0;
317}
318
319static int wm_master_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
320{
321 ice1712_t *ice = snd_kcontrol_chip(kcontrol);
322 int ch, change = 0;
323
324 snd_ice1712_save_gpio_status(ice);
325 for (ch = 0; ch < 2; ch++) {
326 if (ucontrol->value.integer.value[ch] != ice->spec.phase28.master[ch]) {
327 int dac;
328 ice->spec.phase28.master[ch] &= WM_VOL_MUTE;
329 ice->spec.phase28.master[ch] |= ucontrol->value.integer.value[ch];
330 for (dac = 0; dac < ice->num_total_dacs; dac += 2)
331 wm_set_vol(ice, WM_DAC_ATTEN + dac + ch,
332 ice->spec.phase28.vol[dac + ch],
333 ice->spec.phase28.master[ch]);
334 change = 1;
335 }
336 }
337 snd_ice1712_restore_gpio_status(ice);
338 return change;
339}
340
341static int __devinit phase28_init(ice1712_t *ice)
342{
343 static unsigned short wm_inits_phase28[] = {
344 /* These come first to reduce init pop noise */
345 0x1b, 0x044, /* ADC Mux (AC'97 source) */
346 0x1c, 0x00B, /* Out Mux1 (VOUT1 = DAC+AUX, VOUT2 = DAC) */
347 0x1d, 0x009, /* Out Mux2 (VOUT2 = DAC, VOUT3 = DAC) */
348
349 0x18, 0x000, /* All power-up */
350
351 0x16, 0x122, /* I2S, normal polarity, 24bit */
352 0x17, 0x022, /* 256fs, slave mode */
353 0x00, 0, /* DAC1 analog mute */
354 0x01, 0, /* DAC2 analog mute */
355 0x02, 0, /* DAC3 analog mute */
356 0x03, 0, /* DAC4 analog mute */
357 0x04, 0, /* DAC5 analog mute */
358 0x05, 0, /* DAC6 analog mute */
359 0x06, 0, /* DAC7 analog mute */
360 0x07, 0, /* DAC8 analog mute */
361 0x08, 0x100, /* master analog mute */
362 0x09, 0xff, /* DAC1 digital full */
363 0x0a, 0xff, /* DAC2 digital full */
364 0x0b, 0xff, /* DAC3 digital full */
365 0x0c, 0xff, /* DAC4 digital full */
366 0x0d, 0xff, /* DAC5 digital full */
367 0x0e, 0xff, /* DAC6 digital full */
368 0x0f, 0xff, /* DAC7 digital full */
369 0x10, 0xff, /* DAC8 digital full */
370 0x11, 0x1ff, /* master digital full */
371 0x12, 0x000, /* phase normal */
372 0x13, 0x090, /* unmute DAC L/R */
373 0x14, 0x000, /* all unmute */
374 0x15, 0x000, /* no deemphasis, no ZFLG */
375 0x19, 0x000, /* -12dB ADC/L */
376 0x1a, 0x000, /* -12dB ADC/R */
377 (unsigned short)-1
378 };
379
380 unsigned int tmp;
381 akm4xxx_t *ak;
382 unsigned short *p;
383 int i;
384
385 ice->num_total_dacs = 8;
386 ice->num_total_adcs = 2;
387
388 // Initialize analog chips
389 ak = ice->akm = kcalloc(1, sizeof(akm4xxx_t), GFP_KERNEL);
390 if (!ak)
391 return -ENOMEM;
392 ice->akm_codecs = 1;
393
394 snd_ice1712_gpio_set_dir(ice, 0x5fffff); /* fix this for the time being */
395
396 /* reset the wm codec as the SPI mode */
397 snd_ice1712_save_gpio_status(ice);
398 snd_ice1712_gpio_set_mask(ice, ~(PHASE28_WM_RESET|PHASE28_WM_CS|PHASE28_HP_SEL));
399
400 tmp = snd_ice1712_gpio_read(ice);
401 tmp &= ~PHASE28_WM_RESET;
402 snd_ice1712_gpio_write(ice, tmp);
403 udelay(1);
404 tmp |= PHASE28_WM_CS;
405 snd_ice1712_gpio_write(ice, tmp);
406 udelay(1);
407 tmp |= PHASE28_WM_RESET;
408 snd_ice1712_gpio_write(ice, tmp);
409 udelay(1);
410
411 p = wm_inits_phase28;
412 for (; *p != (unsigned short)-1; p += 2)
413 wm_put(ice, p[0], p[1]);
414
415 snd_ice1712_restore_gpio_status(ice);
416
417 ice->spec.phase28.master[0] = WM_VOL_MUTE;
418 ice->spec.phase28.master[1] = WM_VOL_MUTE;
419 for (i = 0; i < ice->num_total_dacs; i++) {
420 ice->spec.phase28.vol[i] = WM_VOL_MUTE;
421 wm_set_vol(ice, i, ice->spec.phase28.vol[i], ice->spec.phase28.master[i % 2]);
422 }
423
424 return 0;
425}
426
427/*
428 * DAC volume attenuation mixer control
429 */
430static int wm_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
431{
432 int voices = kcontrol->private_value >> 8;
433 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
434 uinfo->count = voices;
435 uinfo->value.integer.min = 0; /* mute (-101dB) */
436 uinfo->value.integer.max = 0x7F; /* 0dB */
437 return 0;
438}
439
440static int wm_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
441{
442 ice1712_t *ice = snd_kcontrol_chip(kcontrol);
443 int i, ofs, voices;
444
445 voices = kcontrol->private_value >> 8;
446 ofs = kcontrol->private_value & 0xff;
447 for (i = 0; i < voices; i++)
448 ucontrol->value.integer.value[i] = ice->spec.phase28.vol[ofs+i] & ~WM_VOL_MUTE;
449 return 0;
450}
451
452static int wm_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
453{
454 ice1712_t *ice = snd_kcontrol_chip(kcontrol);
455 int i, idx, ofs, voices;
456 int change = 0;
457
458 voices = kcontrol->private_value >> 8;
459 ofs = kcontrol->private_value & 0xff;
460 snd_ice1712_save_gpio_status(ice);
461 for (i = 0; i < voices; i++) {
462 idx = WM_DAC_ATTEN + ofs + i;
463 if (ucontrol->value.integer.value[i] != ice->spec.phase28.vol[ofs+i]) {
464 ice->spec.phase28.vol[ofs+i] &= WM_VOL_MUTE;
465 ice->spec.phase28.vol[ofs+i] |= ucontrol->value.integer.value[i];
466 wm_set_vol(ice, idx, ice->spec.phase28.vol[ofs+i],
467 ice->spec.phase28.master[i]);
468 change = 1;
469 }
470 }
471 snd_ice1712_restore_gpio_status(ice);
472 return change;
473}
474
475/*
476 * WM8770 mute control
477 */
478static int wm_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) {
479 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
480 uinfo->count = kcontrol->private_value >> 8;
481 uinfo->value.integer.min = 0;
482 uinfo->value.integer.max = 1;
483 return 0;
484}
485
486static int wm_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
487{
488 ice1712_t *ice = snd_kcontrol_chip(kcontrol);
489 int voices, ofs, i;
490
491 voices = kcontrol->private_value >> 8;
492 ofs = kcontrol->private_value & 0xFF;
493
494 for (i = 0; i < voices; i++)
495 ucontrol->value.integer.value[i] = (ice->spec.phase28.vol[ofs+i] & WM_VOL_MUTE) ? 0 : 1;
496 return 0;
497}
498
499static int wm_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
500{
501 ice1712_t *ice = snd_kcontrol_chip(kcontrol);
502 int change = 0, voices, ofs, i;
503
504 voices = kcontrol->private_value >> 8;
505 ofs = kcontrol->private_value & 0xFF;
506
507 snd_ice1712_save_gpio_status(ice);
508 for (i = 0; i < voices; i++) {
509 int val = (ice->spec.phase28.vol[ofs + i] & WM_VOL_MUTE) ? 0 : 1;
510 if (ucontrol->value.integer.value[i] != val) {
511 ice->spec.phase28.vol[ofs + i] &= ~WM_VOL_MUTE;
512 ice->spec.phase28.vol[ofs + i] |=
513 ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE;
514 wm_set_vol(ice, ofs + i, ice->spec.phase28.vol[ofs + i],
515 ice->spec.phase28.master[i]);
516 change = 1;
517 }
518 }
519 snd_ice1712_restore_gpio_status(ice);
520
521 return change;
522}
523
524/*
525 * WM8770 master mute control
526 */
527static int wm_master_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) {
528 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
529 uinfo->count = 2;
530 uinfo->value.integer.min = 0;
531 uinfo->value.integer.max = 1;
532 return 0;
533}
534
535static int wm_master_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
536{
537 ice1712_t *ice = snd_kcontrol_chip(kcontrol);
538
539 ucontrol->value.integer.value[0] = (ice->spec.phase28.master[0] & WM_VOL_MUTE) ? 0 : 1;
540 ucontrol->value.integer.value[1] = (ice->spec.phase28.master[1] & WM_VOL_MUTE) ? 0 : 1;
541 return 0;
542}
543
544static int wm_master_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
545{
546 ice1712_t *ice = snd_kcontrol_chip(kcontrol);
547 int change = 0, i;
548
549 snd_ice1712_save_gpio_status(ice);
550 for (i = 0; i < 2; i++) {
551 int val = (ice->spec.phase28.master[i] & WM_VOL_MUTE) ? 0 : 1;
552 if (ucontrol->value.integer.value[i] != val) {
553 int dac;
554 ice->spec.phase28.master[i] &= ~WM_VOL_MUTE;
555 ice->spec.phase28.master[i] |=
556 ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE;
557 for (dac = 0; dac < ice->num_total_dacs; dac += 2)
558 wm_set_vol(ice, WM_DAC_ATTEN + dac + i,
559 ice->spec.phase28.vol[dac + i],
560 ice->spec.phase28.master[i]);
561 change = 1;
562 }
563 }
564 snd_ice1712_restore_gpio_status(ice);
565
566 return change;
567}
568
569/* digital master volume */
570#define PCM_0dB 0xff
571#define PCM_RES 128 /* -64dB */
572#define PCM_MIN (PCM_0dB - PCM_RES)
573static int wm_pcm_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
574{
575 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
576 uinfo->count = 1;
577 uinfo->value.integer.min = 0; /* mute (-64dB) */
578 uinfo->value.integer.max = PCM_RES; /* 0dB */
579 return 0;
580}
581
582static int wm_pcm_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
583{
584 ice1712_t *ice = snd_kcontrol_chip(kcontrol);
585 unsigned short val;
586
587 down(&ice->gpio_mutex);
588 val = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff;
589 val = val > PCM_MIN ? (val - PCM_MIN) : 0;
590 ucontrol->value.integer.value[0] = val;
591 up(&ice->gpio_mutex);
592 return 0;
593}
594
595static int wm_pcm_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
596{
597 ice1712_t *ice = snd_kcontrol_chip(kcontrol);
598 unsigned short ovol, nvol;
599 int change = 0;
600
601 snd_ice1712_save_gpio_status(ice);
602 nvol = ucontrol->value.integer.value[0];
603 nvol = (nvol ? (nvol + PCM_MIN) : 0) & 0xff;
604 ovol = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff;
605 if (ovol != nvol) {
606 wm_put(ice, WM_DAC_DIG_MASTER_ATTEN, nvol); /* prelatch */
607 wm_put_nocache(ice, WM_DAC_DIG_MASTER_ATTEN, nvol | 0x100); /* update */
608 change = 1;
609 }
610 snd_ice1712_restore_gpio_status(ice);
611 return change;
612}
613
614/*
615 */
616static int phase28_mono_bool_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo)
617{
618 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
619 uinfo->count = 1;
620 uinfo->value.integer.min = 0;
621 uinfo->value.integer.max = 1;
622 return 0;
623}
624
625/*
626 * Deemphasis
627 */
628#define phase28_deemp_info phase28_mono_bool_info
629
630static int phase28_deemp_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
631{
632 ice1712_t *ice = snd_kcontrol_chip(kcontrol);
633 ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL2) & 0xf) == 0xf;
634 return 0;
635}
636
637static int phase28_deemp_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
638{
639 ice1712_t *ice = snd_kcontrol_chip(kcontrol);
640 int temp, temp2;
641 temp2 = temp = wm_get(ice, WM_DAC_CTRL2);
642 if (ucontrol->value.integer.value[0])
643 temp |= 0xf;
644 else
645 temp &= ~0xf;
646 if (temp != temp2) {
647 wm_put(ice, WM_DAC_CTRL2, temp);
648 return 1;
649 }
650 return 0;
651}
652
653/*
654 * ADC Oversampling
655 */
656static int phase28_oversampling_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo)
657{
658 static char *texts[2] = { "128x", "64x" };
659
660 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
661 uinfo->count = 1;
662 uinfo->value.enumerated.items = 2;
663
664 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
665 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
666 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
667
668 return 0;
669}
670
671static int phase28_oversampling_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
672{
673 ice1712_t *ice = snd_kcontrol_chip(kcontrol);
674 ucontrol->value.enumerated.item[0] = (wm_get(ice, WM_MASTER) & 0x8) == 0x8;
675 return 0;
676}
677
678static int phase28_oversampling_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
679{
680 int temp, temp2;
681 ice1712_t *ice = snd_kcontrol_chip(kcontrol);
682
683 temp2 = temp = wm_get(ice, WM_MASTER);
684
685 if (ucontrol->value.enumerated.item[0])
686 temp |= 0x8;
687 else
688 temp &= ~0x8;
689
690 if (temp != temp2) {
691 wm_put(ice, WM_MASTER, temp);
692 return 1;
693 }
694 return 0;
695}
696
697static snd_kcontrol_new_t phase28_dac_controls[] __devinitdata = {
698 {
699 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
700 .name = "Master Playback Switch",
701 .info = wm_master_mute_info,
702 .get = wm_master_mute_get,
703 .put = wm_master_mute_put
704 },
705 {
706 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
707 .name = "Master Playback Volume",
708 .info = wm_master_vol_info,
709 .get = wm_master_vol_get,
710 .put = wm_master_vol_put
711 },
712 {
713 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
714 .name = "Front Playback Switch",
715 .info = wm_mute_info,
716 .get = wm_mute_get,
717 .put = wm_mute_put,
718 .private_value = (2 << 8) | 0
719 },
720 {
721 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
722 .name = "Front Playback Volume",
723 .info = wm_vol_info,
724 .get = wm_vol_get,
725 .put = wm_vol_put,
726 .private_value = (2 << 8) | 0
727 },
728 {
729 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
730 .name = "Rear Playback Switch",
731 .info = wm_mute_info,
732 .get = wm_mute_get,
733 .put = wm_mute_put,
734 .private_value = (2 << 8) | 2
735 },
736 {
737 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
738 .name = "Rear Playback Volume",
739 .info = wm_vol_info,
740 .get = wm_vol_get,
741 .put = wm_vol_put,
742 .private_value = (2 << 8) | 2
743 },
744 {
745 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
746 .name = "Center Playback Switch",
747 .info = wm_mute_info,
748 .get = wm_mute_get,
749 .put = wm_mute_put,
750 .private_value = (1 << 8) | 4
751 },
752 {
753 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
754 .name = "Center Playback Volume",
755 .info = wm_vol_info,
756 .get = wm_vol_get,
757 .put = wm_vol_put,
758 .private_value = (1 << 8) | 4
759 },
760 {
761 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
762 .name = "LFE Playback Switch",
763 .info = wm_mute_info,
764 .get = wm_mute_get,
765 .put = wm_mute_put,
766 .private_value = (1 << 8) | 5
767 },
768 {
769 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
770 .name = "LFE Playback Volume",
771 .info = wm_vol_info,
772 .get = wm_vol_get,
773 .put = wm_vol_put,
774 .private_value = (1 << 8) | 5
775 },
776 {
777 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
778 .name = "Side Playback Switch",
779 .info = wm_mute_info,
780 .get = wm_mute_get,
781 .put = wm_mute_put,
782 .private_value = (2 << 8) | 6
783 },
784 {
785 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
786 .name = "Side Playback Volume",
787 .info = wm_vol_info,
788 .get = wm_vol_get,
789 .put = wm_vol_put,
790 .private_value = (2 << 8) | 6
791 }
792};
793
794static snd_kcontrol_new_t wm_controls[] __devinitdata = {
795 {
796 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
797 .name = "PCM Playback Switch",
798 .info = wm_pcm_mute_info,
799 .get = wm_pcm_mute_get,
800 .put = wm_pcm_mute_put
801 },
802 {
803 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
804 .name = "PCM Playback Volume",
805 .info = wm_pcm_vol_info,
806 .get = wm_pcm_vol_get,
807 .put = wm_pcm_vol_put
808 },
809 {
810 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
811 .name = "DAC Deemphasis Switch",
812 .info = phase28_deemp_info,
813 .get = phase28_deemp_get,
814 .put = phase28_deemp_put
815 },
816 {
817 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
818 .name = "ADC Oversampling",
819 .info = phase28_oversampling_info,
820 .get = phase28_oversampling_get,
821 .put = phase28_oversampling_put
822 }
823};
824
825static int __devinit phase28_add_controls(ice1712_t *ice)
826{
827 unsigned int i, counts;
828 int err;
829
830 counts = ARRAY_SIZE(phase28_dac_controls);
831 for (i = 0; i < counts; i++) {
832 err = snd_ctl_add(ice->card, snd_ctl_new1(&phase28_dac_controls[i], ice));
833 if (err < 0)
834 return err;
835 }
836
837 for (i = 0; i < ARRAY_SIZE(wm_controls); i++) {
838 err = snd_ctl_add(ice->card, snd_ctl_new1(&wm_controls[i], ice));
839 if (err < 0)
840 return err;
841 }
842
843 return 0;
844}
845
127struct snd_ice1712_card_info snd_vt1724_phase_cards[] __devinitdata = { 846struct snd_ice1712_card_info snd_vt1724_phase_cards[] __devinitdata = {
128 { 847 {
129 .subvendor = VT1724_SUBDEVICE_PHASE22, 848 .subvendor = VT1724_SUBDEVICE_PHASE22,
@@ -134,5 +853,14 @@ struct snd_ice1712_card_info snd_vt1724_phase_cards[] __devinitdata = {
134 .eeprom_size = sizeof(phase22_eeprom), 853 .eeprom_size = sizeof(phase22_eeprom),
135 .eeprom_data = phase22_eeprom, 854 .eeprom_data = phase22_eeprom,
136 }, 855 },
856 {
857 .subvendor = VT1724_SUBDEVICE_PHASE28,
858 .name = "Terratec PHASE 28",
859 .model = "phase28",
860 .chip_init = phase28_init,
861 .build_controls = phase28_add_controls,
862 .eeprom_size = sizeof(phase28_eeprom),
863 .eeprom_data = phase28_eeprom,
864 },
137 { } /* terminator */ 865 { } /* terminator */
138}; 866};
diff --git a/sound/pci/ice1712/phase.h b/sound/pci/ice1712/phase.h
index 6230cf16989f..13e841b55488 100644
--- a/sound/pci/ice1712/phase.h
+++ b/sound/pci/ice1712/phase.h
@@ -24,11 +24,28 @@
24 * 24 *
25 */ 25 */
26 26
27#define PHASE_DEVICE_DESC "{Terratec,Phase 22}," 27#define PHASE_DEVICE_DESC "{Terratec,Phase 22},"\
28 "{Terratec,Phase 28},"
28 29
29#define VT1724_SUBDEVICE_PHASE22 0x3b155011 30#define VT1724_SUBDEVICE_PHASE22 0x3b155011
31#define VT1724_SUBDEVICE_PHASE28 0x3b154911
30 32
31/* entry point */ 33/* entry point */
32extern struct snd_ice1712_card_info snd_vt1724_phase_cards[]; 34extern struct snd_ice1712_card_info snd_vt1724_phase_cards[];
33 35
36/* PHASE28 GPIO bits */
37#define PHASE28_SPI_MISO (1 << 21)
38#define PHASE28_WM_RESET (1 << 20)
39#define PHASE28_SPI_CLK (1 << 19)
40#define PHASE28_SPI_MOSI (1 << 18)
41#define PHASE28_WM_RW (1 << 17)
42#define PHASE28_AC97_RESET (1 << 16)
43#define PHASE28_DIGITAL_SEL1 (1 << 15)
44#define PHASE28_HP_SEL (1 << 14)
45#define PHASE28_WM_CS (1 << 12)
46#define PHASE28_AC97_COMMIT (1 << 11)
47#define PHASE28_AC97_ADDR (1 << 10)
48#define PHASE28_AC97_DATA_LOW (1 << 9)
49#define PHASE28_AC97_DATA_HIGH (1 << 8)
50#define PHASE28_AC97_DATA_MASK 0xFF
34#endif /* __SOUND_PHASE */ 51#endif /* __SOUND_PHASE */
diff --git a/sound/pci/ice1712/vt1720_mobo.c b/sound/pci/ice1712/vt1720_mobo.c
index 3bd92627231c..ab61e383024f 100644
--- a/sound/pci/ice1712/vt1720_mobo.c
+++ b/sound/pci/ice1712/vt1720_mobo.c
@@ -110,6 +110,15 @@ struct snd_ice1712_card_info snd_vt1720_mobo_cards[] __devinitdata = {
110 .eeprom_size = sizeof(k8x800_eeprom), 110 .eeprom_size = sizeof(k8x800_eeprom),
111 .eeprom_data = k8x800_eeprom, 111 .eeprom_data = k8x800_eeprom,
112 }, 112 },
113 {
114 .subvendor = VT1720_SUBDEVICE_SN25P,
115 .name = "Shuttle SN25P",
116 /* identical with k8x800 */
117 .chip_init = k8x800_init,
118 .build_controls = k8x800_add_controls,
119 .eeprom_size = sizeof(k8x800_eeprom),
120 .eeprom_data = k8x800_eeprom,
121 },
113 { } /* terminator */ 122 { } /* terminator */
114}; 123};
115 124
diff --git a/sound/pci/ice1712/vt1720_mobo.h b/sound/pci/ice1712/vt1720_mobo.h
index f949eb804cae..0b1b0ee1bea7 100644
--- a/sound/pci/ice1712/vt1720_mobo.h
+++ b/sound/pci/ice1712/vt1720_mobo.h
@@ -27,12 +27,14 @@
27#define VT1720_MOBO_DEVICE_DESC "{Albatron,K8X800 Pro II},"\ 27#define VT1720_MOBO_DEVICE_DESC "{Albatron,K8X800 Pro II},"\
28 "{Chaintech,ZNF3-150},"\ 28 "{Chaintech,ZNF3-150},"\
29 "{Chaintech,ZNF3-250},"\ 29 "{Chaintech,ZNF3-250},"\
30 "{Chaintech,9CJS}," 30 "{Chaintech,9CJS},"\
31 "{Shuttle,SN25P},"
31 32
32#define VT1720_SUBDEVICE_K8X800 0xf217052c 33#define VT1720_SUBDEVICE_K8X800 0xf217052c
33#define VT1720_SUBDEVICE_ZNF3_150 0x0f2741f6 34#define VT1720_SUBDEVICE_ZNF3_150 0x0f2741f6
34#define VT1720_SUBDEVICE_ZNF3_250 0x0f2745f6 35#define VT1720_SUBDEVICE_ZNF3_250 0x0f2745f6
35#define VT1720_SUBDEVICE_9CJS 0x0f272327 36#define VT1720_SUBDEVICE_9CJS 0x0f272327
37#define VT1720_SUBDEVICE_SN25P 0x97123650
36 38
37extern struct snd_ice1712_card_info snd_vt1720_mobo_cards[]; 39extern struct snd_ice1712_card_info snd_vt1720_mobo_cards[];
38 40
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 8b33b12fa5dc..cc16f95f9cef 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -1725,229 +1725,235 @@ static struct ac97_pcm ac97_pcm_defs[] __devinitdata = {
1725 1725
1726static struct ac97_quirk ac97_quirks[] __devinitdata = { 1726static struct ac97_quirk ac97_quirks[] __devinitdata = {
1727 { 1727 {
1728 .vendor = 0x0e11, 1728 .subvendor = 0x0e11,
1729 .device = 0x008a, 1729 .subdevice = 0x008a,
1730 .name = "Compaq Evo W4000", /* AD1885 */ 1730 .name = "Compaq Evo W4000", /* AD1885 */
1731 .type = AC97_TUNE_HP_ONLY 1731 .type = AC97_TUNE_HP_ONLY
1732 }, 1732 },
1733 { 1733 {
1734 .vendor = 0x0e11, 1734 .subvendor = 0x0e11,
1735 .device = 0x00b8, 1735 .subdevice = 0x00b8,
1736 .name = "Compaq Evo D510C", 1736 .name = "Compaq Evo D510C",
1737 .type = AC97_TUNE_HP_ONLY 1737 .type = AC97_TUNE_HP_ONLY
1738 }, 1738 },
1739 { 1739 {
1740 .vendor = 0x0e11, 1740 .subvendor = 0x0e11,
1741 .device = 0x0860, 1741 .subdevice = 0x0860,
1742 .name = "HP/Compaq nx7010", 1742 .name = "HP/Compaq nx7010",
1743 .type = AC97_TUNE_MUTE_LED 1743 .type = AC97_TUNE_MUTE_LED
1744 }, 1744 },
1745 { 1745 {
1746 .vendor = 0x1014, 1746 .subvendor = 0x1014,
1747 .device = 0x1f00, 1747 .subdevice = 0x1f00,
1748 .name = "MS-9128", 1748 .name = "MS-9128",
1749 .type = AC97_TUNE_ALC_JACK 1749 .type = AC97_TUNE_ALC_JACK
1750 }, 1750 },
1751 { 1751 {
1752 .vendor = 0x1028, 1752 .subvendor = 0x1028,
1753 .device = 0x00d8, 1753 .subdevice = 0x00d8,
1754 .name = "Dell Precision 530", /* AD1885 */ 1754 .name = "Dell Precision 530", /* AD1885 */
1755 .type = AC97_TUNE_HP_ONLY 1755 .type = AC97_TUNE_HP_ONLY
1756 }, 1756 },
1757 { 1757 {
1758 .vendor = 0x1028, 1758 .subvendor = 0x1028,
1759 .device = 0x010d, 1759 .subdevice = 0x010d,
1760 .name = "Dell", /* which model? AD1885 */ 1760 .name = "Dell", /* which model? AD1885 */
1761 .type = AC97_TUNE_HP_ONLY 1761 .type = AC97_TUNE_HP_ONLY
1762 }, 1762 },
1763 { 1763 {
1764 .vendor = 0x1028, 1764 .subvendor = 0x1028,
1765 .device = 0x0126, 1765 .subdevice = 0x0126,
1766 .name = "Dell Optiplex GX260", /* AD1981A */ 1766 .name = "Dell Optiplex GX260", /* AD1981A */
1767 .type = AC97_TUNE_HP_ONLY 1767 .type = AC97_TUNE_HP_ONLY
1768 }, 1768 },
1769 { 1769 {
1770 .vendor = 0x1028, 1770 .subvendor = 0x1028,
1771 .device = 0x012c, 1771 .subdevice = 0x012c,
1772 .name = "Dell Precision 650", /* AD1981A */ 1772 .name = "Dell Precision 650", /* AD1981A */
1773 .type = AC97_TUNE_HP_ONLY 1773 .type = AC97_TUNE_HP_ONLY
1774 }, 1774 },
1775 { 1775 {
1776 .vendor = 0x1028, 1776 .subvendor = 0x1028,
1777 .device = 0x012d, 1777 .subdevice = 0x012d,
1778 .name = "Dell Precision 450", /* AD1981B*/ 1778 .name = "Dell Precision 450", /* AD1981B*/
1779 .type = AC97_TUNE_HP_ONLY 1779 .type = AC97_TUNE_HP_ONLY
1780 }, 1780 },
1781 { 1781 {
1782 .vendor = 0x1028, 1782 .subvendor = 0x1028,
1783 .device = 0x0147, 1783 .subdevice = 0x0147,
1784 .name = "Dell", /* which model? AD1981B*/ 1784 .name = "Dell", /* which model? AD1981B*/
1785 .type = AC97_TUNE_HP_ONLY 1785 .type = AC97_TUNE_HP_ONLY
1786 }, 1786 },
1787 { 1787 {
1788 .vendor = 0x1028, 1788 .subvendor = 0x1028,
1789 .device = 0x0163, 1789 .subdevice = 0x0163,
1790 .name = "Dell Unknown", /* STAC9750/51 */ 1790 .name = "Dell Unknown", /* STAC9750/51 */
1791 .type = AC97_TUNE_HP_ONLY 1791 .type = AC97_TUNE_HP_ONLY
1792 }, 1792 },
1793 { 1793 {
1794 .vendor = 0x103c, 1794 .subvendor = 0x103c,
1795 .device = 0x006d, 1795 .subdevice = 0x006d,
1796 .name = "HP zv5000", 1796 .name = "HP zv5000",
1797 .type = AC97_TUNE_MUTE_LED /*AD1981B*/ 1797 .type = AC97_TUNE_MUTE_LED /*AD1981B*/
1798 }, 1798 },
1799 { /* FIXME: which codec? */ 1799 { /* FIXME: which codec? */
1800 .vendor = 0x103c, 1800 .subvendor = 0x103c,
1801 .device = 0x00c3, 1801 .subdevice = 0x00c3,
1802 .name = "HP xw6000", 1802 .name = "HP xw6000",
1803 .type = AC97_TUNE_HP_ONLY 1803 .type = AC97_TUNE_HP_ONLY
1804 }, 1804 },
1805 { 1805 {
1806 .vendor = 0x103c, 1806 .subvendor = 0x103c,
1807 .device = 0x088c, 1807 .subdevice = 0x088c,
1808 .name = "HP nc8000", 1808 .name = "HP nc8000",
1809 .type = AC97_TUNE_MUTE_LED 1809 .type = AC97_TUNE_MUTE_LED
1810 }, 1810 },
1811 { 1811 {
1812 .vendor = 0x103c, 1812 .subvendor = 0x103c,
1813 .device = 0x0890, 1813 .subdevice = 0x0890,
1814 .name = "HP nc6000", 1814 .name = "HP nc6000",
1815 .type = AC97_TUNE_MUTE_LED 1815 .type = AC97_TUNE_MUTE_LED
1816 }, 1816 },
1817 { 1817 {
1818 .vendor = 0x103c, 1818 .subvendor = 0x103c,
1819 .device = 0x129d, 1819 .subdevice = 0x129d,
1820 .name = "HP xw8000", 1820 .name = "HP xw8000",
1821 .type = AC97_TUNE_HP_ONLY 1821 .type = AC97_TUNE_HP_ONLY
1822 }, 1822 },
1823 { 1823 {
1824 .vendor = 0x103c, 1824 .subvendor = 0x103c,
1825 .device = 0x12f1, 1825 .subdevice = 0x12f1,
1826 .name = "HP xw8200", /* AD1981B*/ 1826 .name = "HP xw8200", /* AD1981B*/
1827 .type = AC97_TUNE_HP_ONLY 1827 .type = AC97_TUNE_HP_ONLY
1828 }, 1828 },
1829 { 1829 {
1830 .vendor = 0x103c, 1830 .subvendor = 0x103c,
1831 .device = 0x12f2, 1831 .subdevice = 0x12f2,
1832 .name = "HP xw6200", 1832 .name = "HP xw6200",
1833 .type = AC97_TUNE_HP_ONLY 1833 .type = AC97_TUNE_HP_ONLY
1834 }, 1834 },
1835 { 1835 {
1836 .vendor = 0x103c, 1836 .subvendor = 0x103c,
1837 .device = 0x3008, 1837 .subdevice = 0x3008,
1838 .name = "HP xw4200", /* AD1981B*/ 1838 .name = "HP xw4200", /* AD1981B*/
1839 .type = AC97_TUNE_HP_ONLY 1839 .type = AC97_TUNE_HP_ONLY
1840 }, 1840 },
1841 { 1841 {
1842 .vendor = 0x104d, 1842 .subvendor = 0x104d,
1843 .device = 0x8197, 1843 .subdevice = 0x8197,
1844 .name = "Sony S1XP", 1844 .name = "Sony S1XP",
1845 .type = AC97_TUNE_INV_EAPD 1845 .type = AC97_TUNE_INV_EAPD
1846 }, 1846 },
1847 { 1847 {
1848 .vendor = 0x1043, 1848 .subvendor = 0x1043,
1849 .device = 0x80f3, 1849 .subdevice = 0x80f3,
1850 .name = "ASUS ICH5/AD1985", 1850 .name = "ASUS ICH5/AD1985",
1851 .type = AC97_TUNE_AD_SHARING 1851 .type = AC97_TUNE_AD_SHARING
1852 }, 1852 },
1853 { 1853 {
1854 .vendor = 0x10cf, 1854 .subvendor = 0x10cf,
1855 .device = 0x11c3, 1855 .subdevice = 0x11c3,
1856 .name = "Fujitsu-Siemens E4010", 1856 .name = "Fujitsu-Siemens E4010",
1857 .type = AC97_TUNE_HP_ONLY 1857 .type = AC97_TUNE_HP_ONLY
1858 }, 1858 },
1859 { 1859 {
1860 .vendor = 0x10cf, 1860 .subvendor = 0x10cf,
1861 .device = 0x1253, 1861 .subdevice = 0x1225,
1862 .name = "Fujitsu-Siemens T3010",
1863 .type = AC97_TUNE_HP_ONLY
1864 },
1865 {
1866 .subvendor = 0x10cf,
1867 .subdevice = 0x1253,
1862 .name = "Fujitsu S6210", /* STAC9750/51 */ 1868 .name = "Fujitsu S6210", /* STAC9750/51 */
1863 .type = AC97_TUNE_HP_ONLY 1869 .type = AC97_TUNE_HP_ONLY
1864 }, 1870 },
1865 { 1871 {
1866 .vendor = 0x10f1, 1872 .subvendor = 0x10f1,
1867 .device = 0x2665, 1873 .subdevice = 0x2665,
1868 .name = "Fujitsu-Siemens Celsius", /* AD1981? */ 1874 .name = "Fujitsu-Siemens Celsius", /* AD1981? */
1869 .type = AC97_TUNE_HP_ONLY 1875 .type = AC97_TUNE_HP_ONLY
1870 }, 1876 },
1871 { 1877 {
1872 .vendor = 0x10f1, 1878 .subvendor = 0x10f1,
1873 .device = 0x2885, 1879 .subdevice = 0x2885,
1874 .name = "AMD64 Mobo", /* ALC650 */ 1880 .name = "AMD64 Mobo", /* ALC650 */
1875 .type = AC97_TUNE_HP_ONLY 1881 .type = AC97_TUNE_HP_ONLY
1876 }, 1882 },
1877 { 1883 {
1878 .vendor = 0x110a, 1884 .subvendor = 0x110a,
1879 .device = 0x0056, 1885 .subdevice = 0x0056,
1880 .name = "Fujitsu-Siemens Scenic", /* AD1981? */ 1886 .name = "Fujitsu-Siemens Scenic", /* AD1981? */
1881 .type = AC97_TUNE_HP_ONLY 1887 .type = AC97_TUNE_HP_ONLY
1882 }, 1888 },
1883 { 1889 {
1884 .vendor = 0x11d4, 1890 .subvendor = 0x11d4,
1885 .device = 0x5375, 1891 .subdevice = 0x5375,
1886 .name = "ADI AD1985 (discrete)", 1892 .name = "ADI AD1985 (discrete)",
1887 .type = AC97_TUNE_HP_ONLY 1893 .type = AC97_TUNE_HP_ONLY
1888 }, 1894 },
1889 { 1895 {
1890 .vendor = 0x1462, 1896 .subvendor = 0x1462,
1891 .device = 0x5470, 1897 .subdevice = 0x5470,
1892 .name = "MSI P4 ATX 645 Ultra", 1898 .name = "MSI P4 ATX 645 Ultra",
1893 .type = AC97_TUNE_HP_ONLY 1899 .type = AC97_TUNE_HP_ONLY
1894 }, 1900 },
1895 { 1901 {
1896 .vendor = 0x1734, 1902 .subvendor = 0x1734,
1897 .device = 0x0088, 1903 .subdevice = 0x0088,
1898 .name = "Fujitsu-Siemens D1522", /* AD1981 */ 1904 .name = "Fujitsu-Siemens D1522", /* AD1981 */
1899 .type = AC97_TUNE_HP_ONLY 1905 .type = AC97_TUNE_HP_ONLY
1900 }, 1906 },
1901 { 1907 {
1902 .vendor = 0x8086, 1908 .subvendor = 0x8086,
1903 .device = 0x2000, 1909 .subdevice = 0x2000,
1904 .mask = 0xfff0, 1910 .mask = 0xfff0,
1905 .name = "Intel ICH5/AD1985", 1911 .name = "Intel ICH5/AD1985",
1906 .type = AC97_TUNE_AD_SHARING 1912 .type = AC97_TUNE_AD_SHARING
1907 }, 1913 },
1908 { 1914 {
1909 .vendor = 0x8086, 1915 .subvendor = 0x8086,
1910 .device = 0x4000, 1916 .subdevice = 0x4000,
1911 .mask = 0xfff0, 1917 .mask = 0xfff0,
1912 .name = "Intel ICH5/AD1985", 1918 .name = "Intel ICH5/AD1985",
1913 .type = AC97_TUNE_AD_SHARING 1919 .type = AC97_TUNE_AD_SHARING
1914 }, 1920 },
1915 { 1921 {
1916 .vendor = 0x8086, 1922 .subvendor = 0x8086,
1917 .device = 0x4856, 1923 .subdevice = 0x4856,
1918 .name = "Intel D845WN (82801BA)", 1924 .name = "Intel D845WN (82801BA)",
1919 .type = AC97_TUNE_SWAP_HP 1925 .type = AC97_TUNE_SWAP_HP
1920 }, 1926 },
1921 { 1927 {
1922 .vendor = 0x8086, 1928 .subvendor = 0x8086,
1923 .device = 0x4d44, 1929 .subdevice = 0x4d44,
1924 .name = "Intel D850EMV2", /* AD1885 */ 1930 .name = "Intel D850EMV2", /* AD1885 */
1925 .type = AC97_TUNE_HP_ONLY 1931 .type = AC97_TUNE_HP_ONLY
1926 }, 1932 },
1927 { 1933 {
1928 .vendor = 0x8086, 1934 .subvendor = 0x8086,
1929 .device = 0x4d56, 1935 .subdevice = 0x4d56,
1930 .name = "Intel ICH/AD1885", 1936 .name = "Intel ICH/AD1885",
1931 .type = AC97_TUNE_HP_ONLY 1937 .type = AC97_TUNE_HP_ONLY
1932 }, 1938 },
1933 { 1939 {
1934 .vendor = 0x8086, 1940 .subvendor = 0x8086,
1935 .device = 0x6000, 1941 .subdevice = 0x6000,
1936 .mask = 0xfff0, 1942 .mask = 0xfff0,
1937 .name = "Intel ICH5/AD1985", 1943 .name = "Intel ICH5/AD1985",
1938 .type = AC97_TUNE_AD_SHARING 1944 .type = AC97_TUNE_AD_SHARING
1939 }, 1945 },
1940 { 1946 {
1941 .vendor = 0x8086, 1947 .subvendor = 0x8086,
1942 .device = 0xe000, 1948 .subdevice = 0xe000,
1943 .mask = 0xfff0, 1949 .mask = 0xfff0,
1944 .name = "Intel ICH5/AD1985", 1950 .name = "Intel ICH5/AD1985",
1945 .type = AC97_TUNE_AD_SHARING 1951 .type = AC97_TUNE_AD_SHARING
1946 }, 1952 },
1947#if 0 /* FIXME: this seems wrong on most boards */ 1953#if 0 /* FIXME: this seems wrong on most boards */
1948 { 1954 {
1949 .vendor = 0x8086, 1955 .subvendor = 0x8086,
1950 .device = 0xa000, 1956 .subdevice = 0xa000,
1951 .mask = 0xfff0, 1957 .mask = 0xfff0,
1952 .name = "Intel ICH5/AD1985", 1958 .name = "Intel ICH5/AD1985",
1953 .type = AC97_TUNE_HP_ONLY 1959 .type = AC97_TUNE_HP_ONLY
@@ -2849,7 +2855,7 @@ static struct pci_driver driver = {
2849 2855
2850static int __init alsa_card_intel8x0_init(void) 2856static int __init alsa_card_intel8x0_init(void)
2851{ 2857{
2852 return pci_module_init(&driver); 2858 return pci_register_driver(&driver);
2853} 2859}
2854 2860
2855static void __exit alsa_card_intel8x0_exit(void) 2861static void __exit alsa_card_intel8x0_exit(void)
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index 67da096d659b..bb758c77d211 100644
--- a/sound/pci/intel8x0m.c
+++ b/sound/pci/intel8x0m.c
@@ -35,7 +35,6 @@
35#include <sound/pcm.h> 35#include <sound/pcm.h>
36#include <sound/ac97_codec.h> 36#include <sound/ac97_codec.h>
37#include <sound/info.h> 37#include <sound/info.h>
38#include <sound/control.h>
39#include <sound/initval.h> 38#include <sound/initval.h>
40 39
41MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 40MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
@@ -292,60 +291,9 @@ static struct pci_device_id snd_intel8x0m_ids[] = {
292#endif 291#endif
293 { 0, } 292 { 0, }
294}; 293};
295static int snd_intel8x0m_switch_default_get(snd_kcontrol_t *kcontrol,
296 snd_ctl_elem_value_t *ucontrol);
297static int snd_intel8x0m_switch_default_put(snd_kcontrol_t *kcontrol,
298 snd_ctl_elem_value_t *ucontrol);
299static int snd_intel8x0m_switch_default_info(snd_kcontrol_t *kcontrol,
300 snd_ctl_elem_info_t *uinfo);
301
302#define PRIVATE_VALUE_INITIALIZER(r,m) (((r) & 0xffff) << 16 | ((m) & 0xffff))
303#define PRIVATE_VALUE_MASK(control) ((control)->private_value & 0xffff)
304#define PRIVATE_VALUE_REG(control) (((control)->private_value >> 16) & 0xffff)
305
306static snd_kcontrol_new_t snd_intel8x0m_mixer_switches[] __devinitdata = {
307 { .name = "Off-hook Switch",
308 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
309 .info = snd_intel8x0m_switch_default_info,
310 .get = snd_intel8x0m_switch_default_get,
311 .put = snd_intel8x0m_switch_default_put,
312 .private_value = PRIVATE_VALUE_INITIALIZER(AC97_GPIO_STATUS,AC97_GPIO_LINE1_OH)
313 }
314};
315 294
316MODULE_DEVICE_TABLE(pci, snd_intel8x0m_ids); 295MODULE_DEVICE_TABLE(pci, snd_intel8x0m_ids);
317 296
318static int snd_intel8x0m_switch_default_info(snd_kcontrol_t *kcontrol,
319 snd_ctl_elem_info_t *uinfo)
320{
321 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
322 uinfo->count = 1;
323 uinfo->value.integer.min = 0;
324 uinfo->value.integer.max = 1;
325 return 0;
326}
327
328static int snd_intel8x0m_switch_default_get(snd_kcontrol_t *kcontrol,
329 snd_ctl_elem_value_t *ucontrol)
330{
331 unsigned short mask = PRIVATE_VALUE_MASK(kcontrol);
332 unsigned short reg = PRIVATE_VALUE_REG(kcontrol);
333 intel8x0_t *chip = snd_kcontrol_chip(kcontrol);
334 unsigned int status;
335 status = snd_ac97_read(chip->ac97, reg) & mask ? 1 : 0;
336 ucontrol->value.integer.value[0] = status;
337 return 0;
338}
339static int snd_intel8x0m_switch_default_put(snd_kcontrol_t *kcontrol,
340 snd_ctl_elem_value_t *ucontrol)
341{
342 unsigned short mask = PRIVATE_VALUE_MASK(kcontrol);
343 unsigned short reg = PRIVATE_VALUE_REG(kcontrol);
344 intel8x0_t *chip = snd_kcontrol_chip(kcontrol);
345 unsigned short new_status = ucontrol->value.integer.value[0] ? mask : ~mask;
346 return snd_ac97_update_bits(chip->ac97, reg,
347 mask, new_status);
348}
349/* 297/*
350 * Lowlevel I/O - busmaster 298 * Lowlevel I/O - busmaster
351 */ 299 */
@@ -500,6 +448,8 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97,
500 res = 0xffff; 448 res = 0xffff;
501 } 449 }
502 } 450 }
451 if (reg == AC97_GPIO_STATUS)
452 iagetword(chip, 0); /* clear semaphore */
503 return res; 453 return res;
504} 454}
505 455
@@ -698,21 +648,6 @@ static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(snd_pcm_substream_t * substrea
698 return bytes_to_frames(substream->runtime, ptr); 648 return bytes_to_frames(substream->runtime, ptr);
699} 649}
700 650
701static int snd_intel8x0m_pcm_trigger(snd_pcm_substream_t *substream, int cmd)
702{
703 /* hook off/on on start/stop */
704 /* Moved this to mixer control */
705 switch (cmd) {
706 case SNDRV_PCM_TRIGGER_START:
707 break;
708 case SNDRV_PCM_TRIGGER_STOP:
709 break;
710 default:
711 return -EINVAL;
712 }
713 return snd_intel8x0_pcm_trigger(substream,cmd);
714}
715
716static int snd_intel8x0m_pcm_prepare(snd_pcm_substream_t * substream) 651static int snd_intel8x0m_pcm_prepare(snd_pcm_substream_t * substream)
717{ 652{
718 intel8x0_t *chip = snd_pcm_substream_chip(substream); 653 intel8x0_t *chip = snd_pcm_substream_chip(substream);
@@ -808,7 +743,7 @@ static snd_pcm_ops_t snd_intel8x0m_playback_ops = {
808 .hw_params = snd_intel8x0_hw_params, 743 .hw_params = snd_intel8x0_hw_params,
809 .hw_free = snd_intel8x0_hw_free, 744 .hw_free = snd_intel8x0_hw_free,
810 .prepare = snd_intel8x0m_pcm_prepare, 745 .prepare = snd_intel8x0m_pcm_prepare,
811 .trigger = snd_intel8x0m_pcm_trigger, 746 .trigger = snd_intel8x0_pcm_trigger,
812 .pointer = snd_intel8x0_pcm_pointer, 747 .pointer = snd_intel8x0_pcm_pointer,
813}; 748};
814 749
@@ -819,7 +754,7 @@ static snd_pcm_ops_t snd_intel8x0m_capture_ops = {
819 .hw_params = snd_intel8x0_hw_params, 754 .hw_params = snd_intel8x0_hw_params,
820 .hw_free = snd_intel8x0_hw_free, 755 .hw_free = snd_intel8x0_hw_free,
821 .prepare = snd_intel8x0m_pcm_prepare, 756 .prepare = snd_intel8x0m_pcm_prepare,
822 .trigger = snd_intel8x0m_pcm_trigger, 757 .trigger = snd_intel8x0_pcm_trigger,
823 .pointer = snd_intel8x0_pcm_pointer, 758 .pointer = snd_intel8x0_pcm_pointer,
824}; 759};
825 760
@@ -947,7 +882,6 @@ static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock)
947 ac97_t *x97; 882 ac97_t *x97;
948 int err; 883 int err;
949 unsigned int glob_sta = 0; 884 unsigned int glob_sta = 0;
950 unsigned int idx;
951 static ac97_bus_ops_t ops = { 885 static ac97_bus_ops_t ops = {
952 .write = snd_intel8x0_codec_write, 886 .write = snd_intel8x0_codec_write,
953 .read = snd_intel8x0_codec_read, 887 .read = snd_intel8x0_codec_read,
@@ -983,10 +917,6 @@ static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock)
983 chip->ichd[ICHD_MDMIN].ac97 = x97; 917 chip->ichd[ICHD_MDMIN].ac97 = x97;
984 chip->ichd[ICHD_MDMOUT].ac97 = x97; 918 chip->ichd[ICHD_MDMOUT].ac97 = x97;
985 } 919 }
986 for (idx = 0; idx < ARRAY_SIZE(snd_intel8x0m_mixer_switches); idx++) {
987 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_intel8x0m_mixer_switches[idx], chip))) < 0)
988 goto __err;
989 }
990 920
991 chip->in_ac97_init = 0; 921 chip->in_ac97_init = 0;
992 return 0; 922 return 0;
@@ -1450,7 +1380,7 @@ static struct pci_driver driver = {
1450 1380
1451static int __init alsa_card_intel8x0m_init(void) 1381static int __init alsa_card_intel8x0m_init(void)
1452{ 1382{
1453 return pci_module_init(&driver); 1383 return pci_register_driver(&driver);
1454} 1384}
1455 1385
1456static void __exit alsa_card_intel8x0m_exit(void) 1386static void __exit alsa_card_intel8x0m_exit(void)
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index bb1de2008176..79d8eda54f0d 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -2541,7 +2541,7 @@ static struct pci_driver driver = {
2541 2541
2542static int __init alsa_card_korg1212_init(void) 2542static int __init alsa_card_korg1212_init(void)
2543{ 2543{
2544 return pci_module_init(&driver); 2544 return pci_register_driver(&driver);
2545} 2545}
2546 2546
2547static void __exit alsa_card_korg1212_exit(void) 2547static void __exit alsa_card_korg1212_exit(void)
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 2cf33083d7cc..096f15132853 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -779,6 +779,12 @@ struct m3_quirk {
779 (e.g. for IrDA on Dell Inspirons) */ 779 (e.g. for IrDA on Dell Inspirons) */
780}; 780};
781 781
782struct m3_hv_quirk {
783 u16 vendor, device, subsystem_vendor, subsystem_device;
784 u32 config; /* ALLEGRO_CONFIG hardware volume bits */
785 int is_omnibook; /* Do HP OmniBook GPIO magic? */
786};
787
782struct m3_list { 788struct m3_list {
783 int curlen; 789 int curlen;
784 int mem_addr; 790 int mem_addr;
@@ -828,6 +834,7 @@ struct snd_m3 {
828 834
829 struct pci_dev *pci; 835 struct pci_dev *pci;
830 struct m3_quirk *quirk; 836 struct m3_quirk *quirk;
837 struct m3_hv_quirk *hv_quirk;
831 838
832 int dacs_active; 839 int dacs_active;
833 int timer_users; 840 int timer_users;
@@ -851,6 +858,11 @@ struct snd_m3 {
851 m3_dma_t *substreams; 858 m3_dma_t *substreams;
852 859
853 spinlock_t reg_lock; 860 spinlock_t reg_lock;
861 spinlock_t ac97_lock;
862
863 snd_kcontrol_t *master_switch;
864 snd_kcontrol_t *master_volume;
865 struct tasklet_struct hwvol_tq;
854 866
855#ifdef CONFIG_PM 867#ifdef CONFIG_PM
856 u16 *suspend_mem; 868 u16 *suspend_mem;
@@ -968,6 +980,71 @@ static struct m3_quirk m3_quirk_list[] = {
968 { NULL } 980 { NULL }
969}; 981};
970 982
983/* These values came from the Windows driver. */
984static struct m3_hv_quirk m3_hv_quirk_list[] = {
985 /* Allegro chips */
986 { 0x125D, 0x1988, 0x0E11, 0x002E, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
987 { 0x125D, 0x1988, 0x0E11, 0x0094, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
988 { 0x125D, 0x1988, 0x0E11, 0xB112, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
989 { 0x125D, 0x1988, 0x0E11, 0xB114, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
990 { 0x125D, 0x1988, 0x103C, 0x0012, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
991 { 0x125D, 0x1988, 0x103C, 0x0018, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
992 { 0x125D, 0x1988, 0x103C, 0x001C, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
993 { 0x125D, 0x1988, 0x103C, 0x001D, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
994 { 0x125D, 0x1988, 0x103C, 0x001E, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
995 { 0x125D, 0x1988, 0x107B, 0x3350, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
996 { 0x125D, 0x1988, 0x10F7, 0x8338, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
997 { 0x125D, 0x1988, 0x10F7, 0x833C, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
998 { 0x125D, 0x1988, 0x10F7, 0x833D, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
999 { 0x125D, 0x1988, 0x10F7, 0x833E, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
1000 { 0x125D, 0x1988, 0x10F7, 0x833F, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
1001 { 0x125D, 0x1988, 0x13BD, 0x1018, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
1002 { 0x125D, 0x1988, 0x13BD, 0x1019, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
1003 { 0x125D, 0x1988, 0x13BD, 0x101A, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
1004 { 0x125D, 0x1988, 0x14FF, 0x0F03, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
1005 { 0x125D, 0x1988, 0x14FF, 0x0F04, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
1006 { 0x125D, 0x1988, 0x14FF, 0x0F05, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
1007 { 0x125D, 0x1988, 0x156D, 0xB400, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
1008 { 0x125D, 0x1988, 0x156D, 0xB795, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
1009 { 0x125D, 0x1988, 0x156D, 0xB797, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
1010 { 0x125D, 0x1988, 0x156D, 0xC700, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD, 0 },
1011 { 0x125D, 0x1988, 0x1033, 0x80F1, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
1012 { 0x125D, 0x1988, 0x103C, 0x001A, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 }, /* HP OmniBook 6100 */
1013 { 0x125D, 0x1988, 0x107B, 0x340A, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
1014 { 0x125D, 0x1988, 0x107B, 0x3450, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
1015 { 0x125D, 0x1988, 0x109F, 0x3134, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
1016 { 0x125D, 0x1988, 0x109F, 0x3161, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
1017 { 0x125D, 0x1988, 0x144D, 0x3280, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
1018 { 0x125D, 0x1988, 0x144D, 0x3281, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
1019 { 0x125D, 0x1988, 0x144D, 0xC002, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
1020 { 0x125D, 0x1988, 0x144D, 0xC003, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
1021 { 0x125D, 0x1988, 0x1509, 0x1740, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
1022 { 0x125D, 0x1988, 0x1610, 0x0010, HV_CTRL_ENABLE | HV_BUTTON_FROM_GD | REDUCED_DEBOUNCE, 0 },
1023 { 0x125D, 0x1988, 0x1042, 0x1042, HV_CTRL_ENABLE, 0 },
1024 { 0x125D, 0x1988, 0x107B, 0x9500, HV_CTRL_ENABLE, 0 },
1025 { 0x125D, 0x1988, 0x14FF, 0x0F06, HV_CTRL_ENABLE, 0 },
1026 { 0x125D, 0x1988, 0x1558, 0x8586, HV_CTRL_ENABLE, 0 },
1027 { 0x125D, 0x1988, 0x161F, 0x2011, HV_CTRL_ENABLE, 0 },
1028 /* Maestro3 chips */
1029 { 0x125D, 0x1998, 0x103C, 0x000E, HV_CTRL_ENABLE, 0 },
1030 { 0x125D, 0x1998, 0x103C, 0x0010, HV_CTRL_ENABLE, 1 }, /* HP OmniBook 6000 */
1031 { 0x125D, 0x1998, 0x103C, 0x0011, HV_CTRL_ENABLE, 1 }, /* HP OmniBook 500 */
1032 { 0x125D, 0x1998, 0x103C, 0x001B, HV_CTRL_ENABLE, 0 },
1033 { 0x125D, 0x1998, 0x104D, 0x80A6, HV_CTRL_ENABLE, 0 },
1034 { 0x125D, 0x1998, 0x104D, 0x80AA, HV_CTRL_ENABLE, 0 },
1035 { 0x125D, 0x1998, 0x107B, 0x5300, HV_CTRL_ENABLE, 0 },
1036 { 0x125D, 0x1998, 0x110A, 0x1998, HV_CTRL_ENABLE, 0 },
1037 { 0x125D, 0x1998, 0x13BD, 0x1015, HV_CTRL_ENABLE, 0 },
1038 { 0x125D, 0x1998, 0x13BD, 0x101C, HV_CTRL_ENABLE, 0 },
1039 { 0x125D, 0x1998, 0x13BD, 0x1802, HV_CTRL_ENABLE, 0 },
1040 { 0x125D, 0x1998, 0x1599, 0x0715, HV_CTRL_ENABLE, 0 },
1041 { 0x125D, 0x1998, 0x5643, 0x5643, HV_CTRL_ENABLE, 0 },
1042 { 0x125D, 0x199A, 0x144D, 0x3260, HV_CTRL_ENABLE | REDUCED_DEBOUNCE, 0 },
1043 { 0x125D, 0x199A, 0x144D, 0x3261, HV_CTRL_ENABLE | REDUCED_DEBOUNCE, 0 },
1044 { 0x125D, 0x199A, 0x144D, 0xC000, HV_CTRL_ENABLE | REDUCED_DEBOUNCE, 0 },
1045 { 0x125D, 0x199A, 0x144D, 0xC001, HV_CTRL_ENABLE | REDUCED_DEBOUNCE, 0 },
1046 { 0 }
1047};
971 1048
972/* 1049/*
973 * lowlevel functions 1050 * lowlevel functions
@@ -1565,6 +1642,68 @@ static void snd_m3_update_ptr(m3_t *chip, m3_dma_t *s)
1565 } 1642 }
1566} 1643}
1567 1644
1645static void snd_m3_update_hw_volume(unsigned long private_data)
1646{
1647 m3_t *chip = (m3_t *) private_data;
1648 int x, val;
1649 unsigned long flags;
1650
1651 /* Figure out which volume control button was pushed,
1652 based on differences from the default register
1653 values. */
1654 x = inb(chip->iobase + SHADOW_MIX_REG_VOICE) & 0xee;
1655
1656 /* Reset the volume control registers. */
1657 outb(0x88, chip->iobase + SHADOW_MIX_REG_VOICE);
1658 outb(0x88, chip->iobase + HW_VOL_COUNTER_VOICE);
1659 outb(0x88, chip->iobase + SHADOW_MIX_REG_MASTER);
1660 outb(0x88, chip->iobase + HW_VOL_COUNTER_MASTER);
1661
1662 if (!chip->master_switch || !chip->master_volume)
1663 return;
1664
1665 /* FIXME: we can't call snd_ac97_* functions since here is in tasklet. */
1666 spin_lock_irqsave(&chip->ac97_lock, flags);
1667
1668 val = chip->ac97->regs[AC97_MASTER_VOL];
1669 switch (x) {
1670 case 0x88:
1671 /* mute */
1672 val ^= 0x8000;
1673 chip->ac97->regs[AC97_MASTER_VOL] = val;
1674 outw(val, chip->iobase + CODEC_DATA);
1675 outb(AC97_MASTER_VOL, chip->iobase + CODEC_COMMAND);
1676 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
1677 &chip->master_switch->id);
1678 break;
1679 case 0xaa:
1680 /* volume up */
1681 if ((val & 0x7f) > 0)
1682 val--;
1683 if ((val & 0x7f00) > 0)
1684 val -= 0x0100;
1685 chip->ac97->regs[AC97_MASTER_VOL] = val;
1686 outw(val, chip->iobase + CODEC_DATA);
1687 outb(AC97_MASTER_VOL, chip->iobase + CODEC_COMMAND);
1688 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
1689 &chip->master_volume->id);
1690 break;
1691 case 0x66:
1692 /* volume down */
1693 if ((val & 0x7f) < 0x1f)
1694 val++;
1695 if ((val & 0x7f00) < 0x1f00)
1696 val += 0x0100;
1697 chip->ac97->regs[AC97_MASTER_VOL] = val;
1698 outw(val, chip->iobase + CODEC_DATA);
1699 outb(AC97_MASTER_VOL, chip->iobase + CODEC_COMMAND);
1700 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
1701 &chip->master_volume->id);
1702 break;
1703 }
1704 spin_unlock_irqrestore(&chip->ac97_lock, flags);
1705}
1706
1568static irqreturn_t 1707static irqreturn_t
1569snd_m3_interrupt(int irq, void *dev_id, struct pt_regs *regs) 1708snd_m3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1570{ 1709{
@@ -1576,7 +1715,10 @@ snd_m3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1576 1715
1577 if (status == 0xff) 1716 if (status == 0xff)
1578 return IRQ_NONE; 1717 return IRQ_NONE;
1579 1718
1719 if (status & HV_INT_PENDING)
1720 tasklet_hi_schedule(&chip->hwvol_tq);
1721
1580 /* 1722 /*
1581 * ack an assp int if its running 1723 * ack an assp int if its running
1582 * and has an int pending 1724 * and has an int pending
@@ -1605,7 +1747,7 @@ snd_m3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1605#endif 1747#endif
1606 1748
1607 /* ack ints */ 1749 /* ack ints */
1608 snd_m3_outw(chip, HOST_INT_STATUS, status); 1750 outb(status, chip->iobase + HOST_INT_STATUS);
1609 1751
1610 return IRQ_HANDLED; 1752 return IRQ_HANDLED;
1611} 1753}
@@ -1842,24 +1984,32 @@ static unsigned short
1842snd_m3_ac97_read(ac97_t *ac97, unsigned short reg) 1984snd_m3_ac97_read(ac97_t *ac97, unsigned short reg)
1843{ 1985{
1844 m3_t *chip = ac97->private_data; 1986 m3_t *chip = ac97->private_data;
1987 unsigned long flags;
1988 unsigned short data;
1845 1989
1846 if (snd_m3_ac97_wait(chip)) 1990 if (snd_m3_ac97_wait(chip))
1847 return 0xffff; 1991 return 0xffff;
1992 spin_lock_irqsave(&chip->ac97_lock, flags);
1848 snd_m3_outb(chip, 0x80 | (reg & 0x7f), CODEC_COMMAND); 1993 snd_m3_outb(chip, 0x80 | (reg & 0x7f), CODEC_COMMAND);
1849 if (snd_m3_ac97_wait(chip)) 1994 if (snd_m3_ac97_wait(chip))
1850 return 0xffff; 1995 return 0xffff;
1851 return snd_m3_inw(chip, CODEC_DATA); 1996 data = snd_m3_inw(chip, CODEC_DATA);
1997 spin_unlock_irqrestore(&chip->ac97_lock, flags);
1998 return data;
1852} 1999}
1853 2000
1854static void 2001static void
1855snd_m3_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) 2002snd_m3_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val)
1856{ 2003{
1857 m3_t *chip = ac97->private_data; 2004 m3_t *chip = ac97->private_data;
2005 unsigned long flags;
1858 2006
1859 if (snd_m3_ac97_wait(chip)) 2007 if (snd_m3_ac97_wait(chip))
1860 return; 2008 return;
2009 spin_lock_irqsave(&chip->ac97_lock, flags);
1861 snd_m3_outw(chip, val, CODEC_DATA); 2010 snd_m3_outw(chip, val, CODEC_DATA);
1862 snd_m3_outb(chip, reg & 0x7f, CODEC_COMMAND); 2011 snd_m3_outb(chip, reg & 0x7f, CODEC_COMMAND);
2012 spin_unlock_irqrestore(&chip->ac97_lock, flags);
1863} 2013}
1864 2014
1865 2015
@@ -1968,6 +2118,7 @@ static int __devinit snd_m3_mixer(m3_t *chip)
1968{ 2118{
1969 ac97_bus_t *pbus; 2119 ac97_bus_t *pbus;
1970 ac97_template_t ac97; 2120 ac97_template_t ac97;
2121 snd_ctl_elem_id_t id;
1971 int err; 2122 int err;
1972 static ac97_bus_ops_t ops = { 2123 static ac97_bus_ops_t ops = {
1973 .write = snd_m3_ac97_write, 2124 .write = snd_m3_ac97_write,
@@ -1988,6 +2139,15 @@ static int __devinit snd_m3_mixer(m3_t *chip)
1988 schedule_timeout(HZ / 10); 2139 schedule_timeout(HZ / 10);
1989 snd_ac97_write(chip->ac97, AC97_PCM, 0); 2140 snd_ac97_write(chip->ac97, AC97_PCM, 0);
1990 2141
2142 memset(&id, 0, sizeof(id));
2143 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
2144 strcpy(id.name, "Master Playback Switch");
2145 chip->master_switch = snd_ctl_find_id(chip->card, &id);
2146 memset(&id, 0, sizeof(id));
2147 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
2148 strcpy(id.name, "Master Playback Volume");
2149 chip->master_volume = snd_ctl_find_id(chip->card, &id);
2150
1991 return 0; 2151 return 0;
1992} 2152}
1993 2153
@@ -2293,6 +2453,7 @@ static int
2293snd_m3_chip_init(m3_t *chip) 2453snd_m3_chip_init(m3_t *chip)
2294{ 2454{
2295 struct pci_dev *pcidev = chip->pci; 2455 struct pci_dev *pcidev = chip->pci;
2456 unsigned long io = chip->iobase;
2296 u32 n; 2457 u32 n;
2297 u16 w; 2458 u16 w;
2298 u8 t; /* makes as much sense as 'n', no? */ 2459 u8 t; /* makes as much sense as 'n', no? */
@@ -2303,8 +2464,27 @@ snd_m3_chip_init(m3_t *chip)
2303 DISABLE_LEGACY); 2464 DISABLE_LEGACY);
2304 pci_write_config_word(pcidev, PCI_LEGACY_AUDIO_CTRL, w); 2465 pci_write_config_word(pcidev, PCI_LEGACY_AUDIO_CTRL, w);
2305 2466
2467 if (chip->hv_quirk && chip->hv_quirk->is_omnibook) {
2468 /*
2469 * Volume buttons on some HP OmniBook laptops don't work
2470 * correctly. This makes them work for the most part.
2471 *
2472 * Volume up and down buttons on the laptop side work.
2473 * Fn+cursor_up (volme up) works.
2474 * Fn+cursor_down (volume down) doesn't work.
2475 * Fn+F7 (mute) works acts as volume up.
2476 */
2477 outw(~(GPI_VOL_DOWN|GPI_VOL_UP), io + GPIO_MASK);
2478 outw(inw(io + GPIO_DIRECTION) & ~(GPI_VOL_DOWN|GPI_VOL_UP), io + GPIO_DIRECTION);
2479 outw((GPI_VOL_DOWN|GPI_VOL_UP), io + GPIO_DATA);
2480 outw(0xffff, io + GPIO_MASK);
2481 }
2306 pci_read_config_dword(pcidev, PCI_ALLEGRO_CONFIG, &n); 2482 pci_read_config_dword(pcidev, PCI_ALLEGRO_CONFIG, &n);
2307 n &= REDUCED_DEBOUNCE; 2483 n &= ~(HV_CTRL_ENABLE | REDUCED_DEBOUNCE | HV_BUTTON_FROM_GD);
2484 if (chip->hv_quirk)
2485 n |= chip->hv_quirk->config;
2486 /* For some reason we must always use reduced debounce. */
2487 n |= REDUCED_DEBOUNCE;
2308 n |= PM_CTRL_ENABLE | CLK_DIV_BY_49 | USE_PCI_TIMING; 2488 n |= PM_CTRL_ENABLE | CLK_DIV_BY_49 | USE_PCI_TIMING;
2309 pci_write_config_dword(pcidev, PCI_ALLEGRO_CONFIG, n); 2489 pci_write_config_dword(pcidev, PCI_ALLEGRO_CONFIG, n);
2310 2490
@@ -2332,6 +2512,12 @@ snd_m3_chip_init(m3_t *chip)
2332 2512
2333 outb(RUN_ASSP, chip->iobase + ASSP_CONTROL_B); 2513 outb(RUN_ASSP, chip->iobase + ASSP_CONTROL_B);
2334 2514
2515 outb(0x00, io + HARDWARE_VOL_CTRL);
2516 outb(0x88, io + SHADOW_MIX_REG_VOICE);
2517 outb(0x88, io + HW_VOL_COUNTER_VOICE);
2518 outb(0x88, io + SHADOW_MIX_REG_MASTER);
2519 outb(0x88, io + HW_VOL_COUNTER_MASTER);
2520
2335 return 0; 2521 return 0;
2336} 2522}
2337 2523
@@ -2341,7 +2527,7 @@ snd_m3_enable_ints(m3_t *chip)
2341 unsigned long io = chip->iobase; 2527 unsigned long io = chip->iobase;
2342 2528
2343 /* TODO: MPU401 not supported yet */ 2529 /* TODO: MPU401 not supported yet */
2344 outw(ASSP_INT_ENABLE /*| MPU401_INT_ENABLE*/, io + HOST_INT_CTRL); 2530 outw(ASSP_INT_ENABLE | HV_INT_ENABLE /*| MPU401_INT_ENABLE*/, io + HOST_INT_CTRL);
2345 outb(inb(io + ASSP_CONTROL_C) | ASSP_HOST_INT_ENABLE, 2531 outb(inb(io + ASSP_CONTROL_C) | ASSP_HOST_INT_ENABLE,
2346 io + ASSP_CONTROL_C); 2532 io + ASSP_CONTROL_C);
2347} 2533}
@@ -2367,7 +2553,7 @@ static int snd_m3_free(m3_t *chip)
2367 kfree(chip->substreams); 2553 kfree(chip->substreams);
2368 } 2554 }
2369 if (chip->iobase) { 2555 if (chip->iobase) {
2370 snd_m3_outw(chip, HOST_INT_CTRL, 0); /* disable ints */ 2556 outw(0, chip->iobase + HOST_INT_CTRL); /* disable ints */
2371 } 2557 }
2372 2558
2373#ifdef CONFIG_PM 2559#ifdef CONFIG_PM
@@ -2486,7 +2672,7 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci,
2486 m3_t *chip; 2672 m3_t *chip;
2487 int i, err; 2673 int i, err;
2488 struct m3_quirk *quirk; 2674 struct m3_quirk *quirk;
2489 u16 subsystem_vendor, subsystem_device; 2675 struct m3_hv_quirk *hv_quirk;
2490 static snd_device_ops_t ops = { 2676 static snd_device_ops_t ops = {
2491 .dev_free = snd_m3_dev_free, 2677 .dev_free = snd_m3_dev_free,
2492 }; 2678 };
@@ -2524,18 +2710,25 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci,
2524 chip->pci = pci; 2710 chip->pci = pci;
2525 chip->irq = -1; 2711 chip->irq = -1;
2526 2712
2527 pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor);
2528 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &subsystem_device);
2529
2530 for (quirk = m3_quirk_list; quirk->vendor; quirk++) { 2713 for (quirk = m3_quirk_list; quirk->vendor; quirk++) {
2531 if (subsystem_vendor == quirk->vendor && 2714 if (pci->subsystem_vendor == quirk->vendor &&
2532 subsystem_device == quirk->device) { 2715 pci->subsystem_device == quirk->device) {
2533 printk(KERN_INFO "maestro3: enabled hack for '%s'\n", quirk->name); 2716 printk(KERN_INFO "maestro3: enabled hack for '%s'\n", quirk->name);
2534 chip->quirk = quirk; 2717 chip->quirk = quirk;
2535 break; 2718 break;
2536 } 2719 }
2537 } 2720 }
2538 2721
2722 for (hv_quirk = m3_hv_quirk_list; hv_quirk->vendor; hv_quirk++) {
2723 if (pci->vendor == hv_quirk->vendor &&
2724 pci->device == hv_quirk->device &&
2725 pci->subsystem_vendor == hv_quirk->subsystem_vendor &&
2726 pci->subsystem_device == hv_quirk->subsystem_device) {
2727 chip->hv_quirk = hv_quirk;
2728 break;
2729 }
2730 }
2731
2539 chip->external_amp = enable_amp; 2732 chip->external_amp = enable_amp;
2540 if (amp_gpio >= 0 && amp_gpio <= 0x0f) 2733 if (amp_gpio >= 0 && amp_gpio <= 0x0f)
2541 chip->amp_gpio = amp_gpio; 2734 chip->amp_gpio = amp_gpio;
@@ -2593,6 +2786,9 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci,
2593 return err; 2786 return err;
2594 } 2787 }
2595 2788
2789 spin_lock_init(&chip->ac97_lock);
2790 tasklet_init(&chip->hwvol_tq, snd_m3_update_hw_volume, (unsigned long)chip);
2791
2596 if ((err = snd_m3_mixer(chip)) < 0) 2792 if ((err = snd_m3_mixer(chip)) < 0)
2597 return err; 2793 return err;
2598 2794
@@ -2702,7 +2898,7 @@ static struct pci_driver driver = {
2702 2898
2703static int __init alsa_card_m3_init(void) 2899static int __init alsa_card_m3_init(void)
2704{ 2900{
2705 return pci_module_init(&driver); 2901 return pci_register_driver(&driver);
2706} 2902}
2707 2903
2708static void __exit alsa_card_m3_exit(void) 2904static void __exit alsa_card_m3_exit(void)
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index 65bb0f47af2c..082c0d0f73d2 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -1431,7 +1431,7 @@ static struct pci_driver driver = {
1431 1431
1432static int __init alsa_card_mixart_init(void) 1432static int __init alsa_card_mixart_init(void)
1433{ 1433{
1434 return pci_module_init(&driver); 1434 return pci_register_driver(&driver);
1435} 1435}
1436 1436
1437static void __exit alsa_card_mixart_exit(void) 1437static void __exit alsa_card_mixart_exit(void)
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index 356fbeac6f9e..8a52091f8552 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -1645,7 +1645,7 @@ static struct pci_driver driver = {
1645 1645
1646static int __init alsa_card_nm256_init(void) 1646static int __init alsa_card_nm256_init(void)
1647{ 1647{
1648 return pci_module_init(&driver); 1648 return pci_register_driver(&driver);
1649} 1649}
1650 1650
1651static void __exit alsa_card_nm256_exit(void) 1651static void __exit alsa_card_nm256_exit(void)
diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c
index b96acd5a57db..b7b554df6705 100644
--- a/sound/pci/rme32.c
+++ b/sound/pci/rme32.c
@@ -2031,7 +2031,7 @@ static struct pci_driver driver = {
2031 2031
2032static int __init alsa_card_rme32_init(void) 2032static int __init alsa_card_rme32_init(void)
2033{ 2033{
2034 return pci_module_init(&driver); 2034 return pci_register_driver(&driver);
2035} 2035}
2036 2036
2037static void __exit alsa_card_rme32_exit(void) 2037static void __exit alsa_card_rme32_exit(void)
diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c
index 8e2666841d21..10c4f45a913c 100644
--- a/sound/pci/rme96.c
+++ b/sound/pci/rme96.c
@@ -2437,7 +2437,7 @@ static struct pci_driver driver = {
2437 2437
2438static int __init alsa_card_rme96_init(void) 2438static int __init alsa_card_rme96_init(void)
2439{ 2439{
2440 return pci_module_init(&driver); 2440 return pci_register_driver(&driver);
2441} 2441}
2442 2442
2443static void __exit alsa_card_rme96_exit(void) 2443static void __exit alsa_card_rme96_exit(void)
diff --git a/sound/pci/rme9652/Makefile b/sound/pci/rme9652/Makefile
index 917374c9cd40..d2c294e136f9 100644
--- a/sound/pci/rme9652/Makefile
+++ b/sound/pci/rme9652/Makefile
@@ -5,7 +5,9 @@
5 5
6snd-rme9652-objs := rme9652.o 6snd-rme9652-objs := rme9652.o
7snd-hdsp-objs := hdsp.o 7snd-hdsp-objs := hdsp.o
8snd-hdspm-objs := hdspm.o
8 9
9# Toplevel Module Dependency 10# Toplevel Module Dependency
10obj-$(CONFIG_SND_RME9652) += snd-rme9652.o 11obj-$(CONFIG_SND_RME9652) += snd-rme9652.o
11obj-$(CONFIG_SND_HDSP) += snd-hdsp.o 12obj-$(CONFIG_SND_HDSP) += snd-hdsp.o
13obj-$(CONFIG_SND_HDSPM) +=snd-hdspm.o
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index 12efbf0fab54..a673cc438b91 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -559,18 +559,22 @@ static int snd_hammerfall_get_buffer(struct pci_dev *pci, struct snd_dma_buffer
559{ 559{
560 dmab->dev.type = SNDRV_DMA_TYPE_DEV; 560 dmab->dev.type = SNDRV_DMA_TYPE_DEV;
561 dmab->dev.dev = snd_dma_pci_data(pci); 561 dmab->dev.dev = snd_dma_pci_data(pci);
562 if (! snd_dma_get_reserved_buf(dmab, snd_dma_pci_buf_id(pci))) { 562 if (snd_dma_get_reserved_buf(dmab, snd_dma_pci_buf_id(pci))) {
563 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 563 if (dmab->bytes >= size)
564 size, dmab) < 0) 564 return 0;
565 return -ENOMEM;
566 } 565 }
566 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
567 size, dmab) < 0)
568 return -ENOMEM;
567 return 0; 569 return 0;
568} 570}
569 571
570static void snd_hammerfall_free_buffer(struct snd_dma_buffer *dmab, struct pci_dev *pci) 572static void snd_hammerfall_free_buffer(struct snd_dma_buffer *dmab, struct pci_dev *pci)
571{ 573{
572 if (dmab->area) 574 if (dmab->area) {
575 dmab->dev.dev = NULL; /* make it anonymous */
573 snd_dma_reserve_buf(dmab, snd_dma_pci_buf_id(pci)); 576 snd_dma_reserve_buf(dmab, snd_dma_pci_buf_id(pci));
577 }
574} 578}
575 579
576 580
@@ -4912,19 +4916,9 @@ static int __devinit hdsp_request_fw_loader(hdsp_t *hdsp)
4912 release_firmware(fw); 4916 release_firmware(fw);
4913 return -EINVAL; 4917 return -EINVAL;
4914 } 4918 }
4915#ifdef SNDRV_BIG_ENDIAN 4919
4916 {
4917 int i;
4918 u32 *src = (u32*)fw->data;
4919 for (i = 0; i < ARRAY_SIZE(hdsp->firmware_cache); i++, src++)
4920 hdsp->firmware_cache[i] = ((*src & 0x000000ff) << 16) |
4921 ((*src & 0x0000ff00) << 8) |
4922 ((*src & 0x00ff0000) >> 8) |
4923 ((*src & 0xff000000) >> 16);
4924 }
4925#else
4926 memcpy(hdsp->firmware_cache, fw->data, sizeof(hdsp->firmware_cache)); 4920 memcpy(hdsp->firmware_cache, fw->data, sizeof(hdsp->firmware_cache));
4927#endif 4921
4928 release_firmware(fw); 4922 release_firmware(fw);
4929 4923
4930 hdsp->state |= HDSP_FirmwareCached; 4924 hdsp->state |= HDSP_FirmwareCached;
@@ -5194,7 +5188,7 @@ static struct pci_driver driver = {
5194 5188
5195static int __init alsa_card_hdsp_init(void) 5189static int __init alsa_card_hdsp_init(void)
5196{ 5190{
5197 return pci_module_init(&driver); 5191 return pci_register_driver(&driver);
5198} 5192}
5199 5193
5200static void __exit alsa_card_hdsp_exit(void) 5194static void __exit alsa_card_hdsp_exit(void)
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
new file mode 100644
index 000000000000..9e86d0eb41ce
--- /dev/null
+++ b/sound/pci/rme9652/hdspm.c
@@ -0,0 +1,3671 @@
1/* -*- linux-c -*-
2 *
3 * ALSA driver for RME Hammerfall DSP MADI audio interface(s)
4 *
5 * Copyright (c) 2003 Winfried Ritsch (IEM)
6 * code based on hdsp.c Paul Davis
7 * Marcus Andersson
8 * Thomas Charbonnel
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */
25#include <sound/driver.h>
26#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/interrupt.h>
29#include <linux/moduleparam.h>
30#include <linux/slab.h>
31#include <linux/pci.h>
32#include <asm/io.h>
33
34#include <sound/core.h>
35#include <sound/control.h>
36#include <sound/pcm.h>
37#include <sound/info.h>
38#include <sound/asoundef.h>
39#include <sound/rawmidi.h>
40#include <sound/hwdep.h>
41#include <sound/initval.h>
42
43#include <sound/hdspm.h>
44
45static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
46static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
47static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */
48
49/* Disable precise pointer at start */
50static int precise_ptr[SNDRV_CARDS];
51
52/* Send all playback to line outs */
53static int line_outs_monitor[SNDRV_CARDS];
54
55/* Enable Analog Outs on Channel 63/64 by default */
56static int enable_monitor[SNDRV_CARDS];
57
58module_param_array(index, int, NULL, 0444);
59MODULE_PARM_DESC(index, "Index value for RME HDSPM interface.");
60
61module_param_array(id, charp, NULL, 0444);
62MODULE_PARM_DESC(id, "ID string for RME HDSPM interface.");
63
64module_param_array(enable, bool, NULL, 0444);
65MODULE_PARM_DESC(enable, "Enable/disable specific HDSPM soundcards.");
66
67module_param_array(precise_ptr, bool, NULL, 0444);
68MODULE_PARM_DESC(precise_ptr, "Enable precise pointer, or disable.");
69
70module_param_array(line_outs_monitor, bool, NULL, 0444);
71MODULE_PARM_DESC(line_outs_monitor,
72 "Send playback streams to analog outs by default.");
73
74module_param_array(enable_monitor, bool, NULL, 0444);
75MODULE_PARM_DESC(enable_monitor,
76 "Enable Analog Out on Channel 63/64 by default.");
77
78MODULE_AUTHOR
79 ("Winfried Ritsch <ritsch_AT_iem.at>, Paul Davis <paul@linuxaudiosystems.com>, "
80 "Marcus Andersson, Thomas Charbonnel <thomas@undata.org>");
81MODULE_DESCRIPTION("RME HDSPM");
82MODULE_LICENSE("GPL");
83MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}");
84
85/* --- Write registers. ---
86 These are defined as byte-offsets from the iobase value. */
87
88#define HDSPM_controlRegister 64
89#define HDSPM_interruptConfirmation 96
90#define HDSPM_control2Reg 256 /* not in specs ???????? */
91#define HDSPM_midiDataOut0 352 /* just believe in old code */
92#define HDSPM_midiDataOut1 356
93
94/* DMA enable for 64 channels, only Bit 0 is relevant */
95#define HDSPM_outputEnableBase 512 /* 512-767 input DMA */
96#define HDSPM_inputEnableBase 768 /* 768-1023 output DMA */
97
98/* 16 page addresses for each of the 64 channels DMA buffer in and out
99 (each 64k=16*4k) Buffer must be 4k aligned (which is default i386 ????) */
100#define HDSPM_pageAddressBufferOut 8192
101#define HDSPM_pageAddressBufferIn (HDSPM_pageAddressBufferOut+64*16*4)
102
103#define HDSPM_MADI_mixerBase 32768 /* 32768-65535 for 2x64x64 Fader */
104
105#define HDSPM_MATRIX_MIXER_SIZE 8192 /* = 2*64*64 * 4 Byte => 32kB */
106
107/* --- Read registers. ---
108 These are defined as byte-offsets from the iobase value */
109#define HDSPM_statusRegister 0
110#define HDSPM_statusRegister2 96
111
112#define HDSPM_midiDataIn0 360
113#define HDSPM_midiDataIn1 364
114
115/* status is data bytes in MIDI-FIFO (0-128) */
116#define HDSPM_midiStatusOut0 384
117#define HDSPM_midiStatusOut1 388
118#define HDSPM_midiStatusIn0 392
119#define HDSPM_midiStatusIn1 396
120
121
122/* the meters are regular i/o-mapped registers, but offset
123 considerably from the rest. the peak registers are reset
124 when read; the least-significant 4 bits are full-scale counters;
125 the actual peak value is in the most-significant 24 bits.
126*/
127#define HDSPM_MADI_peakrmsbase 4096 /* 4096-8191 2x64x32Bit Meters */
128
129/* --- Control Register bits --------- */
130#define HDSPM_Start (1<<0) /* start engine */
131
132#define HDSPM_Latency0 (1<<1) /* buffer size = 2^n */
133#define HDSPM_Latency1 (1<<2) /* where n is defined */
134#define HDSPM_Latency2 (1<<3) /* by Latency{2,1,0} */
135
136#define HDSPM_ClockModeMaster (1<<4) /* 1=Master, 0=Slave/Autosync */
137
138#define HDSPM_AudioInterruptEnable (1<<5) /* what do you think ? */
139
140#define HDSPM_Frequency0 (1<<6) /* 0=44.1kHz/88.2kHz 1=48kHz/96kHz */
141#define HDSPM_Frequency1 (1<<7) /* 0=32kHz/64kHz */
142#define HDSPM_DoubleSpeed (1<<8) /* 0=normal speed, 1=double speed */
143#define HDSPM_QuadSpeed (1<<31) /* quad speed bit, not implemented now */
144
145#define HDSPM_TX_64ch (1<<10) /* Output 64channel MODE=1,
146 56channelMODE=0 */
147
148#define HDSPM_AutoInp (1<<11) /* Auto Input (takeover) == Safe Mode,
149 0=off, 1=on */
150
151#define HDSPM_InputSelect0 (1<<14) /* Input select 0= optical, 1=coax */
152#define HDSPM_InputSelect1 (1<<15) /* should be 0 */
153
154#define HDSPM_SyncRef0 (1<<16) /* 0=WOrd, 1=MADI */
155#define HDSPM_SyncRef1 (1<<17) /* should be 0 */
156
157#define HDSPM_clr_tms (1<<19) /* clear track marker, do not use
158 AES additional bits in
159 lower 5 Audiodatabits ??? */
160
161#define HDSPM_Midi0InterruptEnable (1<<22)
162#define HDSPM_Midi1InterruptEnable (1<<23)
163
164#define HDSPM_LineOut (1<<24) /* Analog Out on channel 63/64 on=1, mute=0 */
165
166
167/* --- bit helper defines */
168#define HDSPM_LatencyMask (HDSPM_Latency0|HDSPM_Latency1|HDSPM_Latency2)
169#define HDSPM_FrequencyMask (HDSPM_Frequency0|HDSPM_Frequency1)
170#define HDSPM_InputMask (HDSPM_InputSelect0|HDSPM_InputSelect1)
171#define HDSPM_InputOptical 0
172#define HDSPM_InputCoaxial (HDSPM_InputSelect0)
173#define HDSPM_SyncRefMask (HDSPM_SyncRef0|HDSPM_SyncRef1)
174#define HDSPM_SyncRef_Word 0
175#define HDSPM_SyncRef_MADI (HDSPM_SyncRef0)
176
177#define HDSPM_SYNC_FROM_WORD 0 /* Preferred sync reference */
178#define HDSPM_SYNC_FROM_MADI 1 /* choices - used by "pref_sync_ref" */
179
180#define HDSPM_Frequency32KHz HDSPM_Frequency0
181#define HDSPM_Frequency44_1KHz HDSPM_Frequency1
182#define HDSPM_Frequency48KHz (HDSPM_Frequency1|HDSPM_Frequency0)
183#define HDSPM_Frequency64KHz (HDSPM_DoubleSpeed|HDSPM_Frequency0)
184#define HDSPM_Frequency88_2KHz (HDSPM_DoubleSpeed|HDSPM_Frequency1)
185#define HDSPM_Frequency96KHz (HDSPM_DoubleSpeed|HDSPM_Frequency1|HDSPM_Frequency0)
186
187/* --- for internal discrimination */
188#define HDSPM_CLOCK_SOURCE_AUTOSYNC 0 /* Sample Clock Sources */
189#define HDSPM_CLOCK_SOURCE_INTERNAL_32KHZ 1
190#define HDSPM_CLOCK_SOURCE_INTERNAL_44_1KHZ 2
191#define HDSPM_CLOCK_SOURCE_INTERNAL_48KHZ 3
192#define HDSPM_CLOCK_SOURCE_INTERNAL_64KHZ 4
193#define HDSPM_CLOCK_SOURCE_INTERNAL_88_2KHZ 5
194#define HDSPM_CLOCK_SOURCE_INTERNAL_96KHZ 6
195#define HDSPM_CLOCK_SOURCE_INTERNAL_128KHZ 7
196#define HDSPM_CLOCK_SOURCE_INTERNAL_176_4KHZ 8
197#define HDSPM_CLOCK_SOURCE_INTERNAL_192KHZ 9
198
199/* Synccheck Status */
200#define HDSPM_SYNC_CHECK_NO_LOCK 0
201#define HDSPM_SYNC_CHECK_LOCK 1
202#define HDSPM_SYNC_CHECK_SYNC 2
203
204/* AutoSync References - used by "autosync_ref" control switch */
205#define HDSPM_AUTOSYNC_FROM_WORD 0
206#define HDSPM_AUTOSYNC_FROM_MADI 1
207#define HDSPM_AUTOSYNC_FROM_NONE 2
208
209/* Possible sources of MADI input */
210#define HDSPM_OPTICAL 0 /* optical */
211#define HDSPM_COAXIAL 1 /* BNC */
212
213#define hdspm_encode_latency(x) (((x)<<1) & HDSPM_LatencyMask)
214#define hdspm_decode_latency(x) (((x) & HDSPM_LatencyMask)>>1)
215
216#define hdspm_encode_in(x) (((x)&0x3)<<14)
217#define hdspm_decode_in(x) (((x)>>14)&0x3)
218
219/* --- control2 register bits --- */
220#define HDSPM_TMS (1<<0)
221#define HDSPM_TCK (1<<1)
222#define HDSPM_TDI (1<<2)
223#define HDSPM_JTAG (1<<3)
224#define HDSPM_PWDN (1<<4)
225#define HDSPM_PROGRAM (1<<5)
226#define HDSPM_CONFIG_MODE_0 (1<<6)
227#define HDSPM_CONFIG_MODE_1 (1<<7)
228/*#define HDSPM_VERSION_BIT (1<<8) not defined any more*/
229#define HDSPM_BIGENDIAN_MODE (1<<9)
230#define HDSPM_RD_MULTIPLE (1<<10)
231
232/* --- Status Register bits --- */
233#define HDSPM_audioIRQPending (1<<0) /* IRQ is high and pending */
234#define HDSPM_RX_64ch (1<<1) /* Input 64chan. MODE=1, 56chn. MODE=0 */
235#define HDSPM_AB_int (1<<2) /* InputChannel Opt=0, Coax=1 (like inp0) */
236#define HDSPM_madiLock (1<<3) /* MADI Locked =1, no=0 */
237
238#define HDSPM_BufferPositionMask 0x000FFC0 /* Bit 6..15 : h/w buffer pointer */
239 /* since 64byte accurate last 6 bits
240 are not used */
241
242#define HDSPM_madiSync (1<<18) /* MADI is in sync */
243#define HDSPM_DoubleSpeedStatus (1<<19) /* (input) card in double speed */
244
245#define HDSPM_madiFreq0 (1<<22) /* system freq 0=error */
246#define HDSPM_madiFreq1 (1<<23) /* 1=32, 2=44.1 3=48 */
247#define HDSPM_madiFreq2 (1<<24) /* 4=64, 5=88.2 6=96 */
248#define HDSPM_madiFreq3 (1<<25) /* 7=128, 8=176.4 9=192 */
249
250#define HDSPM_BufferID (1<<26) /* (Double)Buffer ID toggles with Interrupt */
251#define HDSPM_midi0IRQPending (1<<30) /* MIDI IRQ is pending */
252#define HDSPM_midi1IRQPending (1<<31) /* and aktiv */
253
254/* --- status bit helpers */
255#define HDSPM_madiFreqMask (HDSPM_madiFreq0|HDSPM_madiFreq1|HDSPM_madiFreq2|HDSPM_madiFreq3)
256#define HDSPM_madiFreq32 (HDSPM_madiFreq0)
257#define HDSPM_madiFreq44_1 (HDSPM_madiFreq1)
258#define HDSPM_madiFreq48 (HDSPM_madiFreq0|HDSPM_madiFreq1)
259#define HDSPM_madiFreq64 (HDSPM_madiFreq2)
260#define HDSPM_madiFreq88_2 (HDSPM_madiFreq0|HDSPM_madiFreq2)
261#define HDSPM_madiFreq96 (HDSPM_madiFreq1|HDSPM_madiFreq2)
262#define HDSPM_madiFreq128 (HDSPM_madiFreq0|HDSPM_madiFreq1|HDSPM_madiFreq2)
263#define HDSPM_madiFreq176_4 (HDSPM_madiFreq3)
264#define HDSPM_madiFreq192 (HDSPM_madiFreq3|HDSPM_madiFreq0)
265
266/* Status2 Register bits */
267
268#define HDSPM_version0 (1<<0) /* not realy defined but I guess */
269#define HDSPM_version1 (1<<1) /* in former cards it was ??? */
270#define HDSPM_version2 (1<<2)
271
272#define HDSPM_wcLock (1<<3) /* Wordclock is detected and locked */
273#define HDSPM_wcSync (1<<4) /* Wordclock is in sync with systemclock */
274
275#define HDSPM_wc_freq0 (1<<5) /* input freq detected via autosync */
276#define HDSPM_wc_freq1 (1<<6) /* 001=32, 010==44.1, 011=48, */
277#define HDSPM_wc_freq2 (1<<7) /* 100=64, 101=88.2, 110=96, */
278/* missing Bit for 111=128, 1000=176.4, 1001=192 */
279
280#define HDSPM_SelSyncRef0 (1<<8) /* Sync Source in slave mode */
281#define HDSPM_SelSyncRef1 (1<<9) /* 000=word, 001=MADI, */
282#define HDSPM_SelSyncRef2 (1<<10) /* 111=no valid signal */
283
284#define HDSPM_wc_valid (HDSPM_wcLock|HDSPM_wcSync)
285
286#define HDSPM_wcFreqMask (HDSPM_wc_freq0|HDSPM_wc_freq1|HDSPM_wc_freq2)
287#define HDSPM_wcFreq32 (HDSPM_wc_freq0)
288#define HDSPM_wcFreq44_1 (HDSPM_wc_freq1)
289#define HDSPM_wcFreq48 (HDSPM_wc_freq0|HDSPM_wc_freq1)
290#define HDSPM_wcFreq64 (HDSPM_wc_freq2)
291#define HDSPM_wcFreq88_2 (HDSPM_wc_freq0|HDSPM_wc_freq2)
292#define HDSPM_wcFreq96 (HDSPM_wc_freq1|HDSPM_wc_freq2)
293
294
295#define HDSPM_SelSyncRefMask (HDSPM_SelSyncRef0|HDSPM_SelSyncRef1|HDSPM_SelSyncRef2)
296#define HDSPM_SelSyncRef_WORD 0
297#define HDSPM_SelSyncRef_MADI (HDSPM_SelSyncRef0)
298#define HDSPM_SelSyncRef_NVALID (HDSPM_SelSyncRef0|HDSPM_SelSyncRef1|HDSPM_SelSyncRef2)
299
300/* Mixer Values */
301#define UNITY_GAIN 32768 /* = 65536/2 */
302#define MINUS_INFINITY_GAIN 0
303
304/* PCI info */
305#ifndef PCI_VENDOR_ID_XILINX
306#define PCI_VENDOR_ID_XILINX 0x10ee
307#endif
308#ifndef PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP
309#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP 0x3fc5
310#endif
311#ifndef PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI
312#define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI 0x3fc6
313#endif
314
315
316/* Number of channels for different Speed Modes */
317#define MADI_SS_CHANNELS 64
318#define MADI_DS_CHANNELS 32
319#define MADI_QS_CHANNELS 16
320
321/* the size of a substream (1 mono data stream) */
322#define HDSPM_CHANNEL_BUFFER_SAMPLES (16*1024)
323#define HDSPM_CHANNEL_BUFFER_BYTES (4*HDSPM_CHANNEL_BUFFER_SAMPLES)
324
325/* the size of the area we need to allocate for DMA transfers. the
326 size is the same regardless of the number of channels, and
327 also the latency to use.
328 for one direction !!!
329*/
330#define HDSPM_DMA_AREA_BYTES (HDSPM_MAX_CHANNELS * HDSPM_CHANNEL_BUFFER_BYTES)
331#define HDSPM_DMA_AREA_KILOBYTES (HDSPM_DMA_AREA_BYTES/1024)
332
333typedef struct _hdspm hdspm_t;
334typedef struct _hdspm_midi hdspm_midi_t;
335
336struct _hdspm_midi {
337 hdspm_t *hdspm;
338 int id;
339 snd_rawmidi_t *rmidi;
340 snd_rawmidi_substream_t *input;
341 snd_rawmidi_substream_t *output;
342 char istimer; /* timer in use */
343 struct timer_list timer;
344 spinlock_t lock;
345 int pending;
346};
347
348struct _hdspm {
349 spinlock_t lock;
350 snd_pcm_substream_t *capture_substream; /* only one playback */
351 snd_pcm_substream_t *playback_substream; /* and/or capture stream */
352
353 char *card_name; /* for procinfo */
354 unsigned short firmware_rev; /* dont know if relevant */
355
356 int precise_ptr; /* use precise pointers, to be tested */
357 int monitor_outs; /* set up monitoring outs init flag */
358
359 u32 control_register; /* cached value */
360 u32 control2_register; /* cached value */
361
362 hdspm_midi_t midi[2];
363 struct tasklet_struct midi_tasklet;
364
365 size_t period_bytes;
366 unsigned char ss_channels; /* channels of card in single speed */
367 unsigned char ds_channels; /* Double Speed */
368 unsigned char qs_channels; /* Quad Speed */
369
370 unsigned char *playback_buffer; /* suitably aligned address */
371 unsigned char *capture_buffer; /* suitably aligned address */
372
373 pid_t capture_pid; /* process id which uses capture */
374 pid_t playback_pid; /* process id which uses capture */
375 int running; /* running status */
376
377 int last_external_sample_rate; /* samplerate mystic ... */
378 int last_internal_sample_rate;
379 int system_sample_rate;
380
381 char *channel_map; /* channel map for DS and Quadspeed */
382
383 int dev; /* Hardware vars... */
384 int irq;
385 unsigned long port;
386 void __iomem *iobase;
387
388 int irq_count; /* for debug */
389
390 snd_card_t *card; /* one card */
391 snd_pcm_t *pcm; /* has one pcm */
392 snd_hwdep_t *hwdep; /* and a hwdep for additional ioctl */
393 struct pci_dev *pci; /* and an pci info */
394
395 /* Mixer vars */
396 snd_kcontrol_t *playback_mixer_ctls[HDSPM_MAX_CHANNELS]; /* fast alsa mixer */
397 snd_kcontrol_t *input_mixer_ctls[HDSPM_MAX_CHANNELS]; /* but input to much, so not used */
398 hdspm_mixer_t *mixer; /* full mixer accessable over mixer ioctl or hwdep-device */
399
400};
401
402/* These tables map the ALSA channels 1..N to the channels that we
403 need to use in order to find the relevant channel buffer. RME
404 refer to this kind of mapping as between "the ADAT channel and
405 the DMA channel." We index it using the logical audio channel,
406 and the value is the DMA channel (i.e. channel buffer number)
407 where the data for that channel can be read/written from/to.
408*/
409
410static char channel_map_madi_ss[HDSPM_MAX_CHANNELS] = {
411 0, 1, 2, 3, 4, 5, 6, 7,
412 8, 9, 10, 11, 12, 13, 14, 15,
413 16, 17, 18, 19, 20, 21, 22, 23,
414 24, 25, 26, 27, 28, 29, 30, 31,
415 32, 33, 34, 35, 36, 37, 38, 39,
416 40, 41, 42, 43, 44, 45, 46, 47,
417 48, 49, 50, 51, 52, 53, 54, 55,
418 56, 57, 58, 59, 60, 61, 62, 63
419};
420
421static char channel_map_madi_ds[HDSPM_MAX_CHANNELS] = {
422 0, 2, 4, 6, 8, 10, 12, 14,
423 16, 18, 20, 22, 24, 26, 28, 30,
424 32, 34, 36, 38, 40, 42, 44, 46,
425 48, 50, 52, 54, 56, 58, 60, 62,
426 -1, -1, -1, -1, -1, -1, -1, -1,
427 -1, -1, -1, -1, -1, -1, -1, -1,
428 -1, -1, -1, -1, -1, -1, -1, -1,
429 -1, -1, -1, -1, -1, -1, -1, -1
430};
431
432static char channel_map_madi_qs[HDSPM_MAX_CHANNELS] = {
433 0, 4, 8, 12, 16, 20, 24, 28,
434 32, 36, 40, 44, 48, 52, 56, 60
435 -1, -1, -1, -1, -1, -1, -1, -1,
436 -1, -1, -1, -1, -1, -1, -1, -1,
437 -1, -1, -1, -1, -1, -1, -1, -1,
438 -1, -1, -1, -1, -1, -1, -1, -1,
439 -1, -1, -1, -1, -1, -1, -1, -1,
440 -1, -1, -1, -1, -1, -1, -1, -1
441};
442
443
444static struct pci_device_id snd_hdspm_ids[] = {
445 {
446 .vendor = PCI_VENDOR_ID_XILINX,
447 .device = PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI,
448 .subvendor = PCI_ANY_ID,
449 .subdevice = PCI_ANY_ID,
450 .class = 0,
451 .class_mask = 0,
452 .driver_data = 0},
453 {0,}
454};
455
456MODULE_DEVICE_TABLE(pci, snd_hdspm_ids);
457
458/* prototypes */
459static int __devinit snd_hdspm_create_alsa_devices(snd_card_t * card,
460 hdspm_t * hdspm);
461static int __devinit snd_hdspm_create_pcm(snd_card_t * card,
462 hdspm_t * hdspm);
463
464static inline void snd_hdspm_initialize_midi_flush(hdspm_t * hdspm);
465static int hdspm_update_simple_mixer_controls(hdspm_t * hdspm);
466static int hdspm_autosync_ref(hdspm_t * hdspm);
467static int snd_hdspm_set_defaults(hdspm_t * hdspm);
468static void hdspm_set_sgbuf(hdspm_t * hdspm, struct snd_sg_buf *sgbuf,
469 unsigned int reg, int channels);
470
471/* Write/read to/from HDSPM with Adresses in Bytes
472 not words but only 32Bit writes are allowed */
473
474static inline void hdspm_write(hdspm_t * hdspm, unsigned int reg,
475 unsigned int val)
476{
477 writel(val, hdspm->iobase + reg);
478}
479
480static inline unsigned int hdspm_read(hdspm_t * hdspm, unsigned int reg)
481{
482 return readl(hdspm->iobase + reg);
483}
484
485/* for each output channel (chan) I have an Input (in) and Playback (pb) Fader
486 mixer is write only on hardware so we have to cache him for read
487 each fader is a u32, but uses only the first 16 bit */
488
489static inline int hdspm_read_in_gain(hdspm_t * hdspm, unsigned int chan,
490 unsigned int in)
491{
492 if (chan > HDSPM_MIXER_CHANNELS || in > HDSPM_MIXER_CHANNELS)
493 return 0;
494
495 return hdspm->mixer->ch[chan].in[in];
496}
497
498static inline int hdspm_read_pb_gain(hdspm_t * hdspm, unsigned int chan,
499 unsigned int pb)
500{
501 if (chan > HDSPM_MIXER_CHANNELS || pb > HDSPM_MIXER_CHANNELS)
502 return 0;
503 return hdspm->mixer->ch[chan].pb[pb];
504}
505
506static inline int hdspm_write_in_gain(hdspm_t * hdspm, unsigned int chan,
507 unsigned int in, unsigned short data)
508{
509 if (chan >= HDSPM_MIXER_CHANNELS || in >= HDSPM_MIXER_CHANNELS)
510 return -1;
511
512 hdspm_write(hdspm,
513 HDSPM_MADI_mixerBase +
514 ((in + 128 * chan) * sizeof(u32)),
515 (hdspm->mixer->ch[chan].in[in] = data & 0xFFFF));
516 return 0;
517}
518
519static inline int hdspm_write_pb_gain(hdspm_t * hdspm, unsigned int chan,
520 unsigned int pb, unsigned short data)
521{
522 if (chan >= HDSPM_MIXER_CHANNELS || pb >= HDSPM_MIXER_CHANNELS)
523 return -1;
524
525 hdspm_write(hdspm,
526 HDSPM_MADI_mixerBase +
527 ((64 + pb + 128 * chan) * sizeof(u32)),
528 (hdspm->mixer->ch[chan].pb[pb] = data & 0xFFFF));
529 return 0;
530}
531
532
533/* enable DMA for specific channels, now available for DSP-MADI */
534static inline void snd_hdspm_enable_in(hdspm_t * hdspm, int i, int v)
535{
536 hdspm_write(hdspm, HDSPM_inputEnableBase + (4 * i), v);
537}
538
539static inline void snd_hdspm_enable_out(hdspm_t * hdspm, int i, int v)
540{
541 hdspm_write(hdspm, HDSPM_outputEnableBase + (4 * i), v);
542}
543
544/* check if same process is writing and reading */
545static inline int snd_hdspm_use_is_exclusive(hdspm_t * hdspm)
546{
547 unsigned long flags;
548 int ret = 1;
549
550 spin_lock_irqsave(&hdspm->lock, flags);
551 if ((hdspm->playback_pid != hdspm->capture_pid) &&
552 (hdspm->playback_pid >= 0) && (hdspm->capture_pid >= 0)) {
553 ret = 0;
554 }
555 spin_unlock_irqrestore(&hdspm->lock, flags);
556 return ret;
557}
558
559/* check for external sample rate */
560static inline int hdspm_external_sample_rate(hdspm_t * hdspm)
561{
562 unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
563 unsigned int status = hdspm_read(hdspm, HDSPM_statusRegister);
564 unsigned int rate_bits;
565 int rate = 0;
566
567 /* if wordclock has synced freq and wordclock is valid */
568 if ((status2 & HDSPM_wcLock) != 0 &&
569 (status & HDSPM_SelSyncRef0) == 0) {
570
571 rate_bits = status2 & HDSPM_wcFreqMask;
572
573 switch (rate_bits) {
574 case HDSPM_wcFreq32:
575 rate = 32000;
576 break;
577 case HDSPM_wcFreq44_1:
578 rate = 44100;
579 break;
580 case HDSPM_wcFreq48:
581 rate = 48000;
582 break;
583 case HDSPM_wcFreq64:
584 rate = 64000;
585 break;
586 case HDSPM_wcFreq88_2:
587 rate = 88200;
588 break;
589 case HDSPM_wcFreq96:
590 rate = 96000;
591 break;
592 /* Quadspeed Bit missing ???? */
593 default:
594 rate = 0;
595 break;
596 }
597 }
598
599 /* if rate detected and Syncref is Word than have it, word has priority to MADI */
600 if (rate != 0
601 && (status2 & HDSPM_SelSyncRefMask) == HDSPM_SelSyncRef_WORD)
602 return rate;
603
604 /* maby a madi input (which is taken if sel sync is madi) */
605 if (status & HDSPM_madiLock) {
606 rate_bits = status & HDSPM_madiFreqMask;
607
608 switch (rate_bits) {
609 case HDSPM_madiFreq32:
610 rate = 32000;
611 break;
612 case HDSPM_madiFreq44_1:
613 rate = 44100;
614 break;
615 case HDSPM_madiFreq48:
616 rate = 48000;
617 break;
618 case HDSPM_madiFreq64:
619 rate = 64000;
620 break;
621 case HDSPM_madiFreq88_2:
622 rate = 88200;
623 break;
624 case HDSPM_madiFreq96:
625 rate = 96000;
626 break;
627 case HDSPM_madiFreq128:
628 rate = 128000;
629 break;
630 case HDSPM_madiFreq176_4:
631 rate = 176400;
632 break;
633 case HDSPM_madiFreq192:
634 rate = 192000;
635 break;
636 default:
637 rate = 0;
638 break;
639 }
640 }
641 return rate;
642}
643
644/* Latency function */
645static inline void hdspm_compute_period_size(hdspm_t * hdspm)
646{
647 hdspm->period_bytes =
648 1 << ((hdspm_decode_latency(hdspm->control_register) + 8));
649}
650
651static snd_pcm_uframes_t hdspm_hw_pointer(hdspm_t * hdspm)
652{
653 int position;
654
655 position = hdspm_read(hdspm, HDSPM_statusRegister);
656
657 if (!hdspm->precise_ptr) {
658 return (position & HDSPM_BufferID) ? (hdspm->period_bytes /
659 4) : 0;
660 }
661
662 /* hwpointer comes in bytes and is 64Bytes accurate (by docu since PCI Burst)
663 i have experimented that it is at most 64 Byte to much for playing
664 so substraction of 64 byte should be ok for ALSA, but use it only
665 for application where you know what you do since if you come to
666 near with record pointer it can be a disaster */
667
668 position &= HDSPM_BufferPositionMask;
669 position = ((position - 64) % (2 * hdspm->period_bytes)) / 4;
670
671 return position;
672}
673
674
675static inline void hdspm_start_audio(hdspm_t * s)
676{
677 s->control_register |= (HDSPM_AudioInterruptEnable | HDSPM_Start);
678 hdspm_write(s, HDSPM_controlRegister, s->control_register);
679}
680
681static inline void hdspm_stop_audio(hdspm_t * s)
682{
683 s->control_register &= ~(HDSPM_Start | HDSPM_AudioInterruptEnable);
684 hdspm_write(s, HDSPM_controlRegister, s->control_register);
685}
686
687/* should I silence all or only opened ones ? doit all for first even is 4MB*/
688static inline void hdspm_silence_playback(hdspm_t * hdspm)
689{
690 int i;
691 int n = hdspm->period_bytes;
692 void *buf = hdspm->playback_buffer;
693
694 snd_assert(buf != NULL, return);
695
696 for (i = 0; i < HDSPM_MAX_CHANNELS; i++) {
697 memset(buf, 0, n);
698 buf += HDSPM_CHANNEL_BUFFER_BYTES;
699 }
700}
701
702static int hdspm_set_interrupt_interval(hdspm_t * s, unsigned int frames)
703{
704 int n;
705
706 spin_lock_irq(&s->lock);
707
708 frames >>= 7;
709 n = 0;
710 while (frames) {
711 n++;
712 frames >>= 1;
713 }
714 s->control_register &= ~HDSPM_LatencyMask;
715 s->control_register |= hdspm_encode_latency(n);
716
717 hdspm_write(s, HDSPM_controlRegister, s->control_register);
718
719 hdspm_compute_period_size(s);
720
721 spin_unlock_irq(&s->lock);
722
723 return 0;
724}
725
726
727/* dummy set rate lets see what happens */
728static int hdspm_set_rate(hdspm_t * hdspm, int rate, int called_internally)
729{
730 int reject_if_open = 0;
731 int current_rate;
732 int rate_bits;
733 int not_set = 0;
734
735 /* ASSUMPTION: hdspm->lock is either set, or there is no need for
736 it (e.g. during module initialization).
737 */
738
739 if (!(hdspm->control_register & HDSPM_ClockModeMaster)) {
740
741 /* SLAVE --- */
742 if (called_internally) {
743
744 /* request from ctl or card initialization
745 just make a warning an remember setting
746 for future master mode switching */
747
748 snd_printk
749 (KERN_WARNING "HDSPM: Warning: device is not running as a clock master.\n");
750 not_set = 1;
751 } else {
752
753 /* hw_param request while in AutoSync mode */
754 int external_freq =
755 hdspm_external_sample_rate(hdspm);
756
757 if ((hdspm_autosync_ref(hdspm) ==
758 HDSPM_AUTOSYNC_FROM_NONE)) {
759
760 snd_printk(KERN_WARNING "HDSPM: Detected no Externel Sync \n");
761 not_set = 1;
762
763 } else if (rate != external_freq) {
764
765 snd_printk
766 (KERN_WARNING "HDSPM: Warning: No AutoSync source for requested rate\n");
767 not_set = 1;
768 }
769 }
770 }
771
772 current_rate = hdspm->system_sample_rate;
773
774 /* Changing between Singe, Double and Quad speed is not
775 allowed if any substreams are open. This is because such a change
776 causes a shift in the location of the DMA buffers and a reduction
777 in the number of available buffers.
778
779 Note that a similar but essentially insoluble problem exists for
780 externally-driven rate changes. All we can do is to flag rate
781 changes in the read/write routines.
782 */
783
784 switch (rate) {
785 case 32000:
786 if (current_rate > 48000) {
787 reject_if_open = 1;
788 }
789 rate_bits = HDSPM_Frequency32KHz;
790 break;
791 case 44100:
792 if (current_rate > 48000) {
793 reject_if_open = 1;
794 }
795 rate_bits = HDSPM_Frequency44_1KHz;
796 break;
797 case 48000:
798 if (current_rate > 48000) {
799 reject_if_open = 1;
800 }
801 rate_bits = HDSPM_Frequency48KHz;
802 break;
803 case 64000:
804 if (current_rate <= 48000) {
805 reject_if_open = 1;
806 }
807 rate_bits = HDSPM_Frequency64KHz;
808 break;
809 case 88200:
810 if (current_rate <= 48000) {
811 reject_if_open = 1;
812 }
813 rate_bits = HDSPM_Frequency88_2KHz;
814 break;
815 case 96000:
816 if (current_rate <= 48000) {
817 reject_if_open = 1;
818 }
819 rate_bits = HDSPM_Frequency96KHz;
820 break;
821 default:
822 return -EINVAL;
823 }
824
825 if (reject_if_open
826 && (hdspm->capture_pid >= 0 || hdspm->playback_pid >= 0)) {
827 snd_printk
828 (KERN_ERR "HDSPM: cannot change between single- and double-speed mode (capture PID = %d, playback PID = %d)\n",
829 hdspm->capture_pid, hdspm->playback_pid);
830 return -EBUSY;
831 }
832
833 hdspm->control_register &= ~HDSPM_FrequencyMask;
834 hdspm->control_register |= rate_bits;
835 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
836
837 if (rate > 64000)
838 hdspm->channel_map = channel_map_madi_qs;
839 else if (rate > 48000)
840 hdspm->channel_map = channel_map_madi_ds;
841 else
842 hdspm->channel_map = channel_map_madi_ss;
843
844 hdspm->system_sample_rate = rate;
845
846 if (not_set != 0)
847 return -1;
848
849 return 0;
850}
851
852/* mainly for init to 0 on load */
853static void all_in_all_mixer(hdspm_t * hdspm, int sgain)
854{
855 int i, j;
856 unsigned int gain =
857 (sgain > UNITY_GAIN) ? UNITY_GAIN : (sgain < 0) ? 0 : sgain;
858
859 for (i = 0; i < HDSPM_MIXER_CHANNELS; i++)
860 for (j = 0; j < HDSPM_MIXER_CHANNELS; j++) {
861 hdspm_write_in_gain(hdspm, i, j, gain);
862 hdspm_write_pb_gain(hdspm, i, j, gain);
863 }
864}
865
866/*----------------------------------------------------------------------------
867 MIDI
868 ----------------------------------------------------------------------------*/
869
870static inline unsigned char snd_hdspm_midi_read_byte (hdspm_t *hdspm, int id)
871{
872 /* the hardware already does the relevant bit-mask with 0xff */
873 if (id)
874 return hdspm_read(hdspm, HDSPM_midiDataIn1);
875 else
876 return hdspm_read(hdspm, HDSPM_midiDataIn0);
877}
878
879static inline void snd_hdspm_midi_write_byte (hdspm_t *hdspm, int id, int val)
880{
881 /* the hardware already does the relevant bit-mask with 0xff */
882 if (id)
883 return hdspm_write(hdspm, HDSPM_midiDataOut1, val);
884 else
885 return hdspm_write(hdspm, HDSPM_midiDataOut0, val);
886}
887
888static inline int snd_hdspm_midi_input_available (hdspm_t *hdspm, int id)
889{
890 if (id)
891 return (hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xff);
892 else
893 return (hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xff);
894}
895
896static inline int snd_hdspm_midi_output_possible (hdspm_t *hdspm, int id)
897{
898 int fifo_bytes_used;
899
900 if (id)
901 fifo_bytes_used = hdspm_read(hdspm, HDSPM_midiStatusOut1) & 0xff;
902 else
903 fifo_bytes_used = hdspm_read(hdspm, HDSPM_midiStatusOut0) & 0xff;
904
905 if (fifo_bytes_used < 128)
906 return 128 - fifo_bytes_used;
907 else
908 return 0;
909}
910
911static inline void snd_hdspm_flush_midi_input (hdspm_t *hdspm, int id)
912{
913 while (snd_hdspm_midi_input_available (hdspm, id))
914 snd_hdspm_midi_read_byte (hdspm, id);
915}
916
917static int snd_hdspm_midi_output_write (hdspm_midi_t *hmidi)
918{
919 unsigned long flags;
920 int n_pending;
921 int to_write;
922 int i;
923 unsigned char buf[128];
924
925 /* Output is not interrupt driven */
926
927 spin_lock_irqsave (&hmidi->lock, flags);
928 if (hmidi->output) {
929 if (!snd_rawmidi_transmit_empty (hmidi->output)) {
930 if ((n_pending = snd_hdspm_midi_output_possible (hmidi->hdspm, hmidi->id)) > 0) {
931 if (n_pending > (int)sizeof (buf))
932 n_pending = sizeof (buf);
933
934 if ((to_write = snd_rawmidi_transmit (hmidi->output, buf, n_pending)) > 0) {
935 for (i = 0; i < to_write; ++i)
936 snd_hdspm_midi_write_byte (hmidi->hdspm, hmidi->id, buf[i]);
937 }
938 }
939 }
940 }
941 spin_unlock_irqrestore (&hmidi->lock, flags);
942 return 0;
943}
944
945static int snd_hdspm_midi_input_read (hdspm_midi_t *hmidi)
946{
947 unsigned char buf[128]; /* this buffer is designed to match the MIDI input FIFO size */
948 unsigned long flags;
949 int n_pending;
950 int i;
951
952 spin_lock_irqsave (&hmidi->lock, flags);
953 if ((n_pending = snd_hdspm_midi_input_available (hmidi->hdspm, hmidi->id)) > 0) {
954 if (hmidi->input) {
955 if (n_pending > (int)sizeof (buf)) {
956 n_pending = sizeof (buf);
957 }
958 for (i = 0; i < n_pending; ++i) {
959 buf[i] = snd_hdspm_midi_read_byte (hmidi->hdspm, hmidi->id);
960 }
961 if (n_pending) {
962 snd_rawmidi_receive (hmidi->input, buf, n_pending);
963 }
964 } else {
965 /* flush the MIDI input FIFO */
966 while (n_pending--) {
967 snd_hdspm_midi_read_byte (hmidi->hdspm, hmidi->id);
968 }
969 }
970 }
971 hmidi->pending = 0;
972 if (hmidi->id) {
973 hmidi->hdspm->control_register |= HDSPM_Midi1InterruptEnable;
974 } else {
975 hmidi->hdspm->control_register |= HDSPM_Midi0InterruptEnable;
976 }
977 hdspm_write(hmidi->hdspm, HDSPM_controlRegister, hmidi->hdspm->control_register);
978 spin_unlock_irqrestore (&hmidi->lock, flags);
979 return snd_hdspm_midi_output_write (hmidi);
980}
981
982static void snd_hdspm_midi_input_trigger(snd_rawmidi_substream_t * substream, int up)
983{
984 hdspm_t *hdspm;
985 hdspm_midi_t *hmidi;
986 unsigned long flags;
987 u32 ie;
988
989 hmidi = (hdspm_midi_t *) substream->rmidi->private_data;
990 hdspm = hmidi->hdspm;
991 ie = hmidi->id ? HDSPM_Midi1InterruptEnable : HDSPM_Midi0InterruptEnable;
992 spin_lock_irqsave (&hdspm->lock, flags);
993 if (up) {
994 if (!(hdspm->control_register & ie)) {
995 snd_hdspm_flush_midi_input (hdspm, hmidi->id);
996 hdspm->control_register |= ie;
997 }
998 } else {
999 hdspm->control_register &= ~ie;
1000 }
1001
1002 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
1003 spin_unlock_irqrestore (&hdspm->lock, flags);
1004}
1005
1006static void snd_hdspm_midi_output_timer(unsigned long data)
1007{
1008 hdspm_midi_t *hmidi = (hdspm_midi_t *) data;
1009 unsigned long flags;
1010
1011 snd_hdspm_midi_output_write(hmidi);
1012 spin_lock_irqsave (&hmidi->lock, flags);
1013
1014 /* this does not bump hmidi->istimer, because the
1015 kernel automatically removed the timer when it
1016 expired, and we are now adding it back, thus
1017 leaving istimer wherever it was set before.
1018 */
1019
1020 if (hmidi->istimer) {
1021 hmidi->timer.expires = 1 + jiffies;
1022 add_timer(&hmidi->timer);
1023 }
1024
1025 spin_unlock_irqrestore (&hmidi->lock, flags);
1026}
1027
1028static void snd_hdspm_midi_output_trigger(snd_rawmidi_substream_t * substream, int up)
1029{
1030 hdspm_midi_t *hmidi;
1031 unsigned long flags;
1032
1033 hmidi = (hdspm_midi_t *) substream->rmidi->private_data;
1034 spin_lock_irqsave (&hmidi->lock, flags);
1035 if (up) {
1036 if (!hmidi->istimer) {
1037 init_timer(&hmidi->timer);
1038 hmidi->timer.function = snd_hdspm_midi_output_timer;
1039 hmidi->timer.data = (unsigned long) hmidi;
1040 hmidi->timer.expires = 1 + jiffies;
1041 add_timer(&hmidi->timer);
1042 hmidi->istimer++;
1043 }
1044 } else {
1045 if (hmidi->istimer && --hmidi->istimer <= 0) {
1046 del_timer (&hmidi->timer);
1047 }
1048 }
1049 spin_unlock_irqrestore (&hmidi->lock, flags);
1050 if (up)
1051 snd_hdspm_midi_output_write(hmidi);
1052}
1053
1054static int snd_hdspm_midi_input_open(snd_rawmidi_substream_t * substream)
1055{
1056 hdspm_midi_t *hmidi;
1057
1058 hmidi = (hdspm_midi_t *) substream->rmidi->private_data;
1059 spin_lock_irq (&hmidi->lock);
1060 snd_hdspm_flush_midi_input (hmidi->hdspm, hmidi->id);
1061 hmidi->input = substream;
1062 spin_unlock_irq (&hmidi->lock);
1063
1064 return 0;
1065}
1066
1067static int snd_hdspm_midi_output_open(snd_rawmidi_substream_t * substream)
1068{
1069 hdspm_midi_t *hmidi;
1070
1071 hmidi = (hdspm_midi_t *) substream->rmidi->private_data;
1072 spin_lock_irq (&hmidi->lock);
1073 hmidi->output = substream;
1074 spin_unlock_irq (&hmidi->lock);
1075
1076 return 0;
1077}
1078
1079static int snd_hdspm_midi_input_close(snd_rawmidi_substream_t * substream)
1080{
1081 hdspm_midi_t *hmidi;
1082
1083 snd_hdspm_midi_input_trigger (substream, 0);
1084
1085 hmidi = (hdspm_midi_t *) substream->rmidi->private_data;
1086 spin_lock_irq (&hmidi->lock);
1087 hmidi->input = NULL;
1088 spin_unlock_irq (&hmidi->lock);
1089
1090 return 0;
1091}
1092
1093static int snd_hdspm_midi_output_close(snd_rawmidi_substream_t * substream)
1094{
1095 hdspm_midi_t *hmidi;
1096
1097 snd_hdspm_midi_output_trigger (substream, 0);
1098
1099 hmidi = (hdspm_midi_t *) substream->rmidi->private_data;
1100 spin_lock_irq (&hmidi->lock);
1101 hmidi->output = NULL;
1102 spin_unlock_irq (&hmidi->lock);
1103
1104 return 0;
1105}
1106
1107snd_rawmidi_ops_t snd_hdspm_midi_output =
1108{
1109 .open = snd_hdspm_midi_output_open,
1110 .close = snd_hdspm_midi_output_close,
1111 .trigger = snd_hdspm_midi_output_trigger,
1112};
1113
1114snd_rawmidi_ops_t snd_hdspm_midi_input =
1115{
1116 .open = snd_hdspm_midi_input_open,
1117 .close = snd_hdspm_midi_input_close,
1118 .trigger = snd_hdspm_midi_input_trigger,
1119};
1120
1121static int __devinit snd_hdspm_create_midi (snd_card_t *card, hdspm_t *hdspm, int id)
1122{
1123 int err;
1124 char buf[32];
1125
1126 hdspm->midi[id].id = id;
1127 hdspm->midi[id].rmidi = NULL;
1128 hdspm->midi[id].input = NULL;
1129 hdspm->midi[id].output = NULL;
1130 hdspm->midi[id].hdspm = hdspm;
1131 hdspm->midi[id].istimer = 0;
1132 hdspm->midi[id].pending = 0;
1133 spin_lock_init (&hdspm->midi[id].lock);
1134
1135 sprintf (buf, "%s MIDI %d", card->shortname, id+1);
1136 if ((err = snd_rawmidi_new (card, buf, id, 1, 1, &hdspm->midi[id].rmidi)) < 0)
1137 return err;
1138
1139 sprintf (hdspm->midi[id].rmidi->name, "%s MIDI %d", card->id, id+1);
1140 hdspm->midi[id].rmidi->private_data = &hdspm->midi[id];
1141
1142 snd_rawmidi_set_ops (hdspm->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_hdspm_midi_output);
1143 snd_rawmidi_set_ops (hdspm->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_hdspm_midi_input);
1144
1145 hdspm->midi[id].rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT |
1146 SNDRV_RAWMIDI_INFO_INPUT |
1147 SNDRV_RAWMIDI_INFO_DUPLEX;
1148
1149 return 0;
1150}
1151
1152
1153static void hdspm_midi_tasklet(unsigned long arg)
1154{
1155 hdspm_t *hdspm = (hdspm_t *)arg;
1156
1157 if (hdspm->midi[0].pending)
1158 snd_hdspm_midi_input_read (&hdspm->midi[0]);
1159 if (hdspm->midi[1].pending)
1160 snd_hdspm_midi_input_read (&hdspm->midi[1]);
1161}
1162
1163
1164/*-----------------------------------------------------------------------------
1165 Status Interface
1166 ----------------------------------------------------------------------------*/
1167
1168/* get the system sample rate which is set */
1169
1170#define HDSPM_SYSTEM_SAMPLE_RATE(xname, xindex) \
1171{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
1172 .name = xname, \
1173 .index = xindex, \
1174 .access = SNDRV_CTL_ELEM_ACCESS_READ, \
1175 .info = snd_hdspm_info_system_sample_rate, \
1176 .get = snd_hdspm_get_system_sample_rate \
1177}
1178
1179static int snd_hdspm_info_system_sample_rate(snd_kcontrol_t * kcontrol,
1180 snd_ctl_elem_info_t * uinfo)
1181{
1182 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1183 uinfo->count = 1;
1184 return 0;
1185}
1186
1187static int snd_hdspm_get_system_sample_rate(snd_kcontrol_t * kcontrol,
1188 snd_ctl_elem_value_t *
1189 ucontrol)
1190{
1191 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1192
1193 ucontrol->value.enumerated.item[0] = hdspm->system_sample_rate;
1194 return 0;
1195}
1196
1197#define HDSPM_AUTOSYNC_SAMPLE_RATE(xname, xindex) \
1198{ .iface = SNDRV_CTL_ELEM_IFACE_PCM, \
1199 .name = xname, \
1200 .index = xindex, \
1201 .access = SNDRV_CTL_ELEM_ACCESS_READ, \
1202 .info = snd_hdspm_info_autosync_sample_rate, \
1203 .get = snd_hdspm_get_autosync_sample_rate \
1204}
1205
1206static int snd_hdspm_info_autosync_sample_rate(snd_kcontrol_t * kcontrol,
1207 snd_ctl_elem_info_t * uinfo)
1208{
1209 static char *texts[] = { "32000", "44100", "48000",
1210 "64000", "88200", "96000",
1211 "128000", "176400", "192000",
1212 "None"
1213 };
1214 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1215 uinfo->count = 1;
1216 uinfo->value.enumerated.items = 10;
1217 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
1218 uinfo->value.enumerated.item =
1219 uinfo->value.enumerated.items - 1;
1220 strcpy(uinfo->value.enumerated.name,
1221 texts[uinfo->value.enumerated.item]);
1222 return 0;
1223}
1224
1225static int snd_hdspm_get_autosync_sample_rate(snd_kcontrol_t * kcontrol,
1226 snd_ctl_elem_value_t *
1227 ucontrol)
1228{
1229 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1230
1231 switch (hdspm_external_sample_rate(hdspm)) {
1232 case 32000:
1233 ucontrol->value.enumerated.item[0] = 0;
1234 break;
1235 case 44100:
1236 ucontrol->value.enumerated.item[0] = 1;
1237 break;
1238 case 48000:
1239 ucontrol->value.enumerated.item[0] = 2;
1240 break;
1241 case 64000:
1242 ucontrol->value.enumerated.item[0] = 3;
1243 break;
1244 case 88200:
1245 ucontrol->value.enumerated.item[0] = 4;
1246 break;
1247 case 96000:
1248 ucontrol->value.enumerated.item[0] = 5;
1249 break;
1250 case 128000:
1251 ucontrol->value.enumerated.item[0] = 6;
1252 break;
1253 case 176400:
1254 ucontrol->value.enumerated.item[0] = 7;
1255 break;
1256 case 192000:
1257 ucontrol->value.enumerated.item[0] = 8;
1258 break;
1259
1260 default:
1261 ucontrol->value.enumerated.item[0] = 9;
1262 }
1263 return 0;
1264}
1265
1266#define HDSPM_SYSTEM_CLOCK_MODE(xname, xindex) \
1267{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
1268 .name = xname, \
1269 .index = xindex, \
1270 .access = SNDRV_CTL_ELEM_ACCESS_READ, \
1271 .info = snd_hdspm_info_system_clock_mode, \
1272 .get = snd_hdspm_get_system_clock_mode, \
1273}
1274
1275
1276
1277static int hdspm_system_clock_mode(hdspm_t * hdspm)
1278{
1279 /* Always reflect the hardware info, rme is never wrong !!!! */
1280
1281 if (hdspm->control_register & HDSPM_ClockModeMaster)
1282 return 0;
1283 return 1;
1284}
1285
1286static int snd_hdspm_info_system_clock_mode(snd_kcontrol_t * kcontrol,
1287 snd_ctl_elem_info_t * uinfo)
1288{
1289 static char *texts[] = { "Master", "Slave" };
1290
1291 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1292 uinfo->count = 1;
1293 uinfo->value.enumerated.items = 2;
1294 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
1295 uinfo->value.enumerated.item =
1296 uinfo->value.enumerated.items - 1;
1297 strcpy(uinfo->value.enumerated.name,
1298 texts[uinfo->value.enumerated.item]);
1299 return 0;
1300}
1301
1302static int snd_hdspm_get_system_clock_mode(snd_kcontrol_t * kcontrol,
1303 snd_ctl_elem_value_t * ucontrol)
1304{
1305 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1306
1307 ucontrol->value.enumerated.item[0] =
1308 hdspm_system_clock_mode(hdspm);
1309 return 0;
1310}
1311
1312#define HDSPM_CLOCK_SOURCE(xname, xindex) \
1313{ .iface = SNDRV_CTL_ELEM_IFACE_PCM, \
1314 .name = xname, \
1315 .index = xindex, \
1316 .info = snd_hdspm_info_clock_source, \
1317 .get = snd_hdspm_get_clock_source, \
1318 .put = snd_hdspm_put_clock_source \
1319}
1320
1321static int hdspm_clock_source(hdspm_t * hdspm)
1322{
1323 if (hdspm->control_register & HDSPM_ClockModeMaster) {
1324 switch (hdspm->system_sample_rate) {
1325 case 32000:
1326 return 1;
1327 case 44100:
1328 return 2;
1329 case 48000:
1330 return 3;
1331 case 64000:
1332 return 4;
1333 case 88200:
1334 return 5;
1335 case 96000:
1336 return 6;
1337 case 128000:
1338 return 7;
1339 case 176400:
1340 return 8;
1341 case 192000:
1342 return 9;
1343 default:
1344 return 3;
1345 }
1346 } else {
1347 return 0;
1348 }
1349}
1350
1351static int hdspm_set_clock_source(hdspm_t * hdspm, int mode)
1352{
1353 int rate;
1354 switch (mode) {
1355
1356 case HDSPM_CLOCK_SOURCE_AUTOSYNC:
1357 if (hdspm_external_sample_rate(hdspm) != 0) {
1358 hdspm->control_register &= ~HDSPM_ClockModeMaster;
1359 hdspm_write(hdspm, HDSPM_controlRegister,
1360 hdspm->control_register);
1361 return 0;
1362 }
1363 return -1;
1364 case HDSPM_CLOCK_SOURCE_INTERNAL_32KHZ:
1365 rate = 32000;
1366 break;
1367 case HDSPM_CLOCK_SOURCE_INTERNAL_44_1KHZ:
1368 rate = 44100;
1369 break;
1370 case HDSPM_CLOCK_SOURCE_INTERNAL_48KHZ:
1371 rate = 48000;
1372 break;
1373 case HDSPM_CLOCK_SOURCE_INTERNAL_64KHZ:
1374 rate = 64000;
1375 break;
1376 case HDSPM_CLOCK_SOURCE_INTERNAL_88_2KHZ:
1377 rate = 88200;
1378 break;
1379 case HDSPM_CLOCK_SOURCE_INTERNAL_96KHZ:
1380 rate = 96000;
1381 break;
1382 case HDSPM_CLOCK_SOURCE_INTERNAL_128KHZ:
1383 rate = 128000;
1384 break;
1385 case HDSPM_CLOCK_SOURCE_INTERNAL_176_4KHZ:
1386 rate = 176400;
1387 break;
1388 case HDSPM_CLOCK_SOURCE_INTERNAL_192KHZ:
1389 rate = 192000;
1390 break;
1391
1392 default:
1393 rate = 44100;
1394 }
1395 hdspm->control_register |= HDSPM_ClockModeMaster;
1396 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
1397 hdspm_set_rate(hdspm, rate, 1);
1398 return 0;
1399}
1400
1401static int snd_hdspm_info_clock_source(snd_kcontrol_t * kcontrol,
1402 snd_ctl_elem_info_t * uinfo)
1403{
1404 static char *texts[] = { "AutoSync",
1405 "Internal 32.0 kHz", "Internal 44.1 kHz",
1406 "Internal 48.0 kHz",
1407 "Internal 64.0 kHz", "Internal 88.2 kHz",
1408 "Internal 96.0 kHz",
1409 "Internal 128.0 kHz", "Internal 176.4 kHz",
1410 "Internal 192.0 kHz"
1411 };
1412
1413 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1414 uinfo->count = 1;
1415 uinfo->value.enumerated.items = 10;
1416
1417 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
1418 uinfo->value.enumerated.item =
1419 uinfo->value.enumerated.items - 1;
1420
1421 strcpy(uinfo->value.enumerated.name,
1422 texts[uinfo->value.enumerated.item]);
1423
1424 return 0;
1425}
1426
1427static int snd_hdspm_get_clock_source(snd_kcontrol_t * kcontrol,
1428 snd_ctl_elem_value_t * ucontrol)
1429{
1430 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1431
1432 ucontrol->value.enumerated.item[0] = hdspm_clock_source(hdspm);
1433 return 0;
1434}
1435
1436static int snd_hdspm_put_clock_source(snd_kcontrol_t * kcontrol,
1437 snd_ctl_elem_value_t * ucontrol)
1438{
1439 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1440 int change;
1441 int val;
1442
1443 if (!snd_hdspm_use_is_exclusive(hdspm))
1444 return -EBUSY;
1445 val = ucontrol->value.enumerated.item[0];
1446 if (val < 0)
1447 val = 0;
1448 if (val > 6)
1449 val = 6;
1450 spin_lock_irq(&hdspm->lock);
1451 if (val != hdspm_clock_source(hdspm))
1452 change = (hdspm_set_clock_source(hdspm, val) == 0) ? 1 : 0;
1453 else
1454 change = 0;
1455 spin_unlock_irq(&hdspm->lock);
1456 return change;
1457}
1458
1459#define HDSPM_PREF_SYNC_REF(xname, xindex) \
1460{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
1461 .name = xname, \
1462 .index = xindex, \
1463 .info = snd_hdspm_info_pref_sync_ref, \
1464 .get = snd_hdspm_get_pref_sync_ref, \
1465 .put = snd_hdspm_put_pref_sync_ref \
1466}
1467
1468static int hdspm_pref_sync_ref(hdspm_t * hdspm)
1469{
1470 /* Notice that this looks at the requested sync source,
1471 not the one actually in use.
1472 */
1473 switch (hdspm->control_register & HDSPM_SyncRefMask) {
1474 case HDSPM_SyncRef_Word:
1475 return HDSPM_SYNC_FROM_WORD;
1476 case HDSPM_SyncRef_MADI:
1477 return HDSPM_SYNC_FROM_MADI;
1478 }
1479
1480 return HDSPM_SYNC_FROM_WORD;
1481}
1482
1483static int hdspm_set_pref_sync_ref(hdspm_t * hdspm, int pref)
1484{
1485 hdspm->control_register &= ~HDSPM_SyncRefMask;
1486
1487 switch (pref) {
1488 case HDSPM_SYNC_FROM_MADI:
1489 hdspm->control_register |= HDSPM_SyncRef_MADI;
1490 break;
1491 case HDSPM_SYNC_FROM_WORD:
1492 hdspm->control_register |= HDSPM_SyncRef_Word;
1493 break;
1494 default:
1495 return -1;
1496 }
1497 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
1498 return 0;
1499}
1500
1501static int snd_hdspm_info_pref_sync_ref(snd_kcontrol_t * kcontrol,
1502 snd_ctl_elem_info_t * uinfo)
1503{
1504 static char *texts[] = { "Word", "MADI" };
1505
1506 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1507 uinfo->count = 1;
1508
1509 uinfo->value.enumerated.items = 2;
1510
1511 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
1512 uinfo->value.enumerated.item =
1513 uinfo->value.enumerated.items - 1;
1514 strcpy(uinfo->value.enumerated.name,
1515 texts[uinfo->value.enumerated.item]);
1516 return 0;
1517}
1518
1519static int snd_hdspm_get_pref_sync_ref(snd_kcontrol_t * kcontrol,
1520 snd_ctl_elem_value_t * ucontrol)
1521{
1522 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1523
1524 ucontrol->value.enumerated.item[0] = hdspm_pref_sync_ref(hdspm);
1525 return 0;
1526}
1527
1528static int snd_hdspm_put_pref_sync_ref(snd_kcontrol_t * kcontrol,
1529 snd_ctl_elem_value_t * ucontrol)
1530{
1531 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1532 int change, max;
1533 unsigned int val;
1534
1535 max = 2;
1536
1537 if (!snd_hdspm_use_is_exclusive(hdspm))
1538 return -EBUSY;
1539
1540 val = ucontrol->value.enumerated.item[0] % max;
1541
1542 spin_lock_irq(&hdspm->lock);
1543 change = (int) val != hdspm_pref_sync_ref(hdspm);
1544 hdspm_set_pref_sync_ref(hdspm, val);
1545 spin_unlock_irq(&hdspm->lock);
1546 return change;
1547}
1548
1549#define HDSPM_AUTOSYNC_REF(xname, xindex) \
1550{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
1551 .name = xname, \
1552 .index = xindex, \
1553 .access = SNDRV_CTL_ELEM_ACCESS_READ, \
1554 .info = snd_hdspm_info_autosync_ref, \
1555 .get = snd_hdspm_get_autosync_ref, \
1556}
1557
1558static int hdspm_autosync_ref(hdspm_t * hdspm)
1559{
1560 /* This looks at the autosync selected sync reference */
1561 unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
1562
1563 switch (status2 & HDSPM_SelSyncRefMask) {
1564
1565 case HDSPM_SelSyncRef_WORD:
1566 return HDSPM_AUTOSYNC_FROM_WORD;
1567
1568 case HDSPM_SelSyncRef_MADI:
1569 return HDSPM_AUTOSYNC_FROM_MADI;
1570
1571 case HDSPM_SelSyncRef_NVALID:
1572 return HDSPM_AUTOSYNC_FROM_NONE;
1573
1574 default:
1575 return 0;
1576 }
1577
1578 return 0;
1579}
1580
1581static int snd_hdspm_info_autosync_ref(snd_kcontrol_t * kcontrol,
1582 snd_ctl_elem_info_t * uinfo)
1583{
1584 static char *texts[] = { "WordClock", "MADI", "None" };
1585
1586 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1587 uinfo->count = 1;
1588 uinfo->value.enumerated.items = 3;
1589 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
1590 uinfo->value.enumerated.item =
1591 uinfo->value.enumerated.items - 1;
1592 strcpy(uinfo->value.enumerated.name,
1593 texts[uinfo->value.enumerated.item]);
1594 return 0;
1595}
1596
1597static int snd_hdspm_get_autosync_ref(snd_kcontrol_t * kcontrol,
1598 snd_ctl_elem_value_t * ucontrol)
1599{
1600 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1601
1602 ucontrol->value.enumerated.item[0] = hdspm_pref_sync_ref(hdspm);
1603 return 0;
1604}
1605
1606#define HDSPM_LINE_OUT(xname, xindex) \
1607{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
1608 .name = xname, \
1609 .index = xindex, \
1610 .info = snd_hdspm_info_line_out, \
1611 .get = snd_hdspm_get_line_out, \
1612 .put = snd_hdspm_put_line_out \
1613}
1614
1615static int hdspm_line_out(hdspm_t * hdspm)
1616{
1617 return (hdspm->control_register & HDSPM_LineOut) ? 1 : 0;
1618}
1619
1620
1621static int hdspm_set_line_output(hdspm_t * hdspm, int out)
1622{
1623 if (out)
1624 hdspm->control_register |= HDSPM_LineOut;
1625 else
1626 hdspm->control_register &= ~HDSPM_LineOut;
1627 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
1628
1629 return 0;
1630}
1631
1632static int snd_hdspm_info_line_out(snd_kcontrol_t * kcontrol,
1633 snd_ctl_elem_info_t * uinfo)
1634{
1635 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1636 uinfo->count = 1;
1637 uinfo->value.integer.min = 0;
1638 uinfo->value.integer.max = 1;
1639 return 0;
1640}
1641
1642static int snd_hdspm_get_line_out(snd_kcontrol_t * kcontrol,
1643 snd_ctl_elem_value_t * ucontrol)
1644{
1645 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1646
1647 spin_lock_irq(&hdspm->lock);
1648 ucontrol->value.integer.value[0] = hdspm_line_out(hdspm);
1649 spin_unlock_irq(&hdspm->lock);
1650 return 0;
1651}
1652
1653static int snd_hdspm_put_line_out(snd_kcontrol_t * kcontrol,
1654 snd_ctl_elem_value_t * ucontrol)
1655{
1656 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1657 int change;
1658 unsigned int val;
1659
1660 if (!snd_hdspm_use_is_exclusive(hdspm))
1661 return -EBUSY;
1662 val = ucontrol->value.integer.value[0] & 1;
1663 spin_lock_irq(&hdspm->lock);
1664 change = (int) val != hdspm_line_out(hdspm);
1665 hdspm_set_line_output(hdspm, val);
1666 spin_unlock_irq(&hdspm->lock);
1667 return change;
1668}
1669
1670#define HDSPM_TX_64(xname, xindex) \
1671{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
1672 .name = xname, \
1673 .index = xindex, \
1674 .info = snd_hdspm_info_tx_64, \
1675 .get = snd_hdspm_get_tx_64, \
1676 .put = snd_hdspm_put_tx_64 \
1677}
1678
1679static int hdspm_tx_64(hdspm_t * hdspm)
1680{
1681 return (hdspm->control_register & HDSPM_TX_64ch) ? 1 : 0;
1682}
1683
1684static int hdspm_set_tx_64(hdspm_t * hdspm, int out)
1685{
1686 if (out)
1687 hdspm->control_register |= HDSPM_TX_64ch;
1688 else
1689 hdspm->control_register &= ~HDSPM_TX_64ch;
1690 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
1691
1692 return 0;
1693}
1694
1695static int snd_hdspm_info_tx_64(snd_kcontrol_t * kcontrol,
1696 snd_ctl_elem_info_t * uinfo)
1697{
1698 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1699 uinfo->count = 1;
1700 uinfo->value.integer.min = 0;
1701 uinfo->value.integer.max = 1;
1702 return 0;
1703}
1704
1705static int snd_hdspm_get_tx_64(snd_kcontrol_t * kcontrol,
1706 snd_ctl_elem_value_t * ucontrol)
1707{
1708 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1709
1710 spin_lock_irq(&hdspm->lock);
1711 ucontrol->value.integer.value[0] = hdspm_tx_64(hdspm);
1712 spin_unlock_irq(&hdspm->lock);
1713 return 0;
1714}
1715
1716static int snd_hdspm_put_tx_64(snd_kcontrol_t * kcontrol,
1717 snd_ctl_elem_value_t * ucontrol)
1718{
1719 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1720 int change;
1721 unsigned int val;
1722
1723 if (!snd_hdspm_use_is_exclusive(hdspm))
1724 return -EBUSY;
1725 val = ucontrol->value.integer.value[0] & 1;
1726 spin_lock_irq(&hdspm->lock);
1727 change = (int) val != hdspm_tx_64(hdspm);
1728 hdspm_set_tx_64(hdspm, val);
1729 spin_unlock_irq(&hdspm->lock);
1730 return change;
1731}
1732
1733#define HDSPM_C_TMS(xname, xindex) \
1734{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
1735 .name = xname, \
1736 .index = xindex, \
1737 .info = snd_hdspm_info_c_tms, \
1738 .get = snd_hdspm_get_c_tms, \
1739 .put = snd_hdspm_put_c_tms \
1740}
1741
1742static int hdspm_c_tms(hdspm_t * hdspm)
1743{
1744 return (hdspm->control_register & HDSPM_clr_tms) ? 1 : 0;
1745}
1746
1747static int hdspm_set_c_tms(hdspm_t * hdspm, int out)
1748{
1749 if (out)
1750 hdspm->control_register |= HDSPM_clr_tms;
1751 else
1752 hdspm->control_register &= ~HDSPM_clr_tms;
1753 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
1754
1755 return 0;
1756}
1757
1758static int snd_hdspm_info_c_tms(snd_kcontrol_t * kcontrol,
1759 snd_ctl_elem_info_t * uinfo)
1760{
1761 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1762 uinfo->count = 1;
1763 uinfo->value.integer.min = 0;
1764 uinfo->value.integer.max = 1;
1765 return 0;
1766}
1767
1768static int snd_hdspm_get_c_tms(snd_kcontrol_t * kcontrol,
1769 snd_ctl_elem_value_t * ucontrol)
1770{
1771 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1772
1773 spin_lock_irq(&hdspm->lock);
1774 ucontrol->value.integer.value[0] = hdspm_c_tms(hdspm);
1775 spin_unlock_irq(&hdspm->lock);
1776 return 0;
1777}
1778
1779static int snd_hdspm_put_c_tms(snd_kcontrol_t * kcontrol,
1780 snd_ctl_elem_value_t * ucontrol)
1781{
1782 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1783 int change;
1784 unsigned int val;
1785
1786 if (!snd_hdspm_use_is_exclusive(hdspm))
1787 return -EBUSY;
1788 val = ucontrol->value.integer.value[0] & 1;
1789 spin_lock_irq(&hdspm->lock);
1790 change = (int) val != hdspm_c_tms(hdspm);
1791 hdspm_set_c_tms(hdspm, val);
1792 spin_unlock_irq(&hdspm->lock);
1793 return change;
1794}
1795
1796#define HDSPM_SAFE_MODE(xname, xindex) \
1797{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
1798 .name = xname, \
1799 .index = xindex, \
1800 .info = snd_hdspm_info_safe_mode, \
1801 .get = snd_hdspm_get_safe_mode, \
1802 .put = snd_hdspm_put_safe_mode \
1803}
1804
1805static int hdspm_safe_mode(hdspm_t * hdspm)
1806{
1807 return (hdspm->control_register & HDSPM_AutoInp) ? 1 : 0;
1808}
1809
1810static int hdspm_set_safe_mode(hdspm_t * hdspm, int out)
1811{
1812 if (out)
1813 hdspm->control_register |= HDSPM_AutoInp;
1814 else
1815 hdspm->control_register &= ~HDSPM_AutoInp;
1816 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
1817
1818 return 0;
1819}
1820
1821static int snd_hdspm_info_safe_mode(snd_kcontrol_t * kcontrol,
1822 snd_ctl_elem_info_t * uinfo)
1823{
1824 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1825 uinfo->count = 1;
1826 uinfo->value.integer.min = 0;
1827 uinfo->value.integer.max = 1;
1828 return 0;
1829}
1830
1831static int snd_hdspm_get_safe_mode(snd_kcontrol_t * kcontrol,
1832 snd_ctl_elem_value_t * ucontrol)
1833{
1834 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1835
1836 spin_lock_irq(&hdspm->lock);
1837 ucontrol->value.integer.value[0] = hdspm_safe_mode(hdspm);
1838 spin_unlock_irq(&hdspm->lock);
1839 return 0;
1840}
1841
1842static int snd_hdspm_put_safe_mode(snd_kcontrol_t * kcontrol,
1843 snd_ctl_elem_value_t * ucontrol)
1844{
1845 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1846 int change;
1847 unsigned int val;
1848
1849 if (!snd_hdspm_use_is_exclusive(hdspm))
1850 return -EBUSY;
1851 val = ucontrol->value.integer.value[0] & 1;
1852 spin_lock_irq(&hdspm->lock);
1853 change = (int) val != hdspm_safe_mode(hdspm);
1854 hdspm_set_safe_mode(hdspm, val);
1855 spin_unlock_irq(&hdspm->lock);
1856 return change;
1857}
1858
1859#define HDSPM_INPUT_SELECT(xname, xindex) \
1860{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
1861 .name = xname, \
1862 .index = xindex, \
1863 .info = snd_hdspm_info_input_select, \
1864 .get = snd_hdspm_get_input_select, \
1865 .put = snd_hdspm_put_input_select \
1866}
1867
1868static int hdspm_input_select(hdspm_t * hdspm)
1869{
1870 return (hdspm->control_register & HDSPM_InputSelect0) ? 1 : 0;
1871}
1872
1873static int hdspm_set_input_select(hdspm_t * hdspm, int out)
1874{
1875 if (out)
1876 hdspm->control_register |= HDSPM_InputSelect0;
1877 else
1878 hdspm->control_register &= ~HDSPM_InputSelect0;
1879 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
1880
1881 return 0;
1882}
1883
1884static int snd_hdspm_info_input_select(snd_kcontrol_t * kcontrol,
1885 snd_ctl_elem_info_t * uinfo)
1886{
1887 static char *texts[] = { "optical", "coaxial" };
1888
1889 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1890 uinfo->count = 1;
1891 uinfo->value.enumerated.items = 2;
1892
1893 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
1894 uinfo->value.enumerated.item =
1895 uinfo->value.enumerated.items - 1;
1896 strcpy(uinfo->value.enumerated.name,
1897 texts[uinfo->value.enumerated.item]);
1898
1899 return 0;
1900}
1901
1902static int snd_hdspm_get_input_select(snd_kcontrol_t * kcontrol,
1903 snd_ctl_elem_value_t * ucontrol)
1904{
1905 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1906
1907 spin_lock_irq(&hdspm->lock);
1908 ucontrol->value.enumerated.item[0] = hdspm_input_select(hdspm);
1909 spin_unlock_irq(&hdspm->lock);
1910 return 0;
1911}
1912
1913static int snd_hdspm_put_input_select(snd_kcontrol_t * kcontrol,
1914 snd_ctl_elem_value_t * ucontrol)
1915{
1916 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1917 int change;
1918 unsigned int val;
1919
1920 if (!snd_hdspm_use_is_exclusive(hdspm))
1921 return -EBUSY;
1922 val = ucontrol->value.integer.value[0] & 1;
1923 spin_lock_irq(&hdspm->lock);
1924 change = (int) val != hdspm_input_select(hdspm);
1925 hdspm_set_input_select(hdspm, val);
1926 spin_unlock_irq(&hdspm->lock);
1927 return change;
1928}
1929
1930/* Simple Mixer
1931 deprecated since to much faders ???
1932 MIXER interface says output (source, destination, value)
1933 where source > MAX_channels are playback channels
1934 on MADICARD
1935 - playback mixer matrix: [channelout+64] [output] [value]
1936 - input(thru) mixer matrix: [channelin] [output] [value]
1937 (better do 2 kontrols for seperation ?)
1938*/
1939
1940#define HDSPM_MIXER(xname, xindex) \
1941{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
1942 .name = xname, \
1943 .index = xindex, \
1944 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1945 SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
1946 .info = snd_hdspm_info_mixer, \
1947 .get = snd_hdspm_get_mixer, \
1948 .put = snd_hdspm_put_mixer \
1949}
1950
1951static int snd_hdspm_info_mixer(snd_kcontrol_t * kcontrol,
1952 snd_ctl_elem_info_t * uinfo)
1953{
1954 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1955 uinfo->count = 3;
1956 uinfo->value.integer.min = 0;
1957 uinfo->value.integer.max = 65535;
1958 uinfo->value.integer.step = 1;
1959 return 0;
1960}
1961
1962static int snd_hdspm_get_mixer(snd_kcontrol_t * kcontrol,
1963 snd_ctl_elem_value_t * ucontrol)
1964{
1965 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1966 int source;
1967 int destination;
1968
1969 source = ucontrol->value.integer.value[0];
1970 if (source < 0)
1971 source = 0;
1972 else if (source >= 2 * HDSPM_MAX_CHANNELS)
1973 source = 2 * HDSPM_MAX_CHANNELS - 1;
1974
1975 destination = ucontrol->value.integer.value[1];
1976 if (destination < 0)
1977 destination = 0;
1978 else if (destination >= HDSPM_MAX_CHANNELS)
1979 destination = HDSPM_MAX_CHANNELS - 1;
1980
1981 spin_lock_irq(&hdspm->lock);
1982 if (source >= HDSPM_MAX_CHANNELS)
1983 ucontrol->value.integer.value[2] =
1984 hdspm_read_pb_gain(hdspm, destination,
1985 source - HDSPM_MAX_CHANNELS);
1986 else
1987 ucontrol->value.integer.value[2] =
1988 hdspm_read_in_gain(hdspm, destination, source);
1989
1990 spin_unlock_irq(&hdspm->lock);
1991
1992 return 0;
1993}
1994
1995static int snd_hdspm_put_mixer(snd_kcontrol_t * kcontrol,
1996 snd_ctl_elem_value_t * ucontrol)
1997{
1998 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
1999 int change;
2000 int source;
2001 int destination;
2002 int gain;
2003
2004 if (!snd_hdspm_use_is_exclusive(hdspm))
2005 return -EBUSY;
2006
2007 source = ucontrol->value.integer.value[0];
2008 destination = ucontrol->value.integer.value[1];
2009
2010 if (source < 0 || source >= 2 * HDSPM_MAX_CHANNELS)
2011 return -1;
2012 if (destination < 0 || destination >= HDSPM_MAX_CHANNELS)
2013 return -1;
2014
2015 gain = ucontrol->value.integer.value[2];
2016
2017 spin_lock_irq(&hdspm->lock);
2018
2019 if (source >= HDSPM_MAX_CHANNELS)
2020 change = gain != hdspm_read_pb_gain(hdspm, destination,
2021 source -
2022 HDSPM_MAX_CHANNELS);
2023 else
2024 change =
2025 gain != hdspm_read_in_gain(hdspm, destination, source);
2026
2027 if (change) {
2028 if (source >= HDSPM_MAX_CHANNELS)
2029 hdspm_write_pb_gain(hdspm, destination,
2030 source - HDSPM_MAX_CHANNELS,
2031 gain);
2032 else
2033 hdspm_write_in_gain(hdspm, destination, source,
2034 gain);
2035 }
2036 spin_unlock_irq(&hdspm->lock);
2037
2038 return change;
2039}
2040
2041/* The simple mixer control(s) provide gain control for the
2042 basic 1:1 mappings of playback streams to output
2043 streams.
2044*/
2045
2046#define HDSPM_PLAYBACK_MIXER \
2047{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2048 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_WRITE | \
2049 SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
2050 .info = snd_hdspm_info_playback_mixer, \
2051 .get = snd_hdspm_get_playback_mixer, \
2052 .put = snd_hdspm_put_playback_mixer \
2053}
2054
2055static int snd_hdspm_info_playback_mixer(snd_kcontrol_t * kcontrol,
2056 snd_ctl_elem_info_t * uinfo)
2057{
2058 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
2059 uinfo->count = 1;
2060 uinfo->value.integer.min = 0;
2061 uinfo->value.integer.max = 65536;
2062 uinfo->value.integer.step = 1;
2063 return 0;
2064}
2065
2066static int snd_hdspm_get_playback_mixer(snd_kcontrol_t * kcontrol,
2067 snd_ctl_elem_value_t * ucontrol)
2068{
2069 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
2070 int channel;
2071 int mapped_channel;
2072
2073 channel = ucontrol->id.index - 1;
2074
2075 snd_assert(channel >= 0
2076 || channel < HDSPM_MAX_CHANNELS, return -EINVAL);
2077
2078 if ((mapped_channel = hdspm->channel_map[channel]) < 0)
2079 return -EINVAL;
2080
2081 spin_lock_irq(&hdspm->lock);
2082 ucontrol->value.integer.value[0] =
2083 hdspm_read_pb_gain(hdspm, mapped_channel, mapped_channel);
2084 spin_unlock_irq(&hdspm->lock);
2085
2086 /* snd_printdd("get pb mixer index %d, channel %d, mapped_channel %d, value %d\n",
2087 ucontrol->id.index, channel, mapped_channel, ucontrol->value.integer.value[0]);
2088 */
2089
2090 return 0;
2091}
2092
2093static int snd_hdspm_put_playback_mixer(snd_kcontrol_t * kcontrol,
2094 snd_ctl_elem_value_t * ucontrol)
2095{
2096 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
2097 int change;
2098 int channel;
2099 int mapped_channel;
2100 int gain;
2101
2102 if (!snd_hdspm_use_is_exclusive(hdspm))
2103 return -EBUSY;
2104
2105 channel = ucontrol->id.index - 1;
2106
2107 snd_assert(channel >= 0
2108 || channel < HDSPM_MAX_CHANNELS, return -EINVAL);
2109
2110 if ((mapped_channel = hdspm->channel_map[channel]) < 0)
2111 return -EINVAL;
2112
2113 gain = ucontrol->value.integer.value[0];
2114
2115 spin_lock_irq(&hdspm->lock);
2116 change =
2117 gain != hdspm_read_pb_gain(hdspm, mapped_channel,
2118 mapped_channel);
2119 if (change)
2120 hdspm_write_pb_gain(hdspm, mapped_channel, mapped_channel,
2121 gain);
2122 spin_unlock_irq(&hdspm->lock);
2123 return change;
2124}
2125
2126#define HDSPM_WC_SYNC_CHECK(xname, xindex) \
2127{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
2128 .name = xname, \
2129 .index = xindex, \
2130 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
2131 .info = snd_hdspm_info_sync_check, \
2132 .get = snd_hdspm_get_wc_sync_check \
2133}
2134
2135static int snd_hdspm_info_sync_check(snd_kcontrol_t * kcontrol,
2136 snd_ctl_elem_info_t * uinfo)
2137{
2138 static char *texts[] = { "No Lock", "Lock", "Sync" };
2139 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2140 uinfo->count = 1;
2141 uinfo->value.enumerated.items = 3;
2142 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
2143 uinfo->value.enumerated.item =
2144 uinfo->value.enumerated.items - 1;
2145 strcpy(uinfo->value.enumerated.name,
2146 texts[uinfo->value.enumerated.item]);
2147 return 0;
2148}
2149
2150static int hdspm_wc_sync_check(hdspm_t * hdspm)
2151{
2152 int status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
2153 if (status2 & HDSPM_wcLock) {
2154 if (status2 & HDSPM_wcSync)
2155 return 2;
2156 else
2157 return 1;
2158 }
2159 return 0;
2160}
2161
2162static int snd_hdspm_get_wc_sync_check(snd_kcontrol_t * kcontrol,
2163 snd_ctl_elem_value_t * ucontrol)
2164{
2165 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
2166
2167 ucontrol->value.enumerated.item[0] = hdspm_wc_sync_check(hdspm);
2168 return 0;
2169}
2170
2171
2172#define HDSPM_MADI_SYNC_CHECK(xname, xindex) \
2173{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
2174 .name = xname, \
2175 .index = xindex, \
2176 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
2177 .info = snd_hdspm_info_sync_check, \
2178 .get = snd_hdspm_get_madisync_sync_check \
2179}
2180
2181static int hdspm_madisync_sync_check(hdspm_t * hdspm)
2182{
2183 int status = hdspm_read(hdspm, HDSPM_statusRegister);
2184 if (status & HDSPM_madiLock) {
2185 if (status & HDSPM_madiSync)
2186 return 2;
2187 else
2188 return 1;
2189 }
2190 return 0;
2191}
2192
2193static int snd_hdspm_get_madisync_sync_check(snd_kcontrol_t * kcontrol,
2194 snd_ctl_elem_value_t *
2195 ucontrol)
2196{
2197 hdspm_t *hdspm = snd_kcontrol_chip(kcontrol);
2198
2199 ucontrol->value.enumerated.item[0] =
2200 hdspm_madisync_sync_check(hdspm);
2201 return 0;
2202}
2203
2204
2205
2206
2207static snd_kcontrol_new_t snd_hdspm_controls[] = {
2208
2209 HDSPM_MIXER("Mixer", 0),
2210/* 'Sample Clock Source' complies with the alsa control naming scheme */
2211 HDSPM_CLOCK_SOURCE("Sample Clock Source", 0),
2212
2213 HDSPM_SYSTEM_CLOCK_MODE("System Clock Mode", 0),
2214 HDSPM_PREF_SYNC_REF("Preferred Sync Reference", 0),
2215 HDSPM_AUTOSYNC_REF("AutoSync Reference", 0),
2216 HDSPM_SYSTEM_SAMPLE_RATE("System Sample Rate", 0),
2217/* 'External Rate' complies with the alsa control naming scheme */
2218 HDSPM_AUTOSYNC_SAMPLE_RATE("External Rate", 0),
2219 HDSPM_WC_SYNC_CHECK("Word Clock Lock Status", 0),
2220 HDSPM_MADI_SYNC_CHECK("MADI Sync Lock Status", 0),
2221 HDSPM_LINE_OUT("Line Out", 0),
2222 HDSPM_TX_64("TX 64 channels mode", 0),
2223 HDSPM_C_TMS("Clear Track Marker", 0),
2224 HDSPM_SAFE_MODE("Safe Mode", 0),
2225 HDSPM_INPUT_SELECT("Input Select", 0),
2226};
2227
2228static snd_kcontrol_new_t snd_hdspm_playback_mixer = HDSPM_PLAYBACK_MIXER;
2229
2230
2231static int hdspm_update_simple_mixer_controls(hdspm_t * hdspm)
2232{
2233 int i;
2234
2235 for (i = hdspm->ds_channels; i < hdspm->ss_channels; ++i) {
2236 if (hdspm->system_sample_rate > 48000) {
2237 hdspm->playback_mixer_ctls[i]->vd[0].access =
2238 SNDRV_CTL_ELEM_ACCESS_INACTIVE |
2239 SNDRV_CTL_ELEM_ACCESS_READ |
2240 SNDRV_CTL_ELEM_ACCESS_VOLATILE;
2241 } else {
2242 hdspm->playback_mixer_ctls[i]->vd[0].access =
2243 SNDRV_CTL_ELEM_ACCESS_READWRITE |
2244 SNDRV_CTL_ELEM_ACCESS_VOLATILE;
2245 }
2246 snd_ctl_notify(hdspm->card, SNDRV_CTL_EVENT_MASK_VALUE |
2247 SNDRV_CTL_EVENT_MASK_INFO,
2248 &hdspm->playback_mixer_ctls[i]->id);
2249 }
2250
2251 return 0;
2252}
2253
2254
2255static int snd_hdspm_create_controls(snd_card_t * card, hdspm_t * hdspm)
2256{
2257 unsigned int idx, limit;
2258 int err;
2259 snd_kcontrol_t *kctl;
2260
2261 /* add control list first */
2262
2263 for (idx = 0; idx < ARRAY_SIZE(snd_hdspm_controls); idx++) {
2264 if ((err =
2265 snd_ctl_add(card, kctl =
2266 snd_ctl_new1(&snd_hdspm_controls[idx],
2267 hdspm))) < 0) {
2268 return err;
2269 }
2270 }
2271
2272 /* Channel playback mixer as default control
2273 Note: the whole matrix would be 128*HDSPM_MIXER_CHANNELS Faders, thats to big for any alsamixer
2274 they are accesible via special IOCTL on hwdep
2275 and the mixer 2dimensional mixer control */
2276
2277 snd_hdspm_playback_mixer.name = "Chn";
2278 limit = HDSPM_MAX_CHANNELS;
2279
2280 /* The index values are one greater than the channel ID so that alsamixer
2281 will display them correctly. We want to use the index for fast lookup
2282 of the relevant channel, but if we use it at all, most ALSA software
2283 does the wrong thing with it ...
2284 */
2285
2286 for (idx = 0; idx < limit; ++idx) {
2287 snd_hdspm_playback_mixer.index = idx + 1;
2288 if ((err = snd_ctl_add(card,
2289 kctl =
2290 snd_ctl_new1
2291 (&snd_hdspm_playback_mixer,
2292 hdspm)))) {
2293 return err;
2294 }
2295 hdspm->playback_mixer_ctls[idx] = kctl;
2296 }
2297
2298 return 0;
2299}
2300
2301/*------------------------------------------------------------
2302 /proc interface
2303 ------------------------------------------------------------*/
2304
2305static void
2306snd_hdspm_proc_read(snd_info_entry_t * entry, snd_info_buffer_t * buffer)
2307{
2308 hdspm_t *hdspm = (hdspm_t *) entry->private_data;
2309 unsigned int status;
2310 unsigned int status2;
2311 char *pref_sync_ref;
2312 char *autosync_ref;
2313 char *system_clock_mode;
2314 char *clock_source;
2315 char *insel;
2316 char *syncref;
2317 int x, x2;
2318
2319 status = hdspm_read(hdspm, HDSPM_statusRegister);
2320 status2 = hdspm_read(hdspm, HDSPM_statusRegister2);
2321
2322 snd_iprintf(buffer, "%s (Card #%d) Rev.%x Status2first3bits: %x\n",
2323 hdspm->card_name, hdspm->card->number + 1,
2324 hdspm->firmware_rev,
2325 (status2 & HDSPM_version0) |
2326 (status2 & HDSPM_version1) | (status2 &
2327 HDSPM_version2));
2328
2329 snd_iprintf(buffer, "IRQ: %d Registers bus: 0x%lx VM: 0x%lx\n",
2330 hdspm->irq, hdspm->port, (unsigned long)hdspm->iobase);
2331
2332 snd_iprintf(buffer, "--- System ---\n");
2333
2334 snd_iprintf(buffer,
2335 "IRQ Pending: Audio=%d, MIDI0=%d, MIDI1=%d, IRQcount=%d\n",
2336 status & HDSPM_audioIRQPending,
2337 (status & HDSPM_midi0IRQPending) ? 1 : 0,
2338 (status & HDSPM_midi1IRQPending) ? 1 : 0,
2339 hdspm->irq_count);
2340 snd_iprintf(buffer,
2341 "HW pointer: id = %d, rawptr = %d (%d->%d) estimated= %ld (bytes)\n",
2342 ((status & HDSPM_BufferID) ? 1 : 0),
2343 (status & HDSPM_BufferPositionMask),
2344 (status & HDSPM_BufferPositionMask) % (2 *
2345 (int)hdspm->
2346 period_bytes),
2347 ((status & HDSPM_BufferPositionMask) -
2348 64) % (2 * (int)hdspm->period_bytes),
2349 (long) hdspm_hw_pointer(hdspm) * 4);
2350
2351 snd_iprintf(buffer,
2352 "MIDI FIFO: Out1=0x%x, Out2=0x%x, In1=0x%x, In2=0x%x \n",
2353 hdspm_read(hdspm, HDSPM_midiStatusOut0) & 0xFF,
2354 hdspm_read(hdspm, HDSPM_midiStatusOut1) & 0xFF,
2355 hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xFF,
2356 hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xFF);
2357 snd_iprintf(buffer,
2358 "Register: ctrl1=0x%x, ctrl2=0x%x, status1=0x%x, status2=0x%x\n",
2359 hdspm->control_register, hdspm->control2_register,
2360 status, status2);
2361
2362 snd_iprintf(buffer, "--- Settings ---\n");
2363
2364 x = 1 << (6 +
2365 hdspm_decode_latency(hdspm->
2366 control_register &
2367 HDSPM_LatencyMask));
2368
2369 snd_iprintf(buffer,
2370 "Size (Latency): %d samples (2 periods of %lu bytes)\n",
2371 x, (unsigned long) hdspm->period_bytes);
2372
2373 snd_iprintf(buffer, "Line out: %s, Precise Pointer: %s\n",
2374 (hdspm->
2375 control_register & HDSPM_LineOut) ? "on " : "off",
2376 (hdspm->precise_ptr) ? "on" : "off");
2377
2378 switch (hdspm->control_register & HDSPM_InputMask) {
2379 case HDSPM_InputOptical:
2380 insel = "Optical";
2381 break;
2382 case HDSPM_InputCoaxial:
2383 insel = "Coaxial";
2384 break;
2385 default:
2386 insel = "Unkown";
2387 }
2388
2389 switch (hdspm->control_register & HDSPM_SyncRefMask) {
2390 case HDSPM_SyncRef_Word:
2391 syncref = "WordClock";
2392 break;
2393 case HDSPM_SyncRef_MADI:
2394 syncref = "MADI";
2395 break;
2396 default:
2397 syncref = "Unkown";
2398 }
2399 snd_iprintf(buffer, "Inputsel = %s, SyncRef = %s\n", insel,
2400 syncref);
2401
2402 snd_iprintf(buffer,
2403 "ClearTrackMarker = %s, Transmit in %s Channel Mode, Auto Input %s\n",
2404 (hdspm->
2405 control_register & HDSPM_clr_tms) ? "on" : "off",
2406 (hdspm->
2407 control_register & HDSPM_TX_64ch) ? "64" : "56",
2408 (hdspm->
2409 control_register & HDSPM_AutoInp) ? "on" : "off");
2410
2411 switch (hdspm_clock_source(hdspm)) {
2412 case HDSPM_CLOCK_SOURCE_AUTOSYNC:
2413 clock_source = "AutoSync";
2414 break;
2415 case HDSPM_CLOCK_SOURCE_INTERNAL_32KHZ:
2416 clock_source = "Internal 32 kHz";
2417 break;
2418 case HDSPM_CLOCK_SOURCE_INTERNAL_44_1KHZ:
2419 clock_source = "Internal 44.1 kHz";
2420 break;
2421 case HDSPM_CLOCK_SOURCE_INTERNAL_48KHZ:
2422 clock_source = "Internal 48 kHz";
2423 break;
2424 case HDSPM_CLOCK_SOURCE_INTERNAL_64KHZ:
2425 clock_source = "Internal 64 kHz";
2426 break;
2427 case HDSPM_CLOCK_SOURCE_INTERNAL_88_2KHZ:
2428 clock_source = "Internal 88.2 kHz";
2429 break;
2430 case HDSPM_CLOCK_SOURCE_INTERNAL_96KHZ:
2431 clock_source = "Internal 96 kHz";
2432 break;
2433 default:
2434 clock_source = "Error";
2435 }
2436 snd_iprintf(buffer, "Sample Clock Source: %s\n", clock_source);
2437 if (!(hdspm->control_register & HDSPM_ClockModeMaster)) {
2438 system_clock_mode = "Slave";
2439 } else {
2440 system_clock_mode = "Master";
2441 }
2442 snd_iprintf(buffer, "System Clock Mode: %s\n", system_clock_mode);
2443
2444 switch (hdspm_pref_sync_ref(hdspm)) {
2445 case HDSPM_SYNC_FROM_WORD:
2446 pref_sync_ref = "Word Clock";
2447 break;
2448 case HDSPM_SYNC_FROM_MADI:
2449 pref_sync_ref = "MADI Sync";
2450 break;
2451 default:
2452 pref_sync_ref = "XXXX Clock";
2453 break;
2454 }
2455 snd_iprintf(buffer, "Preferred Sync Reference: %s\n",
2456 pref_sync_ref);
2457
2458 snd_iprintf(buffer, "System Clock Frequency: %d\n",
2459 hdspm->system_sample_rate);
2460
2461
2462 snd_iprintf(buffer, "--- Status:\n");
2463
2464 x = status & HDSPM_madiSync;
2465 x2 = status2 & HDSPM_wcSync;
2466
2467 snd_iprintf(buffer, "Inputs MADI=%s, WordClock=%s\n",
2468 (status & HDSPM_madiLock) ? (x ? "Sync" : "Lock") :
2469 "NoLock",
2470 (status2 & HDSPM_wcLock) ? (x2 ? "Sync" : "Lock") :
2471 "NoLock");
2472
2473 switch (hdspm_autosync_ref(hdspm)) {
2474 case HDSPM_AUTOSYNC_FROM_WORD:
2475 autosync_ref = "Word Clock";
2476 break;
2477 case HDSPM_AUTOSYNC_FROM_MADI:
2478 autosync_ref = "MADI Sync";
2479 break;
2480 case HDSPM_AUTOSYNC_FROM_NONE:
2481 autosync_ref = "Input not valid";
2482 break;
2483 default:
2484 autosync_ref = "---";
2485 break;
2486 }
2487 snd_iprintf(buffer,
2488 "AutoSync: Reference= %s, Freq=%d (MADI = %d, Word = %d)\n",
2489 autosync_ref, hdspm_external_sample_rate(hdspm),
2490 (status & HDSPM_madiFreqMask) >> 22,
2491 (status2 & HDSPM_wcFreqMask) >> 5);
2492
2493 snd_iprintf(buffer, "Input: %s, Mode=%s\n",
2494 (status & HDSPM_AB_int) ? "Coax" : "Optical",
2495 (status & HDSPM_RX_64ch) ? "64 channels" :
2496 "56 channels");
2497
2498 snd_iprintf(buffer, "\n");
2499}
2500
2501static void __devinit snd_hdspm_proc_init(hdspm_t * hdspm)
2502{
2503 snd_info_entry_t *entry;
2504
2505 if (!snd_card_proc_new(hdspm->card, "hdspm", &entry))
2506 snd_info_set_text_ops(entry, hdspm, 1024,
2507 snd_hdspm_proc_read);
2508}
2509
2510/*------------------------------------------------------------
2511 hdspm intitialize
2512 ------------------------------------------------------------*/
2513
2514static int snd_hdspm_set_defaults(hdspm_t * hdspm)
2515{
2516 unsigned int i;
2517
2518 /* ASSUMPTION: hdspm->lock is either held, or there is no need to
2519 hold it (e.g. during module initalization).
2520 */
2521
2522 /* set defaults: */
2523
2524 hdspm->control_register = HDSPM_ClockModeMaster | /* Master Cloack Mode on */
2525 hdspm_encode_latency(7) | /* latency maximum = 8192 samples */
2526 HDSPM_InputCoaxial | /* Input Coax not Optical */
2527 HDSPM_SyncRef_MADI | /* Madi is syncclock */
2528 HDSPM_LineOut | /* Analog output in */
2529 HDSPM_TX_64ch | /* transmit in 64ch mode */
2530 HDSPM_AutoInp; /* AutoInput chossing (takeover) */
2531
2532 /* ! HDSPM_Frequency0|HDSPM_Frequency1 = 44.1khz */
2533 /* ! HDSPM_DoubleSpeed HDSPM_QuadSpeed = normal speed */
2534 /* ! HDSPM_clr_tms = do not clear bits in track marks */
2535
2536 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register);
2537
2538#ifdef SNDRV_BIG_ENDIAN
2539 hdspm->control2_register = HDSPM_BIGENDIAN_MODE;
2540#else
2541 hdspm->control2_register = 0;
2542#endif
2543
2544 hdspm_write(hdspm, HDSPM_control2Reg, hdspm->control2_register);
2545 hdspm_compute_period_size(hdspm);
2546
2547 /* silence everything */
2548
2549 all_in_all_mixer(hdspm, 0 * UNITY_GAIN);
2550
2551 if (line_outs_monitor[hdspm->dev]) {
2552
2553 snd_printk(KERN_INFO "HDSPM: sending all playback streams to line outs.\n");
2554
2555 for (i = 0; i < HDSPM_MIXER_CHANNELS; i++) {
2556 if (hdspm_write_pb_gain(hdspm, i, i, UNITY_GAIN))
2557 return -EIO;
2558 }
2559 }
2560
2561 /* set a default rate so that the channel map is set up. */
2562 hdspm->channel_map = channel_map_madi_ss;
2563 hdspm_set_rate(hdspm, 44100, 1);
2564
2565 return 0;
2566}
2567
2568
2569/*------------------------------------------------------------
2570 interupt
2571 ------------------------------------------------------------*/
2572
2573static irqreturn_t snd_hdspm_interrupt(int irq, void *dev_id,
2574 struct pt_regs *regs)
2575{
2576 hdspm_t *hdspm = (hdspm_t *) dev_id;
2577 unsigned int status;
2578 int audio;
2579 int midi0;
2580 int midi1;
2581 unsigned int midi0status;
2582 unsigned int midi1status;
2583 int schedule = 0;
2584
2585 status = hdspm_read(hdspm, HDSPM_statusRegister);
2586
2587 audio = status & HDSPM_audioIRQPending;
2588 midi0 = status & HDSPM_midi0IRQPending;
2589 midi1 = status & HDSPM_midi1IRQPending;
2590
2591 if (!audio && !midi0 && !midi1)
2592 return IRQ_NONE;
2593
2594 hdspm_write(hdspm, HDSPM_interruptConfirmation, 0);
2595 hdspm->irq_count++;
2596
2597 midi0status = hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xff;
2598 midi1status = hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xff;
2599
2600 if (audio) {
2601
2602 if (hdspm->capture_substream)
2603 snd_pcm_period_elapsed(hdspm->pcm->
2604 streams
2605 [SNDRV_PCM_STREAM_CAPTURE].
2606 substream);
2607
2608 if (hdspm->playback_substream)
2609 snd_pcm_period_elapsed(hdspm->pcm->
2610 streams
2611 [SNDRV_PCM_STREAM_PLAYBACK].
2612 substream);
2613 }
2614
2615 if (midi0 && midi0status) {
2616 /* we disable interrupts for this input until processing is done */
2617 hdspm->control_register &= ~HDSPM_Midi0InterruptEnable;
2618 hdspm_write(hdspm, HDSPM_controlRegister,
2619 hdspm->control_register);
2620 hdspm->midi[0].pending = 1;
2621 schedule = 1;
2622 }
2623 if (midi1 && midi1status) {
2624 /* we disable interrupts for this input until processing is done */
2625 hdspm->control_register &= ~HDSPM_Midi1InterruptEnable;
2626 hdspm_write(hdspm, HDSPM_controlRegister,
2627 hdspm->control_register);
2628 hdspm->midi[1].pending = 1;
2629 schedule = 1;
2630 }
2631 if (schedule)
2632 tasklet_hi_schedule(&hdspm->midi_tasklet);
2633 return IRQ_HANDLED;
2634}
2635
2636/*------------------------------------------------------------
2637 pcm interface
2638 ------------------------------------------------------------*/
2639
2640
2641static snd_pcm_uframes_t snd_hdspm_hw_pointer(snd_pcm_substream_t *
2642 substream)
2643{
2644 hdspm_t *hdspm = snd_pcm_substream_chip(substream);
2645 return hdspm_hw_pointer(hdspm);
2646}
2647
2648static char *hdspm_channel_buffer_location(hdspm_t * hdspm,
2649 int stream, int channel)
2650{
2651 int mapped_channel;
2652
2653 snd_assert(channel >= 0
2654 || channel < HDSPM_MAX_CHANNELS, return NULL);
2655
2656 if ((mapped_channel = hdspm->channel_map[channel]) < 0)
2657 return NULL;
2658
2659 if (stream == SNDRV_PCM_STREAM_CAPTURE) {
2660 return hdspm->capture_buffer +
2661 mapped_channel * HDSPM_CHANNEL_BUFFER_BYTES;
2662 } else {
2663 return hdspm->playback_buffer +
2664 mapped_channel * HDSPM_CHANNEL_BUFFER_BYTES;
2665 }
2666}
2667
2668
2669/* dont know why need it ??? */
2670static int snd_hdspm_playback_copy(snd_pcm_substream_t * substream,
2671 int channel, snd_pcm_uframes_t pos,
2672 void __user *src, snd_pcm_uframes_t count)
2673{
2674 hdspm_t *hdspm = snd_pcm_substream_chip(substream);
2675 char *channel_buf;
2676
2677 snd_assert(pos + count <= HDSPM_CHANNEL_BUFFER_BYTES / 4,
2678 return -EINVAL);
2679
2680 channel_buf = hdspm_channel_buffer_location(hdspm,
2681 substream->pstr->
2682 stream, channel);
2683
2684 snd_assert(channel_buf != NULL, return -EIO);
2685
2686 return copy_from_user(channel_buf + pos * 4, src, count * 4);
2687}
2688
2689static int snd_hdspm_capture_copy(snd_pcm_substream_t * substream,
2690 int channel, snd_pcm_uframes_t pos,
2691 void __user *dst, snd_pcm_uframes_t count)
2692{
2693 hdspm_t *hdspm = snd_pcm_substream_chip(substream);
2694 char *channel_buf;
2695
2696 snd_assert(pos + count <= HDSPM_CHANNEL_BUFFER_BYTES / 4,
2697 return -EINVAL);
2698
2699 channel_buf = hdspm_channel_buffer_location(hdspm,
2700 substream->pstr->
2701 stream, channel);
2702 snd_assert(channel_buf != NULL, return -EIO);
2703 return copy_to_user(dst, channel_buf + pos * 4, count * 4);
2704}
2705
2706static int snd_hdspm_hw_silence(snd_pcm_substream_t * substream,
2707 int channel, snd_pcm_uframes_t pos,
2708 snd_pcm_uframes_t count)
2709{
2710 hdspm_t *hdspm = snd_pcm_substream_chip(substream);
2711 char *channel_buf;
2712
2713 channel_buf =
2714 hdspm_channel_buffer_location(hdspm, substream->pstr->stream,
2715 channel);
2716 snd_assert(channel_buf != NULL, return -EIO);
2717 memset(channel_buf + pos * 4, 0, count * 4);
2718 return 0;
2719}
2720
2721static int snd_hdspm_reset(snd_pcm_substream_t * substream)
2722{
2723 snd_pcm_runtime_t *runtime = substream->runtime;
2724 hdspm_t *hdspm = snd_pcm_substream_chip(substream);
2725 snd_pcm_substream_t *other;
2726
2727 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
2728 other = hdspm->capture_substream;
2729 else
2730 other = hdspm->playback_substream;
2731
2732 if (hdspm->running)
2733 runtime->status->hw_ptr = hdspm_hw_pointer(hdspm);
2734 else
2735 runtime->status->hw_ptr = 0;
2736 if (other) {
2737 struct list_head *pos;
2738 snd_pcm_substream_t *s;
2739 snd_pcm_runtime_t *oruntime = other->runtime;
2740 snd_pcm_group_for_each(pos, substream) {
2741 s = snd_pcm_group_substream_entry(pos);
2742 if (s == other) {
2743 oruntime->status->hw_ptr =
2744 runtime->status->hw_ptr;
2745 break;
2746 }
2747 }
2748 }
2749 return 0;
2750}
2751
2752static int snd_hdspm_hw_params(snd_pcm_substream_t * substream,
2753 snd_pcm_hw_params_t * params)
2754{
2755 hdspm_t *hdspm = snd_pcm_substream_chip(substream);
2756 int err;
2757 int i;
2758 pid_t this_pid;
2759 pid_t other_pid;
2760 struct snd_sg_buf *sgbuf;
2761
2762
2763 spin_lock_irq(&hdspm->lock);
2764
2765 if (substream->pstr->stream == SNDRV_PCM_STREAM_PLAYBACK) {
2766 this_pid = hdspm->playback_pid;
2767 other_pid = hdspm->capture_pid;
2768 } else {
2769 this_pid = hdspm->capture_pid;
2770 other_pid = hdspm->playback_pid;
2771 }
2772
2773 if ((other_pid > 0) && (this_pid != other_pid)) {
2774
2775 /* The other stream is open, and not by the same
2776 task as this one. Make sure that the parameters
2777 that matter are the same.
2778 */
2779
2780 if (params_rate(params) != hdspm->system_sample_rate) {
2781 spin_unlock_irq(&hdspm->lock);
2782 _snd_pcm_hw_param_setempty(params,
2783 SNDRV_PCM_HW_PARAM_RATE);
2784 return -EBUSY;
2785 }
2786
2787 if (params_period_size(params) != hdspm->period_bytes / 4) {
2788 spin_unlock_irq(&hdspm->lock);
2789 _snd_pcm_hw_param_setempty(params,
2790 SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
2791 return -EBUSY;
2792 }
2793
2794 }
2795 /* We're fine. */
2796 spin_unlock_irq(&hdspm->lock);
2797
2798 /* how to make sure that the rate matches an externally-set one ? */
2799
2800 spin_lock_irq(&hdspm->lock);
2801 if ((err = hdspm_set_rate(hdspm, params_rate(params), 0)) < 0) {
2802 spin_unlock_irq(&hdspm->lock);
2803 _snd_pcm_hw_param_setempty(params,
2804 SNDRV_PCM_HW_PARAM_RATE);
2805 return err;
2806 }
2807 spin_unlock_irq(&hdspm->lock);
2808
2809 if ((err =
2810 hdspm_set_interrupt_interval(hdspm,
2811 params_period_size(params))) <
2812 0) {
2813 _snd_pcm_hw_param_setempty(params,
2814 SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
2815 return err;
2816 }
2817
2818 /* Memory allocation, takashi's method, dont know if we should spinlock */
2819 /* malloc all buffer even if not enabled to get sure */
2820 /* malloc only needed bytes */
2821 err =
2822 snd_pcm_lib_malloc_pages(substream,
2823 HDSPM_CHANNEL_BUFFER_BYTES *
2824 params_channels(params));
2825 if (err < 0)
2826 return err;
2827
2828 sgbuf = snd_pcm_substream_sgbuf(substream);
2829
2830 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
2831
2832 hdspm_set_sgbuf(hdspm, sgbuf, HDSPM_pageAddressBufferOut,
2833 params_channels(params));
2834
2835 for (i = 0; i < params_channels(params); ++i)
2836 snd_hdspm_enable_out(hdspm, i, 1);
2837
2838 hdspm->playback_buffer =
2839 (unsigned char *) substream->runtime->dma_area;
2840 } else {
2841 hdspm_set_sgbuf(hdspm, sgbuf, HDSPM_pageAddressBufferIn,
2842 params_channels(params));
2843
2844 for (i = 0; i < params_channels(params); ++i)
2845 snd_hdspm_enable_in(hdspm, i, 1);
2846
2847 hdspm->capture_buffer =
2848 (unsigned char *) substream->runtime->dma_area;
2849 }
2850 return 0;
2851}
2852
2853static int snd_hdspm_hw_free(snd_pcm_substream_t * substream)
2854{
2855 int i;
2856 hdspm_t *hdspm = snd_pcm_substream_chip(substream);
2857
2858 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
2859
2860 /* params_channels(params) should be enough,
2861 but to get sure in case of error */
2862 for (i = 0; i < HDSPM_MAX_CHANNELS; ++i)
2863 snd_hdspm_enable_out(hdspm, i, 0);
2864
2865 hdspm->playback_buffer = NULL;
2866 } else {
2867 for (i = 0; i < HDSPM_MAX_CHANNELS; ++i)
2868 snd_hdspm_enable_in(hdspm, i, 0);
2869
2870 hdspm->capture_buffer = NULL;
2871
2872 }
2873
2874 snd_pcm_lib_free_pages(substream);
2875
2876 return 0;
2877}
2878
2879static int snd_hdspm_channel_info(snd_pcm_substream_t * substream,
2880 snd_pcm_channel_info_t * info)
2881{
2882 hdspm_t *hdspm = snd_pcm_substream_chip(substream);
2883 int mapped_channel;
2884
2885 snd_assert(info->channel < HDSPM_MAX_CHANNELS, return -EINVAL);
2886
2887 if ((mapped_channel = hdspm->channel_map[info->channel]) < 0)
2888 return -EINVAL;
2889
2890 info->offset = mapped_channel * HDSPM_CHANNEL_BUFFER_BYTES;
2891 info->first = 0;
2892 info->step = 32;
2893 return 0;
2894}
2895
2896static int snd_hdspm_ioctl(snd_pcm_substream_t * substream,
2897 unsigned int cmd, void *arg)
2898{
2899 switch (cmd) {
2900 case SNDRV_PCM_IOCTL1_RESET:
2901 {
2902 return snd_hdspm_reset(substream);
2903 }
2904
2905 case SNDRV_PCM_IOCTL1_CHANNEL_INFO:
2906 {
2907 snd_pcm_channel_info_t *info = arg;
2908 return snd_hdspm_channel_info(substream, info);
2909 }
2910 default:
2911 break;
2912 }
2913
2914 return snd_pcm_lib_ioctl(substream, cmd, arg);
2915}
2916
2917static int snd_hdspm_trigger(snd_pcm_substream_t * substream, int cmd)
2918{
2919 hdspm_t *hdspm = snd_pcm_substream_chip(substream);
2920 snd_pcm_substream_t *other;
2921 int running;
2922
2923 spin_lock(&hdspm->lock);
2924 running = hdspm->running;
2925 switch (cmd) {
2926 case SNDRV_PCM_TRIGGER_START:
2927 running |= 1 << substream->stream;
2928 break;
2929 case SNDRV_PCM_TRIGGER_STOP:
2930 running &= ~(1 << substream->stream);
2931 break;
2932 default:
2933 snd_BUG();
2934 spin_unlock(&hdspm->lock);
2935 return -EINVAL;
2936 }
2937 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
2938 other = hdspm->capture_substream;
2939 else
2940 other = hdspm->playback_substream;
2941
2942 if (other) {
2943 struct list_head *pos;
2944 snd_pcm_substream_t *s;
2945 snd_pcm_group_for_each(pos, substream) {
2946 s = snd_pcm_group_substream_entry(pos);
2947 if (s == other) {
2948 snd_pcm_trigger_done(s, substream);
2949 if (cmd == SNDRV_PCM_TRIGGER_START)
2950 running |= 1 << s->stream;
2951 else
2952 running &= ~(1 << s->stream);
2953 goto _ok;
2954 }
2955 }
2956 if (cmd == SNDRV_PCM_TRIGGER_START) {
2957 if (!(running & (1 << SNDRV_PCM_STREAM_PLAYBACK))
2958 && substream->stream ==
2959 SNDRV_PCM_STREAM_CAPTURE)
2960 hdspm_silence_playback(hdspm);
2961 } else {
2962 if (running &&
2963 substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
2964 hdspm_silence_playback(hdspm);
2965 }
2966 } else {
2967 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
2968 hdspm_silence_playback(hdspm);
2969 }
2970 _ok:
2971 snd_pcm_trigger_done(substream, substream);
2972 if (!hdspm->running && running)
2973 hdspm_start_audio(hdspm);
2974 else if (hdspm->running && !running)
2975 hdspm_stop_audio(hdspm);
2976 hdspm->running = running;
2977 spin_unlock(&hdspm->lock);
2978
2979 return 0;
2980}
2981
2982static int snd_hdspm_prepare(snd_pcm_substream_t * substream)
2983{
2984 return 0;
2985}
2986
2987static unsigned int period_sizes[] =
2988 { 64, 128, 256, 512, 1024, 2048, 4096, 8192 };
2989
2990static snd_pcm_hardware_t snd_hdspm_playback_subinfo = {
2991 .info = (SNDRV_PCM_INFO_MMAP |
2992 SNDRV_PCM_INFO_MMAP_VALID |
2993 SNDRV_PCM_INFO_NONINTERLEAVED |
2994 SNDRV_PCM_INFO_SYNC_START | SNDRV_PCM_INFO_DOUBLE),
2995 .formats = SNDRV_PCM_FMTBIT_S32_LE,
2996 .rates = (SNDRV_PCM_RATE_32000 |
2997 SNDRV_PCM_RATE_44100 |
2998 SNDRV_PCM_RATE_48000 |
2999 SNDRV_PCM_RATE_64000 |
3000 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000),
3001 .rate_min = 32000,
3002 .rate_max = 96000,
3003 .channels_min = 1,
3004 .channels_max = HDSPM_MAX_CHANNELS,
3005 .buffer_bytes_max =
3006 HDSPM_CHANNEL_BUFFER_BYTES * HDSPM_MAX_CHANNELS,
3007 .period_bytes_min = (64 * 4),
3008 .period_bytes_max = (8192 * 4) * HDSPM_MAX_CHANNELS,
3009 .periods_min = 2,
3010 .periods_max = 2,
3011 .fifo_size = 0
3012};
3013
3014static snd_pcm_hardware_t snd_hdspm_capture_subinfo = {
3015 .info = (SNDRV_PCM_INFO_MMAP |
3016 SNDRV_PCM_INFO_MMAP_VALID |
3017 SNDRV_PCM_INFO_NONINTERLEAVED |
3018 SNDRV_PCM_INFO_SYNC_START),
3019 .formats = SNDRV_PCM_FMTBIT_S32_LE,
3020 .rates = (SNDRV_PCM_RATE_32000 |
3021 SNDRV_PCM_RATE_44100 |
3022 SNDRV_PCM_RATE_48000 |
3023 SNDRV_PCM_RATE_64000 |
3024 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000),
3025 .rate_min = 32000,
3026 .rate_max = 96000,
3027 .channels_min = 1,
3028 .channels_max = HDSPM_MAX_CHANNELS,
3029 .buffer_bytes_max =
3030 HDSPM_CHANNEL_BUFFER_BYTES * HDSPM_MAX_CHANNELS,
3031 .period_bytes_min = (64 * 4),
3032 .period_bytes_max = (8192 * 4) * HDSPM_MAX_CHANNELS,
3033 .periods_min = 2,
3034 .periods_max = 2,
3035 .fifo_size = 0
3036};
3037
3038static snd_pcm_hw_constraint_list_t hw_constraints_period_sizes = {
3039 .count = ARRAY_SIZE(period_sizes),
3040 .list = period_sizes,
3041 .mask = 0
3042};
3043
3044
3045static int snd_hdspm_hw_rule_channels_rate(snd_pcm_hw_params_t * params,
3046 snd_pcm_hw_rule_t * rule)
3047{
3048 hdspm_t *hdspm = rule->private;
3049 snd_interval_t *c =
3050 hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
3051 snd_interval_t *r =
3052 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
3053
3054 if (r->min > 48000) {
3055 snd_interval_t t = {
3056 .min = 1,
3057 .max = hdspm->ds_channels,
3058 .integer = 1,
3059 };
3060 return snd_interval_refine(c, &t);
3061 } else if (r->max < 64000) {
3062 snd_interval_t t = {
3063 .min = 1,
3064 .max = hdspm->ss_channels,
3065 .integer = 1,
3066 };
3067 return snd_interval_refine(c, &t);
3068 }
3069 return 0;
3070}
3071
3072static int snd_hdspm_hw_rule_rate_channels(snd_pcm_hw_params_t * params,
3073 snd_pcm_hw_rule_t * rule)
3074{
3075 hdspm_t *hdspm = rule->private;
3076 snd_interval_t *c =
3077 hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
3078 snd_interval_t *r =
3079 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
3080
3081 if (c->min <= hdspm->ss_channels) {
3082 snd_interval_t t = {
3083 .min = 32000,
3084 .max = 48000,
3085 .integer = 1,
3086 };
3087 return snd_interval_refine(r, &t);
3088 } else if (c->max > hdspm->ss_channels) {
3089 snd_interval_t t = {
3090 .min = 64000,
3091 .max = 96000,
3092 .integer = 1,
3093 };
3094
3095 return snd_interval_refine(r, &t);
3096 }
3097 return 0;
3098}
3099
3100static int snd_hdspm_playback_open(snd_pcm_substream_t * substream)
3101{
3102 hdspm_t *hdspm = snd_pcm_substream_chip(substream);
3103 snd_pcm_runtime_t *runtime = substream->runtime;
3104
3105 snd_printdd("Open device substream %d\n", substream->stream);
3106
3107 spin_lock_irq(&hdspm->lock);
3108
3109 snd_pcm_set_sync(substream);
3110
3111 runtime->hw = snd_hdspm_playback_subinfo;
3112
3113 if (hdspm->capture_substream == NULL)
3114 hdspm_stop_audio(hdspm);
3115
3116 hdspm->playback_pid = current->pid;
3117 hdspm->playback_substream = substream;
3118
3119 spin_unlock_irq(&hdspm->lock);
3120
3121 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
3122
3123 snd_pcm_hw_constraint_list(runtime, 0,
3124 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
3125 &hw_constraints_period_sizes);
3126
3127 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
3128 snd_hdspm_hw_rule_channels_rate, hdspm,
3129 SNDRV_PCM_HW_PARAM_RATE, -1);
3130
3131 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
3132 snd_hdspm_hw_rule_rate_channels, hdspm,
3133 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
3134
3135 return 0;
3136}
3137
3138static int snd_hdspm_playback_release(snd_pcm_substream_t * substream)
3139{
3140 hdspm_t *hdspm = snd_pcm_substream_chip(substream);
3141
3142 spin_lock_irq(&hdspm->lock);
3143
3144 hdspm->playback_pid = -1;
3145 hdspm->playback_substream = NULL;
3146
3147 spin_unlock_irq(&hdspm->lock);
3148
3149 return 0;
3150}
3151
3152
3153static int snd_hdspm_capture_open(snd_pcm_substream_t * substream)
3154{
3155 hdspm_t *hdspm = snd_pcm_substream_chip(substream);
3156 snd_pcm_runtime_t *runtime = substream->runtime;
3157
3158 spin_lock_irq(&hdspm->lock);
3159 snd_pcm_set_sync(substream);
3160 runtime->hw = snd_hdspm_capture_subinfo;
3161
3162 if (hdspm->playback_substream == NULL)
3163 hdspm_stop_audio(hdspm);
3164
3165 hdspm->capture_pid = current->pid;
3166 hdspm->capture_substream = substream;
3167
3168 spin_unlock_irq(&hdspm->lock);
3169
3170 snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
3171 snd_pcm_hw_constraint_list(runtime, 0,
3172 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
3173 &hw_constraints_period_sizes);
3174
3175 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
3176 snd_hdspm_hw_rule_channels_rate, hdspm,
3177 SNDRV_PCM_HW_PARAM_RATE, -1);
3178
3179 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
3180 snd_hdspm_hw_rule_rate_channels, hdspm,
3181 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
3182 return 0;
3183}
3184
3185static int snd_hdspm_capture_release(snd_pcm_substream_t * substream)
3186{
3187 hdspm_t *hdspm = snd_pcm_substream_chip(substream);
3188
3189 spin_lock_irq(&hdspm->lock);
3190
3191 hdspm->capture_pid = -1;
3192 hdspm->capture_substream = NULL;
3193
3194 spin_unlock_irq(&hdspm->lock);
3195 return 0;
3196}
3197
3198static int snd_hdspm_hwdep_dummy_op(snd_hwdep_t * hw, struct file *file)
3199{
3200 /* we have nothing to initialize but the call is required */
3201 return 0;
3202}
3203
3204
3205static int snd_hdspm_hwdep_ioctl(snd_hwdep_t * hw, struct file *file,
3206 unsigned int cmd, unsigned long arg)
3207{
3208 hdspm_t *hdspm = (hdspm_t *) hw->private_data;
3209 struct sndrv_hdspm_mixer_ioctl mixer;
3210 hdspm_config_info_t info;
3211 hdspm_version_t hdspm_version;
3212 struct sndrv_hdspm_peak_rms_ioctl rms;
3213
3214 switch (cmd) {
3215
3216
3217 case SNDRV_HDSPM_IOCTL_GET_PEAK_RMS:
3218 if (copy_from_user(&rms, (void __user *)arg, sizeof(rms)))
3219 return -EFAULT;
3220 /* maybe there is a chance to memorymap in future so dont touch just copy */
3221 if(copy_to_user_fromio((void __user *)rms.peak,
3222 hdspm->iobase+HDSPM_MADI_peakrmsbase,
3223 sizeof(hdspm_peak_rms_t)) != 0 )
3224 return -EFAULT;
3225
3226 break;
3227
3228
3229 case SNDRV_HDSPM_IOCTL_GET_CONFIG_INFO:
3230
3231 spin_lock_irq(&hdspm->lock);
3232 info.pref_sync_ref =
3233 (unsigned char) hdspm_pref_sync_ref(hdspm);
3234 info.wordclock_sync_check =
3235 (unsigned char) hdspm_wc_sync_check(hdspm);
3236
3237 info.system_sample_rate = hdspm->system_sample_rate;
3238 info.autosync_sample_rate =
3239 hdspm_external_sample_rate(hdspm);
3240 info.system_clock_mode =
3241 (unsigned char) hdspm_system_clock_mode(hdspm);
3242 info.clock_source =
3243 (unsigned char) hdspm_clock_source(hdspm);
3244 info.autosync_ref =
3245 (unsigned char) hdspm_autosync_ref(hdspm);
3246 info.line_out = (unsigned char) hdspm_line_out(hdspm);
3247 info.passthru = 0;
3248 spin_unlock_irq(&hdspm->lock);
3249 if (copy_to_user((void __user *) arg, &info, sizeof(info)))
3250 return -EFAULT;
3251 break;
3252
3253 case SNDRV_HDSPM_IOCTL_GET_VERSION:
3254 hdspm_version.firmware_rev = hdspm->firmware_rev;
3255 if (copy_to_user((void __user *) arg, &hdspm_version,
3256 sizeof(hdspm_version)))
3257 return -EFAULT;
3258 break;
3259
3260 case SNDRV_HDSPM_IOCTL_GET_MIXER:
3261 if (copy_from_user(&mixer, (void __user *)arg, sizeof(mixer)))
3262 return -EFAULT;
3263 if (copy_to_user
3264 ((void __user *)mixer.mixer, hdspm->mixer, sizeof(hdspm_mixer_t)))
3265 return -EFAULT;
3266 break;
3267
3268 default:
3269 return -EINVAL;
3270 }
3271 return 0;
3272}
3273
3274static snd_pcm_ops_t snd_hdspm_playback_ops = {
3275 .open = snd_hdspm_playback_open,
3276 .close = snd_hdspm_playback_release,
3277 .ioctl = snd_hdspm_ioctl,
3278 .hw_params = snd_hdspm_hw_params,
3279 .hw_free = snd_hdspm_hw_free,
3280 .prepare = snd_hdspm_prepare,
3281 .trigger = snd_hdspm_trigger,
3282 .pointer = snd_hdspm_hw_pointer,
3283 .copy = snd_hdspm_playback_copy,
3284 .silence = snd_hdspm_hw_silence,
3285 .page = snd_pcm_sgbuf_ops_page,
3286};
3287
3288static snd_pcm_ops_t snd_hdspm_capture_ops = {
3289 .open = snd_hdspm_capture_open,
3290 .close = snd_hdspm_capture_release,
3291 .ioctl = snd_hdspm_ioctl,
3292 .hw_params = snd_hdspm_hw_params,
3293 .hw_free = snd_hdspm_hw_free,
3294 .prepare = snd_hdspm_prepare,
3295 .trigger = snd_hdspm_trigger,
3296 .pointer = snd_hdspm_hw_pointer,
3297 .copy = snd_hdspm_capture_copy,
3298 .page = snd_pcm_sgbuf_ops_page,
3299};
3300
3301static int __devinit snd_hdspm_create_hwdep(snd_card_t * card,
3302 hdspm_t * hdspm)
3303{
3304 snd_hwdep_t *hw;
3305 int err;
3306
3307 if ((err = snd_hwdep_new(card, "HDSPM hwdep", 0, &hw)) < 0)
3308 return err;
3309
3310 hdspm->hwdep = hw;
3311 hw->private_data = hdspm;
3312 strcpy(hw->name, "HDSPM hwdep interface");
3313
3314 hw->ops.open = snd_hdspm_hwdep_dummy_op;
3315 hw->ops.ioctl = snd_hdspm_hwdep_ioctl;
3316 hw->ops.release = snd_hdspm_hwdep_dummy_op;
3317
3318 return 0;
3319}
3320
3321
3322/*------------------------------------------------------------
3323 memory interface
3324 ------------------------------------------------------------*/
3325static int __devinit snd_hdspm_preallocate_memory(hdspm_t * hdspm)
3326{
3327 int err;
3328 snd_pcm_t *pcm;
3329 size_t wanted;
3330
3331 pcm = hdspm->pcm;
3332
3333 wanted = HDSPM_DMA_AREA_BYTES + 4096; /* dont know why, but it works */
3334
3335 if ((err =
3336 snd_pcm_lib_preallocate_pages_for_all(pcm,
3337 SNDRV_DMA_TYPE_DEV_SG,
3338 snd_dma_pci_data(hdspm->pci),
3339 wanted,
3340 wanted)) < 0) {
3341 snd_printdd("Could not preallocate %d Bytes\n", wanted);
3342
3343 return err;
3344 } else
3345 snd_printdd(" Preallocated %d Bytes\n", wanted);
3346
3347 return 0;
3348}
3349
3350static int snd_hdspm_memory_free(hdspm_t * hdspm)
3351{
3352 snd_printdd("memory_free_for_all %p\n", hdspm->pcm);
3353
3354 snd_pcm_lib_preallocate_free_for_all(hdspm->pcm);
3355 return 0;
3356}
3357
3358
3359static void hdspm_set_sgbuf(hdspm_t * hdspm, struct snd_sg_buf *sgbuf,
3360 unsigned int reg, int channels)
3361{
3362 int i;
3363 for (i = 0; i < (channels * 16); i++)
3364 hdspm_write(hdspm, reg + 4 * i,
3365 snd_pcm_sgbuf_get_addr(sgbuf,
3366 (size_t) 4096 * i));
3367}
3368
3369/* ------------- ALSA Devices ---------------------------- */
3370static int __devinit snd_hdspm_create_pcm(snd_card_t * card,
3371 hdspm_t * hdspm)
3372{
3373 snd_pcm_t *pcm;
3374 int err;
3375
3376 if ((err = snd_pcm_new(card, hdspm->card_name, 0, 1, 1, &pcm)) < 0)
3377 return err;
3378
3379 hdspm->pcm = pcm;
3380 pcm->private_data = hdspm;
3381 strcpy(pcm->name, hdspm->card_name);
3382
3383 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
3384 &snd_hdspm_playback_ops);
3385 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
3386 &snd_hdspm_capture_ops);
3387
3388 pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX;
3389
3390 if ((err = snd_hdspm_preallocate_memory(hdspm)) < 0)
3391 return err;
3392
3393 return 0;
3394}
3395
3396static inline void snd_hdspm_initialize_midi_flush(hdspm_t * hdspm)
3397{
3398 snd_hdspm_flush_midi_input(hdspm, 0);
3399 snd_hdspm_flush_midi_input(hdspm, 1);
3400}
3401
3402static int __devinit snd_hdspm_create_alsa_devices(snd_card_t * card,
3403 hdspm_t * hdspm)
3404{
3405 int err;
3406
3407 snd_printdd("Create card...\n");
3408 if ((err = snd_hdspm_create_pcm(card, hdspm)) < 0)
3409 return err;
3410
3411 if ((err = snd_hdspm_create_midi(card, hdspm, 0)) < 0)
3412 return err;
3413
3414 if ((err = snd_hdspm_create_midi(card, hdspm, 1)) < 0)
3415 return err;
3416
3417 if ((err = snd_hdspm_create_controls(card, hdspm)) < 0)
3418 return err;
3419
3420 if ((err = snd_hdspm_create_hwdep(card, hdspm)) < 0)
3421 return err;
3422
3423 snd_printdd("proc init...\n");
3424 snd_hdspm_proc_init(hdspm);
3425
3426 hdspm->system_sample_rate = -1;
3427 hdspm->last_external_sample_rate = -1;
3428 hdspm->last_internal_sample_rate = -1;
3429 hdspm->playback_pid = -1;
3430 hdspm->capture_pid = -1;
3431 hdspm->capture_substream = NULL;
3432 hdspm->playback_substream = NULL;
3433
3434 snd_printdd("Set defaults...\n");
3435 if ((err = snd_hdspm_set_defaults(hdspm)) < 0)
3436 return err;
3437
3438 snd_printdd("Update mixer controls...\n");
3439 hdspm_update_simple_mixer_controls(hdspm);
3440
3441 snd_printdd("Initializeing complete ???\n");
3442
3443 if ((err = snd_card_register(card)) < 0) {
3444 snd_printk(KERN_ERR "HDSPM: error registering card\n");
3445 return err;
3446 }
3447
3448 snd_printdd("... yes now\n");
3449
3450 return 0;
3451}
3452
3453static int __devinit snd_hdspm_create(snd_card_t * card, hdspm_t * hdspm,
3454 int precise_ptr, int enable_monitor)
3455{
3456 struct pci_dev *pci = hdspm->pci;
3457 int err;
3458 int i;
3459
3460 unsigned long io_extent;
3461
3462 hdspm->irq = -1;
3463 hdspm->irq_count = 0;
3464
3465 hdspm->midi[0].rmidi = NULL;
3466 hdspm->midi[1].rmidi = NULL;
3467 hdspm->midi[0].input = NULL;
3468 hdspm->midi[1].input = NULL;
3469 hdspm->midi[0].output = NULL;
3470 hdspm->midi[1].output = NULL;
3471 spin_lock_init(&hdspm->midi[0].lock);
3472 spin_lock_init(&hdspm->midi[1].lock);
3473 hdspm->iobase = NULL;
3474 hdspm->control_register = 0;
3475 hdspm->control2_register = 0;
3476
3477 hdspm->playback_buffer = NULL;
3478 hdspm->capture_buffer = NULL;
3479
3480 for (i = 0; i < HDSPM_MAX_CHANNELS; ++i)
3481 hdspm->playback_mixer_ctls[i] = NULL;
3482 hdspm->mixer = NULL;
3483
3484 hdspm->card = card;
3485
3486 spin_lock_init(&hdspm->lock);
3487
3488 tasklet_init(&hdspm->midi_tasklet,
3489 hdspm_midi_tasklet, (unsigned long) hdspm);
3490
3491 pci_read_config_word(hdspm->pci,
3492 PCI_CLASS_REVISION, &hdspm->firmware_rev);
3493
3494 strcpy(card->driver, "HDSPM");
3495 strcpy(card->mixername, "Xilinx FPGA");
3496 hdspm->card_name = "RME HDSPM MADI";
3497
3498 if ((err = pci_enable_device(pci)) < 0)
3499 return err;
3500
3501 pci_set_master(hdspm->pci);
3502
3503 if ((err = pci_request_regions(pci, "hdspm")) < 0)
3504 return err;
3505
3506 hdspm->port = pci_resource_start(pci, 0);
3507 io_extent = pci_resource_len(pci, 0);
3508
3509 snd_printdd("grabbed memory region 0x%lx-0x%lx\n",
3510 hdspm->port, hdspm->port + io_extent - 1);
3511
3512
3513 if ((hdspm->iobase = ioremap_nocache(hdspm->port, io_extent)) == NULL) {
3514 snd_printk(KERN_ERR "HDSPM: unable to remap region 0x%lx-0x%lx\n",
3515 hdspm->port, hdspm->port + io_extent - 1);
3516 return -EBUSY;
3517 }
3518 snd_printdd("remapped region (0x%lx) 0x%lx-0x%lx\n",
3519 (unsigned long)hdspm->iobase, hdspm->port,
3520 hdspm->port + io_extent - 1);
3521
3522 if (request_irq(pci->irq, snd_hdspm_interrupt,
3523 SA_INTERRUPT | SA_SHIRQ, "hdspm",
3524 (void *) hdspm)) {
3525 snd_printk(KERN_ERR "HDSPM: unable to use IRQ %d\n", pci->irq);
3526 return -EBUSY;
3527 }
3528
3529 snd_printdd("use IRQ %d\n", pci->irq);
3530
3531 hdspm->irq = pci->irq;
3532 hdspm->precise_ptr = precise_ptr;
3533
3534 hdspm->monitor_outs = enable_monitor;
3535
3536 snd_printdd("kmalloc Mixer memory of %d Bytes\n",
3537 sizeof(hdspm_mixer_t));
3538 if ((hdspm->mixer =
3539 (hdspm_mixer_t *) kmalloc(sizeof(hdspm_mixer_t), GFP_KERNEL))
3540 == NULL) {
3541 snd_printk(KERN_ERR "HDSPM: unable to kmalloc Mixer memory of %d Bytes\n",
3542 (int)sizeof(hdspm_mixer_t));
3543 return err;
3544 }
3545
3546 hdspm->ss_channels = MADI_SS_CHANNELS;
3547 hdspm->ds_channels = MADI_DS_CHANNELS;
3548 hdspm->qs_channels = MADI_QS_CHANNELS;
3549
3550 snd_printdd("create alsa devices.\n");
3551 if ((err = snd_hdspm_create_alsa_devices(card, hdspm)) < 0)
3552 return err;
3553
3554 snd_hdspm_initialize_midi_flush(hdspm);
3555
3556 return 0;
3557}
3558
3559static int snd_hdspm_free(hdspm_t * hdspm)
3560{
3561
3562 if (hdspm->port) {
3563
3564 /* stop th audio, and cancel all interrupts */
3565 hdspm->control_register &=
3566 ~(HDSPM_Start | HDSPM_AudioInterruptEnable
3567 | HDSPM_Midi0InterruptEnable |
3568 HDSPM_Midi1InterruptEnable);
3569 hdspm_write(hdspm, HDSPM_controlRegister,
3570 hdspm->control_register);
3571 }
3572
3573 if (hdspm->irq >= 0)
3574 free_irq(hdspm->irq, (void *) hdspm);
3575
3576
3577 if (hdspm->mixer)
3578 kfree(hdspm->mixer);
3579
3580 if (hdspm->iobase)
3581 iounmap(hdspm->iobase);
3582
3583 snd_hdspm_memory_free(hdspm);
3584
3585 if (hdspm->port)
3586 pci_release_regions(hdspm->pci);
3587
3588 pci_disable_device(hdspm->pci);
3589 return 0;
3590}
3591
3592static void snd_hdspm_card_free(snd_card_t * card)
3593{
3594 hdspm_t *hdspm = (hdspm_t *) card->private_data;
3595
3596 if (hdspm)
3597 snd_hdspm_free(hdspm);
3598}
3599
3600static int __devinit snd_hdspm_probe(struct pci_dev *pci,
3601 const struct pci_device_id *pci_id)
3602{
3603 static int dev;
3604 hdspm_t *hdspm;
3605 snd_card_t *card;
3606 int err;
3607
3608 if (dev >= SNDRV_CARDS)
3609 return -ENODEV;
3610 if (!enable[dev]) {
3611 dev++;
3612 return -ENOENT;
3613 }
3614
3615 if (!(card = snd_card_new(index[dev], id[dev],
3616 THIS_MODULE, sizeof(hdspm_t))))
3617 return -ENOMEM;
3618
3619 hdspm = (hdspm_t *) card->private_data;
3620 card->private_free = snd_hdspm_card_free;
3621 hdspm->dev = dev;
3622 hdspm->pci = pci;
3623
3624 if ((err =
3625 snd_hdspm_create(card, hdspm, precise_ptr[dev],
3626 enable_monitor[dev])) < 0) {
3627 snd_card_free(card);
3628 return err;
3629 }
3630
3631 strcpy(card->shortname, "HDSPM MADI");
3632 sprintf(card->longname, "%s at 0x%lx, irq %d", hdspm->card_name,
3633 hdspm->port, hdspm->irq);
3634
3635 if ((err = snd_card_register(card)) < 0) {
3636 snd_card_free(card);
3637 return err;
3638 }
3639
3640 pci_set_drvdata(pci, card);
3641
3642 dev++;
3643 return 0;
3644}
3645
3646static void __devexit snd_hdspm_remove(struct pci_dev *pci)
3647{
3648 snd_card_free(pci_get_drvdata(pci));
3649 pci_set_drvdata(pci, NULL);
3650}
3651
3652static struct pci_driver driver = {
3653 .name = "RME Hammerfall DSP MADI",
3654 .id_table = snd_hdspm_ids,
3655 .probe = snd_hdspm_probe,
3656 .remove = __devexit_p(snd_hdspm_remove),
3657};
3658
3659
3660static int __init alsa_card_hdspm_init(void)
3661{
3662 return pci_register_driver(&driver);
3663}
3664
3665static void __exit alsa_card_hdspm_exit(void)
3666{
3667 pci_unregister_driver(&driver);
3668}
3669
3670module_init(alsa_card_hdspm_init)
3671module_exit(alsa_card_hdspm_exit)
diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
index 69cd81eaa111..f3037402d58f 100644
--- a/sound/pci/rme9652/rme9652.c
+++ b/sound/pci/rme9652/rme9652.c
@@ -303,18 +303,22 @@ static int snd_hammerfall_get_buffer(struct pci_dev *pci, struct snd_dma_buffer
303{ 303{
304 dmab->dev.type = SNDRV_DMA_TYPE_DEV; 304 dmab->dev.type = SNDRV_DMA_TYPE_DEV;
305 dmab->dev.dev = snd_dma_pci_data(pci); 305 dmab->dev.dev = snd_dma_pci_data(pci);
306 if (! snd_dma_get_reserved_buf(dmab, snd_dma_pci_buf_id(pci))) { 306 if (snd_dma_get_reserved_buf(dmab, snd_dma_pci_buf_id(pci))) {
307 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 307 if (dmab->bytes >= size)
308 size, dmab) < 0) 308 return 0;
309 return -ENOMEM;
310 } 309 }
310 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
311 size, dmab) < 0)
312 return -ENOMEM;
311 return 0; 313 return 0;
312} 314}
313 315
314static void snd_hammerfall_free_buffer(struct snd_dma_buffer *dmab, struct pci_dev *pci) 316static void snd_hammerfall_free_buffer(struct snd_dma_buffer *dmab, struct pci_dev *pci)
315{ 317{
316 if (dmab->area) 318 if (dmab->area) {
319 dmab->dev.dev = NULL; /* make it anonymous */
317 snd_dma_reserve_buf(dmab, snd_dma_pci_buf_id(pci)); 320 snd_dma_reserve_buf(dmab, snd_dma_pci_buf_id(pci));
321 }
318} 322}
319 323
320 324
@@ -2664,7 +2668,7 @@ static struct pci_driver driver = {
2664 2668
2665static int __init alsa_card_hammerfall_init(void) 2669static int __init alsa_card_hammerfall_init(void)
2666{ 2670{
2667 return pci_module_init(&driver); 2671 return pci_register_driver(&driver);
2668} 2672}
2669 2673
2670static void __exit alsa_card_hammerfall_exit(void) 2674static void __exit alsa_card_hammerfall_exit(void)
diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c
index cfd2c5fd6ddf..60ecb2bdb65e 100644
--- a/sound/pci/sonicvibes.c
+++ b/sound/pci/sonicvibes.c
@@ -1522,7 +1522,7 @@ static struct pci_driver driver = {
1522 1522
1523static int __init alsa_card_sonicvibes_init(void) 1523static int __init alsa_card_sonicvibes_init(void)
1524{ 1524{
1525 return pci_module_init(&driver); 1525 return pci_register_driver(&driver);
1526} 1526}
1527 1527
1528static void __exit alsa_card_sonicvibes_exit(void) 1528static void __exit alsa_card_sonicvibes_exit(void)
diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c
index ad58e08d66e2..940d531575c0 100644
--- a/sound/pci/trident/trident.c
+++ b/sound/pci/trident/trident.c
@@ -143,7 +143,8 @@ static int __devinit snd_trident_probe(struct pci_dev *pci,
143 return err; 143 return err;
144 } 144 }
145 } 145 }
146 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE, 146 if (trident->device != TRIDENT_DEVICE_ID_SI7018 &&
147 (err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE,
147 trident->midi_port, 1, 148 trident->midi_port, 1,
148 trident->irq, 0, &trident->rmidi)) < 0) { 149 trident->irq, 0, &trident->rmidi)) < 0) {
149 snd_card_free(card); 150 snd_card_free(card);
@@ -184,7 +185,7 @@ static struct pci_driver driver = {
184 185
185static int __init alsa_card_trident_init(void) 186static int __init alsa_card_trident_init(void)
186{ 187{
187 return pci_module_init(&driver); 188 return pci_register_driver(&driver);
188} 189}
189 190
190static void __exit alsa_card_trident_exit(void) 191static void __exit alsa_card_trident_exit(void)
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index 9b4d74d49f98..42c48f0ce8e8 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -101,7 +101,7 @@ MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz).");
101module_param_array(ac97_quirk, charp, NULL, 0444); 101module_param_array(ac97_quirk, charp, NULL, 0444);
102MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); 102MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
103module_param_array(dxs_support, int, NULL, 0444); 103module_param_array(dxs_support, int, NULL, 0444);
104MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA)"); 104MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA, 5 = enable any sample rate)");
105 105
106 106
107/* pci ids */ 107/* pci ids */
@@ -302,6 +302,7 @@ DEFINE_VIA_REGSET(CAPTURE_8233, 0x60);
302#define VIA_DXS_DISABLE 2 302#define VIA_DXS_DISABLE 2
303#define VIA_DXS_48K 3 303#define VIA_DXS_48K 3
304#define VIA_DXS_NO_VRA 4 304#define VIA_DXS_NO_VRA 4
305#define VIA_DXS_SRC 5
305 306
306 307
307/* 308/*
@@ -380,6 +381,7 @@ struct _snd_via82xx {
380 struct via_rate_lock rates[2]; /* playback and capture */ 381 struct via_rate_lock rates[2]; /* playback and capture */
381 unsigned int dxs_fixed: 1; /* DXS channel accepts only 48kHz */ 382 unsigned int dxs_fixed: 1; /* DXS channel accepts only 48kHz */
382 unsigned int no_vra: 1; /* no need to set VRA on DXS channels */ 383 unsigned int no_vra: 1; /* no need to set VRA on DXS channels */
384 unsigned int dxs_src: 1; /* use full SRC capabilities of DXS */
383 unsigned int spdif_on: 1; /* only spdif rates work to external DACs */ 385 unsigned int spdif_on: 1; /* only spdif rates work to external DACs */
384 386
385 snd_pcm_t *pcms[2]; 387 snd_pcm_t *pcms[2];
@@ -489,10 +491,8 @@ static int clean_via_table(viadev_t *dev, snd_pcm_substream_t *substream,
489 snd_dma_free_pages(&dev->table); 491 snd_dma_free_pages(&dev->table);
490 dev->table.area = NULL; 492 dev->table.area = NULL;
491 } 493 }
492 if (dev->idx_table) { 494 kfree(dev->idx_table);
493 kfree(dev->idx_table); 495 dev->idx_table = NULL;
494 dev->idx_table = NULL;
495 }
496 return 0; 496 return 0;
497} 497}
498 498
@@ -924,15 +924,17 @@ static int snd_via8233_playback_prepare(snd_pcm_substream_t *substream)
924 via82xx_t *chip = snd_pcm_substream_chip(substream); 924 via82xx_t *chip = snd_pcm_substream_chip(substream);
925 viadev_t *viadev = (viadev_t *)substream->runtime->private_data; 925 viadev_t *viadev = (viadev_t *)substream->runtime->private_data;
926 snd_pcm_runtime_t *runtime = substream->runtime; 926 snd_pcm_runtime_t *runtime = substream->runtime;
927 int ac97_rate = chip->dxs_src ? 48000 : runtime->rate;
927 int rate_changed; 928 int rate_changed;
928 u32 rbits; 929 u32 rbits;
929 930
930 if ((rate_changed = via_lock_rate(&chip->rates[0], runtime->rate)) < 0) 931 if ((rate_changed = via_lock_rate(&chip->rates[0], ac97_rate)) < 0)
931 return rate_changed; 932 return rate_changed;
932 if (rate_changed) { 933 if (rate_changed) {
933 snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE, 934 snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE,
934 chip->no_vra ? 48000 : runtime->rate); 935 chip->no_vra ? 48000 : runtime->rate);
935 snd_ac97_set_rate(chip->ac97, AC97_SPDIF, runtime->rate); 936 snd_ac97_set_rate(chip->ac97, AC97_SPDIF,
937 chip->no_vra ? 48000 : runtime->rate);
936 } 938 }
937 if (runtime->rate == 48000) 939 if (runtime->rate == 48000)
938 rbits = 0xfffff; 940 rbits = 0xfffff;
@@ -1074,6 +1076,12 @@ static int snd_via82xx_pcm_open(via82xx_t *chip, viadev_t *viadev, snd_pcm_subst
1074 /* fixed DXS playback rate */ 1076 /* fixed DXS playback rate */
1075 runtime->hw.rates = SNDRV_PCM_RATE_48000; 1077 runtime->hw.rates = SNDRV_PCM_RATE_48000;
1076 runtime->hw.rate_min = runtime->hw.rate_max = 48000; 1078 runtime->hw.rate_min = runtime->hw.rate_max = 48000;
1079 } else if (chip->dxs_src && viadev->reg_offset < 0x40) {
1080 /* use full SRC capabilities of DXS */
1081 runtime->hw.rates = (SNDRV_PCM_RATE_CONTINUOUS |
1082 SNDRV_PCM_RATE_8000_48000);
1083 runtime->hw.rate_min = 8000;
1084 runtime->hw.rate_max = 48000;
1077 } else if (! ratep->rate) { 1085 } else if (! ratep->rate) {
1078 int idx = viadev->direction ? AC97_RATES_ADC : AC97_RATES_FRONT_DAC; 1086 int idx = viadev->direction ? AC97_RATES_ADC : AC97_RATES_FRONT_DAC;
1079 runtime->hw.rates = chip->ac97->rates[idx]; 1087 runtime->hw.rates = chip->ac97->rates[idx];
@@ -1550,51 +1558,51 @@ static void snd_via82xx_mixer_free_ac97(ac97_t *ac97)
1550 1558
1551static struct ac97_quirk ac97_quirks[] = { 1559static struct ac97_quirk ac97_quirks[] = {
1552 { 1560 {
1553 .vendor = 0x1106, 1561 .subvendor = 0x1106,
1554 .device = 0x4161, 1562 .subdevice = 0x4161,
1555 .codec_id = 0x56494161, /* VT1612A */ 1563 .codec_id = 0x56494161, /* VT1612A */
1556 .name = "Soltek SL-75DRV5", 1564 .name = "Soltek SL-75DRV5",
1557 .type = AC97_TUNE_NONE 1565 .type = AC97_TUNE_NONE
1558 }, 1566 },
1559 { /* FIXME: which codec? */ 1567 { /* FIXME: which codec? */
1560 .vendor = 0x1106, 1568 .subvendor = 0x1106,
1561 .device = 0x4161, 1569 .subdevice = 0x4161,
1562 .name = "ASRock K7VT2", 1570 .name = "ASRock K7VT2",
1563 .type = AC97_TUNE_HP_ONLY 1571 .type = AC97_TUNE_HP_ONLY
1564 }, 1572 },
1565 { 1573 {
1566 .vendor = 0x1019, 1574 .subvendor = 0x1019,
1567 .device = 0x0a81, 1575 .subdevice = 0x0a81,
1568 .name = "ECS K7VTA3", 1576 .name = "ECS K7VTA3",
1569 .type = AC97_TUNE_HP_ONLY 1577 .type = AC97_TUNE_HP_ONLY
1570 }, 1578 },
1571 { 1579 {
1572 .vendor = 0x1019, 1580 .subvendor = 0x1019,
1573 .device = 0x0a85, 1581 .subdevice = 0x0a85,
1574 .name = "ECS L7VMM2", 1582 .name = "ECS L7VMM2",
1575 .type = AC97_TUNE_HP_ONLY 1583 .type = AC97_TUNE_HP_ONLY
1576 }, 1584 },
1577 { 1585 {
1578 .vendor = 0x1849, 1586 .subvendor = 0x1849,
1579 .device = 0x3059, 1587 .subdevice = 0x3059,
1580 .name = "ASRock K7VM2", 1588 .name = "ASRock K7VM2",
1581 .type = AC97_TUNE_HP_ONLY /* VT1616 */ 1589 .type = AC97_TUNE_HP_ONLY /* VT1616 */
1582 }, 1590 },
1583 { 1591 {
1584 .vendor = 0x14cd, 1592 .subvendor = 0x14cd,
1585 .device = 0x7002, 1593 .subdevice = 0x7002,
1586 .name = "Unknown", 1594 .name = "Unknown",
1587 .type = AC97_TUNE_ALC_JACK 1595 .type = AC97_TUNE_ALC_JACK
1588 }, 1596 },
1589 { 1597 {
1590 .vendor = 0x1071, 1598 .subvendor = 0x1071,
1591 .device = 0x8590, 1599 .subdevice = 0x8590,
1592 .name = "Mitac Mobo", 1600 .name = "Mitac Mobo",
1593 .type = AC97_TUNE_ALC_JACK 1601 .type = AC97_TUNE_ALC_JACK
1594 }, 1602 },
1595 { 1603 {
1596 .vendor = 0x161f, 1604 .subvendor = 0x161f,
1597 .device = 0x202b, 1605 .subdevice = 0x202b,
1598 .name = "Arima Notebook", 1606 .name = "Arima Notebook",
1599 .type = AC97_TUNE_HP_ONLY, 1607 .type = AC97_TUNE_HP_ONLY,
1600 }, 1608 },
@@ -2132,8 +2140,8 @@ static struct via823x_info via823x_cards[] __devinitdata = {
2132 * auto detection of DXS channel supports. 2140 * auto detection of DXS channel supports.
2133 */ 2141 */
2134struct dxs_whitelist { 2142struct dxs_whitelist {
2135 unsigned short vendor; 2143 unsigned short subvendor;
2136 unsigned short device; 2144 unsigned short subdevice;
2137 unsigned short mask; 2145 unsigned short mask;
2138 short action; /* new dxs_support value */ 2146 short action; /* new dxs_support value */
2139}; 2147};
@@ -2141,38 +2149,44 @@ struct dxs_whitelist {
2141static int __devinit check_dxs_list(struct pci_dev *pci) 2149static int __devinit check_dxs_list(struct pci_dev *pci)
2142{ 2150{
2143 static struct dxs_whitelist whitelist[] = { 2151 static struct dxs_whitelist whitelist[] = {
2144 { .vendor = 0x1005, .device = 0x4710, .action = VIA_DXS_ENABLE }, /* Avance Logic Mobo */ 2152 { .subvendor = 0x1005, .subdevice = 0x4710, .action = VIA_DXS_ENABLE }, /* Avance Logic Mobo */
2145 { .vendor = 0x1019, .device = 0x0996, .action = VIA_DXS_48K }, 2153 { .subvendor = 0x1019, .subdevice = 0x0996, .action = VIA_DXS_48K },
2146 { .vendor = 0x1019, .device = 0x0a81, .action = VIA_DXS_NO_VRA }, /* ECS K7VTA3 v8.0 */ 2154 { .subvendor = 0x1019, .subdevice = 0x0a81, .action = VIA_DXS_NO_VRA }, /* ECS K7VTA3 v8.0 */
2147 { .vendor = 0x1019, .device = 0x0a85, .action = VIA_DXS_NO_VRA }, /* ECS L7VMM2 */ 2155 { .subvendor = 0x1019, .subdevice = 0x0a85, .action = VIA_DXS_NO_VRA }, /* ECS L7VMM2 */
2148 { .vendor = 0x1025, .device = 0x0033, .action = VIA_DXS_NO_VRA }, /* Acer Inspire 1353LM */ 2156 { .subvendor = 0x1025, .subdevice = 0x0033, .action = VIA_DXS_NO_VRA }, /* Acer Inspire 1353LM */
2149 { .vendor = 0x1043, .device = 0x8095, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8X (FIXME: possibly VIA_DXS_ENABLE?)*/ 2157 { .subvendor = 0x1043, .subdevice = 0x8095, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8X (FIXME: possibly VIA_DXS_ENABLE?)*/
2150 { .vendor = 0x1043, .device = 0x80a1, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8-X */ 2158 { .subvendor = 0x1043, .subdevice = 0x80a1, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8-X */
2151 { .vendor = 0x1043, .device = 0x80b0, .action = VIA_DXS_NO_VRA }, /* ASUS A7V600 & K8V*/ 2159 { .subvendor = 0x1043, .subdevice = 0x80b0, .action = VIA_DXS_NO_VRA }, /* ASUS A7V600 & K8V*/
2152 { .vendor = 0x1071, .device = 0x8375, .action = VIA_DXS_NO_VRA }, /* Vobis/Yakumo/Mitac notebook */ 2160 { .subvendor = 0x1043, .subdevice = 0x812a, .action = VIA_DXS_SRC }, /* ASUS A8V Deluxe */
2153 { .vendor = 0x10cf, .device = 0x118e, .action = VIA_DXS_ENABLE }, /* FSC laptop */ 2161 { .subvendor = 0x1071, .subdevice = 0x8375, .action = VIA_DXS_NO_VRA }, /* Vobis/Yakumo/Mitac notebook */
2154 { .vendor = 0x1106, .device = 0x4161, .action = VIA_DXS_NO_VRA }, /* ASRock K7VT2 */ 2162 { .subvendor = 0x1071, .subdevice = 0x8399, .action = VIA_DXS_NO_VRA }, /* Umax AB 595T (VIA K8N800A - VT8237) */
2155 { .vendor = 0x1106, .device = 0x4552, .action = VIA_DXS_NO_VRA }, /* QDI Kudoz 7X/600-6AL */ 2163 { .subvendor = 0x10cf, .subdevice = 0x118e, .action = VIA_DXS_ENABLE }, /* FSC laptop */
2156 { .vendor = 0x1106, .device = 0xaa01, .action = VIA_DXS_NO_VRA }, /* EPIA MII */ 2164 { .subvendor = 0x1106, .subdevice = 0x4161, .action = VIA_DXS_NO_VRA }, /* ASRock K7VT2 */
2157 { .vendor = 0x1297, .device = 0xa232, .action = VIA_DXS_ENABLE }, /* Shuttle ?? */ 2165 { .subvendor = 0x1106, .subdevice = 0x4552, .action = VIA_DXS_NO_VRA }, /* QDI Kudoz 7X/600-6AL */
2158 { .vendor = 0x1297, .device = 0xc160, .action = VIA_DXS_ENABLE }, /* Shuttle SK41G */ 2166 { .subvendor = 0x1106, .subdevice = 0xaa01, .action = VIA_DXS_NO_VRA }, /* EPIA MII */
2159 { .vendor = 0x1458, .device = 0xa002, .action = VIA_DXS_ENABLE }, /* Gigabyte GA-7VAXP */ 2167 { .subvendor = 0x1106, .subdevice = 0xc001, .action = VIA_DXS_SRC }, /* Insight P4-ITX */
2160 { .vendor = 0x1462, .device = 0x3800, .action = VIA_DXS_ENABLE }, /* MSI KT266 */ 2168 { .subvendor = 0x1297, .subdevice = 0xa232, .action = VIA_DXS_ENABLE }, /* Shuttle ?? */
2161 { .vendor = 0x1462, .device = 0x5901, .action = VIA_DXS_NO_VRA }, /* MSI KT6 Delta-SR */ 2169 { .subvendor = 0x1297, .subdevice = 0xc160, .action = VIA_DXS_ENABLE }, /* Shuttle SK41G */
2162 { .vendor = 0x1462, .device = 0x7023, .action = VIA_DXS_NO_VRA }, /* MSI K8T Neo2-FI */ 2170 { .subvendor = 0x1458, .subdevice = 0xa002, .action = VIA_DXS_ENABLE }, /* Gigabyte GA-7VAXP */
2163 { .vendor = 0x1462, .device = 0x7120, .action = VIA_DXS_ENABLE }, /* MSI KT4V */ 2171 { .subvendor = 0x1462, .subdevice = 0x0080, .action = VIA_DXS_SRC }, /* MSI K8T Neo-FIS2R */
2164 { .vendor = 0x147b, .device = 0x1401, .action = VIA_DXS_ENABLE }, /* ABIT KD7(-RAID) */ 2172 { .subvendor = 0x1462, .subdevice = 0x3800, .action = VIA_DXS_ENABLE }, /* MSI KT266 */
2165 { .vendor = 0x147b, .device = 0x1411, .action = VIA_DXS_ENABLE }, /* ABIT VA-20 */ 2173 { .subvendor = 0x1462, .subdevice = 0x5901, .action = VIA_DXS_NO_VRA }, /* MSI KT6 Delta-SR */
2166 { .vendor = 0x147b, .device = 0x1413, .action = VIA_DXS_ENABLE }, /* ABIT KV8 Pro */ 2174 { .subvendor = 0x1462, .subdevice = 0x7023, .action = VIA_DXS_NO_VRA }, /* MSI K8T Neo2-FI */
2167 { .vendor = 0x147b, .device = 0x1415, .action = VIA_DXS_NO_VRA }, /* Abit AV8 */ 2175 { .subvendor = 0x1462, .subdevice = 0x7120, .action = VIA_DXS_ENABLE }, /* MSI KT4V */
2168 { .vendor = 0x14ff, .device = 0x0403, .action = VIA_DXS_ENABLE }, /* Twinhead mobo */ 2176 { .subvendor = 0x147b, .subdevice = 0x1401, .action = VIA_DXS_ENABLE }, /* ABIT KD7(-RAID) */
2169 { .vendor = 0x1584, .device = 0x8120, .action = VIA_DXS_ENABLE }, /* Gericom/Targa/Vobis/Uniwill laptop */ 2177 { .subvendor = 0x147b, .subdevice = 0x1411, .action = VIA_DXS_ENABLE }, /* ABIT VA-20 */
2170 { .vendor = 0x1584, .device = 0x8123, .action = VIA_DXS_NO_VRA }, /* Uniwill (Targa Visionary XP-210) */ 2178 { .subvendor = 0x147b, .subdevice = 0x1413, .action = VIA_DXS_ENABLE }, /* ABIT KV8 Pro */
2171 { .vendor = 0x161f, .device = 0x202b, .action = VIA_DXS_NO_VRA }, /* Amira Note book */ 2179 { .subvendor = 0x147b, .subdevice = 0x1415, .action = VIA_DXS_NO_VRA }, /* Abit AV8 */
2172 { .vendor = 0x161f, .device = 0x2032, .action = VIA_DXS_48K }, /* m680x machines */ 2180 { .subvendor = 0x14ff, .subdevice = 0x0403, .action = VIA_DXS_ENABLE }, /* Twinhead mobo */
2173 { .vendor = 0x1631, .device = 0xe004, .action = VIA_DXS_ENABLE }, /* Easy Note 3174, Packard Bell */ 2181 { .subvendor = 0x14ff, .subdevice = 0x0408, .action = VIA_DXS_NO_VRA }, /* Twinhead mobo */
2174 { .vendor = 0x1695, .device = 0x3005, .action = VIA_DXS_ENABLE }, /* EPoX EP-8K9A */ 2182 { .subvendor = 0x1584, .subdevice = 0x8120, .action = VIA_DXS_ENABLE }, /* Gericom/Targa/Vobis/Uniwill laptop */
2175 { .vendor = 0x1849, .device = 0x3059, .action = VIA_DXS_NO_VRA }, /* ASRock K7VM2 */ 2183 { .subvendor = 0x1584, .subdevice = 0x8123, .action = VIA_DXS_NO_VRA }, /* Uniwill (Targa Visionary XP-210) */
2184 { .subvendor = 0x161f, .subdevice = 0x202b, .action = VIA_DXS_NO_VRA }, /* Amira Note book */
2185 { .subvendor = 0x161f, .subdevice = 0x2032, .action = VIA_DXS_48K }, /* m680x machines */
2186 { .subvendor = 0x1631, .subdevice = 0xe004, .action = VIA_DXS_ENABLE }, /* Easy Note 3174, Packard Bell */
2187 { .subvendor = 0x1695, .subdevice = 0x3005, .action = VIA_DXS_ENABLE }, /* EPoX EP-8K9A */
2188 { .subvendor = 0x1849, .subdevice = 0x3059, .action = VIA_DXS_NO_VRA }, /* ASRock K7VM2 */
2189 { .subvendor = 0x1919, .subdevice = 0x200a, .action = VIA_DXS_NO_VRA }, /* Soltek SL-K8Tpro-939 */
2176 { } /* terminator */ 2190 { } /* terminator */
2177 }; 2191 };
2178 struct dxs_whitelist *w; 2192 struct dxs_whitelist *w;
@@ -2182,14 +2196,14 @@ static int __devinit check_dxs_list(struct pci_dev *pci)
2182 pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); 2196 pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor);
2183 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &subsystem_device); 2197 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &subsystem_device);
2184 2198
2185 for (w = whitelist; w->vendor; w++) { 2199 for (w = whitelist; w->subvendor; w++) {
2186 if (w->vendor != subsystem_vendor) 2200 if (w->subvendor != subsystem_vendor)
2187 continue; 2201 continue;
2188 if (w->mask) { 2202 if (w->mask) {
2189 if ((w->mask & subsystem_device) == w->device) 2203 if ((w->mask & subsystem_device) == w->subdevice)
2190 return w->action; 2204 return w->action;
2191 } else { 2205 } else {
2192 if (subsystem_device == w->device) 2206 if (subsystem_device == w->subdevice)
2193 return w->action; 2207 return w->action;
2194 } 2208 }
2195 } 2209 }
@@ -2198,8 +2212,9 @@ static int __devinit check_dxs_list(struct pci_dev *pci)
2198 * not detected, try 48k rate only to be sure. 2212 * not detected, try 48k rate only to be sure.
2199 */ 2213 */
2200 printk(KERN_INFO "via82xx: Assuming DXS channels with 48k fixed sample rate.\n"); 2214 printk(KERN_INFO "via82xx: Assuming DXS channels with 48k fixed sample rate.\n");
2201 printk(KERN_INFO " Please try dxs_support=1 or dxs_support=4 option\n"); 2215 printk(KERN_INFO " Please try dxs_support=5 option\n");
2202 printk(KERN_INFO " and report if it works on your machine.\n"); 2216 printk(KERN_INFO " and report if it works on your machine.\n");
2217 printk(KERN_INFO " For more details, read ALSA-Configuration.txt.\n");
2203 return VIA_DXS_48K; 2218 return VIA_DXS_48K;
2204}; 2219};
2205 2220
@@ -2288,6 +2303,10 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
2288 chip->dxs_fixed = 1; 2303 chip->dxs_fixed = 1;
2289 else if (dxs_support[dev] == VIA_DXS_NO_VRA) 2304 else if (dxs_support[dev] == VIA_DXS_NO_VRA)
2290 chip->no_vra = 1; 2305 chip->no_vra = 1;
2306 else if (dxs_support[dev] == VIA_DXS_SRC) {
2307 chip->no_vra = 1;
2308 chip->dxs_src = 1;
2309 }
2291 } 2310 }
2292 if ((err = snd_via8233_init_misc(chip, dev)) < 0) 2311 if ((err = snd_via8233_init_misc(chip, dev)) < 0)
2293 goto __error; 2312 goto __error;
@@ -2334,7 +2353,7 @@ static struct pci_driver driver = {
2334 2353
2335static int __init alsa_card_via82xx_init(void) 2354static int __init alsa_card_via82xx_init(void)
2336{ 2355{
2337 return pci_module_init(&driver); 2356 return pci_register_driver(&driver);
2338} 2357}
2339 2358
2340static void __exit alsa_card_via82xx_exit(void) 2359static void __exit alsa_card_via82xx_exit(void)
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index ea5c6f640159..5896d289f9ac 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -352,10 +352,8 @@ static int clean_via_table(viadev_t *dev, snd_pcm_substream_t *substream,
352 snd_dma_free_pages(&dev->table); 352 snd_dma_free_pages(&dev->table);
353 dev->table.area = NULL; 353 dev->table.area = NULL;
354 } 354 }
355 if (dev->idx_table) { 355 kfree(dev->idx_table);
356 kfree(dev->idx_table); 356 dev->idx_table = NULL;
357 dev->idx_table = NULL;
358 }
359 return 0; 357 return 0;
360} 358}
361 359
@@ -420,7 +418,10 @@ static void snd_via82xx_codec_write(ac97_t *ac97,
420{ 418{
421 via82xx_t *chip = ac97->private_data; 419 via82xx_t *chip = ac97->private_data;
422 unsigned int xval; 420 unsigned int xval;
423 421 if(reg == AC97_GPIO_STATUS) {
422 outl(val, VIAREG(chip, GPI_STATUS));
423 return;
424 }
424 xval = !ac97->num ? VIA_REG_AC97_CODEC_ID_PRIMARY : VIA_REG_AC97_CODEC_ID_SECONDARY; 425 xval = !ac97->num ? VIA_REG_AC97_CODEC_ID_PRIMARY : VIA_REG_AC97_CODEC_ID_SECONDARY;
425 xval <<= VIA_REG_AC97_CODEC_ID_SHIFT; 426 xval <<= VIA_REG_AC97_CODEC_ID_SHIFT;
426 xval |= reg << VIA_REG_AC97_CMD_SHIFT; 427 xval |= reg << VIA_REG_AC97_CMD_SHIFT;
@@ -544,25 +545,6 @@ static int snd_via82xx_pcm_trigger(snd_pcm_substream_t * substream, int cmd)
544 return 0; 545 return 0;
545} 546}
546 547
547static int snd_via82xx_modem_pcm_trigger(snd_pcm_substream_t * substream, int cmd)
548{
549 via82xx_t *chip = snd_pcm_substream_chip(substream);
550 unsigned int val = 0;
551 switch (cmd) {
552 case SNDRV_PCM_TRIGGER_START:
553 val = snd_ac97_read(chip->ac97, AC97_GPIO_STATUS);
554 outl(val|AC97_GPIO_LINE1_OH, VIAREG(chip, GPI_STATUS));
555 break;
556 case SNDRV_PCM_TRIGGER_STOP:
557 val = snd_ac97_read(chip->ac97, AC97_GPIO_STATUS);
558 outl(val&~AC97_GPIO_LINE1_OH, VIAREG(chip, GPI_STATUS));
559 break;
560 default:
561 break;
562 }
563 return snd_via82xx_pcm_trigger(substream, cmd);
564}
565
566/* 548/*
567 * pointer callbacks 549 * pointer callbacks
568 */ 550 */
@@ -806,7 +788,7 @@ static snd_pcm_ops_t snd_via686_playback_ops = {
806 .hw_params = snd_via82xx_hw_params, 788 .hw_params = snd_via82xx_hw_params,
807 .hw_free = snd_via82xx_hw_free, 789 .hw_free = snd_via82xx_hw_free,
808 .prepare = snd_via82xx_pcm_prepare, 790 .prepare = snd_via82xx_pcm_prepare,
809 .trigger = snd_via82xx_modem_pcm_trigger, 791 .trigger = snd_via82xx_pcm_trigger,
810 .pointer = snd_via686_pcm_pointer, 792 .pointer = snd_via686_pcm_pointer,
811 .page = snd_pcm_sgbuf_ops_page, 793 .page = snd_pcm_sgbuf_ops_page,
812}; 794};
@@ -819,7 +801,7 @@ static snd_pcm_ops_t snd_via686_capture_ops = {
819 .hw_params = snd_via82xx_hw_params, 801 .hw_params = snd_via82xx_hw_params,
820 .hw_free = snd_via82xx_hw_free, 802 .hw_free = snd_via82xx_hw_free,
821 .prepare = snd_via82xx_pcm_prepare, 803 .prepare = snd_via82xx_pcm_prepare,
822 .trigger = snd_via82xx_modem_pcm_trigger, 804 .trigger = snd_via82xx_pcm_trigger,
823 .pointer = snd_via686_pcm_pointer, 805 .pointer = snd_via686_pcm_pointer,
824 .page = snd_pcm_sgbuf_ops_page, 806 .page = snd_pcm_sgbuf_ops_page,
825}; 807};
@@ -938,7 +920,7 @@ static void __devinit snd_via82xx_proc_init(via82xx_t *chip)
938 * 920 *
939 */ 921 */
940 922
941static int __devinit snd_via82xx_chip_init(via82xx_t *chip) 923static int snd_via82xx_chip_init(via82xx_t *chip)
942{ 924{
943 unsigned int val; 925 unsigned int val;
944 int max_count; 926 int max_count;
@@ -1233,7 +1215,7 @@ static struct pci_driver driver = {
1233 1215
1234static int __init alsa_card_via82xx_init(void) 1216static int __init alsa_card_via82xx_init(void)
1235{ 1217{
1236 return pci_module_init(&driver); 1218 return pci_register_driver(&driver);
1237} 1219}
1238 1220
1239static void __exit alsa_card_via82xx_exit(void) 1221static void __exit alsa_card_via82xx_exit(void)
diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c
index 4ffbb25658a5..dca6bd2c7580 100644
--- a/sound/pci/vx222/vx222.c
+++ b/sound/pci/vx222/vx222.c
@@ -260,7 +260,7 @@ static struct pci_driver driver = {
260 260
261static int __init alsa_card_vx222_init(void) 261static int __init alsa_card_vx222_init(void)
262{ 262{
263 return pci_module_init(&driver); 263 return pci_register_driver(&driver);
264} 264}
265 265
266static void __exit alsa_card_vx222_exit(void) 266static void __exit alsa_card_vx222_exit(void)
diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c
index 9f3ef22df08d..5b5b624b47d0 100644
--- a/sound/pci/ymfpci/ymfpci.c
+++ b/sound/pci/ymfpci/ymfpci.c
@@ -360,7 +360,7 @@ static struct pci_driver driver = {
360 360
361static int __init alsa_card_ymfpci_init(void) 361static int __init alsa_card_ymfpci_init(void)
362{ 362{
363 return pci_module_init(&driver); 363 return pci_register_driver(&driver);
364} 364}
365 365
366static void __exit alsa_card_ymfpci_exit(void) 366static void __exit alsa_card_ymfpci_exit(void)
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index 05f1629760bc..2ae79610ecb5 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -829,9 +829,7 @@ static snd_pcm_hardware_t snd_ymfpci_capture =
829 829
830static void snd_ymfpci_pcm_free_substream(snd_pcm_runtime_t *runtime) 830static void snd_ymfpci_pcm_free_substream(snd_pcm_runtime_t *runtime)
831{ 831{
832 ymfpci_pcm_t *ypcm = runtime->private_data; 832 kfree(runtime->private_data);
833
834 kfree(ypcm);
835} 833}
836 834
837static int snd_ymfpci_playback_open_1(snd_pcm_substream_t * substream) 835static int snd_ymfpci_playback_open_1(snd_pcm_substream_t * substream)
@@ -1421,17 +1419,15 @@ static snd_kcontrol_new_t snd_ymfpci_drec_source __devinitdata = {
1421 1419
1422static int snd_ymfpci_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1420static int snd_ymfpci_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
1423{ 1421{
1424 unsigned int mask = 1;
1425
1426 switch (kcontrol->private_value) { 1422 switch (kcontrol->private_value) {
1427 case YDSXGR_SPDIFOUTCTRL: break; 1423 case YDSXGR_SPDIFOUTCTRL: break;
1428 case YDSXGR_SPDIFINCTRL: break; 1424 case YDSXGR_SPDIFINCTRL: break;
1429 default: return -EINVAL; 1425 default: return -EINVAL;
1430 } 1426 }
1431 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; 1427 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1432 uinfo->count = 1; 1428 uinfo->count = 1;
1433 uinfo->value.integer.min = 0; 1429 uinfo->value.integer.min = 0;
1434 uinfo->value.integer.max = mask; 1430 uinfo->value.integer.max = 1;
1435 return 0; 1431 return 0;
1436} 1432}
1437 1433
@@ -1439,7 +1435,7 @@ static int snd_ymfpci_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
1439{ 1435{
1440 ymfpci_t *chip = snd_kcontrol_chip(kcontrol); 1436 ymfpci_t *chip = snd_kcontrol_chip(kcontrol);
1441 int reg = kcontrol->private_value; 1437 int reg = kcontrol->private_value;
1442 unsigned int shift = 0, mask = 1, invert = 0; 1438 unsigned int shift = 0, mask = 1;
1443 1439
1444 switch (kcontrol->private_value) { 1440 switch (kcontrol->private_value) {
1445 case YDSXGR_SPDIFOUTCTRL: break; 1441 case YDSXGR_SPDIFOUTCTRL: break;
@@ -1447,8 +1443,6 @@ static int snd_ymfpci_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
1447 default: return -EINVAL; 1443 default: return -EINVAL;
1448 } 1444 }
1449 ucontrol->value.integer.value[0] = (snd_ymfpci_readl(chip, reg) >> shift) & mask; 1445 ucontrol->value.integer.value[0] = (snd_ymfpci_readl(chip, reg) >> shift) & mask;
1450 if (invert)
1451 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
1452 return 0; 1446 return 0;
1453} 1447}
1454 1448
@@ -1456,7 +1450,7 @@ static int snd_ymfpci_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
1456{ 1450{
1457 ymfpci_t *chip = snd_kcontrol_chip(kcontrol); 1451 ymfpci_t *chip = snd_kcontrol_chip(kcontrol);
1458 int reg = kcontrol->private_value; 1452 int reg = kcontrol->private_value;
1459 unsigned int shift = 0, mask = 1, invert = 0; 1453 unsigned int shift = 0, mask = 1;
1460 int change; 1454 int change;
1461 unsigned int val, oval; 1455 unsigned int val, oval;
1462 1456
@@ -1466,8 +1460,6 @@ static int snd_ymfpci_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
1466 default: return -EINVAL; 1460 default: return -EINVAL;
1467 } 1461 }
1468 val = (ucontrol->value.integer.value[0] & mask); 1462 val = (ucontrol->value.integer.value[0] & mask);
1469 if (invert)
1470 val = mask - val;
1471 val <<= shift; 1463 val <<= shift;
1472 spin_lock_irq(&chip->reg_lock); 1464 spin_lock_irq(&chip->reg_lock);
1473 oval = snd_ymfpci_readl(chip, reg); 1465 oval = snd_ymfpci_readl(chip, reg);
@@ -1487,14 +1479,13 @@ static int snd_ymfpci_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
1487static int snd_ymfpci_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 1479static int snd_ymfpci_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
1488{ 1480{
1489 unsigned int reg = kcontrol->private_value; 1481 unsigned int reg = kcontrol->private_value;
1490 unsigned int mask = 16383;
1491 1482
1492 if (reg < 0x80 || reg >= 0xc0) 1483 if (reg < 0x80 || reg >= 0xc0)
1493 return -EINVAL; 1484 return -EINVAL;
1494 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; 1485 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1495 uinfo->count = 2; 1486 uinfo->count = 2;
1496 uinfo->value.integer.min = 0; 1487 uinfo->value.integer.min = 0;
1497 uinfo->value.integer.max = mask; 1488 uinfo->value.integer.max = 16383;
1498 return 0; 1489 return 0;
1499} 1490}
1500 1491
@@ -1502,7 +1493,7 @@ static int snd_ymfpci_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
1502{ 1493{
1503 ymfpci_t *chip = snd_kcontrol_chip(kcontrol); 1494 ymfpci_t *chip = snd_kcontrol_chip(kcontrol);
1504 unsigned int reg = kcontrol->private_value; 1495 unsigned int reg = kcontrol->private_value;
1505 unsigned int shift_left = 0, shift_right = 16, mask = 16383, invert = 0; 1496 unsigned int shift_left = 0, shift_right = 16, mask = 16383;
1506 unsigned int val; 1497 unsigned int val;
1507 1498
1508 if (reg < 0x80 || reg >= 0xc0) 1499 if (reg < 0x80 || reg >= 0xc0)
@@ -1512,10 +1503,6 @@ static int snd_ymfpci_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
1512 spin_unlock_irq(&chip->reg_lock); 1503 spin_unlock_irq(&chip->reg_lock);
1513 ucontrol->value.integer.value[0] = (val >> shift_left) & mask; 1504 ucontrol->value.integer.value[0] = (val >> shift_left) & mask;
1514 ucontrol->value.integer.value[1] = (val >> shift_right) & mask; 1505 ucontrol->value.integer.value[1] = (val >> shift_right) & mask;
1515 if (invert) {
1516 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
1517 ucontrol->value.integer.value[1] = mask - ucontrol->value.integer.value[1];
1518 }
1519 return 0; 1506 return 0;
1520} 1507}
1521 1508
@@ -1523,7 +1510,7 @@ static int snd_ymfpci_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
1523{ 1510{
1524 ymfpci_t *chip = snd_kcontrol_chip(kcontrol); 1511 ymfpci_t *chip = snd_kcontrol_chip(kcontrol);
1525 unsigned int reg = kcontrol->private_value; 1512 unsigned int reg = kcontrol->private_value;
1526 unsigned int shift_left = 0, shift_right = 16, mask = 16383, invert = 0; 1513 unsigned int shift_left = 0, shift_right = 16, mask = 16383;
1527 int change; 1514 int change;
1528 unsigned int val1, val2, oval; 1515 unsigned int val1, val2, oval;
1529 1516
@@ -1531,10 +1518,6 @@ static int snd_ymfpci_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
1531 return -EINVAL; 1518 return -EINVAL;
1532 val1 = ucontrol->value.integer.value[0] & mask; 1519 val1 = ucontrol->value.integer.value[0] & mask;
1533 val2 = ucontrol->value.integer.value[1] & mask; 1520 val2 = ucontrol->value.integer.value[1] & mask;
1534 if (invert) {
1535 val1 = mask - val1;
1536 val2 = mask - val2;
1537 }
1538 val1 <<= shift_left; 1521 val1 <<= shift_left;
1539 val2 <<= shift_right; 1522 val2 <<= shift_right;
1540 spin_lock_irq(&chip->reg_lock); 1523 spin_lock_irq(&chip->reg_lock);
diff --git a/sound/pcmcia/vx/vx_entry.c b/sound/pcmcia/vx/vx_entry.c
index 53d8172c52ae..332bbca3dfc4 100644
--- a/sound/pcmcia/vx/vx_entry.c
+++ b/sound/pcmcia/vx/vx_entry.c
@@ -68,8 +68,7 @@ static int snd_vxpocket_free(vx_core_t *chip)
68 if (hw) 68 if (hw)
69 hw->card_list[vxp->index] = NULL; 69 hw->card_list[vxp->index] = NULL;
70 chip->card = NULL; 70 chip->card = NULL;
71 if (chip->dev) 71 kfree(chip->dev);
72 kfree(chip->dev);
73 72
74 snd_vx_free_firmware(chip); 73 snd_vx_free_firmware(chip);
75 kfree(chip); 74 kfree(chip);
diff --git a/sound/synth/emux/emux_effect.c b/sound/synth/emux/emux_effect.c
index ec3fc1ba7fca..4764940f11a0 100644
--- a/sound/synth/emux/emux_effect.c
+++ b/sound/synth/emux/emux_effect.c
@@ -291,10 +291,8 @@ snd_emux_create_effect(snd_emux_port_t *p)
291void 291void
292snd_emux_delete_effect(snd_emux_port_t *p) 292snd_emux_delete_effect(snd_emux_port_t *p)
293{ 293{
294 if (p->effect) { 294 kfree(p->effect);
295 kfree(p->effect); 295 p->effect = NULL;
296 p->effect = NULL;
297 }
298} 296}
299 297
300void 298void
diff --git a/sound/usb/Kconfig b/sound/usb/Kconfig
index 9329e992c841..f05d02f5b69f 100644
--- a/sound/usb/Kconfig
+++ b/sound/usb/Kconfig
@@ -6,6 +6,7 @@ menu "USB devices"
6config SND_USB_AUDIO 6config SND_USB_AUDIO
7 tristate "USB Audio/MIDI driver" 7 tristate "USB Audio/MIDI driver"
8 depends on SND && USB 8 depends on SND && USB
9 select SND_HWDEP
9 select SND_RAWMIDI 10 select SND_RAWMIDI
10 select SND_PCM 11 select SND_PCM
11 help 12 help
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index aae66144d411..a75695045f29 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -98,7 +98,7 @@ MODULE_PARM_DESC(async_unlink, "Use async unlink mode.");
98#define MAX_PACKS 10 98#define MAX_PACKS 10
99#define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */ 99#define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */
100#define MAX_URBS 5 /* max. 20ms long packets */ 100#define MAX_URBS 5 /* max. 20ms long packets */
101#define SYNC_URBS 2 /* always two urbs for sync */ 101#define SYNC_URBS 4 /* always four urbs for sync */
102#define MIN_PACKS_URB 1 /* minimum 1 packet per urb */ 102#define MIN_PACKS_URB 1 /* minimum 1 packet per urb */
103 103
104typedef struct snd_usb_substream snd_usb_substream_t; 104typedef struct snd_usb_substream snd_usb_substream_t;
@@ -177,7 +177,7 @@ struct snd_usb_substream {
177 unsigned int nurbs; /* # urbs */ 177 unsigned int nurbs; /* # urbs */
178 snd_urb_ctx_t dataurb[MAX_URBS]; /* data urb table */ 178 snd_urb_ctx_t dataurb[MAX_URBS]; /* data urb table */
179 snd_urb_ctx_t syncurb[SYNC_URBS]; /* sync urb table */ 179 snd_urb_ctx_t syncurb[SYNC_URBS]; /* sync urb table */
180 char syncbuf[SYNC_URBS * MAX_PACKS * 4]; /* sync buffer; it's so small - let's get static */ 180 char syncbuf[SYNC_URBS * 4]; /* sync buffer; it's so small - let's get static */
181 char *tmpbuf; /* temporary buffer for playback */ 181 char *tmpbuf; /* temporary buffer for playback */
182 182
183 u64 formats; /* format bitmasks (all or'ed) */ 183 u64 formats; /* format bitmasks (all or'ed) */
@@ -251,17 +251,13 @@ static int prepare_capture_sync_urb(snd_usb_substream_t *subs,
251{ 251{
252 unsigned char *cp = urb->transfer_buffer; 252 unsigned char *cp = urb->transfer_buffer;
253 snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; 253 snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context;
254 int i, offs;
255 254
256 urb->number_of_packets = ctx->packets;
257 urb->dev = ctx->subs->dev; /* we need to set this at each time */ 255 urb->dev = ctx->subs->dev; /* we need to set this at each time */
258 for (i = offs = 0; i < urb->number_of_packets; i++, offs += 4, cp += 4) { 256 urb->iso_frame_desc[0].length = 3;
259 urb->iso_frame_desc[i].length = 3; 257 urb->iso_frame_desc[0].offset = 0;
260 urb->iso_frame_desc[i].offset = offs; 258 cp[0] = subs->freqn >> 2;
261 cp[0] = subs->freqn >> 2; 259 cp[1] = subs->freqn >> 10;
262 cp[1] = subs->freqn >> 10; 260 cp[2] = subs->freqn >> 18;
263 cp[2] = subs->freqn >> 18;
264 }
265 return 0; 261 return 0;
266} 262}
267 263
@@ -277,18 +273,14 @@ static int prepare_capture_sync_urb_hs(snd_usb_substream_t *subs,
277{ 273{
278 unsigned char *cp = urb->transfer_buffer; 274 unsigned char *cp = urb->transfer_buffer;
279 snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; 275 snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context;
280 int i, offs;
281 276
282 urb->number_of_packets = ctx->packets;
283 urb->dev = ctx->subs->dev; /* we need to set this at each time */ 277 urb->dev = ctx->subs->dev; /* we need to set this at each time */
284 for (i = offs = 0; i < urb->number_of_packets; i++, offs += 4, cp += 4) { 278 urb->iso_frame_desc[0].length = 4;
285 urb->iso_frame_desc[i].length = 4; 279 urb->iso_frame_desc[0].offset = 0;
286 urb->iso_frame_desc[i].offset = offs; 280 cp[0] = subs->freqn;
287 cp[0] = subs->freqn; 281 cp[1] = subs->freqn >> 8;
288 cp[1] = subs->freqn >> 8; 282 cp[2] = subs->freqn >> 16;
289 cp[2] = subs->freqn >> 16; 283 cp[3] = subs->freqn >> 24;
290 cp[3] = subs->freqn >> 24;
291 }
292 return 0; 284 return 0;
293} 285}
294 286
@@ -418,15 +410,11 @@ static int prepare_playback_sync_urb(snd_usb_substream_t *subs,
418 snd_pcm_runtime_t *runtime, 410 snd_pcm_runtime_t *runtime,
419 struct urb *urb) 411 struct urb *urb)
420{ 412{
421 int i, offs;
422 snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; 413 snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context;
423 414
424 urb->number_of_packets = ctx->packets;
425 urb->dev = ctx->subs->dev; /* we need to set this at each time */ 415 urb->dev = ctx->subs->dev; /* we need to set this at each time */
426 for (i = offs = 0; i < urb->number_of_packets; i++, offs += 4) { 416 urb->iso_frame_desc[0].length = 3;
427 urb->iso_frame_desc[i].length = 3; 417 urb->iso_frame_desc[0].offset = 0;
428 urb->iso_frame_desc[i].offset = offs;
429 }
430 return 0; 418 return 0;
431} 419}
432 420
@@ -440,15 +428,11 @@ static int prepare_playback_sync_urb_hs(snd_usb_substream_t *subs,
440 snd_pcm_runtime_t *runtime, 428 snd_pcm_runtime_t *runtime,
441 struct urb *urb) 429 struct urb *urb)
442{ 430{
443 int i, offs;
444 snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; 431 snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context;
445 432
446 urb->number_of_packets = ctx->packets;
447 urb->dev = ctx->subs->dev; /* we need to set this at each time */ 433 urb->dev = ctx->subs->dev; /* we need to set this at each time */
448 for (i = offs = 0; i < urb->number_of_packets; i++, offs += 4) { 434 urb->iso_frame_desc[0].length = 4;
449 urb->iso_frame_desc[i].length = 4; 435 urb->iso_frame_desc[0].offset = 0;
450 urb->iso_frame_desc[i].offset = offs;
451 }
452 return 0; 436 return 0;
453} 437}
454 438
@@ -462,31 +446,17 @@ static int retire_playback_sync_urb(snd_usb_substream_t *subs,
462 snd_pcm_runtime_t *runtime, 446 snd_pcm_runtime_t *runtime,
463 struct urb *urb) 447 struct urb *urb)
464{ 448{
465 int i; 449 unsigned int f;
466 unsigned int f, found;
467 unsigned char *cp = urb->transfer_buffer;
468 unsigned long flags; 450 unsigned long flags;
469 451
470 found = 0; 452 if (urb->iso_frame_desc[0].status == 0 &&
471 for (i = 0; i < urb->number_of_packets; i++, cp += 4) { 453 urb->iso_frame_desc[0].actual_length == 3) {
472 if (urb->iso_frame_desc[i].status || 454 f = combine_triple((u8*)urb->transfer_buffer) << 2;
473 urb->iso_frame_desc[i].actual_length < 3) 455 if (f >= subs->freqn - subs->freqn / 8 && f <= subs->freqmax) {
474 continue; 456 spin_lock_irqsave(&subs->lock, flags);
475 f = combine_triple(cp) << 2; 457 subs->freqm = f;
476#if 0 458 spin_unlock_irqrestore(&subs->lock, flags);
477 if (f < subs->freqn - (subs->freqn>>3) || f > subs->freqmax) {
478 snd_printd(KERN_WARNING "requested frequency %d (%u,%03uHz) out of range (current nominal %d (%u,%03uHz))\n",
479 f, f >> 14, (f & ((1 << 14) - 1) * 1000) / ((1 << 14) - 1),
480 subs->freqn, subs->freqn >> 14, (subs->freqn & ((1 << 14) - 1) * 1000) / ((1 << 14) - 1));
481 continue;
482 } 459 }
483#endif
484 found = f;
485 }
486 if (found) {
487 spin_lock_irqsave(&subs->lock, flags);
488 subs->freqm = found;
489 spin_unlock_irqrestore(&subs->lock, flags);
490 } 460 }
491 461
492 return 0; 462 return 0;
@@ -502,22 +472,17 @@ static int retire_playback_sync_urb_hs(snd_usb_substream_t *subs,
502 snd_pcm_runtime_t *runtime, 472 snd_pcm_runtime_t *runtime,
503 struct urb *urb) 473 struct urb *urb)
504{ 474{
505 int i; 475 unsigned int f;
506 unsigned int found;
507 unsigned char *cp = urb->transfer_buffer;
508 unsigned long flags; 476 unsigned long flags;
509 477
510 found = 0; 478 if (urb->iso_frame_desc[0].status == 0 &&
511 for (i = 0; i < urb->number_of_packets; i++, cp += 4) { 479 urb->iso_frame_desc[0].actual_length == 4) {
512 if (urb->iso_frame_desc[i].status || 480 f = combine_quad((u8*)urb->transfer_buffer) & 0x0fffffff;
513 urb->iso_frame_desc[i].actual_length < 4) 481 if (f >= subs->freqn - subs->freqn / 8 && f <= subs->freqmax) {
514 continue; 482 spin_lock_irqsave(&subs->lock, flags);
515 found = combine_quad(cp) & 0x0fffffff; 483 subs->freqm = f;
516 } 484 spin_unlock_irqrestore(&subs->lock, flags);
517 if (found) { 485 }
518 spin_lock_irqsave(&subs->lock, flags);
519 subs->freqm = found;
520 spin_unlock_irqrestore(&subs->lock, flags);
521 } 486 }
522 487
523 return 0; 488 return 0;
@@ -600,6 +565,8 @@ static int prepare_playback_urb(snd_usb_substream_t *subs,
600 /* set the buffer pointer */ 565 /* set the buffer pointer */
601 urb->transfer_buffer = runtime->dma_area + subs->hwptr * stride; 566 urb->transfer_buffer = runtime->dma_area + subs->hwptr * stride;
602 subs->hwptr += offs; 567 subs->hwptr += offs;
568 if (subs->hwptr == runtime->buffer_size)
569 subs->hwptr = 0;
603 } 570 }
604 spin_unlock_irqrestore(&subs->lock, flags); 571 spin_unlock_irqrestore(&subs->lock, flags);
605 urb->transfer_buffer_length = offs * stride; 572 urb->transfer_buffer_length = offs * stride;
@@ -892,10 +859,8 @@ static void release_urb_ctx(snd_urb_ctx_t *u)
892 usb_free_urb(u->urb); 859 usb_free_urb(u->urb);
893 u->urb = NULL; 860 u->urb = NULL;
894 } 861 }
895 if (u->buf) { 862 kfree(u->buf);
896 kfree(u->buf); 863 u->buf = NULL;
897 u->buf = NULL;
898 }
899} 864}
900 865
901/* 866/*
@@ -913,10 +878,8 @@ static void release_substream_urbs(snd_usb_substream_t *subs, int force)
913 release_urb_ctx(&subs->dataurb[i]); 878 release_urb_ctx(&subs->dataurb[i]);
914 for (i = 0; i < SYNC_URBS; i++) 879 for (i = 0; i < SYNC_URBS; i++)
915 release_urb_ctx(&subs->syncurb[i]); 880 release_urb_ctx(&subs->syncurb[i]);
916 if (subs->tmpbuf) { 881 kfree(subs->tmpbuf);
917 kfree(subs->tmpbuf); 882 subs->tmpbuf = NULL;
918 subs->tmpbuf = NULL;
919 }
920 subs->nurbs = 0; 883 subs->nurbs = 0;
921} 884}
922 885
@@ -1039,22 +1002,19 @@ static int init_substream_urbs(snd_usb_substream_t *subs, unsigned int period_by
1039 snd_urb_ctx_t *u = &subs->syncurb[i]; 1002 snd_urb_ctx_t *u = &subs->syncurb[i];
1040 u->index = i; 1003 u->index = i;
1041 u->subs = subs; 1004 u->subs = subs;
1042 u->packets = nrpacks; 1005 u->packets = 1;
1043 u->urb = usb_alloc_urb(u->packets, GFP_KERNEL); 1006 u->urb = usb_alloc_urb(1, GFP_KERNEL);
1044 if (! u->urb) { 1007 if (! u->urb) {
1045 release_substream_urbs(subs, 0); 1008 release_substream_urbs(subs, 0);
1046 return -ENOMEM; 1009 return -ENOMEM;
1047 } 1010 }
1048 u->urb->transfer_buffer = subs->syncbuf + i * nrpacks * 4; 1011 u->urb->transfer_buffer = subs->syncbuf + i * 4;
1049 u->urb->transfer_buffer_length = nrpacks * 4; 1012 u->urb->transfer_buffer_length = 4;
1050 u->urb->dev = subs->dev; 1013 u->urb->dev = subs->dev;
1051 u->urb->pipe = subs->syncpipe; 1014 u->urb->pipe = subs->syncpipe;
1052 u->urb->transfer_flags = URB_ISO_ASAP; 1015 u->urb->transfer_flags = URB_ISO_ASAP;
1053 u->urb->number_of_packets = u->packets; 1016 u->urb->number_of_packets = 1;
1054 if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH) 1017 u->urb->interval = 1 << subs->syncinterval;
1055 u->urb->interval = 8;
1056 else
1057 u->urb->interval = 1;
1058 u->urb->context = u; 1018 u->urb->context = u;
1059 u->urb->complete = snd_usb_complete_callback(snd_complete_sync_urb); 1019 u->urb->complete = snd_usb_complete_callback(snd_complete_sync_urb);
1060 } 1020 }
@@ -1272,7 +1232,17 @@ static int set_format(snd_usb_substream_t *subs, struct audioformat *fmt)
1272 subs->syncpipe = usb_rcvisocpipe(dev, ep); 1232 subs->syncpipe = usb_rcvisocpipe(dev, ep);
1273 else 1233 else
1274 subs->syncpipe = usb_sndisocpipe(dev, ep); 1234 subs->syncpipe = usb_sndisocpipe(dev, ep);
1275 subs->syncinterval = get_endpoint(alts, 1)->bRefresh; 1235 if (get_endpoint(alts, 1)->bLength >= USB_DT_ENDPOINT_AUDIO_SIZE &&
1236 get_endpoint(alts, 1)->bRefresh >= 1 &&
1237 get_endpoint(alts, 1)->bRefresh <= 9)
1238 subs->syncinterval = get_endpoint(alts, 1)->bRefresh;
1239 else if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL)
1240 subs->syncinterval = 1;
1241 else if (get_endpoint(alts, 1)->bInterval >= 1 &&
1242 get_endpoint(alts, 1)->bInterval <= 16)
1243 subs->syncinterval = get_endpoint(alts, 1)->bInterval - 1;
1244 else
1245 subs->syncinterval = 3;
1276 } 1246 }
1277 1247
1278 /* always fill max packet size */ 1248 /* always fill max packet size */
@@ -1990,10 +1960,11 @@ static void proc_dump_substream_status(snd_usb_substream_t *subs, snd_info_buffe
1990 snd_iprintf(buffer, "%d ", subs->dataurb[i].packets); 1960 snd_iprintf(buffer, "%d ", subs->dataurb[i].packets);
1991 snd_iprintf(buffer, "]\n"); 1961 snd_iprintf(buffer, "]\n");
1992 snd_iprintf(buffer, " Packet Size = %d\n", subs->curpacksize); 1962 snd_iprintf(buffer, " Packet Size = %d\n", subs->curpacksize);
1993 snd_iprintf(buffer, " Momentary freq = %u Hz\n", 1963 snd_iprintf(buffer, " Momentary freq = %u Hz (%#x.%04x)\n",
1994 snd_usb_get_speed(subs->dev) == USB_SPEED_FULL 1964 snd_usb_get_speed(subs->dev) == USB_SPEED_FULL
1995 ? get_full_speed_hz(subs->freqm) 1965 ? get_full_speed_hz(subs->freqm)
1996 : get_high_speed_hz(subs->freqm)); 1966 : get_high_speed_hz(subs->freqm),
1967 subs->freqm >> 16, subs->freqm & 0xffff);
1997 } else { 1968 } else {
1998 snd_iprintf(buffer, " Status: Stop\n"); 1969 snd_iprintf(buffer, " Status: Stop\n");
1999 } 1970 }
@@ -2183,17 +2154,15 @@ static int add_audio_endpoint(snd_usb_audio_t *chip, int stream, struct audiofor
2183/* 2154/*
2184 * check if the device uses big-endian samples 2155 * check if the device uses big-endian samples
2185 */ 2156 */
2186static int is_big_endian_format(struct usb_device *dev, struct audioformat *fp) 2157static int is_big_endian_format(snd_usb_audio_t *chip, struct audioformat *fp)
2187{ 2158{
2188 /* M-Audio */ 2159 switch (chip->usb_id) {
2189 if (le16_to_cpu(dev->descriptor.idVendor) == 0x0763) { 2160 case USB_ID(0x0763, 0x2001): /* M-Audio Quattro: captured data only */
2190 /* Quattro: captured data only */ 2161 if (fp->endpoint & USB_DIR_IN)
2191 if (le16_to_cpu(dev->descriptor.idProduct) == 0x2001 &&
2192 fp->endpoint & USB_DIR_IN)
2193 return 1;
2194 /* Audiophile USB */
2195 if (le16_to_cpu(dev->descriptor.idProduct) == 0x2003)
2196 return 1; 2162 return 1;
2163 break;
2164 case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
2165 return 1;
2197 } 2166 }
2198 return 0; 2167 return 0;
2199} 2168}
@@ -2207,7 +2176,7 @@ static int is_big_endian_format(struct usb_device *dev, struct audioformat *fp)
2207 * @format: the format tag (wFormatTag) 2176 * @format: the format tag (wFormatTag)
2208 * @fmt: the format type descriptor 2177 * @fmt: the format type descriptor
2209 */ 2178 */
2210static int parse_audio_format_i_type(struct usb_device *dev, struct audioformat *fp, 2179static int parse_audio_format_i_type(snd_usb_audio_t *chip, struct audioformat *fp,
2211 int format, unsigned char *fmt) 2180 int format, unsigned char *fmt)
2212{ 2181{
2213 int pcm_format; 2182 int pcm_format;
@@ -2220,12 +2189,12 @@ static int parse_audio_format_i_type(struct usb_device *dev, struct audioformat
2220 switch (format) { 2189 switch (format) {
2221 case 0: /* some devices don't define this correctly... */ 2190 case 0: /* some devices don't define this correctly... */
2222 snd_printdd(KERN_INFO "%d:%u:%d : format type 0 is detected, processed as PCM\n", 2191 snd_printdd(KERN_INFO "%d:%u:%d : format type 0 is detected, processed as PCM\n",
2223 dev->devnum, fp->iface, fp->altsetting); 2192 chip->dev->devnum, fp->iface, fp->altsetting);
2224 /* fall-through */ 2193 /* fall-through */
2225 case USB_AUDIO_FORMAT_PCM: 2194 case USB_AUDIO_FORMAT_PCM:
2226 if (sample_width > sample_bytes * 8) { 2195 if (sample_width > sample_bytes * 8) {
2227 snd_printk(KERN_INFO "%d:%u:%d : sample bitwidth %d in over sample bytes %d\n", 2196 snd_printk(KERN_INFO "%d:%u:%d : sample bitwidth %d in over sample bytes %d\n",
2228 dev->devnum, fp->iface, fp->altsetting, 2197 chip->dev->devnum, fp->iface, fp->altsetting,
2229 sample_width, sample_bytes); 2198 sample_width, sample_bytes);
2230 } 2199 }
2231 /* check the format byte size */ 2200 /* check the format byte size */
@@ -2234,13 +2203,13 @@ static int parse_audio_format_i_type(struct usb_device *dev, struct audioformat
2234 pcm_format = SNDRV_PCM_FORMAT_S8; 2203 pcm_format = SNDRV_PCM_FORMAT_S8;
2235 break; 2204 break;
2236 case 2: 2205 case 2:
2237 if (is_big_endian_format(dev, fp)) 2206 if (is_big_endian_format(chip, fp))
2238 pcm_format = SNDRV_PCM_FORMAT_S16_BE; /* grrr, big endian!! */ 2207 pcm_format = SNDRV_PCM_FORMAT_S16_BE; /* grrr, big endian!! */
2239 else 2208 else
2240 pcm_format = SNDRV_PCM_FORMAT_S16_LE; 2209 pcm_format = SNDRV_PCM_FORMAT_S16_LE;
2241 break; 2210 break;
2242 case 3: 2211 case 3:
2243 if (is_big_endian_format(dev, fp)) 2212 if (is_big_endian_format(chip, fp))
2244 pcm_format = SNDRV_PCM_FORMAT_S24_3BE; /* grrr, big endian!! */ 2213 pcm_format = SNDRV_PCM_FORMAT_S24_3BE; /* grrr, big endian!! */
2245 else 2214 else
2246 pcm_format = SNDRV_PCM_FORMAT_S24_3LE; 2215 pcm_format = SNDRV_PCM_FORMAT_S24_3LE;
@@ -2250,14 +2219,14 @@ static int parse_audio_format_i_type(struct usb_device *dev, struct audioformat
2250 break; 2219 break;
2251 default: 2220 default:
2252 snd_printk(KERN_INFO "%d:%u:%d : unsupported sample bitwidth %d in %d bytes\n", 2221 snd_printk(KERN_INFO "%d:%u:%d : unsupported sample bitwidth %d in %d bytes\n",
2253 dev->devnum, fp->iface, fp->altsetting, sample_width, sample_bytes); 2222 chip->dev->devnum, fp->iface,
2223 fp->altsetting, sample_width, sample_bytes);
2254 break; 2224 break;
2255 } 2225 }
2256 break; 2226 break;
2257 case USB_AUDIO_FORMAT_PCM8: 2227 case USB_AUDIO_FORMAT_PCM8:
2258 /* Dallas DS4201 workaround */ 2228 /* Dallas DS4201 workaround */
2259 if (le16_to_cpu(dev->descriptor.idVendor) == 0x04fa && 2229 if (chip->usb_id == USB_ID(0x04fa, 0x4201))
2260 le16_to_cpu(dev->descriptor.idProduct) == 0x4201)
2261 pcm_format = SNDRV_PCM_FORMAT_S8; 2230 pcm_format = SNDRV_PCM_FORMAT_S8;
2262 else 2231 else
2263 pcm_format = SNDRV_PCM_FORMAT_U8; 2232 pcm_format = SNDRV_PCM_FORMAT_U8;
@@ -2273,7 +2242,7 @@ static int parse_audio_format_i_type(struct usb_device *dev, struct audioformat
2273 break; 2242 break;
2274 default: 2243 default:
2275 snd_printk(KERN_INFO "%d:%u:%d : unsupported format type %d\n", 2244 snd_printk(KERN_INFO "%d:%u:%d : unsupported format type %d\n",
2276 dev->devnum, fp->iface, fp->altsetting, format); 2245 chip->dev->devnum, fp->iface, fp->altsetting, format);
2277 break; 2246 break;
2278 } 2247 }
2279 return pcm_format; 2248 return pcm_format;
@@ -2290,13 +2259,13 @@ static int parse_audio_format_i_type(struct usb_device *dev, struct audioformat
2290 * @offset: the start offset of descriptor pointing the rate type 2259 * @offset: the start offset of descriptor pointing the rate type
2291 * (7 for type I and II, 8 for type II) 2260 * (7 for type I and II, 8 for type II)
2292 */ 2261 */
2293static int parse_audio_format_rates(struct usb_device *dev, struct audioformat *fp, 2262static int parse_audio_format_rates(snd_usb_audio_t *chip, struct audioformat *fp,
2294 unsigned char *fmt, int offset) 2263 unsigned char *fmt, int offset)
2295{ 2264{
2296 int nr_rates = fmt[offset]; 2265 int nr_rates = fmt[offset];
2297 if (fmt[0] < offset + 1 + 3 * (nr_rates ? nr_rates : 2)) { 2266 if (fmt[0] < offset + 1 + 3 * (nr_rates ? nr_rates : 2)) {
2298 snd_printk(KERN_ERR "%d:%u:%d : invalid FORMAT_TYPE desc\n", 2267 snd_printk(KERN_ERR "%d:%u:%d : invalid FORMAT_TYPE desc\n",
2299 dev->devnum, fp->iface, fp->altsetting); 2268 chip->dev->devnum, fp->iface, fp->altsetting);
2300 return -1; 2269 return -1;
2301 } 2270 }
2302 2271
@@ -2343,7 +2312,7 @@ static int parse_audio_format_rates(struct usb_device *dev, struct audioformat *
2343/* 2312/*
2344 * parse the format type I and III descriptors 2313 * parse the format type I and III descriptors
2345 */ 2314 */
2346static int parse_audio_format_i(struct usb_device *dev, struct audioformat *fp, 2315static int parse_audio_format_i(snd_usb_audio_t *chip, struct audioformat *fp,
2347 int format, unsigned char *fmt) 2316 int format, unsigned char *fmt)
2348{ 2317{
2349 int pcm_format; 2318 int pcm_format;
@@ -2355,7 +2324,7 @@ static int parse_audio_format_i(struct usb_device *dev, struct audioformat *fp,
2355 */ 2324 */
2356 pcm_format = SNDRV_PCM_FORMAT_S16_LE; 2325 pcm_format = SNDRV_PCM_FORMAT_S16_LE;
2357 } else { 2326 } else {
2358 pcm_format = parse_audio_format_i_type(dev, fp, format, fmt); 2327 pcm_format = parse_audio_format_i_type(chip, fp, format, fmt);
2359 if (pcm_format < 0) 2328 if (pcm_format < 0)
2360 return -1; 2329 return -1;
2361 } 2330 }
@@ -2363,16 +2332,16 @@ static int parse_audio_format_i(struct usb_device *dev, struct audioformat *fp,
2363 fp->channels = fmt[4]; 2332 fp->channels = fmt[4];
2364 if (fp->channels < 1) { 2333 if (fp->channels < 1) {
2365 snd_printk(KERN_ERR "%d:%u:%d : invalid channels %d\n", 2334 snd_printk(KERN_ERR "%d:%u:%d : invalid channels %d\n",
2366 dev->devnum, fp->iface, fp->altsetting, fp->channels); 2335 chip->dev->devnum, fp->iface, fp->altsetting, fp->channels);
2367 return -1; 2336 return -1;
2368 } 2337 }
2369 return parse_audio_format_rates(dev, fp, fmt, 7); 2338 return parse_audio_format_rates(chip, fp, fmt, 7);
2370} 2339}
2371 2340
2372/* 2341/*
2373 * prase the format type II descriptor 2342 * prase the format type II descriptor
2374 */ 2343 */
2375static int parse_audio_format_ii(struct usb_device *dev, struct audioformat *fp, 2344static int parse_audio_format_ii(snd_usb_audio_t *chip, struct audioformat *fp,
2376 int format, unsigned char *fmt) 2345 int format, unsigned char *fmt)
2377{ 2346{
2378 int brate, framesize; 2347 int brate, framesize;
@@ -2387,7 +2356,7 @@ static int parse_audio_format_ii(struct usb_device *dev, struct audioformat *fp,
2387 break; 2356 break;
2388 default: 2357 default:
2389 snd_printd(KERN_INFO "%d:%u:%d : unknown format tag 0x%x is detected. processed as MPEG.\n", 2358 snd_printd(KERN_INFO "%d:%u:%d : unknown format tag 0x%x is detected. processed as MPEG.\n",
2390 dev->devnum, fp->iface, fp->altsetting, format); 2359 chip->dev->devnum, fp->iface, fp->altsetting, format);
2391 fp->format = SNDRV_PCM_FORMAT_MPEG; 2360 fp->format = SNDRV_PCM_FORMAT_MPEG;
2392 break; 2361 break;
2393 } 2362 }
@@ -2396,10 +2365,10 @@ static int parse_audio_format_ii(struct usb_device *dev, struct audioformat *fp,
2396 framesize = combine_word(&fmt[6]); /* fmt[6,7]: wSamplesPerFrame */ 2365 framesize = combine_word(&fmt[6]); /* fmt[6,7]: wSamplesPerFrame */
2397 snd_printd(KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize); 2366 snd_printd(KERN_INFO "found format II with max.bitrate = %d, frame size=%d\n", brate, framesize);
2398 fp->frame_size = framesize; 2367 fp->frame_size = framesize;
2399 return parse_audio_format_rates(dev, fp, fmt, 8); /* fmt[8..] sample rates */ 2368 return parse_audio_format_rates(chip, fp, fmt, 8); /* fmt[8..] sample rates */
2400} 2369}
2401 2370
2402static int parse_audio_format(struct usb_device *dev, struct audioformat *fp, 2371static int parse_audio_format(snd_usb_audio_t *chip, struct audioformat *fp,
2403 int format, unsigned char *fmt, int stream) 2372 int format, unsigned char *fmt, int stream)
2404{ 2373{
2405 int err; 2374 int err;
@@ -2407,29 +2376,30 @@ static int parse_audio_format(struct usb_device *dev, struct audioformat *fp,
2407 switch (fmt[3]) { 2376 switch (fmt[3]) {
2408 case USB_FORMAT_TYPE_I: 2377 case USB_FORMAT_TYPE_I:
2409 case USB_FORMAT_TYPE_III: 2378 case USB_FORMAT_TYPE_III:
2410 err = parse_audio_format_i(dev, fp, format, fmt); 2379 err = parse_audio_format_i(chip, fp, format, fmt);
2411 break; 2380 break;
2412 case USB_FORMAT_TYPE_II: 2381 case USB_FORMAT_TYPE_II:
2413 err = parse_audio_format_ii(dev, fp, format, fmt); 2382 err = parse_audio_format_ii(chip, fp, format, fmt);
2414 break; 2383 break;
2415 default: 2384 default:
2416 snd_printd(KERN_INFO "%d:%u:%d : format type %d is not supported yet\n", 2385 snd_printd(KERN_INFO "%d:%u:%d : format type %d is not supported yet\n",
2417 dev->devnum, fp->iface, fp->altsetting, fmt[3]); 2386 chip->dev->devnum, fp->iface, fp->altsetting, fmt[3]);
2418 return -1; 2387 return -1;
2419 } 2388 }
2420 fp->fmt_type = fmt[3]; 2389 fp->fmt_type = fmt[3];
2421 if (err < 0) 2390 if (err < 0)
2422 return err; 2391 return err;
2423#if 1 2392#if 1
2424 /* FIXME: temporary hack for extigy */ 2393 /* FIXME: temporary hack for extigy/audigy 2 nx */
2425 /* extigy apparently supports sample rates other than 48k 2394 /* extigy apparently supports sample rates other than 48k
2426 * but not in ordinary way. so we enable only 48k atm. 2395 * but not in ordinary way. so we enable only 48k atm.
2427 */ 2396 */
2428 if (le16_to_cpu(dev->descriptor.idVendor) == 0x041e && 2397 if (chip->usb_id == USB_ID(0x041e, 0x3000) ||
2429 le16_to_cpu(dev->descriptor.idProduct) == 0x3000) { 2398 chip->usb_id == USB_ID(0x041e, 0x3020)) {
2430 if (fmt[3] == USB_FORMAT_TYPE_I && 2399 if (fmt[3] == USB_FORMAT_TYPE_I &&
2431 stream == SNDRV_PCM_STREAM_PLAYBACK && 2400 stream == SNDRV_PCM_STREAM_PLAYBACK &&
2432 fp->rates != SNDRV_PCM_RATE_48000) 2401 fp->rates != SNDRV_PCM_RATE_48000 &&
2402 fp->rates != SNDRV_PCM_RATE_96000)
2433 return -1; /* use 48k only */ 2403 return -1; /* use 48k only */
2434 } 2404 }
2435#endif 2405#endif
@@ -2528,40 +2498,35 @@ static int parse_audio_endpoints(snd_usb_audio_t *chip, int iface_no)
2528 2498
2529 /* some quirks for attributes here */ 2499 /* some quirks for attributes here */
2530 2500
2531 /* workaround for AudioTrak Optoplay */ 2501 switch (chip->usb_id) {
2532 if (le16_to_cpu(dev->descriptor.idVendor) == 0x0a92 && 2502 case USB_ID(0x0a92, 0x0053): /* AudioTrak Optoplay */
2533 le16_to_cpu(dev->descriptor.idProduct) == 0x0053) {
2534 /* Optoplay sets the sample rate attribute although 2503 /* Optoplay sets the sample rate attribute although
2535 * it seems not supporting it in fact. 2504 * it seems not supporting it in fact.
2536 */ 2505 */
2537 fp->attributes &= ~EP_CS_ATTR_SAMPLE_RATE; 2506 fp->attributes &= ~EP_CS_ATTR_SAMPLE_RATE;
2538 } 2507 break;
2539 2508 case USB_ID(0x041e, 0x3020): /* Creative SB Audigy 2 NX */
2540 /* workaround for M-Audio Audiophile USB */ 2509 case USB_ID(0x0763, 0x2003): /* M-Audio Audiophile USB */
2541 if (le16_to_cpu(dev->descriptor.idVendor) == 0x0763 &&
2542 le16_to_cpu(dev->descriptor.idProduct) == 0x2003) {
2543 /* doesn't set the sample rate attribute, but supports it */ 2510 /* doesn't set the sample rate attribute, but supports it */
2544 fp->attributes |= EP_CS_ATTR_SAMPLE_RATE; 2511 fp->attributes |= EP_CS_ATTR_SAMPLE_RATE;
2545 } 2512 break;
2546 2513 case USB_ID(0x047f, 0x0ca1): /* plantronics headset */
2514 case USB_ID(0x077d, 0x07af): /* Griffin iMic (note that there is
2515 an older model 77d:223) */
2547 /* 2516 /*
2548 * plantronics headset and Griffin iMic have set adaptive-in 2517 * plantronics headset and Griffin iMic have set adaptive-in
2549 * although it's really not... 2518 * although it's really not...
2550 */ 2519 */
2551 if ((le16_to_cpu(dev->descriptor.idVendor) == 0x047f &&
2552 le16_to_cpu(dev->descriptor.idProduct) == 0x0ca1) ||
2553 /* Griffin iMic (note that there is an older model 77d:223) */
2554 (le16_to_cpu(dev->descriptor.idVendor) == 0x077d &&
2555 le16_to_cpu(dev->descriptor.idProduct) == 0x07af)) {
2556 fp->ep_attr &= ~EP_ATTR_MASK; 2520 fp->ep_attr &= ~EP_ATTR_MASK;
2557 if (stream == SNDRV_PCM_STREAM_PLAYBACK) 2521 if (stream == SNDRV_PCM_STREAM_PLAYBACK)
2558 fp->ep_attr |= EP_ATTR_ADAPTIVE; 2522 fp->ep_attr |= EP_ATTR_ADAPTIVE;
2559 else 2523 else
2560 fp->ep_attr |= EP_ATTR_SYNC; 2524 fp->ep_attr |= EP_ATTR_SYNC;
2525 break;
2561 } 2526 }
2562 2527
2563 /* ok, let's parse further... */ 2528 /* ok, let's parse further... */
2564 if (parse_audio_format(dev, fp, format, fmt, stream) < 0) { 2529 if (parse_audio_format(chip, fp, format, fmt, stream) < 0) {
2565 kfree(fp->rate_table); 2530 kfree(fp->rate_table);
2566 kfree(fp); 2531 kfree(fp);
2567 continue; 2532 continue;
@@ -2587,7 +2552,7 @@ static int parse_audio_endpoints(snd_usb_audio_t *chip, int iface_no)
2587 * disconnect streams 2552 * disconnect streams
2588 * called from snd_usb_audio_disconnect() 2553 * called from snd_usb_audio_disconnect()
2589 */ 2554 */
2590static void snd_usb_stream_disconnect(struct list_head *head, struct usb_driver *driver) 2555static void snd_usb_stream_disconnect(struct list_head *head)
2591{ 2556{
2592 int idx; 2557 int idx;
2593 snd_usb_stream_t *as; 2558 snd_usb_stream_t *as;
@@ -2796,7 +2761,7 @@ static int create_ua700_ua25_quirk(snd_usb_audio_t *chip,
2796 .type = QUIRK_MIDI_FIXED_ENDPOINT, 2761 .type = QUIRK_MIDI_FIXED_ENDPOINT,
2797 .data = &ua25_ep 2762 .data = &ua25_ep
2798 }; 2763 };
2799 if (le16_to_cpu(chip->dev->descriptor.idProduct) == 0x002b) 2764 if (chip->usb_id == USB_ID(0x0582, 0x002b))
2800 return snd_usb_create_midi_interface(chip, iface, 2765 return snd_usb_create_midi_interface(chip, iface,
2801 &ua700_quirk); 2766 &ua700_quirk);
2802 else 2767 else
@@ -2959,6 +2924,25 @@ static int snd_usb_extigy_boot_quirk(struct usb_device *dev, struct usb_interfac
2959 return 0; 2924 return 0;
2960} 2925}
2961 2926
2927static int snd_usb_audigy2nx_boot_quirk(struct usb_device *dev)
2928{
2929#if 0
2930 /* TODO: enable this when high speed synchronization actually works */
2931 u8 buf = 1;
2932
2933 snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), 0x2a,
2934 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER,
2935 0, 0, &buf, 1, 1000);
2936 if (buf == 0) {
2937 snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 0x29,
2938 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
2939 1, 2000, NULL, 0, 1000);
2940 return -ENODEV;
2941 }
2942#endif
2943 return 0;
2944}
2945
2962 2946
2963/* 2947/*
2964 * audio-interface quirks 2948 * audio-interface quirks
@@ -3015,8 +2999,8 @@ static void proc_audio_usbid_read(snd_info_entry_t *entry, snd_info_buffer_t *bu
3015 snd_usb_audio_t *chip = entry->private_data; 2999 snd_usb_audio_t *chip = entry->private_data;
3016 if (! chip->shutdown) 3000 if (! chip->shutdown)
3017 snd_iprintf(buffer, "%04x:%04x\n", 3001 snd_iprintf(buffer, "%04x:%04x\n",
3018 le16_to_cpu(chip->dev->descriptor.idVendor), 3002 USB_ID_VENDOR(chip->usb_id),
3019 le16_to_cpu(chip->dev->descriptor.idProduct)); 3003 USB_ID_PRODUCT(chip->usb_id));
3020} 3004}
3021 3005
3022static void snd_usb_audio_create_proc(snd_usb_audio_t *chip) 3006static void snd_usb_audio_create_proc(snd_usb_audio_t *chip)
@@ -3086,8 +3070,11 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx,
3086 chip->index = idx; 3070 chip->index = idx;
3087 chip->dev = dev; 3071 chip->dev = dev;
3088 chip->card = card; 3072 chip->card = card;
3073 chip->usb_id = USB_ID(le16_to_cpu(dev->descriptor.idVendor),
3074 le16_to_cpu(dev->descriptor.idProduct));
3089 INIT_LIST_HEAD(&chip->pcm_list); 3075 INIT_LIST_HEAD(&chip->pcm_list);
3090 INIT_LIST_HEAD(&chip->midi_list); 3076 INIT_LIST_HEAD(&chip->midi_list);
3077 INIT_LIST_HEAD(&chip->mixer_list);
3091 3078
3092 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { 3079 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
3093 snd_usb_audio_free(chip); 3080 snd_usb_audio_free(chip);
@@ -3097,8 +3084,7 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx,
3097 3084
3098 strcpy(card->driver, "USB-Audio"); 3085 strcpy(card->driver, "USB-Audio");
3099 sprintf(component, "USB%04x:%04x", 3086 sprintf(component, "USB%04x:%04x",
3100 le16_to_cpu(dev->descriptor.idVendor), 3087 USB_ID_VENDOR(chip->usb_id), USB_ID_PRODUCT(chip->usb_id));
3101 le16_to_cpu(dev->descriptor.idProduct));
3102 snd_component_add(card, component); 3088 snd_component_add(card, component);
3103 3089
3104 /* retrieve the device string as shortname */ 3090 /* retrieve the device string as shortname */
@@ -3110,8 +3096,8 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx,
3110 card->shortname, sizeof(card->shortname)) <= 0) { 3096 card->shortname, sizeof(card->shortname)) <= 0) {
3111 /* no name available from anywhere, so use ID */ 3097 /* no name available from anywhere, so use ID */
3112 sprintf(card->shortname, "USB Device %#04x:%#04x", 3098 sprintf(card->shortname, "USB Device %#04x:%#04x",
3113 le16_to_cpu(dev->descriptor.idVendor), 3099 USB_ID_VENDOR(chip->usb_id),
3114 le16_to_cpu(dev->descriptor.idProduct)); 3100 USB_ID_PRODUCT(chip->usb_id));
3115 } 3101 }
3116 } 3102 }
3117 3103
@@ -3142,8 +3128,6 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx,
3142 3128
3143 snd_usb_audio_create_proc(chip); 3129 snd_usb_audio_create_proc(chip);
3144 3130
3145 snd_card_set_dev(card, &dev->dev);
3146
3147 *rchip = chip; 3131 *rchip = chip;
3148 return 0; 3132 return 0;
3149} 3133}
@@ -3169,21 +3153,28 @@ static void *snd_usb_audio_probe(struct usb_device *dev,
3169 snd_usb_audio_t *chip; 3153 snd_usb_audio_t *chip;
3170 struct usb_host_interface *alts; 3154 struct usb_host_interface *alts;
3171 int ifnum; 3155 int ifnum;
3156 u32 id;
3172 3157
3173 alts = &intf->altsetting[0]; 3158 alts = &intf->altsetting[0];
3174 ifnum = get_iface_desc(alts)->bInterfaceNumber; 3159 ifnum = get_iface_desc(alts)->bInterfaceNumber;
3160 id = USB_ID(le16_to_cpu(dev->descriptor.idVendor),
3161 le16_to_cpu(dev->descriptor.idProduct));
3175 3162
3176 if (quirk && quirk->ifnum >= 0 && ifnum != quirk->ifnum) 3163 if (quirk && quirk->ifnum >= 0 && ifnum != quirk->ifnum)
3177 goto __err_val; 3164 goto __err_val;
3178 3165
3179 /* SB Extigy needs special boot-up sequence */ 3166 /* SB Extigy needs special boot-up sequence */
3180 /* if more models come, this will go to the quirk list. */ 3167 /* if more models come, this will go to the quirk list. */
3181 if (le16_to_cpu(dev->descriptor.idVendor) == 0x041e && 3168 if (id == USB_ID(0x041e, 0x3000)) {
3182 le16_to_cpu(dev->descriptor.idProduct) == 0x3000) {
3183 if (snd_usb_extigy_boot_quirk(dev, intf) < 0) 3169 if (snd_usb_extigy_boot_quirk(dev, intf) < 0)
3184 goto __err_val; 3170 goto __err_val;
3185 config = dev->actconfig; 3171 config = dev->actconfig;
3186 } 3172 }
3173 /* SB Audigy 2 NX needs its own boot-up magic, too */
3174 if (id == USB_ID(0x041e, 0x3020)) {
3175 if (snd_usb_audigy2nx_boot_quirk(dev) < 0)
3176 goto __err_val;
3177 }
3187 3178
3188 /* 3179 /*
3189 * found a config. now register to ALSA 3180 * found a config. now register to ALSA
@@ -3213,11 +3204,12 @@ static void *snd_usb_audio_probe(struct usb_device *dev,
3213 } 3204 }
3214 for (i = 0; i < SNDRV_CARDS; i++) 3205 for (i = 0; i < SNDRV_CARDS; i++)
3215 if (enable[i] && ! usb_chip[i] && 3206 if (enable[i] && ! usb_chip[i] &&
3216 (vid[i] == -1 || vid[i] == le16_to_cpu(dev->descriptor.idVendor)) && 3207 (vid[i] == -1 || vid[i] == USB_ID_VENDOR(id)) &&
3217 (pid[i] == -1 || pid[i] == le16_to_cpu(dev->descriptor.idProduct))) { 3208 (pid[i] == -1 || pid[i] == USB_ID_PRODUCT(id))) {
3218 if (snd_usb_audio_create(dev, i, quirk, &chip) < 0) { 3209 if (snd_usb_audio_create(dev, i, quirk, &chip) < 0) {
3219 goto __error; 3210 goto __error;
3220 } 3211 }
3212 snd_card_set_dev(chip->card, &intf->dev);
3221 break; 3213 break;
3222 } 3214 }
3223 if (! chip) { 3215 if (! chip) {
@@ -3281,11 +3273,15 @@ static void snd_usb_audio_disconnect(struct usb_device *dev, void *ptr)
3281 snd_card_disconnect(card); 3273 snd_card_disconnect(card);
3282 /* release the pcm resources */ 3274 /* release the pcm resources */
3283 list_for_each(p, &chip->pcm_list) { 3275 list_for_each(p, &chip->pcm_list) {
3284 snd_usb_stream_disconnect(p, &usb_audio_driver); 3276 snd_usb_stream_disconnect(p);
3285 } 3277 }
3286 /* release the midi resources */ 3278 /* release the midi resources */
3287 list_for_each(p, &chip->midi_list) { 3279 list_for_each(p, &chip->midi_list) {
3288 snd_usbmidi_disconnect(p, &usb_audio_driver); 3280 snd_usbmidi_disconnect(p);
3281 }
3282 /* release mixer resources */
3283 list_for_each(p, &chip->mixer_list) {
3284 snd_usb_mixer_disconnect(p);
3289 } 3285 }
3290 usb_chip[chip->index] = NULL; 3286 usb_chip[chip->index] = NULL;
3291 up(&register_mutex); 3287 up(&register_mutex);
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
index eecbf19fcb6f..aedb42aaa749 100644
--- a/sound/usb/usbaudio.h
+++ b/sound/usb/usbaudio.h
@@ -118,6 +118,11 @@
118/* maximum number of endpoints per interface */ 118/* maximum number of endpoints per interface */
119#define MIDI_MAX_ENDPOINTS 2 119#define MIDI_MAX_ENDPOINTS 2
120 120
121/* handling of USB vendor/product ID pairs as 32-bit numbers */
122#define USB_ID(vendor, product) (((vendor) << 16) | (product))
123#define USB_ID_VENDOR(id) ((id) >> 16)
124#define USB_ID_PRODUCT(id) ((u16)(id))
125
121/* 126/*
122 */ 127 */
123 128
@@ -127,6 +132,7 @@ struct snd_usb_audio {
127 int index; 132 int index;
128 struct usb_device *dev; 133 struct usb_device *dev;
129 snd_card_t *card; 134 snd_card_t *card;
135 u32 usb_id;
130 int shutdown; 136 int shutdown;
131 int num_interfaces; 137 int num_interfaces;
132 138
@@ -136,7 +142,7 @@ struct snd_usb_audio {
136 struct list_head midi_list; /* list of midi interfaces */ 142 struct list_head midi_list; /* list of midi interfaces */
137 int next_midi_device; 143 int next_midi_device;
138 144
139 unsigned int ignore_ctl_error; /* for mixer */ 145 struct list_head mixer_list; /* list of mixer interfaces */
140}; 146};
141 147
142/* 148/*
@@ -219,11 +225,12 @@ void *snd_usb_find_csint_desc(void *descstart, int desclen, void *after, u8 dsub
219int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size, int timeout); 225int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size, int timeout);
220 226
221int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif); 227int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif);
228void snd_usb_mixer_disconnect(struct list_head *p);
222 229
223int snd_usb_create_midi_interface(snd_usb_audio_t *chip, struct usb_interface *iface, const snd_usb_audio_quirk_t *quirk); 230int snd_usb_create_midi_interface(snd_usb_audio_t *chip, struct usb_interface *iface, const snd_usb_audio_quirk_t *quirk);
224void snd_usbmidi_input_stop(struct list_head* p); 231void snd_usbmidi_input_stop(struct list_head* p);
225void snd_usbmidi_input_start(struct list_head* p); 232void snd_usbmidi_input_start(struct list_head* p);
226void snd_usbmidi_disconnect(struct list_head *p, struct usb_driver *driver); 233void snd_usbmidi_disconnect(struct list_head *p);
227 234
228/* 235/*
229 * retrieve usb_interface descriptor from the host interface 236 * retrieve usb_interface descriptor from the host interface
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
index 5d32857ff955..bee70068dce0 100644
--- a/sound/usb/usbmidi.c
+++ b/sound/usb/usbmidi.c
@@ -912,7 +912,7 @@ static void snd_usbmidi_free(snd_usb_midi_t* umidi)
912/* 912/*
913 * Unlinks all URBs (must be done before the usb_device is deleted). 913 * Unlinks all URBs (must be done before the usb_device is deleted).
914 */ 914 */
915void snd_usbmidi_disconnect(struct list_head* p, struct usb_driver *driver) 915void snd_usbmidi_disconnect(struct list_head* p)
916{ 916{
917 snd_usb_midi_t* umidi; 917 snd_usb_midi_t* umidi;
918 int i; 918 int i;
@@ -955,88 +955,87 @@ static snd_rawmidi_substream_t* snd_usbmidi_find_substream(snd_usb_midi_t* umidi
955 * such as internal control or synthesizer ports. 955 * such as internal control or synthesizer ports.
956 */ 956 */
957static struct { 957static struct {
958 __u16 vendor; 958 u32 id;
959 __u16 product;
960 int port; 959 int port;
961 const char *name_format; 960 const char *name_format;
962} snd_usbmidi_port_names[] = { 961} snd_usbmidi_port_names[] = {
963 /* Roland UA-100 */ 962 /* Roland UA-100 */
964 {0x0582, 0x0000, 2, "%s Control"}, 963 { USB_ID(0x0582, 0x0000), 2, "%s Control" },
965 /* Roland SC-8850 */ 964 /* Roland SC-8850 */
966 {0x0582, 0x0003, 0, "%s Part A"}, 965 { USB_ID(0x0582, 0x0003), 0, "%s Part A" },
967 {0x0582, 0x0003, 1, "%s Part B"}, 966 { USB_ID(0x0582, 0x0003), 1, "%s Part B" },
968 {0x0582, 0x0003, 2, "%s Part C"}, 967 { USB_ID(0x0582, 0x0003), 2, "%s Part C" },
969 {0x0582, 0x0003, 3, "%s Part D"}, 968 { USB_ID(0x0582, 0x0003), 3, "%s Part D" },
970 {0x0582, 0x0003, 4, "%s MIDI 1"}, 969 { USB_ID(0x0582, 0x0003), 4, "%s MIDI 1" },
971 {0x0582, 0x0003, 5, "%s MIDI 2"}, 970 { USB_ID(0x0582, 0x0003), 5, "%s MIDI 2" },
972 /* Roland U-8 */ 971 /* Roland U-8 */
973 {0x0582, 0x0004, 0, "%s MIDI"}, 972 { USB_ID(0x0582, 0x0004), 0, "%s MIDI" },
974 {0x0582, 0x0004, 1, "%s Control"}, 973 { USB_ID(0x0582, 0x0004), 1, "%s Control" },
975 /* Roland SC-8820 */ 974 /* Roland SC-8820 */
976 {0x0582, 0x0007, 0, "%s Part A"}, 975 { USB_ID(0x0582, 0x0007), 0, "%s Part A" },
977 {0x0582, 0x0007, 1, "%s Part B"}, 976 { USB_ID(0x0582, 0x0007), 1, "%s Part B" },
978 {0x0582, 0x0007, 2, "%s MIDI"}, 977 { USB_ID(0x0582, 0x0007), 2, "%s MIDI" },
979 /* Roland SK-500 */ 978 /* Roland SK-500 */
980 {0x0582, 0x000b, 0, "%s Part A"}, 979 { USB_ID(0x0582, 0x000b), 0, "%s Part A" },
981 {0x0582, 0x000b, 1, "%s Part B"}, 980 { USB_ID(0x0582, 0x000b), 1, "%s Part B" },
982 {0x0582, 0x000b, 2, "%s MIDI"}, 981 { USB_ID(0x0582, 0x000b), 2, "%s MIDI" },
983 /* Roland SC-D70 */ 982 /* Roland SC-D70 */
984 {0x0582, 0x000c, 0, "%s Part A"}, 983 { USB_ID(0x0582, 0x000c), 0, "%s Part A" },
985 {0x0582, 0x000c, 1, "%s Part B"}, 984 { USB_ID(0x0582, 0x000c), 1, "%s Part B" },
986 {0x0582, 0x000c, 2, "%s MIDI"}, 985 { USB_ID(0x0582, 0x000c), 2, "%s MIDI" },
987 /* Edirol UM-880 */ 986 /* Edirol UM-880 */
988 {0x0582, 0x0014, 8, "%s Control"}, 987 { USB_ID(0x0582, 0x0014), 8, "%s Control" },
989 /* Edirol SD-90 */ 988 /* Edirol SD-90 */
990 {0x0582, 0x0016, 0, "%s Part A"}, 989 { USB_ID(0x0582, 0x0016), 0, "%s Part A" },
991 {0x0582, 0x0016, 1, "%s Part B"}, 990 { USB_ID(0x0582, 0x0016), 1, "%s Part B" },
992 {0x0582, 0x0016, 2, "%s MIDI 1"}, 991 { USB_ID(0x0582, 0x0016), 2, "%s MIDI 1" },
993 {0x0582, 0x0016, 3, "%s MIDI 2"}, 992 { USB_ID(0x0582, 0x0016), 3, "%s MIDI 2" },
994 /* Edirol UM-550 */ 993 /* Edirol UM-550 */
995 {0x0582, 0x0023, 5, "%s Control"}, 994 { USB_ID(0x0582, 0x0023), 5, "%s Control" },
996 /* Edirol SD-20 */ 995 /* Edirol SD-20 */
997 {0x0582, 0x0027, 0, "%s Part A"}, 996 { USB_ID(0x0582, 0x0027), 0, "%s Part A" },
998 {0x0582, 0x0027, 1, "%s Part B"}, 997 { USB_ID(0x0582, 0x0027), 1, "%s Part B" },
999 {0x0582, 0x0027, 2, "%s MIDI"}, 998 { USB_ID(0x0582, 0x0027), 2, "%s MIDI" },
1000 /* Edirol SD-80 */ 999 /* Edirol SD-80 */
1001 {0x0582, 0x0029, 0, "%s Part A"}, 1000 { USB_ID(0x0582, 0x0029), 0, "%s Part A" },
1002 {0x0582, 0x0029, 1, "%s Part B"}, 1001 { USB_ID(0x0582, 0x0029), 1, "%s Part B" },
1003 {0x0582, 0x0029, 2, "%s MIDI 1"}, 1002 { USB_ID(0x0582, 0x0029), 2, "%s MIDI 1" },
1004 {0x0582, 0x0029, 3, "%s MIDI 2"}, 1003 { USB_ID(0x0582, 0x0029), 3, "%s MIDI 2" },
1005 /* Edirol UA-700 */ 1004 /* Edirol UA-700 */
1006 {0x0582, 0x002b, 0, "%s MIDI"}, 1005 { USB_ID(0x0582, 0x002b), 0, "%s MIDI" },
1007 {0x0582, 0x002b, 1, "%s Control"}, 1006 { USB_ID(0x0582, 0x002b), 1, "%s Control" },
1008 /* Roland VariOS */ 1007 /* Roland VariOS */
1009 {0x0582, 0x002f, 0, "%s MIDI"}, 1008 { USB_ID(0x0582, 0x002f), 0, "%s MIDI" },
1010 {0x0582, 0x002f, 1, "%s External MIDI"}, 1009 { USB_ID(0x0582, 0x002f), 1, "%s External MIDI" },
1011 {0x0582, 0x002f, 2, "%s Sync"}, 1010 { USB_ID(0x0582, 0x002f), 2, "%s Sync" },
1012 /* Edirol PCR */ 1011 /* Edirol PCR */
1013 {0x0582, 0x0033, 0, "%s MIDI"}, 1012 { USB_ID(0x0582, 0x0033), 0, "%s MIDI" },
1014 {0x0582, 0x0033, 1, "%s 1"}, 1013 { USB_ID(0x0582, 0x0033), 1, "%s 1" },
1015 {0x0582, 0x0033, 2, "%s 2"}, 1014 { USB_ID(0x0582, 0x0033), 2, "%s 2" },
1016 /* BOSS GS-10 */ 1015 /* BOSS GS-10 */
1017 {0x0582, 0x003b, 0, "%s MIDI"}, 1016 { USB_ID(0x0582, 0x003b), 0, "%s MIDI" },
1018 {0x0582, 0x003b, 1, "%s Control"}, 1017 { USB_ID(0x0582, 0x003b), 1, "%s Control" },
1019 /* Edirol UA-1000 */ 1018 /* Edirol UA-1000 */
1020 {0x0582, 0x0044, 0, "%s MIDI"}, 1019 { USB_ID(0x0582, 0x0044), 0, "%s MIDI" },
1021 {0x0582, 0x0044, 1, "%s Control"}, 1020 { USB_ID(0x0582, 0x0044), 1, "%s Control" },
1022 /* Edirol UR-80 */ 1021 /* Edirol UR-80 */
1023 {0x0582, 0x0048, 0, "%s MIDI"}, 1022 { USB_ID(0x0582, 0x0048), 0, "%s MIDI" },
1024 {0x0582, 0x0048, 1, "%s 1"}, 1023 { USB_ID(0x0582, 0x0048), 1, "%s 1" },
1025 {0x0582, 0x0048, 2, "%s 2"}, 1024 { USB_ID(0x0582, 0x0048), 2, "%s 2" },
1026 /* Edirol PCR-A */ 1025 /* Edirol PCR-A */
1027 {0x0582, 0x004d, 0, "%s MIDI"}, 1026 { USB_ID(0x0582, 0x004d), 0, "%s MIDI" },
1028 {0x0582, 0x004d, 1, "%s 1"}, 1027 { USB_ID(0x0582, 0x004d), 1, "%s 1" },
1029 {0x0582, 0x004d, 2, "%s 2"}, 1028 { USB_ID(0x0582, 0x004d), 2, "%s 2" },
1030 /* M-Audio MidiSport 8x8 */ 1029 /* M-Audio MidiSport 8x8 */
1031 {0x0763, 0x1031, 8, "%s Control"}, 1030 { USB_ID(0x0763, 0x1031), 8, "%s Control" },
1032 {0x0763, 0x1033, 8, "%s Control"}, 1031 { USB_ID(0x0763, 0x1033), 8, "%s Control" },
1033 /* MOTU Fastlane */ 1032 /* MOTU Fastlane */
1034 {0x07fd, 0x0001, 0, "%s MIDI A"}, 1033 { USB_ID(0x07fd, 0x0001), 0, "%s MIDI A" },
1035 {0x07fd, 0x0001, 1, "%s MIDI B"}, 1034 { USB_ID(0x07fd, 0x0001), 1, "%s MIDI B" },
1036 /* Emagic Unitor8/AMT8/MT4 */ 1035 /* Emagic Unitor8/AMT8/MT4 */
1037 {0x086a, 0x0001, 8, "%s Broadcast"}, 1036 { USB_ID(0x086a, 0x0001), 8, "%s Broadcast" },
1038 {0x086a, 0x0002, 8, "%s Broadcast"}, 1037 { USB_ID(0x086a, 0x0002), 8, "%s Broadcast" },
1039 {0x086a, 0x0003, 4, "%s Broadcast"}, 1038 { USB_ID(0x086a, 0x0003), 4, "%s Broadcast" },
1040}; 1039};
1041 1040
1042static void snd_usbmidi_init_substream(snd_usb_midi_t* umidi, 1041static void snd_usbmidi_init_substream(snd_usb_midi_t* umidi,
@@ -1044,7 +1043,6 @@ static void snd_usbmidi_init_substream(snd_usb_midi_t* umidi,
1044 snd_rawmidi_substream_t** rsubstream) 1043 snd_rawmidi_substream_t** rsubstream)
1045{ 1044{
1046 int i; 1045 int i;
1047 __u16 vendor, product;
1048 const char *name_format; 1046 const char *name_format;
1049 1047
1050 snd_rawmidi_substream_t* substream = snd_usbmidi_find_substream(umidi, stream, number); 1048 snd_rawmidi_substream_t* substream = snd_usbmidi_find_substream(umidi, stream, number);
@@ -1055,11 +1053,8 @@ static void snd_usbmidi_init_substream(snd_usb_midi_t* umidi,
1055 1053
1056 /* TODO: read port name from jack descriptor */ 1054 /* TODO: read port name from jack descriptor */
1057 name_format = "%s MIDI %d"; 1055 name_format = "%s MIDI %d";
1058 vendor = le16_to_cpu(umidi->chip->dev->descriptor.idVendor);
1059 product = le16_to_cpu(umidi->chip->dev->descriptor.idProduct);
1060 for (i = 0; i < ARRAY_SIZE(snd_usbmidi_port_names); ++i) { 1056 for (i = 0; i < ARRAY_SIZE(snd_usbmidi_port_names); ++i) {
1061 if (snd_usbmidi_port_names[i].vendor == vendor && 1057 if (snd_usbmidi_port_names[i].id == umidi->chip->usb_id &&
1062 snd_usbmidi_port_names[i].product == product &&
1063 snd_usbmidi_port_names[i].port == number) { 1058 snd_usbmidi_port_names[i].port == number) {
1064 name_format = snd_usbmidi_port_names[i].name_format; 1059 name_format = snd_usbmidi_port_names[i].name_format;
1065 break; 1060 break;
@@ -1226,9 +1221,12 @@ static int snd_usbmidi_detect_endpoints(snd_usb_midi_t* umidi,
1226 struct usb_endpoint_descriptor* epd; 1221 struct usb_endpoint_descriptor* epd;
1227 int i, out_eps = 0, in_eps = 0; 1222 int i, out_eps = 0, in_eps = 0;
1228 1223
1229 if (le16_to_cpu(umidi->chip->dev->descriptor.idVendor) == 0x0582) 1224 if (USB_ID_VENDOR(umidi->chip->usb_id) == 0x0582)
1230 snd_usbmidi_switch_roland_altsetting(umidi); 1225 snd_usbmidi_switch_roland_altsetting(umidi);
1231 1226
1227 if (endpoint[0].out_ep || endpoint[0].in_ep)
1228 return 0;
1229
1232 intf = umidi->iface; 1230 intf = umidi->iface;
1233 if (!intf || intf->num_altsetting < 1) 1231 if (!intf || intf->num_altsetting < 1)
1234 return -ENOENT; 1232 return -ENOENT;
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c
index 5f1906915aa6..e73c1c9d3e73 100644
--- a/sound/usb/usbmixer.c
+++ b/sound/usb/usbmixer.c
@@ -35,10 +35,11 @@
35#include <linux/usb.h> 35#include <linux/usb.h>
36#include <sound/core.h> 36#include <sound/core.h>
37#include <sound/control.h> 37#include <sound/control.h>
38#include <sound/hwdep.h>
39#include <sound/info.h>
38 40
39#include "usbaudio.h" 41#include "usbaudio.h"
40 42
41
42/* 43/*
43 */ 44 */
44 45
@@ -50,6 +51,31 @@ typedef struct usb_audio_term usb_audio_term_t;
50typedef struct usb_mixer_elem_info usb_mixer_elem_info_t; 51typedef struct usb_mixer_elem_info usb_mixer_elem_info_t;
51 52
52 53
54struct usb_mixer_interface {
55 snd_usb_audio_t *chip;
56 unsigned int ctrlif;
57 struct list_head list;
58 unsigned int ignore_ctl_error;
59 struct urb *urb;
60 usb_mixer_elem_info_t **id_elems; /* array[256], indexed by unit id */
61
62 /* Sound Blaster remote control stuff */
63 enum {
64 RC_NONE,
65 RC_EXTIGY,
66 RC_AUDIGY2NX,
67 } rc_type;
68 unsigned long rc_hwdep_open;
69 u32 rc_code;
70 wait_queue_head_t rc_waitq;
71 struct urb *rc_urb;
72 struct usb_ctrlrequest *rc_setup_packet;
73 u8 rc_buffer[6];
74
75 u8 audigy2nx_leds[3];
76};
77
78
53struct usb_audio_term { 79struct usb_audio_term {
54 int id; 80 int id;
55 int type; 81 int type;
@@ -62,26 +88,26 @@ struct usbmix_name_map;
62 88
63struct usb_mixer_build { 89struct usb_mixer_build {
64 snd_usb_audio_t *chip; 90 snd_usb_audio_t *chip;
91 struct usb_mixer_interface *mixer;
65 unsigned char *buffer; 92 unsigned char *buffer;
66 unsigned int buflen; 93 unsigned int buflen;
67 unsigned int ctrlif; 94 DECLARE_BITMAP(unitbitmap, 256);
68 unsigned short vendor;
69 unsigned short product;
70 DECLARE_BITMAP(unitbitmap, 32*32);
71 usb_audio_term_t oterm; 95 usb_audio_term_t oterm;
72 const struct usbmix_name_map *map; 96 const struct usbmix_name_map *map;
97 const struct usbmix_selector_map *selector_map;
73}; 98};
74 99
75struct usb_mixer_elem_info { 100struct usb_mixer_elem_info {
76 snd_usb_audio_t *chip; 101 struct usb_mixer_interface *mixer;
77 unsigned int ctrlif; 102 usb_mixer_elem_info_t *next_id_elem; /* list of controls with same id */
103 snd_ctl_elem_id_t *elem_id;
78 unsigned int id; 104 unsigned int id;
79 unsigned int control; /* CS or ICN (high byte) */ 105 unsigned int control; /* CS or ICN (high byte) */
80 unsigned int cmask; /* channel mask bitmap: 0 = master */ 106 unsigned int cmask; /* channel mask bitmap: 0 = master */
81 int channels; 107 int channels;
82 int val_type; 108 int val_type;
83 int min, max, res; 109 int min, max, res;
84 unsigned int initialized: 1; 110 u8 initialized;
85}; 111};
86 112
87 113
@@ -187,6 +213,21 @@ static int check_ignored_ctl(mixer_build_t *state, int unitid, int control)
187 return 0; 213 return 0;
188} 214}
189 215
216/* get the mapped selector source name */
217static int check_mapped_selector_name(mixer_build_t *state, int unitid,
218 int index, char *buf, int buflen)
219{
220 const struct usbmix_selector_map *p;
221
222 if (! state->selector_map)
223 return 0;
224 for (p = state->selector_map; p->id; p++) {
225 if (p->id == unitid && index < p->count)
226 return strlcpy(buf, p->names[index], buflen);
227 }
228 return 0;
229}
230
190/* 231/*
191 * find an audio control unit with the given unit id 232 * find an audio control unit with the given unit id
192 */ 233 */
@@ -301,16 +342,18 @@ static int get_ctl_value(usb_mixer_elem_info_t *cval, int request, int validx, i
301 int timeout = 10; 342 int timeout = 10;
302 343
303 while (timeout-- > 0) { 344 while (timeout-- > 0) {
304 if (snd_usb_ctl_msg(cval->chip->dev, usb_rcvctrlpipe(cval->chip->dev, 0), 345 if (snd_usb_ctl_msg(cval->mixer->chip->dev,
346 usb_rcvctrlpipe(cval->mixer->chip->dev, 0),
305 request, 347 request,
306 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 348 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
307 validx, cval->ctrlif | (cval->id << 8), 349 validx, cval->mixer->ctrlif | (cval->id << 8),
308 buf, val_len, 100) >= 0) { 350 buf, val_len, 100) >= 0) {
309 *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len)); 351 *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len));
310 return 0; 352 return 0;
311 } 353 }
312 } 354 }
313 snd_printdd(KERN_ERR "cannot get ctl value: req = 0x%x, wValue = 0x%x, wIndex = 0x%x, type = %d\n", request, validx, cval->ctrlif | (cval->id << 8), cval->val_type); 355 snd_printdd(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n",
356 request, validx, cval->mixer->ctrlif | (cval->id << 8), cval->val_type);
314 return -EINVAL; 357 return -EINVAL;
315} 358}
316 359
@@ -339,13 +382,15 @@ static int set_ctl_value(usb_mixer_elem_info_t *cval, int request, int validx, i
339 buf[0] = value_set & 0xff; 382 buf[0] = value_set & 0xff;
340 buf[1] = (value_set >> 8) & 0xff; 383 buf[1] = (value_set >> 8) & 0xff;
341 while (timeout -- > 0) 384 while (timeout -- > 0)
342 if (snd_usb_ctl_msg(cval->chip->dev, usb_sndctrlpipe(cval->chip->dev, 0), 385 if (snd_usb_ctl_msg(cval->mixer->chip->dev,
386 usb_sndctrlpipe(cval->mixer->chip->dev, 0),
343 request, 387 request,
344 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, 388 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
345 validx, cval->ctrlif | (cval->id << 8), 389 validx, cval->mixer->ctrlif | (cval->id << 8),
346 buf, val_len, 100) >= 0) 390 buf, val_len, 100) >= 0)
347 return 0; 391 return 0;
348 snd_printdd(KERN_ERR "cannot set ctl value: req = 0x%x, wValue = 0x%x, wIndex = 0x%x, type = %d, data = 0x%x/0x%x\n", request, validx, cval->ctrlif | (cval->id << 8), cval->val_type, buf[0], buf[1]); 392 snd_printdd(KERN_ERR "cannot set ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d, data = %#x/%#x\n",
393 request, validx, cval->mixer->ctrlif | (cval->id << 8), cval->val_type, buf[0], buf[1]);
349 return -EINVAL; 394 return -EINVAL;
350} 395}
351 396
@@ -385,16 +430,22 @@ static int check_matrix_bitmap(unsigned char *bmap, int ich, int och, int num_ou
385 * if failed, give up and free the control instance. 430 * if failed, give up and free the control instance.
386 */ 431 */
387 432
388static int add_control_to_empty(snd_card_t *card, snd_kcontrol_t *kctl) 433static int add_control_to_empty(mixer_build_t *state, snd_kcontrol_t *kctl)
389{ 434{
435 usb_mixer_elem_info_t *cval = kctl->private_data;
390 int err; 436 int err;
391 while (snd_ctl_find_id(card, &kctl->id)) 437
438 while (snd_ctl_find_id(state->chip->card, &kctl->id))
392 kctl->id.index++; 439 kctl->id.index++;
393 if ((err = snd_ctl_add(card, kctl)) < 0) { 440 if ((err = snd_ctl_add(state->chip->card, kctl)) < 0) {
394 snd_printd(KERN_ERR "cannot add control (err = %d)\n", err); 441 snd_printd(KERN_ERR "cannot add control (err = %d)\n", err);
395 snd_ctl_free_one(kctl); 442 snd_ctl_free_one(kctl);
443 return err;
396 } 444 }
397 return err; 445 cval->elem_id = &kctl->id;
446 cval->next_id_elem = state->mixer->id_elems[cval->id];
447 state->mixer->id_elems[cval->id] = cval;
448 return 0;
398} 449}
399 450
400 451
@@ -572,10 +623,8 @@ static struct usb_feature_control_info audio_feature_info[] = {
572/* private_free callback */ 623/* private_free callback */
573static void usb_mixer_elem_free(snd_kcontrol_t *kctl) 624static void usb_mixer_elem_free(snd_kcontrol_t *kctl)
574{ 625{
575 if (kctl->private_data) { 626 kfree(kctl->private_data);
576 kfree(kctl->private_data); 627 kctl->private_data = NULL;
577 kctl->private_data = NULL;
578 }
579} 628}
580 629
581 630
@@ -608,7 +657,8 @@ static int get_min_max(usb_mixer_elem_info_t *cval, int default_min)
608 } 657 }
609 if (get_ctl_value(cval, GET_MAX, (cval->control << 8) | minchn, &cval->max) < 0 || 658 if (get_ctl_value(cval, GET_MAX, (cval->control << 8) | minchn, &cval->max) < 0 ||
610 get_ctl_value(cval, GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) { 659 get_ctl_value(cval, GET_MIN, (cval->control << 8) | minchn, &cval->min) < 0) {
611 snd_printd(KERN_ERR "%d:%d: cannot get min/max values for control %d (id %d)\n", cval->id, cval->ctrlif, cval->control, cval->id); 660 snd_printd(KERN_ERR "%d:%d: cannot get min/max values for control %d (id %d)\n",
661 cval->id, cval->mixer->ctrlif, cval->control, cval->id);
612 return -EINVAL; 662 return -EINVAL;
613 } 663 }
614 if (get_ctl_value(cval, GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) { 664 if (get_ctl_value(cval, GET_RES, (cval->control << 8) | minchn, &cval->res) < 0) {
@@ -668,7 +718,7 @@ static int mixer_ctl_feature_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t
668 if (cval->cmask & (1 << c)) { 718 if (cval->cmask & (1 << c)) {
669 err = get_cur_mix_value(cval, c + 1, &val); 719 err = get_cur_mix_value(cval, c + 1, &val);
670 if (err < 0) { 720 if (err < 0) {
671 if (cval->chip->ignore_ctl_error) { 721 if (cval->mixer->ignore_ctl_error) {
672 ucontrol->value.integer.value[0] = cval->min; 722 ucontrol->value.integer.value[0] = cval->min;
673 return 0; 723 return 0;
674 } 724 }
@@ -684,7 +734,7 @@ static int mixer_ctl_feature_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t
684 /* master channel */ 734 /* master channel */
685 err = get_cur_mix_value(cval, 0, &val); 735 err = get_cur_mix_value(cval, 0, &val);
686 if (err < 0) { 736 if (err < 0) {
687 if (cval->chip->ignore_ctl_error) { 737 if (cval->mixer->ignore_ctl_error) {
688 ucontrol->value.integer.value[0] = cval->min; 738 ucontrol->value.integer.value[0] = cval->min;
689 return 0; 739 return 0;
690 } 740 }
@@ -710,7 +760,7 @@ static int mixer_ctl_feature_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t
710 if (cval->cmask & (1 << c)) { 760 if (cval->cmask & (1 << c)) {
711 err = get_cur_mix_value(cval, c + 1, &oval); 761 err = get_cur_mix_value(cval, c + 1, &oval);
712 if (err < 0) { 762 if (err < 0) {
713 if (cval->chip->ignore_ctl_error) 763 if (cval->mixer->ignore_ctl_error)
714 return 0; 764 return 0;
715 return err; 765 return err;
716 } 766 }
@@ -727,7 +777,7 @@ static int mixer_ctl_feature_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t
727 } else { 777 } else {
728 /* master channel */ 778 /* master channel */
729 err = get_cur_mix_value(cval, 0, &oval); 779 err = get_cur_mix_value(cval, 0, &oval);
730 if (err < 0 && cval->chip->ignore_ctl_error) 780 if (err < 0 && cval->mixer->ignore_ctl_error)
731 return 0; 781 return 0;
732 if (err < 0) 782 if (err < 0)
733 return err; 783 return err;
@@ -779,8 +829,7 @@ static void build_feature_ctl(mixer_build_t *state, unsigned char *desc,
779 snd_printk(KERN_ERR "cannot malloc kcontrol\n"); 829 snd_printk(KERN_ERR "cannot malloc kcontrol\n");
780 return; 830 return;
781 } 831 }
782 cval->chip = state->chip; 832 cval->mixer = state->mixer;
783 cval->ctrlif = state->ctrlif;
784 cval->id = unitid; 833 cval->id = unitid;
785 cval->control = control; 834 cval->control = control;
786 cval->cmask = ctl_mask; 835 cval->cmask = ctl_mask;
@@ -855,16 +904,21 @@ static void build_feature_ctl(mixer_build_t *state, unsigned char *desc,
855 /* note that detection between firmware 2.1.1.7 (N101) and later 2.1.1.21 */ 904 /* note that detection between firmware 2.1.1.7 (N101) and later 2.1.1.21 */
856 /* is not very clear from datasheets */ 905 /* is not very clear from datasheets */
857 /* I hope that the min value is -15360 for newer firmware --jk */ 906 /* I hope that the min value is -15360 for newer firmware --jk */
858 if (((state->vendor == 0x471 && (state->product == 0x104 || state->product == 0x105 || state->product == 0x101)) || 907 switch (state->chip->usb_id) {
859 (state->vendor == 0x672 && state->product == 0x1041)) && !strcmp(kctl->id.name, "PCM Playback Volume") && 908 case USB_ID(0x0471, 0x0101):
860 cval->min == -15616) { 909 case USB_ID(0x0471, 0x0104):
861 snd_printk("USB Audio: using volume control quirk for the UDA1321/N101 chip\n"); 910 case USB_ID(0x0471, 0x0105):
862 cval->max = -256; 911 case USB_ID(0x0672, 0x1041):
912 if (!strcmp(kctl->id.name, "PCM Playback Volume") &&
913 cval->min == -15616) {
914 snd_printk("using volume control quirk for the UDA1321/N101 chip\n");
915 cval->max = -256;
916 }
863 } 917 }
864 918
865 snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n", 919 snd_printdd(KERN_INFO "[%d] FU [%s] ch = %d, val = %d/%d/%d\n",
866 cval->id, kctl->id.name, cval->channels, cval->min, cval->max, cval->res); 920 cval->id, kctl->id.name, cval->channels, cval->min, cval->max, cval->res);
867 add_control_to_empty(state->chip->card, kctl); 921 add_control_to_empty(state, kctl);
868} 922}
869 923
870 924
@@ -947,8 +1001,7 @@ static void build_mixer_unit_ctl(mixer_build_t *state, unsigned char *desc,
947 if (! cval) 1001 if (! cval)
948 return; 1002 return;
949 1003
950 cval->chip = state->chip; 1004 cval->mixer = state->mixer;
951 cval->ctrlif = state->ctrlif;
952 cval->id = unitid; 1005 cval->id = unitid;
953 cval->control = in_ch + 1; /* based on 1 */ 1006 cval->control = in_ch + 1; /* based on 1 */
954 cval->val_type = USB_MIXER_S16; 1007 cval->val_type = USB_MIXER_S16;
@@ -979,7 +1032,7 @@ static void build_mixer_unit_ctl(mixer_build_t *state, unsigned char *desc,
979 1032
980 snd_printdd(KERN_INFO "[%d] MU [%s] ch = %d, val = %d/%d\n", 1033 snd_printdd(KERN_INFO "[%d] MU [%s] ch = %d, val = %d/%d\n",
981 cval->id, kctl->id.name, cval->channels, cval->min, cval->max); 1034 cval->id, kctl->id.name, cval->channels, cval->min, cval->max);
982 add_control_to_empty(state->chip->card, kctl); 1035 add_control_to_empty(state, kctl);
983} 1036}
984 1037
985 1038
@@ -1042,7 +1095,7 @@ static int mixer_ctl_procunit_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t
1042 int err, val; 1095 int err, val;
1043 1096
1044 err = get_cur_ctl_value(cval, cval->control << 8, &val); 1097 err = get_cur_ctl_value(cval, cval->control << 8, &val);
1045 if (err < 0 && cval->chip->ignore_ctl_error) { 1098 if (err < 0 && cval->mixer->ignore_ctl_error) {
1046 ucontrol->value.integer.value[0] = cval->min; 1099 ucontrol->value.integer.value[0] = cval->min;
1047 return 0; 1100 return 0;
1048 } 1101 }
@@ -1061,7 +1114,7 @@ static int mixer_ctl_procunit_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t
1061 1114
1062 err = get_cur_ctl_value(cval, cval->control << 8, &oval); 1115 err = get_cur_ctl_value(cval, cval->control << 8, &oval);
1063 if (err < 0) { 1116 if (err < 0) {
1064 if (cval->chip->ignore_ctl_error) 1117 if (cval->mixer->ignore_ctl_error)
1065 return 0; 1118 return 0;
1066 return err; 1119 return err;
1067 } 1120 }
@@ -1179,9 +1232,6 @@ static int build_audio_procunit(mixer_build_t *state, int unitid, unsigned char
1179 } 1232 }
1180 1233
1181 type = combine_word(&dsc[4]); 1234 type = combine_word(&dsc[4]);
1182 if (! type)
1183 return 0; /* undefined? */
1184
1185 for (info = list; info && info->type; info++) 1235 for (info = list; info && info->type; info++)
1186 if (info->type == type) 1236 if (info->type == type)
1187 break; 1237 break;
@@ -1199,8 +1249,7 @@ static int build_audio_procunit(mixer_build_t *state, int unitid, unsigned char
1199 snd_printk(KERN_ERR "cannot malloc kcontrol\n"); 1249 snd_printk(KERN_ERR "cannot malloc kcontrol\n");
1200 return -ENOMEM; 1250 return -ENOMEM;
1201 } 1251 }
1202 cval->chip = state->chip; 1252 cval->mixer = state->mixer;
1203 cval->ctrlif = state->ctrlif;
1204 cval->id = unitid; 1253 cval->id = unitid;
1205 cval->control = valinfo->control; 1254 cval->control = valinfo->control;
1206 cval->val_type = valinfo->val_type; 1255 cval->val_type = valinfo->val_type;
@@ -1241,7 +1290,7 @@ static int build_audio_procunit(mixer_build_t *state, int unitid, unsigned char
1241 1290
1242 snd_printdd(KERN_INFO "[%d] PU [%s] ch = %d, val = %d/%d\n", 1291 snd_printdd(KERN_INFO "[%d] PU [%s] ch = %d, val = %d/%d\n",
1243 cval->id, kctl->id.name, cval->channels, cval->min, cval->max); 1292 cval->id, kctl->id.name, cval->channels, cval->min, cval->max);
1244 if ((err = add_control_to_empty(state->chip->card, kctl)) < 0) 1293 if ((err = add_control_to_empty(state, kctl)) < 0)
1245 return err; 1294 return err;
1246 } 1295 }
1247 return 0; 1296 return 0;
@@ -1289,7 +1338,7 @@ static int mixer_ctl_selector_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t
1289 1338
1290 err = get_cur_ctl_value(cval, 0, &val); 1339 err = get_cur_ctl_value(cval, 0, &val);
1291 if (err < 0) { 1340 if (err < 0) {
1292 if (cval->chip->ignore_ctl_error) { 1341 if (cval->mixer->ignore_ctl_error) {
1293 ucontrol->value.enumerated.item[0] = 0; 1342 ucontrol->value.enumerated.item[0] = 0;
1294 return 0; 1343 return 0;
1295 } 1344 }
@@ -1308,7 +1357,7 @@ static int mixer_ctl_selector_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t
1308 1357
1309 err = get_cur_ctl_value(cval, 0, &oval); 1358 err = get_cur_ctl_value(cval, 0, &oval);
1310 if (err < 0) { 1359 if (err < 0) {
1311 if (cval->chip->ignore_ctl_error) 1360 if (cval->mixer->ignore_ctl_error)
1312 return 0; 1361 return 0;
1313 return err; 1362 return err;
1314 } 1363 }
@@ -1386,8 +1435,7 @@ static int parse_audio_selector_unit(mixer_build_t *state, int unitid, unsigned
1386 snd_printk(KERN_ERR "cannot malloc kcontrol\n"); 1435 snd_printk(KERN_ERR "cannot malloc kcontrol\n");
1387 return -ENOMEM; 1436 return -ENOMEM;
1388 } 1437 }
1389 cval->chip = state->chip; 1438 cval->mixer = state->mixer;
1390 cval->ctrlif = state->ctrlif;
1391 cval->id = unitid; 1439 cval->id = unitid;
1392 cval->val_type = USB_MIXER_U8; 1440 cval->val_type = USB_MIXER_U8;
1393 cval->channels = 1; 1441 cval->channels = 1;
@@ -1415,7 +1463,9 @@ static int parse_audio_selector_unit(mixer_build_t *state, int unitid, unsigned
1415 kfree(cval); 1463 kfree(cval);
1416 return -ENOMEM; 1464 return -ENOMEM;
1417 } 1465 }
1418 if (check_input_term(state, desc[5 + i], &iterm) >= 0) 1466 len = check_mapped_selector_name(state, unitid, i, namelist[i],
1467 MAX_ITEM_NAME_LEN);
1468 if (! len && check_input_term(state, desc[5 + i], &iterm) >= 0)
1419 len = get_term_name(state, &iterm, namelist[i], MAX_ITEM_NAME_LEN, 0); 1469 len = get_term_name(state, &iterm, namelist[i], MAX_ITEM_NAME_LEN, 0);
1420 if (! len) 1470 if (! len)
1421 sprintf(namelist[i], "Input %d", i); 1471 sprintf(namelist[i], "Input %d", i);
@@ -1450,7 +1500,7 @@ static int parse_audio_selector_unit(mixer_build_t *state, int unitid, unsigned
1450 1500
1451 snd_printdd(KERN_INFO "[%d] SU [%s] items = %d\n", 1501 snd_printdd(KERN_INFO "[%d] SU [%s] items = %d\n",
1452 cval->id, kctl->id.name, num_ins); 1502 cval->id, kctl->id.name, num_ins);
1453 if ((err = add_control_to_empty(state->chip->card, kctl)) < 0) 1503 if ((err = add_control_to_empty(state, kctl)) < 0)
1454 return err; 1504 return err;
1455 1505
1456 return 0; 1506 return 0;
@@ -1493,41 +1543,55 @@ static int parse_audio_unit(mixer_build_t *state, int unitid)
1493 } 1543 }
1494} 1544}
1495 1545
1546static void snd_usb_mixer_free(struct usb_mixer_interface *mixer)
1547{
1548 kfree(mixer->id_elems);
1549 if (mixer->urb) {
1550 kfree(mixer->urb->transfer_buffer);
1551 usb_free_urb(mixer->urb);
1552 }
1553 if (mixer->rc_urb)
1554 usb_free_urb(mixer->rc_urb);
1555 kfree(mixer->rc_setup_packet);
1556 kfree(mixer);
1557}
1558
1559static int snd_usb_mixer_dev_free(snd_device_t *device)
1560{
1561 struct usb_mixer_interface *mixer = device->device_data;
1562 snd_usb_mixer_free(mixer);
1563 return 0;
1564}
1565
1496/* 1566/*
1497 * create mixer controls 1567 * create mixer controls
1498 * 1568 *
1499 * walk through all OUTPUT_TERMINAL descriptors to search for mixers 1569 * walk through all OUTPUT_TERMINAL descriptors to search for mixers
1500 */ 1570 */
1501int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif) 1571static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
1502{ 1572{
1503 unsigned char *desc; 1573 unsigned char *desc;
1504 mixer_build_t state; 1574 mixer_build_t state;
1505 int err; 1575 int err;
1506 const struct usbmix_ctl_map *map; 1576 const struct usbmix_ctl_map *map;
1507 struct usb_device_descriptor *dev = &chip->dev->descriptor; 1577 struct usb_host_interface *hostif;
1508 struct usb_host_interface *hostif = &usb_ifnum_to_if(chip->dev, ctrlif)->altsetting[0];
1509
1510 strcpy(chip->card->mixername, "USB Mixer");
1511 1578
1579 hostif = &usb_ifnum_to_if(mixer->chip->dev, mixer->ctrlif)->altsetting[0];
1512 memset(&state, 0, sizeof(state)); 1580 memset(&state, 0, sizeof(state));
1513 state.chip = chip; 1581 state.chip = mixer->chip;
1582 state.mixer = mixer;
1514 state.buffer = hostif->extra; 1583 state.buffer = hostif->extra;
1515 state.buflen = hostif->extralen; 1584 state.buflen = hostif->extralen;
1516 state.ctrlif = ctrlif;
1517 state.vendor = le16_to_cpu(dev->idVendor);
1518 state.product = le16_to_cpu(dev->idProduct);
1519 1585
1520 /* check the mapping table */ 1586 /* check the mapping table */
1521 for (map = usbmix_ctl_maps; map->vendor; map++) { 1587 for (map = usbmix_ctl_maps; map->id; map++) {
1522 if (map->vendor == state.vendor && map->product == state.product) { 1588 if (map->id == state.chip->usb_id) {
1523 state.map = map->map; 1589 state.map = map->map;
1524 chip->ignore_ctl_error = map->ignore_ctl_error; 1590 state.selector_map = map->selector_map;
1591 mixer->ignore_ctl_error = map->ignore_ctl_error;
1525 break; 1592 break;
1526 } 1593 }
1527 } 1594 }
1528#ifdef IGNORE_CTL_ERROR
1529 chip->ignore_ctl_error = 1;
1530#endif
1531 1595
1532 desc = NULL; 1596 desc = NULL;
1533 while ((desc = snd_usb_find_csint_desc(hostif->extra, hostif->extralen, desc, OUTPUT_TERMINAL)) != NULL) { 1597 while ((desc = snd_usb_find_csint_desc(hostif->extra, hostif->extralen, desc, OUTPUT_TERMINAL)) != NULL) {
@@ -1543,3 +1607,393 @@ int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif)
1543 } 1607 }
1544 return 0; 1608 return 0;
1545} 1609}
1610
1611static void snd_usb_mixer_notify_id(struct usb_mixer_interface *mixer,
1612 int unitid)
1613{
1614 usb_mixer_elem_info_t *info;
1615
1616 for (info = mixer->id_elems[unitid]; info; info = info->next_id_elem)
1617 snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
1618 info->elem_id);
1619}
1620
1621static void snd_usb_mixer_memory_change(struct usb_mixer_interface *mixer,
1622 int unitid)
1623{
1624 if (mixer->rc_type == RC_NONE)
1625 return;
1626 /* unit ids specific to Extigy/Audigy 2 NX: */
1627 switch (unitid) {
1628 case 0: /* remote control */
1629 mixer->rc_urb->dev = mixer->chip->dev;
1630 usb_submit_urb(mixer->rc_urb, GFP_ATOMIC);
1631 break;
1632 case 4: /* digital in jack */
1633 case 7: /* line in jacks */
1634 case 19: /* speaker out jacks */
1635 case 20: /* headphones out jack */
1636 break;
1637 default:
1638 snd_printd(KERN_DEBUG "memory change in unknown unit %d\n", unitid);
1639 break;
1640 }
1641}
1642
1643static void snd_usb_mixer_status_complete(struct urb *urb, struct pt_regs *regs)
1644{
1645 struct usb_mixer_interface *mixer = urb->context;
1646
1647 if (urb->status == 0) {
1648 u8 *buf = urb->transfer_buffer;
1649 int i;
1650
1651 for (i = urb->actual_length; i >= 2; buf += 2, i -= 2) {
1652 snd_printd(KERN_DEBUG "status interrupt: %02x %02x\n",
1653 buf[0], buf[1]);
1654 /* ignore any notifications not from the control interface */
1655 if ((buf[0] & 0x0f) != 0)
1656 continue;
1657 if (!(buf[0] & 0x40))
1658 snd_usb_mixer_notify_id(mixer, buf[1]);
1659 else
1660 snd_usb_mixer_memory_change(mixer, buf[1]);
1661 }
1662 }
1663 if (urb->status != -ENOENT && urb->status != -ECONNRESET) {
1664 urb->dev = mixer->chip->dev;
1665 usb_submit_urb(urb, GFP_ATOMIC);
1666 }
1667}
1668
1669/* create the handler for the optional status interrupt endpoint */
1670static int snd_usb_mixer_status_create(struct usb_mixer_interface *mixer)
1671{
1672 struct usb_host_interface *hostif;
1673 struct usb_endpoint_descriptor *ep;
1674 void *transfer_buffer;
1675 int buffer_length;
1676 unsigned int epnum;
1677
1678 hostif = &usb_ifnum_to_if(mixer->chip->dev, mixer->ctrlif)->altsetting[0];
1679 /* we need one interrupt input endpoint */
1680 if (get_iface_desc(hostif)->bNumEndpoints < 1)
1681 return 0;
1682 ep = get_endpoint(hostif, 0);
1683 if ((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) != USB_DIR_IN ||
1684 (ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
1685 return 0;
1686
1687 epnum = ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
1688 buffer_length = le16_to_cpu(ep->wMaxPacketSize);
1689 transfer_buffer = kmalloc(buffer_length, GFP_KERNEL);
1690 if (!transfer_buffer)
1691 return -ENOMEM;
1692 mixer->urb = usb_alloc_urb(0, GFP_KERNEL);
1693 if (!mixer->urb) {
1694 kfree(transfer_buffer);
1695 return -ENOMEM;
1696 }
1697 usb_fill_int_urb(mixer->urb, mixer->chip->dev,
1698 usb_rcvintpipe(mixer->chip->dev, epnum),
1699 transfer_buffer, buffer_length,
1700 snd_usb_mixer_status_complete, mixer, ep->bInterval);
1701 usb_submit_urb(mixer->urb, GFP_KERNEL);
1702 return 0;
1703}
1704
1705static void snd_usb_soundblaster_remote_complete(struct urb *urb,
1706 struct pt_regs *regs)
1707{
1708 struct usb_mixer_interface *mixer = urb->context;
1709 /*
1710 * format of remote control data:
1711 * Extigy: xx 00
1712 * Audigy 2 NX: 06 80 xx 00 00 00
1713 */
1714 int offset = mixer->rc_type == RC_EXTIGY ? 0 : 2;
1715 u32 code;
1716
1717 if (urb->status < 0 || urb->actual_length <= offset)
1718 return;
1719 code = mixer->rc_buffer[offset];
1720 /* the Mute button actually changes the mixer control */
1721 if (code == 13)
1722 snd_usb_mixer_notify_id(mixer, 18);
1723 mixer->rc_code = code;
1724 wmb();
1725 wake_up(&mixer->rc_waitq);
1726}
1727
1728static int snd_usb_sbrc_hwdep_open(snd_hwdep_t *hw, struct file *file)
1729{
1730 struct usb_mixer_interface *mixer = hw->private_data;
1731
1732 if (test_and_set_bit(0, &mixer->rc_hwdep_open))
1733 return -EBUSY;
1734 return 0;
1735}
1736
1737static int snd_usb_sbrc_hwdep_release(snd_hwdep_t *hw, struct file *file)
1738{
1739 struct usb_mixer_interface *mixer = hw->private_data;
1740
1741 clear_bit(0, &mixer->rc_hwdep_open);
1742 smp_mb__after_clear_bit();
1743 return 0;
1744}
1745
1746static long snd_usb_sbrc_hwdep_read(snd_hwdep_t *hw, char __user *buf,
1747 long count, loff_t *offset)
1748{
1749 struct usb_mixer_interface *mixer = hw->private_data;
1750 int err;
1751 u32 rc_code;
1752
1753 if (count != 1 && count != 4)
1754 return -EINVAL;
1755 err = wait_event_interruptible(mixer->rc_waitq,
1756 (rc_code = xchg(&mixer->rc_code, 0)) != 0);
1757 if (err == 0) {
1758 if (count == 1)
1759 err = put_user(rc_code, buf);
1760 else
1761 err = put_user(rc_code, (u32 __user *)buf);
1762 }
1763 return err < 0 ? err : count;
1764}
1765
1766static unsigned int snd_usb_sbrc_hwdep_poll(snd_hwdep_t *hw, struct file *file,
1767 poll_table *wait)
1768{
1769 struct usb_mixer_interface *mixer = hw->private_data;
1770
1771 poll_wait(file, &mixer->rc_waitq, wait);
1772 return mixer->rc_code ? POLLIN | POLLRDNORM : 0;
1773}
1774
1775static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer)
1776{
1777 snd_hwdep_t *hwdep;
1778 int err, len;
1779
1780 switch (mixer->chip->usb_id) {
1781 case USB_ID(0x041e, 0x3000):
1782 mixer->rc_type = RC_EXTIGY;
1783 len = 2;
1784 break;
1785 case USB_ID(0x041e, 0x3020):
1786 mixer->rc_type = RC_AUDIGY2NX;
1787 len = 6;
1788 break;
1789 default:
1790 return 0;
1791 }
1792
1793 init_waitqueue_head(&mixer->rc_waitq);
1794 err = snd_hwdep_new(mixer->chip->card, "SB remote control", 0, &hwdep);
1795 if (err < 0)
1796 return err;
1797 snprintf(hwdep->name, sizeof(hwdep->name),
1798 "%s remote control", mixer->chip->card->shortname);
1799 hwdep->iface = SNDRV_HWDEP_IFACE_SB_RC;
1800 hwdep->private_data = mixer;
1801 hwdep->ops.read = snd_usb_sbrc_hwdep_read;
1802 hwdep->ops.open = snd_usb_sbrc_hwdep_open;
1803 hwdep->ops.release = snd_usb_sbrc_hwdep_release;
1804 hwdep->ops.poll = snd_usb_sbrc_hwdep_poll;
1805
1806 mixer->rc_urb = usb_alloc_urb(0, GFP_KERNEL);
1807 if (!mixer->rc_urb)
1808 return -ENOMEM;
1809 mixer->rc_setup_packet = kmalloc(sizeof(*mixer->rc_setup_packet), GFP_KERNEL);
1810 if (!mixer->rc_setup_packet) {
1811 usb_free_urb(mixer->rc_urb);
1812 mixer->rc_urb = NULL;
1813 return -ENOMEM;
1814 }
1815 mixer->rc_setup_packet->bRequestType =
1816 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE;
1817 mixer->rc_setup_packet->bRequest = GET_MEM;
1818 mixer->rc_setup_packet->wValue = cpu_to_le16(0);
1819 mixer->rc_setup_packet->wIndex = cpu_to_le16(0);
1820 mixer->rc_setup_packet->wLength = cpu_to_le16(len);
1821 usb_fill_control_urb(mixer->rc_urb, mixer->chip->dev,
1822 usb_rcvctrlpipe(mixer->chip->dev, 0),
1823 (u8*)mixer->rc_setup_packet, mixer->rc_buffer, len,
1824 snd_usb_soundblaster_remote_complete, mixer);
1825 return 0;
1826}
1827
1828static int snd_audigy2nx_led_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
1829{
1830 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1831 uinfo->count = 1;
1832 uinfo->value.integer.min = 0;
1833 uinfo->value.integer.max = 1;
1834 return 0;
1835}
1836
1837static int snd_audigy2nx_led_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1838{
1839 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
1840 int index = kcontrol->private_value;
1841
1842 ucontrol->value.integer.value[0] = mixer->audigy2nx_leds[index];
1843 return 0;
1844}
1845
1846static int snd_audigy2nx_led_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
1847{
1848 struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol);
1849 int index = kcontrol->private_value;
1850 int value = ucontrol->value.integer.value[0];
1851 int err, changed;
1852
1853 if (value > 1)
1854 return -EINVAL;
1855 changed = value != mixer->audigy2nx_leds[index];
1856 err = snd_usb_ctl_msg(mixer->chip->dev,
1857 usb_sndctrlpipe(mixer->chip->dev, 0), 0x24,
1858 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
1859 value, index + 2, NULL, 0, 100);
1860 if (err < 0)
1861 return err;
1862 mixer->audigy2nx_leds[index] = value;
1863 return changed;
1864}
1865
1866static snd_kcontrol_new_t snd_audigy2nx_controls[] = {
1867 {
1868 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1869 .name = "CMSS LED Switch",
1870 .info = snd_audigy2nx_led_info,
1871 .get = snd_audigy2nx_led_get,
1872 .put = snd_audigy2nx_led_put,
1873 .private_value = 0,
1874 },
1875 {
1876 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1877 .name = "Power LED Switch",
1878 .info = snd_audigy2nx_led_info,
1879 .get = snd_audigy2nx_led_get,
1880 .put = snd_audigy2nx_led_put,
1881 .private_value = 1,
1882 },
1883 {
1884 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1885 .name = "Dolby Digital LED Switch",
1886 .info = snd_audigy2nx_led_info,
1887 .get = snd_audigy2nx_led_get,
1888 .put = snd_audigy2nx_led_put,
1889 .private_value = 2,
1890 },
1891};
1892
1893static int snd_audigy2nx_controls_create(struct usb_mixer_interface *mixer)
1894{
1895 int i, err;
1896
1897 for (i = 0; i < ARRAY_SIZE(snd_audigy2nx_controls); ++i) {
1898 err = snd_ctl_add(mixer->chip->card,
1899 snd_ctl_new1(&snd_audigy2nx_controls[i], mixer));
1900 if (err < 0)
1901 return err;
1902 }
1903 mixer->audigy2nx_leds[1] = 1; /* Power LED is on by default */
1904 return 0;
1905}
1906
1907static void snd_audigy2nx_proc_read(snd_info_entry_t *entry,
1908 snd_info_buffer_t *buffer)
1909{
1910 static const struct {
1911 int unitid;
1912 const char *name;
1913 } jacks[] = {
1914 {4, "dig in "},
1915 {7, "line in"},
1916 {19, "spk out"},
1917 {20, "hph out"},
1918 };
1919 struct usb_mixer_interface *mixer = entry->private_data;
1920 int i, err;
1921 u8 buf[3];
1922
1923 snd_iprintf(buffer, "%s jacks\n\n", mixer->chip->card->shortname);
1924 for (i = 0; i < ARRAY_SIZE(jacks); ++i) {
1925 snd_iprintf(buffer, "%s: ", jacks[i].name);
1926 err = snd_usb_ctl_msg(mixer->chip->dev,
1927 usb_rcvctrlpipe(mixer->chip->dev, 0),
1928 GET_MEM, USB_DIR_IN | USB_TYPE_CLASS |
1929 USB_RECIP_INTERFACE, 0,
1930 jacks[i].unitid << 8, buf, 3, 100);
1931 if (err == 3 && buf[0] == 3)
1932 snd_iprintf(buffer, "%02x %02x\n", buf[1], buf[2]);
1933 else
1934 snd_iprintf(buffer, "?\n");
1935 }
1936}
1937
1938int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif)
1939{
1940 static snd_device_ops_t dev_ops = {
1941 .dev_free = snd_usb_mixer_dev_free
1942 };
1943 struct usb_mixer_interface *mixer;
1944 int err;
1945
1946 strcpy(chip->card->mixername, "USB Mixer");
1947
1948 mixer = kcalloc(1, sizeof(*mixer), GFP_KERNEL);
1949 if (!mixer)
1950 return -ENOMEM;
1951 mixer->chip = chip;
1952 mixer->ctrlif = ctrlif;
1953#ifdef IGNORE_CTL_ERROR
1954 mixer->ignore_ctl_error = 1;
1955#endif
1956 mixer->id_elems = kcalloc(256, sizeof(*mixer->id_elems), GFP_KERNEL);
1957 if (!mixer->id_elems) {
1958 kfree(mixer);
1959 return -ENOMEM;
1960 }
1961
1962 if ((err = snd_usb_mixer_controls(mixer)) < 0 ||
1963 (err = snd_usb_mixer_status_create(mixer)) < 0)
1964 goto _error;
1965
1966 if ((err = snd_usb_soundblaster_remote_init(mixer)) < 0)
1967 goto _error;
1968
1969 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020)) {
1970 snd_info_entry_t *entry;
1971
1972 if ((err = snd_audigy2nx_controls_create(mixer)) < 0)
1973 goto _error;
1974 if (!snd_card_proc_new(chip->card, "audigy2nx", &entry))
1975 snd_info_set_text_ops(entry, mixer, 1024,
1976 snd_audigy2nx_proc_read);
1977 }
1978
1979 err = snd_device_new(chip->card, SNDRV_DEV_LOWLEVEL, mixer, &dev_ops);
1980 if (err < 0)
1981 goto _error;
1982 list_add(&mixer->list, &chip->mixer_list);
1983 return 0;
1984
1985_error:
1986 snd_usb_mixer_free(mixer);
1987 return err;
1988}
1989
1990void snd_usb_mixer_disconnect(struct list_head *p)
1991{
1992 struct usb_mixer_interface *mixer;
1993
1994 mixer = list_entry(p, struct usb_mixer_interface, list);
1995 if (mixer->urb)
1996 usb_kill_urb(mixer->urb);
1997 if (mixer->rc_urb)
1998 usb_kill_urb(mixer->rc_urb);
1999}
diff --git a/sound/usb/usbmixer_maps.c b/sound/usb/usbmixer_maps.c
index c69b4b0875f8..f05500b05ec0 100644
--- a/sound/usb/usbmixer_maps.c
+++ b/sound/usb/usbmixer_maps.c
@@ -26,10 +26,16 @@ struct usbmix_name_map {
26 int control; 26 int control;
27}; 27};
28 28
29struct usbmix_selector_map {
30 int id;
31 int count;
32 const char **names;
33};
34
29struct usbmix_ctl_map { 35struct usbmix_ctl_map {
30 int vendor; 36 u32 id;
31 int product;
32 const struct usbmix_name_map *map; 37 const struct usbmix_name_map *map;
38 const struct usbmix_selector_map *selector_map;
33 int ignore_ctl_error; 39 int ignore_ctl_error;
34}; 40};
35 41
@@ -91,6 +97,96 @@ static struct usbmix_name_map extigy_map[] = {
91 { 0 } /* terminator */ 97 { 0 } /* terminator */
92}; 98};
93 99
100/* Sound Blaster MP3+ controls mapping
101 * The default mixer channels have totally misleading names,
102 * e.g. no Master and fake PCM volume
103 * Pavel Mihaylov <bin@bash.info>
104 */
105static struct usbmix_name_map mp3plus_map[] = {
106 /* 1: IT pcm */
107 /* 2: IT mic */
108 /* 3: IT line */
109 /* 4: IT digital in */
110 /* 5: OT digital out */
111 /* 6: OT speaker */
112 /* 7: OT pcm capture */
113 { 8, "Capture Input Source" }, /* FU, default PCM Capture Source */
114 /* (Mic, Input 1 = Line input, Input 2 = Optical input) */
115 { 9, "Master Playback" }, /* FU, default Speaker 1 */
116 /* { 10, "Mic Capture", 1 }, */ /* FU, Mic Capture */
117 /* { 10, "Mic Capture", 2 }, */ /* FU, Mic Capture */
118 { 10, "Mic Boost", 7 }, /* FU, default Auto Gain Input */
119 { 11, "Line Capture" }, /* FU, default PCM Capture */
120 { 12, "Digital In Playback" }, /* FU, default PCM 1 */
121 /* { 13, "Mic Playback" }, */ /* FU, default Mic Playback */
122 { 14, "Line Playback" }, /* FU, default Speaker */
123 /* 15: MU */
124 { 0 } /* terminator */
125};
126
127/* Topology of SB Audigy 2 NX
128
129 +----------------------------->EU[27]--+
130 | v
131 | +----------------------------------->SU[29]---->FU[22]-->Dig_OUT[24]
132 | | ^
133USB_IN[1]-+------------+ +->EU[17]->+->FU[11]-+
134 | v | v |
135Dig_IN[4]---+->FU[6]-->MU[16]->FU[18]-+->EU[21]->SU[31]----->FU[30]->Hph_OUT[20]
136 | ^ | |
137Lin_IN[7]-+--->FU[8]---+ +->EU[23]->FU[28]------------->Spk_OUT[19]
138 | | v
139 +--->FU[12]------------------------------------->SU[14]--->USB_OUT[15]
140 | ^
141 +->FU[13]--------------------------------------+
142*/
143static struct usbmix_name_map audigy2nx_map[] = {
144 /* 1: IT pcm playback */
145 /* 4: IT digital in */
146 { 6, "Digital In Playback" }, /* FU */
147 /* 7: IT line in */
148 { 8, "Line Playback" }, /* FU */
149 { 11, "What-U-Hear Capture" }, /* FU */
150 { 12, "Line Capture" }, /* FU */
151 { 13, "Digital In Capture" }, /* FU */
152 { 14, "Capture Source" }, /* SU */
153 /* 15: OT pcm capture */
154 /* 16: MU w/o controls */
155 { 17, NULL }, /* DISABLED: EU (for what?) */
156 { 18, "Master Playback" }, /* FU */
157 /* 19: OT speaker */
158 /* 20: OT headphone */
159 { 21, NULL }, /* DISABLED: EU (for what?) */
160 { 22, "Digital Out Playback" }, /* FU */
161 { 23, NULL }, /* DISABLED: EU (for what?) */
162 /* 24: OT digital out */
163 { 27, NULL }, /* DISABLED: EU (for what?) */
164 { 28, "Speaker Playback" }, /* FU */
165 { 29, "Digital Out Source" }, /* SU */
166 { 30, "Headphone Playback" }, /* FU */
167 { 31, "Headphone Source" }, /* SU */
168 { 0 } /* terminator */
169};
170
171static struct usbmix_selector_map audigy2nx_selectors[] = {
172 {
173 .id = 14, /* Capture Source */
174 .count = 3,
175 .names = (const char*[]) {"Line", "Digital In", "What-U-Hear"}
176 },
177 {
178 .id = 29, /* Digital Out Source */
179 .count = 3,
180 .names = (const char*[]) {"Front", "PCM", "Digital In"}
181 },
182 {
183 .id = 31, /* Headphone Source */
184 .count = 2,
185 .names = (const char*[]) {"Front", "Side"}
186 },
187 { 0 } /* terminator */
188};
189
94/* LineX FM Transmitter entry - needed to bypass controls bug */ 190/* LineX FM Transmitter entry - needed to bypass controls bug */
95static struct usbmix_name_map linex_map[] = { 191static struct usbmix_name_map linex_map[] = {
96 /* 1: IT pcm */ 192 /* 1: IT pcm */
@@ -127,9 +223,29 @@ static struct usbmix_name_map justlink_map[] = {
127 */ 223 */
128 224
129static struct usbmix_ctl_map usbmix_ctl_maps[] = { 225static struct usbmix_ctl_map usbmix_ctl_maps[] = {
130 { 0x41e, 0x3000, extigy_map, 1 }, 226 {
131 { 0x8bb, 0x2702, linex_map, 1 }, 227 .id = USB_ID(0x041e, 0x3000),
132 { 0xc45, 0x1158, justlink_map, 0 }, 228 .map = extigy_map,
229 .ignore_ctl_error = 1,
230 },
231 {
232 .id = USB_ID(0x041e, 0x3010),
233 .map = mp3plus_map,
234 },
235 {
236 .id = USB_ID(0x041e, 0x3020),
237 .map = audigy2nx_map,
238 .selector_map = audigy2nx_selectors,
239 },
240 {
241 .id = USB_ID(0x08bb, 0x2702),
242 .map = linex_map,
243 .ignore_ctl_error = 1,
244 },
245 {
246 .id = USB_ID(0x0c45, 0x1158),
247 .map = justlink_map,
248 },
133 { 0 } /* terminator */ 249 { 0 } /* terminator */
134}; 250};
135 251
diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h
index 88bbd944d4be..f5135641b3e2 100644
--- a/sound/usb/usbquirks.h
+++ b/sound/usb/usbquirks.h
@@ -203,11 +203,28 @@ YAMAHA_DEVICE(0x7010, "UB99"),
203 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { 203 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {
204 .vendor_name = "EDIROL", 204 .vendor_name = "EDIROL",
205 .product_name = "UM-4", 205 .product_name = "UM-4",
206 .ifnum = 2, 206 .ifnum = QUIRK_ANY_INTERFACE,
207 .type = QUIRK_MIDI_FIXED_ENDPOINT, 207 .type = QUIRK_COMPOSITE,
208 .data = & (const snd_usb_midi_endpoint_info_t) { 208 .data = (const snd_usb_audio_quirk_t[]) {
209 .out_cables = 0x000f, 209 {
210 .in_cables = 0x000f 210 .ifnum = 0,
211 .type = QUIRK_IGNORE_INTERFACE
212 },
213 {
214 .ifnum = 1,
215 .type = QUIRK_IGNORE_INTERFACE
216 },
217 {
218 .ifnum = 2,
219 .type = QUIRK_MIDI_FIXED_ENDPOINT,
220 .data = & (const snd_usb_midi_endpoint_info_t) {
221 .out_cables = 0x000f,
222 .in_cables = 0x000f
223 }
224 },
225 {
226 .ifnum = -1
227 }
211 } 228 }
212 } 229 }
213}, 230},
@@ -216,11 +233,28 @@ YAMAHA_DEVICE(0x7010, "UB99"),
216 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { 233 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {
217 .vendor_name = "Roland", 234 .vendor_name = "Roland",
218 .product_name = "SC-8850", 235 .product_name = "SC-8850",
219 .ifnum = 2, 236 .ifnum = QUIRK_ANY_INTERFACE,
220 .type = QUIRK_MIDI_FIXED_ENDPOINT, 237 .type = QUIRK_COMPOSITE,
221 .data = & (const snd_usb_midi_endpoint_info_t) { 238 .data = (const snd_usb_audio_quirk_t[]) {
222 .out_cables = 0x003f, 239 {
223 .in_cables = 0x003f 240 .ifnum = 0,
241 .type = QUIRK_IGNORE_INTERFACE
242 },
243 {
244 .ifnum = 1,
245 .type = QUIRK_IGNORE_INTERFACE
246 },
247 {
248 .ifnum = 2,
249 .type = QUIRK_MIDI_FIXED_ENDPOINT,
250 .data = & (const snd_usb_midi_endpoint_info_t) {
251 .out_cables = 0x003f,
252 .in_cables = 0x003f
253 }
254 },
255 {
256 .ifnum = -1
257 }
224 } 258 }
225 } 259 }
226}, 260},
@@ -229,11 +263,28 @@ YAMAHA_DEVICE(0x7010, "UB99"),
229 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { 263 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {
230 .vendor_name = "Roland", 264 .vendor_name = "Roland",
231 .product_name = "U-8", 265 .product_name = "U-8",
232 .ifnum = 2, 266 .ifnum = QUIRK_ANY_INTERFACE,
233 .type = QUIRK_MIDI_FIXED_ENDPOINT, 267 .type = QUIRK_COMPOSITE,
234 .data = & (const snd_usb_midi_endpoint_info_t) { 268 .data = (const snd_usb_audio_quirk_t[]) {
235 .out_cables = 0x0005, 269 {
236 .in_cables = 0x0005 270 .ifnum = 0,
271 .type = QUIRK_IGNORE_INTERFACE
272 },
273 {
274 .ifnum = 1,
275 .type = QUIRK_IGNORE_INTERFACE
276 },
277 {
278 .ifnum = 2,
279 .type = QUIRK_MIDI_FIXED_ENDPOINT,
280 .data = & (const snd_usb_midi_endpoint_info_t) {
281 .out_cables = 0x0005,
282 .in_cables = 0x0005
283 }
284 },
285 {
286 .ifnum = -1
287 }
237 } 288 }
238 } 289 }
239}, 290},
@@ -242,11 +293,28 @@ YAMAHA_DEVICE(0x7010, "UB99"),
242 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { 293 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {
243 .vendor_name = "EDIROL", 294 .vendor_name = "EDIROL",
244 .product_name = "UM-2", 295 .product_name = "UM-2",
245 .ifnum = 2, 296 .ifnum = QUIRK_ANY_INTERFACE,
246 .type = QUIRK_MIDI_FIXED_ENDPOINT, 297 .type = QUIRK_COMPOSITE,
247 .data = & (const snd_usb_midi_endpoint_info_t) { 298 .data = (const snd_usb_audio_quirk_t[]) {
248 .out_cables = 0x0003, 299 {
249 .in_cables = 0x0003 300 .ifnum = 0,
301 .type = QUIRK_IGNORE_INTERFACE
302 },
303 {
304 .ifnum = 1,
305 .type = QUIRK_IGNORE_INTERFACE
306 },
307 {
308 .ifnum = 2,
309 .type = QUIRK_MIDI_FIXED_ENDPOINT,
310 .data = & (const snd_usb_midi_endpoint_info_t) {
311 .out_cables = 0x0003,
312 .in_cables = 0x0003
313 }
314 },
315 {
316 .ifnum = -1
317 }
250 } 318 }
251 } 319 }
252}, 320},
@@ -255,11 +323,28 @@ YAMAHA_DEVICE(0x7010, "UB99"),
255 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { 323 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {
256 .vendor_name = "Roland", 324 .vendor_name = "Roland",
257 .product_name = "SC-8820", 325 .product_name = "SC-8820",
258 .ifnum = 2, 326 .ifnum = QUIRK_ANY_INTERFACE,
259 .type = QUIRK_MIDI_FIXED_ENDPOINT, 327 .type = QUIRK_COMPOSITE,
260 .data = & (const snd_usb_midi_endpoint_info_t) { 328 .data = (const snd_usb_audio_quirk_t[]) {
261 .out_cables = 0x0013, 329 {
262 .in_cables = 0x0013 330 .ifnum = 0,
331 .type = QUIRK_IGNORE_INTERFACE
332 },
333 {
334 .ifnum = 1,
335 .type = QUIRK_IGNORE_INTERFACE
336 },
337 {
338 .ifnum = 2,
339 .type = QUIRK_MIDI_FIXED_ENDPOINT,
340 .data = & (const snd_usb_midi_endpoint_info_t) {
341 .out_cables = 0x0013,
342 .in_cables = 0x0013
343 }
344 },
345 {
346 .ifnum = -1
347 }
263 } 348 }
264 } 349 }
265}, 350},
@@ -268,11 +353,28 @@ YAMAHA_DEVICE(0x7010, "UB99"),
268 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { 353 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {
269 .vendor_name = "Roland", 354 .vendor_name = "Roland",
270 .product_name = "PC-300", 355 .product_name = "PC-300",
271 .ifnum = 2, 356 .ifnum = QUIRK_ANY_INTERFACE,
272 .type = QUIRK_MIDI_FIXED_ENDPOINT, 357 .type = QUIRK_COMPOSITE,
273 .data = & (const snd_usb_midi_endpoint_info_t) { 358 .data = (const snd_usb_audio_quirk_t[]) {
274 .out_cables = 0x0001, 359 {
275 .in_cables = 0x0001 360 .ifnum = 0,
361 .type = QUIRK_IGNORE_INTERFACE
362 },
363 {
364 .ifnum = 1,
365 .type = QUIRK_IGNORE_INTERFACE
366 },
367 {
368 .ifnum = 2,
369 .type = QUIRK_MIDI_FIXED_ENDPOINT,
370 .data = & (const snd_usb_midi_endpoint_info_t) {
371 .out_cables = 0x0001,
372 .in_cables = 0x0001
373 }
374 },
375 {
376 .ifnum = -1
377 }
276 } 378 }
277 } 379 }
278}, 380},
@@ -281,11 +383,28 @@ YAMAHA_DEVICE(0x7010, "UB99"),
281 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { 383 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {
282 .vendor_name = "EDIROL", 384 .vendor_name = "EDIROL",
283 .product_name = "UM-1", 385 .product_name = "UM-1",
284 .ifnum = 2, 386 .ifnum = QUIRK_ANY_INTERFACE,
285 .type = QUIRK_MIDI_FIXED_ENDPOINT, 387 .type = QUIRK_COMPOSITE,
286 .data = & (const snd_usb_midi_endpoint_info_t) { 388 .data = (const snd_usb_audio_quirk_t[]) {
287 .out_cables = 0x0001, 389 {
288 .in_cables = 0x0001 390 .ifnum = 0,
391 .type = QUIRK_IGNORE_INTERFACE
392 },
393 {
394 .ifnum = 1,
395 .type = QUIRK_IGNORE_INTERFACE
396 },
397 {
398 .ifnum = 2,
399 .type = QUIRK_MIDI_FIXED_ENDPOINT,
400 .data = & (const snd_usb_midi_endpoint_info_t) {
401 .out_cables = 0x0001,
402 .in_cables = 0x0001
403 }
404 },
405 {
406 .ifnum = -1
407 }
289 } 408 }
290 } 409 }
291}, 410},
@@ -294,11 +413,28 @@ YAMAHA_DEVICE(0x7010, "UB99"),
294 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { 413 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {
295 .vendor_name = "Roland", 414 .vendor_name = "Roland",
296 .product_name = "SK-500", 415 .product_name = "SK-500",
297 .ifnum = 2, 416 .ifnum = QUIRK_ANY_INTERFACE,
298 .type = QUIRK_MIDI_FIXED_ENDPOINT, 417 .type = QUIRK_COMPOSITE,
299 .data = & (const snd_usb_midi_endpoint_info_t) { 418 .data = (const snd_usb_audio_quirk_t[]) {
300 .out_cables = 0x0013, 419 {
301 .in_cables = 0x0013 420 .ifnum = 0,
421 .type = QUIRK_IGNORE_INTERFACE
422 },
423 {
424 .ifnum = 1,
425 .type = QUIRK_IGNORE_INTERFACE
426 },
427 {
428 .ifnum = 2,
429 .type = QUIRK_MIDI_FIXED_ENDPOINT,
430 .data = & (const snd_usb_midi_endpoint_info_t) {
431 .out_cables = 0x0013,
432 .in_cables = 0x0013
433 }
434 },
435 {
436 .ifnum = -1
437 }
302 } 438 }
303 } 439 }
304}, 440},
@@ -421,11 +557,28 @@ YAMAHA_DEVICE(0x7010, "UB99"),
421 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { 557 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {
422 .vendor_name = "EDIROL", 558 .vendor_name = "EDIROL",
423 .product_name = "SD-90", 559 .product_name = "SD-90",
424 .ifnum = 2, 560 .ifnum = QUIRK_ANY_INTERFACE,
425 .type = QUIRK_MIDI_FIXED_ENDPOINT, 561 .type = QUIRK_COMPOSITE,
426 .data = & (const snd_usb_midi_endpoint_info_t) { 562 .data = (const snd_usb_audio_quirk_t[]) {
427 .out_cables = 0x000f, 563 {
428 .in_cables = 0x000f 564 .ifnum = 0,
565 .type = QUIRK_IGNORE_INTERFACE
566 },
567 {
568 .ifnum = 1,
569 .type = QUIRK_IGNORE_INTERFACE
570 },
571 {
572 .ifnum = 2,
573 .type = QUIRK_MIDI_FIXED_ENDPOINT,
574 .data = & (const snd_usb_midi_endpoint_info_t) {
575 .out_cables = 0x000f,
576 .in_cables = 0x000f
577 }
578 },
579 {
580 .ifnum = -1
581 }
429 } 582 }
430 } 583 }
431}, 584},
@@ -434,11 +587,28 @@ YAMAHA_DEVICE(0x7010, "UB99"),
434 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { 587 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {
435 .vendor_name = "Roland", 588 .vendor_name = "Roland",
436 .product_name = "MMP-2", 589 .product_name = "MMP-2",
437 .ifnum = 2, 590 .ifnum = QUIRK_ANY_INTERFACE,
438 .type = QUIRK_MIDI_FIXED_ENDPOINT, 591 .type = QUIRK_COMPOSITE,
439 .data = & (const snd_usb_midi_endpoint_info_t) { 592 .data = (const snd_usb_audio_quirk_t[]) {
440 .out_cables = 0x0001, 593 {
441 .in_cables = 0x0001 594 .ifnum = 0,
595 .type = QUIRK_IGNORE_INTERFACE
596 },
597 {
598 .ifnum = 1,
599 .type = QUIRK_IGNORE_INTERFACE
600 },
601 {
602 .ifnum = 2,
603 .type = QUIRK_MIDI_FIXED_ENDPOINT,
604 .data = & (const snd_usb_midi_endpoint_info_t) {
605 .out_cables = 0x0001,
606 .in_cables = 0x0001
607 }
608 },
609 {
610 .ifnum = -1
611 }
442 } 612 }
443 } 613 }
444}, 614},
@@ -609,15 +779,33 @@ YAMAHA_DEVICE(0x7010, "UB99"),
609 } 779 }
610}, 780},
611{ 781{
782 /*
783 * This quirk is for the "Advanced Driver" mode. If off, the GS-10
784 * has ID 0x003c and is standard compliant, but has only 16-bit PCM
785 * and no MIDI.
786 */
612 USB_DEVICE_VENDOR_SPEC(0x0582, 0x003b), 787 USB_DEVICE_VENDOR_SPEC(0x0582, 0x003b),
613 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { 788 .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) {
614 .vendor_name = "BOSS", 789 .vendor_name = "BOSS",
615 .product_name = "GS-10", 790 .product_name = "GS-10",
616 .ifnum = 3, 791 .ifnum = QUIRK_ANY_INTERFACE,
617 .type = QUIRK_MIDI_FIXED_ENDPOINT, 792 .type = QUIRK_COMPOSITE,
618 .data = & (const snd_usb_midi_endpoint_info_t) { 793 .data = & (const snd_usb_audio_quirk_t[]) {
619 .out_cables = 0x0003, 794 {
620 .in_cables = 0x0003 795 .ifnum = 1,
796 .type = QUIRK_AUDIO_STANDARD_INTERFACE
797 },
798 {
799 .ifnum = 2,
800 .type = QUIRK_AUDIO_STANDARD_INTERFACE
801 },
802 {
803 .ifnum = 3,
804 .type = QUIRK_MIDI_STANDARD_INTERFACE
805 },
806 {
807 .ifnum = -1
808 }
621 } 809 }
622 } 810 }
623}, 811},
diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c
index 89ee8b732013..e6e6da159671 100644
--- a/sound/usb/usx2y/usbusx2y.c
+++ b/sound/usb/usx2y/usbusx2y.c
@@ -442,7 +442,7 @@ static void usX2Y_usb_disconnect(struct usb_device* device, void* ptr)
442 snd_card_disconnect((snd_card_t*)ptr); 442 snd_card_disconnect((snd_card_t*)ptr);
443 /* release the midi resources */ 443 /* release the midi resources */
444 list_for_each(p, &usX2Y->chip.midi_list) { 444 list_for_each(p, &usX2Y->chip.midi_list) {
445 snd_usbmidi_disconnect(p, &snd_usX2Y_usb_driver); 445 snd_usbmidi_disconnect(p);
446 } 446 }
447 if (usX2Y->us428ctls_sharedmem) 447 if (usX2Y->us428ctls_sharedmem)
448 wake_up(&usX2Y->us428ctls_wait_queue_head); 448 wake_up(&usX2Y->us428ctls_wait_queue_head);
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c
index 4c292e090069..62dfd28b3b07 100644
--- a/sound/usb/usx2y/usbusx2yaudio.c
+++ b/sound/usb/usx2y/usbusx2yaudio.c
@@ -401,10 +401,8 @@ static void usX2Y_urbs_release(snd_usX2Y_substream_t *subs)
401 for (i = 0; i < NRURBS; i++) 401 for (i = 0; i < NRURBS; i++)
402 usX2Y_urb_release(subs->urb + i, subs != subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]); 402 usX2Y_urb_release(subs->urb + i, subs != subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]);
403 403
404 if (subs->tmpbuf) { 404 kfree(subs->tmpbuf);
405 kfree(subs->tmpbuf); 405 subs->tmpbuf = NULL;
406 subs->tmpbuf = NULL;
407 }
408} 406}
409/* 407/*
410 * initialize a substream's urbs 408 * initialize a substream's urbs